diff --git a/__fixtures__/v-next/outputicjs/cosmos/staking/v1beta1/staking.ts b/__fixtures__/v-next/outputicjs/cosmos/staking/v1beta1/staking.ts index dfb5305a9b..f95997e8ee 100644 --- a/__fixtures__/v-next/outputicjs/cosmos/staking/v1beta1/staking.ts +++ b/__fixtures__/v-next/outputicjs/cosmos/staking/v1beta1/staking.ts @@ -6,7 +6,7 @@ import { Coin, CoinAmino } from "../../base/v1beta1/coin"; import { BinaryReader, BinaryWriter } from "../../../binary"; import { DeepPartial, toTimestamp, fromTimestamp } from "../../../helpers"; import { encodePubkey, decodePubkey } from "@cosmjs/proto-signing"; -import { Pubkey } from "@cosmjs/amino"; +import { Pubkey } from "@interchainjs/Pubkey"; /** BondStatus is the status of a validator. */ export enum BondStatus { /** BOND_STATUS_UNSPECIFIED - UNSPECIFIED defines an invalid validator status. */ diff --git a/__fixtures__/v-next/outputicjs/cosmos/staking/v1beta1/tx.ts b/__fixtures__/v-next/outputicjs/cosmos/staking/v1beta1/tx.ts index dc0e2fa401..5b729825d3 100644 --- a/__fixtures__/v-next/outputicjs/cosmos/staking/v1beta1/tx.ts +++ b/__fixtures__/v-next/outputicjs/cosmos/staking/v1beta1/tx.ts @@ -5,7 +5,7 @@ import { Timestamp } from "../../../google/protobuf/timestamp"; import { BinaryReader, BinaryWriter } from "../../../binary"; import { DeepPartial, toTimestamp, fromTimestamp } from "../../../helpers"; import { encodePubkey, decodePubkey } from "@cosmjs/proto-signing"; -import { Pubkey } from "@cosmjs/amino"; +import { Pubkey } from "@interchainjs/Pubkey"; /** MsgCreateValidator defines a SDK message for creating a new validator. */ export interface MsgCreateValidator { description: Description; diff --git a/__fixtures__/v-next/outputicjsdeps/akash/audit/v1beta1/audit.amino.ts b/__fixtures__/v-next/outputicjsdeps/akash/audit/v1beta1/audit.amino.ts new file mode 100644 index 0000000000..80e34ef2a1 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/audit/v1beta1/audit.amino.ts @@ -0,0 +1,81 @@ +/* eslint-disable */ +import { Attribute, AttributeSDKType } from "../../base/v1beta1/attribute.js"; +import { ReadOnlyAminoMsg as AminoMsg } from "@interchainjs/ReadOnlyAminoMsg"; +import { MsgSignProviderAttributes, MsgSignProviderAttributesSDKType, MsgDeleteProviderAttributes, MsgDeleteProviderAttributesSDKType } from "./audit.js"; +export interface MsgSignProviderAttributesAminoType extends AminoMsg { + type: "akash/audit/testonly-sign-provider-attributes"; + value: { + owner: string; + auditor: string; + attributes: { + key: string; + value: string; + }[]; + }; +} +export interface MsgDeleteProviderAttributesAminoType extends AminoMsg { + type: "akash/audit/testonly-delete-provider-attributes"; + value: { + owner: string; + auditor: string; + keys: string[]; + }; +} +export const AminoConverter = { + "/akash.audit.v1beta1.MsgSignProviderAttributes": { + aminoType: "akash/audit/testonly-sign-provider-attributes", + toAmino: ({ + owner, + auditor, + attributes + }: MsgSignProviderAttributes): MsgSignProviderAttributesAminoType["value"] => { + return { + owner, + auditor, + attributes: attributes.map(el0 => ({ + key: el0.key, + value: el0.value + })) + }; + }, + fromAmino: ({ + owner, + auditor, + attributes + }: MsgSignProviderAttributesAminoType["value"]): MsgSignProviderAttributes => { + return { + owner, + auditor, + attributes: attributes.map(el0 => ({ + key: el0.key, + value: el0.value + })) + }; + } + }, + "/akash.audit.v1beta1.MsgDeleteProviderAttributes": { + aminoType: "akash/audit/testonly-delete-provider-attributes", + toAmino: ({ + owner, + auditor, + keys + }: MsgDeleteProviderAttributes): MsgDeleteProviderAttributesAminoType["value"] => { + return { + owner, + auditor, + keys + }; + }, + fromAmino: ({ + owner, + auditor, + keys + }: MsgDeleteProviderAttributesAminoType["value"]): MsgDeleteProviderAttributes => { + return { + owner, + auditor, + keys + }; + } + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/audit/v1beta1/audit.registry.ts b/__fixtures__/v-next/outputicjsdeps/akash/audit/v1beta1/audit.registry.ts new file mode 100644 index 0000000000..1a0849c6f1 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/audit/v1beta1/audit.registry.ts @@ -0,0 +1,81 @@ +import { Attribute, AttributeSDKType } from "../../base/v1beta1/attribute.js"; +import { GeneratedType, Registry } from "@cosmjs/proto-signing"; +import { MsgSignProviderAttributes, MsgSignProviderAttributesSDKType, MsgDeleteProviderAttributes, MsgDeleteProviderAttributesSDKType } from "./audit.js"; +export const registry: ReadonlyArray<[string, GeneratedType]> = [["/akash.audit.v1beta1.MsgSignProviderAttributes", MsgSignProviderAttributes], ["/akash.audit.v1beta1.MsgDeleteProviderAttributes", MsgDeleteProviderAttributes]]; +export const load = (protoRegistry: Registry) => { + registry.forEach(([typeUrl, mod]) => { + protoRegistry.register(typeUrl, mod); + }); +}; +export const MessageComposer = { + encoded: { + signProviderAttributes(value: MsgSignProviderAttributes) { + return { + typeUrl: "/akash.audit.v1beta1.MsgSignProviderAttributes", + value: MsgSignProviderAttributes.encode(value).finish() + }; + }, + deleteProviderAttributes(value: MsgDeleteProviderAttributes) { + return { + typeUrl: "/akash.audit.v1beta1.MsgDeleteProviderAttributes", + value: MsgDeleteProviderAttributes.encode(value).finish() + }; + } + }, + withTypeUrl: { + signProviderAttributes(value: MsgSignProviderAttributes) { + return { + typeUrl: "/akash.audit.v1beta1.MsgSignProviderAttributes", + value + }; + }, + deleteProviderAttributes(value: MsgDeleteProviderAttributes) { + return { + typeUrl: "/akash.audit.v1beta1.MsgDeleteProviderAttributes", + value + }; + } + }, + toJSON: { + signProviderAttributes(value: MsgSignProviderAttributes) { + return { + typeUrl: "/akash.audit.v1beta1.MsgSignProviderAttributes", + value: MsgSignProviderAttributes.toJSON(value) + }; + }, + deleteProviderAttributes(value: MsgDeleteProviderAttributes) { + return { + typeUrl: "/akash.audit.v1beta1.MsgDeleteProviderAttributes", + value: MsgDeleteProviderAttributes.toJSON(value) + }; + } + }, + fromJSON: { + signProviderAttributes(value: any) { + return { + typeUrl: "/akash.audit.v1beta1.MsgSignProviderAttributes", + value: MsgSignProviderAttributes.fromJSON(value) + }; + }, + deleteProviderAttributes(value: any) { + return { + typeUrl: "/akash.audit.v1beta1.MsgDeleteProviderAttributes", + value: MsgDeleteProviderAttributes.fromJSON(value) + }; + } + }, + fromPartial: { + signProviderAttributes(value: MsgSignProviderAttributes) { + return { + typeUrl: "/akash.audit.v1beta1.MsgSignProviderAttributes", + value: MsgSignProviderAttributes.fromPartial(value) + }; + }, + deleteProviderAttributes(value: MsgDeleteProviderAttributes) { + return { + typeUrl: "/akash.audit.v1beta1.MsgDeleteProviderAttributes", + value: MsgDeleteProviderAttributes.fromPartial(value) + }; + } + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/audit/v1beta1/audit.rpc.func.ts b/__fixtures__/v-next/outputicjsdeps/akash/audit/v1beta1/audit.rpc.func.ts new file mode 100644 index 0000000000..250106d07b --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/audit/v1beta1/audit.rpc.func.ts @@ -0,0 +1,22 @@ +import { buildTx, SigningClientResolver } from "../../../helper-func-types"; +import { buildUseMutation } from "../../../react-query"; +import { toEncoders, toConverters } from "@interchainjs/cosmos/utils"; +import { MsgSignProviderAttributes, MsgDeleteProviderAttributes } from "./audit"; +export const createSignProviderAttributes = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgSignProviderAttributes.typeUrl, + encoders: toEncoders(MsgSignProviderAttributes), + converters: toConverters(MsgSignProviderAttributes) +}); +export const useSignProviderAttributes = buildUseMutation({ + builderMutationFn: createSignProviderAttributes +}); +export const createDeleteProviderAttributes = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgDeleteProviderAttributes.typeUrl, + encoders: toEncoders(MsgDeleteProviderAttributes), + converters: toConverters(MsgDeleteProviderAttributes) +}); +export const useDeleteProviderAttributes = buildUseMutation({ + builderMutationFn: createDeleteProviderAttributes +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/audit/v1beta1/audit.rpc.msg.ts b/__fixtures__/v-next/outputicjsdeps/akash/audit/v1beta1/audit.rpc.msg.ts new file mode 100644 index 0000000000..b48344533a --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/audit/v1beta1/audit.rpc.msg.ts @@ -0,0 +1,32 @@ +import { Attribute, AttributeSDKType } from "../../base/v1beta1/attribute.js"; +import { Rpc } from "../../../helpers.js"; +import { BinaryReader } from "../../../binary.js"; +import { MsgSignProviderAttributes, MsgSignProviderAttributesSDKType, MsgSignProviderAttributesResponse, MsgSignProviderAttributesResponseSDKType, MsgDeleteProviderAttributes, MsgDeleteProviderAttributesSDKType, MsgDeleteProviderAttributesResponse, MsgDeleteProviderAttributesResponseSDKType } from "./audit.js"; +/** Msg defines the provider Msg service */ +export interface Msg { + /** SignProviderAttributes defines a method that signs provider attributes */ + signProviderAttributes(request: MsgSignProviderAttributes): Promise; + /** DeleteProviderAttributes defines a method that deletes provider attributes */ + deleteProviderAttributes(request: MsgDeleteProviderAttributes): Promise; +} +export class MsgClientImpl implements Msg { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + } + /* SignProviderAttributes defines a method that signs provider attributes */ + signProviderAttributes = async (request: MsgSignProviderAttributes): Promise => { + const data = MsgSignProviderAttributes.encode(request).finish(); + const promise = this.rpc.request("akash.audit.v1beta1.Msg", "SignProviderAttributes", data); + return promise.then(data => MsgSignProviderAttributesResponse.decode(new BinaryReader(data))); + }; + /* DeleteProviderAttributes defines a method that deletes provider attributes */ + deleteProviderAttributes = async (request: MsgDeleteProviderAttributes): Promise => { + const data = MsgDeleteProviderAttributes.encode(request).finish(); + const promise = this.rpc.request("akash.audit.v1beta1.Msg", "DeleteProviderAttributes", data); + return promise.then(data => MsgDeleteProviderAttributesResponse.decode(new BinaryReader(data))); + }; +} +export const createClientImpl = (rpc: Rpc) => { + return new MsgClientImpl(rpc); +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/audit/v1beta1/audit.ts b/__fixtures__/v-next/outputicjsdeps/akash/audit/v1beta1/audit.ts new file mode 100644 index 0000000000..5091e8d3a3 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/audit/v1beta1/audit.ts @@ -0,0 +1,1046 @@ +import { Attribute, AttributeSDKType } from "../../base/v1beta1/attribute.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial, Exact } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "akash.audit.v1beta1"; +/** Provider stores owner auditor and attributes details */ +export interface Provider { + owner: string; + auditor: string; + attributes: Attribute[]; +} +export interface ProviderProtoMsg { + typeUrl: "/akash.audit.v1beta1.Provider"; + value: Uint8Array; +} +/** Provider stores owner auditor and attributes details */ +export interface ProviderSDKType { + owner: string; + auditor: string; + attributes: AttributeSDKType[]; +} +/** Attributes */ +export interface AuditedAttributes { + owner: string; + auditor: string; + attributes: Attribute[]; +} +export interface AuditedAttributesProtoMsg { + typeUrl: "/akash.audit.v1beta1.AuditedAttributes"; + value: Uint8Array; +} +/** Attributes */ +export interface AuditedAttributesSDKType { + owner: string; + auditor: string; + attributes: AttributeSDKType[]; +} +/** AttributesResponse represents details of deployment along with group details */ +export interface AttributesResponse { + attributes: AuditedAttributes[]; +} +export interface AttributesResponseProtoMsg { + typeUrl: "/akash.audit.v1beta1.AttributesResponse"; + value: Uint8Array; +} +/** AttributesResponse represents details of deployment along with group details */ +export interface AttributesResponseSDKType { + attributes: AuditedAttributesSDKType[]; +} +/** AttributesFilters defines filters used to filter deployments */ +export interface AttributesFilters { + auditors: string[]; + owners: string[]; +} +export interface AttributesFiltersProtoMsg { + typeUrl: "/akash.audit.v1beta1.AttributesFilters"; + value: Uint8Array; +} +/** AttributesFilters defines filters used to filter deployments */ +export interface AttributesFiltersSDKType { + auditors: string[]; + owners: string[]; +} +/** MsgSignProviderAttributes defines an SDK message for signing a provider attributes */ +export interface MsgSignProviderAttributes { + owner: string; + auditor: string; + attributes: Attribute[]; +} +export interface MsgSignProviderAttributesProtoMsg { + typeUrl: "/akash.audit.v1beta1.MsgSignProviderAttributes"; + value: Uint8Array; +} +/** MsgSignProviderAttributes defines an SDK message for signing a provider attributes */ +export interface MsgSignProviderAttributesSDKType { + owner: string; + auditor: string; + attributes: AttributeSDKType[]; +} +/** MsgSignProviderAttributesResponse defines the Msg/CreateProvider response type. */ +export interface MsgSignProviderAttributesResponse {} +export interface MsgSignProviderAttributesResponseProtoMsg { + typeUrl: "/akash.audit.v1beta1.MsgSignProviderAttributesResponse"; + value: Uint8Array; +} +/** MsgSignProviderAttributesResponse defines the Msg/CreateProvider response type. */ +export interface MsgSignProviderAttributesResponseSDKType {} +/** MsgDeleteProviderAttributes defined the Msg/DeleteProviderAttributes */ +export interface MsgDeleteProviderAttributes { + owner: string; + auditor: string; + keys: string[]; +} +export interface MsgDeleteProviderAttributesProtoMsg { + typeUrl: "/akash.audit.v1beta1.MsgDeleteProviderAttributes"; + value: Uint8Array; +} +/** MsgDeleteProviderAttributes defined the Msg/DeleteProviderAttributes */ +export interface MsgDeleteProviderAttributesSDKType { + owner: string; + auditor: string; + keys: string[]; +} +/** MsgDeleteProviderAttributesResponse defines the Msg/ProviderAttributes response type. */ +export interface MsgDeleteProviderAttributesResponse {} +export interface MsgDeleteProviderAttributesResponseProtoMsg { + typeUrl: "/akash.audit.v1beta1.MsgDeleteProviderAttributesResponse"; + value: Uint8Array; +} +/** MsgDeleteProviderAttributesResponse defines the Msg/ProviderAttributes response type. */ +export interface MsgDeleteProviderAttributesResponseSDKType {} +function createBaseProvider(): Provider { + return { + owner: "", + auditor: "", + attributes: [] + }; +} +export const Provider = { + typeUrl: "/akash.audit.v1beta1.Provider", + encode(message: Provider, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.owner !== undefined) { + writer.uint32(10).string(message.owner); + } + if (message.auditor !== undefined) { + writer.uint32(18).string(message.auditor); + } + for (const v of message.attributes) { + Attribute.encode(v!, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Provider { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseProvider(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.owner = reader.string(); + break; + case 2: + message.auditor = reader.string(); + break; + case 4: + message.attributes.push(Attribute.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Provider { + const obj = createBaseProvider(); + if (isSet(object.owner)) obj.owner = String(object.owner); + if (isSet(object.auditor)) obj.auditor = String(object.auditor); + if (Array.isArray(object?.attributes)) obj.attributes = object.attributes.map((e: any) => Attribute.fromJSON(e)); + return obj; + }, + toJSON(message: Provider): JsonSafe { + const obj: any = {}; + message.owner !== undefined && (obj.owner = message.owner); + message.auditor !== undefined && (obj.auditor = message.auditor); + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? Attribute.toJSON(e) : undefined); + } else { + obj.attributes = []; + } + return obj; + }, + fromPartial, I>>(object: I): Provider { + const message = createBaseProvider(); + message.owner = object.owner ?? ""; + message.auditor = object.auditor ?? ""; + message.attributes = object.attributes?.map(e => Attribute.fromPartial(e)) || []; + return message; + }, + fromSDK(object: ProviderSDKType): Provider { + return { + owner: object?.owner, + auditor: object?.auditor, + attributes: Array.isArray(object?.attributes) ? object.attributes.map((e: any) => Attribute.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): ProviderSDKType { + return { + owner: isSet(object.owner) ? String(object.owner) : "", + auditor: isSet(object.auditor) ? String(object.auditor) : "", + attributes: Array.isArray(object?.attributes) ? object.attributes.map((e: any) => Attribute.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: Provider): ProviderSDKType { + const obj: any = {}; + obj.owner = message.owner; + obj.auditor = message.auditor; + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? Attribute.toSDK(e) : undefined); + } else { + obj.attributes = []; + } + return obj; + }, + fromAmino(object: ProviderAmino): Provider { + const message = createBaseProvider(); + if (object.owner !== undefined && object.owner !== null) { + message.owner = object.owner; + } + if (object.auditor !== undefined && object.auditor !== null) { + message.auditor = object.auditor; + } + message.attributes = object.attributes?.map(e => Attribute.fromAmino(e)) || []; + return message; + }, + toAmino(message: Provider): ProviderAmino { + const obj: any = {}; + obj.owner = message.owner ?? ""; + obj.auditor = message.auditor ?? ""; + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? Attribute.toAmino(e) : undefined); + } else { + obj.attributes = message.attributes; + } + return obj; + }, + fromAminoMsg(object: ProviderAminoMsg): Provider { + return Provider.fromAmino(object.value); + }, + toAminoMsg(message: Provider): ProviderAminoMsg { + return { + type: "akash/audit/provider", + value: Provider.toAmino(message) + }; + }, + fromProtoMsg(message: ProviderProtoMsg): Provider { + return Provider.decode(message.value); + }, + toProto(message: Provider): Uint8Array { + return Provider.encode(message).finish(); + }, + toProtoMsg(message: Provider): ProviderProtoMsg { + return { + typeUrl: "/akash.audit.v1beta1.Provider", + value: Provider.encode(message).finish() + }; + } +}; +function createBaseAuditedAttributes(): AuditedAttributes { + return { + owner: "", + auditor: "", + attributes: [] + }; +} +export const AuditedAttributes = { + typeUrl: "/akash.audit.v1beta1.AuditedAttributes", + encode(message: AuditedAttributes, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.owner !== undefined) { + writer.uint32(10).string(message.owner); + } + if (message.auditor !== undefined) { + writer.uint32(18).string(message.auditor); + } + for (const v of message.attributes) { + Attribute.encode(v!, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): AuditedAttributes { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseAuditedAttributes(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.owner = reader.string(); + break; + case 2: + message.auditor = reader.string(); + break; + case 3: + message.attributes.push(Attribute.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): AuditedAttributes { + const obj = createBaseAuditedAttributes(); + if (isSet(object.owner)) obj.owner = String(object.owner); + if (isSet(object.auditor)) obj.auditor = String(object.auditor); + if (Array.isArray(object?.attributes)) obj.attributes = object.attributes.map((e: any) => Attribute.fromJSON(e)); + return obj; + }, + toJSON(message: AuditedAttributes): JsonSafe { + const obj: any = {}; + message.owner !== undefined && (obj.owner = message.owner); + message.auditor !== undefined && (obj.auditor = message.auditor); + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? Attribute.toJSON(e) : undefined); + } else { + obj.attributes = []; + } + return obj; + }, + fromPartial, I>>(object: I): AuditedAttributes { + const message = createBaseAuditedAttributes(); + message.owner = object.owner ?? ""; + message.auditor = object.auditor ?? ""; + message.attributes = object.attributes?.map(e => Attribute.fromPartial(e)) || []; + return message; + }, + fromSDK(object: AuditedAttributesSDKType): AuditedAttributes { + return { + owner: object?.owner, + auditor: object?.auditor, + attributes: Array.isArray(object?.attributes) ? object.attributes.map((e: any) => Attribute.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): AuditedAttributesSDKType { + return { + owner: isSet(object.owner) ? String(object.owner) : "", + auditor: isSet(object.auditor) ? String(object.auditor) : "", + attributes: Array.isArray(object?.attributes) ? object.attributes.map((e: any) => Attribute.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: AuditedAttributes): AuditedAttributesSDKType { + const obj: any = {}; + obj.owner = message.owner; + obj.auditor = message.auditor; + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? Attribute.toSDK(e) : undefined); + } else { + obj.attributes = []; + } + return obj; + }, + fromAmino(object: AuditedAttributesAmino): AuditedAttributes { + const message = createBaseAuditedAttributes(); + if (object.owner !== undefined && object.owner !== null) { + message.owner = object.owner; + } + if (object.auditor !== undefined && object.auditor !== null) { + message.auditor = object.auditor; + } + message.attributes = object.attributes?.map(e => Attribute.fromAmino(e)) || []; + return message; + }, + toAmino(message: AuditedAttributes): AuditedAttributesAmino { + const obj: any = {}; + obj.owner = message.owner ?? ""; + obj.auditor = message.auditor ?? ""; + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? Attribute.toAmino(e) : undefined); + } else { + obj.attributes = message.attributes; + } + return obj; + }, + fromAminoMsg(object: AuditedAttributesAminoMsg): AuditedAttributes { + return AuditedAttributes.fromAmino(object.value); + }, + toAminoMsg(message: AuditedAttributes): AuditedAttributesAminoMsg { + return { + type: "akash/audit/audited-attributes", + value: AuditedAttributes.toAmino(message) + }; + }, + fromProtoMsg(message: AuditedAttributesProtoMsg): AuditedAttributes { + return AuditedAttributes.decode(message.value); + }, + toProto(message: AuditedAttributes): Uint8Array { + return AuditedAttributes.encode(message).finish(); + }, + toProtoMsg(message: AuditedAttributes): AuditedAttributesProtoMsg { + return { + typeUrl: "/akash.audit.v1beta1.AuditedAttributes", + value: AuditedAttributes.encode(message).finish() + }; + } +}; +function createBaseAttributesResponse(): AttributesResponse { + return { + attributes: [] + }; +} +export const AttributesResponse = { + typeUrl: "/akash.audit.v1beta1.AttributesResponse", + encode(message: AttributesResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.attributes) { + AuditedAttributes.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): AttributesResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseAttributesResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.attributes.push(AuditedAttributes.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): AttributesResponse { + const obj = createBaseAttributesResponse(); + if (Array.isArray(object?.attributes)) obj.attributes = object.attributes.map((e: any) => AuditedAttributes.fromJSON(e)); + return obj; + }, + toJSON(message: AttributesResponse): JsonSafe { + const obj: any = {}; + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? AuditedAttributes.toJSON(e) : undefined); + } else { + obj.attributes = []; + } + return obj; + }, + fromPartial, I>>(object: I): AttributesResponse { + const message = createBaseAttributesResponse(); + message.attributes = object.attributes?.map(e => AuditedAttributes.fromPartial(e)) || []; + return message; + }, + fromSDK(object: AttributesResponseSDKType): AttributesResponse { + return { + attributes: Array.isArray(object?.attributes) ? object.attributes.map((e: any) => AuditedAttributes.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): AttributesResponseSDKType { + return { + attributes: Array.isArray(object?.attributes) ? object.attributes.map((e: any) => AuditedAttributes.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: AttributesResponse): AttributesResponseSDKType { + const obj: any = {}; + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? AuditedAttributes.toSDK(e) : undefined); + } else { + obj.attributes = []; + } + return obj; + }, + fromAmino(object: AttributesResponseAmino): AttributesResponse { + const message = createBaseAttributesResponse(); + message.attributes = object.attributes?.map(e => AuditedAttributes.fromAmino(e)) || []; + return message; + }, + toAmino(message: AttributesResponse): AttributesResponseAmino { + const obj: any = {}; + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? AuditedAttributes.toAmino(e) : undefined); + } else { + obj.attributes = message.attributes; + } + return obj; + }, + fromAminoMsg(object: AttributesResponseAminoMsg): AttributesResponse { + return AttributesResponse.fromAmino(object.value); + }, + toAminoMsg(message: AttributesResponse): AttributesResponseAminoMsg { + return { + type: "akash/audit/attributes-response", + value: AttributesResponse.toAmino(message) + }; + }, + fromProtoMsg(message: AttributesResponseProtoMsg): AttributesResponse { + return AttributesResponse.decode(message.value); + }, + toProto(message: AttributesResponse): Uint8Array { + return AttributesResponse.encode(message).finish(); + }, + toProtoMsg(message: AttributesResponse): AttributesResponseProtoMsg { + return { + typeUrl: "/akash.audit.v1beta1.AttributesResponse", + value: AttributesResponse.encode(message).finish() + }; + } +}; +function createBaseAttributesFilters(): AttributesFilters { + return { + auditors: [], + owners: [] + }; +} +export const AttributesFilters = { + typeUrl: "/akash.audit.v1beta1.AttributesFilters", + encode(message: AttributesFilters, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.auditors) { + writer.uint32(10).string(v!); + } + for (const v of message.owners) { + writer.uint32(18).string(v!); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): AttributesFilters { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseAttributesFilters(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.auditors.push(reader.string()); + break; + case 2: + message.owners.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): AttributesFilters { + const obj = createBaseAttributesFilters(); + if (Array.isArray(object?.auditors)) obj.auditors = object.auditors.map((e: any) => String(e)); + if (Array.isArray(object?.owners)) obj.owners = object.owners.map((e: any) => String(e)); + return obj; + }, + toJSON(message: AttributesFilters): JsonSafe { + const obj: any = {}; + if (message.auditors) { + obj.auditors = message.auditors.map(e => e); + } else { + obj.auditors = []; + } + if (message.owners) { + obj.owners = message.owners.map(e => e); + } else { + obj.owners = []; + } + return obj; + }, + fromPartial, I>>(object: I): AttributesFilters { + const message = createBaseAttributesFilters(); + message.auditors = object.auditors?.map(e => e) || []; + message.owners = object.owners?.map(e => e) || []; + return message; + }, + fromSDK(object: AttributesFiltersSDKType): AttributesFilters { + return { + auditors: Array.isArray(object?.auditors) ? object.auditors.map((e: any) => e) : [], + owners: Array.isArray(object?.owners) ? object.owners.map((e: any) => e) : [] + }; + }, + fromSDKJSON(object: any): AttributesFiltersSDKType { + return { + auditors: Array.isArray(object?.auditors) ? object.auditors.map((e: any) => String(e)) : [], + owners: Array.isArray(object?.owners) ? object.owners.map((e: any) => String(e)) : [] + }; + }, + toSDK(message: AttributesFilters): AttributesFiltersSDKType { + const obj: any = {}; + if (message.auditors) { + obj.auditors = message.auditors.map(e => e); + } else { + obj.auditors = []; + } + if (message.owners) { + obj.owners = message.owners.map(e => e); + } else { + obj.owners = []; + } + return obj; + }, + fromAmino(object: AttributesFiltersAmino): AttributesFilters { + const message = createBaseAttributesFilters(); + message.auditors = object.auditors?.map(e => e) || []; + message.owners = object.owners?.map(e => e) || []; + return message; + }, + toAmino(message: AttributesFilters): AttributesFiltersAmino { + const obj: any = {}; + if (message.auditors) { + obj.auditors = message.auditors.map(e => e); + } else { + obj.auditors = message.auditors; + } + if (message.owners) { + obj.owners = message.owners.map(e => e); + } else { + obj.owners = message.owners; + } + return obj; + }, + fromAminoMsg(object: AttributesFiltersAminoMsg): AttributesFilters { + return AttributesFilters.fromAmino(object.value); + }, + toAminoMsg(message: AttributesFilters): AttributesFiltersAminoMsg { + return { + type: "akash/audit/attributes-filters", + value: AttributesFilters.toAmino(message) + }; + }, + fromProtoMsg(message: AttributesFiltersProtoMsg): AttributesFilters { + return AttributesFilters.decode(message.value); + }, + toProto(message: AttributesFilters): Uint8Array { + return AttributesFilters.encode(message).finish(); + }, + toProtoMsg(message: AttributesFilters): AttributesFiltersProtoMsg { + return { + typeUrl: "/akash.audit.v1beta1.AttributesFilters", + value: AttributesFilters.encode(message).finish() + }; + } +}; +function createBaseMsgSignProviderAttributes(): MsgSignProviderAttributes { + return { + owner: "", + auditor: "", + attributes: [] + }; +} +export const MsgSignProviderAttributes = { + typeUrl: "/akash.audit.v1beta1.MsgSignProviderAttributes", + encode(message: MsgSignProviderAttributes, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.owner !== undefined) { + writer.uint32(10).string(message.owner); + } + if (message.auditor !== undefined) { + writer.uint32(18).string(message.auditor); + } + for (const v of message.attributes) { + Attribute.encode(v!, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgSignProviderAttributes { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgSignProviderAttributes(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.owner = reader.string(); + break; + case 2: + message.auditor = reader.string(); + break; + case 3: + message.attributes.push(Attribute.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgSignProviderAttributes { + const obj = createBaseMsgSignProviderAttributes(); + if (isSet(object.owner)) obj.owner = String(object.owner); + if (isSet(object.auditor)) obj.auditor = String(object.auditor); + if (Array.isArray(object?.attributes)) obj.attributes = object.attributes.map((e: any) => Attribute.fromJSON(e)); + return obj; + }, + toJSON(message: MsgSignProviderAttributes): JsonSafe { + const obj: any = {}; + message.owner !== undefined && (obj.owner = message.owner); + message.auditor !== undefined && (obj.auditor = message.auditor); + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? Attribute.toJSON(e) : undefined); + } else { + obj.attributes = []; + } + return obj; + }, + fromPartial, I>>(object: I): MsgSignProviderAttributes { + const message = createBaseMsgSignProviderAttributes(); + message.owner = object.owner ?? ""; + message.auditor = object.auditor ?? ""; + message.attributes = object.attributes?.map(e => Attribute.fromPartial(e)) || []; + return message; + }, + fromSDK(object: MsgSignProviderAttributesSDKType): MsgSignProviderAttributes { + return { + owner: object?.owner, + auditor: object?.auditor, + attributes: Array.isArray(object?.attributes) ? object.attributes.map((e: any) => Attribute.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): MsgSignProviderAttributesSDKType { + return { + owner: isSet(object.owner) ? String(object.owner) : "", + auditor: isSet(object.auditor) ? String(object.auditor) : "", + attributes: Array.isArray(object?.attributes) ? object.attributes.map((e: any) => Attribute.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: MsgSignProviderAttributes): MsgSignProviderAttributesSDKType { + const obj: any = {}; + obj.owner = message.owner; + obj.auditor = message.auditor; + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? Attribute.toSDK(e) : undefined); + } else { + obj.attributes = []; + } + return obj; + }, + fromAmino(object: MsgSignProviderAttributesAmino): MsgSignProviderAttributes { + const message = createBaseMsgSignProviderAttributes(); + if (object.owner !== undefined && object.owner !== null) { + message.owner = object.owner; + } + if (object.auditor !== undefined && object.auditor !== null) { + message.auditor = object.auditor; + } + message.attributes = object.attributes?.map(e => Attribute.fromAmino(e)) || []; + return message; + }, + toAmino(message: MsgSignProviderAttributes): MsgSignProviderAttributesAmino { + const obj: any = {}; + obj.owner = message.owner ?? ""; + obj.auditor = message.auditor ?? ""; + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? Attribute.toAmino(e) : undefined); + } else { + obj.attributes = message.attributes; + } + return obj; + }, + fromAminoMsg(object: MsgSignProviderAttributesAminoMsg): MsgSignProviderAttributes { + return MsgSignProviderAttributes.fromAmino(object.value); + }, + toAminoMsg(message: MsgSignProviderAttributes): MsgSignProviderAttributesAminoMsg { + return { + type: "akash/audit/testonly-sign-provider-attributes", + value: MsgSignProviderAttributes.toAmino(message) + }; + }, + fromProtoMsg(message: MsgSignProviderAttributesProtoMsg): MsgSignProviderAttributes { + return MsgSignProviderAttributes.decode(message.value); + }, + toProto(message: MsgSignProviderAttributes): Uint8Array { + return MsgSignProviderAttributes.encode(message).finish(); + }, + toProtoMsg(message: MsgSignProviderAttributes): MsgSignProviderAttributesProtoMsg { + return { + typeUrl: "/akash.audit.v1beta1.MsgSignProviderAttributes", + value: MsgSignProviderAttributes.encode(message).finish() + }; + } +}; +function createBaseMsgSignProviderAttributesResponse(): MsgSignProviderAttributesResponse { + return {}; +} +export const MsgSignProviderAttributesResponse = { + typeUrl: "/akash.audit.v1beta1.MsgSignProviderAttributesResponse", + encode(_: MsgSignProviderAttributesResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgSignProviderAttributesResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgSignProviderAttributesResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgSignProviderAttributesResponse { + const obj = createBaseMsgSignProviderAttributesResponse(); + return obj; + }, + toJSON(_: MsgSignProviderAttributesResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): MsgSignProviderAttributesResponse { + const message = createBaseMsgSignProviderAttributesResponse(); + return message; + }, + fromSDK(_: MsgSignProviderAttributesResponseSDKType): MsgSignProviderAttributesResponse { + return {}; + }, + fromSDKJSON(_: any): MsgSignProviderAttributesResponseSDKType { + return {}; + }, + toSDK(_: MsgSignProviderAttributesResponse): MsgSignProviderAttributesResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgSignProviderAttributesResponseAmino): MsgSignProviderAttributesResponse { + const message = createBaseMsgSignProviderAttributesResponse(); + return message; + }, + toAmino(_: MsgSignProviderAttributesResponse): MsgSignProviderAttributesResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgSignProviderAttributesResponseAminoMsg): MsgSignProviderAttributesResponse { + return MsgSignProviderAttributesResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgSignProviderAttributesResponse): MsgSignProviderAttributesResponseAminoMsg { + return { + type: "akash/audit/testonly-sign-provider-attributes-response", + value: MsgSignProviderAttributesResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgSignProviderAttributesResponseProtoMsg): MsgSignProviderAttributesResponse { + return MsgSignProviderAttributesResponse.decode(message.value); + }, + toProto(message: MsgSignProviderAttributesResponse): Uint8Array { + return MsgSignProviderAttributesResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgSignProviderAttributesResponse): MsgSignProviderAttributesResponseProtoMsg { + return { + typeUrl: "/akash.audit.v1beta1.MsgSignProviderAttributesResponse", + value: MsgSignProviderAttributesResponse.encode(message).finish() + }; + } +}; +function createBaseMsgDeleteProviderAttributes(): MsgDeleteProviderAttributes { + return { + owner: "", + auditor: "", + keys: [] + }; +} +export const MsgDeleteProviderAttributes = { + typeUrl: "/akash.audit.v1beta1.MsgDeleteProviderAttributes", + encode(message: MsgDeleteProviderAttributes, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.owner !== undefined) { + writer.uint32(10).string(message.owner); + } + if (message.auditor !== undefined) { + writer.uint32(18).string(message.auditor); + } + for (const v of message.keys) { + writer.uint32(26).string(v!); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgDeleteProviderAttributes { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgDeleteProviderAttributes(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.owner = reader.string(); + break; + case 2: + message.auditor = reader.string(); + break; + case 3: + message.keys.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgDeleteProviderAttributes { + const obj = createBaseMsgDeleteProviderAttributes(); + if (isSet(object.owner)) obj.owner = String(object.owner); + if (isSet(object.auditor)) obj.auditor = String(object.auditor); + if (Array.isArray(object?.keys)) obj.keys = object.keys.map((e: any) => String(e)); + return obj; + }, + toJSON(message: MsgDeleteProviderAttributes): JsonSafe { + const obj: any = {}; + message.owner !== undefined && (obj.owner = message.owner); + message.auditor !== undefined && (obj.auditor = message.auditor); + if (message.keys) { + obj.keys = message.keys.map(e => e); + } else { + obj.keys = []; + } + return obj; + }, + fromPartial, I>>(object: I): MsgDeleteProviderAttributes { + const message = createBaseMsgDeleteProviderAttributes(); + message.owner = object.owner ?? ""; + message.auditor = object.auditor ?? ""; + message.keys = object.keys?.map(e => e) || []; + return message; + }, + fromSDK(object: MsgDeleteProviderAttributesSDKType): MsgDeleteProviderAttributes { + return { + owner: object?.owner, + auditor: object?.auditor, + keys: Array.isArray(object?.keys) ? object.keys.map((e: any) => e) : [] + }; + }, + fromSDKJSON(object: any): MsgDeleteProviderAttributesSDKType { + return { + owner: isSet(object.owner) ? String(object.owner) : "", + auditor: isSet(object.auditor) ? String(object.auditor) : "", + keys: Array.isArray(object?.keys) ? object.keys.map((e: any) => String(e)) : [] + }; + }, + toSDK(message: MsgDeleteProviderAttributes): MsgDeleteProviderAttributesSDKType { + const obj: any = {}; + obj.owner = message.owner; + obj.auditor = message.auditor; + if (message.keys) { + obj.keys = message.keys.map(e => e); + } else { + obj.keys = []; + } + return obj; + }, + fromAmino(object: MsgDeleteProviderAttributesAmino): MsgDeleteProviderAttributes { + const message = createBaseMsgDeleteProviderAttributes(); + if (object.owner !== undefined && object.owner !== null) { + message.owner = object.owner; + } + if (object.auditor !== undefined && object.auditor !== null) { + message.auditor = object.auditor; + } + message.keys = object.keys?.map(e => e) || []; + return message; + }, + toAmino(message: MsgDeleteProviderAttributes): MsgDeleteProviderAttributesAmino { + const obj: any = {}; + obj.owner = message.owner ?? ""; + obj.auditor = message.auditor ?? ""; + if (message.keys) { + obj.keys = message.keys.map(e => e); + } else { + obj.keys = message.keys; + } + return obj; + }, + fromAminoMsg(object: MsgDeleteProviderAttributesAminoMsg): MsgDeleteProviderAttributes { + return MsgDeleteProviderAttributes.fromAmino(object.value); + }, + toAminoMsg(message: MsgDeleteProviderAttributes): MsgDeleteProviderAttributesAminoMsg { + return { + type: "akash/audit/testonly-delete-provider-attributes", + value: MsgDeleteProviderAttributes.toAmino(message) + }; + }, + fromProtoMsg(message: MsgDeleteProviderAttributesProtoMsg): MsgDeleteProviderAttributes { + return MsgDeleteProviderAttributes.decode(message.value); + }, + toProto(message: MsgDeleteProviderAttributes): Uint8Array { + return MsgDeleteProviderAttributes.encode(message).finish(); + }, + toProtoMsg(message: MsgDeleteProviderAttributes): MsgDeleteProviderAttributesProtoMsg { + return { + typeUrl: "/akash.audit.v1beta1.MsgDeleteProviderAttributes", + value: MsgDeleteProviderAttributes.encode(message).finish() + }; + } +}; +function createBaseMsgDeleteProviderAttributesResponse(): MsgDeleteProviderAttributesResponse { + return {}; +} +export const MsgDeleteProviderAttributesResponse = { + typeUrl: "/akash.audit.v1beta1.MsgDeleteProviderAttributesResponse", + encode(_: MsgDeleteProviderAttributesResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgDeleteProviderAttributesResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgDeleteProviderAttributesResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgDeleteProviderAttributesResponse { + const obj = createBaseMsgDeleteProviderAttributesResponse(); + return obj; + }, + toJSON(_: MsgDeleteProviderAttributesResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): MsgDeleteProviderAttributesResponse { + const message = createBaseMsgDeleteProviderAttributesResponse(); + return message; + }, + fromSDK(_: MsgDeleteProviderAttributesResponseSDKType): MsgDeleteProviderAttributesResponse { + return {}; + }, + fromSDKJSON(_: any): MsgDeleteProviderAttributesResponseSDKType { + return {}; + }, + toSDK(_: MsgDeleteProviderAttributesResponse): MsgDeleteProviderAttributesResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgDeleteProviderAttributesResponseAmino): MsgDeleteProviderAttributesResponse { + const message = createBaseMsgDeleteProviderAttributesResponse(); + return message; + }, + toAmino(_: MsgDeleteProviderAttributesResponse): MsgDeleteProviderAttributesResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgDeleteProviderAttributesResponseAminoMsg): MsgDeleteProviderAttributesResponse { + return MsgDeleteProviderAttributesResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgDeleteProviderAttributesResponse): MsgDeleteProviderAttributesResponseAminoMsg { + return { + type: "akash/audit/testonly-delete-provider-attributes-response", + value: MsgDeleteProviderAttributesResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgDeleteProviderAttributesResponseProtoMsg): MsgDeleteProviderAttributesResponse { + return MsgDeleteProviderAttributesResponse.decode(message.value); + }, + toProto(message: MsgDeleteProviderAttributesResponse): Uint8Array { + return MsgDeleteProviderAttributesResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgDeleteProviderAttributesResponse): MsgDeleteProviderAttributesResponseProtoMsg { + return { + typeUrl: "/akash.audit.v1beta1.MsgDeleteProviderAttributesResponse", + value: MsgDeleteProviderAttributesResponse.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/audit/v1beta2/audit.amino.ts b/__fixtures__/v-next/outputicjsdeps/akash/audit/v1beta2/audit.amino.ts new file mode 100644 index 0000000000..87628cdaf2 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/audit/v1beta2/audit.amino.ts @@ -0,0 +1,81 @@ +/* eslint-disable */ +import { Attribute, AttributeSDKType } from "../../base/v1beta2/attribute.js"; +import { ReadOnlyAminoMsg as AminoMsg } from "@interchainjs/ReadOnlyAminoMsg"; +import { MsgSignProviderAttributes, MsgSignProviderAttributesSDKType, MsgDeleteProviderAttributes, MsgDeleteProviderAttributesSDKType } from "./audit.js"; +export interface MsgSignProviderAttributesAminoType extends AminoMsg { + type: "mymessage-testonly"; + value: { + owner: string; + auditor: string; + attributes: { + key: string; + value: string; + }[]; + }; +} +export interface MsgDeleteProviderAttributesAminoType extends AminoMsg { + type: "akash/audit/v1beta2/testonly-delete-provider-attributes"; + value: { + owner: string; + auditor: string; + keys: string[]; + }; +} +export const AminoConverter = { + "/akash.audit.v1beta2.MsgSignProviderAttributes": { + aminoType: "mymessage-testonly", + toAmino: ({ + owner, + auditor, + attributes + }: MsgSignProviderAttributes): MsgSignProviderAttributesAminoType["value"] => { + return { + owner, + auditor, + attributes: attributes.map(el0 => ({ + key: el0.key, + value: el0.value + })) + }; + }, + fromAmino: ({ + owner, + auditor, + attributes + }: MsgSignProviderAttributesAminoType["value"]): MsgSignProviderAttributes => { + return { + owner, + auditor, + attributes: attributes.map(el0 => ({ + key: el0.key, + value: el0.value + })) + }; + } + }, + "/akash.audit.v1beta2.MsgDeleteProviderAttributes": { + aminoType: "akash/audit/v1beta2/testonly-delete-provider-attributes", + toAmino: ({ + owner, + auditor, + keys + }: MsgDeleteProviderAttributes): MsgDeleteProviderAttributesAminoType["value"] => { + return { + owner, + auditor, + keys + }; + }, + fromAmino: ({ + owner, + auditor, + keys + }: MsgDeleteProviderAttributesAminoType["value"]): MsgDeleteProviderAttributes => { + return { + owner, + auditor, + keys + }; + } + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/audit/v1beta2/audit.registry.ts b/__fixtures__/v-next/outputicjsdeps/akash/audit/v1beta2/audit.registry.ts new file mode 100644 index 0000000000..c0c62a8f7d --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/audit/v1beta2/audit.registry.ts @@ -0,0 +1,81 @@ +import { Attribute, AttributeSDKType } from "../../base/v1beta2/attribute.js"; +import { GeneratedType, Registry } from "@cosmjs/proto-signing"; +import { MsgSignProviderAttributes, MsgSignProviderAttributesSDKType, MsgDeleteProviderAttributes, MsgDeleteProviderAttributesSDKType } from "./audit.js"; +export const registry: ReadonlyArray<[string, GeneratedType]> = [["/akash.audit.v1beta2.MsgSignProviderAttributes", MsgSignProviderAttributes], ["/akash.audit.v1beta2.MsgDeleteProviderAttributes", MsgDeleteProviderAttributes]]; +export const load = (protoRegistry: Registry) => { + registry.forEach(([typeUrl, mod]) => { + protoRegistry.register(typeUrl, mod); + }); +}; +export const MessageComposer = { + encoded: { + signProviderAttributes(value: MsgSignProviderAttributes) { + return { + typeUrl: "/akash.audit.v1beta2.MsgSignProviderAttributes", + value: MsgSignProviderAttributes.encode(value).finish() + }; + }, + deleteProviderAttributes(value: MsgDeleteProviderAttributes) { + return { + typeUrl: "/akash.audit.v1beta2.MsgDeleteProviderAttributes", + value: MsgDeleteProviderAttributes.encode(value).finish() + }; + } + }, + withTypeUrl: { + signProviderAttributes(value: MsgSignProviderAttributes) { + return { + typeUrl: "/akash.audit.v1beta2.MsgSignProviderAttributes", + value + }; + }, + deleteProviderAttributes(value: MsgDeleteProviderAttributes) { + return { + typeUrl: "/akash.audit.v1beta2.MsgDeleteProviderAttributes", + value + }; + } + }, + toJSON: { + signProviderAttributes(value: MsgSignProviderAttributes) { + return { + typeUrl: "/akash.audit.v1beta2.MsgSignProviderAttributes", + value: MsgSignProviderAttributes.toJSON(value) + }; + }, + deleteProviderAttributes(value: MsgDeleteProviderAttributes) { + return { + typeUrl: "/akash.audit.v1beta2.MsgDeleteProviderAttributes", + value: MsgDeleteProviderAttributes.toJSON(value) + }; + } + }, + fromJSON: { + signProviderAttributes(value: any) { + return { + typeUrl: "/akash.audit.v1beta2.MsgSignProviderAttributes", + value: MsgSignProviderAttributes.fromJSON(value) + }; + }, + deleteProviderAttributes(value: any) { + return { + typeUrl: "/akash.audit.v1beta2.MsgDeleteProviderAttributes", + value: MsgDeleteProviderAttributes.fromJSON(value) + }; + } + }, + fromPartial: { + signProviderAttributes(value: MsgSignProviderAttributes) { + return { + typeUrl: "/akash.audit.v1beta2.MsgSignProviderAttributes", + value: MsgSignProviderAttributes.fromPartial(value) + }; + }, + deleteProviderAttributes(value: MsgDeleteProviderAttributes) { + return { + typeUrl: "/akash.audit.v1beta2.MsgDeleteProviderAttributes", + value: MsgDeleteProviderAttributes.fromPartial(value) + }; + } + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/audit/v1beta2/audit.rpc.func.ts b/__fixtures__/v-next/outputicjsdeps/akash/audit/v1beta2/audit.rpc.func.ts new file mode 100644 index 0000000000..250106d07b --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/audit/v1beta2/audit.rpc.func.ts @@ -0,0 +1,22 @@ +import { buildTx, SigningClientResolver } from "../../../helper-func-types"; +import { buildUseMutation } from "../../../react-query"; +import { toEncoders, toConverters } from "@interchainjs/cosmos/utils"; +import { MsgSignProviderAttributes, MsgDeleteProviderAttributes } from "./audit"; +export const createSignProviderAttributes = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgSignProviderAttributes.typeUrl, + encoders: toEncoders(MsgSignProviderAttributes), + converters: toConverters(MsgSignProviderAttributes) +}); +export const useSignProviderAttributes = buildUseMutation({ + builderMutationFn: createSignProviderAttributes +}); +export const createDeleteProviderAttributes = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgDeleteProviderAttributes.typeUrl, + encoders: toEncoders(MsgDeleteProviderAttributes), + converters: toConverters(MsgDeleteProviderAttributes) +}); +export const useDeleteProviderAttributes = buildUseMutation({ + builderMutationFn: createDeleteProviderAttributes +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/audit/v1beta2/audit.rpc.msg.ts b/__fixtures__/v-next/outputicjsdeps/akash/audit/v1beta2/audit.rpc.msg.ts new file mode 100644 index 0000000000..d7ebc0a0ab --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/audit/v1beta2/audit.rpc.msg.ts @@ -0,0 +1,32 @@ +import { Attribute, AttributeSDKType } from "../../base/v1beta2/attribute.js"; +import { Rpc } from "../../../helpers.js"; +import { BinaryReader } from "../../../binary.js"; +import { MsgSignProviderAttributes, MsgSignProviderAttributesSDKType, MsgSignProviderAttributesResponse, MsgSignProviderAttributesResponseSDKType, MsgDeleteProviderAttributes, MsgDeleteProviderAttributesSDKType, MsgDeleteProviderAttributesResponse, MsgDeleteProviderAttributesResponseSDKType } from "./audit.js"; +/** Msg defines the provider Msg service */ +export interface Msg { + /** SignProviderAttributes defines a method that signs provider attributes */ + signProviderAttributes(request: MsgSignProviderAttributes): Promise; + /** DeleteProviderAttributes defines a method that deletes provider attributes */ + deleteProviderAttributes(request: MsgDeleteProviderAttributes): Promise; +} +export class MsgClientImpl implements Msg { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + } + /* SignProviderAttributes defines a method that signs provider attributes */ + signProviderAttributes = async (request: MsgSignProviderAttributes): Promise => { + const data = MsgSignProviderAttributes.encode(request).finish(); + const promise = this.rpc.request("akash.audit.v1beta2.Msg", "SignProviderAttributes", data); + return promise.then(data => MsgSignProviderAttributesResponse.decode(new BinaryReader(data))); + }; + /* DeleteProviderAttributes defines a method that deletes provider attributes */ + deleteProviderAttributes = async (request: MsgDeleteProviderAttributes): Promise => { + const data = MsgDeleteProviderAttributes.encode(request).finish(); + const promise = this.rpc.request("akash.audit.v1beta2.Msg", "DeleteProviderAttributes", data); + return promise.then(data => MsgDeleteProviderAttributesResponse.decode(new BinaryReader(data))); + }; +} +export const createClientImpl = (rpc: Rpc) => { + return new MsgClientImpl(rpc); +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/audit/v1beta2/audit.ts b/__fixtures__/v-next/outputicjsdeps/akash/audit/v1beta2/audit.ts new file mode 100644 index 0000000000..6a533db05e --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/audit/v1beta2/audit.ts @@ -0,0 +1,1046 @@ +import { Attribute, AttributeSDKType } from "../../base/v1beta2/attribute.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial, Exact } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "akash.audit.v1beta2"; +/** Provider stores owner auditor and attributes details */ +export interface Provider { + owner: string; + auditor: string; + attributes: Attribute[]; +} +export interface ProviderProtoMsg { + typeUrl: "/akash.audit.v1beta2.Provider"; + value: Uint8Array; +} +/** Provider stores owner auditor and attributes details */ +export interface ProviderSDKType { + owner: string; + auditor: string; + attributes: AttributeSDKType[]; +} +/** Attributes */ +export interface AuditedAttributes { + owner: string; + auditor: string; + attributes: Attribute[]; +} +export interface AuditedAttributesProtoMsg { + typeUrl: "/akash.audit.v1beta2.AuditedAttributes"; + value: Uint8Array; +} +/** Attributes */ +export interface AuditedAttributesSDKType { + owner: string; + auditor: string; + attributes: AttributeSDKType[]; +} +/** AttributesResponse represents details of deployment along with group details */ +export interface AttributesResponse { + attributes: AuditedAttributes[]; +} +export interface AttributesResponseProtoMsg { + typeUrl: "/akash.audit.v1beta2.AttributesResponse"; + value: Uint8Array; +} +/** AttributesResponse represents details of deployment along with group details */ +export interface AttributesResponseSDKType { + attributes: AuditedAttributesSDKType[]; +} +/** AttributesFilters defines filters used to filter deployments */ +export interface AttributesFilters { + auditors: string[]; + owners: string[]; +} +export interface AttributesFiltersProtoMsg { + typeUrl: "/akash.audit.v1beta2.AttributesFilters"; + value: Uint8Array; +} +/** AttributesFilters defines filters used to filter deployments */ +export interface AttributesFiltersSDKType { + auditors: string[]; + owners: string[]; +} +/** MsgSignProviderAttributes defines an SDK message for signing a provider attributes */ +export interface MsgSignProviderAttributes { + owner: string; + auditor: string; + attributes: Attribute[]; +} +export interface MsgSignProviderAttributesProtoMsg { + typeUrl: "/akash.audit.v1beta2.MsgSignProviderAttributes"; + value: Uint8Array; +} +/** MsgSignProviderAttributes defines an SDK message for signing a provider attributes */ +export interface MsgSignProviderAttributesSDKType { + owner: string; + auditor: string; + attributes: AttributeSDKType[]; +} +/** MsgSignProviderAttributesResponse defines the Msg/CreateProvider response type. */ +export interface MsgSignProviderAttributesResponse {} +export interface MsgSignProviderAttributesResponseProtoMsg { + typeUrl: "/akash.audit.v1beta2.MsgSignProviderAttributesResponse"; + value: Uint8Array; +} +/** MsgSignProviderAttributesResponse defines the Msg/CreateProvider response type. */ +export interface MsgSignProviderAttributesResponseSDKType {} +/** MsgDeleteProviderAttributes defined the Msg/DeleteProviderAttributes */ +export interface MsgDeleteProviderAttributes { + owner: string; + auditor: string; + keys: string[]; +} +export interface MsgDeleteProviderAttributesProtoMsg { + typeUrl: "/akash.audit.v1beta2.MsgDeleteProviderAttributes"; + value: Uint8Array; +} +/** MsgDeleteProviderAttributes defined the Msg/DeleteProviderAttributes */ +export interface MsgDeleteProviderAttributesSDKType { + owner: string; + auditor: string; + keys: string[]; +} +/** MsgDeleteProviderAttributesResponse defines the Msg/ProviderAttributes response type. */ +export interface MsgDeleteProviderAttributesResponse {} +export interface MsgDeleteProviderAttributesResponseProtoMsg { + typeUrl: "/akash.audit.v1beta2.MsgDeleteProviderAttributesResponse"; + value: Uint8Array; +} +/** MsgDeleteProviderAttributesResponse defines the Msg/ProviderAttributes response type. */ +export interface MsgDeleteProviderAttributesResponseSDKType {} +function createBaseProvider(): Provider { + return { + owner: "", + auditor: "", + attributes: [] + }; +} +export const Provider = { + typeUrl: "/akash.audit.v1beta2.Provider", + encode(message: Provider, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.owner !== undefined) { + writer.uint32(10).string(message.owner); + } + if (message.auditor !== undefined) { + writer.uint32(18).string(message.auditor); + } + for (const v of message.attributes) { + Attribute.encode(v!, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Provider { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseProvider(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.owner = reader.string(); + break; + case 2: + message.auditor = reader.string(); + break; + case 4: + message.attributes.push(Attribute.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Provider { + const obj = createBaseProvider(); + if (isSet(object.owner)) obj.owner = String(object.owner); + if (isSet(object.auditor)) obj.auditor = String(object.auditor); + if (Array.isArray(object?.attributes)) obj.attributes = object.attributes.map((e: any) => Attribute.fromJSON(e)); + return obj; + }, + toJSON(message: Provider): JsonSafe { + const obj: any = {}; + message.owner !== undefined && (obj.owner = message.owner); + message.auditor !== undefined && (obj.auditor = message.auditor); + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? Attribute.toJSON(e) : undefined); + } else { + obj.attributes = []; + } + return obj; + }, + fromPartial, I>>(object: I): Provider { + const message = createBaseProvider(); + message.owner = object.owner ?? ""; + message.auditor = object.auditor ?? ""; + message.attributes = object.attributes?.map(e => Attribute.fromPartial(e)) || []; + return message; + }, + fromSDK(object: ProviderSDKType): Provider { + return { + owner: object?.owner, + auditor: object?.auditor, + attributes: Array.isArray(object?.attributes) ? object.attributes.map((e: any) => Attribute.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): ProviderSDKType { + return { + owner: isSet(object.owner) ? String(object.owner) : "", + auditor: isSet(object.auditor) ? String(object.auditor) : "", + attributes: Array.isArray(object?.attributes) ? object.attributes.map((e: any) => Attribute.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: Provider): ProviderSDKType { + const obj: any = {}; + obj.owner = message.owner; + obj.auditor = message.auditor; + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? Attribute.toSDK(e) : undefined); + } else { + obj.attributes = []; + } + return obj; + }, + fromAmino(object: ProviderAmino): Provider { + const message = createBaseProvider(); + if (object.owner !== undefined && object.owner !== null) { + message.owner = object.owner; + } + if (object.auditor !== undefined && object.auditor !== null) { + message.auditor = object.auditor; + } + message.attributes = object.attributes?.map(e => Attribute.fromAmino(e)) || []; + return message; + }, + toAmino(message: Provider): ProviderAmino { + const obj: any = {}; + obj.owner = message.owner ?? ""; + obj.auditor = message.auditor ?? ""; + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? Attribute.toAmino(e) : undefined); + } else { + obj.attributes = message.attributes; + } + return obj; + }, + fromAminoMsg(object: ProviderAminoMsg): Provider { + return Provider.fromAmino(object.value); + }, + toAminoMsg(message: Provider): ProviderAminoMsg { + return { + type: "akash/audit/v1beta2/provider", + value: Provider.toAmino(message) + }; + }, + fromProtoMsg(message: ProviderProtoMsg): Provider { + return Provider.decode(message.value); + }, + toProto(message: Provider): Uint8Array { + return Provider.encode(message).finish(); + }, + toProtoMsg(message: Provider): ProviderProtoMsg { + return { + typeUrl: "/akash.audit.v1beta2.Provider", + value: Provider.encode(message).finish() + }; + } +}; +function createBaseAuditedAttributes(): AuditedAttributes { + return { + owner: "", + auditor: "", + attributes: [] + }; +} +export const AuditedAttributes = { + typeUrl: "/akash.audit.v1beta2.AuditedAttributes", + encode(message: AuditedAttributes, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.owner !== undefined) { + writer.uint32(10).string(message.owner); + } + if (message.auditor !== undefined) { + writer.uint32(18).string(message.auditor); + } + for (const v of message.attributes) { + Attribute.encode(v!, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): AuditedAttributes { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseAuditedAttributes(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.owner = reader.string(); + break; + case 2: + message.auditor = reader.string(); + break; + case 3: + message.attributes.push(Attribute.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): AuditedAttributes { + const obj = createBaseAuditedAttributes(); + if (isSet(object.owner)) obj.owner = String(object.owner); + if (isSet(object.auditor)) obj.auditor = String(object.auditor); + if (Array.isArray(object?.attributes)) obj.attributes = object.attributes.map((e: any) => Attribute.fromJSON(e)); + return obj; + }, + toJSON(message: AuditedAttributes): JsonSafe { + const obj: any = {}; + message.owner !== undefined && (obj.owner = message.owner); + message.auditor !== undefined && (obj.auditor = message.auditor); + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? Attribute.toJSON(e) : undefined); + } else { + obj.attributes = []; + } + return obj; + }, + fromPartial, I>>(object: I): AuditedAttributes { + const message = createBaseAuditedAttributes(); + message.owner = object.owner ?? ""; + message.auditor = object.auditor ?? ""; + message.attributes = object.attributes?.map(e => Attribute.fromPartial(e)) || []; + return message; + }, + fromSDK(object: AuditedAttributesSDKType): AuditedAttributes { + return { + owner: object?.owner, + auditor: object?.auditor, + attributes: Array.isArray(object?.attributes) ? object.attributes.map((e: any) => Attribute.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): AuditedAttributesSDKType { + return { + owner: isSet(object.owner) ? String(object.owner) : "", + auditor: isSet(object.auditor) ? String(object.auditor) : "", + attributes: Array.isArray(object?.attributes) ? object.attributes.map((e: any) => Attribute.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: AuditedAttributes): AuditedAttributesSDKType { + const obj: any = {}; + obj.owner = message.owner; + obj.auditor = message.auditor; + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? Attribute.toSDK(e) : undefined); + } else { + obj.attributes = []; + } + return obj; + }, + fromAmino(object: AuditedAttributesAmino): AuditedAttributes { + const message = createBaseAuditedAttributes(); + if (object.owner !== undefined && object.owner !== null) { + message.owner = object.owner; + } + if (object.auditor !== undefined && object.auditor !== null) { + message.auditor = object.auditor; + } + message.attributes = object.attributes?.map(e => Attribute.fromAmino(e)) || []; + return message; + }, + toAmino(message: AuditedAttributes): AuditedAttributesAmino { + const obj: any = {}; + obj.owner = message.owner ?? ""; + obj.auditor = message.auditor ?? ""; + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? Attribute.toAmino(e) : undefined); + } else { + obj.attributes = message.attributes; + } + return obj; + }, + fromAminoMsg(object: AuditedAttributesAminoMsg): AuditedAttributes { + return AuditedAttributes.fromAmino(object.value); + }, + toAminoMsg(message: AuditedAttributes): AuditedAttributesAminoMsg { + return { + type: "akash/audit/v1beta2/audited-attributes", + value: AuditedAttributes.toAmino(message) + }; + }, + fromProtoMsg(message: AuditedAttributesProtoMsg): AuditedAttributes { + return AuditedAttributes.decode(message.value); + }, + toProto(message: AuditedAttributes): Uint8Array { + return AuditedAttributes.encode(message).finish(); + }, + toProtoMsg(message: AuditedAttributes): AuditedAttributesProtoMsg { + return { + typeUrl: "/akash.audit.v1beta2.AuditedAttributes", + value: AuditedAttributes.encode(message).finish() + }; + } +}; +function createBaseAttributesResponse(): AttributesResponse { + return { + attributes: [] + }; +} +export const AttributesResponse = { + typeUrl: "/akash.audit.v1beta2.AttributesResponse", + encode(message: AttributesResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.attributes) { + AuditedAttributes.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): AttributesResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseAttributesResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.attributes.push(AuditedAttributes.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): AttributesResponse { + const obj = createBaseAttributesResponse(); + if (Array.isArray(object?.attributes)) obj.attributes = object.attributes.map((e: any) => AuditedAttributes.fromJSON(e)); + return obj; + }, + toJSON(message: AttributesResponse): JsonSafe { + const obj: any = {}; + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? AuditedAttributes.toJSON(e) : undefined); + } else { + obj.attributes = []; + } + return obj; + }, + fromPartial, I>>(object: I): AttributesResponse { + const message = createBaseAttributesResponse(); + message.attributes = object.attributes?.map(e => AuditedAttributes.fromPartial(e)) || []; + return message; + }, + fromSDK(object: AttributesResponseSDKType): AttributesResponse { + return { + attributes: Array.isArray(object?.attributes) ? object.attributes.map((e: any) => AuditedAttributes.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): AttributesResponseSDKType { + return { + attributes: Array.isArray(object?.attributes) ? object.attributes.map((e: any) => AuditedAttributes.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: AttributesResponse): AttributesResponseSDKType { + const obj: any = {}; + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? AuditedAttributes.toSDK(e) : undefined); + } else { + obj.attributes = []; + } + return obj; + }, + fromAmino(object: AttributesResponseAmino): AttributesResponse { + const message = createBaseAttributesResponse(); + message.attributes = object.attributes?.map(e => AuditedAttributes.fromAmino(e)) || []; + return message; + }, + toAmino(message: AttributesResponse): AttributesResponseAmino { + const obj: any = {}; + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? AuditedAttributes.toAmino(e) : undefined); + } else { + obj.attributes = message.attributes; + } + return obj; + }, + fromAminoMsg(object: AttributesResponseAminoMsg): AttributesResponse { + return AttributesResponse.fromAmino(object.value); + }, + toAminoMsg(message: AttributesResponse): AttributesResponseAminoMsg { + return { + type: "akash/audit/v1beta2/attributes-response", + value: AttributesResponse.toAmino(message) + }; + }, + fromProtoMsg(message: AttributesResponseProtoMsg): AttributesResponse { + return AttributesResponse.decode(message.value); + }, + toProto(message: AttributesResponse): Uint8Array { + return AttributesResponse.encode(message).finish(); + }, + toProtoMsg(message: AttributesResponse): AttributesResponseProtoMsg { + return { + typeUrl: "/akash.audit.v1beta2.AttributesResponse", + value: AttributesResponse.encode(message).finish() + }; + } +}; +function createBaseAttributesFilters(): AttributesFilters { + return { + auditors: [], + owners: [] + }; +} +export const AttributesFilters = { + typeUrl: "/akash.audit.v1beta2.AttributesFilters", + encode(message: AttributesFilters, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.auditors) { + writer.uint32(10).string(v!); + } + for (const v of message.owners) { + writer.uint32(18).string(v!); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): AttributesFilters { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseAttributesFilters(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.auditors.push(reader.string()); + break; + case 2: + message.owners.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): AttributesFilters { + const obj = createBaseAttributesFilters(); + if (Array.isArray(object?.auditors)) obj.auditors = object.auditors.map((e: any) => String(e)); + if (Array.isArray(object?.owners)) obj.owners = object.owners.map((e: any) => String(e)); + return obj; + }, + toJSON(message: AttributesFilters): JsonSafe { + const obj: any = {}; + if (message.auditors) { + obj.auditors = message.auditors.map(e => e); + } else { + obj.auditors = []; + } + if (message.owners) { + obj.owners = message.owners.map(e => e); + } else { + obj.owners = []; + } + return obj; + }, + fromPartial, I>>(object: I): AttributesFilters { + const message = createBaseAttributesFilters(); + message.auditors = object.auditors?.map(e => e) || []; + message.owners = object.owners?.map(e => e) || []; + return message; + }, + fromSDK(object: AttributesFiltersSDKType): AttributesFilters { + return { + auditors: Array.isArray(object?.auditors) ? object.auditors.map((e: any) => e) : [], + owners: Array.isArray(object?.owners) ? object.owners.map((e: any) => e) : [] + }; + }, + fromSDKJSON(object: any): AttributesFiltersSDKType { + return { + auditors: Array.isArray(object?.auditors) ? object.auditors.map((e: any) => String(e)) : [], + owners: Array.isArray(object?.owners) ? object.owners.map((e: any) => String(e)) : [] + }; + }, + toSDK(message: AttributesFilters): AttributesFiltersSDKType { + const obj: any = {}; + if (message.auditors) { + obj.auditors = message.auditors.map(e => e); + } else { + obj.auditors = []; + } + if (message.owners) { + obj.owners = message.owners.map(e => e); + } else { + obj.owners = []; + } + return obj; + }, + fromAmino(object: AttributesFiltersAmino): AttributesFilters { + const message = createBaseAttributesFilters(); + message.auditors = object.auditors?.map(e => e) || []; + message.owners = object.owners?.map(e => e) || []; + return message; + }, + toAmino(message: AttributesFilters): AttributesFiltersAmino { + const obj: any = {}; + if (message.auditors) { + obj.auditors = message.auditors.map(e => e); + } else { + obj.auditors = message.auditors; + } + if (message.owners) { + obj.owners = message.owners.map(e => e); + } else { + obj.owners = message.owners; + } + return obj; + }, + fromAminoMsg(object: AttributesFiltersAminoMsg): AttributesFilters { + return AttributesFilters.fromAmino(object.value); + }, + toAminoMsg(message: AttributesFilters): AttributesFiltersAminoMsg { + return { + type: "akash/audit/v1beta2/attributes-filters", + value: AttributesFilters.toAmino(message) + }; + }, + fromProtoMsg(message: AttributesFiltersProtoMsg): AttributesFilters { + return AttributesFilters.decode(message.value); + }, + toProto(message: AttributesFilters): Uint8Array { + return AttributesFilters.encode(message).finish(); + }, + toProtoMsg(message: AttributesFilters): AttributesFiltersProtoMsg { + return { + typeUrl: "/akash.audit.v1beta2.AttributesFilters", + value: AttributesFilters.encode(message).finish() + }; + } +}; +function createBaseMsgSignProviderAttributes(): MsgSignProviderAttributes { + return { + owner: "", + auditor: "", + attributes: [] + }; +} +export const MsgSignProviderAttributes = { + typeUrl: "/akash.audit.v1beta2.MsgSignProviderAttributes", + encode(message: MsgSignProviderAttributes, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.owner !== undefined) { + writer.uint32(10).string(message.owner); + } + if (message.auditor !== undefined) { + writer.uint32(18).string(message.auditor); + } + for (const v of message.attributes) { + Attribute.encode(v!, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgSignProviderAttributes { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgSignProviderAttributes(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.owner = reader.string(); + break; + case 2: + message.auditor = reader.string(); + break; + case 3: + message.attributes.push(Attribute.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgSignProviderAttributes { + const obj = createBaseMsgSignProviderAttributes(); + if (isSet(object.owner)) obj.owner = String(object.owner); + if (isSet(object.auditor)) obj.auditor = String(object.auditor); + if (Array.isArray(object?.attributes)) obj.attributes = object.attributes.map((e: any) => Attribute.fromJSON(e)); + return obj; + }, + toJSON(message: MsgSignProviderAttributes): JsonSafe { + const obj: any = {}; + message.owner !== undefined && (obj.owner = message.owner); + message.auditor !== undefined && (obj.auditor = message.auditor); + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? Attribute.toJSON(e) : undefined); + } else { + obj.attributes = []; + } + return obj; + }, + fromPartial, I>>(object: I): MsgSignProviderAttributes { + const message = createBaseMsgSignProviderAttributes(); + message.owner = object.owner ?? ""; + message.auditor = object.auditor ?? ""; + message.attributes = object.attributes?.map(e => Attribute.fromPartial(e)) || []; + return message; + }, + fromSDK(object: MsgSignProviderAttributesSDKType): MsgSignProviderAttributes { + return { + owner: object?.owner, + auditor: object?.auditor, + attributes: Array.isArray(object?.attributes) ? object.attributes.map((e: any) => Attribute.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): MsgSignProviderAttributesSDKType { + return { + owner: isSet(object.owner) ? String(object.owner) : "", + auditor: isSet(object.auditor) ? String(object.auditor) : "", + attributes: Array.isArray(object?.attributes) ? object.attributes.map((e: any) => Attribute.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: MsgSignProviderAttributes): MsgSignProviderAttributesSDKType { + const obj: any = {}; + obj.owner = message.owner; + obj.auditor = message.auditor; + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? Attribute.toSDK(e) : undefined); + } else { + obj.attributes = []; + } + return obj; + }, + fromAmino(object: MsgSignProviderAttributesAmino): MsgSignProviderAttributes { + const message = createBaseMsgSignProviderAttributes(); + if (object.owner !== undefined && object.owner !== null) { + message.owner = object.owner; + } + if (object.auditor !== undefined && object.auditor !== null) { + message.auditor = object.auditor; + } + message.attributes = object.attributes?.map(e => Attribute.fromAmino(e)) || []; + return message; + }, + toAmino(message: MsgSignProviderAttributes): MsgSignProviderAttributesAmino { + const obj: any = {}; + obj.owner = message.owner ?? ""; + obj.auditor = message.auditor ?? ""; + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? Attribute.toAmino(e) : undefined); + } else { + obj.attributes = message.attributes; + } + return obj; + }, + fromAminoMsg(object: MsgSignProviderAttributesAminoMsg): MsgSignProviderAttributes { + return MsgSignProviderAttributes.fromAmino(object.value); + }, + toAminoMsg(message: MsgSignProviderAttributes): MsgSignProviderAttributesAminoMsg { + return { + type: "mymessage-testonly", + value: MsgSignProviderAttributes.toAmino(message) + }; + }, + fromProtoMsg(message: MsgSignProviderAttributesProtoMsg): MsgSignProviderAttributes { + return MsgSignProviderAttributes.decode(message.value); + }, + toProto(message: MsgSignProviderAttributes): Uint8Array { + return MsgSignProviderAttributes.encode(message).finish(); + }, + toProtoMsg(message: MsgSignProviderAttributes): MsgSignProviderAttributesProtoMsg { + return { + typeUrl: "/akash.audit.v1beta2.MsgSignProviderAttributes", + value: MsgSignProviderAttributes.encode(message).finish() + }; + } +}; +function createBaseMsgSignProviderAttributesResponse(): MsgSignProviderAttributesResponse { + return {}; +} +export const MsgSignProviderAttributesResponse = { + typeUrl: "/akash.audit.v1beta2.MsgSignProviderAttributesResponse", + encode(_: MsgSignProviderAttributesResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgSignProviderAttributesResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgSignProviderAttributesResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgSignProviderAttributesResponse { + const obj = createBaseMsgSignProviderAttributesResponse(); + return obj; + }, + toJSON(_: MsgSignProviderAttributesResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): MsgSignProviderAttributesResponse { + const message = createBaseMsgSignProviderAttributesResponse(); + return message; + }, + fromSDK(_: MsgSignProviderAttributesResponseSDKType): MsgSignProviderAttributesResponse { + return {}; + }, + fromSDKJSON(_: any): MsgSignProviderAttributesResponseSDKType { + return {}; + }, + toSDK(_: MsgSignProviderAttributesResponse): MsgSignProviderAttributesResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgSignProviderAttributesResponseAmino): MsgSignProviderAttributesResponse { + const message = createBaseMsgSignProviderAttributesResponse(); + return message; + }, + toAmino(_: MsgSignProviderAttributesResponse): MsgSignProviderAttributesResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgSignProviderAttributesResponseAminoMsg): MsgSignProviderAttributesResponse { + return MsgSignProviderAttributesResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgSignProviderAttributesResponse): MsgSignProviderAttributesResponseAminoMsg { + return { + type: "akash/audit/v1beta2/testonly-sign-provider-attributes-response", + value: MsgSignProviderAttributesResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgSignProviderAttributesResponseProtoMsg): MsgSignProviderAttributesResponse { + return MsgSignProviderAttributesResponse.decode(message.value); + }, + toProto(message: MsgSignProviderAttributesResponse): Uint8Array { + return MsgSignProviderAttributesResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgSignProviderAttributesResponse): MsgSignProviderAttributesResponseProtoMsg { + return { + typeUrl: "/akash.audit.v1beta2.MsgSignProviderAttributesResponse", + value: MsgSignProviderAttributesResponse.encode(message).finish() + }; + } +}; +function createBaseMsgDeleteProviderAttributes(): MsgDeleteProviderAttributes { + return { + owner: "", + auditor: "", + keys: [] + }; +} +export const MsgDeleteProviderAttributes = { + typeUrl: "/akash.audit.v1beta2.MsgDeleteProviderAttributes", + encode(message: MsgDeleteProviderAttributes, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.owner !== undefined) { + writer.uint32(10).string(message.owner); + } + if (message.auditor !== undefined) { + writer.uint32(18).string(message.auditor); + } + for (const v of message.keys) { + writer.uint32(26).string(v!); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgDeleteProviderAttributes { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgDeleteProviderAttributes(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.owner = reader.string(); + break; + case 2: + message.auditor = reader.string(); + break; + case 3: + message.keys.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgDeleteProviderAttributes { + const obj = createBaseMsgDeleteProviderAttributes(); + if (isSet(object.owner)) obj.owner = String(object.owner); + if (isSet(object.auditor)) obj.auditor = String(object.auditor); + if (Array.isArray(object?.keys)) obj.keys = object.keys.map((e: any) => String(e)); + return obj; + }, + toJSON(message: MsgDeleteProviderAttributes): JsonSafe { + const obj: any = {}; + message.owner !== undefined && (obj.owner = message.owner); + message.auditor !== undefined && (obj.auditor = message.auditor); + if (message.keys) { + obj.keys = message.keys.map(e => e); + } else { + obj.keys = []; + } + return obj; + }, + fromPartial, I>>(object: I): MsgDeleteProviderAttributes { + const message = createBaseMsgDeleteProviderAttributes(); + message.owner = object.owner ?? ""; + message.auditor = object.auditor ?? ""; + message.keys = object.keys?.map(e => e) || []; + return message; + }, + fromSDK(object: MsgDeleteProviderAttributesSDKType): MsgDeleteProviderAttributes { + return { + owner: object?.owner, + auditor: object?.auditor, + keys: Array.isArray(object?.keys) ? object.keys.map((e: any) => e) : [] + }; + }, + fromSDKJSON(object: any): MsgDeleteProviderAttributesSDKType { + return { + owner: isSet(object.owner) ? String(object.owner) : "", + auditor: isSet(object.auditor) ? String(object.auditor) : "", + keys: Array.isArray(object?.keys) ? object.keys.map((e: any) => String(e)) : [] + }; + }, + toSDK(message: MsgDeleteProviderAttributes): MsgDeleteProviderAttributesSDKType { + const obj: any = {}; + obj.owner = message.owner; + obj.auditor = message.auditor; + if (message.keys) { + obj.keys = message.keys.map(e => e); + } else { + obj.keys = []; + } + return obj; + }, + fromAmino(object: MsgDeleteProviderAttributesAmino): MsgDeleteProviderAttributes { + const message = createBaseMsgDeleteProviderAttributes(); + if (object.owner !== undefined && object.owner !== null) { + message.owner = object.owner; + } + if (object.auditor !== undefined && object.auditor !== null) { + message.auditor = object.auditor; + } + message.keys = object.keys?.map(e => e) || []; + return message; + }, + toAmino(message: MsgDeleteProviderAttributes): MsgDeleteProviderAttributesAmino { + const obj: any = {}; + obj.owner = message.owner ?? ""; + obj.auditor = message.auditor ?? ""; + if (message.keys) { + obj.keys = message.keys.map(e => e); + } else { + obj.keys = message.keys; + } + return obj; + }, + fromAminoMsg(object: MsgDeleteProviderAttributesAminoMsg): MsgDeleteProviderAttributes { + return MsgDeleteProviderAttributes.fromAmino(object.value); + }, + toAminoMsg(message: MsgDeleteProviderAttributes): MsgDeleteProviderAttributesAminoMsg { + return { + type: "akash/audit/v1beta2/testonly-delete-provider-attributes", + value: MsgDeleteProviderAttributes.toAmino(message) + }; + }, + fromProtoMsg(message: MsgDeleteProviderAttributesProtoMsg): MsgDeleteProviderAttributes { + return MsgDeleteProviderAttributes.decode(message.value); + }, + toProto(message: MsgDeleteProviderAttributes): Uint8Array { + return MsgDeleteProviderAttributes.encode(message).finish(); + }, + toProtoMsg(message: MsgDeleteProviderAttributes): MsgDeleteProviderAttributesProtoMsg { + return { + typeUrl: "/akash.audit.v1beta2.MsgDeleteProviderAttributes", + value: MsgDeleteProviderAttributes.encode(message).finish() + }; + } +}; +function createBaseMsgDeleteProviderAttributesResponse(): MsgDeleteProviderAttributesResponse { + return {}; +} +export const MsgDeleteProviderAttributesResponse = { + typeUrl: "/akash.audit.v1beta2.MsgDeleteProviderAttributesResponse", + encode(_: MsgDeleteProviderAttributesResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgDeleteProviderAttributesResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgDeleteProviderAttributesResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgDeleteProviderAttributesResponse { + const obj = createBaseMsgDeleteProviderAttributesResponse(); + return obj; + }, + toJSON(_: MsgDeleteProviderAttributesResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): MsgDeleteProviderAttributesResponse { + const message = createBaseMsgDeleteProviderAttributesResponse(); + return message; + }, + fromSDK(_: MsgDeleteProviderAttributesResponseSDKType): MsgDeleteProviderAttributesResponse { + return {}; + }, + fromSDKJSON(_: any): MsgDeleteProviderAttributesResponseSDKType { + return {}; + }, + toSDK(_: MsgDeleteProviderAttributesResponse): MsgDeleteProviderAttributesResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgDeleteProviderAttributesResponseAmino): MsgDeleteProviderAttributesResponse { + const message = createBaseMsgDeleteProviderAttributesResponse(); + return message; + }, + toAmino(_: MsgDeleteProviderAttributesResponse): MsgDeleteProviderAttributesResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgDeleteProviderAttributesResponseAminoMsg): MsgDeleteProviderAttributesResponse { + return MsgDeleteProviderAttributesResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgDeleteProviderAttributesResponse): MsgDeleteProviderAttributesResponseAminoMsg { + return { + type: "akash/audit/v1beta2/testonly-delete-provider-attributes-response", + value: MsgDeleteProviderAttributesResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgDeleteProviderAttributesResponseProtoMsg): MsgDeleteProviderAttributesResponse { + return MsgDeleteProviderAttributesResponse.decode(message.value); + }, + toProto(message: MsgDeleteProviderAttributesResponse): Uint8Array { + return MsgDeleteProviderAttributesResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgDeleteProviderAttributesResponse): MsgDeleteProviderAttributesResponseProtoMsg { + return { + typeUrl: "/akash.audit.v1beta2.MsgDeleteProviderAttributesResponse", + value: MsgDeleteProviderAttributesResponse.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/audit/v1beta2/genesis.ts b/__fixtures__/v-next/outputicjsdeps/akash/audit/v1beta2/genesis.ts new file mode 100644 index 0000000000..d8761d76e8 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/audit/v1beta2/genesis.ts @@ -0,0 +1,121 @@ +import { AuditedAttributes, AuditedAttributesSDKType } from "./audit.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { JsonSafe } from "../../../json-safe.js"; +import { DeepPartial, Exact } from "../../../helpers.js"; +export const protobufPackage = "akash.audit.v1beta2"; +/** GenesisState defines the basic genesis state used by audit module */ +export interface GenesisState { + attributes: AuditedAttributes[]; +} +export interface GenesisStateProtoMsg { + typeUrl: "/akash.audit.v1beta2.GenesisState"; + value: Uint8Array; +} +/** GenesisState defines the basic genesis state used by audit module */ +export interface GenesisStateSDKType { + attributes: AuditedAttributesSDKType[]; +} +function createBaseGenesisState(): GenesisState { + return { + attributes: [] + }; +} +export const GenesisState = { + typeUrl: "/akash.audit.v1beta2.GenesisState", + encode(message: GenesisState, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.attributes) { + AuditedAttributes.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GenesisState { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGenesisState(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.attributes.push(AuditedAttributes.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GenesisState { + const obj = createBaseGenesisState(); + if (Array.isArray(object?.attributes)) obj.attributes = object.attributes.map((e: any) => AuditedAttributes.fromJSON(e)); + return obj; + }, + toJSON(message: GenesisState): JsonSafe { + const obj: any = {}; + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? AuditedAttributes.toJSON(e) : undefined); + } else { + obj.attributes = []; + } + return obj; + }, + fromPartial, I>>(object: I): GenesisState { + const message = createBaseGenesisState(); + message.attributes = object.attributes?.map(e => AuditedAttributes.fromPartial(e)) || []; + return message; + }, + fromSDK(object: GenesisStateSDKType): GenesisState { + return { + attributes: Array.isArray(object?.attributes) ? object.attributes.map((e: any) => AuditedAttributes.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): GenesisStateSDKType { + return { + attributes: Array.isArray(object?.attributes) ? object.attributes.map((e: any) => AuditedAttributes.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: GenesisState): GenesisStateSDKType { + const obj: any = {}; + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? AuditedAttributes.toSDK(e) : undefined); + } else { + obj.attributes = []; + } + return obj; + }, + fromAmino(object: GenesisStateAmino): GenesisState { + const message = createBaseGenesisState(); + message.attributes = object.attributes?.map(e => AuditedAttributes.fromAmino(e)) || []; + return message; + }, + toAmino(message: GenesisState): GenesisStateAmino { + const obj: any = {}; + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? AuditedAttributes.toAmino(e) : undefined); + } else { + obj.attributes = message.attributes; + } + return obj; + }, + fromAminoMsg(object: GenesisStateAminoMsg): GenesisState { + return GenesisState.fromAmino(object.value); + }, + toAminoMsg(message: GenesisState): GenesisStateAminoMsg { + return { + type: "akash/audit/v1beta2/genesis-state", + value: GenesisState.toAmino(message) + }; + }, + fromProtoMsg(message: GenesisStateProtoMsg): GenesisState { + return GenesisState.decode(message.value); + }, + toProto(message: GenesisState): Uint8Array { + return GenesisState.encode(message).finish(); + }, + toProtoMsg(message: GenesisState): GenesisStateProtoMsg { + return { + typeUrl: "/akash.audit.v1beta2.GenesisState", + value: GenesisState.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/audit/v1beta2/query.lcd.ts b/__fixtures__/v-next/outputicjsdeps/akash/audit/v1beta2/query.lcd.ts new file mode 100644 index 0000000000..a3d3052087 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/audit/v1beta2/query.lcd.ts @@ -0,0 +1,63 @@ +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../../cosmos/base/query/v1beta1/pagination.js"; +import { Provider, ProviderSDKType } from "./audit.js"; +import { setPaginationParams } from "../../../helpers.js"; +import { LCDClient } from "@cosmology/lcd"; +import { QueryAllProvidersAttributesRequest, QueryAllProvidersAttributesRequestSDKType, QueryProvidersResponse, QueryProvidersResponseSDKType, QueryProviderAttributesRequest, QueryProviderAttributesRequestSDKType, QueryProviderAuditorRequest, QueryProviderAuditorRequestSDKType, QueryAuditorAttributesRequest, QueryAuditorAttributesRequestSDKType } from "./query.js"; +export class LCDQueryClient { + req: LCDClient; + constructor({ + requestClient + }: { + requestClient: LCDClient; + }) { + this.req = requestClient; + } + /* AllProvidersAttributes queries all providers + buf:lint:ignore RPC_REQUEST_RESPONSE_UNIQUE + buf:lint:ignore RPC_RESPONSE_STANDARD_NAME */ + allProvidersAttributes = async (params: QueryAllProvidersAttributesRequest = { + pagination: PageRequest.fromPartial({}) + }): Promise => { + const options: any = { + params: {} + }; + if (typeof params?.pagination !== "undefined") { + setPaginationParams(options, params.pagination); + } + const endpoint = `akash/audit/v1beta2/audit/attributes/list`; + return QueryProvidersResponse.fromSDKJSON(await this.req.get(endpoint, options)); + }; + /* ProviderAttributes queries all provider signed attributes + buf:lint:ignore RPC_REQUEST_RESPONSE_UNIQUE + buf:lint:ignore RPC_RESPONSE_STANDARD_NAME */ + providerAttributes = async (params: QueryProviderAttributesRequest): Promise => { + const options: any = { + params: {} + }; + if (typeof params?.pagination !== "undefined") { + setPaginationParams(options, params.pagination); + } + const endpoint = `akash/audit/v1beta2/audit/attributes/${params.owner}/list`; + return QueryProvidersResponse.fromSDKJSON(await this.req.get(endpoint, options)); + }; + /* ProviderAuditorAttributes queries provider signed attributes by specific auditor + buf:lint:ignore RPC_REQUEST_RESPONSE_UNIQUE + buf:lint:ignore RPC_RESPONSE_STANDARD_NAME */ + providerAuditorAttributes = async (params: QueryProviderAuditorRequest): Promise => { + const endpoint = `akash/audit/v1beta2/audit/attributes/${params.auditor}/${params.owner}`; + return QueryProvidersResponse.fromSDKJSON(await this.req.get(endpoint)); + }; + /* AuditorAttributes queries all providers signed by this auditor + buf:lint:ignore RPC_REQUEST_RESPONSE_UNIQUE + buf:lint:ignore RPC_RESPONSE_STANDARD_NAME */ + auditorAttributes = async (params: QueryAuditorAttributesRequest): Promise => { + const options: any = { + params: {} + }; + if (typeof params?.pagination !== "undefined") { + setPaginationParams(options, params.pagination); + } + const endpoint = `akash/provider/v1beta2/auditor/${params.auditor}/list`; + return QueryProvidersResponse.fromSDKJSON(await this.req.get(endpoint, options)); + }; +} \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/audit/v1beta2/query.rpc.Query.ts b/__fixtures__/v-next/outputicjsdeps/akash/audit/v1beta2/query.rpc.Query.ts new file mode 100644 index 0000000000..2b2e2c3db5 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/audit/v1beta2/query.rpc.Query.ts @@ -0,0 +1,91 @@ +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../../cosmos/base/query/v1beta1/pagination.js"; +import { Provider, ProviderSDKType } from "./audit.js"; +import { Rpc } from "../../../helpers.js"; +import { BinaryReader } from "../../../binary.js"; +import { QueryClient, createProtobufRpcClient } from "@cosmjs/stargate"; +import { QueryAllProvidersAttributesRequest, QueryAllProvidersAttributesRequestSDKType, QueryProvidersResponse, QueryProvidersResponseSDKType, QueryProviderAttributesRequest, QueryProviderAttributesRequestSDKType, QueryProviderAuditorRequest, QueryProviderAuditorRequestSDKType, QueryAuditorAttributesRequest, QueryAuditorAttributesRequestSDKType } from "./query.js"; +/** Query defines the gRPC querier service */ +export interface Query { + /** + * AllProvidersAttributes queries all providers + * buf:lint:ignore RPC_REQUEST_RESPONSE_UNIQUE + * buf:lint:ignore RPC_RESPONSE_STANDARD_NAME + */ + allProvidersAttributes(request?: QueryAllProvidersAttributesRequest): Promise; + /** + * ProviderAttributes queries all provider signed attributes + * buf:lint:ignore RPC_REQUEST_RESPONSE_UNIQUE + * buf:lint:ignore RPC_RESPONSE_STANDARD_NAME + */ + providerAttributes(request: QueryProviderAttributesRequest): Promise; + /** + * ProviderAuditorAttributes queries provider signed attributes by specific auditor + * buf:lint:ignore RPC_REQUEST_RESPONSE_UNIQUE + * buf:lint:ignore RPC_RESPONSE_STANDARD_NAME + */ + providerAuditorAttributes(request: QueryProviderAuditorRequest): Promise; + /** + * AuditorAttributes queries all providers signed by this auditor + * buf:lint:ignore RPC_REQUEST_RESPONSE_UNIQUE + * buf:lint:ignore RPC_RESPONSE_STANDARD_NAME + */ + auditorAttributes(request: QueryAuditorAttributesRequest): Promise; +} +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + } + /* AllProvidersAttributes queries all providers + buf:lint:ignore RPC_REQUEST_RESPONSE_UNIQUE + buf:lint:ignore RPC_RESPONSE_STANDARD_NAME */ + allProvidersAttributes = async (request: QueryAllProvidersAttributesRequest = { + pagination: PageRequest.fromPartial({}) + }): Promise => { + const data = QueryAllProvidersAttributesRequest.encode(request).finish(); + const promise = this.rpc.request("akash.audit.v1beta2.Query", "AllProvidersAttributes", data); + return promise.then(data => QueryProvidersResponse.decode(new BinaryReader(data))); + }; + /* ProviderAttributes queries all provider signed attributes + buf:lint:ignore RPC_REQUEST_RESPONSE_UNIQUE + buf:lint:ignore RPC_RESPONSE_STANDARD_NAME */ + providerAttributes = async (request: QueryProviderAttributesRequest): Promise => { + const data = QueryProviderAttributesRequest.encode(request).finish(); + const promise = this.rpc.request("akash.audit.v1beta2.Query", "ProviderAttributes", data); + return promise.then(data => QueryProvidersResponse.decode(new BinaryReader(data))); + }; + /* ProviderAuditorAttributes queries provider signed attributes by specific auditor + buf:lint:ignore RPC_REQUEST_RESPONSE_UNIQUE + buf:lint:ignore RPC_RESPONSE_STANDARD_NAME */ + providerAuditorAttributes = async (request: QueryProviderAuditorRequest): Promise => { + const data = QueryProviderAuditorRequest.encode(request).finish(); + const promise = this.rpc.request("akash.audit.v1beta2.Query", "ProviderAuditorAttributes", data); + return promise.then(data => QueryProvidersResponse.decode(new BinaryReader(data))); + }; + /* AuditorAttributes queries all providers signed by this auditor + buf:lint:ignore RPC_REQUEST_RESPONSE_UNIQUE + buf:lint:ignore RPC_RESPONSE_STANDARD_NAME */ + auditorAttributes = async (request: QueryAuditorAttributesRequest): Promise => { + const data = QueryAuditorAttributesRequest.encode(request).finish(); + const promise = this.rpc.request("akash.audit.v1beta2.Query", "AuditorAttributes", data); + return promise.then(data => QueryProvidersResponse.decode(new BinaryReader(data))); + }; +} +export const createRpcQueryExtension = (base: QueryClient) => { + const rpc = createProtobufRpcClient(base); + const queryService = new QueryClientImpl(rpc); + return { + allProvidersAttributes(request?: QueryAllProvidersAttributesRequest): Promise { + return queryService.allProvidersAttributes(request); + }, + providerAttributes(request: QueryProviderAttributesRequest): Promise { + return queryService.providerAttributes(request); + }, + providerAuditorAttributes(request: QueryProviderAuditorRequest): Promise { + return queryService.providerAuditorAttributes(request); + }, + auditorAttributes(request: QueryAuditorAttributesRequest): Promise { + return queryService.auditorAttributes(request); + } + }; +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/audit/v1beta2/query.rpc.func.ts b/__fixtures__/v-next/outputicjsdeps/akash/audit/v1beta2/query.rpc.func.ts new file mode 100644 index 0000000000..338094efb7 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/audit/v1beta2/query.rpc.func.ts @@ -0,0 +1,47 @@ +import { RpcResolver, buildQuery } from "../../../helper-func-types"; +import { buildUseQuery } from "../../../react-query"; +import { QueryAllProvidersAttributesRequest, QueryProvidersResponse, QueryProviderAttributesRequest, QueryProviderAuditorRequest, QueryAuditorAttributesRequest } from "./query"; +export const createGetAllProvidersAttributes = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryAllProvidersAttributesRequest.encode, + decode: QueryProvidersResponse.decode, + service: "akash.audit.v1beta2.Query", + method: "AllProvidersAttributes", + getRpcInstance: getRpcInstance +}); +export const useGetAllProvidersAttributes = buildUseQuery({ + builderQueryFn: createGetAllProvidersAttributes, + queryKeyPrefix: "AllProvidersAttributesQuery" +}); +export const createGetProviderAttributes = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryProviderAttributesRequest.encode, + decode: QueryProvidersResponse.decode, + service: "akash.audit.v1beta2.Query", + method: "ProviderAttributes", + getRpcInstance: getRpcInstance +}); +export const useGetProviderAttributes = buildUseQuery({ + builderQueryFn: createGetProviderAttributes, + queryKeyPrefix: "ProviderAttributesQuery" +}); +export const createGetProviderAuditorAttributes = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryProviderAuditorRequest.encode, + decode: QueryProvidersResponse.decode, + service: "akash.audit.v1beta2.Query", + method: "ProviderAuditorAttributes", + getRpcInstance: getRpcInstance +}); +export const useGetProviderAuditorAttributes = buildUseQuery({ + builderQueryFn: createGetProviderAuditorAttributes, + queryKeyPrefix: "ProviderAuditorAttributesQuery" +}); +export const createGetAuditorAttributes = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryAuditorAttributesRequest.encode, + decode: QueryProvidersResponse.decode, + service: "akash.audit.v1beta2.Query", + method: "AuditorAttributes", + getRpcInstance: getRpcInstance +}); +export const useGetAuditorAttributes = buildUseQuery({ + builderQueryFn: createGetAuditorAttributes, + queryKeyPrefix: "AuditorAttributesQuery" +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/audit/v1beta2/query.ts b/__fixtures__/v-next/outputicjsdeps/akash/audit/v1beta2/query.ts new file mode 100644 index 0000000000..0610b399f4 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/audit/v1beta2/query.ts @@ -0,0 +1,755 @@ +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../../cosmos/base/query/v1beta1/pagination.js"; +import { Provider, ProviderSDKType } from "./audit.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial, Exact } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "akash.audit.v1beta2"; +/** QueryProvidersResponse is response type for the Query/Providers RPC method */ +export interface QueryProvidersResponse { + providers: Provider[]; + pagination?: PageResponse; +} +export interface QueryProvidersResponseProtoMsg { + typeUrl: "/akash.audit.v1beta2.QueryProvidersResponse"; + value: Uint8Array; +} +/** QueryProvidersResponse is response type for the Query/Providers RPC method */ +export interface QueryProvidersResponseSDKType { + providers: ProviderSDKType[]; + pagination?: PageResponseSDKType; +} +/** QueryProviderRequest is request type for the Query/Provider RPC method */ +export interface QueryProviderRequest { + auditor: string; + owner: string; +} +export interface QueryProviderRequestProtoMsg { + typeUrl: "/akash.audit.v1beta2.QueryProviderRequest"; + value: Uint8Array; +} +/** QueryProviderRequest is request type for the Query/Provider RPC method */ +export interface QueryProviderRequestSDKType { + auditor: string; + owner: string; +} +/** QueryAllProvidersAttributesRequest is request type for the Query/All Providers RPC method */ +export interface QueryAllProvidersAttributesRequest { + pagination?: PageRequest; +} +export interface QueryAllProvidersAttributesRequestProtoMsg { + typeUrl: "/akash.audit.v1beta2.QueryAllProvidersAttributesRequest"; + value: Uint8Array; +} +/** QueryAllProvidersAttributesRequest is request type for the Query/All Providers RPC method */ +export interface QueryAllProvidersAttributesRequestSDKType { + pagination?: PageRequestSDKType; +} +/** QueryProviderAttributesRequest is request type for the Query/Provider RPC method */ +export interface QueryProviderAttributesRequest { + owner: string; + pagination?: PageRequest; +} +export interface QueryProviderAttributesRequestProtoMsg { + typeUrl: "/akash.audit.v1beta2.QueryProviderAttributesRequest"; + value: Uint8Array; +} +/** QueryProviderAttributesRequest is request type for the Query/Provider RPC method */ +export interface QueryProviderAttributesRequestSDKType { + owner: string; + pagination?: PageRequestSDKType; +} +/** QueryProviderAuditorRequest is request type for the Query/Providers RPC method */ +export interface QueryProviderAuditorRequest { + auditor: string; + owner: string; +} +export interface QueryProviderAuditorRequestProtoMsg { + typeUrl: "/akash.audit.v1beta2.QueryProviderAuditorRequest"; + value: Uint8Array; +} +/** QueryProviderAuditorRequest is request type for the Query/Providers RPC method */ +export interface QueryProviderAuditorRequestSDKType { + auditor: string; + owner: string; +} +/** QueryAuditorAttributesRequest is request type for the Query/Providers RPC method */ +export interface QueryAuditorAttributesRequest { + auditor: string; + pagination?: PageRequest; +} +export interface QueryAuditorAttributesRequestProtoMsg { + typeUrl: "/akash.audit.v1beta2.QueryAuditorAttributesRequest"; + value: Uint8Array; +} +/** QueryAuditorAttributesRequest is request type for the Query/Providers RPC method */ +export interface QueryAuditorAttributesRequestSDKType { + auditor: string; + pagination?: PageRequestSDKType; +} +function createBaseQueryProvidersResponse(): QueryProvidersResponse { + return { + providers: [], + pagination: undefined + }; +} +export const QueryProvidersResponse = { + typeUrl: "/akash.audit.v1beta2.QueryProvidersResponse", + encode(message: QueryProvidersResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.providers) { + Provider.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryProvidersResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryProvidersResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.providers.push(Provider.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryProvidersResponse { + const obj = createBaseQueryProvidersResponse(); + if (Array.isArray(object?.providers)) obj.providers = object.providers.map((e: any) => Provider.fromJSON(e)); + if (isSet(object.pagination)) obj.pagination = PageResponse.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryProvidersResponse): JsonSafe { + const obj: any = {}; + if (message.providers) { + obj.providers = message.providers.map(e => e ? Provider.toJSON(e) : undefined); + } else { + obj.providers = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryProvidersResponse { + const message = createBaseQueryProvidersResponse(); + message.providers = object.providers?.map(e => Provider.fromPartial(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryProvidersResponseSDKType): QueryProvidersResponse { + return { + providers: Array.isArray(object?.providers) ? object.providers.map((e: any) => Provider.fromSDK(e)) : [], + pagination: object.pagination ? PageResponse.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryProvidersResponseSDKType { + return { + providers: Array.isArray(object?.providers) ? object.providers.map((e: any) => Provider.fromSDKJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryProvidersResponse): QueryProvidersResponseSDKType { + const obj: any = {}; + if (message.providers) { + obj.providers = message.providers.map(e => e ? Provider.toSDK(e) : undefined); + } else { + obj.providers = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryProvidersResponseAmino): QueryProvidersResponse { + const message = createBaseQueryProvidersResponse(); + message.providers = object.providers?.map(e => Provider.fromAmino(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryProvidersResponse): QueryProvidersResponseAmino { + const obj: any = {}; + if (message.providers) { + obj.providers = message.providers.map(e => e ? Provider.toAmino(e) : undefined); + } else { + obj.providers = message.providers; + } + obj.pagination = message.pagination ? PageResponse.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryProvidersResponseAminoMsg): QueryProvidersResponse { + return QueryProvidersResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryProvidersResponse): QueryProvidersResponseAminoMsg { + return { + type: "akash/audit/v1beta2/query-providers-response", + value: QueryProvidersResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryProvidersResponseProtoMsg): QueryProvidersResponse { + return QueryProvidersResponse.decode(message.value); + }, + toProto(message: QueryProvidersResponse): Uint8Array { + return QueryProvidersResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryProvidersResponse): QueryProvidersResponseProtoMsg { + return { + typeUrl: "/akash.audit.v1beta2.QueryProvidersResponse", + value: QueryProvidersResponse.encode(message).finish() + }; + } +}; +function createBaseQueryProviderRequest(): QueryProviderRequest { + return { + auditor: "", + owner: "" + }; +} +export const QueryProviderRequest = { + typeUrl: "/akash.audit.v1beta2.QueryProviderRequest", + encode(message: QueryProviderRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.auditor !== undefined) { + writer.uint32(10).string(message.auditor); + } + if (message.owner !== undefined) { + writer.uint32(18).string(message.owner); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryProviderRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryProviderRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.auditor = reader.string(); + break; + case 2: + message.owner = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryProviderRequest { + const obj = createBaseQueryProviderRequest(); + if (isSet(object.auditor)) obj.auditor = String(object.auditor); + if (isSet(object.owner)) obj.owner = String(object.owner); + return obj; + }, + toJSON(message: QueryProviderRequest): JsonSafe { + const obj: any = {}; + message.auditor !== undefined && (obj.auditor = message.auditor); + message.owner !== undefined && (obj.owner = message.owner); + return obj; + }, + fromPartial, I>>(object: I): QueryProviderRequest { + const message = createBaseQueryProviderRequest(); + message.auditor = object.auditor ?? ""; + message.owner = object.owner ?? ""; + return message; + }, + fromSDK(object: QueryProviderRequestSDKType): QueryProviderRequest { + return { + auditor: object?.auditor, + owner: object?.owner + }; + }, + fromSDKJSON(object: any): QueryProviderRequestSDKType { + return { + auditor: isSet(object.auditor) ? String(object.auditor) : "", + owner: isSet(object.owner) ? String(object.owner) : "" + }; + }, + toSDK(message: QueryProviderRequest): QueryProviderRequestSDKType { + const obj: any = {}; + obj.auditor = message.auditor; + obj.owner = message.owner; + return obj; + }, + fromAmino(object: QueryProviderRequestAmino): QueryProviderRequest { + const message = createBaseQueryProviderRequest(); + if (object.auditor !== undefined && object.auditor !== null) { + message.auditor = object.auditor; + } + if (object.owner !== undefined && object.owner !== null) { + message.owner = object.owner; + } + return message; + }, + toAmino(message: QueryProviderRequest): QueryProviderRequestAmino { + const obj: any = {}; + obj.auditor = message.auditor === "" ? undefined : message.auditor; + obj.owner = message.owner === "" ? undefined : message.owner; + return obj; + }, + fromAminoMsg(object: QueryProviderRequestAminoMsg): QueryProviderRequest { + return QueryProviderRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryProviderRequest): QueryProviderRequestAminoMsg { + return { + type: "akash/audit/v1beta2/query-provider-request", + value: QueryProviderRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryProviderRequestProtoMsg): QueryProviderRequest { + return QueryProviderRequest.decode(message.value); + }, + toProto(message: QueryProviderRequest): Uint8Array { + return QueryProviderRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryProviderRequest): QueryProviderRequestProtoMsg { + return { + typeUrl: "/akash.audit.v1beta2.QueryProviderRequest", + value: QueryProviderRequest.encode(message).finish() + }; + } +}; +function createBaseQueryAllProvidersAttributesRequest(): QueryAllProvidersAttributesRequest { + return { + pagination: undefined + }; +} +export const QueryAllProvidersAttributesRequest = { + typeUrl: "/akash.audit.v1beta2.QueryAllProvidersAttributesRequest", + encode(message: QueryAllProvidersAttributesRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryAllProvidersAttributesRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryAllProvidersAttributesRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryAllProvidersAttributesRequest { + const obj = createBaseQueryAllProvidersAttributesRequest(); + if (isSet(object.pagination)) obj.pagination = PageRequest.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryAllProvidersAttributesRequest): JsonSafe { + const obj: any = {}; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryAllProvidersAttributesRequest { + const message = createBaseQueryAllProvidersAttributesRequest(); + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryAllProvidersAttributesRequestSDKType): QueryAllProvidersAttributesRequest { + return { + pagination: object.pagination ? PageRequest.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryAllProvidersAttributesRequestSDKType { + return { + pagination: isSet(object.pagination) ? PageRequest.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryAllProvidersAttributesRequest): QueryAllProvidersAttributesRequestSDKType { + const obj: any = {}; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryAllProvidersAttributesRequestAmino): QueryAllProvidersAttributesRequest { + const message = createBaseQueryAllProvidersAttributesRequest(); + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryAllProvidersAttributesRequest): QueryAllProvidersAttributesRequestAmino { + const obj: any = {}; + obj.pagination = message.pagination ? PageRequest.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryAllProvidersAttributesRequestAminoMsg): QueryAllProvidersAttributesRequest { + return QueryAllProvidersAttributesRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryAllProvidersAttributesRequest): QueryAllProvidersAttributesRequestAminoMsg { + return { + type: "akash/audit/v1beta2/query-all-providers-attributes-request", + value: QueryAllProvidersAttributesRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryAllProvidersAttributesRequestProtoMsg): QueryAllProvidersAttributesRequest { + return QueryAllProvidersAttributesRequest.decode(message.value); + }, + toProto(message: QueryAllProvidersAttributesRequest): Uint8Array { + return QueryAllProvidersAttributesRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryAllProvidersAttributesRequest): QueryAllProvidersAttributesRequestProtoMsg { + return { + typeUrl: "/akash.audit.v1beta2.QueryAllProvidersAttributesRequest", + value: QueryAllProvidersAttributesRequest.encode(message).finish() + }; + } +}; +function createBaseQueryProviderAttributesRequest(): QueryProviderAttributesRequest { + return { + owner: "", + pagination: undefined + }; +} +export const QueryProviderAttributesRequest = { + typeUrl: "/akash.audit.v1beta2.QueryProviderAttributesRequest", + encode(message: QueryProviderAttributesRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.owner !== undefined) { + writer.uint32(10).string(message.owner); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryProviderAttributesRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryProviderAttributesRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.owner = reader.string(); + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryProviderAttributesRequest { + const obj = createBaseQueryProviderAttributesRequest(); + if (isSet(object.owner)) obj.owner = String(object.owner); + if (isSet(object.pagination)) obj.pagination = PageRequest.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryProviderAttributesRequest): JsonSafe { + const obj: any = {}; + message.owner !== undefined && (obj.owner = message.owner); + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryProviderAttributesRequest { + const message = createBaseQueryProviderAttributesRequest(); + message.owner = object.owner ?? ""; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryProviderAttributesRequestSDKType): QueryProviderAttributesRequest { + return { + owner: object?.owner, + pagination: object.pagination ? PageRequest.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryProviderAttributesRequestSDKType { + return { + owner: isSet(object.owner) ? String(object.owner) : "", + pagination: isSet(object.pagination) ? PageRequest.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryProviderAttributesRequest): QueryProviderAttributesRequestSDKType { + const obj: any = {}; + obj.owner = message.owner; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryProviderAttributesRequestAmino): QueryProviderAttributesRequest { + const message = createBaseQueryProviderAttributesRequest(); + if (object.owner !== undefined && object.owner !== null) { + message.owner = object.owner; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryProviderAttributesRequest): QueryProviderAttributesRequestAmino { + const obj: any = {}; + obj.owner = message.owner === "" ? undefined : message.owner; + obj.pagination = message.pagination ? PageRequest.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryProviderAttributesRequestAminoMsg): QueryProviderAttributesRequest { + return QueryProviderAttributesRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryProviderAttributesRequest): QueryProviderAttributesRequestAminoMsg { + return { + type: "akash/audit/v1beta2/query-provider-attributes-request", + value: QueryProviderAttributesRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryProviderAttributesRequestProtoMsg): QueryProviderAttributesRequest { + return QueryProviderAttributesRequest.decode(message.value); + }, + toProto(message: QueryProviderAttributesRequest): Uint8Array { + return QueryProviderAttributesRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryProviderAttributesRequest): QueryProviderAttributesRequestProtoMsg { + return { + typeUrl: "/akash.audit.v1beta2.QueryProviderAttributesRequest", + value: QueryProviderAttributesRequest.encode(message).finish() + }; + } +}; +function createBaseQueryProviderAuditorRequest(): QueryProviderAuditorRequest { + return { + auditor: "", + owner: "" + }; +} +export const QueryProviderAuditorRequest = { + typeUrl: "/akash.audit.v1beta2.QueryProviderAuditorRequest", + encode(message: QueryProviderAuditorRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.auditor !== undefined) { + writer.uint32(10).string(message.auditor); + } + if (message.owner !== undefined) { + writer.uint32(18).string(message.owner); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryProviderAuditorRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryProviderAuditorRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.auditor = reader.string(); + break; + case 2: + message.owner = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryProviderAuditorRequest { + const obj = createBaseQueryProviderAuditorRequest(); + if (isSet(object.auditor)) obj.auditor = String(object.auditor); + if (isSet(object.owner)) obj.owner = String(object.owner); + return obj; + }, + toJSON(message: QueryProviderAuditorRequest): JsonSafe { + const obj: any = {}; + message.auditor !== undefined && (obj.auditor = message.auditor); + message.owner !== undefined && (obj.owner = message.owner); + return obj; + }, + fromPartial, I>>(object: I): QueryProviderAuditorRequest { + const message = createBaseQueryProviderAuditorRequest(); + message.auditor = object.auditor ?? ""; + message.owner = object.owner ?? ""; + return message; + }, + fromSDK(object: QueryProviderAuditorRequestSDKType): QueryProviderAuditorRequest { + return { + auditor: object?.auditor, + owner: object?.owner + }; + }, + fromSDKJSON(object: any): QueryProviderAuditorRequestSDKType { + return { + auditor: isSet(object.auditor) ? String(object.auditor) : "", + owner: isSet(object.owner) ? String(object.owner) : "" + }; + }, + toSDK(message: QueryProviderAuditorRequest): QueryProviderAuditorRequestSDKType { + const obj: any = {}; + obj.auditor = message.auditor; + obj.owner = message.owner; + return obj; + }, + fromAmino(object: QueryProviderAuditorRequestAmino): QueryProviderAuditorRequest { + const message = createBaseQueryProviderAuditorRequest(); + if (object.auditor !== undefined && object.auditor !== null) { + message.auditor = object.auditor; + } + if (object.owner !== undefined && object.owner !== null) { + message.owner = object.owner; + } + return message; + }, + toAmino(message: QueryProviderAuditorRequest): QueryProviderAuditorRequestAmino { + const obj: any = {}; + obj.auditor = message.auditor === "" ? undefined : message.auditor; + obj.owner = message.owner === "" ? undefined : message.owner; + return obj; + }, + fromAminoMsg(object: QueryProviderAuditorRequestAminoMsg): QueryProviderAuditorRequest { + return QueryProviderAuditorRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryProviderAuditorRequest): QueryProviderAuditorRequestAminoMsg { + return { + type: "akash/audit/v1beta2/query-provider-auditor-request", + value: QueryProviderAuditorRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryProviderAuditorRequestProtoMsg): QueryProviderAuditorRequest { + return QueryProviderAuditorRequest.decode(message.value); + }, + toProto(message: QueryProviderAuditorRequest): Uint8Array { + return QueryProviderAuditorRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryProviderAuditorRequest): QueryProviderAuditorRequestProtoMsg { + return { + typeUrl: "/akash.audit.v1beta2.QueryProviderAuditorRequest", + value: QueryProviderAuditorRequest.encode(message).finish() + }; + } +}; +function createBaseQueryAuditorAttributesRequest(): QueryAuditorAttributesRequest { + return { + auditor: "", + pagination: undefined + }; +} +export const QueryAuditorAttributesRequest = { + typeUrl: "/akash.audit.v1beta2.QueryAuditorAttributesRequest", + encode(message: QueryAuditorAttributesRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.auditor !== undefined) { + writer.uint32(10).string(message.auditor); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryAuditorAttributesRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryAuditorAttributesRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.auditor = reader.string(); + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryAuditorAttributesRequest { + const obj = createBaseQueryAuditorAttributesRequest(); + if (isSet(object.auditor)) obj.auditor = String(object.auditor); + if (isSet(object.pagination)) obj.pagination = PageRequest.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryAuditorAttributesRequest): JsonSafe { + const obj: any = {}; + message.auditor !== undefined && (obj.auditor = message.auditor); + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryAuditorAttributesRequest { + const message = createBaseQueryAuditorAttributesRequest(); + message.auditor = object.auditor ?? ""; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryAuditorAttributesRequestSDKType): QueryAuditorAttributesRequest { + return { + auditor: object?.auditor, + pagination: object.pagination ? PageRequest.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryAuditorAttributesRequestSDKType { + return { + auditor: isSet(object.auditor) ? String(object.auditor) : "", + pagination: isSet(object.pagination) ? PageRequest.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryAuditorAttributesRequest): QueryAuditorAttributesRequestSDKType { + const obj: any = {}; + obj.auditor = message.auditor; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryAuditorAttributesRequestAmino): QueryAuditorAttributesRequest { + const message = createBaseQueryAuditorAttributesRequest(); + if (object.auditor !== undefined && object.auditor !== null) { + message.auditor = object.auditor; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryAuditorAttributesRequest): QueryAuditorAttributesRequestAmino { + const obj: any = {}; + obj.auditor = message.auditor === "" ? undefined : message.auditor; + obj.pagination = message.pagination ? PageRequest.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryAuditorAttributesRequestAminoMsg): QueryAuditorAttributesRequest { + return QueryAuditorAttributesRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryAuditorAttributesRequest): QueryAuditorAttributesRequestAminoMsg { + return { + type: "akash/audit/v1beta2/query-auditor-attributes-request", + value: QueryAuditorAttributesRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryAuditorAttributesRequestProtoMsg): QueryAuditorAttributesRequest { + return QueryAuditorAttributesRequest.decode(message.value); + }, + toProto(message: QueryAuditorAttributesRequest): Uint8Array { + return QueryAuditorAttributesRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryAuditorAttributesRequest): QueryAuditorAttributesRequestProtoMsg { + return { + typeUrl: "/akash.audit.v1beta2.QueryAuditorAttributesRequest", + value: QueryAuditorAttributesRequest.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/base/v1beta1/attribute.ts b/__fixtures__/v-next/outputicjsdeps/akash/base/v1beta1/attribute.ts new file mode 100644 index 0000000000..631a835c33 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/base/v1beta1/attribute.ts @@ -0,0 +1,425 @@ +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial, Exact } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "akash.base.v1beta1"; +/** Attribute represents key value pair */ +export interface Attribute { + key: string; + value: string; +} +export interface AttributeProtoMsg { + typeUrl: "/akash.base.v1beta1.Attribute"; + value: Uint8Array; +} +/** Attribute represents key value pair */ +export interface AttributeSDKType { + key: string; + value: string; +} +/** + * SignedBy represents validation accounts that tenant expects signatures for provider attributes + * AllOf has precedence i.e. if there is at least one entry AnyOf is ignored regardless to how many + * entries there + * this behaviour to be discussed + */ +export interface SignedBy { + /** all_of all keys in this list must have signed attributes */ + allOf: string[]; + /** any_of at least of of the keys from the list must have signed attributes */ + anyOf: string[]; +} +export interface SignedByProtoMsg { + typeUrl: "/akash.base.v1beta1.SignedBy"; + value: Uint8Array; +} +/** + * SignedBy represents validation accounts that tenant expects signatures for provider attributes + * AllOf has precedence i.e. if there is at least one entry AnyOf is ignored regardless to how many + * entries there + * this behaviour to be discussed + */ +export interface SignedBySDKType { + all_of: string[]; + any_of: string[]; +} +/** PlacementRequirements */ +export interface PlacementRequirements { + /** SignedBy list of keys that tenants expect to have signatures from */ + signedBy: SignedBy; + /** Attribute list of attributes tenant expects from the provider */ + attributes: Attribute[]; +} +export interface PlacementRequirementsProtoMsg { + typeUrl: "/akash.base.v1beta1.PlacementRequirements"; + value: Uint8Array; +} +/** PlacementRequirements */ +export interface PlacementRequirementsSDKType { + signed_by: SignedBySDKType; + attributes: AttributeSDKType[]; +} +function createBaseAttribute(): Attribute { + return { + key: "", + value: "" + }; +} +export const Attribute = { + typeUrl: "/akash.base.v1beta1.Attribute", + encode(message: Attribute, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.key !== undefined) { + writer.uint32(10).string(message.key); + } + if (message.value !== undefined) { + writer.uint32(18).string(message.value); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Attribute { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseAttribute(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.string(); + break; + case 2: + message.value = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Attribute { + const obj = createBaseAttribute(); + if (isSet(object.key)) obj.key = String(object.key); + if (isSet(object.value)) obj.value = String(object.value); + return obj; + }, + toJSON(message: Attribute): JsonSafe { + const obj: any = {}; + message.key !== undefined && (obj.key = message.key); + message.value !== undefined && (obj.value = message.value); + return obj; + }, + fromPartial, I>>(object: I): Attribute { + const message = createBaseAttribute(); + message.key = object.key ?? ""; + message.value = object.value ?? ""; + return message; + }, + fromSDK(object: AttributeSDKType): Attribute { + return { + key: object?.key, + value: object?.value + }; + }, + fromSDKJSON(object: any): AttributeSDKType { + return { + key: isSet(object.key) ? String(object.key) : "", + value: isSet(object.value) ? String(object.value) : "" + }; + }, + toSDK(message: Attribute): AttributeSDKType { + const obj: any = {}; + obj.key = message.key; + obj.value = message.value; + return obj; + }, + fromAmino(object: AttributeAmino): Attribute { + const message = createBaseAttribute(); + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } + if (object.value !== undefined && object.value !== null) { + message.value = object.value; + } + return message; + }, + toAmino(message: Attribute): AttributeAmino { + const obj: any = {}; + obj.key = message.key === "" ? undefined : message.key; + obj.value = message.value === "" ? undefined : message.value; + return obj; + }, + fromAminoMsg(object: AttributeAminoMsg): Attribute { + return Attribute.fromAmino(object.value); + }, + toAminoMsg(message: Attribute): AttributeAminoMsg { + return { + type: "akash/base/attribute", + value: Attribute.toAmino(message) + }; + }, + fromProtoMsg(message: AttributeProtoMsg): Attribute { + return Attribute.decode(message.value); + }, + toProto(message: Attribute): Uint8Array { + return Attribute.encode(message).finish(); + }, + toProtoMsg(message: Attribute): AttributeProtoMsg { + return { + typeUrl: "/akash.base.v1beta1.Attribute", + value: Attribute.encode(message).finish() + }; + } +}; +function createBaseSignedBy(): SignedBy { + return { + allOf: [], + anyOf: [] + }; +} +export const SignedBy = { + typeUrl: "/akash.base.v1beta1.SignedBy", + encode(message: SignedBy, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.allOf) { + writer.uint32(10).string(v!); + } + for (const v of message.anyOf) { + writer.uint32(18).string(v!); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): SignedBy { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseSignedBy(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.allOf.push(reader.string()); + break; + case 2: + message.anyOf.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): SignedBy { + const obj = createBaseSignedBy(); + if (Array.isArray(object?.allOf)) obj.allOf = object.allOf.map((e: any) => String(e)); + if (Array.isArray(object?.anyOf)) obj.anyOf = object.anyOf.map((e: any) => String(e)); + return obj; + }, + toJSON(message: SignedBy): JsonSafe { + const obj: any = {}; + if (message.allOf) { + obj.allOf = message.allOf.map(e => e); + } else { + obj.allOf = []; + } + if (message.anyOf) { + obj.anyOf = message.anyOf.map(e => e); + } else { + obj.anyOf = []; + } + return obj; + }, + fromPartial, I>>(object: I): SignedBy { + const message = createBaseSignedBy(); + message.allOf = object.allOf?.map(e => e) || []; + message.anyOf = object.anyOf?.map(e => e) || []; + return message; + }, + fromSDK(object: SignedBySDKType): SignedBy { + return { + allOf: Array.isArray(object?.all_of) ? object.all_of.map((e: any) => e) : [], + anyOf: Array.isArray(object?.any_of) ? object.any_of.map((e: any) => e) : [] + }; + }, + fromSDKJSON(object: any): SignedBySDKType { + return { + all_of: Array.isArray(object?.all_of) ? object.all_of.map((e: any) => String(e)) : [], + any_of: Array.isArray(object?.any_of) ? object.any_of.map((e: any) => String(e)) : [] + }; + }, + toSDK(message: SignedBy): SignedBySDKType { + const obj: any = {}; + if (message.allOf) { + obj.all_of = message.allOf.map(e => e); + } else { + obj.all_of = []; + } + if (message.anyOf) { + obj.any_of = message.anyOf.map(e => e); + } else { + obj.any_of = []; + } + return obj; + }, + fromAmino(object: SignedByAmino): SignedBy { + const message = createBaseSignedBy(); + message.allOf = object.all_of?.map(e => e) || []; + message.anyOf = object.any_of?.map(e => e) || []; + return message; + }, + toAmino(message: SignedBy): SignedByAmino { + const obj: any = {}; + if (message.allOf) { + obj.all_of = message.allOf.map(e => e); + } else { + obj.all_of = message.allOf; + } + if (message.anyOf) { + obj.any_of = message.anyOf.map(e => e); + } else { + obj.any_of = message.anyOf; + } + return obj; + }, + fromAminoMsg(object: SignedByAminoMsg): SignedBy { + return SignedBy.fromAmino(object.value); + }, + toAminoMsg(message: SignedBy): SignedByAminoMsg { + return { + type: "akash/base/signed-by", + value: SignedBy.toAmino(message) + }; + }, + fromProtoMsg(message: SignedByProtoMsg): SignedBy { + return SignedBy.decode(message.value); + }, + toProto(message: SignedBy): Uint8Array { + return SignedBy.encode(message).finish(); + }, + toProtoMsg(message: SignedBy): SignedByProtoMsg { + return { + typeUrl: "/akash.base.v1beta1.SignedBy", + value: SignedBy.encode(message).finish() + }; + } +}; +function createBasePlacementRequirements(): PlacementRequirements { + return { + signedBy: SignedBy.fromPartial({}), + attributes: [] + }; +} +export const PlacementRequirements = { + typeUrl: "/akash.base.v1beta1.PlacementRequirements", + encode(message: PlacementRequirements, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.signedBy !== undefined) { + SignedBy.encode(message.signedBy, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.attributes) { + Attribute.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): PlacementRequirements { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBasePlacementRequirements(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.signedBy = SignedBy.decode(reader, reader.uint32()); + break; + case 2: + message.attributes.push(Attribute.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): PlacementRequirements { + const obj = createBasePlacementRequirements(); + if (isSet(object.signedBy)) obj.signedBy = SignedBy.fromJSON(object.signedBy); + if (Array.isArray(object?.attributes)) obj.attributes = object.attributes.map((e: any) => Attribute.fromJSON(e)); + return obj; + }, + toJSON(message: PlacementRequirements): JsonSafe { + const obj: any = {}; + message.signedBy !== undefined && (obj.signedBy = message.signedBy ? SignedBy.toJSON(message.signedBy) : undefined); + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? Attribute.toJSON(e) : undefined); + } else { + obj.attributes = []; + } + return obj; + }, + fromPartial, I>>(object: I): PlacementRequirements { + const message = createBasePlacementRequirements(); + if (object.signedBy !== undefined && object.signedBy !== null) { + message.signedBy = SignedBy.fromPartial(object.signedBy); + } + message.attributes = object.attributes?.map(e => Attribute.fromPartial(e)) || []; + return message; + }, + fromSDK(object: PlacementRequirementsSDKType): PlacementRequirements { + return { + signedBy: object.signed_by ? SignedBy.fromSDK(object.signed_by) : undefined, + attributes: Array.isArray(object?.attributes) ? object.attributes.map((e: any) => Attribute.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): PlacementRequirementsSDKType { + return { + signed_by: isSet(object.signed_by) ? SignedBy.fromSDKJSON(object.signed_by) : undefined, + attributes: Array.isArray(object?.attributes) ? object.attributes.map((e: any) => Attribute.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: PlacementRequirements): PlacementRequirementsSDKType { + const obj: any = {}; + message.signedBy !== undefined && (obj.signed_by = message.signedBy ? SignedBy.toSDK(message.signedBy) : undefined); + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? Attribute.toSDK(e) : undefined); + } else { + obj.attributes = []; + } + return obj; + }, + fromAmino(object: PlacementRequirementsAmino): PlacementRequirements { + const message = createBasePlacementRequirements(); + if (object.signed_by !== undefined && object.signed_by !== null) { + message.signedBy = SignedBy.fromAmino(object.signed_by); + } + message.attributes = object.attributes?.map(e => Attribute.fromAmino(e)) || []; + return message; + }, + toAmino(message: PlacementRequirements): PlacementRequirementsAmino { + const obj: any = {}; + obj.signed_by = message.signedBy ? SignedBy.toAmino(message.signedBy) : SignedBy.toAmino(SignedBy.fromPartial({})); + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? Attribute.toAmino(e) : undefined); + } else { + obj.attributes = message.attributes; + } + return obj; + }, + fromAminoMsg(object: PlacementRequirementsAminoMsg): PlacementRequirements { + return PlacementRequirements.fromAmino(object.value); + }, + toAminoMsg(message: PlacementRequirements): PlacementRequirementsAminoMsg { + return { + type: "akash/base/placement-requirements", + value: PlacementRequirements.toAmino(message) + }; + }, + fromProtoMsg(message: PlacementRequirementsProtoMsg): PlacementRequirements { + return PlacementRequirements.decode(message.value); + }, + toProto(message: PlacementRequirements): Uint8Array { + return PlacementRequirements.encode(message).finish(); + }, + toProtoMsg(message: PlacementRequirements): PlacementRequirementsProtoMsg { + return { + typeUrl: "/akash.base.v1beta1.PlacementRequirements", + value: PlacementRequirements.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/base/v1beta1/endpoint.ts b/__fixtures__/v-next/outputicjsdeps/akash/base/v1beta1/endpoint.ts new file mode 100644 index 0000000000..46d46f2d6c --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/base/v1beta1/endpoint.ts @@ -0,0 +1,144 @@ +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial, Exact } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "akash.base.v1beta1"; +/** This describes how the endpoint is implemented when the lease is deployed */ +export enum Endpoint_Kind { + /** SHARED_HTTP - Describes an endpoint that becomes a Kubernetes Ingress */ + SHARED_HTTP = 0, + /** RANDOM_PORT - Describes an endpoint that becomes a Kubernetes NodePort */ + RANDOM_PORT = 1, + UNRECOGNIZED = -1, +} +export const Endpoint_KindSDKType = Endpoint_Kind; +export function endpoint_KindFromJSON(object: any): Endpoint_Kind { + switch (object) { + case 0: + case "SHARED_HTTP": + return Endpoint_Kind.SHARED_HTTP; + case 1: + case "RANDOM_PORT": + return Endpoint_Kind.RANDOM_PORT; + case -1: + case "UNRECOGNIZED": + default: + return Endpoint_Kind.UNRECOGNIZED; + } +} +export function endpoint_KindToJSON(object: Endpoint_Kind): string { + switch (object) { + case Endpoint_Kind.SHARED_HTTP: + return "SHARED_HTTP"; + case Endpoint_Kind.RANDOM_PORT: + return "RANDOM_PORT"; + case Endpoint_Kind.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** Endpoint describes a publicly accessible IP service */ +export interface Endpoint { + kind: Endpoint_Kind; +} +export interface EndpointProtoMsg { + typeUrl: "/akash.base.v1beta1.Endpoint"; + value: Uint8Array; +} +/** Endpoint describes a publicly accessible IP service */ +export interface EndpointSDKType { + kind: Endpoint_Kind; +} +function createBaseEndpoint(): Endpoint { + return { + kind: 0 + }; +} +export const Endpoint = { + typeUrl: "/akash.base.v1beta1.Endpoint", + encode(message: Endpoint, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.kind !== 0) { + writer.uint32(8).int32(message.kind); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Endpoint { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseEndpoint(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.kind = (reader.int32() as any); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Endpoint { + const obj = createBaseEndpoint(); + if (isSet(object.kind)) obj.kind = endpoint_KindFromJSON(object.kind); + return obj; + }, + toJSON(message: Endpoint): JsonSafe { + const obj: any = {}; + message.kind !== undefined && (obj.kind = endpoint_KindToJSON(message.kind)); + return obj; + }, + fromPartial, I>>(object: I): Endpoint { + const message = createBaseEndpoint(); + message.kind = object.kind ?? 0; + return message; + }, + fromSDK(object: EndpointSDKType): Endpoint { + return { + kind: isSet(object.kind) ? endpoint_KindFromJSON(object.kind) : -1 + }; + }, + fromSDKJSON(object: any): EndpointSDKType { + return { + kind: isSet(object.kind) ? endpoint_KindFromJSON(object.kind) : -1 + }; + }, + toSDK(message: Endpoint): EndpointSDKType { + const obj: any = {}; + message.kind !== undefined && (obj.kind = endpoint_KindToJSON(message.kind)); + return obj; + }, + fromAmino(object: EndpointAmino): Endpoint { + const message = createBaseEndpoint(); + if (object.kind !== undefined && object.kind !== null) { + message.kind = object.kind; + } + return message; + }, + toAmino(message: Endpoint): EndpointAmino { + const obj: any = {}; + obj.kind = message.kind === 0 ? undefined : message.kind; + return obj; + }, + fromAminoMsg(object: EndpointAminoMsg): Endpoint { + return Endpoint.fromAmino(object.value); + }, + toAminoMsg(message: Endpoint): EndpointAminoMsg { + return { + type: "akash/base/endpoint", + value: Endpoint.toAmino(message) + }; + }, + fromProtoMsg(message: EndpointProtoMsg): Endpoint { + return Endpoint.decode(message.value); + }, + toProto(message: Endpoint): Uint8Array { + return Endpoint.encode(message).finish(); + }, + toProtoMsg(message: Endpoint): EndpointProtoMsg { + return { + typeUrl: "/akash.base.v1beta1.Endpoint", + value: Endpoint.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/base/v1beta1/resource.ts b/__fixtures__/v-next/outputicjsdeps/akash/base/v1beta1/resource.ts new file mode 100644 index 0000000000..edcfb36d7f --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/base/v1beta1/resource.ts @@ -0,0 +1,603 @@ +import { ResourceValue, ResourceValueSDKType } from "./resourcevalue.js"; +import { Attribute, AttributeSDKType } from "./attribute.js"; +import { Endpoint, EndpointSDKType } from "./endpoint.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial, Exact } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "akash.base.v1beta1"; +/** CPU stores resource units and cpu config attributes */ +export interface CPU { + units: ResourceValue; + attributes: Attribute[]; +} +export interface CPUProtoMsg { + typeUrl: "/akash.base.v1beta1.CPU"; + value: Uint8Array; +} +/** CPU stores resource units and cpu config attributes */ +export interface CPUSDKType { + units: ResourceValueSDKType; + attributes: AttributeSDKType[]; +} +/** Memory stores resource quantity and memory attributes */ +export interface Memory { + quantity: ResourceValue; + attributes: Attribute[]; +} +export interface MemoryProtoMsg { + typeUrl: "/akash.base.v1beta1.Memory"; + value: Uint8Array; +} +/** Memory stores resource quantity and memory attributes */ +export interface MemorySDKType { + quantity: ResourceValueSDKType; + attributes: AttributeSDKType[]; +} +/** Storage stores resource quantity and storage attributes */ +export interface Storage { + quantity: ResourceValue; + attributes: Attribute[]; +} +export interface StorageProtoMsg { + typeUrl: "/akash.base.v1beta1.Storage"; + value: Uint8Array; +} +/** Storage stores resource quantity and storage attributes */ +export interface StorageSDKType { + quantity: ResourceValueSDKType; + attributes: AttributeSDKType[]; +} +/** + * ResourceUnits describes all available resources types for deployment/node etc + * if field is nil resource is not present in the given data-structure + */ +export interface ResourceUnits { + cpu?: CPU; + memory?: Memory; + storage?: Storage; + endpoints: Endpoint[]; +} +export interface ResourceUnitsProtoMsg { + typeUrl: "/akash.base.v1beta1.ResourceUnits"; + value: Uint8Array; +} +/** + * ResourceUnits describes all available resources types for deployment/node etc + * if field is nil resource is not present in the given data-structure + */ +export interface ResourceUnitsSDKType { + cpu?: CPUSDKType; + memory?: MemorySDKType; + storage?: StorageSDKType; + endpoints: EndpointSDKType[]; +} +function createBaseCPU(): CPU { + return { + units: ResourceValue.fromPartial({}), + attributes: [] + }; +} +export const CPU = { + typeUrl: "/akash.base.v1beta1.CPU", + encode(message: CPU, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.units !== undefined) { + ResourceValue.encode(message.units, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.attributes) { + Attribute.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): CPU { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCPU(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.units = ResourceValue.decode(reader, reader.uint32()); + break; + case 2: + message.attributes.push(Attribute.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): CPU { + const obj = createBaseCPU(); + if (isSet(object.units)) obj.units = ResourceValue.fromJSON(object.units); + if (Array.isArray(object?.attributes)) obj.attributes = object.attributes.map((e: any) => Attribute.fromJSON(e)); + return obj; + }, + toJSON(message: CPU): JsonSafe { + const obj: any = {}; + message.units !== undefined && (obj.units = message.units ? ResourceValue.toJSON(message.units) : undefined); + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? Attribute.toJSON(e) : undefined); + } else { + obj.attributes = []; + } + return obj; + }, + fromPartial, I>>(object: I): CPU { + const message = createBaseCPU(); + if (object.units !== undefined && object.units !== null) { + message.units = ResourceValue.fromPartial(object.units); + } + message.attributes = object.attributes?.map(e => Attribute.fromPartial(e)) || []; + return message; + }, + fromSDK(object: CPUSDKType): CPU { + return { + units: object.units ? ResourceValue.fromSDK(object.units) : undefined, + attributes: Array.isArray(object?.attributes) ? object.attributes.map((e: any) => Attribute.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): CPUSDKType { + return { + units: isSet(object.units) ? ResourceValue.fromSDKJSON(object.units) : undefined, + attributes: Array.isArray(object?.attributes) ? object.attributes.map((e: any) => Attribute.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: CPU): CPUSDKType { + const obj: any = {}; + message.units !== undefined && (obj.units = message.units ? ResourceValue.toSDK(message.units) : undefined); + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? Attribute.toSDK(e) : undefined); + } else { + obj.attributes = []; + } + return obj; + }, + fromAmino(object: CPUAmino): CPU { + const message = createBaseCPU(); + if (object.units !== undefined && object.units !== null) { + message.units = ResourceValue.fromAmino(object.units); + } + message.attributes = object.attributes?.map(e => Attribute.fromAmino(e)) || []; + return message; + }, + toAmino(message: CPU): CPUAmino { + const obj: any = {}; + obj.units = message.units ? ResourceValue.toAmino(message.units) : undefined; + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? Attribute.toAmino(e) : undefined); + } else { + obj.attributes = message.attributes; + } + return obj; + }, + fromAminoMsg(object: CPUAminoMsg): CPU { + return CPU.fromAmino(object.value); + }, + toAminoMsg(message: CPU): CPUAminoMsg { + return { + type: "akash/base/cpu", + value: CPU.toAmino(message) + }; + }, + fromProtoMsg(message: CPUProtoMsg): CPU { + return CPU.decode(message.value); + }, + toProto(message: CPU): Uint8Array { + return CPU.encode(message).finish(); + }, + toProtoMsg(message: CPU): CPUProtoMsg { + return { + typeUrl: "/akash.base.v1beta1.CPU", + value: CPU.encode(message).finish() + }; + } +}; +function createBaseMemory(): Memory { + return { + quantity: ResourceValue.fromPartial({}), + attributes: [] + }; +} +export const Memory = { + typeUrl: "/akash.base.v1beta1.Memory", + encode(message: Memory, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.quantity !== undefined) { + ResourceValue.encode(message.quantity, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.attributes) { + Attribute.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Memory { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMemory(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.quantity = ResourceValue.decode(reader, reader.uint32()); + break; + case 2: + message.attributes.push(Attribute.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Memory { + const obj = createBaseMemory(); + if (isSet(object.quantity)) obj.quantity = ResourceValue.fromJSON(object.quantity); + if (Array.isArray(object?.attributes)) obj.attributes = object.attributes.map((e: any) => Attribute.fromJSON(e)); + return obj; + }, + toJSON(message: Memory): JsonSafe { + const obj: any = {}; + message.quantity !== undefined && (obj.quantity = message.quantity ? ResourceValue.toJSON(message.quantity) : undefined); + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? Attribute.toJSON(e) : undefined); + } else { + obj.attributes = []; + } + return obj; + }, + fromPartial, I>>(object: I): Memory { + const message = createBaseMemory(); + if (object.quantity !== undefined && object.quantity !== null) { + message.quantity = ResourceValue.fromPartial(object.quantity); + } + message.attributes = object.attributes?.map(e => Attribute.fromPartial(e)) || []; + return message; + }, + fromSDK(object: MemorySDKType): Memory { + return { + quantity: object.quantity ? ResourceValue.fromSDK(object.quantity) : undefined, + attributes: Array.isArray(object?.attributes) ? object.attributes.map((e: any) => Attribute.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): MemorySDKType { + return { + quantity: isSet(object.quantity) ? ResourceValue.fromSDKJSON(object.quantity) : undefined, + attributes: Array.isArray(object?.attributes) ? object.attributes.map((e: any) => Attribute.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: Memory): MemorySDKType { + const obj: any = {}; + message.quantity !== undefined && (obj.quantity = message.quantity ? ResourceValue.toSDK(message.quantity) : undefined); + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? Attribute.toSDK(e) : undefined); + } else { + obj.attributes = []; + } + return obj; + }, + fromAmino(object: MemoryAmino): Memory { + const message = createBaseMemory(); + if (object.quantity !== undefined && object.quantity !== null) { + message.quantity = ResourceValue.fromAmino(object.quantity); + } + message.attributes = object.attributes?.map(e => Attribute.fromAmino(e)) || []; + return message; + }, + toAmino(message: Memory): MemoryAmino { + const obj: any = {}; + obj.quantity = message.quantity ? ResourceValue.toAmino(message.quantity) : ResourceValue.toAmino(ResourceValue.fromPartial({})); + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? Attribute.toAmino(e) : undefined); + } else { + obj.attributes = message.attributes; + } + return obj; + }, + fromAminoMsg(object: MemoryAminoMsg): Memory { + return Memory.fromAmino(object.value); + }, + toAminoMsg(message: Memory): MemoryAminoMsg { + return { + type: "akash/base/memory", + value: Memory.toAmino(message) + }; + }, + fromProtoMsg(message: MemoryProtoMsg): Memory { + return Memory.decode(message.value); + }, + toProto(message: Memory): Uint8Array { + return Memory.encode(message).finish(); + }, + toProtoMsg(message: Memory): MemoryProtoMsg { + return { + typeUrl: "/akash.base.v1beta1.Memory", + value: Memory.encode(message).finish() + }; + } +}; +function createBaseStorage(): Storage { + return { + quantity: ResourceValue.fromPartial({}), + attributes: [] + }; +} +export const Storage = { + typeUrl: "/akash.base.v1beta1.Storage", + encode(message: Storage, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.quantity !== undefined) { + ResourceValue.encode(message.quantity, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.attributes) { + Attribute.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Storage { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseStorage(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.quantity = ResourceValue.decode(reader, reader.uint32()); + break; + case 2: + message.attributes.push(Attribute.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Storage { + const obj = createBaseStorage(); + if (isSet(object.quantity)) obj.quantity = ResourceValue.fromJSON(object.quantity); + if (Array.isArray(object?.attributes)) obj.attributes = object.attributes.map((e: any) => Attribute.fromJSON(e)); + return obj; + }, + toJSON(message: Storage): JsonSafe { + const obj: any = {}; + message.quantity !== undefined && (obj.quantity = message.quantity ? ResourceValue.toJSON(message.quantity) : undefined); + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? Attribute.toJSON(e) : undefined); + } else { + obj.attributes = []; + } + return obj; + }, + fromPartial, I>>(object: I): Storage { + const message = createBaseStorage(); + if (object.quantity !== undefined && object.quantity !== null) { + message.quantity = ResourceValue.fromPartial(object.quantity); + } + message.attributes = object.attributes?.map(e => Attribute.fromPartial(e)) || []; + return message; + }, + fromSDK(object: StorageSDKType): Storage { + return { + quantity: object.quantity ? ResourceValue.fromSDK(object.quantity) : undefined, + attributes: Array.isArray(object?.attributes) ? object.attributes.map((e: any) => Attribute.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): StorageSDKType { + return { + quantity: isSet(object.quantity) ? ResourceValue.fromSDKJSON(object.quantity) : undefined, + attributes: Array.isArray(object?.attributes) ? object.attributes.map((e: any) => Attribute.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: Storage): StorageSDKType { + const obj: any = {}; + message.quantity !== undefined && (obj.quantity = message.quantity ? ResourceValue.toSDK(message.quantity) : undefined); + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? Attribute.toSDK(e) : undefined); + } else { + obj.attributes = []; + } + return obj; + }, + fromAmino(object: StorageAmino): Storage { + const message = createBaseStorage(); + if (object.quantity !== undefined && object.quantity !== null) { + message.quantity = ResourceValue.fromAmino(object.quantity); + } + message.attributes = object.attributes?.map(e => Attribute.fromAmino(e)) || []; + return message; + }, + toAmino(message: Storage): StorageAmino { + const obj: any = {}; + obj.quantity = message.quantity ? ResourceValue.toAmino(message.quantity) : ResourceValue.toAmino(ResourceValue.fromPartial({})); + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? Attribute.toAmino(e) : undefined); + } else { + obj.attributes = message.attributes; + } + return obj; + }, + fromAminoMsg(object: StorageAminoMsg): Storage { + return Storage.fromAmino(object.value); + }, + toAminoMsg(message: Storage): StorageAminoMsg { + return { + type: "akash/base/storage", + value: Storage.toAmino(message) + }; + }, + fromProtoMsg(message: StorageProtoMsg): Storage { + return Storage.decode(message.value); + }, + toProto(message: Storage): Uint8Array { + return Storage.encode(message).finish(); + }, + toProtoMsg(message: Storage): StorageProtoMsg { + return { + typeUrl: "/akash.base.v1beta1.Storage", + value: Storage.encode(message).finish() + }; + } +}; +function createBaseResourceUnits(): ResourceUnits { + return { + cpu: undefined, + memory: undefined, + storage: undefined, + endpoints: [] + }; +} +export const ResourceUnits = { + typeUrl: "/akash.base.v1beta1.ResourceUnits", + encode(message: ResourceUnits, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.cpu !== undefined) { + CPU.encode(message.cpu, writer.uint32(10).fork()).ldelim(); + } + if (message.memory !== undefined) { + Memory.encode(message.memory, writer.uint32(18).fork()).ldelim(); + } + if (message.storage !== undefined) { + Storage.encode(message.storage, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.endpoints) { + Endpoint.encode(v!, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ResourceUnits { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseResourceUnits(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.cpu = CPU.decode(reader, reader.uint32()); + break; + case 2: + message.memory = Memory.decode(reader, reader.uint32()); + break; + case 3: + message.storage = Storage.decode(reader, reader.uint32()); + break; + case 4: + message.endpoints.push(Endpoint.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ResourceUnits { + const obj = createBaseResourceUnits(); + if (isSet(object.cpu)) obj.cpu = CPU.fromJSON(object.cpu); + if (isSet(object.memory)) obj.memory = Memory.fromJSON(object.memory); + if (isSet(object.storage)) obj.storage = Storage.fromJSON(object.storage); + if (Array.isArray(object?.endpoints)) obj.endpoints = object.endpoints.map((e: any) => Endpoint.fromJSON(e)); + return obj; + }, + toJSON(message: ResourceUnits): JsonSafe { + const obj: any = {}; + message.cpu !== undefined && (obj.cpu = message.cpu ? CPU.toJSON(message.cpu) : undefined); + message.memory !== undefined && (obj.memory = message.memory ? Memory.toJSON(message.memory) : undefined); + message.storage !== undefined && (obj.storage = message.storage ? Storage.toJSON(message.storage) : undefined); + if (message.endpoints) { + obj.endpoints = message.endpoints.map(e => e ? Endpoint.toJSON(e) : undefined); + } else { + obj.endpoints = []; + } + return obj; + }, + fromPartial, I>>(object: I): ResourceUnits { + const message = createBaseResourceUnits(); + if (object.cpu !== undefined && object.cpu !== null) { + message.cpu = CPU.fromPartial(object.cpu); + } + if (object.memory !== undefined && object.memory !== null) { + message.memory = Memory.fromPartial(object.memory); + } + if (object.storage !== undefined && object.storage !== null) { + message.storage = Storage.fromPartial(object.storage); + } + message.endpoints = object.endpoints?.map(e => Endpoint.fromPartial(e)) || []; + return message; + }, + fromSDK(object: ResourceUnitsSDKType): ResourceUnits { + return { + cpu: object.cpu ? CPU.fromSDK(object.cpu) : undefined, + memory: object.memory ? Memory.fromSDK(object.memory) : undefined, + storage: object.storage ? Storage.fromSDK(object.storage) : undefined, + endpoints: Array.isArray(object?.endpoints) ? object.endpoints.map((e: any) => Endpoint.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): ResourceUnitsSDKType { + return { + cpu: isSet(object.cpu) ? CPU.fromSDKJSON(object.cpu) : undefined, + memory: isSet(object.memory) ? Memory.fromSDKJSON(object.memory) : undefined, + storage: isSet(object.storage) ? Storage.fromSDKJSON(object.storage) : undefined, + endpoints: Array.isArray(object?.endpoints) ? object.endpoints.map((e: any) => Endpoint.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: ResourceUnits): ResourceUnitsSDKType { + const obj: any = {}; + message.cpu !== undefined && (obj.cpu = message.cpu ? CPU.toSDK(message.cpu) : undefined); + message.memory !== undefined && (obj.memory = message.memory ? Memory.toSDK(message.memory) : undefined); + message.storage !== undefined && (obj.storage = message.storage ? Storage.toSDK(message.storage) : undefined); + if (message.endpoints) { + obj.endpoints = message.endpoints.map(e => e ? Endpoint.toSDK(e) : undefined); + } else { + obj.endpoints = []; + } + return obj; + }, + fromAmino(object: ResourceUnitsAmino): ResourceUnits { + const message = createBaseResourceUnits(); + if (object.cpu !== undefined && object.cpu !== null) { + message.cpu = CPU.fromAmino(object.cpu); + } + if (object.memory !== undefined && object.memory !== null) { + message.memory = Memory.fromAmino(object.memory); + } + if (object.storage !== undefined && object.storage !== null) { + message.storage = Storage.fromAmino(object.storage); + } + message.endpoints = object.endpoints?.map(e => Endpoint.fromAmino(e)) || []; + return message; + }, + toAmino(message: ResourceUnits): ResourceUnitsAmino { + const obj: any = {}; + obj.cpu = message.cpu ? CPU.toAmino(message.cpu) : undefined; + obj.memory = message.memory ? Memory.toAmino(message.memory) : undefined; + obj.storage = message.storage ? Storage.toAmino(message.storage) : undefined; + if (message.endpoints) { + obj.endpoints = message.endpoints.map(e => e ? Endpoint.toAmino(e) : undefined); + } else { + obj.endpoints = message.endpoints; + } + return obj; + }, + fromAminoMsg(object: ResourceUnitsAminoMsg): ResourceUnits { + return ResourceUnits.fromAmino(object.value); + }, + toAminoMsg(message: ResourceUnits): ResourceUnitsAminoMsg { + return { + type: "akash/base/resource-units", + value: ResourceUnits.toAmino(message) + }; + }, + fromProtoMsg(message: ResourceUnitsProtoMsg): ResourceUnits { + return ResourceUnits.decode(message.value); + }, + toProto(message: ResourceUnits): Uint8Array { + return ResourceUnits.encode(message).finish(); + }, + toProtoMsg(message: ResourceUnits): ResourceUnitsProtoMsg { + return { + typeUrl: "/akash.base.v1beta1.ResourceUnits", + value: ResourceUnits.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/base/v1beta1/resourcevalue.ts b/__fixtures__/v-next/outputicjsdeps/akash/base/v1beta1/resourcevalue.ts new file mode 100644 index 0000000000..e5bb736a5c --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/base/v1beta1/resourcevalue.ts @@ -0,0 +1,110 @@ +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, bytesFromBase64, base64FromBytes, DeepPartial, Exact } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "akash.base.v1beta1"; +/** Unit stores cpu, memory and storage metrics */ +export interface ResourceValue { + val: Uint8Array; +} +export interface ResourceValueProtoMsg { + typeUrl: "/akash.base.v1beta1.ResourceValue"; + value: Uint8Array; +} +/** Unit stores cpu, memory and storage metrics */ +export interface ResourceValueSDKType { + val: Uint8Array; +} +function createBaseResourceValue(): ResourceValue { + return { + val: new Uint8Array() + }; +} +export const ResourceValue = { + typeUrl: "/akash.base.v1beta1.ResourceValue", + encode(message: ResourceValue, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.val.length !== 0) { + writer.uint32(10).bytes(message.val); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ResourceValue { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseResourceValue(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.val = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ResourceValue { + const obj = createBaseResourceValue(); + if (isSet(object.val)) obj.val = bytesFromBase64(object.val); + return obj; + }, + toJSON(message: ResourceValue): JsonSafe { + const obj: any = {}; + message.val !== undefined && (obj.val = base64FromBytes(message.val !== undefined ? message.val : new Uint8Array())); + return obj; + }, + fromPartial, I>>(object: I): ResourceValue { + const message = createBaseResourceValue(); + message.val = object.val ?? new Uint8Array(); + return message; + }, + fromSDK(object: ResourceValueSDKType): ResourceValue { + return { + val: object?.val + }; + }, + fromSDKJSON(object: any): ResourceValueSDKType { + return { + val: isSet(object.val) ? bytesFromBase64(object.val) : new Uint8Array() + }; + }, + toSDK(message: ResourceValue): ResourceValueSDKType { + const obj: any = {}; + obj.val = message.val; + return obj; + }, + fromAmino(object: ResourceValueAmino): ResourceValue { + const message = createBaseResourceValue(); + if (object.val !== undefined && object.val !== null) { + message.val = bytesFromBase64(object.val); + } + return message; + }, + toAmino(message: ResourceValue): ResourceValueAmino { + const obj: any = {}; + obj.val = message.val ? base64FromBytes(message.val) : undefined; + return obj; + }, + fromAminoMsg(object: ResourceValueAminoMsg): ResourceValue { + return ResourceValue.fromAmino(object.value); + }, + toAminoMsg(message: ResourceValue): ResourceValueAminoMsg { + return { + type: "akash/base/resource-value", + value: ResourceValue.toAmino(message) + }; + }, + fromProtoMsg(message: ResourceValueProtoMsg): ResourceValue { + return ResourceValue.decode(message.value); + }, + toProto(message: ResourceValue): Uint8Array { + return ResourceValue.encode(message).finish(); + }, + toProtoMsg(message: ResourceValue): ResourceValueProtoMsg { + return { + typeUrl: "/akash.base.v1beta1.ResourceValue", + value: ResourceValue.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/base/v1beta2/attribute.ts b/__fixtures__/v-next/outputicjsdeps/akash/base/v1beta2/attribute.ts new file mode 100644 index 0000000000..ebd6e8f64f --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/base/v1beta2/attribute.ts @@ -0,0 +1,425 @@ +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial, Exact } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "akash.base.v1beta2"; +/** Attribute represents key value pair */ +export interface Attribute { + key: string; + value: string; +} +export interface AttributeProtoMsg { + typeUrl: "/akash.base.v1beta2.Attribute"; + value: Uint8Array; +} +/** Attribute represents key value pair */ +export interface AttributeSDKType { + key: string; + value: string; +} +/** + * SignedBy represents validation accounts that tenant expects signatures for provider attributes + * AllOf has precedence i.e. if there is at least one entry AnyOf is ignored regardless to how many + * entries there + * this behaviour to be discussed + */ +export interface SignedBy { + /** all_of all keys in this list must have signed attributes */ + allOf: string[]; + /** any_of at least of of the keys from the list must have signed attributes */ + anyOf: string[]; +} +export interface SignedByProtoMsg { + typeUrl: "/akash.base.v1beta2.SignedBy"; + value: Uint8Array; +} +/** + * SignedBy represents validation accounts that tenant expects signatures for provider attributes + * AllOf has precedence i.e. if there is at least one entry AnyOf is ignored regardless to how many + * entries there + * this behaviour to be discussed + */ +export interface SignedBySDKType { + all_of: string[]; + any_of: string[]; +} +/** PlacementRequirements */ +export interface PlacementRequirements { + /** SignedBy list of keys that tenants expect to have signatures from */ + signedBy: SignedBy; + /** Attribute list of attributes tenant expects from the provider */ + attributes: Attribute[]; +} +export interface PlacementRequirementsProtoMsg { + typeUrl: "/akash.base.v1beta2.PlacementRequirements"; + value: Uint8Array; +} +/** PlacementRequirements */ +export interface PlacementRequirementsSDKType { + signed_by: SignedBySDKType; + attributes: AttributeSDKType[]; +} +function createBaseAttribute(): Attribute { + return { + key: "", + value: "" + }; +} +export const Attribute = { + typeUrl: "/akash.base.v1beta2.Attribute", + encode(message: Attribute, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.key !== undefined) { + writer.uint32(10).string(message.key); + } + if (message.value !== undefined) { + writer.uint32(18).string(message.value); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Attribute { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseAttribute(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.string(); + break; + case 2: + message.value = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Attribute { + const obj = createBaseAttribute(); + if (isSet(object.key)) obj.key = String(object.key); + if (isSet(object.value)) obj.value = String(object.value); + return obj; + }, + toJSON(message: Attribute): JsonSafe { + const obj: any = {}; + message.key !== undefined && (obj.key = message.key); + message.value !== undefined && (obj.value = message.value); + return obj; + }, + fromPartial, I>>(object: I): Attribute { + const message = createBaseAttribute(); + message.key = object.key ?? ""; + message.value = object.value ?? ""; + return message; + }, + fromSDK(object: AttributeSDKType): Attribute { + return { + key: object?.key, + value: object?.value + }; + }, + fromSDKJSON(object: any): AttributeSDKType { + return { + key: isSet(object.key) ? String(object.key) : "", + value: isSet(object.value) ? String(object.value) : "" + }; + }, + toSDK(message: Attribute): AttributeSDKType { + const obj: any = {}; + obj.key = message.key; + obj.value = message.value; + return obj; + }, + fromAmino(object: AttributeAmino): Attribute { + const message = createBaseAttribute(); + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } + if (object.value !== undefined && object.value !== null) { + message.value = object.value; + } + return message; + }, + toAmino(message: Attribute): AttributeAmino { + const obj: any = {}; + obj.key = message.key === "" ? undefined : message.key; + obj.value = message.value === "" ? undefined : message.value; + return obj; + }, + fromAminoMsg(object: AttributeAminoMsg): Attribute { + return Attribute.fromAmino(object.value); + }, + toAminoMsg(message: Attribute): AttributeAminoMsg { + return { + type: "akash/base/v1beta2/attribute", + value: Attribute.toAmino(message) + }; + }, + fromProtoMsg(message: AttributeProtoMsg): Attribute { + return Attribute.decode(message.value); + }, + toProto(message: Attribute): Uint8Array { + return Attribute.encode(message).finish(); + }, + toProtoMsg(message: Attribute): AttributeProtoMsg { + return { + typeUrl: "/akash.base.v1beta2.Attribute", + value: Attribute.encode(message).finish() + }; + } +}; +function createBaseSignedBy(): SignedBy { + return { + allOf: [], + anyOf: [] + }; +} +export const SignedBy = { + typeUrl: "/akash.base.v1beta2.SignedBy", + encode(message: SignedBy, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.allOf) { + writer.uint32(10).string(v!); + } + for (const v of message.anyOf) { + writer.uint32(18).string(v!); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): SignedBy { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseSignedBy(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.allOf.push(reader.string()); + break; + case 2: + message.anyOf.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): SignedBy { + const obj = createBaseSignedBy(); + if (Array.isArray(object?.allOf)) obj.allOf = object.allOf.map((e: any) => String(e)); + if (Array.isArray(object?.anyOf)) obj.anyOf = object.anyOf.map((e: any) => String(e)); + return obj; + }, + toJSON(message: SignedBy): JsonSafe { + const obj: any = {}; + if (message.allOf) { + obj.allOf = message.allOf.map(e => e); + } else { + obj.allOf = []; + } + if (message.anyOf) { + obj.anyOf = message.anyOf.map(e => e); + } else { + obj.anyOf = []; + } + return obj; + }, + fromPartial, I>>(object: I): SignedBy { + const message = createBaseSignedBy(); + message.allOf = object.allOf?.map(e => e) || []; + message.anyOf = object.anyOf?.map(e => e) || []; + return message; + }, + fromSDK(object: SignedBySDKType): SignedBy { + return { + allOf: Array.isArray(object?.all_of) ? object.all_of.map((e: any) => e) : [], + anyOf: Array.isArray(object?.any_of) ? object.any_of.map((e: any) => e) : [] + }; + }, + fromSDKJSON(object: any): SignedBySDKType { + return { + all_of: Array.isArray(object?.all_of) ? object.all_of.map((e: any) => String(e)) : [], + any_of: Array.isArray(object?.any_of) ? object.any_of.map((e: any) => String(e)) : [] + }; + }, + toSDK(message: SignedBy): SignedBySDKType { + const obj: any = {}; + if (message.allOf) { + obj.all_of = message.allOf.map(e => e); + } else { + obj.all_of = []; + } + if (message.anyOf) { + obj.any_of = message.anyOf.map(e => e); + } else { + obj.any_of = []; + } + return obj; + }, + fromAmino(object: SignedByAmino): SignedBy { + const message = createBaseSignedBy(); + message.allOf = object.all_of?.map(e => e) || []; + message.anyOf = object.any_of?.map(e => e) || []; + return message; + }, + toAmino(message: SignedBy): SignedByAmino { + const obj: any = {}; + if (message.allOf) { + obj.all_of = message.allOf.map(e => e); + } else { + obj.all_of = message.allOf; + } + if (message.anyOf) { + obj.any_of = message.anyOf.map(e => e); + } else { + obj.any_of = message.anyOf; + } + return obj; + }, + fromAminoMsg(object: SignedByAminoMsg): SignedBy { + return SignedBy.fromAmino(object.value); + }, + toAminoMsg(message: SignedBy): SignedByAminoMsg { + return { + type: "akash/base/v1beta2/signed-by", + value: SignedBy.toAmino(message) + }; + }, + fromProtoMsg(message: SignedByProtoMsg): SignedBy { + return SignedBy.decode(message.value); + }, + toProto(message: SignedBy): Uint8Array { + return SignedBy.encode(message).finish(); + }, + toProtoMsg(message: SignedBy): SignedByProtoMsg { + return { + typeUrl: "/akash.base.v1beta2.SignedBy", + value: SignedBy.encode(message).finish() + }; + } +}; +function createBasePlacementRequirements(): PlacementRequirements { + return { + signedBy: SignedBy.fromPartial({}), + attributes: [] + }; +} +export const PlacementRequirements = { + typeUrl: "/akash.base.v1beta2.PlacementRequirements", + encode(message: PlacementRequirements, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.signedBy !== undefined) { + SignedBy.encode(message.signedBy, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.attributes) { + Attribute.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): PlacementRequirements { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBasePlacementRequirements(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.signedBy = SignedBy.decode(reader, reader.uint32()); + break; + case 2: + message.attributes.push(Attribute.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): PlacementRequirements { + const obj = createBasePlacementRequirements(); + if (isSet(object.signedBy)) obj.signedBy = SignedBy.fromJSON(object.signedBy); + if (Array.isArray(object?.attributes)) obj.attributes = object.attributes.map((e: any) => Attribute.fromJSON(e)); + return obj; + }, + toJSON(message: PlacementRequirements): JsonSafe { + const obj: any = {}; + message.signedBy !== undefined && (obj.signedBy = message.signedBy ? SignedBy.toJSON(message.signedBy) : undefined); + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? Attribute.toJSON(e) : undefined); + } else { + obj.attributes = []; + } + return obj; + }, + fromPartial, I>>(object: I): PlacementRequirements { + const message = createBasePlacementRequirements(); + if (object.signedBy !== undefined && object.signedBy !== null) { + message.signedBy = SignedBy.fromPartial(object.signedBy); + } + message.attributes = object.attributes?.map(e => Attribute.fromPartial(e)) || []; + return message; + }, + fromSDK(object: PlacementRequirementsSDKType): PlacementRequirements { + return { + signedBy: object.signed_by ? SignedBy.fromSDK(object.signed_by) : undefined, + attributes: Array.isArray(object?.attributes) ? object.attributes.map((e: any) => Attribute.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): PlacementRequirementsSDKType { + return { + signed_by: isSet(object.signed_by) ? SignedBy.fromSDKJSON(object.signed_by) : undefined, + attributes: Array.isArray(object?.attributes) ? object.attributes.map((e: any) => Attribute.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: PlacementRequirements): PlacementRequirementsSDKType { + const obj: any = {}; + message.signedBy !== undefined && (obj.signed_by = message.signedBy ? SignedBy.toSDK(message.signedBy) : undefined); + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? Attribute.toSDK(e) : undefined); + } else { + obj.attributes = []; + } + return obj; + }, + fromAmino(object: PlacementRequirementsAmino): PlacementRequirements { + const message = createBasePlacementRequirements(); + if (object.signed_by !== undefined && object.signed_by !== null) { + message.signedBy = SignedBy.fromAmino(object.signed_by); + } + message.attributes = object.attributes?.map(e => Attribute.fromAmino(e)) || []; + return message; + }, + toAmino(message: PlacementRequirements): PlacementRequirementsAmino { + const obj: any = {}; + obj.signed_by = message.signedBy ? SignedBy.toAmino(message.signedBy) : SignedBy.toAmino(SignedBy.fromPartial({})); + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? Attribute.toAmino(e) : undefined); + } else { + obj.attributes = message.attributes; + } + return obj; + }, + fromAminoMsg(object: PlacementRequirementsAminoMsg): PlacementRequirements { + return PlacementRequirements.fromAmino(object.value); + }, + toAminoMsg(message: PlacementRequirements): PlacementRequirementsAminoMsg { + return { + type: "akash/base/v1beta2/placement-requirements", + value: PlacementRequirements.toAmino(message) + }; + }, + fromProtoMsg(message: PlacementRequirementsProtoMsg): PlacementRequirements { + return PlacementRequirements.decode(message.value); + }, + toProto(message: PlacementRequirements): Uint8Array { + return PlacementRequirements.encode(message).finish(); + }, + toProtoMsg(message: PlacementRequirements): PlacementRequirementsProtoMsg { + return { + typeUrl: "/akash.base.v1beta2.PlacementRequirements", + value: PlacementRequirements.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/base/v1beta2/endpoint.ts b/__fixtures__/v-next/outputicjsdeps/akash/base/v1beta2/endpoint.ts new file mode 100644 index 0000000000..5acb0a01fc --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/base/v1beta2/endpoint.ts @@ -0,0 +1,170 @@ +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial, Exact } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "akash.base.v1beta2"; +/** This describes how the endpoint is implemented when the lease is deployed */ +export enum Endpoint_Kind { + /** SHARED_HTTP - Describes an endpoint that becomes a Kubernetes Ingress */ + SHARED_HTTP = 0, + /** RANDOM_PORT - Describes an endpoint that becomes a Kubernetes NodePort */ + RANDOM_PORT = 1, + /** LEASED_IP - Describes an endpoint that becomes a leased IP */ + LEASED_IP = 2, + UNRECOGNIZED = -1, +} +export const Endpoint_KindSDKType = Endpoint_Kind; +export function endpoint_KindFromJSON(object: any): Endpoint_Kind { + switch (object) { + case 0: + case "SHARED_HTTP": + return Endpoint_Kind.SHARED_HTTP; + case 1: + case "RANDOM_PORT": + return Endpoint_Kind.RANDOM_PORT; + case 2: + case "LEASED_IP": + return Endpoint_Kind.LEASED_IP; + case -1: + case "UNRECOGNIZED": + default: + return Endpoint_Kind.UNRECOGNIZED; + } +} +export function endpoint_KindToJSON(object: Endpoint_Kind): string { + switch (object) { + case Endpoint_Kind.SHARED_HTTP: + return "SHARED_HTTP"; + case Endpoint_Kind.RANDOM_PORT: + return "RANDOM_PORT"; + case Endpoint_Kind.LEASED_IP: + return "LEASED_IP"; + case Endpoint_Kind.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** Endpoint describes a publicly accessible IP service */ +export interface Endpoint { + kind: Endpoint_Kind; + sequenceNumber: number; +} +export interface EndpointProtoMsg { + typeUrl: "/akash.base.v1beta2.Endpoint"; + value: Uint8Array; +} +/** Endpoint describes a publicly accessible IP service */ +export interface EndpointSDKType { + kind: Endpoint_Kind; + sequence_number: number; +} +function createBaseEndpoint(): Endpoint { + return { + kind: 0, + sequenceNumber: 0 + }; +} +export const Endpoint = { + typeUrl: "/akash.base.v1beta2.Endpoint", + encode(message: Endpoint, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.kind !== 0) { + writer.uint32(8).int32(message.kind); + } + if (message.sequenceNumber !== undefined) { + writer.uint32(16).uint32(message.sequenceNumber); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Endpoint { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseEndpoint(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.kind = (reader.int32() as any); + break; + case 2: + message.sequenceNumber = reader.uint32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Endpoint { + const obj = createBaseEndpoint(); + if (isSet(object.kind)) obj.kind = endpoint_KindFromJSON(object.kind); + if (isSet(object.sequenceNumber)) obj.sequenceNumber = Number(object.sequenceNumber); + return obj; + }, + toJSON(message: Endpoint): JsonSafe { + const obj: any = {}; + message.kind !== undefined && (obj.kind = endpoint_KindToJSON(message.kind)); + message.sequenceNumber !== undefined && (obj.sequenceNumber = Math.round(message.sequenceNumber)); + return obj; + }, + fromPartial, I>>(object: I): Endpoint { + const message = createBaseEndpoint(); + message.kind = object.kind ?? 0; + message.sequenceNumber = object.sequenceNumber ?? 0; + return message; + }, + fromSDK(object: EndpointSDKType): Endpoint { + return { + kind: isSet(object.kind) ? endpoint_KindFromJSON(object.kind) : -1, + sequenceNumber: object?.sequence_number + }; + }, + fromSDKJSON(object: any): EndpointSDKType { + return { + kind: isSet(object.kind) ? endpoint_KindFromJSON(object.kind) : -1, + sequence_number: isSet(object.sequence_number) ? Number(object.sequence_number) : 0 + }; + }, + toSDK(message: Endpoint): EndpointSDKType { + const obj: any = {}; + message.kind !== undefined && (obj.kind = endpoint_KindToJSON(message.kind)); + obj.sequence_number = message.sequenceNumber; + return obj; + }, + fromAmino(object: EndpointAmino): Endpoint { + const message = createBaseEndpoint(); + if (object.kind !== undefined && object.kind !== null) { + message.kind = object.kind; + } + if (object.sequence_number !== undefined && object.sequence_number !== null) { + message.sequenceNumber = object.sequence_number; + } + return message; + }, + toAmino(message: Endpoint): EndpointAmino { + const obj: any = {}; + obj.kind = message.kind === 0 ? undefined : message.kind; + obj.sequence_number = message.sequenceNumber ?? 0; + return obj; + }, + fromAminoMsg(object: EndpointAminoMsg): Endpoint { + return Endpoint.fromAmino(object.value); + }, + toAminoMsg(message: Endpoint): EndpointAminoMsg { + return { + type: "akash/base/v1beta2/endpoint", + value: Endpoint.toAmino(message) + }; + }, + fromProtoMsg(message: EndpointProtoMsg): Endpoint { + return Endpoint.decode(message.value); + }, + toProto(message: Endpoint): Uint8Array { + return Endpoint.encode(message).finish(); + }, + toProtoMsg(message: Endpoint): EndpointProtoMsg { + return { + typeUrl: "/akash.base.v1beta2.Endpoint", + value: Endpoint.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/base/v1beta2/resource.ts b/__fixtures__/v-next/outputicjsdeps/akash/base/v1beta2/resource.ts new file mode 100644 index 0000000000..242720eb13 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/base/v1beta2/resource.ts @@ -0,0 +1,436 @@ +import { ResourceValue, ResourceValueSDKType } from "./resourcevalue.js"; +import { Attribute, AttributeSDKType } from "./attribute.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial, Exact } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "akash.base.v1beta2"; +/** CPU stores resource units and cpu config attributes */ +export interface CPU { + units: ResourceValue; + attributes: Attribute[]; +} +export interface CPUProtoMsg { + typeUrl: "/akash.base.v1beta2.CPU"; + value: Uint8Array; +} +/** CPU stores resource units and cpu config attributes */ +export interface CPUSDKType { + units: ResourceValueSDKType; + attributes: AttributeSDKType[]; +} +/** Memory stores resource quantity and memory attributes */ +export interface Memory { + quantity: ResourceValue; + attributes: Attribute[]; +} +export interface MemoryProtoMsg { + typeUrl: "/akash.base.v1beta2.Memory"; + value: Uint8Array; +} +/** Memory stores resource quantity and memory attributes */ +export interface MemorySDKType { + quantity: ResourceValueSDKType; + attributes: AttributeSDKType[]; +} +/** Storage stores resource quantity and storage attributes */ +export interface Storage { + name: string; + quantity: ResourceValue; + attributes: Attribute[]; +} +export interface StorageProtoMsg { + typeUrl: "/akash.base.v1beta2.Storage"; + value: Uint8Array; +} +/** Storage stores resource quantity and storage attributes */ +export interface StorageSDKType { + name: string; + quantity: ResourceValueSDKType; + attributes: AttributeSDKType[]; +} +function createBaseCPU(): CPU { + return { + units: ResourceValue.fromPartial({}), + attributes: [] + }; +} +export const CPU = { + typeUrl: "/akash.base.v1beta2.CPU", + encode(message: CPU, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.units !== undefined) { + ResourceValue.encode(message.units, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.attributes) { + Attribute.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): CPU { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCPU(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.units = ResourceValue.decode(reader, reader.uint32()); + break; + case 2: + message.attributes.push(Attribute.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): CPU { + const obj = createBaseCPU(); + if (isSet(object.units)) obj.units = ResourceValue.fromJSON(object.units); + if (Array.isArray(object?.attributes)) obj.attributes = object.attributes.map((e: any) => Attribute.fromJSON(e)); + return obj; + }, + toJSON(message: CPU): JsonSafe { + const obj: any = {}; + message.units !== undefined && (obj.units = message.units ? ResourceValue.toJSON(message.units) : undefined); + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? Attribute.toJSON(e) : undefined); + } else { + obj.attributes = []; + } + return obj; + }, + fromPartial, I>>(object: I): CPU { + const message = createBaseCPU(); + if (object.units !== undefined && object.units !== null) { + message.units = ResourceValue.fromPartial(object.units); + } + message.attributes = object.attributes?.map(e => Attribute.fromPartial(e)) || []; + return message; + }, + fromSDK(object: CPUSDKType): CPU { + return { + units: object.units ? ResourceValue.fromSDK(object.units) : undefined, + attributes: Array.isArray(object?.attributes) ? object.attributes.map((e: any) => Attribute.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): CPUSDKType { + return { + units: isSet(object.units) ? ResourceValue.fromSDKJSON(object.units) : undefined, + attributes: Array.isArray(object?.attributes) ? object.attributes.map((e: any) => Attribute.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: CPU): CPUSDKType { + const obj: any = {}; + message.units !== undefined && (obj.units = message.units ? ResourceValue.toSDK(message.units) : undefined); + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? Attribute.toSDK(e) : undefined); + } else { + obj.attributes = []; + } + return obj; + }, + fromAmino(object: CPUAmino): CPU { + const message = createBaseCPU(); + if (object.units !== undefined && object.units !== null) { + message.units = ResourceValue.fromAmino(object.units); + } + message.attributes = object.attributes?.map(e => Attribute.fromAmino(e)) || []; + return message; + }, + toAmino(message: CPU): CPUAmino { + const obj: any = {}; + obj.units = message.units ? ResourceValue.toAmino(message.units) : undefined; + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? Attribute.toAmino(e) : undefined); + } else { + obj.attributes = message.attributes; + } + return obj; + }, + fromAminoMsg(object: CPUAminoMsg): CPU { + return CPU.fromAmino(object.value); + }, + toAminoMsg(message: CPU): CPUAminoMsg { + return { + type: "akash/base/v1beta2/cpu", + value: CPU.toAmino(message) + }; + }, + fromProtoMsg(message: CPUProtoMsg): CPU { + return CPU.decode(message.value); + }, + toProto(message: CPU): Uint8Array { + return CPU.encode(message).finish(); + }, + toProtoMsg(message: CPU): CPUProtoMsg { + return { + typeUrl: "/akash.base.v1beta2.CPU", + value: CPU.encode(message).finish() + }; + } +}; +function createBaseMemory(): Memory { + return { + quantity: ResourceValue.fromPartial({}), + attributes: [] + }; +} +export const Memory = { + typeUrl: "/akash.base.v1beta2.Memory", + encode(message: Memory, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.quantity !== undefined) { + ResourceValue.encode(message.quantity, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.attributes) { + Attribute.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Memory { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMemory(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.quantity = ResourceValue.decode(reader, reader.uint32()); + break; + case 2: + message.attributes.push(Attribute.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Memory { + const obj = createBaseMemory(); + if (isSet(object.quantity)) obj.quantity = ResourceValue.fromJSON(object.quantity); + if (Array.isArray(object?.attributes)) obj.attributes = object.attributes.map((e: any) => Attribute.fromJSON(e)); + return obj; + }, + toJSON(message: Memory): JsonSafe { + const obj: any = {}; + message.quantity !== undefined && (obj.quantity = message.quantity ? ResourceValue.toJSON(message.quantity) : undefined); + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? Attribute.toJSON(e) : undefined); + } else { + obj.attributes = []; + } + return obj; + }, + fromPartial, I>>(object: I): Memory { + const message = createBaseMemory(); + if (object.quantity !== undefined && object.quantity !== null) { + message.quantity = ResourceValue.fromPartial(object.quantity); + } + message.attributes = object.attributes?.map(e => Attribute.fromPartial(e)) || []; + return message; + }, + fromSDK(object: MemorySDKType): Memory { + return { + quantity: object.quantity ? ResourceValue.fromSDK(object.quantity) : undefined, + attributes: Array.isArray(object?.attributes) ? object.attributes.map((e: any) => Attribute.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): MemorySDKType { + return { + quantity: isSet(object.quantity) ? ResourceValue.fromSDKJSON(object.quantity) : undefined, + attributes: Array.isArray(object?.attributes) ? object.attributes.map((e: any) => Attribute.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: Memory): MemorySDKType { + const obj: any = {}; + message.quantity !== undefined && (obj.quantity = message.quantity ? ResourceValue.toSDK(message.quantity) : undefined); + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? Attribute.toSDK(e) : undefined); + } else { + obj.attributes = []; + } + return obj; + }, + fromAmino(object: MemoryAmino): Memory { + const message = createBaseMemory(); + if (object.quantity !== undefined && object.quantity !== null) { + message.quantity = ResourceValue.fromAmino(object.quantity); + } + message.attributes = object.attributes?.map(e => Attribute.fromAmino(e)) || []; + return message; + }, + toAmino(message: Memory): MemoryAmino { + const obj: any = {}; + obj.quantity = message.quantity ? ResourceValue.toAmino(message.quantity) : ResourceValue.toAmino(ResourceValue.fromPartial({})); + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? Attribute.toAmino(e) : undefined); + } else { + obj.attributes = message.attributes; + } + return obj; + }, + fromAminoMsg(object: MemoryAminoMsg): Memory { + return Memory.fromAmino(object.value); + }, + toAminoMsg(message: Memory): MemoryAminoMsg { + return { + type: "akash/base/v1beta2/memory", + value: Memory.toAmino(message) + }; + }, + fromProtoMsg(message: MemoryProtoMsg): Memory { + return Memory.decode(message.value); + }, + toProto(message: Memory): Uint8Array { + return Memory.encode(message).finish(); + }, + toProtoMsg(message: Memory): MemoryProtoMsg { + return { + typeUrl: "/akash.base.v1beta2.Memory", + value: Memory.encode(message).finish() + }; + } +}; +function createBaseStorage(): Storage { + return { + name: "", + quantity: ResourceValue.fromPartial({}), + attributes: [] + }; +} +export const Storage = { + typeUrl: "/akash.base.v1beta2.Storage", + encode(message: Storage, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + if (message.quantity !== undefined) { + ResourceValue.encode(message.quantity, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.attributes) { + Attribute.encode(v!, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Storage { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseStorage(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.quantity = ResourceValue.decode(reader, reader.uint32()); + break; + case 3: + message.attributes.push(Attribute.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Storage { + const obj = createBaseStorage(); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.quantity)) obj.quantity = ResourceValue.fromJSON(object.quantity); + if (Array.isArray(object?.attributes)) obj.attributes = object.attributes.map((e: any) => Attribute.fromJSON(e)); + return obj; + }, + toJSON(message: Storage): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.quantity !== undefined && (obj.quantity = message.quantity ? ResourceValue.toJSON(message.quantity) : undefined); + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? Attribute.toJSON(e) : undefined); + } else { + obj.attributes = []; + } + return obj; + }, + fromPartial, I>>(object: I): Storage { + const message = createBaseStorage(); + message.name = object.name ?? ""; + if (object.quantity !== undefined && object.quantity !== null) { + message.quantity = ResourceValue.fromPartial(object.quantity); + } + message.attributes = object.attributes?.map(e => Attribute.fromPartial(e)) || []; + return message; + }, + fromSDK(object: StorageSDKType): Storage { + return { + name: object?.name, + quantity: object.quantity ? ResourceValue.fromSDK(object.quantity) : undefined, + attributes: Array.isArray(object?.attributes) ? object.attributes.map((e: any) => Attribute.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): StorageSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + quantity: isSet(object.quantity) ? ResourceValue.fromSDKJSON(object.quantity) : undefined, + attributes: Array.isArray(object?.attributes) ? object.attributes.map((e: any) => Attribute.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: Storage): StorageSDKType { + const obj: any = {}; + obj.name = message.name; + message.quantity !== undefined && (obj.quantity = message.quantity ? ResourceValue.toSDK(message.quantity) : undefined); + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? Attribute.toSDK(e) : undefined); + } else { + obj.attributes = []; + } + return obj; + }, + fromAmino(object: StorageAmino): Storage { + const message = createBaseStorage(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + if (object.quantity !== undefined && object.quantity !== null) { + message.quantity = ResourceValue.fromAmino(object.quantity); + } + message.attributes = object.attributes?.map(e => Attribute.fromAmino(e)) || []; + return message; + }, + toAmino(message: Storage): StorageAmino { + const obj: any = {}; + obj.name = message.name ?? ""; + obj.quantity = message.quantity ? ResourceValue.toAmino(message.quantity) : ResourceValue.toAmino(ResourceValue.fromPartial({})); + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? Attribute.toAmino(e) : undefined); + } else { + obj.attributes = message.attributes; + } + return obj; + }, + fromAminoMsg(object: StorageAminoMsg): Storage { + return Storage.fromAmino(object.value); + }, + toAminoMsg(message: Storage): StorageAminoMsg { + return { + type: "akash/base/v1beta2/storage", + value: Storage.toAmino(message) + }; + }, + fromProtoMsg(message: StorageProtoMsg): Storage { + return Storage.decode(message.value); + }, + toProto(message: Storage): Uint8Array { + return Storage.encode(message).finish(); + }, + toProtoMsg(message: Storage): StorageProtoMsg { + return { + typeUrl: "/akash.base.v1beta2.Storage", + value: Storage.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/base/v1beta2/resourceunits.ts b/__fixtures__/v-next/outputicjsdeps/akash/base/v1beta2/resourceunits.ts new file mode 100644 index 0000000000..9b9a8160ce --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/base/v1beta2/resourceunits.ts @@ -0,0 +1,199 @@ +import { CPU, CPUSDKType, Memory, MemorySDKType, Storage, StorageSDKType } from "./resource.js"; +import { Endpoint, EndpointSDKType } from "./endpoint.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial, Exact } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "akash.base.v1beta2"; +/** + * ResourceUnits describes all available resources types for deployment/node etc + * if field is nil resource is not present in the given data-structure + */ +export interface ResourceUnits { + cpu?: CPU; + memory?: Memory; + storage: Storage[]; + endpoints: Endpoint[]; +} +export interface ResourceUnitsProtoMsg { + typeUrl: "/akash.base.v1beta2.ResourceUnits"; + value: Uint8Array; +} +/** + * ResourceUnits describes all available resources types for deployment/node etc + * if field is nil resource is not present in the given data-structure + */ +export interface ResourceUnitsSDKType { + cpu?: CPUSDKType; + memory?: MemorySDKType; + storage: StorageSDKType[]; + endpoints: EndpointSDKType[]; +} +function createBaseResourceUnits(): ResourceUnits { + return { + cpu: undefined, + memory: undefined, + storage: [], + endpoints: [] + }; +} +export const ResourceUnits = { + typeUrl: "/akash.base.v1beta2.ResourceUnits", + encode(message: ResourceUnits, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.cpu !== undefined) { + CPU.encode(message.cpu, writer.uint32(10).fork()).ldelim(); + } + if (message.memory !== undefined) { + Memory.encode(message.memory, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.storage) { + Storage.encode(v!, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.endpoints) { + Endpoint.encode(v!, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ResourceUnits { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseResourceUnits(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.cpu = CPU.decode(reader, reader.uint32()); + break; + case 2: + message.memory = Memory.decode(reader, reader.uint32()); + break; + case 3: + message.storage.push(Storage.decode(reader, reader.uint32())); + break; + case 4: + message.endpoints.push(Endpoint.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ResourceUnits { + const obj = createBaseResourceUnits(); + if (isSet(object.cpu)) obj.cpu = CPU.fromJSON(object.cpu); + if (isSet(object.memory)) obj.memory = Memory.fromJSON(object.memory); + if (Array.isArray(object?.storage)) obj.storage = object.storage.map((e: any) => Storage.fromJSON(e)); + if (Array.isArray(object?.endpoints)) obj.endpoints = object.endpoints.map((e: any) => Endpoint.fromJSON(e)); + return obj; + }, + toJSON(message: ResourceUnits): JsonSafe { + const obj: any = {}; + message.cpu !== undefined && (obj.cpu = message.cpu ? CPU.toJSON(message.cpu) : undefined); + message.memory !== undefined && (obj.memory = message.memory ? Memory.toJSON(message.memory) : undefined); + if (message.storage) { + obj.storage = message.storage.map(e => e ? Storage.toJSON(e) : undefined); + } else { + obj.storage = []; + } + if (message.endpoints) { + obj.endpoints = message.endpoints.map(e => e ? Endpoint.toJSON(e) : undefined); + } else { + obj.endpoints = []; + } + return obj; + }, + fromPartial, I>>(object: I): ResourceUnits { + const message = createBaseResourceUnits(); + if (object.cpu !== undefined && object.cpu !== null) { + message.cpu = CPU.fromPartial(object.cpu); + } + if (object.memory !== undefined && object.memory !== null) { + message.memory = Memory.fromPartial(object.memory); + } + message.storage = object.storage?.map(e => Storage.fromPartial(e)) || []; + message.endpoints = object.endpoints?.map(e => Endpoint.fromPartial(e)) || []; + return message; + }, + fromSDK(object: ResourceUnitsSDKType): ResourceUnits { + return { + cpu: object.cpu ? CPU.fromSDK(object.cpu) : undefined, + memory: object.memory ? Memory.fromSDK(object.memory) : undefined, + storage: Array.isArray(object?.storage) ? object.storage.map((e: any) => Storage.fromSDK(e)) : [], + endpoints: Array.isArray(object?.endpoints) ? object.endpoints.map((e: any) => Endpoint.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): ResourceUnitsSDKType { + return { + cpu: isSet(object.cpu) ? CPU.fromSDKJSON(object.cpu) : undefined, + memory: isSet(object.memory) ? Memory.fromSDKJSON(object.memory) : undefined, + storage: Array.isArray(object?.storage) ? object.storage.map((e: any) => Storage.fromSDKJSON(e)) : [], + endpoints: Array.isArray(object?.endpoints) ? object.endpoints.map((e: any) => Endpoint.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: ResourceUnits): ResourceUnitsSDKType { + const obj: any = {}; + message.cpu !== undefined && (obj.cpu = message.cpu ? CPU.toSDK(message.cpu) : undefined); + message.memory !== undefined && (obj.memory = message.memory ? Memory.toSDK(message.memory) : undefined); + if (message.storage) { + obj.storage = message.storage.map(e => e ? Storage.toSDK(e) : undefined); + } else { + obj.storage = []; + } + if (message.endpoints) { + obj.endpoints = message.endpoints.map(e => e ? Endpoint.toSDK(e) : undefined); + } else { + obj.endpoints = []; + } + return obj; + }, + fromAmino(object: ResourceUnitsAmino): ResourceUnits { + const message = createBaseResourceUnits(); + if (object.cpu !== undefined && object.cpu !== null) { + message.cpu = CPU.fromAmino(object.cpu); + } + if (object.memory !== undefined && object.memory !== null) { + message.memory = Memory.fromAmino(object.memory); + } + message.storage = object.storage?.map(e => Storage.fromAmino(e)) || []; + message.endpoints = object.endpoints?.map(e => Endpoint.fromAmino(e)) || []; + return message; + }, + toAmino(message: ResourceUnits): ResourceUnitsAmino { + const obj: any = {}; + obj.cpu = message.cpu ? CPU.toAmino(message.cpu) : undefined; + obj.memory = message.memory ? Memory.toAmino(message.memory) : undefined; + if (message.storage) { + obj.storage = message.storage.map(e => e ? Storage.toAmino(e) : undefined); + } else { + obj.storage = message.storage; + } + if (message.endpoints) { + obj.endpoints = message.endpoints.map(e => e ? Endpoint.toAmino(e) : undefined); + } else { + obj.endpoints = message.endpoints; + } + return obj; + }, + fromAminoMsg(object: ResourceUnitsAminoMsg): ResourceUnits { + return ResourceUnits.fromAmino(object.value); + }, + toAminoMsg(message: ResourceUnits): ResourceUnitsAminoMsg { + return { + type: "akash/base/v1beta2/resource-units", + value: ResourceUnits.toAmino(message) + }; + }, + fromProtoMsg(message: ResourceUnitsProtoMsg): ResourceUnits { + return ResourceUnits.decode(message.value); + }, + toProto(message: ResourceUnits): Uint8Array { + return ResourceUnits.encode(message).finish(); + }, + toProtoMsg(message: ResourceUnits): ResourceUnitsProtoMsg { + return { + typeUrl: "/akash.base.v1beta2.ResourceUnits", + value: ResourceUnits.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/base/v1beta2/resourcevalue.ts b/__fixtures__/v-next/outputicjsdeps/akash/base/v1beta2/resourcevalue.ts new file mode 100644 index 0000000000..4566de985a --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/base/v1beta2/resourcevalue.ts @@ -0,0 +1,110 @@ +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, bytesFromBase64, base64FromBytes, DeepPartial, Exact } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "akash.base.v1beta2"; +/** Unit stores cpu, memory and storage metrics */ +export interface ResourceValue { + val: Uint8Array; +} +export interface ResourceValueProtoMsg { + typeUrl: "/akash.base.v1beta2.ResourceValue"; + value: Uint8Array; +} +/** Unit stores cpu, memory and storage metrics */ +export interface ResourceValueSDKType { + val: Uint8Array; +} +function createBaseResourceValue(): ResourceValue { + return { + val: new Uint8Array() + }; +} +export const ResourceValue = { + typeUrl: "/akash.base.v1beta2.ResourceValue", + encode(message: ResourceValue, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.val.length !== 0) { + writer.uint32(10).bytes(message.val); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ResourceValue { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseResourceValue(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.val = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ResourceValue { + const obj = createBaseResourceValue(); + if (isSet(object.val)) obj.val = bytesFromBase64(object.val); + return obj; + }, + toJSON(message: ResourceValue): JsonSafe { + const obj: any = {}; + message.val !== undefined && (obj.val = base64FromBytes(message.val !== undefined ? message.val : new Uint8Array())); + return obj; + }, + fromPartial, I>>(object: I): ResourceValue { + const message = createBaseResourceValue(); + message.val = object.val ?? new Uint8Array(); + return message; + }, + fromSDK(object: ResourceValueSDKType): ResourceValue { + return { + val: object?.val + }; + }, + fromSDKJSON(object: any): ResourceValueSDKType { + return { + val: isSet(object.val) ? bytesFromBase64(object.val) : new Uint8Array() + }; + }, + toSDK(message: ResourceValue): ResourceValueSDKType { + const obj: any = {}; + obj.val = message.val; + return obj; + }, + fromAmino(object: ResourceValueAmino): ResourceValue { + const message = createBaseResourceValue(); + if (object.val !== undefined && object.val !== null) { + message.val = bytesFromBase64(object.val); + } + return message; + }, + toAmino(message: ResourceValue): ResourceValueAmino { + const obj: any = {}; + obj.val = message.val ? base64FromBytes(message.val) : undefined; + return obj; + }, + fromAminoMsg(object: ResourceValueAminoMsg): ResourceValue { + return ResourceValue.fromAmino(object.value); + }, + toAminoMsg(message: ResourceValue): ResourceValueAminoMsg { + return { + type: "akash/base/v1beta2/resource-value", + value: ResourceValue.toAmino(message) + }; + }, + fromProtoMsg(message: ResourceValueProtoMsg): ResourceValue { + return ResourceValue.decode(message.value); + }, + toProto(message: ResourceValue): Uint8Array { + return ResourceValue.encode(message).finish(); + }, + toProtoMsg(message: ResourceValue): ResourceValueProtoMsg { + return { + typeUrl: "/akash.base.v1beta2.ResourceValue", + value: ResourceValue.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/bundle.ts b/__fixtures__/v-next/outputicjsdeps/akash/bundle.ts new file mode 100644 index 0000000000..e5eece9d00 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/bundle.ts @@ -0,0 +1,232 @@ +import * as _0 from "./audit/v1beta1/audit.js"; +import * as _1 from "./audit/v1beta2/audit.js"; +import * as _2 from "./audit/v1beta2/genesis.js"; +import * as _3 from "./audit/v1beta2/query.js"; +import * as _4 from "./base/v1beta1/attribute.js"; +import * as _5 from "./base/v1beta1/endpoint.js"; +import * as _6 from "./base/v1beta1/resource.js"; +import * as _7 from "./base/v1beta1/resourcevalue.js"; +import * as _8 from "./base/v1beta2/attribute.js"; +import * as _9 from "./base/v1beta2/endpoint.js"; +import * as _10 from "./base/v1beta2/resource.js"; +import * as _11 from "./base/v1beta2/resourceunits.js"; +import * as _12 from "./base/v1beta2/resourcevalue.js"; +import * as _13 from "./cert/v1beta2/cert.js"; +import * as _14 from "./cert/v1beta2/genesis.js"; +import * as _15 from "./cert/v1beta2/query.js"; +import * as _16 from "./deployment/v1beta1/authz.js"; +import * as _17 from "./deployment/v1beta1/deployment.js"; +import * as _18 from "./deployment/v1beta1/genesis.js"; +import * as _19 from "./deployment/v1beta1/group.js"; +import * as _20 from "./deployment/v1beta1/params.js"; +import * as _21 from "./deployment/v1beta1/query.js"; +import * as _22 from "./deployment/v1beta2/authz.js"; +import * as _23 from "./deployment/v1beta2/deployment.js"; +import * as _24 from "./deployment/v1beta2/deploymentmsg.js"; +import * as _25 from "./deployment/v1beta2/genesis.js"; +import * as _26 from "./deployment/v1beta2/group.js"; +import * as _27 from "./deployment/v1beta2/groupid.js"; +import * as _28 from "./deployment/v1beta2/groupmsg.js"; +import * as _29 from "./deployment/v1beta2/groupspec.js"; +import * as _30 from "./deployment/v1beta2/params.js"; +import * as _31 from "./deployment/v1beta2/query.js"; +import * as _32 from "./deployment/v1beta2/resource.js"; +import * as _33 from "./deployment/v1beta2/service.js"; +import * as _34 from "./escrow/v1beta1/genesis.js"; +import * as _35 from "./escrow/v1beta1/query.js"; +import * as _36 from "./escrow/v1beta1/types.js"; +import * as _37 from "./escrow/v1beta2/genesis.js"; +import * as _38 from "./escrow/v1beta2/query.js"; +import * as _39 from "./escrow/v1beta2/types.js"; +import * as _40 from "./inflation/v1beta2/genesis.js"; +import * as _41 from "./inflation/v1beta2/params.js"; +import * as _42 from "./market/v1beta2/bid.js"; +import * as _43 from "./market/v1beta2/genesis.js"; +import * as _44 from "./market/v1beta2/lease.js"; +import * as _45 from "./market/v1beta2/order.js"; +import * as _46 from "./market/v1beta2/params.js"; +import * as _47 from "./market/v1beta2/query.js"; +import * as _48 from "./market/v1beta2/service.js"; +import * as _49 from "./provider/v1beta1/provider.js"; +import * as _50 from "./provider/v1beta2/genesis.js"; +import * as _51 from "./provider/v1beta2/provider.js"; +import * as _52 from "./provider/v1beta2/query.js"; +import * as _316 from "./audit/v1beta1/audit.amino.js"; +import * as _317 from "./audit/v1beta2/audit.amino.js"; +import * as _318 from "./cert/v1beta2/cert.amino.js"; +import * as _319 from "./deployment/v1beta2/service.amino.js"; +import * as _320 from "./market/v1beta2/service.amino.js"; +import * as _321 from "./provider/v1beta1/provider.amino.js"; +import * as _322 from "./provider/v1beta2/provider.amino.js"; +import * as _323 from "./audit/v1beta1/audit.registry.js"; +import * as _324 from "./audit/v1beta2/audit.registry.js"; +import * as _325 from "./cert/v1beta2/cert.registry.js"; +import * as _326 from "./deployment/v1beta2/service.registry.js"; +import * as _327 from "./market/v1beta2/service.registry.js"; +import * as _328 from "./provider/v1beta1/provider.registry.js"; +import * as _329 from "./provider/v1beta2/provider.registry.js"; +import * as _330 from "./audit/v1beta2/query.lcd.js"; +import * as _331 from "./cert/v1beta2/query.lcd.js"; +import * as _332 from "./deployment/v1beta1/query.lcd.js"; +import * as _333 from "./deployment/v1beta2/query.lcd.js"; +import * as _334 from "./escrow/v1beta1/query.lcd.js"; +import * as _335 from "./escrow/v1beta2/query.lcd.js"; +import * as _336 from "./market/v1beta2/query.lcd.js"; +import * as _337 from "./provider/v1beta2/query.lcd.js"; +import * as _338 from "./audit/v1beta2/query.rpc.Query.js"; +import * as _339 from "./cert/v1beta2/query.rpc.Query.js"; +import * as _340 from "./deployment/v1beta2/query.rpc.Query.js"; +import * as _341 from "./escrow/v1beta1/query.rpc.Query.js"; +import * as _342 from "./escrow/v1beta2/query.rpc.Query.js"; +import * as _343 from "./market/v1beta2/query.rpc.Query.js"; +import * as _344 from "./provider/v1beta2/query.rpc.Query.js"; +import * as _345 from "./audit/v1beta1/audit.rpc.msg.js"; +import * as _346 from "./audit/v1beta2/audit.rpc.msg.js"; +import * as _347 from "./cert/v1beta2/cert.rpc.msg.js"; +import * as _348 from "./deployment/v1beta2/service.rpc.msg.js"; +import * as _349 from "./market/v1beta2/service.rpc.msg.js"; +import * as _350 from "./provider/v1beta1/provider.rpc.msg.js"; +import * as _351 from "./provider/v1beta2/provider.rpc.msg.js"; +import * as _352 from "./cert/v1beta2/query.pinia.store.js"; +import * as _536 from "./lcd.js"; +import * as _537 from "./rpc.query.js"; +import * as _538 from "./rpc.tx.js"; +export namespace akash { + export namespace audit { + export const v1beta1 = { + ..._0, + ..._316, + ..._323, + ..._345 + }; + export const v1beta2 = { + ..._1, + ..._2, + ..._3, + ..._317, + ..._324, + ..._330, + ..._338, + ..._346 + }; + } + export namespace base { + export const v1beta1 = { + ..._4, + ..._5, + ..._6, + ..._7 + }; + export const v1beta2 = { + ..._8, + ..._9, + ..._10, + ..._11, + ..._12 + }; + } + export namespace cert { + export const v1beta2 = { + ..._13, + ..._14, + ..._15, + ..._318, + ..._325, + ..._331, + ..._339, + ..._347, + ..._352 + }; + } + export namespace deployment { + export const v1beta1 = { + ..._16, + ..._17, + ..._18, + ..._19, + ..._20, + ..._21, + ..._332 + }; + export const v1beta2 = { + ..._22, + ..._23, + ..._24, + ..._25, + ..._26, + ..._27, + ..._28, + ..._29, + ..._30, + ..._31, + ..._32, + ..._33, + ..._319, + ..._326, + ..._333, + ..._340, + ..._348 + }; + } + export namespace escrow { + export const v1beta1 = { + ..._34, + ..._35, + ..._36, + ..._334, + ..._341 + }; + export const v1beta2 = { + ..._37, + ..._38, + ..._39, + ..._335, + ..._342 + }; + } + export namespace inflation { + export const v1beta2 = { + ..._40, + ..._41 + }; + } + export namespace market { + export const v1beta2 = { + ..._42, + ..._43, + ..._44, + ..._45, + ..._46, + ..._47, + ..._48, + ..._320, + ..._327, + ..._336, + ..._343, + ..._349 + }; + } + export namespace provider { + export const v1beta1 = { + ..._49, + ..._321, + ..._328, + ..._350 + }; + export const v1beta2 = { + ..._50, + ..._51, + ..._52, + ..._322, + ..._329, + ..._337, + ..._344, + ..._351 + }; + } + export const ClientFactory = { + ..._536, + ..._537, + ..._538 + }; +} \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/cert/v1beta2/cert.amino.ts b/__fixtures__/v-next/outputicjsdeps/akash/cert/v1beta2/cert.amino.ts new file mode 100644 index 0000000000..463d6a2ebf --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/cert/v1beta2/cert.amino.ts @@ -0,0 +1,70 @@ +/* eslint-disable */ +import { ReadOnlyAminoMsg as AminoMsg } from "@interchainjs/ReadOnlyAminoMsg"; +import { CertificateID, CertificateIDSDKType, MsgCreateCertificate, MsgCreateCertificateSDKType, MsgRevokeCertificate, MsgRevokeCertificateSDKType } from "./cert.js"; +export interface MsgCreateCertificateAminoType extends AminoMsg { + type: "akash/cert/v1beta2/testonly-create-certificate"; + value: { + owner: string; + cert: Uint8Array; + pubkey: Uint8Array; + }; +} +export interface MsgRevokeCertificateAminoType extends AminoMsg { + type: "akash/cert/v1beta2/testonly-revoke-certificate"; + value: { + id: { + owner: string; + serial: string; + }; + }; +} +export const AminoConverter = { + "/akash.cert.v1beta2.MsgCreateCertificate": { + aminoType: "akash/cert/v1beta2/testonly-create-certificate", + toAmino: ({ + owner, + cert, + pubkey + }: MsgCreateCertificate): MsgCreateCertificateAminoType["value"] => { + return { + owner, + cert, + pubkey + }; + }, + fromAmino: ({ + owner, + cert, + pubkey + }: MsgCreateCertificateAminoType["value"]): MsgCreateCertificate => { + return { + owner, + cert, + pubkey + }; + } + }, + "/akash.cert.v1beta2.MsgRevokeCertificate": { + aminoType: "akash/cert/v1beta2/testonly-revoke-certificate", + toAmino: ({ + id + }: MsgRevokeCertificate): MsgRevokeCertificateAminoType["value"] => { + return { + id: { + owner: id.owner, + serial: id.serial + } + }; + }, + fromAmino: ({ + id + }: MsgRevokeCertificateAminoType["value"]): MsgRevokeCertificate => { + return { + id: { + owner: id.owner, + serial: id.serial + } + }; + } + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/cert/v1beta2/cert.registry.ts b/__fixtures__/v-next/outputicjsdeps/akash/cert/v1beta2/cert.registry.ts new file mode 100644 index 0000000000..08519e3655 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/cert/v1beta2/cert.registry.ts @@ -0,0 +1,80 @@ +import { GeneratedType, Registry } from "@cosmjs/proto-signing"; +import { MsgCreateCertificate, MsgCreateCertificateSDKType, MsgRevokeCertificate, MsgRevokeCertificateSDKType } from "./cert.js"; +export const registry: ReadonlyArray<[string, GeneratedType]> = [["/akash.cert.v1beta2.MsgCreateCertificate", MsgCreateCertificate], ["/akash.cert.v1beta2.MsgRevokeCertificate", MsgRevokeCertificate]]; +export const load = (protoRegistry: Registry) => { + registry.forEach(([typeUrl, mod]) => { + protoRegistry.register(typeUrl, mod); + }); +}; +export const MessageComposer = { + encoded: { + createCertificate(value: MsgCreateCertificate) { + return { + typeUrl: "/akash.cert.v1beta2.MsgCreateCertificate", + value: MsgCreateCertificate.encode(value).finish() + }; + }, + revokeCertificate(value: MsgRevokeCertificate) { + return { + typeUrl: "/akash.cert.v1beta2.MsgRevokeCertificate", + value: MsgRevokeCertificate.encode(value).finish() + }; + } + }, + withTypeUrl: { + createCertificate(value: MsgCreateCertificate) { + return { + typeUrl: "/akash.cert.v1beta2.MsgCreateCertificate", + value + }; + }, + revokeCertificate(value: MsgRevokeCertificate) { + return { + typeUrl: "/akash.cert.v1beta2.MsgRevokeCertificate", + value + }; + } + }, + toJSON: { + createCertificate(value: MsgCreateCertificate) { + return { + typeUrl: "/akash.cert.v1beta2.MsgCreateCertificate", + value: MsgCreateCertificate.toJSON(value) + }; + }, + revokeCertificate(value: MsgRevokeCertificate) { + return { + typeUrl: "/akash.cert.v1beta2.MsgRevokeCertificate", + value: MsgRevokeCertificate.toJSON(value) + }; + } + }, + fromJSON: { + createCertificate(value: any) { + return { + typeUrl: "/akash.cert.v1beta2.MsgCreateCertificate", + value: MsgCreateCertificate.fromJSON(value) + }; + }, + revokeCertificate(value: any) { + return { + typeUrl: "/akash.cert.v1beta2.MsgRevokeCertificate", + value: MsgRevokeCertificate.fromJSON(value) + }; + } + }, + fromPartial: { + createCertificate(value: MsgCreateCertificate) { + return { + typeUrl: "/akash.cert.v1beta2.MsgCreateCertificate", + value: MsgCreateCertificate.fromPartial(value) + }; + }, + revokeCertificate(value: MsgRevokeCertificate) { + return { + typeUrl: "/akash.cert.v1beta2.MsgRevokeCertificate", + value: MsgRevokeCertificate.fromPartial(value) + }; + } + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/cert/v1beta2/cert.rpc.func.ts b/__fixtures__/v-next/outputicjsdeps/akash/cert/v1beta2/cert.rpc.func.ts new file mode 100644 index 0000000000..c89045581b --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/cert/v1beta2/cert.rpc.func.ts @@ -0,0 +1,22 @@ +import { buildTx, SigningClientResolver } from "../../../helper-func-types"; +import { buildUseMutation } from "../../../react-query"; +import { toEncoders, toConverters } from "@interchainjs/cosmos/utils"; +import { MsgCreateCertificate, MsgRevokeCertificate } from "./cert"; +export const createCreateCertificate = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgCreateCertificate.typeUrl, + encoders: toEncoders(MsgCreateCertificate), + converters: toConverters(MsgCreateCertificate) +}); +export const useCreateCertificate = buildUseMutation({ + builderMutationFn: createCreateCertificate +}); +export const createRevokeCertificate = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgRevokeCertificate.typeUrl, + encoders: toEncoders(MsgRevokeCertificate), + converters: toConverters(MsgRevokeCertificate) +}); +export const useRevokeCertificate = buildUseMutation({ + builderMutationFn: createRevokeCertificate +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/cert/v1beta2/cert.rpc.msg.ts b/__fixtures__/v-next/outputicjsdeps/akash/cert/v1beta2/cert.rpc.msg.ts new file mode 100644 index 0000000000..2ac8d153a7 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/cert/v1beta2/cert.rpc.msg.ts @@ -0,0 +1,31 @@ +import { Rpc } from "../../../helpers.js"; +import { BinaryReader } from "../../../binary.js"; +import { MsgCreateCertificate, MsgCreateCertificateSDKType, MsgCreateCertificateResponse, MsgCreateCertificateResponseSDKType, MsgRevokeCertificate, MsgRevokeCertificateSDKType, MsgRevokeCertificateResponse, MsgRevokeCertificateResponseSDKType } from "./cert.js"; +/** Msg defines the provider Msg service */ +export interface Msg { + /** CreateCertificate defines a method to create new certificate given proper inputs. */ + createCertificate(request: MsgCreateCertificate): Promise; + /** RevokeCertificate defines a method to revoke the certificate */ + revokeCertificate(request: MsgRevokeCertificate): Promise; +} +export class MsgClientImpl implements Msg { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + } + /* CreateCertificate defines a method to create new certificate given proper inputs. */ + createCertificate = async (request: MsgCreateCertificate): Promise => { + const data = MsgCreateCertificate.encode(request).finish(); + const promise = this.rpc.request("akash.cert.v1beta2.Msg", "CreateCertificate", data); + return promise.then(data => MsgCreateCertificateResponse.decode(new BinaryReader(data))); + }; + /* RevokeCertificate defines a method to revoke the certificate */ + revokeCertificate = async (request: MsgRevokeCertificate): Promise => { + const data = MsgRevokeCertificate.encode(request).finish(); + const promise = this.rpc.request("akash.cert.v1beta2.Msg", "RevokeCertificate", data); + return promise.then(data => MsgRevokeCertificateResponse.decode(new BinaryReader(data))); + }; +} +export const createClientImpl = (rpc: Rpc) => { + return new MsgClientImpl(rpc); +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/cert/v1beta2/cert.ts b/__fixtures__/v-next/outputicjsdeps/akash/cert/v1beta2/cert.ts new file mode 100644 index 0000000000..178e9adc0c --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/cert/v1beta2/cert.ts @@ -0,0 +1,874 @@ +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial, Exact, bytesFromBase64, base64FromBytes } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "akash.cert.v1beta2"; +/** State is an enum which refers to state of deployment */ +export enum Certificate_State { + /** invalid - Prefix should start with 0 in enum. So declaring dummy state */ + invalid = 0, + /** valid - CertificateValid denotes state for deployment active */ + valid = 1, + /** revoked - CertificateRevoked denotes state for deployment closed */ + revoked = 2, + UNRECOGNIZED = -1, +} +export const Certificate_StateSDKType = Certificate_State; +export function certificate_StateFromJSON(object: any): Certificate_State { + switch (object) { + case 0: + case "invalid": + return Certificate_State.invalid; + case 1: + case "valid": + return Certificate_State.valid; + case 2: + case "revoked": + return Certificate_State.revoked; + case -1: + case "UNRECOGNIZED": + default: + return Certificate_State.UNRECOGNIZED; + } +} +export function certificate_StateToJSON(object: Certificate_State): string { + switch (object) { + case Certificate_State.invalid: + return "invalid"; + case Certificate_State.valid: + return "valid"; + case Certificate_State.revoked: + return "revoked"; + case Certificate_State.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** CertificateID stores owner and sequence number */ +export interface CertificateID { + owner: string; + serial: string; +} +export interface CertificateIDProtoMsg { + typeUrl: "/akash.cert.v1beta2.CertificateID"; + value: Uint8Array; +} +/** CertificateID stores owner and sequence number */ +export interface CertificateIDSDKType { + owner: string; + serial: string; +} +/** Certificate stores state, certificate and it's public key */ +export interface Certificate { + state: Certificate_State; + cert: Uint8Array; + pubkey: Uint8Array; +} +export interface CertificateProtoMsg { + typeUrl: "/akash.cert.v1beta2.Certificate"; + value: Uint8Array; +} +/** Certificate stores state, certificate and it's public key */ +export interface CertificateSDKType { + state: Certificate_State; + cert: Uint8Array; + pubkey: Uint8Array; +} +/** CertificateFilter defines filters used to filter certificates */ +export interface CertificateFilter { + owner: string; + serial: string; + state: string; +} +export interface CertificateFilterProtoMsg { + typeUrl: "/akash.cert.v1beta2.CertificateFilter"; + value: Uint8Array; +} +/** CertificateFilter defines filters used to filter certificates */ +export interface CertificateFilterSDKType { + owner: string; + serial: string; + state: string; +} +/** MsgCreateCertificate defines an SDK message for creating certificate */ +export interface MsgCreateCertificate { + owner: string; + cert: Uint8Array; + pubkey: Uint8Array; +} +export interface MsgCreateCertificateProtoMsg { + typeUrl: "/akash.cert.v1beta2.MsgCreateCertificate"; + value: Uint8Array; +} +/** MsgCreateCertificate defines an SDK message for creating certificate */ +export interface MsgCreateCertificateSDKType { + owner: string; + cert: Uint8Array; + pubkey: Uint8Array; +} +/** MsgCreateCertificateResponse defines the Msg/CreateCertificate response type. */ +export interface MsgCreateCertificateResponse {} +export interface MsgCreateCertificateResponseProtoMsg { + typeUrl: "/akash.cert.v1beta2.MsgCreateCertificateResponse"; + value: Uint8Array; +} +/** MsgCreateCertificateResponse defines the Msg/CreateCertificate response type. */ +export interface MsgCreateCertificateResponseSDKType {} +/** MsgRevokeCertificate defines an SDK message for revoking certificate */ +export interface MsgRevokeCertificate { + id: CertificateID; +} +export interface MsgRevokeCertificateProtoMsg { + typeUrl: "/akash.cert.v1beta2.MsgRevokeCertificate"; + value: Uint8Array; +} +/** MsgRevokeCertificate defines an SDK message for revoking certificate */ +export interface MsgRevokeCertificateSDKType { + id: CertificateIDSDKType; +} +/** MsgRevokeCertificateResponse defines the Msg/RevokeCertificate response type. */ +export interface MsgRevokeCertificateResponse {} +export interface MsgRevokeCertificateResponseProtoMsg { + typeUrl: "/akash.cert.v1beta2.MsgRevokeCertificateResponse"; + value: Uint8Array; +} +/** MsgRevokeCertificateResponse defines the Msg/RevokeCertificate response type. */ +export interface MsgRevokeCertificateResponseSDKType {} +function createBaseCertificateID(): CertificateID { + return { + owner: "", + serial: "" + }; +} +export const CertificateID = { + typeUrl: "/akash.cert.v1beta2.CertificateID", + encode(message: CertificateID, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.owner !== undefined) { + writer.uint32(10).string(message.owner); + } + if (message.serial !== undefined) { + writer.uint32(18).string(message.serial); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): CertificateID { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCertificateID(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.owner = reader.string(); + break; + case 2: + message.serial = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): CertificateID { + const obj = createBaseCertificateID(); + if (isSet(object.owner)) obj.owner = String(object.owner); + if (isSet(object.serial)) obj.serial = String(object.serial); + return obj; + }, + toJSON(message: CertificateID): JsonSafe { + const obj: any = {}; + message.owner !== undefined && (obj.owner = message.owner); + message.serial !== undefined && (obj.serial = message.serial); + return obj; + }, + fromPartial, I>>(object: I): CertificateID { + const message = createBaseCertificateID(); + message.owner = object.owner ?? ""; + message.serial = object.serial ?? ""; + return message; + }, + fromSDK(object: CertificateIDSDKType): CertificateID { + return { + owner: object?.owner, + serial: object?.serial + }; + }, + fromSDKJSON(object: any): CertificateIDSDKType { + return { + owner: isSet(object.owner) ? String(object.owner) : "", + serial: isSet(object.serial) ? String(object.serial) : "" + }; + }, + toSDK(message: CertificateID): CertificateIDSDKType { + const obj: any = {}; + obj.owner = message.owner; + obj.serial = message.serial; + return obj; + }, + fromAmino(object: CertificateIDAmino): CertificateID { + const message = createBaseCertificateID(); + if (object.owner !== undefined && object.owner !== null) { + message.owner = object.owner; + } + if (object.serial !== undefined && object.serial !== null) { + message.serial = object.serial; + } + return message; + }, + toAmino(message: CertificateID): CertificateIDAmino { + const obj: any = {}; + obj.owner = message.owner ?? ""; + obj.serial = message.serial ?? ""; + return obj; + }, + fromAminoMsg(object: CertificateIDAminoMsg): CertificateID { + return CertificateID.fromAmino(object.value); + }, + toAminoMsg(message: CertificateID): CertificateIDAminoMsg { + return { + type: "akash/cert/v1beta2/certificate-i-d", + value: CertificateID.toAmino(message) + }; + }, + fromProtoMsg(message: CertificateIDProtoMsg): CertificateID { + return CertificateID.decode(message.value); + }, + toProto(message: CertificateID): Uint8Array { + return CertificateID.encode(message).finish(); + }, + toProtoMsg(message: CertificateID): CertificateIDProtoMsg { + return { + typeUrl: "/akash.cert.v1beta2.CertificateID", + value: CertificateID.encode(message).finish() + }; + } +}; +function createBaseCertificate(): Certificate { + return { + state: 0, + cert: new Uint8Array(), + pubkey: new Uint8Array() + }; +} +export const Certificate = { + typeUrl: "/akash.cert.v1beta2.Certificate", + encode(message: Certificate, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.state !== 0) { + writer.uint32(16).int32(message.state); + } + if (message.cert.length !== 0) { + writer.uint32(26).bytes(message.cert); + } + if (message.pubkey.length !== 0) { + writer.uint32(34).bytes(message.pubkey); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Certificate { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCertificate(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.state = (reader.int32() as any); + break; + case 3: + message.cert = reader.bytes(); + break; + case 4: + message.pubkey = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Certificate { + const obj = createBaseCertificate(); + if (isSet(object.state)) obj.state = certificate_StateFromJSON(object.state); + if (isSet(object.cert)) obj.cert = bytesFromBase64(object.cert); + if (isSet(object.pubkey)) obj.pubkey = bytesFromBase64(object.pubkey); + return obj; + }, + toJSON(message: Certificate): JsonSafe { + const obj: any = {}; + message.state !== undefined && (obj.state = certificate_StateToJSON(message.state)); + message.cert !== undefined && (obj.cert = base64FromBytes(message.cert !== undefined ? message.cert : new Uint8Array())); + message.pubkey !== undefined && (obj.pubkey = base64FromBytes(message.pubkey !== undefined ? message.pubkey : new Uint8Array())); + return obj; + }, + fromPartial, I>>(object: I): Certificate { + const message = createBaseCertificate(); + message.state = object.state ?? 0; + message.cert = object.cert ?? new Uint8Array(); + message.pubkey = object.pubkey ?? new Uint8Array(); + return message; + }, + fromSDK(object: CertificateSDKType): Certificate { + return { + state: isSet(object.state) ? certificate_StateFromJSON(object.state) : -1, + cert: object?.cert, + pubkey: object?.pubkey + }; + }, + fromSDKJSON(object: any): CertificateSDKType { + return { + state: isSet(object.state) ? certificate_StateFromJSON(object.state) : -1, + cert: isSet(object.cert) ? bytesFromBase64(object.cert) : new Uint8Array(), + pubkey: isSet(object.pubkey) ? bytesFromBase64(object.pubkey) : new Uint8Array() + }; + }, + toSDK(message: Certificate): CertificateSDKType { + const obj: any = {}; + message.state !== undefined && (obj.state = certificate_StateToJSON(message.state)); + obj.cert = message.cert; + obj.pubkey = message.pubkey; + return obj; + }, + fromAmino(object: CertificateAmino): Certificate { + const message = createBaseCertificate(); + if (object.state !== undefined && object.state !== null) { + message.state = object.state; + } + if (object.cert !== undefined && object.cert !== null) { + message.cert = bytesFromBase64(object.cert); + } + if (object.pubkey !== undefined && object.pubkey !== null) { + message.pubkey = bytesFromBase64(object.pubkey); + } + return message; + }, + toAmino(message: Certificate): CertificateAmino { + const obj: any = {}; + obj.state = message.state ?? 0; + obj.cert = message.cert ? base64FromBytes(message.cert) : ""; + obj.pubkey = message.pubkey ? base64FromBytes(message.pubkey) : ""; + return obj; + }, + fromAminoMsg(object: CertificateAminoMsg): Certificate { + return Certificate.fromAmino(object.value); + }, + toAminoMsg(message: Certificate): CertificateAminoMsg { + return { + type: "akash/cert/v1beta2/certificate", + value: Certificate.toAmino(message) + }; + }, + fromProtoMsg(message: CertificateProtoMsg): Certificate { + return Certificate.decode(message.value); + }, + toProto(message: Certificate): Uint8Array { + return Certificate.encode(message).finish(); + }, + toProtoMsg(message: Certificate): CertificateProtoMsg { + return { + typeUrl: "/akash.cert.v1beta2.Certificate", + value: Certificate.encode(message).finish() + }; + } +}; +function createBaseCertificateFilter(): CertificateFilter { + return { + owner: "", + serial: "", + state: "" + }; +} +export const CertificateFilter = { + typeUrl: "/akash.cert.v1beta2.CertificateFilter", + encode(message: CertificateFilter, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.owner !== undefined) { + writer.uint32(10).string(message.owner); + } + if (message.serial !== undefined) { + writer.uint32(18).string(message.serial); + } + if (message.state !== undefined) { + writer.uint32(26).string(message.state); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): CertificateFilter { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCertificateFilter(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.owner = reader.string(); + break; + case 2: + message.serial = reader.string(); + break; + case 3: + message.state = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): CertificateFilter { + const obj = createBaseCertificateFilter(); + if (isSet(object.owner)) obj.owner = String(object.owner); + if (isSet(object.serial)) obj.serial = String(object.serial); + if (isSet(object.state)) obj.state = String(object.state); + return obj; + }, + toJSON(message: CertificateFilter): JsonSafe { + const obj: any = {}; + message.owner !== undefined && (obj.owner = message.owner); + message.serial !== undefined && (obj.serial = message.serial); + message.state !== undefined && (obj.state = message.state); + return obj; + }, + fromPartial, I>>(object: I): CertificateFilter { + const message = createBaseCertificateFilter(); + message.owner = object.owner ?? ""; + message.serial = object.serial ?? ""; + message.state = object.state ?? ""; + return message; + }, + fromSDK(object: CertificateFilterSDKType): CertificateFilter { + return { + owner: object?.owner, + serial: object?.serial, + state: object?.state + }; + }, + fromSDKJSON(object: any): CertificateFilterSDKType { + return { + owner: isSet(object.owner) ? String(object.owner) : "", + serial: isSet(object.serial) ? String(object.serial) : "", + state: isSet(object.state) ? String(object.state) : "" + }; + }, + toSDK(message: CertificateFilter): CertificateFilterSDKType { + const obj: any = {}; + obj.owner = message.owner; + obj.serial = message.serial; + obj.state = message.state; + return obj; + }, + fromAmino(object: CertificateFilterAmino): CertificateFilter { + const message = createBaseCertificateFilter(); + if (object.owner !== undefined && object.owner !== null) { + message.owner = object.owner; + } + if (object.serial !== undefined && object.serial !== null) { + message.serial = object.serial; + } + if (object.state !== undefined && object.state !== null) { + message.state = object.state; + } + return message; + }, + toAmino(message: CertificateFilter): CertificateFilterAmino { + const obj: any = {}; + obj.owner = message.owner ?? ""; + obj.serial = message.serial ?? ""; + obj.state = message.state ?? ""; + return obj; + }, + fromAminoMsg(object: CertificateFilterAminoMsg): CertificateFilter { + return CertificateFilter.fromAmino(object.value); + }, + toAminoMsg(message: CertificateFilter): CertificateFilterAminoMsg { + return { + type: "akash/cert/v1beta2/certificate-filter", + value: CertificateFilter.toAmino(message) + }; + }, + fromProtoMsg(message: CertificateFilterProtoMsg): CertificateFilter { + return CertificateFilter.decode(message.value); + }, + toProto(message: CertificateFilter): Uint8Array { + return CertificateFilter.encode(message).finish(); + }, + toProtoMsg(message: CertificateFilter): CertificateFilterProtoMsg { + return { + typeUrl: "/akash.cert.v1beta2.CertificateFilter", + value: CertificateFilter.encode(message).finish() + }; + } +}; +function createBaseMsgCreateCertificate(): MsgCreateCertificate { + return { + owner: "", + cert: new Uint8Array(), + pubkey: new Uint8Array() + }; +} +export const MsgCreateCertificate = { + typeUrl: "/akash.cert.v1beta2.MsgCreateCertificate", + encode(message: MsgCreateCertificate, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.owner !== undefined) { + writer.uint32(10).string(message.owner); + } + if (message.cert.length !== 0) { + writer.uint32(18).bytes(message.cert); + } + if (message.pubkey.length !== 0) { + writer.uint32(26).bytes(message.pubkey); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgCreateCertificate { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgCreateCertificate(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.owner = reader.string(); + break; + case 2: + message.cert = reader.bytes(); + break; + case 3: + message.pubkey = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgCreateCertificate { + const obj = createBaseMsgCreateCertificate(); + if (isSet(object.owner)) obj.owner = String(object.owner); + if (isSet(object.cert)) obj.cert = bytesFromBase64(object.cert); + if (isSet(object.pubkey)) obj.pubkey = bytesFromBase64(object.pubkey); + return obj; + }, + toJSON(message: MsgCreateCertificate): JsonSafe { + const obj: any = {}; + message.owner !== undefined && (obj.owner = message.owner); + message.cert !== undefined && (obj.cert = base64FromBytes(message.cert !== undefined ? message.cert : new Uint8Array())); + message.pubkey !== undefined && (obj.pubkey = base64FromBytes(message.pubkey !== undefined ? message.pubkey : new Uint8Array())); + return obj; + }, + fromPartial, I>>(object: I): MsgCreateCertificate { + const message = createBaseMsgCreateCertificate(); + message.owner = object.owner ?? ""; + message.cert = object.cert ?? new Uint8Array(); + message.pubkey = object.pubkey ?? new Uint8Array(); + return message; + }, + fromSDK(object: MsgCreateCertificateSDKType): MsgCreateCertificate { + return { + owner: object?.owner, + cert: object?.cert, + pubkey: object?.pubkey + }; + }, + fromSDKJSON(object: any): MsgCreateCertificateSDKType { + return { + owner: isSet(object.owner) ? String(object.owner) : "", + cert: isSet(object.cert) ? bytesFromBase64(object.cert) : new Uint8Array(), + pubkey: isSet(object.pubkey) ? bytesFromBase64(object.pubkey) : new Uint8Array() + }; + }, + toSDK(message: MsgCreateCertificate): MsgCreateCertificateSDKType { + const obj: any = {}; + obj.owner = message.owner; + obj.cert = message.cert; + obj.pubkey = message.pubkey; + return obj; + }, + fromAmino(object: MsgCreateCertificateAmino): MsgCreateCertificate { + const message = createBaseMsgCreateCertificate(); + if (object.owner !== undefined && object.owner !== null) { + message.owner = object.owner; + } + if (object.cert !== undefined && object.cert !== null) { + message.cert = bytesFromBase64(object.cert); + } + if (object.pubkey !== undefined && object.pubkey !== null) { + message.pubkey = bytesFromBase64(object.pubkey); + } + return message; + }, + toAmino(message: MsgCreateCertificate): MsgCreateCertificateAmino { + const obj: any = {}; + obj.owner = message.owner ?? ""; + obj.cert = message.cert ? base64FromBytes(message.cert) : ""; + obj.pubkey = message.pubkey ? base64FromBytes(message.pubkey) : ""; + return obj; + }, + fromAminoMsg(object: MsgCreateCertificateAminoMsg): MsgCreateCertificate { + return MsgCreateCertificate.fromAmino(object.value); + }, + toAminoMsg(message: MsgCreateCertificate): MsgCreateCertificateAminoMsg { + return { + type: "akash/cert/v1beta2/testonly-create-certificate", + value: MsgCreateCertificate.toAmino(message) + }; + }, + fromProtoMsg(message: MsgCreateCertificateProtoMsg): MsgCreateCertificate { + return MsgCreateCertificate.decode(message.value); + }, + toProto(message: MsgCreateCertificate): Uint8Array { + return MsgCreateCertificate.encode(message).finish(); + }, + toProtoMsg(message: MsgCreateCertificate): MsgCreateCertificateProtoMsg { + return { + typeUrl: "/akash.cert.v1beta2.MsgCreateCertificate", + value: MsgCreateCertificate.encode(message).finish() + }; + } +}; +function createBaseMsgCreateCertificateResponse(): MsgCreateCertificateResponse { + return {}; +} +export const MsgCreateCertificateResponse = { + typeUrl: "/akash.cert.v1beta2.MsgCreateCertificateResponse", + encode(_: MsgCreateCertificateResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgCreateCertificateResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgCreateCertificateResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgCreateCertificateResponse { + const obj = createBaseMsgCreateCertificateResponse(); + return obj; + }, + toJSON(_: MsgCreateCertificateResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): MsgCreateCertificateResponse { + const message = createBaseMsgCreateCertificateResponse(); + return message; + }, + fromSDK(_: MsgCreateCertificateResponseSDKType): MsgCreateCertificateResponse { + return {}; + }, + fromSDKJSON(_: any): MsgCreateCertificateResponseSDKType { + return {}; + }, + toSDK(_: MsgCreateCertificateResponse): MsgCreateCertificateResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgCreateCertificateResponseAmino): MsgCreateCertificateResponse { + const message = createBaseMsgCreateCertificateResponse(); + return message; + }, + toAmino(_: MsgCreateCertificateResponse): MsgCreateCertificateResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgCreateCertificateResponseAminoMsg): MsgCreateCertificateResponse { + return MsgCreateCertificateResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgCreateCertificateResponse): MsgCreateCertificateResponseAminoMsg { + return { + type: "akash/cert/v1beta2/testonly-create-certificate-response", + value: MsgCreateCertificateResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgCreateCertificateResponseProtoMsg): MsgCreateCertificateResponse { + return MsgCreateCertificateResponse.decode(message.value); + }, + toProto(message: MsgCreateCertificateResponse): Uint8Array { + return MsgCreateCertificateResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgCreateCertificateResponse): MsgCreateCertificateResponseProtoMsg { + return { + typeUrl: "/akash.cert.v1beta2.MsgCreateCertificateResponse", + value: MsgCreateCertificateResponse.encode(message).finish() + }; + } +}; +function createBaseMsgRevokeCertificate(): MsgRevokeCertificate { + return { + id: CertificateID.fromPartial({}) + }; +} +export const MsgRevokeCertificate = { + typeUrl: "/akash.cert.v1beta2.MsgRevokeCertificate", + encode(message: MsgRevokeCertificate, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.id !== undefined) { + CertificateID.encode(message.id, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgRevokeCertificate { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgRevokeCertificate(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.id = CertificateID.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgRevokeCertificate { + const obj = createBaseMsgRevokeCertificate(); + if (isSet(object.id)) obj.id = CertificateID.fromJSON(object.id); + return obj; + }, + toJSON(message: MsgRevokeCertificate): JsonSafe { + const obj: any = {}; + message.id !== undefined && (obj.id = message.id ? CertificateID.toJSON(message.id) : undefined); + return obj; + }, + fromPartial, I>>(object: I): MsgRevokeCertificate { + const message = createBaseMsgRevokeCertificate(); + if (object.id !== undefined && object.id !== null) { + message.id = CertificateID.fromPartial(object.id); + } + return message; + }, + fromSDK(object: MsgRevokeCertificateSDKType): MsgRevokeCertificate { + return { + id: object.id ? CertificateID.fromSDK(object.id) : undefined + }; + }, + fromSDKJSON(object: any): MsgRevokeCertificateSDKType { + return { + id: isSet(object.id) ? CertificateID.fromSDKJSON(object.id) : undefined + }; + }, + toSDK(message: MsgRevokeCertificate): MsgRevokeCertificateSDKType { + const obj: any = {}; + message.id !== undefined && (obj.id = message.id ? CertificateID.toSDK(message.id) : undefined); + return obj; + }, + fromAmino(object: MsgRevokeCertificateAmino): MsgRevokeCertificate { + const message = createBaseMsgRevokeCertificate(); + if (object.id !== undefined && object.id !== null) { + message.id = CertificateID.fromAmino(object.id); + } + return message; + }, + toAmino(message: MsgRevokeCertificate): MsgRevokeCertificateAmino { + const obj: any = {}; + obj.id = message.id ? CertificateID.toAmino(message.id) : CertificateID.toAmino(CertificateID.fromPartial({})); + return obj; + }, + fromAminoMsg(object: MsgRevokeCertificateAminoMsg): MsgRevokeCertificate { + return MsgRevokeCertificate.fromAmino(object.value); + }, + toAminoMsg(message: MsgRevokeCertificate): MsgRevokeCertificateAminoMsg { + return { + type: "akash/cert/v1beta2/testonly-revoke-certificate", + value: MsgRevokeCertificate.toAmino(message) + }; + }, + fromProtoMsg(message: MsgRevokeCertificateProtoMsg): MsgRevokeCertificate { + return MsgRevokeCertificate.decode(message.value); + }, + toProto(message: MsgRevokeCertificate): Uint8Array { + return MsgRevokeCertificate.encode(message).finish(); + }, + toProtoMsg(message: MsgRevokeCertificate): MsgRevokeCertificateProtoMsg { + return { + typeUrl: "/akash.cert.v1beta2.MsgRevokeCertificate", + value: MsgRevokeCertificate.encode(message).finish() + }; + } +}; +function createBaseMsgRevokeCertificateResponse(): MsgRevokeCertificateResponse { + return {}; +} +export const MsgRevokeCertificateResponse = { + typeUrl: "/akash.cert.v1beta2.MsgRevokeCertificateResponse", + encode(_: MsgRevokeCertificateResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgRevokeCertificateResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgRevokeCertificateResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgRevokeCertificateResponse { + const obj = createBaseMsgRevokeCertificateResponse(); + return obj; + }, + toJSON(_: MsgRevokeCertificateResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): MsgRevokeCertificateResponse { + const message = createBaseMsgRevokeCertificateResponse(); + return message; + }, + fromSDK(_: MsgRevokeCertificateResponseSDKType): MsgRevokeCertificateResponse { + return {}; + }, + fromSDKJSON(_: any): MsgRevokeCertificateResponseSDKType { + return {}; + }, + toSDK(_: MsgRevokeCertificateResponse): MsgRevokeCertificateResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgRevokeCertificateResponseAmino): MsgRevokeCertificateResponse { + const message = createBaseMsgRevokeCertificateResponse(); + return message; + }, + toAmino(_: MsgRevokeCertificateResponse): MsgRevokeCertificateResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgRevokeCertificateResponseAminoMsg): MsgRevokeCertificateResponse { + return MsgRevokeCertificateResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgRevokeCertificateResponse): MsgRevokeCertificateResponseAminoMsg { + return { + type: "akash/cert/v1beta2/testonly-revoke-certificate-response", + value: MsgRevokeCertificateResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgRevokeCertificateResponseProtoMsg): MsgRevokeCertificateResponse { + return MsgRevokeCertificateResponse.decode(message.value); + }, + toProto(message: MsgRevokeCertificateResponse): Uint8Array { + return MsgRevokeCertificateResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgRevokeCertificateResponse): MsgRevokeCertificateResponseProtoMsg { + return { + typeUrl: "/akash.cert.v1beta2.MsgRevokeCertificateResponse", + value: MsgRevokeCertificateResponse.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/cert/v1beta2/genesis.ts b/__fixtures__/v-next/outputicjsdeps/akash/cert/v1beta2/genesis.ts new file mode 100644 index 0000000000..6961fe42ac --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/cert/v1beta2/genesis.ts @@ -0,0 +1,248 @@ +import { Certificate, CertificateSDKType } from "./cert.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial, Exact } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "akash.cert.v1beta2"; +/** GenesisCertificate defines certificate entry at genesis */ +export interface GenesisCertificate { + owner: string; + certificate: Certificate; +} +export interface GenesisCertificateProtoMsg { + typeUrl: "/akash.cert.v1beta2.GenesisCertificate"; + value: Uint8Array; +} +/** GenesisCertificate defines certificate entry at genesis */ +export interface GenesisCertificateSDKType { + owner: string; + certificate: CertificateSDKType; +} +/** GenesisState defines the basic genesis state used by cert module */ +export interface GenesisState { + certificates: GenesisCertificate[]; +} +export interface GenesisStateProtoMsg { + typeUrl: "/akash.cert.v1beta2.GenesisState"; + value: Uint8Array; +} +/** GenesisState defines the basic genesis state used by cert module */ +export interface GenesisStateSDKType { + certificates: GenesisCertificateSDKType[]; +} +function createBaseGenesisCertificate(): GenesisCertificate { + return { + owner: "", + certificate: Certificate.fromPartial({}) + }; +} +export const GenesisCertificate = { + typeUrl: "/akash.cert.v1beta2.GenesisCertificate", + encode(message: GenesisCertificate, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.owner !== undefined) { + writer.uint32(10).string(message.owner); + } + if (message.certificate !== undefined) { + Certificate.encode(message.certificate, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GenesisCertificate { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGenesisCertificate(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.owner = reader.string(); + break; + case 2: + message.certificate = Certificate.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GenesisCertificate { + const obj = createBaseGenesisCertificate(); + if (isSet(object.owner)) obj.owner = String(object.owner); + if (isSet(object.certificate)) obj.certificate = Certificate.fromJSON(object.certificate); + return obj; + }, + toJSON(message: GenesisCertificate): JsonSafe { + const obj: any = {}; + message.owner !== undefined && (obj.owner = message.owner); + message.certificate !== undefined && (obj.certificate = message.certificate ? Certificate.toJSON(message.certificate) : undefined); + return obj; + }, + fromPartial, I>>(object: I): GenesisCertificate { + const message = createBaseGenesisCertificate(); + message.owner = object.owner ?? ""; + if (object.certificate !== undefined && object.certificate !== null) { + message.certificate = Certificate.fromPartial(object.certificate); + } + return message; + }, + fromSDK(object: GenesisCertificateSDKType): GenesisCertificate { + return { + owner: object?.owner, + certificate: object.certificate ? Certificate.fromSDK(object.certificate) : undefined + }; + }, + fromSDKJSON(object: any): GenesisCertificateSDKType { + return { + owner: isSet(object.owner) ? String(object.owner) : "", + certificate: isSet(object.certificate) ? Certificate.fromSDKJSON(object.certificate) : undefined + }; + }, + toSDK(message: GenesisCertificate): GenesisCertificateSDKType { + const obj: any = {}; + obj.owner = message.owner; + message.certificate !== undefined && (obj.certificate = message.certificate ? Certificate.toSDK(message.certificate) : undefined); + return obj; + }, + fromAmino(object: GenesisCertificateAmino): GenesisCertificate { + const message = createBaseGenesisCertificate(); + if (object.owner !== undefined && object.owner !== null) { + message.owner = object.owner; + } + if (object.certificate !== undefined && object.certificate !== null) { + message.certificate = Certificate.fromAmino(object.certificate); + } + return message; + }, + toAmino(message: GenesisCertificate): GenesisCertificateAmino { + const obj: any = {}; + obj.owner = message.owner ?? ""; + obj.certificate = message.certificate ? Certificate.toAmino(message.certificate) : Certificate.toAmino(Certificate.fromPartial({})); + return obj; + }, + fromAminoMsg(object: GenesisCertificateAminoMsg): GenesisCertificate { + return GenesisCertificate.fromAmino(object.value); + }, + toAminoMsg(message: GenesisCertificate): GenesisCertificateAminoMsg { + return { + type: "akash/cert/v1beta2/genesis-certificate", + value: GenesisCertificate.toAmino(message) + }; + }, + fromProtoMsg(message: GenesisCertificateProtoMsg): GenesisCertificate { + return GenesisCertificate.decode(message.value); + }, + toProto(message: GenesisCertificate): Uint8Array { + return GenesisCertificate.encode(message).finish(); + }, + toProtoMsg(message: GenesisCertificate): GenesisCertificateProtoMsg { + return { + typeUrl: "/akash.cert.v1beta2.GenesisCertificate", + value: GenesisCertificate.encode(message).finish() + }; + } +}; +function createBaseGenesisState(): GenesisState { + return { + certificates: [] + }; +} +export const GenesisState = { + typeUrl: "/akash.cert.v1beta2.GenesisState", + encode(message: GenesisState, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.certificates) { + GenesisCertificate.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GenesisState { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGenesisState(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.certificates.push(GenesisCertificate.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GenesisState { + const obj = createBaseGenesisState(); + if (Array.isArray(object?.certificates)) obj.certificates = object.certificates.map((e: any) => GenesisCertificate.fromJSON(e)); + return obj; + }, + toJSON(message: GenesisState): JsonSafe { + const obj: any = {}; + if (message.certificates) { + obj.certificates = message.certificates.map(e => e ? GenesisCertificate.toJSON(e) : undefined); + } else { + obj.certificates = []; + } + return obj; + }, + fromPartial, I>>(object: I): GenesisState { + const message = createBaseGenesisState(); + message.certificates = object.certificates?.map(e => GenesisCertificate.fromPartial(e)) || []; + return message; + }, + fromSDK(object: GenesisStateSDKType): GenesisState { + return { + certificates: Array.isArray(object?.certificates) ? object.certificates.map((e: any) => GenesisCertificate.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): GenesisStateSDKType { + return { + certificates: Array.isArray(object?.certificates) ? object.certificates.map((e: any) => GenesisCertificate.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: GenesisState): GenesisStateSDKType { + const obj: any = {}; + if (message.certificates) { + obj.certificates = message.certificates.map(e => e ? GenesisCertificate.toSDK(e) : undefined); + } else { + obj.certificates = []; + } + return obj; + }, + fromAmino(object: GenesisStateAmino): GenesisState { + const message = createBaseGenesisState(); + message.certificates = object.certificates?.map(e => GenesisCertificate.fromAmino(e)) || []; + return message; + }, + toAmino(message: GenesisState): GenesisStateAmino { + const obj: any = {}; + if (message.certificates) { + obj.certificates = message.certificates.map(e => e ? GenesisCertificate.toAmino(e) : undefined); + } else { + obj.certificates = message.certificates; + } + return obj; + }, + fromAminoMsg(object: GenesisStateAminoMsg): GenesisState { + return GenesisState.fromAmino(object.value); + }, + toAminoMsg(message: GenesisState): GenesisStateAminoMsg { + return { + type: "akash/cert/v1beta2/genesis-state", + value: GenesisState.toAmino(message) + }; + }, + fromProtoMsg(message: GenesisStateProtoMsg): GenesisState { + return GenesisState.decode(message.value); + }, + toProto(message: GenesisState): Uint8Array { + return GenesisState.encode(message).finish(); + }, + toProtoMsg(message: GenesisState): GenesisStateProtoMsg { + return { + typeUrl: "/akash.cert.v1beta2.GenesisState", + value: GenesisState.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/cert/v1beta2/query.lcd.ts b/__fixtures__/v-next/outputicjsdeps/akash/cert/v1beta2/query.lcd.ts new file mode 100644 index 0000000000..c47f74451a --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/cert/v1beta2/query.lcd.ts @@ -0,0 +1,29 @@ +import { CertificateFilter, CertificateFilterSDKType, Certificate, CertificateSDKType } from "./cert.js"; +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../../cosmos/base/query/v1beta1/pagination.js"; +import { setPaginationParams } from "../../../helpers.js"; +import { LCDClient } from "@cosmology/lcd"; +import { QueryCertificatesRequest, QueryCertificatesRequestSDKType, QueryCertificatesResponse, QueryCertificatesResponseSDKType } from "./query.js"; +export class LCDQueryClient { + req: LCDClient; + constructor({ + requestClient + }: { + requestClient: LCDClient; + }) { + this.req = requestClient; + } + /* Certificates queries certificates */ + certificates = async (params: QueryCertificatesRequest): Promise => { + const options: any = { + params: {} + }; + if (typeof params?.filter !== "undefined") { + options.params.filter = params.filter; + } + if (typeof params?.pagination !== "undefined") { + setPaginationParams(options, params.pagination); + } + const endpoint = `akash/cert/v1beta2/certificates/list`; + return QueryCertificatesResponse.fromSDKJSON(await this.req.get(endpoint, options)); + }; +} \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/cert/v1beta2/query.pinia.store.ts b/__fixtures__/v-next/outputicjsdeps/akash/cert/v1beta2/query.pinia.store.ts new file mode 100644 index 0000000000..a9ca08d4c1 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/cert/v1beta2/query.pinia.store.ts @@ -0,0 +1,26 @@ +import { CertificateFilter, CertificateFilterSDKType, Certificate, CertificateSDKType } from "./cert.js"; +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../../cosmos/base/query/v1beta1/pagination.js"; +import { LCDClient } from "@cosmology/lcd"; +import { useEndpoint } from "../../../pinia-endpoint.js"; +import { QueryCertificatesRequest, QueryCertificatesRequestSDKType, QueryCertificatesResponse, QueryCertificatesResponseSDKType } from "./query.js"; +import { defineStore } from "pinia"; +import { LCDQueryClient } from "./query.lcd.js"; +export const usePiniaStore = defineStore('akash/cert/v1beta2/query.proto', { + state: () => { + return { + certificates: ({} as QueryCertificatesResponseSDKType) + }; + }, + getters: { + lcdClient() { + const requestClient = useEndpoint().restClient; + return new LCDQueryClient({ requestClient }); + } + }, + actions: { + async fetchCertificates(param : QueryCertificatesRequestSDKType) { + this.certificates = await this.lcdClient.certificates(param); + return this.certificates; + } + } +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/cert/v1beta2/query.rpc.Query.ts b/__fixtures__/v-next/outputicjsdeps/akash/cert/v1beta2/query.rpc.Query.ts new file mode 100644 index 0000000000..e161d47fa8 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/cert/v1beta2/query.rpc.Query.ts @@ -0,0 +1,76 @@ +import { CertificateFilter, CertificateFilterSDKType, Certificate, CertificateSDKType } from "./cert.js"; +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../../cosmos/base/query/v1beta1/pagination.js"; +import { Rpc } from "../../../helpers.js"; +import { BinaryReader } from "../../../binary.js"; +import { QueryClient, createProtobufRpcClient, ProtobufRpcClient } from "@cosmjs/stargate"; +import { ReactQueryParams } from "../../../react-query.js"; +import { useQuery } from "@tanstack/react-query"; +import { QueryStore, MobxResponse } from "../../../mobx.js"; +import { makeObservable, override } from "mobx"; +import { QueryCertificatesRequest, QueryCertificatesRequestSDKType, QueryCertificatesResponse, QueryCertificatesResponseSDKType } from "./query.js"; +/** Query defines the gRPC querier service */ +export interface Query { + /** Certificates queries certificates */ + certificates(request: QueryCertificatesRequest): Promise; +} +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + } + /* Certificates queries certificates */ + certificates = async (request: QueryCertificatesRequest): Promise => { + const data = QueryCertificatesRequest.encode(request).finish(); + const promise = this.rpc.request("akash.cert.v1beta2.Query", "Certificates", data); + return promise.then(data => QueryCertificatesResponse.decode(new BinaryReader(data))); + }; +} +export const createRpcQueryExtension = (base: QueryClient) => { + const rpc = createProtobufRpcClient(base); + const queryService = new QueryClientImpl(rpc); + return { + certificates(request: QueryCertificatesRequest): Promise { + return queryService.certificates(request); + } + }; +}; +export interface UseCertificatesQuery extends ReactQueryParams { + request: QueryCertificatesRequest; +} +const _queryClients: WeakMap = new WeakMap(); +const getQueryService = (rpc: ProtobufRpcClient | undefined): QueryClientImpl | undefined => { + if (!rpc) return; + if (_queryClients.has(rpc)) { + return _queryClients.get(rpc); + } + const queryService = new QueryClientImpl(rpc); + _queryClients.set(rpc, queryService); + return queryService; +}; +export const createRpcQueryHooks = (rpc: ProtobufRpcClient | undefined) => { + const queryService = getQueryService(rpc); + const useCertificates = ({ + request, + options + }: UseCertificatesQuery) => { + return useQuery(["certificatesQuery", request], () => { + if (!queryService) throw new Error("Query Service not initialized"); + return queryService.certificates(request); + }, options); + }; + return { + /** Certificates queries certificates */useCertificates + }; +}; +export const createRpcQueryMobxStores = (rpc: ProtobufRpcClient | undefined) => { + const queryService = getQueryService(rpc); + class QueryCertificatesStore { + store = new QueryStore(queryService?.certificates); + certificates(request: QueryCertificatesRequest) { + return this.store.getData(request); + } + } + return { + /** Certificates queries certificates */QueryCertificatesStore + }; +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/cert/v1beta2/query.rpc.func.ts b/__fixtures__/v-next/outputicjsdeps/akash/cert/v1beta2/query.rpc.func.ts new file mode 100644 index 0000000000..b86c96165a --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/cert/v1beta2/query.rpc.func.ts @@ -0,0 +1,14 @@ +import { RpcResolver, buildQuery } from "../../../helper-func-types"; +import { buildUseQuery } from "../../../react-query"; +import { QueryCertificatesRequest, QueryCertificatesResponse } from "./query"; +export const createGetCertificates = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryCertificatesRequest.encode, + decode: QueryCertificatesResponse.decode, + service: "akash.cert.v1beta2.Query", + method: "Certificates", + getRpcInstance: getRpcInstance +}); +export const useGetCertificates = buildUseQuery({ + builderQueryFn: createGetCertificates, + queryKeyPrefix: "CertificatesQuery" +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/cert/v1beta2/query.ts b/__fixtures__/v-next/outputicjsdeps/akash/cert/v1beta2/query.ts new file mode 100644 index 0000000000..7aa12c9328 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/cert/v1beta2/query.ts @@ -0,0 +1,399 @@ +import { CertificateFilter, CertificateFilterSDKType, Certificate, CertificateSDKType } from "./cert.js"; +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../../cosmos/base/query/v1beta1/pagination.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial, Exact } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "akash.cert.v1beta2"; +/** CertificateResponse contains a single X509 certificate and its serial number */ +export interface CertificateResponse { + certificate: Certificate; + serial: string; +} +export interface CertificateResponseProtoMsg { + typeUrl: "/akash.cert.v1beta2.CertificateResponse"; + value: Uint8Array; +} +/** CertificateResponse contains a single X509 certificate and its serial number */ +export interface CertificateResponseSDKType { + certificate: CertificateSDKType; + serial: string; +} +/** QueryDeploymentsRequest is request type for the Query/Deployments RPC method */ +export interface QueryCertificatesRequest { + filter: CertificateFilter; + pagination?: PageRequest; +} +export interface QueryCertificatesRequestProtoMsg { + typeUrl: "/akash.cert.v1beta2.QueryCertificatesRequest"; + value: Uint8Array; +} +/** QueryDeploymentsRequest is request type for the Query/Deployments RPC method */ +export interface QueryCertificatesRequestSDKType { + filter: CertificateFilterSDKType; + pagination?: PageRequestSDKType; +} +/** QueryCertificatesResponse is response type for the Query/Certificates RPC method */ +export interface QueryCertificatesResponse { + certificates: CertificateResponse[]; + pagination?: PageResponse; +} +export interface QueryCertificatesResponseProtoMsg { + typeUrl: "/akash.cert.v1beta2.QueryCertificatesResponse"; + value: Uint8Array; +} +/** QueryCertificatesResponse is response type for the Query/Certificates RPC method */ +export interface QueryCertificatesResponseSDKType { + certificates: CertificateResponseSDKType[]; + pagination?: PageResponseSDKType; +} +function createBaseCertificateResponse(): CertificateResponse { + return { + certificate: Certificate.fromPartial({}), + serial: "" + }; +} +export const CertificateResponse = { + typeUrl: "/akash.cert.v1beta2.CertificateResponse", + encode(message: CertificateResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.certificate !== undefined) { + Certificate.encode(message.certificate, writer.uint32(10).fork()).ldelim(); + } + if (message.serial !== undefined) { + writer.uint32(18).string(message.serial); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): CertificateResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCertificateResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.certificate = Certificate.decode(reader, reader.uint32()); + break; + case 2: + message.serial = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): CertificateResponse { + const obj = createBaseCertificateResponse(); + if (isSet(object.certificate)) obj.certificate = Certificate.fromJSON(object.certificate); + if (isSet(object.serial)) obj.serial = String(object.serial); + return obj; + }, + toJSON(message: CertificateResponse): JsonSafe { + const obj: any = {}; + message.certificate !== undefined && (obj.certificate = message.certificate ? Certificate.toJSON(message.certificate) : undefined); + message.serial !== undefined && (obj.serial = message.serial); + return obj; + }, + fromPartial, I>>(object: I): CertificateResponse { + const message = createBaseCertificateResponse(); + if (object.certificate !== undefined && object.certificate !== null) { + message.certificate = Certificate.fromPartial(object.certificate); + } + message.serial = object.serial ?? ""; + return message; + }, + fromSDK(object: CertificateResponseSDKType): CertificateResponse { + return { + certificate: object.certificate ? Certificate.fromSDK(object.certificate) : undefined, + serial: object?.serial + }; + }, + fromSDKJSON(object: any): CertificateResponseSDKType { + return { + certificate: isSet(object.certificate) ? Certificate.fromSDKJSON(object.certificate) : undefined, + serial: isSet(object.serial) ? String(object.serial) : "" + }; + }, + toSDK(message: CertificateResponse): CertificateResponseSDKType { + const obj: any = {}; + message.certificate !== undefined && (obj.certificate = message.certificate ? Certificate.toSDK(message.certificate) : undefined); + obj.serial = message.serial; + return obj; + }, + fromAmino(object: CertificateResponseAmino): CertificateResponse { + const message = createBaseCertificateResponse(); + if (object.certificate !== undefined && object.certificate !== null) { + message.certificate = Certificate.fromAmino(object.certificate); + } + if (object.serial !== undefined && object.serial !== null) { + message.serial = object.serial; + } + return message; + }, + toAmino(message: CertificateResponse): CertificateResponseAmino { + const obj: any = {}; + obj.certificate = message.certificate ? Certificate.toAmino(message.certificate) : Certificate.toAmino(Certificate.fromPartial({})); + obj.serial = message.serial ?? ""; + return obj; + }, + fromAminoMsg(object: CertificateResponseAminoMsg): CertificateResponse { + return CertificateResponse.fromAmino(object.value); + }, + toAminoMsg(message: CertificateResponse): CertificateResponseAminoMsg { + return { + type: "akash/cert/v1beta2/certificate-response", + value: CertificateResponse.toAmino(message) + }; + }, + fromProtoMsg(message: CertificateResponseProtoMsg): CertificateResponse { + return CertificateResponse.decode(message.value); + }, + toProto(message: CertificateResponse): Uint8Array { + return CertificateResponse.encode(message).finish(); + }, + toProtoMsg(message: CertificateResponse): CertificateResponseProtoMsg { + return { + typeUrl: "/akash.cert.v1beta2.CertificateResponse", + value: CertificateResponse.encode(message).finish() + }; + } +}; +function createBaseQueryCertificatesRequest(): QueryCertificatesRequest { + return { + filter: CertificateFilter.fromPartial({}), + pagination: undefined + }; +} +export const QueryCertificatesRequest = { + typeUrl: "/akash.cert.v1beta2.QueryCertificatesRequest", + encode(message: QueryCertificatesRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.filter !== undefined) { + CertificateFilter.encode(message.filter, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryCertificatesRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryCertificatesRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.filter = CertificateFilter.decode(reader, reader.uint32()); + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryCertificatesRequest { + const obj = createBaseQueryCertificatesRequest(); + if (isSet(object.filter)) obj.filter = CertificateFilter.fromJSON(object.filter); + if (isSet(object.pagination)) obj.pagination = PageRequest.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryCertificatesRequest): JsonSafe { + const obj: any = {}; + message.filter !== undefined && (obj.filter = message.filter ? CertificateFilter.toJSON(message.filter) : undefined); + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryCertificatesRequest { + const message = createBaseQueryCertificatesRequest(); + if (object.filter !== undefined && object.filter !== null) { + message.filter = CertificateFilter.fromPartial(object.filter); + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryCertificatesRequestSDKType): QueryCertificatesRequest { + return { + filter: object.filter ? CertificateFilter.fromSDK(object.filter) : undefined, + pagination: object.pagination ? PageRequest.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryCertificatesRequestSDKType { + return { + filter: isSet(object.filter) ? CertificateFilter.fromSDKJSON(object.filter) : undefined, + pagination: isSet(object.pagination) ? PageRequest.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryCertificatesRequest): QueryCertificatesRequestSDKType { + const obj: any = {}; + message.filter !== undefined && (obj.filter = message.filter ? CertificateFilter.toSDK(message.filter) : undefined); + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryCertificatesRequestAmino): QueryCertificatesRequest { + const message = createBaseQueryCertificatesRequest(); + if (object.filter !== undefined && object.filter !== null) { + message.filter = CertificateFilter.fromAmino(object.filter); + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryCertificatesRequest): QueryCertificatesRequestAmino { + const obj: any = {}; + obj.filter = message.filter ? CertificateFilter.toAmino(message.filter) : undefined; + obj.pagination = message.pagination ? PageRequest.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryCertificatesRequestAminoMsg): QueryCertificatesRequest { + return QueryCertificatesRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryCertificatesRequest): QueryCertificatesRequestAminoMsg { + return { + type: "akash/cert/v1beta2/query-certificates-request", + value: QueryCertificatesRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryCertificatesRequestProtoMsg): QueryCertificatesRequest { + return QueryCertificatesRequest.decode(message.value); + }, + toProto(message: QueryCertificatesRequest): Uint8Array { + return QueryCertificatesRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryCertificatesRequest): QueryCertificatesRequestProtoMsg { + return { + typeUrl: "/akash.cert.v1beta2.QueryCertificatesRequest", + value: QueryCertificatesRequest.encode(message).finish() + }; + } +}; +function createBaseQueryCertificatesResponse(): QueryCertificatesResponse { + return { + certificates: [], + pagination: undefined + }; +} +export const QueryCertificatesResponse = { + typeUrl: "/akash.cert.v1beta2.QueryCertificatesResponse", + encode(message: QueryCertificatesResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.certificates) { + CertificateResponse.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryCertificatesResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryCertificatesResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.certificates.push(CertificateResponse.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryCertificatesResponse { + const obj = createBaseQueryCertificatesResponse(); + if (Array.isArray(object?.certificates)) obj.certificates = object.certificates.map((e: any) => CertificateResponse.fromJSON(e)); + if (isSet(object.pagination)) obj.pagination = PageResponse.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryCertificatesResponse): JsonSafe { + const obj: any = {}; + if (message.certificates) { + obj.certificates = message.certificates.map(e => e ? CertificateResponse.toJSON(e) : undefined); + } else { + obj.certificates = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryCertificatesResponse { + const message = createBaseQueryCertificatesResponse(); + message.certificates = object.certificates?.map(e => CertificateResponse.fromPartial(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryCertificatesResponseSDKType): QueryCertificatesResponse { + return { + certificates: Array.isArray(object?.certificates) ? object.certificates.map((e: any) => CertificateResponse.fromSDK(e)) : [], + pagination: object.pagination ? PageResponse.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryCertificatesResponseSDKType { + return { + certificates: Array.isArray(object?.certificates) ? object.certificates.map((e: any) => CertificateResponse.fromSDKJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryCertificatesResponse): QueryCertificatesResponseSDKType { + const obj: any = {}; + if (message.certificates) { + obj.certificates = message.certificates.map(e => e ? CertificateResponse.toSDK(e) : undefined); + } else { + obj.certificates = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryCertificatesResponseAmino): QueryCertificatesResponse { + const message = createBaseQueryCertificatesResponse(); + message.certificates = object.certificates?.map(e => CertificateResponse.fromAmino(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryCertificatesResponse): QueryCertificatesResponseAmino { + const obj: any = {}; + if (message.certificates) { + obj.certificates = message.certificates.map(e => e ? CertificateResponse.toAmino(e) : undefined); + } else { + obj.certificates = message.certificates; + } + obj.pagination = message.pagination ? PageResponse.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryCertificatesResponseAminoMsg): QueryCertificatesResponse { + return QueryCertificatesResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryCertificatesResponse): QueryCertificatesResponseAminoMsg { + return { + type: "akash/cert/v1beta2/query-certificates-response", + value: QueryCertificatesResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryCertificatesResponseProtoMsg): QueryCertificatesResponse { + return QueryCertificatesResponse.decode(message.value); + }, + toProto(message: QueryCertificatesResponse): Uint8Array { + return QueryCertificatesResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryCertificatesResponse): QueryCertificatesResponseProtoMsg { + return { + typeUrl: "/akash.cert.v1beta2.QueryCertificatesResponse", + value: QueryCertificatesResponse.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/client.ts b/__fixtures__/v-next/outputicjsdeps/akash/client.ts new file mode 100644 index 0000000000..f6e6e7fec0 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/client.ts @@ -0,0 +1,65 @@ +import { GeneratedType, Registry, OfflineSigner } from "@cosmjs/proto-signing"; +import { defaultRegistryTypes, AminoTypes, SigningStargateClient } from "@cosmjs/stargate"; +import { HttpEndpoint } from "@cosmjs/tendermint-rpc"; +import * as akashAuditV1beta1AuditRegistry from "./audit/v1beta1/audit.registry.js"; +import * as akashAuditV1beta2AuditRegistry from "./audit/v1beta2/audit.registry.js"; +import * as akashCertV1beta2CertRegistry from "./cert/v1beta2/cert.registry.js"; +import * as akashDeploymentV1beta2ServiceRegistry from "./deployment/v1beta2/service.registry.js"; +import * as akashMarketV1beta2ServiceRegistry from "./market/v1beta2/service.registry.js"; +import * as akashProviderV1beta1ProviderRegistry from "./provider/v1beta1/provider.registry.js"; +import * as akashProviderV1beta2ProviderRegistry from "./provider/v1beta2/provider.registry.js"; +import * as akashAuditV1beta1AuditAmino from "./audit/v1beta1/audit.amino.js"; +import * as akashAuditV1beta2AuditAmino from "./audit/v1beta2/audit.amino.js"; +import * as akashCertV1beta2CertAmino from "./cert/v1beta2/cert.amino.js"; +import * as akashDeploymentV1beta2ServiceAmino from "./deployment/v1beta2/service.amino.js"; +import * as akashMarketV1beta2ServiceAmino from "./market/v1beta2/service.amino.js"; +import * as akashProviderV1beta1ProviderAmino from "./provider/v1beta1/provider.amino.js"; +import * as akashProviderV1beta2ProviderAmino from "./provider/v1beta2/provider.amino.js"; +export const akashAminoConverters = { + ...akashAuditV1beta1AuditAmino.AminoConverter, + ...akashAuditV1beta2AuditAmino.AminoConverter, + ...akashCertV1beta2CertAmino.AminoConverter, + ...akashDeploymentV1beta2ServiceAmino.AminoConverter, + ...akashMarketV1beta2ServiceAmino.AminoConverter, + ...akashProviderV1beta1ProviderAmino.AminoConverter, + ...akashProviderV1beta2ProviderAmino.AminoConverter +}; +export const akashProtoRegistry: ReadonlyArray<[string, GeneratedType]> = [...akashAuditV1beta1AuditRegistry.registry, ...akashAuditV1beta2AuditRegistry.registry, ...akashCertV1beta2CertRegistry.registry, ...akashDeploymentV1beta2ServiceRegistry.registry, ...akashMarketV1beta2ServiceRegistry.registry, ...akashProviderV1beta1ProviderRegistry.registry, ...akashProviderV1beta2ProviderRegistry.registry]; +export const getSigningAkashClientOptions = ({ + defaultTypes = defaultRegistryTypes +}: { + defaultTypes?: ReadonlyArray<[string, GeneratedType]>; +} = {}): { + registry: Registry; + aminoTypes: AminoTypes; +} => { + const registry = new Registry([...defaultTypes, ...akashProtoRegistry]); + const aminoTypes = new AminoTypes({ + ...akashAminoConverters + }); + return { + registry, + aminoTypes + }; +}; +export const getSigningAkashClient = async ({ + rpcEndpoint, + signer, + defaultTypes = defaultRegistryTypes +}: { + rpcEndpoint: string | HttpEndpoint; + signer: OfflineSigner; + defaultTypes?: ReadonlyArray<[string, GeneratedType]>; +}) => { + const { + registry, + aminoTypes + } = getSigningAkashClientOptions({ + defaultTypes + }); + const client = await SigningStargateClient.connectWithSigner(rpcEndpoint, signer, { + registry: (registry as any), + aminoTypes + }); + return client; +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta1/authz.ts b/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta1/authz.ts new file mode 100644 index 0000000000..53b769fd9f --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta1/authz.ts @@ -0,0 +1,123 @@ +import { Coin, CoinSDKType } from "../../../cosmos/base/v1beta1/coin.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, Exact } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "akash.deployment.v1beta1"; +/** + * DepositDeploymentAuthorization allows the grantee to deposit up to spend_limit coins from + * the granter's account for a deployment. + */ +export interface DepositDeploymentAuthorization { + /** + * SpendLimit is the amount the grantee is authorized to spend from the granter's account for + * the purpose of deployment. + */ + spendLimit: Coin | undefined; +} +export interface DepositDeploymentAuthorizationProtoMsg { + typeUrl: "/akash.deployment.v1beta1.DepositDeploymentAuthorization"; + value: Uint8Array; +} +/** + * DepositDeploymentAuthorization allows the grantee to deposit up to spend_limit coins from + * the granter's account for a deployment. + */ +export interface DepositDeploymentAuthorizationSDKType { + spend_limit: CoinSDKType | undefined; +} +function createBaseDepositDeploymentAuthorization(): DepositDeploymentAuthorization { + return { + spendLimit: Coin.fromPartial({}) + }; +} +export const DepositDeploymentAuthorization = { + typeUrl: "/akash.deployment.v1beta1.DepositDeploymentAuthorization", + encode(message: DepositDeploymentAuthorization, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.spendLimit !== undefined) { + Coin.encode(message.spendLimit, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): DepositDeploymentAuthorization { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDepositDeploymentAuthorization(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.spendLimit = Coin.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): DepositDeploymentAuthorization { + const obj = createBaseDepositDeploymentAuthorization(); + if (isSet(object.spendLimit)) obj.spendLimit = Coin.fromJSON(object.spendLimit); + return obj; + }, + toJSON(message: DepositDeploymentAuthorization): JsonSafe { + const obj: any = {}; + message.spendLimit !== undefined && (obj.spendLimit = message.spendLimit ? Coin.toJSON(message.spendLimit) : undefined); + return obj; + }, + fromPartial, I>>(object: I): DepositDeploymentAuthorization { + const message = createBaseDepositDeploymentAuthorization(); + if (object.spendLimit !== undefined && object.spendLimit !== null) { + message.spendLimit = Coin.fromPartial(object.spendLimit); + } + return message; + }, + fromSDK(object: DepositDeploymentAuthorizationSDKType): DepositDeploymentAuthorization { + return { + spendLimit: object.spend_limit ? Coin.fromSDK(object.spend_limit) : undefined + }; + }, + fromSDKJSON(object: any): DepositDeploymentAuthorizationSDKType { + return { + spend_limit: isSet(object.spend_limit) ? Coin.fromSDKJSON(object.spend_limit) : undefined + }; + }, + toSDK(message: DepositDeploymentAuthorization): DepositDeploymentAuthorizationSDKType { + const obj: any = {}; + message.spendLimit !== undefined && (obj.spend_limit = message.spendLimit ? Coin.toSDK(message.spendLimit) : undefined); + return obj; + }, + fromAmino(object: DepositDeploymentAuthorizationAmino): DepositDeploymentAuthorization { + const message = createBaseDepositDeploymentAuthorization(); + if (object.spend_limit !== undefined && object.spend_limit !== null) { + message.spendLimit = Coin.fromAmino(object.spend_limit); + } + return message; + }, + toAmino(message: DepositDeploymentAuthorization): DepositDeploymentAuthorizationAmino { + const obj: any = {}; + obj.spend_limit = message.spendLimit ? Coin.toAmino(message.spendLimit) : Coin.toAmino(Coin.fromPartial({})); + return obj; + }, + fromAminoMsg(object: DepositDeploymentAuthorizationAminoMsg): DepositDeploymentAuthorization { + return DepositDeploymentAuthorization.fromAmino(object.value); + }, + toAminoMsg(message: DepositDeploymentAuthorization): DepositDeploymentAuthorizationAminoMsg { + return { + type: "akash/deployment/deposit-deployment-authorization", + value: DepositDeploymentAuthorization.toAmino(message) + }; + }, + fromProtoMsg(message: DepositDeploymentAuthorizationProtoMsg): DepositDeploymentAuthorization { + return DepositDeploymentAuthorization.decode(message.value); + }, + toProto(message: DepositDeploymentAuthorization): Uint8Array { + return DepositDeploymentAuthorization.encode(message).finish(); + }, + toProtoMsg(message: DepositDeploymentAuthorization): DepositDeploymentAuthorizationProtoMsg { + return { + typeUrl: "/akash.deployment.v1beta1.DepositDeploymentAuthorization", + value: DepositDeploymentAuthorization.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta1/deployment.rpc.func.ts b/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta1/deployment.rpc.func.ts new file mode 100644 index 0000000000..ca44f17744 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta1/deployment.rpc.func.ts @@ -0,0 +1,68 @@ +import { MsgCloseGroup, MsgPauseGroup, MsgStartGroup } from "./group"; +import { buildTx, SigningClientResolver } from "../../../helper-func-types"; +import { buildUseMutation } from "../../../react-query"; +import { toEncoders, toConverters } from "@interchainjs/cosmos/utils"; +import { MsgCreateDeployment, MsgDepositDeployment, MsgUpdateDeployment, MsgCloseDeployment } from "./deployment"; +export const createCreateDeployment = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgCreateDeployment.typeUrl, + encoders: toEncoders(MsgCreateDeployment), + converters: toConverters(MsgCreateDeployment) +}); +export const useCreateDeployment = buildUseMutation({ + builderMutationFn: createCreateDeployment +}); +export const createDepositDeployment = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgDepositDeployment.typeUrl, + encoders: toEncoders(MsgDepositDeployment), + converters: toConverters(MsgDepositDeployment) +}); +export const useDepositDeployment = buildUseMutation({ + builderMutationFn: createDepositDeployment +}); +export const createUpdateDeployment = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgUpdateDeployment.typeUrl, + encoders: toEncoders(MsgUpdateDeployment), + converters: toConverters(MsgUpdateDeployment) +}); +export const useUpdateDeployment = buildUseMutation({ + builderMutationFn: createUpdateDeployment +}); +export const createCloseDeployment = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgCloseDeployment.typeUrl, + encoders: toEncoders(MsgCloseDeployment), + converters: toConverters(MsgCloseDeployment) +}); +export const useCloseDeployment = buildUseMutation({ + builderMutationFn: createCloseDeployment +}); +export const createCloseGroup = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgCloseGroup.typeUrl, + encoders: toEncoders(MsgCloseGroup), + converters: toConverters(MsgCloseGroup) +}); +export const useCloseGroup = buildUseMutation({ + builderMutationFn: createCloseGroup +}); +export const createPauseGroup = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgPauseGroup.typeUrl, + encoders: toEncoders(MsgPauseGroup), + converters: toConverters(MsgPauseGroup) +}); +export const usePauseGroup = buildUseMutation({ + builderMutationFn: createPauseGroup +}); +export const createStartGroup = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgStartGroup.typeUrl, + encoders: toEncoders(MsgStartGroup), + converters: toConverters(MsgStartGroup) +}); +export const useStartGroup = buildUseMutation({ + builderMutationFn: createStartGroup +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta1/deployment.ts b/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta1/deployment.ts new file mode 100644 index 0000000000..31b1ed7c86 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta1/deployment.ts @@ -0,0 +1,1455 @@ +//@ts-nocheck +/* eslint-disable */ +import { GroupSpec, GroupSpecSDKType, GroupID, GroupIDSDKType } from "./group.js"; +import { Coin, CoinSDKType } from "../../../cosmos/base/v1beta1/coin.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, bytesFromBase64, base64FromBytes, Exact, Rpc } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "akash.deployment.v1beta1"; +/** State is an enum which refers to state of deployment */ +export enum Deployment_State { + /** invalid - Prefix should start with 0 in enum. So declaring dummy state */ + invalid = 0, + /** active - DeploymentActive denotes state for deployment active */ + active = 1, + /** closed - DeploymentClosed denotes state for deployment closed */ + closed = 2, + UNRECOGNIZED = -1, +} +export const Deployment_StateSDKType = Deployment_State; +export function deployment_StateFromJSON(object: any): Deployment_State { + switch (object) { + case 0: + case "invalid": + return Deployment_State.invalid; + case 1: + case "active": + return Deployment_State.active; + case 2: + case "closed": + return Deployment_State.closed; + case -1: + case "UNRECOGNIZED": + default: + return Deployment_State.UNRECOGNIZED; + } +} +export function deployment_StateToJSON(object: Deployment_State): string { + switch (object) { + case Deployment_State.invalid: + return "invalid"; + case Deployment_State.active: + return "active"; + case Deployment_State.closed: + return "closed"; + case Deployment_State.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** MsgCreateDeployment defines an SDK message for creating deployment */ +export interface MsgCreateDeployment { + id: DeploymentID | undefined; + groups: GroupSpec[]; + version: Uint8Array; + deposit: Coin | undefined; +} +export interface MsgCreateDeploymentProtoMsg { + typeUrl: "/akash.deployment.v1beta1.MsgCreateDeployment"; + value: Uint8Array; +} +/** MsgCreateDeployment defines an SDK message for creating deployment */ +export interface MsgCreateDeploymentSDKType { + id: DeploymentIDSDKType | undefined; + groups: GroupSpecSDKType[]; + version: Uint8Array; + deposit: CoinSDKType | undefined; +} +/** MsgCreateDeploymentResponse defines the Msg/CreateDeployment response type. */ +export interface MsgCreateDeploymentResponse {} +export interface MsgCreateDeploymentResponseProtoMsg { + typeUrl: "/akash.deployment.v1beta1.MsgCreateDeploymentResponse"; + value: Uint8Array; +} +/** MsgCreateDeploymentResponse defines the Msg/CreateDeployment response type. */ +export interface MsgCreateDeploymentResponseSDKType {} +/** MsgDepositDeployment deposits more funds into the deposit account */ +export interface MsgDepositDeployment { + id: DeploymentID | undefined; + amount: Coin | undefined; +} +export interface MsgDepositDeploymentProtoMsg { + typeUrl: "/akash.deployment.v1beta1.MsgDepositDeployment"; + value: Uint8Array; +} +/** MsgDepositDeployment deposits more funds into the deposit account */ +export interface MsgDepositDeploymentSDKType { + id: DeploymentIDSDKType | undefined; + amount: CoinSDKType | undefined; +} +/** MsgCreateDeploymentResponse defines the Msg/CreateDeployment response type. */ +export interface MsgDepositDeploymentResponse {} +export interface MsgDepositDeploymentResponseProtoMsg { + typeUrl: "/akash.deployment.v1beta1.MsgDepositDeploymentResponse"; + value: Uint8Array; +} +/** MsgCreateDeploymentResponse defines the Msg/CreateDeployment response type. */ +export interface MsgDepositDeploymentResponseSDKType {} +/** MsgUpdateDeployment defines an SDK message for updating deployment */ +export interface MsgUpdateDeployment { + id: DeploymentID | undefined; + groups: GroupSpec[]; + version: Uint8Array; +} +export interface MsgUpdateDeploymentProtoMsg { + typeUrl: "/akash.deployment.v1beta1.MsgUpdateDeployment"; + value: Uint8Array; +} +/** MsgUpdateDeployment defines an SDK message for updating deployment */ +export interface MsgUpdateDeploymentSDKType { + id: DeploymentIDSDKType | undefined; + groups: GroupSpecSDKType[]; + version: Uint8Array; +} +/** MsgUpdateDeploymentResponse defines the Msg/UpdateDeployment response type. */ +export interface MsgUpdateDeploymentResponse {} +export interface MsgUpdateDeploymentResponseProtoMsg { + typeUrl: "/akash.deployment.v1beta1.MsgUpdateDeploymentResponse"; + value: Uint8Array; +} +/** MsgUpdateDeploymentResponse defines the Msg/UpdateDeployment response type. */ +export interface MsgUpdateDeploymentResponseSDKType {} +/** MsgCloseDeployment defines an SDK message for closing deployment */ +export interface MsgCloseDeployment { + id: DeploymentID | undefined; +} +export interface MsgCloseDeploymentProtoMsg { + typeUrl: "/akash.deployment.v1beta1.MsgCloseDeployment"; + value: Uint8Array; +} +/** MsgCloseDeployment defines an SDK message for closing deployment */ +export interface MsgCloseDeploymentSDKType { + id: DeploymentIDSDKType | undefined; +} +/** MsgCloseDeploymentResponse defines the Msg/CloseDeployment response type. */ +export interface MsgCloseDeploymentResponse {} +export interface MsgCloseDeploymentResponseProtoMsg { + typeUrl: "/akash.deployment.v1beta1.MsgCloseDeploymentResponse"; + value: Uint8Array; +} +/** MsgCloseDeploymentResponse defines the Msg/CloseDeployment response type. */ +export interface MsgCloseDeploymentResponseSDKType {} +/** DeploymentID stores owner and sequence number */ +export interface DeploymentID { + owner: string; + dseq: bigint; +} +export interface DeploymentIDProtoMsg { + typeUrl: "/akash.deployment.v1beta1.DeploymentID"; + value: Uint8Array; +} +/** DeploymentID stores owner and sequence number */ +export interface DeploymentIDSDKType { + owner: string; + dseq: bigint; +} +/** Deployment stores deploymentID, state and version details */ +export interface Deployment { + deploymentId: DeploymentID | undefined; + state: Deployment_State; + version: Uint8Array; + createdAt: bigint; +} +export interface DeploymentProtoMsg { + typeUrl: "/akash.deployment.v1beta1.Deployment"; + value: Uint8Array; +} +/** Deployment stores deploymentID, state and version details */ +export interface DeploymentSDKType { + deployment_id: DeploymentIDSDKType | undefined; + state: Deployment_State; + version: Uint8Array; + created_at: bigint; +} +/** DeploymentFilters defines filters used to filter deployments */ +export interface DeploymentFilters { + owner: string; + dseq: bigint; + state: string; +} +export interface DeploymentFiltersProtoMsg { + typeUrl: "/akash.deployment.v1beta1.DeploymentFilters"; + value: Uint8Array; +} +/** DeploymentFilters defines filters used to filter deployments */ +export interface DeploymentFiltersSDKType { + owner: string; + dseq: bigint; + state: string; +} +function createBaseMsgCreateDeployment(): MsgCreateDeployment { + return { + id: DeploymentID.fromPartial({}), + groups: [], + version: new Uint8Array(), + deposit: Coin.fromPartial({}) + }; +} +export const MsgCreateDeployment = { + typeUrl: "/akash.deployment.v1beta1.MsgCreateDeployment", + encode(message: MsgCreateDeployment, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.id !== undefined) { + DeploymentID.encode(message.id, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.groups) { + GroupSpec.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.version.length !== 0) { + writer.uint32(26).bytes(message.version); + } + if (message.deposit !== undefined) { + Coin.encode(message.deposit, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgCreateDeployment { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgCreateDeployment(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.id = DeploymentID.decode(reader, reader.uint32()); + break; + case 2: + message.groups.push(GroupSpec.decode(reader, reader.uint32())); + break; + case 3: + message.version = reader.bytes(); + break; + case 4: + message.deposit = Coin.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgCreateDeployment { + const obj = createBaseMsgCreateDeployment(); + if (isSet(object.id)) obj.id = DeploymentID.fromJSON(object.id); + if (Array.isArray(object?.groups)) obj.groups = object.groups.map((e: any) => GroupSpec.fromJSON(e)); + if (isSet(object.version)) obj.version = bytesFromBase64(object.version); + if (isSet(object.deposit)) obj.deposit = Coin.fromJSON(object.deposit); + return obj; + }, + toJSON(message: MsgCreateDeployment): JsonSafe { + const obj: any = {}; + message.id !== undefined && (obj.id = message.id ? DeploymentID.toJSON(message.id) : undefined); + if (message.groups) { + obj.groups = message.groups.map(e => e ? GroupSpec.toJSON(e) : undefined); + } else { + obj.groups = []; + } + message.version !== undefined && (obj.version = base64FromBytes(message.version !== undefined ? message.version : new Uint8Array())); + message.deposit !== undefined && (obj.deposit = message.deposit ? Coin.toJSON(message.deposit) : undefined); + return obj; + }, + fromPartial, I>>(object: I): MsgCreateDeployment { + const message = createBaseMsgCreateDeployment(); + if (object.id !== undefined && object.id !== null) { + message.id = DeploymentID.fromPartial(object.id); + } + message.groups = object.groups?.map(e => GroupSpec.fromPartial(e)) || []; + message.version = object.version ?? new Uint8Array(); + if (object.deposit !== undefined && object.deposit !== null) { + message.deposit = Coin.fromPartial(object.deposit); + } + return message; + }, + fromSDK(object: MsgCreateDeploymentSDKType): MsgCreateDeployment { + return { + id: object.id ? DeploymentID.fromSDK(object.id) : undefined, + groups: Array.isArray(object?.groups) ? object.groups.map((e: any) => GroupSpec.fromSDK(e)) : [], + version: object?.version, + deposit: object.deposit ? Coin.fromSDK(object.deposit) : undefined + }; + }, + fromSDKJSON(object: any): MsgCreateDeploymentSDKType { + return { + id: isSet(object.id) ? DeploymentID.fromSDKJSON(object.id) : undefined, + groups: Array.isArray(object?.groups) ? object.groups.map((e: any) => GroupSpec.fromSDKJSON(e)) : [], + version: isSet(object.version) ? bytesFromBase64(object.version) : new Uint8Array(), + deposit: isSet(object.deposit) ? Coin.fromSDKJSON(object.deposit) : undefined + }; + }, + toSDK(message: MsgCreateDeployment): MsgCreateDeploymentSDKType { + const obj: any = {}; + message.id !== undefined && (obj.id = message.id ? DeploymentID.toSDK(message.id) : undefined); + if (message.groups) { + obj.groups = message.groups.map(e => e ? GroupSpec.toSDK(e) : undefined); + } else { + obj.groups = []; + } + obj.version = message.version; + message.deposit !== undefined && (obj.deposit = message.deposit ? Coin.toSDK(message.deposit) : undefined); + return obj; + }, + fromAmino(object: MsgCreateDeploymentAmino): MsgCreateDeployment { + const message = createBaseMsgCreateDeployment(); + if (object.id !== undefined && object.id !== null) { + message.id = DeploymentID.fromAmino(object.id); + } + message.groups = object.groups?.map(e => GroupSpec.fromAmino(e)) || []; + if (object.version !== undefined && object.version !== null) { + message.version = bytesFromBase64(object.version); + } + if (object.deposit !== undefined && object.deposit !== null) { + message.deposit = Coin.fromAmino(object.deposit); + } + return message; + }, + toAmino(message: MsgCreateDeployment): MsgCreateDeploymentAmino { + const obj: any = {}; + obj.id = message.id ? DeploymentID.toAmino(message.id) : DeploymentID.toAmino(DeploymentID.fromPartial({})); + if (message.groups) { + obj.groups = message.groups.map(e => e ? GroupSpec.toAmino(e) : undefined); + } else { + obj.groups = message.groups; + } + obj.version = message.version ? base64FromBytes(message.version) : ""; + obj.deposit = message.deposit ? Coin.toAmino(message.deposit) : Coin.toAmino(Coin.fromPartial({})); + return obj; + }, + fromAminoMsg(object: MsgCreateDeploymentAminoMsg): MsgCreateDeployment { + return MsgCreateDeployment.fromAmino(object.value); + }, + toAminoMsg(message: MsgCreateDeployment): MsgCreateDeploymentAminoMsg { + return { + type: "akash/deployment/testonly-create-deployment", + value: MsgCreateDeployment.toAmino(message) + }; + }, + fromProtoMsg(message: MsgCreateDeploymentProtoMsg): MsgCreateDeployment { + return MsgCreateDeployment.decode(message.value); + }, + toProto(message: MsgCreateDeployment): Uint8Array { + return MsgCreateDeployment.encode(message).finish(); + }, + toProtoMsg(message: MsgCreateDeployment): MsgCreateDeploymentProtoMsg { + return { + typeUrl: "/akash.deployment.v1beta1.MsgCreateDeployment", + value: MsgCreateDeployment.encode(message).finish() + }; + } +}; +function createBaseMsgCreateDeploymentResponse(): MsgCreateDeploymentResponse { + return {}; +} +export const MsgCreateDeploymentResponse = { + typeUrl: "/akash.deployment.v1beta1.MsgCreateDeploymentResponse", + encode(_: MsgCreateDeploymentResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgCreateDeploymentResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgCreateDeploymentResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgCreateDeploymentResponse { + const obj = createBaseMsgCreateDeploymentResponse(); + return obj; + }, + toJSON(_: MsgCreateDeploymentResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): MsgCreateDeploymentResponse { + const message = createBaseMsgCreateDeploymentResponse(); + return message; + }, + fromSDK(_: MsgCreateDeploymentResponseSDKType): MsgCreateDeploymentResponse { + return {}; + }, + fromSDKJSON(_: any): MsgCreateDeploymentResponseSDKType { + return {}; + }, + toSDK(_: MsgCreateDeploymentResponse): MsgCreateDeploymentResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgCreateDeploymentResponseAmino): MsgCreateDeploymentResponse { + const message = createBaseMsgCreateDeploymentResponse(); + return message; + }, + toAmino(_: MsgCreateDeploymentResponse): MsgCreateDeploymentResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgCreateDeploymentResponseAminoMsg): MsgCreateDeploymentResponse { + return MsgCreateDeploymentResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgCreateDeploymentResponse): MsgCreateDeploymentResponseAminoMsg { + return { + type: "akash/deployment/testonly-create-deployment-response", + value: MsgCreateDeploymentResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgCreateDeploymentResponseProtoMsg): MsgCreateDeploymentResponse { + return MsgCreateDeploymentResponse.decode(message.value); + }, + toProto(message: MsgCreateDeploymentResponse): Uint8Array { + return MsgCreateDeploymentResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgCreateDeploymentResponse): MsgCreateDeploymentResponseProtoMsg { + return { + typeUrl: "/akash.deployment.v1beta1.MsgCreateDeploymentResponse", + value: MsgCreateDeploymentResponse.encode(message).finish() + }; + } +}; +function createBaseMsgDepositDeployment(): MsgDepositDeployment { + return { + id: DeploymentID.fromPartial({}), + amount: Coin.fromPartial({}) + }; +} +export const MsgDepositDeployment = { + typeUrl: "/akash.deployment.v1beta1.MsgDepositDeployment", + encode(message: MsgDepositDeployment, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.id !== undefined) { + DeploymentID.encode(message.id, writer.uint32(10).fork()).ldelim(); + } + if (message.amount !== undefined) { + Coin.encode(message.amount, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgDepositDeployment { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgDepositDeployment(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.id = DeploymentID.decode(reader, reader.uint32()); + break; + case 2: + message.amount = Coin.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgDepositDeployment { + const obj = createBaseMsgDepositDeployment(); + if (isSet(object.id)) obj.id = DeploymentID.fromJSON(object.id); + if (isSet(object.amount)) obj.amount = Coin.fromJSON(object.amount); + return obj; + }, + toJSON(message: MsgDepositDeployment): JsonSafe { + const obj: any = {}; + message.id !== undefined && (obj.id = message.id ? DeploymentID.toJSON(message.id) : undefined); + message.amount !== undefined && (obj.amount = message.amount ? Coin.toJSON(message.amount) : undefined); + return obj; + }, + fromPartial, I>>(object: I): MsgDepositDeployment { + const message = createBaseMsgDepositDeployment(); + if (object.id !== undefined && object.id !== null) { + message.id = DeploymentID.fromPartial(object.id); + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = Coin.fromPartial(object.amount); + } + return message; + }, + fromSDK(object: MsgDepositDeploymentSDKType): MsgDepositDeployment { + return { + id: object.id ? DeploymentID.fromSDK(object.id) : undefined, + amount: object.amount ? Coin.fromSDK(object.amount) : undefined + }; + }, + fromSDKJSON(object: any): MsgDepositDeploymentSDKType { + return { + id: isSet(object.id) ? DeploymentID.fromSDKJSON(object.id) : undefined, + amount: isSet(object.amount) ? Coin.fromSDKJSON(object.amount) : undefined + }; + }, + toSDK(message: MsgDepositDeployment): MsgDepositDeploymentSDKType { + const obj: any = {}; + message.id !== undefined && (obj.id = message.id ? DeploymentID.toSDK(message.id) : undefined); + message.amount !== undefined && (obj.amount = message.amount ? Coin.toSDK(message.amount) : undefined); + return obj; + }, + fromAmino(object: MsgDepositDeploymentAmino): MsgDepositDeployment { + const message = createBaseMsgDepositDeployment(); + if (object.id !== undefined && object.id !== null) { + message.id = DeploymentID.fromAmino(object.id); + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = Coin.fromAmino(object.amount); + } + return message; + }, + toAmino(message: MsgDepositDeployment): MsgDepositDeploymentAmino { + const obj: any = {}; + obj.id = message.id ? DeploymentID.toAmino(message.id) : DeploymentID.toAmino(DeploymentID.fromPartial({})); + obj.amount = message.amount ? Coin.toAmino(message.amount) : Coin.toAmino(Coin.fromPartial({})); + return obj; + }, + fromAminoMsg(object: MsgDepositDeploymentAminoMsg): MsgDepositDeployment { + return MsgDepositDeployment.fromAmino(object.value); + }, + toAminoMsg(message: MsgDepositDeployment): MsgDepositDeploymentAminoMsg { + return { + type: "akash/deployment/testonly-deposit-deployment", + value: MsgDepositDeployment.toAmino(message) + }; + }, + fromProtoMsg(message: MsgDepositDeploymentProtoMsg): MsgDepositDeployment { + return MsgDepositDeployment.decode(message.value); + }, + toProto(message: MsgDepositDeployment): Uint8Array { + return MsgDepositDeployment.encode(message).finish(); + }, + toProtoMsg(message: MsgDepositDeployment): MsgDepositDeploymentProtoMsg { + return { + typeUrl: "/akash.deployment.v1beta1.MsgDepositDeployment", + value: MsgDepositDeployment.encode(message).finish() + }; + } +}; +function createBaseMsgDepositDeploymentResponse(): MsgDepositDeploymentResponse { + return {}; +} +export const MsgDepositDeploymentResponse = { + typeUrl: "/akash.deployment.v1beta1.MsgDepositDeploymentResponse", + encode(_: MsgDepositDeploymentResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgDepositDeploymentResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgDepositDeploymentResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgDepositDeploymentResponse { + const obj = createBaseMsgDepositDeploymentResponse(); + return obj; + }, + toJSON(_: MsgDepositDeploymentResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): MsgDepositDeploymentResponse { + const message = createBaseMsgDepositDeploymentResponse(); + return message; + }, + fromSDK(_: MsgDepositDeploymentResponseSDKType): MsgDepositDeploymentResponse { + return {}; + }, + fromSDKJSON(_: any): MsgDepositDeploymentResponseSDKType { + return {}; + }, + toSDK(_: MsgDepositDeploymentResponse): MsgDepositDeploymentResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgDepositDeploymentResponseAmino): MsgDepositDeploymentResponse { + const message = createBaseMsgDepositDeploymentResponse(); + return message; + }, + toAmino(_: MsgDepositDeploymentResponse): MsgDepositDeploymentResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgDepositDeploymentResponseAminoMsg): MsgDepositDeploymentResponse { + return MsgDepositDeploymentResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgDepositDeploymentResponse): MsgDepositDeploymentResponseAminoMsg { + return { + type: "akash/deployment/testonly-deposit-deployment-response", + value: MsgDepositDeploymentResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgDepositDeploymentResponseProtoMsg): MsgDepositDeploymentResponse { + return MsgDepositDeploymentResponse.decode(message.value); + }, + toProto(message: MsgDepositDeploymentResponse): Uint8Array { + return MsgDepositDeploymentResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgDepositDeploymentResponse): MsgDepositDeploymentResponseProtoMsg { + return { + typeUrl: "/akash.deployment.v1beta1.MsgDepositDeploymentResponse", + value: MsgDepositDeploymentResponse.encode(message).finish() + }; + } +}; +function createBaseMsgUpdateDeployment(): MsgUpdateDeployment { + return { + id: DeploymentID.fromPartial({}), + groups: [], + version: new Uint8Array() + }; +} +export const MsgUpdateDeployment = { + typeUrl: "/akash.deployment.v1beta1.MsgUpdateDeployment", + encode(message: MsgUpdateDeployment, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.id !== undefined) { + DeploymentID.encode(message.id, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.groups) { + GroupSpec.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.version.length !== 0) { + writer.uint32(26).bytes(message.version); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgUpdateDeployment { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgUpdateDeployment(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.id = DeploymentID.decode(reader, reader.uint32()); + break; + case 2: + message.groups.push(GroupSpec.decode(reader, reader.uint32())); + break; + case 3: + message.version = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgUpdateDeployment { + const obj = createBaseMsgUpdateDeployment(); + if (isSet(object.id)) obj.id = DeploymentID.fromJSON(object.id); + if (Array.isArray(object?.groups)) obj.groups = object.groups.map((e: any) => GroupSpec.fromJSON(e)); + if (isSet(object.version)) obj.version = bytesFromBase64(object.version); + return obj; + }, + toJSON(message: MsgUpdateDeployment): JsonSafe { + const obj: any = {}; + message.id !== undefined && (obj.id = message.id ? DeploymentID.toJSON(message.id) : undefined); + if (message.groups) { + obj.groups = message.groups.map(e => e ? GroupSpec.toJSON(e) : undefined); + } else { + obj.groups = []; + } + message.version !== undefined && (obj.version = base64FromBytes(message.version !== undefined ? message.version : new Uint8Array())); + return obj; + }, + fromPartial, I>>(object: I): MsgUpdateDeployment { + const message = createBaseMsgUpdateDeployment(); + if (object.id !== undefined && object.id !== null) { + message.id = DeploymentID.fromPartial(object.id); + } + message.groups = object.groups?.map(e => GroupSpec.fromPartial(e)) || []; + message.version = object.version ?? new Uint8Array(); + return message; + }, + fromSDK(object: MsgUpdateDeploymentSDKType): MsgUpdateDeployment { + return { + id: object.id ? DeploymentID.fromSDK(object.id) : undefined, + groups: Array.isArray(object?.groups) ? object.groups.map((e: any) => GroupSpec.fromSDK(e)) : [], + version: object?.version + }; + }, + fromSDKJSON(object: any): MsgUpdateDeploymentSDKType { + return { + id: isSet(object.id) ? DeploymentID.fromSDKJSON(object.id) : undefined, + groups: Array.isArray(object?.groups) ? object.groups.map((e: any) => GroupSpec.fromSDKJSON(e)) : [], + version: isSet(object.version) ? bytesFromBase64(object.version) : new Uint8Array() + }; + }, + toSDK(message: MsgUpdateDeployment): MsgUpdateDeploymentSDKType { + const obj: any = {}; + message.id !== undefined && (obj.id = message.id ? DeploymentID.toSDK(message.id) : undefined); + if (message.groups) { + obj.groups = message.groups.map(e => e ? GroupSpec.toSDK(e) : undefined); + } else { + obj.groups = []; + } + obj.version = message.version; + return obj; + }, + fromAmino(object: MsgUpdateDeploymentAmino): MsgUpdateDeployment { + const message = createBaseMsgUpdateDeployment(); + if (object.id !== undefined && object.id !== null) { + message.id = DeploymentID.fromAmino(object.id); + } + message.groups = object.groups?.map(e => GroupSpec.fromAmino(e)) || []; + if (object.version !== undefined && object.version !== null) { + message.version = bytesFromBase64(object.version); + } + return message; + }, + toAmino(message: MsgUpdateDeployment): MsgUpdateDeploymentAmino { + const obj: any = {}; + obj.id = message.id ? DeploymentID.toAmino(message.id) : DeploymentID.toAmino(DeploymentID.fromPartial({})); + if (message.groups) { + obj.groups = message.groups.map(e => e ? GroupSpec.toAmino(e) : undefined); + } else { + obj.groups = message.groups; + } + obj.version = message.version ? base64FromBytes(message.version) : ""; + return obj; + }, + fromAminoMsg(object: MsgUpdateDeploymentAminoMsg): MsgUpdateDeployment { + return MsgUpdateDeployment.fromAmino(object.value); + }, + toAminoMsg(message: MsgUpdateDeployment): MsgUpdateDeploymentAminoMsg { + return { + type: "akash/deployment/testonly-update-deployment", + value: MsgUpdateDeployment.toAmino(message) + }; + }, + fromProtoMsg(message: MsgUpdateDeploymentProtoMsg): MsgUpdateDeployment { + return MsgUpdateDeployment.decode(message.value); + }, + toProto(message: MsgUpdateDeployment): Uint8Array { + return MsgUpdateDeployment.encode(message).finish(); + }, + toProtoMsg(message: MsgUpdateDeployment): MsgUpdateDeploymentProtoMsg { + return { + typeUrl: "/akash.deployment.v1beta1.MsgUpdateDeployment", + value: MsgUpdateDeployment.encode(message).finish() + }; + } +}; +function createBaseMsgUpdateDeploymentResponse(): MsgUpdateDeploymentResponse { + return {}; +} +export const MsgUpdateDeploymentResponse = { + typeUrl: "/akash.deployment.v1beta1.MsgUpdateDeploymentResponse", + encode(_: MsgUpdateDeploymentResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgUpdateDeploymentResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgUpdateDeploymentResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgUpdateDeploymentResponse { + const obj = createBaseMsgUpdateDeploymentResponse(); + return obj; + }, + toJSON(_: MsgUpdateDeploymentResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): MsgUpdateDeploymentResponse { + const message = createBaseMsgUpdateDeploymentResponse(); + return message; + }, + fromSDK(_: MsgUpdateDeploymentResponseSDKType): MsgUpdateDeploymentResponse { + return {}; + }, + fromSDKJSON(_: any): MsgUpdateDeploymentResponseSDKType { + return {}; + }, + toSDK(_: MsgUpdateDeploymentResponse): MsgUpdateDeploymentResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgUpdateDeploymentResponseAmino): MsgUpdateDeploymentResponse { + const message = createBaseMsgUpdateDeploymentResponse(); + return message; + }, + toAmino(_: MsgUpdateDeploymentResponse): MsgUpdateDeploymentResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgUpdateDeploymentResponseAminoMsg): MsgUpdateDeploymentResponse { + return MsgUpdateDeploymentResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgUpdateDeploymentResponse): MsgUpdateDeploymentResponseAminoMsg { + return { + type: "akash/deployment/testonly-update-deployment-response", + value: MsgUpdateDeploymentResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgUpdateDeploymentResponseProtoMsg): MsgUpdateDeploymentResponse { + return MsgUpdateDeploymentResponse.decode(message.value); + }, + toProto(message: MsgUpdateDeploymentResponse): Uint8Array { + return MsgUpdateDeploymentResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgUpdateDeploymentResponse): MsgUpdateDeploymentResponseProtoMsg { + return { + typeUrl: "/akash.deployment.v1beta1.MsgUpdateDeploymentResponse", + value: MsgUpdateDeploymentResponse.encode(message).finish() + }; + } +}; +function createBaseMsgCloseDeployment(): MsgCloseDeployment { + return { + id: DeploymentID.fromPartial({}) + }; +} +export const MsgCloseDeployment = { + typeUrl: "/akash.deployment.v1beta1.MsgCloseDeployment", + encode(message: MsgCloseDeployment, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.id !== undefined) { + DeploymentID.encode(message.id, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgCloseDeployment { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgCloseDeployment(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.id = DeploymentID.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgCloseDeployment { + const obj = createBaseMsgCloseDeployment(); + if (isSet(object.id)) obj.id = DeploymentID.fromJSON(object.id); + return obj; + }, + toJSON(message: MsgCloseDeployment): JsonSafe { + const obj: any = {}; + message.id !== undefined && (obj.id = message.id ? DeploymentID.toJSON(message.id) : undefined); + return obj; + }, + fromPartial, I>>(object: I): MsgCloseDeployment { + const message = createBaseMsgCloseDeployment(); + if (object.id !== undefined && object.id !== null) { + message.id = DeploymentID.fromPartial(object.id); + } + return message; + }, + fromSDK(object: MsgCloseDeploymentSDKType): MsgCloseDeployment { + return { + id: object.id ? DeploymentID.fromSDK(object.id) : undefined + }; + }, + fromSDKJSON(object: any): MsgCloseDeploymentSDKType { + return { + id: isSet(object.id) ? DeploymentID.fromSDKJSON(object.id) : undefined + }; + }, + toSDK(message: MsgCloseDeployment): MsgCloseDeploymentSDKType { + const obj: any = {}; + message.id !== undefined && (obj.id = message.id ? DeploymentID.toSDK(message.id) : undefined); + return obj; + }, + fromAmino(object: MsgCloseDeploymentAmino): MsgCloseDeployment { + const message = createBaseMsgCloseDeployment(); + if (object.id !== undefined && object.id !== null) { + message.id = DeploymentID.fromAmino(object.id); + } + return message; + }, + toAmino(message: MsgCloseDeployment): MsgCloseDeploymentAmino { + const obj: any = {}; + obj.id = message.id ? DeploymentID.toAmino(message.id) : DeploymentID.toAmino(DeploymentID.fromPartial({})); + return obj; + }, + fromAminoMsg(object: MsgCloseDeploymentAminoMsg): MsgCloseDeployment { + return MsgCloseDeployment.fromAmino(object.value); + }, + toAminoMsg(message: MsgCloseDeployment): MsgCloseDeploymentAminoMsg { + return { + type: "akash/deployment/testonly-close-deployment", + value: MsgCloseDeployment.toAmino(message) + }; + }, + fromProtoMsg(message: MsgCloseDeploymentProtoMsg): MsgCloseDeployment { + return MsgCloseDeployment.decode(message.value); + }, + toProto(message: MsgCloseDeployment): Uint8Array { + return MsgCloseDeployment.encode(message).finish(); + }, + toProtoMsg(message: MsgCloseDeployment): MsgCloseDeploymentProtoMsg { + return { + typeUrl: "/akash.deployment.v1beta1.MsgCloseDeployment", + value: MsgCloseDeployment.encode(message).finish() + }; + } +}; +function createBaseMsgCloseDeploymentResponse(): MsgCloseDeploymentResponse { + return {}; +} +export const MsgCloseDeploymentResponse = { + typeUrl: "/akash.deployment.v1beta1.MsgCloseDeploymentResponse", + encode(_: MsgCloseDeploymentResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgCloseDeploymentResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgCloseDeploymentResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgCloseDeploymentResponse { + const obj = createBaseMsgCloseDeploymentResponse(); + return obj; + }, + toJSON(_: MsgCloseDeploymentResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): MsgCloseDeploymentResponse { + const message = createBaseMsgCloseDeploymentResponse(); + return message; + }, + fromSDK(_: MsgCloseDeploymentResponseSDKType): MsgCloseDeploymentResponse { + return {}; + }, + fromSDKJSON(_: any): MsgCloseDeploymentResponseSDKType { + return {}; + }, + toSDK(_: MsgCloseDeploymentResponse): MsgCloseDeploymentResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgCloseDeploymentResponseAmino): MsgCloseDeploymentResponse { + const message = createBaseMsgCloseDeploymentResponse(); + return message; + }, + toAmino(_: MsgCloseDeploymentResponse): MsgCloseDeploymentResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgCloseDeploymentResponseAminoMsg): MsgCloseDeploymentResponse { + return MsgCloseDeploymentResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgCloseDeploymentResponse): MsgCloseDeploymentResponseAminoMsg { + return { + type: "akash/deployment/testonly-close-deployment-response", + value: MsgCloseDeploymentResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgCloseDeploymentResponseProtoMsg): MsgCloseDeploymentResponse { + return MsgCloseDeploymentResponse.decode(message.value); + }, + toProto(message: MsgCloseDeploymentResponse): Uint8Array { + return MsgCloseDeploymentResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgCloseDeploymentResponse): MsgCloseDeploymentResponseProtoMsg { + return { + typeUrl: "/akash.deployment.v1beta1.MsgCloseDeploymentResponse", + value: MsgCloseDeploymentResponse.encode(message).finish() + }; + } +}; +function createBaseDeploymentID(): DeploymentID { + return { + owner: "", + dseq: BigInt(0) + }; +} +export const DeploymentID = { + typeUrl: "/akash.deployment.v1beta1.DeploymentID", + encode(message: DeploymentID, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.owner !== undefined) { + writer.uint32(10).string(message.owner); + } + if (message.dseq !== undefined) { + writer.uint32(16).uint64(message.dseq); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): DeploymentID { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDeploymentID(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.owner = reader.string(); + break; + case 2: + message.dseq = reader.uint64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): DeploymentID { + const obj = createBaseDeploymentID(); + if (isSet(object.owner)) obj.owner = String(object.owner); + if (isSet(object.dseq)) obj.dseq = BigInt(object.dseq.toString()); + return obj; + }, + toJSON(message: DeploymentID): JsonSafe { + const obj: any = {}; + message.owner !== undefined && (obj.owner = message.owner); + message.dseq !== undefined && (obj.dseq = (message.dseq || BigInt(0)).toString()); + return obj; + }, + fromPartial, I>>(object: I): DeploymentID { + const message = createBaseDeploymentID(); + message.owner = object.owner ?? ""; + if (object.dseq !== undefined && object.dseq !== null) { + message.dseq = BigInt(object.dseq.toString()); + } + return message; + }, + fromSDK(object: DeploymentIDSDKType): DeploymentID { + return { + owner: object?.owner, + dseq: object?.dseq + }; + }, + fromSDKJSON(object: any): DeploymentIDSDKType { + return { + owner: isSet(object.owner) ? String(object.owner) : "", + dseq: isSet(object.dseq) ? BigInt(object.dseq.toString()) : BigInt(0) + }; + }, + toSDK(message: DeploymentID): DeploymentIDSDKType { + const obj: any = {}; + obj.owner = message.owner; + obj.dseq = message.dseq; + return obj; + }, + fromAmino(object: DeploymentIDAmino): DeploymentID { + const message = createBaseDeploymentID(); + if (object.owner !== undefined && object.owner !== null) { + message.owner = object.owner; + } + if (object.dseq !== undefined && object.dseq !== null) { + message.dseq = BigInt(object.dseq); + } + return message; + }, + toAmino(message: DeploymentID): DeploymentIDAmino { + const obj: any = {}; + obj.owner = message.owner ?? ""; + obj.dseq = message.dseq ? message.dseq?.toString() : "0"; + return obj; + }, + fromAminoMsg(object: DeploymentIDAminoMsg): DeploymentID { + return DeploymentID.fromAmino(object.value); + }, + toAminoMsg(message: DeploymentID): DeploymentIDAminoMsg { + return { + type: "akash/deployment/deployment-i-d", + value: DeploymentID.toAmino(message) + }; + }, + fromProtoMsg(message: DeploymentIDProtoMsg): DeploymentID { + return DeploymentID.decode(message.value); + }, + toProto(message: DeploymentID): Uint8Array { + return DeploymentID.encode(message).finish(); + }, + toProtoMsg(message: DeploymentID): DeploymentIDProtoMsg { + return { + typeUrl: "/akash.deployment.v1beta1.DeploymentID", + value: DeploymentID.encode(message).finish() + }; + } +}; +function createBaseDeployment(): Deployment { + return { + deploymentId: DeploymentID.fromPartial({}), + state: 0, + version: new Uint8Array(), + createdAt: BigInt(0) + }; +} +export const Deployment = { + typeUrl: "/akash.deployment.v1beta1.Deployment", + encode(message: Deployment, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.deploymentId !== undefined) { + DeploymentID.encode(message.deploymentId, writer.uint32(10).fork()).ldelim(); + } + if (message.state !== 0) { + writer.uint32(16).int32(message.state); + } + if (message.version.length !== 0) { + writer.uint32(26).bytes(message.version); + } + if (message.createdAt !== undefined) { + writer.uint32(32).int64(message.createdAt); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Deployment { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDeployment(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.deploymentId = DeploymentID.decode(reader, reader.uint32()); + break; + case 2: + message.state = (reader.int32() as any); + break; + case 3: + message.version = reader.bytes(); + break; + case 4: + message.createdAt = reader.int64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Deployment { + const obj = createBaseDeployment(); + if (isSet(object.deploymentId)) obj.deploymentId = DeploymentID.fromJSON(object.deploymentId); + if (isSet(object.state)) obj.state = deployment_StateFromJSON(object.state); + if (isSet(object.version)) obj.version = bytesFromBase64(object.version); + if (isSet(object.createdAt)) obj.createdAt = BigInt(object.createdAt.toString()); + return obj; + }, + toJSON(message: Deployment): JsonSafe { + const obj: any = {}; + message.deploymentId !== undefined && (obj.deploymentId = message.deploymentId ? DeploymentID.toJSON(message.deploymentId) : undefined); + message.state !== undefined && (obj.state = deployment_StateToJSON(message.state)); + message.version !== undefined && (obj.version = base64FromBytes(message.version !== undefined ? message.version : new Uint8Array())); + message.createdAt !== undefined && (obj.createdAt = (message.createdAt || BigInt(0)).toString()); + return obj; + }, + fromPartial, I>>(object: I): Deployment { + const message = createBaseDeployment(); + if (object.deploymentId !== undefined && object.deploymentId !== null) { + message.deploymentId = DeploymentID.fromPartial(object.deploymentId); + } + message.state = object.state ?? 0; + message.version = object.version ?? new Uint8Array(); + if (object.createdAt !== undefined && object.createdAt !== null) { + message.createdAt = BigInt(object.createdAt.toString()); + } + return message; + }, + fromSDK(object: DeploymentSDKType): Deployment { + return { + deploymentId: object.deployment_id ? DeploymentID.fromSDK(object.deployment_id) : undefined, + state: isSet(object.state) ? deployment_StateFromJSON(object.state) : -1, + version: object?.version, + createdAt: object?.created_at + }; + }, + fromSDKJSON(object: any): DeploymentSDKType { + return { + deployment_id: isSet(object.deployment_id) ? DeploymentID.fromSDKJSON(object.deployment_id) : undefined, + state: isSet(object.state) ? deployment_StateFromJSON(object.state) : -1, + version: isSet(object.version) ? bytesFromBase64(object.version) : new Uint8Array(), + created_at: isSet(object.created_at) ? BigInt(object.created_at.toString()) : BigInt(0) + }; + }, + toSDK(message: Deployment): DeploymentSDKType { + const obj: any = {}; + message.deploymentId !== undefined && (obj.deployment_id = message.deploymentId ? DeploymentID.toSDK(message.deploymentId) : undefined); + message.state !== undefined && (obj.state = deployment_StateToJSON(message.state)); + obj.version = message.version; + obj.created_at = message.createdAt; + return obj; + }, + fromAmino(object: DeploymentAmino): Deployment { + const message = createBaseDeployment(); + if (object.deployment_id !== undefined && object.deployment_id !== null) { + message.deploymentId = DeploymentID.fromAmino(object.deployment_id); + } + if (object.state !== undefined && object.state !== null) { + message.state = object.state; + } + if (object.version !== undefined && object.version !== null) { + message.version = bytesFromBase64(object.version); + } + if (object.created_at !== undefined && object.created_at !== null) { + message.createdAt = BigInt(object.created_at); + } + return message; + }, + toAmino(message: Deployment): DeploymentAmino { + const obj: any = {}; + obj.deployment_id = message.deploymentId ? DeploymentID.toAmino(message.deploymentId) : DeploymentID.toAmino(DeploymentID.fromPartial({})); + obj.state = message.state ?? 0; + obj.version = message.version ? base64FromBytes(message.version) : ""; + obj.created_at = message.createdAt !== BigInt(0) ? message.createdAt?.toString() : undefined; + return obj; + }, + fromAminoMsg(object: DeploymentAminoMsg): Deployment { + return Deployment.fromAmino(object.value); + }, + toAminoMsg(message: Deployment): DeploymentAminoMsg { + return { + type: "akash/deployment/deployment", + value: Deployment.toAmino(message) + }; + }, + fromProtoMsg(message: DeploymentProtoMsg): Deployment { + return Deployment.decode(message.value); + }, + toProto(message: Deployment): Uint8Array { + return Deployment.encode(message).finish(); + }, + toProtoMsg(message: Deployment): DeploymentProtoMsg { + return { + typeUrl: "/akash.deployment.v1beta1.Deployment", + value: Deployment.encode(message).finish() + }; + } +}; +function createBaseDeploymentFilters(): DeploymentFilters { + return { + owner: "", + dseq: BigInt(0), + state: "" + }; +} +export const DeploymentFilters = { + typeUrl: "/akash.deployment.v1beta1.DeploymentFilters", + encode(message: DeploymentFilters, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.owner !== undefined) { + writer.uint32(10).string(message.owner); + } + if (message.dseq !== undefined) { + writer.uint32(16).uint64(message.dseq); + } + if (message.state !== undefined) { + writer.uint32(26).string(message.state); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): DeploymentFilters { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDeploymentFilters(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.owner = reader.string(); + break; + case 2: + message.dseq = reader.uint64(); + break; + case 3: + message.state = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): DeploymentFilters { + const obj = createBaseDeploymentFilters(); + if (isSet(object.owner)) obj.owner = String(object.owner); + if (isSet(object.dseq)) obj.dseq = BigInt(object.dseq.toString()); + if (isSet(object.state)) obj.state = String(object.state); + return obj; + }, + toJSON(message: DeploymentFilters): JsonSafe { + const obj: any = {}; + message.owner !== undefined && (obj.owner = message.owner); + message.dseq !== undefined && (obj.dseq = (message.dseq || BigInt(0)).toString()); + message.state !== undefined && (obj.state = message.state); + return obj; + }, + fromPartial, I>>(object: I): DeploymentFilters { + const message = createBaseDeploymentFilters(); + message.owner = object.owner ?? ""; + if (object.dseq !== undefined && object.dseq !== null) { + message.dseq = BigInt(object.dseq.toString()); + } + message.state = object.state ?? ""; + return message; + }, + fromSDK(object: DeploymentFiltersSDKType): DeploymentFilters { + return { + owner: object?.owner, + dseq: object?.dseq, + state: object?.state + }; + }, + fromSDKJSON(object: any): DeploymentFiltersSDKType { + return { + owner: isSet(object.owner) ? String(object.owner) : "", + dseq: isSet(object.dseq) ? BigInt(object.dseq.toString()) : BigInt(0), + state: isSet(object.state) ? String(object.state) : "" + }; + }, + toSDK(message: DeploymentFilters): DeploymentFiltersSDKType { + const obj: any = {}; + obj.owner = message.owner; + obj.dseq = message.dseq; + obj.state = message.state; + return obj; + }, + fromAmino(object: DeploymentFiltersAmino): DeploymentFilters { + const message = createBaseDeploymentFilters(); + if (object.owner !== undefined && object.owner !== null) { + message.owner = object.owner; + } + if (object.dseq !== undefined && object.dseq !== null) { + message.dseq = BigInt(object.dseq); + } + if (object.state !== undefined && object.state !== null) { + message.state = object.state; + } + return message; + }, + toAmino(message: DeploymentFilters): DeploymentFiltersAmino { + const obj: any = {}; + obj.owner = message.owner ?? ""; + obj.dseq = message.dseq ? message.dseq?.toString() : "0"; + obj.state = message.state ?? ""; + return obj; + }, + fromAminoMsg(object: DeploymentFiltersAminoMsg): DeploymentFilters { + return DeploymentFilters.fromAmino(object.value); + }, + toAminoMsg(message: DeploymentFilters): DeploymentFiltersAminoMsg { + return { + type: "akash/deployment/deployment-filters", + value: DeploymentFilters.toAmino(message) + }; + }, + fromProtoMsg(message: DeploymentFiltersProtoMsg): DeploymentFilters { + return DeploymentFilters.decode(message.value); + }, + toProto(message: DeploymentFilters): Uint8Array { + return DeploymentFilters.encode(message).finish(); + }, + toProtoMsg(message: DeploymentFilters): DeploymentFiltersProtoMsg { + return { + typeUrl: "/akash.deployment.v1beta1.DeploymentFilters", + value: DeploymentFilters.encode(message).finish() + }; + } +}; +/** Msg defines the deployment Msg service. */ +export interface Msg { + /** CreateDeployment defines a method to create new deployment given proper inputs. */ + createDeployment(request: MsgCreateDeployment): Promise; + /** DepositDeployment deposits more funds into the deployment account */ + depositDeployment(request: MsgDepositDeployment): Promise; + /** UpdateDeployment defines a method to update a deployment given proper inputs. */ + updateDeployment(request: MsgUpdateDeployment): Promise; + /** CloseDeployment defines a method to close a deployment given proper inputs. */ + closeDeployment(request: MsgCloseDeployment): Promise; + /** CloseGroup defines a method to close a group of a deployment given proper inputs. */ + closeGroup(request: MsgCloseGroup): Promise; + /** PauseGroup defines a method to close a group of a deployment given proper inputs. */ + pauseGroup(request: MsgPauseGroup): Promise; + /** StartGroup defines a method to close a group of a deployment given proper inputs. */ + startGroup(request: MsgStartGroup): Promise; +} +export class MsgClientImpl implements Msg { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + } + /* CreateDeployment defines a method to create new deployment given proper inputs. */ + createDeployment = async (request: MsgCreateDeployment): Promise => { + const data = MsgCreateDeployment.encode(request).finish(); + const promise = this.rpc.request("akash.deployment.v1beta1.Msg", "CreateDeployment", data); + return promise.then(data => MsgCreateDeploymentResponse.decode(new BinaryReader(data))); + }; + /* DepositDeployment deposits more funds into the deployment account */ + depositDeployment = async (request: MsgDepositDeployment): Promise => { + const data = MsgDepositDeployment.encode(request).finish(); + const promise = this.rpc.request("akash.deployment.v1beta1.Msg", "DepositDeployment", data); + return promise.then(data => MsgDepositDeploymentResponse.decode(new BinaryReader(data))); + }; + /* UpdateDeployment defines a method to update a deployment given proper inputs. */ + updateDeployment = async (request: MsgUpdateDeployment): Promise => { + const data = MsgUpdateDeployment.encode(request).finish(); + const promise = this.rpc.request("akash.deployment.v1beta1.Msg", "UpdateDeployment", data); + return promise.then(data => MsgUpdateDeploymentResponse.decode(new BinaryReader(data))); + }; + /* CloseDeployment defines a method to close a deployment given proper inputs. */ + closeDeployment = async (request: MsgCloseDeployment): Promise => { + const data = MsgCloseDeployment.encode(request).finish(); + const promise = this.rpc.request("akash.deployment.v1beta1.Msg", "CloseDeployment", data); + return promise.then(data => MsgCloseDeploymentResponse.decode(new BinaryReader(data))); + }; + /* CloseGroup defines a method to close a group of a deployment given proper inputs. */ + closeGroup = async (request: MsgCloseGroup): Promise => { + const data = MsgCloseGroup.encode(request).finish(); + const promise = this.rpc.request("akash.deployment.v1beta1.Msg", "CloseGroup", data); + return promise.then(data => MsgCloseGroupResponse.decode(new BinaryReader(data))); + }; + /* PauseGroup defines a method to close a group of a deployment given proper inputs. */ + pauseGroup = async (request: MsgPauseGroup): Promise => { + const data = MsgPauseGroup.encode(request).finish(); + const promise = this.rpc.request("akash.deployment.v1beta1.Msg", "PauseGroup", data); + return promise.then(data => MsgPauseGroupResponse.decode(new BinaryReader(data))); + }; + /* StartGroup defines a method to close a group of a deployment given proper inputs. */ + startGroup = async (request: MsgStartGroup): Promise => { + const data = MsgStartGroup.encode(request).finish(); + const promise = this.rpc.request("akash.deployment.v1beta1.Msg", "StartGroup", data); + return promise.then(data => MsgStartGroupResponse.decode(new BinaryReader(data))); + }; +} +export const createClientImpl = (rpc: Rpc) => { + return new MsgClientImpl(rpc); +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta1/genesis.ts b/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta1/genesis.ts new file mode 100644 index 0000000000..d913620200 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta1/genesis.ts @@ -0,0 +1,281 @@ +import { Deployment, DeploymentSDKType } from "./deployment.js"; +import { Group, GroupSDKType } from "./group.js"; +import { Params, ParamsSDKType } from "./params.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, Exact } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "akash.deployment.v1beta1"; +/** GenesisDeployment defines the basic genesis state used by deployment module */ +export interface GenesisDeployment { + deployment: Deployment | undefined; + groups: Group[]; +} +export interface GenesisDeploymentProtoMsg { + typeUrl: "/akash.deployment.v1beta1.GenesisDeployment"; + value: Uint8Array; +} +/** GenesisDeployment defines the basic genesis state used by deployment module */ +export interface GenesisDeploymentSDKType { + deployment: DeploymentSDKType | undefined; + groups: GroupSDKType[]; +} +/** GenesisState stores slice of genesis deployment instance */ +export interface GenesisState { + deployments: GenesisDeployment[]; + params: Params | undefined; +} +export interface GenesisStateProtoMsg { + typeUrl: "/akash.deployment.v1beta1.GenesisState"; + value: Uint8Array; +} +/** GenesisState stores slice of genesis deployment instance */ +export interface GenesisStateSDKType { + deployments: GenesisDeploymentSDKType[]; + params: ParamsSDKType | undefined; +} +function createBaseGenesisDeployment(): GenesisDeployment { + return { + deployment: Deployment.fromPartial({}), + groups: [] + }; +} +export const GenesisDeployment = { + typeUrl: "/akash.deployment.v1beta1.GenesisDeployment", + encode(message: GenesisDeployment, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.deployment !== undefined) { + Deployment.encode(message.deployment, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.groups) { + Group.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GenesisDeployment { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGenesisDeployment(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.deployment = Deployment.decode(reader, reader.uint32()); + break; + case 2: + message.groups.push(Group.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GenesisDeployment { + const obj = createBaseGenesisDeployment(); + if (isSet(object.deployment)) obj.deployment = Deployment.fromJSON(object.deployment); + if (Array.isArray(object?.groups)) obj.groups = object.groups.map((e: any) => Group.fromJSON(e)); + return obj; + }, + toJSON(message: GenesisDeployment): JsonSafe { + const obj: any = {}; + message.deployment !== undefined && (obj.deployment = message.deployment ? Deployment.toJSON(message.deployment) : undefined); + if (message.groups) { + obj.groups = message.groups.map(e => e ? Group.toJSON(e) : undefined); + } else { + obj.groups = []; + } + return obj; + }, + fromPartial, I>>(object: I): GenesisDeployment { + const message = createBaseGenesisDeployment(); + if (object.deployment !== undefined && object.deployment !== null) { + message.deployment = Deployment.fromPartial(object.deployment); + } + message.groups = object.groups?.map(e => Group.fromPartial(e)) || []; + return message; + }, + fromSDK(object: GenesisDeploymentSDKType): GenesisDeployment { + return { + deployment: object.deployment ? Deployment.fromSDK(object.deployment) : undefined, + groups: Array.isArray(object?.groups) ? object.groups.map((e: any) => Group.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): GenesisDeploymentSDKType { + return { + deployment: isSet(object.deployment) ? Deployment.fromSDKJSON(object.deployment) : undefined, + groups: Array.isArray(object?.groups) ? object.groups.map((e: any) => Group.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: GenesisDeployment): GenesisDeploymentSDKType { + const obj: any = {}; + message.deployment !== undefined && (obj.deployment = message.deployment ? Deployment.toSDK(message.deployment) : undefined); + if (message.groups) { + obj.groups = message.groups.map(e => e ? Group.toSDK(e) : undefined); + } else { + obj.groups = []; + } + return obj; + }, + fromAmino(object: GenesisDeploymentAmino): GenesisDeployment { + const message = createBaseGenesisDeployment(); + if (object.deployment !== undefined && object.deployment !== null) { + message.deployment = Deployment.fromAmino(object.deployment); + } + message.groups = object.groups?.map(e => Group.fromAmino(e)) || []; + return message; + }, + toAmino(message: GenesisDeployment): GenesisDeploymentAmino { + const obj: any = {}; + obj.deployment = message.deployment ? Deployment.toAmino(message.deployment) : Deployment.toAmino(Deployment.fromPartial({})); + if (message.groups) { + obj.groups = message.groups.map(e => e ? Group.toAmino(e) : undefined); + } else { + obj.groups = message.groups; + } + return obj; + }, + fromAminoMsg(object: GenesisDeploymentAminoMsg): GenesisDeployment { + return GenesisDeployment.fromAmino(object.value); + }, + toAminoMsg(message: GenesisDeployment): GenesisDeploymentAminoMsg { + return { + type: "akash/deployment/genesis-deployment", + value: GenesisDeployment.toAmino(message) + }; + }, + fromProtoMsg(message: GenesisDeploymentProtoMsg): GenesisDeployment { + return GenesisDeployment.decode(message.value); + }, + toProto(message: GenesisDeployment): Uint8Array { + return GenesisDeployment.encode(message).finish(); + }, + toProtoMsg(message: GenesisDeployment): GenesisDeploymentProtoMsg { + return { + typeUrl: "/akash.deployment.v1beta1.GenesisDeployment", + value: GenesisDeployment.encode(message).finish() + }; + } +}; +function createBaseGenesisState(): GenesisState { + return { + deployments: [], + params: Params.fromPartial({}) + }; +} +export const GenesisState = { + typeUrl: "/akash.deployment.v1beta1.GenesisState", + encode(message: GenesisState, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.deployments) { + GenesisDeployment.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GenesisState { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGenesisState(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.deployments.push(GenesisDeployment.decode(reader, reader.uint32())); + break; + case 2: + message.params = Params.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GenesisState { + const obj = createBaseGenesisState(); + if (Array.isArray(object?.deployments)) obj.deployments = object.deployments.map((e: any) => GenesisDeployment.fromJSON(e)); + if (isSet(object.params)) obj.params = Params.fromJSON(object.params); + return obj; + }, + toJSON(message: GenesisState): JsonSafe { + const obj: any = {}; + if (message.deployments) { + obj.deployments = message.deployments.map(e => e ? GenesisDeployment.toJSON(e) : undefined); + } else { + obj.deployments = []; + } + message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); + return obj; + }, + fromPartial, I>>(object: I): GenesisState { + const message = createBaseGenesisState(); + message.deployments = object.deployments?.map(e => GenesisDeployment.fromPartial(e)) || []; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } + return message; + }, + fromSDK(object: GenesisStateSDKType): GenesisState { + return { + deployments: Array.isArray(object?.deployments) ? object.deployments.map((e: any) => GenesisDeployment.fromSDK(e)) : [], + params: object.params ? Params.fromSDK(object.params) : undefined + }; + }, + fromSDKJSON(object: any): GenesisStateSDKType { + return { + deployments: Array.isArray(object?.deployments) ? object.deployments.map((e: any) => GenesisDeployment.fromSDKJSON(e)) : [], + params: isSet(object.params) ? Params.fromSDKJSON(object.params) : undefined + }; + }, + toSDK(message: GenesisState): GenesisStateSDKType { + const obj: any = {}; + if (message.deployments) { + obj.deployments = message.deployments.map(e => e ? GenesisDeployment.toSDK(e) : undefined); + } else { + obj.deployments = []; + } + message.params !== undefined && (obj.params = message.params ? Params.toSDK(message.params) : undefined); + return obj; + }, + fromAmino(object: GenesisStateAmino): GenesisState { + const message = createBaseGenesisState(); + message.deployments = object.deployments?.map(e => GenesisDeployment.fromAmino(e)) || []; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromAmino(object.params); + } + return message; + }, + toAmino(message: GenesisState): GenesisStateAmino { + const obj: any = {}; + if (message.deployments) { + obj.deployments = message.deployments.map(e => e ? GenesisDeployment.toAmino(e) : undefined); + } else { + obj.deployments = message.deployments; + } + obj.params = message.params ? Params.toAmino(message.params) : Params.toAmino(Params.fromPartial({})); + return obj; + }, + fromAminoMsg(object: GenesisStateAminoMsg): GenesisState { + return GenesisState.fromAmino(object.value); + }, + toAminoMsg(message: GenesisState): GenesisStateAminoMsg { + return { + type: "akash/deployment/genesis-state", + value: GenesisState.toAmino(message) + }; + }, + fromProtoMsg(message: GenesisStateProtoMsg): GenesisState { + return GenesisState.decode(message.value); + }, + toProto(message: GenesisState): Uint8Array { + return GenesisState.encode(message).finish(); + }, + toProtoMsg(message: GenesisState): GenesisStateProtoMsg { + return { + typeUrl: "/akash.deployment.v1beta1.GenesisState", + value: GenesisState.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta1/group.ts b/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta1/group.ts new file mode 100644 index 0000000000..33f785f03f --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta1/group.ts @@ -0,0 +1,1251 @@ +import { PlacementRequirements, PlacementRequirementsSDKType } from "../../base/v1beta1/attribute.js"; +import { ResourceUnits, ResourceUnitsSDKType } from "../../base/v1beta1/resource.js"; +import { Coin, CoinSDKType } from "../../../cosmos/base/v1beta1/coin.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, Exact } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "akash.deployment.v1beta1"; +/** State is an enum which refers to state of group */ +export enum Group_State { + /** invalid - Prefix should start with 0 in enum. So declaring dummy state */ + invalid = 0, + /** open - GroupOpen denotes state for group open */ + open = 1, + /** paused - GroupOrdered denotes state for group ordered */ + paused = 2, + /** insufficient_funds - GroupInsufficientFunds denotes state for group insufficient_funds */ + insufficient_funds = 3, + /** closed - GroupClosed denotes state for group closed */ + closed = 4, + UNRECOGNIZED = -1, +} +export const Group_StateSDKType = Group_State; +export function group_StateFromJSON(object: any): Group_State { + switch (object) { + case 0: + case "invalid": + return Group_State.invalid; + case 1: + case "open": + return Group_State.open; + case 2: + case "paused": + return Group_State.paused; + case 3: + case "insufficient_funds": + return Group_State.insufficient_funds; + case 4: + case "closed": + return Group_State.closed; + case -1: + case "UNRECOGNIZED": + default: + return Group_State.UNRECOGNIZED; + } +} +export function group_StateToJSON(object: Group_State): string { + switch (object) { + case Group_State.invalid: + return "invalid"; + case Group_State.open: + return "open"; + case Group_State.paused: + return "paused"; + case Group_State.insufficient_funds: + return "insufficient_funds"; + case Group_State.closed: + return "closed"; + case Group_State.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** MsgCloseGroup defines SDK message to close a single Group within a Deployment. */ +export interface MsgCloseGroup { + id: GroupID | undefined; +} +export interface MsgCloseGroupProtoMsg { + typeUrl: "/akash.deployment.v1beta1.MsgCloseGroup"; + value: Uint8Array; +} +/** MsgCloseGroup defines SDK message to close a single Group within a Deployment. */ +export interface MsgCloseGroupSDKType { + id: GroupIDSDKType | undefined; +} +/** MsgCloseGroupResponse defines the Msg/CloseGroup response type. */ +export interface MsgCloseGroupResponse {} +export interface MsgCloseGroupResponseProtoMsg { + typeUrl: "/akash.deployment.v1beta1.MsgCloseGroupResponse"; + value: Uint8Array; +} +/** MsgCloseGroupResponse defines the Msg/CloseGroup response type. */ +export interface MsgCloseGroupResponseSDKType {} +/** MsgPauseGroup defines SDK message to close a single Group within a Deployment. */ +export interface MsgPauseGroup { + id: GroupID | undefined; +} +export interface MsgPauseGroupProtoMsg { + typeUrl: "/akash.deployment.v1beta1.MsgPauseGroup"; + value: Uint8Array; +} +/** MsgPauseGroup defines SDK message to close a single Group within a Deployment. */ +export interface MsgPauseGroupSDKType { + id: GroupIDSDKType | undefined; +} +/** MsgPauseGroupResponse defines the Msg/PauseGroup response type. */ +export interface MsgPauseGroupResponse {} +export interface MsgPauseGroupResponseProtoMsg { + typeUrl: "/akash.deployment.v1beta1.MsgPauseGroupResponse"; + value: Uint8Array; +} +/** MsgPauseGroupResponse defines the Msg/PauseGroup response type. */ +export interface MsgPauseGroupResponseSDKType {} +/** MsgStartGroup defines SDK message to close a single Group within a Deployment. */ +export interface MsgStartGroup { + id: GroupID | undefined; +} +export interface MsgStartGroupProtoMsg { + typeUrl: "/akash.deployment.v1beta1.MsgStartGroup"; + value: Uint8Array; +} +/** MsgStartGroup defines SDK message to close a single Group within a Deployment. */ +export interface MsgStartGroupSDKType { + id: GroupIDSDKType | undefined; +} +/** MsgStartGroupResponse defines the Msg/StartGroup response type. */ +export interface MsgStartGroupResponse {} +export interface MsgStartGroupResponseProtoMsg { + typeUrl: "/akash.deployment.v1beta1.MsgStartGroupResponse"; + value: Uint8Array; +} +/** MsgStartGroupResponse defines the Msg/StartGroup response type. */ +export interface MsgStartGroupResponseSDKType {} +/** GroupID stores owner, deployment sequence number and group sequence number */ +export interface GroupID { + owner: string; + dseq: bigint; + gseq: number; +} +export interface GroupIDProtoMsg { + typeUrl: "/akash.deployment.v1beta1.GroupID"; + value: Uint8Array; +} +/** GroupID stores owner, deployment sequence number and group sequence number */ +export interface GroupIDSDKType { + owner: string; + dseq: bigint; + gseq: number; +} +/** GroupSpec stores group specifications */ +export interface GroupSpec { + name: string; + requirements: PlacementRequirements | undefined; + resources: Resource[]; +} +export interface GroupSpecProtoMsg { + typeUrl: "/akash.deployment.v1beta1.GroupSpec"; + value: Uint8Array; +} +/** GroupSpec stores group specifications */ +export interface GroupSpecSDKType { + name: string; + requirements: PlacementRequirementsSDKType | undefined; + resources: ResourceSDKType[]; +} +/** Group stores group id, state and specifications of group */ +export interface Group { + groupId: GroupID | undefined; + state: Group_State; + groupSpec: GroupSpec | undefined; + createdAt: bigint; +} +export interface GroupProtoMsg { + typeUrl: "/akash.deployment.v1beta1.Group"; + value: Uint8Array; +} +/** Group stores group id, state and specifications of group */ +export interface GroupSDKType { + group_id: GroupIDSDKType | undefined; + state: Group_State; + group_spec: GroupSpecSDKType | undefined; + created_at: bigint; +} +/** Resource stores unit, total count and price of resource */ +export interface Resource { + resources: ResourceUnits | undefined; + count: number; + price: Coin | undefined; +} +export interface ResourceProtoMsg { + typeUrl: "/akash.deployment.v1beta1.Resource"; + value: Uint8Array; +} +/** Resource stores unit, total count and price of resource */ +export interface ResourceSDKType { + resources: ResourceUnitsSDKType | undefined; + count: number; + price: CoinSDKType | undefined; +} +function createBaseMsgCloseGroup(): MsgCloseGroup { + return { + id: GroupID.fromPartial({}) + }; +} +export const MsgCloseGroup = { + typeUrl: "/akash.deployment.v1beta1.MsgCloseGroup", + encode(message: MsgCloseGroup, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.id !== undefined) { + GroupID.encode(message.id, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgCloseGroup { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgCloseGroup(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.id = GroupID.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgCloseGroup { + const obj = createBaseMsgCloseGroup(); + if (isSet(object.id)) obj.id = GroupID.fromJSON(object.id); + return obj; + }, + toJSON(message: MsgCloseGroup): JsonSafe { + const obj: any = {}; + message.id !== undefined && (obj.id = message.id ? GroupID.toJSON(message.id) : undefined); + return obj; + }, + fromPartial, I>>(object: I): MsgCloseGroup { + const message = createBaseMsgCloseGroup(); + if (object.id !== undefined && object.id !== null) { + message.id = GroupID.fromPartial(object.id); + } + return message; + }, + fromSDK(object: MsgCloseGroupSDKType): MsgCloseGroup { + return { + id: object.id ? GroupID.fromSDK(object.id) : undefined + }; + }, + fromSDKJSON(object: any): MsgCloseGroupSDKType { + return { + id: isSet(object.id) ? GroupID.fromSDKJSON(object.id) : undefined + }; + }, + toSDK(message: MsgCloseGroup): MsgCloseGroupSDKType { + const obj: any = {}; + message.id !== undefined && (obj.id = message.id ? GroupID.toSDK(message.id) : undefined); + return obj; + }, + fromAmino(object: MsgCloseGroupAmino): MsgCloseGroup { + const message = createBaseMsgCloseGroup(); + if (object.id !== undefined && object.id !== null) { + message.id = GroupID.fromAmino(object.id); + } + return message; + }, + toAmino(message: MsgCloseGroup): MsgCloseGroupAmino { + const obj: any = {}; + obj.id = message.id ? GroupID.toAmino(message.id) : GroupID.toAmino(GroupID.fromPartial({})); + return obj; + }, + fromAminoMsg(object: MsgCloseGroupAminoMsg): MsgCloseGroup { + return MsgCloseGroup.fromAmino(object.value); + }, + toAminoMsg(message: MsgCloseGroup): MsgCloseGroupAminoMsg { + return { + type: "akash/deployment/testonly-close-group", + value: MsgCloseGroup.toAmino(message) + }; + }, + fromProtoMsg(message: MsgCloseGroupProtoMsg): MsgCloseGroup { + return MsgCloseGroup.decode(message.value); + }, + toProto(message: MsgCloseGroup): Uint8Array { + return MsgCloseGroup.encode(message).finish(); + }, + toProtoMsg(message: MsgCloseGroup): MsgCloseGroupProtoMsg { + return { + typeUrl: "/akash.deployment.v1beta1.MsgCloseGroup", + value: MsgCloseGroup.encode(message).finish() + }; + } +}; +function createBaseMsgCloseGroupResponse(): MsgCloseGroupResponse { + return {}; +} +export const MsgCloseGroupResponse = { + typeUrl: "/akash.deployment.v1beta1.MsgCloseGroupResponse", + encode(_: MsgCloseGroupResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgCloseGroupResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgCloseGroupResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgCloseGroupResponse { + const obj = createBaseMsgCloseGroupResponse(); + return obj; + }, + toJSON(_: MsgCloseGroupResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): MsgCloseGroupResponse { + const message = createBaseMsgCloseGroupResponse(); + return message; + }, + fromSDK(_: MsgCloseGroupResponseSDKType): MsgCloseGroupResponse { + return {}; + }, + fromSDKJSON(_: any): MsgCloseGroupResponseSDKType { + return {}; + }, + toSDK(_: MsgCloseGroupResponse): MsgCloseGroupResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgCloseGroupResponseAmino): MsgCloseGroupResponse { + const message = createBaseMsgCloseGroupResponse(); + return message; + }, + toAmino(_: MsgCloseGroupResponse): MsgCloseGroupResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgCloseGroupResponseAminoMsg): MsgCloseGroupResponse { + return MsgCloseGroupResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgCloseGroupResponse): MsgCloseGroupResponseAminoMsg { + return { + type: "akash/deployment/testonly-close-group-response", + value: MsgCloseGroupResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgCloseGroupResponseProtoMsg): MsgCloseGroupResponse { + return MsgCloseGroupResponse.decode(message.value); + }, + toProto(message: MsgCloseGroupResponse): Uint8Array { + return MsgCloseGroupResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgCloseGroupResponse): MsgCloseGroupResponseProtoMsg { + return { + typeUrl: "/akash.deployment.v1beta1.MsgCloseGroupResponse", + value: MsgCloseGroupResponse.encode(message).finish() + }; + } +}; +function createBaseMsgPauseGroup(): MsgPauseGroup { + return { + id: GroupID.fromPartial({}) + }; +} +export const MsgPauseGroup = { + typeUrl: "/akash.deployment.v1beta1.MsgPauseGroup", + encode(message: MsgPauseGroup, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.id !== undefined) { + GroupID.encode(message.id, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgPauseGroup { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgPauseGroup(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.id = GroupID.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgPauseGroup { + const obj = createBaseMsgPauseGroup(); + if (isSet(object.id)) obj.id = GroupID.fromJSON(object.id); + return obj; + }, + toJSON(message: MsgPauseGroup): JsonSafe { + const obj: any = {}; + message.id !== undefined && (obj.id = message.id ? GroupID.toJSON(message.id) : undefined); + return obj; + }, + fromPartial, I>>(object: I): MsgPauseGroup { + const message = createBaseMsgPauseGroup(); + if (object.id !== undefined && object.id !== null) { + message.id = GroupID.fromPartial(object.id); + } + return message; + }, + fromSDK(object: MsgPauseGroupSDKType): MsgPauseGroup { + return { + id: object.id ? GroupID.fromSDK(object.id) : undefined + }; + }, + fromSDKJSON(object: any): MsgPauseGroupSDKType { + return { + id: isSet(object.id) ? GroupID.fromSDKJSON(object.id) : undefined + }; + }, + toSDK(message: MsgPauseGroup): MsgPauseGroupSDKType { + const obj: any = {}; + message.id !== undefined && (obj.id = message.id ? GroupID.toSDK(message.id) : undefined); + return obj; + }, + fromAmino(object: MsgPauseGroupAmino): MsgPauseGroup { + const message = createBaseMsgPauseGroup(); + if (object.id !== undefined && object.id !== null) { + message.id = GroupID.fromAmino(object.id); + } + return message; + }, + toAmino(message: MsgPauseGroup): MsgPauseGroupAmino { + const obj: any = {}; + obj.id = message.id ? GroupID.toAmino(message.id) : GroupID.toAmino(GroupID.fromPartial({})); + return obj; + }, + fromAminoMsg(object: MsgPauseGroupAminoMsg): MsgPauseGroup { + return MsgPauseGroup.fromAmino(object.value); + }, + toAminoMsg(message: MsgPauseGroup): MsgPauseGroupAminoMsg { + return { + type: "akash/deployment/testonly-pause-group", + value: MsgPauseGroup.toAmino(message) + }; + }, + fromProtoMsg(message: MsgPauseGroupProtoMsg): MsgPauseGroup { + return MsgPauseGroup.decode(message.value); + }, + toProto(message: MsgPauseGroup): Uint8Array { + return MsgPauseGroup.encode(message).finish(); + }, + toProtoMsg(message: MsgPauseGroup): MsgPauseGroupProtoMsg { + return { + typeUrl: "/akash.deployment.v1beta1.MsgPauseGroup", + value: MsgPauseGroup.encode(message).finish() + }; + } +}; +function createBaseMsgPauseGroupResponse(): MsgPauseGroupResponse { + return {}; +} +export const MsgPauseGroupResponse = { + typeUrl: "/akash.deployment.v1beta1.MsgPauseGroupResponse", + encode(_: MsgPauseGroupResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgPauseGroupResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgPauseGroupResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgPauseGroupResponse { + const obj = createBaseMsgPauseGroupResponse(); + return obj; + }, + toJSON(_: MsgPauseGroupResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): MsgPauseGroupResponse { + const message = createBaseMsgPauseGroupResponse(); + return message; + }, + fromSDK(_: MsgPauseGroupResponseSDKType): MsgPauseGroupResponse { + return {}; + }, + fromSDKJSON(_: any): MsgPauseGroupResponseSDKType { + return {}; + }, + toSDK(_: MsgPauseGroupResponse): MsgPauseGroupResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgPauseGroupResponseAmino): MsgPauseGroupResponse { + const message = createBaseMsgPauseGroupResponse(); + return message; + }, + toAmino(_: MsgPauseGroupResponse): MsgPauseGroupResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgPauseGroupResponseAminoMsg): MsgPauseGroupResponse { + return MsgPauseGroupResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgPauseGroupResponse): MsgPauseGroupResponseAminoMsg { + return { + type: "akash/deployment/testonly-pause-group-response", + value: MsgPauseGroupResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgPauseGroupResponseProtoMsg): MsgPauseGroupResponse { + return MsgPauseGroupResponse.decode(message.value); + }, + toProto(message: MsgPauseGroupResponse): Uint8Array { + return MsgPauseGroupResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgPauseGroupResponse): MsgPauseGroupResponseProtoMsg { + return { + typeUrl: "/akash.deployment.v1beta1.MsgPauseGroupResponse", + value: MsgPauseGroupResponse.encode(message).finish() + }; + } +}; +function createBaseMsgStartGroup(): MsgStartGroup { + return { + id: GroupID.fromPartial({}) + }; +} +export const MsgStartGroup = { + typeUrl: "/akash.deployment.v1beta1.MsgStartGroup", + encode(message: MsgStartGroup, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.id !== undefined) { + GroupID.encode(message.id, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgStartGroup { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgStartGroup(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.id = GroupID.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgStartGroup { + const obj = createBaseMsgStartGroup(); + if (isSet(object.id)) obj.id = GroupID.fromJSON(object.id); + return obj; + }, + toJSON(message: MsgStartGroup): JsonSafe { + const obj: any = {}; + message.id !== undefined && (obj.id = message.id ? GroupID.toJSON(message.id) : undefined); + return obj; + }, + fromPartial, I>>(object: I): MsgStartGroup { + const message = createBaseMsgStartGroup(); + if (object.id !== undefined && object.id !== null) { + message.id = GroupID.fromPartial(object.id); + } + return message; + }, + fromSDK(object: MsgStartGroupSDKType): MsgStartGroup { + return { + id: object.id ? GroupID.fromSDK(object.id) : undefined + }; + }, + fromSDKJSON(object: any): MsgStartGroupSDKType { + return { + id: isSet(object.id) ? GroupID.fromSDKJSON(object.id) : undefined + }; + }, + toSDK(message: MsgStartGroup): MsgStartGroupSDKType { + const obj: any = {}; + message.id !== undefined && (obj.id = message.id ? GroupID.toSDK(message.id) : undefined); + return obj; + }, + fromAmino(object: MsgStartGroupAmino): MsgStartGroup { + const message = createBaseMsgStartGroup(); + if (object.id !== undefined && object.id !== null) { + message.id = GroupID.fromAmino(object.id); + } + return message; + }, + toAmino(message: MsgStartGroup): MsgStartGroupAmino { + const obj: any = {}; + obj.id = message.id ? GroupID.toAmino(message.id) : GroupID.toAmino(GroupID.fromPartial({})); + return obj; + }, + fromAminoMsg(object: MsgStartGroupAminoMsg): MsgStartGroup { + return MsgStartGroup.fromAmino(object.value); + }, + toAminoMsg(message: MsgStartGroup): MsgStartGroupAminoMsg { + return { + type: "akash/deployment/testonly-start-group", + value: MsgStartGroup.toAmino(message) + }; + }, + fromProtoMsg(message: MsgStartGroupProtoMsg): MsgStartGroup { + return MsgStartGroup.decode(message.value); + }, + toProto(message: MsgStartGroup): Uint8Array { + return MsgStartGroup.encode(message).finish(); + }, + toProtoMsg(message: MsgStartGroup): MsgStartGroupProtoMsg { + return { + typeUrl: "/akash.deployment.v1beta1.MsgStartGroup", + value: MsgStartGroup.encode(message).finish() + }; + } +}; +function createBaseMsgStartGroupResponse(): MsgStartGroupResponse { + return {}; +} +export const MsgStartGroupResponse = { + typeUrl: "/akash.deployment.v1beta1.MsgStartGroupResponse", + encode(_: MsgStartGroupResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgStartGroupResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgStartGroupResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgStartGroupResponse { + const obj = createBaseMsgStartGroupResponse(); + return obj; + }, + toJSON(_: MsgStartGroupResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): MsgStartGroupResponse { + const message = createBaseMsgStartGroupResponse(); + return message; + }, + fromSDK(_: MsgStartGroupResponseSDKType): MsgStartGroupResponse { + return {}; + }, + fromSDKJSON(_: any): MsgStartGroupResponseSDKType { + return {}; + }, + toSDK(_: MsgStartGroupResponse): MsgStartGroupResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgStartGroupResponseAmino): MsgStartGroupResponse { + const message = createBaseMsgStartGroupResponse(); + return message; + }, + toAmino(_: MsgStartGroupResponse): MsgStartGroupResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgStartGroupResponseAminoMsg): MsgStartGroupResponse { + return MsgStartGroupResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgStartGroupResponse): MsgStartGroupResponseAminoMsg { + return { + type: "akash/deployment/testonly-start-group-response", + value: MsgStartGroupResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgStartGroupResponseProtoMsg): MsgStartGroupResponse { + return MsgStartGroupResponse.decode(message.value); + }, + toProto(message: MsgStartGroupResponse): Uint8Array { + return MsgStartGroupResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgStartGroupResponse): MsgStartGroupResponseProtoMsg { + return { + typeUrl: "/akash.deployment.v1beta1.MsgStartGroupResponse", + value: MsgStartGroupResponse.encode(message).finish() + }; + } +}; +function createBaseGroupID(): GroupID { + return { + owner: "", + dseq: BigInt(0), + gseq: 0 + }; +} +export const GroupID = { + typeUrl: "/akash.deployment.v1beta1.GroupID", + encode(message: GroupID, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.owner !== undefined) { + writer.uint32(10).string(message.owner); + } + if (message.dseq !== undefined) { + writer.uint32(16).uint64(message.dseq); + } + if (message.gseq !== undefined) { + writer.uint32(24).uint32(message.gseq); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GroupID { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGroupID(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.owner = reader.string(); + break; + case 2: + message.dseq = reader.uint64(); + break; + case 3: + message.gseq = reader.uint32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GroupID { + const obj = createBaseGroupID(); + if (isSet(object.owner)) obj.owner = String(object.owner); + if (isSet(object.dseq)) obj.dseq = BigInt(object.dseq.toString()); + if (isSet(object.gseq)) obj.gseq = Number(object.gseq); + return obj; + }, + toJSON(message: GroupID): JsonSafe { + const obj: any = {}; + message.owner !== undefined && (obj.owner = message.owner); + message.dseq !== undefined && (obj.dseq = (message.dseq || BigInt(0)).toString()); + message.gseq !== undefined && (obj.gseq = Math.round(message.gseq)); + return obj; + }, + fromPartial, I>>(object: I): GroupID { + const message = createBaseGroupID(); + message.owner = object.owner ?? ""; + if (object.dseq !== undefined && object.dseq !== null) { + message.dseq = BigInt(object.dseq.toString()); + } + message.gseq = object.gseq ?? 0; + return message; + }, + fromSDK(object: GroupIDSDKType): GroupID { + return { + owner: object?.owner, + dseq: object?.dseq, + gseq: object?.gseq + }; + }, + fromSDKJSON(object: any): GroupIDSDKType { + return { + owner: isSet(object.owner) ? String(object.owner) : "", + dseq: isSet(object.dseq) ? BigInt(object.dseq.toString()) : BigInt(0), + gseq: isSet(object.gseq) ? Number(object.gseq) : 0 + }; + }, + toSDK(message: GroupID): GroupIDSDKType { + const obj: any = {}; + obj.owner = message.owner; + obj.dseq = message.dseq; + obj.gseq = message.gseq; + return obj; + }, + fromAmino(object: GroupIDAmino): GroupID { + const message = createBaseGroupID(); + if (object.owner !== undefined && object.owner !== null) { + message.owner = object.owner; + } + if (object.dseq !== undefined && object.dseq !== null) { + message.dseq = BigInt(object.dseq); + } + if (object.gseq !== undefined && object.gseq !== null) { + message.gseq = object.gseq; + } + return message; + }, + toAmino(message: GroupID): GroupIDAmino { + const obj: any = {}; + obj.owner = message.owner ?? ""; + obj.dseq = message.dseq ? message.dseq?.toString() : "0"; + obj.gseq = message.gseq ?? 0; + return obj; + }, + fromAminoMsg(object: GroupIDAminoMsg): GroupID { + return GroupID.fromAmino(object.value); + }, + toAminoMsg(message: GroupID): GroupIDAminoMsg { + return { + type: "akash/deployment/group-i-d", + value: GroupID.toAmino(message) + }; + }, + fromProtoMsg(message: GroupIDProtoMsg): GroupID { + return GroupID.decode(message.value); + }, + toProto(message: GroupID): Uint8Array { + return GroupID.encode(message).finish(); + }, + toProtoMsg(message: GroupID): GroupIDProtoMsg { + return { + typeUrl: "/akash.deployment.v1beta1.GroupID", + value: GroupID.encode(message).finish() + }; + } +}; +function createBaseGroupSpec(): GroupSpec { + return { + name: "", + requirements: PlacementRequirements.fromPartial({}), + resources: [] + }; +} +export const GroupSpec = { + typeUrl: "/akash.deployment.v1beta1.GroupSpec", + encode(message: GroupSpec, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + if (message.requirements !== undefined) { + PlacementRequirements.encode(message.requirements, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.resources) { + Resource.encode(v!, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GroupSpec { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGroupSpec(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.requirements = PlacementRequirements.decode(reader, reader.uint32()); + break; + case 3: + message.resources.push(Resource.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GroupSpec { + const obj = createBaseGroupSpec(); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.requirements)) obj.requirements = PlacementRequirements.fromJSON(object.requirements); + if (Array.isArray(object?.resources)) obj.resources = object.resources.map((e: any) => Resource.fromJSON(e)); + return obj; + }, + toJSON(message: GroupSpec): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.requirements !== undefined && (obj.requirements = message.requirements ? PlacementRequirements.toJSON(message.requirements) : undefined); + if (message.resources) { + obj.resources = message.resources.map(e => e ? Resource.toJSON(e) : undefined); + } else { + obj.resources = []; + } + return obj; + }, + fromPartial, I>>(object: I): GroupSpec { + const message = createBaseGroupSpec(); + message.name = object.name ?? ""; + if (object.requirements !== undefined && object.requirements !== null) { + message.requirements = PlacementRequirements.fromPartial(object.requirements); + } + message.resources = object.resources?.map(e => Resource.fromPartial(e)) || []; + return message; + }, + fromSDK(object: GroupSpecSDKType): GroupSpec { + return { + name: object?.name, + requirements: object.requirements ? PlacementRequirements.fromSDK(object.requirements) : undefined, + resources: Array.isArray(object?.resources) ? object.resources.map((e: any) => Resource.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): GroupSpecSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + requirements: isSet(object.requirements) ? PlacementRequirements.fromSDKJSON(object.requirements) : undefined, + resources: Array.isArray(object?.resources) ? object.resources.map((e: any) => Resource.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: GroupSpec): GroupSpecSDKType { + const obj: any = {}; + obj.name = message.name; + message.requirements !== undefined && (obj.requirements = message.requirements ? PlacementRequirements.toSDK(message.requirements) : undefined); + if (message.resources) { + obj.resources = message.resources.map(e => e ? Resource.toSDK(e) : undefined); + } else { + obj.resources = []; + } + return obj; + }, + fromAmino(object: GroupSpecAmino): GroupSpec { + const message = createBaseGroupSpec(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + if (object.requirements !== undefined && object.requirements !== null) { + message.requirements = PlacementRequirements.fromAmino(object.requirements); + } + message.resources = object.resources?.map(e => Resource.fromAmino(e)) || []; + return message; + }, + toAmino(message: GroupSpec): GroupSpecAmino { + const obj: any = {}; + obj.name = message.name ?? ""; + obj.requirements = message.requirements ? PlacementRequirements.toAmino(message.requirements) : PlacementRequirements.toAmino(PlacementRequirements.fromPartial({})); + if (message.resources) { + obj.resources = message.resources.map(e => e ? Resource.toAmino(e) : undefined); + } else { + obj.resources = message.resources; + } + return obj; + }, + fromAminoMsg(object: GroupSpecAminoMsg): GroupSpec { + return GroupSpec.fromAmino(object.value); + }, + toAminoMsg(message: GroupSpec): GroupSpecAminoMsg { + return { + type: "akash/deployment/group-spec", + value: GroupSpec.toAmino(message) + }; + }, + fromProtoMsg(message: GroupSpecProtoMsg): GroupSpec { + return GroupSpec.decode(message.value); + }, + toProto(message: GroupSpec): Uint8Array { + return GroupSpec.encode(message).finish(); + }, + toProtoMsg(message: GroupSpec): GroupSpecProtoMsg { + return { + typeUrl: "/akash.deployment.v1beta1.GroupSpec", + value: GroupSpec.encode(message).finish() + }; + } +}; +function createBaseGroup(): Group { + return { + groupId: GroupID.fromPartial({}), + state: 0, + groupSpec: GroupSpec.fromPartial({}), + createdAt: BigInt(0) + }; +} +export const Group = { + typeUrl: "/akash.deployment.v1beta1.Group", + encode(message: Group, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.groupId !== undefined) { + GroupID.encode(message.groupId, writer.uint32(10).fork()).ldelim(); + } + if (message.state !== 0) { + writer.uint32(16).int32(message.state); + } + if (message.groupSpec !== undefined) { + GroupSpec.encode(message.groupSpec, writer.uint32(26).fork()).ldelim(); + } + if (message.createdAt !== undefined) { + writer.uint32(32).int64(message.createdAt); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Group { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGroup(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.groupId = GroupID.decode(reader, reader.uint32()); + break; + case 2: + message.state = (reader.int32() as any); + break; + case 3: + message.groupSpec = GroupSpec.decode(reader, reader.uint32()); + break; + case 4: + message.createdAt = reader.int64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Group { + const obj = createBaseGroup(); + if (isSet(object.groupId)) obj.groupId = GroupID.fromJSON(object.groupId); + if (isSet(object.state)) obj.state = group_StateFromJSON(object.state); + if (isSet(object.groupSpec)) obj.groupSpec = GroupSpec.fromJSON(object.groupSpec); + if (isSet(object.createdAt)) obj.createdAt = BigInt(object.createdAt.toString()); + return obj; + }, + toJSON(message: Group): JsonSafe { + const obj: any = {}; + message.groupId !== undefined && (obj.groupId = message.groupId ? GroupID.toJSON(message.groupId) : undefined); + message.state !== undefined && (obj.state = group_StateToJSON(message.state)); + message.groupSpec !== undefined && (obj.groupSpec = message.groupSpec ? GroupSpec.toJSON(message.groupSpec) : undefined); + message.createdAt !== undefined && (obj.createdAt = (message.createdAt || BigInt(0)).toString()); + return obj; + }, + fromPartial, I>>(object: I): Group { + const message = createBaseGroup(); + if (object.groupId !== undefined && object.groupId !== null) { + message.groupId = GroupID.fromPartial(object.groupId); + } + message.state = object.state ?? 0; + if (object.groupSpec !== undefined && object.groupSpec !== null) { + message.groupSpec = GroupSpec.fromPartial(object.groupSpec); + } + if (object.createdAt !== undefined && object.createdAt !== null) { + message.createdAt = BigInt(object.createdAt.toString()); + } + return message; + }, + fromSDK(object: GroupSDKType): Group { + return { + groupId: object.group_id ? GroupID.fromSDK(object.group_id) : undefined, + state: isSet(object.state) ? group_StateFromJSON(object.state) : -1, + groupSpec: object.group_spec ? GroupSpec.fromSDK(object.group_spec) : undefined, + createdAt: object?.created_at + }; + }, + fromSDKJSON(object: any): GroupSDKType { + return { + group_id: isSet(object.group_id) ? GroupID.fromSDKJSON(object.group_id) : undefined, + state: isSet(object.state) ? group_StateFromJSON(object.state) : -1, + group_spec: isSet(object.group_spec) ? GroupSpec.fromSDKJSON(object.group_spec) : undefined, + created_at: isSet(object.created_at) ? BigInt(object.created_at.toString()) : BigInt(0) + }; + }, + toSDK(message: Group): GroupSDKType { + const obj: any = {}; + message.groupId !== undefined && (obj.group_id = message.groupId ? GroupID.toSDK(message.groupId) : undefined); + message.state !== undefined && (obj.state = group_StateToJSON(message.state)); + message.groupSpec !== undefined && (obj.group_spec = message.groupSpec ? GroupSpec.toSDK(message.groupSpec) : undefined); + obj.created_at = message.createdAt; + return obj; + }, + fromAmino(object: GroupAmino): Group { + const message = createBaseGroup(); + if (object.group_id !== undefined && object.group_id !== null) { + message.groupId = GroupID.fromAmino(object.group_id); + } + if (object.state !== undefined && object.state !== null) { + message.state = object.state; + } + if (object.group_spec !== undefined && object.group_spec !== null) { + message.groupSpec = GroupSpec.fromAmino(object.group_spec); + } + if (object.created_at !== undefined && object.created_at !== null) { + message.createdAt = BigInt(object.created_at); + } + return message; + }, + toAmino(message: Group): GroupAmino { + const obj: any = {}; + obj.group_id = message.groupId ? GroupID.toAmino(message.groupId) : GroupID.toAmino(GroupID.fromPartial({})); + obj.state = message.state ?? 0; + obj.group_spec = message.groupSpec ? GroupSpec.toAmino(message.groupSpec) : GroupSpec.toAmino(GroupSpec.fromPartial({})); + obj.created_at = message.createdAt !== BigInt(0) ? message.createdAt?.toString() : undefined; + return obj; + }, + fromAminoMsg(object: GroupAminoMsg): Group { + return Group.fromAmino(object.value); + }, + toAminoMsg(message: Group): GroupAminoMsg { + return { + type: "akash/deployment/group", + value: Group.toAmino(message) + }; + }, + fromProtoMsg(message: GroupProtoMsg): Group { + return Group.decode(message.value); + }, + toProto(message: Group): Uint8Array { + return Group.encode(message).finish(); + }, + toProtoMsg(message: Group): GroupProtoMsg { + return { + typeUrl: "/akash.deployment.v1beta1.Group", + value: Group.encode(message).finish() + }; + } +}; +function createBaseResource(): Resource { + return { + resources: ResourceUnits.fromPartial({}), + count: 0, + price: Coin.fromPartial({}) + }; +} +export const Resource = { + typeUrl: "/akash.deployment.v1beta1.Resource", + encode(message: Resource, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.resources !== undefined) { + ResourceUnits.encode(message.resources, writer.uint32(10).fork()).ldelim(); + } + if (message.count !== undefined) { + writer.uint32(16).uint32(message.count); + } + if (message.price !== undefined) { + Coin.encode(message.price, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Resource { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseResource(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.resources = ResourceUnits.decode(reader, reader.uint32()); + break; + case 2: + message.count = reader.uint32(); + break; + case 3: + message.price = Coin.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Resource { + const obj = createBaseResource(); + if (isSet(object.resources)) obj.resources = ResourceUnits.fromJSON(object.resources); + if (isSet(object.count)) obj.count = Number(object.count); + if (isSet(object.price)) obj.price = Coin.fromJSON(object.price); + return obj; + }, + toJSON(message: Resource): JsonSafe { + const obj: any = {}; + message.resources !== undefined && (obj.resources = message.resources ? ResourceUnits.toJSON(message.resources) : undefined); + message.count !== undefined && (obj.count = Math.round(message.count)); + message.price !== undefined && (obj.price = message.price ? Coin.toJSON(message.price) : undefined); + return obj; + }, + fromPartial, I>>(object: I): Resource { + const message = createBaseResource(); + if (object.resources !== undefined && object.resources !== null) { + message.resources = ResourceUnits.fromPartial(object.resources); + } + message.count = object.count ?? 0; + if (object.price !== undefined && object.price !== null) { + message.price = Coin.fromPartial(object.price); + } + return message; + }, + fromSDK(object: ResourceSDKType): Resource { + return { + resources: object.resources ? ResourceUnits.fromSDK(object.resources) : undefined, + count: object?.count, + price: object.price ? Coin.fromSDK(object.price) : undefined + }; + }, + fromSDKJSON(object: any): ResourceSDKType { + return { + resources: isSet(object.resources) ? ResourceUnits.fromSDKJSON(object.resources) : undefined, + count: isSet(object.count) ? Number(object.count) : 0, + price: isSet(object.price) ? Coin.fromSDKJSON(object.price) : undefined + }; + }, + toSDK(message: Resource): ResourceSDKType { + const obj: any = {}; + message.resources !== undefined && (obj.resources = message.resources ? ResourceUnits.toSDK(message.resources) : undefined); + obj.count = message.count; + message.price !== undefined && (obj.price = message.price ? Coin.toSDK(message.price) : undefined); + return obj; + }, + fromAmino(object: ResourceAmino): Resource { + const message = createBaseResource(); + if (object.resources !== undefined && object.resources !== null) { + message.resources = ResourceUnits.fromAmino(object.resources); + } + if (object.count !== undefined && object.count !== null) { + message.count = object.count; + } + if (object.price !== undefined && object.price !== null) { + message.price = Coin.fromAmino(object.price); + } + return message; + }, + toAmino(message: Resource): ResourceAmino { + const obj: any = {}; + obj.resources = message.resources ? ResourceUnits.toAmino(message.resources) : ResourceUnits.toAmino(ResourceUnits.fromPartial({})); + obj.count = message.count ?? 0; + obj.price = message.price ? Coin.toAmino(message.price) : Coin.toAmino(Coin.fromPartial({})); + return obj; + }, + fromAminoMsg(object: ResourceAminoMsg): Resource { + return Resource.fromAmino(object.value); + }, + toAminoMsg(message: Resource): ResourceAminoMsg { + return { + type: "akash/deployment/resource", + value: Resource.toAmino(message) + }; + }, + fromProtoMsg(message: ResourceProtoMsg): Resource { + return Resource.decode(message.value); + }, + toProto(message: Resource): Uint8Array { + return Resource.encode(message).finish(); + }, + toProtoMsg(message: Resource): ResourceProtoMsg { + return { + typeUrl: "/akash.deployment.v1beta1.Resource", + value: Resource.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta1/params.ts b/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta1/params.ts new file mode 100644 index 0000000000..e50fba78db --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta1/params.ts @@ -0,0 +1,113 @@ +import { Coin, CoinSDKType } from "../../../cosmos/base/v1beta1/coin.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, Exact } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "akash.deployment.v1beta1"; +/** Params defines the parameters for the x/deployment package */ +export interface Params { + deploymentMinDeposit: Coin | undefined; +} +export interface ParamsProtoMsg { + typeUrl: "/akash.deployment.v1beta1.Params"; + value: Uint8Array; +} +/** Params defines the parameters for the x/deployment package */ +export interface ParamsSDKType { + deployment_min_deposit: CoinSDKType | undefined; +} +function createBaseParams(): Params { + return { + deploymentMinDeposit: Coin.fromPartial({}) + }; +} +export const Params = { + typeUrl: "/akash.deployment.v1beta1.Params", + encode(message: Params, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.deploymentMinDeposit !== undefined) { + Coin.encode(message.deploymentMinDeposit, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Params { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseParams(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.deploymentMinDeposit = Coin.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Params { + const obj = createBaseParams(); + if (isSet(object.deploymentMinDeposit)) obj.deploymentMinDeposit = Coin.fromJSON(object.deploymentMinDeposit); + return obj; + }, + toJSON(message: Params): JsonSafe { + const obj: any = {}; + message.deploymentMinDeposit !== undefined && (obj.deploymentMinDeposit = message.deploymentMinDeposit ? Coin.toJSON(message.deploymentMinDeposit) : undefined); + return obj; + }, + fromPartial, I>>(object: I): Params { + const message = createBaseParams(); + if (object.deploymentMinDeposit !== undefined && object.deploymentMinDeposit !== null) { + message.deploymentMinDeposit = Coin.fromPartial(object.deploymentMinDeposit); + } + return message; + }, + fromSDK(object: ParamsSDKType): Params { + return { + deploymentMinDeposit: object.deployment_min_deposit ? Coin.fromSDK(object.deployment_min_deposit) : undefined + }; + }, + fromSDKJSON(object: any): ParamsSDKType { + return { + deployment_min_deposit: isSet(object.deployment_min_deposit) ? Coin.fromSDKJSON(object.deployment_min_deposit) : undefined + }; + }, + toSDK(message: Params): ParamsSDKType { + const obj: any = {}; + message.deploymentMinDeposit !== undefined && (obj.deployment_min_deposit = message.deploymentMinDeposit ? Coin.toSDK(message.deploymentMinDeposit) : undefined); + return obj; + }, + fromAmino(object: ParamsAmino): Params { + const message = createBaseParams(); + if (object.deployment_min_deposit !== undefined && object.deployment_min_deposit !== null) { + message.deploymentMinDeposit = Coin.fromAmino(object.deployment_min_deposit); + } + return message; + }, + toAmino(message: Params): ParamsAmino { + const obj: any = {}; + obj.deployment_min_deposit = message.deploymentMinDeposit ? Coin.toAmino(message.deploymentMinDeposit) : Coin.toAmino(Coin.fromPartial({})); + return obj; + }, + fromAminoMsg(object: ParamsAminoMsg): Params { + return Params.fromAmino(object.value); + }, + toAminoMsg(message: Params): ParamsAminoMsg { + return { + type: "akash/deployment/params", + value: Params.toAmino(message) + }; + }, + fromProtoMsg(message: ParamsProtoMsg): Params { + return Params.decode(message.value); + }, + toProto(message: Params): Uint8Array { + return Params.encode(message).finish(); + }, + toProtoMsg(message: Params): ParamsProtoMsg { + return { + typeUrl: "/akash.deployment.v1beta1.Params", + value: Params.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta1/query.lcd.ts b/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta1/query.lcd.ts new file mode 100644 index 0000000000..6858681d6f --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta1/query.lcd.ts @@ -0,0 +1,53 @@ +import { DeploymentFilters, DeploymentFiltersSDKType, DeploymentID, DeploymentIDSDKType, Deployment, DeploymentSDKType } from "./deployment.js"; +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../../cosmos/base/query/v1beta1/pagination.js"; +import { GroupID, GroupIDSDKType, Group, GroupSDKType } from "./group.js"; +import { Account, AccountSDKType } from "../../escrow/v1beta1/types.js"; +import { setPaginationParams } from "../../../helpers.js"; +import { LCDClient } from "@cosmology/lcd"; +import { QueryDeploymentsRequest, QueryDeploymentsRequestSDKType, QueryDeploymentsResponse, QueryDeploymentsResponseSDKType, QueryDeploymentRequest, QueryDeploymentRequestSDKType, QueryDeploymentResponse, QueryDeploymentResponseSDKType, QueryGroupRequest, QueryGroupRequestSDKType, QueryGroupResponse, QueryGroupResponseSDKType } from "./query.js"; +export class LCDQueryClient { + req: LCDClient; + constructor({ + requestClient + }: { + requestClient: LCDClient; + }) { + this.req = requestClient; + } + /* Deployments queries deployments */ + deployments = async (params: QueryDeploymentsRequest): Promise => { + const options: any = { + params: {} + }; + if (typeof params?.filters !== "undefined") { + options.params.filters = params.filters; + } + if (typeof params?.pagination !== "undefined") { + setPaginationParams(options, params.pagination); + } + const endpoint = `akash/deployment/v1beta1/deployments/list`; + return QueryDeploymentsResponse.fromSDKJSON(await this.req.get(endpoint, options)); + }; + /* Deployment queries deployment details */ + deployment = async (params: QueryDeploymentRequest): Promise => { + const options: any = { + params: {} + }; + if (typeof params?.id !== "undefined") { + options.params.id = params.id; + } + const endpoint = `akash/deployment/v1beta1/deployments/info`; + return QueryDeploymentResponse.fromSDKJSON(await this.req.get(endpoint, options)); + }; + /* Group queries group details */ + group = async (params: QueryGroupRequest): Promise => { + const options: any = { + params: {} + }; + if (typeof params?.id !== "undefined") { + options.params.id = params.id; + } + const endpoint = `akash/deployment/v1beta1/groups/info`; + return QueryGroupResponse.fromSDKJSON(await this.req.get(endpoint, options)); + }; +} \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta1/query.rpc.func.ts b/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta1/query.rpc.func.ts new file mode 100644 index 0000000000..12106daa30 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta1/query.rpc.func.ts @@ -0,0 +1,36 @@ +import { RpcResolver, buildQuery } from "../../../helper-func-types"; +import { buildUseQuery } from "../../../react-query"; +import { QueryDeploymentsRequest, QueryDeploymentsResponse, QueryDeploymentRequest, QueryDeploymentResponse, QueryGroupRequest, QueryGroupResponse } from "./query"; +export const createGetDeployments = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryDeploymentsRequest.encode, + decode: QueryDeploymentsResponse.decode, + service: "akash.deployment.v1beta1.Query", + method: "Deployments", + getRpcInstance: getRpcInstance +}); +export const useGetDeployments = buildUseQuery({ + builderQueryFn: createGetDeployments, + queryKeyPrefix: "DeploymentsQuery" +}); +export const createGetDeployment = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryDeploymentRequest.encode, + decode: QueryDeploymentResponse.decode, + service: "akash.deployment.v1beta1.Query", + method: "Deployment", + getRpcInstance: getRpcInstance +}); +export const useGetDeployment = buildUseQuery({ + builderQueryFn: createGetDeployment, + queryKeyPrefix: "DeploymentQuery" +}); +export const createGetGroup = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryGroupRequest.encode, + decode: QueryGroupResponse.decode, + service: "akash.deployment.v1beta1.Query", + method: "Group", + getRpcInstance: getRpcInstance +}); +export const useGetGroup = buildUseQuery({ + builderQueryFn: createGetGroup, + queryKeyPrefix: "GroupQuery" +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta1/query.ts b/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta1/query.ts new file mode 100644 index 0000000000..c14cc3a793 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta1/query.ts @@ -0,0 +1,805 @@ +import { DeploymentFilters, DeploymentFiltersSDKType, DeploymentID, DeploymentIDSDKType, Deployment, DeploymentSDKType } from "./deployment.js"; +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../../cosmos/base/query/v1beta1/pagination.js"; +import { GroupID, GroupIDSDKType, Group, GroupSDKType } from "./group.js"; +import { Account, AccountSDKType } from "../../escrow/v1beta1/types.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, Exact, Rpc } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +import { QueryClient, createProtobufRpcClient } from "@cosmjs/stargate"; +export const protobufPackage = "akash.deployment.v1beta1"; +/** QueryDeploymentsRequest is request type for the Query/Deployments RPC method */ +export interface QueryDeploymentsRequest { + filters: DeploymentFilters | undefined; + pagination?: PageRequest | undefined; +} +export interface QueryDeploymentsRequestProtoMsg { + typeUrl: "/akash.deployment.v1beta1.QueryDeploymentsRequest"; + value: Uint8Array; +} +/** QueryDeploymentsRequest is request type for the Query/Deployments RPC method */ +export interface QueryDeploymentsRequestSDKType { + filters: DeploymentFiltersSDKType | undefined; + pagination?: PageRequestSDKType | undefined; +} +/** QueryDeploymentsResponse is response type for the Query/Deployments RPC method */ +export interface QueryDeploymentsResponse { + deployments: QueryDeploymentResponse[]; + pagination?: PageResponse | undefined; +} +export interface QueryDeploymentsResponseProtoMsg { + typeUrl: "/akash.deployment.v1beta1.QueryDeploymentsResponse"; + value: Uint8Array; +} +/** QueryDeploymentsResponse is response type for the Query/Deployments RPC method */ +export interface QueryDeploymentsResponseSDKType { + deployments: QueryDeploymentResponseSDKType[]; + pagination?: PageResponseSDKType | undefined; +} +/** QueryDeploymentRequest is request type for the Query/Deployment RPC method */ +export interface QueryDeploymentRequest { + id: DeploymentID | undefined; +} +export interface QueryDeploymentRequestProtoMsg { + typeUrl: "/akash.deployment.v1beta1.QueryDeploymentRequest"; + value: Uint8Array; +} +/** QueryDeploymentRequest is request type for the Query/Deployment RPC method */ +export interface QueryDeploymentRequestSDKType { + id: DeploymentIDSDKType | undefined; +} +/** QueryDeploymentResponse is response type for the Query/Deployment RPC method */ +export interface QueryDeploymentResponse { + deployment: Deployment | undefined; + groups: Group[]; + escrowAccount: Account | undefined; +} +export interface QueryDeploymentResponseProtoMsg { + typeUrl: "/akash.deployment.v1beta1.QueryDeploymentResponse"; + value: Uint8Array; +} +/** QueryDeploymentResponse is response type for the Query/Deployment RPC method */ +export interface QueryDeploymentResponseSDKType { + deployment: DeploymentSDKType | undefined; + groups: GroupSDKType[]; + escrow_account: AccountSDKType | undefined; +} +/** QueryGroupRequest is request type for the Query/Group RPC method */ +export interface QueryGroupRequest { + id: GroupID | undefined; +} +export interface QueryGroupRequestProtoMsg { + typeUrl: "/akash.deployment.v1beta1.QueryGroupRequest"; + value: Uint8Array; +} +/** QueryGroupRequest is request type for the Query/Group RPC method */ +export interface QueryGroupRequestSDKType { + id: GroupIDSDKType | undefined; +} +/** QueryGroupResponse is response type for the Query/Group RPC method */ +export interface QueryGroupResponse { + group: Group | undefined; +} +export interface QueryGroupResponseProtoMsg { + typeUrl: "/akash.deployment.v1beta1.QueryGroupResponse"; + value: Uint8Array; +} +/** QueryGroupResponse is response type for the Query/Group RPC method */ +export interface QueryGroupResponseSDKType { + group: GroupSDKType | undefined; +} +function createBaseQueryDeploymentsRequest(): QueryDeploymentsRequest { + return { + filters: DeploymentFilters.fromPartial({}), + pagination: undefined + }; +} +export const QueryDeploymentsRequest = { + typeUrl: "/akash.deployment.v1beta1.QueryDeploymentsRequest", + encode(message: QueryDeploymentsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.filters !== undefined) { + DeploymentFilters.encode(message.filters, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryDeploymentsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryDeploymentsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.filters = DeploymentFilters.decode(reader, reader.uint32()); + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryDeploymentsRequest { + const obj = createBaseQueryDeploymentsRequest(); + if (isSet(object.filters)) obj.filters = DeploymentFilters.fromJSON(object.filters); + if (isSet(object.pagination)) obj.pagination = PageRequest.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryDeploymentsRequest): JsonSafe { + const obj: any = {}; + message.filters !== undefined && (obj.filters = message.filters ? DeploymentFilters.toJSON(message.filters) : undefined); + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryDeploymentsRequest { + const message = createBaseQueryDeploymentsRequest(); + if (object.filters !== undefined && object.filters !== null) { + message.filters = DeploymentFilters.fromPartial(object.filters); + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryDeploymentsRequestSDKType): QueryDeploymentsRequest { + return { + filters: object.filters ? DeploymentFilters.fromSDK(object.filters) : undefined, + pagination: object.pagination ? PageRequest.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryDeploymentsRequestSDKType { + return { + filters: isSet(object.filters) ? DeploymentFilters.fromSDKJSON(object.filters) : undefined, + pagination: isSet(object.pagination) ? PageRequest.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryDeploymentsRequest): QueryDeploymentsRequestSDKType { + const obj: any = {}; + message.filters !== undefined && (obj.filters = message.filters ? DeploymentFilters.toSDK(message.filters) : undefined); + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryDeploymentsRequestAmino): QueryDeploymentsRequest { + const message = createBaseQueryDeploymentsRequest(); + if (object.filters !== undefined && object.filters !== null) { + message.filters = DeploymentFilters.fromAmino(object.filters); + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryDeploymentsRequest): QueryDeploymentsRequestAmino { + const obj: any = {}; + obj.filters = message.filters ? DeploymentFilters.toAmino(message.filters) : undefined; + obj.pagination = message.pagination ? PageRequest.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryDeploymentsRequestAminoMsg): QueryDeploymentsRequest { + return QueryDeploymentsRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryDeploymentsRequest): QueryDeploymentsRequestAminoMsg { + return { + type: "akash/deployment/query-deployments-request", + value: QueryDeploymentsRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryDeploymentsRequestProtoMsg): QueryDeploymentsRequest { + return QueryDeploymentsRequest.decode(message.value); + }, + toProto(message: QueryDeploymentsRequest): Uint8Array { + return QueryDeploymentsRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryDeploymentsRequest): QueryDeploymentsRequestProtoMsg { + return { + typeUrl: "/akash.deployment.v1beta1.QueryDeploymentsRequest", + value: QueryDeploymentsRequest.encode(message).finish() + }; + } +}; +function createBaseQueryDeploymentsResponse(): QueryDeploymentsResponse { + return { + deployments: [], + pagination: undefined + }; +} +export const QueryDeploymentsResponse = { + typeUrl: "/akash.deployment.v1beta1.QueryDeploymentsResponse", + encode(message: QueryDeploymentsResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.deployments) { + QueryDeploymentResponse.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryDeploymentsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryDeploymentsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.deployments.push(QueryDeploymentResponse.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryDeploymentsResponse { + const obj = createBaseQueryDeploymentsResponse(); + if (Array.isArray(object?.deployments)) obj.deployments = object.deployments.map((e: any) => QueryDeploymentResponse.fromJSON(e)); + if (isSet(object.pagination)) obj.pagination = PageResponse.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryDeploymentsResponse): JsonSafe { + const obj: any = {}; + if (message.deployments) { + obj.deployments = message.deployments.map(e => e ? QueryDeploymentResponse.toJSON(e) : undefined); + } else { + obj.deployments = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryDeploymentsResponse { + const message = createBaseQueryDeploymentsResponse(); + message.deployments = object.deployments?.map(e => QueryDeploymentResponse.fromPartial(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryDeploymentsResponseSDKType): QueryDeploymentsResponse { + return { + deployments: Array.isArray(object?.deployments) ? object.deployments.map((e: any) => QueryDeploymentResponse.fromSDK(e)) : [], + pagination: object.pagination ? PageResponse.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryDeploymentsResponseSDKType { + return { + deployments: Array.isArray(object?.deployments) ? object.deployments.map((e: any) => QueryDeploymentResponse.fromSDKJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryDeploymentsResponse): QueryDeploymentsResponseSDKType { + const obj: any = {}; + if (message.deployments) { + obj.deployments = message.deployments.map(e => e ? QueryDeploymentResponse.toSDK(e) : undefined); + } else { + obj.deployments = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryDeploymentsResponseAmino): QueryDeploymentsResponse { + const message = createBaseQueryDeploymentsResponse(); + message.deployments = object.deployments?.map(e => QueryDeploymentResponse.fromAmino(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryDeploymentsResponse): QueryDeploymentsResponseAmino { + const obj: any = {}; + if (message.deployments) { + obj.deployments = message.deployments.map(e => e ? QueryDeploymentResponse.toAmino(e) : undefined); + } else { + obj.deployments = message.deployments; + } + obj.pagination = message.pagination ? PageResponse.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryDeploymentsResponseAminoMsg): QueryDeploymentsResponse { + return QueryDeploymentsResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryDeploymentsResponse): QueryDeploymentsResponseAminoMsg { + return { + type: "akash/deployment/query-deployments-response", + value: QueryDeploymentsResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryDeploymentsResponseProtoMsg): QueryDeploymentsResponse { + return QueryDeploymentsResponse.decode(message.value); + }, + toProto(message: QueryDeploymentsResponse): Uint8Array { + return QueryDeploymentsResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryDeploymentsResponse): QueryDeploymentsResponseProtoMsg { + return { + typeUrl: "/akash.deployment.v1beta1.QueryDeploymentsResponse", + value: QueryDeploymentsResponse.encode(message).finish() + }; + } +}; +function createBaseQueryDeploymentRequest(): QueryDeploymentRequest { + return { + id: DeploymentID.fromPartial({}) + }; +} +export const QueryDeploymentRequest = { + typeUrl: "/akash.deployment.v1beta1.QueryDeploymentRequest", + encode(message: QueryDeploymentRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.id !== undefined) { + DeploymentID.encode(message.id, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryDeploymentRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryDeploymentRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.id = DeploymentID.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryDeploymentRequest { + const obj = createBaseQueryDeploymentRequest(); + if (isSet(object.id)) obj.id = DeploymentID.fromJSON(object.id); + return obj; + }, + toJSON(message: QueryDeploymentRequest): JsonSafe { + const obj: any = {}; + message.id !== undefined && (obj.id = message.id ? DeploymentID.toJSON(message.id) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryDeploymentRequest { + const message = createBaseQueryDeploymentRequest(); + if (object.id !== undefined && object.id !== null) { + message.id = DeploymentID.fromPartial(object.id); + } + return message; + }, + fromSDK(object: QueryDeploymentRequestSDKType): QueryDeploymentRequest { + return { + id: object.id ? DeploymentID.fromSDK(object.id) : undefined + }; + }, + fromSDKJSON(object: any): QueryDeploymentRequestSDKType { + return { + id: isSet(object.id) ? DeploymentID.fromSDKJSON(object.id) : undefined + }; + }, + toSDK(message: QueryDeploymentRequest): QueryDeploymentRequestSDKType { + const obj: any = {}; + message.id !== undefined && (obj.id = message.id ? DeploymentID.toSDK(message.id) : undefined); + return obj; + }, + fromAmino(object: QueryDeploymentRequestAmino): QueryDeploymentRequest { + const message = createBaseQueryDeploymentRequest(); + if (object.id !== undefined && object.id !== null) { + message.id = DeploymentID.fromAmino(object.id); + } + return message; + }, + toAmino(message: QueryDeploymentRequest): QueryDeploymentRequestAmino { + const obj: any = {}; + obj.id = message.id ? DeploymentID.toAmino(message.id) : undefined; + return obj; + }, + fromAminoMsg(object: QueryDeploymentRequestAminoMsg): QueryDeploymentRequest { + return QueryDeploymentRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryDeploymentRequest): QueryDeploymentRequestAminoMsg { + return { + type: "akash/deployment/query-deployment-request", + value: QueryDeploymentRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryDeploymentRequestProtoMsg): QueryDeploymentRequest { + return QueryDeploymentRequest.decode(message.value); + }, + toProto(message: QueryDeploymentRequest): Uint8Array { + return QueryDeploymentRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryDeploymentRequest): QueryDeploymentRequestProtoMsg { + return { + typeUrl: "/akash.deployment.v1beta1.QueryDeploymentRequest", + value: QueryDeploymentRequest.encode(message).finish() + }; + } +}; +function createBaseQueryDeploymentResponse(): QueryDeploymentResponse { + return { + deployment: Deployment.fromPartial({}), + groups: [], + escrowAccount: Account.fromPartial({}) + }; +} +export const QueryDeploymentResponse = { + typeUrl: "/akash.deployment.v1beta1.QueryDeploymentResponse", + encode(message: QueryDeploymentResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.deployment !== undefined) { + Deployment.encode(message.deployment, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.groups) { + Group.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.escrowAccount !== undefined) { + Account.encode(message.escrowAccount, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryDeploymentResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryDeploymentResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.deployment = Deployment.decode(reader, reader.uint32()); + break; + case 2: + message.groups.push(Group.decode(reader, reader.uint32())); + break; + case 3: + message.escrowAccount = Account.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryDeploymentResponse { + const obj = createBaseQueryDeploymentResponse(); + if (isSet(object.deployment)) obj.deployment = Deployment.fromJSON(object.deployment); + if (Array.isArray(object?.groups)) obj.groups = object.groups.map((e: any) => Group.fromJSON(e)); + if (isSet(object.escrowAccount)) obj.escrowAccount = Account.fromJSON(object.escrowAccount); + return obj; + }, + toJSON(message: QueryDeploymentResponse): JsonSafe { + const obj: any = {}; + message.deployment !== undefined && (obj.deployment = message.deployment ? Deployment.toJSON(message.deployment) : undefined); + if (message.groups) { + obj.groups = message.groups.map(e => e ? Group.toJSON(e) : undefined); + } else { + obj.groups = []; + } + message.escrowAccount !== undefined && (obj.escrowAccount = message.escrowAccount ? Account.toJSON(message.escrowAccount) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryDeploymentResponse { + const message = createBaseQueryDeploymentResponse(); + if (object.deployment !== undefined && object.deployment !== null) { + message.deployment = Deployment.fromPartial(object.deployment); + } + message.groups = object.groups?.map(e => Group.fromPartial(e)) || []; + if (object.escrowAccount !== undefined && object.escrowAccount !== null) { + message.escrowAccount = Account.fromPartial(object.escrowAccount); + } + return message; + }, + fromSDK(object: QueryDeploymentResponseSDKType): QueryDeploymentResponse { + return { + deployment: object.deployment ? Deployment.fromSDK(object.deployment) : undefined, + groups: Array.isArray(object?.groups) ? object.groups.map((e: any) => Group.fromSDK(e)) : [], + escrowAccount: object.escrow_account ? Account.fromSDK(object.escrow_account) : undefined + }; + }, + fromSDKJSON(object: any): QueryDeploymentResponseSDKType { + return { + deployment: isSet(object.deployment) ? Deployment.fromSDKJSON(object.deployment) : undefined, + groups: Array.isArray(object?.groups) ? object.groups.map((e: any) => Group.fromSDKJSON(e)) : [], + escrow_account: isSet(object.escrow_account) ? Account.fromSDKJSON(object.escrow_account) : undefined + }; + }, + toSDK(message: QueryDeploymentResponse): QueryDeploymentResponseSDKType { + const obj: any = {}; + message.deployment !== undefined && (obj.deployment = message.deployment ? Deployment.toSDK(message.deployment) : undefined); + if (message.groups) { + obj.groups = message.groups.map(e => e ? Group.toSDK(e) : undefined); + } else { + obj.groups = []; + } + message.escrowAccount !== undefined && (obj.escrow_account = message.escrowAccount ? Account.toSDK(message.escrowAccount) : undefined); + return obj; + }, + fromAmino(object: QueryDeploymentResponseAmino): QueryDeploymentResponse { + const message = createBaseQueryDeploymentResponse(); + if (object.deployment !== undefined && object.deployment !== null) { + message.deployment = Deployment.fromAmino(object.deployment); + } + message.groups = object.groups?.map(e => Group.fromAmino(e)) || []; + if (object.escrow_account !== undefined && object.escrow_account !== null) { + message.escrowAccount = Account.fromAmino(object.escrow_account); + } + return message; + }, + toAmino(message: QueryDeploymentResponse): QueryDeploymentResponseAmino { + const obj: any = {}; + obj.deployment = message.deployment ? Deployment.toAmino(message.deployment) : Deployment.toAmino(Deployment.fromPartial({})); + if (message.groups) { + obj.groups = message.groups.map(e => e ? Group.toAmino(e) : undefined); + } else { + obj.groups = message.groups; + } + obj.escrow_account = message.escrowAccount ? Account.toAmino(message.escrowAccount) : undefined; + return obj; + }, + fromAminoMsg(object: QueryDeploymentResponseAminoMsg): QueryDeploymentResponse { + return QueryDeploymentResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryDeploymentResponse): QueryDeploymentResponseAminoMsg { + return { + type: "akash/deployment/query-deployment-response", + value: QueryDeploymentResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryDeploymentResponseProtoMsg): QueryDeploymentResponse { + return QueryDeploymentResponse.decode(message.value); + }, + toProto(message: QueryDeploymentResponse): Uint8Array { + return QueryDeploymentResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryDeploymentResponse): QueryDeploymentResponseProtoMsg { + return { + typeUrl: "/akash.deployment.v1beta1.QueryDeploymentResponse", + value: QueryDeploymentResponse.encode(message).finish() + }; + } +}; +function createBaseQueryGroupRequest(): QueryGroupRequest { + return { + id: GroupID.fromPartial({}) + }; +} +export const QueryGroupRequest = { + typeUrl: "/akash.deployment.v1beta1.QueryGroupRequest", + encode(message: QueryGroupRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.id !== undefined) { + GroupID.encode(message.id, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryGroupRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryGroupRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.id = GroupID.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryGroupRequest { + const obj = createBaseQueryGroupRequest(); + if (isSet(object.id)) obj.id = GroupID.fromJSON(object.id); + return obj; + }, + toJSON(message: QueryGroupRequest): JsonSafe { + const obj: any = {}; + message.id !== undefined && (obj.id = message.id ? GroupID.toJSON(message.id) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryGroupRequest { + const message = createBaseQueryGroupRequest(); + if (object.id !== undefined && object.id !== null) { + message.id = GroupID.fromPartial(object.id); + } + return message; + }, + fromSDK(object: QueryGroupRequestSDKType): QueryGroupRequest { + return { + id: object.id ? GroupID.fromSDK(object.id) : undefined + }; + }, + fromSDKJSON(object: any): QueryGroupRequestSDKType { + return { + id: isSet(object.id) ? GroupID.fromSDKJSON(object.id) : undefined + }; + }, + toSDK(message: QueryGroupRequest): QueryGroupRequestSDKType { + const obj: any = {}; + message.id !== undefined && (obj.id = message.id ? GroupID.toSDK(message.id) : undefined); + return obj; + }, + fromAmino(object: QueryGroupRequestAmino): QueryGroupRequest { + const message = createBaseQueryGroupRequest(); + if (object.id !== undefined && object.id !== null) { + message.id = GroupID.fromAmino(object.id); + } + return message; + }, + toAmino(message: QueryGroupRequest): QueryGroupRequestAmino { + const obj: any = {}; + obj.id = message.id ? GroupID.toAmino(message.id) : undefined; + return obj; + }, + fromAminoMsg(object: QueryGroupRequestAminoMsg): QueryGroupRequest { + return QueryGroupRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryGroupRequest): QueryGroupRequestAminoMsg { + return { + type: "akash/deployment/query-group-request", + value: QueryGroupRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryGroupRequestProtoMsg): QueryGroupRequest { + return QueryGroupRequest.decode(message.value); + }, + toProto(message: QueryGroupRequest): Uint8Array { + return QueryGroupRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryGroupRequest): QueryGroupRequestProtoMsg { + return { + typeUrl: "/akash.deployment.v1beta1.QueryGroupRequest", + value: QueryGroupRequest.encode(message).finish() + }; + } +}; +function createBaseQueryGroupResponse(): QueryGroupResponse { + return { + group: Group.fromPartial({}) + }; +} +export const QueryGroupResponse = { + typeUrl: "/akash.deployment.v1beta1.QueryGroupResponse", + encode(message: QueryGroupResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.group !== undefined) { + Group.encode(message.group, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryGroupResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryGroupResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.group = Group.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryGroupResponse { + const obj = createBaseQueryGroupResponse(); + if (isSet(object.group)) obj.group = Group.fromJSON(object.group); + return obj; + }, + toJSON(message: QueryGroupResponse): JsonSafe { + const obj: any = {}; + message.group !== undefined && (obj.group = message.group ? Group.toJSON(message.group) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryGroupResponse { + const message = createBaseQueryGroupResponse(); + if (object.group !== undefined && object.group !== null) { + message.group = Group.fromPartial(object.group); + } + return message; + }, + fromSDK(object: QueryGroupResponseSDKType): QueryGroupResponse { + return { + group: object.group ? Group.fromSDK(object.group) : undefined + }; + }, + fromSDKJSON(object: any): QueryGroupResponseSDKType { + return { + group: isSet(object.group) ? Group.fromSDKJSON(object.group) : undefined + }; + }, + toSDK(message: QueryGroupResponse): QueryGroupResponseSDKType { + const obj: any = {}; + message.group !== undefined && (obj.group = message.group ? Group.toSDK(message.group) : undefined); + return obj; + }, + fromAmino(object: QueryGroupResponseAmino): QueryGroupResponse { + const message = createBaseQueryGroupResponse(); + if (object.group !== undefined && object.group !== null) { + message.group = Group.fromAmino(object.group); + } + return message; + }, + toAmino(message: QueryGroupResponse): QueryGroupResponseAmino { + const obj: any = {}; + obj.group = message.group ? Group.toAmino(message.group) : undefined; + return obj; + }, + fromAminoMsg(object: QueryGroupResponseAminoMsg): QueryGroupResponse { + return QueryGroupResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryGroupResponse): QueryGroupResponseAminoMsg { + return { + type: "akash/deployment/query-group-response", + value: QueryGroupResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryGroupResponseProtoMsg): QueryGroupResponse { + return QueryGroupResponse.decode(message.value); + }, + toProto(message: QueryGroupResponse): Uint8Array { + return QueryGroupResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryGroupResponse): QueryGroupResponseProtoMsg { + return { + typeUrl: "/akash.deployment.v1beta1.QueryGroupResponse", + value: QueryGroupResponse.encode(message).finish() + }; + } +}; +/** Query defines the gRPC querier service */ +export interface Query { + /** Deployments queries deployments */ + deployments(request: QueryDeploymentsRequest): Promise; + /** Deployment queries deployment details */ + deployment(request: QueryDeploymentRequest): Promise; + /** Group queries group details */ + group(request: QueryGroupRequest): Promise; +} +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + } + /* Deployments queries deployments */ + deployments = async (request: QueryDeploymentsRequest): Promise => { + const data = QueryDeploymentsRequest.encode(request).finish(); + const promise = this.rpc.request("akash.deployment.v1beta1.Query", "Deployments", data); + return promise.then(data => QueryDeploymentsResponse.decode(new BinaryReader(data))); + }; + /* Deployment queries deployment details */ + deployment = async (request: QueryDeploymentRequest): Promise => { + const data = QueryDeploymentRequest.encode(request).finish(); + const promise = this.rpc.request("akash.deployment.v1beta1.Query", "Deployment", data); + return promise.then(data => QueryDeploymentResponse.decode(new BinaryReader(data))); + }; + /* Group queries group details */ + group = async (request: QueryGroupRequest): Promise => { + const data = QueryGroupRequest.encode(request).finish(); + const promise = this.rpc.request("akash.deployment.v1beta1.Query", "Group", data); + return promise.then(data => QueryGroupResponse.decode(new BinaryReader(data))); + }; +} +export const createRpcQueryExtension = (base: QueryClient) => { + const rpc = createProtobufRpcClient(base); + const queryService = new QueryClientImpl(rpc); + return { + deployments(request: QueryDeploymentsRequest): Promise { + return queryService.deployments(request); + }, + deployment(request: QueryDeploymentRequest): Promise { + return queryService.deployment(request); + }, + group(request: QueryGroupRequest): Promise { + return queryService.group(request); + } + }; +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta2/authz.ts b/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta2/authz.ts new file mode 100644 index 0000000000..dcdf559d64 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta2/authz.ts @@ -0,0 +1,123 @@ +import { Coin, CoinSDKType } from "../../../cosmos/base/v1beta1/coin.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial, Exact } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "akash.deployment.v1beta2"; +/** + * DepositDeploymentAuthorization allows the grantee to deposit up to spend_limit coins from + * the granter's account for a deployment. + */ +export interface DepositDeploymentAuthorization { + /** + * SpendLimit is the amount the grantee is authorized to spend from the granter's account for + * the purpose of deployment. + */ + spendLimit: Coin; +} +export interface DepositDeploymentAuthorizationProtoMsg { + typeUrl: "/akash.deployment.v1beta2.DepositDeploymentAuthorization"; + value: Uint8Array; +} +/** + * DepositDeploymentAuthorization allows the grantee to deposit up to spend_limit coins from + * the granter's account for a deployment. + */ +export interface DepositDeploymentAuthorizationSDKType { + spend_limit: CoinSDKType; +} +function createBaseDepositDeploymentAuthorization(): DepositDeploymentAuthorization { + return { + spendLimit: Coin.fromPartial({}) + }; +} +export const DepositDeploymentAuthorization = { + typeUrl: "/akash.deployment.v1beta2.DepositDeploymentAuthorization", + encode(message: DepositDeploymentAuthorization, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.spendLimit !== undefined) { + Coin.encode(message.spendLimit, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): DepositDeploymentAuthorization { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDepositDeploymentAuthorization(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.spendLimit = Coin.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): DepositDeploymentAuthorization { + const obj = createBaseDepositDeploymentAuthorization(); + if (isSet(object.spendLimit)) obj.spendLimit = Coin.fromJSON(object.spendLimit); + return obj; + }, + toJSON(message: DepositDeploymentAuthorization): JsonSafe { + const obj: any = {}; + message.spendLimit !== undefined && (obj.spendLimit = message.spendLimit ? Coin.toJSON(message.spendLimit) : undefined); + return obj; + }, + fromPartial, I>>(object: I): DepositDeploymentAuthorization { + const message = createBaseDepositDeploymentAuthorization(); + if (object.spendLimit !== undefined && object.spendLimit !== null) { + message.spendLimit = Coin.fromPartial(object.spendLimit); + } + return message; + }, + fromSDK(object: DepositDeploymentAuthorizationSDKType): DepositDeploymentAuthorization { + return { + spendLimit: object.spend_limit ? Coin.fromSDK(object.spend_limit) : undefined + }; + }, + fromSDKJSON(object: any): DepositDeploymentAuthorizationSDKType { + return { + spend_limit: isSet(object.spend_limit) ? Coin.fromSDKJSON(object.spend_limit) : undefined + }; + }, + toSDK(message: DepositDeploymentAuthorization): DepositDeploymentAuthorizationSDKType { + const obj: any = {}; + message.spendLimit !== undefined && (obj.spend_limit = message.spendLimit ? Coin.toSDK(message.spendLimit) : undefined); + return obj; + }, + fromAmino(object: DepositDeploymentAuthorizationAmino): DepositDeploymentAuthorization { + const message = createBaseDepositDeploymentAuthorization(); + if (object.spend_limit !== undefined && object.spend_limit !== null) { + message.spendLimit = Coin.fromAmino(object.spend_limit); + } + return message; + }, + toAmino(message: DepositDeploymentAuthorization): DepositDeploymentAuthorizationAmino { + const obj: any = {}; + obj.spend_limit = message.spendLimit ? Coin.toAmino(message.spendLimit) : Coin.toAmino(Coin.fromPartial({})); + return obj; + }, + fromAminoMsg(object: DepositDeploymentAuthorizationAminoMsg): DepositDeploymentAuthorization { + return DepositDeploymentAuthorization.fromAmino(object.value); + }, + toAminoMsg(message: DepositDeploymentAuthorization): DepositDeploymentAuthorizationAminoMsg { + return { + type: "akash/deployment/v1beta2/deposit-deployment-authorization", + value: DepositDeploymentAuthorization.toAmino(message) + }; + }, + fromProtoMsg(message: DepositDeploymentAuthorizationProtoMsg): DepositDeploymentAuthorization { + return DepositDeploymentAuthorization.decode(message.value); + }, + toProto(message: DepositDeploymentAuthorization): Uint8Array { + return DepositDeploymentAuthorization.encode(message).finish(); + }, + toProtoMsg(message: DepositDeploymentAuthorization): DepositDeploymentAuthorizationProtoMsg { + return { + typeUrl: "/akash.deployment.v1beta2.DepositDeploymentAuthorization", + value: DepositDeploymentAuthorization.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta2/deployment.ts b/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta2/deployment.ts new file mode 100644 index 0000000000..623a6d0d5d --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta2/deployment.ts @@ -0,0 +1,485 @@ +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial, Exact, bytesFromBase64, base64FromBytes } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "akash.deployment.v1beta2"; +/** State is an enum which refers to state of deployment */ +export enum Deployment_State { + /** invalid - Prefix should start with 0 in enum. So declaring dummy state */ + invalid = 0, + /** active - DeploymentActive denotes state for deployment active */ + active = 1, + /** closed - DeploymentClosed denotes state for deployment closed */ + closed = 2, + UNRECOGNIZED = -1, +} +export const Deployment_StateSDKType = Deployment_State; +export function deployment_StateFromJSON(object: any): Deployment_State { + switch (object) { + case 0: + case "invalid": + return Deployment_State.invalid; + case 1: + case "active": + return Deployment_State.active; + case 2: + case "closed": + return Deployment_State.closed; + case -1: + case "UNRECOGNIZED": + default: + return Deployment_State.UNRECOGNIZED; + } +} +export function deployment_StateToJSON(object: Deployment_State): string { + switch (object) { + case Deployment_State.invalid: + return "invalid"; + case Deployment_State.active: + return "active"; + case Deployment_State.closed: + return "closed"; + case Deployment_State.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** DeploymentID stores owner and sequence number */ +export interface DeploymentID { + owner: string; + dseq: bigint; +} +export interface DeploymentIDProtoMsg { + typeUrl: "/akash.deployment.v1beta2.DeploymentID"; + value: Uint8Array; +} +/** DeploymentID stores owner and sequence number */ +export interface DeploymentIDSDKType { + owner: string; + dseq: bigint; +} +/** Deployment stores deploymentID, state and version details */ +export interface Deployment { + deploymentId: DeploymentID; + state: Deployment_State; + version: Uint8Array; + createdAt: bigint; +} +export interface DeploymentProtoMsg { + typeUrl: "/akash.deployment.v1beta2.Deployment"; + value: Uint8Array; +} +/** Deployment stores deploymentID, state and version details */ +export interface DeploymentSDKType { + deployment_id: DeploymentIDSDKType; + state: Deployment_State; + version: Uint8Array; + created_at: bigint; +} +/** DeploymentFilters defines filters used to filter deployments */ +export interface DeploymentFilters { + owner: string; + dseq: bigint; + state: string; +} +export interface DeploymentFiltersProtoMsg { + typeUrl: "/akash.deployment.v1beta2.DeploymentFilters"; + value: Uint8Array; +} +/** DeploymentFilters defines filters used to filter deployments */ +export interface DeploymentFiltersSDKType { + owner: string; + dseq: bigint; + state: string; +} +function createBaseDeploymentID(): DeploymentID { + return { + owner: "", + dseq: BigInt(0) + }; +} +export const DeploymentID = { + typeUrl: "/akash.deployment.v1beta2.DeploymentID", + encode(message: DeploymentID, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.owner !== undefined) { + writer.uint32(10).string(message.owner); + } + if (message.dseq !== undefined) { + writer.uint32(16).uint64(message.dseq); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): DeploymentID { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDeploymentID(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.owner = reader.string(); + break; + case 2: + message.dseq = reader.uint64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): DeploymentID { + const obj = createBaseDeploymentID(); + if (isSet(object.owner)) obj.owner = String(object.owner); + if (isSet(object.dseq)) obj.dseq = BigInt(object.dseq.toString()); + return obj; + }, + toJSON(message: DeploymentID): JsonSafe { + const obj: any = {}; + message.owner !== undefined && (obj.owner = message.owner); + message.dseq !== undefined && (obj.dseq = (message.dseq || BigInt(0)).toString()); + return obj; + }, + fromPartial, I>>(object: I): DeploymentID { + const message = createBaseDeploymentID(); + message.owner = object.owner ?? ""; + if (object.dseq !== undefined && object.dseq !== null) { + message.dseq = BigInt(object.dseq.toString()); + } + return message; + }, + fromSDK(object: DeploymentIDSDKType): DeploymentID { + return { + owner: object?.owner, + dseq: object?.dseq + }; + }, + fromSDKJSON(object: any): DeploymentIDSDKType { + return { + owner: isSet(object.owner) ? String(object.owner) : "", + dseq: isSet(object.dseq) ? BigInt(object.dseq.toString()) : BigInt(0) + }; + }, + toSDK(message: DeploymentID): DeploymentIDSDKType { + const obj: any = {}; + obj.owner = message.owner; + obj.dseq = message.dseq; + return obj; + }, + fromAmino(object: DeploymentIDAmino): DeploymentID { + const message = createBaseDeploymentID(); + if (object.owner !== undefined && object.owner !== null) { + message.owner = object.owner; + } + if (object.dseq !== undefined && object.dseq !== null) { + message.dseq = BigInt(object.dseq); + } + return message; + }, + toAmino(message: DeploymentID): DeploymentIDAmino { + const obj: any = {}; + obj.owner = message.owner ?? ""; + obj.dseq = message.dseq ? message.dseq?.toString() : "0"; + return obj; + }, + fromAminoMsg(object: DeploymentIDAminoMsg): DeploymentID { + return DeploymentID.fromAmino(object.value); + }, + toAminoMsg(message: DeploymentID): DeploymentIDAminoMsg { + return { + type: "akash/deployment/v1beta2/deployment-i-d", + value: DeploymentID.toAmino(message) + }; + }, + fromProtoMsg(message: DeploymentIDProtoMsg): DeploymentID { + return DeploymentID.decode(message.value); + }, + toProto(message: DeploymentID): Uint8Array { + return DeploymentID.encode(message).finish(); + }, + toProtoMsg(message: DeploymentID): DeploymentIDProtoMsg { + return { + typeUrl: "/akash.deployment.v1beta2.DeploymentID", + value: DeploymentID.encode(message).finish() + }; + } +}; +function createBaseDeployment(): Deployment { + return { + deploymentId: DeploymentID.fromPartial({}), + state: 0, + version: new Uint8Array(), + createdAt: BigInt(0) + }; +} +export const Deployment = { + typeUrl: "/akash.deployment.v1beta2.Deployment", + encode(message: Deployment, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.deploymentId !== undefined) { + DeploymentID.encode(message.deploymentId, writer.uint32(10).fork()).ldelim(); + } + if (message.state !== 0) { + writer.uint32(16).int32(message.state); + } + if (message.version.length !== 0) { + writer.uint32(26).bytes(message.version); + } + if (message.createdAt !== undefined) { + writer.uint32(32).int64(message.createdAt); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Deployment { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDeployment(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.deploymentId = DeploymentID.decode(reader, reader.uint32()); + break; + case 2: + message.state = (reader.int32() as any); + break; + case 3: + message.version = reader.bytes(); + break; + case 4: + message.createdAt = reader.int64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Deployment { + const obj = createBaseDeployment(); + if (isSet(object.deploymentId)) obj.deploymentId = DeploymentID.fromJSON(object.deploymentId); + if (isSet(object.state)) obj.state = deployment_StateFromJSON(object.state); + if (isSet(object.version)) obj.version = bytesFromBase64(object.version); + if (isSet(object.createdAt)) obj.createdAt = BigInt(object.createdAt.toString()); + return obj; + }, + toJSON(message: Deployment): JsonSafe { + const obj: any = {}; + message.deploymentId !== undefined && (obj.deploymentId = message.deploymentId ? DeploymentID.toJSON(message.deploymentId) : undefined); + message.state !== undefined && (obj.state = deployment_StateToJSON(message.state)); + message.version !== undefined && (obj.version = base64FromBytes(message.version !== undefined ? message.version : new Uint8Array())); + message.createdAt !== undefined && (obj.createdAt = (message.createdAt || BigInt(0)).toString()); + return obj; + }, + fromPartial, I>>(object: I): Deployment { + const message = createBaseDeployment(); + if (object.deploymentId !== undefined && object.deploymentId !== null) { + message.deploymentId = DeploymentID.fromPartial(object.deploymentId); + } + message.state = object.state ?? 0; + message.version = object.version ?? new Uint8Array(); + if (object.createdAt !== undefined && object.createdAt !== null) { + message.createdAt = BigInt(object.createdAt.toString()); + } + return message; + }, + fromSDK(object: DeploymentSDKType): Deployment { + return { + deploymentId: object.deployment_id ? DeploymentID.fromSDK(object.deployment_id) : undefined, + state: isSet(object.state) ? deployment_StateFromJSON(object.state) : -1, + version: object?.version, + createdAt: object?.created_at + }; + }, + fromSDKJSON(object: any): DeploymentSDKType { + return { + deployment_id: isSet(object.deployment_id) ? DeploymentID.fromSDKJSON(object.deployment_id) : undefined, + state: isSet(object.state) ? deployment_StateFromJSON(object.state) : -1, + version: isSet(object.version) ? bytesFromBase64(object.version) : new Uint8Array(), + created_at: isSet(object.created_at) ? BigInt(object.created_at.toString()) : BigInt(0) + }; + }, + toSDK(message: Deployment): DeploymentSDKType { + const obj: any = {}; + message.deploymentId !== undefined && (obj.deployment_id = message.deploymentId ? DeploymentID.toSDK(message.deploymentId) : undefined); + message.state !== undefined && (obj.state = deployment_StateToJSON(message.state)); + obj.version = message.version; + obj.created_at = message.createdAt; + return obj; + }, + fromAmino(object: DeploymentAmino): Deployment { + const message = createBaseDeployment(); + if (object.deployment_id !== undefined && object.deployment_id !== null) { + message.deploymentId = DeploymentID.fromAmino(object.deployment_id); + } + if (object.state !== undefined && object.state !== null) { + message.state = object.state; + } + if (object.version !== undefined && object.version !== null) { + message.version = bytesFromBase64(object.version); + } + if (object.created_at !== undefined && object.created_at !== null) { + message.createdAt = BigInt(object.created_at); + } + return message; + }, + toAmino(message: Deployment): DeploymentAmino { + const obj: any = {}; + obj.deployment_id = message.deploymentId ? DeploymentID.toAmino(message.deploymentId) : DeploymentID.toAmino(DeploymentID.fromPartial({})); + obj.state = message.state ?? 0; + obj.version = message.version ? base64FromBytes(message.version) : ""; + obj.created_at = message.createdAt !== BigInt(0) ? message.createdAt?.toString() : undefined; + return obj; + }, + fromAminoMsg(object: DeploymentAminoMsg): Deployment { + return Deployment.fromAmino(object.value); + }, + toAminoMsg(message: Deployment): DeploymentAminoMsg { + return { + type: "akash/deployment/v1beta2/deployment", + value: Deployment.toAmino(message) + }; + }, + fromProtoMsg(message: DeploymentProtoMsg): Deployment { + return Deployment.decode(message.value); + }, + toProto(message: Deployment): Uint8Array { + return Deployment.encode(message).finish(); + }, + toProtoMsg(message: Deployment): DeploymentProtoMsg { + return { + typeUrl: "/akash.deployment.v1beta2.Deployment", + value: Deployment.encode(message).finish() + }; + } +}; +function createBaseDeploymentFilters(): DeploymentFilters { + return { + owner: "", + dseq: BigInt(0), + state: "" + }; +} +export const DeploymentFilters = { + typeUrl: "/akash.deployment.v1beta2.DeploymentFilters", + encode(message: DeploymentFilters, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.owner !== undefined) { + writer.uint32(10).string(message.owner); + } + if (message.dseq !== undefined) { + writer.uint32(16).uint64(message.dseq); + } + if (message.state !== undefined) { + writer.uint32(26).string(message.state); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): DeploymentFilters { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDeploymentFilters(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.owner = reader.string(); + break; + case 2: + message.dseq = reader.uint64(); + break; + case 3: + message.state = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): DeploymentFilters { + const obj = createBaseDeploymentFilters(); + if (isSet(object.owner)) obj.owner = String(object.owner); + if (isSet(object.dseq)) obj.dseq = BigInt(object.dseq.toString()); + if (isSet(object.state)) obj.state = String(object.state); + return obj; + }, + toJSON(message: DeploymentFilters): JsonSafe { + const obj: any = {}; + message.owner !== undefined && (obj.owner = message.owner); + message.dseq !== undefined && (obj.dseq = (message.dseq || BigInt(0)).toString()); + message.state !== undefined && (obj.state = message.state); + return obj; + }, + fromPartial, I>>(object: I): DeploymentFilters { + const message = createBaseDeploymentFilters(); + message.owner = object.owner ?? ""; + if (object.dseq !== undefined && object.dseq !== null) { + message.dseq = BigInt(object.dseq.toString()); + } + message.state = object.state ?? ""; + return message; + }, + fromSDK(object: DeploymentFiltersSDKType): DeploymentFilters { + return { + owner: object?.owner, + dseq: object?.dseq, + state: object?.state + }; + }, + fromSDKJSON(object: any): DeploymentFiltersSDKType { + return { + owner: isSet(object.owner) ? String(object.owner) : "", + dseq: isSet(object.dseq) ? BigInt(object.dseq.toString()) : BigInt(0), + state: isSet(object.state) ? String(object.state) : "" + }; + }, + toSDK(message: DeploymentFilters): DeploymentFiltersSDKType { + const obj: any = {}; + obj.owner = message.owner; + obj.dseq = message.dseq; + obj.state = message.state; + return obj; + }, + fromAmino(object: DeploymentFiltersAmino): DeploymentFilters { + const message = createBaseDeploymentFilters(); + if (object.owner !== undefined && object.owner !== null) { + message.owner = object.owner; + } + if (object.dseq !== undefined && object.dseq !== null) { + message.dseq = BigInt(object.dseq); + } + if (object.state !== undefined && object.state !== null) { + message.state = object.state; + } + return message; + }, + toAmino(message: DeploymentFilters): DeploymentFiltersAmino { + const obj: any = {}; + obj.owner = message.owner ?? ""; + obj.dseq = message.dseq ? message.dseq?.toString() : "0"; + obj.state = message.state ?? ""; + return obj; + }, + fromAminoMsg(object: DeploymentFiltersAminoMsg): DeploymentFilters { + return DeploymentFilters.fromAmino(object.value); + }, + toAminoMsg(message: DeploymentFilters): DeploymentFiltersAminoMsg { + return { + type: "akash/deployment/v1beta2/deployment-filters", + value: DeploymentFilters.toAmino(message) + }; + }, + fromProtoMsg(message: DeploymentFiltersProtoMsg): DeploymentFilters { + return DeploymentFilters.decode(message.value); + }, + toProto(message: DeploymentFilters): Uint8Array { + return DeploymentFilters.encode(message).finish(); + }, + toProtoMsg(message: DeploymentFilters): DeploymentFiltersProtoMsg { + return { + typeUrl: "/akash.deployment.v1beta2.DeploymentFilters", + value: DeploymentFilters.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta2/deploymentmsg.ts b/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta2/deploymentmsg.ts new file mode 100644 index 0000000000..cb585d0d10 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta2/deploymentmsg.ts @@ -0,0 +1,916 @@ +import { DeploymentID, DeploymentIDSDKType } from "./deployment.js"; +import { GroupSpec, GroupSpecSDKType } from "./groupspec.js"; +import { Coin, CoinSDKType } from "../../../cosmos/base/v1beta1/coin.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, bytesFromBase64, base64FromBytes, DeepPartial, Exact } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "akash.deployment.v1beta2"; +/** MsgCreateDeployment defines an SDK message for creating deployment */ +export interface MsgCreateDeployment { + id: DeploymentID; + groups: GroupSpec[]; + version: Uint8Array; + deposit: Coin; + /** Depositor pays for the deposit */ + depositor: string; +} +export interface MsgCreateDeploymentProtoMsg { + typeUrl: "/akash.deployment.v1beta2.MsgCreateDeployment"; + value: Uint8Array; +} +/** MsgCreateDeployment defines an SDK message for creating deployment */ +export interface MsgCreateDeploymentSDKType { + id: DeploymentIDSDKType; + groups: GroupSpecSDKType[]; + version: Uint8Array; + deposit: CoinSDKType; + depositor: string; +} +/** MsgCreateDeploymentResponse defines the Msg/CreateDeployment response type. */ +export interface MsgCreateDeploymentResponse {} +export interface MsgCreateDeploymentResponseProtoMsg { + typeUrl: "/akash.deployment.v1beta2.MsgCreateDeploymentResponse"; + value: Uint8Array; +} +/** MsgCreateDeploymentResponse defines the Msg/CreateDeployment response type. */ +export interface MsgCreateDeploymentResponseSDKType {} +/** MsgDepositDeployment deposits more funds into the deposit account */ +export interface MsgDepositDeployment { + id: DeploymentID; + amount: Coin; + /** Depositor pays for the deposit */ + depositor: string; +} +export interface MsgDepositDeploymentProtoMsg { + typeUrl: "/akash.deployment.v1beta2.MsgDepositDeployment"; + value: Uint8Array; +} +/** MsgDepositDeployment deposits more funds into the deposit account */ +export interface MsgDepositDeploymentSDKType { + id: DeploymentIDSDKType; + amount: CoinSDKType; + depositor: string; +} +/** MsgCreateDeploymentResponse defines the Msg/CreateDeployment response type. */ +export interface MsgDepositDeploymentResponse {} +export interface MsgDepositDeploymentResponseProtoMsg { + typeUrl: "/akash.deployment.v1beta2.MsgDepositDeploymentResponse"; + value: Uint8Array; +} +/** MsgCreateDeploymentResponse defines the Msg/CreateDeployment response type. */ +export interface MsgDepositDeploymentResponseSDKType {} +/** MsgUpdateDeployment defines an SDK message for updating deployment */ +export interface MsgUpdateDeployment { + id: DeploymentID; + version: Uint8Array; +} +export interface MsgUpdateDeploymentProtoMsg { + typeUrl: "/akash.deployment.v1beta2.MsgUpdateDeployment"; + value: Uint8Array; +} +/** MsgUpdateDeployment defines an SDK message for updating deployment */ +export interface MsgUpdateDeploymentSDKType { + id: DeploymentIDSDKType; + version: Uint8Array; +} +/** MsgUpdateDeploymentResponse defines the Msg/UpdateDeployment response type. */ +export interface MsgUpdateDeploymentResponse {} +export interface MsgUpdateDeploymentResponseProtoMsg { + typeUrl: "/akash.deployment.v1beta2.MsgUpdateDeploymentResponse"; + value: Uint8Array; +} +/** MsgUpdateDeploymentResponse defines the Msg/UpdateDeployment response type. */ +export interface MsgUpdateDeploymentResponseSDKType {} +/** MsgCloseDeployment defines an SDK message for closing deployment */ +export interface MsgCloseDeployment { + id: DeploymentID; +} +export interface MsgCloseDeploymentProtoMsg { + typeUrl: "/akash.deployment.v1beta2.MsgCloseDeployment"; + value: Uint8Array; +} +/** MsgCloseDeployment defines an SDK message for closing deployment */ +export interface MsgCloseDeploymentSDKType { + id: DeploymentIDSDKType; +} +/** MsgCloseDeploymentResponse defines the Msg/CloseDeployment response type. */ +export interface MsgCloseDeploymentResponse {} +export interface MsgCloseDeploymentResponseProtoMsg { + typeUrl: "/akash.deployment.v1beta2.MsgCloseDeploymentResponse"; + value: Uint8Array; +} +/** MsgCloseDeploymentResponse defines the Msg/CloseDeployment response type. */ +export interface MsgCloseDeploymentResponseSDKType {} +function createBaseMsgCreateDeployment(): MsgCreateDeployment { + return { + id: DeploymentID.fromPartial({}), + groups: [], + version: new Uint8Array(), + deposit: Coin.fromPartial({}), + depositor: "" + }; +} +export const MsgCreateDeployment = { + typeUrl: "/akash.deployment.v1beta2.MsgCreateDeployment", + encode(message: MsgCreateDeployment, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.id !== undefined) { + DeploymentID.encode(message.id, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.groups) { + GroupSpec.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.version.length !== 0) { + writer.uint32(26).bytes(message.version); + } + if (message.deposit !== undefined) { + Coin.encode(message.deposit, writer.uint32(34).fork()).ldelim(); + } + if (message.depositor !== undefined) { + writer.uint32(42).string(message.depositor); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgCreateDeployment { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgCreateDeployment(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.id = DeploymentID.decode(reader, reader.uint32()); + break; + case 2: + message.groups.push(GroupSpec.decode(reader, reader.uint32())); + break; + case 3: + message.version = reader.bytes(); + break; + case 4: + message.deposit = Coin.decode(reader, reader.uint32()); + break; + case 5: + message.depositor = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgCreateDeployment { + const obj = createBaseMsgCreateDeployment(); + if (isSet(object.id)) obj.id = DeploymentID.fromJSON(object.id); + if (Array.isArray(object?.groups)) obj.groups = object.groups.map((e: any) => GroupSpec.fromJSON(e)); + if (isSet(object.version)) obj.version = bytesFromBase64(object.version); + if (isSet(object.deposit)) obj.deposit = Coin.fromJSON(object.deposit); + if (isSet(object.depositor)) obj.depositor = String(object.depositor); + return obj; + }, + toJSON(message: MsgCreateDeployment): JsonSafe { + const obj: any = {}; + message.id !== undefined && (obj.id = message.id ? DeploymentID.toJSON(message.id) : undefined); + if (message.groups) { + obj.groups = message.groups.map(e => e ? GroupSpec.toJSON(e) : undefined); + } else { + obj.groups = []; + } + message.version !== undefined && (obj.version = base64FromBytes(message.version !== undefined ? message.version : new Uint8Array())); + message.deposit !== undefined && (obj.deposit = message.deposit ? Coin.toJSON(message.deposit) : undefined); + message.depositor !== undefined && (obj.depositor = message.depositor); + return obj; + }, + fromPartial, I>>(object: I): MsgCreateDeployment { + const message = createBaseMsgCreateDeployment(); + if (object.id !== undefined && object.id !== null) { + message.id = DeploymentID.fromPartial(object.id); + } + message.groups = object.groups?.map(e => GroupSpec.fromPartial(e)) || []; + message.version = object.version ?? new Uint8Array(); + if (object.deposit !== undefined && object.deposit !== null) { + message.deposit = Coin.fromPartial(object.deposit); + } + message.depositor = object.depositor ?? ""; + return message; + }, + fromSDK(object: MsgCreateDeploymentSDKType): MsgCreateDeployment { + return { + id: object.id ? DeploymentID.fromSDK(object.id) : undefined, + groups: Array.isArray(object?.groups) ? object.groups.map((e: any) => GroupSpec.fromSDK(e)) : [], + version: object?.version, + deposit: object.deposit ? Coin.fromSDK(object.deposit) : undefined, + depositor: object?.depositor + }; + }, + fromSDKJSON(object: any): MsgCreateDeploymentSDKType { + return { + id: isSet(object.id) ? DeploymentID.fromSDKJSON(object.id) : undefined, + groups: Array.isArray(object?.groups) ? object.groups.map((e: any) => GroupSpec.fromSDKJSON(e)) : [], + version: isSet(object.version) ? bytesFromBase64(object.version) : new Uint8Array(), + deposit: isSet(object.deposit) ? Coin.fromSDKJSON(object.deposit) : undefined, + depositor: isSet(object.depositor) ? String(object.depositor) : "" + }; + }, + toSDK(message: MsgCreateDeployment): MsgCreateDeploymentSDKType { + const obj: any = {}; + message.id !== undefined && (obj.id = message.id ? DeploymentID.toSDK(message.id) : undefined); + if (message.groups) { + obj.groups = message.groups.map(e => e ? GroupSpec.toSDK(e) : undefined); + } else { + obj.groups = []; + } + obj.version = message.version; + message.deposit !== undefined && (obj.deposit = message.deposit ? Coin.toSDK(message.deposit) : undefined); + obj.depositor = message.depositor; + return obj; + }, + fromAmino(object: MsgCreateDeploymentAmino): MsgCreateDeployment { + const message = createBaseMsgCreateDeployment(); + if (object.id !== undefined && object.id !== null) { + message.id = DeploymentID.fromAmino(object.id); + } + message.groups = object.groups?.map(e => GroupSpec.fromAmino(e)) || []; + if (object.version !== undefined && object.version !== null) { + message.version = bytesFromBase64(object.version); + } + if (object.deposit !== undefined && object.deposit !== null) { + message.deposit = Coin.fromAmino(object.deposit); + } + if (object.depositor !== undefined && object.depositor !== null) { + message.depositor = object.depositor; + } + return message; + }, + toAmino(message: MsgCreateDeployment): MsgCreateDeploymentAmino { + const obj: any = {}; + obj.id = message.id ? DeploymentID.toAmino(message.id) : DeploymentID.toAmino(DeploymentID.fromPartial({})); + if (message.groups) { + obj.groups = message.groups.map(e => e ? GroupSpec.toAmino(e) : undefined); + } else { + obj.groups = message.groups; + } + obj.version = message.version ? base64FromBytes(message.version) : ""; + obj.deposit = message.deposit ? Coin.toAmino(message.deposit) : Coin.toAmino(Coin.fromPartial({})); + obj.depositor = message.depositor ?? ""; + return obj; + }, + fromAminoMsg(object: MsgCreateDeploymentAminoMsg): MsgCreateDeployment { + return MsgCreateDeployment.fromAmino(object.value); + }, + toAminoMsg(message: MsgCreateDeployment): MsgCreateDeploymentAminoMsg { + return { + type: "akash/deployment/v1beta2/testonly-create-deployment", + value: MsgCreateDeployment.toAmino(message) + }; + }, + fromProtoMsg(message: MsgCreateDeploymentProtoMsg): MsgCreateDeployment { + return MsgCreateDeployment.decode(message.value); + }, + toProto(message: MsgCreateDeployment): Uint8Array { + return MsgCreateDeployment.encode(message).finish(); + }, + toProtoMsg(message: MsgCreateDeployment): MsgCreateDeploymentProtoMsg { + return { + typeUrl: "/akash.deployment.v1beta2.MsgCreateDeployment", + value: MsgCreateDeployment.encode(message).finish() + }; + } +}; +function createBaseMsgCreateDeploymentResponse(): MsgCreateDeploymentResponse { + return {}; +} +export const MsgCreateDeploymentResponse = { + typeUrl: "/akash.deployment.v1beta2.MsgCreateDeploymentResponse", + encode(_: MsgCreateDeploymentResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgCreateDeploymentResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgCreateDeploymentResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgCreateDeploymentResponse { + const obj = createBaseMsgCreateDeploymentResponse(); + return obj; + }, + toJSON(_: MsgCreateDeploymentResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): MsgCreateDeploymentResponse { + const message = createBaseMsgCreateDeploymentResponse(); + return message; + }, + fromSDK(_: MsgCreateDeploymentResponseSDKType): MsgCreateDeploymentResponse { + return {}; + }, + fromSDKJSON(_: any): MsgCreateDeploymentResponseSDKType { + return {}; + }, + toSDK(_: MsgCreateDeploymentResponse): MsgCreateDeploymentResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgCreateDeploymentResponseAmino): MsgCreateDeploymentResponse { + const message = createBaseMsgCreateDeploymentResponse(); + return message; + }, + toAmino(_: MsgCreateDeploymentResponse): MsgCreateDeploymentResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgCreateDeploymentResponseAminoMsg): MsgCreateDeploymentResponse { + return MsgCreateDeploymentResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgCreateDeploymentResponse): MsgCreateDeploymentResponseAminoMsg { + return { + type: "akash/deployment/v1beta2/testonly-create-deployment-response", + value: MsgCreateDeploymentResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgCreateDeploymentResponseProtoMsg): MsgCreateDeploymentResponse { + return MsgCreateDeploymentResponse.decode(message.value); + }, + toProto(message: MsgCreateDeploymentResponse): Uint8Array { + return MsgCreateDeploymentResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgCreateDeploymentResponse): MsgCreateDeploymentResponseProtoMsg { + return { + typeUrl: "/akash.deployment.v1beta2.MsgCreateDeploymentResponse", + value: MsgCreateDeploymentResponse.encode(message).finish() + }; + } +}; +function createBaseMsgDepositDeployment(): MsgDepositDeployment { + return { + id: DeploymentID.fromPartial({}), + amount: Coin.fromPartial({}), + depositor: "" + }; +} +export const MsgDepositDeployment = { + typeUrl: "/akash.deployment.v1beta2.MsgDepositDeployment", + encode(message: MsgDepositDeployment, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.id !== undefined) { + DeploymentID.encode(message.id, writer.uint32(10).fork()).ldelim(); + } + if (message.amount !== undefined) { + Coin.encode(message.amount, writer.uint32(18).fork()).ldelim(); + } + if (message.depositor !== undefined) { + writer.uint32(26).string(message.depositor); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgDepositDeployment { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgDepositDeployment(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.id = DeploymentID.decode(reader, reader.uint32()); + break; + case 2: + message.amount = Coin.decode(reader, reader.uint32()); + break; + case 3: + message.depositor = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgDepositDeployment { + const obj = createBaseMsgDepositDeployment(); + if (isSet(object.id)) obj.id = DeploymentID.fromJSON(object.id); + if (isSet(object.amount)) obj.amount = Coin.fromJSON(object.amount); + if (isSet(object.depositor)) obj.depositor = String(object.depositor); + return obj; + }, + toJSON(message: MsgDepositDeployment): JsonSafe { + const obj: any = {}; + message.id !== undefined && (obj.id = message.id ? DeploymentID.toJSON(message.id) : undefined); + message.amount !== undefined && (obj.amount = message.amount ? Coin.toJSON(message.amount) : undefined); + message.depositor !== undefined && (obj.depositor = message.depositor); + return obj; + }, + fromPartial, I>>(object: I): MsgDepositDeployment { + const message = createBaseMsgDepositDeployment(); + if (object.id !== undefined && object.id !== null) { + message.id = DeploymentID.fromPartial(object.id); + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = Coin.fromPartial(object.amount); + } + message.depositor = object.depositor ?? ""; + return message; + }, + fromSDK(object: MsgDepositDeploymentSDKType): MsgDepositDeployment { + return { + id: object.id ? DeploymentID.fromSDK(object.id) : undefined, + amount: object.amount ? Coin.fromSDK(object.amount) : undefined, + depositor: object?.depositor + }; + }, + fromSDKJSON(object: any): MsgDepositDeploymentSDKType { + return { + id: isSet(object.id) ? DeploymentID.fromSDKJSON(object.id) : undefined, + amount: isSet(object.amount) ? Coin.fromSDKJSON(object.amount) : undefined, + depositor: isSet(object.depositor) ? String(object.depositor) : "" + }; + }, + toSDK(message: MsgDepositDeployment): MsgDepositDeploymentSDKType { + const obj: any = {}; + message.id !== undefined && (obj.id = message.id ? DeploymentID.toSDK(message.id) : undefined); + message.amount !== undefined && (obj.amount = message.amount ? Coin.toSDK(message.amount) : undefined); + obj.depositor = message.depositor; + return obj; + }, + fromAmino(object: MsgDepositDeploymentAmino): MsgDepositDeployment { + const message = createBaseMsgDepositDeployment(); + if (object.id !== undefined && object.id !== null) { + message.id = DeploymentID.fromAmino(object.id); + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = Coin.fromAmino(object.amount); + } + if (object.depositor !== undefined && object.depositor !== null) { + message.depositor = object.depositor; + } + return message; + }, + toAmino(message: MsgDepositDeployment): MsgDepositDeploymentAmino { + const obj: any = {}; + obj.id = message.id ? DeploymentID.toAmino(message.id) : DeploymentID.toAmino(DeploymentID.fromPartial({})); + obj.amount = message.amount ? Coin.toAmino(message.amount) : Coin.toAmino(Coin.fromPartial({})); + obj.depositor = message.depositor ?? ""; + return obj; + }, + fromAminoMsg(object: MsgDepositDeploymentAminoMsg): MsgDepositDeployment { + return MsgDepositDeployment.fromAmino(object.value); + }, + toAminoMsg(message: MsgDepositDeployment): MsgDepositDeploymentAminoMsg { + return { + type: "akash/deployment/v1beta2/testonly-deposit-deployment", + value: MsgDepositDeployment.toAmino(message) + }; + }, + fromProtoMsg(message: MsgDepositDeploymentProtoMsg): MsgDepositDeployment { + return MsgDepositDeployment.decode(message.value); + }, + toProto(message: MsgDepositDeployment): Uint8Array { + return MsgDepositDeployment.encode(message).finish(); + }, + toProtoMsg(message: MsgDepositDeployment): MsgDepositDeploymentProtoMsg { + return { + typeUrl: "/akash.deployment.v1beta2.MsgDepositDeployment", + value: MsgDepositDeployment.encode(message).finish() + }; + } +}; +function createBaseMsgDepositDeploymentResponse(): MsgDepositDeploymentResponse { + return {}; +} +export const MsgDepositDeploymentResponse = { + typeUrl: "/akash.deployment.v1beta2.MsgDepositDeploymentResponse", + encode(_: MsgDepositDeploymentResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgDepositDeploymentResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgDepositDeploymentResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgDepositDeploymentResponse { + const obj = createBaseMsgDepositDeploymentResponse(); + return obj; + }, + toJSON(_: MsgDepositDeploymentResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): MsgDepositDeploymentResponse { + const message = createBaseMsgDepositDeploymentResponse(); + return message; + }, + fromSDK(_: MsgDepositDeploymentResponseSDKType): MsgDepositDeploymentResponse { + return {}; + }, + fromSDKJSON(_: any): MsgDepositDeploymentResponseSDKType { + return {}; + }, + toSDK(_: MsgDepositDeploymentResponse): MsgDepositDeploymentResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgDepositDeploymentResponseAmino): MsgDepositDeploymentResponse { + const message = createBaseMsgDepositDeploymentResponse(); + return message; + }, + toAmino(_: MsgDepositDeploymentResponse): MsgDepositDeploymentResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgDepositDeploymentResponseAminoMsg): MsgDepositDeploymentResponse { + return MsgDepositDeploymentResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgDepositDeploymentResponse): MsgDepositDeploymentResponseAminoMsg { + return { + type: "akash/deployment/v1beta2/testonly-deposit-deployment-response", + value: MsgDepositDeploymentResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgDepositDeploymentResponseProtoMsg): MsgDepositDeploymentResponse { + return MsgDepositDeploymentResponse.decode(message.value); + }, + toProto(message: MsgDepositDeploymentResponse): Uint8Array { + return MsgDepositDeploymentResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgDepositDeploymentResponse): MsgDepositDeploymentResponseProtoMsg { + return { + typeUrl: "/akash.deployment.v1beta2.MsgDepositDeploymentResponse", + value: MsgDepositDeploymentResponse.encode(message).finish() + }; + } +}; +function createBaseMsgUpdateDeployment(): MsgUpdateDeployment { + return { + id: DeploymentID.fromPartial({}), + version: new Uint8Array() + }; +} +export const MsgUpdateDeployment = { + typeUrl: "/akash.deployment.v1beta2.MsgUpdateDeployment", + encode(message: MsgUpdateDeployment, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.id !== undefined) { + DeploymentID.encode(message.id, writer.uint32(10).fork()).ldelim(); + } + if (message.version.length !== 0) { + writer.uint32(26).bytes(message.version); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgUpdateDeployment { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgUpdateDeployment(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.id = DeploymentID.decode(reader, reader.uint32()); + break; + case 3: + message.version = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgUpdateDeployment { + const obj = createBaseMsgUpdateDeployment(); + if (isSet(object.id)) obj.id = DeploymentID.fromJSON(object.id); + if (isSet(object.version)) obj.version = bytesFromBase64(object.version); + return obj; + }, + toJSON(message: MsgUpdateDeployment): JsonSafe { + const obj: any = {}; + message.id !== undefined && (obj.id = message.id ? DeploymentID.toJSON(message.id) : undefined); + message.version !== undefined && (obj.version = base64FromBytes(message.version !== undefined ? message.version : new Uint8Array())); + return obj; + }, + fromPartial, I>>(object: I): MsgUpdateDeployment { + const message = createBaseMsgUpdateDeployment(); + if (object.id !== undefined && object.id !== null) { + message.id = DeploymentID.fromPartial(object.id); + } + message.version = object.version ?? new Uint8Array(); + return message; + }, + fromSDK(object: MsgUpdateDeploymentSDKType): MsgUpdateDeployment { + return { + id: object.id ? DeploymentID.fromSDK(object.id) : undefined, + version: object?.version + }; + }, + fromSDKJSON(object: any): MsgUpdateDeploymentSDKType { + return { + id: isSet(object.id) ? DeploymentID.fromSDKJSON(object.id) : undefined, + version: isSet(object.version) ? bytesFromBase64(object.version) : new Uint8Array() + }; + }, + toSDK(message: MsgUpdateDeployment): MsgUpdateDeploymentSDKType { + const obj: any = {}; + message.id !== undefined && (obj.id = message.id ? DeploymentID.toSDK(message.id) : undefined); + obj.version = message.version; + return obj; + }, + fromAmino(object: MsgUpdateDeploymentAmino): MsgUpdateDeployment { + const message = createBaseMsgUpdateDeployment(); + if (object.id !== undefined && object.id !== null) { + message.id = DeploymentID.fromAmino(object.id); + } + if (object.version !== undefined && object.version !== null) { + message.version = bytesFromBase64(object.version); + } + return message; + }, + toAmino(message: MsgUpdateDeployment): MsgUpdateDeploymentAmino { + const obj: any = {}; + obj.id = message.id ? DeploymentID.toAmino(message.id) : DeploymentID.toAmino(DeploymentID.fromPartial({})); + obj.version = message.version ? base64FromBytes(message.version) : ""; + return obj; + }, + fromAminoMsg(object: MsgUpdateDeploymentAminoMsg): MsgUpdateDeployment { + return MsgUpdateDeployment.fromAmino(object.value); + }, + toAminoMsg(message: MsgUpdateDeployment): MsgUpdateDeploymentAminoMsg { + return { + type: "akash/deployment/v1beta2/testonly-update-deployment", + value: MsgUpdateDeployment.toAmino(message) + }; + }, + fromProtoMsg(message: MsgUpdateDeploymentProtoMsg): MsgUpdateDeployment { + return MsgUpdateDeployment.decode(message.value); + }, + toProto(message: MsgUpdateDeployment): Uint8Array { + return MsgUpdateDeployment.encode(message).finish(); + }, + toProtoMsg(message: MsgUpdateDeployment): MsgUpdateDeploymentProtoMsg { + return { + typeUrl: "/akash.deployment.v1beta2.MsgUpdateDeployment", + value: MsgUpdateDeployment.encode(message).finish() + }; + } +}; +function createBaseMsgUpdateDeploymentResponse(): MsgUpdateDeploymentResponse { + return {}; +} +export const MsgUpdateDeploymentResponse = { + typeUrl: "/akash.deployment.v1beta2.MsgUpdateDeploymentResponse", + encode(_: MsgUpdateDeploymentResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgUpdateDeploymentResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgUpdateDeploymentResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgUpdateDeploymentResponse { + const obj = createBaseMsgUpdateDeploymentResponse(); + return obj; + }, + toJSON(_: MsgUpdateDeploymentResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): MsgUpdateDeploymentResponse { + const message = createBaseMsgUpdateDeploymentResponse(); + return message; + }, + fromSDK(_: MsgUpdateDeploymentResponseSDKType): MsgUpdateDeploymentResponse { + return {}; + }, + fromSDKJSON(_: any): MsgUpdateDeploymentResponseSDKType { + return {}; + }, + toSDK(_: MsgUpdateDeploymentResponse): MsgUpdateDeploymentResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgUpdateDeploymentResponseAmino): MsgUpdateDeploymentResponse { + const message = createBaseMsgUpdateDeploymentResponse(); + return message; + }, + toAmino(_: MsgUpdateDeploymentResponse): MsgUpdateDeploymentResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgUpdateDeploymentResponseAminoMsg): MsgUpdateDeploymentResponse { + return MsgUpdateDeploymentResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgUpdateDeploymentResponse): MsgUpdateDeploymentResponseAminoMsg { + return { + type: "akash/deployment/v1beta2/testonly-update-deployment-response", + value: MsgUpdateDeploymentResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgUpdateDeploymentResponseProtoMsg): MsgUpdateDeploymentResponse { + return MsgUpdateDeploymentResponse.decode(message.value); + }, + toProto(message: MsgUpdateDeploymentResponse): Uint8Array { + return MsgUpdateDeploymentResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgUpdateDeploymentResponse): MsgUpdateDeploymentResponseProtoMsg { + return { + typeUrl: "/akash.deployment.v1beta2.MsgUpdateDeploymentResponse", + value: MsgUpdateDeploymentResponse.encode(message).finish() + }; + } +}; +function createBaseMsgCloseDeployment(): MsgCloseDeployment { + return { + id: DeploymentID.fromPartial({}) + }; +} +export const MsgCloseDeployment = { + typeUrl: "/akash.deployment.v1beta2.MsgCloseDeployment", + encode(message: MsgCloseDeployment, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.id !== undefined) { + DeploymentID.encode(message.id, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgCloseDeployment { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgCloseDeployment(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.id = DeploymentID.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgCloseDeployment { + const obj = createBaseMsgCloseDeployment(); + if (isSet(object.id)) obj.id = DeploymentID.fromJSON(object.id); + return obj; + }, + toJSON(message: MsgCloseDeployment): JsonSafe { + const obj: any = {}; + message.id !== undefined && (obj.id = message.id ? DeploymentID.toJSON(message.id) : undefined); + return obj; + }, + fromPartial, I>>(object: I): MsgCloseDeployment { + const message = createBaseMsgCloseDeployment(); + if (object.id !== undefined && object.id !== null) { + message.id = DeploymentID.fromPartial(object.id); + } + return message; + }, + fromSDK(object: MsgCloseDeploymentSDKType): MsgCloseDeployment { + return { + id: object.id ? DeploymentID.fromSDK(object.id) : undefined + }; + }, + fromSDKJSON(object: any): MsgCloseDeploymentSDKType { + return { + id: isSet(object.id) ? DeploymentID.fromSDKJSON(object.id) : undefined + }; + }, + toSDK(message: MsgCloseDeployment): MsgCloseDeploymentSDKType { + const obj: any = {}; + message.id !== undefined && (obj.id = message.id ? DeploymentID.toSDK(message.id) : undefined); + return obj; + }, + fromAmino(object: MsgCloseDeploymentAmino): MsgCloseDeployment { + const message = createBaseMsgCloseDeployment(); + if (object.id !== undefined && object.id !== null) { + message.id = DeploymentID.fromAmino(object.id); + } + return message; + }, + toAmino(message: MsgCloseDeployment): MsgCloseDeploymentAmino { + const obj: any = {}; + obj.id = message.id ? DeploymentID.toAmino(message.id) : DeploymentID.toAmino(DeploymentID.fromPartial({})); + return obj; + }, + fromAminoMsg(object: MsgCloseDeploymentAminoMsg): MsgCloseDeployment { + return MsgCloseDeployment.fromAmino(object.value); + }, + toAminoMsg(message: MsgCloseDeployment): MsgCloseDeploymentAminoMsg { + return { + type: "akash/deployment/v1beta2/testonly-close-deployment", + value: MsgCloseDeployment.toAmino(message) + }; + }, + fromProtoMsg(message: MsgCloseDeploymentProtoMsg): MsgCloseDeployment { + return MsgCloseDeployment.decode(message.value); + }, + toProto(message: MsgCloseDeployment): Uint8Array { + return MsgCloseDeployment.encode(message).finish(); + }, + toProtoMsg(message: MsgCloseDeployment): MsgCloseDeploymentProtoMsg { + return { + typeUrl: "/akash.deployment.v1beta2.MsgCloseDeployment", + value: MsgCloseDeployment.encode(message).finish() + }; + } +}; +function createBaseMsgCloseDeploymentResponse(): MsgCloseDeploymentResponse { + return {}; +} +export const MsgCloseDeploymentResponse = { + typeUrl: "/akash.deployment.v1beta2.MsgCloseDeploymentResponse", + encode(_: MsgCloseDeploymentResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgCloseDeploymentResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgCloseDeploymentResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgCloseDeploymentResponse { + const obj = createBaseMsgCloseDeploymentResponse(); + return obj; + }, + toJSON(_: MsgCloseDeploymentResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): MsgCloseDeploymentResponse { + const message = createBaseMsgCloseDeploymentResponse(); + return message; + }, + fromSDK(_: MsgCloseDeploymentResponseSDKType): MsgCloseDeploymentResponse { + return {}; + }, + fromSDKJSON(_: any): MsgCloseDeploymentResponseSDKType { + return {}; + }, + toSDK(_: MsgCloseDeploymentResponse): MsgCloseDeploymentResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgCloseDeploymentResponseAmino): MsgCloseDeploymentResponse { + const message = createBaseMsgCloseDeploymentResponse(); + return message; + }, + toAmino(_: MsgCloseDeploymentResponse): MsgCloseDeploymentResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgCloseDeploymentResponseAminoMsg): MsgCloseDeploymentResponse { + return MsgCloseDeploymentResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgCloseDeploymentResponse): MsgCloseDeploymentResponseAminoMsg { + return { + type: "akash/deployment/v1beta2/testonly-close-deployment-response", + value: MsgCloseDeploymentResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgCloseDeploymentResponseProtoMsg): MsgCloseDeploymentResponse { + return MsgCloseDeploymentResponse.decode(message.value); + }, + toProto(message: MsgCloseDeploymentResponse): Uint8Array { + return MsgCloseDeploymentResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgCloseDeploymentResponse): MsgCloseDeploymentResponseProtoMsg { + return { + typeUrl: "/akash.deployment.v1beta2.MsgCloseDeploymentResponse", + value: MsgCloseDeploymentResponse.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta2/genesis.ts b/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta2/genesis.ts new file mode 100644 index 0000000000..0f45748d43 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta2/genesis.ts @@ -0,0 +1,281 @@ +import { Deployment, DeploymentSDKType } from "./deployment.js"; +import { Group, GroupSDKType } from "./group.js"; +import { Params, ParamsSDKType } from "./params.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial, Exact } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "akash.deployment.v1beta2"; +/** GenesisDeployment defines the basic genesis state used by deployment module */ +export interface GenesisDeployment { + deployment: Deployment; + groups: Group[]; +} +export interface GenesisDeploymentProtoMsg { + typeUrl: "/akash.deployment.v1beta2.GenesisDeployment"; + value: Uint8Array; +} +/** GenesisDeployment defines the basic genesis state used by deployment module */ +export interface GenesisDeploymentSDKType { + deployment: DeploymentSDKType; + groups: GroupSDKType[]; +} +/** GenesisState stores slice of genesis deployment instance */ +export interface GenesisState { + deployments: GenesisDeployment[]; + params: Params; +} +export interface GenesisStateProtoMsg { + typeUrl: "/akash.deployment.v1beta2.GenesisState"; + value: Uint8Array; +} +/** GenesisState stores slice of genesis deployment instance */ +export interface GenesisStateSDKType { + deployments: GenesisDeploymentSDKType[]; + params: ParamsSDKType; +} +function createBaseGenesisDeployment(): GenesisDeployment { + return { + deployment: Deployment.fromPartial({}), + groups: [] + }; +} +export const GenesisDeployment = { + typeUrl: "/akash.deployment.v1beta2.GenesisDeployment", + encode(message: GenesisDeployment, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.deployment !== undefined) { + Deployment.encode(message.deployment, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.groups) { + Group.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GenesisDeployment { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGenesisDeployment(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.deployment = Deployment.decode(reader, reader.uint32()); + break; + case 2: + message.groups.push(Group.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GenesisDeployment { + const obj = createBaseGenesisDeployment(); + if (isSet(object.deployment)) obj.deployment = Deployment.fromJSON(object.deployment); + if (Array.isArray(object?.groups)) obj.groups = object.groups.map((e: any) => Group.fromJSON(e)); + return obj; + }, + toJSON(message: GenesisDeployment): JsonSafe { + const obj: any = {}; + message.deployment !== undefined && (obj.deployment = message.deployment ? Deployment.toJSON(message.deployment) : undefined); + if (message.groups) { + obj.groups = message.groups.map(e => e ? Group.toJSON(e) : undefined); + } else { + obj.groups = []; + } + return obj; + }, + fromPartial, I>>(object: I): GenesisDeployment { + const message = createBaseGenesisDeployment(); + if (object.deployment !== undefined && object.deployment !== null) { + message.deployment = Deployment.fromPartial(object.deployment); + } + message.groups = object.groups?.map(e => Group.fromPartial(e)) || []; + return message; + }, + fromSDK(object: GenesisDeploymentSDKType): GenesisDeployment { + return { + deployment: object.deployment ? Deployment.fromSDK(object.deployment) : undefined, + groups: Array.isArray(object?.groups) ? object.groups.map((e: any) => Group.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): GenesisDeploymentSDKType { + return { + deployment: isSet(object.deployment) ? Deployment.fromSDKJSON(object.deployment) : undefined, + groups: Array.isArray(object?.groups) ? object.groups.map((e: any) => Group.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: GenesisDeployment): GenesisDeploymentSDKType { + const obj: any = {}; + message.deployment !== undefined && (obj.deployment = message.deployment ? Deployment.toSDK(message.deployment) : undefined); + if (message.groups) { + obj.groups = message.groups.map(e => e ? Group.toSDK(e) : undefined); + } else { + obj.groups = []; + } + return obj; + }, + fromAmino(object: GenesisDeploymentAmino): GenesisDeployment { + const message = createBaseGenesisDeployment(); + if (object.deployment !== undefined && object.deployment !== null) { + message.deployment = Deployment.fromAmino(object.deployment); + } + message.groups = object.groups?.map(e => Group.fromAmino(e)) || []; + return message; + }, + toAmino(message: GenesisDeployment): GenesisDeploymentAmino { + const obj: any = {}; + obj.deployment = message.deployment ? Deployment.toAmino(message.deployment) : Deployment.toAmino(Deployment.fromPartial({})); + if (message.groups) { + obj.groups = message.groups.map(e => e ? Group.toAmino(e) : undefined); + } else { + obj.groups = message.groups; + } + return obj; + }, + fromAminoMsg(object: GenesisDeploymentAminoMsg): GenesisDeployment { + return GenesisDeployment.fromAmino(object.value); + }, + toAminoMsg(message: GenesisDeployment): GenesisDeploymentAminoMsg { + return { + type: "akash/deployment/v1beta2/genesis-deployment", + value: GenesisDeployment.toAmino(message) + }; + }, + fromProtoMsg(message: GenesisDeploymentProtoMsg): GenesisDeployment { + return GenesisDeployment.decode(message.value); + }, + toProto(message: GenesisDeployment): Uint8Array { + return GenesisDeployment.encode(message).finish(); + }, + toProtoMsg(message: GenesisDeployment): GenesisDeploymentProtoMsg { + return { + typeUrl: "/akash.deployment.v1beta2.GenesisDeployment", + value: GenesisDeployment.encode(message).finish() + }; + } +}; +function createBaseGenesisState(): GenesisState { + return { + deployments: [], + params: Params.fromPartial({}) + }; +} +export const GenesisState = { + typeUrl: "/akash.deployment.v1beta2.GenesisState", + encode(message: GenesisState, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.deployments) { + GenesisDeployment.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GenesisState { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGenesisState(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.deployments.push(GenesisDeployment.decode(reader, reader.uint32())); + break; + case 2: + message.params = Params.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GenesisState { + const obj = createBaseGenesisState(); + if (Array.isArray(object?.deployments)) obj.deployments = object.deployments.map((e: any) => GenesisDeployment.fromJSON(e)); + if (isSet(object.params)) obj.params = Params.fromJSON(object.params); + return obj; + }, + toJSON(message: GenesisState): JsonSafe { + const obj: any = {}; + if (message.deployments) { + obj.deployments = message.deployments.map(e => e ? GenesisDeployment.toJSON(e) : undefined); + } else { + obj.deployments = []; + } + message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); + return obj; + }, + fromPartial, I>>(object: I): GenesisState { + const message = createBaseGenesisState(); + message.deployments = object.deployments?.map(e => GenesisDeployment.fromPartial(e)) || []; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } + return message; + }, + fromSDK(object: GenesisStateSDKType): GenesisState { + return { + deployments: Array.isArray(object?.deployments) ? object.deployments.map((e: any) => GenesisDeployment.fromSDK(e)) : [], + params: object.params ? Params.fromSDK(object.params) : undefined + }; + }, + fromSDKJSON(object: any): GenesisStateSDKType { + return { + deployments: Array.isArray(object?.deployments) ? object.deployments.map((e: any) => GenesisDeployment.fromSDKJSON(e)) : [], + params: isSet(object.params) ? Params.fromSDKJSON(object.params) : undefined + }; + }, + toSDK(message: GenesisState): GenesisStateSDKType { + const obj: any = {}; + if (message.deployments) { + obj.deployments = message.deployments.map(e => e ? GenesisDeployment.toSDK(e) : undefined); + } else { + obj.deployments = []; + } + message.params !== undefined && (obj.params = message.params ? Params.toSDK(message.params) : undefined); + return obj; + }, + fromAmino(object: GenesisStateAmino): GenesisState { + const message = createBaseGenesisState(); + message.deployments = object.deployments?.map(e => GenesisDeployment.fromAmino(e)) || []; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromAmino(object.params); + } + return message; + }, + toAmino(message: GenesisState): GenesisStateAmino { + const obj: any = {}; + if (message.deployments) { + obj.deployments = message.deployments.map(e => e ? GenesisDeployment.toAmino(e) : undefined); + } else { + obj.deployments = message.deployments; + } + obj.params = message.params ? Params.toAmino(message.params) : Params.toAmino(Params.fromPartial({})); + return obj; + }, + fromAminoMsg(object: GenesisStateAminoMsg): GenesisState { + return GenesisState.fromAmino(object.value); + }, + toAminoMsg(message: GenesisState): GenesisStateAminoMsg { + return { + type: "akash/deployment/v1beta2/genesis-state", + value: GenesisState.toAmino(message) + }; + }, + fromProtoMsg(message: GenesisStateProtoMsg): GenesisState { + return GenesisState.decode(message.value); + }, + toProto(message: GenesisState): Uint8Array { + return GenesisState.encode(message).finish(); + }, + toProtoMsg(message: GenesisState): GenesisStateProtoMsg { + return { + typeUrl: "/akash.deployment.v1beta2.GenesisState", + value: GenesisState.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta2/group.ts b/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta2/group.ts new file mode 100644 index 0000000000..c4c93334e5 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta2/group.ts @@ -0,0 +1,230 @@ +import { GroupID, GroupIDSDKType } from "./groupid.js"; +import { GroupSpec, GroupSpecSDKType } from "./groupspec.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial, Exact } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "akash.deployment.v1beta2"; +/** State is an enum which refers to state of group */ +export enum Group_State { + /** invalid - Prefix should start with 0 in enum. So declaring dummy state */ + invalid = 0, + /** open - GroupOpen denotes state for group open */ + open = 1, + /** paused - GroupOrdered denotes state for group ordered */ + paused = 2, + /** insufficient_funds - GroupInsufficientFunds denotes state for group insufficient_funds */ + insufficient_funds = 3, + /** closed - GroupClosed denotes state for group closed */ + closed = 4, + UNRECOGNIZED = -1, +} +export const Group_StateSDKType = Group_State; +export function group_StateFromJSON(object: any): Group_State { + switch (object) { + case 0: + case "invalid": + return Group_State.invalid; + case 1: + case "open": + return Group_State.open; + case 2: + case "paused": + return Group_State.paused; + case 3: + case "insufficient_funds": + return Group_State.insufficient_funds; + case 4: + case "closed": + return Group_State.closed; + case -1: + case "UNRECOGNIZED": + default: + return Group_State.UNRECOGNIZED; + } +} +export function group_StateToJSON(object: Group_State): string { + switch (object) { + case Group_State.invalid: + return "invalid"; + case Group_State.open: + return "open"; + case Group_State.paused: + return "paused"; + case Group_State.insufficient_funds: + return "insufficient_funds"; + case Group_State.closed: + return "closed"; + case Group_State.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** Group stores group id, state and specifications of group */ +export interface Group { + groupId: GroupID; + state: Group_State; + groupSpec: GroupSpec; + createdAt: bigint; +} +export interface GroupProtoMsg { + typeUrl: "/akash.deployment.v1beta2.Group"; + value: Uint8Array; +} +/** Group stores group id, state and specifications of group */ +export interface GroupSDKType { + group_id: GroupIDSDKType; + state: Group_State; + group_spec: GroupSpecSDKType; + created_at: bigint; +} +function createBaseGroup(): Group { + return { + groupId: GroupID.fromPartial({}), + state: 0, + groupSpec: GroupSpec.fromPartial({}), + createdAt: BigInt(0) + }; +} +export const Group = { + typeUrl: "/akash.deployment.v1beta2.Group", + encode(message: Group, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.groupId !== undefined) { + GroupID.encode(message.groupId, writer.uint32(10).fork()).ldelim(); + } + if (message.state !== 0) { + writer.uint32(16).int32(message.state); + } + if (message.groupSpec !== undefined) { + GroupSpec.encode(message.groupSpec, writer.uint32(26).fork()).ldelim(); + } + if (message.createdAt !== undefined) { + writer.uint32(32).int64(message.createdAt); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Group { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGroup(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.groupId = GroupID.decode(reader, reader.uint32()); + break; + case 2: + message.state = (reader.int32() as any); + break; + case 3: + message.groupSpec = GroupSpec.decode(reader, reader.uint32()); + break; + case 4: + message.createdAt = reader.int64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Group { + const obj = createBaseGroup(); + if (isSet(object.groupId)) obj.groupId = GroupID.fromJSON(object.groupId); + if (isSet(object.state)) obj.state = group_StateFromJSON(object.state); + if (isSet(object.groupSpec)) obj.groupSpec = GroupSpec.fromJSON(object.groupSpec); + if (isSet(object.createdAt)) obj.createdAt = BigInt(object.createdAt.toString()); + return obj; + }, + toJSON(message: Group): JsonSafe { + const obj: any = {}; + message.groupId !== undefined && (obj.groupId = message.groupId ? GroupID.toJSON(message.groupId) : undefined); + message.state !== undefined && (obj.state = group_StateToJSON(message.state)); + message.groupSpec !== undefined && (obj.groupSpec = message.groupSpec ? GroupSpec.toJSON(message.groupSpec) : undefined); + message.createdAt !== undefined && (obj.createdAt = (message.createdAt || BigInt(0)).toString()); + return obj; + }, + fromPartial, I>>(object: I): Group { + const message = createBaseGroup(); + if (object.groupId !== undefined && object.groupId !== null) { + message.groupId = GroupID.fromPartial(object.groupId); + } + message.state = object.state ?? 0; + if (object.groupSpec !== undefined && object.groupSpec !== null) { + message.groupSpec = GroupSpec.fromPartial(object.groupSpec); + } + if (object.createdAt !== undefined && object.createdAt !== null) { + message.createdAt = BigInt(object.createdAt.toString()); + } + return message; + }, + fromSDK(object: GroupSDKType): Group { + return { + groupId: object.group_id ? GroupID.fromSDK(object.group_id) : undefined, + state: isSet(object.state) ? group_StateFromJSON(object.state) : -1, + groupSpec: object.group_spec ? GroupSpec.fromSDK(object.group_spec) : undefined, + createdAt: object?.created_at + }; + }, + fromSDKJSON(object: any): GroupSDKType { + return { + group_id: isSet(object.group_id) ? GroupID.fromSDKJSON(object.group_id) : undefined, + state: isSet(object.state) ? group_StateFromJSON(object.state) : -1, + group_spec: isSet(object.group_spec) ? GroupSpec.fromSDKJSON(object.group_spec) : undefined, + created_at: isSet(object.created_at) ? BigInt(object.created_at.toString()) : BigInt(0) + }; + }, + toSDK(message: Group): GroupSDKType { + const obj: any = {}; + message.groupId !== undefined && (obj.group_id = message.groupId ? GroupID.toSDK(message.groupId) : undefined); + message.state !== undefined && (obj.state = group_StateToJSON(message.state)); + message.groupSpec !== undefined && (obj.group_spec = message.groupSpec ? GroupSpec.toSDK(message.groupSpec) : undefined); + obj.created_at = message.createdAt; + return obj; + }, + fromAmino(object: GroupAmino): Group { + const message = createBaseGroup(); + if (object.group_id !== undefined && object.group_id !== null) { + message.groupId = GroupID.fromAmino(object.group_id); + } + if (object.state !== undefined && object.state !== null) { + message.state = object.state; + } + if (object.group_spec !== undefined && object.group_spec !== null) { + message.groupSpec = GroupSpec.fromAmino(object.group_spec); + } + if (object.created_at !== undefined && object.created_at !== null) { + message.createdAt = BigInt(object.created_at); + } + return message; + }, + toAmino(message: Group): GroupAmino { + const obj: any = {}; + obj.group_id = message.groupId ? GroupID.toAmino(message.groupId) : GroupID.toAmino(GroupID.fromPartial({})); + obj.state = message.state ?? 0; + obj.group_spec = message.groupSpec ? GroupSpec.toAmino(message.groupSpec) : GroupSpec.toAmino(GroupSpec.fromPartial({})); + obj.created_at = message.createdAt !== BigInt(0) ? message.createdAt?.toString() : undefined; + return obj; + }, + fromAminoMsg(object: GroupAminoMsg): Group { + return Group.fromAmino(object.value); + }, + toAminoMsg(message: Group): GroupAminoMsg { + return { + type: "akash/deployment/v1beta2/group", + value: Group.toAmino(message) + }; + }, + fromProtoMsg(message: GroupProtoMsg): Group { + return Group.decode(message.value); + }, + toProto(message: Group): Uint8Array { + return Group.encode(message).finish(); + }, + toProtoMsg(message: Group): GroupProtoMsg { + return { + typeUrl: "/akash.deployment.v1beta2.Group", + value: Group.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta2/groupid.ts b/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta2/groupid.ts new file mode 100644 index 0000000000..7fc3b96ad9 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta2/groupid.ts @@ -0,0 +1,150 @@ +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial, Exact } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "akash.deployment.v1beta2"; +/** GroupID stores owner, deployment sequence number and group sequence number */ +export interface GroupID { + owner: string; + dseq: bigint; + gseq: number; +} +export interface GroupIDProtoMsg { + typeUrl: "/akash.deployment.v1beta2.GroupID"; + value: Uint8Array; +} +/** GroupID stores owner, deployment sequence number and group sequence number */ +export interface GroupIDSDKType { + owner: string; + dseq: bigint; + gseq: number; +} +function createBaseGroupID(): GroupID { + return { + owner: "", + dseq: BigInt(0), + gseq: 0 + }; +} +export const GroupID = { + typeUrl: "/akash.deployment.v1beta2.GroupID", + encode(message: GroupID, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.owner !== undefined) { + writer.uint32(10).string(message.owner); + } + if (message.dseq !== undefined) { + writer.uint32(16).uint64(message.dseq); + } + if (message.gseq !== undefined) { + writer.uint32(24).uint32(message.gseq); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GroupID { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGroupID(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.owner = reader.string(); + break; + case 2: + message.dseq = reader.uint64(); + break; + case 3: + message.gseq = reader.uint32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GroupID { + const obj = createBaseGroupID(); + if (isSet(object.owner)) obj.owner = String(object.owner); + if (isSet(object.dseq)) obj.dseq = BigInt(object.dseq.toString()); + if (isSet(object.gseq)) obj.gseq = Number(object.gseq); + return obj; + }, + toJSON(message: GroupID): JsonSafe { + const obj: any = {}; + message.owner !== undefined && (obj.owner = message.owner); + message.dseq !== undefined && (obj.dseq = (message.dseq || BigInt(0)).toString()); + message.gseq !== undefined && (obj.gseq = Math.round(message.gseq)); + return obj; + }, + fromPartial, I>>(object: I): GroupID { + const message = createBaseGroupID(); + message.owner = object.owner ?? ""; + if (object.dseq !== undefined && object.dseq !== null) { + message.dseq = BigInt(object.dseq.toString()); + } + message.gseq = object.gseq ?? 0; + return message; + }, + fromSDK(object: GroupIDSDKType): GroupID { + return { + owner: object?.owner, + dseq: object?.dseq, + gseq: object?.gseq + }; + }, + fromSDKJSON(object: any): GroupIDSDKType { + return { + owner: isSet(object.owner) ? String(object.owner) : "", + dseq: isSet(object.dseq) ? BigInt(object.dseq.toString()) : BigInt(0), + gseq: isSet(object.gseq) ? Number(object.gseq) : 0 + }; + }, + toSDK(message: GroupID): GroupIDSDKType { + const obj: any = {}; + obj.owner = message.owner; + obj.dseq = message.dseq; + obj.gseq = message.gseq; + return obj; + }, + fromAmino(object: GroupIDAmino): GroupID { + const message = createBaseGroupID(); + if (object.owner !== undefined && object.owner !== null) { + message.owner = object.owner; + } + if (object.dseq !== undefined && object.dseq !== null) { + message.dseq = BigInt(object.dseq); + } + if (object.gseq !== undefined && object.gseq !== null) { + message.gseq = object.gseq; + } + return message; + }, + toAmino(message: GroupID): GroupIDAmino { + const obj: any = {}; + obj.owner = message.owner ?? ""; + obj.dseq = message.dseq ? message.dseq?.toString() : "0"; + obj.gseq = message.gseq ?? 0; + return obj; + }, + fromAminoMsg(object: GroupIDAminoMsg): GroupID { + return GroupID.fromAmino(object.value); + }, + toAminoMsg(message: GroupID): GroupIDAminoMsg { + return { + type: "akash/deployment/v1beta2/group-i-d", + value: GroupID.toAmino(message) + }; + }, + fromProtoMsg(message: GroupIDProtoMsg): GroupID { + return GroupID.decode(message.value); + }, + toProto(message: GroupID): Uint8Array { + return GroupID.encode(message).finish(); + }, + toProtoMsg(message: GroupID): GroupIDProtoMsg { + return { + typeUrl: "/akash.deployment.v1beta2.GroupID", + value: GroupID.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta2/groupmsg.ts b/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta2/groupmsg.ts new file mode 100644 index 0000000000..f6e5c96efb --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta2/groupmsg.ts @@ -0,0 +1,575 @@ +import { GroupID, GroupIDSDKType } from "./groupid.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial, Exact } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "akash.deployment.v1beta2"; +/** MsgCloseGroup defines SDK message to close a single Group within a Deployment. */ +export interface MsgCloseGroup { + id: GroupID; +} +export interface MsgCloseGroupProtoMsg { + typeUrl: "/akash.deployment.v1beta2.MsgCloseGroup"; + value: Uint8Array; +} +/** MsgCloseGroup defines SDK message to close a single Group within a Deployment. */ +export interface MsgCloseGroupSDKType { + id: GroupIDSDKType; +} +/** MsgCloseGroupResponse defines the Msg/CloseGroup response type. */ +export interface MsgCloseGroupResponse {} +export interface MsgCloseGroupResponseProtoMsg { + typeUrl: "/akash.deployment.v1beta2.MsgCloseGroupResponse"; + value: Uint8Array; +} +/** MsgCloseGroupResponse defines the Msg/CloseGroup response type. */ +export interface MsgCloseGroupResponseSDKType {} +/** MsgPauseGroup defines SDK message to close a single Group within a Deployment. */ +export interface MsgPauseGroup { + id: GroupID; +} +export interface MsgPauseGroupProtoMsg { + typeUrl: "/akash.deployment.v1beta2.MsgPauseGroup"; + value: Uint8Array; +} +/** MsgPauseGroup defines SDK message to close a single Group within a Deployment. */ +export interface MsgPauseGroupSDKType { + id: GroupIDSDKType; +} +/** MsgPauseGroupResponse defines the Msg/PauseGroup response type. */ +export interface MsgPauseGroupResponse {} +export interface MsgPauseGroupResponseProtoMsg { + typeUrl: "/akash.deployment.v1beta2.MsgPauseGroupResponse"; + value: Uint8Array; +} +/** MsgPauseGroupResponse defines the Msg/PauseGroup response type. */ +export interface MsgPauseGroupResponseSDKType {} +/** MsgStartGroup defines SDK message to close a single Group within a Deployment. */ +export interface MsgStartGroup { + id: GroupID; +} +export interface MsgStartGroupProtoMsg { + typeUrl: "/akash.deployment.v1beta2.MsgStartGroup"; + value: Uint8Array; +} +/** MsgStartGroup defines SDK message to close a single Group within a Deployment. */ +export interface MsgStartGroupSDKType { + id: GroupIDSDKType; +} +/** MsgStartGroupResponse defines the Msg/StartGroup response type. */ +export interface MsgStartGroupResponse {} +export interface MsgStartGroupResponseProtoMsg { + typeUrl: "/akash.deployment.v1beta2.MsgStartGroupResponse"; + value: Uint8Array; +} +/** MsgStartGroupResponse defines the Msg/StartGroup response type. */ +export interface MsgStartGroupResponseSDKType {} +function createBaseMsgCloseGroup(): MsgCloseGroup { + return { + id: GroupID.fromPartial({}) + }; +} +export const MsgCloseGroup = { + typeUrl: "/akash.deployment.v1beta2.MsgCloseGroup", + encode(message: MsgCloseGroup, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.id !== undefined) { + GroupID.encode(message.id, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgCloseGroup { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgCloseGroup(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.id = GroupID.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgCloseGroup { + const obj = createBaseMsgCloseGroup(); + if (isSet(object.id)) obj.id = GroupID.fromJSON(object.id); + return obj; + }, + toJSON(message: MsgCloseGroup): JsonSafe { + const obj: any = {}; + message.id !== undefined && (obj.id = message.id ? GroupID.toJSON(message.id) : undefined); + return obj; + }, + fromPartial, I>>(object: I): MsgCloseGroup { + const message = createBaseMsgCloseGroup(); + if (object.id !== undefined && object.id !== null) { + message.id = GroupID.fromPartial(object.id); + } + return message; + }, + fromSDK(object: MsgCloseGroupSDKType): MsgCloseGroup { + return { + id: object.id ? GroupID.fromSDK(object.id) : undefined + }; + }, + fromSDKJSON(object: any): MsgCloseGroupSDKType { + return { + id: isSet(object.id) ? GroupID.fromSDKJSON(object.id) : undefined + }; + }, + toSDK(message: MsgCloseGroup): MsgCloseGroupSDKType { + const obj: any = {}; + message.id !== undefined && (obj.id = message.id ? GroupID.toSDK(message.id) : undefined); + return obj; + }, + fromAmino(object: MsgCloseGroupAmino): MsgCloseGroup { + const message = createBaseMsgCloseGroup(); + if (object.id !== undefined && object.id !== null) { + message.id = GroupID.fromAmino(object.id); + } + return message; + }, + toAmino(message: MsgCloseGroup): MsgCloseGroupAmino { + const obj: any = {}; + obj.id = message.id ? GroupID.toAmino(message.id) : GroupID.toAmino(GroupID.fromPartial({})); + return obj; + }, + fromAminoMsg(object: MsgCloseGroupAminoMsg): MsgCloseGroup { + return MsgCloseGroup.fromAmino(object.value); + }, + toAminoMsg(message: MsgCloseGroup): MsgCloseGroupAminoMsg { + return { + type: "akash/deployment/v1beta2/testonly-close-group", + value: MsgCloseGroup.toAmino(message) + }; + }, + fromProtoMsg(message: MsgCloseGroupProtoMsg): MsgCloseGroup { + return MsgCloseGroup.decode(message.value); + }, + toProto(message: MsgCloseGroup): Uint8Array { + return MsgCloseGroup.encode(message).finish(); + }, + toProtoMsg(message: MsgCloseGroup): MsgCloseGroupProtoMsg { + return { + typeUrl: "/akash.deployment.v1beta2.MsgCloseGroup", + value: MsgCloseGroup.encode(message).finish() + }; + } +}; +function createBaseMsgCloseGroupResponse(): MsgCloseGroupResponse { + return {}; +} +export const MsgCloseGroupResponse = { + typeUrl: "/akash.deployment.v1beta2.MsgCloseGroupResponse", + encode(_: MsgCloseGroupResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgCloseGroupResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgCloseGroupResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgCloseGroupResponse { + const obj = createBaseMsgCloseGroupResponse(); + return obj; + }, + toJSON(_: MsgCloseGroupResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): MsgCloseGroupResponse { + const message = createBaseMsgCloseGroupResponse(); + return message; + }, + fromSDK(_: MsgCloseGroupResponseSDKType): MsgCloseGroupResponse { + return {}; + }, + fromSDKJSON(_: any): MsgCloseGroupResponseSDKType { + return {}; + }, + toSDK(_: MsgCloseGroupResponse): MsgCloseGroupResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgCloseGroupResponseAmino): MsgCloseGroupResponse { + const message = createBaseMsgCloseGroupResponse(); + return message; + }, + toAmino(_: MsgCloseGroupResponse): MsgCloseGroupResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgCloseGroupResponseAminoMsg): MsgCloseGroupResponse { + return MsgCloseGroupResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgCloseGroupResponse): MsgCloseGroupResponseAminoMsg { + return { + type: "akash/deployment/v1beta2/testonly-close-group-response", + value: MsgCloseGroupResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgCloseGroupResponseProtoMsg): MsgCloseGroupResponse { + return MsgCloseGroupResponse.decode(message.value); + }, + toProto(message: MsgCloseGroupResponse): Uint8Array { + return MsgCloseGroupResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgCloseGroupResponse): MsgCloseGroupResponseProtoMsg { + return { + typeUrl: "/akash.deployment.v1beta2.MsgCloseGroupResponse", + value: MsgCloseGroupResponse.encode(message).finish() + }; + } +}; +function createBaseMsgPauseGroup(): MsgPauseGroup { + return { + id: GroupID.fromPartial({}) + }; +} +export const MsgPauseGroup = { + typeUrl: "/akash.deployment.v1beta2.MsgPauseGroup", + encode(message: MsgPauseGroup, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.id !== undefined) { + GroupID.encode(message.id, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgPauseGroup { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgPauseGroup(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.id = GroupID.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgPauseGroup { + const obj = createBaseMsgPauseGroup(); + if (isSet(object.id)) obj.id = GroupID.fromJSON(object.id); + return obj; + }, + toJSON(message: MsgPauseGroup): JsonSafe { + const obj: any = {}; + message.id !== undefined && (obj.id = message.id ? GroupID.toJSON(message.id) : undefined); + return obj; + }, + fromPartial, I>>(object: I): MsgPauseGroup { + const message = createBaseMsgPauseGroup(); + if (object.id !== undefined && object.id !== null) { + message.id = GroupID.fromPartial(object.id); + } + return message; + }, + fromSDK(object: MsgPauseGroupSDKType): MsgPauseGroup { + return { + id: object.id ? GroupID.fromSDK(object.id) : undefined + }; + }, + fromSDKJSON(object: any): MsgPauseGroupSDKType { + return { + id: isSet(object.id) ? GroupID.fromSDKJSON(object.id) : undefined + }; + }, + toSDK(message: MsgPauseGroup): MsgPauseGroupSDKType { + const obj: any = {}; + message.id !== undefined && (obj.id = message.id ? GroupID.toSDK(message.id) : undefined); + return obj; + }, + fromAmino(object: MsgPauseGroupAmino): MsgPauseGroup { + const message = createBaseMsgPauseGroup(); + if (object.id !== undefined && object.id !== null) { + message.id = GroupID.fromAmino(object.id); + } + return message; + }, + toAmino(message: MsgPauseGroup): MsgPauseGroupAmino { + const obj: any = {}; + obj.id = message.id ? GroupID.toAmino(message.id) : GroupID.toAmino(GroupID.fromPartial({})); + return obj; + }, + fromAminoMsg(object: MsgPauseGroupAminoMsg): MsgPauseGroup { + return MsgPauseGroup.fromAmino(object.value); + }, + toAminoMsg(message: MsgPauseGroup): MsgPauseGroupAminoMsg { + return { + type: "akash/deployment/v1beta2/testonly-pause-group", + value: MsgPauseGroup.toAmino(message) + }; + }, + fromProtoMsg(message: MsgPauseGroupProtoMsg): MsgPauseGroup { + return MsgPauseGroup.decode(message.value); + }, + toProto(message: MsgPauseGroup): Uint8Array { + return MsgPauseGroup.encode(message).finish(); + }, + toProtoMsg(message: MsgPauseGroup): MsgPauseGroupProtoMsg { + return { + typeUrl: "/akash.deployment.v1beta2.MsgPauseGroup", + value: MsgPauseGroup.encode(message).finish() + }; + } +}; +function createBaseMsgPauseGroupResponse(): MsgPauseGroupResponse { + return {}; +} +export const MsgPauseGroupResponse = { + typeUrl: "/akash.deployment.v1beta2.MsgPauseGroupResponse", + encode(_: MsgPauseGroupResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgPauseGroupResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgPauseGroupResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgPauseGroupResponse { + const obj = createBaseMsgPauseGroupResponse(); + return obj; + }, + toJSON(_: MsgPauseGroupResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): MsgPauseGroupResponse { + const message = createBaseMsgPauseGroupResponse(); + return message; + }, + fromSDK(_: MsgPauseGroupResponseSDKType): MsgPauseGroupResponse { + return {}; + }, + fromSDKJSON(_: any): MsgPauseGroupResponseSDKType { + return {}; + }, + toSDK(_: MsgPauseGroupResponse): MsgPauseGroupResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgPauseGroupResponseAmino): MsgPauseGroupResponse { + const message = createBaseMsgPauseGroupResponse(); + return message; + }, + toAmino(_: MsgPauseGroupResponse): MsgPauseGroupResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgPauseGroupResponseAminoMsg): MsgPauseGroupResponse { + return MsgPauseGroupResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgPauseGroupResponse): MsgPauseGroupResponseAminoMsg { + return { + type: "akash/deployment/v1beta2/testonly-pause-group-response", + value: MsgPauseGroupResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgPauseGroupResponseProtoMsg): MsgPauseGroupResponse { + return MsgPauseGroupResponse.decode(message.value); + }, + toProto(message: MsgPauseGroupResponse): Uint8Array { + return MsgPauseGroupResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgPauseGroupResponse): MsgPauseGroupResponseProtoMsg { + return { + typeUrl: "/akash.deployment.v1beta2.MsgPauseGroupResponse", + value: MsgPauseGroupResponse.encode(message).finish() + }; + } +}; +function createBaseMsgStartGroup(): MsgStartGroup { + return { + id: GroupID.fromPartial({}) + }; +} +export const MsgStartGroup = { + typeUrl: "/akash.deployment.v1beta2.MsgStartGroup", + encode(message: MsgStartGroup, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.id !== undefined) { + GroupID.encode(message.id, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgStartGroup { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgStartGroup(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.id = GroupID.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgStartGroup { + const obj = createBaseMsgStartGroup(); + if (isSet(object.id)) obj.id = GroupID.fromJSON(object.id); + return obj; + }, + toJSON(message: MsgStartGroup): JsonSafe { + const obj: any = {}; + message.id !== undefined && (obj.id = message.id ? GroupID.toJSON(message.id) : undefined); + return obj; + }, + fromPartial, I>>(object: I): MsgStartGroup { + const message = createBaseMsgStartGroup(); + if (object.id !== undefined && object.id !== null) { + message.id = GroupID.fromPartial(object.id); + } + return message; + }, + fromSDK(object: MsgStartGroupSDKType): MsgStartGroup { + return { + id: object.id ? GroupID.fromSDK(object.id) : undefined + }; + }, + fromSDKJSON(object: any): MsgStartGroupSDKType { + return { + id: isSet(object.id) ? GroupID.fromSDKJSON(object.id) : undefined + }; + }, + toSDK(message: MsgStartGroup): MsgStartGroupSDKType { + const obj: any = {}; + message.id !== undefined && (obj.id = message.id ? GroupID.toSDK(message.id) : undefined); + return obj; + }, + fromAmino(object: MsgStartGroupAmino): MsgStartGroup { + const message = createBaseMsgStartGroup(); + if (object.id !== undefined && object.id !== null) { + message.id = GroupID.fromAmino(object.id); + } + return message; + }, + toAmino(message: MsgStartGroup): MsgStartGroupAmino { + const obj: any = {}; + obj.id = message.id ? GroupID.toAmino(message.id) : GroupID.toAmino(GroupID.fromPartial({})); + return obj; + }, + fromAminoMsg(object: MsgStartGroupAminoMsg): MsgStartGroup { + return MsgStartGroup.fromAmino(object.value); + }, + toAminoMsg(message: MsgStartGroup): MsgStartGroupAminoMsg { + return { + type: "akash/deployment/v1beta2/testonly-start-group", + value: MsgStartGroup.toAmino(message) + }; + }, + fromProtoMsg(message: MsgStartGroupProtoMsg): MsgStartGroup { + return MsgStartGroup.decode(message.value); + }, + toProto(message: MsgStartGroup): Uint8Array { + return MsgStartGroup.encode(message).finish(); + }, + toProtoMsg(message: MsgStartGroup): MsgStartGroupProtoMsg { + return { + typeUrl: "/akash.deployment.v1beta2.MsgStartGroup", + value: MsgStartGroup.encode(message).finish() + }; + } +}; +function createBaseMsgStartGroupResponse(): MsgStartGroupResponse { + return {}; +} +export const MsgStartGroupResponse = { + typeUrl: "/akash.deployment.v1beta2.MsgStartGroupResponse", + encode(_: MsgStartGroupResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgStartGroupResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgStartGroupResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgStartGroupResponse { + const obj = createBaseMsgStartGroupResponse(); + return obj; + }, + toJSON(_: MsgStartGroupResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): MsgStartGroupResponse { + const message = createBaseMsgStartGroupResponse(); + return message; + }, + fromSDK(_: MsgStartGroupResponseSDKType): MsgStartGroupResponse { + return {}; + }, + fromSDKJSON(_: any): MsgStartGroupResponseSDKType { + return {}; + }, + toSDK(_: MsgStartGroupResponse): MsgStartGroupResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgStartGroupResponseAmino): MsgStartGroupResponse { + const message = createBaseMsgStartGroupResponse(); + return message; + }, + toAmino(_: MsgStartGroupResponse): MsgStartGroupResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgStartGroupResponseAminoMsg): MsgStartGroupResponse { + return MsgStartGroupResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgStartGroupResponse): MsgStartGroupResponseAminoMsg { + return { + type: "akash/deployment/v1beta2/testonly-start-group-response", + value: MsgStartGroupResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgStartGroupResponseProtoMsg): MsgStartGroupResponse { + return MsgStartGroupResponse.decode(message.value); + }, + toProto(message: MsgStartGroupResponse): Uint8Array { + return MsgStartGroupResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgStartGroupResponse): MsgStartGroupResponseProtoMsg { + return { + typeUrl: "/akash.deployment.v1beta2.MsgStartGroupResponse", + value: MsgStartGroupResponse.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta2/groupspec.ts b/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta2/groupspec.ts new file mode 100644 index 0000000000..88e3b3c3ba --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta2/groupspec.ts @@ -0,0 +1,162 @@ +import { PlacementRequirements, PlacementRequirementsSDKType } from "../../base/v1beta2/attribute.js"; +import { Resource, ResourceSDKType } from "./resource.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial, Exact } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "akash.deployment.v1beta2"; +/** GroupSpec stores group specifications */ +export interface GroupSpec { + name: string; + requirements: PlacementRequirements; + resources: Resource[]; +} +export interface GroupSpecProtoMsg { + typeUrl: "/akash.deployment.v1beta2.GroupSpec"; + value: Uint8Array; +} +/** GroupSpec stores group specifications */ +export interface GroupSpecSDKType { + name: string; + requirements: PlacementRequirementsSDKType; + resources: ResourceSDKType[]; +} +function createBaseGroupSpec(): GroupSpec { + return { + name: "", + requirements: PlacementRequirements.fromPartial({}), + resources: [] + }; +} +export const GroupSpec = { + typeUrl: "/akash.deployment.v1beta2.GroupSpec", + encode(message: GroupSpec, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + if (message.requirements !== undefined) { + PlacementRequirements.encode(message.requirements, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.resources) { + Resource.encode(v!, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GroupSpec { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGroupSpec(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.requirements = PlacementRequirements.decode(reader, reader.uint32()); + break; + case 3: + message.resources.push(Resource.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GroupSpec { + const obj = createBaseGroupSpec(); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.requirements)) obj.requirements = PlacementRequirements.fromJSON(object.requirements); + if (Array.isArray(object?.resources)) obj.resources = object.resources.map((e: any) => Resource.fromJSON(e)); + return obj; + }, + toJSON(message: GroupSpec): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.requirements !== undefined && (obj.requirements = message.requirements ? PlacementRequirements.toJSON(message.requirements) : undefined); + if (message.resources) { + obj.resources = message.resources.map(e => e ? Resource.toJSON(e) : undefined); + } else { + obj.resources = []; + } + return obj; + }, + fromPartial, I>>(object: I): GroupSpec { + const message = createBaseGroupSpec(); + message.name = object.name ?? ""; + if (object.requirements !== undefined && object.requirements !== null) { + message.requirements = PlacementRequirements.fromPartial(object.requirements); + } + message.resources = object.resources?.map(e => Resource.fromPartial(e)) || []; + return message; + }, + fromSDK(object: GroupSpecSDKType): GroupSpec { + return { + name: object?.name, + requirements: object.requirements ? PlacementRequirements.fromSDK(object.requirements) : undefined, + resources: Array.isArray(object?.resources) ? object.resources.map((e: any) => Resource.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): GroupSpecSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + requirements: isSet(object.requirements) ? PlacementRequirements.fromSDKJSON(object.requirements) : undefined, + resources: Array.isArray(object?.resources) ? object.resources.map((e: any) => Resource.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: GroupSpec): GroupSpecSDKType { + const obj: any = {}; + obj.name = message.name; + message.requirements !== undefined && (obj.requirements = message.requirements ? PlacementRequirements.toSDK(message.requirements) : undefined); + if (message.resources) { + obj.resources = message.resources.map(e => e ? Resource.toSDK(e) : undefined); + } else { + obj.resources = []; + } + return obj; + }, + fromAmino(object: GroupSpecAmino): GroupSpec { + const message = createBaseGroupSpec(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + if (object.requirements !== undefined && object.requirements !== null) { + message.requirements = PlacementRequirements.fromAmino(object.requirements); + } + message.resources = object.resources?.map(e => Resource.fromAmino(e)) || []; + return message; + }, + toAmino(message: GroupSpec): GroupSpecAmino { + const obj: any = {}; + obj.name = message.name ?? ""; + obj.requirements = message.requirements ? PlacementRequirements.toAmino(message.requirements) : PlacementRequirements.toAmino(PlacementRequirements.fromPartial({})); + if (message.resources) { + obj.resources = message.resources.map(e => e ? Resource.toAmino(e) : undefined); + } else { + obj.resources = message.resources; + } + return obj; + }, + fromAminoMsg(object: GroupSpecAminoMsg): GroupSpec { + return GroupSpec.fromAmino(object.value); + }, + toAminoMsg(message: GroupSpec): GroupSpecAminoMsg { + return { + type: "akash/deployment/v1beta2/group-spec", + value: GroupSpec.toAmino(message) + }; + }, + fromProtoMsg(message: GroupSpecProtoMsg): GroupSpec { + return GroupSpec.decode(message.value); + }, + toProto(message: GroupSpec): Uint8Array { + return GroupSpec.encode(message).finish(); + }, + toProtoMsg(message: GroupSpec): GroupSpecProtoMsg { + return { + typeUrl: "/akash.deployment.v1beta2.GroupSpec", + value: GroupSpec.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta2/params.ts b/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta2/params.ts new file mode 100644 index 0000000000..c80222742a --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta2/params.ts @@ -0,0 +1,113 @@ +import { Coin, CoinSDKType } from "../../../cosmos/base/v1beta1/coin.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial, Exact } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "akash.deployment.v1beta2"; +/** Params defines the parameters for the x/deployment package */ +export interface Params { + deploymentMinDeposit: Coin; +} +export interface ParamsProtoMsg { + typeUrl: "/akash.deployment.v1beta2.Params"; + value: Uint8Array; +} +/** Params defines the parameters for the x/deployment package */ +export interface ParamsSDKType { + deployment_min_deposit: CoinSDKType; +} +function createBaseParams(): Params { + return { + deploymentMinDeposit: Coin.fromPartial({}) + }; +} +export const Params = { + typeUrl: "/akash.deployment.v1beta2.Params", + encode(message: Params, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.deploymentMinDeposit !== undefined) { + Coin.encode(message.deploymentMinDeposit, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Params { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseParams(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.deploymentMinDeposit = Coin.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Params { + const obj = createBaseParams(); + if (isSet(object.deploymentMinDeposit)) obj.deploymentMinDeposit = Coin.fromJSON(object.deploymentMinDeposit); + return obj; + }, + toJSON(message: Params): JsonSafe { + const obj: any = {}; + message.deploymentMinDeposit !== undefined && (obj.deploymentMinDeposit = message.deploymentMinDeposit ? Coin.toJSON(message.deploymentMinDeposit) : undefined); + return obj; + }, + fromPartial, I>>(object: I): Params { + const message = createBaseParams(); + if (object.deploymentMinDeposit !== undefined && object.deploymentMinDeposit !== null) { + message.deploymentMinDeposit = Coin.fromPartial(object.deploymentMinDeposit); + } + return message; + }, + fromSDK(object: ParamsSDKType): Params { + return { + deploymentMinDeposit: object.deployment_min_deposit ? Coin.fromSDK(object.deployment_min_deposit) : undefined + }; + }, + fromSDKJSON(object: any): ParamsSDKType { + return { + deployment_min_deposit: isSet(object.deployment_min_deposit) ? Coin.fromSDKJSON(object.deployment_min_deposit) : undefined + }; + }, + toSDK(message: Params): ParamsSDKType { + const obj: any = {}; + message.deploymentMinDeposit !== undefined && (obj.deployment_min_deposit = message.deploymentMinDeposit ? Coin.toSDK(message.deploymentMinDeposit) : undefined); + return obj; + }, + fromAmino(object: ParamsAmino): Params { + const message = createBaseParams(); + if (object.deployment_min_deposit !== undefined && object.deployment_min_deposit !== null) { + message.deploymentMinDeposit = Coin.fromAmino(object.deployment_min_deposit); + } + return message; + }, + toAmino(message: Params): ParamsAmino { + const obj: any = {}; + obj.deployment_min_deposit = message.deploymentMinDeposit ? Coin.toAmino(message.deploymentMinDeposit) : Coin.toAmino(Coin.fromPartial({})); + return obj; + }, + fromAminoMsg(object: ParamsAminoMsg): Params { + return Params.fromAmino(object.value); + }, + toAminoMsg(message: Params): ParamsAminoMsg { + return { + type: "akash/deployment/v1beta2/params", + value: Params.toAmino(message) + }; + }, + fromProtoMsg(message: ParamsProtoMsg): Params { + return Params.decode(message.value); + }, + toProto(message: Params): Uint8Array { + return Params.encode(message).finish(); + }, + toProtoMsg(message: Params): ParamsProtoMsg { + return { + typeUrl: "/akash.deployment.v1beta2.Params", + value: Params.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta2/query.lcd.ts b/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta2/query.lcd.ts new file mode 100644 index 0000000000..8d0d534caf --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta2/query.lcd.ts @@ -0,0 +1,54 @@ +import { DeploymentFilters, DeploymentFiltersSDKType, DeploymentID, DeploymentIDSDKType, Deployment, DeploymentSDKType } from "./deployment.js"; +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../../cosmos/base/query/v1beta1/pagination.js"; +import { GroupID, GroupIDSDKType } from "./groupid.js"; +import { Group, GroupSDKType } from "./group.js"; +import { Account, AccountSDKType } from "../../escrow/v1beta2/types.js"; +import { setPaginationParams } from "../../../helpers.js"; +import { LCDClient } from "@cosmology/lcd"; +import { QueryDeploymentsRequest, QueryDeploymentsRequestSDKType, QueryDeploymentsResponse, QueryDeploymentsResponseSDKType, QueryDeploymentRequest, QueryDeploymentRequestSDKType, QueryDeploymentResponse, QueryDeploymentResponseSDKType, QueryGroupRequest, QueryGroupRequestSDKType, QueryGroupResponse, QueryGroupResponseSDKType } from "./query.js"; +export class LCDQueryClient { + req: LCDClient; + constructor({ + requestClient + }: { + requestClient: LCDClient; + }) { + this.req = requestClient; + } + /* Deployments queries deployments */ + deployments = async (params: QueryDeploymentsRequest): Promise => { + const options: any = { + params: {} + }; + if (typeof params?.filters !== "undefined") { + options.params.filters = params.filters; + } + if (typeof params?.pagination !== "undefined") { + setPaginationParams(options, params.pagination); + } + const endpoint = `akash/deployment/v1beta2/deployments/list`; + return QueryDeploymentsResponse.fromSDKJSON(await this.req.get(endpoint, options)); + }; + /* Deployment queries deployment details */ + deployment = async (params: QueryDeploymentRequest): Promise => { + const options: any = { + params: {} + }; + if (typeof params?.id !== "undefined") { + options.params.id = params.id; + } + const endpoint = `akash/deployment/v1beta2/deployments/info`; + return QueryDeploymentResponse.fromSDKJSON(await this.req.get(endpoint, options)); + }; + /* Group queries group details */ + group = async (params: QueryGroupRequest): Promise => { + const options: any = { + params: {} + }; + if (typeof params?.id !== "undefined") { + options.params.id = params.id; + } + const endpoint = `akash/deployment/v1beta2/groups/info`; + return QueryGroupResponse.fromSDKJSON(await this.req.get(endpoint, options)); + }; +} \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta2/query.rpc.Query.ts b/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta2/query.rpc.Query.ts new file mode 100644 index 0000000000..8f46132593 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta2/query.rpc.Query.ts @@ -0,0 +1,57 @@ +import { DeploymentFilters, DeploymentFiltersSDKType, DeploymentID, DeploymentIDSDKType, Deployment, DeploymentSDKType } from "./deployment.js"; +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../../cosmos/base/query/v1beta1/pagination.js"; +import { GroupID, GroupIDSDKType } from "./groupid.js"; +import { Group, GroupSDKType } from "./group.js"; +import { Account, AccountSDKType } from "../../escrow/v1beta2/types.js"; +import { Rpc } from "../../../helpers.js"; +import { BinaryReader } from "../../../binary.js"; +import { QueryClient, createProtobufRpcClient } from "@cosmjs/stargate"; +import { QueryDeploymentsRequest, QueryDeploymentsRequestSDKType, QueryDeploymentsResponse, QueryDeploymentsResponseSDKType, QueryDeploymentRequest, QueryDeploymentRequestSDKType, QueryDeploymentResponse, QueryDeploymentResponseSDKType, QueryGroupRequest, QueryGroupRequestSDKType, QueryGroupResponse, QueryGroupResponseSDKType } from "./query.js"; +/** Query defines the gRPC querier service */ +export interface Query { + /** Deployments queries deployments */ + deployments(request: QueryDeploymentsRequest): Promise; + /** Deployment queries deployment details */ + deployment(request: QueryDeploymentRequest): Promise; + /** Group queries group details */ + group(request: QueryGroupRequest): Promise; +} +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + } + /* Deployments queries deployments */ + deployments = async (request: QueryDeploymentsRequest): Promise => { + const data = QueryDeploymentsRequest.encode(request).finish(); + const promise = this.rpc.request("akash.deployment.v1beta2.Query", "Deployments", data); + return promise.then(data => QueryDeploymentsResponse.decode(new BinaryReader(data))); + }; + /* Deployment queries deployment details */ + deployment = async (request: QueryDeploymentRequest): Promise => { + const data = QueryDeploymentRequest.encode(request).finish(); + const promise = this.rpc.request("akash.deployment.v1beta2.Query", "Deployment", data); + return promise.then(data => QueryDeploymentResponse.decode(new BinaryReader(data))); + }; + /* Group queries group details */ + group = async (request: QueryGroupRequest): Promise => { + const data = QueryGroupRequest.encode(request).finish(); + const promise = this.rpc.request("akash.deployment.v1beta2.Query", "Group", data); + return promise.then(data => QueryGroupResponse.decode(new BinaryReader(data))); + }; +} +export const createRpcQueryExtension = (base: QueryClient) => { + const rpc = createProtobufRpcClient(base); + const queryService = new QueryClientImpl(rpc); + return { + deployments(request: QueryDeploymentsRequest): Promise { + return queryService.deployments(request); + }, + deployment(request: QueryDeploymentRequest): Promise { + return queryService.deployment(request); + }, + group(request: QueryGroupRequest): Promise { + return queryService.group(request); + } + }; +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta2/query.rpc.func.ts b/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta2/query.rpc.func.ts new file mode 100644 index 0000000000..01524ac05b --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta2/query.rpc.func.ts @@ -0,0 +1,36 @@ +import { RpcResolver, buildQuery } from "../../../helper-func-types"; +import { buildUseQuery } from "../../../react-query"; +import { QueryDeploymentsRequest, QueryDeploymentsResponse, QueryDeploymentRequest, QueryDeploymentResponse, QueryGroupRequest, QueryGroupResponse } from "./query"; +export const createGetDeployments = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryDeploymentsRequest.encode, + decode: QueryDeploymentsResponse.decode, + service: "akash.deployment.v1beta2.Query", + method: "Deployments", + getRpcInstance: getRpcInstance +}); +export const useGetDeployments = buildUseQuery({ + builderQueryFn: createGetDeployments, + queryKeyPrefix: "DeploymentsQuery" +}); +export const createGetDeployment = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryDeploymentRequest.encode, + decode: QueryDeploymentResponse.decode, + service: "akash.deployment.v1beta2.Query", + method: "Deployment", + getRpcInstance: getRpcInstance +}); +export const useGetDeployment = buildUseQuery({ + builderQueryFn: createGetDeployment, + queryKeyPrefix: "DeploymentQuery" +}); +export const createGetGroup = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryGroupRequest.encode, + decode: QueryGroupResponse.decode, + service: "akash.deployment.v1beta2.Query", + method: "Group", + getRpcInstance: getRpcInstance +}); +export const useGetGroup = buildUseQuery({ + builderQueryFn: createGetGroup, + queryKeyPrefix: "GroupQuery" +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta2/query.ts b/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta2/query.ts new file mode 100644 index 0000000000..ed4ebc976b --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta2/query.ts @@ -0,0 +1,757 @@ +import { DeploymentFilters, DeploymentFiltersSDKType, DeploymentID, DeploymentIDSDKType, Deployment, DeploymentSDKType } from "./deployment.js"; +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../../cosmos/base/query/v1beta1/pagination.js"; +import { GroupID, GroupIDSDKType } from "./groupid.js"; +import { Group, GroupSDKType } from "./group.js"; +import { Account, AccountSDKType } from "../../escrow/v1beta2/types.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial, Exact } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "akash.deployment.v1beta2"; +/** QueryDeploymentsRequest is request type for the Query/Deployments RPC method */ +export interface QueryDeploymentsRequest { + filters: DeploymentFilters; + pagination?: PageRequest; +} +export interface QueryDeploymentsRequestProtoMsg { + typeUrl: "/akash.deployment.v1beta2.QueryDeploymentsRequest"; + value: Uint8Array; +} +/** QueryDeploymentsRequest is request type for the Query/Deployments RPC method */ +export interface QueryDeploymentsRequestSDKType { + filters: DeploymentFiltersSDKType; + pagination?: PageRequestSDKType; +} +/** QueryDeploymentsResponse is response type for the Query/Deployments RPC method */ +export interface QueryDeploymentsResponse { + deployments: QueryDeploymentResponse[]; + pagination?: PageResponse; +} +export interface QueryDeploymentsResponseProtoMsg { + typeUrl: "/akash.deployment.v1beta2.QueryDeploymentsResponse"; + value: Uint8Array; +} +/** QueryDeploymentsResponse is response type for the Query/Deployments RPC method */ +export interface QueryDeploymentsResponseSDKType { + deployments: QueryDeploymentResponseSDKType[]; + pagination?: PageResponseSDKType; +} +/** QueryDeploymentRequest is request type for the Query/Deployment RPC method */ +export interface QueryDeploymentRequest { + id: DeploymentID; +} +export interface QueryDeploymentRequestProtoMsg { + typeUrl: "/akash.deployment.v1beta2.QueryDeploymentRequest"; + value: Uint8Array; +} +/** QueryDeploymentRequest is request type for the Query/Deployment RPC method */ +export interface QueryDeploymentRequestSDKType { + id: DeploymentIDSDKType; +} +/** QueryDeploymentResponse is response type for the Query/Deployment RPC method */ +export interface QueryDeploymentResponse { + deployment: Deployment; + groups: Group[]; + escrowAccount: Account; +} +export interface QueryDeploymentResponseProtoMsg { + typeUrl: "/akash.deployment.v1beta2.QueryDeploymentResponse"; + value: Uint8Array; +} +/** QueryDeploymentResponse is response type for the Query/Deployment RPC method */ +export interface QueryDeploymentResponseSDKType { + deployment: DeploymentSDKType; + groups: GroupSDKType[]; + escrow_account: AccountSDKType; +} +/** QueryGroupRequest is request type for the Query/Group RPC method */ +export interface QueryGroupRequest { + id: GroupID; +} +export interface QueryGroupRequestProtoMsg { + typeUrl: "/akash.deployment.v1beta2.QueryGroupRequest"; + value: Uint8Array; +} +/** QueryGroupRequest is request type for the Query/Group RPC method */ +export interface QueryGroupRequestSDKType { + id: GroupIDSDKType; +} +/** QueryGroupResponse is response type for the Query/Group RPC method */ +export interface QueryGroupResponse { + group: Group; +} +export interface QueryGroupResponseProtoMsg { + typeUrl: "/akash.deployment.v1beta2.QueryGroupResponse"; + value: Uint8Array; +} +/** QueryGroupResponse is response type for the Query/Group RPC method */ +export interface QueryGroupResponseSDKType { + group: GroupSDKType; +} +function createBaseQueryDeploymentsRequest(): QueryDeploymentsRequest { + return { + filters: DeploymentFilters.fromPartial({}), + pagination: undefined + }; +} +export const QueryDeploymentsRequest = { + typeUrl: "/akash.deployment.v1beta2.QueryDeploymentsRequest", + encode(message: QueryDeploymentsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.filters !== undefined) { + DeploymentFilters.encode(message.filters, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryDeploymentsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryDeploymentsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.filters = DeploymentFilters.decode(reader, reader.uint32()); + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryDeploymentsRequest { + const obj = createBaseQueryDeploymentsRequest(); + if (isSet(object.filters)) obj.filters = DeploymentFilters.fromJSON(object.filters); + if (isSet(object.pagination)) obj.pagination = PageRequest.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryDeploymentsRequest): JsonSafe { + const obj: any = {}; + message.filters !== undefined && (obj.filters = message.filters ? DeploymentFilters.toJSON(message.filters) : undefined); + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryDeploymentsRequest { + const message = createBaseQueryDeploymentsRequest(); + if (object.filters !== undefined && object.filters !== null) { + message.filters = DeploymentFilters.fromPartial(object.filters); + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryDeploymentsRequestSDKType): QueryDeploymentsRequest { + return { + filters: object.filters ? DeploymentFilters.fromSDK(object.filters) : undefined, + pagination: object.pagination ? PageRequest.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryDeploymentsRequestSDKType { + return { + filters: isSet(object.filters) ? DeploymentFilters.fromSDKJSON(object.filters) : undefined, + pagination: isSet(object.pagination) ? PageRequest.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryDeploymentsRequest): QueryDeploymentsRequestSDKType { + const obj: any = {}; + message.filters !== undefined && (obj.filters = message.filters ? DeploymentFilters.toSDK(message.filters) : undefined); + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryDeploymentsRequestAmino): QueryDeploymentsRequest { + const message = createBaseQueryDeploymentsRequest(); + if (object.filters !== undefined && object.filters !== null) { + message.filters = DeploymentFilters.fromAmino(object.filters); + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryDeploymentsRequest): QueryDeploymentsRequestAmino { + const obj: any = {}; + obj.filters = message.filters ? DeploymentFilters.toAmino(message.filters) : undefined; + obj.pagination = message.pagination ? PageRequest.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryDeploymentsRequestAminoMsg): QueryDeploymentsRequest { + return QueryDeploymentsRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryDeploymentsRequest): QueryDeploymentsRequestAminoMsg { + return { + type: "akash/deployment/v1beta2/query-deployments-request", + value: QueryDeploymentsRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryDeploymentsRequestProtoMsg): QueryDeploymentsRequest { + return QueryDeploymentsRequest.decode(message.value); + }, + toProto(message: QueryDeploymentsRequest): Uint8Array { + return QueryDeploymentsRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryDeploymentsRequest): QueryDeploymentsRequestProtoMsg { + return { + typeUrl: "/akash.deployment.v1beta2.QueryDeploymentsRequest", + value: QueryDeploymentsRequest.encode(message).finish() + }; + } +}; +function createBaseQueryDeploymentsResponse(): QueryDeploymentsResponse { + return { + deployments: [], + pagination: undefined + }; +} +export const QueryDeploymentsResponse = { + typeUrl: "/akash.deployment.v1beta2.QueryDeploymentsResponse", + encode(message: QueryDeploymentsResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.deployments) { + QueryDeploymentResponse.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryDeploymentsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryDeploymentsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.deployments.push(QueryDeploymentResponse.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryDeploymentsResponse { + const obj = createBaseQueryDeploymentsResponse(); + if (Array.isArray(object?.deployments)) obj.deployments = object.deployments.map((e: any) => QueryDeploymentResponse.fromJSON(e)); + if (isSet(object.pagination)) obj.pagination = PageResponse.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryDeploymentsResponse): JsonSafe { + const obj: any = {}; + if (message.deployments) { + obj.deployments = message.deployments.map(e => e ? QueryDeploymentResponse.toJSON(e) : undefined); + } else { + obj.deployments = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryDeploymentsResponse { + const message = createBaseQueryDeploymentsResponse(); + message.deployments = object.deployments?.map(e => QueryDeploymentResponse.fromPartial(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryDeploymentsResponseSDKType): QueryDeploymentsResponse { + return { + deployments: Array.isArray(object?.deployments) ? object.deployments.map((e: any) => QueryDeploymentResponse.fromSDK(e)) : [], + pagination: object.pagination ? PageResponse.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryDeploymentsResponseSDKType { + return { + deployments: Array.isArray(object?.deployments) ? object.deployments.map((e: any) => QueryDeploymentResponse.fromSDKJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryDeploymentsResponse): QueryDeploymentsResponseSDKType { + const obj: any = {}; + if (message.deployments) { + obj.deployments = message.deployments.map(e => e ? QueryDeploymentResponse.toSDK(e) : undefined); + } else { + obj.deployments = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryDeploymentsResponseAmino): QueryDeploymentsResponse { + const message = createBaseQueryDeploymentsResponse(); + message.deployments = object.deployments?.map(e => QueryDeploymentResponse.fromAmino(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryDeploymentsResponse): QueryDeploymentsResponseAmino { + const obj: any = {}; + if (message.deployments) { + obj.deployments = message.deployments.map(e => e ? QueryDeploymentResponse.toAmino(e) : undefined); + } else { + obj.deployments = message.deployments; + } + obj.pagination = message.pagination ? PageResponse.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryDeploymentsResponseAminoMsg): QueryDeploymentsResponse { + return QueryDeploymentsResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryDeploymentsResponse): QueryDeploymentsResponseAminoMsg { + return { + type: "akash/deployment/v1beta2/query-deployments-response", + value: QueryDeploymentsResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryDeploymentsResponseProtoMsg): QueryDeploymentsResponse { + return QueryDeploymentsResponse.decode(message.value); + }, + toProto(message: QueryDeploymentsResponse): Uint8Array { + return QueryDeploymentsResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryDeploymentsResponse): QueryDeploymentsResponseProtoMsg { + return { + typeUrl: "/akash.deployment.v1beta2.QueryDeploymentsResponse", + value: QueryDeploymentsResponse.encode(message).finish() + }; + } +}; +function createBaseQueryDeploymentRequest(): QueryDeploymentRequest { + return { + id: DeploymentID.fromPartial({}) + }; +} +export const QueryDeploymentRequest = { + typeUrl: "/akash.deployment.v1beta2.QueryDeploymentRequest", + encode(message: QueryDeploymentRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.id !== undefined) { + DeploymentID.encode(message.id, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryDeploymentRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryDeploymentRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.id = DeploymentID.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryDeploymentRequest { + const obj = createBaseQueryDeploymentRequest(); + if (isSet(object.id)) obj.id = DeploymentID.fromJSON(object.id); + return obj; + }, + toJSON(message: QueryDeploymentRequest): JsonSafe { + const obj: any = {}; + message.id !== undefined && (obj.id = message.id ? DeploymentID.toJSON(message.id) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryDeploymentRequest { + const message = createBaseQueryDeploymentRequest(); + if (object.id !== undefined && object.id !== null) { + message.id = DeploymentID.fromPartial(object.id); + } + return message; + }, + fromSDK(object: QueryDeploymentRequestSDKType): QueryDeploymentRequest { + return { + id: object.id ? DeploymentID.fromSDK(object.id) : undefined + }; + }, + fromSDKJSON(object: any): QueryDeploymentRequestSDKType { + return { + id: isSet(object.id) ? DeploymentID.fromSDKJSON(object.id) : undefined + }; + }, + toSDK(message: QueryDeploymentRequest): QueryDeploymentRequestSDKType { + const obj: any = {}; + message.id !== undefined && (obj.id = message.id ? DeploymentID.toSDK(message.id) : undefined); + return obj; + }, + fromAmino(object: QueryDeploymentRequestAmino): QueryDeploymentRequest { + const message = createBaseQueryDeploymentRequest(); + if (object.id !== undefined && object.id !== null) { + message.id = DeploymentID.fromAmino(object.id); + } + return message; + }, + toAmino(message: QueryDeploymentRequest): QueryDeploymentRequestAmino { + const obj: any = {}; + obj.id = message.id ? DeploymentID.toAmino(message.id) : undefined; + return obj; + }, + fromAminoMsg(object: QueryDeploymentRequestAminoMsg): QueryDeploymentRequest { + return QueryDeploymentRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryDeploymentRequest): QueryDeploymentRequestAminoMsg { + return { + type: "akash/deployment/v1beta2/query-deployment-request", + value: QueryDeploymentRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryDeploymentRequestProtoMsg): QueryDeploymentRequest { + return QueryDeploymentRequest.decode(message.value); + }, + toProto(message: QueryDeploymentRequest): Uint8Array { + return QueryDeploymentRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryDeploymentRequest): QueryDeploymentRequestProtoMsg { + return { + typeUrl: "/akash.deployment.v1beta2.QueryDeploymentRequest", + value: QueryDeploymentRequest.encode(message).finish() + }; + } +}; +function createBaseQueryDeploymentResponse(): QueryDeploymentResponse { + return { + deployment: Deployment.fromPartial({}), + groups: [], + escrowAccount: Account.fromPartial({}) + }; +} +export const QueryDeploymentResponse = { + typeUrl: "/akash.deployment.v1beta2.QueryDeploymentResponse", + encode(message: QueryDeploymentResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.deployment !== undefined) { + Deployment.encode(message.deployment, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.groups) { + Group.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.escrowAccount !== undefined) { + Account.encode(message.escrowAccount, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryDeploymentResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryDeploymentResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.deployment = Deployment.decode(reader, reader.uint32()); + break; + case 2: + message.groups.push(Group.decode(reader, reader.uint32())); + break; + case 3: + message.escrowAccount = Account.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryDeploymentResponse { + const obj = createBaseQueryDeploymentResponse(); + if (isSet(object.deployment)) obj.deployment = Deployment.fromJSON(object.deployment); + if (Array.isArray(object?.groups)) obj.groups = object.groups.map((e: any) => Group.fromJSON(e)); + if (isSet(object.escrowAccount)) obj.escrowAccount = Account.fromJSON(object.escrowAccount); + return obj; + }, + toJSON(message: QueryDeploymentResponse): JsonSafe { + const obj: any = {}; + message.deployment !== undefined && (obj.deployment = message.deployment ? Deployment.toJSON(message.deployment) : undefined); + if (message.groups) { + obj.groups = message.groups.map(e => e ? Group.toJSON(e) : undefined); + } else { + obj.groups = []; + } + message.escrowAccount !== undefined && (obj.escrowAccount = message.escrowAccount ? Account.toJSON(message.escrowAccount) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryDeploymentResponse { + const message = createBaseQueryDeploymentResponse(); + if (object.deployment !== undefined && object.deployment !== null) { + message.deployment = Deployment.fromPartial(object.deployment); + } + message.groups = object.groups?.map(e => Group.fromPartial(e)) || []; + if (object.escrowAccount !== undefined && object.escrowAccount !== null) { + message.escrowAccount = Account.fromPartial(object.escrowAccount); + } + return message; + }, + fromSDK(object: QueryDeploymentResponseSDKType): QueryDeploymentResponse { + return { + deployment: object.deployment ? Deployment.fromSDK(object.deployment) : undefined, + groups: Array.isArray(object?.groups) ? object.groups.map((e: any) => Group.fromSDK(e)) : [], + escrowAccount: object.escrow_account ? Account.fromSDK(object.escrow_account) : undefined + }; + }, + fromSDKJSON(object: any): QueryDeploymentResponseSDKType { + return { + deployment: isSet(object.deployment) ? Deployment.fromSDKJSON(object.deployment) : undefined, + groups: Array.isArray(object?.groups) ? object.groups.map((e: any) => Group.fromSDKJSON(e)) : [], + escrow_account: isSet(object.escrow_account) ? Account.fromSDKJSON(object.escrow_account) : undefined + }; + }, + toSDK(message: QueryDeploymentResponse): QueryDeploymentResponseSDKType { + const obj: any = {}; + message.deployment !== undefined && (obj.deployment = message.deployment ? Deployment.toSDK(message.deployment) : undefined); + if (message.groups) { + obj.groups = message.groups.map(e => e ? Group.toSDK(e) : undefined); + } else { + obj.groups = []; + } + message.escrowAccount !== undefined && (obj.escrow_account = message.escrowAccount ? Account.toSDK(message.escrowAccount) : undefined); + return obj; + }, + fromAmino(object: QueryDeploymentResponseAmino): QueryDeploymentResponse { + const message = createBaseQueryDeploymentResponse(); + if (object.deployment !== undefined && object.deployment !== null) { + message.deployment = Deployment.fromAmino(object.deployment); + } + message.groups = object.groups?.map(e => Group.fromAmino(e)) || []; + if (object.escrow_account !== undefined && object.escrow_account !== null) { + message.escrowAccount = Account.fromAmino(object.escrow_account); + } + return message; + }, + toAmino(message: QueryDeploymentResponse): QueryDeploymentResponseAmino { + const obj: any = {}; + obj.deployment = message.deployment ? Deployment.toAmino(message.deployment) : Deployment.toAmino(Deployment.fromPartial({})); + if (message.groups) { + obj.groups = message.groups.map(e => e ? Group.toAmino(e) : undefined); + } else { + obj.groups = message.groups; + } + obj.escrow_account = message.escrowAccount ? Account.toAmino(message.escrowAccount) : undefined; + return obj; + }, + fromAminoMsg(object: QueryDeploymentResponseAminoMsg): QueryDeploymentResponse { + return QueryDeploymentResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryDeploymentResponse): QueryDeploymentResponseAminoMsg { + return { + type: "akash/deployment/v1beta2/query-deployment-response", + value: QueryDeploymentResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryDeploymentResponseProtoMsg): QueryDeploymentResponse { + return QueryDeploymentResponse.decode(message.value); + }, + toProto(message: QueryDeploymentResponse): Uint8Array { + return QueryDeploymentResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryDeploymentResponse): QueryDeploymentResponseProtoMsg { + return { + typeUrl: "/akash.deployment.v1beta2.QueryDeploymentResponse", + value: QueryDeploymentResponse.encode(message).finish() + }; + } +}; +function createBaseQueryGroupRequest(): QueryGroupRequest { + return { + id: GroupID.fromPartial({}) + }; +} +export const QueryGroupRequest = { + typeUrl: "/akash.deployment.v1beta2.QueryGroupRequest", + encode(message: QueryGroupRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.id !== undefined) { + GroupID.encode(message.id, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryGroupRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryGroupRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.id = GroupID.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryGroupRequest { + const obj = createBaseQueryGroupRequest(); + if (isSet(object.id)) obj.id = GroupID.fromJSON(object.id); + return obj; + }, + toJSON(message: QueryGroupRequest): JsonSafe { + const obj: any = {}; + message.id !== undefined && (obj.id = message.id ? GroupID.toJSON(message.id) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryGroupRequest { + const message = createBaseQueryGroupRequest(); + if (object.id !== undefined && object.id !== null) { + message.id = GroupID.fromPartial(object.id); + } + return message; + }, + fromSDK(object: QueryGroupRequestSDKType): QueryGroupRequest { + return { + id: object.id ? GroupID.fromSDK(object.id) : undefined + }; + }, + fromSDKJSON(object: any): QueryGroupRequestSDKType { + return { + id: isSet(object.id) ? GroupID.fromSDKJSON(object.id) : undefined + }; + }, + toSDK(message: QueryGroupRequest): QueryGroupRequestSDKType { + const obj: any = {}; + message.id !== undefined && (obj.id = message.id ? GroupID.toSDK(message.id) : undefined); + return obj; + }, + fromAmino(object: QueryGroupRequestAmino): QueryGroupRequest { + const message = createBaseQueryGroupRequest(); + if (object.id !== undefined && object.id !== null) { + message.id = GroupID.fromAmino(object.id); + } + return message; + }, + toAmino(message: QueryGroupRequest): QueryGroupRequestAmino { + const obj: any = {}; + obj.id = message.id ? GroupID.toAmino(message.id) : undefined; + return obj; + }, + fromAminoMsg(object: QueryGroupRequestAminoMsg): QueryGroupRequest { + return QueryGroupRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryGroupRequest): QueryGroupRequestAminoMsg { + return { + type: "akash/deployment/v1beta2/query-group-request", + value: QueryGroupRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryGroupRequestProtoMsg): QueryGroupRequest { + return QueryGroupRequest.decode(message.value); + }, + toProto(message: QueryGroupRequest): Uint8Array { + return QueryGroupRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryGroupRequest): QueryGroupRequestProtoMsg { + return { + typeUrl: "/akash.deployment.v1beta2.QueryGroupRequest", + value: QueryGroupRequest.encode(message).finish() + }; + } +}; +function createBaseQueryGroupResponse(): QueryGroupResponse { + return { + group: Group.fromPartial({}) + }; +} +export const QueryGroupResponse = { + typeUrl: "/akash.deployment.v1beta2.QueryGroupResponse", + encode(message: QueryGroupResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.group !== undefined) { + Group.encode(message.group, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryGroupResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryGroupResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.group = Group.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryGroupResponse { + const obj = createBaseQueryGroupResponse(); + if (isSet(object.group)) obj.group = Group.fromJSON(object.group); + return obj; + }, + toJSON(message: QueryGroupResponse): JsonSafe { + const obj: any = {}; + message.group !== undefined && (obj.group = message.group ? Group.toJSON(message.group) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryGroupResponse { + const message = createBaseQueryGroupResponse(); + if (object.group !== undefined && object.group !== null) { + message.group = Group.fromPartial(object.group); + } + return message; + }, + fromSDK(object: QueryGroupResponseSDKType): QueryGroupResponse { + return { + group: object.group ? Group.fromSDK(object.group) : undefined + }; + }, + fromSDKJSON(object: any): QueryGroupResponseSDKType { + return { + group: isSet(object.group) ? Group.fromSDKJSON(object.group) : undefined + }; + }, + toSDK(message: QueryGroupResponse): QueryGroupResponseSDKType { + const obj: any = {}; + message.group !== undefined && (obj.group = message.group ? Group.toSDK(message.group) : undefined); + return obj; + }, + fromAmino(object: QueryGroupResponseAmino): QueryGroupResponse { + const message = createBaseQueryGroupResponse(); + if (object.group !== undefined && object.group !== null) { + message.group = Group.fromAmino(object.group); + } + return message; + }, + toAmino(message: QueryGroupResponse): QueryGroupResponseAmino { + const obj: any = {}; + obj.group = message.group ? Group.toAmino(message.group) : undefined; + return obj; + }, + fromAminoMsg(object: QueryGroupResponseAminoMsg): QueryGroupResponse { + return QueryGroupResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryGroupResponse): QueryGroupResponseAminoMsg { + return { + type: "akash/deployment/v1beta2/query-group-response", + value: QueryGroupResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryGroupResponseProtoMsg): QueryGroupResponse { + return QueryGroupResponse.decode(message.value); + }, + toProto(message: QueryGroupResponse): Uint8Array { + return QueryGroupResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryGroupResponse): QueryGroupResponseProtoMsg { + return { + typeUrl: "/akash.deployment.v1beta2.QueryGroupResponse", + value: QueryGroupResponse.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta2/resource.ts b/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta2/resource.ts new file mode 100644 index 0000000000..ae349812fe --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta2/resource.ts @@ -0,0 +1,154 @@ +import { ResourceUnits, ResourceUnitsSDKType } from "../../base/v1beta2/resourceunits.js"; +import { DecCoin, DecCoinSDKType } from "../../../cosmos/base/v1beta1/coin.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial, Exact } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "akash.deployment.v1beta2"; +/** Resource stores unit, total count and price of resource */ +export interface Resource { + resources: ResourceUnits; + count: number; + price: DecCoin; +} +export interface ResourceProtoMsg { + typeUrl: "/akash.deployment.v1beta2.Resource"; + value: Uint8Array; +} +/** Resource stores unit, total count and price of resource */ +export interface ResourceSDKType { + resources: ResourceUnitsSDKType; + count: number; + price: DecCoinSDKType; +} +function createBaseResource(): Resource { + return { + resources: ResourceUnits.fromPartial({}), + count: 0, + price: DecCoin.fromPartial({}) + }; +} +export const Resource = { + typeUrl: "/akash.deployment.v1beta2.Resource", + encode(message: Resource, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.resources !== undefined) { + ResourceUnits.encode(message.resources, writer.uint32(10).fork()).ldelim(); + } + if (message.count !== undefined) { + writer.uint32(16).uint32(message.count); + } + if (message.price !== undefined) { + DecCoin.encode(message.price, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Resource { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseResource(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.resources = ResourceUnits.decode(reader, reader.uint32()); + break; + case 2: + message.count = reader.uint32(); + break; + case 3: + message.price = DecCoin.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Resource { + const obj = createBaseResource(); + if (isSet(object.resources)) obj.resources = ResourceUnits.fromJSON(object.resources); + if (isSet(object.count)) obj.count = Number(object.count); + if (isSet(object.price)) obj.price = DecCoin.fromJSON(object.price); + return obj; + }, + toJSON(message: Resource): JsonSafe { + const obj: any = {}; + message.resources !== undefined && (obj.resources = message.resources ? ResourceUnits.toJSON(message.resources) : undefined); + message.count !== undefined && (obj.count = Math.round(message.count)); + message.price !== undefined && (obj.price = message.price ? DecCoin.toJSON(message.price) : undefined); + return obj; + }, + fromPartial, I>>(object: I): Resource { + const message = createBaseResource(); + if (object.resources !== undefined && object.resources !== null) { + message.resources = ResourceUnits.fromPartial(object.resources); + } + message.count = object.count ?? 0; + if (object.price !== undefined && object.price !== null) { + message.price = DecCoin.fromPartial(object.price); + } + return message; + }, + fromSDK(object: ResourceSDKType): Resource { + return { + resources: object.resources ? ResourceUnits.fromSDK(object.resources) : undefined, + count: object?.count, + price: object.price ? DecCoin.fromSDK(object.price) : undefined + }; + }, + fromSDKJSON(object: any): ResourceSDKType { + return { + resources: isSet(object.resources) ? ResourceUnits.fromSDKJSON(object.resources) : undefined, + count: isSet(object.count) ? Number(object.count) : 0, + price: isSet(object.price) ? DecCoin.fromSDKJSON(object.price) : undefined + }; + }, + toSDK(message: Resource): ResourceSDKType { + const obj: any = {}; + message.resources !== undefined && (obj.resources = message.resources ? ResourceUnits.toSDK(message.resources) : undefined); + obj.count = message.count; + message.price !== undefined && (obj.price = message.price ? DecCoin.toSDK(message.price) : undefined); + return obj; + }, + fromAmino(object: ResourceAmino): Resource { + const message = createBaseResource(); + if (object.resources !== undefined && object.resources !== null) { + message.resources = ResourceUnits.fromAmino(object.resources); + } + if (object.count !== undefined && object.count !== null) { + message.count = object.count; + } + if (object.price !== undefined && object.price !== null) { + message.price = DecCoin.fromAmino(object.price); + } + return message; + }, + toAmino(message: Resource): ResourceAmino { + const obj: any = {}; + obj.resources = message.resources ? ResourceUnits.toAmino(message.resources) : ResourceUnits.toAmino(ResourceUnits.fromPartial({})); + obj.count = message.count ?? 0; + obj.price = message.price ? DecCoin.toAmino(message.price) : DecCoin.toAmino(DecCoin.fromPartial({})); + return obj; + }, + fromAminoMsg(object: ResourceAminoMsg): Resource { + return Resource.fromAmino(object.value); + }, + toAminoMsg(message: Resource): ResourceAminoMsg { + return { + type: "akash/deployment/v1beta2/resource", + value: Resource.toAmino(message) + }; + }, + fromProtoMsg(message: ResourceProtoMsg): Resource { + return Resource.decode(message.value); + }, + toProto(message: Resource): Uint8Array { + return Resource.encode(message).finish(); + }, + toProtoMsg(message: Resource): ResourceProtoMsg { + return { + typeUrl: "/akash.deployment.v1beta2.Resource", + value: Resource.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta2/service.amino.ts b/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta2/service.amino.ts new file mode 100644 index 0000000000..55aa75c437 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta2/service.amino.ts @@ -0,0 +1,461 @@ +/* eslint-disable */ +import { DeploymentID, DeploymentIDSDKType } from "./deployment.js"; +import { GroupSpec, GroupSpecSDKType } from "./groupspec.js"; +import { Coin, CoinSDKType, DecCoin, DecCoinSDKType } from "../../../cosmos/base/v1beta1/coin.js"; +import { GroupID, GroupIDSDKType } from "./groupid.js"; +import { ReadOnlyAminoMsg as AminoMsg } from "@interchainjs/ReadOnlyAminoMsg"; +import { PlacementRequirements, PlacementRequirementsSDKType, SignedBy, SignedBySDKType, Attribute, AttributeSDKType } from "../../base/v1beta2/attribute.js"; +import { Resource, ResourceSDKType } from "./resource.js"; +import { ResourceUnits, ResourceUnitsSDKType } from "../../base/v1beta2/resourceunits.js"; +import { CPU, CPUSDKType, Memory, MemorySDKType, Storage, StorageSDKType } from "../../base/v1beta2/resource.js"; +import { ResourceValue, ResourceValueSDKType } from "../../base/v1beta2/resourcevalue.js"; +import { Endpoint, EndpointSDKType, endpoint_KindFromJSON } from "../../base/v1beta2/endpoint.js"; +import { MsgCreateDeployment, MsgCreateDeploymentSDKType, MsgDepositDeployment, MsgDepositDeploymentSDKType, MsgUpdateDeployment, MsgUpdateDeploymentSDKType, MsgCloseDeployment, MsgCloseDeploymentSDKType } from "./deploymentmsg.js"; +import { MsgCloseGroup, MsgCloseGroupSDKType, MsgPauseGroup, MsgPauseGroupSDKType, MsgStartGroup, MsgStartGroupSDKType } from "./groupmsg.js"; +export interface MsgCreateDeploymentAminoType extends AminoMsg { + type: "akash/deployment/v1beta2/testonly-create-deployment"; + value: { + id: { + owner: string; + dseq: string; + }; + groups: { + name: string; + requirements: { + signed_by: { + all_of: string[]; + any_of: string[]; + }; + attributes: { + key: string; + value: string; + }[]; + }; + resources: { + resources: { + cpu: { + units: { + val: Uint8Array; + }; + attributes: { + key: string; + value: string; + }[]; + }; + memory: { + quantity: { + val: Uint8Array; + }; + attributes: { + key: string; + value: string; + }[]; + }; + storage: { + name: string; + quantity: { + val: Uint8Array; + }; + attributes: { + key: string; + value: string; + }[]; + }[]; + endpoints: { + kind: number; + sequence_number: number; + }[]; + }; + count: number; + price: { + denom: string; + amount: string; + }; + }[]; + }[]; + version: Uint8Array; + deposit: { + denom: string; + amount: string; + }; + depositor: string; + }; +} +export interface MsgDepositDeploymentAminoType extends AminoMsg { + type: "akash/deployment/v1beta2/testonly-deposit-deployment"; + value: { + id: { + owner: string; + dseq: string; + }; + amount: { + denom: string; + amount: string; + }; + depositor: string; + }; +} +export interface MsgUpdateDeploymentAminoType extends AminoMsg { + type: "akash/deployment/v1beta2/testonly-update-deployment"; + value: { + id: { + owner: string; + dseq: string; + }; + version: Uint8Array; + }; +} +export interface MsgCloseDeploymentAminoType extends AminoMsg { + type: "akash/deployment/v1beta2/testonly-close-deployment"; + value: { + id: { + owner: string; + dseq: string; + }; + }; +} +export interface MsgCloseGroupAminoType extends AminoMsg { + type: "akash/deployment/v1beta2/testonly-close-group"; + value: { + id: { + owner: string; + dseq: string; + gseq: number; + }; + }; +} +export interface MsgPauseGroupAminoType extends AminoMsg { + type: "akash/deployment/v1beta2/testonly-pause-group"; + value: { + id: { + owner: string; + dseq: string; + gseq: number; + }; + }; +} +export interface MsgStartGroupAminoType extends AminoMsg { + type: "akash/deployment/v1beta2/testonly-start-group"; + value: { + id: { + owner: string; + dseq: string; + gseq: number; + }; + }; +} +export const AminoConverter = { + "/akash.deployment.v1beta2.MsgCreateDeployment": { + aminoType: "akash/deployment/v1beta2/testonly-create-deployment", + toAmino: ({ + id, + groups, + version, + deposit, + depositor + }: MsgCreateDeployment): MsgCreateDeploymentAminoType["value"] => { + return { + id: { + owner: id.owner, + dseq: id.dseq.toString() + }, + groups: groups.map(el0 => ({ + name: el0.name, + requirements: { + signed_by: { + all_of: el0.requirements.signedBy.allOf, + any_of: el0.requirements.signedBy.anyOf + }, + attributes: el0.requirements.attributes.map(el1 => ({ + key: el1.key, + value: el1.value + })) + }, + resources: el0.resources.map(el1 => ({ + resources: { + cpu: { + units: { + val: el1.resources.cpu.units.val + }, + attributes: el1.resources.cpu.attributes.map(el2 => ({ + key: el2.key, + value: el2.value + })) + }, + memory: { + quantity: { + val: el1.resources.memory.quantity.val + }, + attributes: el1.resources.memory.attributes.map(el2 => ({ + key: el2.key, + value: el2.value + })) + }, + storage: el1.resources.storage.map(el2 => ({ + name: el2.name, + quantity: { + val: el2.quantity.val + }, + attributes: el2.attributes.map(el3 => ({ + key: el3.key, + value: el3.value + })) + })), + endpoints: el1.resources.endpoints.map(el2 => ({ + kind: el2.kind, + sequence_number: el2.sequenceNumber + })) + }, + count: el1.count, + price: { + denom: el1.price.denom, + amount: el1.price.amount + } + })) + })), + version, + deposit: { + denom: deposit.denom, + amount: deposit.amount + }, + depositor + }; + }, + fromAmino: ({ + id, + groups, + version, + deposit, + depositor + }: MsgCreateDeploymentAminoType["value"]): MsgCreateDeployment => { + return { + id: { + owner: id.owner, + dseq: BigInt(id.dseq) + }, + groups: groups.map(el0 => ({ + name: el0.name, + requirements: { + signedBy: { + allOf: el0.requirements.signed_by.all_of, + anyOf: el0.requirements.signed_by.any_of + }, + attributes: el0.requirements.attributes.map(el2 => ({ + key: el2.key, + value: el2.value + })) + }, + resources: el0.resources.map(el1 => ({ + resources: { + cpu: { + units: { + val: el1.resources.cpu.units.val + }, + attributes: el1.resources.cpu.attributes.map(el4 => ({ + key: el4.key, + value: el4.value + })) + }, + memory: { + quantity: { + val: el1.resources.memory.quantity.val + }, + attributes: el1.resources.memory.attributes.map(el4 => ({ + key: el4.key, + value: el4.value + })) + }, + storage: el1.resources.storage.map(el3 => ({ + name: el3.name, + quantity: { + val: el3.quantity.val + }, + attributes: el3.attributes.map(el4 => ({ + key: el4.key, + value: el4.value + })) + })), + endpoints: el1.resources.endpoints.map(el3 => ({ + kind: endpoint_KindFromJSON(el3.kind), + sequenceNumber: el3.sequence_number + })) + }, + count: el1.count, + price: { + denom: el1.price.denom, + amount: el1.price.amount + } + })) + })), + version, + deposit: { + denom: deposit.denom, + amount: deposit.amount + }, + depositor + }; + } + }, + "/akash.deployment.v1beta2.MsgDepositDeployment": { + aminoType: "akash/deployment/v1beta2/testonly-deposit-deployment", + toAmino: ({ + id, + amount, + depositor + }: MsgDepositDeployment): MsgDepositDeploymentAminoType["value"] => { + return { + id: { + owner: id.owner, + dseq: id.dseq.toString() + }, + amount: { + denom: amount.denom, + amount: amount.amount + }, + depositor + }; + }, + fromAmino: ({ + id, + amount, + depositor + }: MsgDepositDeploymentAminoType["value"]): MsgDepositDeployment => { + return { + id: { + owner: id.owner, + dseq: BigInt(id.dseq) + }, + amount: { + denom: amount.denom, + amount: amount.amount + }, + depositor + }; + } + }, + "/akash.deployment.v1beta2.MsgUpdateDeployment": { + aminoType: "akash/deployment/v1beta2/testonly-update-deployment", + toAmino: ({ + id, + version + }: MsgUpdateDeployment): MsgUpdateDeploymentAminoType["value"] => { + return { + id: { + owner: id.owner, + dseq: id.dseq.toString() + }, + version + }; + }, + fromAmino: ({ + id, + version + }: MsgUpdateDeploymentAminoType["value"]): MsgUpdateDeployment => { + return { + id: { + owner: id.owner, + dseq: BigInt(id.dseq) + }, + version + }; + } + }, + "/akash.deployment.v1beta2.MsgCloseDeployment": { + aminoType: "akash/deployment/v1beta2/testonly-close-deployment", + toAmino: ({ + id + }: MsgCloseDeployment): MsgCloseDeploymentAminoType["value"] => { + return { + id: { + owner: id.owner, + dseq: id.dseq.toString() + } + }; + }, + fromAmino: ({ + id + }: MsgCloseDeploymentAminoType["value"]): MsgCloseDeployment => { + return { + id: { + owner: id.owner, + dseq: BigInt(id.dseq) + } + }; + } + }, + "/akash.deployment.v1beta2.MsgCloseGroup": { + aminoType: "akash/deployment/v1beta2/testonly-close-group", + toAmino: ({ + id + }: MsgCloseGroup): MsgCloseGroupAminoType["value"] => { + return { + id: { + owner: id.owner, + dseq: id.dseq.toString(), + gseq: id.gseq + } + }; + }, + fromAmino: ({ + id + }: MsgCloseGroupAminoType["value"]): MsgCloseGroup => { + return { + id: { + owner: id.owner, + dseq: BigInt(id.dseq), + gseq: id.gseq + } + }; + } + }, + "/akash.deployment.v1beta2.MsgPauseGroup": { + aminoType: "akash/deployment/v1beta2/testonly-pause-group", + toAmino: ({ + id + }: MsgPauseGroup): MsgPauseGroupAminoType["value"] => { + return { + id: { + owner: id.owner, + dseq: id.dseq.toString(), + gseq: id.gseq + } + }; + }, + fromAmino: ({ + id + }: MsgPauseGroupAminoType["value"]): MsgPauseGroup => { + return { + id: { + owner: id.owner, + dseq: BigInt(id.dseq), + gseq: id.gseq + } + }; + } + }, + "/akash.deployment.v1beta2.MsgStartGroup": { + aminoType: "akash/deployment/v1beta2/testonly-start-group", + toAmino: ({ + id + }: MsgStartGroup): MsgStartGroupAminoType["value"] => { + return { + id: { + owner: id.owner, + dseq: id.dseq.toString(), + gseq: id.gseq + } + }; + }, + fromAmino: ({ + id + }: MsgStartGroupAminoType["value"]): MsgStartGroup => { + return { + id: { + owner: id.owner, + dseq: BigInt(id.dseq), + gseq: id.gseq + } + }; + } + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta2/service.registry.ts b/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta2/service.registry.ts new file mode 100644 index 0000000000..ded19e9bff --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta2/service.registry.ts @@ -0,0 +1,235 @@ +import { DeploymentID, DeploymentIDSDKType } from "./deployment.js"; +import { GroupSpec, GroupSpecSDKType } from "./groupspec.js"; +import { Coin, CoinSDKType } from "../../../cosmos/base/v1beta1/coin.js"; +import { GroupID, GroupIDSDKType } from "./groupid.js"; +import { GeneratedType, Registry } from "@cosmjs/proto-signing"; +import { MsgCreateDeployment, MsgCreateDeploymentSDKType, MsgDepositDeployment, MsgDepositDeploymentSDKType, MsgUpdateDeployment, MsgUpdateDeploymentSDKType, MsgCloseDeployment, MsgCloseDeploymentSDKType } from "./deploymentmsg.js"; +import { MsgCloseGroup, MsgCloseGroupSDKType, MsgPauseGroup, MsgPauseGroupSDKType, MsgStartGroup, MsgStartGroupSDKType } from "./groupmsg.js"; +export const registry: ReadonlyArray<[string, GeneratedType]> = [["/akash.deployment.v1beta2.MsgCreateDeployment", MsgCreateDeployment], ["/akash.deployment.v1beta2.MsgDepositDeployment", MsgDepositDeployment], ["/akash.deployment.v1beta2.MsgUpdateDeployment", MsgUpdateDeployment], ["/akash.deployment.v1beta2.MsgCloseDeployment", MsgCloseDeployment], ["/akash.deployment.v1beta2.MsgCloseGroup", MsgCloseGroup], ["/akash.deployment.v1beta2.MsgPauseGroup", MsgPauseGroup], ["/akash.deployment.v1beta2.MsgStartGroup", MsgStartGroup]]; +export const load = (protoRegistry: Registry) => { + registry.forEach(([typeUrl, mod]) => { + protoRegistry.register(typeUrl, mod); + }); +}; +export const MessageComposer = { + encoded: { + createDeployment(value: MsgCreateDeployment) { + return { + typeUrl: "/akash.deployment.v1beta2.MsgCreateDeployment", + value: MsgCreateDeployment.encode(value).finish() + }; + }, + depositDeployment(value: MsgDepositDeployment) { + return { + typeUrl: "/akash.deployment.v1beta2.MsgDepositDeployment", + value: MsgDepositDeployment.encode(value).finish() + }; + }, + updateDeployment(value: MsgUpdateDeployment) { + return { + typeUrl: "/akash.deployment.v1beta2.MsgUpdateDeployment", + value: MsgUpdateDeployment.encode(value).finish() + }; + }, + closeDeployment(value: MsgCloseDeployment) { + return { + typeUrl: "/akash.deployment.v1beta2.MsgCloseDeployment", + value: MsgCloseDeployment.encode(value).finish() + }; + }, + closeGroup(value: MsgCloseGroup) { + return { + typeUrl: "/akash.deployment.v1beta2.MsgCloseGroup", + value: MsgCloseGroup.encode(value).finish() + }; + }, + pauseGroup(value: MsgPauseGroup) { + return { + typeUrl: "/akash.deployment.v1beta2.MsgPauseGroup", + value: MsgPauseGroup.encode(value).finish() + }; + }, + startGroup(value: MsgStartGroup) { + return { + typeUrl: "/akash.deployment.v1beta2.MsgStartGroup", + value: MsgStartGroup.encode(value).finish() + }; + } + }, + withTypeUrl: { + createDeployment(value: MsgCreateDeployment) { + return { + typeUrl: "/akash.deployment.v1beta2.MsgCreateDeployment", + value + }; + }, + depositDeployment(value: MsgDepositDeployment) { + return { + typeUrl: "/akash.deployment.v1beta2.MsgDepositDeployment", + value + }; + }, + updateDeployment(value: MsgUpdateDeployment) { + return { + typeUrl: "/akash.deployment.v1beta2.MsgUpdateDeployment", + value + }; + }, + closeDeployment(value: MsgCloseDeployment) { + return { + typeUrl: "/akash.deployment.v1beta2.MsgCloseDeployment", + value + }; + }, + closeGroup(value: MsgCloseGroup) { + return { + typeUrl: "/akash.deployment.v1beta2.MsgCloseGroup", + value + }; + }, + pauseGroup(value: MsgPauseGroup) { + return { + typeUrl: "/akash.deployment.v1beta2.MsgPauseGroup", + value + }; + }, + startGroup(value: MsgStartGroup) { + return { + typeUrl: "/akash.deployment.v1beta2.MsgStartGroup", + value + }; + } + }, + toJSON: { + createDeployment(value: MsgCreateDeployment) { + return { + typeUrl: "/akash.deployment.v1beta2.MsgCreateDeployment", + value: MsgCreateDeployment.toJSON(value) + }; + }, + depositDeployment(value: MsgDepositDeployment) { + return { + typeUrl: "/akash.deployment.v1beta2.MsgDepositDeployment", + value: MsgDepositDeployment.toJSON(value) + }; + }, + updateDeployment(value: MsgUpdateDeployment) { + return { + typeUrl: "/akash.deployment.v1beta2.MsgUpdateDeployment", + value: MsgUpdateDeployment.toJSON(value) + }; + }, + closeDeployment(value: MsgCloseDeployment) { + return { + typeUrl: "/akash.deployment.v1beta2.MsgCloseDeployment", + value: MsgCloseDeployment.toJSON(value) + }; + }, + closeGroup(value: MsgCloseGroup) { + return { + typeUrl: "/akash.deployment.v1beta2.MsgCloseGroup", + value: MsgCloseGroup.toJSON(value) + }; + }, + pauseGroup(value: MsgPauseGroup) { + return { + typeUrl: "/akash.deployment.v1beta2.MsgPauseGroup", + value: MsgPauseGroup.toJSON(value) + }; + }, + startGroup(value: MsgStartGroup) { + return { + typeUrl: "/akash.deployment.v1beta2.MsgStartGroup", + value: MsgStartGroup.toJSON(value) + }; + } + }, + fromJSON: { + createDeployment(value: any) { + return { + typeUrl: "/akash.deployment.v1beta2.MsgCreateDeployment", + value: MsgCreateDeployment.fromJSON(value) + }; + }, + depositDeployment(value: any) { + return { + typeUrl: "/akash.deployment.v1beta2.MsgDepositDeployment", + value: MsgDepositDeployment.fromJSON(value) + }; + }, + updateDeployment(value: any) { + return { + typeUrl: "/akash.deployment.v1beta2.MsgUpdateDeployment", + value: MsgUpdateDeployment.fromJSON(value) + }; + }, + closeDeployment(value: any) { + return { + typeUrl: "/akash.deployment.v1beta2.MsgCloseDeployment", + value: MsgCloseDeployment.fromJSON(value) + }; + }, + closeGroup(value: any) { + return { + typeUrl: "/akash.deployment.v1beta2.MsgCloseGroup", + value: MsgCloseGroup.fromJSON(value) + }; + }, + pauseGroup(value: any) { + return { + typeUrl: "/akash.deployment.v1beta2.MsgPauseGroup", + value: MsgPauseGroup.fromJSON(value) + }; + }, + startGroup(value: any) { + return { + typeUrl: "/akash.deployment.v1beta2.MsgStartGroup", + value: MsgStartGroup.fromJSON(value) + }; + } + }, + fromPartial: { + createDeployment(value: MsgCreateDeployment) { + return { + typeUrl: "/akash.deployment.v1beta2.MsgCreateDeployment", + value: MsgCreateDeployment.fromPartial(value) + }; + }, + depositDeployment(value: MsgDepositDeployment) { + return { + typeUrl: "/akash.deployment.v1beta2.MsgDepositDeployment", + value: MsgDepositDeployment.fromPartial(value) + }; + }, + updateDeployment(value: MsgUpdateDeployment) { + return { + typeUrl: "/akash.deployment.v1beta2.MsgUpdateDeployment", + value: MsgUpdateDeployment.fromPartial(value) + }; + }, + closeDeployment(value: MsgCloseDeployment) { + return { + typeUrl: "/akash.deployment.v1beta2.MsgCloseDeployment", + value: MsgCloseDeployment.fromPartial(value) + }; + }, + closeGroup(value: MsgCloseGroup) { + return { + typeUrl: "/akash.deployment.v1beta2.MsgCloseGroup", + value: MsgCloseGroup.fromPartial(value) + }; + }, + pauseGroup(value: MsgPauseGroup) { + return { + typeUrl: "/akash.deployment.v1beta2.MsgPauseGroup", + value: MsgPauseGroup.fromPartial(value) + }; + }, + startGroup(value: MsgStartGroup) { + return { + typeUrl: "/akash.deployment.v1beta2.MsgStartGroup", + value: MsgStartGroup.fromPartial(value) + }; + } + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta2/service.rpc.func.ts b/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta2/service.rpc.func.ts new file mode 100644 index 0000000000..965bdbe80d --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta2/service.rpc.func.ts @@ -0,0 +1,68 @@ +import { buildTx, SigningClientResolver } from "../../../helper-func-types"; +import { buildUseMutation } from "../../../react-query"; +import { toEncoders, toConverters } from "@interchainjs/cosmos/utils"; +import { MsgCreateDeployment, MsgDepositDeployment, MsgUpdateDeployment, MsgCloseDeployment } from "./deploymentmsg"; +import { MsgCloseGroup, MsgPauseGroup, MsgStartGroup } from "./groupmsg"; +export const createCreateDeployment = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgCreateDeployment.typeUrl, + encoders: toEncoders(MsgCreateDeployment), + converters: toConverters(MsgCreateDeployment) +}); +export const useCreateDeployment = buildUseMutation({ + builderMutationFn: createCreateDeployment +}); +export const createDepositDeployment = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgDepositDeployment.typeUrl, + encoders: toEncoders(MsgDepositDeployment), + converters: toConverters(MsgDepositDeployment) +}); +export const useDepositDeployment = buildUseMutation({ + builderMutationFn: createDepositDeployment +}); +export const createUpdateDeployment = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgUpdateDeployment.typeUrl, + encoders: toEncoders(MsgUpdateDeployment), + converters: toConverters(MsgUpdateDeployment) +}); +export const useUpdateDeployment = buildUseMutation({ + builderMutationFn: createUpdateDeployment +}); +export const createCloseDeployment = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgCloseDeployment.typeUrl, + encoders: toEncoders(MsgCloseDeployment), + converters: toConverters(MsgCloseDeployment) +}); +export const useCloseDeployment = buildUseMutation({ + builderMutationFn: createCloseDeployment +}); +export const createCloseGroup = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgCloseGroup.typeUrl, + encoders: toEncoders(MsgCloseGroup), + converters: toConverters(MsgCloseGroup) +}); +export const useCloseGroup = buildUseMutation({ + builderMutationFn: createCloseGroup +}); +export const createPauseGroup = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgPauseGroup.typeUrl, + encoders: toEncoders(MsgPauseGroup), + converters: toConverters(MsgPauseGroup) +}); +export const usePauseGroup = buildUseMutation({ + builderMutationFn: createPauseGroup +}); +export const createStartGroup = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgStartGroup.typeUrl, + encoders: toEncoders(MsgStartGroup), + converters: toConverters(MsgStartGroup) +}); +export const useStartGroup = buildUseMutation({ + builderMutationFn: createStartGroup +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta2/service.rpc.msg.ts b/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta2/service.rpc.msg.ts new file mode 100644 index 0000000000..b9636cf3dd --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta2/service.rpc.msg.ts @@ -0,0 +1,76 @@ +import { DeploymentID, DeploymentIDSDKType } from "./deployment.js"; +import { GroupSpec, GroupSpecSDKType } from "./groupspec.js"; +import { Coin, CoinSDKType } from "../../../cosmos/base/v1beta1/coin.js"; +import { GroupID, GroupIDSDKType } from "./groupid.js"; +import { Rpc } from "../../../helpers.js"; +import { BinaryReader } from "../../../binary.js"; +import { MsgCreateDeployment, MsgCreateDeploymentSDKType, MsgCreateDeploymentResponse, MsgCreateDeploymentResponseSDKType, MsgDepositDeployment, MsgDepositDeploymentSDKType, MsgDepositDeploymentResponse, MsgDepositDeploymentResponseSDKType, MsgUpdateDeployment, MsgUpdateDeploymentSDKType, MsgUpdateDeploymentResponse, MsgUpdateDeploymentResponseSDKType, MsgCloseDeployment, MsgCloseDeploymentSDKType, MsgCloseDeploymentResponse, MsgCloseDeploymentResponseSDKType } from "./deploymentmsg.js"; +import { MsgCloseGroup, MsgCloseGroupSDKType, MsgCloseGroupResponse, MsgCloseGroupResponseSDKType, MsgPauseGroup, MsgPauseGroupSDKType, MsgPauseGroupResponse, MsgPauseGroupResponseSDKType, MsgStartGroup, MsgStartGroupSDKType, MsgStartGroupResponse, MsgStartGroupResponseSDKType } from "./groupmsg.js"; +/** Msg defines the deployment Msg service. */ +export interface Msg { + /** CreateDeployment defines a method to create new deployment given proper inputs. */ + createDeployment(request: MsgCreateDeployment): Promise; + /** DepositDeployment deposits more funds into the deployment account */ + depositDeployment(request: MsgDepositDeployment): Promise; + /** UpdateDeployment defines a method to update a deployment given proper inputs. */ + updateDeployment(request: MsgUpdateDeployment): Promise; + /** CloseDeployment defines a method to close a deployment given proper inputs. */ + closeDeployment(request: MsgCloseDeployment): Promise; + /** CloseGroup defines a method to close a group of a deployment given proper inputs. */ + closeGroup(request: MsgCloseGroup): Promise; + /** PauseGroup defines a method to close a group of a deployment given proper inputs. */ + pauseGroup(request: MsgPauseGroup): Promise; + /** StartGroup defines a method to close a group of a deployment given proper inputs. */ + startGroup(request: MsgStartGroup): Promise; +} +export class MsgClientImpl implements Msg { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + } + /* CreateDeployment defines a method to create new deployment given proper inputs. */ + createDeployment = async (request: MsgCreateDeployment): Promise => { + const data = MsgCreateDeployment.encode(request).finish(); + const promise = this.rpc.request("akash.deployment.v1beta2.Msg", "CreateDeployment", data); + return promise.then(data => MsgCreateDeploymentResponse.decode(new BinaryReader(data))); + }; + /* DepositDeployment deposits more funds into the deployment account */ + depositDeployment = async (request: MsgDepositDeployment): Promise => { + const data = MsgDepositDeployment.encode(request).finish(); + const promise = this.rpc.request("akash.deployment.v1beta2.Msg", "DepositDeployment", data); + return promise.then(data => MsgDepositDeploymentResponse.decode(new BinaryReader(data))); + }; + /* UpdateDeployment defines a method to update a deployment given proper inputs. */ + updateDeployment = async (request: MsgUpdateDeployment): Promise => { + const data = MsgUpdateDeployment.encode(request).finish(); + const promise = this.rpc.request("akash.deployment.v1beta2.Msg", "UpdateDeployment", data); + return promise.then(data => MsgUpdateDeploymentResponse.decode(new BinaryReader(data))); + }; + /* CloseDeployment defines a method to close a deployment given proper inputs. */ + closeDeployment = async (request: MsgCloseDeployment): Promise => { + const data = MsgCloseDeployment.encode(request).finish(); + const promise = this.rpc.request("akash.deployment.v1beta2.Msg", "CloseDeployment", data); + return promise.then(data => MsgCloseDeploymentResponse.decode(new BinaryReader(data))); + }; + /* CloseGroup defines a method to close a group of a deployment given proper inputs. */ + closeGroup = async (request: MsgCloseGroup): Promise => { + const data = MsgCloseGroup.encode(request).finish(); + const promise = this.rpc.request("akash.deployment.v1beta2.Msg", "CloseGroup", data); + return promise.then(data => MsgCloseGroupResponse.decode(new BinaryReader(data))); + }; + /* PauseGroup defines a method to close a group of a deployment given proper inputs. */ + pauseGroup = async (request: MsgPauseGroup): Promise => { + const data = MsgPauseGroup.encode(request).finish(); + const promise = this.rpc.request("akash.deployment.v1beta2.Msg", "PauseGroup", data); + return promise.then(data => MsgPauseGroupResponse.decode(new BinaryReader(data))); + }; + /* StartGroup defines a method to close a group of a deployment given proper inputs. */ + startGroup = async (request: MsgStartGroup): Promise => { + const data = MsgStartGroup.encode(request).finish(); + const promise = this.rpc.request("akash.deployment.v1beta2.Msg", "StartGroup", data); + return promise.then(data => MsgStartGroupResponse.decode(new BinaryReader(data))); + }; +} +export const createClientImpl = (rpc: Rpc) => { + return new MsgClientImpl(rpc); +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta2/service.ts b/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta2/service.ts new file mode 100644 index 0000000000..693da49fc4 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/deployment/v1beta2/service.ts @@ -0,0 +1 @@ +export {} \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/escrow/v1beta1/genesis.ts b/__fixtures__/v-next/outputicjsdeps/akash/escrow/v1beta1/genesis.ts new file mode 100644 index 0000000000..d5f63cbc70 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/escrow/v1beta1/genesis.ts @@ -0,0 +1,150 @@ +import { Account, AccountSDKType, Payment, PaymentSDKType } from "./types.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { JsonSafe } from "../../../json-safe.js"; +import { DeepPartial, Exact } from "../../../helpers.js"; +export const protobufPackage = "akash.escrow.v1beta1"; +/** GenesisState defines the basic genesis state used by escrow module */ +export interface GenesisState { + accounts: Account[]; + payments: Payment[]; +} +export interface GenesisStateProtoMsg { + typeUrl: "/akash.escrow.v1beta1.GenesisState"; + value: Uint8Array; +} +/** GenesisState defines the basic genesis state used by escrow module */ +export interface GenesisStateSDKType { + accounts: AccountSDKType[]; + payments: PaymentSDKType[]; +} +function createBaseGenesisState(): GenesisState { + return { + accounts: [], + payments: [] + }; +} +export const GenesisState = { + typeUrl: "/akash.escrow.v1beta1.GenesisState", + encode(message: GenesisState, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.accounts) { + Account.encode(v!, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.payments) { + Payment.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GenesisState { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGenesisState(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.accounts.push(Account.decode(reader, reader.uint32())); + break; + case 2: + message.payments.push(Payment.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GenesisState { + const obj = createBaseGenesisState(); + if (Array.isArray(object?.accounts)) obj.accounts = object.accounts.map((e: any) => Account.fromJSON(e)); + if (Array.isArray(object?.payments)) obj.payments = object.payments.map((e: any) => Payment.fromJSON(e)); + return obj; + }, + toJSON(message: GenesisState): JsonSafe { + const obj: any = {}; + if (message.accounts) { + obj.accounts = message.accounts.map(e => e ? Account.toJSON(e) : undefined); + } else { + obj.accounts = []; + } + if (message.payments) { + obj.payments = message.payments.map(e => e ? Payment.toJSON(e) : undefined); + } else { + obj.payments = []; + } + return obj; + }, + fromPartial, I>>(object: I): GenesisState { + const message = createBaseGenesisState(); + message.accounts = object.accounts?.map(e => Account.fromPartial(e)) || []; + message.payments = object.payments?.map(e => Payment.fromPartial(e)) || []; + return message; + }, + fromSDK(object: GenesisStateSDKType): GenesisState { + return { + accounts: Array.isArray(object?.accounts) ? object.accounts.map((e: any) => Account.fromSDK(e)) : [], + payments: Array.isArray(object?.payments) ? object.payments.map((e: any) => Payment.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): GenesisStateSDKType { + return { + accounts: Array.isArray(object?.accounts) ? object.accounts.map((e: any) => Account.fromSDKJSON(e)) : [], + payments: Array.isArray(object?.payments) ? object.payments.map((e: any) => Payment.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: GenesisState): GenesisStateSDKType { + const obj: any = {}; + if (message.accounts) { + obj.accounts = message.accounts.map(e => e ? Account.toSDK(e) : undefined); + } else { + obj.accounts = []; + } + if (message.payments) { + obj.payments = message.payments.map(e => e ? Payment.toSDK(e) : undefined); + } else { + obj.payments = []; + } + return obj; + }, + fromAmino(object: GenesisStateAmino): GenesisState { + const message = createBaseGenesisState(); + message.accounts = object.accounts?.map(e => Account.fromAmino(e)) || []; + message.payments = object.payments?.map(e => Payment.fromAmino(e)) || []; + return message; + }, + toAmino(message: GenesisState): GenesisStateAmino { + const obj: any = {}; + if (message.accounts) { + obj.accounts = message.accounts.map(e => e ? Account.toAmino(e) : undefined); + } else { + obj.accounts = message.accounts; + } + if (message.payments) { + obj.payments = message.payments.map(e => e ? Payment.toAmino(e) : undefined); + } else { + obj.payments = message.payments; + } + return obj; + }, + fromAminoMsg(object: GenesisStateAminoMsg): GenesisState { + return GenesisState.fromAmino(object.value); + }, + toAminoMsg(message: GenesisState): GenesisStateAminoMsg { + return { + type: "akash/escrow/genesis-state", + value: GenesisState.toAmino(message) + }; + }, + fromProtoMsg(message: GenesisStateProtoMsg): GenesisState { + return GenesisState.decode(message.value); + }, + toProto(message: GenesisState): Uint8Array { + return GenesisState.encode(message).finish(); + }, + toProtoMsg(message: GenesisState): GenesisStateProtoMsg { + return { + typeUrl: "/akash.escrow.v1beta1.GenesisState", + value: GenesisState.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/escrow/v1beta1/query.lcd.ts b/__fixtures__/v-next/outputicjsdeps/akash/escrow/v1beta1/query.lcd.ts new file mode 100644 index 0000000000..8e2e4586d4 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/escrow/v1beta1/query.lcd.ts @@ -0,0 +1,68 @@ +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../../cosmos/base/query/v1beta1/pagination.js"; +import { Account, AccountSDKType, Payment, PaymentSDKType } from "./types.js"; +import { setPaginationParams } from "../../../helpers.js"; +import { LCDClient } from "@cosmology/lcd"; +import { QueryAccountsRequest, QueryAccountsRequestSDKType, QueryAccountsResponse, QueryAccountsResponseSDKType, QueryPaymentsRequest, QueryPaymentsRequestSDKType, QueryPaymentsResponse, QueryPaymentsResponseSDKType } from "./query.js"; +export class LCDQueryClient { + req: LCDClient; + constructor({ + requestClient + }: { + requestClient: LCDClient; + }) { + this.req = requestClient; + } + /* buf:lint:ignore RPC_REQUEST_RESPONSE_UNIQUE + buf:lint:ignore RPC_RESPONSE_STANDARD_NAME + Accounts queries all accounts */ + accounts = async (params: QueryAccountsRequest): Promise => { + const options: any = { + params: {} + }; + if (typeof params?.scope !== "undefined") { + options.params.scope = params.scope; + } + if (typeof params?.xid !== "undefined") { + options.params.xid = params.xid; + } + if (typeof params?.owner !== "undefined") { + options.params.owner = params.owner; + } + if (typeof params?.state !== "undefined") { + options.params.state = params.state; + } + if (typeof params?.pagination !== "undefined") { + setPaginationParams(options, params.pagination); + } + const endpoint = `akash/escrow/v1beta1/types/accounts/list`; + return QueryAccountsResponse.fromSDKJSON(await this.req.get(endpoint, options)); + }; + /* buf:lint:ignore RPC_REQUEST_RESPONSE_UNIQUE + buf:lint:ignore RPC_RESPONSE_STANDARD_NAME + Payments queries all payments */ + payments = async (params: QueryPaymentsRequest): Promise => { + const options: any = { + params: {} + }; + if (typeof params?.scope !== "undefined") { + options.params.scope = params.scope; + } + if (typeof params?.xid !== "undefined") { + options.params.xid = params.xid; + } + if (typeof params?.id !== "undefined") { + options.params.id = params.id; + } + if (typeof params?.owner !== "undefined") { + options.params.owner = params.owner; + } + if (typeof params?.state !== "undefined") { + options.params.state = params.state; + } + if (typeof params?.pagination !== "undefined") { + setPaginationParams(options, params.pagination); + } + const endpoint = `akash/escrow/v1beta1/types/payments/list`; + return QueryPaymentsResponse.fromSDKJSON(await this.req.get(endpoint, options)); + }; +} \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/escrow/v1beta1/query.rpc.Query.ts b/__fixtures__/v-next/outputicjsdeps/akash/escrow/v1beta1/query.rpc.Query.ts new file mode 100644 index 0000000000..5b8a13eb57 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/escrow/v1beta1/query.rpc.Query.ts @@ -0,0 +1,55 @@ +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../../cosmos/base/query/v1beta1/pagination.js"; +import { Account, AccountSDKType, Payment, PaymentSDKType } from "./types.js"; +import { Rpc } from "../../../helpers.js"; +import { BinaryReader } from "../../../binary.js"; +import { QueryClient, createProtobufRpcClient } from "@cosmjs/stargate"; +import { QueryAccountsRequest, QueryAccountsRequestSDKType, QueryAccountsResponse, QueryAccountsResponseSDKType, QueryPaymentsRequest, QueryPaymentsRequestSDKType, QueryPaymentsResponse, QueryPaymentsResponseSDKType } from "./query.js"; +/** Query defines the gRPC querier service */ +export interface Query { + /** + * buf:lint:ignore RPC_REQUEST_RESPONSE_UNIQUE + * buf:lint:ignore RPC_RESPONSE_STANDARD_NAME + * Accounts queries all accounts + */ + accounts(request: QueryAccountsRequest): Promise; + /** + * buf:lint:ignore RPC_REQUEST_RESPONSE_UNIQUE + * buf:lint:ignore RPC_RESPONSE_STANDARD_NAME + * Payments queries all payments + */ + payments(request: QueryPaymentsRequest): Promise; +} +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + } + /* buf:lint:ignore RPC_REQUEST_RESPONSE_UNIQUE + buf:lint:ignore RPC_RESPONSE_STANDARD_NAME + Accounts queries all accounts */ + accounts = async (request: QueryAccountsRequest): Promise => { + const data = QueryAccountsRequest.encode(request).finish(); + const promise = this.rpc.request("akash.escrow.v1beta1.Query", "Accounts", data); + return promise.then(data => QueryAccountsResponse.decode(new BinaryReader(data))); + }; + /* buf:lint:ignore RPC_REQUEST_RESPONSE_UNIQUE + buf:lint:ignore RPC_RESPONSE_STANDARD_NAME + Payments queries all payments */ + payments = async (request: QueryPaymentsRequest): Promise => { + const data = QueryPaymentsRequest.encode(request).finish(); + const promise = this.rpc.request("akash.escrow.v1beta1.Query", "Payments", data); + return promise.then(data => QueryPaymentsResponse.decode(new BinaryReader(data))); + }; +} +export const createRpcQueryExtension = (base: QueryClient) => { + const rpc = createProtobufRpcClient(base); + const queryService = new QueryClientImpl(rpc); + return { + accounts(request: QueryAccountsRequest): Promise { + return queryService.accounts(request); + }, + payments(request: QueryPaymentsRequest): Promise { + return queryService.payments(request); + } + }; +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/escrow/v1beta1/query.rpc.func.ts b/__fixtures__/v-next/outputicjsdeps/akash/escrow/v1beta1/query.rpc.func.ts new file mode 100644 index 0000000000..0aa868170c --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/escrow/v1beta1/query.rpc.func.ts @@ -0,0 +1,25 @@ +import { RpcResolver, buildQuery } from "../../../helper-func-types"; +import { buildUseQuery } from "../../../react-query"; +import { QueryAccountsRequest, QueryAccountsResponse, QueryPaymentsRequest, QueryPaymentsResponse } from "./query"; +export const createGetAccounts = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryAccountsRequest.encode, + decode: QueryAccountsResponse.decode, + service: "akash.escrow.v1beta1.Query", + method: "Accounts", + getRpcInstance: getRpcInstance +}); +export const useGetAccounts = buildUseQuery({ + builderQueryFn: createGetAccounts, + queryKeyPrefix: "AccountsQuery" +}); +export const createGetPayments = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryPaymentsRequest.encode, + decode: QueryPaymentsResponse.decode, + service: "akash.escrow.v1beta1.Query", + method: "Payments", + getRpcInstance: getRpcInstance +}); +export const useGetPayments = buildUseQuery({ + builderQueryFn: createGetPayments, + queryKeyPrefix: "PaymentsQuery" +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/escrow/v1beta1/query.ts b/__fixtures__/v-next/outputicjsdeps/akash/escrow/v1beta1/query.ts new file mode 100644 index 0000000000..41d131decd --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/escrow/v1beta1/query.ts @@ -0,0 +1,667 @@ +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../../cosmos/base/query/v1beta1/pagination.js"; +import { Account, AccountSDKType, Payment, PaymentSDKType } from "./types.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial, Exact } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "akash.escrow.v1beta1"; +/** QueryAccountRequest is request type for the Query/Account RPC method */ +export interface QueryAccountsRequest { + scope: string; + xid: string; + owner: string; + state: string; + pagination?: PageRequest; +} +export interface QueryAccountsRequestProtoMsg { + typeUrl: "/akash.escrow.v1beta1.QueryAccountsRequest"; + value: Uint8Array; +} +/** QueryAccountRequest is request type for the Query/Account RPC method */ +export interface QueryAccountsRequestSDKType { + scope: string; + xid: string; + owner: string; + state: string; + pagination?: PageRequestSDKType; +} +/** QueryProvidersResponse is response type for the Query/Providers RPC method */ +export interface QueryAccountsResponse { + accounts: Account[]; + pagination?: PageResponse; +} +export interface QueryAccountsResponseProtoMsg { + typeUrl: "/akash.escrow.v1beta1.QueryAccountsResponse"; + value: Uint8Array; +} +/** QueryProvidersResponse is response type for the Query/Providers RPC method */ +export interface QueryAccountsResponseSDKType { + accounts: AccountSDKType[]; + pagination?: PageResponseSDKType; +} +/** QueryPaymentRequest is request type for the Query/Payment RPC method */ +export interface QueryPaymentsRequest { + scope: string; + xid: string; + id: string; + owner: string; + state: string; + pagination?: PageRequest; +} +export interface QueryPaymentsRequestProtoMsg { + typeUrl: "/akash.escrow.v1beta1.QueryPaymentsRequest"; + value: Uint8Array; +} +/** QueryPaymentRequest is request type for the Query/Payment RPC method */ +export interface QueryPaymentsRequestSDKType { + scope: string; + xid: string; + id: string; + owner: string; + state: string; + pagination?: PageRequestSDKType; +} +/** QueryProvidersResponse is response type for the Query/Providers RPC method */ +export interface QueryPaymentsResponse { + payments: Payment[]; + pagination?: PageResponse; +} +export interface QueryPaymentsResponseProtoMsg { + typeUrl: "/akash.escrow.v1beta1.QueryPaymentsResponse"; + value: Uint8Array; +} +/** QueryProvidersResponse is response type for the Query/Providers RPC method */ +export interface QueryPaymentsResponseSDKType { + payments: PaymentSDKType[]; + pagination?: PageResponseSDKType; +} +function createBaseQueryAccountsRequest(): QueryAccountsRequest { + return { + scope: "", + xid: "", + owner: "", + state: "", + pagination: undefined + }; +} +export const QueryAccountsRequest = { + typeUrl: "/akash.escrow.v1beta1.QueryAccountsRequest", + encode(message: QueryAccountsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.scope !== undefined) { + writer.uint32(10).string(message.scope); + } + if (message.xid !== undefined) { + writer.uint32(18).string(message.xid); + } + if (message.owner !== undefined) { + writer.uint32(26).string(message.owner); + } + if (message.state !== undefined) { + writer.uint32(34).string(message.state); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(42).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryAccountsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryAccountsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.scope = reader.string(); + break; + case 2: + message.xid = reader.string(); + break; + case 3: + message.owner = reader.string(); + break; + case 4: + message.state = reader.string(); + break; + case 5: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryAccountsRequest { + const obj = createBaseQueryAccountsRequest(); + if (isSet(object.scope)) obj.scope = String(object.scope); + if (isSet(object.xid)) obj.xid = String(object.xid); + if (isSet(object.owner)) obj.owner = String(object.owner); + if (isSet(object.state)) obj.state = String(object.state); + if (isSet(object.pagination)) obj.pagination = PageRequest.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryAccountsRequest): JsonSafe { + const obj: any = {}; + message.scope !== undefined && (obj.scope = message.scope); + message.xid !== undefined && (obj.xid = message.xid); + message.owner !== undefined && (obj.owner = message.owner); + message.state !== undefined && (obj.state = message.state); + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryAccountsRequest { + const message = createBaseQueryAccountsRequest(); + message.scope = object.scope ?? ""; + message.xid = object.xid ?? ""; + message.owner = object.owner ?? ""; + message.state = object.state ?? ""; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryAccountsRequestSDKType): QueryAccountsRequest { + return { + scope: object?.scope, + xid: object?.xid, + owner: object?.owner, + state: object?.state, + pagination: object.pagination ? PageRequest.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryAccountsRequestSDKType { + return { + scope: isSet(object.scope) ? String(object.scope) : "", + xid: isSet(object.xid) ? String(object.xid) : "", + owner: isSet(object.owner) ? String(object.owner) : "", + state: isSet(object.state) ? String(object.state) : "", + pagination: isSet(object.pagination) ? PageRequest.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryAccountsRequest): QueryAccountsRequestSDKType { + const obj: any = {}; + obj.scope = message.scope; + obj.xid = message.xid; + obj.owner = message.owner; + obj.state = message.state; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryAccountsRequestAmino): QueryAccountsRequest { + const message = createBaseQueryAccountsRequest(); + if (object.scope !== undefined && object.scope !== null) { + message.scope = object.scope; + } + if (object.xid !== undefined && object.xid !== null) { + message.xid = object.xid; + } + if (object.owner !== undefined && object.owner !== null) { + message.owner = object.owner; + } + if (object.state !== undefined && object.state !== null) { + message.state = object.state; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryAccountsRequest): QueryAccountsRequestAmino { + const obj: any = {}; + obj.scope = message.scope === "" ? undefined : message.scope; + obj.xid = message.xid === "" ? undefined : message.xid; + obj.owner = message.owner === "" ? undefined : message.owner; + obj.state = message.state === "" ? undefined : message.state; + obj.pagination = message.pagination ? PageRequest.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryAccountsRequestAminoMsg): QueryAccountsRequest { + return QueryAccountsRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryAccountsRequest): QueryAccountsRequestAminoMsg { + return { + type: "akash/escrow/query-accounts-request", + value: QueryAccountsRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryAccountsRequestProtoMsg): QueryAccountsRequest { + return QueryAccountsRequest.decode(message.value); + }, + toProto(message: QueryAccountsRequest): Uint8Array { + return QueryAccountsRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryAccountsRequest): QueryAccountsRequestProtoMsg { + return { + typeUrl: "/akash.escrow.v1beta1.QueryAccountsRequest", + value: QueryAccountsRequest.encode(message).finish() + }; + } +}; +function createBaseQueryAccountsResponse(): QueryAccountsResponse { + return { + accounts: [], + pagination: undefined + }; +} +export const QueryAccountsResponse = { + typeUrl: "/akash.escrow.v1beta1.QueryAccountsResponse", + encode(message: QueryAccountsResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.accounts) { + Account.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryAccountsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryAccountsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.accounts.push(Account.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryAccountsResponse { + const obj = createBaseQueryAccountsResponse(); + if (Array.isArray(object?.accounts)) obj.accounts = object.accounts.map((e: any) => Account.fromJSON(e)); + if (isSet(object.pagination)) obj.pagination = PageResponse.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryAccountsResponse): JsonSafe { + const obj: any = {}; + if (message.accounts) { + obj.accounts = message.accounts.map(e => e ? Account.toJSON(e) : undefined); + } else { + obj.accounts = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryAccountsResponse { + const message = createBaseQueryAccountsResponse(); + message.accounts = object.accounts?.map(e => Account.fromPartial(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryAccountsResponseSDKType): QueryAccountsResponse { + return { + accounts: Array.isArray(object?.accounts) ? object.accounts.map((e: any) => Account.fromSDK(e)) : [], + pagination: object.pagination ? PageResponse.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryAccountsResponseSDKType { + return { + accounts: Array.isArray(object?.accounts) ? object.accounts.map((e: any) => Account.fromSDKJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryAccountsResponse): QueryAccountsResponseSDKType { + const obj: any = {}; + if (message.accounts) { + obj.accounts = message.accounts.map(e => e ? Account.toSDK(e) : undefined); + } else { + obj.accounts = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryAccountsResponseAmino): QueryAccountsResponse { + const message = createBaseQueryAccountsResponse(); + message.accounts = object.accounts?.map(e => Account.fromAmino(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryAccountsResponse): QueryAccountsResponseAmino { + const obj: any = {}; + if (message.accounts) { + obj.accounts = message.accounts.map(e => e ? Account.toAmino(e) : undefined); + } else { + obj.accounts = message.accounts; + } + obj.pagination = message.pagination ? PageResponse.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryAccountsResponseAminoMsg): QueryAccountsResponse { + return QueryAccountsResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryAccountsResponse): QueryAccountsResponseAminoMsg { + return { + type: "akash/escrow/query-accounts-response", + value: QueryAccountsResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryAccountsResponseProtoMsg): QueryAccountsResponse { + return QueryAccountsResponse.decode(message.value); + }, + toProto(message: QueryAccountsResponse): Uint8Array { + return QueryAccountsResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryAccountsResponse): QueryAccountsResponseProtoMsg { + return { + typeUrl: "/akash.escrow.v1beta1.QueryAccountsResponse", + value: QueryAccountsResponse.encode(message).finish() + }; + } +}; +function createBaseQueryPaymentsRequest(): QueryPaymentsRequest { + return { + scope: "", + xid: "", + id: "", + owner: "", + state: "", + pagination: undefined + }; +} +export const QueryPaymentsRequest = { + typeUrl: "/akash.escrow.v1beta1.QueryPaymentsRequest", + encode(message: QueryPaymentsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.scope !== undefined) { + writer.uint32(10).string(message.scope); + } + if (message.xid !== undefined) { + writer.uint32(18).string(message.xid); + } + if (message.id !== undefined) { + writer.uint32(26).string(message.id); + } + if (message.owner !== undefined) { + writer.uint32(34).string(message.owner); + } + if (message.state !== undefined) { + writer.uint32(42).string(message.state); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(50).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryPaymentsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryPaymentsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.scope = reader.string(); + break; + case 2: + message.xid = reader.string(); + break; + case 3: + message.id = reader.string(); + break; + case 4: + message.owner = reader.string(); + break; + case 5: + message.state = reader.string(); + break; + case 6: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryPaymentsRequest { + const obj = createBaseQueryPaymentsRequest(); + if (isSet(object.scope)) obj.scope = String(object.scope); + if (isSet(object.xid)) obj.xid = String(object.xid); + if (isSet(object.id)) obj.id = String(object.id); + if (isSet(object.owner)) obj.owner = String(object.owner); + if (isSet(object.state)) obj.state = String(object.state); + if (isSet(object.pagination)) obj.pagination = PageRequest.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryPaymentsRequest): JsonSafe { + const obj: any = {}; + message.scope !== undefined && (obj.scope = message.scope); + message.xid !== undefined && (obj.xid = message.xid); + message.id !== undefined && (obj.id = message.id); + message.owner !== undefined && (obj.owner = message.owner); + message.state !== undefined && (obj.state = message.state); + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryPaymentsRequest { + const message = createBaseQueryPaymentsRequest(); + message.scope = object.scope ?? ""; + message.xid = object.xid ?? ""; + message.id = object.id ?? ""; + message.owner = object.owner ?? ""; + message.state = object.state ?? ""; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryPaymentsRequestSDKType): QueryPaymentsRequest { + return { + scope: object?.scope, + xid: object?.xid, + id: object?.id, + owner: object?.owner, + state: object?.state, + pagination: object.pagination ? PageRequest.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryPaymentsRequestSDKType { + return { + scope: isSet(object.scope) ? String(object.scope) : "", + xid: isSet(object.xid) ? String(object.xid) : "", + id: isSet(object.id) ? String(object.id) : "", + owner: isSet(object.owner) ? String(object.owner) : "", + state: isSet(object.state) ? String(object.state) : "", + pagination: isSet(object.pagination) ? PageRequest.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryPaymentsRequest): QueryPaymentsRequestSDKType { + const obj: any = {}; + obj.scope = message.scope; + obj.xid = message.xid; + obj.id = message.id; + obj.owner = message.owner; + obj.state = message.state; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryPaymentsRequestAmino): QueryPaymentsRequest { + const message = createBaseQueryPaymentsRequest(); + if (object.scope !== undefined && object.scope !== null) { + message.scope = object.scope; + } + if (object.xid !== undefined && object.xid !== null) { + message.xid = object.xid; + } + if (object.id !== undefined && object.id !== null) { + message.id = object.id; + } + if (object.owner !== undefined && object.owner !== null) { + message.owner = object.owner; + } + if (object.state !== undefined && object.state !== null) { + message.state = object.state; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryPaymentsRequest): QueryPaymentsRequestAmino { + const obj: any = {}; + obj.scope = message.scope === "" ? undefined : message.scope; + obj.xid = message.xid === "" ? undefined : message.xid; + obj.id = message.id === "" ? undefined : message.id; + obj.owner = message.owner === "" ? undefined : message.owner; + obj.state = message.state === "" ? undefined : message.state; + obj.pagination = message.pagination ? PageRequest.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryPaymentsRequestAminoMsg): QueryPaymentsRequest { + return QueryPaymentsRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryPaymentsRequest): QueryPaymentsRequestAminoMsg { + return { + type: "akash/escrow/query-payments-request", + value: QueryPaymentsRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryPaymentsRequestProtoMsg): QueryPaymentsRequest { + return QueryPaymentsRequest.decode(message.value); + }, + toProto(message: QueryPaymentsRequest): Uint8Array { + return QueryPaymentsRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryPaymentsRequest): QueryPaymentsRequestProtoMsg { + return { + typeUrl: "/akash.escrow.v1beta1.QueryPaymentsRequest", + value: QueryPaymentsRequest.encode(message).finish() + }; + } +}; +function createBaseQueryPaymentsResponse(): QueryPaymentsResponse { + return { + payments: [], + pagination: undefined + }; +} +export const QueryPaymentsResponse = { + typeUrl: "/akash.escrow.v1beta1.QueryPaymentsResponse", + encode(message: QueryPaymentsResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.payments) { + Payment.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryPaymentsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryPaymentsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.payments.push(Payment.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryPaymentsResponse { + const obj = createBaseQueryPaymentsResponse(); + if (Array.isArray(object?.payments)) obj.payments = object.payments.map((e: any) => Payment.fromJSON(e)); + if (isSet(object.pagination)) obj.pagination = PageResponse.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryPaymentsResponse): JsonSafe { + const obj: any = {}; + if (message.payments) { + obj.payments = message.payments.map(e => e ? Payment.toJSON(e) : undefined); + } else { + obj.payments = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryPaymentsResponse { + const message = createBaseQueryPaymentsResponse(); + message.payments = object.payments?.map(e => Payment.fromPartial(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryPaymentsResponseSDKType): QueryPaymentsResponse { + return { + payments: Array.isArray(object?.payments) ? object.payments.map((e: any) => Payment.fromSDK(e)) : [], + pagination: object.pagination ? PageResponse.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryPaymentsResponseSDKType { + return { + payments: Array.isArray(object?.payments) ? object.payments.map((e: any) => Payment.fromSDKJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryPaymentsResponse): QueryPaymentsResponseSDKType { + const obj: any = {}; + if (message.payments) { + obj.payments = message.payments.map(e => e ? Payment.toSDK(e) : undefined); + } else { + obj.payments = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryPaymentsResponseAmino): QueryPaymentsResponse { + const message = createBaseQueryPaymentsResponse(); + message.payments = object.payments?.map(e => Payment.fromAmino(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryPaymentsResponse): QueryPaymentsResponseAmino { + const obj: any = {}; + if (message.payments) { + obj.payments = message.payments.map(e => e ? Payment.toAmino(e) : undefined); + } else { + obj.payments = message.payments; + } + obj.pagination = message.pagination ? PageResponse.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryPaymentsResponseAminoMsg): QueryPaymentsResponse { + return QueryPaymentsResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryPaymentsResponse): QueryPaymentsResponseAminoMsg { + return { + type: "akash/escrow/query-payments-response", + value: QueryPaymentsResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryPaymentsResponseProtoMsg): QueryPaymentsResponse { + return QueryPaymentsResponse.decode(message.value); + }, + toProto(message: QueryPaymentsResponse): Uint8Array { + return QueryPaymentsResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryPaymentsResponse): QueryPaymentsResponseProtoMsg { + return { + typeUrl: "/akash.escrow.v1beta1.QueryPaymentsResponse", + value: QueryPaymentsResponse.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/escrow/v1beta1/types.ts b/__fixtures__/v-next/outputicjsdeps/akash/escrow/v1beta1/types.ts new file mode 100644 index 0000000000..9f121e6d6b --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/escrow/v1beta1/types.ts @@ -0,0 +1,669 @@ +import { Coin, CoinSDKType } from "../../../cosmos/base/v1beta1/coin.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial, Exact } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "akash.escrow.v1beta1"; +/** State stores state for an escrow account */ +export enum Account_State { + /** invalid - AccountStateInvalid is an invalid state */ + invalid = 0, + /** open - AccountOpen is the state when an account is open */ + open = 1, + /** closed - AccountClosed is the state when an account is closed */ + closed = 2, + /** overdrawn - AccountOverdrawn is the state when an account is overdrawn */ + overdrawn = 3, + UNRECOGNIZED = -1, +} +export const Account_StateSDKType = Account_State; +export function account_StateFromJSON(object: any): Account_State { + switch (object) { + case 0: + case "invalid": + return Account_State.invalid; + case 1: + case "open": + return Account_State.open; + case 2: + case "closed": + return Account_State.closed; + case 3: + case "overdrawn": + return Account_State.overdrawn; + case -1: + case "UNRECOGNIZED": + default: + return Account_State.UNRECOGNIZED; + } +} +export function account_StateToJSON(object: Account_State): string { + switch (object) { + case Account_State.invalid: + return "invalid"; + case Account_State.open: + return "open"; + case Account_State.closed: + return "closed"; + case Account_State.overdrawn: + return "overdrawn"; + case Account_State.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** Payment State */ +export enum Payment_State { + /** invalid - PaymentStateInvalid is the state when the payment is invalid */ + invalid = 0, + /** open - PaymentStateOpen is the state when the payment is open */ + open = 1, + /** closed - PaymentStateClosed is the state when the payment is closed */ + closed = 2, + /** overdrawn - PaymentStateOverdrawn is the state when the payment is overdrawn */ + overdrawn = 3, + UNRECOGNIZED = -1, +} +export const Payment_StateSDKType = Payment_State; +export function payment_StateFromJSON(object: any): Payment_State { + switch (object) { + case 0: + case "invalid": + return Payment_State.invalid; + case 1: + case "open": + return Payment_State.open; + case 2: + case "closed": + return Payment_State.closed; + case 3: + case "overdrawn": + return Payment_State.overdrawn; + case -1: + case "UNRECOGNIZED": + default: + return Payment_State.UNRECOGNIZED; + } +} +export function payment_StateToJSON(object: Payment_State): string { + switch (object) { + case Payment_State.invalid: + return "invalid"; + case Payment_State.open: + return "open"; + case Payment_State.closed: + return "closed"; + case Payment_State.overdrawn: + return "overdrawn"; + case Payment_State.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** AccountID is the account identifier */ +export interface AccountID { + scope: string; + xid: string; +} +export interface AccountIDProtoMsg { + typeUrl: "/akash.escrow.v1beta1.AccountID"; + value: Uint8Array; +} +/** AccountID is the account identifier */ +export interface AccountIDSDKType { + scope: string; + xid: string; +} +/** Account stores state for an escrow account */ +export interface Account { + /** unique identifier for this escrow account */ + id: AccountID; + /** bech32 encoded account address of the owner of this escrow account */ + owner: string; + /** current state of this escrow account */ + state: Account_State; + /** unspent coins received from the owner's wallet */ + balance: Coin; + /** total coins spent by this account */ + transferred: Coin; + /** block height at which this account was last settled */ + settledAt: bigint; +} +export interface AccountProtoMsg { + typeUrl: "/akash.escrow.v1beta1.Account"; + value: Uint8Array; +} +/** Account stores state for an escrow account */ +export interface AccountSDKType { + id: AccountIDSDKType; + owner: string; + state: Account_State; + balance: CoinSDKType; + transferred: CoinSDKType; + settled_at: bigint; +} +/** Payment stores state for a payment */ +export interface Payment { + accountId: AccountID; + paymentId: string; + owner: string; + state: Payment_State; + rate: Coin; + balance: Coin; + withdrawn: Coin; +} +export interface PaymentProtoMsg { + typeUrl: "/akash.escrow.v1beta1.Payment"; + value: Uint8Array; +} +/** Payment stores state for a payment */ +export interface PaymentSDKType { + account_id: AccountIDSDKType; + payment_id: string; + owner: string; + state: Payment_State; + rate: CoinSDKType; + balance: CoinSDKType; + withdrawn: CoinSDKType; +} +function createBaseAccountID(): AccountID { + return { + scope: "", + xid: "" + }; +} +export const AccountID = { + typeUrl: "/akash.escrow.v1beta1.AccountID", + encode(message: AccountID, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.scope !== undefined) { + writer.uint32(10).string(message.scope); + } + if (message.xid !== undefined) { + writer.uint32(18).string(message.xid); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): AccountID { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseAccountID(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.scope = reader.string(); + break; + case 2: + message.xid = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): AccountID { + const obj = createBaseAccountID(); + if (isSet(object.scope)) obj.scope = String(object.scope); + if (isSet(object.xid)) obj.xid = String(object.xid); + return obj; + }, + toJSON(message: AccountID): JsonSafe { + const obj: any = {}; + message.scope !== undefined && (obj.scope = message.scope); + message.xid !== undefined && (obj.xid = message.xid); + return obj; + }, + fromPartial, I>>(object: I): AccountID { + const message = createBaseAccountID(); + message.scope = object.scope ?? ""; + message.xid = object.xid ?? ""; + return message; + }, + fromSDK(object: AccountIDSDKType): AccountID { + return { + scope: object?.scope, + xid: object?.xid + }; + }, + fromSDKJSON(object: any): AccountIDSDKType { + return { + scope: isSet(object.scope) ? String(object.scope) : "", + xid: isSet(object.xid) ? String(object.xid) : "" + }; + }, + toSDK(message: AccountID): AccountIDSDKType { + const obj: any = {}; + obj.scope = message.scope; + obj.xid = message.xid; + return obj; + }, + fromAmino(object: AccountIDAmino): AccountID { + const message = createBaseAccountID(); + if (object.scope !== undefined && object.scope !== null) { + message.scope = object.scope; + } + if (object.xid !== undefined && object.xid !== null) { + message.xid = object.xid; + } + return message; + }, + toAmino(message: AccountID): AccountIDAmino { + const obj: any = {}; + obj.scope = message.scope ?? ""; + obj.xid = message.xid ?? ""; + return obj; + }, + fromAminoMsg(object: AccountIDAminoMsg): AccountID { + return AccountID.fromAmino(object.value); + }, + toAminoMsg(message: AccountID): AccountIDAminoMsg { + return { + type: "akash/escrow/account-i-d", + value: AccountID.toAmino(message) + }; + }, + fromProtoMsg(message: AccountIDProtoMsg): AccountID { + return AccountID.decode(message.value); + }, + toProto(message: AccountID): Uint8Array { + return AccountID.encode(message).finish(); + }, + toProtoMsg(message: AccountID): AccountIDProtoMsg { + return { + typeUrl: "/akash.escrow.v1beta1.AccountID", + value: AccountID.encode(message).finish() + }; + } +}; +function createBaseAccount(): Account { + return { + id: AccountID.fromPartial({}), + owner: "", + state: 0, + balance: Coin.fromPartial({}), + transferred: Coin.fromPartial({}), + settledAt: BigInt(0) + }; +} +export const Account = { + typeUrl: "/akash.escrow.v1beta1.Account", + encode(message: Account, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.id !== undefined) { + AccountID.encode(message.id, writer.uint32(10).fork()).ldelim(); + } + if (message.owner !== undefined) { + writer.uint32(18).string(message.owner); + } + if (message.state !== 0) { + writer.uint32(24).int32(message.state); + } + if (message.balance !== undefined) { + Coin.encode(message.balance, writer.uint32(34).fork()).ldelim(); + } + if (message.transferred !== undefined) { + Coin.encode(message.transferred, writer.uint32(42).fork()).ldelim(); + } + if (message.settledAt !== undefined) { + writer.uint32(48).int64(message.settledAt); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Account { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseAccount(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.id = AccountID.decode(reader, reader.uint32()); + break; + case 2: + message.owner = reader.string(); + break; + case 3: + message.state = (reader.int32() as any); + break; + case 4: + message.balance = Coin.decode(reader, reader.uint32()); + break; + case 5: + message.transferred = Coin.decode(reader, reader.uint32()); + break; + case 6: + message.settledAt = reader.int64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Account { + const obj = createBaseAccount(); + if (isSet(object.id)) obj.id = AccountID.fromJSON(object.id); + if (isSet(object.owner)) obj.owner = String(object.owner); + if (isSet(object.state)) obj.state = account_StateFromJSON(object.state); + if (isSet(object.balance)) obj.balance = Coin.fromJSON(object.balance); + if (isSet(object.transferred)) obj.transferred = Coin.fromJSON(object.transferred); + if (isSet(object.settledAt)) obj.settledAt = BigInt(object.settledAt.toString()); + return obj; + }, + toJSON(message: Account): JsonSafe { + const obj: any = {}; + message.id !== undefined && (obj.id = message.id ? AccountID.toJSON(message.id) : undefined); + message.owner !== undefined && (obj.owner = message.owner); + message.state !== undefined && (obj.state = account_StateToJSON(message.state)); + message.balance !== undefined && (obj.balance = message.balance ? Coin.toJSON(message.balance) : undefined); + message.transferred !== undefined && (obj.transferred = message.transferred ? Coin.toJSON(message.transferred) : undefined); + message.settledAt !== undefined && (obj.settledAt = (message.settledAt || BigInt(0)).toString()); + return obj; + }, + fromPartial, I>>(object: I): Account { + const message = createBaseAccount(); + if (object.id !== undefined && object.id !== null) { + message.id = AccountID.fromPartial(object.id); + } + message.owner = object.owner ?? ""; + message.state = object.state ?? 0; + if (object.balance !== undefined && object.balance !== null) { + message.balance = Coin.fromPartial(object.balance); + } + if (object.transferred !== undefined && object.transferred !== null) { + message.transferred = Coin.fromPartial(object.transferred); + } + if (object.settledAt !== undefined && object.settledAt !== null) { + message.settledAt = BigInt(object.settledAt.toString()); + } + return message; + }, + fromSDK(object: AccountSDKType): Account { + return { + id: object.id ? AccountID.fromSDK(object.id) : undefined, + owner: object?.owner, + state: isSet(object.state) ? account_StateFromJSON(object.state) : -1, + balance: object.balance ? Coin.fromSDK(object.balance) : undefined, + transferred: object.transferred ? Coin.fromSDK(object.transferred) : undefined, + settledAt: object?.settled_at + }; + }, + fromSDKJSON(object: any): AccountSDKType { + return { + id: isSet(object.id) ? AccountID.fromSDKJSON(object.id) : undefined, + owner: isSet(object.owner) ? String(object.owner) : "", + state: isSet(object.state) ? account_StateFromJSON(object.state) : -1, + balance: isSet(object.balance) ? Coin.fromSDKJSON(object.balance) : undefined, + transferred: isSet(object.transferred) ? Coin.fromSDKJSON(object.transferred) : undefined, + settled_at: isSet(object.settled_at) ? BigInt(object.settled_at.toString()) : BigInt(0) + }; + }, + toSDK(message: Account): AccountSDKType { + const obj: any = {}; + message.id !== undefined && (obj.id = message.id ? AccountID.toSDK(message.id) : undefined); + obj.owner = message.owner; + message.state !== undefined && (obj.state = account_StateToJSON(message.state)); + message.balance !== undefined && (obj.balance = message.balance ? Coin.toSDK(message.balance) : undefined); + message.transferred !== undefined && (obj.transferred = message.transferred ? Coin.toSDK(message.transferred) : undefined); + obj.settled_at = message.settledAt; + return obj; + }, + fromAmino(object: AccountAmino): Account { + const message = createBaseAccount(); + if (object.id !== undefined && object.id !== null) { + message.id = AccountID.fromAmino(object.id); + } + if (object.owner !== undefined && object.owner !== null) { + message.owner = object.owner; + } + if (object.state !== undefined && object.state !== null) { + message.state = object.state; + } + if (object.balance !== undefined && object.balance !== null) { + message.balance = Coin.fromAmino(object.balance); + } + if (object.transferred !== undefined && object.transferred !== null) { + message.transferred = Coin.fromAmino(object.transferred); + } + if (object.settled_at !== undefined && object.settled_at !== null) { + message.settledAt = BigInt(object.settled_at); + } + return message; + }, + toAmino(message: Account): AccountAmino { + const obj: any = {}; + obj.id = message.id ? AccountID.toAmino(message.id) : AccountID.toAmino(AccountID.fromPartial({})); + obj.owner = message.owner ?? ""; + obj.state = message.state ?? 0; + obj.balance = message.balance ? Coin.toAmino(message.balance) : Coin.toAmino(Coin.fromPartial({})); + obj.transferred = message.transferred ? Coin.toAmino(message.transferred) : Coin.toAmino(Coin.fromPartial({})); + obj.settled_at = message.settledAt ? message.settledAt?.toString() : "0"; + return obj; + }, + fromAminoMsg(object: AccountAminoMsg): Account { + return Account.fromAmino(object.value); + }, + toAminoMsg(message: Account): AccountAminoMsg { + return { + type: "akash/escrow/account", + value: Account.toAmino(message) + }; + }, + fromProtoMsg(message: AccountProtoMsg): Account { + return Account.decode(message.value); + }, + toProto(message: Account): Uint8Array { + return Account.encode(message).finish(); + }, + toProtoMsg(message: Account): AccountProtoMsg { + return { + typeUrl: "/akash.escrow.v1beta1.Account", + value: Account.encode(message).finish() + }; + } +}; +function createBasePayment(): Payment { + return { + accountId: AccountID.fromPartial({}), + paymentId: "", + owner: "", + state: 0, + rate: Coin.fromPartial({}), + balance: Coin.fromPartial({}), + withdrawn: Coin.fromPartial({}) + }; +} +export const Payment = { + typeUrl: "/akash.escrow.v1beta1.Payment", + encode(message: Payment, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.accountId !== undefined) { + AccountID.encode(message.accountId, writer.uint32(10).fork()).ldelim(); + } + if (message.paymentId !== undefined) { + writer.uint32(18).string(message.paymentId); + } + if (message.owner !== undefined) { + writer.uint32(26).string(message.owner); + } + if (message.state !== 0) { + writer.uint32(32).int32(message.state); + } + if (message.rate !== undefined) { + Coin.encode(message.rate, writer.uint32(42).fork()).ldelim(); + } + if (message.balance !== undefined) { + Coin.encode(message.balance, writer.uint32(50).fork()).ldelim(); + } + if (message.withdrawn !== undefined) { + Coin.encode(message.withdrawn, writer.uint32(58).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Payment { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBasePayment(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.accountId = AccountID.decode(reader, reader.uint32()); + break; + case 2: + message.paymentId = reader.string(); + break; + case 3: + message.owner = reader.string(); + break; + case 4: + message.state = (reader.int32() as any); + break; + case 5: + message.rate = Coin.decode(reader, reader.uint32()); + break; + case 6: + message.balance = Coin.decode(reader, reader.uint32()); + break; + case 7: + message.withdrawn = Coin.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Payment { + const obj = createBasePayment(); + if (isSet(object.accountId)) obj.accountId = AccountID.fromJSON(object.accountId); + if (isSet(object.paymentId)) obj.paymentId = String(object.paymentId); + if (isSet(object.owner)) obj.owner = String(object.owner); + if (isSet(object.state)) obj.state = payment_StateFromJSON(object.state); + if (isSet(object.rate)) obj.rate = Coin.fromJSON(object.rate); + if (isSet(object.balance)) obj.balance = Coin.fromJSON(object.balance); + if (isSet(object.withdrawn)) obj.withdrawn = Coin.fromJSON(object.withdrawn); + return obj; + }, + toJSON(message: Payment): JsonSafe { + const obj: any = {}; + message.accountId !== undefined && (obj.accountId = message.accountId ? AccountID.toJSON(message.accountId) : undefined); + message.paymentId !== undefined && (obj.paymentId = message.paymentId); + message.owner !== undefined && (obj.owner = message.owner); + message.state !== undefined && (obj.state = payment_StateToJSON(message.state)); + message.rate !== undefined && (obj.rate = message.rate ? Coin.toJSON(message.rate) : undefined); + message.balance !== undefined && (obj.balance = message.balance ? Coin.toJSON(message.balance) : undefined); + message.withdrawn !== undefined && (obj.withdrawn = message.withdrawn ? Coin.toJSON(message.withdrawn) : undefined); + return obj; + }, + fromPartial, I>>(object: I): Payment { + const message = createBasePayment(); + if (object.accountId !== undefined && object.accountId !== null) { + message.accountId = AccountID.fromPartial(object.accountId); + } + message.paymentId = object.paymentId ?? ""; + message.owner = object.owner ?? ""; + message.state = object.state ?? 0; + if (object.rate !== undefined && object.rate !== null) { + message.rate = Coin.fromPartial(object.rate); + } + if (object.balance !== undefined && object.balance !== null) { + message.balance = Coin.fromPartial(object.balance); + } + if (object.withdrawn !== undefined && object.withdrawn !== null) { + message.withdrawn = Coin.fromPartial(object.withdrawn); + } + return message; + }, + fromSDK(object: PaymentSDKType): Payment { + return { + accountId: object.account_id ? AccountID.fromSDK(object.account_id) : undefined, + paymentId: object?.payment_id, + owner: object?.owner, + state: isSet(object.state) ? payment_StateFromJSON(object.state) : -1, + rate: object.rate ? Coin.fromSDK(object.rate) : undefined, + balance: object.balance ? Coin.fromSDK(object.balance) : undefined, + withdrawn: object.withdrawn ? Coin.fromSDK(object.withdrawn) : undefined + }; + }, + fromSDKJSON(object: any): PaymentSDKType { + return { + account_id: isSet(object.account_id) ? AccountID.fromSDKJSON(object.account_id) : undefined, + payment_id: isSet(object.payment_id) ? String(object.payment_id) : "", + owner: isSet(object.owner) ? String(object.owner) : "", + state: isSet(object.state) ? payment_StateFromJSON(object.state) : -1, + rate: isSet(object.rate) ? Coin.fromSDKJSON(object.rate) : undefined, + balance: isSet(object.balance) ? Coin.fromSDKJSON(object.balance) : undefined, + withdrawn: isSet(object.withdrawn) ? Coin.fromSDKJSON(object.withdrawn) : undefined + }; + }, + toSDK(message: Payment): PaymentSDKType { + const obj: any = {}; + message.accountId !== undefined && (obj.account_id = message.accountId ? AccountID.toSDK(message.accountId) : undefined); + obj.payment_id = message.paymentId; + obj.owner = message.owner; + message.state !== undefined && (obj.state = payment_StateToJSON(message.state)); + message.rate !== undefined && (obj.rate = message.rate ? Coin.toSDK(message.rate) : undefined); + message.balance !== undefined && (obj.balance = message.balance ? Coin.toSDK(message.balance) : undefined); + message.withdrawn !== undefined && (obj.withdrawn = message.withdrawn ? Coin.toSDK(message.withdrawn) : undefined); + return obj; + }, + fromAmino(object: PaymentAmino): Payment { + const message = createBasePayment(); + if (object.account_id !== undefined && object.account_id !== null) { + message.accountId = AccountID.fromAmino(object.account_id); + } + if (object.payment_id !== undefined && object.payment_id !== null) { + message.paymentId = object.payment_id; + } + if (object.owner !== undefined && object.owner !== null) { + message.owner = object.owner; + } + if (object.state !== undefined && object.state !== null) { + message.state = object.state; + } + if (object.rate !== undefined && object.rate !== null) { + message.rate = Coin.fromAmino(object.rate); + } + if (object.balance !== undefined && object.balance !== null) { + message.balance = Coin.fromAmino(object.balance); + } + if (object.withdrawn !== undefined && object.withdrawn !== null) { + message.withdrawn = Coin.fromAmino(object.withdrawn); + } + return message; + }, + toAmino(message: Payment): PaymentAmino { + const obj: any = {}; + obj.account_id = message.accountId ? AccountID.toAmino(message.accountId) : AccountID.toAmino(AccountID.fromPartial({})); + obj.payment_id = message.paymentId ?? ""; + obj.owner = message.owner ?? ""; + obj.state = message.state ?? 0; + obj.rate = message.rate ? Coin.toAmino(message.rate) : Coin.toAmino(Coin.fromPartial({})); + obj.balance = message.balance ? Coin.toAmino(message.balance) : Coin.toAmino(Coin.fromPartial({})); + obj.withdrawn = message.withdrawn ? Coin.toAmino(message.withdrawn) : Coin.toAmino(Coin.fromPartial({})); + return obj; + }, + fromAminoMsg(object: PaymentAminoMsg): Payment { + return Payment.fromAmino(object.value); + }, + toAminoMsg(message: Payment): PaymentAminoMsg { + return { + type: "akash/escrow/payment", + value: Payment.toAmino(message) + }; + }, + fromProtoMsg(message: PaymentProtoMsg): Payment { + return Payment.decode(message.value); + }, + toProto(message: Payment): Uint8Array { + return Payment.encode(message).finish(); + }, + toProtoMsg(message: Payment): PaymentProtoMsg { + return { + typeUrl: "/akash.escrow.v1beta1.Payment", + value: Payment.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/escrow/v1beta2/genesis.ts b/__fixtures__/v-next/outputicjsdeps/akash/escrow/v1beta2/genesis.ts new file mode 100644 index 0000000000..289b809e01 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/escrow/v1beta2/genesis.ts @@ -0,0 +1,150 @@ +import { Account, AccountSDKType, FractionalPayment, FractionalPaymentSDKType } from "./types.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { JsonSafe } from "../../../json-safe.js"; +import { DeepPartial, Exact } from "../../../helpers.js"; +export const protobufPackage = "akash.escrow.v1beta2"; +/** GenesisState defines the basic genesis state used by escrow module */ +export interface GenesisState { + accounts: Account[]; + payments: FractionalPayment[]; +} +export interface GenesisStateProtoMsg { + typeUrl: "/akash.escrow.v1beta2.GenesisState"; + value: Uint8Array; +} +/** GenesisState defines the basic genesis state used by escrow module */ +export interface GenesisStateSDKType { + accounts: AccountSDKType[]; + payments: FractionalPaymentSDKType[]; +} +function createBaseGenesisState(): GenesisState { + return { + accounts: [], + payments: [] + }; +} +export const GenesisState = { + typeUrl: "/akash.escrow.v1beta2.GenesisState", + encode(message: GenesisState, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.accounts) { + Account.encode(v!, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.payments) { + FractionalPayment.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GenesisState { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGenesisState(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.accounts.push(Account.decode(reader, reader.uint32())); + break; + case 2: + message.payments.push(FractionalPayment.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GenesisState { + const obj = createBaseGenesisState(); + if (Array.isArray(object?.accounts)) obj.accounts = object.accounts.map((e: any) => Account.fromJSON(e)); + if (Array.isArray(object?.payments)) obj.payments = object.payments.map((e: any) => FractionalPayment.fromJSON(e)); + return obj; + }, + toJSON(message: GenesisState): JsonSafe { + const obj: any = {}; + if (message.accounts) { + obj.accounts = message.accounts.map(e => e ? Account.toJSON(e) : undefined); + } else { + obj.accounts = []; + } + if (message.payments) { + obj.payments = message.payments.map(e => e ? FractionalPayment.toJSON(e) : undefined); + } else { + obj.payments = []; + } + return obj; + }, + fromPartial, I>>(object: I): GenesisState { + const message = createBaseGenesisState(); + message.accounts = object.accounts?.map(e => Account.fromPartial(e)) || []; + message.payments = object.payments?.map(e => FractionalPayment.fromPartial(e)) || []; + return message; + }, + fromSDK(object: GenesisStateSDKType): GenesisState { + return { + accounts: Array.isArray(object?.accounts) ? object.accounts.map((e: any) => Account.fromSDK(e)) : [], + payments: Array.isArray(object?.payments) ? object.payments.map((e: any) => FractionalPayment.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): GenesisStateSDKType { + return { + accounts: Array.isArray(object?.accounts) ? object.accounts.map((e: any) => Account.fromSDKJSON(e)) : [], + payments: Array.isArray(object?.payments) ? object.payments.map((e: any) => FractionalPayment.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: GenesisState): GenesisStateSDKType { + const obj: any = {}; + if (message.accounts) { + obj.accounts = message.accounts.map(e => e ? Account.toSDK(e) : undefined); + } else { + obj.accounts = []; + } + if (message.payments) { + obj.payments = message.payments.map(e => e ? FractionalPayment.toSDK(e) : undefined); + } else { + obj.payments = []; + } + return obj; + }, + fromAmino(object: GenesisStateAmino): GenesisState { + const message = createBaseGenesisState(); + message.accounts = object.accounts?.map(e => Account.fromAmino(e)) || []; + message.payments = object.payments?.map(e => FractionalPayment.fromAmino(e)) || []; + return message; + }, + toAmino(message: GenesisState): GenesisStateAmino { + const obj: any = {}; + if (message.accounts) { + obj.accounts = message.accounts.map(e => e ? Account.toAmino(e) : undefined); + } else { + obj.accounts = message.accounts; + } + if (message.payments) { + obj.payments = message.payments.map(e => e ? FractionalPayment.toAmino(e) : undefined); + } else { + obj.payments = message.payments; + } + return obj; + }, + fromAminoMsg(object: GenesisStateAminoMsg): GenesisState { + return GenesisState.fromAmino(object.value); + }, + toAminoMsg(message: GenesisState): GenesisStateAminoMsg { + return { + type: "akash/escrow/v1beta2/genesis-state", + value: GenesisState.toAmino(message) + }; + }, + fromProtoMsg(message: GenesisStateProtoMsg): GenesisState { + return GenesisState.decode(message.value); + }, + toProto(message: GenesisState): Uint8Array { + return GenesisState.encode(message).finish(); + }, + toProtoMsg(message: GenesisState): GenesisStateProtoMsg { + return { + typeUrl: "/akash.escrow.v1beta2.GenesisState", + value: GenesisState.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/escrow/v1beta2/query.lcd.ts b/__fixtures__/v-next/outputicjsdeps/akash/escrow/v1beta2/query.lcd.ts new file mode 100644 index 0000000000..fac26fa2c3 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/escrow/v1beta2/query.lcd.ts @@ -0,0 +1,68 @@ +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../../cosmos/base/query/v1beta1/pagination.js"; +import { Account, AccountSDKType, FractionalPayment, FractionalPaymentSDKType } from "./types.js"; +import { setPaginationParams } from "../../../helpers.js"; +import { LCDClient } from "@cosmology/lcd"; +import { QueryAccountsRequest, QueryAccountsRequestSDKType, QueryAccountsResponse, QueryAccountsResponseSDKType, QueryPaymentsRequest, QueryPaymentsRequestSDKType, QueryPaymentsResponse, QueryPaymentsResponseSDKType } from "./query.js"; +export class LCDQueryClient { + req: LCDClient; + constructor({ + requestClient + }: { + requestClient: LCDClient; + }) { + this.req = requestClient; + } + /* buf:lint:ignore RPC_REQUEST_RESPONSE_UNIQUE + buf:lint:ignore RPC_RESPONSE_STANDARD_NAME + Accounts queries all accounts */ + accounts = async (params: QueryAccountsRequest): Promise => { + const options: any = { + params: {} + }; + if (typeof params?.scope !== "undefined") { + options.params.scope = params.scope; + } + if (typeof params?.xid !== "undefined") { + options.params.xid = params.xid; + } + if (typeof params?.owner !== "undefined") { + options.params.owner = params.owner; + } + if (typeof params?.state !== "undefined") { + options.params.state = params.state; + } + if (typeof params?.pagination !== "undefined") { + setPaginationParams(options, params.pagination); + } + const endpoint = `akash/escrow/v1beta2/types/accounts/list`; + return QueryAccountsResponse.fromSDKJSON(await this.req.get(endpoint, options)); + }; + /* buf:lint:ignore RPC_REQUEST_RESPONSE_UNIQUE + buf:lint:ignore RPC_RESPONSE_STANDARD_NAME + Payments queries all payments */ + payments = async (params: QueryPaymentsRequest): Promise => { + const options: any = { + params: {} + }; + if (typeof params?.scope !== "undefined") { + options.params.scope = params.scope; + } + if (typeof params?.xid !== "undefined") { + options.params.xid = params.xid; + } + if (typeof params?.id !== "undefined") { + options.params.id = params.id; + } + if (typeof params?.owner !== "undefined") { + options.params.owner = params.owner; + } + if (typeof params?.state !== "undefined") { + options.params.state = params.state; + } + if (typeof params?.pagination !== "undefined") { + setPaginationParams(options, params.pagination); + } + const endpoint = `akash/escrow/v1beta2/types/payments/list`; + return QueryPaymentsResponse.fromSDKJSON(await this.req.get(endpoint, options)); + }; +} \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/escrow/v1beta2/query.rpc.Query.ts b/__fixtures__/v-next/outputicjsdeps/akash/escrow/v1beta2/query.rpc.Query.ts new file mode 100644 index 0000000000..e6c0ec9480 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/escrow/v1beta2/query.rpc.Query.ts @@ -0,0 +1,55 @@ +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../../cosmos/base/query/v1beta1/pagination.js"; +import { Account, AccountSDKType, FractionalPayment, FractionalPaymentSDKType } from "./types.js"; +import { Rpc } from "../../../helpers.js"; +import { BinaryReader } from "../../../binary.js"; +import { QueryClient, createProtobufRpcClient } from "@cosmjs/stargate"; +import { QueryAccountsRequest, QueryAccountsRequestSDKType, QueryAccountsResponse, QueryAccountsResponseSDKType, QueryPaymentsRequest, QueryPaymentsRequestSDKType, QueryPaymentsResponse, QueryPaymentsResponseSDKType } from "./query.js"; +/** Query defines the gRPC querier service */ +export interface Query { + /** + * buf:lint:ignore RPC_REQUEST_RESPONSE_UNIQUE + * buf:lint:ignore RPC_RESPONSE_STANDARD_NAME + * Accounts queries all accounts + */ + accounts(request: QueryAccountsRequest): Promise; + /** + * buf:lint:ignore RPC_REQUEST_RESPONSE_UNIQUE + * buf:lint:ignore RPC_RESPONSE_STANDARD_NAME + * Payments queries all payments + */ + payments(request: QueryPaymentsRequest): Promise; +} +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + } + /* buf:lint:ignore RPC_REQUEST_RESPONSE_UNIQUE + buf:lint:ignore RPC_RESPONSE_STANDARD_NAME + Accounts queries all accounts */ + accounts = async (request: QueryAccountsRequest): Promise => { + const data = QueryAccountsRequest.encode(request).finish(); + const promise = this.rpc.request("akash.escrow.v1beta2.Query", "Accounts", data); + return promise.then(data => QueryAccountsResponse.decode(new BinaryReader(data))); + }; + /* buf:lint:ignore RPC_REQUEST_RESPONSE_UNIQUE + buf:lint:ignore RPC_RESPONSE_STANDARD_NAME + Payments queries all payments */ + payments = async (request: QueryPaymentsRequest): Promise => { + const data = QueryPaymentsRequest.encode(request).finish(); + const promise = this.rpc.request("akash.escrow.v1beta2.Query", "Payments", data); + return promise.then(data => QueryPaymentsResponse.decode(new BinaryReader(data))); + }; +} +export const createRpcQueryExtension = (base: QueryClient) => { + const rpc = createProtobufRpcClient(base); + const queryService = new QueryClientImpl(rpc); + return { + accounts(request: QueryAccountsRequest): Promise { + return queryService.accounts(request); + }, + payments(request: QueryPaymentsRequest): Promise { + return queryService.payments(request); + } + }; +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/escrow/v1beta2/query.rpc.func.ts b/__fixtures__/v-next/outputicjsdeps/akash/escrow/v1beta2/query.rpc.func.ts new file mode 100644 index 0000000000..aafd37a85a --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/escrow/v1beta2/query.rpc.func.ts @@ -0,0 +1,25 @@ +import { RpcResolver, buildQuery } from "../../../helper-func-types"; +import { buildUseQuery } from "../../../react-query"; +import { QueryAccountsRequest, QueryAccountsResponse, QueryPaymentsRequest, QueryPaymentsResponse } from "./query"; +export const createGetAccounts = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryAccountsRequest.encode, + decode: QueryAccountsResponse.decode, + service: "akash.escrow.v1beta2.Query", + method: "Accounts", + getRpcInstance: getRpcInstance +}); +export const useGetAccounts = buildUseQuery({ + builderQueryFn: createGetAccounts, + queryKeyPrefix: "AccountsQuery" +}); +export const createGetPayments = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryPaymentsRequest.encode, + decode: QueryPaymentsResponse.decode, + service: "akash.escrow.v1beta2.Query", + method: "Payments", + getRpcInstance: getRpcInstance +}); +export const useGetPayments = buildUseQuery({ + builderQueryFn: createGetPayments, + queryKeyPrefix: "PaymentsQuery" +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/escrow/v1beta2/query.ts b/__fixtures__/v-next/outputicjsdeps/akash/escrow/v1beta2/query.ts new file mode 100644 index 0000000000..e7f7c1359a --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/escrow/v1beta2/query.ts @@ -0,0 +1,667 @@ +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../../cosmos/base/query/v1beta1/pagination.js"; +import { Account, AccountSDKType, FractionalPayment, FractionalPaymentSDKType } from "./types.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial, Exact } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "akash.escrow.v1beta2"; +/** QueryAccountRequest is request type for the Query/Account RPC method */ +export interface QueryAccountsRequest { + scope: string; + xid: string; + owner: string; + state: string; + pagination?: PageRequest; +} +export interface QueryAccountsRequestProtoMsg { + typeUrl: "/akash.escrow.v1beta2.QueryAccountsRequest"; + value: Uint8Array; +} +/** QueryAccountRequest is request type for the Query/Account RPC method */ +export interface QueryAccountsRequestSDKType { + scope: string; + xid: string; + owner: string; + state: string; + pagination?: PageRequestSDKType; +} +/** QueryProvidersResponse is response type for the Query/Providers RPC method */ +export interface QueryAccountsResponse { + accounts: Account[]; + pagination?: PageResponse; +} +export interface QueryAccountsResponseProtoMsg { + typeUrl: "/akash.escrow.v1beta2.QueryAccountsResponse"; + value: Uint8Array; +} +/** QueryProvidersResponse is response type for the Query/Providers RPC method */ +export interface QueryAccountsResponseSDKType { + accounts: AccountSDKType[]; + pagination?: PageResponseSDKType; +} +/** QueryPaymentRequest is request type for the Query/Payment RPC method */ +export interface QueryPaymentsRequest { + scope: string; + xid: string; + id: string; + owner: string; + state: string; + pagination?: PageRequest; +} +export interface QueryPaymentsRequestProtoMsg { + typeUrl: "/akash.escrow.v1beta2.QueryPaymentsRequest"; + value: Uint8Array; +} +/** QueryPaymentRequest is request type for the Query/Payment RPC method */ +export interface QueryPaymentsRequestSDKType { + scope: string; + xid: string; + id: string; + owner: string; + state: string; + pagination?: PageRequestSDKType; +} +/** QueryProvidersResponse is response type for the Query/Providers RPC method */ +export interface QueryPaymentsResponse { + payments: FractionalPayment[]; + pagination?: PageResponse; +} +export interface QueryPaymentsResponseProtoMsg { + typeUrl: "/akash.escrow.v1beta2.QueryPaymentsResponse"; + value: Uint8Array; +} +/** QueryProvidersResponse is response type for the Query/Providers RPC method */ +export interface QueryPaymentsResponseSDKType { + payments: FractionalPaymentSDKType[]; + pagination?: PageResponseSDKType; +} +function createBaseQueryAccountsRequest(): QueryAccountsRequest { + return { + scope: "", + xid: "", + owner: "", + state: "", + pagination: undefined + }; +} +export const QueryAccountsRequest = { + typeUrl: "/akash.escrow.v1beta2.QueryAccountsRequest", + encode(message: QueryAccountsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.scope !== undefined) { + writer.uint32(10).string(message.scope); + } + if (message.xid !== undefined) { + writer.uint32(18).string(message.xid); + } + if (message.owner !== undefined) { + writer.uint32(26).string(message.owner); + } + if (message.state !== undefined) { + writer.uint32(34).string(message.state); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(42).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryAccountsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryAccountsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.scope = reader.string(); + break; + case 2: + message.xid = reader.string(); + break; + case 3: + message.owner = reader.string(); + break; + case 4: + message.state = reader.string(); + break; + case 5: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryAccountsRequest { + const obj = createBaseQueryAccountsRequest(); + if (isSet(object.scope)) obj.scope = String(object.scope); + if (isSet(object.xid)) obj.xid = String(object.xid); + if (isSet(object.owner)) obj.owner = String(object.owner); + if (isSet(object.state)) obj.state = String(object.state); + if (isSet(object.pagination)) obj.pagination = PageRequest.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryAccountsRequest): JsonSafe { + const obj: any = {}; + message.scope !== undefined && (obj.scope = message.scope); + message.xid !== undefined && (obj.xid = message.xid); + message.owner !== undefined && (obj.owner = message.owner); + message.state !== undefined && (obj.state = message.state); + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryAccountsRequest { + const message = createBaseQueryAccountsRequest(); + message.scope = object.scope ?? ""; + message.xid = object.xid ?? ""; + message.owner = object.owner ?? ""; + message.state = object.state ?? ""; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryAccountsRequestSDKType): QueryAccountsRequest { + return { + scope: object?.scope, + xid: object?.xid, + owner: object?.owner, + state: object?.state, + pagination: object.pagination ? PageRequest.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryAccountsRequestSDKType { + return { + scope: isSet(object.scope) ? String(object.scope) : "", + xid: isSet(object.xid) ? String(object.xid) : "", + owner: isSet(object.owner) ? String(object.owner) : "", + state: isSet(object.state) ? String(object.state) : "", + pagination: isSet(object.pagination) ? PageRequest.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryAccountsRequest): QueryAccountsRequestSDKType { + const obj: any = {}; + obj.scope = message.scope; + obj.xid = message.xid; + obj.owner = message.owner; + obj.state = message.state; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryAccountsRequestAmino): QueryAccountsRequest { + const message = createBaseQueryAccountsRequest(); + if (object.scope !== undefined && object.scope !== null) { + message.scope = object.scope; + } + if (object.xid !== undefined && object.xid !== null) { + message.xid = object.xid; + } + if (object.owner !== undefined && object.owner !== null) { + message.owner = object.owner; + } + if (object.state !== undefined && object.state !== null) { + message.state = object.state; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryAccountsRequest): QueryAccountsRequestAmino { + const obj: any = {}; + obj.scope = message.scope === "" ? undefined : message.scope; + obj.xid = message.xid === "" ? undefined : message.xid; + obj.owner = message.owner === "" ? undefined : message.owner; + obj.state = message.state === "" ? undefined : message.state; + obj.pagination = message.pagination ? PageRequest.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryAccountsRequestAminoMsg): QueryAccountsRequest { + return QueryAccountsRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryAccountsRequest): QueryAccountsRequestAminoMsg { + return { + type: "akash/escrow/v1beta2/query-accounts-request", + value: QueryAccountsRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryAccountsRequestProtoMsg): QueryAccountsRequest { + return QueryAccountsRequest.decode(message.value); + }, + toProto(message: QueryAccountsRequest): Uint8Array { + return QueryAccountsRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryAccountsRequest): QueryAccountsRequestProtoMsg { + return { + typeUrl: "/akash.escrow.v1beta2.QueryAccountsRequest", + value: QueryAccountsRequest.encode(message).finish() + }; + } +}; +function createBaseQueryAccountsResponse(): QueryAccountsResponse { + return { + accounts: [], + pagination: undefined + }; +} +export const QueryAccountsResponse = { + typeUrl: "/akash.escrow.v1beta2.QueryAccountsResponse", + encode(message: QueryAccountsResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.accounts) { + Account.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryAccountsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryAccountsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.accounts.push(Account.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryAccountsResponse { + const obj = createBaseQueryAccountsResponse(); + if (Array.isArray(object?.accounts)) obj.accounts = object.accounts.map((e: any) => Account.fromJSON(e)); + if (isSet(object.pagination)) obj.pagination = PageResponse.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryAccountsResponse): JsonSafe { + const obj: any = {}; + if (message.accounts) { + obj.accounts = message.accounts.map(e => e ? Account.toJSON(e) : undefined); + } else { + obj.accounts = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryAccountsResponse { + const message = createBaseQueryAccountsResponse(); + message.accounts = object.accounts?.map(e => Account.fromPartial(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryAccountsResponseSDKType): QueryAccountsResponse { + return { + accounts: Array.isArray(object?.accounts) ? object.accounts.map((e: any) => Account.fromSDK(e)) : [], + pagination: object.pagination ? PageResponse.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryAccountsResponseSDKType { + return { + accounts: Array.isArray(object?.accounts) ? object.accounts.map((e: any) => Account.fromSDKJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryAccountsResponse): QueryAccountsResponseSDKType { + const obj: any = {}; + if (message.accounts) { + obj.accounts = message.accounts.map(e => e ? Account.toSDK(e) : undefined); + } else { + obj.accounts = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryAccountsResponseAmino): QueryAccountsResponse { + const message = createBaseQueryAccountsResponse(); + message.accounts = object.accounts?.map(e => Account.fromAmino(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryAccountsResponse): QueryAccountsResponseAmino { + const obj: any = {}; + if (message.accounts) { + obj.accounts = message.accounts.map(e => e ? Account.toAmino(e) : undefined); + } else { + obj.accounts = message.accounts; + } + obj.pagination = message.pagination ? PageResponse.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryAccountsResponseAminoMsg): QueryAccountsResponse { + return QueryAccountsResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryAccountsResponse): QueryAccountsResponseAminoMsg { + return { + type: "akash/escrow/v1beta2/query-accounts-response", + value: QueryAccountsResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryAccountsResponseProtoMsg): QueryAccountsResponse { + return QueryAccountsResponse.decode(message.value); + }, + toProto(message: QueryAccountsResponse): Uint8Array { + return QueryAccountsResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryAccountsResponse): QueryAccountsResponseProtoMsg { + return { + typeUrl: "/akash.escrow.v1beta2.QueryAccountsResponse", + value: QueryAccountsResponse.encode(message).finish() + }; + } +}; +function createBaseQueryPaymentsRequest(): QueryPaymentsRequest { + return { + scope: "", + xid: "", + id: "", + owner: "", + state: "", + pagination: undefined + }; +} +export const QueryPaymentsRequest = { + typeUrl: "/akash.escrow.v1beta2.QueryPaymentsRequest", + encode(message: QueryPaymentsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.scope !== undefined) { + writer.uint32(10).string(message.scope); + } + if (message.xid !== undefined) { + writer.uint32(18).string(message.xid); + } + if (message.id !== undefined) { + writer.uint32(26).string(message.id); + } + if (message.owner !== undefined) { + writer.uint32(34).string(message.owner); + } + if (message.state !== undefined) { + writer.uint32(42).string(message.state); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(50).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryPaymentsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryPaymentsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.scope = reader.string(); + break; + case 2: + message.xid = reader.string(); + break; + case 3: + message.id = reader.string(); + break; + case 4: + message.owner = reader.string(); + break; + case 5: + message.state = reader.string(); + break; + case 6: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryPaymentsRequest { + const obj = createBaseQueryPaymentsRequest(); + if (isSet(object.scope)) obj.scope = String(object.scope); + if (isSet(object.xid)) obj.xid = String(object.xid); + if (isSet(object.id)) obj.id = String(object.id); + if (isSet(object.owner)) obj.owner = String(object.owner); + if (isSet(object.state)) obj.state = String(object.state); + if (isSet(object.pagination)) obj.pagination = PageRequest.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryPaymentsRequest): JsonSafe { + const obj: any = {}; + message.scope !== undefined && (obj.scope = message.scope); + message.xid !== undefined && (obj.xid = message.xid); + message.id !== undefined && (obj.id = message.id); + message.owner !== undefined && (obj.owner = message.owner); + message.state !== undefined && (obj.state = message.state); + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryPaymentsRequest { + const message = createBaseQueryPaymentsRequest(); + message.scope = object.scope ?? ""; + message.xid = object.xid ?? ""; + message.id = object.id ?? ""; + message.owner = object.owner ?? ""; + message.state = object.state ?? ""; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryPaymentsRequestSDKType): QueryPaymentsRequest { + return { + scope: object?.scope, + xid: object?.xid, + id: object?.id, + owner: object?.owner, + state: object?.state, + pagination: object.pagination ? PageRequest.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryPaymentsRequestSDKType { + return { + scope: isSet(object.scope) ? String(object.scope) : "", + xid: isSet(object.xid) ? String(object.xid) : "", + id: isSet(object.id) ? String(object.id) : "", + owner: isSet(object.owner) ? String(object.owner) : "", + state: isSet(object.state) ? String(object.state) : "", + pagination: isSet(object.pagination) ? PageRequest.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryPaymentsRequest): QueryPaymentsRequestSDKType { + const obj: any = {}; + obj.scope = message.scope; + obj.xid = message.xid; + obj.id = message.id; + obj.owner = message.owner; + obj.state = message.state; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryPaymentsRequestAmino): QueryPaymentsRequest { + const message = createBaseQueryPaymentsRequest(); + if (object.scope !== undefined && object.scope !== null) { + message.scope = object.scope; + } + if (object.xid !== undefined && object.xid !== null) { + message.xid = object.xid; + } + if (object.id !== undefined && object.id !== null) { + message.id = object.id; + } + if (object.owner !== undefined && object.owner !== null) { + message.owner = object.owner; + } + if (object.state !== undefined && object.state !== null) { + message.state = object.state; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryPaymentsRequest): QueryPaymentsRequestAmino { + const obj: any = {}; + obj.scope = message.scope === "" ? undefined : message.scope; + obj.xid = message.xid === "" ? undefined : message.xid; + obj.id = message.id === "" ? undefined : message.id; + obj.owner = message.owner === "" ? undefined : message.owner; + obj.state = message.state === "" ? undefined : message.state; + obj.pagination = message.pagination ? PageRequest.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryPaymentsRequestAminoMsg): QueryPaymentsRequest { + return QueryPaymentsRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryPaymentsRequest): QueryPaymentsRequestAminoMsg { + return { + type: "akash/escrow/v1beta2/query-payments-request", + value: QueryPaymentsRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryPaymentsRequestProtoMsg): QueryPaymentsRequest { + return QueryPaymentsRequest.decode(message.value); + }, + toProto(message: QueryPaymentsRequest): Uint8Array { + return QueryPaymentsRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryPaymentsRequest): QueryPaymentsRequestProtoMsg { + return { + typeUrl: "/akash.escrow.v1beta2.QueryPaymentsRequest", + value: QueryPaymentsRequest.encode(message).finish() + }; + } +}; +function createBaseQueryPaymentsResponse(): QueryPaymentsResponse { + return { + payments: [], + pagination: undefined + }; +} +export const QueryPaymentsResponse = { + typeUrl: "/akash.escrow.v1beta2.QueryPaymentsResponse", + encode(message: QueryPaymentsResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.payments) { + FractionalPayment.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryPaymentsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryPaymentsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.payments.push(FractionalPayment.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryPaymentsResponse { + const obj = createBaseQueryPaymentsResponse(); + if (Array.isArray(object?.payments)) obj.payments = object.payments.map((e: any) => FractionalPayment.fromJSON(e)); + if (isSet(object.pagination)) obj.pagination = PageResponse.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryPaymentsResponse): JsonSafe { + const obj: any = {}; + if (message.payments) { + obj.payments = message.payments.map(e => e ? FractionalPayment.toJSON(e) : undefined); + } else { + obj.payments = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryPaymentsResponse { + const message = createBaseQueryPaymentsResponse(); + message.payments = object.payments?.map(e => FractionalPayment.fromPartial(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryPaymentsResponseSDKType): QueryPaymentsResponse { + return { + payments: Array.isArray(object?.payments) ? object.payments.map((e: any) => FractionalPayment.fromSDK(e)) : [], + pagination: object.pagination ? PageResponse.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryPaymentsResponseSDKType { + return { + payments: Array.isArray(object?.payments) ? object.payments.map((e: any) => FractionalPayment.fromSDKJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryPaymentsResponse): QueryPaymentsResponseSDKType { + const obj: any = {}; + if (message.payments) { + obj.payments = message.payments.map(e => e ? FractionalPayment.toSDK(e) : undefined); + } else { + obj.payments = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryPaymentsResponseAmino): QueryPaymentsResponse { + const message = createBaseQueryPaymentsResponse(); + message.payments = object.payments?.map(e => FractionalPayment.fromAmino(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryPaymentsResponse): QueryPaymentsResponseAmino { + const obj: any = {}; + if (message.payments) { + obj.payments = message.payments.map(e => e ? FractionalPayment.toAmino(e) : undefined); + } else { + obj.payments = message.payments; + } + obj.pagination = message.pagination ? PageResponse.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryPaymentsResponseAminoMsg): QueryPaymentsResponse { + return QueryPaymentsResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryPaymentsResponse): QueryPaymentsResponseAminoMsg { + return { + type: "akash/escrow/v1beta2/query-payments-response", + value: QueryPaymentsResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryPaymentsResponseProtoMsg): QueryPaymentsResponse { + return QueryPaymentsResponse.decode(message.value); + }, + toProto(message: QueryPaymentsResponse): Uint8Array { + return QueryPaymentsResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryPaymentsResponse): QueryPaymentsResponseProtoMsg { + return { + typeUrl: "/akash.escrow.v1beta2.QueryPaymentsResponse", + value: QueryPaymentsResponse.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/escrow/v1beta2/types.ts b/__fixtures__/v-next/outputicjsdeps/akash/escrow/v1beta2/types.ts new file mode 100644 index 0000000000..a206e98d98 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/escrow/v1beta2/types.ts @@ -0,0 +1,718 @@ +import { DecCoin, DecCoinSDKType, Coin, CoinSDKType } from "../../../cosmos/base/v1beta1/coin.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial, Exact } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "akash.escrow.v1beta2"; +/** State stores state for an escrow account */ +export enum Account_State { + /** invalid - AccountStateInvalid is an invalid state */ + invalid = 0, + /** open - AccountOpen is the state when an account is open */ + open = 1, + /** closed - AccountClosed is the state when an account is closed */ + closed = 2, + /** overdrawn - AccountOverdrawn is the state when an account is overdrawn */ + overdrawn = 3, + UNRECOGNIZED = -1, +} +export const Account_StateSDKType = Account_State; +export function account_StateFromJSON(object: any): Account_State { + switch (object) { + case 0: + case "invalid": + return Account_State.invalid; + case 1: + case "open": + return Account_State.open; + case 2: + case "closed": + return Account_State.closed; + case 3: + case "overdrawn": + return Account_State.overdrawn; + case -1: + case "UNRECOGNIZED": + default: + return Account_State.UNRECOGNIZED; + } +} +export function account_StateToJSON(object: Account_State): string { + switch (object) { + case Account_State.invalid: + return "invalid"; + case Account_State.open: + return "open"; + case Account_State.closed: + return "closed"; + case Account_State.overdrawn: + return "overdrawn"; + case Account_State.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** Payment State */ +export enum FractionalPayment_State { + /** invalid - PaymentStateInvalid is the state when the payment is invalid */ + invalid = 0, + /** open - PaymentStateOpen is the state when the payment is open */ + open = 1, + /** closed - PaymentStateClosed is the state when the payment is closed */ + closed = 2, + /** overdrawn - PaymentStateOverdrawn is the state when the payment is overdrawn */ + overdrawn = 3, + UNRECOGNIZED = -1, +} +export const FractionalPayment_StateSDKType = FractionalPayment_State; +export function fractionalPayment_StateFromJSON(object: any): FractionalPayment_State { + switch (object) { + case 0: + case "invalid": + return FractionalPayment_State.invalid; + case 1: + case "open": + return FractionalPayment_State.open; + case 2: + case "closed": + return FractionalPayment_State.closed; + case 3: + case "overdrawn": + return FractionalPayment_State.overdrawn; + case -1: + case "UNRECOGNIZED": + default: + return FractionalPayment_State.UNRECOGNIZED; + } +} +export function fractionalPayment_StateToJSON(object: FractionalPayment_State): string { + switch (object) { + case FractionalPayment_State.invalid: + return "invalid"; + case FractionalPayment_State.open: + return "open"; + case FractionalPayment_State.closed: + return "closed"; + case FractionalPayment_State.overdrawn: + return "overdrawn"; + case FractionalPayment_State.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** AccountID is the account identifier */ +export interface AccountID { + scope: string; + xid: string; +} +export interface AccountIDProtoMsg { + typeUrl: "/akash.escrow.v1beta2.AccountID"; + value: Uint8Array; +} +/** AccountID is the account identifier */ +export interface AccountIDSDKType { + scope: string; + xid: string; +} +/** Account stores state for an escrow account */ +export interface Account { + /** unique identifier for this escrow account */ + id: AccountID; + /** bech32 encoded account address of the owner of this escrow account */ + owner: string; + /** current state of this escrow account */ + state: Account_State; + /** unspent coins received from the owner's wallet */ + balance: DecCoin; + /** total coins spent by this account */ + transferred: DecCoin; + /** block height at which this account was last settled */ + settledAt: bigint; + /** + * bech32 encoded account address of the depositor. + * If depositor is same as the owner, then any incoming coins are added to the Balance. + * If depositor isn't same as the owner, then any incoming coins are added to the Funds. + */ + depositor: string; + /** + * Funds are unspent coins received from the (non-Owner) Depositor's wallet. + * If there are any funds, they should be spent before spending the Balance. + */ + funds: DecCoin; +} +export interface AccountProtoMsg { + typeUrl: "/akash.escrow.v1beta2.Account"; + value: Uint8Array; +} +/** Account stores state for an escrow account */ +export interface AccountSDKType { + id: AccountIDSDKType; + owner: string; + state: Account_State; + balance: DecCoinSDKType; + transferred: DecCoinSDKType; + settled_at: bigint; + depositor: string; + funds: DecCoinSDKType; +} +/** Payment stores state for a payment */ +export interface FractionalPayment { + accountId: AccountID; + paymentId: string; + owner: string; + state: FractionalPayment_State; + rate: DecCoin; + balance: DecCoin; + withdrawn: Coin; +} +export interface FractionalPaymentProtoMsg { + typeUrl: "/akash.escrow.v1beta2.FractionalPayment"; + value: Uint8Array; +} +/** Payment stores state for a payment */ +export interface FractionalPaymentSDKType { + account_id: AccountIDSDKType; + payment_id: string; + owner: string; + state: FractionalPayment_State; + rate: DecCoinSDKType; + balance: DecCoinSDKType; + withdrawn: CoinSDKType; +} +function createBaseAccountID(): AccountID { + return { + scope: "", + xid: "" + }; +} +export const AccountID = { + typeUrl: "/akash.escrow.v1beta2.AccountID", + encode(message: AccountID, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.scope !== undefined) { + writer.uint32(10).string(message.scope); + } + if (message.xid !== undefined) { + writer.uint32(18).string(message.xid); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): AccountID { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseAccountID(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.scope = reader.string(); + break; + case 2: + message.xid = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): AccountID { + const obj = createBaseAccountID(); + if (isSet(object.scope)) obj.scope = String(object.scope); + if (isSet(object.xid)) obj.xid = String(object.xid); + return obj; + }, + toJSON(message: AccountID): JsonSafe { + const obj: any = {}; + message.scope !== undefined && (obj.scope = message.scope); + message.xid !== undefined && (obj.xid = message.xid); + return obj; + }, + fromPartial, I>>(object: I): AccountID { + const message = createBaseAccountID(); + message.scope = object.scope ?? ""; + message.xid = object.xid ?? ""; + return message; + }, + fromSDK(object: AccountIDSDKType): AccountID { + return { + scope: object?.scope, + xid: object?.xid + }; + }, + fromSDKJSON(object: any): AccountIDSDKType { + return { + scope: isSet(object.scope) ? String(object.scope) : "", + xid: isSet(object.xid) ? String(object.xid) : "" + }; + }, + toSDK(message: AccountID): AccountIDSDKType { + const obj: any = {}; + obj.scope = message.scope; + obj.xid = message.xid; + return obj; + }, + fromAmino(object: AccountIDAmino): AccountID { + const message = createBaseAccountID(); + if (object.scope !== undefined && object.scope !== null) { + message.scope = object.scope; + } + if (object.xid !== undefined && object.xid !== null) { + message.xid = object.xid; + } + return message; + }, + toAmino(message: AccountID): AccountIDAmino { + const obj: any = {}; + obj.scope = message.scope ?? ""; + obj.xid = message.xid ?? ""; + return obj; + }, + fromAminoMsg(object: AccountIDAminoMsg): AccountID { + return AccountID.fromAmino(object.value); + }, + toAminoMsg(message: AccountID): AccountIDAminoMsg { + return { + type: "akash/escrow/v1beta2/account-i-d", + value: AccountID.toAmino(message) + }; + }, + fromProtoMsg(message: AccountIDProtoMsg): AccountID { + return AccountID.decode(message.value); + }, + toProto(message: AccountID): Uint8Array { + return AccountID.encode(message).finish(); + }, + toProtoMsg(message: AccountID): AccountIDProtoMsg { + return { + typeUrl: "/akash.escrow.v1beta2.AccountID", + value: AccountID.encode(message).finish() + }; + } +}; +function createBaseAccount(): Account { + return { + id: AccountID.fromPartial({}), + owner: "", + state: 0, + balance: DecCoin.fromPartial({}), + transferred: DecCoin.fromPartial({}), + settledAt: BigInt(0), + depositor: "", + funds: DecCoin.fromPartial({}) + }; +} +export const Account = { + typeUrl: "/akash.escrow.v1beta2.Account", + encode(message: Account, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.id !== undefined) { + AccountID.encode(message.id, writer.uint32(10).fork()).ldelim(); + } + if (message.owner !== undefined) { + writer.uint32(18).string(message.owner); + } + if (message.state !== 0) { + writer.uint32(24).int32(message.state); + } + if (message.balance !== undefined) { + DecCoin.encode(message.balance, writer.uint32(34).fork()).ldelim(); + } + if (message.transferred !== undefined) { + DecCoin.encode(message.transferred, writer.uint32(42).fork()).ldelim(); + } + if (message.settledAt !== undefined) { + writer.uint32(48).int64(message.settledAt); + } + if (message.depositor !== undefined) { + writer.uint32(58).string(message.depositor); + } + if (message.funds !== undefined) { + DecCoin.encode(message.funds, writer.uint32(66).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Account { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseAccount(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.id = AccountID.decode(reader, reader.uint32()); + break; + case 2: + message.owner = reader.string(); + break; + case 3: + message.state = (reader.int32() as any); + break; + case 4: + message.balance = DecCoin.decode(reader, reader.uint32()); + break; + case 5: + message.transferred = DecCoin.decode(reader, reader.uint32()); + break; + case 6: + message.settledAt = reader.int64(); + break; + case 7: + message.depositor = reader.string(); + break; + case 8: + message.funds = DecCoin.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Account { + const obj = createBaseAccount(); + if (isSet(object.id)) obj.id = AccountID.fromJSON(object.id); + if (isSet(object.owner)) obj.owner = String(object.owner); + if (isSet(object.state)) obj.state = account_StateFromJSON(object.state); + if (isSet(object.balance)) obj.balance = DecCoin.fromJSON(object.balance); + if (isSet(object.transferred)) obj.transferred = DecCoin.fromJSON(object.transferred); + if (isSet(object.settledAt)) obj.settledAt = BigInt(object.settledAt.toString()); + if (isSet(object.depositor)) obj.depositor = String(object.depositor); + if (isSet(object.funds)) obj.funds = DecCoin.fromJSON(object.funds); + return obj; + }, + toJSON(message: Account): JsonSafe { + const obj: any = {}; + message.id !== undefined && (obj.id = message.id ? AccountID.toJSON(message.id) : undefined); + message.owner !== undefined && (obj.owner = message.owner); + message.state !== undefined && (obj.state = account_StateToJSON(message.state)); + message.balance !== undefined && (obj.balance = message.balance ? DecCoin.toJSON(message.balance) : undefined); + message.transferred !== undefined && (obj.transferred = message.transferred ? DecCoin.toJSON(message.transferred) : undefined); + message.settledAt !== undefined && (obj.settledAt = (message.settledAt || BigInt(0)).toString()); + message.depositor !== undefined && (obj.depositor = message.depositor); + message.funds !== undefined && (obj.funds = message.funds ? DecCoin.toJSON(message.funds) : undefined); + return obj; + }, + fromPartial, I>>(object: I): Account { + const message = createBaseAccount(); + if (object.id !== undefined && object.id !== null) { + message.id = AccountID.fromPartial(object.id); + } + message.owner = object.owner ?? ""; + message.state = object.state ?? 0; + if (object.balance !== undefined && object.balance !== null) { + message.balance = DecCoin.fromPartial(object.balance); + } + if (object.transferred !== undefined && object.transferred !== null) { + message.transferred = DecCoin.fromPartial(object.transferred); + } + if (object.settledAt !== undefined && object.settledAt !== null) { + message.settledAt = BigInt(object.settledAt.toString()); + } + message.depositor = object.depositor ?? ""; + if (object.funds !== undefined && object.funds !== null) { + message.funds = DecCoin.fromPartial(object.funds); + } + return message; + }, + fromSDK(object: AccountSDKType): Account { + return { + id: object.id ? AccountID.fromSDK(object.id) : undefined, + owner: object?.owner, + state: isSet(object.state) ? account_StateFromJSON(object.state) : -1, + balance: object.balance ? DecCoin.fromSDK(object.balance) : undefined, + transferred: object.transferred ? DecCoin.fromSDK(object.transferred) : undefined, + settledAt: object?.settled_at, + depositor: object?.depositor, + funds: object.funds ? DecCoin.fromSDK(object.funds) : undefined + }; + }, + fromSDKJSON(object: any): AccountSDKType { + return { + id: isSet(object.id) ? AccountID.fromSDKJSON(object.id) : undefined, + owner: isSet(object.owner) ? String(object.owner) : "", + state: isSet(object.state) ? account_StateFromJSON(object.state) : -1, + balance: isSet(object.balance) ? DecCoin.fromSDKJSON(object.balance) : undefined, + transferred: isSet(object.transferred) ? DecCoin.fromSDKJSON(object.transferred) : undefined, + settled_at: isSet(object.settled_at) ? BigInt(object.settled_at.toString()) : BigInt(0), + depositor: isSet(object.depositor) ? String(object.depositor) : "", + funds: isSet(object.funds) ? DecCoin.fromSDKJSON(object.funds) : undefined + }; + }, + toSDK(message: Account): AccountSDKType { + const obj: any = {}; + message.id !== undefined && (obj.id = message.id ? AccountID.toSDK(message.id) : undefined); + obj.owner = message.owner; + message.state !== undefined && (obj.state = account_StateToJSON(message.state)); + message.balance !== undefined && (obj.balance = message.balance ? DecCoin.toSDK(message.balance) : undefined); + message.transferred !== undefined && (obj.transferred = message.transferred ? DecCoin.toSDK(message.transferred) : undefined); + obj.settled_at = message.settledAt; + obj.depositor = message.depositor; + message.funds !== undefined && (obj.funds = message.funds ? DecCoin.toSDK(message.funds) : undefined); + return obj; + }, + fromAmino(object: AccountAmino): Account { + const message = createBaseAccount(); + if (object.id !== undefined && object.id !== null) { + message.id = AccountID.fromAmino(object.id); + } + if (object.owner !== undefined && object.owner !== null) { + message.owner = object.owner; + } + if (object.state !== undefined && object.state !== null) { + message.state = object.state; + } + if (object.balance !== undefined && object.balance !== null) { + message.balance = DecCoin.fromAmino(object.balance); + } + if (object.transferred !== undefined && object.transferred !== null) { + message.transferred = DecCoin.fromAmino(object.transferred); + } + if (object.settled_at !== undefined && object.settled_at !== null) { + message.settledAt = BigInt(object.settled_at); + } + if (object.depositor !== undefined && object.depositor !== null) { + message.depositor = object.depositor; + } + if (object.funds !== undefined && object.funds !== null) { + message.funds = DecCoin.fromAmino(object.funds); + } + return message; + }, + toAmino(message: Account): AccountAmino { + const obj: any = {}; + obj.id = message.id ? AccountID.toAmino(message.id) : AccountID.toAmino(AccountID.fromPartial({})); + obj.owner = message.owner ?? ""; + obj.state = message.state ?? 0; + obj.balance = message.balance ? DecCoin.toAmino(message.balance) : DecCoin.toAmino(DecCoin.fromPartial({})); + obj.transferred = message.transferred ? DecCoin.toAmino(message.transferred) : DecCoin.toAmino(DecCoin.fromPartial({})); + obj.settled_at = message.settledAt ? message.settledAt?.toString() : "0"; + obj.depositor = message.depositor ?? ""; + obj.funds = message.funds ? DecCoin.toAmino(message.funds) : DecCoin.toAmino(DecCoin.fromPartial({})); + return obj; + }, + fromAminoMsg(object: AccountAminoMsg): Account { + return Account.fromAmino(object.value); + }, + toAminoMsg(message: Account): AccountAminoMsg { + return { + type: "akash/escrow/v1beta2/account", + value: Account.toAmino(message) + }; + }, + fromProtoMsg(message: AccountProtoMsg): Account { + return Account.decode(message.value); + }, + toProto(message: Account): Uint8Array { + return Account.encode(message).finish(); + }, + toProtoMsg(message: Account): AccountProtoMsg { + return { + typeUrl: "/akash.escrow.v1beta2.Account", + value: Account.encode(message).finish() + }; + } +}; +function createBaseFractionalPayment(): FractionalPayment { + return { + accountId: AccountID.fromPartial({}), + paymentId: "", + owner: "", + state: 0, + rate: DecCoin.fromPartial({}), + balance: DecCoin.fromPartial({}), + withdrawn: Coin.fromPartial({}) + }; +} +export const FractionalPayment = { + typeUrl: "/akash.escrow.v1beta2.FractionalPayment", + encode(message: FractionalPayment, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.accountId !== undefined) { + AccountID.encode(message.accountId, writer.uint32(10).fork()).ldelim(); + } + if (message.paymentId !== undefined) { + writer.uint32(18).string(message.paymentId); + } + if (message.owner !== undefined) { + writer.uint32(26).string(message.owner); + } + if (message.state !== 0) { + writer.uint32(32).int32(message.state); + } + if (message.rate !== undefined) { + DecCoin.encode(message.rate, writer.uint32(42).fork()).ldelim(); + } + if (message.balance !== undefined) { + DecCoin.encode(message.balance, writer.uint32(50).fork()).ldelim(); + } + if (message.withdrawn !== undefined) { + Coin.encode(message.withdrawn, writer.uint32(58).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): FractionalPayment { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseFractionalPayment(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.accountId = AccountID.decode(reader, reader.uint32()); + break; + case 2: + message.paymentId = reader.string(); + break; + case 3: + message.owner = reader.string(); + break; + case 4: + message.state = (reader.int32() as any); + break; + case 5: + message.rate = DecCoin.decode(reader, reader.uint32()); + break; + case 6: + message.balance = DecCoin.decode(reader, reader.uint32()); + break; + case 7: + message.withdrawn = Coin.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): FractionalPayment { + const obj = createBaseFractionalPayment(); + if (isSet(object.accountId)) obj.accountId = AccountID.fromJSON(object.accountId); + if (isSet(object.paymentId)) obj.paymentId = String(object.paymentId); + if (isSet(object.owner)) obj.owner = String(object.owner); + if (isSet(object.state)) obj.state = fractionalPayment_StateFromJSON(object.state); + if (isSet(object.rate)) obj.rate = DecCoin.fromJSON(object.rate); + if (isSet(object.balance)) obj.balance = DecCoin.fromJSON(object.balance); + if (isSet(object.withdrawn)) obj.withdrawn = Coin.fromJSON(object.withdrawn); + return obj; + }, + toJSON(message: FractionalPayment): JsonSafe { + const obj: any = {}; + message.accountId !== undefined && (obj.accountId = message.accountId ? AccountID.toJSON(message.accountId) : undefined); + message.paymentId !== undefined && (obj.paymentId = message.paymentId); + message.owner !== undefined && (obj.owner = message.owner); + message.state !== undefined && (obj.state = fractionalPayment_StateToJSON(message.state)); + message.rate !== undefined && (obj.rate = message.rate ? DecCoin.toJSON(message.rate) : undefined); + message.balance !== undefined && (obj.balance = message.balance ? DecCoin.toJSON(message.balance) : undefined); + message.withdrawn !== undefined && (obj.withdrawn = message.withdrawn ? Coin.toJSON(message.withdrawn) : undefined); + return obj; + }, + fromPartial, I>>(object: I): FractionalPayment { + const message = createBaseFractionalPayment(); + if (object.accountId !== undefined && object.accountId !== null) { + message.accountId = AccountID.fromPartial(object.accountId); + } + message.paymentId = object.paymentId ?? ""; + message.owner = object.owner ?? ""; + message.state = object.state ?? 0; + if (object.rate !== undefined && object.rate !== null) { + message.rate = DecCoin.fromPartial(object.rate); + } + if (object.balance !== undefined && object.balance !== null) { + message.balance = DecCoin.fromPartial(object.balance); + } + if (object.withdrawn !== undefined && object.withdrawn !== null) { + message.withdrawn = Coin.fromPartial(object.withdrawn); + } + return message; + }, + fromSDK(object: FractionalPaymentSDKType): FractionalPayment { + return { + accountId: object.account_id ? AccountID.fromSDK(object.account_id) : undefined, + paymentId: object?.payment_id, + owner: object?.owner, + state: isSet(object.state) ? fractionalPayment_StateFromJSON(object.state) : -1, + rate: object.rate ? DecCoin.fromSDK(object.rate) : undefined, + balance: object.balance ? DecCoin.fromSDK(object.balance) : undefined, + withdrawn: object.withdrawn ? Coin.fromSDK(object.withdrawn) : undefined + }; + }, + fromSDKJSON(object: any): FractionalPaymentSDKType { + return { + account_id: isSet(object.account_id) ? AccountID.fromSDKJSON(object.account_id) : undefined, + payment_id: isSet(object.payment_id) ? String(object.payment_id) : "", + owner: isSet(object.owner) ? String(object.owner) : "", + state: isSet(object.state) ? fractionalPayment_StateFromJSON(object.state) : -1, + rate: isSet(object.rate) ? DecCoin.fromSDKJSON(object.rate) : undefined, + balance: isSet(object.balance) ? DecCoin.fromSDKJSON(object.balance) : undefined, + withdrawn: isSet(object.withdrawn) ? Coin.fromSDKJSON(object.withdrawn) : undefined + }; + }, + toSDK(message: FractionalPayment): FractionalPaymentSDKType { + const obj: any = {}; + message.accountId !== undefined && (obj.account_id = message.accountId ? AccountID.toSDK(message.accountId) : undefined); + obj.payment_id = message.paymentId; + obj.owner = message.owner; + message.state !== undefined && (obj.state = fractionalPayment_StateToJSON(message.state)); + message.rate !== undefined && (obj.rate = message.rate ? DecCoin.toSDK(message.rate) : undefined); + message.balance !== undefined && (obj.balance = message.balance ? DecCoin.toSDK(message.balance) : undefined); + message.withdrawn !== undefined && (obj.withdrawn = message.withdrawn ? Coin.toSDK(message.withdrawn) : undefined); + return obj; + }, + fromAmino(object: FractionalPaymentAmino): FractionalPayment { + const message = createBaseFractionalPayment(); + if (object.account_id !== undefined && object.account_id !== null) { + message.accountId = AccountID.fromAmino(object.account_id); + } + if (object.payment_id !== undefined && object.payment_id !== null) { + message.paymentId = object.payment_id; + } + if (object.owner !== undefined && object.owner !== null) { + message.owner = object.owner; + } + if (object.state !== undefined && object.state !== null) { + message.state = object.state; + } + if (object.rate !== undefined && object.rate !== null) { + message.rate = DecCoin.fromAmino(object.rate); + } + if (object.balance !== undefined && object.balance !== null) { + message.balance = DecCoin.fromAmino(object.balance); + } + if (object.withdrawn !== undefined && object.withdrawn !== null) { + message.withdrawn = Coin.fromAmino(object.withdrawn); + } + return message; + }, + toAmino(message: FractionalPayment): FractionalPaymentAmino { + const obj: any = {}; + obj.account_id = message.accountId ? AccountID.toAmino(message.accountId) : AccountID.toAmino(AccountID.fromPartial({})); + obj.payment_id = message.paymentId ?? ""; + obj.owner = message.owner ?? ""; + obj.state = message.state ?? 0; + obj.rate = message.rate ? DecCoin.toAmino(message.rate) : DecCoin.toAmino(DecCoin.fromPartial({})); + obj.balance = message.balance ? DecCoin.toAmino(message.balance) : DecCoin.toAmino(DecCoin.fromPartial({})); + obj.withdrawn = message.withdrawn ? Coin.toAmino(message.withdrawn) : Coin.toAmino(Coin.fromPartial({})); + return obj; + }, + fromAminoMsg(object: FractionalPaymentAminoMsg): FractionalPayment { + return FractionalPayment.fromAmino(object.value); + }, + toAminoMsg(message: FractionalPayment): FractionalPaymentAminoMsg { + return { + type: "akash/escrow/v1beta2/fractional-payment", + value: FractionalPayment.toAmino(message) + }; + }, + fromProtoMsg(message: FractionalPaymentProtoMsg): FractionalPayment { + return FractionalPayment.decode(message.value); + }, + toProto(message: FractionalPayment): Uint8Array { + return FractionalPayment.encode(message).finish(); + }, + toProtoMsg(message: FractionalPayment): FractionalPaymentProtoMsg { + return { + typeUrl: "/akash.escrow.v1beta2.FractionalPayment", + value: FractionalPayment.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/inflation/v1beta2/genesis.ts b/__fixtures__/v-next/outputicjsdeps/akash/inflation/v1beta2/genesis.ts new file mode 100644 index 0000000000..a98c988f1e --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/inflation/v1beta2/genesis.ts @@ -0,0 +1,113 @@ +import { Params, ParamsSDKType } from "./params.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial, Exact } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "akash.inflation.v1beta2"; +/** GenesisState stores slice of genesis deployment instance */ +export interface GenesisState { + params: Params; +} +export interface GenesisStateProtoMsg { + typeUrl: "/akash.inflation.v1beta2.GenesisState"; + value: Uint8Array; +} +/** GenesisState stores slice of genesis deployment instance */ +export interface GenesisStateSDKType { + params: ParamsSDKType; +} +function createBaseGenesisState(): GenesisState { + return { + params: Params.fromPartial({}) + }; +} +export const GenesisState = { + typeUrl: "/akash.inflation.v1beta2.GenesisState", + encode(message: GenesisState, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GenesisState { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGenesisState(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.params = Params.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GenesisState { + const obj = createBaseGenesisState(); + if (isSet(object.params)) obj.params = Params.fromJSON(object.params); + return obj; + }, + toJSON(message: GenesisState): JsonSafe { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); + return obj; + }, + fromPartial, I>>(object: I): GenesisState { + const message = createBaseGenesisState(); + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } + return message; + }, + fromSDK(object: GenesisStateSDKType): GenesisState { + return { + params: object.params ? Params.fromSDK(object.params) : undefined + }; + }, + fromSDKJSON(object: any): GenesisStateSDKType { + return { + params: isSet(object.params) ? Params.fromSDKJSON(object.params) : undefined + }; + }, + toSDK(message: GenesisState): GenesisStateSDKType { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toSDK(message.params) : undefined); + return obj; + }, + fromAmino(object: GenesisStateAmino): GenesisState { + const message = createBaseGenesisState(); + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromAmino(object.params); + } + return message; + }, + toAmino(message: GenesisState): GenesisStateAmino { + const obj: any = {}; + obj.params = message.params ? Params.toAmino(message.params) : Params.toAmino(Params.fromPartial({})); + return obj; + }, + fromAminoMsg(object: GenesisStateAminoMsg): GenesisState { + return GenesisState.fromAmino(object.value); + }, + toAminoMsg(message: GenesisState): GenesisStateAminoMsg { + return { + type: "akash/inflation/v1beta2/genesis-state", + value: GenesisState.toAmino(message) + }; + }, + fromProtoMsg(message: GenesisStateProtoMsg): GenesisState { + return GenesisState.decode(message.value); + }, + toProto(message: GenesisState): Uint8Array { + return GenesisState.encode(message).finish(); + }, + toProtoMsg(message: GenesisState): GenesisStateProtoMsg { + return { + typeUrl: "/akash.inflation.v1beta2.GenesisState", + value: GenesisState.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/inflation/v1beta2/params.ts b/__fixtures__/v-next/outputicjsdeps/akash/inflation/v1beta2/params.ts new file mode 100644 index 0000000000..4dc44acea8 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/inflation/v1beta2/params.ts @@ -0,0 +1,158 @@ +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { Decimal } from "@cosmjs/math"; +import { isSet, DeepPartial, Exact } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "akash.inflation.v1beta2"; +/** Params defines the parameters for the x/deployment package */ +export interface Params { + /** InflationDecayFactor is the number of years it takes inflation to halve. */ + inflationDecayFactor: string; + /** + * InitialInflation is the rate at which inflation starts at genesis. + * It is a decimal value in the range [0.0, 100.0]. + */ + initialInflation: string; + /** + * Variance defines the fraction by which inflation can vary from ideal inflation in a block. + * It is a decimal value in the range [0.0, 1.0]. + */ + variance: string; +} +export interface ParamsProtoMsg { + typeUrl: "/akash.inflation.v1beta2.Params"; + value: Uint8Array; +} +/** Params defines the parameters for the x/deployment package */ +export interface ParamsSDKType { + inflation_decay_factor: string; + initial_inflation: string; + variance: string; +} +function createBaseParams(): Params { + return { + inflationDecayFactor: "", + initialInflation: "", + variance: "" + }; +} +export const Params = { + typeUrl: "/akash.inflation.v1beta2.Params", + encode(message: Params, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.inflationDecayFactor !== undefined) { + writer.uint32(10).string(Decimal.fromUserInput(message.inflationDecayFactor, 18).atomics); + } + if (message.initialInflation !== undefined) { + writer.uint32(18).string(Decimal.fromUserInput(message.initialInflation, 18).atomics); + } + if (message.variance !== undefined) { + writer.uint32(26).string(Decimal.fromUserInput(message.variance, 18).atomics); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Params { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseParams(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.inflationDecayFactor = Decimal.fromAtomics(reader.string(), 18).toString(); + break; + case 2: + message.initialInflation = Decimal.fromAtomics(reader.string(), 18).toString(); + break; + case 3: + message.variance = Decimal.fromAtomics(reader.string(), 18).toString(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Params { + const obj = createBaseParams(); + if (isSet(object.inflationDecayFactor)) obj.inflationDecayFactor = String(object.inflationDecayFactor); + if (isSet(object.initialInflation)) obj.initialInflation = String(object.initialInflation); + if (isSet(object.variance)) obj.variance = String(object.variance); + return obj; + }, + toJSON(message: Params): JsonSafe { + const obj: any = {}; + message.inflationDecayFactor !== undefined && (obj.inflationDecayFactor = message.inflationDecayFactor); + message.initialInflation !== undefined && (obj.initialInflation = message.initialInflation); + message.variance !== undefined && (obj.variance = message.variance); + return obj; + }, + fromPartial, I>>(object: I): Params { + const message = createBaseParams(); + message.inflationDecayFactor = object.inflationDecayFactor ?? ""; + message.initialInflation = object.initialInflation ?? ""; + message.variance = object.variance ?? ""; + return message; + }, + fromSDK(object: ParamsSDKType): Params { + return { + inflationDecayFactor: object?.inflation_decay_factor, + initialInflation: object?.initial_inflation, + variance: object?.variance + }; + }, + fromSDKJSON(object: any): ParamsSDKType { + return { + inflation_decay_factor: isSet(object.inflation_decay_factor) ? String(object.inflation_decay_factor) : "", + initial_inflation: isSet(object.initial_inflation) ? String(object.initial_inflation) : "", + variance: isSet(object.variance) ? String(object.variance) : "" + }; + }, + toSDK(message: Params): ParamsSDKType { + const obj: any = {}; + obj.inflation_decay_factor = message.inflationDecayFactor; + obj.initial_inflation = message.initialInflation; + obj.variance = message.variance; + return obj; + }, + fromAmino(object: ParamsAmino): Params { + const message = createBaseParams(); + if (object.inflation_decay_factor !== undefined && object.inflation_decay_factor !== null) { + message.inflationDecayFactor = object.inflation_decay_factor; + } + if (object.initial_inflation !== undefined && object.initial_inflation !== null) { + message.initialInflation = object.initial_inflation; + } + if (object.variance !== undefined && object.variance !== null) { + message.variance = object.variance; + } + return message; + }, + toAmino(message: Params): ParamsAmino { + const obj: any = {}; + obj.inflation_decay_factor = message.inflationDecayFactor ?? ""; + obj.initial_inflation = message.initialInflation ?? ""; + obj.variance = message.variance ?? ""; + return obj; + }, + fromAminoMsg(object: ParamsAminoMsg): Params { + return Params.fromAmino(object.value); + }, + toAminoMsg(message: Params): ParamsAminoMsg { + return { + type: "akash/inflation/v1beta2/params", + value: Params.toAmino(message) + }; + }, + fromProtoMsg(message: ParamsProtoMsg): Params { + return Params.decode(message.value); + }, + toProto(message: Params): Uint8Array { + return Params.encode(message).finish(); + }, + toProtoMsg(message: Params): ParamsProtoMsg { + return { + typeUrl: "/akash.inflation.v1beta2.Params", + value: Params.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/lcd.ts b/__fixtures__/v-next/outputicjsdeps/akash/lcd.ts new file mode 100644 index 0000000000..00e538ff1b --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/lcd.ts @@ -0,0 +1,145 @@ +import { LCDClient } from "@cosmology/lcd"; +export const createLCDClient = async ({ + restEndpoint +}: { + restEndpoint: string; +}) => { + const requestClient = new LCDClient({ + restEndpoint + }); + return { + akash: { + audit: { + v1beta2: new (await import("./audit/v1beta2/query.lcd")).LCDQueryClient({ + requestClient + }) + }, + cert: { + v1beta2: new (await import("./cert/v1beta2/query.lcd")).LCDQueryClient({ + requestClient + }) + }, + deployment: { + v1beta1: new (await import("./deployment/v1beta1/query.lcd")).LCDQueryClient({ + requestClient + }), + v1beta2: new (await import("./deployment/v1beta2/query.lcd")).LCDQueryClient({ + requestClient + }) + }, + escrow: { + v1beta1: new (await import("./escrow/v1beta1/query.lcd")).LCDQueryClient({ + requestClient + }), + v1beta2: new (await import("./escrow/v1beta2/query.lcd")).LCDQueryClient({ + requestClient + }) + }, + market: { + v1beta2: new (await import("./market/v1beta2/query.lcd")).LCDQueryClient({ + requestClient + }) + }, + provider: { + v1beta2: new (await import("./provider/v1beta2/query.lcd")).LCDQueryClient({ + requestClient + }) + } + }, + cosmos: { + auth: { + v1beta1: new (await import("../cosmos/auth/v1beta1/query.lcd")).LCDQueryClient({ + requestClient + }) + }, + authz: { + v1beta1: new (await import("../cosmos/authz/v1beta1/query.lcd")).LCDQueryClient({ + requestClient + }) + }, + bank: { + v1beta1: new (await import("../cosmos/bank/v1beta1/query.lcd")).LCDQueryClient({ + requestClient + }) + }, + base: { + reflection: { + v1beta1: new (await import("../cosmos/base/reflection/v1beta1/reflection.lcd")).LCDQueryClient({ + requestClient + }), + v2alpha1: new (await import("../cosmos/base/reflection/v2alpha1/reflection.lcd")).LCDQueryClient({ + requestClient + }) + }, + tendermint: { + v1beta1: new (await import("../cosmos/base/tendermint/v1beta1/query.lcd")).LCDQueryClient({ + requestClient + }) + } + }, + distribution: { + v1beta1: new (await import("../cosmos/distribution/v1beta1/query.lcd")).LCDQueryClient({ + requestClient + }) + }, + evidence: { + v1beta1: new (await import("../cosmos/evidence/v1beta1/query.lcd")).LCDQueryClient({ + requestClient + }) + }, + feegrant: { + v1beta1: new (await import("../cosmos/feegrant/v1beta1/query.lcd")).LCDQueryClient({ + requestClient + }) + }, + gov: { + v1: new (await import("../cosmos/gov/v1/query.lcd")).LCDQueryClient({ + requestClient + }), + v1beta1: new (await import("../cosmos/gov/v1beta1/query.lcd")).LCDQueryClient({ + requestClient + }) + }, + group: { + v1: new (await import("../cosmos/group/v1/query.lcd")).LCDQueryClient({ + requestClient + }) + }, + mint: { + v1beta1: new (await import("../cosmos/mint/v1beta1/query.lcd")).LCDQueryClient({ + requestClient + }) + }, + nft: { + v1beta1: new (await import("../cosmos/nft/v1beta1/query.lcd")).LCDQueryClient({ + requestClient + }) + }, + params: { + v1beta1: new (await import("../cosmos/params/v1beta1/query.lcd")).LCDQueryClient({ + requestClient + }) + }, + slashing: { + v1beta1: new (await import("../cosmos/slashing/v1beta1/query.lcd")).LCDQueryClient({ + requestClient + }) + }, + staking: { + v1beta1: new (await import("../cosmos/staking/v1beta1/query.lcd")).LCDQueryClient({ + requestClient + }) + }, + tx: { + v1beta1: new (await import("../cosmos/tx/v1beta1/service.lcd")).LCDQueryClient({ + requestClient + }) + }, + upgrade: { + v1beta1: new (await import("../cosmos/upgrade/v1beta1/query.lcd")).LCDQueryClient({ + requestClient + }) + } + } + }; +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/market/v1beta2/bid.ts b/__fixtures__/v-next/outputicjsdeps/akash/market/v1beta2/bid.ts new file mode 100644 index 0000000000..3c4a677ee0 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/market/v1beta2/bid.ts @@ -0,0 +1,1064 @@ +import { OrderID, OrderIDSDKType } from "./order.js"; +import { DecCoin, DecCoinSDKType, Coin, CoinSDKType } from "../../../cosmos/base/v1beta1/coin.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial, Exact } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "akash.market.v1beta2"; +/** State is an enum which refers to state of bid */ +export enum Bid_State { + /** invalid - Prefix should start with 0 in enum. So declaring dummy state */ + invalid = 0, + /** open - BidOpen denotes state for bid open */ + open = 1, + /** active - BidMatched denotes state for bid open */ + active = 2, + /** lost - BidLost denotes state for bid lost */ + lost = 3, + /** closed - BidClosed denotes state for bid closed */ + closed = 4, + UNRECOGNIZED = -1, +} +export const Bid_StateSDKType = Bid_State; +export function bid_StateFromJSON(object: any): Bid_State { + switch (object) { + case 0: + case "invalid": + return Bid_State.invalid; + case 1: + case "open": + return Bid_State.open; + case 2: + case "active": + return Bid_State.active; + case 3: + case "lost": + return Bid_State.lost; + case 4: + case "closed": + return Bid_State.closed; + case -1: + case "UNRECOGNIZED": + default: + return Bid_State.UNRECOGNIZED; + } +} +export function bid_StateToJSON(object: Bid_State): string { + switch (object) { + case Bid_State.invalid: + return "invalid"; + case Bid_State.open: + return "open"; + case Bid_State.active: + return "active"; + case Bid_State.lost: + return "lost"; + case Bid_State.closed: + return "closed"; + case Bid_State.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** MsgCreateBid defines an SDK message for creating Bid */ +export interface MsgCreateBid { + order: OrderID; + provider: string; + price: DecCoin; + deposit: Coin; +} +export interface MsgCreateBidProtoMsg { + typeUrl: "/akash.market.v1beta2.MsgCreateBid"; + value: Uint8Array; +} +/** MsgCreateBid defines an SDK message for creating Bid */ +export interface MsgCreateBidSDKType { + order: OrderIDSDKType; + provider: string; + price: DecCoinSDKType; + deposit: CoinSDKType; +} +/** MsgCreateBidResponse defines the Msg/CreateBid response type. */ +export interface MsgCreateBidResponse {} +export interface MsgCreateBidResponseProtoMsg { + typeUrl: "/akash.market.v1beta2.MsgCreateBidResponse"; + value: Uint8Array; +} +/** MsgCreateBidResponse defines the Msg/CreateBid response type. */ +export interface MsgCreateBidResponseSDKType {} +/** MsgCloseBid defines an SDK message for closing bid */ +export interface MsgCloseBid { + bidId: BidID; +} +export interface MsgCloseBidProtoMsg { + typeUrl: "/akash.market.v1beta2.MsgCloseBid"; + value: Uint8Array; +} +/** MsgCloseBid defines an SDK message for closing bid */ +export interface MsgCloseBidSDKType { + bid_id: BidIDSDKType; +} +/** MsgCloseBidResponse defines the Msg/CloseBid response type. */ +export interface MsgCloseBidResponse {} +export interface MsgCloseBidResponseProtoMsg { + typeUrl: "/akash.market.v1beta2.MsgCloseBidResponse"; + value: Uint8Array; +} +/** MsgCloseBidResponse defines the Msg/CloseBid response type. */ +export interface MsgCloseBidResponseSDKType {} +/** + * BidID stores owner and all other seq numbers + * A successful bid becomes a Lease(ID). + */ +export interface BidID { + owner: string; + dseq: bigint; + gseq: number; + oseq: number; + provider: string; +} +export interface BidIDProtoMsg { + typeUrl: "/akash.market.v1beta2.BidID"; + value: Uint8Array; +} +/** + * BidID stores owner and all other seq numbers + * A successful bid becomes a Lease(ID). + */ +export interface BidIDSDKType { + owner: string; + dseq: bigint; + gseq: number; + oseq: number; + provider: string; +} +/** Bid stores BidID, state of bid and price */ +export interface Bid { + bidId: BidID; + state: Bid_State; + price: DecCoin; + createdAt: bigint; +} +export interface BidProtoMsg { + typeUrl: "/akash.market.v1beta2.Bid"; + value: Uint8Array; +} +/** Bid stores BidID, state of bid and price */ +export interface BidSDKType { + bid_id: BidIDSDKType; + state: Bid_State; + price: DecCoinSDKType; + created_at: bigint; +} +/** BidFilters defines flags for bid list filter */ +export interface BidFilters { + owner: string; + dseq: bigint; + gseq: number; + oseq: number; + provider: string; + state: string; +} +export interface BidFiltersProtoMsg { + typeUrl: "/akash.market.v1beta2.BidFilters"; + value: Uint8Array; +} +/** BidFilters defines flags for bid list filter */ +export interface BidFiltersSDKType { + owner: string; + dseq: bigint; + gseq: number; + oseq: number; + provider: string; + state: string; +} +function createBaseMsgCreateBid(): MsgCreateBid { + return { + order: OrderID.fromPartial({}), + provider: "", + price: DecCoin.fromPartial({}), + deposit: Coin.fromPartial({}) + }; +} +export const MsgCreateBid = { + typeUrl: "/akash.market.v1beta2.MsgCreateBid", + encode(message: MsgCreateBid, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.order !== undefined) { + OrderID.encode(message.order, writer.uint32(10).fork()).ldelim(); + } + if (message.provider !== undefined) { + writer.uint32(18).string(message.provider); + } + if (message.price !== undefined) { + DecCoin.encode(message.price, writer.uint32(26).fork()).ldelim(); + } + if (message.deposit !== undefined) { + Coin.encode(message.deposit, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgCreateBid { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgCreateBid(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.order = OrderID.decode(reader, reader.uint32()); + break; + case 2: + message.provider = reader.string(); + break; + case 3: + message.price = DecCoin.decode(reader, reader.uint32()); + break; + case 4: + message.deposit = Coin.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgCreateBid { + const obj = createBaseMsgCreateBid(); + if (isSet(object.order)) obj.order = OrderID.fromJSON(object.order); + if (isSet(object.provider)) obj.provider = String(object.provider); + if (isSet(object.price)) obj.price = DecCoin.fromJSON(object.price); + if (isSet(object.deposit)) obj.deposit = Coin.fromJSON(object.deposit); + return obj; + }, + toJSON(message: MsgCreateBid): JsonSafe { + const obj: any = {}; + message.order !== undefined && (obj.order = message.order ? OrderID.toJSON(message.order) : undefined); + message.provider !== undefined && (obj.provider = message.provider); + message.price !== undefined && (obj.price = message.price ? DecCoin.toJSON(message.price) : undefined); + message.deposit !== undefined && (obj.deposit = message.deposit ? Coin.toJSON(message.deposit) : undefined); + return obj; + }, + fromPartial, I>>(object: I): MsgCreateBid { + const message = createBaseMsgCreateBid(); + if (object.order !== undefined && object.order !== null) { + message.order = OrderID.fromPartial(object.order); + } + message.provider = object.provider ?? ""; + if (object.price !== undefined && object.price !== null) { + message.price = DecCoin.fromPartial(object.price); + } + if (object.deposit !== undefined && object.deposit !== null) { + message.deposit = Coin.fromPartial(object.deposit); + } + return message; + }, + fromSDK(object: MsgCreateBidSDKType): MsgCreateBid { + return { + order: object.order ? OrderID.fromSDK(object.order) : undefined, + provider: object?.provider, + price: object.price ? DecCoin.fromSDK(object.price) : undefined, + deposit: object.deposit ? Coin.fromSDK(object.deposit) : undefined + }; + }, + fromSDKJSON(object: any): MsgCreateBidSDKType { + return { + order: isSet(object.order) ? OrderID.fromSDKJSON(object.order) : undefined, + provider: isSet(object.provider) ? String(object.provider) : "", + price: isSet(object.price) ? DecCoin.fromSDKJSON(object.price) : undefined, + deposit: isSet(object.deposit) ? Coin.fromSDKJSON(object.deposit) : undefined + }; + }, + toSDK(message: MsgCreateBid): MsgCreateBidSDKType { + const obj: any = {}; + message.order !== undefined && (obj.order = message.order ? OrderID.toSDK(message.order) : undefined); + obj.provider = message.provider; + message.price !== undefined && (obj.price = message.price ? DecCoin.toSDK(message.price) : undefined); + message.deposit !== undefined && (obj.deposit = message.deposit ? Coin.toSDK(message.deposit) : undefined); + return obj; + }, + fromAmino(object: MsgCreateBidAmino): MsgCreateBid { + const message = createBaseMsgCreateBid(); + if (object.order !== undefined && object.order !== null) { + message.order = OrderID.fromAmino(object.order); + } + if (object.provider !== undefined && object.provider !== null) { + message.provider = object.provider; + } + if (object.price !== undefined && object.price !== null) { + message.price = DecCoin.fromAmino(object.price); + } + if (object.deposit !== undefined && object.deposit !== null) { + message.deposit = Coin.fromAmino(object.deposit); + } + return message; + }, + toAmino(message: MsgCreateBid): MsgCreateBidAmino { + const obj: any = {}; + obj.order = message.order ? OrderID.toAmino(message.order) : OrderID.toAmino(OrderID.fromPartial({})); + obj.provider = message.provider ?? ""; + obj.price = message.price ? DecCoin.toAmino(message.price) : DecCoin.toAmino(DecCoin.fromPartial({})); + obj.deposit = message.deposit ? Coin.toAmino(message.deposit) : Coin.toAmino(Coin.fromPartial({})); + return obj; + }, + fromAminoMsg(object: MsgCreateBidAminoMsg): MsgCreateBid { + return MsgCreateBid.fromAmino(object.value); + }, + toAminoMsg(message: MsgCreateBid): MsgCreateBidAminoMsg { + return { + type: "akash/market/v1beta2/testonly-create-bid", + value: MsgCreateBid.toAmino(message) + }; + }, + fromProtoMsg(message: MsgCreateBidProtoMsg): MsgCreateBid { + return MsgCreateBid.decode(message.value); + }, + toProto(message: MsgCreateBid): Uint8Array { + return MsgCreateBid.encode(message).finish(); + }, + toProtoMsg(message: MsgCreateBid): MsgCreateBidProtoMsg { + return { + typeUrl: "/akash.market.v1beta2.MsgCreateBid", + value: MsgCreateBid.encode(message).finish() + }; + } +}; +function createBaseMsgCreateBidResponse(): MsgCreateBidResponse { + return {}; +} +export const MsgCreateBidResponse = { + typeUrl: "/akash.market.v1beta2.MsgCreateBidResponse", + encode(_: MsgCreateBidResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgCreateBidResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgCreateBidResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgCreateBidResponse { + const obj = createBaseMsgCreateBidResponse(); + return obj; + }, + toJSON(_: MsgCreateBidResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): MsgCreateBidResponse { + const message = createBaseMsgCreateBidResponse(); + return message; + }, + fromSDK(_: MsgCreateBidResponseSDKType): MsgCreateBidResponse { + return {}; + }, + fromSDKJSON(_: any): MsgCreateBidResponseSDKType { + return {}; + }, + toSDK(_: MsgCreateBidResponse): MsgCreateBidResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgCreateBidResponseAmino): MsgCreateBidResponse { + const message = createBaseMsgCreateBidResponse(); + return message; + }, + toAmino(_: MsgCreateBidResponse): MsgCreateBidResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgCreateBidResponseAminoMsg): MsgCreateBidResponse { + return MsgCreateBidResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgCreateBidResponse): MsgCreateBidResponseAminoMsg { + return { + type: "akash/market/v1beta2/testonly-create-bid-response", + value: MsgCreateBidResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgCreateBidResponseProtoMsg): MsgCreateBidResponse { + return MsgCreateBidResponse.decode(message.value); + }, + toProto(message: MsgCreateBidResponse): Uint8Array { + return MsgCreateBidResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgCreateBidResponse): MsgCreateBidResponseProtoMsg { + return { + typeUrl: "/akash.market.v1beta2.MsgCreateBidResponse", + value: MsgCreateBidResponse.encode(message).finish() + }; + } +}; +function createBaseMsgCloseBid(): MsgCloseBid { + return { + bidId: BidID.fromPartial({}) + }; +} +export const MsgCloseBid = { + typeUrl: "/akash.market.v1beta2.MsgCloseBid", + encode(message: MsgCloseBid, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.bidId !== undefined) { + BidID.encode(message.bidId, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgCloseBid { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgCloseBid(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.bidId = BidID.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgCloseBid { + const obj = createBaseMsgCloseBid(); + if (isSet(object.bidId)) obj.bidId = BidID.fromJSON(object.bidId); + return obj; + }, + toJSON(message: MsgCloseBid): JsonSafe { + const obj: any = {}; + message.bidId !== undefined && (obj.bidId = message.bidId ? BidID.toJSON(message.bidId) : undefined); + return obj; + }, + fromPartial, I>>(object: I): MsgCloseBid { + const message = createBaseMsgCloseBid(); + if (object.bidId !== undefined && object.bidId !== null) { + message.bidId = BidID.fromPartial(object.bidId); + } + return message; + }, + fromSDK(object: MsgCloseBidSDKType): MsgCloseBid { + return { + bidId: object.bid_id ? BidID.fromSDK(object.bid_id) : undefined + }; + }, + fromSDKJSON(object: any): MsgCloseBidSDKType { + return { + bid_id: isSet(object.bid_id) ? BidID.fromSDKJSON(object.bid_id) : undefined + }; + }, + toSDK(message: MsgCloseBid): MsgCloseBidSDKType { + const obj: any = {}; + message.bidId !== undefined && (obj.bid_id = message.bidId ? BidID.toSDK(message.bidId) : undefined); + return obj; + }, + fromAmino(object: MsgCloseBidAmino): MsgCloseBid { + const message = createBaseMsgCloseBid(); + if (object.bid_id !== undefined && object.bid_id !== null) { + message.bidId = BidID.fromAmino(object.bid_id); + } + return message; + }, + toAmino(message: MsgCloseBid): MsgCloseBidAmino { + const obj: any = {}; + obj.bid_id = message.bidId ? BidID.toAmino(message.bidId) : BidID.toAmino(BidID.fromPartial({})); + return obj; + }, + fromAminoMsg(object: MsgCloseBidAminoMsg): MsgCloseBid { + return MsgCloseBid.fromAmino(object.value); + }, + toAminoMsg(message: MsgCloseBid): MsgCloseBidAminoMsg { + return { + type: "akash/market/v1beta2/testonly-close-bid", + value: MsgCloseBid.toAmino(message) + }; + }, + fromProtoMsg(message: MsgCloseBidProtoMsg): MsgCloseBid { + return MsgCloseBid.decode(message.value); + }, + toProto(message: MsgCloseBid): Uint8Array { + return MsgCloseBid.encode(message).finish(); + }, + toProtoMsg(message: MsgCloseBid): MsgCloseBidProtoMsg { + return { + typeUrl: "/akash.market.v1beta2.MsgCloseBid", + value: MsgCloseBid.encode(message).finish() + }; + } +}; +function createBaseMsgCloseBidResponse(): MsgCloseBidResponse { + return {}; +} +export const MsgCloseBidResponse = { + typeUrl: "/akash.market.v1beta2.MsgCloseBidResponse", + encode(_: MsgCloseBidResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgCloseBidResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgCloseBidResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgCloseBidResponse { + const obj = createBaseMsgCloseBidResponse(); + return obj; + }, + toJSON(_: MsgCloseBidResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): MsgCloseBidResponse { + const message = createBaseMsgCloseBidResponse(); + return message; + }, + fromSDK(_: MsgCloseBidResponseSDKType): MsgCloseBidResponse { + return {}; + }, + fromSDKJSON(_: any): MsgCloseBidResponseSDKType { + return {}; + }, + toSDK(_: MsgCloseBidResponse): MsgCloseBidResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgCloseBidResponseAmino): MsgCloseBidResponse { + const message = createBaseMsgCloseBidResponse(); + return message; + }, + toAmino(_: MsgCloseBidResponse): MsgCloseBidResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgCloseBidResponseAminoMsg): MsgCloseBidResponse { + return MsgCloseBidResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgCloseBidResponse): MsgCloseBidResponseAminoMsg { + return { + type: "akash/market/v1beta2/testonly-close-bid-response", + value: MsgCloseBidResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgCloseBidResponseProtoMsg): MsgCloseBidResponse { + return MsgCloseBidResponse.decode(message.value); + }, + toProto(message: MsgCloseBidResponse): Uint8Array { + return MsgCloseBidResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgCloseBidResponse): MsgCloseBidResponseProtoMsg { + return { + typeUrl: "/akash.market.v1beta2.MsgCloseBidResponse", + value: MsgCloseBidResponse.encode(message).finish() + }; + } +}; +function createBaseBidID(): BidID { + return { + owner: "", + dseq: BigInt(0), + gseq: 0, + oseq: 0, + provider: "" + }; +} +export const BidID = { + typeUrl: "/akash.market.v1beta2.BidID", + encode(message: BidID, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.owner !== undefined) { + writer.uint32(10).string(message.owner); + } + if (message.dseq !== undefined) { + writer.uint32(16).uint64(message.dseq); + } + if (message.gseq !== undefined) { + writer.uint32(24).uint32(message.gseq); + } + if (message.oseq !== undefined) { + writer.uint32(32).uint32(message.oseq); + } + if (message.provider !== undefined) { + writer.uint32(42).string(message.provider); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): BidID { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseBidID(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.owner = reader.string(); + break; + case 2: + message.dseq = reader.uint64(); + break; + case 3: + message.gseq = reader.uint32(); + break; + case 4: + message.oseq = reader.uint32(); + break; + case 5: + message.provider = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): BidID { + const obj = createBaseBidID(); + if (isSet(object.owner)) obj.owner = String(object.owner); + if (isSet(object.dseq)) obj.dseq = BigInt(object.dseq.toString()); + if (isSet(object.gseq)) obj.gseq = Number(object.gseq); + if (isSet(object.oseq)) obj.oseq = Number(object.oseq); + if (isSet(object.provider)) obj.provider = String(object.provider); + return obj; + }, + toJSON(message: BidID): JsonSafe { + const obj: any = {}; + message.owner !== undefined && (obj.owner = message.owner); + message.dseq !== undefined && (obj.dseq = (message.dseq || BigInt(0)).toString()); + message.gseq !== undefined && (obj.gseq = Math.round(message.gseq)); + message.oseq !== undefined && (obj.oseq = Math.round(message.oseq)); + message.provider !== undefined && (obj.provider = message.provider); + return obj; + }, + fromPartial, I>>(object: I): BidID { + const message = createBaseBidID(); + message.owner = object.owner ?? ""; + if (object.dseq !== undefined && object.dseq !== null) { + message.dseq = BigInt(object.dseq.toString()); + } + message.gseq = object.gseq ?? 0; + message.oseq = object.oseq ?? 0; + message.provider = object.provider ?? ""; + return message; + }, + fromSDK(object: BidIDSDKType): BidID { + return { + owner: object?.owner, + dseq: object?.dseq, + gseq: object?.gseq, + oseq: object?.oseq, + provider: object?.provider + }; + }, + fromSDKJSON(object: any): BidIDSDKType { + return { + owner: isSet(object.owner) ? String(object.owner) : "", + dseq: isSet(object.dseq) ? BigInt(object.dseq.toString()) : BigInt(0), + gseq: isSet(object.gseq) ? Number(object.gseq) : 0, + oseq: isSet(object.oseq) ? Number(object.oseq) : 0, + provider: isSet(object.provider) ? String(object.provider) : "" + }; + }, + toSDK(message: BidID): BidIDSDKType { + const obj: any = {}; + obj.owner = message.owner; + obj.dseq = message.dseq; + obj.gseq = message.gseq; + obj.oseq = message.oseq; + obj.provider = message.provider; + return obj; + }, + fromAmino(object: BidIDAmino): BidID { + const message = createBaseBidID(); + if (object.owner !== undefined && object.owner !== null) { + message.owner = object.owner; + } + if (object.dseq !== undefined && object.dseq !== null) { + message.dseq = BigInt(object.dseq); + } + if (object.gseq !== undefined && object.gseq !== null) { + message.gseq = object.gseq; + } + if (object.oseq !== undefined && object.oseq !== null) { + message.oseq = object.oseq; + } + if (object.provider !== undefined && object.provider !== null) { + message.provider = object.provider; + } + return message; + }, + toAmino(message: BidID): BidIDAmino { + const obj: any = {}; + obj.owner = message.owner ?? ""; + obj.dseq = message.dseq ? message.dseq?.toString() : "0"; + obj.gseq = message.gseq ?? 0; + obj.oseq = message.oseq ?? 0; + obj.provider = message.provider ?? ""; + return obj; + }, + fromAminoMsg(object: BidIDAminoMsg): BidID { + return BidID.fromAmino(object.value); + }, + toAminoMsg(message: BidID): BidIDAminoMsg { + return { + type: "akash/market/v1beta2/bid-i-d", + value: BidID.toAmino(message) + }; + }, + fromProtoMsg(message: BidIDProtoMsg): BidID { + return BidID.decode(message.value); + }, + toProto(message: BidID): Uint8Array { + return BidID.encode(message).finish(); + }, + toProtoMsg(message: BidID): BidIDProtoMsg { + return { + typeUrl: "/akash.market.v1beta2.BidID", + value: BidID.encode(message).finish() + }; + } +}; +function createBaseBid(): Bid { + return { + bidId: BidID.fromPartial({}), + state: 0, + price: DecCoin.fromPartial({}), + createdAt: BigInt(0) + }; +} +export const Bid = { + typeUrl: "/akash.market.v1beta2.Bid", + encode(message: Bid, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.bidId !== undefined) { + BidID.encode(message.bidId, writer.uint32(10).fork()).ldelim(); + } + if (message.state !== 0) { + writer.uint32(16).int32(message.state); + } + if (message.price !== undefined) { + DecCoin.encode(message.price, writer.uint32(26).fork()).ldelim(); + } + if (message.createdAt !== undefined) { + writer.uint32(32).int64(message.createdAt); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Bid { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseBid(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.bidId = BidID.decode(reader, reader.uint32()); + break; + case 2: + message.state = (reader.int32() as any); + break; + case 3: + message.price = DecCoin.decode(reader, reader.uint32()); + break; + case 4: + message.createdAt = reader.int64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Bid { + const obj = createBaseBid(); + if (isSet(object.bidId)) obj.bidId = BidID.fromJSON(object.bidId); + if (isSet(object.state)) obj.state = bid_StateFromJSON(object.state); + if (isSet(object.price)) obj.price = DecCoin.fromJSON(object.price); + if (isSet(object.createdAt)) obj.createdAt = BigInt(object.createdAt.toString()); + return obj; + }, + toJSON(message: Bid): JsonSafe { + const obj: any = {}; + message.bidId !== undefined && (obj.bidId = message.bidId ? BidID.toJSON(message.bidId) : undefined); + message.state !== undefined && (obj.state = bid_StateToJSON(message.state)); + message.price !== undefined && (obj.price = message.price ? DecCoin.toJSON(message.price) : undefined); + message.createdAt !== undefined && (obj.createdAt = (message.createdAt || BigInt(0)).toString()); + return obj; + }, + fromPartial, I>>(object: I): Bid { + const message = createBaseBid(); + if (object.bidId !== undefined && object.bidId !== null) { + message.bidId = BidID.fromPartial(object.bidId); + } + message.state = object.state ?? 0; + if (object.price !== undefined && object.price !== null) { + message.price = DecCoin.fromPartial(object.price); + } + if (object.createdAt !== undefined && object.createdAt !== null) { + message.createdAt = BigInt(object.createdAt.toString()); + } + return message; + }, + fromSDK(object: BidSDKType): Bid { + return { + bidId: object.bid_id ? BidID.fromSDK(object.bid_id) : undefined, + state: isSet(object.state) ? bid_StateFromJSON(object.state) : -1, + price: object.price ? DecCoin.fromSDK(object.price) : undefined, + createdAt: object?.created_at + }; + }, + fromSDKJSON(object: any): BidSDKType { + return { + bid_id: isSet(object.bid_id) ? BidID.fromSDKJSON(object.bid_id) : undefined, + state: isSet(object.state) ? bid_StateFromJSON(object.state) : -1, + price: isSet(object.price) ? DecCoin.fromSDKJSON(object.price) : undefined, + created_at: isSet(object.created_at) ? BigInt(object.created_at.toString()) : BigInt(0) + }; + }, + toSDK(message: Bid): BidSDKType { + const obj: any = {}; + message.bidId !== undefined && (obj.bid_id = message.bidId ? BidID.toSDK(message.bidId) : undefined); + message.state !== undefined && (obj.state = bid_StateToJSON(message.state)); + message.price !== undefined && (obj.price = message.price ? DecCoin.toSDK(message.price) : undefined); + obj.created_at = message.createdAt; + return obj; + }, + fromAmino(object: BidAmino): Bid { + const message = createBaseBid(); + if (object.bid_id !== undefined && object.bid_id !== null) { + message.bidId = BidID.fromAmino(object.bid_id); + } + if (object.state !== undefined && object.state !== null) { + message.state = object.state; + } + if (object.price !== undefined && object.price !== null) { + message.price = DecCoin.fromAmino(object.price); + } + if (object.created_at !== undefined && object.created_at !== null) { + message.createdAt = BigInt(object.created_at); + } + return message; + }, + toAmino(message: Bid): BidAmino { + const obj: any = {}; + obj.bid_id = message.bidId ? BidID.toAmino(message.bidId) : BidID.toAmino(BidID.fromPartial({})); + obj.state = message.state ?? 0; + obj.price = message.price ? DecCoin.toAmino(message.price) : DecCoin.toAmino(DecCoin.fromPartial({})); + obj.created_at = message.createdAt !== BigInt(0) ? message.createdAt?.toString() : undefined; + return obj; + }, + fromAminoMsg(object: BidAminoMsg): Bid { + return Bid.fromAmino(object.value); + }, + toAminoMsg(message: Bid): BidAminoMsg { + return { + type: "akash/market/v1beta2/bid", + value: Bid.toAmino(message) + }; + }, + fromProtoMsg(message: BidProtoMsg): Bid { + return Bid.decode(message.value); + }, + toProto(message: Bid): Uint8Array { + return Bid.encode(message).finish(); + }, + toProtoMsg(message: Bid): BidProtoMsg { + return { + typeUrl: "/akash.market.v1beta2.Bid", + value: Bid.encode(message).finish() + }; + } +}; +function createBaseBidFilters(): BidFilters { + return { + owner: "", + dseq: BigInt(0), + gseq: 0, + oseq: 0, + provider: "", + state: "" + }; +} +export const BidFilters = { + typeUrl: "/akash.market.v1beta2.BidFilters", + encode(message: BidFilters, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.owner !== undefined) { + writer.uint32(10).string(message.owner); + } + if (message.dseq !== undefined) { + writer.uint32(16).uint64(message.dseq); + } + if (message.gseq !== undefined) { + writer.uint32(24).uint32(message.gseq); + } + if (message.oseq !== undefined) { + writer.uint32(32).uint32(message.oseq); + } + if (message.provider !== undefined) { + writer.uint32(42).string(message.provider); + } + if (message.state !== undefined) { + writer.uint32(50).string(message.state); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): BidFilters { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseBidFilters(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.owner = reader.string(); + break; + case 2: + message.dseq = reader.uint64(); + break; + case 3: + message.gseq = reader.uint32(); + break; + case 4: + message.oseq = reader.uint32(); + break; + case 5: + message.provider = reader.string(); + break; + case 6: + message.state = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): BidFilters { + const obj = createBaseBidFilters(); + if (isSet(object.owner)) obj.owner = String(object.owner); + if (isSet(object.dseq)) obj.dseq = BigInt(object.dseq.toString()); + if (isSet(object.gseq)) obj.gseq = Number(object.gseq); + if (isSet(object.oseq)) obj.oseq = Number(object.oseq); + if (isSet(object.provider)) obj.provider = String(object.provider); + if (isSet(object.state)) obj.state = String(object.state); + return obj; + }, + toJSON(message: BidFilters): JsonSafe { + const obj: any = {}; + message.owner !== undefined && (obj.owner = message.owner); + message.dseq !== undefined && (obj.dseq = (message.dseq || BigInt(0)).toString()); + message.gseq !== undefined && (obj.gseq = Math.round(message.gseq)); + message.oseq !== undefined && (obj.oseq = Math.round(message.oseq)); + message.provider !== undefined && (obj.provider = message.provider); + message.state !== undefined && (obj.state = message.state); + return obj; + }, + fromPartial, I>>(object: I): BidFilters { + const message = createBaseBidFilters(); + message.owner = object.owner ?? ""; + if (object.dseq !== undefined && object.dseq !== null) { + message.dseq = BigInt(object.dseq.toString()); + } + message.gseq = object.gseq ?? 0; + message.oseq = object.oseq ?? 0; + message.provider = object.provider ?? ""; + message.state = object.state ?? ""; + return message; + }, + fromSDK(object: BidFiltersSDKType): BidFilters { + return { + owner: object?.owner, + dseq: object?.dseq, + gseq: object?.gseq, + oseq: object?.oseq, + provider: object?.provider, + state: object?.state + }; + }, + fromSDKJSON(object: any): BidFiltersSDKType { + return { + owner: isSet(object.owner) ? String(object.owner) : "", + dseq: isSet(object.dseq) ? BigInt(object.dseq.toString()) : BigInt(0), + gseq: isSet(object.gseq) ? Number(object.gseq) : 0, + oseq: isSet(object.oseq) ? Number(object.oseq) : 0, + provider: isSet(object.provider) ? String(object.provider) : "", + state: isSet(object.state) ? String(object.state) : "" + }; + }, + toSDK(message: BidFilters): BidFiltersSDKType { + const obj: any = {}; + obj.owner = message.owner; + obj.dseq = message.dseq; + obj.gseq = message.gseq; + obj.oseq = message.oseq; + obj.provider = message.provider; + obj.state = message.state; + return obj; + }, + fromAmino(object: BidFiltersAmino): BidFilters { + const message = createBaseBidFilters(); + if (object.owner !== undefined && object.owner !== null) { + message.owner = object.owner; + } + if (object.dseq !== undefined && object.dseq !== null) { + message.dseq = BigInt(object.dseq); + } + if (object.gseq !== undefined && object.gseq !== null) { + message.gseq = object.gseq; + } + if (object.oseq !== undefined && object.oseq !== null) { + message.oseq = object.oseq; + } + if (object.provider !== undefined && object.provider !== null) { + message.provider = object.provider; + } + if (object.state !== undefined && object.state !== null) { + message.state = object.state; + } + return message; + }, + toAmino(message: BidFilters): BidFiltersAmino { + const obj: any = {}; + obj.owner = message.owner ?? ""; + obj.dseq = message.dseq ? message.dseq?.toString() : "0"; + obj.gseq = message.gseq ?? 0; + obj.oseq = message.oseq ?? 0; + obj.provider = message.provider ?? ""; + obj.state = message.state ?? ""; + return obj; + }, + fromAminoMsg(object: BidFiltersAminoMsg): BidFilters { + return BidFilters.fromAmino(object.value); + }, + toAminoMsg(message: BidFilters): BidFiltersAminoMsg { + return { + type: "akash/market/v1beta2/bid-filters", + value: BidFilters.toAmino(message) + }; + }, + fromProtoMsg(message: BidFiltersProtoMsg): BidFilters { + return BidFilters.decode(message.value); + }, + toProto(message: BidFilters): Uint8Array { + return BidFilters.encode(message).finish(); + }, + toProtoMsg(message: BidFilters): BidFiltersProtoMsg { + return { + typeUrl: "/akash.market.v1beta2.BidFilters", + value: BidFilters.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/market/v1beta2/genesis.ts b/__fixtures__/v-next/outputicjsdeps/akash/market/v1beta2/genesis.ts new file mode 100644 index 0000000000..0f3383be41 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/market/v1beta2/genesis.ts @@ -0,0 +1,173 @@ +import { Order, OrderSDKType } from "./order.js"; +import { Lease, LeaseSDKType } from "./lease.js"; +import { Params, ParamsSDKType } from "./params.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial, Exact } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "akash.market.v1beta2"; +/** GenesisState defines the basic genesis state used by market module */ +export interface GenesisState { + orders: Order[]; + leases: Lease[]; + params: Params; +} +export interface GenesisStateProtoMsg { + typeUrl: "/akash.market.v1beta2.GenesisState"; + value: Uint8Array; +} +/** GenesisState defines the basic genesis state used by market module */ +export interface GenesisStateSDKType { + orders: OrderSDKType[]; + leases: LeaseSDKType[]; + params: ParamsSDKType; +} +function createBaseGenesisState(): GenesisState { + return { + orders: [], + leases: [], + params: Params.fromPartial({}) + }; +} +export const GenesisState = { + typeUrl: "/akash.market.v1beta2.GenesisState", + encode(message: GenesisState, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.orders) { + Order.encode(v!, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.leases) { + Lease.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GenesisState { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGenesisState(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.orders.push(Order.decode(reader, reader.uint32())); + break; + case 2: + message.leases.push(Lease.decode(reader, reader.uint32())); + break; + case 3: + message.params = Params.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GenesisState { + const obj = createBaseGenesisState(); + if (Array.isArray(object?.orders)) obj.orders = object.orders.map((e: any) => Order.fromJSON(e)); + if (Array.isArray(object?.leases)) obj.leases = object.leases.map((e: any) => Lease.fromJSON(e)); + if (isSet(object.params)) obj.params = Params.fromJSON(object.params); + return obj; + }, + toJSON(message: GenesisState): JsonSafe { + const obj: any = {}; + if (message.orders) { + obj.orders = message.orders.map(e => e ? Order.toJSON(e) : undefined); + } else { + obj.orders = []; + } + if (message.leases) { + obj.leases = message.leases.map(e => e ? Lease.toJSON(e) : undefined); + } else { + obj.leases = []; + } + message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); + return obj; + }, + fromPartial, I>>(object: I): GenesisState { + const message = createBaseGenesisState(); + message.orders = object.orders?.map(e => Order.fromPartial(e)) || []; + message.leases = object.leases?.map(e => Lease.fromPartial(e)) || []; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } + return message; + }, + fromSDK(object: GenesisStateSDKType): GenesisState { + return { + orders: Array.isArray(object?.orders) ? object.orders.map((e: any) => Order.fromSDK(e)) : [], + leases: Array.isArray(object?.leases) ? object.leases.map((e: any) => Lease.fromSDK(e)) : [], + params: object.params ? Params.fromSDK(object.params) : undefined + }; + }, + fromSDKJSON(object: any): GenesisStateSDKType { + return { + orders: Array.isArray(object?.orders) ? object.orders.map((e: any) => Order.fromSDKJSON(e)) : [], + leases: Array.isArray(object?.leases) ? object.leases.map((e: any) => Lease.fromSDKJSON(e)) : [], + params: isSet(object.params) ? Params.fromSDKJSON(object.params) : undefined + }; + }, + toSDK(message: GenesisState): GenesisStateSDKType { + const obj: any = {}; + if (message.orders) { + obj.orders = message.orders.map(e => e ? Order.toSDK(e) : undefined); + } else { + obj.orders = []; + } + if (message.leases) { + obj.leases = message.leases.map(e => e ? Lease.toSDK(e) : undefined); + } else { + obj.leases = []; + } + message.params !== undefined && (obj.params = message.params ? Params.toSDK(message.params) : undefined); + return obj; + }, + fromAmino(object: GenesisStateAmino): GenesisState { + const message = createBaseGenesisState(); + message.orders = object.orders?.map(e => Order.fromAmino(e)) || []; + message.leases = object.leases?.map(e => Lease.fromAmino(e)) || []; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromAmino(object.params); + } + return message; + }, + toAmino(message: GenesisState): GenesisStateAmino { + const obj: any = {}; + if (message.orders) { + obj.orders = message.orders.map(e => e ? Order.toAmino(e) : undefined); + } else { + obj.orders = message.orders; + } + if (message.leases) { + obj.leases = message.leases.map(e => e ? Lease.toAmino(e) : undefined); + } else { + obj.leases = message.leases; + } + obj.params = message.params ? Params.toAmino(message.params) : Params.toAmino(Params.fromPartial({})); + return obj; + }, + fromAminoMsg(object: GenesisStateAminoMsg): GenesisState { + return GenesisState.fromAmino(object.value); + }, + toAminoMsg(message: GenesisState): GenesisStateAminoMsg { + return { + type: "akash/market/v1beta2/genesis-state", + value: GenesisState.toAmino(message) + }; + }, + fromProtoMsg(message: GenesisStateProtoMsg): GenesisState { + return GenesisState.decode(message.value); + }, + toProto(message: GenesisState): Uint8Array { + return GenesisState.encode(message).finish(); + }, + toProtoMsg(message: GenesisState): GenesisStateProtoMsg { + return { + typeUrl: "/akash.market.v1beta2.GenesisState", + value: GenesisState.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/market/v1beta2/lease.ts b/__fixtures__/v-next/outputicjsdeps/akash/market/v1beta2/lease.ts new file mode 100644 index 0000000000..ee2ab39e69 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/market/v1beta2/lease.ts @@ -0,0 +1,1201 @@ +import { DecCoin, DecCoinSDKType } from "../../../cosmos/base/v1beta1/coin.js"; +import { BidID, BidIDSDKType } from "./bid.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial, Exact } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "akash.market.v1beta2"; +/** State is an enum which refers to state of lease */ +export enum Lease_State { + /** invalid - Prefix should start with 0 in enum. So declaring dummy state */ + invalid = 0, + /** active - LeaseActive denotes state for lease active */ + active = 1, + /** insufficient_funds - LeaseInsufficientFunds denotes state for lease insufficient_funds */ + insufficient_funds = 2, + /** closed - LeaseClosed denotes state for lease closed */ + closed = 3, + UNRECOGNIZED = -1, +} +export const Lease_StateSDKType = Lease_State; +export function lease_StateFromJSON(object: any): Lease_State { + switch (object) { + case 0: + case "invalid": + return Lease_State.invalid; + case 1: + case "active": + return Lease_State.active; + case 2: + case "insufficient_funds": + return Lease_State.insufficient_funds; + case 3: + case "closed": + return Lease_State.closed; + case -1: + case "UNRECOGNIZED": + default: + return Lease_State.UNRECOGNIZED; + } +} +export function lease_StateToJSON(object: Lease_State): string { + switch (object) { + case Lease_State.invalid: + return "invalid"; + case Lease_State.active: + return "active"; + case Lease_State.insufficient_funds: + return "insufficient_funds"; + case Lease_State.closed: + return "closed"; + case Lease_State.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** LeaseID stores bid details of lease */ +export interface LeaseID { + owner: string; + dseq: bigint; + gseq: number; + oseq: number; + provider: string; +} +export interface LeaseIDProtoMsg { + typeUrl: "/akash.market.v1beta2.LeaseID"; + value: Uint8Array; +} +/** LeaseID stores bid details of lease */ +export interface LeaseIDSDKType { + owner: string; + dseq: bigint; + gseq: number; + oseq: number; + provider: string; +} +/** Lease stores LeaseID, state of lease and price */ +export interface Lease { + leaseId: LeaseID; + state: Lease_State; + price: DecCoin; + createdAt: bigint; + closedOn: bigint; +} +export interface LeaseProtoMsg { + typeUrl: "/akash.market.v1beta2.Lease"; + value: Uint8Array; +} +/** Lease stores LeaseID, state of lease and price */ +export interface LeaseSDKType { + lease_id: LeaseIDSDKType; + state: Lease_State; + price: DecCoinSDKType; + created_at: bigint; + closed_on: bigint; +} +/** LeaseFilters defines flags for lease list filter */ +export interface LeaseFilters { + owner: string; + dseq: bigint; + gseq: number; + oseq: number; + provider: string; + state: string; +} +export interface LeaseFiltersProtoMsg { + typeUrl: "/akash.market.v1beta2.LeaseFilters"; + value: Uint8Array; +} +/** LeaseFilters defines flags for lease list filter */ +export interface LeaseFiltersSDKType { + owner: string; + dseq: bigint; + gseq: number; + oseq: number; + provider: string; + state: string; +} +/** MsgCreateLease is sent to create a lease */ +export interface MsgCreateLease { + bidId: BidID; +} +export interface MsgCreateLeaseProtoMsg { + typeUrl: "/akash.market.v1beta2.MsgCreateLease"; + value: Uint8Array; +} +/** MsgCreateLease is sent to create a lease */ +export interface MsgCreateLeaseSDKType { + bid_id: BidIDSDKType; +} +/** MsgCreateLeaseResponse is the response from creating a lease */ +export interface MsgCreateLeaseResponse {} +export interface MsgCreateLeaseResponseProtoMsg { + typeUrl: "/akash.market.v1beta2.MsgCreateLeaseResponse"; + value: Uint8Array; +} +/** MsgCreateLeaseResponse is the response from creating a lease */ +export interface MsgCreateLeaseResponseSDKType {} +/** MsgWithdrawLease defines an SDK message for closing bid */ +export interface MsgWithdrawLease { + bidId: LeaseID; +} +export interface MsgWithdrawLeaseProtoMsg { + typeUrl: "/akash.market.v1beta2.MsgWithdrawLease"; + value: Uint8Array; +} +/** MsgWithdrawLease defines an SDK message for closing bid */ +export interface MsgWithdrawLeaseSDKType { + bid_id: LeaseIDSDKType; +} +/** MsgWithdrawLeaseResponse defines the Msg/WithdrawLease response type. */ +export interface MsgWithdrawLeaseResponse {} +export interface MsgWithdrawLeaseResponseProtoMsg { + typeUrl: "/akash.market.v1beta2.MsgWithdrawLeaseResponse"; + value: Uint8Array; +} +/** MsgWithdrawLeaseResponse defines the Msg/WithdrawLease response type. */ +export interface MsgWithdrawLeaseResponseSDKType {} +/** MsgCloseLease defines an SDK message for closing order */ +export interface MsgCloseLease { + leaseId: LeaseID; +} +export interface MsgCloseLeaseProtoMsg { + typeUrl: "/akash.market.v1beta2.MsgCloseLease"; + value: Uint8Array; +} +/** MsgCloseLease defines an SDK message for closing order */ +export interface MsgCloseLeaseSDKType { + lease_id: LeaseIDSDKType; +} +/** MsgCloseLeaseResponse defines the Msg/CloseLease response type. */ +export interface MsgCloseLeaseResponse {} +export interface MsgCloseLeaseResponseProtoMsg { + typeUrl: "/akash.market.v1beta2.MsgCloseLeaseResponse"; + value: Uint8Array; +} +/** MsgCloseLeaseResponse defines the Msg/CloseLease response type. */ +export interface MsgCloseLeaseResponseSDKType {} +function createBaseLeaseID(): LeaseID { + return { + owner: "", + dseq: BigInt(0), + gseq: 0, + oseq: 0, + provider: "" + }; +} +export const LeaseID = { + typeUrl: "/akash.market.v1beta2.LeaseID", + encode(message: LeaseID, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.owner !== undefined) { + writer.uint32(10).string(message.owner); + } + if (message.dseq !== undefined) { + writer.uint32(16).uint64(message.dseq); + } + if (message.gseq !== undefined) { + writer.uint32(24).uint32(message.gseq); + } + if (message.oseq !== undefined) { + writer.uint32(32).uint32(message.oseq); + } + if (message.provider !== undefined) { + writer.uint32(42).string(message.provider); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): LeaseID { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseLeaseID(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.owner = reader.string(); + break; + case 2: + message.dseq = reader.uint64(); + break; + case 3: + message.gseq = reader.uint32(); + break; + case 4: + message.oseq = reader.uint32(); + break; + case 5: + message.provider = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): LeaseID { + const obj = createBaseLeaseID(); + if (isSet(object.owner)) obj.owner = String(object.owner); + if (isSet(object.dseq)) obj.dseq = BigInt(object.dseq.toString()); + if (isSet(object.gseq)) obj.gseq = Number(object.gseq); + if (isSet(object.oseq)) obj.oseq = Number(object.oseq); + if (isSet(object.provider)) obj.provider = String(object.provider); + return obj; + }, + toJSON(message: LeaseID): JsonSafe { + const obj: any = {}; + message.owner !== undefined && (obj.owner = message.owner); + message.dseq !== undefined && (obj.dseq = (message.dseq || BigInt(0)).toString()); + message.gseq !== undefined && (obj.gseq = Math.round(message.gseq)); + message.oseq !== undefined && (obj.oseq = Math.round(message.oseq)); + message.provider !== undefined && (obj.provider = message.provider); + return obj; + }, + fromPartial, I>>(object: I): LeaseID { + const message = createBaseLeaseID(); + message.owner = object.owner ?? ""; + if (object.dseq !== undefined && object.dseq !== null) { + message.dseq = BigInt(object.dseq.toString()); + } + message.gseq = object.gseq ?? 0; + message.oseq = object.oseq ?? 0; + message.provider = object.provider ?? ""; + return message; + }, + fromSDK(object: LeaseIDSDKType): LeaseID { + return { + owner: object?.owner, + dseq: object?.dseq, + gseq: object?.gseq, + oseq: object?.oseq, + provider: object?.provider + }; + }, + fromSDKJSON(object: any): LeaseIDSDKType { + return { + owner: isSet(object.owner) ? String(object.owner) : "", + dseq: isSet(object.dseq) ? BigInt(object.dseq.toString()) : BigInt(0), + gseq: isSet(object.gseq) ? Number(object.gseq) : 0, + oseq: isSet(object.oseq) ? Number(object.oseq) : 0, + provider: isSet(object.provider) ? String(object.provider) : "" + }; + }, + toSDK(message: LeaseID): LeaseIDSDKType { + const obj: any = {}; + obj.owner = message.owner; + obj.dseq = message.dseq; + obj.gseq = message.gseq; + obj.oseq = message.oseq; + obj.provider = message.provider; + return obj; + }, + fromAmino(object: LeaseIDAmino): LeaseID { + const message = createBaseLeaseID(); + if (object.owner !== undefined && object.owner !== null) { + message.owner = object.owner; + } + if (object.dseq !== undefined && object.dseq !== null) { + message.dseq = BigInt(object.dseq); + } + if (object.gseq !== undefined && object.gseq !== null) { + message.gseq = object.gseq; + } + if (object.oseq !== undefined && object.oseq !== null) { + message.oseq = object.oseq; + } + if (object.provider !== undefined && object.provider !== null) { + message.provider = object.provider; + } + return message; + }, + toAmino(message: LeaseID): LeaseIDAmino { + const obj: any = {}; + obj.owner = message.owner ?? ""; + obj.dseq = message.dseq ? message.dseq?.toString() : "0"; + obj.gseq = message.gseq ?? 0; + obj.oseq = message.oseq ?? 0; + obj.provider = message.provider ?? ""; + return obj; + }, + fromAminoMsg(object: LeaseIDAminoMsg): LeaseID { + return LeaseID.fromAmino(object.value); + }, + toAminoMsg(message: LeaseID): LeaseIDAminoMsg { + return { + type: "akash/market/v1beta2/lease-i-d", + value: LeaseID.toAmino(message) + }; + }, + fromProtoMsg(message: LeaseIDProtoMsg): LeaseID { + return LeaseID.decode(message.value); + }, + toProto(message: LeaseID): Uint8Array { + return LeaseID.encode(message).finish(); + }, + toProtoMsg(message: LeaseID): LeaseIDProtoMsg { + return { + typeUrl: "/akash.market.v1beta2.LeaseID", + value: LeaseID.encode(message).finish() + }; + } +}; +function createBaseLease(): Lease { + return { + leaseId: LeaseID.fromPartial({}), + state: 0, + price: DecCoin.fromPartial({}), + createdAt: BigInt(0), + closedOn: BigInt(0) + }; +} +export const Lease = { + typeUrl: "/akash.market.v1beta2.Lease", + encode(message: Lease, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.leaseId !== undefined) { + LeaseID.encode(message.leaseId, writer.uint32(10).fork()).ldelim(); + } + if (message.state !== 0) { + writer.uint32(16).int32(message.state); + } + if (message.price !== undefined) { + DecCoin.encode(message.price, writer.uint32(26).fork()).ldelim(); + } + if (message.createdAt !== undefined) { + writer.uint32(32).int64(message.createdAt); + } + if (message.closedOn !== undefined) { + writer.uint32(40).int64(message.closedOn); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Lease { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseLease(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.leaseId = LeaseID.decode(reader, reader.uint32()); + break; + case 2: + message.state = (reader.int32() as any); + break; + case 3: + message.price = DecCoin.decode(reader, reader.uint32()); + break; + case 4: + message.createdAt = reader.int64(); + break; + case 5: + message.closedOn = reader.int64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Lease { + const obj = createBaseLease(); + if (isSet(object.leaseId)) obj.leaseId = LeaseID.fromJSON(object.leaseId); + if (isSet(object.state)) obj.state = lease_StateFromJSON(object.state); + if (isSet(object.price)) obj.price = DecCoin.fromJSON(object.price); + if (isSet(object.createdAt)) obj.createdAt = BigInt(object.createdAt.toString()); + if (isSet(object.closedOn)) obj.closedOn = BigInt(object.closedOn.toString()); + return obj; + }, + toJSON(message: Lease): JsonSafe { + const obj: any = {}; + message.leaseId !== undefined && (obj.leaseId = message.leaseId ? LeaseID.toJSON(message.leaseId) : undefined); + message.state !== undefined && (obj.state = lease_StateToJSON(message.state)); + message.price !== undefined && (obj.price = message.price ? DecCoin.toJSON(message.price) : undefined); + message.createdAt !== undefined && (obj.createdAt = (message.createdAt || BigInt(0)).toString()); + message.closedOn !== undefined && (obj.closedOn = (message.closedOn || BigInt(0)).toString()); + return obj; + }, + fromPartial, I>>(object: I): Lease { + const message = createBaseLease(); + if (object.leaseId !== undefined && object.leaseId !== null) { + message.leaseId = LeaseID.fromPartial(object.leaseId); + } + message.state = object.state ?? 0; + if (object.price !== undefined && object.price !== null) { + message.price = DecCoin.fromPartial(object.price); + } + if (object.createdAt !== undefined && object.createdAt !== null) { + message.createdAt = BigInt(object.createdAt.toString()); + } + if (object.closedOn !== undefined && object.closedOn !== null) { + message.closedOn = BigInt(object.closedOn.toString()); + } + return message; + }, + fromSDK(object: LeaseSDKType): Lease { + return { + leaseId: object.lease_id ? LeaseID.fromSDK(object.lease_id) : undefined, + state: isSet(object.state) ? lease_StateFromJSON(object.state) : -1, + price: object.price ? DecCoin.fromSDK(object.price) : undefined, + createdAt: object?.created_at, + closedOn: object?.closed_on + }; + }, + fromSDKJSON(object: any): LeaseSDKType { + return { + lease_id: isSet(object.lease_id) ? LeaseID.fromSDKJSON(object.lease_id) : undefined, + state: isSet(object.state) ? lease_StateFromJSON(object.state) : -1, + price: isSet(object.price) ? DecCoin.fromSDKJSON(object.price) : undefined, + created_at: isSet(object.created_at) ? BigInt(object.created_at.toString()) : BigInt(0), + closed_on: isSet(object.closed_on) ? BigInt(object.closed_on.toString()) : BigInt(0) + }; + }, + toSDK(message: Lease): LeaseSDKType { + const obj: any = {}; + message.leaseId !== undefined && (obj.lease_id = message.leaseId ? LeaseID.toSDK(message.leaseId) : undefined); + message.state !== undefined && (obj.state = lease_StateToJSON(message.state)); + message.price !== undefined && (obj.price = message.price ? DecCoin.toSDK(message.price) : undefined); + obj.created_at = message.createdAt; + obj.closed_on = message.closedOn; + return obj; + }, + fromAmino(object: LeaseAmino): Lease { + const message = createBaseLease(); + if (object.lease_id !== undefined && object.lease_id !== null) { + message.leaseId = LeaseID.fromAmino(object.lease_id); + } + if (object.state !== undefined && object.state !== null) { + message.state = object.state; + } + if (object.price !== undefined && object.price !== null) { + message.price = DecCoin.fromAmino(object.price); + } + if (object.created_at !== undefined && object.created_at !== null) { + message.createdAt = BigInt(object.created_at); + } + if (object.closed_on !== undefined && object.closed_on !== null) { + message.closedOn = BigInt(object.closed_on); + } + return message; + }, + toAmino(message: Lease): LeaseAmino { + const obj: any = {}; + obj.lease_id = message.leaseId ? LeaseID.toAmino(message.leaseId) : LeaseID.toAmino(LeaseID.fromPartial({})); + obj.state = message.state ?? 0; + obj.price = message.price ? DecCoin.toAmino(message.price) : DecCoin.toAmino(DecCoin.fromPartial({})); + obj.created_at = message.createdAt !== BigInt(0) ? message.createdAt?.toString() : undefined; + obj.closed_on = message.closedOn !== BigInt(0) ? message.closedOn?.toString() : undefined; + return obj; + }, + fromAminoMsg(object: LeaseAminoMsg): Lease { + return Lease.fromAmino(object.value); + }, + toAminoMsg(message: Lease): LeaseAminoMsg { + return { + type: "akash/market/v1beta2/lease", + value: Lease.toAmino(message) + }; + }, + fromProtoMsg(message: LeaseProtoMsg): Lease { + return Lease.decode(message.value); + }, + toProto(message: Lease): Uint8Array { + return Lease.encode(message).finish(); + }, + toProtoMsg(message: Lease): LeaseProtoMsg { + return { + typeUrl: "/akash.market.v1beta2.Lease", + value: Lease.encode(message).finish() + }; + } +}; +function createBaseLeaseFilters(): LeaseFilters { + return { + owner: "", + dseq: BigInt(0), + gseq: 0, + oseq: 0, + provider: "", + state: "" + }; +} +export const LeaseFilters = { + typeUrl: "/akash.market.v1beta2.LeaseFilters", + encode(message: LeaseFilters, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.owner !== undefined) { + writer.uint32(10).string(message.owner); + } + if (message.dseq !== undefined) { + writer.uint32(16).uint64(message.dseq); + } + if (message.gseq !== undefined) { + writer.uint32(24).uint32(message.gseq); + } + if (message.oseq !== undefined) { + writer.uint32(32).uint32(message.oseq); + } + if (message.provider !== undefined) { + writer.uint32(42).string(message.provider); + } + if (message.state !== undefined) { + writer.uint32(50).string(message.state); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): LeaseFilters { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseLeaseFilters(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.owner = reader.string(); + break; + case 2: + message.dseq = reader.uint64(); + break; + case 3: + message.gseq = reader.uint32(); + break; + case 4: + message.oseq = reader.uint32(); + break; + case 5: + message.provider = reader.string(); + break; + case 6: + message.state = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): LeaseFilters { + const obj = createBaseLeaseFilters(); + if (isSet(object.owner)) obj.owner = String(object.owner); + if (isSet(object.dseq)) obj.dseq = BigInt(object.dseq.toString()); + if (isSet(object.gseq)) obj.gseq = Number(object.gseq); + if (isSet(object.oseq)) obj.oseq = Number(object.oseq); + if (isSet(object.provider)) obj.provider = String(object.provider); + if (isSet(object.state)) obj.state = String(object.state); + return obj; + }, + toJSON(message: LeaseFilters): JsonSafe { + const obj: any = {}; + message.owner !== undefined && (obj.owner = message.owner); + message.dseq !== undefined && (obj.dseq = (message.dseq || BigInt(0)).toString()); + message.gseq !== undefined && (obj.gseq = Math.round(message.gseq)); + message.oseq !== undefined && (obj.oseq = Math.round(message.oseq)); + message.provider !== undefined && (obj.provider = message.provider); + message.state !== undefined && (obj.state = message.state); + return obj; + }, + fromPartial, I>>(object: I): LeaseFilters { + const message = createBaseLeaseFilters(); + message.owner = object.owner ?? ""; + if (object.dseq !== undefined && object.dseq !== null) { + message.dseq = BigInt(object.dseq.toString()); + } + message.gseq = object.gseq ?? 0; + message.oseq = object.oseq ?? 0; + message.provider = object.provider ?? ""; + message.state = object.state ?? ""; + return message; + }, + fromSDK(object: LeaseFiltersSDKType): LeaseFilters { + return { + owner: object?.owner, + dseq: object?.dseq, + gseq: object?.gseq, + oseq: object?.oseq, + provider: object?.provider, + state: object?.state + }; + }, + fromSDKJSON(object: any): LeaseFiltersSDKType { + return { + owner: isSet(object.owner) ? String(object.owner) : "", + dseq: isSet(object.dseq) ? BigInt(object.dseq.toString()) : BigInt(0), + gseq: isSet(object.gseq) ? Number(object.gseq) : 0, + oseq: isSet(object.oseq) ? Number(object.oseq) : 0, + provider: isSet(object.provider) ? String(object.provider) : "", + state: isSet(object.state) ? String(object.state) : "" + }; + }, + toSDK(message: LeaseFilters): LeaseFiltersSDKType { + const obj: any = {}; + obj.owner = message.owner; + obj.dseq = message.dseq; + obj.gseq = message.gseq; + obj.oseq = message.oseq; + obj.provider = message.provider; + obj.state = message.state; + return obj; + }, + fromAmino(object: LeaseFiltersAmino): LeaseFilters { + const message = createBaseLeaseFilters(); + if (object.owner !== undefined && object.owner !== null) { + message.owner = object.owner; + } + if (object.dseq !== undefined && object.dseq !== null) { + message.dseq = BigInt(object.dseq); + } + if (object.gseq !== undefined && object.gseq !== null) { + message.gseq = object.gseq; + } + if (object.oseq !== undefined && object.oseq !== null) { + message.oseq = object.oseq; + } + if (object.provider !== undefined && object.provider !== null) { + message.provider = object.provider; + } + if (object.state !== undefined && object.state !== null) { + message.state = object.state; + } + return message; + }, + toAmino(message: LeaseFilters): LeaseFiltersAmino { + const obj: any = {}; + obj.owner = message.owner ?? ""; + obj.dseq = message.dseq ? message.dseq?.toString() : "0"; + obj.gseq = message.gseq ?? 0; + obj.oseq = message.oseq ?? 0; + obj.provider = message.provider ?? ""; + obj.state = message.state ?? ""; + return obj; + }, + fromAminoMsg(object: LeaseFiltersAminoMsg): LeaseFilters { + return LeaseFilters.fromAmino(object.value); + }, + toAminoMsg(message: LeaseFilters): LeaseFiltersAminoMsg { + return { + type: "akash/market/v1beta2/lease-filters", + value: LeaseFilters.toAmino(message) + }; + }, + fromProtoMsg(message: LeaseFiltersProtoMsg): LeaseFilters { + return LeaseFilters.decode(message.value); + }, + toProto(message: LeaseFilters): Uint8Array { + return LeaseFilters.encode(message).finish(); + }, + toProtoMsg(message: LeaseFilters): LeaseFiltersProtoMsg { + return { + typeUrl: "/akash.market.v1beta2.LeaseFilters", + value: LeaseFilters.encode(message).finish() + }; + } +}; +function createBaseMsgCreateLease(): MsgCreateLease { + return { + bidId: BidID.fromPartial({}) + }; +} +export const MsgCreateLease = { + typeUrl: "/akash.market.v1beta2.MsgCreateLease", + encode(message: MsgCreateLease, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.bidId !== undefined) { + BidID.encode(message.bidId, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgCreateLease { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgCreateLease(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.bidId = BidID.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgCreateLease { + const obj = createBaseMsgCreateLease(); + if (isSet(object.bidId)) obj.bidId = BidID.fromJSON(object.bidId); + return obj; + }, + toJSON(message: MsgCreateLease): JsonSafe { + const obj: any = {}; + message.bidId !== undefined && (obj.bidId = message.bidId ? BidID.toJSON(message.bidId) : undefined); + return obj; + }, + fromPartial, I>>(object: I): MsgCreateLease { + const message = createBaseMsgCreateLease(); + if (object.bidId !== undefined && object.bidId !== null) { + message.bidId = BidID.fromPartial(object.bidId); + } + return message; + }, + fromSDK(object: MsgCreateLeaseSDKType): MsgCreateLease { + return { + bidId: object.bid_id ? BidID.fromSDK(object.bid_id) : undefined + }; + }, + fromSDKJSON(object: any): MsgCreateLeaseSDKType { + return { + bid_id: isSet(object.bid_id) ? BidID.fromSDKJSON(object.bid_id) : undefined + }; + }, + toSDK(message: MsgCreateLease): MsgCreateLeaseSDKType { + const obj: any = {}; + message.bidId !== undefined && (obj.bid_id = message.bidId ? BidID.toSDK(message.bidId) : undefined); + return obj; + }, + fromAmino(object: MsgCreateLeaseAmino): MsgCreateLease { + const message = createBaseMsgCreateLease(); + if (object.bid_id !== undefined && object.bid_id !== null) { + message.bidId = BidID.fromAmino(object.bid_id); + } + return message; + }, + toAmino(message: MsgCreateLease): MsgCreateLeaseAmino { + const obj: any = {}; + obj.bid_id = message.bidId ? BidID.toAmino(message.bidId) : BidID.toAmino(BidID.fromPartial({})); + return obj; + }, + fromAminoMsg(object: MsgCreateLeaseAminoMsg): MsgCreateLease { + return MsgCreateLease.fromAmino(object.value); + }, + toAminoMsg(message: MsgCreateLease): MsgCreateLeaseAminoMsg { + return { + type: "akash/market/v1beta2/testonly-create-lease", + value: MsgCreateLease.toAmino(message) + }; + }, + fromProtoMsg(message: MsgCreateLeaseProtoMsg): MsgCreateLease { + return MsgCreateLease.decode(message.value); + }, + toProto(message: MsgCreateLease): Uint8Array { + return MsgCreateLease.encode(message).finish(); + }, + toProtoMsg(message: MsgCreateLease): MsgCreateLeaseProtoMsg { + return { + typeUrl: "/akash.market.v1beta2.MsgCreateLease", + value: MsgCreateLease.encode(message).finish() + }; + } +}; +function createBaseMsgCreateLeaseResponse(): MsgCreateLeaseResponse { + return {}; +} +export const MsgCreateLeaseResponse = { + typeUrl: "/akash.market.v1beta2.MsgCreateLeaseResponse", + encode(_: MsgCreateLeaseResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgCreateLeaseResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgCreateLeaseResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgCreateLeaseResponse { + const obj = createBaseMsgCreateLeaseResponse(); + return obj; + }, + toJSON(_: MsgCreateLeaseResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): MsgCreateLeaseResponse { + const message = createBaseMsgCreateLeaseResponse(); + return message; + }, + fromSDK(_: MsgCreateLeaseResponseSDKType): MsgCreateLeaseResponse { + return {}; + }, + fromSDKJSON(_: any): MsgCreateLeaseResponseSDKType { + return {}; + }, + toSDK(_: MsgCreateLeaseResponse): MsgCreateLeaseResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgCreateLeaseResponseAmino): MsgCreateLeaseResponse { + const message = createBaseMsgCreateLeaseResponse(); + return message; + }, + toAmino(_: MsgCreateLeaseResponse): MsgCreateLeaseResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgCreateLeaseResponseAminoMsg): MsgCreateLeaseResponse { + return MsgCreateLeaseResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgCreateLeaseResponse): MsgCreateLeaseResponseAminoMsg { + return { + type: "akash/market/v1beta2/testonly-create-lease-response", + value: MsgCreateLeaseResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgCreateLeaseResponseProtoMsg): MsgCreateLeaseResponse { + return MsgCreateLeaseResponse.decode(message.value); + }, + toProto(message: MsgCreateLeaseResponse): Uint8Array { + return MsgCreateLeaseResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgCreateLeaseResponse): MsgCreateLeaseResponseProtoMsg { + return { + typeUrl: "/akash.market.v1beta2.MsgCreateLeaseResponse", + value: MsgCreateLeaseResponse.encode(message).finish() + }; + } +}; +function createBaseMsgWithdrawLease(): MsgWithdrawLease { + return { + bidId: LeaseID.fromPartial({}) + }; +} +export const MsgWithdrawLease = { + typeUrl: "/akash.market.v1beta2.MsgWithdrawLease", + encode(message: MsgWithdrawLease, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.bidId !== undefined) { + LeaseID.encode(message.bidId, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgWithdrawLease { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgWithdrawLease(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.bidId = LeaseID.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgWithdrawLease { + const obj = createBaseMsgWithdrawLease(); + if (isSet(object.bidId)) obj.bidId = LeaseID.fromJSON(object.bidId); + return obj; + }, + toJSON(message: MsgWithdrawLease): JsonSafe { + const obj: any = {}; + message.bidId !== undefined && (obj.bidId = message.bidId ? LeaseID.toJSON(message.bidId) : undefined); + return obj; + }, + fromPartial, I>>(object: I): MsgWithdrawLease { + const message = createBaseMsgWithdrawLease(); + if (object.bidId !== undefined && object.bidId !== null) { + message.bidId = LeaseID.fromPartial(object.bidId); + } + return message; + }, + fromSDK(object: MsgWithdrawLeaseSDKType): MsgWithdrawLease { + return { + bidId: object.bid_id ? LeaseID.fromSDK(object.bid_id) : undefined + }; + }, + fromSDKJSON(object: any): MsgWithdrawLeaseSDKType { + return { + bid_id: isSet(object.bid_id) ? LeaseID.fromSDKJSON(object.bid_id) : undefined + }; + }, + toSDK(message: MsgWithdrawLease): MsgWithdrawLeaseSDKType { + const obj: any = {}; + message.bidId !== undefined && (obj.bid_id = message.bidId ? LeaseID.toSDK(message.bidId) : undefined); + return obj; + }, + fromAmino(object: MsgWithdrawLeaseAmino): MsgWithdrawLease { + const message = createBaseMsgWithdrawLease(); + if (object.bid_id !== undefined && object.bid_id !== null) { + message.bidId = LeaseID.fromAmino(object.bid_id); + } + return message; + }, + toAmino(message: MsgWithdrawLease): MsgWithdrawLeaseAmino { + const obj: any = {}; + obj.bid_id = message.bidId ? LeaseID.toAmino(message.bidId) : LeaseID.toAmino(LeaseID.fromPartial({})); + return obj; + }, + fromAminoMsg(object: MsgWithdrawLeaseAminoMsg): MsgWithdrawLease { + return MsgWithdrawLease.fromAmino(object.value); + }, + toAminoMsg(message: MsgWithdrawLease): MsgWithdrawLeaseAminoMsg { + return { + type: "akash/market/v1beta2/testonly-withdraw-lease", + value: MsgWithdrawLease.toAmino(message) + }; + }, + fromProtoMsg(message: MsgWithdrawLeaseProtoMsg): MsgWithdrawLease { + return MsgWithdrawLease.decode(message.value); + }, + toProto(message: MsgWithdrawLease): Uint8Array { + return MsgWithdrawLease.encode(message).finish(); + }, + toProtoMsg(message: MsgWithdrawLease): MsgWithdrawLeaseProtoMsg { + return { + typeUrl: "/akash.market.v1beta2.MsgWithdrawLease", + value: MsgWithdrawLease.encode(message).finish() + }; + } +}; +function createBaseMsgWithdrawLeaseResponse(): MsgWithdrawLeaseResponse { + return {}; +} +export const MsgWithdrawLeaseResponse = { + typeUrl: "/akash.market.v1beta2.MsgWithdrawLeaseResponse", + encode(_: MsgWithdrawLeaseResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgWithdrawLeaseResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgWithdrawLeaseResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgWithdrawLeaseResponse { + const obj = createBaseMsgWithdrawLeaseResponse(); + return obj; + }, + toJSON(_: MsgWithdrawLeaseResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): MsgWithdrawLeaseResponse { + const message = createBaseMsgWithdrawLeaseResponse(); + return message; + }, + fromSDK(_: MsgWithdrawLeaseResponseSDKType): MsgWithdrawLeaseResponse { + return {}; + }, + fromSDKJSON(_: any): MsgWithdrawLeaseResponseSDKType { + return {}; + }, + toSDK(_: MsgWithdrawLeaseResponse): MsgWithdrawLeaseResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgWithdrawLeaseResponseAmino): MsgWithdrawLeaseResponse { + const message = createBaseMsgWithdrawLeaseResponse(); + return message; + }, + toAmino(_: MsgWithdrawLeaseResponse): MsgWithdrawLeaseResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgWithdrawLeaseResponseAminoMsg): MsgWithdrawLeaseResponse { + return MsgWithdrawLeaseResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgWithdrawLeaseResponse): MsgWithdrawLeaseResponseAminoMsg { + return { + type: "akash/market/v1beta2/testonly-withdraw-lease-response", + value: MsgWithdrawLeaseResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgWithdrawLeaseResponseProtoMsg): MsgWithdrawLeaseResponse { + return MsgWithdrawLeaseResponse.decode(message.value); + }, + toProto(message: MsgWithdrawLeaseResponse): Uint8Array { + return MsgWithdrawLeaseResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgWithdrawLeaseResponse): MsgWithdrawLeaseResponseProtoMsg { + return { + typeUrl: "/akash.market.v1beta2.MsgWithdrawLeaseResponse", + value: MsgWithdrawLeaseResponse.encode(message).finish() + }; + } +}; +function createBaseMsgCloseLease(): MsgCloseLease { + return { + leaseId: LeaseID.fromPartial({}) + }; +} +export const MsgCloseLease = { + typeUrl: "/akash.market.v1beta2.MsgCloseLease", + encode(message: MsgCloseLease, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.leaseId !== undefined) { + LeaseID.encode(message.leaseId, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgCloseLease { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgCloseLease(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.leaseId = LeaseID.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgCloseLease { + const obj = createBaseMsgCloseLease(); + if (isSet(object.leaseId)) obj.leaseId = LeaseID.fromJSON(object.leaseId); + return obj; + }, + toJSON(message: MsgCloseLease): JsonSafe { + const obj: any = {}; + message.leaseId !== undefined && (obj.leaseId = message.leaseId ? LeaseID.toJSON(message.leaseId) : undefined); + return obj; + }, + fromPartial, I>>(object: I): MsgCloseLease { + const message = createBaseMsgCloseLease(); + if (object.leaseId !== undefined && object.leaseId !== null) { + message.leaseId = LeaseID.fromPartial(object.leaseId); + } + return message; + }, + fromSDK(object: MsgCloseLeaseSDKType): MsgCloseLease { + return { + leaseId: object.lease_id ? LeaseID.fromSDK(object.lease_id) : undefined + }; + }, + fromSDKJSON(object: any): MsgCloseLeaseSDKType { + return { + lease_id: isSet(object.lease_id) ? LeaseID.fromSDKJSON(object.lease_id) : undefined + }; + }, + toSDK(message: MsgCloseLease): MsgCloseLeaseSDKType { + const obj: any = {}; + message.leaseId !== undefined && (obj.lease_id = message.leaseId ? LeaseID.toSDK(message.leaseId) : undefined); + return obj; + }, + fromAmino(object: MsgCloseLeaseAmino): MsgCloseLease { + const message = createBaseMsgCloseLease(); + if (object.lease_id !== undefined && object.lease_id !== null) { + message.leaseId = LeaseID.fromAmino(object.lease_id); + } + return message; + }, + toAmino(message: MsgCloseLease): MsgCloseLeaseAmino { + const obj: any = {}; + obj.lease_id = message.leaseId ? LeaseID.toAmino(message.leaseId) : LeaseID.toAmino(LeaseID.fromPartial({})); + return obj; + }, + fromAminoMsg(object: MsgCloseLeaseAminoMsg): MsgCloseLease { + return MsgCloseLease.fromAmino(object.value); + }, + toAminoMsg(message: MsgCloseLease): MsgCloseLeaseAminoMsg { + return { + type: "akash/market/v1beta2/testonly-close-lease", + value: MsgCloseLease.toAmino(message) + }; + }, + fromProtoMsg(message: MsgCloseLeaseProtoMsg): MsgCloseLease { + return MsgCloseLease.decode(message.value); + }, + toProto(message: MsgCloseLease): Uint8Array { + return MsgCloseLease.encode(message).finish(); + }, + toProtoMsg(message: MsgCloseLease): MsgCloseLeaseProtoMsg { + return { + typeUrl: "/akash.market.v1beta2.MsgCloseLease", + value: MsgCloseLease.encode(message).finish() + }; + } +}; +function createBaseMsgCloseLeaseResponse(): MsgCloseLeaseResponse { + return {}; +} +export const MsgCloseLeaseResponse = { + typeUrl: "/akash.market.v1beta2.MsgCloseLeaseResponse", + encode(_: MsgCloseLeaseResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgCloseLeaseResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgCloseLeaseResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgCloseLeaseResponse { + const obj = createBaseMsgCloseLeaseResponse(); + return obj; + }, + toJSON(_: MsgCloseLeaseResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): MsgCloseLeaseResponse { + const message = createBaseMsgCloseLeaseResponse(); + return message; + }, + fromSDK(_: MsgCloseLeaseResponseSDKType): MsgCloseLeaseResponse { + return {}; + }, + fromSDKJSON(_: any): MsgCloseLeaseResponseSDKType { + return {}; + }, + toSDK(_: MsgCloseLeaseResponse): MsgCloseLeaseResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgCloseLeaseResponseAmino): MsgCloseLeaseResponse { + const message = createBaseMsgCloseLeaseResponse(); + return message; + }, + toAmino(_: MsgCloseLeaseResponse): MsgCloseLeaseResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgCloseLeaseResponseAminoMsg): MsgCloseLeaseResponse { + return MsgCloseLeaseResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgCloseLeaseResponse): MsgCloseLeaseResponseAminoMsg { + return { + type: "akash/market/v1beta2/testonly-close-lease-response", + value: MsgCloseLeaseResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgCloseLeaseResponseProtoMsg): MsgCloseLeaseResponse { + return MsgCloseLeaseResponse.decode(message.value); + }, + toProto(message: MsgCloseLeaseResponse): Uint8Array { + return MsgCloseLeaseResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgCloseLeaseResponse): MsgCloseLeaseResponseProtoMsg { + return { + typeUrl: "/akash.market.v1beta2.MsgCloseLeaseResponse", + value: MsgCloseLeaseResponse.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/market/v1beta2/order.ts b/__fixtures__/v-next/outputicjsdeps/akash/market/v1beta2/order.ts new file mode 100644 index 0000000000..e363e20ccf --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/market/v1beta2/order.ts @@ -0,0 +1,571 @@ +import { GroupSpec, GroupSpecSDKType } from "../../deployment/v1beta2/groupspec.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial, Exact } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "akash.market.v1beta2"; +/** State is an enum which refers to state of order */ +export enum Order_State { + /** invalid - Prefix should start with 0 in enum. So declaring dummy state */ + invalid = 0, + /** open - OrderOpen denotes state for order open */ + open = 1, + /** active - OrderMatched denotes state for order matched */ + active = 2, + /** closed - OrderClosed denotes state for order lost */ + closed = 3, + UNRECOGNIZED = -1, +} +export const Order_StateSDKType = Order_State; +export function order_StateFromJSON(object: any): Order_State { + switch (object) { + case 0: + case "invalid": + return Order_State.invalid; + case 1: + case "open": + return Order_State.open; + case 2: + case "active": + return Order_State.active; + case 3: + case "closed": + return Order_State.closed; + case -1: + case "UNRECOGNIZED": + default: + return Order_State.UNRECOGNIZED; + } +} +export function order_StateToJSON(object: Order_State): string { + switch (object) { + case Order_State.invalid: + return "invalid"; + case Order_State.open: + return "open"; + case Order_State.active: + return "active"; + case Order_State.closed: + return "closed"; + case Order_State.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** OrderID stores owner and all other seq numbers */ +export interface OrderID { + owner: string; + dseq: bigint; + gseq: number; + oseq: number; +} +export interface OrderIDProtoMsg { + typeUrl: "/akash.market.v1beta2.OrderID"; + value: Uint8Array; +} +/** OrderID stores owner and all other seq numbers */ +export interface OrderIDSDKType { + owner: string; + dseq: bigint; + gseq: number; + oseq: number; +} +/** Order stores orderID, state of order and other details */ +export interface Order { + orderId: OrderID; + state: Order_State; + spec: GroupSpec; + createdAt: bigint; +} +export interface OrderProtoMsg { + typeUrl: "/akash.market.v1beta2.Order"; + value: Uint8Array; +} +/** Order stores orderID, state of order and other details */ +export interface OrderSDKType { + order_id: OrderIDSDKType; + state: Order_State; + spec: GroupSpecSDKType; + created_at: bigint; +} +/** OrderFilters defines flags for order list filter */ +export interface OrderFilters { + owner: string; + dseq: bigint; + gseq: number; + oseq: number; + state: string; +} +export interface OrderFiltersProtoMsg { + typeUrl: "/akash.market.v1beta2.OrderFilters"; + value: Uint8Array; +} +/** OrderFilters defines flags for order list filter */ +export interface OrderFiltersSDKType { + owner: string; + dseq: bigint; + gseq: number; + oseq: number; + state: string; +} +function createBaseOrderID(): OrderID { + return { + owner: "", + dseq: BigInt(0), + gseq: 0, + oseq: 0 + }; +} +export const OrderID = { + typeUrl: "/akash.market.v1beta2.OrderID", + encode(message: OrderID, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.owner !== undefined) { + writer.uint32(10).string(message.owner); + } + if (message.dseq !== undefined) { + writer.uint32(16).uint64(message.dseq); + } + if (message.gseq !== undefined) { + writer.uint32(24).uint32(message.gseq); + } + if (message.oseq !== undefined) { + writer.uint32(32).uint32(message.oseq); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): OrderID { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseOrderID(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.owner = reader.string(); + break; + case 2: + message.dseq = reader.uint64(); + break; + case 3: + message.gseq = reader.uint32(); + break; + case 4: + message.oseq = reader.uint32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): OrderID { + const obj = createBaseOrderID(); + if (isSet(object.owner)) obj.owner = String(object.owner); + if (isSet(object.dseq)) obj.dseq = BigInt(object.dseq.toString()); + if (isSet(object.gseq)) obj.gseq = Number(object.gseq); + if (isSet(object.oseq)) obj.oseq = Number(object.oseq); + return obj; + }, + toJSON(message: OrderID): JsonSafe { + const obj: any = {}; + message.owner !== undefined && (obj.owner = message.owner); + message.dseq !== undefined && (obj.dseq = (message.dseq || BigInt(0)).toString()); + message.gseq !== undefined && (obj.gseq = Math.round(message.gseq)); + message.oseq !== undefined && (obj.oseq = Math.round(message.oseq)); + return obj; + }, + fromPartial, I>>(object: I): OrderID { + const message = createBaseOrderID(); + message.owner = object.owner ?? ""; + if (object.dseq !== undefined && object.dseq !== null) { + message.dseq = BigInt(object.dseq.toString()); + } + message.gseq = object.gseq ?? 0; + message.oseq = object.oseq ?? 0; + return message; + }, + fromSDK(object: OrderIDSDKType): OrderID { + return { + owner: object?.owner, + dseq: object?.dseq, + gseq: object?.gseq, + oseq: object?.oseq + }; + }, + fromSDKJSON(object: any): OrderIDSDKType { + return { + owner: isSet(object.owner) ? String(object.owner) : "", + dseq: isSet(object.dseq) ? BigInt(object.dseq.toString()) : BigInt(0), + gseq: isSet(object.gseq) ? Number(object.gseq) : 0, + oseq: isSet(object.oseq) ? Number(object.oseq) : 0 + }; + }, + toSDK(message: OrderID): OrderIDSDKType { + const obj: any = {}; + obj.owner = message.owner; + obj.dseq = message.dseq; + obj.gseq = message.gseq; + obj.oseq = message.oseq; + return obj; + }, + fromAmino(object: OrderIDAmino): OrderID { + const message = createBaseOrderID(); + if (object.owner !== undefined && object.owner !== null) { + message.owner = object.owner; + } + if (object.dseq !== undefined && object.dseq !== null) { + message.dseq = BigInt(object.dseq); + } + if (object.gseq !== undefined && object.gseq !== null) { + message.gseq = object.gseq; + } + if (object.oseq !== undefined && object.oseq !== null) { + message.oseq = object.oseq; + } + return message; + }, + toAmino(message: OrderID): OrderIDAmino { + const obj: any = {}; + obj.owner = message.owner ?? ""; + obj.dseq = message.dseq ? message.dseq?.toString() : "0"; + obj.gseq = message.gseq ?? 0; + obj.oseq = message.oseq ?? 0; + return obj; + }, + fromAminoMsg(object: OrderIDAminoMsg): OrderID { + return OrderID.fromAmino(object.value); + }, + toAminoMsg(message: OrderID): OrderIDAminoMsg { + return { + type: "akash/market/v1beta2/order-i-d", + value: OrderID.toAmino(message) + }; + }, + fromProtoMsg(message: OrderIDProtoMsg): OrderID { + return OrderID.decode(message.value); + }, + toProto(message: OrderID): Uint8Array { + return OrderID.encode(message).finish(); + }, + toProtoMsg(message: OrderID): OrderIDProtoMsg { + return { + typeUrl: "/akash.market.v1beta2.OrderID", + value: OrderID.encode(message).finish() + }; + } +}; +function createBaseOrder(): Order { + return { + orderId: OrderID.fromPartial({}), + state: 0, + spec: GroupSpec.fromPartial({}), + createdAt: BigInt(0) + }; +} +export const Order = { + typeUrl: "/akash.market.v1beta2.Order", + encode(message: Order, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.orderId !== undefined) { + OrderID.encode(message.orderId, writer.uint32(10).fork()).ldelim(); + } + if (message.state !== 0) { + writer.uint32(16).int32(message.state); + } + if (message.spec !== undefined) { + GroupSpec.encode(message.spec, writer.uint32(26).fork()).ldelim(); + } + if (message.createdAt !== undefined) { + writer.uint32(32).int64(message.createdAt); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Order { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseOrder(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.orderId = OrderID.decode(reader, reader.uint32()); + break; + case 2: + message.state = (reader.int32() as any); + break; + case 3: + message.spec = GroupSpec.decode(reader, reader.uint32()); + break; + case 4: + message.createdAt = reader.int64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Order { + const obj = createBaseOrder(); + if (isSet(object.orderId)) obj.orderId = OrderID.fromJSON(object.orderId); + if (isSet(object.state)) obj.state = order_StateFromJSON(object.state); + if (isSet(object.spec)) obj.spec = GroupSpec.fromJSON(object.spec); + if (isSet(object.createdAt)) obj.createdAt = BigInt(object.createdAt.toString()); + return obj; + }, + toJSON(message: Order): JsonSafe { + const obj: any = {}; + message.orderId !== undefined && (obj.orderId = message.orderId ? OrderID.toJSON(message.orderId) : undefined); + message.state !== undefined && (obj.state = order_StateToJSON(message.state)); + message.spec !== undefined && (obj.spec = message.spec ? GroupSpec.toJSON(message.spec) : undefined); + message.createdAt !== undefined && (obj.createdAt = (message.createdAt || BigInt(0)).toString()); + return obj; + }, + fromPartial, I>>(object: I): Order { + const message = createBaseOrder(); + if (object.orderId !== undefined && object.orderId !== null) { + message.orderId = OrderID.fromPartial(object.orderId); + } + message.state = object.state ?? 0; + if (object.spec !== undefined && object.spec !== null) { + message.spec = GroupSpec.fromPartial(object.spec); + } + if (object.createdAt !== undefined && object.createdAt !== null) { + message.createdAt = BigInt(object.createdAt.toString()); + } + return message; + }, + fromSDK(object: OrderSDKType): Order { + return { + orderId: object.order_id ? OrderID.fromSDK(object.order_id) : undefined, + state: isSet(object.state) ? order_StateFromJSON(object.state) : -1, + spec: object.spec ? GroupSpec.fromSDK(object.spec) : undefined, + createdAt: object?.created_at + }; + }, + fromSDKJSON(object: any): OrderSDKType { + return { + order_id: isSet(object.order_id) ? OrderID.fromSDKJSON(object.order_id) : undefined, + state: isSet(object.state) ? order_StateFromJSON(object.state) : -1, + spec: isSet(object.spec) ? GroupSpec.fromSDKJSON(object.spec) : undefined, + created_at: isSet(object.created_at) ? BigInt(object.created_at.toString()) : BigInt(0) + }; + }, + toSDK(message: Order): OrderSDKType { + const obj: any = {}; + message.orderId !== undefined && (obj.order_id = message.orderId ? OrderID.toSDK(message.orderId) : undefined); + message.state !== undefined && (obj.state = order_StateToJSON(message.state)); + message.spec !== undefined && (obj.spec = message.spec ? GroupSpec.toSDK(message.spec) : undefined); + obj.created_at = message.createdAt; + return obj; + }, + fromAmino(object: OrderAmino): Order { + const message = createBaseOrder(); + if (object.order_id !== undefined && object.order_id !== null) { + message.orderId = OrderID.fromAmino(object.order_id); + } + if (object.state !== undefined && object.state !== null) { + message.state = object.state; + } + if (object.spec !== undefined && object.spec !== null) { + message.spec = GroupSpec.fromAmino(object.spec); + } + if (object.created_at !== undefined && object.created_at !== null) { + message.createdAt = BigInt(object.created_at); + } + return message; + }, + toAmino(message: Order): OrderAmino { + const obj: any = {}; + obj.order_id = message.orderId ? OrderID.toAmino(message.orderId) : OrderID.toAmino(OrderID.fromPartial({})); + obj.state = message.state ?? 0; + obj.spec = message.spec ? GroupSpec.toAmino(message.spec) : GroupSpec.toAmino(GroupSpec.fromPartial({})); + obj.created_at = message.createdAt !== BigInt(0) ? message.createdAt?.toString() : undefined; + return obj; + }, + fromAminoMsg(object: OrderAminoMsg): Order { + return Order.fromAmino(object.value); + }, + toAminoMsg(message: Order): OrderAminoMsg { + return { + type: "akash/market/v1beta2/order", + value: Order.toAmino(message) + }; + }, + fromProtoMsg(message: OrderProtoMsg): Order { + return Order.decode(message.value); + }, + toProto(message: Order): Uint8Array { + return Order.encode(message).finish(); + }, + toProtoMsg(message: Order): OrderProtoMsg { + return { + typeUrl: "/akash.market.v1beta2.Order", + value: Order.encode(message).finish() + }; + } +}; +function createBaseOrderFilters(): OrderFilters { + return { + owner: "", + dseq: BigInt(0), + gseq: 0, + oseq: 0, + state: "" + }; +} +export const OrderFilters = { + typeUrl: "/akash.market.v1beta2.OrderFilters", + encode(message: OrderFilters, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.owner !== undefined) { + writer.uint32(10).string(message.owner); + } + if (message.dseq !== undefined) { + writer.uint32(16).uint64(message.dseq); + } + if (message.gseq !== undefined) { + writer.uint32(24).uint32(message.gseq); + } + if (message.oseq !== undefined) { + writer.uint32(32).uint32(message.oseq); + } + if (message.state !== undefined) { + writer.uint32(42).string(message.state); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): OrderFilters { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseOrderFilters(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.owner = reader.string(); + break; + case 2: + message.dseq = reader.uint64(); + break; + case 3: + message.gseq = reader.uint32(); + break; + case 4: + message.oseq = reader.uint32(); + break; + case 5: + message.state = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): OrderFilters { + const obj = createBaseOrderFilters(); + if (isSet(object.owner)) obj.owner = String(object.owner); + if (isSet(object.dseq)) obj.dseq = BigInt(object.dseq.toString()); + if (isSet(object.gseq)) obj.gseq = Number(object.gseq); + if (isSet(object.oseq)) obj.oseq = Number(object.oseq); + if (isSet(object.state)) obj.state = String(object.state); + return obj; + }, + toJSON(message: OrderFilters): JsonSafe { + const obj: any = {}; + message.owner !== undefined && (obj.owner = message.owner); + message.dseq !== undefined && (obj.dseq = (message.dseq || BigInt(0)).toString()); + message.gseq !== undefined && (obj.gseq = Math.round(message.gseq)); + message.oseq !== undefined && (obj.oseq = Math.round(message.oseq)); + message.state !== undefined && (obj.state = message.state); + return obj; + }, + fromPartial, I>>(object: I): OrderFilters { + const message = createBaseOrderFilters(); + message.owner = object.owner ?? ""; + if (object.dseq !== undefined && object.dseq !== null) { + message.dseq = BigInt(object.dseq.toString()); + } + message.gseq = object.gseq ?? 0; + message.oseq = object.oseq ?? 0; + message.state = object.state ?? ""; + return message; + }, + fromSDK(object: OrderFiltersSDKType): OrderFilters { + return { + owner: object?.owner, + dseq: object?.dseq, + gseq: object?.gseq, + oseq: object?.oseq, + state: object?.state + }; + }, + fromSDKJSON(object: any): OrderFiltersSDKType { + return { + owner: isSet(object.owner) ? String(object.owner) : "", + dseq: isSet(object.dseq) ? BigInt(object.dseq.toString()) : BigInt(0), + gseq: isSet(object.gseq) ? Number(object.gseq) : 0, + oseq: isSet(object.oseq) ? Number(object.oseq) : 0, + state: isSet(object.state) ? String(object.state) : "" + }; + }, + toSDK(message: OrderFilters): OrderFiltersSDKType { + const obj: any = {}; + obj.owner = message.owner; + obj.dseq = message.dseq; + obj.gseq = message.gseq; + obj.oseq = message.oseq; + obj.state = message.state; + return obj; + }, + fromAmino(object: OrderFiltersAmino): OrderFilters { + const message = createBaseOrderFilters(); + if (object.owner !== undefined && object.owner !== null) { + message.owner = object.owner; + } + if (object.dseq !== undefined && object.dseq !== null) { + message.dseq = BigInt(object.dseq); + } + if (object.gseq !== undefined && object.gseq !== null) { + message.gseq = object.gseq; + } + if (object.oseq !== undefined && object.oseq !== null) { + message.oseq = object.oseq; + } + if (object.state !== undefined && object.state !== null) { + message.state = object.state; + } + return message; + }, + toAmino(message: OrderFilters): OrderFiltersAmino { + const obj: any = {}; + obj.owner = message.owner ?? ""; + obj.dseq = message.dseq ? message.dseq?.toString() : "0"; + obj.gseq = message.gseq ?? 0; + obj.oseq = message.oseq ?? 0; + obj.state = message.state ?? ""; + return obj; + }, + fromAminoMsg(object: OrderFiltersAminoMsg): OrderFilters { + return OrderFilters.fromAmino(object.value); + }, + toAminoMsg(message: OrderFilters): OrderFiltersAminoMsg { + return { + type: "akash/market/v1beta2/order-filters", + value: OrderFilters.toAmino(message) + }; + }, + fromProtoMsg(message: OrderFiltersProtoMsg): OrderFilters { + return OrderFilters.decode(message.value); + }, + toProto(message: OrderFilters): Uint8Array { + return OrderFilters.encode(message).finish(); + }, + toProtoMsg(message: OrderFilters): OrderFiltersProtoMsg { + return { + typeUrl: "/akash.market.v1beta2.OrderFilters", + value: OrderFilters.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/market/v1beta2/params.ts b/__fixtures__/v-next/outputicjsdeps/akash/market/v1beta2/params.ts new file mode 100644 index 0000000000..5c7b12159d --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/market/v1beta2/params.ts @@ -0,0 +1,132 @@ +import { Coin, CoinSDKType } from "../../../cosmos/base/v1beta1/coin.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial, Exact } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "akash.market.v1beta2"; +/** Params is the params for the x/market module */ +export interface Params { + bidMinDeposit: Coin; + orderMaxBids: number; +} +export interface ParamsProtoMsg { + typeUrl: "/akash.market.v1beta2.Params"; + value: Uint8Array; +} +/** Params is the params for the x/market module */ +export interface ParamsSDKType { + bid_min_deposit: CoinSDKType; + order_max_bids: number; +} +function createBaseParams(): Params { + return { + bidMinDeposit: Coin.fromPartial({}), + orderMaxBids: 0 + }; +} +export const Params = { + typeUrl: "/akash.market.v1beta2.Params", + encode(message: Params, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.bidMinDeposit !== undefined) { + Coin.encode(message.bidMinDeposit, writer.uint32(10).fork()).ldelim(); + } + if (message.orderMaxBids !== undefined) { + writer.uint32(16).uint32(message.orderMaxBids); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Params { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseParams(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.bidMinDeposit = Coin.decode(reader, reader.uint32()); + break; + case 2: + message.orderMaxBids = reader.uint32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Params { + const obj = createBaseParams(); + if (isSet(object.bidMinDeposit)) obj.bidMinDeposit = Coin.fromJSON(object.bidMinDeposit); + if (isSet(object.orderMaxBids)) obj.orderMaxBids = Number(object.orderMaxBids); + return obj; + }, + toJSON(message: Params): JsonSafe { + const obj: any = {}; + message.bidMinDeposit !== undefined && (obj.bidMinDeposit = message.bidMinDeposit ? Coin.toJSON(message.bidMinDeposit) : undefined); + message.orderMaxBids !== undefined && (obj.orderMaxBids = Math.round(message.orderMaxBids)); + return obj; + }, + fromPartial, I>>(object: I): Params { + const message = createBaseParams(); + if (object.bidMinDeposit !== undefined && object.bidMinDeposit !== null) { + message.bidMinDeposit = Coin.fromPartial(object.bidMinDeposit); + } + message.orderMaxBids = object.orderMaxBids ?? 0; + return message; + }, + fromSDK(object: ParamsSDKType): Params { + return { + bidMinDeposit: object.bid_min_deposit ? Coin.fromSDK(object.bid_min_deposit) : undefined, + orderMaxBids: object?.order_max_bids + }; + }, + fromSDKJSON(object: any): ParamsSDKType { + return { + bid_min_deposit: isSet(object.bid_min_deposit) ? Coin.fromSDKJSON(object.bid_min_deposit) : undefined, + order_max_bids: isSet(object.order_max_bids) ? Number(object.order_max_bids) : 0 + }; + }, + toSDK(message: Params): ParamsSDKType { + const obj: any = {}; + message.bidMinDeposit !== undefined && (obj.bid_min_deposit = message.bidMinDeposit ? Coin.toSDK(message.bidMinDeposit) : undefined); + obj.order_max_bids = message.orderMaxBids; + return obj; + }, + fromAmino(object: ParamsAmino): Params { + const message = createBaseParams(); + if (object.bid_min_deposit !== undefined && object.bid_min_deposit !== null) { + message.bidMinDeposit = Coin.fromAmino(object.bid_min_deposit); + } + if (object.order_max_bids !== undefined && object.order_max_bids !== null) { + message.orderMaxBids = object.order_max_bids; + } + return message; + }, + toAmino(message: Params): ParamsAmino { + const obj: any = {}; + obj.bid_min_deposit = message.bidMinDeposit ? Coin.toAmino(message.bidMinDeposit) : Coin.toAmino(Coin.fromPartial({})); + obj.order_max_bids = message.orderMaxBids ?? 0; + return obj; + }, + fromAminoMsg(object: ParamsAminoMsg): Params { + return Params.fromAmino(object.value); + }, + toAminoMsg(message: Params): ParamsAminoMsg { + return { + type: "akash/market/v1beta2/params", + value: Params.toAmino(message) + }; + }, + fromProtoMsg(message: ParamsProtoMsg): Params { + return Params.decode(message.value); + }, + toProto(message: Params): Uint8Array { + return Params.encode(message).finish(); + }, + toProtoMsg(message: Params): ParamsProtoMsg { + return { + typeUrl: "/akash.market.v1beta2.Params", + value: Params.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/market/v1beta2/query.lcd.ts b/__fixtures__/v-next/outputicjsdeps/akash/market/v1beta2/query.lcd.ts new file mode 100644 index 0000000000..4c321ae639 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/market/v1beta2/query.lcd.ts @@ -0,0 +1,93 @@ +import { OrderFilters, OrderFiltersSDKType, OrderID, OrderIDSDKType, Order, OrderSDKType } from "./order.js"; +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../../cosmos/base/query/v1beta1/pagination.js"; +import { BidFilters, BidFiltersSDKType, BidID, BidIDSDKType, Bid, BidSDKType } from "./bid.js"; +import { LeaseFilters, LeaseFiltersSDKType, LeaseID, LeaseIDSDKType, Lease, LeaseSDKType } from "./lease.js"; +import { Account, AccountSDKType, FractionalPayment, FractionalPaymentSDKType } from "../../escrow/v1beta2/types.js"; +import { setPaginationParams } from "../../../helpers.js"; +import { LCDClient } from "@cosmology/lcd"; +import { QueryOrdersRequest, QueryOrdersRequestSDKType, QueryOrdersResponse, QueryOrdersResponseSDKType, QueryOrderRequest, QueryOrderRequestSDKType, QueryOrderResponse, QueryOrderResponseSDKType, QueryBidsRequest, QueryBidsRequestSDKType, QueryBidsResponse, QueryBidsResponseSDKType, QueryBidRequest, QueryBidRequestSDKType, QueryBidResponse, QueryBidResponseSDKType, QueryLeasesRequest, QueryLeasesRequestSDKType, QueryLeasesResponse, QueryLeasesResponseSDKType, QueryLeaseRequest, QueryLeaseRequestSDKType, QueryLeaseResponse, QueryLeaseResponseSDKType } from "./query.js"; +export class LCDQueryClient { + req: LCDClient; + constructor({ + requestClient + }: { + requestClient: LCDClient; + }) { + this.req = requestClient; + } + /* Orders queries orders with filters */ + orders = async (params: QueryOrdersRequest): Promise => { + const options: any = { + params: {} + }; + if (typeof params?.filters !== "undefined") { + options.params.filters = params.filters; + } + if (typeof params?.pagination !== "undefined") { + setPaginationParams(options, params.pagination); + } + const endpoint = `akash/market/v1beta2/orders/list`; + return QueryOrdersResponse.fromSDKJSON(await this.req.get(endpoint, options)); + }; + /* Order queries order details */ + order = async (params: QueryOrderRequest): Promise => { + const options: any = { + params: {} + }; + if (typeof params?.id !== "undefined") { + options.params.id = params.id; + } + const endpoint = `akash/market/v1beta2/orders/info`; + return QueryOrderResponse.fromSDKJSON(await this.req.get(endpoint, options)); + }; + /* Bids queries bids with filters */ + bids = async (params: QueryBidsRequest): Promise => { + const options: any = { + params: {} + }; + if (typeof params?.filters !== "undefined") { + options.params.filters = params.filters; + } + if (typeof params?.pagination !== "undefined") { + setPaginationParams(options, params.pagination); + } + const endpoint = `akash/market/v1beta2/bids/list`; + return QueryBidsResponse.fromSDKJSON(await this.req.get(endpoint, options)); + }; + /* Bid queries bid details */ + bid = async (params: QueryBidRequest): Promise => { + const options: any = { + params: {} + }; + if (typeof params?.id !== "undefined") { + options.params.id = params.id; + } + const endpoint = `akash/market/v1beta2/bids/info`; + return QueryBidResponse.fromSDKJSON(await this.req.get(endpoint, options)); + }; + /* Leases queries leases with filters */ + leases = async (params: QueryLeasesRequest): Promise => { + const options: any = { + params: {} + }; + if (typeof params?.filters !== "undefined") { + options.params.filters = params.filters; + } + if (typeof params?.pagination !== "undefined") { + setPaginationParams(options, params.pagination); + } + const endpoint = `akash/market/v1beta2/leases/list`; + return QueryLeasesResponse.fromSDKJSON(await this.req.get(endpoint, options)); + }; + /* Lease queries lease details */ + lease = async (params: QueryLeaseRequest): Promise => { + const options: any = { + params: {} + }; + if (typeof params?.id !== "undefined") { + options.params.id = params.id; + } + const endpoint = `akash/market/v1beta2/leases/info`; + return QueryLeaseResponse.fromSDKJSON(await this.req.get(endpoint, options)); + }; +} \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/market/v1beta2/query.rpc.Query.ts b/__fixtures__/v-next/outputicjsdeps/akash/market/v1beta2/query.rpc.Query.ts new file mode 100644 index 0000000000..652548c361 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/market/v1beta2/query.rpc.Query.ts @@ -0,0 +1,90 @@ +import { OrderFilters, OrderFiltersSDKType, OrderID, OrderIDSDKType, Order, OrderSDKType } from "./order.js"; +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../../cosmos/base/query/v1beta1/pagination.js"; +import { BidFilters, BidFiltersSDKType, BidID, BidIDSDKType, Bid, BidSDKType } from "./bid.js"; +import { LeaseFilters, LeaseFiltersSDKType, LeaseID, LeaseIDSDKType, Lease, LeaseSDKType } from "./lease.js"; +import { Account, AccountSDKType, FractionalPayment, FractionalPaymentSDKType } from "../../escrow/v1beta2/types.js"; +import { Rpc } from "../../../helpers.js"; +import { BinaryReader } from "../../../binary.js"; +import { QueryClient, createProtobufRpcClient } from "@cosmjs/stargate"; +import { QueryOrdersRequest, QueryOrdersRequestSDKType, QueryOrdersResponse, QueryOrdersResponseSDKType, QueryOrderRequest, QueryOrderRequestSDKType, QueryOrderResponse, QueryOrderResponseSDKType, QueryBidsRequest, QueryBidsRequestSDKType, QueryBidsResponse, QueryBidsResponseSDKType, QueryBidRequest, QueryBidRequestSDKType, QueryBidResponse, QueryBidResponseSDKType, QueryLeasesRequest, QueryLeasesRequestSDKType, QueryLeasesResponse, QueryLeasesResponseSDKType, QueryLeaseRequest, QueryLeaseRequestSDKType, QueryLeaseResponse, QueryLeaseResponseSDKType } from "./query.js"; +/** Query defines the gRPC querier service */ +export interface Query { + /** Orders queries orders with filters */ + orders(request: QueryOrdersRequest): Promise; + /** Order queries order details */ + order(request: QueryOrderRequest): Promise; + /** Bids queries bids with filters */ + bids(request: QueryBidsRequest): Promise; + /** Bid queries bid details */ + bid(request: QueryBidRequest): Promise; + /** Leases queries leases with filters */ + leases(request: QueryLeasesRequest): Promise; + /** Lease queries lease details */ + lease(request: QueryLeaseRequest): Promise; +} +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + } + /* Orders queries orders with filters */ + orders = async (request: QueryOrdersRequest): Promise => { + const data = QueryOrdersRequest.encode(request).finish(); + const promise = this.rpc.request("akash.market.v1beta2.Query", "Orders", data); + return promise.then(data => QueryOrdersResponse.decode(new BinaryReader(data))); + }; + /* Order queries order details */ + order = async (request: QueryOrderRequest): Promise => { + const data = QueryOrderRequest.encode(request).finish(); + const promise = this.rpc.request("akash.market.v1beta2.Query", "Order", data); + return promise.then(data => QueryOrderResponse.decode(new BinaryReader(data))); + }; + /* Bids queries bids with filters */ + bids = async (request: QueryBidsRequest): Promise => { + const data = QueryBidsRequest.encode(request).finish(); + const promise = this.rpc.request("akash.market.v1beta2.Query", "Bids", data); + return promise.then(data => QueryBidsResponse.decode(new BinaryReader(data))); + }; + /* Bid queries bid details */ + bid = async (request: QueryBidRequest): Promise => { + const data = QueryBidRequest.encode(request).finish(); + const promise = this.rpc.request("akash.market.v1beta2.Query", "Bid", data); + return promise.then(data => QueryBidResponse.decode(new BinaryReader(data))); + }; + /* Leases queries leases with filters */ + leases = async (request: QueryLeasesRequest): Promise => { + const data = QueryLeasesRequest.encode(request).finish(); + const promise = this.rpc.request("akash.market.v1beta2.Query", "Leases", data); + return promise.then(data => QueryLeasesResponse.decode(new BinaryReader(data))); + }; + /* Lease queries lease details */ + lease = async (request: QueryLeaseRequest): Promise => { + const data = QueryLeaseRequest.encode(request).finish(); + const promise = this.rpc.request("akash.market.v1beta2.Query", "Lease", data); + return promise.then(data => QueryLeaseResponse.decode(new BinaryReader(data))); + }; +} +export const createRpcQueryExtension = (base: QueryClient) => { + const rpc = createProtobufRpcClient(base); + const queryService = new QueryClientImpl(rpc); + return { + orders(request: QueryOrdersRequest): Promise { + return queryService.orders(request); + }, + order(request: QueryOrderRequest): Promise { + return queryService.order(request); + }, + bids(request: QueryBidsRequest): Promise { + return queryService.bids(request); + }, + bid(request: QueryBidRequest): Promise { + return queryService.bid(request); + }, + leases(request: QueryLeasesRequest): Promise { + return queryService.leases(request); + }, + lease(request: QueryLeaseRequest): Promise { + return queryService.lease(request); + } + }; +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/market/v1beta2/query.rpc.func.ts b/__fixtures__/v-next/outputicjsdeps/akash/market/v1beta2/query.rpc.func.ts new file mode 100644 index 0000000000..752663d71c --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/market/v1beta2/query.rpc.func.ts @@ -0,0 +1,69 @@ +import { RpcResolver, buildQuery } from "../../../helper-func-types"; +import { buildUseQuery } from "../../../react-query"; +import { QueryOrdersRequest, QueryOrdersResponse, QueryOrderRequest, QueryOrderResponse, QueryBidsRequest, QueryBidsResponse, QueryBidRequest, QueryBidResponse, QueryLeasesRequest, QueryLeasesResponse, QueryLeaseRequest, QueryLeaseResponse } from "./query"; +export const createGetOrders = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryOrdersRequest.encode, + decode: QueryOrdersResponse.decode, + service: "akash.market.v1beta2.Query", + method: "Orders", + getRpcInstance: getRpcInstance +}); +export const useGetOrders = buildUseQuery({ + builderQueryFn: createGetOrders, + queryKeyPrefix: "OrdersQuery" +}); +export const createGetOrder = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryOrderRequest.encode, + decode: QueryOrderResponse.decode, + service: "akash.market.v1beta2.Query", + method: "Order", + getRpcInstance: getRpcInstance +}); +export const useGetOrder = buildUseQuery({ + builderQueryFn: createGetOrder, + queryKeyPrefix: "OrderQuery" +}); +export const createGetBids = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryBidsRequest.encode, + decode: QueryBidsResponse.decode, + service: "akash.market.v1beta2.Query", + method: "Bids", + getRpcInstance: getRpcInstance +}); +export const useGetBids = buildUseQuery({ + builderQueryFn: createGetBids, + queryKeyPrefix: "BidsQuery" +}); +export const createGetBid = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryBidRequest.encode, + decode: QueryBidResponse.decode, + service: "akash.market.v1beta2.Query", + method: "Bid", + getRpcInstance: getRpcInstance +}); +export const useGetBid = buildUseQuery({ + builderQueryFn: createGetBid, + queryKeyPrefix: "BidQuery" +}); +export const createGetLeases = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryLeasesRequest.encode, + decode: QueryLeasesResponse.decode, + service: "akash.market.v1beta2.Query", + method: "Leases", + getRpcInstance: getRpcInstance +}); +export const useGetLeases = buildUseQuery({ + builderQueryFn: createGetLeases, + queryKeyPrefix: "LeasesQuery" +}); +export const createGetLease = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryLeaseRequest.encode, + decode: QueryLeaseResponse.decode, + service: "akash.market.v1beta2.Query", + method: "Lease", + getRpcInstance: getRpcInstance +}); +export const useGetLease = buildUseQuery({ + builderQueryFn: createGetLease, + queryKeyPrefix: "LeaseQuery" +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/market/v1beta2/query.ts b/__fixtures__/v-next/outputicjsdeps/akash/market/v1beta2/query.ts new file mode 100644 index 0000000000..38745eae85 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/market/v1beta2/query.ts @@ -0,0 +1,1497 @@ +import { OrderFilters, OrderFiltersSDKType, OrderID, OrderIDSDKType, Order, OrderSDKType } from "./order.js"; +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../../cosmos/base/query/v1beta1/pagination.js"; +import { BidFilters, BidFiltersSDKType, BidID, BidIDSDKType, Bid, BidSDKType } from "./bid.js"; +import { LeaseFilters, LeaseFiltersSDKType, LeaseID, LeaseIDSDKType, Lease, LeaseSDKType } from "./lease.js"; +import { Account, AccountSDKType, FractionalPayment, FractionalPaymentSDKType } from "../../escrow/v1beta2/types.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial, Exact } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "akash.market.v1beta2"; +/** QueryOrdersRequest is request type for the Query/Orders RPC method */ +export interface QueryOrdersRequest { + filters: OrderFilters; + pagination?: PageRequest; +} +export interface QueryOrdersRequestProtoMsg { + typeUrl: "/akash.market.v1beta2.QueryOrdersRequest"; + value: Uint8Array; +} +/** QueryOrdersRequest is request type for the Query/Orders RPC method */ +export interface QueryOrdersRequestSDKType { + filters: OrderFiltersSDKType; + pagination?: PageRequestSDKType; +} +/** QueryOrdersResponse is response type for the Query/Orders RPC method */ +export interface QueryOrdersResponse { + orders: Order[]; + pagination?: PageResponse; +} +export interface QueryOrdersResponseProtoMsg { + typeUrl: "/akash.market.v1beta2.QueryOrdersResponse"; + value: Uint8Array; +} +/** QueryOrdersResponse is response type for the Query/Orders RPC method */ +export interface QueryOrdersResponseSDKType { + orders: OrderSDKType[]; + pagination?: PageResponseSDKType; +} +/** QueryOrderRequest is request type for the Query/Order RPC method */ +export interface QueryOrderRequest { + id: OrderID; +} +export interface QueryOrderRequestProtoMsg { + typeUrl: "/akash.market.v1beta2.QueryOrderRequest"; + value: Uint8Array; +} +/** QueryOrderRequest is request type for the Query/Order RPC method */ +export interface QueryOrderRequestSDKType { + id: OrderIDSDKType; +} +/** QueryOrderResponse is response type for the Query/Order RPC method */ +export interface QueryOrderResponse { + order: Order; +} +export interface QueryOrderResponseProtoMsg { + typeUrl: "/akash.market.v1beta2.QueryOrderResponse"; + value: Uint8Array; +} +/** QueryOrderResponse is response type for the Query/Order RPC method */ +export interface QueryOrderResponseSDKType { + order: OrderSDKType; +} +/** QueryBidsRequest is request type for the Query/Bids RPC method */ +export interface QueryBidsRequest { + filters: BidFilters; + pagination?: PageRequest; +} +export interface QueryBidsRequestProtoMsg { + typeUrl: "/akash.market.v1beta2.QueryBidsRequest"; + value: Uint8Array; +} +/** QueryBidsRequest is request type for the Query/Bids RPC method */ +export interface QueryBidsRequestSDKType { + filters: BidFiltersSDKType; + pagination?: PageRequestSDKType; +} +/** QueryBidsResponse is response type for the Query/Bids RPC method */ +export interface QueryBidsResponse { + bids: QueryBidResponse[]; + pagination?: PageResponse; +} +export interface QueryBidsResponseProtoMsg { + typeUrl: "/akash.market.v1beta2.QueryBidsResponse"; + value: Uint8Array; +} +/** QueryBidsResponse is response type for the Query/Bids RPC method */ +export interface QueryBidsResponseSDKType { + bids: QueryBidResponseSDKType[]; + pagination?: PageResponseSDKType; +} +/** QueryBidRequest is request type for the Query/Bid RPC method */ +export interface QueryBidRequest { + id: BidID; +} +export interface QueryBidRequestProtoMsg { + typeUrl: "/akash.market.v1beta2.QueryBidRequest"; + value: Uint8Array; +} +/** QueryBidRequest is request type for the Query/Bid RPC method */ +export interface QueryBidRequestSDKType { + id: BidIDSDKType; +} +/** QueryBidResponse is response type for the Query/Bid RPC method */ +export interface QueryBidResponse { + bid: Bid; + escrowAccount: Account; +} +export interface QueryBidResponseProtoMsg { + typeUrl: "/akash.market.v1beta2.QueryBidResponse"; + value: Uint8Array; +} +/** QueryBidResponse is response type for the Query/Bid RPC method */ +export interface QueryBidResponseSDKType { + bid: BidSDKType; + escrow_account: AccountSDKType; +} +/** QueryLeasesRequest is request type for the Query/Leases RPC method */ +export interface QueryLeasesRequest { + filters: LeaseFilters; + pagination?: PageRequest; +} +export interface QueryLeasesRequestProtoMsg { + typeUrl: "/akash.market.v1beta2.QueryLeasesRequest"; + value: Uint8Array; +} +/** QueryLeasesRequest is request type for the Query/Leases RPC method */ +export interface QueryLeasesRequestSDKType { + filters: LeaseFiltersSDKType; + pagination?: PageRequestSDKType; +} +/** QueryLeasesResponse is response type for the Query/Leases RPC method */ +export interface QueryLeasesResponse { + leases: QueryLeaseResponse[]; + pagination?: PageResponse; +} +export interface QueryLeasesResponseProtoMsg { + typeUrl: "/akash.market.v1beta2.QueryLeasesResponse"; + value: Uint8Array; +} +/** QueryLeasesResponse is response type for the Query/Leases RPC method */ +export interface QueryLeasesResponseSDKType { + leases: QueryLeaseResponseSDKType[]; + pagination?: PageResponseSDKType; +} +/** QueryLeaseRequest is request type for the Query/Lease RPC method */ +export interface QueryLeaseRequest { + id: LeaseID; +} +export interface QueryLeaseRequestProtoMsg { + typeUrl: "/akash.market.v1beta2.QueryLeaseRequest"; + value: Uint8Array; +} +/** QueryLeaseRequest is request type for the Query/Lease RPC method */ +export interface QueryLeaseRequestSDKType { + id: LeaseIDSDKType; +} +/** QueryLeaseResponse is response type for the Query/Lease RPC method */ +export interface QueryLeaseResponse { + lease: Lease; + escrowPayment: FractionalPayment; +} +export interface QueryLeaseResponseProtoMsg { + typeUrl: "/akash.market.v1beta2.QueryLeaseResponse"; + value: Uint8Array; +} +/** QueryLeaseResponse is response type for the Query/Lease RPC method */ +export interface QueryLeaseResponseSDKType { + lease: LeaseSDKType; + escrow_payment: FractionalPaymentSDKType; +} +function createBaseQueryOrdersRequest(): QueryOrdersRequest { + return { + filters: OrderFilters.fromPartial({}), + pagination: undefined + }; +} +export const QueryOrdersRequest = { + typeUrl: "/akash.market.v1beta2.QueryOrdersRequest", + encode(message: QueryOrdersRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.filters !== undefined) { + OrderFilters.encode(message.filters, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryOrdersRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryOrdersRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.filters = OrderFilters.decode(reader, reader.uint32()); + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryOrdersRequest { + const obj = createBaseQueryOrdersRequest(); + if (isSet(object.filters)) obj.filters = OrderFilters.fromJSON(object.filters); + if (isSet(object.pagination)) obj.pagination = PageRequest.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryOrdersRequest): JsonSafe { + const obj: any = {}; + message.filters !== undefined && (obj.filters = message.filters ? OrderFilters.toJSON(message.filters) : undefined); + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryOrdersRequest { + const message = createBaseQueryOrdersRequest(); + if (object.filters !== undefined && object.filters !== null) { + message.filters = OrderFilters.fromPartial(object.filters); + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryOrdersRequestSDKType): QueryOrdersRequest { + return { + filters: object.filters ? OrderFilters.fromSDK(object.filters) : undefined, + pagination: object.pagination ? PageRequest.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryOrdersRequestSDKType { + return { + filters: isSet(object.filters) ? OrderFilters.fromSDKJSON(object.filters) : undefined, + pagination: isSet(object.pagination) ? PageRequest.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryOrdersRequest): QueryOrdersRequestSDKType { + const obj: any = {}; + message.filters !== undefined && (obj.filters = message.filters ? OrderFilters.toSDK(message.filters) : undefined); + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryOrdersRequestAmino): QueryOrdersRequest { + const message = createBaseQueryOrdersRequest(); + if (object.filters !== undefined && object.filters !== null) { + message.filters = OrderFilters.fromAmino(object.filters); + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryOrdersRequest): QueryOrdersRequestAmino { + const obj: any = {}; + obj.filters = message.filters ? OrderFilters.toAmino(message.filters) : undefined; + obj.pagination = message.pagination ? PageRequest.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryOrdersRequestAminoMsg): QueryOrdersRequest { + return QueryOrdersRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryOrdersRequest): QueryOrdersRequestAminoMsg { + return { + type: "akash/market/v1beta2/query-orders-request", + value: QueryOrdersRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryOrdersRequestProtoMsg): QueryOrdersRequest { + return QueryOrdersRequest.decode(message.value); + }, + toProto(message: QueryOrdersRequest): Uint8Array { + return QueryOrdersRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryOrdersRequest): QueryOrdersRequestProtoMsg { + return { + typeUrl: "/akash.market.v1beta2.QueryOrdersRequest", + value: QueryOrdersRequest.encode(message).finish() + }; + } +}; +function createBaseQueryOrdersResponse(): QueryOrdersResponse { + return { + orders: [], + pagination: undefined + }; +} +export const QueryOrdersResponse = { + typeUrl: "/akash.market.v1beta2.QueryOrdersResponse", + encode(message: QueryOrdersResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.orders) { + Order.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryOrdersResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryOrdersResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.orders.push(Order.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryOrdersResponse { + const obj = createBaseQueryOrdersResponse(); + if (Array.isArray(object?.orders)) obj.orders = object.orders.map((e: any) => Order.fromJSON(e)); + if (isSet(object.pagination)) obj.pagination = PageResponse.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryOrdersResponse): JsonSafe { + const obj: any = {}; + if (message.orders) { + obj.orders = message.orders.map(e => e ? Order.toJSON(e) : undefined); + } else { + obj.orders = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryOrdersResponse { + const message = createBaseQueryOrdersResponse(); + message.orders = object.orders?.map(e => Order.fromPartial(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryOrdersResponseSDKType): QueryOrdersResponse { + return { + orders: Array.isArray(object?.orders) ? object.orders.map((e: any) => Order.fromSDK(e)) : [], + pagination: object.pagination ? PageResponse.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryOrdersResponseSDKType { + return { + orders: Array.isArray(object?.orders) ? object.orders.map((e: any) => Order.fromSDKJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryOrdersResponse): QueryOrdersResponseSDKType { + const obj: any = {}; + if (message.orders) { + obj.orders = message.orders.map(e => e ? Order.toSDK(e) : undefined); + } else { + obj.orders = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryOrdersResponseAmino): QueryOrdersResponse { + const message = createBaseQueryOrdersResponse(); + message.orders = object.orders?.map(e => Order.fromAmino(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryOrdersResponse): QueryOrdersResponseAmino { + const obj: any = {}; + if (message.orders) { + obj.orders = message.orders.map(e => e ? Order.toAmino(e) : undefined); + } else { + obj.orders = message.orders; + } + obj.pagination = message.pagination ? PageResponse.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryOrdersResponseAminoMsg): QueryOrdersResponse { + return QueryOrdersResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryOrdersResponse): QueryOrdersResponseAminoMsg { + return { + type: "akash/market/v1beta2/query-orders-response", + value: QueryOrdersResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryOrdersResponseProtoMsg): QueryOrdersResponse { + return QueryOrdersResponse.decode(message.value); + }, + toProto(message: QueryOrdersResponse): Uint8Array { + return QueryOrdersResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryOrdersResponse): QueryOrdersResponseProtoMsg { + return { + typeUrl: "/akash.market.v1beta2.QueryOrdersResponse", + value: QueryOrdersResponse.encode(message).finish() + }; + } +}; +function createBaseQueryOrderRequest(): QueryOrderRequest { + return { + id: OrderID.fromPartial({}) + }; +} +export const QueryOrderRequest = { + typeUrl: "/akash.market.v1beta2.QueryOrderRequest", + encode(message: QueryOrderRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.id !== undefined) { + OrderID.encode(message.id, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryOrderRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryOrderRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.id = OrderID.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryOrderRequest { + const obj = createBaseQueryOrderRequest(); + if (isSet(object.id)) obj.id = OrderID.fromJSON(object.id); + return obj; + }, + toJSON(message: QueryOrderRequest): JsonSafe { + const obj: any = {}; + message.id !== undefined && (obj.id = message.id ? OrderID.toJSON(message.id) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryOrderRequest { + const message = createBaseQueryOrderRequest(); + if (object.id !== undefined && object.id !== null) { + message.id = OrderID.fromPartial(object.id); + } + return message; + }, + fromSDK(object: QueryOrderRequestSDKType): QueryOrderRequest { + return { + id: object.id ? OrderID.fromSDK(object.id) : undefined + }; + }, + fromSDKJSON(object: any): QueryOrderRequestSDKType { + return { + id: isSet(object.id) ? OrderID.fromSDKJSON(object.id) : undefined + }; + }, + toSDK(message: QueryOrderRequest): QueryOrderRequestSDKType { + const obj: any = {}; + message.id !== undefined && (obj.id = message.id ? OrderID.toSDK(message.id) : undefined); + return obj; + }, + fromAmino(object: QueryOrderRequestAmino): QueryOrderRequest { + const message = createBaseQueryOrderRequest(); + if (object.id !== undefined && object.id !== null) { + message.id = OrderID.fromAmino(object.id); + } + return message; + }, + toAmino(message: QueryOrderRequest): QueryOrderRequestAmino { + const obj: any = {}; + obj.id = message.id ? OrderID.toAmino(message.id) : undefined; + return obj; + }, + fromAminoMsg(object: QueryOrderRequestAminoMsg): QueryOrderRequest { + return QueryOrderRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryOrderRequest): QueryOrderRequestAminoMsg { + return { + type: "akash/market/v1beta2/query-order-request", + value: QueryOrderRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryOrderRequestProtoMsg): QueryOrderRequest { + return QueryOrderRequest.decode(message.value); + }, + toProto(message: QueryOrderRequest): Uint8Array { + return QueryOrderRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryOrderRequest): QueryOrderRequestProtoMsg { + return { + typeUrl: "/akash.market.v1beta2.QueryOrderRequest", + value: QueryOrderRequest.encode(message).finish() + }; + } +}; +function createBaseQueryOrderResponse(): QueryOrderResponse { + return { + order: Order.fromPartial({}) + }; +} +export const QueryOrderResponse = { + typeUrl: "/akash.market.v1beta2.QueryOrderResponse", + encode(message: QueryOrderResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.order !== undefined) { + Order.encode(message.order, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryOrderResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryOrderResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.order = Order.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryOrderResponse { + const obj = createBaseQueryOrderResponse(); + if (isSet(object.order)) obj.order = Order.fromJSON(object.order); + return obj; + }, + toJSON(message: QueryOrderResponse): JsonSafe { + const obj: any = {}; + message.order !== undefined && (obj.order = message.order ? Order.toJSON(message.order) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryOrderResponse { + const message = createBaseQueryOrderResponse(); + if (object.order !== undefined && object.order !== null) { + message.order = Order.fromPartial(object.order); + } + return message; + }, + fromSDK(object: QueryOrderResponseSDKType): QueryOrderResponse { + return { + order: object.order ? Order.fromSDK(object.order) : undefined + }; + }, + fromSDKJSON(object: any): QueryOrderResponseSDKType { + return { + order: isSet(object.order) ? Order.fromSDKJSON(object.order) : undefined + }; + }, + toSDK(message: QueryOrderResponse): QueryOrderResponseSDKType { + const obj: any = {}; + message.order !== undefined && (obj.order = message.order ? Order.toSDK(message.order) : undefined); + return obj; + }, + fromAmino(object: QueryOrderResponseAmino): QueryOrderResponse { + const message = createBaseQueryOrderResponse(); + if (object.order !== undefined && object.order !== null) { + message.order = Order.fromAmino(object.order); + } + return message; + }, + toAmino(message: QueryOrderResponse): QueryOrderResponseAmino { + const obj: any = {}; + obj.order = message.order ? Order.toAmino(message.order) : undefined; + return obj; + }, + fromAminoMsg(object: QueryOrderResponseAminoMsg): QueryOrderResponse { + return QueryOrderResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryOrderResponse): QueryOrderResponseAminoMsg { + return { + type: "akash/market/v1beta2/query-order-response", + value: QueryOrderResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryOrderResponseProtoMsg): QueryOrderResponse { + return QueryOrderResponse.decode(message.value); + }, + toProto(message: QueryOrderResponse): Uint8Array { + return QueryOrderResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryOrderResponse): QueryOrderResponseProtoMsg { + return { + typeUrl: "/akash.market.v1beta2.QueryOrderResponse", + value: QueryOrderResponse.encode(message).finish() + }; + } +}; +function createBaseQueryBidsRequest(): QueryBidsRequest { + return { + filters: BidFilters.fromPartial({}), + pagination: undefined + }; +} +export const QueryBidsRequest = { + typeUrl: "/akash.market.v1beta2.QueryBidsRequest", + encode(message: QueryBidsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.filters !== undefined) { + BidFilters.encode(message.filters, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryBidsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryBidsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.filters = BidFilters.decode(reader, reader.uint32()); + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryBidsRequest { + const obj = createBaseQueryBidsRequest(); + if (isSet(object.filters)) obj.filters = BidFilters.fromJSON(object.filters); + if (isSet(object.pagination)) obj.pagination = PageRequest.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryBidsRequest): JsonSafe { + const obj: any = {}; + message.filters !== undefined && (obj.filters = message.filters ? BidFilters.toJSON(message.filters) : undefined); + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryBidsRequest { + const message = createBaseQueryBidsRequest(); + if (object.filters !== undefined && object.filters !== null) { + message.filters = BidFilters.fromPartial(object.filters); + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryBidsRequestSDKType): QueryBidsRequest { + return { + filters: object.filters ? BidFilters.fromSDK(object.filters) : undefined, + pagination: object.pagination ? PageRequest.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryBidsRequestSDKType { + return { + filters: isSet(object.filters) ? BidFilters.fromSDKJSON(object.filters) : undefined, + pagination: isSet(object.pagination) ? PageRequest.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryBidsRequest): QueryBidsRequestSDKType { + const obj: any = {}; + message.filters !== undefined && (obj.filters = message.filters ? BidFilters.toSDK(message.filters) : undefined); + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryBidsRequestAmino): QueryBidsRequest { + const message = createBaseQueryBidsRequest(); + if (object.filters !== undefined && object.filters !== null) { + message.filters = BidFilters.fromAmino(object.filters); + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryBidsRequest): QueryBidsRequestAmino { + const obj: any = {}; + obj.filters = message.filters ? BidFilters.toAmino(message.filters) : undefined; + obj.pagination = message.pagination ? PageRequest.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryBidsRequestAminoMsg): QueryBidsRequest { + return QueryBidsRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryBidsRequest): QueryBidsRequestAminoMsg { + return { + type: "akash/market/v1beta2/query-bids-request", + value: QueryBidsRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryBidsRequestProtoMsg): QueryBidsRequest { + return QueryBidsRequest.decode(message.value); + }, + toProto(message: QueryBidsRequest): Uint8Array { + return QueryBidsRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryBidsRequest): QueryBidsRequestProtoMsg { + return { + typeUrl: "/akash.market.v1beta2.QueryBidsRequest", + value: QueryBidsRequest.encode(message).finish() + }; + } +}; +function createBaseQueryBidsResponse(): QueryBidsResponse { + return { + bids: [], + pagination: undefined + }; +} +export const QueryBidsResponse = { + typeUrl: "/akash.market.v1beta2.QueryBidsResponse", + encode(message: QueryBidsResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.bids) { + QueryBidResponse.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryBidsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryBidsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.bids.push(QueryBidResponse.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryBidsResponse { + const obj = createBaseQueryBidsResponse(); + if (Array.isArray(object?.bids)) obj.bids = object.bids.map((e: any) => QueryBidResponse.fromJSON(e)); + if (isSet(object.pagination)) obj.pagination = PageResponse.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryBidsResponse): JsonSafe { + const obj: any = {}; + if (message.bids) { + obj.bids = message.bids.map(e => e ? QueryBidResponse.toJSON(e) : undefined); + } else { + obj.bids = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryBidsResponse { + const message = createBaseQueryBidsResponse(); + message.bids = object.bids?.map(e => QueryBidResponse.fromPartial(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryBidsResponseSDKType): QueryBidsResponse { + return { + bids: Array.isArray(object?.bids) ? object.bids.map((e: any) => QueryBidResponse.fromSDK(e)) : [], + pagination: object.pagination ? PageResponse.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryBidsResponseSDKType { + return { + bids: Array.isArray(object?.bids) ? object.bids.map((e: any) => QueryBidResponse.fromSDKJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryBidsResponse): QueryBidsResponseSDKType { + const obj: any = {}; + if (message.bids) { + obj.bids = message.bids.map(e => e ? QueryBidResponse.toSDK(e) : undefined); + } else { + obj.bids = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryBidsResponseAmino): QueryBidsResponse { + const message = createBaseQueryBidsResponse(); + message.bids = object.bids?.map(e => QueryBidResponse.fromAmino(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryBidsResponse): QueryBidsResponseAmino { + const obj: any = {}; + if (message.bids) { + obj.bids = message.bids.map(e => e ? QueryBidResponse.toAmino(e) : undefined); + } else { + obj.bids = message.bids; + } + obj.pagination = message.pagination ? PageResponse.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryBidsResponseAminoMsg): QueryBidsResponse { + return QueryBidsResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryBidsResponse): QueryBidsResponseAminoMsg { + return { + type: "akash/market/v1beta2/query-bids-response", + value: QueryBidsResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryBidsResponseProtoMsg): QueryBidsResponse { + return QueryBidsResponse.decode(message.value); + }, + toProto(message: QueryBidsResponse): Uint8Array { + return QueryBidsResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryBidsResponse): QueryBidsResponseProtoMsg { + return { + typeUrl: "/akash.market.v1beta2.QueryBidsResponse", + value: QueryBidsResponse.encode(message).finish() + }; + } +}; +function createBaseQueryBidRequest(): QueryBidRequest { + return { + id: BidID.fromPartial({}) + }; +} +export const QueryBidRequest = { + typeUrl: "/akash.market.v1beta2.QueryBidRequest", + encode(message: QueryBidRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.id !== undefined) { + BidID.encode(message.id, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryBidRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryBidRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.id = BidID.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryBidRequest { + const obj = createBaseQueryBidRequest(); + if (isSet(object.id)) obj.id = BidID.fromJSON(object.id); + return obj; + }, + toJSON(message: QueryBidRequest): JsonSafe { + const obj: any = {}; + message.id !== undefined && (obj.id = message.id ? BidID.toJSON(message.id) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryBidRequest { + const message = createBaseQueryBidRequest(); + if (object.id !== undefined && object.id !== null) { + message.id = BidID.fromPartial(object.id); + } + return message; + }, + fromSDK(object: QueryBidRequestSDKType): QueryBidRequest { + return { + id: object.id ? BidID.fromSDK(object.id) : undefined + }; + }, + fromSDKJSON(object: any): QueryBidRequestSDKType { + return { + id: isSet(object.id) ? BidID.fromSDKJSON(object.id) : undefined + }; + }, + toSDK(message: QueryBidRequest): QueryBidRequestSDKType { + const obj: any = {}; + message.id !== undefined && (obj.id = message.id ? BidID.toSDK(message.id) : undefined); + return obj; + }, + fromAmino(object: QueryBidRequestAmino): QueryBidRequest { + const message = createBaseQueryBidRequest(); + if (object.id !== undefined && object.id !== null) { + message.id = BidID.fromAmino(object.id); + } + return message; + }, + toAmino(message: QueryBidRequest): QueryBidRequestAmino { + const obj: any = {}; + obj.id = message.id ? BidID.toAmino(message.id) : undefined; + return obj; + }, + fromAminoMsg(object: QueryBidRequestAminoMsg): QueryBidRequest { + return QueryBidRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryBidRequest): QueryBidRequestAminoMsg { + return { + type: "akash/market/v1beta2/query-bid-request", + value: QueryBidRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryBidRequestProtoMsg): QueryBidRequest { + return QueryBidRequest.decode(message.value); + }, + toProto(message: QueryBidRequest): Uint8Array { + return QueryBidRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryBidRequest): QueryBidRequestProtoMsg { + return { + typeUrl: "/akash.market.v1beta2.QueryBidRequest", + value: QueryBidRequest.encode(message).finish() + }; + } +}; +function createBaseQueryBidResponse(): QueryBidResponse { + return { + bid: Bid.fromPartial({}), + escrowAccount: Account.fromPartial({}) + }; +} +export const QueryBidResponse = { + typeUrl: "/akash.market.v1beta2.QueryBidResponse", + encode(message: QueryBidResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.bid !== undefined) { + Bid.encode(message.bid, writer.uint32(10).fork()).ldelim(); + } + if (message.escrowAccount !== undefined) { + Account.encode(message.escrowAccount, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryBidResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryBidResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.bid = Bid.decode(reader, reader.uint32()); + break; + case 2: + message.escrowAccount = Account.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryBidResponse { + const obj = createBaseQueryBidResponse(); + if (isSet(object.bid)) obj.bid = Bid.fromJSON(object.bid); + if (isSet(object.escrowAccount)) obj.escrowAccount = Account.fromJSON(object.escrowAccount); + return obj; + }, + toJSON(message: QueryBidResponse): JsonSafe { + const obj: any = {}; + message.bid !== undefined && (obj.bid = message.bid ? Bid.toJSON(message.bid) : undefined); + message.escrowAccount !== undefined && (obj.escrowAccount = message.escrowAccount ? Account.toJSON(message.escrowAccount) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryBidResponse { + const message = createBaseQueryBidResponse(); + if (object.bid !== undefined && object.bid !== null) { + message.bid = Bid.fromPartial(object.bid); + } + if (object.escrowAccount !== undefined && object.escrowAccount !== null) { + message.escrowAccount = Account.fromPartial(object.escrowAccount); + } + return message; + }, + fromSDK(object: QueryBidResponseSDKType): QueryBidResponse { + return { + bid: object.bid ? Bid.fromSDK(object.bid) : undefined, + escrowAccount: object.escrow_account ? Account.fromSDK(object.escrow_account) : undefined + }; + }, + fromSDKJSON(object: any): QueryBidResponseSDKType { + return { + bid: isSet(object.bid) ? Bid.fromSDKJSON(object.bid) : undefined, + escrow_account: isSet(object.escrow_account) ? Account.fromSDKJSON(object.escrow_account) : undefined + }; + }, + toSDK(message: QueryBidResponse): QueryBidResponseSDKType { + const obj: any = {}; + message.bid !== undefined && (obj.bid = message.bid ? Bid.toSDK(message.bid) : undefined); + message.escrowAccount !== undefined && (obj.escrow_account = message.escrowAccount ? Account.toSDK(message.escrowAccount) : undefined); + return obj; + }, + fromAmino(object: QueryBidResponseAmino): QueryBidResponse { + const message = createBaseQueryBidResponse(); + if (object.bid !== undefined && object.bid !== null) { + message.bid = Bid.fromAmino(object.bid); + } + if (object.escrow_account !== undefined && object.escrow_account !== null) { + message.escrowAccount = Account.fromAmino(object.escrow_account); + } + return message; + }, + toAmino(message: QueryBidResponse): QueryBidResponseAmino { + const obj: any = {}; + obj.bid = message.bid ? Bid.toAmino(message.bid) : undefined; + obj.escrow_account = message.escrowAccount ? Account.toAmino(message.escrowAccount) : undefined; + return obj; + }, + fromAminoMsg(object: QueryBidResponseAminoMsg): QueryBidResponse { + return QueryBidResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryBidResponse): QueryBidResponseAminoMsg { + return { + type: "akash/market/v1beta2/query-bid-response", + value: QueryBidResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryBidResponseProtoMsg): QueryBidResponse { + return QueryBidResponse.decode(message.value); + }, + toProto(message: QueryBidResponse): Uint8Array { + return QueryBidResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryBidResponse): QueryBidResponseProtoMsg { + return { + typeUrl: "/akash.market.v1beta2.QueryBidResponse", + value: QueryBidResponse.encode(message).finish() + }; + } +}; +function createBaseQueryLeasesRequest(): QueryLeasesRequest { + return { + filters: LeaseFilters.fromPartial({}), + pagination: undefined + }; +} +export const QueryLeasesRequest = { + typeUrl: "/akash.market.v1beta2.QueryLeasesRequest", + encode(message: QueryLeasesRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.filters !== undefined) { + LeaseFilters.encode(message.filters, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryLeasesRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryLeasesRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.filters = LeaseFilters.decode(reader, reader.uint32()); + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryLeasesRequest { + const obj = createBaseQueryLeasesRequest(); + if (isSet(object.filters)) obj.filters = LeaseFilters.fromJSON(object.filters); + if (isSet(object.pagination)) obj.pagination = PageRequest.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryLeasesRequest): JsonSafe { + const obj: any = {}; + message.filters !== undefined && (obj.filters = message.filters ? LeaseFilters.toJSON(message.filters) : undefined); + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryLeasesRequest { + const message = createBaseQueryLeasesRequest(); + if (object.filters !== undefined && object.filters !== null) { + message.filters = LeaseFilters.fromPartial(object.filters); + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryLeasesRequestSDKType): QueryLeasesRequest { + return { + filters: object.filters ? LeaseFilters.fromSDK(object.filters) : undefined, + pagination: object.pagination ? PageRequest.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryLeasesRequestSDKType { + return { + filters: isSet(object.filters) ? LeaseFilters.fromSDKJSON(object.filters) : undefined, + pagination: isSet(object.pagination) ? PageRequest.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryLeasesRequest): QueryLeasesRequestSDKType { + const obj: any = {}; + message.filters !== undefined && (obj.filters = message.filters ? LeaseFilters.toSDK(message.filters) : undefined); + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryLeasesRequestAmino): QueryLeasesRequest { + const message = createBaseQueryLeasesRequest(); + if (object.filters !== undefined && object.filters !== null) { + message.filters = LeaseFilters.fromAmino(object.filters); + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryLeasesRequest): QueryLeasesRequestAmino { + const obj: any = {}; + obj.filters = message.filters ? LeaseFilters.toAmino(message.filters) : undefined; + obj.pagination = message.pagination ? PageRequest.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryLeasesRequestAminoMsg): QueryLeasesRequest { + return QueryLeasesRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryLeasesRequest): QueryLeasesRequestAminoMsg { + return { + type: "akash/market/v1beta2/query-leases-request", + value: QueryLeasesRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryLeasesRequestProtoMsg): QueryLeasesRequest { + return QueryLeasesRequest.decode(message.value); + }, + toProto(message: QueryLeasesRequest): Uint8Array { + return QueryLeasesRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryLeasesRequest): QueryLeasesRequestProtoMsg { + return { + typeUrl: "/akash.market.v1beta2.QueryLeasesRequest", + value: QueryLeasesRequest.encode(message).finish() + }; + } +}; +function createBaseQueryLeasesResponse(): QueryLeasesResponse { + return { + leases: [], + pagination: undefined + }; +} +export const QueryLeasesResponse = { + typeUrl: "/akash.market.v1beta2.QueryLeasesResponse", + encode(message: QueryLeasesResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.leases) { + QueryLeaseResponse.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryLeasesResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryLeasesResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.leases.push(QueryLeaseResponse.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryLeasesResponse { + const obj = createBaseQueryLeasesResponse(); + if (Array.isArray(object?.leases)) obj.leases = object.leases.map((e: any) => QueryLeaseResponse.fromJSON(e)); + if (isSet(object.pagination)) obj.pagination = PageResponse.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryLeasesResponse): JsonSafe { + const obj: any = {}; + if (message.leases) { + obj.leases = message.leases.map(e => e ? QueryLeaseResponse.toJSON(e) : undefined); + } else { + obj.leases = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryLeasesResponse { + const message = createBaseQueryLeasesResponse(); + message.leases = object.leases?.map(e => QueryLeaseResponse.fromPartial(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryLeasesResponseSDKType): QueryLeasesResponse { + return { + leases: Array.isArray(object?.leases) ? object.leases.map((e: any) => QueryLeaseResponse.fromSDK(e)) : [], + pagination: object.pagination ? PageResponse.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryLeasesResponseSDKType { + return { + leases: Array.isArray(object?.leases) ? object.leases.map((e: any) => QueryLeaseResponse.fromSDKJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryLeasesResponse): QueryLeasesResponseSDKType { + const obj: any = {}; + if (message.leases) { + obj.leases = message.leases.map(e => e ? QueryLeaseResponse.toSDK(e) : undefined); + } else { + obj.leases = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryLeasesResponseAmino): QueryLeasesResponse { + const message = createBaseQueryLeasesResponse(); + message.leases = object.leases?.map(e => QueryLeaseResponse.fromAmino(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryLeasesResponse): QueryLeasesResponseAmino { + const obj: any = {}; + if (message.leases) { + obj.leases = message.leases.map(e => e ? QueryLeaseResponse.toAmino(e) : undefined); + } else { + obj.leases = message.leases; + } + obj.pagination = message.pagination ? PageResponse.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryLeasesResponseAminoMsg): QueryLeasesResponse { + return QueryLeasesResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryLeasesResponse): QueryLeasesResponseAminoMsg { + return { + type: "akash/market/v1beta2/query-leases-response", + value: QueryLeasesResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryLeasesResponseProtoMsg): QueryLeasesResponse { + return QueryLeasesResponse.decode(message.value); + }, + toProto(message: QueryLeasesResponse): Uint8Array { + return QueryLeasesResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryLeasesResponse): QueryLeasesResponseProtoMsg { + return { + typeUrl: "/akash.market.v1beta2.QueryLeasesResponse", + value: QueryLeasesResponse.encode(message).finish() + }; + } +}; +function createBaseQueryLeaseRequest(): QueryLeaseRequest { + return { + id: LeaseID.fromPartial({}) + }; +} +export const QueryLeaseRequest = { + typeUrl: "/akash.market.v1beta2.QueryLeaseRequest", + encode(message: QueryLeaseRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.id !== undefined) { + LeaseID.encode(message.id, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryLeaseRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryLeaseRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.id = LeaseID.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryLeaseRequest { + const obj = createBaseQueryLeaseRequest(); + if (isSet(object.id)) obj.id = LeaseID.fromJSON(object.id); + return obj; + }, + toJSON(message: QueryLeaseRequest): JsonSafe { + const obj: any = {}; + message.id !== undefined && (obj.id = message.id ? LeaseID.toJSON(message.id) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryLeaseRequest { + const message = createBaseQueryLeaseRequest(); + if (object.id !== undefined && object.id !== null) { + message.id = LeaseID.fromPartial(object.id); + } + return message; + }, + fromSDK(object: QueryLeaseRequestSDKType): QueryLeaseRequest { + return { + id: object.id ? LeaseID.fromSDK(object.id) : undefined + }; + }, + fromSDKJSON(object: any): QueryLeaseRequestSDKType { + return { + id: isSet(object.id) ? LeaseID.fromSDKJSON(object.id) : undefined + }; + }, + toSDK(message: QueryLeaseRequest): QueryLeaseRequestSDKType { + const obj: any = {}; + message.id !== undefined && (obj.id = message.id ? LeaseID.toSDK(message.id) : undefined); + return obj; + }, + fromAmino(object: QueryLeaseRequestAmino): QueryLeaseRequest { + const message = createBaseQueryLeaseRequest(); + if (object.id !== undefined && object.id !== null) { + message.id = LeaseID.fromAmino(object.id); + } + return message; + }, + toAmino(message: QueryLeaseRequest): QueryLeaseRequestAmino { + const obj: any = {}; + obj.id = message.id ? LeaseID.toAmino(message.id) : undefined; + return obj; + }, + fromAminoMsg(object: QueryLeaseRequestAminoMsg): QueryLeaseRequest { + return QueryLeaseRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryLeaseRequest): QueryLeaseRequestAminoMsg { + return { + type: "akash/market/v1beta2/query-lease-request", + value: QueryLeaseRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryLeaseRequestProtoMsg): QueryLeaseRequest { + return QueryLeaseRequest.decode(message.value); + }, + toProto(message: QueryLeaseRequest): Uint8Array { + return QueryLeaseRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryLeaseRequest): QueryLeaseRequestProtoMsg { + return { + typeUrl: "/akash.market.v1beta2.QueryLeaseRequest", + value: QueryLeaseRequest.encode(message).finish() + }; + } +}; +function createBaseQueryLeaseResponse(): QueryLeaseResponse { + return { + lease: Lease.fromPartial({}), + escrowPayment: FractionalPayment.fromPartial({}) + }; +} +export const QueryLeaseResponse = { + typeUrl: "/akash.market.v1beta2.QueryLeaseResponse", + encode(message: QueryLeaseResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.lease !== undefined) { + Lease.encode(message.lease, writer.uint32(10).fork()).ldelim(); + } + if (message.escrowPayment !== undefined) { + FractionalPayment.encode(message.escrowPayment, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryLeaseResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryLeaseResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.lease = Lease.decode(reader, reader.uint32()); + break; + case 2: + message.escrowPayment = FractionalPayment.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryLeaseResponse { + const obj = createBaseQueryLeaseResponse(); + if (isSet(object.lease)) obj.lease = Lease.fromJSON(object.lease); + if (isSet(object.escrowPayment)) obj.escrowPayment = FractionalPayment.fromJSON(object.escrowPayment); + return obj; + }, + toJSON(message: QueryLeaseResponse): JsonSafe { + const obj: any = {}; + message.lease !== undefined && (obj.lease = message.lease ? Lease.toJSON(message.lease) : undefined); + message.escrowPayment !== undefined && (obj.escrowPayment = message.escrowPayment ? FractionalPayment.toJSON(message.escrowPayment) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryLeaseResponse { + const message = createBaseQueryLeaseResponse(); + if (object.lease !== undefined && object.lease !== null) { + message.lease = Lease.fromPartial(object.lease); + } + if (object.escrowPayment !== undefined && object.escrowPayment !== null) { + message.escrowPayment = FractionalPayment.fromPartial(object.escrowPayment); + } + return message; + }, + fromSDK(object: QueryLeaseResponseSDKType): QueryLeaseResponse { + return { + lease: object.lease ? Lease.fromSDK(object.lease) : undefined, + escrowPayment: object.escrow_payment ? FractionalPayment.fromSDK(object.escrow_payment) : undefined + }; + }, + fromSDKJSON(object: any): QueryLeaseResponseSDKType { + return { + lease: isSet(object.lease) ? Lease.fromSDKJSON(object.lease) : undefined, + escrow_payment: isSet(object.escrow_payment) ? FractionalPayment.fromSDKJSON(object.escrow_payment) : undefined + }; + }, + toSDK(message: QueryLeaseResponse): QueryLeaseResponseSDKType { + const obj: any = {}; + message.lease !== undefined && (obj.lease = message.lease ? Lease.toSDK(message.lease) : undefined); + message.escrowPayment !== undefined && (obj.escrow_payment = message.escrowPayment ? FractionalPayment.toSDK(message.escrowPayment) : undefined); + return obj; + }, + fromAmino(object: QueryLeaseResponseAmino): QueryLeaseResponse { + const message = createBaseQueryLeaseResponse(); + if (object.lease !== undefined && object.lease !== null) { + message.lease = Lease.fromAmino(object.lease); + } + if (object.escrow_payment !== undefined && object.escrow_payment !== null) { + message.escrowPayment = FractionalPayment.fromAmino(object.escrow_payment); + } + return message; + }, + toAmino(message: QueryLeaseResponse): QueryLeaseResponseAmino { + const obj: any = {}; + obj.lease = message.lease ? Lease.toAmino(message.lease) : undefined; + obj.escrow_payment = message.escrowPayment ? FractionalPayment.toAmino(message.escrowPayment) : undefined; + return obj; + }, + fromAminoMsg(object: QueryLeaseResponseAminoMsg): QueryLeaseResponse { + return QueryLeaseResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryLeaseResponse): QueryLeaseResponseAminoMsg { + return { + type: "akash/market/v1beta2/query-lease-response", + value: QueryLeaseResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryLeaseResponseProtoMsg): QueryLeaseResponse { + return QueryLeaseResponse.decode(message.value); + }, + toProto(message: QueryLeaseResponse): Uint8Array { + return QueryLeaseResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryLeaseResponse): QueryLeaseResponseProtoMsg { + return { + typeUrl: "/akash.market.v1beta2.QueryLeaseResponse", + value: QueryLeaseResponse.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/market/v1beta2/service.amino.ts b/__fixtures__/v-next/outputicjsdeps/akash/market/v1beta2/service.amino.ts new file mode 100644 index 0000000000..23527977b4 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/market/v1beta2/service.amino.ts @@ -0,0 +1,243 @@ +/* eslint-disable */ +import { OrderID, OrderIDSDKType } from "./order.js"; +import { DecCoin, DecCoinSDKType, Coin, CoinSDKType } from "../../../cosmos/base/v1beta1/coin.js"; +import { BidID, BidIDSDKType, MsgCreateBid, MsgCreateBidSDKType, MsgCloseBid, MsgCloseBidSDKType } from "./bid.js"; +import { LeaseID, LeaseIDSDKType, MsgWithdrawLease, MsgWithdrawLeaseSDKType, MsgCreateLease, MsgCreateLeaseSDKType, MsgCloseLease, MsgCloseLeaseSDKType } from "./lease.js"; +import { ReadOnlyAminoMsg as AminoMsg } from "@interchainjs/ReadOnlyAminoMsg"; +export interface MsgCreateBidAminoType extends AminoMsg { + type: "akash/market/v1beta2/testonly-create-bid"; + value: { + order: { + owner: string; + dseq: string; + gseq: number; + oseq: number; + }; + provider: string; + price: { + denom: string; + amount: string; + }; + deposit: { + denom: string; + amount: string; + }; + }; +} +export interface MsgCloseBidAminoType extends AminoMsg { + type: "akash/market/v1beta2/testonly-close-bid"; + value: { + bid_id: { + owner: string; + dseq: string; + gseq: number; + oseq: number; + provider: string; + }; + }; +} +export interface MsgWithdrawLeaseAminoType extends AminoMsg { + type: "akash/market/v1beta2/testonly-withdraw-lease"; + value: { + bid_id: { + owner: string; + dseq: string; + gseq: number; + oseq: number; + provider: string; + }; + }; +} +export interface MsgCreateLeaseAminoType extends AminoMsg { + type: "akash/market/v1beta2/testonly-create-lease"; + value: { + bid_id: { + owner: string; + dseq: string; + gseq: number; + oseq: number; + provider: string; + }; + }; +} +export interface MsgCloseLeaseAminoType extends AminoMsg { + type: "akash/market/v1beta2/testonly-close-lease"; + value: { + lease_id: { + owner: string; + dseq: string; + gseq: number; + oseq: number; + provider: string; + }; + }; +} +export const AminoConverter = { + "/akash.market.v1beta2.MsgCreateBid": { + aminoType: "akash/market/v1beta2/testonly-create-bid", + toAmino: ({ + order, + provider, + price, + deposit + }: MsgCreateBid): MsgCreateBidAminoType["value"] => { + return { + order: { + owner: order.owner, + dseq: order.dseq.toString(), + gseq: order.gseq, + oseq: order.oseq + }, + provider, + price: { + denom: price.denom, + amount: price.amount + }, + deposit: { + denom: deposit.denom, + amount: deposit.amount + } + }; + }, + fromAmino: ({ + order, + provider, + price, + deposit + }: MsgCreateBidAminoType["value"]): MsgCreateBid => { + return { + order: { + owner: order.owner, + dseq: BigInt(order.dseq), + gseq: order.gseq, + oseq: order.oseq + }, + provider, + price: { + denom: price.denom, + amount: price.amount + }, + deposit: { + denom: deposit.denom, + amount: deposit.amount + } + }; + } + }, + "/akash.market.v1beta2.MsgCloseBid": { + aminoType: "akash/market/v1beta2/testonly-close-bid", + toAmino: ({ + bidId + }: MsgCloseBid): MsgCloseBidAminoType["value"] => { + return { + bid_id: { + owner: bidId.owner, + dseq: bidId.dseq.toString(), + gseq: bidId.gseq, + oseq: bidId.oseq, + provider: bidId.provider + } + }; + }, + fromAmino: ({ + bid_id + }: MsgCloseBidAminoType["value"]): MsgCloseBid => { + return { + bidId: { + owner: bid_id.owner, + dseq: BigInt(bid_id.dseq), + gseq: bid_id.gseq, + oseq: bid_id.oseq, + provider: bid_id.provider + } + }; + } + }, + "/akash.market.v1beta2.MsgWithdrawLease": { + aminoType: "akash/market/v1beta2/testonly-withdraw-lease", + toAmino: ({ + bidId + }: MsgWithdrawLease): MsgWithdrawLeaseAminoType["value"] => { + return { + bid_id: { + owner: bidId.owner, + dseq: bidId.dseq.toString(), + gseq: bidId.gseq, + oseq: bidId.oseq, + provider: bidId.provider + } + }; + }, + fromAmino: ({ + bid_id + }: MsgWithdrawLeaseAminoType["value"]): MsgWithdrawLease => { + return { + bidId: { + owner: bid_id.owner, + dseq: BigInt(bid_id.dseq), + gseq: bid_id.gseq, + oseq: bid_id.oseq, + provider: bid_id.provider + } + }; + } + }, + "/akash.market.v1beta2.MsgCreateLease": { + aminoType: "akash/market/v1beta2/testonly-create-lease", + toAmino: ({ + bidId + }: MsgCreateLease): MsgCreateLeaseAminoType["value"] => { + return { + bid_id: { + owner: bidId.owner, + dseq: bidId.dseq.toString(), + gseq: bidId.gseq, + oseq: bidId.oseq, + provider: bidId.provider + } + }; + }, + fromAmino: ({ + bid_id + }: MsgCreateLeaseAminoType["value"]): MsgCreateLease => { + return { + bidId: { + owner: bid_id.owner, + dseq: BigInt(bid_id.dseq), + gseq: bid_id.gseq, + oseq: bid_id.oseq, + provider: bid_id.provider + } + }; + } + }, + "/akash.market.v1beta2.MsgCloseLease": { + aminoType: "akash/market/v1beta2/testonly-close-lease", + toAmino: ({ + leaseId + }: MsgCloseLease): MsgCloseLeaseAminoType["value"] => { + return { + lease_id: { + owner: leaseId.owner, + dseq: leaseId.dseq.toString(), + gseq: leaseId.gseq, + oseq: leaseId.oseq, + provider: leaseId.provider + } + }; + }, + fromAmino: ({ + lease_id + }: MsgCloseLeaseAminoType["value"]): MsgCloseLease => { + return { + leaseId: { + owner: lease_id.owner, + dseq: BigInt(lease_id.dseq), + gseq: lease_id.gseq, + oseq: lease_id.oseq, + provider: lease_id.provider + } + }; + } + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/market/v1beta2/service.registry.ts b/__fixtures__/v-next/outputicjsdeps/akash/market/v1beta2/service.registry.ts new file mode 100644 index 0000000000..d53ce49797 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/market/v1beta2/service.registry.ts @@ -0,0 +1,173 @@ +import { OrderID, OrderIDSDKType } from "./order.js"; +import { DecCoin, DecCoinSDKType, Coin, CoinSDKType } from "../../../cosmos/base/v1beta1/coin.js"; +import { BidID, BidIDSDKType, MsgCreateBid, MsgCreateBidSDKType, MsgCloseBid, MsgCloseBidSDKType } from "./bid.js"; +import { LeaseID, LeaseIDSDKType, MsgWithdrawLease, MsgWithdrawLeaseSDKType, MsgCreateLease, MsgCreateLeaseSDKType, MsgCloseLease, MsgCloseLeaseSDKType } from "./lease.js"; +import { GeneratedType, Registry } from "@cosmjs/proto-signing"; +export const registry: ReadonlyArray<[string, GeneratedType]> = [["/akash.market.v1beta2.MsgCreateBid", MsgCreateBid], ["/akash.market.v1beta2.MsgCloseBid", MsgCloseBid], ["/akash.market.v1beta2.MsgWithdrawLease", MsgWithdrawLease], ["/akash.market.v1beta2.MsgCreateLease", MsgCreateLease], ["/akash.market.v1beta2.MsgCloseLease", MsgCloseLease]]; +export const load = (protoRegistry: Registry) => { + registry.forEach(([typeUrl, mod]) => { + protoRegistry.register(typeUrl, mod); + }); +}; +export const MessageComposer = { + encoded: { + createBid(value: MsgCreateBid) { + return { + typeUrl: "/akash.market.v1beta2.MsgCreateBid", + value: MsgCreateBid.encode(value).finish() + }; + }, + closeBid(value: MsgCloseBid) { + return { + typeUrl: "/akash.market.v1beta2.MsgCloseBid", + value: MsgCloseBid.encode(value).finish() + }; + }, + withdrawLease(value: MsgWithdrawLease) { + return { + typeUrl: "/akash.market.v1beta2.MsgWithdrawLease", + value: MsgWithdrawLease.encode(value).finish() + }; + }, + createLease(value: MsgCreateLease) { + return { + typeUrl: "/akash.market.v1beta2.MsgCreateLease", + value: MsgCreateLease.encode(value).finish() + }; + }, + closeLease(value: MsgCloseLease) { + return { + typeUrl: "/akash.market.v1beta2.MsgCloseLease", + value: MsgCloseLease.encode(value).finish() + }; + } + }, + withTypeUrl: { + createBid(value: MsgCreateBid) { + return { + typeUrl: "/akash.market.v1beta2.MsgCreateBid", + value + }; + }, + closeBid(value: MsgCloseBid) { + return { + typeUrl: "/akash.market.v1beta2.MsgCloseBid", + value + }; + }, + withdrawLease(value: MsgWithdrawLease) { + return { + typeUrl: "/akash.market.v1beta2.MsgWithdrawLease", + value + }; + }, + createLease(value: MsgCreateLease) { + return { + typeUrl: "/akash.market.v1beta2.MsgCreateLease", + value + }; + }, + closeLease(value: MsgCloseLease) { + return { + typeUrl: "/akash.market.v1beta2.MsgCloseLease", + value + }; + } + }, + toJSON: { + createBid(value: MsgCreateBid) { + return { + typeUrl: "/akash.market.v1beta2.MsgCreateBid", + value: MsgCreateBid.toJSON(value) + }; + }, + closeBid(value: MsgCloseBid) { + return { + typeUrl: "/akash.market.v1beta2.MsgCloseBid", + value: MsgCloseBid.toJSON(value) + }; + }, + withdrawLease(value: MsgWithdrawLease) { + return { + typeUrl: "/akash.market.v1beta2.MsgWithdrawLease", + value: MsgWithdrawLease.toJSON(value) + }; + }, + createLease(value: MsgCreateLease) { + return { + typeUrl: "/akash.market.v1beta2.MsgCreateLease", + value: MsgCreateLease.toJSON(value) + }; + }, + closeLease(value: MsgCloseLease) { + return { + typeUrl: "/akash.market.v1beta2.MsgCloseLease", + value: MsgCloseLease.toJSON(value) + }; + } + }, + fromJSON: { + createBid(value: any) { + return { + typeUrl: "/akash.market.v1beta2.MsgCreateBid", + value: MsgCreateBid.fromJSON(value) + }; + }, + closeBid(value: any) { + return { + typeUrl: "/akash.market.v1beta2.MsgCloseBid", + value: MsgCloseBid.fromJSON(value) + }; + }, + withdrawLease(value: any) { + return { + typeUrl: "/akash.market.v1beta2.MsgWithdrawLease", + value: MsgWithdrawLease.fromJSON(value) + }; + }, + createLease(value: any) { + return { + typeUrl: "/akash.market.v1beta2.MsgCreateLease", + value: MsgCreateLease.fromJSON(value) + }; + }, + closeLease(value: any) { + return { + typeUrl: "/akash.market.v1beta2.MsgCloseLease", + value: MsgCloseLease.fromJSON(value) + }; + } + }, + fromPartial: { + createBid(value: MsgCreateBid) { + return { + typeUrl: "/akash.market.v1beta2.MsgCreateBid", + value: MsgCreateBid.fromPartial(value) + }; + }, + closeBid(value: MsgCloseBid) { + return { + typeUrl: "/akash.market.v1beta2.MsgCloseBid", + value: MsgCloseBid.fromPartial(value) + }; + }, + withdrawLease(value: MsgWithdrawLease) { + return { + typeUrl: "/akash.market.v1beta2.MsgWithdrawLease", + value: MsgWithdrawLease.fromPartial(value) + }; + }, + createLease(value: MsgCreateLease) { + return { + typeUrl: "/akash.market.v1beta2.MsgCreateLease", + value: MsgCreateLease.fromPartial(value) + }; + }, + closeLease(value: MsgCloseLease) { + return { + typeUrl: "/akash.market.v1beta2.MsgCloseLease", + value: MsgCloseLease.fromPartial(value) + }; + } + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/market/v1beta2/service.rpc.func.ts b/__fixtures__/v-next/outputicjsdeps/akash/market/v1beta2/service.rpc.func.ts new file mode 100644 index 0000000000..6353b66e4d --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/market/v1beta2/service.rpc.func.ts @@ -0,0 +1,50 @@ +import { MsgCreateBid, MsgCloseBid } from "./bid"; +import { MsgWithdrawLease, MsgCreateLease, MsgCloseLease } from "./lease"; +import { buildTx, SigningClientResolver } from "../../../helper-func-types"; +import { buildUseMutation } from "../../../react-query"; +import { toEncoders, toConverters } from "@interchainjs/cosmos/utils"; +export const createCreateBid = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgCreateBid.typeUrl, + encoders: toEncoders(MsgCreateBid), + converters: toConverters(MsgCreateBid) +}); +export const useCreateBid = buildUseMutation({ + builderMutationFn: createCreateBid +}); +export const createCloseBid = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgCloseBid.typeUrl, + encoders: toEncoders(MsgCloseBid), + converters: toConverters(MsgCloseBid) +}); +export const useCloseBid = buildUseMutation({ + builderMutationFn: createCloseBid +}); +export const createWithdrawLease = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgWithdrawLease.typeUrl, + encoders: toEncoders(MsgWithdrawLease), + converters: toConverters(MsgWithdrawLease) +}); +export const useWithdrawLease = buildUseMutation({ + builderMutationFn: createWithdrawLease +}); +export const createCreateLease = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgCreateLease.typeUrl, + encoders: toEncoders(MsgCreateLease), + converters: toConverters(MsgCreateLease) +}); +export const useCreateLease = buildUseMutation({ + builderMutationFn: createCreateLease +}); +export const createCloseLease = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgCloseLease.typeUrl, + encoders: toEncoders(MsgCloseLease), + converters: toConverters(MsgCloseLease) +}); +export const useCloseLease = buildUseMutation({ + builderMutationFn: createCloseLease +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/market/v1beta2/service.rpc.msg.ts b/__fixtures__/v-next/outputicjsdeps/akash/market/v1beta2/service.rpc.msg.ts new file mode 100644 index 0000000000..d260ba1c81 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/market/v1beta2/service.rpc.msg.ts @@ -0,0 +1,58 @@ +import { OrderID, OrderIDSDKType } from "./order.js"; +import { DecCoin, DecCoinSDKType, Coin, CoinSDKType } from "../../../cosmos/base/v1beta1/coin.js"; +import { BidID, BidIDSDKType, MsgCreateBid, MsgCreateBidSDKType, MsgCreateBidResponse, MsgCreateBidResponseSDKType, MsgCloseBid, MsgCloseBidSDKType, MsgCloseBidResponse, MsgCloseBidResponseSDKType } from "./bid.js"; +import { LeaseID, LeaseIDSDKType, MsgWithdrawLease, MsgWithdrawLeaseSDKType, MsgWithdrawLeaseResponse, MsgWithdrawLeaseResponseSDKType, MsgCreateLease, MsgCreateLeaseSDKType, MsgCreateLeaseResponse, MsgCreateLeaseResponseSDKType, MsgCloseLease, MsgCloseLeaseSDKType, MsgCloseLeaseResponse, MsgCloseLeaseResponseSDKType } from "./lease.js"; +import { Rpc } from "../../../helpers.js"; +import { BinaryReader } from "../../../binary.js"; +/** Msg defines the market Msg service */ +export interface Msg { + /** CreateBid defines a method to create a bid given proper inputs. */ + createBid(request: MsgCreateBid): Promise; + /** CloseBid defines a method to close a bid given proper inputs. */ + closeBid(request: MsgCloseBid): Promise; + /** WithdrawLease withdraws accrued funds from the lease payment */ + withdrawLease(request: MsgWithdrawLease): Promise; + /** CreateLease creates a new lease */ + createLease(request: MsgCreateLease): Promise; + /** CloseLease defines a method to close an order given proper inputs. */ + closeLease(request: MsgCloseLease): Promise; +} +export class MsgClientImpl implements Msg { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + } + /* CreateBid defines a method to create a bid given proper inputs. */ + createBid = async (request: MsgCreateBid): Promise => { + const data = MsgCreateBid.encode(request).finish(); + const promise = this.rpc.request("akash.market.v1beta2.Msg", "CreateBid", data); + return promise.then(data => MsgCreateBidResponse.decode(new BinaryReader(data))); + }; + /* CloseBid defines a method to close a bid given proper inputs. */ + closeBid = async (request: MsgCloseBid): Promise => { + const data = MsgCloseBid.encode(request).finish(); + const promise = this.rpc.request("akash.market.v1beta2.Msg", "CloseBid", data); + return promise.then(data => MsgCloseBidResponse.decode(new BinaryReader(data))); + }; + /* WithdrawLease withdraws accrued funds from the lease payment */ + withdrawLease = async (request: MsgWithdrawLease): Promise => { + const data = MsgWithdrawLease.encode(request).finish(); + const promise = this.rpc.request("akash.market.v1beta2.Msg", "WithdrawLease", data); + return promise.then(data => MsgWithdrawLeaseResponse.decode(new BinaryReader(data))); + }; + /* CreateLease creates a new lease */ + createLease = async (request: MsgCreateLease): Promise => { + const data = MsgCreateLease.encode(request).finish(); + const promise = this.rpc.request("akash.market.v1beta2.Msg", "CreateLease", data); + return promise.then(data => MsgCreateLeaseResponse.decode(new BinaryReader(data))); + }; + /* CloseLease defines a method to close an order given proper inputs. */ + closeLease = async (request: MsgCloseLease): Promise => { + const data = MsgCloseLease.encode(request).finish(); + const promise = this.rpc.request("akash.market.v1beta2.Msg", "CloseLease", data); + return promise.then(data => MsgCloseLeaseResponse.decode(new BinaryReader(data))); + }; +} +export const createClientImpl = (rpc: Rpc) => { + return new MsgClientImpl(rpc); +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/market/v1beta2/service.ts b/__fixtures__/v-next/outputicjsdeps/akash/market/v1beta2/service.ts new file mode 100644 index 0000000000..693da49fc4 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/market/v1beta2/service.ts @@ -0,0 +1 @@ +export {} \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/provider/v1beta1/provider.amino.ts b/__fixtures__/v-next/outputicjsdeps/akash/provider/v1beta1/provider.amino.ts new file mode 100644 index 0000000000..edc2e41200 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/provider/v1beta1/provider.amino.ts @@ -0,0 +1,141 @@ +/* eslint-disable */ +import { Attribute, AttributeSDKType } from "../../base/v1beta1/attribute.js"; +import { ReadOnlyAminoMsg as AminoMsg } from "@interchainjs/ReadOnlyAminoMsg"; +import { ProviderInfo, ProviderInfoSDKType, MsgCreateProvider, MsgCreateProviderSDKType, MsgUpdateProvider, MsgUpdateProviderSDKType, MsgDeleteProvider, MsgDeleteProviderSDKType } from "./provider.js"; +export interface MsgCreateProviderAminoType extends AminoMsg { + type: "akash/provider/testonly-create-provider"; + value: { + owner: string; + host_uri: string; + attributes: { + key: string; + value: string; + }[]; + info: { + email: string; + website: string; + }; + }; +} +export interface MsgUpdateProviderAminoType extends AminoMsg { + type: "akash/provider/testonly-update-provider"; + value: { + owner: string; + host_uri: string; + attributes: { + key: string; + value: string; + }[]; + info: { + email: string; + website: string; + }; + }; +} +export interface MsgDeleteProviderAminoType extends AminoMsg { + type: "akash/provider/testonly-delete-provider"; + value: { + owner: string; + }; +} +export const AminoConverter = { + "/akash.provider.v1beta1.MsgCreateProvider": { + aminoType: "akash/provider/testonly-create-provider", + toAmino: ({ + owner, + hostUri, + attributes, + info + }: MsgCreateProvider): MsgCreateProviderAminoType["value"] => { + return { + owner, + host_uri: hostUri, + attributes: attributes.map(el0 => ({ + key: el0.key, + value: el0.value + })), + info: { + email: info.email, + website: info.website + } + }; + }, + fromAmino: ({ + owner, + host_uri, + attributes, + info + }: MsgCreateProviderAminoType["value"]): MsgCreateProvider => { + return { + owner, + hostUri: host_uri, + attributes: attributes.map(el0 => ({ + key: el0.key, + value: el0.value + })), + info: { + email: info.email, + website: info.website + } + }; + } + }, + "/akash.provider.v1beta1.MsgUpdateProvider": { + aminoType: "akash/provider/testonly-update-provider", + toAmino: ({ + owner, + hostUri, + attributes, + info + }: MsgUpdateProvider): MsgUpdateProviderAminoType["value"] => { + return { + owner, + host_uri: hostUri, + attributes: attributes.map(el0 => ({ + key: el0.key, + value: el0.value + })), + info: { + email: info.email, + website: info.website + } + }; + }, + fromAmino: ({ + owner, + host_uri, + attributes, + info + }: MsgUpdateProviderAminoType["value"]): MsgUpdateProvider => { + return { + owner, + hostUri: host_uri, + attributes: attributes.map(el0 => ({ + key: el0.key, + value: el0.value + })), + info: { + email: info.email, + website: info.website + } + }; + } + }, + "/akash.provider.v1beta1.MsgDeleteProvider": { + aminoType: "akash/provider/testonly-delete-provider", + toAmino: ({ + owner + }: MsgDeleteProvider): MsgDeleteProviderAminoType["value"] => { + return { + owner + }; + }, + fromAmino: ({ + owner + }: MsgDeleteProviderAminoType["value"]): MsgDeleteProvider => { + return { + owner + }; + } + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/provider/v1beta1/provider.registry.ts b/__fixtures__/v-next/outputicjsdeps/akash/provider/v1beta1/provider.registry.ts new file mode 100644 index 0000000000..db9a938abf --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/provider/v1beta1/provider.registry.ts @@ -0,0 +1,111 @@ +import { Attribute, AttributeSDKType } from "../../base/v1beta1/attribute.js"; +import { GeneratedType, Registry } from "@cosmjs/proto-signing"; +import { MsgCreateProvider, MsgCreateProviderSDKType, MsgUpdateProvider, MsgUpdateProviderSDKType, MsgDeleteProvider, MsgDeleteProviderSDKType } from "./provider.js"; +export const registry: ReadonlyArray<[string, GeneratedType]> = [["/akash.provider.v1beta1.MsgCreateProvider", MsgCreateProvider], ["/akash.provider.v1beta1.MsgUpdateProvider", MsgUpdateProvider], ["/akash.provider.v1beta1.MsgDeleteProvider", MsgDeleteProvider]]; +export const load = (protoRegistry: Registry) => { + registry.forEach(([typeUrl, mod]) => { + protoRegistry.register(typeUrl, mod); + }); +}; +export const MessageComposer = { + encoded: { + createProvider(value: MsgCreateProvider) { + return { + typeUrl: "/akash.provider.v1beta1.MsgCreateProvider", + value: MsgCreateProvider.encode(value).finish() + }; + }, + updateProvider(value: MsgUpdateProvider) { + return { + typeUrl: "/akash.provider.v1beta1.MsgUpdateProvider", + value: MsgUpdateProvider.encode(value).finish() + }; + }, + deleteProvider(value: MsgDeleteProvider) { + return { + typeUrl: "/akash.provider.v1beta1.MsgDeleteProvider", + value: MsgDeleteProvider.encode(value).finish() + }; + } + }, + withTypeUrl: { + createProvider(value: MsgCreateProvider) { + return { + typeUrl: "/akash.provider.v1beta1.MsgCreateProvider", + value + }; + }, + updateProvider(value: MsgUpdateProvider) { + return { + typeUrl: "/akash.provider.v1beta1.MsgUpdateProvider", + value + }; + }, + deleteProvider(value: MsgDeleteProvider) { + return { + typeUrl: "/akash.provider.v1beta1.MsgDeleteProvider", + value + }; + } + }, + toJSON: { + createProvider(value: MsgCreateProvider) { + return { + typeUrl: "/akash.provider.v1beta1.MsgCreateProvider", + value: MsgCreateProvider.toJSON(value) + }; + }, + updateProvider(value: MsgUpdateProvider) { + return { + typeUrl: "/akash.provider.v1beta1.MsgUpdateProvider", + value: MsgUpdateProvider.toJSON(value) + }; + }, + deleteProvider(value: MsgDeleteProvider) { + return { + typeUrl: "/akash.provider.v1beta1.MsgDeleteProvider", + value: MsgDeleteProvider.toJSON(value) + }; + } + }, + fromJSON: { + createProvider(value: any) { + return { + typeUrl: "/akash.provider.v1beta1.MsgCreateProvider", + value: MsgCreateProvider.fromJSON(value) + }; + }, + updateProvider(value: any) { + return { + typeUrl: "/akash.provider.v1beta1.MsgUpdateProvider", + value: MsgUpdateProvider.fromJSON(value) + }; + }, + deleteProvider(value: any) { + return { + typeUrl: "/akash.provider.v1beta1.MsgDeleteProvider", + value: MsgDeleteProvider.fromJSON(value) + }; + } + }, + fromPartial: { + createProvider(value: MsgCreateProvider) { + return { + typeUrl: "/akash.provider.v1beta1.MsgCreateProvider", + value: MsgCreateProvider.fromPartial(value) + }; + }, + updateProvider(value: MsgUpdateProvider) { + return { + typeUrl: "/akash.provider.v1beta1.MsgUpdateProvider", + value: MsgUpdateProvider.fromPartial(value) + }; + }, + deleteProvider(value: MsgDeleteProvider) { + return { + typeUrl: "/akash.provider.v1beta1.MsgDeleteProvider", + value: MsgDeleteProvider.fromPartial(value) + }; + } + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/provider/v1beta1/provider.rpc.func.ts b/__fixtures__/v-next/outputicjsdeps/akash/provider/v1beta1/provider.rpc.func.ts new file mode 100644 index 0000000000..62c9ef6bba --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/provider/v1beta1/provider.rpc.func.ts @@ -0,0 +1,31 @@ +import { buildTx, SigningClientResolver } from "../../../helper-func-types"; +import { buildUseMutation } from "../../../react-query"; +import { toEncoders, toConverters } from "@interchainjs/cosmos/utils"; +import { MsgCreateProvider, MsgUpdateProvider, MsgDeleteProvider } from "./provider"; +export const createCreateProvider = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgCreateProvider.typeUrl, + encoders: toEncoders(MsgCreateProvider), + converters: toConverters(MsgCreateProvider) +}); +export const useCreateProvider = buildUseMutation({ + builderMutationFn: createCreateProvider +}); +export const createUpdateProvider = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgUpdateProvider.typeUrl, + encoders: toEncoders(MsgUpdateProvider), + converters: toConverters(MsgUpdateProvider) +}); +export const useUpdateProvider = buildUseMutation({ + builderMutationFn: createUpdateProvider +}); +export const createDeleteProvider = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgDeleteProvider.typeUrl, + encoders: toEncoders(MsgDeleteProvider), + converters: toConverters(MsgDeleteProvider) +}); +export const useDeleteProvider = buildUseMutation({ + builderMutationFn: createDeleteProvider +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/provider/v1beta1/provider.rpc.msg.ts b/__fixtures__/v-next/outputicjsdeps/akash/provider/v1beta1/provider.rpc.msg.ts new file mode 100644 index 0000000000..5673771a18 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/provider/v1beta1/provider.rpc.msg.ts @@ -0,0 +1,40 @@ +import { Attribute, AttributeSDKType } from "../../base/v1beta1/attribute.js"; +import { Rpc } from "../../../helpers.js"; +import { BinaryReader } from "../../../binary.js"; +import { MsgCreateProvider, MsgCreateProviderSDKType, MsgCreateProviderResponse, MsgCreateProviderResponseSDKType, MsgUpdateProvider, MsgUpdateProviderSDKType, MsgUpdateProviderResponse, MsgUpdateProviderResponseSDKType, MsgDeleteProvider, MsgDeleteProviderSDKType, MsgDeleteProviderResponse, MsgDeleteProviderResponseSDKType } from "./provider.js"; +/** Msg defines the provider Msg service */ +export interface Msg { + /** CreateProvider defines a method that creates a provider given the proper inputs */ + createProvider(request: MsgCreateProvider): Promise; + /** UpdateProvider defines a method that updates a provider given the proper inputs */ + updateProvider(request: MsgUpdateProvider): Promise; + /** DeleteProvider defines a method that deletes a provider given the proper inputs */ + deleteProvider(request: MsgDeleteProvider): Promise; +} +export class MsgClientImpl implements Msg { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + } + /* CreateProvider defines a method that creates a provider given the proper inputs */ + createProvider = async (request: MsgCreateProvider): Promise => { + const data = MsgCreateProvider.encode(request).finish(); + const promise = this.rpc.request("akash.provider.v1beta1.Msg", "CreateProvider", data); + return promise.then(data => MsgCreateProviderResponse.decode(new BinaryReader(data))); + }; + /* UpdateProvider defines a method that updates a provider given the proper inputs */ + updateProvider = async (request: MsgUpdateProvider): Promise => { + const data = MsgUpdateProvider.encode(request).finish(); + const promise = this.rpc.request("akash.provider.v1beta1.Msg", "UpdateProvider", data); + return promise.then(data => MsgUpdateProviderResponse.decode(new BinaryReader(data))); + }; + /* DeleteProvider defines a method that deletes a provider given the proper inputs */ + deleteProvider = async (request: MsgDeleteProvider): Promise => { + const data = MsgDeleteProvider.encode(request).finish(); + const promise = this.rpc.request("akash.provider.v1beta1.Msg", "DeleteProvider", data); + return promise.then(data => MsgDeleteProviderResponse.decode(new BinaryReader(data))); + }; +} +export const createClientImpl = (rpc: Rpc) => { + return new MsgClientImpl(rpc); +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/provider/v1beta1/provider.ts b/__fixtures__/v-next/outputicjsdeps/akash/provider/v1beta1/provider.ts new file mode 100644 index 0000000000..5625191cf3 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/provider/v1beta1/provider.ts @@ -0,0 +1,1007 @@ +import { Attribute, AttributeSDKType } from "../../base/v1beta1/attribute.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial, Exact } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "akash.provider.v1beta1"; +/** ProviderInfo */ +export interface ProviderInfo { + email: string; + website: string; +} +export interface ProviderInfoProtoMsg { + typeUrl: "/akash.provider.v1beta1.ProviderInfo"; + value: Uint8Array; +} +/** ProviderInfo */ +export interface ProviderInfoSDKType { + email: string; + website: string; +} +/** MsgCreateProvider defines an SDK message for creating a provider */ +export interface MsgCreateProvider { + owner: string; + hostUri: string; + attributes: Attribute[]; + info: ProviderInfo; +} +export interface MsgCreateProviderProtoMsg { + typeUrl: "/akash.provider.v1beta1.MsgCreateProvider"; + value: Uint8Array; +} +/** MsgCreateProvider defines an SDK message for creating a provider */ +export interface MsgCreateProviderSDKType { + owner: string; + host_uri: string; + attributes: AttributeSDKType[]; + info: ProviderInfoSDKType; +} +/** MsgCreateProviderResponse defines the Msg/CreateProvider response type. */ +export interface MsgCreateProviderResponse {} +export interface MsgCreateProviderResponseProtoMsg { + typeUrl: "/akash.provider.v1beta1.MsgCreateProviderResponse"; + value: Uint8Array; +} +/** MsgCreateProviderResponse defines the Msg/CreateProvider response type. */ +export interface MsgCreateProviderResponseSDKType {} +/** MsgUpdateProvider defines an SDK message for updating a provider */ +export interface MsgUpdateProvider { + owner: string; + hostUri: string; + attributes: Attribute[]; + info: ProviderInfo; +} +export interface MsgUpdateProviderProtoMsg { + typeUrl: "/akash.provider.v1beta1.MsgUpdateProvider"; + value: Uint8Array; +} +/** MsgUpdateProvider defines an SDK message for updating a provider */ +export interface MsgUpdateProviderSDKType { + owner: string; + host_uri: string; + attributes: AttributeSDKType[]; + info: ProviderInfoSDKType; +} +/** MsgUpdateProviderResponse defines the Msg/UpdateProvider response type. */ +export interface MsgUpdateProviderResponse {} +export interface MsgUpdateProviderResponseProtoMsg { + typeUrl: "/akash.provider.v1beta1.MsgUpdateProviderResponse"; + value: Uint8Array; +} +/** MsgUpdateProviderResponse defines the Msg/UpdateProvider response type. */ +export interface MsgUpdateProviderResponseSDKType {} +/** MsgDeleteProvider defines an SDK message for deleting a provider */ +export interface MsgDeleteProvider { + owner: string; +} +export interface MsgDeleteProviderProtoMsg { + typeUrl: "/akash.provider.v1beta1.MsgDeleteProvider"; + value: Uint8Array; +} +/** MsgDeleteProvider defines an SDK message for deleting a provider */ +export interface MsgDeleteProviderSDKType { + owner: string; +} +/** MsgDeleteProviderResponse defines the Msg/DeleteProvider response type. */ +export interface MsgDeleteProviderResponse {} +export interface MsgDeleteProviderResponseProtoMsg { + typeUrl: "/akash.provider.v1beta1.MsgDeleteProviderResponse"; + value: Uint8Array; +} +/** MsgDeleteProviderResponse defines the Msg/DeleteProvider response type. */ +export interface MsgDeleteProviderResponseSDKType {} +/** Provider stores owner and host details */ +export interface Provider { + owner: string; + hostUri: string; + attributes: Attribute[]; + info: ProviderInfo; +} +export interface ProviderProtoMsg { + typeUrl: "/akash.provider.v1beta1.Provider"; + value: Uint8Array; +} +/** Provider stores owner and host details */ +export interface ProviderSDKType { + owner: string; + host_uri: string; + attributes: AttributeSDKType[]; + info: ProviderInfoSDKType; +} +function createBaseProviderInfo(): ProviderInfo { + return { + email: "", + website: "" + }; +} +export const ProviderInfo = { + typeUrl: "/akash.provider.v1beta1.ProviderInfo", + encode(message: ProviderInfo, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.email !== undefined) { + writer.uint32(10).string(message.email); + } + if (message.website !== undefined) { + writer.uint32(18).string(message.website); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ProviderInfo { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseProviderInfo(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.email = reader.string(); + break; + case 2: + message.website = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ProviderInfo { + const obj = createBaseProviderInfo(); + if (isSet(object.email)) obj.email = String(object.email); + if (isSet(object.website)) obj.website = String(object.website); + return obj; + }, + toJSON(message: ProviderInfo): JsonSafe { + const obj: any = {}; + message.email !== undefined && (obj.email = message.email); + message.website !== undefined && (obj.website = message.website); + return obj; + }, + fromPartial, I>>(object: I): ProviderInfo { + const message = createBaseProviderInfo(); + message.email = object.email ?? ""; + message.website = object.website ?? ""; + return message; + }, + fromSDK(object: ProviderInfoSDKType): ProviderInfo { + return { + email: object?.email, + website: object?.website + }; + }, + fromSDKJSON(object: any): ProviderInfoSDKType { + return { + email: isSet(object.email) ? String(object.email) : "", + website: isSet(object.website) ? String(object.website) : "" + }; + }, + toSDK(message: ProviderInfo): ProviderInfoSDKType { + const obj: any = {}; + obj.email = message.email; + obj.website = message.website; + return obj; + }, + fromAmino(object: ProviderInfoAmino): ProviderInfo { + const message = createBaseProviderInfo(); + if (object.email !== undefined && object.email !== null) { + message.email = object.email; + } + if (object.website !== undefined && object.website !== null) { + message.website = object.website; + } + return message; + }, + toAmino(message: ProviderInfo): ProviderInfoAmino { + const obj: any = {}; + obj.email = message.email ?? ""; + obj.website = message.website ?? ""; + return obj; + }, + fromAminoMsg(object: ProviderInfoAminoMsg): ProviderInfo { + return ProviderInfo.fromAmino(object.value); + }, + toAminoMsg(message: ProviderInfo): ProviderInfoAminoMsg { + return { + type: "akash/provider/provider-info", + value: ProviderInfo.toAmino(message) + }; + }, + fromProtoMsg(message: ProviderInfoProtoMsg): ProviderInfo { + return ProviderInfo.decode(message.value); + }, + toProto(message: ProviderInfo): Uint8Array { + return ProviderInfo.encode(message).finish(); + }, + toProtoMsg(message: ProviderInfo): ProviderInfoProtoMsg { + return { + typeUrl: "/akash.provider.v1beta1.ProviderInfo", + value: ProviderInfo.encode(message).finish() + }; + } +}; +function createBaseMsgCreateProvider(): MsgCreateProvider { + return { + owner: "", + hostUri: "", + attributes: [], + info: ProviderInfo.fromPartial({}) + }; +} +export const MsgCreateProvider = { + typeUrl: "/akash.provider.v1beta1.MsgCreateProvider", + encode(message: MsgCreateProvider, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.owner !== undefined) { + writer.uint32(10).string(message.owner); + } + if (message.hostUri !== undefined) { + writer.uint32(18).string(message.hostUri); + } + for (const v of message.attributes) { + Attribute.encode(v!, writer.uint32(26).fork()).ldelim(); + } + if (message.info !== undefined) { + ProviderInfo.encode(message.info, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgCreateProvider { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgCreateProvider(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.owner = reader.string(); + break; + case 2: + message.hostUri = reader.string(); + break; + case 3: + message.attributes.push(Attribute.decode(reader, reader.uint32())); + break; + case 4: + message.info = ProviderInfo.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgCreateProvider { + const obj = createBaseMsgCreateProvider(); + if (isSet(object.owner)) obj.owner = String(object.owner); + if (isSet(object.hostUri)) obj.hostUri = String(object.hostUri); + if (Array.isArray(object?.attributes)) obj.attributes = object.attributes.map((e: any) => Attribute.fromJSON(e)); + if (isSet(object.info)) obj.info = ProviderInfo.fromJSON(object.info); + return obj; + }, + toJSON(message: MsgCreateProvider): JsonSafe { + const obj: any = {}; + message.owner !== undefined && (obj.owner = message.owner); + message.hostUri !== undefined && (obj.hostUri = message.hostUri); + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? Attribute.toJSON(e) : undefined); + } else { + obj.attributes = []; + } + message.info !== undefined && (obj.info = message.info ? ProviderInfo.toJSON(message.info) : undefined); + return obj; + }, + fromPartial, I>>(object: I): MsgCreateProvider { + const message = createBaseMsgCreateProvider(); + message.owner = object.owner ?? ""; + message.hostUri = object.hostUri ?? ""; + message.attributes = object.attributes?.map(e => Attribute.fromPartial(e)) || []; + if (object.info !== undefined && object.info !== null) { + message.info = ProviderInfo.fromPartial(object.info); + } + return message; + }, + fromSDK(object: MsgCreateProviderSDKType): MsgCreateProvider { + return { + owner: object?.owner, + hostUri: object?.host_uri, + attributes: Array.isArray(object?.attributes) ? object.attributes.map((e: any) => Attribute.fromSDK(e)) : [], + info: object.info ? ProviderInfo.fromSDK(object.info) : undefined + }; + }, + fromSDKJSON(object: any): MsgCreateProviderSDKType { + return { + owner: isSet(object.owner) ? String(object.owner) : "", + host_uri: isSet(object.host_uri) ? String(object.host_uri) : "", + attributes: Array.isArray(object?.attributes) ? object.attributes.map((e: any) => Attribute.fromSDKJSON(e)) : [], + info: isSet(object.info) ? ProviderInfo.fromSDKJSON(object.info) : undefined + }; + }, + toSDK(message: MsgCreateProvider): MsgCreateProviderSDKType { + const obj: any = {}; + obj.owner = message.owner; + obj.host_uri = message.hostUri; + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? Attribute.toSDK(e) : undefined); + } else { + obj.attributes = []; + } + message.info !== undefined && (obj.info = message.info ? ProviderInfo.toSDK(message.info) : undefined); + return obj; + }, + fromAmino(object: MsgCreateProviderAmino): MsgCreateProvider { + const message = createBaseMsgCreateProvider(); + if (object.owner !== undefined && object.owner !== null) { + message.owner = object.owner; + } + if (object.host_uri !== undefined && object.host_uri !== null) { + message.hostUri = object.host_uri; + } + message.attributes = object.attributes?.map(e => Attribute.fromAmino(e)) || []; + if (object.info !== undefined && object.info !== null) { + message.info = ProviderInfo.fromAmino(object.info); + } + return message; + }, + toAmino(message: MsgCreateProvider): MsgCreateProviderAmino { + const obj: any = {}; + obj.owner = message.owner ?? ""; + obj.host_uri = message.hostUri ?? ""; + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? Attribute.toAmino(e) : undefined); + } else { + obj.attributes = message.attributes; + } + obj.info = message.info ? ProviderInfo.toAmino(message.info) : ProviderInfo.toAmino(ProviderInfo.fromPartial({})); + return obj; + }, + fromAminoMsg(object: MsgCreateProviderAminoMsg): MsgCreateProvider { + return MsgCreateProvider.fromAmino(object.value); + }, + toAminoMsg(message: MsgCreateProvider): MsgCreateProviderAminoMsg { + return { + type: "akash/provider/testonly-create-provider", + value: MsgCreateProvider.toAmino(message) + }; + }, + fromProtoMsg(message: MsgCreateProviderProtoMsg): MsgCreateProvider { + return MsgCreateProvider.decode(message.value); + }, + toProto(message: MsgCreateProvider): Uint8Array { + return MsgCreateProvider.encode(message).finish(); + }, + toProtoMsg(message: MsgCreateProvider): MsgCreateProviderProtoMsg { + return { + typeUrl: "/akash.provider.v1beta1.MsgCreateProvider", + value: MsgCreateProvider.encode(message).finish() + }; + } +}; +function createBaseMsgCreateProviderResponse(): MsgCreateProviderResponse { + return {}; +} +export const MsgCreateProviderResponse = { + typeUrl: "/akash.provider.v1beta1.MsgCreateProviderResponse", + encode(_: MsgCreateProviderResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgCreateProviderResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgCreateProviderResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgCreateProviderResponse { + const obj = createBaseMsgCreateProviderResponse(); + return obj; + }, + toJSON(_: MsgCreateProviderResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): MsgCreateProviderResponse { + const message = createBaseMsgCreateProviderResponse(); + return message; + }, + fromSDK(_: MsgCreateProviderResponseSDKType): MsgCreateProviderResponse { + return {}; + }, + fromSDKJSON(_: any): MsgCreateProviderResponseSDKType { + return {}; + }, + toSDK(_: MsgCreateProviderResponse): MsgCreateProviderResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgCreateProviderResponseAmino): MsgCreateProviderResponse { + const message = createBaseMsgCreateProviderResponse(); + return message; + }, + toAmino(_: MsgCreateProviderResponse): MsgCreateProviderResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgCreateProviderResponseAminoMsg): MsgCreateProviderResponse { + return MsgCreateProviderResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgCreateProviderResponse): MsgCreateProviderResponseAminoMsg { + return { + type: "akash/provider/testonly-create-provider-response", + value: MsgCreateProviderResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgCreateProviderResponseProtoMsg): MsgCreateProviderResponse { + return MsgCreateProviderResponse.decode(message.value); + }, + toProto(message: MsgCreateProviderResponse): Uint8Array { + return MsgCreateProviderResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgCreateProviderResponse): MsgCreateProviderResponseProtoMsg { + return { + typeUrl: "/akash.provider.v1beta1.MsgCreateProviderResponse", + value: MsgCreateProviderResponse.encode(message).finish() + }; + } +}; +function createBaseMsgUpdateProvider(): MsgUpdateProvider { + return { + owner: "", + hostUri: "", + attributes: [], + info: ProviderInfo.fromPartial({}) + }; +} +export const MsgUpdateProvider = { + typeUrl: "/akash.provider.v1beta1.MsgUpdateProvider", + encode(message: MsgUpdateProvider, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.owner !== undefined) { + writer.uint32(10).string(message.owner); + } + if (message.hostUri !== undefined) { + writer.uint32(18).string(message.hostUri); + } + for (const v of message.attributes) { + Attribute.encode(v!, writer.uint32(26).fork()).ldelim(); + } + if (message.info !== undefined) { + ProviderInfo.encode(message.info, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgUpdateProvider { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgUpdateProvider(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.owner = reader.string(); + break; + case 2: + message.hostUri = reader.string(); + break; + case 3: + message.attributes.push(Attribute.decode(reader, reader.uint32())); + break; + case 4: + message.info = ProviderInfo.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgUpdateProvider { + const obj = createBaseMsgUpdateProvider(); + if (isSet(object.owner)) obj.owner = String(object.owner); + if (isSet(object.hostUri)) obj.hostUri = String(object.hostUri); + if (Array.isArray(object?.attributes)) obj.attributes = object.attributes.map((e: any) => Attribute.fromJSON(e)); + if (isSet(object.info)) obj.info = ProviderInfo.fromJSON(object.info); + return obj; + }, + toJSON(message: MsgUpdateProvider): JsonSafe { + const obj: any = {}; + message.owner !== undefined && (obj.owner = message.owner); + message.hostUri !== undefined && (obj.hostUri = message.hostUri); + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? Attribute.toJSON(e) : undefined); + } else { + obj.attributes = []; + } + message.info !== undefined && (obj.info = message.info ? ProviderInfo.toJSON(message.info) : undefined); + return obj; + }, + fromPartial, I>>(object: I): MsgUpdateProvider { + const message = createBaseMsgUpdateProvider(); + message.owner = object.owner ?? ""; + message.hostUri = object.hostUri ?? ""; + message.attributes = object.attributes?.map(e => Attribute.fromPartial(e)) || []; + if (object.info !== undefined && object.info !== null) { + message.info = ProviderInfo.fromPartial(object.info); + } + return message; + }, + fromSDK(object: MsgUpdateProviderSDKType): MsgUpdateProvider { + return { + owner: object?.owner, + hostUri: object?.host_uri, + attributes: Array.isArray(object?.attributes) ? object.attributes.map((e: any) => Attribute.fromSDK(e)) : [], + info: object.info ? ProviderInfo.fromSDK(object.info) : undefined + }; + }, + fromSDKJSON(object: any): MsgUpdateProviderSDKType { + return { + owner: isSet(object.owner) ? String(object.owner) : "", + host_uri: isSet(object.host_uri) ? String(object.host_uri) : "", + attributes: Array.isArray(object?.attributes) ? object.attributes.map((e: any) => Attribute.fromSDKJSON(e)) : [], + info: isSet(object.info) ? ProviderInfo.fromSDKJSON(object.info) : undefined + }; + }, + toSDK(message: MsgUpdateProvider): MsgUpdateProviderSDKType { + const obj: any = {}; + obj.owner = message.owner; + obj.host_uri = message.hostUri; + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? Attribute.toSDK(e) : undefined); + } else { + obj.attributes = []; + } + message.info !== undefined && (obj.info = message.info ? ProviderInfo.toSDK(message.info) : undefined); + return obj; + }, + fromAmino(object: MsgUpdateProviderAmino): MsgUpdateProvider { + const message = createBaseMsgUpdateProvider(); + if (object.owner !== undefined && object.owner !== null) { + message.owner = object.owner; + } + if (object.host_uri !== undefined && object.host_uri !== null) { + message.hostUri = object.host_uri; + } + message.attributes = object.attributes?.map(e => Attribute.fromAmino(e)) || []; + if (object.info !== undefined && object.info !== null) { + message.info = ProviderInfo.fromAmino(object.info); + } + return message; + }, + toAmino(message: MsgUpdateProvider): MsgUpdateProviderAmino { + const obj: any = {}; + obj.owner = message.owner ?? ""; + obj.host_uri = message.hostUri ?? ""; + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? Attribute.toAmino(e) : undefined); + } else { + obj.attributes = message.attributes; + } + obj.info = message.info ? ProviderInfo.toAmino(message.info) : ProviderInfo.toAmino(ProviderInfo.fromPartial({})); + return obj; + }, + fromAminoMsg(object: MsgUpdateProviderAminoMsg): MsgUpdateProvider { + return MsgUpdateProvider.fromAmino(object.value); + }, + toAminoMsg(message: MsgUpdateProvider): MsgUpdateProviderAminoMsg { + return { + type: "akash/provider/testonly-update-provider", + value: MsgUpdateProvider.toAmino(message) + }; + }, + fromProtoMsg(message: MsgUpdateProviderProtoMsg): MsgUpdateProvider { + return MsgUpdateProvider.decode(message.value); + }, + toProto(message: MsgUpdateProvider): Uint8Array { + return MsgUpdateProvider.encode(message).finish(); + }, + toProtoMsg(message: MsgUpdateProvider): MsgUpdateProviderProtoMsg { + return { + typeUrl: "/akash.provider.v1beta1.MsgUpdateProvider", + value: MsgUpdateProvider.encode(message).finish() + }; + } +}; +function createBaseMsgUpdateProviderResponse(): MsgUpdateProviderResponse { + return {}; +} +export const MsgUpdateProviderResponse = { + typeUrl: "/akash.provider.v1beta1.MsgUpdateProviderResponse", + encode(_: MsgUpdateProviderResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgUpdateProviderResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgUpdateProviderResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgUpdateProviderResponse { + const obj = createBaseMsgUpdateProviderResponse(); + return obj; + }, + toJSON(_: MsgUpdateProviderResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): MsgUpdateProviderResponse { + const message = createBaseMsgUpdateProviderResponse(); + return message; + }, + fromSDK(_: MsgUpdateProviderResponseSDKType): MsgUpdateProviderResponse { + return {}; + }, + fromSDKJSON(_: any): MsgUpdateProviderResponseSDKType { + return {}; + }, + toSDK(_: MsgUpdateProviderResponse): MsgUpdateProviderResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgUpdateProviderResponseAmino): MsgUpdateProviderResponse { + const message = createBaseMsgUpdateProviderResponse(); + return message; + }, + toAmino(_: MsgUpdateProviderResponse): MsgUpdateProviderResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgUpdateProviderResponseAminoMsg): MsgUpdateProviderResponse { + return MsgUpdateProviderResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgUpdateProviderResponse): MsgUpdateProviderResponseAminoMsg { + return { + type: "akash/provider/testonly-update-provider-response", + value: MsgUpdateProviderResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgUpdateProviderResponseProtoMsg): MsgUpdateProviderResponse { + return MsgUpdateProviderResponse.decode(message.value); + }, + toProto(message: MsgUpdateProviderResponse): Uint8Array { + return MsgUpdateProviderResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgUpdateProviderResponse): MsgUpdateProviderResponseProtoMsg { + return { + typeUrl: "/akash.provider.v1beta1.MsgUpdateProviderResponse", + value: MsgUpdateProviderResponse.encode(message).finish() + }; + } +}; +function createBaseMsgDeleteProvider(): MsgDeleteProvider { + return { + owner: "" + }; +} +export const MsgDeleteProvider = { + typeUrl: "/akash.provider.v1beta1.MsgDeleteProvider", + encode(message: MsgDeleteProvider, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.owner !== undefined) { + writer.uint32(10).string(message.owner); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgDeleteProvider { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgDeleteProvider(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.owner = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgDeleteProvider { + const obj = createBaseMsgDeleteProvider(); + if (isSet(object.owner)) obj.owner = String(object.owner); + return obj; + }, + toJSON(message: MsgDeleteProvider): JsonSafe { + const obj: any = {}; + message.owner !== undefined && (obj.owner = message.owner); + return obj; + }, + fromPartial, I>>(object: I): MsgDeleteProvider { + const message = createBaseMsgDeleteProvider(); + message.owner = object.owner ?? ""; + return message; + }, + fromSDK(object: MsgDeleteProviderSDKType): MsgDeleteProvider { + return { + owner: object?.owner + }; + }, + fromSDKJSON(object: any): MsgDeleteProviderSDKType { + return { + owner: isSet(object.owner) ? String(object.owner) : "" + }; + }, + toSDK(message: MsgDeleteProvider): MsgDeleteProviderSDKType { + const obj: any = {}; + obj.owner = message.owner; + return obj; + }, + fromAmino(object: MsgDeleteProviderAmino): MsgDeleteProvider { + const message = createBaseMsgDeleteProvider(); + if (object.owner !== undefined && object.owner !== null) { + message.owner = object.owner; + } + return message; + }, + toAmino(message: MsgDeleteProvider): MsgDeleteProviderAmino { + const obj: any = {}; + obj.owner = message.owner ?? ""; + return obj; + }, + fromAminoMsg(object: MsgDeleteProviderAminoMsg): MsgDeleteProvider { + return MsgDeleteProvider.fromAmino(object.value); + }, + toAminoMsg(message: MsgDeleteProvider): MsgDeleteProviderAminoMsg { + return { + type: "akash/provider/testonly-delete-provider", + value: MsgDeleteProvider.toAmino(message) + }; + }, + fromProtoMsg(message: MsgDeleteProviderProtoMsg): MsgDeleteProvider { + return MsgDeleteProvider.decode(message.value); + }, + toProto(message: MsgDeleteProvider): Uint8Array { + return MsgDeleteProvider.encode(message).finish(); + }, + toProtoMsg(message: MsgDeleteProvider): MsgDeleteProviderProtoMsg { + return { + typeUrl: "/akash.provider.v1beta1.MsgDeleteProvider", + value: MsgDeleteProvider.encode(message).finish() + }; + } +}; +function createBaseMsgDeleteProviderResponse(): MsgDeleteProviderResponse { + return {}; +} +export const MsgDeleteProviderResponse = { + typeUrl: "/akash.provider.v1beta1.MsgDeleteProviderResponse", + encode(_: MsgDeleteProviderResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgDeleteProviderResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgDeleteProviderResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgDeleteProviderResponse { + const obj = createBaseMsgDeleteProviderResponse(); + return obj; + }, + toJSON(_: MsgDeleteProviderResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): MsgDeleteProviderResponse { + const message = createBaseMsgDeleteProviderResponse(); + return message; + }, + fromSDK(_: MsgDeleteProviderResponseSDKType): MsgDeleteProviderResponse { + return {}; + }, + fromSDKJSON(_: any): MsgDeleteProviderResponseSDKType { + return {}; + }, + toSDK(_: MsgDeleteProviderResponse): MsgDeleteProviderResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgDeleteProviderResponseAmino): MsgDeleteProviderResponse { + const message = createBaseMsgDeleteProviderResponse(); + return message; + }, + toAmino(_: MsgDeleteProviderResponse): MsgDeleteProviderResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgDeleteProviderResponseAminoMsg): MsgDeleteProviderResponse { + return MsgDeleteProviderResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgDeleteProviderResponse): MsgDeleteProviderResponseAminoMsg { + return { + type: "akash/provider/testonly-delete-provider-response", + value: MsgDeleteProviderResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgDeleteProviderResponseProtoMsg): MsgDeleteProviderResponse { + return MsgDeleteProviderResponse.decode(message.value); + }, + toProto(message: MsgDeleteProviderResponse): Uint8Array { + return MsgDeleteProviderResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgDeleteProviderResponse): MsgDeleteProviderResponseProtoMsg { + return { + typeUrl: "/akash.provider.v1beta1.MsgDeleteProviderResponse", + value: MsgDeleteProviderResponse.encode(message).finish() + }; + } +}; +function createBaseProvider(): Provider { + return { + owner: "", + hostUri: "", + attributes: [], + info: ProviderInfo.fromPartial({}) + }; +} +export const Provider = { + typeUrl: "/akash.provider.v1beta1.Provider", + encode(message: Provider, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.owner !== undefined) { + writer.uint32(10).string(message.owner); + } + if (message.hostUri !== undefined) { + writer.uint32(18).string(message.hostUri); + } + for (const v of message.attributes) { + Attribute.encode(v!, writer.uint32(26).fork()).ldelim(); + } + if (message.info !== undefined) { + ProviderInfo.encode(message.info, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Provider { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseProvider(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.owner = reader.string(); + break; + case 2: + message.hostUri = reader.string(); + break; + case 3: + message.attributes.push(Attribute.decode(reader, reader.uint32())); + break; + case 4: + message.info = ProviderInfo.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Provider { + const obj = createBaseProvider(); + if (isSet(object.owner)) obj.owner = String(object.owner); + if (isSet(object.hostUri)) obj.hostUri = String(object.hostUri); + if (Array.isArray(object?.attributes)) obj.attributes = object.attributes.map((e: any) => Attribute.fromJSON(e)); + if (isSet(object.info)) obj.info = ProviderInfo.fromJSON(object.info); + return obj; + }, + toJSON(message: Provider): JsonSafe { + const obj: any = {}; + message.owner !== undefined && (obj.owner = message.owner); + message.hostUri !== undefined && (obj.hostUri = message.hostUri); + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? Attribute.toJSON(e) : undefined); + } else { + obj.attributes = []; + } + message.info !== undefined && (obj.info = message.info ? ProviderInfo.toJSON(message.info) : undefined); + return obj; + }, + fromPartial, I>>(object: I): Provider { + const message = createBaseProvider(); + message.owner = object.owner ?? ""; + message.hostUri = object.hostUri ?? ""; + message.attributes = object.attributes?.map(e => Attribute.fromPartial(e)) || []; + if (object.info !== undefined && object.info !== null) { + message.info = ProviderInfo.fromPartial(object.info); + } + return message; + }, + fromSDK(object: ProviderSDKType): Provider { + return { + owner: object?.owner, + hostUri: object?.host_uri, + attributes: Array.isArray(object?.attributes) ? object.attributes.map((e: any) => Attribute.fromSDK(e)) : [], + info: object.info ? ProviderInfo.fromSDK(object.info) : undefined + }; + }, + fromSDKJSON(object: any): ProviderSDKType { + return { + owner: isSet(object.owner) ? String(object.owner) : "", + host_uri: isSet(object.host_uri) ? String(object.host_uri) : "", + attributes: Array.isArray(object?.attributes) ? object.attributes.map((e: any) => Attribute.fromSDKJSON(e)) : [], + info: isSet(object.info) ? ProviderInfo.fromSDKJSON(object.info) : undefined + }; + }, + toSDK(message: Provider): ProviderSDKType { + const obj: any = {}; + obj.owner = message.owner; + obj.host_uri = message.hostUri; + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? Attribute.toSDK(e) : undefined); + } else { + obj.attributes = []; + } + message.info !== undefined && (obj.info = message.info ? ProviderInfo.toSDK(message.info) : undefined); + return obj; + }, + fromAmino(object: ProviderAmino): Provider { + const message = createBaseProvider(); + if (object.owner !== undefined && object.owner !== null) { + message.owner = object.owner; + } + if (object.host_uri !== undefined && object.host_uri !== null) { + message.hostUri = object.host_uri; + } + message.attributes = object.attributes?.map(e => Attribute.fromAmino(e)) || []; + if (object.info !== undefined && object.info !== null) { + message.info = ProviderInfo.fromAmino(object.info); + } + return message; + }, + toAmino(message: Provider): ProviderAmino { + const obj: any = {}; + obj.owner = message.owner ?? ""; + obj.host_uri = message.hostUri ?? ""; + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? Attribute.toAmino(e) : undefined); + } else { + obj.attributes = message.attributes; + } + obj.info = message.info ? ProviderInfo.toAmino(message.info) : ProviderInfo.toAmino(ProviderInfo.fromPartial({})); + return obj; + }, + fromAminoMsg(object: ProviderAminoMsg): Provider { + return Provider.fromAmino(object.value); + }, + toAminoMsg(message: Provider): ProviderAminoMsg { + return { + type: "akash/provider/provider", + value: Provider.toAmino(message) + }; + }, + fromProtoMsg(message: ProviderProtoMsg): Provider { + return Provider.decode(message.value); + }, + toProto(message: Provider): Uint8Array { + return Provider.encode(message).finish(); + }, + toProtoMsg(message: Provider): ProviderProtoMsg { + return { + typeUrl: "/akash.provider.v1beta1.Provider", + value: Provider.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/provider/v1beta2/genesis.ts b/__fixtures__/v-next/outputicjsdeps/akash/provider/v1beta2/genesis.ts new file mode 100644 index 0000000000..ae7e15bff3 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/provider/v1beta2/genesis.ts @@ -0,0 +1,121 @@ +import { Provider, ProviderSDKType } from "./provider.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { JsonSafe } from "../../../json-safe.js"; +import { DeepPartial, Exact } from "../../../helpers.js"; +export const protobufPackage = "akash.provider.v1beta2"; +/** GenesisState defines the basic genesis state used by provider module */ +export interface GenesisState { + providers: Provider[]; +} +export interface GenesisStateProtoMsg { + typeUrl: "/akash.provider.v1beta2.GenesisState"; + value: Uint8Array; +} +/** GenesisState defines the basic genesis state used by provider module */ +export interface GenesisStateSDKType { + providers: ProviderSDKType[]; +} +function createBaseGenesisState(): GenesisState { + return { + providers: [] + }; +} +export const GenesisState = { + typeUrl: "/akash.provider.v1beta2.GenesisState", + encode(message: GenesisState, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.providers) { + Provider.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GenesisState { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGenesisState(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.providers.push(Provider.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GenesisState { + const obj = createBaseGenesisState(); + if (Array.isArray(object?.providers)) obj.providers = object.providers.map((e: any) => Provider.fromJSON(e)); + return obj; + }, + toJSON(message: GenesisState): JsonSafe { + const obj: any = {}; + if (message.providers) { + obj.providers = message.providers.map(e => e ? Provider.toJSON(e) : undefined); + } else { + obj.providers = []; + } + return obj; + }, + fromPartial, I>>(object: I): GenesisState { + const message = createBaseGenesisState(); + message.providers = object.providers?.map(e => Provider.fromPartial(e)) || []; + return message; + }, + fromSDK(object: GenesisStateSDKType): GenesisState { + return { + providers: Array.isArray(object?.providers) ? object.providers.map((e: any) => Provider.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): GenesisStateSDKType { + return { + providers: Array.isArray(object?.providers) ? object.providers.map((e: any) => Provider.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: GenesisState): GenesisStateSDKType { + const obj: any = {}; + if (message.providers) { + obj.providers = message.providers.map(e => e ? Provider.toSDK(e) : undefined); + } else { + obj.providers = []; + } + return obj; + }, + fromAmino(object: GenesisStateAmino): GenesisState { + const message = createBaseGenesisState(); + message.providers = object.providers?.map(e => Provider.fromAmino(e)) || []; + return message; + }, + toAmino(message: GenesisState): GenesisStateAmino { + const obj: any = {}; + if (message.providers) { + obj.providers = message.providers.map(e => e ? Provider.toAmino(e) : undefined); + } else { + obj.providers = message.providers; + } + return obj; + }, + fromAminoMsg(object: GenesisStateAminoMsg): GenesisState { + return GenesisState.fromAmino(object.value); + }, + toAminoMsg(message: GenesisState): GenesisStateAminoMsg { + return { + type: "akash/provider/v1beta2/genesis-state", + value: GenesisState.toAmino(message) + }; + }, + fromProtoMsg(message: GenesisStateProtoMsg): GenesisState { + return GenesisState.decode(message.value); + }, + toProto(message: GenesisState): Uint8Array { + return GenesisState.encode(message).finish(); + }, + toProtoMsg(message: GenesisState): GenesisStateProtoMsg { + return { + typeUrl: "/akash.provider.v1beta2.GenesisState", + value: GenesisState.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/provider/v1beta2/provider.amino.ts b/__fixtures__/v-next/outputicjsdeps/akash/provider/v1beta2/provider.amino.ts new file mode 100644 index 0000000000..134b792a8e --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/provider/v1beta2/provider.amino.ts @@ -0,0 +1,141 @@ +/* eslint-disable */ +import { Attribute, AttributeSDKType } from "../../base/v1beta2/attribute.js"; +import { ReadOnlyAminoMsg as AminoMsg } from "@interchainjs/ReadOnlyAminoMsg"; +import { ProviderInfo, ProviderInfoSDKType, MsgCreateProvider, MsgCreateProviderSDKType, MsgUpdateProvider, MsgUpdateProviderSDKType, MsgDeleteProvider, MsgDeleteProviderSDKType } from "./provider.js"; +export interface MsgCreateProviderAminoType extends AminoMsg { + type: "akash/provider/v1beta2/testonly-create-provider"; + value: { + owner: string; + host_uri: string; + attributes: { + key: string; + value: string; + }[]; + info: { + email: string; + website: string; + }; + }; +} +export interface MsgUpdateProviderAminoType extends AminoMsg { + type: "akash/provider/v1beta2/testonly-update-provider"; + value: { + owner: string; + host_uri: string; + attributes: { + key: string; + value: string; + }[]; + info: { + email: string; + website: string; + }; + }; +} +export interface MsgDeleteProviderAminoType extends AminoMsg { + type: "akash/provider/v1beta2/testonly-delete-provider"; + value: { + owner: string; + }; +} +export const AminoConverter = { + "/akash.provider.v1beta2.MsgCreateProvider": { + aminoType: "akash/provider/v1beta2/testonly-create-provider", + toAmino: ({ + owner, + hostUri, + attributes, + info + }: MsgCreateProvider): MsgCreateProviderAminoType["value"] => { + return { + owner, + host_uri: hostUri, + attributes: attributes.map(el0 => ({ + key: el0.key, + value: el0.value + })), + info: { + email: info.email, + website: info.website + } + }; + }, + fromAmino: ({ + owner, + host_uri, + attributes, + info + }: MsgCreateProviderAminoType["value"]): MsgCreateProvider => { + return { + owner, + hostUri: host_uri, + attributes: attributes.map(el0 => ({ + key: el0.key, + value: el0.value + })), + info: { + email: info.email, + website: info.website + } + }; + } + }, + "/akash.provider.v1beta2.MsgUpdateProvider": { + aminoType: "akash/provider/v1beta2/testonly-update-provider", + toAmino: ({ + owner, + hostUri, + attributes, + info + }: MsgUpdateProvider): MsgUpdateProviderAminoType["value"] => { + return { + owner, + host_uri: hostUri, + attributes: attributes.map(el0 => ({ + key: el0.key, + value: el0.value + })), + info: { + email: info.email, + website: info.website + } + }; + }, + fromAmino: ({ + owner, + host_uri, + attributes, + info + }: MsgUpdateProviderAminoType["value"]): MsgUpdateProvider => { + return { + owner, + hostUri: host_uri, + attributes: attributes.map(el0 => ({ + key: el0.key, + value: el0.value + })), + info: { + email: info.email, + website: info.website + } + }; + } + }, + "/akash.provider.v1beta2.MsgDeleteProvider": { + aminoType: "akash/provider/v1beta2/testonly-delete-provider", + toAmino: ({ + owner + }: MsgDeleteProvider): MsgDeleteProviderAminoType["value"] => { + return { + owner + }; + }, + fromAmino: ({ + owner + }: MsgDeleteProviderAminoType["value"]): MsgDeleteProvider => { + return { + owner + }; + } + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/provider/v1beta2/provider.registry.ts b/__fixtures__/v-next/outputicjsdeps/akash/provider/v1beta2/provider.registry.ts new file mode 100644 index 0000000000..4f82ef2ec0 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/provider/v1beta2/provider.registry.ts @@ -0,0 +1,111 @@ +import { Attribute, AttributeSDKType } from "../../base/v1beta2/attribute.js"; +import { GeneratedType, Registry } from "@cosmjs/proto-signing"; +import { MsgCreateProvider, MsgCreateProviderSDKType, MsgUpdateProvider, MsgUpdateProviderSDKType, MsgDeleteProvider, MsgDeleteProviderSDKType } from "./provider.js"; +export const registry: ReadonlyArray<[string, GeneratedType]> = [["/akash.provider.v1beta2.MsgCreateProvider", MsgCreateProvider], ["/akash.provider.v1beta2.MsgUpdateProvider", MsgUpdateProvider], ["/akash.provider.v1beta2.MsgDeleteProvider", MsgDeleteProvider]]; +export const load = (protoRegistry: Registry) => { + registry.forEach(([typeUrl, mod]) => { + protoRegistry.register(typeUrl, mod); + }); +}; +export const MessageComposer = { + encoded: { + createProvider(value: MsgCreateProvider) { + return { + typeUrl: "/akash.provider.v1beta2.MsgCreateProvider", + value: MsgCreateProvider.encode(value).finish() + }; + }, + updateProvider(value: MsgUpdateProvider) { + return { + typeUrl: "/akash.provider.v1beta2.MsgUpdateProvider", + value: MsgUpdateProvider.encode(value).finish() + }; + }, + deleteProvider(value: MsgDeleteProvider) { + return { + typeUrl: "/akash.provider.v1beta2.MsgDeleteProvider", + value: MsgDeleteProvider.encode(value).finish() + }; + } + }, + withTypeUrl: { + createProvider(value: MsgCreateProvider) { + return { + typeUrl: "/akash.provider.v1beta2.MsgCreateProvider", + value + }; + }, + updateProvider(value: MsgUpdateProvider) { + return { + typeUrl: "/akash.provider.v1beta2.MsgUpdateProvider", + value + }; + }, + deleteProvider(value: MsgDeleteProvider) { + return { + typeUrl: "/akash.provider.v1beta2.MsgDeleteProvider", + value + }; + } + }, + toJSON: { + createProvider(value: MsgCreateProvider) { + return { + typeUrl: "/akash.provider.v1beta2.MsgCreateProvider", + value: MsgCreateProvider.toJSON(value) + }; + }, + updateProvider(value: MsgUpdateProvider) { + return { + typeUrl: "/akash.provider.v1beta2.MsgUpdateProvider", + value: MsgUpdateProvider.toJSON(value) + }; + }, + deleteProvider(value: MsgDeleteProvider) { + return { + typeUrl: "/akash.provider.v1beta2.MsgDeleteProvider", + value: MsgDeleteProvider.toJSON(value) + }; + } + }, + fromJSON: { + createProvider(value: any) { + return { + typeUrl: "/akash.provider.v1beta2.MsgCreateProvider", + value: MsgCreateProvider.fromJSON(value) + }; + }, + updateProvider(value: any) { + return { + typeUrl: "/akash.provider.v1beta2.MsgUpdateProvider", + value: MsgUpdateProvider.fromJSON(value) + }; + }, + deleteProvider(value: any) { + return { + typeUrl: "/akash.provider.v1beta2.MsgDeleteProvider", + value: MsgDeleteProvider.fromJSON(value) + }; + } + }, + fromPartial: { + createProvider(value: MsgCreateProvider) { + return { + typeUrl: "/akash.provider.v1beta2.MsgCreateProvider", + value: MsgCreateProvider.fromPartial(value) + }; + }, + updateProvider(value: MsgUpdateProvider) { + return { + typeUrl: "/akash.provider.v1beta2.MsgUpdateProvider", + value: MsgUpdateProvider.fromPartial(value) + }; + }, + deleteProvider(value: MsgDeleteProvider) { + return { + typeUrl: "/akash.provider.v1beta2.MsgDeleteProvider", + value: MsgDeleteProvider.fromPartial(value) + }; + } + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/provider/v1beta2/provider.rpc.func.ts b/__fixtures__/v-next/outputicjsdeps/akash/provider/v1beta2/provider.rpc.func.ts new file mode 100644 index 0000000000..62c9ef6bba --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/provider/v1beta2/provider.rpc.func.ts @@ -0,0 +1,31 @@ +import { buildTx, SigningClientResolver } from "../../../helper-func-types"; +import { buildUseMutation } from "../../../react-query"; +import { toEncoders, toConverters } from "@interchainjs/cosmos/utils"; +import { MsgCreateProvider, MsgUpdateProvider, MsgDeleteProvider } from "./provider"; +export const createCreateProvider = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgCreateProvider.typeUrl, + encoders: toEncoders(MsgCreateProvider), + converters: toConverters(MsgCreateProvider) +}); +export const useCreateProvider = buildUseMutation({ + builderMutationFn: createCreateProvider +}); +export const createUpdateProvider = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgUpdateProvider.typeUrl, + encoders: toEncoders(MsgUpdateProvider), + converters: toConverters(MsgUpdateProvider) +}); +export const useUpdateProvider = buildUseMutation({ + builderMutationFn: createUpdateProvider +}); +export const createDeleteProvider = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgDeleteProvider.typeUrl, + encoders: toEncoders(MsgDeleteProvider), + converters: toConverters(MsgDeleteProvider) +}); +export const useDeleteProvider = buildUseMutation({ + builderMutationFn: createDeleteProvider +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/provider/v1beta2/provider.rpc.msg.ts b/__fixtures__/v-next/outputicjsdeps/akash/provider/v1beta2/provider.rpc.msg.ts new file mode 100644 index 0000000000..d0d8c37103 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/provider/v1beta2/provider.rpc.msg.ts @@ -0,0 +1,40 @@ +import { Attribute, AttributeSDKType } from "../../base/v1beta2/attribute.js"; +import { Rpc } from "../../../helpers.js"; +import { BinaryReader } from "../../../binary.js"; +import { MsgCreateProvider, MsgCreateProviderSDKType, MsgCreateProviderResponse, MsgCreateProviderResponseSDKType, MsgUpdateProvider, MsgUpdateProviderSDKType, MsgUpdateProviderResponse, MsgUpdateProviderResponseSDKType, MsgDeleteProvider, MsgDeleteProviderSDKType, MsgDeleteProviderResponse, MsgDeleteProviderResponseSDKType } from "./provider.js"; +/** Msg defines the provider Msg service */ +export interface Msg { + /** CreateProvider defines a method that creates a provider given the proper inputs */ + createProvider(request: MsgCreateProvider): Promise; + /** UpdateProvider defines a method that updates a provider given the proper inputs */ + updateProvider(request: MsgUpdateProvider): Promise; + /** DeleteProvider defines a method that deletes a provider given the proper inputs */ + deleteProvider(request: MsgDeleteProvider): Promise; +} +export class MsgClientImpl implements Msg { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + } + /* CreateProvider defines a method that creates a provider given the proper inputs */ + createProvider = async (request: MsgCreateProvider): Promise => { + const data = MsgCreateProvider.encode(request).finish(); + const promise = this.rpc.request("akash.provider.v1beta2.Msg", "CreateProvider", data); + return promise.then(data => MsgCreateProviderResponse.decode(new BinaryReader(data))); + }; + /* UpdateProvider defines a method that updates a provider given the proper inputs */ + updateProvider = async (request: MsgUpdateProvider): Promise => { + const data = MsgUpdateProvider.encode(request).finish(); + const promise = this.rpc.request("akash.provider.v1beta2.Msg", "UpdateProvider", data); + return promise.then(data => MsgUpdateProviderResponse.decode(new BinaryReader(data))); + }; + /* DeleteProvider defines a method that deletes a provider given the proper inputs */ + deleteProvider = async (request: MsgDeleteProvider): Promise => { + const data = MsgDeleteProvider.encode(request).finish(); + const promise = this.rpc.request("akash.provider.v1beta2.Msg", "DeleteProvider", data); + return promise.then(data => MsgDeleteProviderResponse.decode(new BinaryReader(data))); + }; +} +export const createClientImpl = (rpc: Rpc) => { + return new MsgClientImpl(rpc); +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/provider/v1beta2/provider.ts b/__fixtures__/v-next/outputicjsdeps/akash/provider/v1beta2/provider.ts new file mode 100644 index 0000000000..046d435970 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/provider/v1beta2/provider.ts @@ -0,0 +1,1007 @@ +import { Attribute, AttributeSDKType } from "../../base/v1beta2/attribute.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial, Exact } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "akash.provider.v1beta2"; +/** ProviderInfo */ +export interface ProviderInfo { + email: string; + website: string; +} +export interface ProviderInfoProtoMsg { + typeUrl: "/akash.provider.v1beta2.ProviderInfo"; + value: Uint8Array; +} +/** ProviderInfo */ +export interface ProviderInfoSDKType { + email: string; + website: string; +} +/** MsgCreateProvider defines an SDK message for creating a provider */ +export interface MsgCreateProvider { + owner: string; + hostUri: string; + attributes: Attribute[]; + info: ProviderInfo; +} +export interface MsgCreateProviderProtoMsg { + typeUrl: "/akash.provider.v1beta2.MsgCreateProvider"; + value: Uint8Array; +} +/** MsgCreateProvider defines an SDK message for creating a provider */ +export interface MsgCreateProviderSDKType { + owner: string; + host_uri: string; + attributes: AttributeSDKType[]; + info: ProviderInfoSDKType; +} +/** MsgCreateProviderResponse defines the Msg/CreateProvider response type. */ +export interface MsgCreateProviderResponse {} +export interface MsgCreateProviderResponseProtoMsg { + typeUrl: "/akash.provider.v1beta2.MsgCreateProviderResponse"; + value: Uint8Array; +} +/** MsgCreateProviderResponse defines the Msg/CreateProvider response type. */ +export interface MsgCreateProviderResponseSDKType {} +/** MsgUpdateProvider defines an SDK message for updating a provider */ +export interface MsgUpdateProvider { + owner: string; + hostUri: string; + attributes: Attribute[]; + info: ProviderInfo; +} +export interface MsgUpdateProviderProtoMsg { + typeUrl: "/akash.provider.v1beta2.MsgUpdateProvider"; + value: Uint8Array; +} +/** MsgUpdateProvider defines an SDK message for updating a provider */ +export interface MsgUpdateProviderSDKType { + owner: string; + host_uri: string; + attributes: AttributeSDKType[]; + info: ProviderInfoSDKType; +} +/** MsgUpdateProviderResponse defines the Msg/UpdateProvider response type. */ +export interface MsgUpdateProviderResponse {} +export interface MsgUpdateProviderResponseProtoMsg { + typeUrl: "/akash.provider.v1beta2.MsgUpdateProviderResponse"; + value: Uint8Array; +} +/** MsgUpdateProviderResponse defines the Msg/UpdateProvider response type. */ +export interface MsgUpdateProviderResponseSDKType {} +/** MsgDeleteProvider defines an SDK message for deleting a provider */ +export interface MsgDeleteProvider { + owner: string; +} +export interface MsgDeleteProviderProtoMsg { + typeUrl: "/akash.provider.v1beta2.MsgDeleteProvider"; + value: Uint8Array; +} +/** MsgDeleteProvider defines an SDK message for deleting a provider */ +export interface MsgDeleteProviderSDKType { + owner: string; +} +/** MsgDeleteProviderResponse defines the Msg/DeleteProvider response type. */ +export interface MsgDeleteProviderResponse {} +export interface MsgDeleteProviderResponseProtoMsg { + typeUrl: "/akash.provider.v1beta2.MsgDeleteProviderResponse"; + value: Uint8Array; +} +/** MsgDeleteProviderResponse defines the Msg/DeleteProvider response type. */ +export interface MsgDeleteProviderResponseSDKType {} +/** Provider stores owner and host details */ +export interface Provider { + owner: string; + hostUri: string; + attributes: Attribute[]; + info: ProviderInfo; +} +export interface ProviderProtoMsg { + typeUrl: "/akash.provider.v1beta2.Provider"; + value: Uint8Array; +} +/** Provider stores owner and host details */ +export interface ProviderSDKType { + owner: string; + host_uri: string; + attributes: AttributeSDKType[]; + info: ProviderInfoSDKType; +} +function createBaseProviderInfo(): ProviderInfo { + return { + email: "", + website: "" + }; +} +export const ProviderInfo = { + typeUrl: "/akash.provider.v1beta2.ProviderInfo", + encode(message: ProviderInfo, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.email !== undefined) { + writer.uint32(10).string(message.email); + } + if (message.website !== undefined) { + writer.uint32(18).string(message.website); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ProviderInfo { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseProviderInfo(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.email = reader.string(); + break; + case 2: + message.website = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ProviderInfo { + const obj = createBaseProviderInfo(); + if (isSet(object.email)) obj.email = String(object.email); + if (isSet(object.website)) obj.website = String(object.website); + return obj; + }, + toJSON(message: ProviderInfo): JsonSafe { + const obj: any = {}; + message.email !== undefined && (obj.email = message.email); + message.website !== undefined && (obj.website = message.website); + return obj; + }, + fromPartial, I>>(object: I): ProviderInfo { + const message = createBaseProviderInfo(); + message.email = object.email ?? ""; + message.website = object.website ?? ""; + return message; + }, + fromSDK(object: ProviderInfoSDKType): ProviderInfo { + return { + email: object?.email, + website: object?.website + }; + }, + fromSDKJSON(object: any): ProviderInfoSDKType { + return { + email: isSet(object.email) ? String(object.email) : "", + website: isSet(object.website) ? String(object.website) : "" + }; + }, + toSDK(message: ProviderInfo): ProviderInfoSDKType { + const obj: any = {}; + obj.email = message.email; + obj.website = message.website; + return obj; + }, + fromAmino(object: ProviderInfoAmino): ProviderInfo { + const message = createBaseProviderInfo(); + if (object.email !== undefined && object.email !== null) { + message.email = object.email; + } + if (object.website !== undefined && object.website !== null) { + message.website = object.website; + } + return message; + }, + toAmino(message: ProviderInfo): ProviderInfoAmino { + const obj: any = {}; + obj.email = message.email ?? ""; + obj.website = message.website ?? ""; + return obj; + }, + fromAminoMsg(object: ProviderInfoAminoMsg): ProviderInfo { + return ProviderInfo.fromAmino(object.value); + }, + toAminoMsg(message: ProviderInfo): ProviderInfoAminoMsg { + return { + type: "akash/provider/v1beta2/provider-info", + value: ProviderInfo.toAmino(message) + }; + }, + fromProtoMsg(message: ProviderInfoProtoMsg): ProviderInfo { + return ProviderInfo.decode(message.value); + }, + toProto(message: ProviderInfo): Uint8Array { + return ProviderInfo.encode(message).finish(); + }, + toProtoMsg(message: ProviderInfo): ProviderInfoProtoMsg { + return { + typeUrl: "/akash.provider.v1beta2.ProviderInfo", + value: ProviderInfo.encode(message).finish() + }; + } +}; +function createBaseMsgCreateProvider(): MsgCreateProvider { + return { + owner: "", + hostUri: "", + attributes: [], + info: ProviderInfo.fromPartial({}) + }; +} +export const MsgCreateProvider = { + typeUrl: "/akash.provider.v1beta2.MsgCreateProvider", + encode(message: MsgCreateProvider, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.owner !== undefined) { + writer.uint32(10).string(message.owner); + } + if (message.hostUri !== undefined) { + writer.uint32(18).string(message.hostUri); + } + for (const v of message.attributes) { + Attribute.encode(v!, writer.uint32(26).fork()).ldelim(); + } + if (message.info !== undefined) { + ProviderInfo.encode(message.info, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgCreateProvider { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgCreateProvider(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.owner = reader.string(); + break; + case 2: + message.hostUri = reader.string(); + break; + case 3: + message.attributes.push(Attribute.decode(reader, reader.uint32())); + break; + case 4: + message.info = ProviderInfo.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgCreateProvider { + const obj = createBaseMsgCreateProvider(); + if (isSet(object.owner)) obj.owner = String(object.owner); + if (isSet(object.hostUri)) obj.hostUri = String(object.hostUri); + if (Array.isArray(object?.attributes)) obj.attributes = object.attributes.map((e: any) => Attribute.fromJSON(e)); + if (isSet(object.info)) obj.info = ProviderInfo.fromJSON(object.info); + return obj; + }, + toJSON(message: MsgCreateProvider): JsonSafe { + const obj: any = {}; + message.owner !== undefined && (obj.owner = message.owner); + message.hostUri !== undefined && (obj.hostUri = message.hostUri); + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? Attribute.toJSON(e) : undefined); + } else { + obj.attributes = []; + } + message.info !== undefined && (obj.info = message.info ? ProviderInfo.toJSON(message.info) : undefined); + return obj; + }, + fromPartial, I>>(object: I): MsgCreateProvider { + const message = createBaseMsgCreateProvider(); + message.owner = object.owner ?? ""; + message.hostUri = object.hostUri ?? ""; + message.attributes = object.attributes?.map(e => Attribute.fromPartial(e)) || []; + if (object.info !== undefined && object.info !== null) { + message.info = ProviderInfo.fromPartial(object.info); + } + return message; + }, + fromSDK(object: MsgCreateProviderSDKType): MsgCreateProvider { + return { + owner: object?.owner, + hostUri: object?.host_uri, + attributes: Array.isArray(object?.attributes) ? object.attributes.map((e: any) => Attribute.fromSDK(e)) : [], + info: object.info ? ProviderInfo.fromSDK(object.info) : undefined + }; + }, + fromSDKJSON(object: any): MsgCreateProviderSDKType { + return { + owner: isSet(object.owner) ? String(object.owner) : "", + host_uri: isSet(object.host_uri) ? String(object.host_uri) : "", + attributes: Array.isArray(object?.attributes) ? object.attributes.map((e: any) => Attribute.fromSDKJSON(e)) : [], + info: isSet(object.info) ? ProviderInfo.fromSDKJSON(object.info) : undefined + }; + }, + toSDK(message: MsgCreateProvider): MsgCreateProviderSDKType { + const obj: any = {}; + obj.owner = message.owner; + obj.host_uri = message.hostUri; + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? Attribute.toSDK(e) : undefined); + } else { + obj.attributes = []; + } + message.info !== undefined && (obj.info = message.info ? ProviderInfo.toSDK(message.info) : undefined); + return obj; + }, + fromAmino(object: MsgCreateProviderAmino): MsgCreateProvider { + const message = createBaseMsgCreateProvider(); + if (object.owner !== undefined && object.owner !== null) { + message.owner = object.owner; + } + if (object.host_uri !== undefined && object.host_uri !== null) { + message.hostUri = object.host_uri; + } + message.attributes = object.attributes?.map(e => Attribute.fromAmino(e)) || []; + if (object.info !== undefined && object.info !== null) { + message.info = ProviderInfo.fromAmino(object.info); + } + return message; + }, + toAmino(message: MsgCreateProvider): MsgCreateProviderAmino { + const obj: any = {}; + obj.owner = message.owner ?? ""; + obj.host_uri = message.hostUri ?? ""; + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? Attribute.toAmino(e) : undefined); + } else { + obj.attributes = message.attributes; + } + obj.info = message.info ? ProviderInfo.toAmino(message.info) : ProviderInfo.toAmino(ProviderInfo.fromPartial({})); + return obj; + }, + fromAminoMsg(object: MsgCreateProviderAminoMsg): MsgCreateProvider { + return MsgCreateProvider.fromAmino(object.value); + }, + toAminoMsg(message: MsgCreateProvider): MsgCreateProviderAminoMsg { + return { + type: "akash/provider/v1beta2/testonly-create-provider", + value: MsgCreateProvider.toAmino(message) + }; + }, + fromProtoMsg(message: MsgCreateProviderProtoMsg): MsgCreateProvider { + return MsgCreateProvider.decode(message.value); + }, + toProto(message: MsgCreateProvider): Uint8Array { + return MsgCreateProvider.encode(message).finish(); + }, + toProtoMsg(message: MsgCreateProvider): MsgCreateProviderProtoMsg { + return { + typeUrl: "/akash.provider.v1beta2.MsgCreateProvider", + value: MsgCreateProvider.encode(message).finish() + }; + } +}; +function createBaseMsgCreateProviderResponse(): MsgCreateProviderResponse { + return {}; +} +export const MsgCreateProviderResponse = { + typeUrl: "/akash.provider.v1beta2.MsgCreateProviderResponse", + encode(_: MsgCreateProviderResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgCreateProviderResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgCreateProviderResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgCreateProviderResponse { + const obj = createBaseMsgCreateProviderResponse(); + return obj; + }, + toJSON(_: MsgCreateProviderResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): MsgCreateProviderResponse { + const message = createBaseMsgCreateProviderResponse(); + return message; + }, + fromSDK(_: MsgCreateProviderResponseSDKType): MsgCreateProviderResponse { + return {}; + }, + fromSDKJSON(_: any): MsgCreateProviderResponseSDKType { + return {}; + }, + toSDK(_: MsgCreateProviderResponse): MsgCreateProviderResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgCreateProviderResponseAmino): MsgCreateProviderResponse { + const message = createBaseMsgCreateProviderResponse(); + return message; + }, + toAmino(_: MsgCreateProviderResponse): MsgCreateProviderResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgCreateProviderResponseAminoMsg): MsgCreateProviderResponse { + return MsgCreateProviderResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgCreateProviderResponse): MsgCreateProviderResponseAminoMsg { + return { + type: "akash/provider/v1beta2/testonly-create-provider-response", + value: MsgCreateProviderResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgCreateProviderResponseProtoMsg): MsgCreateProviderResponse { + return MsgCreateProviderResponse.decode(message.value); + }, + toProto(message: MsgCreateProviderResponse): Uint8Array { + return MsgCreateProviderResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgCreateProviderResponse): MsgCreateProviderResponseProtoMsg { + return { + typeUrl: "/akash.provider.v1beta2.MsgCreateProviderResponse", + value: MsgCreateProviderResponse.encode(message).finish() + }; + } +}; +function createBaseMsgUpdateProvider(): MsgUpdateProvider { + return { + owner: "", + hostUri: "", + attributes: [], + info: ProviderInfo.fromPartial({}) + }; +} +export const MsgUpdateProvider = { + typeUrl: "/akash.provider.v1beta2.MsgUpdateProvider", + encode(message: MsgUpdateProvider, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.owner !== undefined) { + writer.uint32(10).string(message.owner); + } + if (message.hostUri !== undefined) { + writer.uint32(18).string(message.hostUri); + } + for (const v of message.attributes) { + Attribute.encode(v!, writer.uint32(26).fork()).ldelim(); + } + if (message.info !== undefined) { + ProviderInfo.encode(message.info, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgUpdateProvider { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgUpdateProvider(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.owner = reader.string(); + break; + case 2: + message.hostUri = reader.string(); + break; + case 3: + message.attributes.push(Attribute.decode(reader, reader.uint32())); + break; + case 4: + message.info = ProviderInfo.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgUpdateProvider { + const obj = createBaseMsgUpdateProvider(); + if (isSet(object.owner)) obj.owner = String(object.owner); + if (isSet(object.hostUri)) obj.hostUri = String(object.hostUri); + if (Array.isArray(object?.attributes)) obj.attributes = object.attributes.map((e: any) => Attribute.fromJSON(e)); + if (isSet(object.info)) obj.info = ProviderInfo.fromJSON(object.info); + return obj; + }, + toJSON(message: MsgUpdateProvider): JsonSafe { + const obj: any = {}; + message.owner !== undefined && (obj.owner = message.owner); + message.hostUri !== undefined && (obj.hostUri = message.hostUri); + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? Attribute.toJSON(e) : undefined); + } else { + obj.attributes = []; + } + message.info !== undefined && (obj.info = message.info ? ProviderInfo.toJSON(message.info) : undefined); + return obj; + }, + fromPartial, I>>(object: I): MsgUpdateProvider { + const message = createBaseMsgUpdateProvider(); + message.owner = object.owner ?? ""; + message.hostUri = object.hostUri ?? ""; + message.attributes = object.attributes?.map(e => Attribute.fromPartial(e)) || []; + if (object.info !== undefined && object.info !== null) { + message.info = ProviderInfo.fromPartial(object.info); + } + return message; + }, + fromSDK(object: MsgUpdateProviderSDKType): MsgUpdateProvider { + return { + owner: object?.owner, + hostUri: object?.host_uri, + attributes: Array.isArray(object?.attributes) ? object.attributes.map((e: any) => Attribute.fromSDK(e)) : [], + info: object.info ? ProviderInfo.fromSDK(object.info) : undefined + }; + }, + fromSDKJSON(object: any): MsgUpdateProviderSDKType { + return { + owner: isSet(object.owner) ? String(object.owner) : "", + host_uri: isSet(object.host_uri) ? String(object.host_uri) : "", + attributes: Array.isArray(object?.attributes) ? object.attributes.map((e: any) => Attribute.fromSDKJSON(e)) : [], + info: isSet(object.info) ? ProviderInfo.fromSDKJSON(object.info) : undefined + }; + }, + toSDK(message: MsgUpdateProvider): MsgUpdateProviderSDKType { + const obj: any = {}; + obj.owner = message.owner; + obj.host_uri = message.hostUri; + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? Attribute.toSDK(e) : undefined); + } else { + obj.attributes = []; + } + message.info !== undefined && (obj.info = message.info ? ProviderInfo.toSDK(message.info) : undefined); + return obj; + }, + fromAmino(object: MsgUpdateProviderAmino): MsgUpdateProvider { + const message = createBaseMsgUpdateProvider(); + if (object.owner !== undefined && object.owner !== null) { + message.owner = object.owner; + } + if (object.host_uri !== undefined && object.host_uri !== null) { + message.hostUri = object.host_uri; + } + message.attributes = object.attributes?.map(e => Attribute.fromAmino(e)) || []; + if (object.info !== undefined && object.info !== null) { + message.info = ProviderInfo.fromAmino(object.info); + } + return message; + }, + toAmino(message: MsgUpdateProvider): MsgUpdateProviderAmino { + const obj: any = {}; + obj.owner = message.owner ?? ""; + obj.host_uri = message.hostUri ?? ""; + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? Attribute.toAmino(e) : undefined); + } else { + obj.attributes = message.attributes; + } + obj.info = message.info ? ProviderInfo.toAmino(message.info) : ProviderInfo.toAmino(ProviderInfo.fromPartial({})); + return obj; + }, + fromAminoMsg(object: MsgUpdateProviderAminoMsg): MsgUpdateProvider { + return MsgUpdateProvider.fromAmino(object.value); + }, + toAminoMsg(message: MsgUpdateProvider): MsgUpdateProviderAminoMsg { + return { + type: "akash/provider/v1beta2/testonly-update-provider", + value: MsgUpdateProvider.toAmino(message) + }; + }, + fromProtoMsg(message: MsgUpdateProviderProtoMsg): MsgUpdateProvider { + return MsgUpdateProvider.decode(message.value); + }, + toProto(message: MsgUpdateProvider): Uint8Array { + return MsgUpdateProvider.encode(message).finish(); + }, + toProtoMsg(message: MsgUpdateProvider): MsgUpdateProviderProtoMsg { + return { + typeUrl: "/akash.provider.v1beta2.MsgUpdateProvider", + value: MsgUpdateProvider.encode(message).finish() + }; + } +}; +function createBaseMsgUpdateProviderResponse(): MsgUpdateProviderResponse { + return {}; +} +export const MsgUpdateProviderResponse = { + typeUrl: "/akash.provider.v1beta2.MsgUpdateProviderResponse", + encode(_: MsgUpdateProviderResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgUpdateProviderResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgUpdateProviderResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgUpdateProviderResponse { + const obj = createBaseMsgUpdateProviderResponse(); + return obj; + }, + toJSON(_: MsgUpdateProviderResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): MsgUpdateProviderResponse { + const message = createBaseMsgUpdateProviderResponse(); + return message; + }, + fromSDK(_: MsgUpdateProviderResponseSDKType): MsgUpdateProviderResponse { + return {}; + }, + fromSDKJSON(_: any): MsgUpdateProviderResponseSDKType { + return {}; + }, + toSDK(_: MsgUpdateProviderResponse): MsgUpdateProviderResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgUpdateProviderResponseAmino): MsgUpdateProviderResponse { + const message = createBaseMsgUpdateProviderResponse(); + return message; + }, + toAmino(_: MsgUpdateProviderResponse): MsgUpdateProviderResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgUpdateProviderResponseAminoMsg): MsgUpdateProviderResponse { + return MsgUpdateProviderResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgUpdateProviderResponse): MsgUpdateProviderResponseAminoMsg { + return { + type: "akash/provider/v1beta2/testonly-update-provider-response", + value: MsgUpdateProviderResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgUpdateProviderResponseProtoMsg): MsgUpdateProviderResponse { + return MsgUpdateProviderResponse.decode(message.value); + }, + toProto(message: MsgUpdateProviderResponse): Uint8Array { + return MsgUpdateProviderResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgUpdateProviderResponse): MsgUpdateProviderResponseProtoMsg { + return { + typeUrl: "/akash.provider.v1beta2.MsgUpdateProviderResponse", + value: MsgUpdateProviderResponse.encode(message).finish() + }; + } +}; +function createBaseMsgDeleteProvider(): MsgDeleteProvider { + return { + owner: "" + }; +} +export const MsgDeleteProvider = { + typeUrl: "/akash.provider.v1beta2.MsgDeleteProvider", + encode(message: MsgDeleteProvider, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.owner !== undefined) { + writer.uint32(10).string(message.owner); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgDeleteProvider { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgDeleteProvider(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.owner = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgDeleteProvider { + const obj = createBaseMsgDeleteProvider(); + if (isSet(object.owner)) obj.owner = String(object.owner); + return obj; + }, + toJSON(message: MsgDeleteProvider): JsonSafe { + const obj: any = {}; + message.owner !== undefined && (obj.owner = message.owner); + return obj; + }, + fromPartial, I>>(object: I): MsgDeleteProvider { + const message = createBaseMsgDeleteProvider(); + message.owner = object.owner ?? ""; + return message; + }, + fromSDK(object: MsgDeleteProviderSDKType): MsgDeleteProvider { + return { + owner: object?.owner + }; + }, + fromSDKJSON(object: any): MsgDeleteProviderSDKType { + return { + owner: isSet(object.owner) ? String(object.owner) : "" + }; + }, + toSDK(message: MsgDeleteProvider): MsgDeleteProviderSDKType { + const obj: any = {}; + obj.owner = message.owner; + return obj; + }, + fromAmino(object: MsgDeleteProviderAmino): MsgDeleteProvider { + const message = createBaseMsgDeleteProvider(); + if (object.owner !== undefined && object.owner !== null) { + message.owner = object.owner; + } + return message; + }, + toAmino(message: MsgDeleteProvider): MsgDeleteProviderAmino { + const obj: any = {}; + obj.owner = message.owner ?? ""; + return obj; + }, + fromAminoMsg(object: MsgDeleteProviderAminoMsg): MsgDeleteProvider { + return MsgDeleteProvider.fromAmino(object.value); + }, + toAminoMsg(message: MsgDeleteProvider): MsgDeleteProviderAminoMsg { + return { + type: "akash/provider/v1beta2/testonly-delete-provider", + value: MsgDeleteProvider.toAmino(message) + }; + }, + fromProtoMsg(message: MsgDeleteProviderProtoMsg): MsgDeleteProvider { + return MsgDeleteProvider.decode(message.value); + }, + toProto(message: MsgDeleteProvider): Uint8Array { + return MsgDeleteProvider.encode(message).finish(); + }, + toProtoMsg(message: MsgDeleteProvider): MsgDeleteProviderProtoMsg { + return { + typeUrl: "/akash.provider.v1beta2.MsgDeleteProvider", + value: MsgDeleteProvider.encode(message).finish() + }; + } +}; +function createBaseMsgDeleteProviderResponse(): MsgDeleteProviderResponse { + return {}; +} +export const MsgDeleteProviderResponse = { + typeUrl: "/akash.provider.v1beta2.MsgDeleteProviderResponse", + encode(_: MsgDeleteProviderResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgDeleteProviderResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgDeleteProviderResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgDeleteProviderResponse { + const obj = createBaseMsgDeleteProviderResponse(); + return obj; + }, + toJSON(_: MsgDeleteProviderResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial, I>>(_: I): MsgDeleteProviderResponse { + const message = createBaseMsgDeleteProviderResponse(); + return message; + }, + fromSDK(_: MsgDeleteProviderResponseSDKType): MsgDeleteProviderResponse { + return {}; + }, + fromSDKJSON(_: any): MsgDeleteProviderResponseSDKType { + return {}; + }, + toSDK(_: MsgDeleteProviderResponse): MsgDeleteProviderResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgDeleteProviderResponseAmino): MsgDeleteProviderResponse { + const message = createBaseMsgDeleteProviderResponse(); + return message; + }, + toAmino(_: MsgDeleteProviderResponse): MsgDeleteProviderResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgDeleteProviderResponseAminoMsg): MsgDeleteProviderResponse { + return MsgDeleteProviderResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgDeleteProviderResponse): MsgDeleteProviderResponseAminoMsg { + return { + type: "akash/provider/v1beta2/testonly-delete-provider-response", + value: MsgDeleteProviderResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgDeleteProviderResponseProtoMsg): MsgDeleteProviderResponse { + return MsgDeleteProviderResponse.decode(message.value); + }, + toProto(message: MsgDeleteProviderResponse): Uint8Array { + return MsgDeleteProviderResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgDeleteProviderResponse): MsgDeleteProviderResponseProtoMsg { + return { + typeUrl: "/akash.provider.v1beta2.MsgDeleteProviderResponse", + value: MsgDeleteProviderResponse.encode(message).finish() + }; + } +}; +function createBaseProvider(): Provider { + return { + owner: "", + hostUri: "", + attributes: [], + info: ProviderInfo.fromPartial({}) + }; +} +export const Provider = { + typeUrl: "/akash.provider.v1beta2.Provider", + encode(message: Provider, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.owner !== undefined) { + writer.uint32(10).string(message.owner); + } + if (message.hostUri !== undefined) { + writer.uint32(18).string(message.hostUri); + } + for (const v of message.attributes) { + Attribute.encode(v!, writer.uint32(26).fork()).ldelim(); + } + if (message.info !== undefined) { + ProviderInfo.encode(message.info, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Provider { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseProvider(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.owner = reader.string(); + break; + case 2: + message.hostUri = reader.string(); + break; + case 3: + message.attributes.push(Attribute.decode(reader, reader.uint32())); + break; + case 4: + message.info = ProviderInfo.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Provider { + const obj = createBaseProvider(); + if (isSet(object.owner)) obj.owner = String(object.owner); + if (isSet(object.hostUri)) obj.hostUri = String(object.hostUri); + if (Array.isArray(object?.attributes)) obj.attributes = object.attributes.map((e: any) => Attribute.fromJSON(e)); + if (isSet(object.info)) obj.info = ProviderInfo.fromJSON(object.info); + return obj; + }, + toJSON(message: Provider): JsonSafe { + const obj: any = {}; + message.owner !== undefined && (obj.owner = message.owner); + message.hostUri !== undefined && (obj.hostUri = message.hostUri); + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? Attribute.toJSON(e) : undefined); + } else { + obj.attributes = []; + } + message.info !== undefined && (obj.info = message.info ? ProviderInfo.toJSON(message.info) : undefined); + return obj; + }, + fromPartial, I>>(object: I): Provider { + const message = createBaseProvider(); + message.owner = object.owner ?? ""; + message.hostUri = object.hostUri ?? ""; + message.attributes = object.attributes?.map(e => Attribute.fromPartial(e)) || []; + if (object.info !== undefined && object.info !== null) { + message.info = ProviderInfo.fromPartial(object.info); + } + return message; + }, + fromSDK(object: ProviderSDKType): Provider { + return { + owner: object?.owner, + hostUri: object?.host_uri, + attributes: Array.isArray(object?.attributes) ? object.attributes.map((e: any) => Attribute.fromSDK(e)) : [], + info: object.info ? ProviderInfo.fromSDK(object.info) : undefined + }; + }, + fromSDKJSON(object: any): ProviderSDKType { + return { + owner: isSet(object.owner) ? String(object.owner) : "", + host_uri: isSet(object.host_uri) ? String(object.host_uri) : "", + attributes: Array.isArray(object?.attributes) ? object.attributes.map((e: any) => Attribute.fromSDKJSON(e)) : [], + info: isSet(object.info) ? ProviderInfo.fromSDKJSON(object.info) : undefined + }; + }, + toSDK(message: Provider): ProviderSDKType { + const obj: any = {}; + obj.owner = message.owner; + obj.host_uri = message.hostUri; + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? Attribute.toSDK(e) : undefined); + } else { + obj.attributes = []; + } + message.info !== undefined && (obj.info = message.info ? ProviderInfo.toSDK(message.info) : undefined); + return obj; + }, + fromAmino(object: ProviderAmino): Provider { + const message = createBaseProvider(); + if (object.owner !== undefined && object.owner !== null) { + message.owner = object.owner; + } + if (object.host_uri !== undefined && object.host_uri !== null) { + message.hostUri = object.host_uri; + } + message.attributes = object.attributes?.map(e => Attribute.fromAmino(e)) || []; + if (object.info !== undefined && object.info !== null) { + message.info = ProviderInfo.fromAmino(object.info); + } + return message; + }, + toAmino(message: Provider): ProviderAmino { + const obj: any = {}; + obj.owner = message.owner ?? ""; + obj.host_uri = message.hostUri ?? ""; + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? Attribute.toAmino(e) : undefined); + } else { + obj.attributes = message.attributes; + } + obj.info = message.info ? ProviderInfo.toAmino(message.info) : ProviderInfo.toAmino(ProviderInfo.fromPartial({})); + return obj; + }, + fromAminoMsg(object: ProviderAminoMsg): Provider { + return Provider.fromAmino(object.value); + }, + toAminoMsg(message: Provider): ProviderAminoMsg { + return { + type: "akash/provider/v1beta2/provider", + value: Provider.toAmino(message) + }; + }, + fromProtoMsg(message: ProviderProtoMsg): Provider { + return Provider.decode(message.value); + }, + toProto(message: Provider): Uint8Array { + return Provider.encode(message).finish(); + }, + toProtoMsg(message: Provider): ProviderProtoMsg { + return { + typeUrl: "/akash.provider.v1beta2.Provider", + value: Provider.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/provider/v1beta2/query.lcd.ts b/__fixtures__/v-next/outputicjsdeps/akash/provider/v1beta2/query.lcd.ts new file mode 100644 index 0000000000..86851c73bf --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/provider/v1beta2/query.lcd.ts @@ -0,0 +1,33 @@ +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../../cosmos/base/query/v1beta1/pagination.js"; +import { Provider, ProviderSDKType } from "./provider.js"; +import { setPaginationParams } from "../../../helpers.js"; +import { LCDClient } from "@cosmology/lcd"; +import { QueryProvidersRequest, QueryProvidersRequestSDKType, QueryProvidersResponse, QueryProvidersResponseSDKType, QueryProviderRequest, QueryProviderRequestSDKType, QueryProviderResponse, QueryProviderResponseSDKType } from "./query.js"; +export class LCDQueryClient { + req: LCDClient; + constructor({ + requestClient + }: { + requestClient: LCDClient; + }) { + this.req = requestClient; + } + /* Providers queries providers */ + providers = async (params: QueryProvidersRequest = { + pagination: PageRequest.fromPartial({}) + }): Promise => { + const options: any = { + params: {} + }; + if (typeof params?.pagination !== "undefined") { + setPaginationParams(options, params.pagination); + } + const endpoint = `akash/provider/v1beta2/providers`; + return QueryProvidersResponse.fromSDKJSON(await this.req.get(endpoint, options)); + }; + /* Provider queries provider details */ + provider = async (params: QueryProviderRequest): Promise => { + const endpoint = `akash/provider/v1beta2/providers/${params.owner}`; + return QueryProviderResponse.fromSDKJSON(await this.req.get(endpoint)); + }; +} \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/provider/v1beta2/query.rpc.Query.ts b/__fixtures__/v-next/outputicjsdeps/akash/provider/v1beta2/query.rpc.Query.ts new file mode 100644 index 0000000000..ca9b6e7fa6 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/provider/v1beta2/query.rpc.Query.ts @@ -0,0 +1,45 @@ +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../../cosmos/base/query/v1beta1/pagination.js"; +import { Provider, ProviderSDKType } from "./provider.js"; +import { Rpc } from "../../../helpers.js"; +import { BinaryReader } from "../../../binary.js"; +import { QueryClient, createProtobufRpcClient } from "@cosmjs/stargate"; +import { QueryProvidersRequest, QueryProvidersRequestSDKType, QueryProvidersResponse, QueryProvidersResponseSDKType, QueryProviderRequest, QueryProviderRequestSDKType, QueryProviderResponse, QueryProviderResponseSDKType } from "./query.js"; +/** Query defines the gRPC querier service */ +export interface Query { + /** Providers queries providers */ + providers(request?: QueryProvidersRequest): Promise; + /** Provider queries provider details */ + provider(request: QueryProviderRequest): Promise; +} +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + } + /* Providers queries providers */ + providers = async (request: QueryProvidersRequest = { + pagination: PageRequest.fromPartial({}) + }): Promise => { + const data = QueryProvidersRequest.encode(request).finish(); + const promise = this.rpc.request("akash.provider.v1beta2.Query", "Providers", data); + return promise.then(data => QueryProvidersResponse.decode(new BinaryReader(data))); + }; + /* Provider queries provider details */ + provider = async (request: QueryProviderRequest): Promise => { + const data = QueryProviderRequest.encode(request).finish(); + const promise = this.rpc.request("akash.provider.v1beta2.Query", "Provider", data); + return promise.then(data => QueryProviderResponse.decode(new BinaryReader(data))); + }; +} +export const createRpcQueryExtension = (base: QueryClient) => { + const rpc = createProtobufRpcClient(base); + const queryService = new QueryClientImpl(rpc); + return { + providers(request?: QueryProvidersRequest): Promise { + return queryService.providers(request); + }, + provider(request: QueryProviderRequest): Promise { + return queryService.provider(request); + } + }; +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/provider/v1beta2/query.rpc.func.ts b/__fixtures__/v-next/outputicjsdeps/akash/provider/v1beta2/query.rpc.func.ts new file mode 100644 index 0000000000..90199b2f13 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/provider/v1beta2/query.rpc.func.ts @@ -0,0 +1,25 @@ +import { RpcResolver, buildQuery } from "../../../helper-func-types"; +import { buildUseQuery } from "../../../react-query"; +import { QueryProvidersRequest, QueryProvidersResponse, QueryProviderRequest, QueryProviderResponse } from "./query"; +export const createGetProviders = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryProvidersRequest.encode, + decode: QueryProvidersResponse.decode, + service: "akash.provider.v1beta2.Query", + method: "Providers", + getRpcInstance: getRpcInstance +}); +export const useGetProviders = buildUseQuery({ + builderQueryFn: createGetProviders, + queryKeyPrefix: "ProvidersQuery" +}); +export const createGetProvider = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryProviderRequest.encode, + decode: QueryProviderResponse.decode, + service: "akash.provider.v1beta2.Query", + method: "Provider", + getRpcInstance: getRpcInstance +}); +export const useGetProvider = buildUseQuery({ + builderQueryFn: createGetProvider, + queryKeyPrefix: "ProviderQuery" +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/provider/v1beta2/query.ts b/__fixtures__/v-next/outputicjsdeps/akash/provider/v1beta2/query.ts new file mode 100644 index 0000000000..88b8d7245e --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/provider/v1beta2/query.ts @@ -0,0 +1,465 @@ +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../../cosmos/base/query/v1beta1/pagination.js"; +import { Provider, ProviderSDKType } from "./provider.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial, Exact } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "akash.provider.v1beta2"; +/** QueryProvidersRequest is request type for the Query/Providers RPC method */ +export interface QueryProvidersRequest { + pagination?: PageRequest; +} +export interface QueryProvidersRequestProtoMsg { + typeUrl: "/akash.provider.v1beta2.QueryProvidersRequest"; + value: Uint8Array; +} +/** QueryProvidersRequest is request type for the Query/Providers RPC method */ +export interface QueryProvidersRequestSDKType { + pagination?: PageRequestSDKType; +} +/** QueryProvidersResponse is response type for the Query/Providers RPC method */ +export interface QueryProvidersResponse { + providers: Provider[]; + pagination?: PageResponse; +} +export interface QueryProvidersResponseProtoMsg { + typeUrl: "/akash.provider.v1beta2.QueryProvidersResponse"; + value: Uint8Array; +} +/** QueryProvidersResponse is response type for the Query/Providers RPC method */ +export interface QueryProvidersResponseSDKType { + providers: ProviderSDKType[]; + pagination?: PageResponseSDKType; +} +/** QueryProviderRequest is request type for the Query/Provider RPC method */ +export interface QueryProviderRequest { + owner: string; +} +export interface QueryProviderRequestProtoMsg { + typeUrl: "/akash.provider.v1beta2.QueryProviderRequest"; + value: Uint8Array; +} +/** QueryProviderRequest is request type for the Query/Provider RPC method */ +export interface QueryProviderRequestSDKType { + owner: string; +} +/** QueryProviderResponse is response type for the Query/Provider RPC method */ +export interface QueryProviderResponse { + provider: Provider; +} +export interface QueryProviderResponseProtoMsg { + typeUrl: "/akash.provider.v1beta2.QueryProviderResponse"; + value: Uint8Array; +} +/** QueryProviderResponse is response type for the Query/Provider RPC method */ +export interface QueryProviderResponseSDKType { + provider: ProviderSDKType; +} +function createBaseQueryProvidersRequest(): QueryProvidersRequest { + return { + pagination: undefined + }; +} +export const QueryProvidersRequest = { + typeUrl: "/akash.provider.v1beta2.QueryProvidersRequest", + encode(message: QueryProvidersRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryProvidersRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryProvidersRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryProvidersRequest { + const obj = createBaseQueryProvidersRequest(); + if (isSet(object.pagination)) obj.pagination = PageRequest.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryProvidersRequest): JsonSafe { + const obj: any = {}; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryProvidersRequest { + const message = createBaseQueryProvidersRequest(); + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryProvidersRequestSDKType): QueryProvidersRequest { + return { + pagination: object.pagination ? PageRequest.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryProvidersRequestSDKType { + return { + pagination: isSet(object.pagination) ? PageRequest.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryProvidersRequest): QueryProvidersRequestSDKType { + const obj: any = {}; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryProvidersRequestAmino): QueryProvidersRequest { + const message = createBaseQueryProvidersRequest(); + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryProvidersRequest): QueryProvidersRequestAmino { + const obj: any = {}; + obj.pagination = message.pagination ? PageRequest.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryProvidersRequestAminoMsg): QueryProvidersRequest { + return QueryProvidersRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryProvidersRequest): QueryProvidersRequestAminoMsg { + return { + type: "akash/provider/v1beta2/query-providers-request", + value: QueryProvidersRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryProvidersRequestProtoMsg): QueryProvidersRequest { + return QueryProvidersRequest.decode(message.value); + }, + toProto(message: QueryProvidersRequest): Uint8Array { + return QueryProvidersRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryProvidersRequest): QueryProvidersRequestProtoMsg { + return { + typeUrl: "/akash.provider.v1beta2.QueryProvidersRequest", + value: QueryProvidersRequest.encode(message).finish() + }; + } +}; +function createBaseQueryProvidersResponse(): QueryProvidersResponse { + return { + providers: [], + pagination: undefined + }; +} +export const QueryProvidersResponse = { + typeUrl: "/akash.provider.v1beta2.QueryProvidersResponse", + encode(message: QueryProvidersResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.providers) { + Provider.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryProvidersResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryProvidersResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.providers.push(Provider.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryProvidersResponse { + const obj = createBaseQueryProvidersResponse(); + if (Array.isArray(object?.providers)) obj.providers = object.providers.map((e: any) => Provider.fromJSON(e)); + if (isSet(object.pagination)) obj.pagination = PageResponse.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryProvidersResponse): JsonSafe { + const obj: any = {}; + if (message.providers) { + obj.providers = message.providers.map(e => e ? Provider.toJSON(e) : undefined); + } else { + obj.providers = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryProvidersResponse { + const message = createBaseQueryProvidersResponse(); + message.providers = object.providers?.map(e => Provider.fromPartial(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryProvidersResponseSDKType): QueryProvidersResponse { + return { + providers: Array.isArray(object?.providers) ? object.providers.map((e: any) => Provider.fromSDK(e)) : [], + pagination: object.pagination ? PageResponse.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryProvidersResponseSDKType { + return { + providers: Array.isArray(object?.providers) ? object.providers.map((e: any) => Provider.fromSDKJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryProvidersResponse): QueryProvidersResponseSDKType { + const obj: any = {}; + if (message.providers) { + obj.providers = message.providers.map(e => e ? Provider.toSDK(e) : undefined); + } else { + obj.providers = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryProvidersResponseAmino): QueryProvidersResponse { + const message = createBaseQueryProvidersResponse(); + message.providers = object.providers?.map(e => Provider.fromAmino(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryProvidersResponse): QueryProvidersResponseAmino { + const obj: any = {}; + if (message.providers) { + obj.providers = message.providers.map(e => e ? Provider.toAmino(e) : undefined); + } else { + obj.providers = message.providers; + } + obj.pagination = message.pagination ? PageResponse.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryProvidersResponseAminoMsg): QueryProvidersResponse { + return QueryProvidersResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryProvidersResponse): QueryProvidersResponseAminoMsg { + return { + type: "akash/provider/v1beta2/query-providers-response", + value: QueryProvidersResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryProvidersResponseProtoMsg): QueryProvidersResponse { + return QueryProvidersResponse.decode(message.value); + }, + toProto(message: QueryProvidersResponse): Uint8Array { + return QueryProvidersResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryProvidersResponse): QueryProvidersResponseProtoMsg { + return { + typeUrl: "/akash.provider.v1beta2.QueryProvidersResponse", + value: QueryProvidersResponse.encode(message).finish() + }; + } +}; +function createBaseQueryProviderRequest(): QueryProviderRequest { + return { + owner: "" + }; +} +export const QueryProviderRequest = { + typeUrl: "/akash.provider.v1beta2.QueryProviderRequest", + encode(message: QueryProviderRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.owner !== undefined) { + writer.uint32(10).string(message.owner); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryProviderRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryProviderRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.owner = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryProviderRequest { + const obj = createBaseQueryProviderRequest(); + if (isSet(object.owner)) obj.owner = String(object.owner); + return obj; + }, + toJSON(message: QueryProviderRequest): JsonSafe { + const obj: any = {}; + message.owner !== undefined && (obj.owner = message.owner); + return obj; + }, + fromPartial, I>>(object: I): QueryProviderRequest { + const message = createBaseQueryProviderRequest(); + message.owner = object.owner ?? ""; + return message; + }, + fromSDK(object: QueryProviderRequestSDKType): QueryProviderRequest { + return { + owner: object?.owner + }; + }, + fromSDKJSON(object: any): QueryProviderRequestSDKType { + return { + owner: isSet(object.owner) ? String(object.owner) : "" + }; + }, + toSDK(message: QueryProviderRequest): QueryProviderRequestSDKType { + const obj: any = {}; + obj.owner = message.owner; + return obj; + }, + fromAmino(object: QueryProviderRequestAmino): QueryProviderRequest { + const message = createBaseQueryProviderRequest(); + if (object.owner !== undefined && object.owner !== null) { + message.owner = object.owner; + } + return message; + }, + toAmino(message: QueryProviderRequest): QueryProviderRequestAmino { + const obj: any = {}; + obj.owner = message.owner === "" ? undefined : message.owner; + return obj; + }, + fromAminoMsg(object: QueryProviderRequestAminoMsg): QueryProviderRequest { + return QueryProviderRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryProviderRequest): QueryProviderRequestAminoMsg { + return { + type: "akash/provider/v1beta2/query-provider-request", + value: QueryProviderRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryProviderRequestProtoMsg): QueryProviderRequest { + return QueryProviderRequest.decode(message.value); + }, + toProto(message: QueryProviderRequest): Uint8Array { + return QueryProviderRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryProviderRequest): QueryProviderRequestProtoMsg { + return { + typeUrl: "/akash.provider.v1beta2.QueryProviderRequest", + value: QueryProviderRequest.encode(message).finish() + }; + } +}; +function createBaseQueryProviderResponse(): QueryProviderResponse { + return { + provider: Provider.fromPartial({}) + }; +} +export const QueryProviderResponse = { + typeUrl: "/akash.provider.v1beta2.QueryProviderResponse", + encode(message: QueryProviderResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.provider !== undefined) { + Provider.encode(message.provider, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryProviderResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryProviderResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.provider = Provider.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryProviderResponse { + const obj = createBaseQueryProviderResponse(); + if (isSet(object.provider)) obj.provider = Provider.fromJSON(object.provider); + return obj; + }, + toJSON(message: QueryProviderResponse): JsonSafe { + const obj: any = {}; + message.provider !== undefined && (obj.provider = message.provider ? Provider.toJSON(message.provider) : undefined); + return obj; + }, + fromPartial, I>>(object: I): QueryProviderResponse { + const message = createBaseQueryProviderResponse(); + if (object.provider !== undefined && object.provider !== null) { + message.provider = Provider.fromPartial(object.provider); + } + return message; + }, + fromSDK(object: QueryProviderResponseSDKType): QueryProviderResponse { + return { + provider: object.provider ? Provider.fromSDK(object.provider) : undefined + }; + }, + fromSDKJSON(object: any): QueryProviderResponseSDKType { + return { + provider: isSet(object.provider) ? Provider.fromSDKJSON(object.provider) : undefined + }; + }, + toSDK(message: QueryProviderResponse): QueryProviderResponseSDKType { + const obj: any = {}; + message.provider !== undefined && (obj.provider = message.provider ? Provider.toSDK(message.provider) : undefined); + return obj; + }, + fromAmino(object: QueryProviderResponseAmino): QueryProviderResponse { + const message = createBaseQueryProviderResponse(); + if (object.provider !== undefined && object.provider !== null) { + message.provider = Provider.fromAmino(object.provider); + } + return message; + }, + toAmino(message: QueryProviderResponse): QueryProviderResponseAmino { + const obj: any = {}; + obj.provider = message.provider ? Provider.toAmino(message.provider) : undefined; + return obj; + }, + fromAminoMsg(object: QueryProviderResponseAminoMsg): QueryProviderResponse { + return QueryProviderResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryProviderResponse): QueryProviderResponseAminoMsg { + return { + type: "akash/provider/v1beta2/query-provider-response", + value: QueryProviderResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryProviderResponseProtoMsg): QueryProviderResponse { + return QueryProviderResponse.decode(message.value); + }, + toProto(message: QueryProviderResponse): Uint8Array { + return QueryProviderResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryProviderResponse): QueryProviderResponseProtoMsg { + return { + typeUrl: "/akash.provider.v1beta2.QueryProviderResponse", + value: QueryProviderResponse.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/rpc.query.ts b/__fixtures__/v-next/outputicjsdeps/akash/rpc.query.ts new file mode 100644 index 0000000000..a55e40d7f3 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/rpc.query.ts @@ -0,0 +1,94 @@ +import { Rpc } from "../helpers.js"; +import { connectComet, HttpEndpoint } from "@cosmjs/tendermint-rpc"; +import { QueryClient } from "@cosmjs/stargate"; +export const createRPCQueryClient = async ({ + rpcEndpoint +}: { + rpcEndpoint: string | HttpEndpoint; +}) => { + const tmClient = await connectComet(rpcEndpoint); + const client = new QueryClient(tmClient); + return { + akash: { + audit: { + v1beta2: (await import("./audit/v1beta2/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + cert: { + v1beta2: (await import("./cert/v1beta2/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + deployment: { + v1beta2: (await import("./deployment/v1beta2/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + escrow: { + v1beta1: (await import("./escrow/v1beta1/query.rpc.Query.js")).createRpcQueryExtension(client), + v1beta2: (await import("./escrow/v1beta2/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + market: { + v1beta2: (await import("./market/v1beta2/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + provider: { + v1beta2: (await import("./provider/v1beta2/query.rpc.Query.js")).createRpcQueryExtension(client) + } + }, + cosmos: { + app: { + v1alpha1: (await import("../cosmos/app/v1alpha1/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + auth: { + v1beta1: (await import("../cosmos/auth/v1beta1/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + authz: { + v1beta1: (await import("../cosmos/authz/v1beta1/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + bank: { + v1beta1: (await import("../cosmos/bank/v1beta1/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + base: { + reflection: { + v1beta1: (await import("../cosmos/base/reflection/v1beta1/reflection.rpc.ReflectionService.js")).createRpcQueryExtension(client), + v2alpha1: (await import("../cosmos/base/reflection/v2alpha1/reflection.rpc.ReflectionService.js")).createRpcQueryExtension(client) + }, + tendermint: { + v1beta1: (await import("../cosmos/base/tendermint/v1beta1/query.rpc.Service.js")).createRpcQueryExtension(client) + } + }, + distribution: { + v1beta1: (await import("../cosmos/distribution/v1beta1/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + evidence: { + v1beta1: (await import("../cosmos/evidence/v1beta1/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + feegrant: { + v1beta1: (await import("../cosmos/feegrant/v1beta1/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + gov: { + v1: (await import("../cosmos/gov/v1/query.rpc.Query.js")).createRpcQueryExtension(client), + v1beta1: (await import("../cosmos/gov/v1beta1/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + group: { + v1: (await import("../cosmos/group/v1/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + mint: { + v1beta1: (await import("../cosmos/mint/v1beta1/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + nft: { + v1beta1: (await import("../cosmos/nft/v1beta1/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + params: { + v1beta1: (await import("../cosmos/params/v1beta1/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + slashing: { + v1beta1: (await import("../cosmos/slashing/v1beta1/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + staking: { + v1beta1: (await import("../cosmos/staking/v1beta1/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + tx: { + v1beta1: (await import("../cosmos/tx/v1beta1/service.rpc.Service.js")).createRpcQueryExtension(client) + }, + upgrade: { + v1beta1: (await import("../cosmos/upgrade/v1beta1/query.rpc.Query.js")).createRpcQueryExtension(client) + } + } + }; +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/akash/rpc.tx.ts b/__fixtures__/v-next/outputicjsdeps/akash/rpc.tx.ts new file mode 100644 index 0000000000..2295931723 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/akash/rpc.tx.ts @@ -0,0 +1,68 @@ +import { Rpc } from "../helpers.js"; +export const createRPCMsgClient = async ({ + rpc +}: { + rpc: Rpc; +}) => ({ + akash: { + audit: { + v1beta1: new (await import("./audit/v1beta1/audit.rpc.msg.js")).MsgClientImpl(rpc), + v1beta2: new (await import("./audit/v1beta2/audit.rpc.msg.js")).MsgClientImpl(rpc) + }, + cert: { + v1beta2: new (await import("./cert/v1beta2/cert.rpc.msg.js")).MsgClientImpl(rpc) + }, + deployment: { + v1beta2: new (await import("./deployment/v1beta2/service.rpc.msg.js")).MsgClientImpl(rpc) + }, + market: { + v1beta2: new (await import("./market/v1beta2/service.rpc.msg.js")).MsgClientImpl(rpc) + }, + provider: { + v1beta1: new (await import("./provider/v1beta1/provider.rpc.msg.js")).MsgClientImpl(rpc), + v1beta2: new (await import("./provider/v1beta2/provider.rpc.msg.js")).MsgClientImpl(rpc) + } + }, + cosmos: { + authz: { + v1beta1: new (await import("../cosmos/authz/v1beta1/tx.rpc.msg.js")).MsgClientImpl(rpc) + }, + bank: { + v1beta1: new (await import("../cosmos/bank/v1beta1/tx.rpc.msg.js")).MsgClientImpl(rpc) + }, + crisis: { + v1beta1: new (await import("../cosmos/crisis/v1beta1/tx.rpc.msg.js")).MsgClientImpl(rpc) + }, + distribution: { + v1beta1: new (await import("../cosmos/distribution/v1beta1/tx.rpc.msg.js")).MsgClientImpl(rpc) + }, + evidence: { + v1beta1: new (await import("../cosmos/evidence/v1beta1/tx.rpc.msg.js")).MsgClientImpl(rpc) + }, + feegrant: { + v1beta1: new (await import("../cosmos/feegrant/v1beta1/tx.rpc.msg.js")).MsgClientImpl(rpc) + }, + gov: { + v1: new (await import("../cosmos/gov/v1/tx.rpc.msg.js")).MsgClientImpl(rpc), + v1beta1: new (await import("../cosmos/gov/v1beta1/tx.rpc.msg.js")).MsgClientImpl(rpc) + }, + group: { + v1: new (await import("../cosmos/group/v1/tx.rpc.msg.js")).MsgClientImpl(rpc) + }, + nft: { + v1beta1: new (await import("../cosmos/nft/v1beta1/tx.rpc.msg.js")).MsgClientImpl(rpc) + }, + slashing: { + v1beta1: new (await import("../cosmos/slashing/v1beta1/tx.rpc.msg.js")).MsgClientImpl(rpc) + }, + staking: { + v1beta1: new (await import("../cosmos/staking/v1beta1/tx.rpc.msg.js")).MsgClientImpl(rpc) + }, + upgrade: { + v1beta1: new (await import("../cosmos/upgrade/v1beta1/tx.rpc.msg.js")).MsgClientImpl(rpc) + }, + vesting: { + v1beta1: new (await import("../cosmos/vesting/v1beta1/tx.rpc.msg.js")).MsgClientImpl(rpc) + } + } +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/binary.ts b/__fixtures__/v-next/outputicjsdeps/binary.ts new file mode 100644 index 0000000000..fbcdd5dade --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/binary.ts @@ -0,0 +1,534 @@ +/** +* This file and any referenced files were automatically generated by @cosmology/telescope@latest +* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain +* and run the transpile command or npm scripts command that is used to regenerate this bundle. +*/ + + +// Copyright (c) 2016, Daniel Wirtz All rights reserved. + +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: + +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// * Neither the name of its author, nor the names of its contributors +// may be used to endorse or promote products derived from this software +// without specific prior written permission. + +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// --- + +// Code generated by the command line utilities is owned by the owner +// of the input file used when generating it. This code is not +// standalone and requires a support library to be linked with it. This +// support library is itself covered by the above license. + +import { utf8Length, utf8Read, utf8Write } from "./utf8.js"; +import { + int64ToString, + readInt32, + readUInt32, + uInt64ToString, + varint32read, + varint64read, + writeVarint32, + writeVarint64, + int64FromString, + int64Length, + writeFixed32, + writeByte, + zzDecode, + zzEncode, +} from "./varint.js"; + +export enum WireType { + Varint = 0, + + Fixed64 = 1, + + Bytes = 2, + + Fixed32 = 5, +} + +// Reader +export interface IBinaryReader { + buf: Uint8Array; + pos: number; + type: number; + len: number; + tag(): [number, WireType, number]; + skip(length?: number): this; + skipType(wireType: number): this; + uint32(): number; + int32(): number; + sint32(): number; + fixed32(): number; + sfixed32(): number; + int64(): bigint; + uint64(): bigint; + sint64(): bigint; + fixed64(): bigint; + sfixed64(): bigint; + float(): number; + double(): number; + bool(): boolean; + bytes(): Uint8Array; + string(): string; +} + +export class BinaryReader implements IBinaryReader { + buf: Uint8Array; + pos: number; + type: number; + len: number; + + assertBounds(): void { + if (this.pos > this.len) throw new RangeError("premature EOF"); + } + + constructor(buf?: ArrayLike) { + this.buf = buf ? new Uint8Array(buf) : new Uint8Array(0); + this.pos = 0; + this.type = 0; + this.len = this.buf.length; + } + + tag(): [number, WireType, number] { + const tag = this.uint32(), + fieldNo = tag >>> 3, + wireType = tag & 7; + if (fieldNo <= 0 || wireType < 0 || wireType > 5) + throw new Error( + "illegal tag: field no " + fieldNo + " wire type " + wireType + ); + return [fieldNo, wireType, tag]; + } + + skip(length?: number) { + if (typeof length === "number") { + if (this.pos + length > this.len) throw indexOutOfRange(this, length); + this.pos += length; + } else { + do { + if (this.pos >= this.len) throw indexOutOfRange(this); + } while (this.buf[this.pos++] & 128); + } + return this; + } + + skipType(wireType: number) { + switch (wireType) { + case WireType.Varint: + this.skip(); + break; + case WireType.Fixed64: + this.skip(8); + break; + case WireType.Bytes: + this.skip(this.uint32()); + break; + case 3: + while ((wireType = this.uint32() & 7) !== 4) { + this.skipType(wireType); + } + break; + case WireType.Fixed32: + this.skip(4); + break; + + /* istanbul ignore next */ + default: + throw Error("invalid wire type " + wireType + " at offset " + this.pos); + } + return this; + } + + uint32(): number { + return varint32read.bind(this)(); + } + + int32(): number { + return this.uint32() | 0; + } + + sint32(): number { + const num = this.uint32(); + return num % 2 === 1 ? (num + 1) / -2 : num / 2; // zigzag encoding + } + + fixed32(): number { + const val = readUInt32(this.buf, this.pos); + this.pos += 4; + return val; + } + + sfixed32(): number { + const val = readInt32(this.buf, this.pos); + this.pos += 4; + return val; + } + + int64(): bigint { + const [lo, hi] = varint64read.bind(this)(); + return BigInt(int64ToString(lo, hi)); + } + + uint64(): bigint { + const [lo, hi] = varint64read.bind(this)(); + return BigInt(uInt64ToString(lo, hi)); + } + + sint64(): bigint { + let [lo, hi] = varint64read.bind(this)(); + // zig zag + [lo, hi] = zzDecode(lo, hi); + return BigInt(int64ToString(lo, hi)); + } + + fixed64(): bigint { + const lo = this.sfixed32(); + const hi = this.sfixed32(); + return BigInt(uInt64ToString(lo, hi)); + } + sfixed64(): bigint { + const lo = this.sfixed32(); + const hi = this.sfixed32(); + return BigInt(int64ToString(lo, hi)); + } + + float(): number { + throw new Error("float not supported"); + } + + double(): number { + throw new Error("double not supported"); + } + + bool(): boolean { + const [lo, hi] = varint64read.bind(this)(); + return lo !== 0 || hi !== 0; + } + + bytes(): Uint8Array { + const len = this.uint32(), + start = this.pos; + this.pos += len; + this.assertBounds(); + return this.buf.subarray(start, start + len); + } + + string(): string { + const bytes = this.bytes(); + return utf8Read(bytes, 0, bytes.length); + } +} + +// Writer +export interface IBinaryWriter { + len: number; + head: IOp; + tail: IOp; + states: State | null; + finish(): Uint8Array; + fork(): IBinaryWriter; + reset(): IBinaryWriter; + ldelim(): IBinaryWriter; + tag(fieldNo: number, type: WireType): IBinaryWriter; + uint32(value: number): IBinaryWriter; + int32(value: number): IBinaryWriter; + sint32(value: number): IBinaryWriter; + int64(value: string | number | bigint): IBinaryWriter; + uint64: (value: string | number | bigint) => IBinaryWriter; + sint64(value: string | number | bigint): IBinaryWriter; + fixed64(value: string | number | bigint): IBinaryWriter; + sfixed64: (value: string | number | bigint) => IBinaryWriter; + bool(value: boolean): IBinaryWriter; + fixed32(value: number): IBinaryWriter; + sfixed32: (value: number) => IBinaryWriter; + float(value: number): IBinaryWriter; + double(value: number): IBinaryWriter; + bytes(value: Uint8Array): IBinaryWriter; + string(value: string): IBinaryWriter; +} + +interface IOp { + len: number; + next?: IOp; + proceed(buf: Uint8Array | number[], pos: number): void; +} + +class Op implements IOp { + fn?: ((val: T, buf: Uint8Array | number[], pos: number) => void) | null; + len: number; + val: T; + next?: IOp; + + constructor( + fn: + | (( + val: T, + buf: Uint8Array | number[], + pos: number + ) => void | undefined | null) + | null, + len: number, + val: T + ) { + this.fn = fn; + this.len = len; + this.val = val; + } + + proceed(buf: Uint8Array | number[], pos: number) { + if (this.fn) { + this.fn(this.val, buf, pos); + } + } +} + +class State { + head: IOp; + tail: IOp; + len: number; + next: State | null; + + constructor(writer: BinaryWriter) { + this.head = writer.head; + this.tail = writer.tail; + this.len = writer.len; + this.next = writer.states; + } +} + +export class BinaryWriter implements IBinaryWriter { + len = 0; + head: IOp; + tail: IOp; + states: State | null; + + constructor() { + this.head = new Op(null, 0, 0); + this.tail = this.head; + this.states = null; + } + + static create() { + return new BinaryWriter(); + } + + static alloc(size: number): Uint8Array | number[] { + if (typeof Uint8Array !== "undefined") { + return pool( + (size) => new Uint8Array(size), + Uint8Array.prototype.subarray + )(size); + } else { + return new Array(size); + } + } + + private _push( + fn: (val: T, buf: Uint8Array | number[], pos: number) => void, + len: number, + val: T + ) { + this.tail = this.tail.next = new Op(fn, len, val); + this.len += len; + return this; + } + + finish(): Uint8Array { + let head = this.head.next, + pos = 0; + const buf = BinaryWriter.alloc(this.len); + while (head) { + head.proceed(buf, pos); + pos += head.len; + head = head.next; + } + return buf as Uint8Array; + } + + fork(): BinaryWriter { + this.states = new State(this); + this.head = this.tail = new Op(null, 0, 0); + this.len = 0; + return this; + } + + reset(): BinaryWriter { + if (this.states) { + this.head = this.states.head; + this.tail = this.states.tail; + this.len = this.states.len; + this.states = this.states.next; + } else { + this.head = this.tail = new Op(null, 0, 0); + this.len = 0; + } + return this; + } + + ldelim(): BinaryWriter { + const head = this.head, + tail = this.tail, + len = this.len; + this.reset().uint32(len); + if (len) { + this.tail.next = head.next; // skip noop + this.tail = tail; + this.len += len; + } + return this; + } + + tag(fieldNo: number, type: WireType): BinaryWriter { + return this.uint32(((fieldNo << 3) | type) >>> 0); + } + + uint32(value: number): BinaryWriter { + this.len += (this.tail = this.tail.next = + new Op( + writeVarint32, + (value = value >>> 0) < 128 + ? 1 + : value < 16384 + ? 2 + : value < 2097152 + ? 3 + : value < 268435456 + ? 4 + : 5, + value + )).len; + return this; + } + + int32(value: number): BinaryWriter { + return value < 0 + ? this._push(writeVarint64, 10, int64FromString(value.toString())) // 10 bytes per spec + : this.uint32(value); + } + + sint32(value: number): BinaryWriter { + return this.uint32(((value << 1) ^ (value >> 31)) >>> 0); + } + + int64(value: string | number | bigint): BinaryWriter { + const { lo, hi } = int64FromString(value.toString()); + return this._push(writeVarint64, int64Length(lo, hi), { lo, hi }); + } + + // uint64 is the same with int64 + uint64 = BinaryWriter.prototype.int64; + + sint64(value: string | number | bigint): BinaryWriter { + let { lo, hi } = int64FromString(value.toString()); + // zig zag + [lo, hi] = zzEncode(lo, hi); + return this._push(writeVarint64, int64Length(lo, hi), { lo, hi }); + } + + fixed64(value: string | number | bigint): BinaryWriter { + const { lo, hi } = int64FromString(value.toString()); + return this._push(writeFixed32, 4, lo)._push(writeFixed32, 4, hi); + } + + // sfixed64 is the same with fixed64 + sfixed64 = BinaryWriter.prototype.fixed64; + + bool(value: boolean): BinaryWriter { + return this._push(writeByte, 1, value ? 1 : 0); + } + + fixed32(value: number): BinaryWriter { + return this._push(writeFixed32, 4, value >>> 0); + } + + // sfixed32 is the same with fixed32 + sfixed32 = BinaryWriter.prototype.fixed32; + + float(value: number): BinaryWriter { + throw new Error("float not supported" + value); + } + + double(value: number): BinaryWriter { + throw new Error("double not supported" + value); + } + + bytes(value: Uint8Array): BinaryWriter { + const len = value.length >>> 0; + if (!len) return this._push(writeByte, 1, 0); + return this.uint32(len)._push(writeBytes, len, value); + } + + string(value: string): BinaryWriter { + const len = utf8Length(value); + return len + ? this.uint32(len)._push(utf8Write, len, value) + : this._push(writeByte, 1, 0); + } +} + +function writeBytes( + val: Uint8Array | number[], + buf: Uint8Array | number[], + pos: number +) { + if (typeof Uint8Array !== "undefined") { + (buf as Uint8Array).set(val, pos); + } else { + for (let i = 0; i < val.length; ++i) buf[pos + i] = val[i]; + } +} + +function pool( + alloc: (size: number) => Uint8Array, + slice: (begin?: number, end?: number) => Uint8Array, + size?: number +): (size: number) => Uint8Array { + const SIZE = size || 8192; + const MAX = SIZE >>> 1; + let slab: Uint8Array | null = null; + let offset = SIZE; + return function pool_alloc(size): Uint8Array { + if (size < 1 || size > MAX) return alloc(size); + if (offset + size > SIZE) { + slab = alloc(SIZE); + offset = 0; + } + const buf: Uint8Array = slice.call(slab, offset, (offset += size)); + if (offset & 7) + // align to 32 bit + offset = (offset | 7) + 1; + return buf; + }; +} + +function indexOutOfRange(reader: BinaryReader, writeLength?: number) { + return RangeError( + "index out of range: " + + reader.pos + + " + " + + (writeLength || 1) + + " > " + + reader.len + ); +} diff --git a/__fixtures__/v-next/outputicjsdeps/confio/proofs.ts b/__fixtures__/v-next/outputicjsdeps/confio/proofs.ts new file mode 100644 index 0000000000..6f55951877 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/confio/proofs.ts @@ -0,0 +1,2293 @@ +import { BinaryReader, BinaryWriter } from "../binary.js"; +import { isSet, bytesFromBase64, base64FromBytes, DeepPartial } from "../helpers.js"; +import { JsonSafe } from "../json-safe.js"; +export const protobufPackage = "ics23"; +export enum HashOp { + /** NO_HASH - NO_HASH is the default if no data passed. Note this is an illegal argument some places. */ + NO_HASH = 0, + SHA256 = 1, + SHA512 = 2, + KECCAK = 3, + RIPEMD160 = 4, + /** BITCOIN - ripemd160(sha256(x)) */ + BITCOIN = 5, + UNRECOGNIZED = -1, +} +export const HashOpSDKType = HashOp; +export function hashOpFromJSON(object: any): HashOp { + switch (object) { + case 0: + case "NO_HASH": + return HashOp.NO_HASH; + case 1: + case "SHA256": + return HashOp.SHA256; + case 2: + case "SHA512": + return HashOp.SHA512; + case 3: + case "KECCAK": + return HashOp.KECCAK; + case 4: + case "RIPEMD160": + return HashOp.RIPEMD160; + case 5: + case "BITCOIN": + return HashOp.BITCOIN; + case -1: + case "UNRECOGNIZED": + default: + return HashOp.UNRECOGNIZED; + } +} +export function hashOpToJSON(object: HashOp): string { + switch (object) { + case HashOp.NO_HASH: + return "NO_HASH"; + case HashOp.SHA256: + return "SHA256"; + case HashOp.SHA512: + return "SHA512"; + case HashOp.KECCAK: + return "KECCAK"; + case HashOp.RIPEMD160: + return "RIPEMD160"; + case HashOp.BITCOIN: + return "BITCOIN"; + case HashOp.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** + * LengthOp defines how to process the key and value of the LeafOp + * to include length information. After encoding the length with the given + * algorithm, the length will be prepended to the key and value bytes. + * (Each one with it's own encoded length) + */ +export enum LengthOp { + /** NO_PREFIX - NO_PREFIX don't include any length info */ + NO_PREFIX = 0, + /** VAR_PROTO - VAR_PROTO uses protobuf (and go-amino) varint encoding of the length */ + VAR_PROTO = 1, + /** VAR_RLP - VAR_RLP uses rlp int encoding of the length */ + VAR_RLP = 2, + /** FIXED32_BIG - FIXED32_BIG uses big-endian encoding of the length as a 32 bit integer */ + FIXED32_BIG = 3, + /** FIXED32_LITTLE - FIXED32_LITTLE uses little-endian encoding of the length as a 32 bit integer */ + FIXED32_LITTLE = 4, + /** FIXED64_BIG - FIXED64_BIG uses big-endian encoding of the length as a 64 bit integer */ + FIXED64_BIG = 5, + /** FIXED64_LITTLE - FIXED64_LITTLE uses little-endian encoding of the length as a 64 bit integer */ + FIXED64_LITTLE = 6, + /** REQUIRE_32_BYTES - REQUIRE_32_BYTES is like NONE, but will fail if the input is not exactly 32 bytes (sha256 output) */ + REQUIRE_32_BYTES = 7, + /** REQUIRE_64_BYTES - REQUIRE_64_BYTES is like NONE, but will fail if the input is not exactly 64 bytes (sha512 output) */ + REQUIRE_64_BYTES = 8, + UNRECOGNIZED = -1, +} +export const LengthOpSDKType = LengthOp; +export function lengthOpFromJSON(object: any): LengthOp { + switch (object) { + case 0: + case "NO_PREFIX": + return LengthOp.NO_PREFIX; + case 1: + case "VAR_PROTO": + return LengthOp.VAR_PROTO; + case 2: + case "VAR_RLP": + return LengthOp.VAR_RLP; + case 3: + case "FIXED32_BIG": + return LengthOp.FIXED32_BIG; + case 4: + case "FIXED32_LITTLE": + return LengthOp.FIXED32_LITTLE; + case 5: + case "FIXED64_BIG": + return LengthOp.FIXED64_BIG; + case 6: + case "FIXED64_LITTLE": + return LengthOp.FIXED64_LITTLE; + case 7: + case "REQUIRE_32_BYTES": + return LengthOp.REQUIRE_32_BYTES; + case 8: + case "REQUIRE_64_BYTES": + return LengthOp.REQUIRE_64_BYTES; + case -1: + case "UNRECOGNIZED": + default: + return LengthOp.UNRECOGNIZED; + } +} +export function lengthOpToJSON(object: LengthOp): string { + switch (object) { + case LengthOp.NO_PREFIX: + return "NO_PREFIX"; + case LengthOp.VAR_PROTO: + return "VAR_PROTO"; + case LengthOp.VAR_RLP: + return "VAR_RLP"; + case LengthOp.FIXED32_BIG: + return "FIXED32_BIG"; + case LengthOp.FIXED32_LITTLE: + return "FIXED32_LITTLE"; + case LengthOp.FIXED64_BIG: + return "FIXED64_BIG"; + case LengthOp.FIXED64_LITTLE: + return "FIXED64_LITTLE"; + case LengthOp.REQUIRE_32_BYTES: + return "REQUIRE_32_BYTES"; + case LengthOp.REQUIRE_64_BYTES: + return "REQUIRE_64_BYTES"; + case LengthOp.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** + * ExistenceProof takes a key and a value and a set of steps to perform on it. + * The result of peforming all these steps will provide a "root hash", which can + * be compared to the value in a header. + * + * Since it is computationally infeasible to produce a hash collission for any of the used + * cryptographic hash functions, if someone can provide a series of operations to transform + * a given key and value into a root hash that matches some trusted root, these key and values + * must be in the referenced merkle tree. + * + * The only possible issue is maliablity in LeafOp, such as providing extra prefix data, + * which should be controlled by a spec. Eg. with lengthOp as NONE, + * prefix = FOO, key = BAR, value = CHOICE + * and + * prefix = F, key = OOBAR, value = CHOICE + * would produce the same value. + * + * With LengthOp this is tricker but not impossible. Which is why the "leafPrefixEqual" field + * in the ProofSpec is valuable to prevent this mutability. And why all trees should + * length-prefix the data before hashing it. + */ +export interface ExistenceProof { + key: Uint8Array; + value: Uint8Array; + leaf?: LeafOp; + path: InnerOp[]; +} +export interface ExistenceProofProtoMsg { + typeUrl: "/ics23.ExistenceProof"; + value: Uint8Array; +} +/** + * ExistenceProof takes a key and a value and a set of steps to perform on it. + * The result of peforming all these steps will provide a "root hash", which can + * be compared to the value in a header. + * + * Since it is computationally infeasible to produce a hash collission for any of the used + * cryptographic hash functions, if someone can provide a series of operations to transform + * a given key and value into a root hash that matches some trusted root, these key and values + * must be in the referenced merkle tree. + * + * The only possible issue is maliablity in LeafOp, such as providing extra prefix data, + * which should be controlled by a spec. Eg. with lengthOp as NONE, + * prefix = FOO, key = BAR, value = CHOICE + * and + * prefix = F, key = OOBAR, value = CHOICE + * would produce the same value. + * + * With LengthOp this is tricker but not impossible. Which is why the "leafPrefixEqual" field + * in the ProofSpec is valuable to prevent this mutability. And why all trees should + * length-prefix the data before hashing it. + */ +export interface ExistenceProofSDKType { + key: Uint8Array; + value: Uint8Array; + leaf?: LeafOpSDKType; + path: InnerOpSDKType[]; +} +/** + * NonExistenceProof takes a proof of two neighbors, one left of the desired key, + * one right of the desired key. If both proofs are valid AND they are neighbors, + * then there is no valid proof for the given key. + */ +export interface NonExistenceProof { + /** TODO: remove this as unnecessary??? we prove a range */ + key: Uint8Array; + left?: ExistenceProof; + right?: ExistenceProof; +} +export interface NonExistenceProofProtoMsg { + typeUrl: "/ics23.NonExistenceProof"; + value: Uint8Array; +} +/** + * NonExistenceProof takes a proof of two neighbors, one left of the desired key, + * one right of the desired key. If both proofs are valid AND they are neighbors, + * then there is no valid proof for the given key. + */ +export interface NonExistenceProofSDKType { + key: Uint8Array; + left?: ExistenceProofSDKType; + right?: ExistenceProofSDKType; +} +/** CommitmentProof is either an ExistenceProof or a NonExistenceProof, or a Batch of such messages */ +export interface CommitmentProof { + exist?: ExistenceProof; + nonexist?: NonExistenceProof; + batch?: BatchProof; + compressed?: CompressedBatchProof; +} +export interface CommitmentProofProtoMsg { + typeUrl: "/ics23.CommitmentProof"; + value: Uint8Array; +} +/** CommitmentProof is either an ExistenceProof or a NonExistenceProof, or a Batch of such messages */ +export interface CommitmentProofSDKType { + exist?: ExistenceProofSDKType; + nonexist?: NonExistenceProofSDKType; + batch?: BatchProofSDKType; + compressed?: CompressedBatchProofSDKType; +} +/** + * LeafOp represents the raw key-value data we wish to prove, and + * must be flexible to represent the internal transformation from + * the original key-value pairs into the basis hash, for many existing + * merkle trees. + * + * key and value are passed in. So that the signature of this operation is: + * leafOp(key, value) -> output + * + * To process this, first prehash the keys and values if needed (ANY means no hash in this case): + * hkey = prehashKey(key) + * hvalue = prehashValue(value) + * + * Then combine the bytes, and hash it + * output = hash(prefix || length(hkey) || hkey || length(hvalue) || hvalue) + */ +export interface LeafOp { + hash: HashOp; + prehashKey: HashOp; + prehashValue: HashOp; + length: LengthOp; + /** + * prefix is a fixed bytes that may optionally be included at the beginning to differentiate + * a leaf node from an inner node. + */ + prefix: Uint8Array; +} +export interface LeafOpProtoMsg { + typeUrl: "/ics23.LeafOp"; + value: Uint8Array; +} +/** + * LeafOp represents the raw key-value data we wish to prove, and + * must be flexible to represent the internal transformation from + * the original key-value pairs into the basis hash, for many existing + * merkle trees. + * + * key and value are passed in. So that the signature of this operation is: + * leafOp(key, value) -> output + * + * To process this, first prehash the keys and values if needed (ANY means no hash in this case): + * hkey = prehashKey(key) + * hvalue = prehashValue(value) + * + * Then combine the bytes, and hash it + * output = hash(prefix || length(hkey) || hkey || length(hvalue) || hvalue) + */ +export interface LeafOpSDKType { + hash: HashOp; + prehash_key: HashOp; + prehash_value: HashOp; + length: LengthOp; + prefix: Uint8Array; +} +/** + * InnerOp represents a merkle-proof step that is not a leaf. + * It represents concatenating two children and hashing them to provide the next result. + * + * The result of the previous step is passed in, so the signature of this op is: + * innerOp(child) -> output + * + * The result of applying InnerOp should be: + * output = op.hash(op.prefix || child || op.suffix) + * + * where the || operator is concatenation of binary data, + * and child is the result of hashing all the tree below this step. + * + * Any special data, like prepending child with the length, or prepending the entire operation with + * some value to differentiate from leaf nodes, should be included in prefix and suffix. + * If either of prefix or suffix is empty, we just treat it as an empty string + */ +export interface InnerOp { + hash: HashOp; + prefix: Uint8Array; + suffix: Uint8Array; +} +export interface InnerOpProtoMsg { + typeUrl: "/ics23.InnerOp"; + value: Uint8Array; +} +/** + * InnerOp represents a merkle-proof step that is not a leaf. + * It represents concatenating two children and hashing them to provide the next result. + * + * The result of the previous step is passed in, so the signature of this op is: + * innerOp(child) -> output + * + * The result of applying InnerOp should be: + * output = op.hash(op.prefix || child || op.suffix) + * + * where the || operator is concatenation of binary data, + * and child is the result of hashing all the tree below this step. + * + * Any special data, like prepending child with the length, or prepending the entire operation with + * some value to differentiate from leaf nodes, should be included in prefix and suffix. + * If either of prefix or suffix is empty, we just treat it as an empty string + */ +export interface InnerOpSDKType { + hash: HashOp; + prefix: Uint8Array; + suffix: Uint8Array; +} +/** + * ProofSpec defines what the expected parameters are for a given proof type. + * This can be stored in the client and used to validate any incoming proofs. + * + * verify(ProofSpec, Proof) -> Proof | Error + * + * As demonstrated in tests, if we don't fix the algorithm used to calculate the + * LeafHash for a given tree, there are many possible key-value pairs that can + * generate a given hash (by interpretting the preimage differently). + * We need this for proper security, requires client knows a priori what + * tree format server uses. But not in code, rather a configuration object. + */ +export interface ProofSpec { + /** + * any field in the ExistenceProof must be the same as in this spec. + * except Prefix, which is just the first bytes of prefix (spec can be longer) + */ + leafSpec?: LeafOp; + innerSpec?: InnerSpec; + /** max_depth (if > 0) is the maximum number of InnerOps allowed (mainly for fixed-depth tries) */ + maxDepth: number; + /** min_depth (if > 0) is the minimum number of InnerOps allowed (mainly for fixed-depth tries) */ + minDepth: number; +} +export interface ProofSpecProtoMsg { + typeUrl: "/ics23.ProofSpec"; + value: Uint8Array; +} +/** + * ProofSpec defines what the expected parameters are for a given proof type. + * This can be stored in the client and used to validate any incoming proofs. + * + * verify(ProofSpec, Proof) -> Proof | Error + * + * As demonstrated in tests, if we don't fix the algorithm used to calculate the + * LeafHash for a given tree, there are many possible key-value pairs that can + * generate a given hash (by interpretting the preimage differently). + * We need this for proper security, requires client knows a priori what + * tree format server uses. But not in code, rather a configuration object. + */ +export interface ProofSpecSDKType { + leaf_spec?: LeafOpSDKType; + inner_spec?: InnerSpecSDKType; + max_depth: number; + min_depth: number; +} +/** + * InnerSpec contains all store-specific structure info to determine if two proofs from a + * given store are neighbors. + * + * This enables: + * + * isLeftMost(spec: InnerSpec, op: InnerOp) + * isRightMost(spec: InnerSpec, op: InnerOp) + * isLeftNeighbor(spec: InnerSpec, left: InnerOp, right: InnerOp) + */ +export interface InnerSpec { + /** + * Child order is the ordering of the children node, must count from 0 + * iavl tree is [0, 1] (left then right) + * merk is [0, 2, 1] (left, right, here) + */ + childOrder: number[]; + childSize: number; + minPrefixLength: number; + maxPrefixLength: number; + /** empty child is the prehash image that is used when one child is nil (eg. 20 bytes of 0) */ + emptyChild: Uint8Array; + /** hash is the algorithm that must be used for each InnerOp */ + hash: HashOp; +} +export interface InnerSpecProtoMsg { + typeUrl: "/ics23.InnerSpec"; + value: Uint8Array; +} +/** + * InnerSpec contains all store-specific structure info to determine if two proofs from a + * given store are neighbors. + * + * This enables: + * + * isLeftMost(spec: InnerSpec, op: InnerOp) + * isRightMost(spec: InnerSpec, op: InnerOp) + * isLeftNeighbor(spec: InnerSpec, left: InnerOp, right: InnerOp) + */ +export interface InnerSpecSDKType { + child_order: number[]; + child_size: number; + min_prefix_length: number; + max_prefix_length: number; + empty_child: Uint8Array; + hash: HashOp; +} +/** BatchProof is a group of multiple proof types than can be compressed */ +export interface BatchProof { + entries: BatchEntry[]; +} +export interface BatchProofProtoMsg { + typeUrl: "/ics23.BatchProof"; + value: Uint8Array; +} +/** BatchProof is a group of multiple proof types than can be compressed */ +export interface BatchProofSDKType { + entries: BatchEntrySDKType[]; +} +/** Use BatchEntry not CommitmentProof, to avoid recursion */ +export interface BatchEntry { + exist?: ExistenceProof; + nonexist?: NonExistenceProof; +} +export interface BatchEntryProtoMsg { + typeUrl: "/ics23.BatchEntry"; + value: Uint8Array; +} +/** Use BatchEntry not CommitmentProof, to avoid recursion */ +export interface BatchEntrySDKType { + exist?: ExistenceProofSDKType; + nonexist?: NonExistenceProofSDKType; +} +export interface CompressedBatchProof { + entries: CompressedBatchEntry[]; + lookupInners: InnerOp[]; +} +export interface CompressedBatchProofProtoMsg { + typeUrl: "/ics23.CompressedBatchProof"; + value: Uint8Array; +} +export interface CompressedBatchProofSDKType { + entries: CompressedBatchEntrySDKType[]; + lookup_inners: InnerOpSDKType[]; +} +/** Use BatchEntry not CommitmentProof, to avoid recursion */ +export interface CompressedBatchEntry { + exist?: CompressedExistenceProof; + nonexist?: CompressedNonExistenceProof; +} +export interface CompressedBatchEntryProtoMsg { + typeUrl: "/ics23.CompressedBatchEntry"; + value: Uint8Array; +} +/** Use BatchEntry not CommitmentProof, to avoid recursion */ +export interface CompressedBatchEntrySDKType { + exist?: CompressedExistenceProofSDKType; + nonexist?: CompressedNonExistenceProofSDKType; +} +export interface CompressedExistenceProof { + key: Uint8Array; + value: Uint8Array; + leaf?: LeafOp; + /** these are indexes into the lookup_inners table in CompressedBatchProof */ + path: number[]; +} +export interface CompressedExistenceProofProtoMsg { + typeUrl: "/ics23.CompressedExistenceProof"; + value: Uint8Array; +} +export interface CompressedExistenceProofSDKType { + key: Uint8Array; + value: Uint8Array; + leaf?: LeafOpSDKType; + path: number[]; +} +export interface CompressedNonExistenceProof { + /** TODO: remove this as unnecessary??? we prove a range */ + key: Uint8Array; + left?: CompressedExistenceProof; + right?: CompressedExistenceProof; +} +export interface CompressedNonExistenceProofProtoMsg { + typeUrl: "/ics23.CompressedNonExistenceProof"; + value: Uint8Array; +} +export interface CompressedNonExistenceProofSDKType { + key: Uint8Array; + left?: CompressedExistenceProofSDKType; + right?: CompressedExistenceProofSDKType; +} +function createBaseExistenceProof(): ExistenceProof { + return { + key: new Uint8Array(), + value: new Uint8Array(), + leaf: undefined, + path: [] + }; +} +export const ExistenceProof = { + typeUrl: "/ics23.ExistenceProof", + encode(message: ExistenceProof, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.key.length !== 0) { + writer.uint32(10).bytes(message.key); + } + if (message.value.length !== 0) { + writer.uint32(18).bytes(message.value); + } + if (message.leaf !== undefined) { + LeafOp.encode(message.leaf, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.path) { + InnerOp.encode(v!, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ExistenceProof { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseExistenceProof(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.bytes(); + break; + case 2: + message.value = reader.bytes(); + break; + case 3: + message.leaf = LeafOp.decode(reader, reader.uint32()); + break; + case 4: + message.path.push(InnerOp.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ExistenceProof { + const obj = createBaseExistenceProof(); + if (isSet(object.key)) obj.key = bytesFromBase64(object.key); + if (isSet(object.value)) obj.value = bytesFromBase64(object.value); + if (isSet(object.leaf)) obj.leaf = LeafOp.fromJSON(object.leaf); + if (Array.isArray(object?.path)) obj.path = object.path.map((e: any) => InnerOp.fromJSON(e)); + return obj; + }, + toJSON(message: ExistenceProof): JsonSafe { + const obj: any = {}; + message.key !== undefined && (obj.key = base64FromBytes(message.key !== undefined ? message.key : new Uint8Array())); + message.value !== undefined && (obj.value = base64FromBytes(message.value !== undefined ? message.value : new Uint8Array())); + message.leaf !== undefined && (obj.leaf = message.leaf ? LeafOp.toJSON(message.leaf) : undefined); + if (message.path) { + obj.path = message.path.map(e => e ? InnerOp.toJSON(e) : undefined); + } else { + obj.path = []; + } + return obj; + }, + fromPartial(object: DeepPartial): ExistenceProof { + const message = createBaseExistenceProof(); + message.key = object.key ?? new Uint8Array(); + message.value = object.value ?? new Uint8Array(); + if (object.leaf !== undefined && object.leaf !== null) { + message.leaf = LeafOp.fromPartial(object.leaf); + } + message.path = object.path?.map(e => InnerOp.fromPartial(e)) || []; + return message; + }, + fromSDK(object: ExistenceProofSDKType): ExistenceProof { + return { + key: object?.key, + value: object?.value, + leaf: object.leaf ? LeafOp.fromSDK(object.leaf) : undefined, + path: Array.isArray(object?.path) ? object.path.map((e: any) => InnerOp.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): ExistenceProofSDKType { + return { + key: isSet(object.key) ? bytesFromBase64(object.key) : new Uint8Array(), + value: isSet(object.value) ? bytesFromBase64(object.value) : new Uint8Array(), + leaf: isSet(object.leaf) ? LeafOp.fromSDKJSON(object.leaf) : undefined, + path: Array.isArray(object?.path) ? object.path.map((e: any) => InnerOp.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: ExistenceProof): ExistenceProofSDKType { + const obj: any = {}; + obj.key = message.key; + obj.value = message.value; + message.leaf !== undefined && (obj.leaf = message.leaf ? LeafOp.toSDK(message.leaf) : undefined); + if (message.path) { + obj.path = message.path.map(e => e ? InnerOp.toSDK(e) : undefined); + } else { + obj.path = []; + } + return obj; + }, + fromAmino(object: ExistenceProofAmino): ExistenceProof { + const message = createBaseExistenceProof(); + if (object.key !== undefined && object.key !== null) { + message.key = bytesFromBase64(object.key); + } + if (object.value !== undefined && object.value !== null) { + message.value = bytesFromBase64(object.value); + } + if (object.leaf !== undefined && object.leaf !== null) { + message.leaf = LeafOp.fromAmino(object.leaf); + } + message.path = object.path?.map(e => InnerOp.fromAmino(e)) || []; + return message; + }, + toAmino(message: ExistenceProof): ExistenceProofAmino { + const obj: any = {}; + obj.key = message.key ? base64FromBytes(message.key) : undefined; + obj.value = message.value ? base64FromBytes(message.value) : undefined; + obj.leaf = message.leaf ? LeafOp.toAmino(message.leaf) : undefined; + if (message.path) { + obj.path = message.path.map(e => e ? InnerOp.toAmino(e) : undefined); + } else { + obj.path = message.path; + } + return obj; + }, + fromAminoMsg(object: ExistenceProofAminoMsg): ExistenceProof { + return ExistenceProof.fromAmino(object.value); + }, + fromProtoMsg(message: ExistenceProofProtoMsg): ExistenceProof { + return ExistenceProof.decode(message.value); + }, + toProto(message: ExistenceProof): Uint8Array { + return ExistenceProof.encode(message).finish(); + }, + toProtoMsg(message: ExistenceProof): ExistenceProofProtoMsg { + return { + typeUrl: "/ics23.ExistenceProof", + value: ExistenceProof.encode(message).finish() + }; + } +}; +function createBaseNonExistenceProof(): NonExistenceProof { + return { + key: new Uint8Array(), + left: undefined, + right: undefined + }; +} +export const NonExistenceProof = { + typeUrl: "/ics23.NonExistenceProof", + encode(message: NonExistenceProof, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.key.length !== 0) { + writer.uint32(10).bytes(message.key); + } + if (message.left !== undefined) { + ExistenceProof.encode(message.left, writer.uint32(18).fork()).ldelim(); + } + if (message.right !== undefined) { + ExistenceProof.encode(message.right, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): NonExistenceProof { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseNonExistenceProof(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.bytes(); + break; + case 2: + message.left = ExistenceProof.decode(reader, reader.uint32()); + break; + case 3: + message.right = ExistenceProof.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): NonExistenceProof { + const obj = createBaseNonExistenceProof(); + if (isSet(object.key)) obj.key = bytesFromBase64(object.key); + if (isSet(object.left)) obj.left = ExistenceProof.fromJSON(object.left); + if (isSet(object.right)) obj.right = ExistenceProof.fromJSON(object.right); + return obj; + }, + toJSON(message: NonExistenceProof): JsonSafe { + const obj: any = {}; + message.key !== undefined && (obj.key = base64FromBytes(message.key !== undefined ? message.key : new Uint8Array())); + message.left !== undefined && (obj.left = message.left ? ExistenceProof.toJSON(message.left) : undefined); + message.right !== undefined && (obj.right = message.right ? ExistenceProof.toJSON(message.right) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): NonExistenceProof { + const message = createBaseNonExistenceProof(); + message.key = object.key ?? new Uint8Array(); + if (object.left !== undefined && object.left !== null) { + message.left = ExistenceProof.fromPartial(object.left); + } + if (object.right !== undefined && object.right !== null) { + message.right = ExistenceProof.fromPartial(object.right); + } + return message; + }, + fromSDK(object: NonExistenceProofSDKType): NonExistenceProof { + return { + key: object?.key, + left: object.left ? ExistenceProof.fromSDK(object.left) : undefined, + right: object.right ? ExistenceProof.fromSDK(object.right) : undefined + }; + }, + fromSDKJSON(object: any): NonExistenceProofSDKType { + return { + key: isSet(object.key) ? bytesFromBase64(object.key) : new Uint8Array(), + left: isSet(object.left) ? ExistenceProof.fromSDKJSON(object.left) : undefined, + right: isSet(object.right) ? ExistenceProof.fromSDKJSON(object.right) : undefined + }; + }, + toSDK(message: NonExistenceProof): NonExistenceProofSDKType { + const obj: any = {}; + obj.key = message.key; + message.left !== undefined && (obj.left = message.left ? ExistenceProof.toSDK(message.left) : undefined); + message.right !== undefined && (obj.right = message.right ? ExistenceProof.toSDK(message.right) : undefined); + return obj; + }, + fromAmino(object: NonExistenceProofAmino): NonExistenceProof { + const message = createBaseNonExistenceProof(); + if (object.key !== undefined && object.key !== null) { + message.key = bytesFromBase64(object.key); + } + if (object.left !== undefined && object.left !== null) { + message.left = ExistenceProof.fromAmino(object.left); + } + if (object.right !== undefined && object.right !== null) { + message.right = ExistenceProof.fromAmino(object.right); + } + return message; + }, + toAmino(message: NonExistenceProof): NonExistenceProofAmino { + const obj: any = {}; + obj.key = message.key ? base64FromBytes(message.key) : undefined; + obj.left = message.left ? ExistenceProof.toAmino(message.left) : undefined; + obj.right = message.right ? ExistenceProof.toAmino(message.right) : undefined; + return obj; + }, + fromAminoMsg(object: NonExistenceProofAminoMsg): NonExistenceProof { + return NonExistenceProof.fromAmino(object.value); + }, + fromProtoMsg(message: NonExistenceProofProtoMsg): NonExistenceProof { + return NonExistenceProof.decode(message.value); + }, + toProto(message: NonExistenceProof): Uint8Array { + return NonExistenceProof.encode(message).finish(); + }, + toProtoMsg(message: NonExistenceProof): NonExistenceProofProtoMsg { + return { + typeUrl: "/ics23.NonExistenceProof", + value: NonExistenceProof.encode(message).finish() + }; + } +}; +function createBaseCommitmentProof(): CommitmentProof { + return { + exist: undefined, + nonexist: undefined, + batch: undefined, + compressed: undefined + }; +} +export const CommitmentProof = { + typeUrl: "/ics23.CommitmentProof", + encode(message: CommitmentProof, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.exist !== undefined) { + ExistenceProof.encode(message.exist, writer.uint32(10).fork()).ldelim(); + } + if (message.nonexist !== undefined) { + NonExistenceProof.encode(message.nonexist, writer.uint32(18).fork()).ldelim(); + } + if (message.batch !== undefined) { + BatchProof.encode(message.batch, writer.uint32(26).fork()).ldelim(); + } + if (message.compressed !== undefined) { + CompressedBatchProof.encode(message.compressed, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): CommitmentProof { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCommitmentProof(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.exist = ExistenceProof.decode(reader, reader.uint32()); + break; + case 2: + message.nonexist = NonExistenceProof.decode(reader, reader.uint32()); + break; + case 3: + message.batch = BatchProof.decode(reader, reader.uint32()); + break; + case 4: + message.compressed = CompressedBatchProof.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): CommitmentProof { + const obj = createBaseCommitmentProof(); + if (isSet(object.exist)) obj.exist = ExistenceProof.fromJSON(object.exist); + if (isSet(object.nonexist)) obj.nonexist = NonExistenceProof.fromJSON(object.nonexist); + if (isSet(object.batch)) obj.batch = BatchProof.fromJSON(object.batch); + if (isSet(object.compressed)) obj.compressed = CompressedBatchProof.fromJSON(object.compressed); + return obj; + }, + toJSON(message: CommitmentProof): JsonSafe { + const obj: any = {}; + message.exist !== undefined && (obj.exist = message.exist ? ExistenceProof.toJSON(message.exist) : undefined); + message.nonexist !== undefined && (obj.nonexist = message.nonexist ? NonExistenceProof.toJSON(message.nonexist) : undefined); + message.batch !== undefined && (obj.batch = message.batch ? BatchProof.toJSON(message.batch) : undefined); + message.compressed !== undefined && (obj.compressed = message.compressed ? CompressedBatchProof.toJSON(message.compressed) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): CommitmentProof { + const message = createBaseCommitmentProof(); + if (object.exist !== undefined && object.exist !== null) { + message.exist = ExistenceProof.fromPartial(object.exist); + } + if (object.nonexist !== undefined && object.nonexist !== null) { + message.nonexist = NonExistenceProof.fromPartial(object.nonexist); + } + if (object.batch !== undefined && object.batch !== null) { + message.batch = BatchProof.fromPartial(object.batch); + } + if (object.compressed !== undefined && object.compressed !== null) { + message.compressed = CompressedBatchProof.fromPartial(object.compressed); + } + return message; + }, + fromSDK(object: CommitmentProofSDKType): CommitmentProof { + return { + exist: object.exist ? ExistenceProof.fromSDK(object.exist) : undefined, + nonexist: object.nonexist ? NonExistenceProof.fromSDK(object.nonexist) : undefined, + batch: object.batch ? BatchProof.fromSDK(object.batch) : undefined, + compressed: object.compressed ? CompressedBatchProof.fromSDK(object.compressed) : undefined + }; + }, + fromSDKJSON(object: any): CommitmentProofSDKType { + return { + exist: isSet(object.exist) ? ExistenceProof.fromSDKJSON(object.exist) : undefined, + nonexist: isSet(object.nonexist) ? NonExistenceProof.fromSDKJSON(object.nonexist) : undefined, + batch: isSet(object.batch) ? BatchProof.fromSDKJSON(object.batch) : undefined, + compressed: isSet(object.compressed) ? CompressedBatchProof.fromSDKJSON(object.compressed) : undefined + }; + }, + toSDK(message: CommitmentProof): CommitmentProofSDKType { + const obj: any = {}; + message.exist !== undefined && (obj.exist = message.exist ? ExistenceProof.toSDK(message.exist) : undefined); + message.nonexist !== undefined && (obj.nonexist = message.nonexist ? NonExistenceProof.toSDK(message.nonexist) : undefined); + message.batch !== undefined && (obj.batch = message.batch ? BatchProof.toSDK(message.batch) : undefined); + message.compressed !== undefined && (obj.compressed = message.compressed ? CompressedBatchProof.toSDK(message.compressed) : undefined); + return obj; + }, + fromAmino(object: CommitmentProofAmino): CommitmentProof { + const message = createBaseCommitmentProof(); + if (object.exist !== undefined && object.exist !== null) { + message.exist = ExistenceProof.fromAmino(object.exist); + } + if (object.nonexist !== undefined && object.nonexist !== null) { + message.nonexist = NonExistenceProof.fromAmino(object.nonexist); + } + if (object.batch !== undefined && object.batch !== null) { + message.batch = BatchProof.fromAmino(object.batch); + } + if (object.compressed !== undefined && object.compressed !== null) { + message.compressed = CompressedBatchProof.fromAmino(object.compressed); + } + return message; + }, + toAmino(message: CommitmentProof): CommitmentProofAmino { + const obj: any = {}; + obj.exist = message.exist ? ExistenceProof.toAmino(message.exist) : undefined; + obj.nonexist = message.nonexist ? NonExistenceProof.toAmino(message.nonexist) : undefined; + obj.batch = message.batch ? BatchProof.toAmino(message.batch) : undefined; + obj.compressed = message.compressed ? CompressedBatchProof.toAmino(message.compressed) : undefined; + return obj; + }, + fromAminoMsg(object: CommitmentProofAminoMsg): CommitmentProof { + return CommitmentProof.fromAmino(object.value); + }, + fromProtoMsg(message: CommitmentProofProtoMsg): CommitmentProof { + return CommitmentProof.decode(message.value); + }, + toProto(message: CommitmentProof): Uint8Array { + return CommitmentProof.encode(message).finish(); + }, + toProtoMsg(message: CommitmentProof): CommitmentProofProtoMsg { + return { + typeUrl: "/ics23.CommitmentProof", + value: CommitmentProof.encode(message).finish() + }; + } +}; +function createBaseLeafOp(): LeafOp { + return { + hash: 0, + prehashKey: 0, + prehashValue: 0, + length: 0, + prefix: new Uint8Array() + }; +} +export const LeafOp = { + typeUrl: "/ics23.LeafOp", + encode(message: LeafOp, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.hash !== 0) { + writer.uint32(8).int32(message.hash); + } + if (message.prehashKey !== 0) { + writer.uint32(16).int32(message.prehashKey); + } + if (message.prehashValue !== 0) { + writer.uint32(24).int32(message.prehashValue); + } + if (message.length !== 0) { + writer.uint32(32).int32(message.length); + } + if (message.prefix.length !== 0) { + writer.uint32(42).bytes(message.prefix); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): LeafOp { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseLeafOp(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.hash = (reader.int32() as any); + break; + case 2: + message.prehashKey = (reader.int32() as any); + break; + case 3: + message.prehashValue = (reader.int32() as any); + break; + case 4: + message.length = (reader.int32() as any); + break; + case 5: + message.prefix = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): LeafOp { + const obj = createBaseLeafOp(); + if (isSet(object.hash)) obj.hash = hashOpFromJSON(object.hash); + if (isSet(object.prehashKey)) obj.prehashKey = hashOpFromJSON(object.prehashKey); + if (isSet(object.prehashValue)) obj.prehashValue = hashOpFromJSON(object.prehashValue); + if (isSet(object.length)) obj.length = lengthOpFromJSON(object.length); + if (isSet(object.prefix)) obj.prefix = bytesFromBase64(object.prefix); + return obj; + }, + toJSON(message: LeafOp): JsonSafe { + const obj: any = {}; + message.hash !== undefined && (obj.hash = hashOpToJSON(message.hash)); + message.prehashKey !== undefined && (obj.prehashKey = hashOpToJSON(message.prehashKey)); + message.prehashValue !== undefined && (obj.prehashValue = hashOpToJSON(message.prehashValue)); + message.length !== undefined && (obj.length = lengthOpToJSON(message.length)); + message.prefix !== undefined && (obj.prefix = base64FromBytes(message.prefix !== undefined ? message.prefix : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): LeafOp { + const message = createBaseLeafOp(); + message.hash = object.hash ?? 0; + message.prehashKey = object.prehashKey ?? 0; + message.prehashValue = object.prehashValue ?? 0; + message.length = object.length ?? 0; + message.prefix = object.prefix ?? new Uint8Array(); + return message; + }, + fromSDK(object: LeafOpSDKType): LeafOp { + return { + hash: isSet(object.hash) ? hashOpFromJSON(object.hash) : -1, + prehashKey: isSet(object.prehash_key) ? hashOpFromJSON(object.prehash_key) : -1, + prehashValue: isSet(object.prehash_value) ? hashOpFromJSON(object.prehash_value) : -1, + length: isSet(object.length) ? lengthOpFromJSON(object.length) : -1, + prefix: object?.prefix + }; + }, + fromSDKJSON(object: any): LeafOpSDKType { + return { + hash: isSet(object.hash) ? hashOpFromJSON(object.hash) : -1, + prehash_key: isSet(object.prehash_key) ? hashOpFromJSON(object.prehash_key) : -1, + prehash_value: isSet(object.prehash_value) ? hashOpFromJSON(object.prehash_value) : -1, + length: isSet(object.length) ? lengthOpFromJSON(object.length) : -1, + prefix: isSet(object.prefix) ? bytesFromBase64(object.prefix) : new Uint8Array() + }; + }, + toSDK(message: LeafOp): LeafOpSDKType { + const obj: any = {}; + message.hash !== undefined && (obj.hash = hashOpToJSON(message.hash)); + message.prehashKey !== undefined && (obj.prehash_key = hashOpToJSON(message.prehashKey)); + message.prehashValue !== undefined && (obj.prehash_value = hashOpToJSON(message.prehashValue)); + message.length !== undefined && (obj.length = lengthOpToJSON(message.length)); + obj.prefix = message.prefix; + return obj; + }, + fromAmino(object: LeafOpAmino): LeafOp { + const message = createBaseLeafOp(); + if (object.hash !== undefined && object.hash !== null) { + message.hash = object.hash; + } + if (object.prehash_key !== undefined && object.prehash_key !== null) { + message.prehashKey = object.prehash_key; + } + if (object.prehash_value !== undefined && object.prehash_value !== null) { + message.prehashValue = object.prehash_value; + } + if (object.length !== undefined && object.length !== null) { + message.length = object.length; + } + if (object.prefix !== undefined && object.prefix !== null) { + message.prefix = bytesFromBase64(object.prefix); + } + return message; + }, + toAmino(message: LeafOp): LeafOpAmino { + const obj: any = {}; + obj.hash = message.hash === 0 ? undefined : message.hash; + obj.prehash_key = message.prehashKey === 0 ? undefined : message.prehashKey; + obj.prehash_value = message.prehashValue === 0 ? undefined : message.prehashValue; + obj.length = message.length === 0 ? undefined : message.length; + obj.prefix = message.prefix ? base64FromBytes(message.prefix) : undefined; + return obj; + }, + fromAminoMsg(object: LeafOpAminoMsg): LeafOp { + return LeafOp.fromAmino(object.value); + }, + fromProtoMsg(message: LeafOpProtoMsg): LeafOp { + return LeafOp.decode(message.value); + }, + toProto(message: LeafOp): Uint8Array { + return LeafOp.encode(message).finish(); + }, + toProtoMsg(message: LeafOp): LeafOpProtoMsg { + return { + typeUrl: "/ics23.LeafOp", + value: LeafOp.encode(message).finish() + }; + } +}; +function createBaseInnerOp(): InnerOp { + return { + hash: 0, + prefix: new Uint8Array(), + suffix: new Uint8Array() + }; +} +export const InnerOp = { + typeUrl: "/ics23.InnerOp", + encode(message: InnerOp, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.hash !== 0) { + writer.uint32(8).int32(message.hash); + } + if (message.prefix.length !== 0) { + writer.uint32(18).bytes(message.prefix); + } + if (message.suffix.length !== 0) { + writer.uint32(26).bytes(message.suffix); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): InnerOp { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseInnerOp(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.hash = (reader.int32() as any); + break; + case 2: + message.prefix = reader.bytes(); + break; + case 3: + message.suffix = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): InnerOp { + const obj = createBaseInnerOp(); + if (isSet(object.hash)) obj.hash = hashOpFromJSON(object.hash); + if (isSet(object.prefix)) obj.prefix = bytesFromBase64(object.prefix); + if (isSet(object.suffix)) obj.suffix = bytesFromBase64(object.suffix); + return obj; + }, + toJSON(message: InnerOp): JsonSafe { + const obj: any = {}; + message.hash !== undefined && (obj.hash = hashOpToJSON(message.hash)); + message.prefix !== undefined && (obj.prefix = base64FromBytes(message.prefix !== undefined ? message.prefix : new Uint8Array())); + message.suffix !== undefined && (obj.suffix = base64FromBytes(message.suffix !== undefined ? message.suffix : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): InnerOp { + const message = createBaseInnerOp(); + message.hash = object.hash ?? 0; + message.prefix = object.prefix ?? new Uint8Array(); + message.suffix = object.suffix ?? new Uint8Array(); + return message; + }, + fromSDK(object: InnerOpSDKType): InnerOp { + return { + hash: isSet(object.hash) ? hashOpFromJSON(object.hash) : -1, + prefix: object?.prefix, + suffix: object?.suffix + }; + }, + fromSDKJSON(object: any): InnerOpSDKType { + return { + hash: isSet(object.hash) ? hashOpFromJSON(object.hash) : -1, + prefix: isSet(object.prefix) ? bytesFromBase64(object.prefix) : new Uint8Array(), + suffix: isSet(object.suffix) ? bytesFromBase64(object.suffix) : new Uint8Array() + }; + }, + toSDK(message: InnerOp): InnerOpSDKType { + const obj: any = {}; + message.hash !== undefined && (obj.hash = hashOpToJSON(message.hash)); + obj.prefix = message.prefix; + obj.suffix = message.suffix; + return obj; + }, + fromAmino(object: InnerOpAmino): InnerOp { + const message = createBaseInnerOp(); + if (object.hash !== undefined && object.hash !== null) { + message.hash = object.hash; + } + if (object.prefix !== undefined && object.prefix !== null) { + message.prefix = bytesFromBase64(object.prefix); + } + if (object.suffix !== undefined && object.suffix !== null) { + message.suffix = bytesFromBase64(object.suffix); + } + return message; + }, + toAmino(message: InnerOp): InnerOpAmino { + const obj: any = {}; + obj.hash = message.hash === 0 ? undefined : message.hash; + obj.prefix = message.prefix ? base64FromBytes(message.prefix) : undefined; + obj.suffix = message.suffix ? base64FromBytes(message.suffix) : undefined; + return obj; + }, + fromAminoMsg(object: InnerOpAminoMsg): InnerOp { + return InnerOp.fromAmino(object.value); + }, + fromProtoMsg(message: InnerOpProtoMsg): InnerOp { + return InnerOp.decode(message.value); + }, + toProto(message: InnerOp): Uint8Array { + return InnerOp.encode(message).finish(); + }, + toProtoMsg(message: InnerOp): InnerOpProtoMsg { + return { + typeUrl: "/ics23.InnerOp", + value: InnerOp.encode(message).finish() + }; + } +}; +function createBaseProofSpec(): ProofSpec { + return { + leafSpec: undefined, + innerSpec: undefined, + maxDepth: 0, + minDepth: 0 + }; +} +export const ProofSpec = { + typeUrl: "/ics23.ProofSpec", + encode(message: ProofSpec, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.leafSpec !== undefined) { + LeafOp.encode(message.leafSpec, writer.uint32(10).fork()).ldelim(); + } + if (message.innerSpec !== undefined) { + InnerSpec.encode(message.innerSpec, writer.uint32(18).fork()).ldelim(); + } + if (message.maxDepth !== undefined) { + writer.uint32(24).int32(message.maxDepth); + } + if (message.minDepth !== undefined) { + writer.uint32(32).int32(message.minDepth); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ProofSpec { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseProofSpec(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.leafSpec = LeafOp.decode(reader, reader.uint32()); + break; + case 2: + message.innerSpec = InnerSpec.decode(reader, reader.uint32()); + break; + case 3: + message.maxDepth = reader.int32(); + break; + case 4: + message.minDepth = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ProofSpec { + const obj = createBaseProofSpec(); + if (isSet(object.leafSpec)) obj.leafSpec = LeafOp.fromJSON(object.leafSpec); + if (isSet(object.innerSpec)) obj.innerSpec = InnerSpec.fromJSON(object.innerSpec); + if (isSet(object.maxDepth)) obj.maxDepth = Number(object.maxDepth); + if (isSet(object.minDepth)) obj.minDepth = Number(object.minDepth); + return obj; + }, + toJSON(message: ProofSpec): JsonSafe { + const obj: any = {}; + message.leafSpec !== undefined && (obj.leafSpec = message.leafSpec ? LeafOp.toJSON(message.leafSpec) : undefined); + message.innerSpec !== undefined && (obj.innerSpec = message.innerSpec ? InnerSpec.toJSON(message.innerSpec) : undefined); + message.maxDepth !== undefined && (obj.maxDepth = Math.round(message.maxDepth)); + message.minDepth !== undefined && (obj.minDepth = Math.round(message.minDepth)); + return obj; + }, + fromPartial(object: DeepPartial): ProofSpec { + const message = createBaseProofSpec(); + if (object.leafSpec !== undefined && object.leafSpec !== null) { + message.leafSpec = LeafOp.fromPartial(object.leafSpec); + } + if (object.innerSpec !== undefined && object.innerSpec !== null) { + message.innerSpec = InnerSpec.fromPartial(object.innerSpec); + } + message.maxDepth = object.maxDepth ?? 0; + message.minDepth = object.minDepth ?? 0; + return message; + }, + fromSDK(object: ProofSpecSDKType): ProofSpec { + return { + leafSpec: object.leaf_spec ? LeafOp.fromSDK(object.leaf_spec) : undefined, + innerSpec: object.inner_spec ? InnerSpec.fromSDK(object.inner_spec) : undefined, + maxDepth: object?.max_depth, + minDepth: object?.min_depth + }; + }, + fromSDKJSON(object: any): ProofSpecSDKType { + return { + leaf_spec: isSet(object.leaf_spec) ? LeafOp.fromSDKJSON(object.leaf_spec) : undefined, + inner_spec: isSet(object.inner_spec) ? InnerSpec.fromSDKJSON(object.inner_spec) : undefined, + max_depth: isSet(object.max_depth) ? Number(object.max_depth) : 0, + min_depth: isSet(object.min_depth) ? Number(object.min_depth) : 0 + }; + }, + toSDK(message: ProofSpec): ProofSpecSDKType { + const obj: any = {}; + message.leafSpec !== undefined && (obj.leaf_spec = message.leafSpec ? LeafOp.toSDK(message.leafSpec) : undefined); + message.innerSpec !== undefined && (obj.inner_spec = message.innerSpec ? InnerSpec.toSDK(message.innerSpec) : undefined); + obj.max_depth = message.maxDepth; + obj.min_depth = message.minDepth; + return obj; + }, + fromAmino(object: ProofSpecAmino): ProofSpec { + const message = createBaseProofSpec(); + if (object.leaf_spec !== undefined && object.leaf_spec !== null) { + message.leafSpec = LeafOp.fromAmino(object.leaf_spec); + } + if (object.inner_spec !== undefined && object.inner_spec !== null) { + message.innerSpec = InnerSpec.fromAmino(object.inner_spec); + } + if (object.max_depth !== undefined && object.max_depth !== null) { + message.maxDepth = object.max_depth; + } + if (object.min_depth !== undefined && object.min_depth !== null) { + message.minDepth = object.min_depth; + } + return message; + }, + toAmino(message: ProofSpec): ProofSpecAmino { + const obj: any = {}; + obj.leaf_spec = message.leafSpec ? LeafOp.toAmino(message.leafSpec) : undefined; + obj.inner_spec = message.innerSpec ? InnerSpec.toAmino(message.innerSpec) : undefined; + obj.max_depth = message.maxDepth === 0 ? undefined : message.maxDepth; + obj.min_depth = message.minDepth === 0 ? undefined : message.minDepth; + return obj; + }, + fromAminoMsg(object: ProofSpecAminoMsg): ProofSpec { + return ProofSpec.fromAmino(object.value); + }, + fromProtoMsg(message: ProofSpecProtoMsg): ProofSpec { + return ProofSpec.decode(message.value); + }, + toProto(message: ProofSpec): Uint8Array { + return ProofSpec.encode(message).finish(); + }, + toProtoMsg(message: ProofSpec): ProofSpecProtoMsg { + return { + typeUrl: "/ics23.ProofSpec", + value: ProofSpec.encode(message).finish() + }; + } +}; +function createBaseInnerSpec(): InnerSpec { + return { + childOrder: [], + childSize: 0, + minPrefixLength: 0, + maxPrefixLength: 0, + emptyChild: new Uint8Array(), + hash: 0 + }; +} +export const InnerSpec = { + typeUrl: "/ics23.InnerSpec", + encode(message: InnerSpec, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + writer.uint32(10).fork(); + for (const v of message.childOrder) { + writer.int32(v); + } + writer.ldelim(); + if (message.childSize !== undefined) { + writer.uint32(16).int32(message.childSize); + } + if (message.minPrefixLength !== undefined) { + writer.uint32(24).int32(message.minPrefixLength); + } + if (message.maxPrefixLength !== undefined) { + writer.uint32(32).int32(message.maxPrefixLength); + } + if (message.emptyChild.length !== 0) { + writer.uint32(42).bytes(message.emptyChild); + } + if (message.hash !== 0) { + writer.uint32(48).int32(message.hash); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): InnerSpec { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseInnerSpec(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.childOrder.push(reader.int32()); + } + } else { + message.childOrder.push(reader.int32()); + } + break; + case 2: + message.childSize = reader.int32(); + break; + case 3: + message.minPrefixLength = reader.int32(); + break; + case 4: + message.maxPrefixLength = reader.int32(); + break; + case 5: + message.emptyChild = reader.bytes(); + break; + case 6: + message.hash = (reader.int32() as any); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): InnerSpec { + const obj = createBaseInnerSpec(); + if (Array.isArray(object?.childOrder)) obj.childOrder = object.childOrder.map((e: any) => Number(e)); + if (isSet(object.childSize)) obj.childSize = Number(object.childSize); + if (isSet(object.minPrefixLength)) obj.minPrefixLength = Number(object.minPrefixLength); + if (isSet(object.maxPrefixLength)) obj.maxPrefixLength = Number(object.maxPrefixLength); + if (isSet(object.emptyChild)) obj.emptyChild = bytesFromBase64(object.emptyChild); + if (isSet(object.hash)) obj.hash = hashOpFromJSON(object.hash); + return obj; + }, + toJSON(message: InnerSpec): JsonSafe { + const obj: any = {}; + if (message.childOrder) { + obj.childOrder = message.childOrder.map(e => Math.round(e)); + } else { + obj.childOrder = []; + } + message.childSize !== undefined && (obj.childSize = Math.round(message.childSize)); + message.minPrefixLength !== undefined && (obj.minPrefixLength = Math.round(message.minPrefixLength)); + message.maxPrefixLength !== undefined && (obj.maxPrefixLength = Math.round(message.maxPrefixLength)); + message.emptyChild !== undefined && (obj.emptyChild = base64FromBytes(message.emptyChild !== undefined ? message.emptyChild : new Uint8Array())); + message.hash !== undefined && (obj.hash = hashOpToJSON(message.hash)); + return obj; + }, + fromPartial(object: DeepPartial): InnerSpec { + const message = createBaseInnerSpec(); + message.childOrder = object.childOrder?.map(e => e) || []; + message.childSize = object.childSize ?? 0; + message.minPrefixLength = object.minPrefixLength ?? 0; + message.maxPrefixLength = object.maxPrefixLength ?? 0; + message.emptyChild = object.emptyChild ?? new Uint8Array(); + message.hash = object.hash ?? 0; + return message; + }, + fromSDK(object: InnerSpecSDKType): InnerSpec { + return { + childOrder: Array.isArray(object?.child_order) ? object.child_order.map((e: any) => e) : [], + childSize: object?.child_size, + minPrefixLength: object?.min_prefix_length, + maxPrefixLength: object?.max_prefix_length, + emptyChild: object?.empty_child, + hash: isSet(object.hash) ? hashOpFromJSON(object.hash) : -1 + }; + }, + fromSDKJSON(object: any): InnerSpecSDKType { + return { + child_order: Array.isArray(object?.child_order) ? object.child_order.map((e: any) => Number(e)) : [], + child_size: isSet(object.child_size) ? Number(object.child_size) : 0, + min_prefix_length: isSet(object.min_prefix_length) ? Number(object.min_prefix_length) : 0, + max_prefix_length: isSet(object.max_prefix_length) ? Number(object.max_prefix_length) : 0, + empty_child: isSet(object.empty_child) ? bytesFromBase64(object.empty_child) : new Uint8Array(), + hash: isSet(object.hash) ? hashOpFromJSON(object.hash) : -1 + }; + }, + toSDK(message: InnerSpec): InnerSpecSDKType { + const obj: any = {}; + if (message.childOrder) { + obj.child_order = message.childOrder.map(e => e); + } else { + obj.child_order = []; + } + obj.child_size = message.childSize; + obj.min_prefix_length = message.minPrefixLength; + obj.max_prefix_length = message.maxPrefixLength; + obj.empty_child = message.emptyChild; + message.hash !== undefined && (obj.hash = hashOpToJSON(message.hash)); + return obj; + }, + fromAmino(object: InnerSpecAmino): InnerSpec { + const message = createBaseInnerSpec(); + message.childOrder = object.child_order?.map(e => e) || []; + if (object.child_size !== undefined && object.child_size !== null) { + message.childSize = object.child_size; + } + if (object.min_prefix_length !== undefined && object.min_prefix_length !== null) { + message.minPrefixLength = object.min_prefix_length; + } + if (object.max_prefix_length !== undefined && object.max_prefix_length !== null) { + message.maxPrefixLength = object.max_prefix_length; + } + if (object.empty_child !== undefined && object.empty_child !== null) { + message.emptyChild = bytesFromBase64(object.empty_child); + } + if (object.hash !== undefined && object.hash !== null) { + message.hash = object.hash; + } + return message; + }, + toAmino(message: InnerSpec): InnerSpecAmino { + const obj: any = {}; + if (message.childOrder) { + obj.child_order = message.childOrder.map(e => e); + } else { + obj.child_order = message.childOrder; + } + obj.child_size = message.childSize === 0 ? undefined : message.childSize; + obj.min_prefix_length = message.minPrefixLength === 0 ? undefined : message.minPrefixLength; + obj.max_prefix_length = message.maxPrefixLength === 0 ? undefined : message.maxPrefixLength; + obj.empty_child = message.emptyChild ? base64FromBytes(message.emptyChild) : undefined; + obj.hash = message.hash === 0 ? undefined : message.hash; + return obj; + }, + fromAminoMsg(object: InnerSpecAminoMsg): InnerSpec { + return InnerSpec.fromAmino(object.value); + }, + fromProtoMsg(message: InnerSpecProtoMsg): InnerSpec { + return InnerSpec.decode(message.value); + }, + toProto(message: InnerSpec): Uint8Array { + return InnerSpec.encode(message).finish(); + }, + toProtoMsg(message: InnerSpec): InnerSpecProtoMsg { + return { + typeUrl: "/ics23.InnerSpec", + value: InnerSpec.encode(message).finish() + }; + } +}; +function createBaseBatchProof(): BatchProof { + return { + entries: [] + }; +} +export const BatchProof = { + typeUrl: "/ics23.BatchProof", + encode(message: BatchProof, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.entries) { + BatchEntry.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): BatchProof { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseBatchProof(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.entries.push(BatchEntry.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): BatchProof { + const obj = createBaseBatchProof(); + if (Array.isArray(object?.entries)) obj.entries = object.entries.map((e: any) => BatchEntry.fromJSON(e)); + return obj; + }, + toJSON(message: BatchProof): JsonSafe { + const obj: any = {}; + if (message.entries) { + obj.entries = message.entries.map(e => e ? BatchEntry.toJSON(e) : undefined); + } else { + obj.entries = []; + } + return obj; + }, + fromPartial(object: DeepPartial): BatchProof { + const message = createBaseBatchProof(); + message.entries = object.entries?.map(e => BatchEntry.fromPartial(e)) || []; + return message; + }, + fromSDK(object: BatchProofSDKType): BatchProof { + return { + entries: Array.isArray(object?.entries) ? object.entries.map((e: any) => BatchEntry.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): BatchProofSDKType { + return { + entries: Array.isArray(object?.entries) ? object.entries.map((e: any) => BatchEntry.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: BatchProof): BatchProofSDKType { + const obj: any = {}; + if (message.entries) { + obj.entries = message.entries.map(e => e ? BatchEntry.toSDK(e) : undefined); + } else { + obj.entries = []; + } + return obj; + }, + fromAmino(object: BatchProofAmino): BatchProof { + const message = createBaseBatchProof(); + message.entries = object.entries?.map(e => BatchEntry.fromAmino(e)) || []; + return message; + }, + toAmino(message: BatchProof): BatchProofAmino { + const obj: any = {}; + if (message.entries) { + obj.entries = message.entries.map(e => e ? BatchEntry.toAmino(e) : undefined); + } else { + obj.entries = message.entries; + } + return obj; + }, + fromAminoMsg(object: BatchProofAminoMsg): BatchProof { + return BatchProof.fromAmino(object.value); + }, + fromProtoMsg(message: BatchProofProtoMsg): BatchProof { + return BatchProof.decode(message.value); + }, + toProto(message: BatchProof): Uint8Array { + return BatchProof.encode(message).finish(); + }, + toProtoMsg(message: BatchProof): BatchProofProtoMsg { + return { + typeUrl: "/ics23.BatchProof", + value: BatchProof.encode(message).finish() + }; + } +}; +function createBaseBatchEntry(): BatchEntry { + return { + exist: undefined, + nonexist: undefined + }; +} +export const BatchEntry = { + typeUrl: "/ics23.BatchEntry", + encode(message: BatchEntry, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.exist !== undefined) { + ExistenceProof.encode(message.exist, writer.uint32(10).fork()).ldelim(); + } + if (message.nonexist !== undefined) { + NonExistenceProof.encode(message.nonexist, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): BatchEntry { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseBatchEntry(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.exist = ExistenceProof.decode(reader, reader.uint32()); + break; + case 2: + message.nonexist = NonExistenceProof.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): BatchEntry { + const obj = createBaseBatchEntry(); + if (isSet(object.exist)) obj.exist = ExistenceProof.fromJSON(object.exist); + if (isSet(object.nonexist)) obj.nonexist = NonExistenceProof.fromJSON(object.nonexist); + return obj; + }, + toJSON(message: BatchEntry): JsonSafe { + const obj: any = {}; + message.exist !== undefined && (obj.exist = message.exist ? ExistenceProof.toJSON(message.exist) : undefined); + message.nonexist !== undefined && (obj.nonexist = message.nonexist ? NonExistenceProof.toJSON(message.nonexist) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): BatchEntry { + const message = createBaseBatchEntry(); + if (object.exist !== undefined && object.exist !== null) { + message.exist = ExistenceProof.fromPartial(object.exist); + } + if (object.nonexist !== undefined && object.nonexist !== null) { + message.nonexist = NonExistenceProof.fromPartial(object.nonexist); + } + return message; + }, + fromSDK(object: BatchEntrySDKType): BatchEntry { + return { + exist: object.exist ? ExistenceProof.fromSDK(object.exist) : undefined, + nonexist: object.nonexist ? NonExistenceProof.fromSDK(object.nonexist) : undefined + }; + }, + fromSDKJSON(object: any): BatchEntrySDKType { + return { + exist: isSet(object.exist) ? ExistenceProof.fromSDKJSON(object.exist) : undefined, + nonexist: isSet(object.nonexist) ? NonExistenceProof.fromSDKJSON(object.nonexist) : undefined + }; + }, + toSDK(message: BatchEntry): BatchEntrySDKType { + const obj: any = {}; + message.exist !== undefined && (obj.exist = message.exist ? ExistenceProof.toSDK(message.exist) : undefined); + message.nonexist !== undefined && (obj.nonexist = message.nonexist ? NonExistenceProof.toSDK(message.nonexist) : undefined); + return obj; + }, + fromAmino(object: BatchEntryAmino): BatchEntry { + const message = createBaseBatchEntry(); + if (object.exist !== undefined && object.exist !== null) { + message.exist = ExistenceProof.fromAmino(object.exist); + } + if (object.nonexist !== undefined && object.nonexist !== null) { + message.nonexist = NonExistenceProof.fromAmino(object.nonexist); + } + return message; + }, + toAmino(message: BatchEntry): BatchEntryAmino { + const obj: any = {}; + obj.exist = message.exist ? ExistenceProof.toAmino(message.exist) : undefined; + obj.nonexist = message.nonexist ? NonExistenceProof.toAmino(message.nonexist) : undefined; + return obj; + }, + fromAminoMsg(object: BatchEntryAminoMsg): BatchEntry { + return BatchEntry.fromAmino(object.value); + }, + fromProtoMsg(message: BatchEntryProtoMsg): BatchEntry { + return BatchEntry.decode(message.value); + }, + toProto(message: BatchEntry): Uint8Array { + return BatchEntry.encode(message).finish(); + }, + toProtoMsg(message: BatchEntry): BatchEntryProtoMsg { + return { + typeUrl: "/ics23.BatchEntry", + value: BatchEntry.encode(message).finish() + }; + } +}; +function createBaseCompressedBatchProof(): CompressedBatchProof { + return { + entries: [], + lookupInners: [] + }; +} +export const CompressedBatchProof = { + typeUrl: "/ics23.CompressedBatchProof", + encode(message: CompressedBatchProof, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.entries) { + CompressedBatchEntry.encode(v!, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.lookupInners) { + InnerOp.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): CompressedBatchProof { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCompressedBatchProof(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.entries.push(CompressedBatchEntry.decode(reader, reader.uint32())); + break; + case 2: + message.lookupInners.push(InnerOp.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): CompressedBatchProof { + const obj = createBaseCompressedBatchProof(); + if (Array.isArray(object?.entries)) obj.entries = object.entries.map((e: any) => CompressedBatchEntry.fromJSON(e)); + if (Array.isArray(object?.lookupInners)) obj.lookupInners = object.lookupInners.map((e: any) => InnerOp.fromJSON(e)); + return obj; + }, + toJSON(message: CompressedBatchProof): JsonSafe { + const obj: any = {}; + if (message.entries) { + obj.entries = message.entries.map(e => e ? CompressedBatchEntry.toJSON(e) : undefined); + } else { + obj.entries = []; + } + if (message.lookupInners) { + obj.lookupInners = message.lookupInners.map(e => e ? InnerOp.toJSON(e) : undefined); + } else { + obj.lookupInners = []; + } + return obj; + }, + fromPartial(object: DeepPartial): CompressedBatchProof { + const message = createBaseCompressedBatchProof(); + message.entries = object.entries?.map(e => CompressedBatchEntry.fromPartial(e)) || []; + message.lookupInners = object.lookupInners?.map(e => InnerOp.fromPartial(e)) || []; + return message; + }, + fromSDK(object: CompressedBatchProofSDKType): CompressedBatchProof { + return { + entries: Array.isArray(object?.entries) ? object.entries.map((e: any) => CompressedBatchEntry.fromSDK(e)) : [], + lookupInners: Array.isArray(object?.lookup_inners) ? object.lookup_inners.map((e: any) => InnerOp.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): CompressedBatchProofSDKType { + return { + entries: Array.isArray(object?.entries) ? object.entries.map((e: any) => CompressedBatchEntry.fromSDKJSON(e)) : [], + lookup_inners: Array.isArray(object?.lookup_inners) ? object.lookup_inners.map((e: any) => InnerOp.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: CompressedBatchProof): CompressedBatchProofSDKType { + const obj: any = {}; + if (message.entries) { + obj.entries = message.entries.map(e => e ? CompressedBatchEntry.toSDK(e) : undefined); + } else { + obj.entries = []; + } + if (message.lookupInners) { + obj.lookup_inners = message.lookupInners.map(e => e ? InnerOp.toSDK(e) : undefined); + } else { + obj.lookup_inners = []; + } + return obj; + }, + fromAmino(object: CompressedBatchProofAmino): CompressedBatchProof { + const message = createBaseCompressedBatchProof(); + message.entries = object.entries?.map(e => CompressedBatchEntry.fromAmino(e)) || []; + message.lookupInners = object.lookup_inners?.map(e => InnerOp.fromAmino(e)) || []; + return message; + }, + toAmino(message: CompressedBatchProof): CompressedBatchProofAmino { + const obj: any = {}; + if (message.entries) { + obj.entries = message.entries.map(e => e ? CompressedBatchEntry.toAmino(e) : undefined); + } else { + obj.entries = message.entries; + } + if (message.lookupInners) { + obj.lookup_inners = message.lookupInners.map(e => e ? InnerOp.toAmino(e) : undefined); + } else { + obj.lookup_inners = message.lookupInners; + } + return obj; + }, + fromAminoMsg(object: CompressedBatchProofAminoMsg): CompressedBatchProof { + return CompressedBatchProof.fromAmino(object.value); + }, + fromProtoMsg(message: CompressedBatchProofProtoMsg): CompressedBatchProof { + return CompressedBatchProof.decode(message.value); + }, + toProto(message: CompressedBatchProof): Uint8Array { + return CompressedBatchProof.encode(message).finish(); + }, + toProtoMsg(message: CompressedBatchProof): CompressedBatchProofProtoMsg { + return { + typeUrl: "/ics23.CompressedBatchProof", + value: CompressedBatchProof.encode(message).finish() + }; + } +}; +function createBaseCompressedBatchEntry(): CompressedBatchEntry { + return { + exist: undefined, + nonexist: undefined + }; +} +export const CompressedBatchEntry = { + typeUrl: "/ics23.CompressedBatchEntry", + encode(message: CompressedBatchEntry, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.exist !== undefined) { + CompressedExistenceProof.encode(message.exist, writer.uint32(10).fork()).ldelim(); + } + if (message.nonexist !== undefined) { + CompressedNonExistenceProof.encode(message.nonexist, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): CompressedBatchEntry { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCompressedBatchEntry(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.exist = CompressedExistenceProof.decode(reader, reader.uint32()); + break; + case 2: + message.nonexist = CompressedNonExistenceProof.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): CompressedBatchEntry { + const obj = createBaseCompressedBatchEntry(); + if (isSet(object.exist)) obj.exist = CompressedExistenceProof.fromJSON(object.exist); + if (isSet(object.nonexist)) obj.nonexist = CompressedNonExistenceProof.fromJSON(object.nonexist); + return obj; + }, + toJSON(message: CompressedBatchEntry): JsonSafe { + const obj: any = {}; + message.exist !== undefined && (obj.exist = message.exist ? CompressedExistenceProof.toJSON(message.exist) : undefined); + message.nonexist !== undefined && (obj.nonexist = message.nonexist ? CompressedNonExistenceProof.toJSON(message.nonexist) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): CompressedBatchEntry { + const message = createBaseCompressedBatchEntry(); + if (object.exist !== undefined && object.exist !== null) { + message.exist = CompressedExistenceProof.fromPartial(object.exist); + } + if (object.nonexist !== undefined && object.nonexist !== null) { + message.nonexist = CompressedNonExistenceProof.fromPartial(object.nonexist); + } + return message; + }, + fromSDK(object: CompressedBatchEntrySDKType): CompressedBatchEntry { + return { + exist: object.exist ? CompressedExistenceProof.fromSDK(object.exist) : undefined, + nonexist: object.nonexist ? CompressedNonExistenceProof.fromSDK(object.nonexist) : undefined + }; + }, + fromSDKJSON(object: any): CompressedBatchEntrySDKType { + return { + exist: isSet(object.exist) ? CompressedExistenceProof.fromSDKJSON(object.exist) : undefined, + nonexist: isSet(object.nonexist) ? CompressedNonExistenceProof.fromSDKJSON(object.nonexist) : undefined + }; + }, + toSDK(message: CompressedBatchEntry): CompressedBatchEntrySDKType { + const obj: any = {}; + message.exist !== undefined && (obj.exist = message.exist ? CompressedExistenceProof.toSDK(message.exist) : undefined); + message.nonexist !== undefined && (obj.nonexist = message.nonexist ? CompressedNonExistenceProof.toSDK(message.nonexist) : undefined); + return obj; + }, + fromAmino(object: CompressedBatchEntryAmino): CompressedBatchEntry { + const message = createBaseCompressedBatchEntry(); + if (object.exist !== undefined && object.exist !== null) { + message.exist = CompressedExistenceProof.fromAmino(object.exist); + } + if (object.nonexist !== undefined && object.nonexist !== null) { + message.nonexist = CompressedNonExistenceProof.fromAmino(object.nonexist); + } + return message; + }, + toAmino(message: CompressedBatchEntry): CompressedBatchEntryAmino { + const obj: any = {}; + obj.exist = message.exist ? CompressedExistenceProof.toAmino(message.exist) : undefined; + obj.nonexist = message.nonexist ? CompressedNonExistenceProof.toAmino(message.nonexist) : undefined; + return obj; + }, + fromAminoMsg(object: CompressedBatchEntryAminoMsg): CompressedBatchEntry { + return CompressedBatchEntry.fromAmino(object.value); + }, + fromProtoMsg(message: CompressedBatchEntryProtoMsg): CompressedBatchEntry { + return CompressedBatchEntry.decode(message.value); + }, + toProto(message: CompressedBatchEntry): Uint8Array { + return CompressedBatchEntry.encode(message).finish(); + }, + toProtoMsg(message: CompressedBatchEntry): CompressedBatchEntryProtoMsg { + return { + typeUrl: "/ics23.CompressedBatchEntry", + value: CompressedBatchEntry.encode(message).finish() + }; + } +}; +function createBaseCompressedExistenceProof(): CompressedExistenceProof { + return { + key: new Uint8Array(), + value: new Uint8Array(), + leaf: undefined, + path: [] + }; +} +export const CompressedExistenceProof = { + typeUrl: "/ics23.CompressedExistenceProof", + encode(message: CompressedExistenceProof, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.key.length !== 0) { + writer.uint32(10).bytes(message.key); + } + if (message.value.length !== 0) { + writer.uint32(18).bytes(message.value); + } + if (message.leaf !== undefined) { + LeafOp.encode(message.leaf, writer.uint32(26).fork()).ldelim(); + } + writer.uint32(34).fork(); + for (const v of message.path) { + writer.int32(v); + } + writer.ldelim(); + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): CompressedExistenceProof { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCompressedExistenceProof(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.bytes(); + break; + case 2: + message.value = reader.bytes(); + break; + case 3: + message.leaf = LeafOp.decode(reader, reader.uint32()); + break; + case 4: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.path.push(reader.int32()); + } + } else { + message.path.push(reader.int32()); + } + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): CompressedExistenceProof { + const obj = createBaseCompressedExistenceProof(); + if (isSet(object.key)) obj.key = bytesFromBase64(object.key); + if (isSet(object.value)) obj.value = bytesFromBase64(object.value); + if (isSet(object.leaf)) obj.leaf = LeafOp.fromJSON(object.leaf); + if (Array.isArray(object?.path)) obj.path = object.path.map((e: any) => Number(e)); + return obj; + }, + toJSON(message: CompressedExistenceProof): JsonSafe { + const obj: any = {}; + message.key !== undefined && (obj.key = base64FromBytes(message.key !== undefined ? message.key : new Uint8Array())); + message.value !== undefined && (obj.value = base64FromBytes(message.value !== undefined ? message.value : new Uint8Array())); + message.leaf !== undefined && (obj.leaf = message.leaf ? LeafOp.toJSON(message.leaf) : undefined); + if (message.path) { + obj.path = message.path.map(e => Math.round(e)); + } else { + obj.path = []; + } + return obj; + }, + fromPartial(object: DeepPartial): CompressedExistenceProof { + const message = createBaseCompressedExistenceProof(); + message.key = object.key ?? new Uint8Array(); + message.value = object.value ?? new Uint8Array(); + if (object.leaf !== undefined && object.leaf !== null) { + message.leaf = LeafOp.fromPartial(object.leaf); + } + message.path = object.path?.map(e => e) || []; + return message; + }, + fromSDK(object: CompressedExistenceProofSDKType): CompressedExistenceProof { + return { + key: object?.key, + value: object?.value, + leaf: object.leaf ? LeafOp.fromSDK(object.leaf) : undefined, + path: Array.isArray(object?.path) ? object.path.map((e: any) => e) : [] + }; + }, + fromSDKJSON(object: any): CompressedExistenceProofSDKType { + return { + key: isSet(object.key) ? bytesFromBase64(object.key) : new Uint8Array(), + value: isSet(object.value) ? bytesFromBase64(object.value) : new Uint8Array(), + leaf: isSet(object.leaf) ? LeafOp.fromSDKJSON(object.leaf) : undefined, + path: Array.isArray(object?.path) ? object.path.map((e: any) => Number(e)) : [] + }; + }, + toSDK(message: CompressedExistenceProof): CompressedExistenceProofSDKType { + const obj: any = {}; + obj.key = message.key; + obj.value = message.value; + message.leaf !== undefined && (obj.leaf = message.leaf ? LeafOp.toSDK(message.leaf) : undefined); + if (message.path) { + obj.path = message.path.map(e => e); + } else { + obj.path = []; + } + return obj; + }, + fromAmino(object: CompressedExistenceProofAmino): CompressedExistenceProof { + const message = createBaseCompressedExistenceProof(); + if (object.key !== undefined && object.key !== null) { + message.key = bytesFromBase64(object.key); + } + if (object.value !== undefined && object.value !== null) { + message.value = bytesFromBase64(object.value); + } + if (object.leaf !== undefined && object.leaf !== null) { + message.leaf = LeafOp.fromAmino(object.leaf); + } + message.path = object.path?.map(e => e) || []; + return message; + }, + toAmino(message: CompressedExistenceProof): CompressedExistenceProofAmino { + const obj: any = {}; + obj.key = message.key ? base64FromBytes(message.key) : undefined; + obj.value = message.value ? base64FromBytes(message.value) : undefined; + obj.leaf = message.leaf ? LeafOp.toAmino(message.leaf) : undefined; + if (message.path) { + obj.path = message.path.map(e => e); + } else { + obj.path = message.path; + } + return obj; + }, + fromAminoMsg(object: CompressedExistenceProofAminoMsg): CompressedExistenceProof { + return CompressedExistenceProof.fromAmino(object.value); + }, + fromProtoMsg(message: CompressedExistenceProofProtoMsg): CompressedExistenceProof { + return CompressedExistenceProof.decode(message.value); + }, + toProto(message: CompressedExistenceProof): Uint8Array { + return CompressedExistenceProof.encode(message).finish(); + }, + toProtoMsg(message: CompressedExistenceProof): CompressedExistenceProofProtoMsg { + return { + typeUrl: "/ics23.CompressedExistenceProof", + value: CompressedExistenceProof.encode(message).finish() + }; + } +}; +function createBaseCompressedNonExistenceProof(): CompressedNonExistenceProof { + return { + key: new Uint8Array(), + left: undefined, + right: undefined + }; +} +export const CompressedNonExistenceProof = { + typeUrl: "/ics23.CompressedNonExistenceProof", + encode(message: CompressedNonExistenceProof, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.key.length !== 0) { + writer.uint32(10).bytes(message.key); + } + if (message.left !== undefined) { + CompressedExistenceProof.encode(message.left, writer.uint32(18).fork()).ldelim(); + } + if (message.right !== undefined) { + CompressedExistenceProof.encode(message.right, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): CompressedNonExistenceProof { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCompressedNonExistenceProof(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.bytes(); + break; + case 2: + message.left = CompressedExistenceProof.decode(reader, reader.uint32()); + break; + case 3: + message.right = CompressedExistenceProof.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): CompressedNonExistenceProof { + const obj = createBaseCompressedNonExistenceProof(); + if (isSet(object.key)) obj.key = bytesFromBase64(object.key); + if (isSet(object.left)) obj.left = CompressedExistenceProof.fromJSON(object.left); + if (isSet(object.right)) obj.right = CompressedExistenceProof.fromJSON(object.right); + return obj; + }, + toJSON(message: CompressedNonExistenceProof): JsonSafe { + const obj: any = {}; + message.key !== undefined && (obj.key = base64FromBytes(message.key !== undefined ? message.key : new Uint8Array())); + message.left !== undefined && (obj.left = message.left ? CompressedExistenceProof.toJSON(message.left) : undefined); + message.right !== undefined && (obj.right = message.right ? CompressedExistenceProof.toJSON(message.right) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): CompressedNonExistenceProof { + const message = createBaseCompressedNonExistenceProof(); + message.key = object.key ?? new Uint8Array(); + if (object.left !== undefined && object.left !== null) { + message.left = CompressedExistenceProof.fromPartial(object.left); + } + if (object.right !== undefined && object.right !== null) { + message.right = CompressedExistenceProof.fromPartial(object.right); + } + return message; + }, + fromSDK(object: CompressedNonExistenceProofSDKType): CompressedNonExistenceProof { + return { + key: object?.key, + left: object.left ? CompressedExistenceProof.fromSDK(object.left) : undefined, + right: object.right ? CompressedExistenceProof.fromSDK(object.right) : undefined + }; + }, + fromSDKJSON(object: any): CompressedNonExistenceProofSDKType { + return { + key: isSet(object.key) ? bytesFromBase64(object.key) : new Uint8Array(), + left: isSet(object.left) ? CompressedExistenceProof.fromSDKJSON(object.left) : undefined, + right: isSet(object.right) ? CompressedExistenceProof.fromSDKJSON(object.right) : undefined + }; + }, + toSDK(message: CompressedNonExistenceProof): CompressedNonExistenceProofSDKType { + const obj: any = {}; + obj.key = message.key; + message.left !== undefined && (obj.left = message.left ? CompressedExistenceProof.toSDK(message.left) : undefined); + message.right !== undefined && (obj.right = message.right ? CompressedExistenceProof.toSDK(message.right) : undefined); + return obj; + }, + fromAmino(object: CompressedNonExistenceProofAmino): CompressedNonExistenceProof { + const message = createBaseCompressedNonExistenceProof(); + if (object.key !== undefined && object.key !== null) { + message.key = bytesFromBase64(object.key); + } + if (object.left !== undefined && object.left !== null) { + message.left = CompressedExistenceProof.fromAmino(object.left); + } + if (object.right !== undefined && object.right !== null) { + message.right = CompressedExistenceProof.fromAmino(object.right); + } + return message; + }, + toAmino(message: CompressedNonExistenceProof): CompressedNonExistenceProofAmino { + const obj: any = {}; + obj.key = message.key ? base64FromBytes(message.key) : undefined; + obj.left = message.left ? CompressedExistenceProof.toAmino(message.left) : undefined; + obj.right = message.right ? CompressedExistenceProof.toAmino(message.right) : undefined; + return obj; + }, + fromAminoMsg(object: CompressedNonExistenceProofAminoMsg): CompressedNonExistenceProof { + return CompressedNonExistenceProof.fromAmino(object.value); + }, + fromProtoMsg(message: CompressedNonExistenceProofProtoMsg): CompressedNonExistenceProof { + return CompressedNonExistenceProof.decode(message.value); + }, + toProto(message: CompressedNonExistenceProof): Uint8Array { + return CompressedNonExistenceProof.encode(message).finish(); + }, + toProtoMsg(message: CompressedNonExistenceProof): CompressedNonExistenceProofProtoMsg { + return { + typeUrl: "/ics23.CompressedNonExistenceProof", + value: CompressedNonExistenceProof.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/app/v1alpha1/config.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/app/v1alpha1/config.ts new file mode 100644 index 0000000000..655de8ba2d --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/app/v1alpha1/config.ts @@ -0,0 +1,281 @@ +import { Any, AnySDKType } from "../../../google/protobuf/any.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { JsonSafe } from "../../../json-safe.js"; +import { DeepPartial, isSet } from "../../../helpers.js"; +export const protobufPackage = "cosmos.app.v1alpha1"; +/** + * Config represents the configuration for a Cosmos SDK ABCI app. + * It is intended that all state machine logic including the version of + * baseapp and tx handlers (and possibly even Tendermint) that an app needs + * can be described in a config object. For compatibility, the framework should + * allow a mixture of declarative and imperative app wiring, however, apps + * that strive for the maximum ease of maintainability should be able to describe + * their state machine with a config object alone. + */ +export interface Config { + /** modules are the module configurations for the app. */ + modules: ModuleConfig[]; +} +export interface ConfigProtoMsg { + typeUrl: "/cosmos.app.v1alpha1.Config"; + value: Uint8Array; +} +/** + * Config represents the configuration for a Cosmos SDK ABCI app. + * It is intended that all state machine logic including the version of + * baseapp and tx handlers (and possibly even Tendermint) that an app needs + * can be described in a config object. For compatibility, the framework should + * allow a mixture of declarative and imperative app wiring, however, apps + * that strive for the maximum ease of maintainability should be able to describe + * their state machine with a config object alone. + */ +export interface ConfigSDKType { + modules: ModuleConfigSDKType[]; +} +/** ModuleConfig is a module configuration for an app. */ +export interface ModuleConfig { + /** + * name is the unique name of the module within the app. It should be a name + * that persists between different versions of a module so that modules + * can be smoothly upgraded to new versions. + * + * For example, for the module cosmos.bank.module.v1.Module, we may chose + * to simply name the module "bank" in the app. When we upgrade to + * cosmos.bank.module.v2.Module, the app-specific name "bank" stays the same + * and the framework knows that the v2 module should receive all the same state + * that the v1 module had. Note: modules should provide info on which versions + * they can migrate from in the ModuleDescriptor.can_migration_from field. + */ + name: string; + /** + * config is the config object for the module. Module config messages should + * define a ModuleDescriptor using the cosmos.app.v1alpha1.is_module extension. + */ + config?: Any; +} +export interface ModuleConfigProtoMsg { + typeUrl: "/cosmos.app.v1alpha1.ModuleConfig"; + value: Uint8Array; +} +/** ModuleConfig is a module configuration for an app. */ +export interface ModuleConfigSDKType { + name: string; + config?: AnySDKType; +} +function createBaseConfig(): Config { + return { + modules: [] + }; +} +export const Config = { + typeUrl: "/cosmos.app.v1alpha1.Config", + encode(message: Config, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.modules) { + ModuleConfig.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Config { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseConfig(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.modules.push(ModuleConfig.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Config { + const obj = createBaseConfig(); + if (Array.isArray(object?.modules)) obj.modules = object.modules.map((e: any) => ModuleConfig.fromJSON(e)); + return obj; + }, + toJSON(message: Config): JsonSafe { + const obj: any = {}; + if (message.modules) { + obj.modules = message.modules.map(e => e ? ModuleConfig.toJSON(e) : undefined); + } else { + obj.modules = []; + } + return obj; + }, + fromPartial(object: DeepPartial): Config { + const message = createBaseConfig(); + message.modules = object.modules?.map(e => ModuleConfig.fromPartial(e)) || []; + return message; + }, + fromSDK(object: ConfigSDKType): Config { + return { + modules: Array.isArray(object?.modules) ? object.modules.map((e: any) => ModuleConfig.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): ConfigSDKType { + return { + modules: Array.isArray(object?.modules) ? object.modules.map((e: any) => ModuleConfig.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: Config): ConfigSDKType { + const obj: any = {}; + if (message.modules) { + obj.modules = message.modules.map(e => e ? ModuleConfig.toSDK(e) : undefined); + } else { + obj.modules = []; + } + return obj; + }, + fromAmino(object: ConfigAmino): Config { + const message = createBaseConfig(); + message.modules = object.modules?.map(e => ModuleConfig.fromAmino(e)) || []; + return message; + }, + toAmino(message: Config): ConfigAmino { + const obj: any = {}; + if (message.modules) { + obj.modules = message.modules.map(e => e ? ModuleConfig.toAmino(e) : undefined); + } else { + obj.modules = message.modules; + } + return obj; + }, + fromAminoMsg(object: ConfigAminoMsg): Config { + return Config.fromAmino(object.value); + }, + toAminoMsg(message: Config): ConfigAminoMsg { + return { + type: "cosmos-sdk/Config", + value: Config.toAmino(message) + }; + }, + fromProtoMsg(message: ConfigProtoMsg): Config { + return Config.decode(message.value); + }, + toProto(message: Config): Uint8Array { + return Config.encode(message).finish(); + }, + toProtoMsg(message: Config): ConfigProtoMsg { + return { + typeUrl: "/cosmos.app.v1alpha1.Config", + value: Config.encode(message).finish() + }; + } +}; +function createBaseModuleConfig(): ModuleConfig { + return { + name: "", + config: undefined + }; +} +export const ModuleConfig = { + typeUrl: "/cosmos.app.v1alpha1.ModuleConfig", + encode(message: ModuleConfig, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + if (message.config !== undefined) { + Any.encode(message.config, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ModuleConfig { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseModuleConfig(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.config = Any.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ModuleConfig { + const obj = createBaseModuleConfig(); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.config)) obj.config = Any.fromJSON(object.config); + return obj; + }, + toJSON(message: ModuleConfig): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.config !== undefined && (obj.config = message.config ? Any.toJSON(message.config) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): ModuleConfig { + const message = createBaseModuleConfig(); + message.name = object.name ?? ""; + if (object.config !== undefined && object.config !== null) { + message.config = Any.fromPartial(object.config); + } + return message; + }, + fromSDK(object: ModuleConfigSDKType): ModuleConfig { + return { + name: object?.name, + config: object.config ? Any.fromSDK(object.config) : undefined + }; + }, + fromSDKJSON(object: any): ModuleConfigSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + config: isSet(object.config) ? Any.fromSDKJSON(object.config) : undefined + }; + }, + toSDK(message: ModuleConfig): ModuleConfigSDKType { + const obj: any = {}; + obj.name = message.name; + message.config !== undefined && (obj.config = message.config ? Any.toSDK(message.config) : undefined); + return obj; + }, + fromAmino(object: ModuleConfigAmino): ModuleConfig { + const message = createBaseModuleConfig(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + if (object.config !== undefined && object.config !== null) { + message.config = Any.fromAmino(object.config); + } + return message; + }, + toAmino(message: ModuleConfig): ModuleConfigAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + obj.config = message.config ? Any.toAmino(message.config) : undefined; + return obj; + }, + fromAminoMsg(object: ModuleConfigAminoMsg): ModuleConfig { + return ModuleConfig.fromAmino(object.value); + }, + toAminoMsg(message: ModuleConfig): ModuleConfigAminoMsg { + return { + type: "cosmos-sdk/ModuleConfig", + value: ModuleConfig.toAmino(message) + }; + }, + fromProtoMsg(message: ModuleConfigProtoMsg): ModuleConfig { + return ModuleConfig.decode(message.value); + }, + toProto(message: ModuleConfig): Uint8Array { + return ModuleConfig.encode(message).finish(); + }, + toProtoMsg(message: ModuleConfig): ModuleConfigProtoMsg { + return { + typeUrl: "/cosmos.app.v1alpha1.ModuleConfig", + value: ModuleConfig.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/app/v1alpha1/module.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/app/v1alpha1/module.ts new file mode 100644 index 0000000000..6e822531b2 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/app/v1alpha1/module.ts @@ -0,0 +1,469 @@ +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "cosmos.app.v1alpha1"; +/** ModuleDescriptor describes an app module. */ +export interface ModuleDescriptor { + /** + * go_import names the package that should be imported by an app to load the + * module in the runtime module registry. Either go_import must be defined here + * or the go_package option must be defined at the file level to indicate + * to users where to location the module implementation. go_import takes + * precedence over go_package when both are defined. + */ + goImport: string; + /** + * use_package refers to a protobuf package that this module + * uses and exposes to the world. In an app, only one module should "use" + * or own a single protobuf package. It is assumed that the module uses + * all of the .proto files in a single package. + */ + usePackage: PackageReference[]; + /** + * can_migrate_from defines which module versions this module can migrate + * state from. The framework will check that one module version is able to + * migrate from a previous module version before attempting to update its + * config. It is assumed that modules can transitively migrate from earlier + * versions. For instance if v3 declares it can migrate from v2, and v2 + * declares it can migrate from v1, the framework knows how to migrate + * from v1 to v3, assuming all 3 module versions are registered at runtime. + */ + canMigrateFrom: MigrateFromInfo[]; +} +export interface ModuleDescriptorProtoMsg { + typeUrl: "/cosmos.app.v1alpha1.ModuleDescriptor"; + value: Uint8Array; +} +/** ModuleDescriptor describes an app module. */ +export interface ModuleDescriptorSDKType { + go_import: string; + use_package: PackageReferenceSDKType[]; + can_migrate_from: MigrateFromInfoSDKType[]; +} +/** PackageReference is a reference to a protobuf package used by a module. */ +export interface PackageReference { + /** name is the fully-qualified name of the package. */ + name: string; + /** + * revision is the optional revision of the package that is being used. + * Protobuf packages used in Cosmos should generally have a major version + * as the last part of the package name, ex. foo.bar.baz.v1. + * The revision of a package can be thought of as the minor version of a + * package which has additional backwards compatible definitions that weren't + * present in a previous version. + * + * A package should indicate its revision with a source code comment + * above the package declaration in one of its fields containing the + * test "Revision N" where N is an integer revision. All packages start + * at revision 0 the first time they are released in a module. + * + * When a new version of a module is released and items are added to existing + * .proto files, these definitions should contain comments of the form + * "Since Revision N" where N is an integer revision. + * + * When the module runtime starts up, it will check the pinned proto + * image and panic if there are runtime protobuf definitions that are not + * in the pinned descriptor which do not have + * a "Since Revision N" comment or have a "Since Revision N" comment where + * N is <= to the revision specified here. This indicates that the protobuf + * files have been updated, but the pinned file descriptor hasn't. + * + * If there are items in the pinned file descriptor with a revision + * greater than the value indicated here, this will also cause a panic + * as it may mean that the pinned descriptor for a legacy module has been + * improperly updated or that there is some other versioning discrepancy. + * Runtime protobuf definitions will also be checked for compatibility + * with pinned file descriptors to make sure there are no incompatible changes. + * + * This behavior ensures that: + * * pinned proto images are up-to-date + * * protobuf files are carefully annotated with revision comments which + * are important good client UX + * * protobuf files are changed in backwards and forwards compatible ways + */ + revision: number; +} +export interface PackageReferenceProtoMsg { + typeUrl: "/cosmos.app.v1alpha1.PackageReference"; + value: Uint8Array; +} +/** PackageReference is a reference to a protobuf package used by a module. */ +export interface PackageReferenceSDKType { + name: string; + revision: number; +} +/** + * MigrateFromInfo is information on a module version that a newer module + * can migrate from. + */ +export interface MigrateFromInfo { + /** + * module is the fully-qualified protobuf name of the module config object + * for the previous module version, ex: "cosmos.group.module.v1.Module". + */ + module: string; +} +export interface MigrateFromInfoProtoMsg { + typeUrl: "/cosmos.app.v1alpha1.MigrateFromInfo"; + value: Uint8Array; +} +/** + * MigrateFromInfo is information on a module version that a newer module + * can migrate from. + */ +export interface MigrateFromInfoSDKType { + module: string; +} +function createBaseModuleDescriptor(): ModuleDescriptor { + return { + goImport: "", + usePackage: [], + canMigrateFrom: [] + }; +} +export const ModuleDescriptor = { + typeUrl: "/cosmos.app.v1alpha1.ModuleDescriptor", + encode(message: ModuleDescriptor, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.goImport !== undefined) { + writer.uint32(10).string(message.goImport); + } + for (const v of message.usePackage) { + PackageReference.encode(v!, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.canMigrateFrom) { + MigrateFromInfo.encode(v!, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ModuleDescriptor { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseModuleDescriptor(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.goImport = reader.string(); + break; + case 2: + message.usePackage.push(PackageReference.decode(reader, reader.uint32())); + break; + case 3: + message.canMigrateFrom.push(MigrateFromInfo.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ModuleDescriptor { + const obj = createBaseModuleDescriptor(); + if (isSet(object.goImport)) obj.goImport = String(object.goImport); + if (Array.isArray(object?.usePackage)) obj.usePackage = object.usePackage.map((e: any) => PackageReference.fromJSON(e)); + if (Array.isArray(object?.canMigrateFrom)) obj.canMigrateFrom = object.canMigrateFrom.map((e: any) => MigrateFromInfo.fromJSON(e)); + return obj; + }, + toJSON(message: ModuleDescriptor): JsonSafe { + const obj: any = {}; + message.goImport !== undefined && (obj.goImport = message.goImport); + if (message.usePackage) { + obj.usePackage = message.usePackage.map(e => e ? PackageReference.toJSON(e) : undefined); + } else { + obj.usePackage = []; + } + if (message.canMigrateFrom) { + obj.canMigrateFrom = message.canMigrateFrom.map(e => e ? MigrateFromInfo.toJSON(e) : undefined); + } else { + obj.canMigrateFrom = []; + } + return obj; + }, + fromPartial(object: DeepPartial): ModuleDescriptor { + const message = createBaseModuleDescriptor(); + message.goImport = object.goImport ?? ""; + message.usePackage = object.usePackage?.map(e => PackageReference.fromPartial(e)) || []; + message.canMigrateFrom = object.canMigrateFrom?.map(e => MigrateFromInfo.fromPartial(e)) || []; + return message; + }, + fromSDK(object: ModuleDescriptorSDKType): ModuleDescriptor { + return { + goImport: object?.go_import, + usePackage: Array.isArray(object?.use_package) ? object.use_package.map((e: any) => PackageReference.fromSDK(e)) : [], + canMigrateFrom: Array.isArray(object?.can_migrate_from) ? object.can_migrate_from.map((e: any) => MigrateFromInfo.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): ModuleDescriptorSDKType { + return { + go_import: isSet(object.go_import) ? String(object.go_import) : "", + use_package: Array.isArray(object?.use_package) ? object.use_package.map((e: any) => PackageReference.fromSDKJSON(e)) : [], + can_migrate_from: Array.isArray(object?.can_migrate_from) ? object.can_migrate_from.map((e: any) => MigrateFromInfo.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: ModuleDescriptor): ModuleDescriptorSDKType { + const obj: any = {}; + obj.go_import = message.goImport; + if (message.usePackage) { + obj.use_package = message.usePackage.map(e => e ? PackageReference.toSDK(e) : undefined); + } else { + obj.use_package = []; + } + if (message.canMigrateFrom) { + obj.can_migrate_from = message.canMigrateFrom.map(e => e ? MigrateFromInfo.toSDK(e) : undefined); + } else { + obj.can_migrate_from = []; + } + return obj; + }, + fromAmino(object: ModuleDescriptorAmino): ModuleDescriptor { + const message = createBaseModuleDescriptor(); + if (object.go_import !== undefined && object.go_import !== null) { + message.goImport = object.go_import; + } + message.usePackage = object.use_package?.map(e => PackageReference.fromAmino(e)) || []; + message.canMigrateFrom = object.can_migrate_from?.map(e => MigrateFromInfo.fromAmino(e)) || []; + return message; + }, + toAmino(message: ModuleDescriptor): ModuleDescriptorAmino { + const obj: any = {}; + obj.go_import = message.goImport === "" ? undefined : message.goImport; + if (message.usePackage) { + obj.use_package = message.usePackage.map(e => e ? PackageReference.toAmino(e) : undefined); + } else { + obj.use_package = message.usePackage; + } + if (message.canMigrateFrom) { + obj.can_migrate_from = message.canMigrateFrom.map(e => e ? MigrateFromInfo.toAmino(e) : undefined); + } else { + obj.can_migrate_from = message.canMigrateFrom; + } + return obj; + }, + fromAminoMsg(object: ModuleDescriptorAminoMsg): ModuleDescriptor { + return ModuleDescriptor.fromAmino(object.value); + }, + toAminoMsg(message: ModuleDescriptor): ModuleDescriptorAminoMsg { + return { + type: "cosmos-sdk/ModuleDescriptor", + value: ModuleDescriptor.toAmino(message) + }; + }, + fromProtoMsg(message: ModuleDescriptorProtoMsg): ModuleDescriptor { + return ModuleDescriptor.decode(message.value); + }, + toProto(message: ModuleDescriptor): Uint8Array { + return ModuleDescriptor.encode(message).finish(); + }, + toProtoMsg(message: ModuleDescriptor): ModuleDescriptorProtoMsg { + return { + typeUrl: "/cosmos.app.v1alpha1.ModuleDescriptor", + value: ModuleDescriptor.encode(message).finish() + }; + } +}; +function createBasePackageReference(): PackageReference { + return { + name: "", + revision: 0 + }; +} +export const PackageReference = { + typeUrl: "/cosmos.app.v1alpha1.PackageReference", + encode(message: PackageReference, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + if (message.revision !== undefined) { + writer.uint32(16).uint32(message.revision); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): PackageReference { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBasePackageReference(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.revision = reader.uint32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): PackageReference { + const obj = createBasePackageReference(); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.revision)) obj.revision = Number(object.revision); + return obj; + }, + toJSON(message: PackageReference): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.revision !== undefined && (obj.revision = Math.round(message.revision)); + return obj; + }, + fromPartial(object: DeepPartial): PackageReference { + const message = createBasePackageReference(); + message.name = object.name ?? ""; + message.revision = object.revision ?? 0; + return message; + }, + fromSDK(object: PackageReferenceSDKType): PackageReference { + return { + name: object?.name, + revision: object?.revision + }; + }, + fromSDKJSON(object: any): PackageReferenceSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + revision: isSet(object.revision) ? Number(object.revision) : 0 + }; + }, + toSDK(message: PackageReference): PackageReferenceSDKType { + const obj: any = {}; + obj.name = message.name; + obj.revision = message.revision; + return obj; + }, + fromAmino(object: PackageReferenceAmino): PackageReference { + const message = createBasePackageReference(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + if (object.revision !== undefined && object.revision !== null) { + message.revision = object.revision; + } + return message; + }, + toAmino(message: PackageReference): PackageReferenceAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + obj.revision = message.revision === 0 ? undefined : message.revision; + return obj; + }, + fromAminoMsg(object: PackageReferenceAminoMsg): PackageReference { + return PackageReference.fromAmino(object.value); + }, + toAminoMsg(message: PackageReference): PackageReferenceAminoMsg { + return { + type: "cosmos-sdk/PackageReference", + value: PackageReference.toAmino(message) + }; + }, + fromProtoMsg(message: PackageReferenceProtoMsg): PackageReference { + return PackageReference.decode(message.value); + }, + toProto(message: PackageReference): Uint8Array { + return PackageReference.encode(message).finish(); + }, + toProtoMsg(message: PackageReference): PackageReferenceProtoMsg { + return { + typeUrl: "/cosmos.app.v1alpha1.PackageReference", + value: PackageReference.encode(message).finish() + }; + } +}; +function createBaseMigrateFromInfo(): MigrateFromInfo { + return { + module: "" + }; +} +export const MigrateFromInfo = { + typeUrl: "/cosmos.app.v1alpha1.MigrateFromInfo", + encode(message: MigrateFromInfo, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.module !== undefined) { + writer.uint32(10).string(message.module); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MigrateFromInfo { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMigrateFromInfo(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.module = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MigrateFromInfo { + const obj = createBaseMigrateFromInfo(); + if (isSet(object.module)) obj.module = String(object.module); + return obj; + }, + toJSON(message: MigrateFromInfo): JsonSafe { + const obj: any = {}; + message.module !== undefined && (obj.module = message.module); + return obj; + }, + fromPartial(object: DeepPartial): MigrateFromInfo { + const message = createBaseMigrateFromInfo(); + message.module = object.module ?? ""; + return message; + }, + fromSDK(object: MigrateFromInfoSDKType): MigrateFromInfo { + return { + module: object?.module + }; + }, + fromSDKJSON(object: any): MigrateFromInfoSDKType { + return { + module: isSet(object.module) ? String(object.module) : "" + }; + }, + toSDK(message: MigrateFromInfo): MigrateFromInfoSDKType { + const obj: any = {}; + obj.module = message.module; + return obj; + }, + fromAmino(object: MigrateFromInfoAmino): MigrateFromInfo { + const message = createBaseMigrateFromInfo(); + if (object.module !== undefined && object.module !== null) { + message.module = object.module; + } + return message; + }, + toAmino(message: MigrateFromInfo): MigrateFromInfoAmino { + const obj: any = {}; + obj.module = message.module === "" ? undefined : message.module; + return obj; + }, + fromAminoMsg(object: MigrateFromInfoAminoMsg): MigrateFromInfo { + return MigrateFromInfo.fromAmino(object.value); + }, + toAminoMsg(message: MigrateFromInfo): MigrateFromInfoAminoMsg { + return { + type: "cosmos-sdk/MigrateFromInfo", + value: MigrateFromInfo.toAmino(message) + }; + }, + fromProtoMsg(message: MigrateFromInfoProtoMsg): MigrateFromInfo { + return MigrateFromInfo.decode(message.value); + }, + toProto(message: MigrateFromInfo): Uint8Array { + return MigrateFromInfo.encode(message).finish(); + }, + toProtoMsg(message: MigrateFromInfo): MigrateFromInfoProtoMsg { + return { + typeUrl: "/cosmos.app.v1alpha1.MigrateFromInfo", + value: MigrateFromInfo.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/app/v1alpha1/query.rpc.Query.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/app/v1alpha1/query.rpc.Query.ts new file mode 100644 index 0000000000..ac71cea766 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/app/v1alpha1/query.rpc.Query.ts @@ -0,0 +1,31 @@ +import { Config, ConfigSDKType } from "./config.js"; +import { Rpc } from "../../../helpers.js"; +import { BinaryReader } from "../../../binary.js"; +import { QueryClient, createProtobufRpcClient } from "@cosmjs/stargate"; +import { QueryConfigRequest, QueryConfigRequestSDKType, QueryConfigResponse, QueryConfigResponseSDKType } from "./query.js"; +/** Query is the app module query service. */ +export interface Query { + /** Config returns the current app config. */ + config(request?: QueryConfigRequest): Promise; +} +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + this.config = this.config.bind(this); + } + config(request: QueryConfigRequest = {}): Promise { + const data = QueryConfigRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.app.v1alpha1.Query", "Config", data); + return promise.then(data => QueryConfigResponse.decode(new BinaryReader(data))); + } +} +export const createRpcQueryExtension = (base: QueryClient) => { + const rpc = createProtobufRpcClient(base); + const queryService = new QueryClientImpl(rpc); + return { + config(request?: QueryConfigRequest): Promise { + return queryService.config(request); + } + }; +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/app/v1alpha1/query.rpc.func.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/app/v1alpha1/query.rpc.func.ts new file mode 100644 index 0000000000..ac6a688fce --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/app/v1alpha1/query.rpc.func.ts @@ -0,0 +1,14 @@ +import { RpcResolver, buildQuery } from "../../../helper-func-types"; +import { buildUseQuery } from "../../../react-query"; +import { QueryConfigRequest, QueryConfigResponse } from "./query"; +export const createGetConfig = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryConfigRequest.encode, + decode: QueryConfigResponse.decode, + service: "cosmos.app.v1alpha1.Query", + method: "Config", + getRpcInstance: getRpcInstance +}); +export const useGetConfig = buildUseQuery({ + builderQueryFn: createGetConfig, + queryKeyPrefix: "ConfigQuery" +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/app/v1alpha1/query.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/app/v1alpha1/query.ts new file mode 100644 index 0000000000..bf417a9732 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/app/v1alpha1/query.ts @@ -0,0 +1,196 @@ +import { Config, ConfigSDKType } from "./config.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { JsonSafe } from "../../../json-safe.js"; +import { DeepPartial, isSet } from "../../../helpers.js"; +export const protobufPackage = "cosmos.app.v1alpha1"; +/** QueryConfigRequest is the Query/Config request type. */ +export interface QueryConfigRequest {} +export interface QueryConfigRequestProtoMsg { + typeUrl: "/cosmos.app.v1alpha1.QueryConfigRequest"; + value: Uint8Array; +} +/** QueryConfigRequest is the Query/Config request type. */ +export interface QueryConfigRequestSDKType {} +/** QueryConfigRequest is the Query/Config response type. */ +export interface QueryConfigResponse { + /** config is the current app config. */ + config?: Config; +} +export interface QueryConfigResponseProtoMsg { + typeUrl: "/cosmos.app.v1alpha1.QueryConfigResponse"; + value: Uint8Array; +} +/** QueryConfigRequest is the Query/Config response type. */ +export interface QueryConfigResponseSDKType { + config?: ConfigSDKType; +} +function createBaseQueryConfigRequest(): QueryConfigRequest { + return {}; +} +export const QueryConfigRequest = { + typeUrl: "/cosmos.app.v1alpha1.QueryConfigRequest", + encode(_: QueryConfigRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryConfigRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryConfigRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): QueryConfigRequest { + const obj = createBaseQueryConfigRequest(); + return obj; + }, + toJSON(_: QueryConfigRequest): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): QueryConfigRequest { + const message = createBaseQueryConfigRequest(); + return message; + }, + fromSDK(_: QueryConfigRequestSDKType): QueryConfigRequest { + return {}; + }, + fromSDKJSON(_: any): QueryConfigRequestSDKType { + return {}; + }, + toSDK(_: QueryConfigRequest): QueryConfigRequestSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: QueryConfigRequestAmino): QueryConfigRequest { + const message = createBaseQueryConfigRequest(); + return message; + }, + toAmino(_: QueryConfigRequest): QueryConfigRequestAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: QueryConfigRequestAminoMsg): QueryConfigRequest { + return QueryConfigRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryConfigRequest): QueryConfigRequestAminoMsg { + return { + type: "cosmos-sdk/QueryConfigRequest", + value: QueryConfigRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryConfigRequestProtoMsg): QueryConfigRequest { + return QueryConfigRequest.decode(message.value); + }, + toProto(message: QueryConfigRequest): Uint8Array { + return QueryConfigRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryConfigRequest): QueryConfigRequestProtoMsg { + return { + typeUrl: "/cosmos.app.v1alpha1.QueryConfigRequest", + value: QueryConfigRequest.encode(message).finish() + }; + } +}; +function createBaseQueryConfigResponse(): QueryConfigResponse { + return { + config: undefined + }; +} +export const QueryConfigResponse = { + typeUrl: "/cosmos.app.v1alpha1.QueryConfigResponse", + encode(message: QueryConfigResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.config !== undefined) { + Config.encode(message.config, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryConfigResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryConfigResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.config = Config.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryConfigResponse { + const obj = createBaseQueryConfigResponse(); + if (isSet(object.config)) obj.config = Config.fromJSON(object.config); + return obj; + }, + toJSON(message: QueryConfigResponse): JsonSafe { + const obj: any = {}; + message.config !== undefined && (obj.config = message.config ? Config.toJSON(message.config) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryConfigResponse { + const message = createBaseQueryConfigResponse(); + if (object.config !== undefined && object.config !== null) { + message.config = Config.fromPartial(object.config); + } + return message; + }, + fromSDK(object: QueryConfigResponseSDKType): QueryConfigResponse { + return { + config: object.config ? Config.fromSDK(object.config) : undefined + }; + }, + fromSDKJSON(object: any): QueryConfigResponseSDKType { + return { + config: isSet(object.config) ? Config.fromSDKJSON(object.config) : undefined + }; + }, + toSDK(message: QueryConfigResponse): QueryConfigResponseSDKType { + const obj: any = {}; + message.config !== undefined && (obj.config = message.config ? Config.toSDK(message.config) : undefined); + return obj; + }, + fromAmino(object: QueryConfigResponseAmino): QueryConfigResponse { + const message = createBaseQueryConfigResponse(); + if (object.config !== undefined && object.config !== null) { + message.config = Config.fromAmino(object.config); + } + return message; + }, + toAmino(message: QueryConfigResponse): QueryConfigResponseAmino { + const obj: any = {}; + obj.config = message.config ? Config.toAmino(message.config) : undefined; + return obj; + }, + fromAminoMsg(object: QueryConfigResponseAminoMsg): QueryConfigResponse { + return QueryConfigResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryConfigResponse): QueryConfigResponseAminoMsg { + return { + type: "cosmos-sdk/QueryConfigResponse", + value: QueryConfigResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryConfigResponseProtoMsg): QueryConfigResponse { + return QueryConfigResponse.decode(message.value); + }, + toProto(message: QueryConfigResponse): Uint8Array { + return QueryConfigResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryConfigResponse): QueryConfigResponseProtoMsg { + return { + typeUrl: "/cosmos.app.v1alpha1.QueryConfigResponse", + value: QueryConfigResponse.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/auth/v1beta1/auth.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/auth/v1beta1/auth.ts new file mode 100644 index 0000000000..ee309a091c --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/auth/v1beta1/auth.ts @@ -0,0 +1,530 @@ +import { Any, AnySDKType } from "../../../google/protobuf/any.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "cosmos.auth.v1beta1"; +/** + * BaseAccount defines a base account type. It contains all the necessary fields + * for basic account functionality. Any custom account type should extend this + * type for additional functionality (e.g. vesting). + */ +export interface BaseAccount { + address: string; + pubKey?: Any; + accountNumber: bigint; + sequence: bigint; +} +export interface BaseAccountProtoMsg { + typeUrl: "/cosmos.auth.v1beta1.BaseAccount"; + value: Uint8Array; +} +/** + * BaseAccount defines a base account type. It contains all the necessary fields + * for basic account functionality. Any custom account type should extend this + * type for additional functionality (e.g. vesting). + */ +export interface BaseAccountSDKType { + address: string; + pub_key?: AnySDKType; + account_number: bigint; + sequence: bigint; +} +/** ModuleAccount defines an account for modules that holds coins on a pool. */ +export interface ModuleAccount { + baseAccount?: BaseAccount; + name: string; + permissions: string[]; +} +export interface ModuleAccountProtoMsg { + typeUrl: "/cosmos.auth.v1beta1.ModuleAccount"; + value: Uint8Array; +} +/** ModuleAccount defines an account for modules that holds coins on a pool. */ +export interface ModuleAccountSDKType { + base_account?: BaseAccountSDKType; + name: string; + permissions: string[]; +} +/** Params defines the parameters for the auth module. */ +export interface Params { + maxMemoCharacters: bigint; + txSigLimit: bigint; + txSizeCostPerByte: bigint; + sigVerifyCostEd25519: bigint; + sigVerifyCostSecp256k1: bigint; +} +export interface ParamsProtoMsg { + typeUrl: "/cosmos.auth.v1beta1.Params"; + value: Uint8Array; +} +/** Params defines the parameters for the auth module. */ +export interface ParamsSDKType { + max_memo_characters: bigint; + tx_sig_limit: bigint; + tx_size_cost_per_byte: bigint; + sig_verify_cost_ed25519: bigint; + sig_verify_cost_secp256k1: bigint; +} +function createBaseBaseAccount(): BaseAccount { + return { + address: "", + pubKey: undefined, + accountNumber: BigInt(0), + sequence: BigInt(0) + }; +} +export const BaseAccount = { + typeUrl: "/cosmos.auth.v1beta1.BaseAccount", + encode(message: BaseAccount, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.address !== undefined) { + writer.uint32(10).string(message.address); + } + if (message.pubKey !== undefined) { + Any.encode(message.pubKey, writer.uint32(18).fork()).ldelim(); + } + if (message.accountNumber !== undefined) { + writer.uint32(24).uint64(message.accountNumber); + } + if (message.sequence !== undefined) { + writer.uint32(32).uint64(message.sequence); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): BaseAccount { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseBaseAccount(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.string(); + break; + case 2: + message.pubKey = Any.decode(reader, reader.uint32()); + break; + case 3: + message.accountNumber = reader.uint64(); + break; + case 4: + message.sequence = reader.uint64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): BaseAccount { + const obj = createBaseBaseAccount(); + if (isSet(object.address)) obj.address = String(object.address); + if (isSet(object.pubKey)) obj.pubKey = Any.fromJSON(object.pubKey); + if (isSet(object.accountNumber)) obj.accountNumber = BigInt(object.accountNumber.toString()); + if (isSet(object.sequence)) obj.sequence = BigInt(object.sequence.toString()); + return obj; + }, + toJSON(message: BaseAccount): JsonSafe { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + message.pubKey !== undefined && (obj.pubKey = message.pubKey ? Any.toJSON(message.pubKey) : undefined); + message.accountNumber !== undefined && (obj.accountNumber = (message.accountNumber || BigInt(0)).toString()); + message.sequence !== undefined && (obj.sequence = (message.sequence || BigInt(0)).toString()); + return obj; + }, + fromPartial(object: DeepPartial): BaseAccount { + const message = createBaseBaseAccount(); + message.address = object.address ?? ""; + if (object.pubKey !== undefined && object.pubKey !== null) { + message.pubKey = Any.fromPartial(object.pubKey); + } + if (object.accountNumber !== undefined && object.accountNumber !== null) { + message.accountNumber = BigInt(object.accountNumber.toString()); + } + if (object.sequence !== undefined && object.sequence !== null) { + message.sequence = BigInt(object.sequence.toString()); + } + return message; + }, + fromSDK(object: BaseAccountSDKType): BaseAccount { + return { + address: object?.address, + pubKey: object.pub_key ? Any.fromSDK(object.pub_key) : undefined, + accountNumber: object?.account_number, + sequence: object?.sequence + }; + }, + fromSDKJSON(object: any): BaseAccountSDKType { + return { + address: isSet(object.address) ? String(object.address) : "", + pub_key: isSet(object.pub_key) ? Any.fromSDKJSON(object.pub_key) : undefined, + account_number: isSet(object.account_number) ? BigInt(object.account_number.toString()) : BigInt(0), + sequence: isSet(object.sequence) ? BigInt(object.sequence.toString()) : BigInt(0) + }; + }, + toSDK(message: BaseAccount): BaseAccountSDKType { + const obj: any = {}; + obj.address = message.address; + message.pubKey !== undefined && (obj.pub_key = message.pubKey ? Any.toSDK(message.pubKey) : undefined); + obj.account_number = message.accountNumber; + obj.sequence = message.sequence; + return obj; + }, + fromAmino(object: BaseAccountAmino): BaseAccount { + const message = createBaseBaseAccount(); + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } + if (object.pub_key !== undefined && object.pub_key !== null) { + message.pubKey = Any.fromAmino(object.pub_key); + } + if (object.account_number !== undefined && object.account_number !== null) { + message.accountNumber = BigInt(object.account_number); + } + if (object.sequence !== undefined && object.sequence !== null) { + message.sequence = BigInt(object.sequence); + } + return message; + }, + toAmino(message: BaseAccount): BaseAccountAmino { + const obj: any = {}; + obj.address = message.address === "" ? undefined : message.address; + obj.pub_key = message.pubKey ? Any.toAmino(message.pubKey) : undefined; + obj.account_number = message.accountNumber !== BigInt(0) ? message.accountNumber?.toString() : undefined; + obj.sequence = message.sequence !== BigInt(0) ? message.sequence?.toString() : undefined; + return obj; + }, + fromAminoMsg(object: BaseAccountAminoMsg): BaseAccount { + return BaseAccount.fromAmino(object.value); + }, + toAminoMsg(message: BaseAccount): BaseAccountAminoMsg { + return { + type: "cosmos-sdk/BaseAccount", + value: BaseAccount.toAmino(message) + }; + }, + fromProtoMsg(message: BaseAccountProtoMsg): BaseAccount { + return BaseAccount.decode(message.value); + }, + toProto(message: BaseAccount): Uint8Array { + return BaseAccount.encode(message).finish(); + }, + toProtoMsg(message: BaseAccount): BaseAccountProtoMsg { + return { + typeUrl: "/cosmos.auth.v1beta1.BaseAccount", + value: BaseAccount.encode(message).finish() + }; + } +}; +function createBaseModuleAccount(): ModuleAccount { + return { + baseAccount: undefined, + name: "", + permissions: [] + }; +} +export const ModuleAccount = { + typeUrl: "/cosmos.auth.v1beta1.ModuleAccount", + encode(message: ModuleAccount, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.baseAccount !== undefined) { + BaseAccount.encode(message.baseAccount, writer.uint32(10).fork()).ldelim(); + } + if (message.name !== undefined) { + writer.uint32(18).string(message.name); + } + for (const v of message.permissions) { + writer.uint32(26).string(v!); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ModuleAccount { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseModuleAccount(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.baseAccount = BaseAccount.decode(reader, reader.uint32()); + break; + case 2: + message.name = reader.string(); + break; + case 3: + message.permissions.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ModuleAccount { + const obj = createBaseModuleAccount(); + if (isSet(object.baseAccount)) obj.baseAccount = BaseAccount.fromJSON(object.baseAccount); + if (isSet(object.name)) obj.name = String(object.name); + if (Array.isArray(object?.permissions)) obj.permissions = object.permissions.map((e: any) => String(e)); + return obj; + }, + toJSON(message: ModuleAccount): JsonSafe { + const obj: any = {}; + message.baseAccount !== undefined && (obj.baseAccount = message.baseAccount ? BaseAccount.toJSON(message.baseAccount) : undefined); + message.name !== undefined && (obj.name = message.name); + if (message.permissions) { + obj.permissions = message.permissions.map(e => e); + } else { + obj.permissions = []; + } + return obj; + }, + fromPartial(object: DeepPartial): ModuleAccount { + const message = createBaseModuleAccount(); + if (object.baseAccount !== undefined && object.baseAccount !== null) { + message.baseAccount = BaseAccount.fromPartial(object.baseAccount); + } + message.name = object.name ?? ""; + message.permissions = object.permissions?.map(e => e) || []; + return message; + }, + fromSDK(object: ModuleAccountSDKType): ModuleAccount { + return { + baseAccount: object.base_account ? BaseAccount.fromSDK(object.base_account) : undefined, + name: object?.name, + permissions: Array.isArray(object?.permissions) ? object.permissions.map((e: any) => e) : [] + }; + }, + fromSDKJSON(object: any): ModuleAccountSDKType { + return { + base_account: isSet(object.base_account) ? BaseAccount.fromSDKJSON(object.base_account) : undefined, + name: isSet(object.name) ? String(object.name) : "", + permissions: Array.isArray(object?.permissions) ? object.permissions.map((e: any) => String(e)) : [] + }; + }, + toSDK(message: ModuleAccount): ModuleAccountSDKType { + const obj: any = {}; + message.baseAccount !== undefined && (obj.base_account = message.baseAccount ? BaseAccount.toSDK(message.baseAccount) : undefined); + obj.name = message.name; + if (message.permissions) { + obj.permissions = message.permissions.map(e => e); + } else { + obj.permissions = []; + } + return obj; + }, + fromAmino(object: ModuleAccountAmino): ModuleAccount { + const message = createBaseModuleAccount(); + if (object.base_account !== undefined && object.base_account !== null) { + message.baseAccount = BaseAccount.fromAmino(object.base_account); + } + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + message.permissions = object.permissions?.map(e => e) || []; + return message; + }, + toAmino(message: ModuleAccount): ModuleAccountAmino { + const obj: any = {}; + obj.base_account = message.baseAccount ? BaseAccount.toAmino(message.baseAccount) : undefined; + obj.name = message.name === "" ? undefined : message.name; + if (message.permissions) { + obj.permissions = message.permissions.map(e => e); + } else { + obj.permissions = message.permissions; + } + return obj; + }, + fromAminoMsg(object: ModuleAccountAminoMsg): ModuleAccount { + return ModuleAccount.fromAmino(object.value); + }, + toAminoMsg(message: ModuleAccount): ModuleAccountAminoMsg { + return { + type: "cosmos-sdk/ModuleAccount", + value: ModuleAccount.toAmino(message) + }; + }, + fromProtoMsg(message: ModuleAccountProtoMsg): ModuleAccount { + return ModuleAccount.decode(message.value); + }, + toProto(message: ModuleAccount): Uint8Array { + return ModuleAccount.encode(message).finish(); + }, + toProtoMsg(message: ModuleAccount): ModuleAccountProtoMsg { + return { + typeUrl: "/cosmos.auth.v1beta1.ModuleAccount", + value: ModuleAccount.encode(message).finish() + }; + } +}; +function createBaseParams(): Params { + return { + maxMemoCharacters: BigInt(0), + txSigLimit: BigInt(0), + txSizeCostPerByte: BigInt(0), + sigVerifyCostEd25519: BigInt(0), + sigVerifyCostSecp256k1: BigInt(0) + }; +} +export const Params = { + typeUrl: "/cosmos.auth.v1beta1.Params", + encode(message: Params, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.maxMemoCharacters !== undefined) { + writer.uint32(8).uint64(message.maxMemoCharacters); + } + if (message.txSigLimit !== undefined) { + writer.uint32(16).uint64(message.txSigLimit); + } + if (message.txSizeCostPerByte !== undefined) { + writer.uint32(24).uint64(message.txSizeCostPerByte); + } + if (message.sigVerifyCostEd25519 !== undefined) { + writer.uint32(32).uint64(message.sigVerifyCostEd25519); + } + if (message.sigVerifyCostSecp256k1 !== undefined) { + writer.uint32(40).uint64(message.sigVerifyCostSecp256k1); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Params { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseParams(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.maxMemoCharacters = reader.uint64(); + break; + case 2: + message.txSigLimit = reader.uint64(); + break; + case 3: + message.txSizeCostPerByte = reader.uint64(); + break; + case 4: + message.sigVerifyCostEd25519 = reader.uint64(); + break; + case 5: + message.sigVerifyCostSecp256k1 = reader.uint64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Params { + const obj = createBaseParams(); + if (isSet(object.maxMemoCharacters)) obj.maxMemoCharacters = BigInt(object.maxMemoCharacters.toString()); + if (isSet(object.txSigLimit)) obj.txSigLimit = BigInt(object.txSigLimit.toString()); + if (isSet(object.txSizeCostPerByte)) obj.txSizeCostPerByte = BigInt(object.txSizeCostPerByte.toString()); + if (isSet(object.sigVerifyCostEd25519)) obj.sigVerifyCostEd25519 = BigInt(object.sigVerifyCostEd25519.toString()); + if (isSet(object.sigVerifyCostSecp256k1)) obj.sigVerifyCostSecp256k1 = BigInt(object.sigVerifyCostSecp256k1.toString()); + return obj; + }, + toJSON(message: Params): JsonSafe { + const obj: any = {}; + message.maxMemoCharacters !== undefined && (obj.maxMemoCharacters = (message.maxMemoCharacters || BigInt(0)).toString()); + message.txSigLimit !== undefined && (obj.txSigLimit = (message.txSigLimit || BigInt(0)).toString()); + message.txSizeCostPerByte !== undefined && (obj.txSizeCostPerByte = (message.txSizeCostPerByte || BigInt(0)).toString()); + message.sigVerifyCostEd25519 !== undefined && (obj.sigVerifyCostEd25519 = (message.sigVerifyCostEd25519 || BigInt(0)).toString()); + message.sigVerifyCostSecp256k1 !== undefined && (obj.sigVerifyCostSecp256k1 = (message.sigVerifyCostSecp256k1 || BigInt(0)).toString()); + return obj; + }, + fromPartial(object: DeepPartial): Params { + const message = createBaseParams(); + if (object.maxMemoCharacters !== undefined && object.maxMemoCharacters !== null) { + message.maxMemoCharacters = BigInt(object.maxMemoCharacters.toString()); + } + if (object.txSigLimit !== undefined && object.txSigLimit !== null) { + message.txSigLimit = BigInt(object.txSigLimit.toString()); + } + if (object.txSizeCostPerByte !== undefined && object.txSizeCostPerByte !== null) { + message.txSizeCostPerByte = BigInt(object.txSizeCostPerByte.toString()); + } + if (object.sigVerifyCostEd25519 !== undefined && object.sigVerifyCostEd25519 !== null) { + message.sigVerifyCostEd25519 = BigInt(object.sigVerifyCostEd25519.toString()); + } + if (object.sigVerifyCostSecp256k1 !== undefined && object.sigVerifyCostSecp256k1 !== null) { + message.sigVerifyCostSecp256k1 = BigInt(object.sigVerifyCostSecp256k1.toString()); + } + return message; + }, + fromSDK(object: ParamsSDKType): Params { + return { + maxMemoCharacters: object?.max_memo_characters, + txSigLimit: object?.tx_sig_limit, + txSizeCostPerByte: object?.tx_size_cost_per_byte, + sigVerifyCostEd25519: object?.sig_verify_cost_ed25519, + sigVerifyCostSecp256k1: object?.sig_verify_cost_secp256k1 + }; + }, + fromSDKJSON(object: any): ParamsSDKType { + return { + max_memo_characters: isSet(object.max_memo_characters) ? BigInt(object.max_memo_characters.toString()) : BigInt(0), + tx_sig_limit: isSet(object.tx_sig_limit) ? BigInt(object.tx_sig_limit.toString()) : BigInt(0), + tx_size_cost_per_byte: isSet(object.tx_size_cost_per_byte) ? BigInt(object.tx_size_cost_per_byte.toString()) : BigInt(0), + sig_verify_cost_ed25519: isSet(object.sig_verify_cost_ed25519) ? BigInt(object.sig_verify_cost_ed25519.toString()) : BigInt(0), + sig_verify_cost_secp256k1: isSet(object.sig_verify_cost_secp256k1) ? BigInt(object.sig_verify_cost_secp256k1.toString()) : BigInt(0) + }; + }, + toSDK(message: Params): ParamsSDKType { + const obj: any = {}; + obj.max_memo_characters = message.maxMemoCharacters; + obj.tx_sig_limit = message.txSigLimit; + obj.tx_size_cost_per_byte = message.txSizeCostPerByte; + obj.sig_verify_cost_ed25519 = message.sigVerifyCostEd25519; + obj.sig_verify_cost_secp256k1 = message.sigVerifyCostSecp256k1; + return obj; + }, + fromAmino(object: ParamsAmino): Params { + const message = createBaseParams(); + if (object.max_memo_characters !== undefined && object.max_memo_characters !== null) { + message.maxMemoCharacters = BigInt(object.max_memo_characters); + } + if (object.tx_sig_limit !== undefined && object.tx_sig_limit !== null) { + message.txSigLimit = BigInt(object.tx_sig_limit); + } + if (object.tx_size_cost_per_byte !== undefined && object.tx_size_cost_per_byte !== null) { + message.txSizeCostPerByte = BigInt(object.tx_size_cost_per_byte); + } + if (object.sig_verify_cost_ed25519 !== undefined && object.sig_verify_cost_ed25519 !== null) { + message.sigVerifyCostEd25519 = BigInt(object.sig_verify_cost_ed25519); + } + if (object.sig_verify_cost_secp256k1 !== undefined && object.sig_verify_cost_secp256k1 !== null) { + message.sigVerifyCostSecp256k1 = BigInt(object.sig_verify_cost_secp256k1); + } + return message; + }, + toAmino(message: Params): ParamsAmino { + const obj: any = {}; + obj.max_memo_characters = message.maxMemoCharacters !== BigInt(0) ? message.maxMemoCharacters?.toString() : undefined; + obj.tx_sig_limit = message.txSigLimit !== BigInt(0) ? message.txSigLimit?.toString() : undefined; + obj.tx_size_cost_per_byte = message.txSizeCostPerByte !== BigInt(0) ? message.txSizeCostPerByte?.toString() : undefined; + obj.sig_verify_cost_ed25519 = message.sigVerifyCostEd25519 !== BigInt(0) ? message.sigVerifyCostEd25519?.toString() : undefined; + obj.sig_verify_cost_secp256k1 = message.sigVerifyCostSecp256k1 !== BigInt(0) ? message.sigVerifyCostSecp256k1?.toString() : undefined; + return obj; + }, + fromAminoMsg(object: ParamsAminoMsg): Params { + return Params.fromAmino(object.value); + }, + toAminoMsg(message: Params): ParamsAminoMsg { + return { + type: "cosmos-sdk/Params", + value: Params.toAmino(message) + }; + }, + fromProtoMsg(message: ParamsProtoMsg): Params { + return Params.decode(message.value); + }, + toProto(message: Params): Uint8Array { + return Params.encode(message).finish(); + }, + toProtoMsg(message: Params): ParamsProtoMsg { + return { + typeUrl: "/cosmos.auth.v1beta1.Params", + value: Params.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/auth/v1beta1/genesis.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/auth/v1beta1/genesis.ts new file mode 100644 index 0000000000..dde14ad56e --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/auth/v1beta1/genesis.ts @@ -0,0 +1,145 @@ +import { Params, ParamsSDKType } from "./auth.js"; +import { Any, AnySDKType } from "../../../google/protobuf/any.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "cosmos.auth.v1beta1"; +/** GenesisState defines the auth module's genesis state. */ +export interface GenesisState { + /** params defines all the paramaters of the module. */ + params: Params; + /** accounts are the accounts present at genesis. */ + accounts: Any[]; +} +export interface GenesisStateProtoMsg { + typeUrl: "/cosmos.auth.v1beta1.GenesisState"; + value: Uint8Array; +} +/** GenesisState defines the auth module's genesis state. */ +export interface GenesisStateSDKType { + params: ParamsSDKType; + accounts: AnySDKType[]; +} +function createBaseGenesisState(): GenesisState { + return { + params: Params.fromPartial({}), + accounts: [] + }; +} +export const GenesisState = { + typeUrl: "/cosmos.auth.v1beta1.GenesisState", + encode(message: GenesisState, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.accounts) { + Any.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GenesisState { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGenesisState(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.params = Params.decode(reader, reader.uint32()); + break; + case 2: + message.accounts.push(Any.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GenesisState { + const obj = createBaseGenesisState(); + if (isSet(object.params)) obj.params = Params.fromJSON(object.params); + if (Array.isArray(object?.accounts)) obj.accounts = object.accounts.map((e: any) => Any.fromJSON(e)); + return obj; + }, + toJSON(message: GenesisState): JsonSafe { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); + if (message.accounts) { + obj.accounts = message.accounts.map(e => e ? Any.toJSON(e) : undefined); + } else { + obj.accounts = []; + } + return obj; + }, + fromPartial(object: DeepPartial): GenesisState { + const message = createBaseGenesisState(); + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } + message.accounts = object.accounts?.map(e => Any.fromPartial(e)) || []; + return message; + }, + fromSDK(object: GenesisStateSDKType): GenesisState { + return { + params: object.params ? Params.fromSDK(object.params) : undefined, + accounts: Array.isArray(object?.accounts) ? object.accounts.map((e: any) => Any.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): GenesisStateSDKType { + return { + params: isSet(object.params) ? Params.fromSDKJSON(object.params) : undefined, + accounts: Array.isArray(object?.accounts) ? object.accounts.map((e: any) => Any.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: GenesisState): GenesisStateSDKType { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toSDK(message.params) : undefined); + if (message.accounts) { + obj.accounts = message.accounts.map(e => e ? Any.toSDK(e) : undefined); + } else { + obj.accounts = []; + } + return obj; + }, + fromAmino(object: GenesisStateAmino): GenesisState { + const message = createBaseGenesisState(); + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromAmino(object.params); + } + message.accounts = object.accounts?.map(e => Any.fromAmino(e)) || []; + return message; + }, + toAmino(message: GenesisState): GenesisStateAmino { + const obj: any = {}; + obj.params = message.params ? Params.toAmino(message.params) : undefined; + if (message.accounts) { + obj.accounts = message.accounts.map(e => e ? Any.toAmino(e) : undefined); + } else { + obj.accounts = message.accounts; + } + return obj; + }, + fromAminoMsg(object: GenesisStateAminoMsg): GenesisState { + return GenesisState.fromAmino(object.value); + }, + toAminoMsg(message: GenesisState): GenesisStateAminoMsg { + return { + type: "cosmos-sdk/GenesisState", + value: GenesisState.toAmino(message) + }; + }, + fromProtoMsg(message: GenesisStateProtoMsg): GenesisState { + return GenesisState.decode(message.value); + }, + toProto(message: GenesisState): Uint8Array { + return GenesisState.encode(message).finish(); + }, + toProtoMsg(message: GenesisState): GenesisStateProtoMsg { + return { + typeUrl: "/cosmos.auth.v1beta1.GenesisState", + value: GenesisState.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/auth/v1beta1/query.lcd.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/auth/v1beta1/query.lcd.ts new file mode 100644 index 0000000000..743d501447 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/auth/v1beta1/query.lcd.ts @@ -0,0 +1,68 @@ +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../base/query/v1beta1/pagination.js"; +import { Any, AnySDKType } from "../../../google/protobuf/any.js"; +import { Params, ParamsSDKType } from "./auth.js"; +import { setPaginationParams } from "../../../helpers.js"; +import { LCDClient } from "@cosmology/lcd"; +import { QueryAccountsRequest, QueryAccountsRequestSDKType, QueryAccountsResponse, QueryAccountsResponseSDKType, QueryAccountRequest, QueryAccountRequestSDKType, QueryAccountResponse, QueryAccountResponseSDKType, QueryParamsRequest, QueryParamsRequestSDKType, QueryParamsResponse, QueryParamsResponseSDKType, QueryModuleAccountsRequest, QueryModuleAccountsRequestSDKType, QueryModuleAccountsResponse, QueryModuleAccountsResponseSDKType, Bech32PrefixRequest, Bech32PrefixRequestSDKType, Bech32PrefixResponse, Bech32PrefixResponseSDKType, AddressBytesToStringRequest, AddressBytesToStringRequestSDKType, AddressBytesToStringResponse, AddressBytesToStringResponseSDKType, AddressStringToBytesRequest, AddressStringToBytesRequestSDKType, AddressStringToBytesResponse, AddressStringToBytesResponseSDKType } from "./query.js"; +export class LCDQueryClient { + req: LCDClient; + constructor({ + requestClient + }: { + requestClient: LCDClient; + }) { + this.req = requestClient; + this.accounts = this.accounts.bind(this); + this.account = this.account.bind(this); + this.params = this.params.bind(this); + this.moduleAccounts = this.moduleAccounts.bind(this); + this.bech32Prefix = this.bech32Prefix.bind(this); + this.addressBytesToString = this.addressBytesToString.bind(this); + this.addressStringToBytes = this.addressStringToBytes.bind(this); + } + /* Accounts returns all the existing accounts + + Since: cosmos-sdk 0.43 */ + async accounts(params: QueryAccountsRequest = { + pagination: PageRequest.fromPartial({}) + }): Promise { + const options: any = { + params: {} + }; + if (typeof params?.pagination !== "undefined") { + setPaginationParams(options, params.pagination); + } + const endpoint = `cosmos/auth/v1beta1/accounts`; + return QueryAccountsResponse.fromSDKJSON(await this.req.get(endpoint, options)); + } + /* Account returns account details based on address. */ + async account(params: QueryAccountRequest): Promise { + const endpoint = `cosmos/auth/v1beta1/accounts/${params.address}`; + return QueryAccountResponse.fromSDKJSON(await this.req.get(endpoint)); + } + /* Params queries all parameters. */ + async params(_params: QueryParamsRequest = {}): Promise { + const endpoint = `cosmos/auth/v1beta1/params`; + return QueryParamsResponse.fromSDKJSON(await this.req.get(endpoint)); + } + /* ModuleAccounts returns all the existing module accounts. */ + async moduleAccounts(_params: QueryModuleAccountsRequest = {}): Promise { + const endpoint = `cosmos/auth/v1beta1/module_accounts`; + return QueryModuleAccountsResponse.fromSDKJSON(await this.req.get(endpoint)); + } + /* Bech32 queries bech32Prefix */ + async bech32Prefix(_params: Bech32PrefixRequest = {}): Promise { + const endpoint = `cosmos/auth/v1beta1/bech32`; + return Bech32PrefixResponse.fromSDKJSON(await this.req.get(endpoint)); + } + /* AddressBytesToString converts Account Address bytes to string */ + async addressBytesToString(params: AddressBytesToStringRequest): Promise { + const endpoint = `cosmos/auth/v1beta1/bech32/${params.addressBytes}`; + return AddressBytesToStringResponse.fromSDKJSON(await this.req.get(endpoint)); + } + /* AddressStringToBytes converts Address string to bytes */ + async addressStringToBytes(params: AddressStringToBytesRequest): Promise { + const endpoint = `cosmos/auth/v1beta1/bech32/${params.addressString}`; + return AddressStringToBytesResponse.fromSDKJSON(await this.req.get(endpoint)); + } +} \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/auth/v1beta1/query.rpc.Query.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/auth/v1beta1/query.rpc.Query.ts new file mode 100644 index 0000000000..828662a3b0 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/auth/v1beta1/query.rpc.Query.ts @@ -0,0 +1,218 @@ +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../base/query/v1beta1/pagination.js"; +import { Any, AnySDKType } from "../../../google/protobuf/any.js"; +import { Params, ParamsSDKType } from "./auth.js"; +import { Rpc } from "../../../helpers.js"; +import { BinaryReader } from "../../../binary.js"; +import { QueryClient, createProtobufRpcClient, ProtobufRpcClient } from "@cosmjs/stargate"; +import { ReactQueryParams } from "../../../react-query.js"; +import { useQuery } from "@tanstack/react-query"; +import { QueryAccountsRequest, QueryAccountsRequestSDKType, QueryAccountsResponse, QueryAccountsResponseSDKType, QueryAccountRequest, QueryAccountRequestSDKType, QueryAccountResponse, QueryAccountResponseSDKType, QueryParamsRequest, QueryParamsRequestSDKType, QueryParamsResponse, QueryParamsResponseSDKType, QueryModuleAccountsRequest, QueryModuleAccountsRequestSDKType, QueryModuleAccountsResponse, QueryModuleAccountsResponseSDKType, Bech32PrefixRequest, Bech32PrefixRequestSDKType, Bech32PrefixResponse, Bech32PrefixResponseSDKType, AddressBytesToStringRequest, AddressBytesToStringRequestSDKType, AddressBytesToStringResponse, AddressBytesToStringResponseSDKType, AddressStringToBytesRequest, AddressStringToBytesRequestSDKType, AddressStringToBytesResponse, AddressStringToBytesResponseSDKType } from "./query.js"; +/** Query defines the gRPC querier service. */ +export interface Query { + /** + * Accounts returns all the existing accounts + * + * Since: cosmos-sdk 0.43 + */ + accounts(request?: QueryAccountsRequest): Promise; + /** Account returns account details based on address. */ + account(request: QueryAccountRequest): Promise; + /** Params queries all parameters. */ + params(request?: QueryParamsRequest): Promise; + /** ModuleAccounts returns all the existing module accounts. */ + moduleAccounts(request?: QueryModuleAccountsRequest): Promise; + /** Bech32 queries bech32Prefix */ + bech32Prefix(request?: Bech32PrefixRequest): Promise; + /** AddressBytesToString converts Account Address bytes to string */ + addressBytesToString(request: AddressBytesToStringRequest): Promise; + /** AddressStringToBytes converts Address string to bytes */ + addressStringToBytes(request: AddressStringToBytesRequest): Promise; +} +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + this.accounts = this.accounts.bind(this); + this.account = this.account.bind(this); + this.params = this.params.bind(this); + this.moduleAccounts = this.moduleAccounts.bind(this); + this.bech32Prefix = this.bech32Prefix.bind(this); + this.addressBytesToString = this.addressBytesToString.bind(this); + this.addressStringToBytes = this.addressStringToBytes.bind(this); + } + accounts(request: QueryAccountsRequest = { + pagination: PageRequest.fromPartial({}) + }): Promise { + const data = QueryAccountsRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.auth.v1beta1.Query", "Accounts", data); + return promise.then(data => QueryAccountsResponse.decode(new BinaryReader(data))); + } + account(request: QueryAccountRequest): Promise { + const data = QueryAccountRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.auth.v1beta1.Query", "Account", data); + return promise.then(data => QueryAccountResponse.decode(new BinaryReader(data))); + } + params(request: QueryParamsRequest = {}): Promise { + const data = QueryParamsRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.auth.v1beta1.Query", "Params", data); + return promise.then(data => QueryParamsResponse.decode(new BinaryReader(data))); + } + moduleAccounts(request: QueryModuleAccountsRequest = {}): Promise { + const data = QueryModuleAccountsRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.auth.v1beta1.Query", "ModuleAccounts", data); + return promise.then(data => QueryModuleAccountsResponse.decode(new BinaryReader(data))); + } + bech32Prefix(request: Bech32PrefixRequest = {}): Promise { + const data = Bech32PrefixRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.auth.v1beta1.Query", "Bech32Prefix", data); + return promise.then(data => Bech32PrefixResponse.decode(new BinaryReader(data))); + } + addressBytesToString(request: AddressBytesToStringRequest): Promise { + const data = AddressBytesToStringRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.auth.v1beta1.Query", "AddressBytesToString", data); + return promise.then(data => AddressBytesToStringResponse.decode(new BinaryReader(data))); + } + addressStringToBytes(request: AddressStringToBytesRequest): Promise { + const data = AddressStringToBytesRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.auth.v1beta1.Query", "AddressStringToBytes", data); + return promise.then(data => AddressStringToBytesResponse.decode(new BinaryReader(data))); + } +} +export const createRpcQueryExtension = (base: QueryClient) => { + const rpc = createProtobufRpcClient(base); + const queryService = new QueryClientImpl(rpc); + return { + accounts(request?: QueryAccountsRequest): Promise { + return queryService.accounts(request); + }, + account(request: QueryAccountRequest): Promise { + return queryService.account(request); + }, + params(request?: QueryParamsRequest): Promise { + return queryService.params(request); + }, + moduleAccounts(request?: QueryModuleAccountsRequest): Promise { + return queryService.moduleAccounts(request); + }, + bech32Prefix(request?: Bech32PrefixRequest): Promise { + return queryService.bech32Prefix(request); + }, + addressBytesToString(request: AddressBytesToStringRequest): Promise { + return queryService.addressBytesToString(request); + }, + addressStringToBytes(request: AddressStringToBytesRequest): Promise { + return queryService.addressStringToBytes(request); + } + }; +}; +export interface UseAccountsQuery extends ReactQueryParams { + request?: QueryAccountsRequest; +} +export interface UseAccountQuery extends ReactQueryParams { + request: QueryAccountRequest; +} +export interface UseParamsQuery extends ReactQueryParams { + request?: QueryParamsRequest; +} +export interface UseModuleAccountsQuery extends ReactQueryParams { + request?: QueryModuleAccountsRequest; +} +export interface UseBech32PrefixQuery extends ReactQueryParams { + request?: Bech32PrefixRequest; +} +export interface UseAddressBytesToStringQuery extends ReactQueryParams { + request: AddressBytesToStringRequest; +} +export interface UseAddressStringToBytesQuery extends ReactQueryParams { + request: AddressStringToBytesRequest; +} +const _queryClients: WeakMap = new WeakMap(); +const getQueryService = (rpc: ProtobufRpcClient | undefined): QueryClientImpl | undefined => { + if (!rpc) return; + if (_queryClients.has(rpc)) { + return _queryClients.get(rpc); + } + const queryService = new QueryClientImpl(rpc); + _queryClients.set(rpc, queryService); + return queryService; +}; +export const createRpcQueryHooks = (rpc: ProtobufRpcClient | undefined) => { + const queryService = getQueryService(rpc); + const useAccounts = ({ + request, + options + }: UseAccountsQuery) => { + return useQuery(["accountsQuery", request], () => { + if (!queryService) throw new Error("Query Service not initialized"); + return queryService.accounts(request); + }, options); + }; + const useAccount = ({ + request, + options + }: UseAccountQuery) => { + return useQuery(["accountQuery", request], () => { + if (!queryService) throw new Error("Query Service not initialized"); + return queryService.account(request); + }, options); + }; + const useParams = ({ + request, + options + }: UseParamsQuery) => { + return useQuery(["paramsQuery", request], () => { + if (!queryService) throw new Error("Query Service not initialized"); + return queryService.params(request); + }, options); + }; + const useModuleAccounts = ({ + request, + options + }: UseModuleAccountsQuery) => { + return useQuery(["moduleAccountsQuery", request], () => { + if (!queryService) throw new Error("Query Service not initialized"); + return queryService.moduleAccounts(request); + }, options); + }; + const useBech32Prefix = ({ + request, + options + }: UseBech32PrefixQuery) => { + return useQuery(["bech32PrefixQuery", request], () => { + if (!queryService) throw new Error("Query Service not initialized"); + return queryService.bech32Prefix(request); + }, options); + }; + const useAddressBytesToString = ({ + request, + options + }: UseAddressBytesToStringQuery) => { + return useQuery(["addressBytesToStringQuery", request], () => { + if (!queryService) throw new Error("Query Service not initialized"); + return queryService.addressBytesToString(request); + }, options); + }; + const useAddressStringToBytes = ({ + request, + options + }: UseAddressStringToBytesQuery) => { + return useQuery(["addressStringToBytesQuery", request], () => { + if (!queryService) throw new Error("Query Service not initialized"); + return queryService.addressStringToBytes(request); + }, options); + }; + return { + /** + * Accounts returns all the existing accounts + * + * Since: cosmos-sdk 0.43 + */ + useAccounts, + /** Account returns account details based on address. */useAccount, + /** Params queries all parameters. */useParams, + /** ModuleAccounts returns all the existing module accounts. */useModuleAccounts, + /** Bech32 queries bech32Prefix */useBech32Prefix, + /** AddressBytesToString converts Account Address bytes to string */useAddressBytesToString, + /** AddressStringToBytes converts Address string to bytes */useAddressStringToBytes + }; +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/auth/v1beta1/query.rpc.func.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/auth/v1beta1/query.rpc.func.ts new file mode 100644 index 0000000000..9e23360f60 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/auth/v1beta1/query.rpc.func.ts @@ -0,0 +1,80 @@ +import { RpcResolver, buildQuery } from "../../../helper-func-types"; +import { buildUseQuery } from "../../../react-query"; +import { QueryAccountsRequest, QueryAccountsResponse, QueryAccountRequest, QueryAccountResponse, QueryParamsRequest, QueryParamsResponse, QueryModuleAccountsRequest, QueryModuleAccountsResponse, Bech32PrefixRequest, Bech32PrefixResponse, AddressBytesToStringRequest, AddressBytesToStringResponse, AddressStringToBytesRequest, AddressStringToBytesResponse } from "./query"; +export const createGetAccounts = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryAccountsRequest.encode, + decode: QueryAccountsResponse.decode, + service: "cosmos.auth.v1beta1.Query", + method: "Accounts", + getRpcInstance: getRpcInstance +}); +export const useGetAccounts = buildUseQuery({ + builderQueryFn: createGetAccounts, + queryKeyPrefix: "AccountsQuery" +}); +export const createGetAccount = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryAccountRequest.encode, + decode: QueryAccountResponse.decode, + service: "cosmos.auth.v1beta1.Query", + method: "Account", + getRpcInstance: getRpcInstance +}); +export const useGetAccount = buildUseQuery({ + builderQueryFn: createGetAccount, + queryKeyPrefix: "AccountQuery" +}); +export const createGetParams = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryParamsRequest.encode, + decode: QueryParamsResponse.decode, + service: "cosmos.auth.v1beta1.Query", + method: "Params", + getRpcInstance: getRpcInstance +}); +export const useGetParams = buildUseQuery({ + builderQueryFn: createGetParams, + queryKeyPrefix: "ParamsQuery" +}); +export const createGetModuleAccounts = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryModuleAccountsRequest.encode, + decode: QueryModuleAccountsResponse.decode, + service: "cosmos.auth.v1beta1.Query", + method: "ModuleAccounts", + getRpcInstance: getRpcInstance +}); +export const useGetModuleAccounts = buildUseQuery({ + builderQueryFn: createGetModuleAccounts, + queryKeyPrefix: "ModuleAccountsQuery" +}); +export const createGetBech32Prefix = (getRpcInstance: RpcResolver) => buildQuery({ + encode: Bech32PrefixRequest.encode, + decode: Bech32PrefixResponse.decode, + service: "cosmos.auth.v1beta1.Query", + method: "Bech32Prefix", + getRpcInstance: getRpcInstance +}); +export const useGetBech32Prefix = buildUseQuery({ + builderQueryFn: createGetBech32Prefix, + queryKeyPrefix: "Bech32PrefixQuery" +}); +export const createGetAddressBytesToString = (getRpcInstance: RpcResolver) => buildQuery({ + encode: AddressBytesToStringRequest.encode, + decode: AddressBytesToStringResponse.decode, + service: "cosmos.auth.v1beta1.Query", + method: "AddressBytesToString", + getRpcInstance: getRpcInstance +}); +export const useGetAddressBytesToString = buildUseQuery({ + builderQueryFn: createGetAddressBytesToString, + queryKeyPrefix: "AddressBytesToStringQuery" +}); +export const createGetAddressStringToBytes = (getRpcInstance: RpcResolver) => buildQuery({ + encode: AddressStringToBytesRequest.encode, + decode: AddressStringToBytesResponse.decode, + service: "cosmos.auth.v1beta1.Query", + method: "AddressStringToBytes", + getRpcInstance: getRpcInstance +}); +export const useGetAddressStringToBytes = buildUseQuery({ + builderQueryFn: createGetAddressStringToBytes, + queryKeyPrefix: "AddressStringToBytesQuery" +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/auth/v1beta1/query.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/auth/v1beta1/query.ts new file mode 100644 index 0000000000..6af28ab2b6 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/auth/v1beta1/query.ts @@ -0,0 +1,1488 @@ +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../base/query/v1beta1/pagination.js"; +import { Any, AnySDKType } from "../../../google/protobuf/any.js"; +import { Params, ParamsSDKType } from "./auth.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial, bytesFromBase64, base64FromBytes } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "cosmos.auth.v1beta1"; +/** + * QueryAccountsRequest is the request type for the Query/Accounts RPC method. + * + * Since: cosmos-sdk 0.43 + */ +export interface QueryAccountsRequest { + /** pagination defines an optional pagination for the request. */ + pagination?: PageRequest; +} +export interface QueryAccountsRequestProtoMsg { + typeUrl: "/cosmos.auth.v1beta1.QueryAccountsRequest"; + value: Uint8Array; +} +/** + * QueryAccountsRequest is the request type for the Query/Accounts RPC method. + * + * Since: cosmos-sdk 0.43 + */ +export interface QueryAccountsRequestSDKType { + pagination?: PageRequestSDKType; +} +/** + * QueryAccountsResponse is the response type for the Query/Accounts RPC method. + * + * Since: cosmos-sdk 0.43 + */ +export interface QueryAccountsResponse { + /** accounts are the existing accounts */ + accounts: Any[]; + /** pagination defines the pagination in the response. */ + pagination?: PageResponse; +} +export interface QueryAccountsResponseProtoMsg { + typeUrl: "/cosmos.auth.v1beta1.QueryAccountsResponse"; + value: Uint8Array; +} +/** + * QueryAccountsResponse is the response type for the Query/Accounts RPC method. + * + * Since: cosmos-sdk 0.43 + */ +export interface QueryAccountsResponseSDKType { + accounts: AnySDKType[]; + pagination?: PageResponseSDKType; +} +/** QueryAccountRequest is the request type for the Query/Account RPC method. */ +export interface QueryAccountRequest { + /** address defines the address to query for. */ + address: string; +} +export interface QueryAccountRequestProtoMsg { + typeUrl: "/cosmos.auth.v1beta1.QueryAccountRequest"; + value: Uint8Array; +} +/** QueryAccountRequest is the request type for the Query/Account RPC method. */ +export interface QueryAccountRequestSDKType { + address: string; +} +/** QueryModuleAccountsRequest is the request type for the Query/ModuleAccounts RPC method. */ +export interface QueryModuleAccountsRequest {} +export interface QueryModuleAccountsRequestProtoMsg { + typeUrl: "/cosmos.auth.v1beta1.QueryModuleAccountsRequest"; + value: Uint8Array; +} +/** QueryModuleAccountsRequest is the request type for the Query/ModuleAccounts RPC method. */ +export interface QueryModuleAccountsRequestSDKType {} +/** QueryParamsResponse is the response type for the Query/Params RPC method. */ +export interface QueryParamsResponse { + /** params defines the parameters of the module. */ + params: Params; +} +export interface QueryParamsResponseProtoMsg { + typeUrl: "/cosmos.auth.v1beta1.QueryParamsResponse"; + value: Uint8Array; +} +/** QueryParamsResponse is the response type for the Query/Params RPC method. */ +export interface QueryParamsResponseSDKType { + params: ParamsSDKType; +} +/** QueryAccountResponse is the response type for the Query/Account RPC method. */ +export interface QueryAccountResponse { + /** account defines the account of the corresponding address. */ + account?: Any; +} +export interface QueryAccountResponseProtoMsg { + typeUrl: "/cosmos.auth.v1beta1.QueryAccountResponse"; + value: Uint8Array; +} +/** QueryAccountResponse is the response type for the Query/Account RPC method. */ +export interface QueryAccountResponseSDKType { + account?: AnySDKType; +} +/** QueryParamsRequest is the request type for the Query/Params RPC method. */ +export interface QueryParamsRequest {} +export interface QueryParamsRequestProtoMsg { + typeUrl: "/cosmos.auth.v1beta1.QueryParamsRequest"; + value: Uint8Array; +} +/** QueryParamsRequest is the request type for the Query/Params RPC method. */ +export interface QueryParamsRequestSDKType {} +/** QueryModuleAccountsResponse is the response type for the Query/ModuleAccounts RPC method. */ +export interface QueryModuleAccountsResponse { + accounts: Any[]; +} +export interface QueryModuleAccountsResponseProtoMsg { + typeUrl: "/cosmos.auth.v1beta1.QueryModuleAccountsResponse"; + value: Uint8Array; +} +/** QueryModuleAccountsResponse is the response type for the Query/ModuleAccounts RPC method. */ +export interface QueryModuleAccountsResponseSDKType { + accounts: AnySDKType[]; +} +/** Bech32PrefixRequest is the request type for Bech32Prefix rpc method */ +export interface Bech32PrefixRequest {} +export interface Bech32PrefixRequestProtoMsg { + typeUrl: "/cosmos.auth.v1beta1.Bech32PrefixRequest"; + value: Uint8Array; +} +/** Bech32PrefixRequest is the request type for Bech32Prefix rpc method */ +export interface Bech32PrefixRequestSDKType {} +/** Bech32PrefixResponse is the response type for Bech32Prefix rpc method */ +export interface Bech32PrefixResponse { + bech32Prefix: string; +} +export interface Bech32PrefixResponseProtoMsg { + typeUrl: "/cosmos.auth.v1beta1.Bech32PrefixResponse"; + value: Uint8Array; +} +/** Bech32PrefixResponse is the response type for Bech32Prefix rpc method */ +export interface Bech32PrefixResponseSDKType { + bech32_prefix: string; +} +/** AddressBytesToStringRequest is the request type for AddressString rpc method */ +export interface AddressBytesToStringRequest { + addressBytes: Uint8Array; +} +export interface AddressBytesToStringRequestProtoMsg { + typeUrl: "/cosmos.auth.v1beta1.AddressBytesToStringRequest"; + value: Uint8Array; +} +/** AddressBytesToStringRequest is the request type for AddressString rpc method */ +export interface AddressBytesToStringRequestSDKType { + address_bytes: Uint8Array; +} +/** AddressBytesToStringResponse is the response type for AddressString rpc method */ +export interface AddressBytesToStringResponse { + addressString: string; +} +export interface AddressBytesToStringResponseProtoMsg { + typeUrl: "/cosmos.auth.v1beta1.AddressBytesToStringResponse"; + value: Uint8Array; +} +/** AddressBytesToStringResponse is the response type for AddressString rpc method */ +export interface AddressBytesToStringResponseSDKType { + address_string: string; +} +/** AddressStringToBytesRequest is the request type for AccountBytes rpc method */ +export interface AddressStringToBytesRequest { + addressString: string; +} +export interface AddressStringToBytesRequestProtoMsg { + typeUrl: "/cosmos.auth.v1beta1.AddressStringToBytesRequest"; + value: Uint8Array; +} +/** AddressStringToBytesRequest is the request type for AccountBytes rpc method */ +export interface AddressStringToBytesRequestSDKType { + address_string: string; +} +/** AddressStringToBytesResponse is the response type for AddressBytes rpc method */ +export interface AddressStringToBytesResponse { + addressBytes: Uint8Array; +} +export interface AddressStringToBytesResponseProtoMsg { + typeUrl: "/cosmos.auth.v1beta1.AddressStringToBytesResponse"; + value: Uint8Array; +} +/** AddressStringToBytesResponse is the response type for AddressBytes rpc method */ +export interface AddressStringToBytesResponseSDKType { + address_bytes: Uint8Array; +} +function createBaseQueryAccountsRequest(): QueryAccountsRequest { + return { + pagination: undefined + }; +} +export const QueryAccountsRequest = { + typeUrl: "/cosmos.auth.v1beta1.QueryAccountsRequest", + encode(message: QueryAccountsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryAccountsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryAccountsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryAccountsRequest { + const obj = createBaseQueryAccountsRequest(); + if (isSet(object.pagination)) obj.pagination = PageRequest.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryAccountsRequest): JsonSafe { + const obj: any = {}; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryAccountsRequest { + const message = createBaseQueryAccountsRequest(); + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryAccountsRequestSDKType): QueryAccountsRequest { + return { + pagination: object.pagination ? PageRequest.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryAccountsRequestSDKType { + return { + pagination: isSet(object.pagination) ? PageRequest.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryAccountsRequest): QueryAccountsRequestSDKType { + const obj: any = {}; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryAccountsRequestAmino): QueryAccountsRequest { + const message = createBaseQueryAccountsRequest(); + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryAccountsRequest): QueryAccountsRequestAmino { + const obj: any = {}; + obj.pagination = message.pagination ? PageRequest.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryAccountsRequestAminoMsg): QueryAccountsRequest { + return QueryAccountsRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryAccountsRequest): QueryAccountsRequestAminoMsg { + return { + type: "cosmos-sdk/QueryAccountsRequest", + value: QueryAccountsRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryAccountsRequestProtoMsg): QueryAccountsRequest { + return QueryAccountsRequest.decode(message.value); + }, + toProto(message: QueryAccountsRequest): Uint8Array { + return QueryAccountsRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryAccountsRequest): QueryAccountsRequestProtoMsg { + return { + typeUrl: "/cosmos.auth.v1beta1.QueryAccountsRequest", + value: QueryAccountsRequest.encode(message).finish() + }; + } +}; +function createBaseQueryAccountsResponse(): QueryAccountsResponse { + return { + accounts: [], + pagination: undefined + }; +} +export const QueryAccountsResponse = { + typeUrl: "/cosmos.auth.v1beta1.QueryAccountsResponse", + encode(message: QueryAccountsResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.accounts) { + Any.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryAccountsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryAccountsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.accounts.push(Any.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryAccountsResponse { + const obj = createBaseQueryAccountsResponse(); + if (Array.isArray(object?.accounts)) obj.accounts = object.accounts.map((e: any) => Any.fromJSON(e)); + if (isSet(object.pagination)) obj.pagination = PageResponse.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryAccountsResponse): JsonSafe { + const obj: any = {}; + if (message.accounts) { + obj.accounts = message.accounts.map(e => e ? Any.toJSON(e) : undefined); + } else { + obj.accounts = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryAccountsResponse { + const message = createBaseQueryAccountsResponse(); + message.accounts = object.accounts?.map(e => Any.fromPartial(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryAccountsResponseSDKType): QueryAccountsResponse { + return { + accounts: Array.isArray(object?.accounts) ? object.accounts.map((e: any) => Any.fromSDK(e)) : [], + pagination: object.pagination ? PageResponse.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryAccountsResponseSDKType { + return { + accounts: Array.isArray(object?.accounts) ? object.accounts.map((e: any) => Any.fromSDKJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryAccountsResponse): QueryAccountsResponseSDKType { + const obj: any = {}; + if (message.accounts) { + obj.accounts = message.accounts.map(e => e ? Any.toSDK(e) : undefined); + } else { + obj.accounts = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryAccountsResponseAmino): QueryAccountsResponse { + const message = createBaseQueryAccountsResponse(); + message.accounts = object.accounts?.map(e => Any.fromAmino(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryAccountsResponse): QueryAccountsResponseAmino { + const obj: any = {}; + if (message.accounts) { + obj.accounts = message.accounts.map(e => e ? Any.toAmino(e) : undefined); + } else { + obj.accounts = message.accounts; + } + obj.pagination = message.pagination ? PageResponse.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryAccountsResponseAminoMsg): QueryAccountsResponse { + return QueryAccountsResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryAccountsResponse): QueryAccountsResponseAminoMsg { + return { + type: "cosmos-sdk/QueryAccountsResponse", + value: QueryAccountsResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryAccountsResponseProtoMsg): QueryAccountsResponse { + return QueryAccountsResponse.decode(message.value); + }, + toProto(message: QueryAccountsResponse): Uint8Array { + return QueryAccountsResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryAccountsResponse): QueryAccountsResponseProtoMsg { + return { + typeUrl: "/cosmos.auth.v1beta1.QueryAccountsResponse", + value: QueryAccountsResponse.encode(message).finish() + }; + } +}; +function createBaseQueryAccountRequest(): QueryAccountRequest { + return { + address: "" + }; +} +export const QueryAccountRequest = { + typeUrl: "/cosmos.auth.v1beta1.QueryAccountRequest", + encode(message: QueryAccountRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.address !== undefined) { + writer.uint32(10).string(message.address); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryAccountRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryAccountRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryAccountRequest { + const obj = createBaseQueryAccountRequest(); + if (isSet(object.address)) obj.address = String(object.address); + return obj; + }, + toJSON(message: QueryAccountRequest): JsonSafe { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + return obj; + }, + fromPartial(object: DeepPartial): QueryAccountRequest { + const message = createBaseQueryAccountRequest(); + message.address = object.address ?? ""; + return message; + }, + fromSDK(object: QueryAccountRequestSDKType): QueryAccountRequest { + return { + address: object?.address + }; + }, + fromSDKJSON(object: any): QueryAccountRequestSDKType { + return { + address: isSet(object.address) ? String(object.address) : "" + }; + }, + toSDK(message: QueryAccountRequest): QueryAccountRequestSDKType { + const obj: any = {}; + obj.address = message.address; + return obj; + }, + fromAmino(object: QueryAccountRequestAmino): QueryAccountRequest { + const message = createBaseQueryAccountRequest(); + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } + return message; + }, + toAmino(message: QueryAccountRequest): QueryAccountRequestAmino { + const obj: any = {}; + obj.address = message.address === "" ? undefined : message.address; + return obj; + }, + fromAminoMsg(object: QueryAccountRequestAminoMsg): QueryAccountRequest { + return QueryAccountRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryAccountRequest): QueryAccountRequestAminoMsg { + return { + type: "cosmos-sdk/QueryAccountRequest", + value: QueryAccountRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryAccountRequestProtoMsg): QueryAccountRequest { + return QueryAccountRequest.decode(message.value); + }, + toProto(message: QueryAccountRequest): Uint8Array { + return QueryAccountRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryAccountRequest): QueryAccountRequestProtoMsg { + return { + typeUrl: "/cosmos.auth.v1beta1.QueryAccountRequest", + value: QueryAccountRequest.encode(message).finish() + }; + } +}; +function createBaseQueryModuleAccountsRequest(): QueryModuleAccountsRequest { + return {}; +} +export const QueryModuleAccountsRequest = { + typeUrl: "/cosmos.auth.v1beta1.QueryModuleAccountsRequest", + encode(_: QueryModuleAccountsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryModuleAccountsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryModuleAccountsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): QueryModuleAccountsRequest { + const obj = createBaseQueryModuleAccountsRequest(); + return obj; + }, + toJSON(_: QueryModuleAccountsRequest): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): QueryModuleAccountsRequest { + const message = createBaseQueryModuleAccountsRequest(); + return message; + }, + fromSDK(_: QueryModuleAccountsRequestSDKType): QueryModuleAccountsRequest { + return {}; + }, + fromSDKJSON(_: any): QueryModuleAccountsRequestSDKType { + return {}; + }, + toSDK(_: QueryModuleAccountsRequest): QueryModuleAccountsRequestSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: QueryModuleAccountsRequestAmino): QueryModuleAccountsRequest { + const message = createBaseQueryModuleAccountsRequest(); + return message; + }, + toAmino(_: QueryModuleAccountsRequest): QueryModuleAccountsRequestAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: QueryModuleAccountsRequestAminoMsg): QueryModuleAccountsRequest { + return QueryModuleAccountsRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryModuleAccountsRequest): QueryModuleAccountsRequestAminoMsg { + return { + type: "cosmos-sdk/QueryModuleAccountsRequest", + value: QueryModuleAccountsRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryModuleAccountsRequestProtoMsg): QueryModuleAccountsRequest { + return QueryModuleAccountsRequest.decode(message.value); + }, + toProto(message: QueryModuleAccountsRequest): Uint8Array { + return QueryModuleAccountsRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryModuleAccountsRequest): QueryModuleAccountsRequestProtoMsg { + return { + typeUrl: "/cosmos.auth.v1beta1.QueryModuleAccountsRequest", + value: QueryModuleAccountsRequest.encode(message).finish() + }; + } +}; +function createBaseQueryParamsResponse(): QueryParamsResponse { + return { + params: Params.fromPartial({}) + }; +} +export const QueryParamsResponse = { + typeUrl: "/cosmos.auth.v1beta1.QueryParamsResponse", + encode(message: QueryParamsResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryParamsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryParamsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.params = Params.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryParamsResponse { + const obj = createBaseQueryParamsResponse(); + if (isSet(object.params)) obj.params = Params.fromJSON(object.params); + return obj; + }, + toJSON(message: QueryParamsResponse): JsonSafe { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryParamsResponse { + const message = createBaseQueryParamsResponse(); + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } + return message; + }, + fromSDK(object: QueryParamsResponseSDKType): QueryParamsResponse { + return { + params: object.params ? Params.fromSDK(object.params) : undefined + }; + }, + fromSDKJSON(object: any): QueryParamsResponseSDKType { + return { + params: isSet(object.params) ? Params.fromSDKJSON(object.params) : undefined + }; + }, + toSDK(message: QueryParamsResponse): QueryParamsResponseSDKType { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toSDK(message.params) : undefined); + return obj; + }, + fromAmino(object: QueryParamsResponseAmino): QueryParamsResponse { + const message = createBaseQueryParamsResponse(); + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromAmino(object.params); + } + return message; + }, + toAmino(message: QueryParamsResponse): QueryParamsResponseAmino { + const obj: any = {}; + obj.params = message.params ? Params.toAmino(message.params) : undefined; + return obj; + }, + fromAminoMsg(object: QueryParamsResponseAminoMsg): QueryParamsResponse { + return QueryParamsResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryParamsResponse): QueryParamsResponseAminoMsg { + return { + type: "cosmos-sdk/QueryParamsResponse", + value: QueryParamsResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryParamsResponseProtoMsg): QueryParamsResponse { + return QueryParamsResponse.decode(message.value); + }, + toProto(message: QueryParamsResponse): Uint8Array { + return QueryParamsResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryParamsResponse): QueryParamsResponseProtoMsg { + return { + typeUrl: "/cosmos.auth.v1beta1.QueryParamsResponse", + value: QueryParamsResponse.encode(message).finish() + }; + } +}; +function createBaseQueryAccountResponse(): QueryAccountResponse { + return { + account: undefined + }; +} +export const QueryAccountResponse = { + typeUrl: "/cosmos.auth.v1beta1.QueryAccountResponse", + encode(message: QueryAccountResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.account !== undefined) { + Any.encode(message.account, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryAccountResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryAccountResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.account = Any.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryAccountResponse { + const obj = createBaseQueryAccountResponse(); + if (isSet(object.account)) obj.account = Any.fromJSON(object.account); + return obj; + }, + toJSON(message: QueryAccountResponse): JsonSafe { + const obj: any = {}; + message.account !== undefined && (obj.account = message.account ? Any.toJSON(message.account) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryAccountResponse { + const message = createBaseQueryAccountResponse(); + if (object.account !== undefined && object.account !== null) { + message.account = Any.fromPartial(object.account); + } + return message; + }, + fromSDK(object: QueryAccountResponseSDKType): QueryAccountResponse { + return { + account: object.account ? Any.fromSDK(object.account) : undefined + }; + }, + fromSDKJSON(object: any): QueryAccountResponseSDKType { + return { + account: isSet(object.account) ? Any.fromSDKJSON(object.account) : undefined + }; + }, + toSDK(message: QueryAccountResponse): QueryAccountResponseSDKType { + const obj: any = {}; + message.account !== undefined && (obj.account = message.account ? Any.toSDK(message.account) : undefined); + return obj; + }, + fromAmino(object: QueryAccountResponseAmino): QueryAccountResponse { + const message = createBaseQueryAccountResponse(); + if (object.account !== undefined && object.account !== null) { + message.account = Any.fromAmino(object.account); + } + return message; + }, + toAmino(message: QueryAccountResponse): QueryAccountResponseAmino { + const obj: any = {}; + obj.account = message.account ? Any.toAmino(message.account) : undefined; + return obj; + }, + fromAminoMsg(object: QueryAccountResponseAminoMsg): QueryAccountResponse { + return QueryAccountResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryAccountResponse): QueryAccountResponseAminoMsg { + return { + type: "cosmos-sdk/QueryAccountResponse", + value: QueryAccountResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryAccountResponseProtoMsg): QueryAccountResponse { + return QueryAccountResponse.decode(message.value); + }, + toProto(message: QueryAccountResponse): Uint8Array { + return QueryAccountResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryAccountResponse): QueryAccountResponseProtoMsg { + return { + typeUrl: "/cosmos.auth.v1beta1.QueryAccountResponse", + value: QueryAccountResponse.encode(message).finish() + }; + } +}; +function createBaseQueryParamsRequest(): QueryParamsRequest { + return {}; +} +export const QueryParamsRequest = { + typeUrl: "/cosmos.auth.v1beta1.QueryParamsRequest", + encode(_: QueryParamsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryParamsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryParamsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): QueryParamsRequest { + const obj = createBaseQueryParamsRequest(); + return obj; + }, + toJSON(_: QueryParamsRequest): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): QueryParamsRequest { + const message = createBaseQueryParamsRequest(); + return message; + }, + fromSDK(_: QueryParamsRequestSDKType): QueryParamsRequest { + return {}; + }, + fromSDKJSON(_: any): QueryParamsRequestSDKType { + return {}; + }, + toSDK(_: QueryParamsRequest): QueryParamsRequestSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: QueryParamsRequestAmino): QueryParamsRequest { + const message = createBaseQueryParamsRequest(); + return message; + }, + toAmino(_: QueryParamsRequest): QueryParamsRequestAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: QueryParamsRequestAminoMsg): QueryParamsRequest { + return QueryParamsRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryParamsRequest): QueryParamsRequestAminoMsg { + return { + type: "cosmos-sdk/QueryParamsRequest", + value: QueryParamsRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryParamsRequestProtoMsg): QueryParamsRequest { + return QueryParamsRequest.decode(message.value); + }, + toProto(message: QueryParamsRequest): Uint8Array { + return QueryParamsRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryParamsRequest): QueryParamsRequestProtoMsg { + return { + typeUrl: "/cosmos.auth.v1beta1.QueryParamsRequest", + value: QueryParamsRequest.encode(message).finish() + }; + } +}; +function createBaseQueryModuleAccountsResponse(): QueryModuleAccountsResponse { + return { + accounts: [] + }; +} +export const QueryModuleAccountsResponse = { + typeUrl: "/cosmos.auth.v1beta1.QueryModuleAccountsResponse", + encode(message: QueryModuleAccountsResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.accounts) { + Any.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryModuleAccountsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryModuleAccountsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.accounts.push(Any.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryModuleAccountsResponse { + const obj = createBaseQueryModuleAccountsResponse(); + if (Array.isArray(object?.accounts)) obj.accounts = object.accounts.map((e: any) => Any.fromJSON(e)); + return obj; + }, + toJSON(message: QueryModuleAccountsResponse): JsonSafe { + const obj: any = {}; + if (message.accounts) { + obj.accounts = message.accounts.map(e => e ? Any.toJSON(e) : undefined); + } else { + obj.accounts = []; + } + return obj; + }, + fromPartial(object: DeepPartial): QueryModuleAccountsResponse { + const message = createBaseQueryModuleAccountsResponse(); + message.accounts = object.accounts?.map(e => Any.fromPartial(e)) || []; + return message; + }, + fromSDK(object: QueryModuleAccountsResponseSDKType): QueryModuleAccountsResponse { + return { + accounts: Array.isArray(object?.accounts) ? object.accounts.map((e: any) => Any.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): QueryModuleAccountsResponseSDKType { + return { + accounts: Array.isArray(object?.accounts) ? object.accounts.map((e: any) => Any.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: QueryModuleAccountsResponse): QueryModuleAccountsResponseSDKType { + const obj: any = {}; + if (message.accounts) { + obj.accounts = message.accounts.map(e => e ? Any.toSDK(e) : undefined); + } else { + obj.accounts = []; + } + return obj; + }, + fromAmino(object: QueryModuleAccountsResponseAmino): QueryModuleAccountsResponse { + const message = createBaseQueryModuleAccountsResponse(); + message.accounts = object.accounts?.map(e => Any.fromAmino(e)) || []; + return message; + }, + toAmino(message: QueryModuleAccountsResponse): QueryModuleAccountsResponseAmino { + const obj: any = {}; + if (message.accounts) { + obj.accounts = message.accounts.map(e => e ? Any.toAmino(e) : undefined); + } else { + obj.accounts = message.accounts; + } + return obj; + }, + fromAminoMsg(object: QueryModuleAccountsResponseAminoMsg): QueryModuleAccountsResponse { + return QueryModuleAccountsResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryModuleAccountsResponse): QueryModuleAccountsResponseAminoMsg { + return { + type: "cosmos-sdk/QueryModuleAccountsResponse", + value: QueryModuleAccountsResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryModuleAccountsResponseProtoMsg): QueryModuleAccountsResponse { + return QueryModuleAccountsResponse.decode(message.value); + }, + toProto(message: QueryModuleAccountsResponse): Uint8Array { + return QueryModuleAccountsResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryModuleAccountsResponse): QueryModuleAccountsResponseProtoMsg { + return { + typeUrl: "/cosmos.auth.v1beta1.QueryModuleAccountsResponse", + value: QueryModuleAccountsResponse.encode(message).finish() + }; + } +}; +function createBaseBech32PrefixRequest(): Bech32PrefixRequest { + return {}; +} +export const Bech32PrefixRequest = { + typeUrl: "/cosmos.auth.v1beta1.Bech32PrefixRequest", + encode(_: Bech32PrefixRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Bech32PrefixRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseBech32PrefixRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): Bech32PrefixRequest { + const obj = createBaseBech32PrefixRequest(); + return obj; + }, + toJSON(_: Bech32PrefixRequest): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): Bech32PrefixRequest { + const message = createBaseBech32PrefixRequest(); + return message; + }, + fromSDK(_: Bech32PrefixRequestSDKType): Bech32PrefixRequest { + return {}; + }, + fromSDKJSON(_: any): Bech32PrefixRequestSDKType { + return {}; + }, + toSDK(_: Bech32PrefixRequest): Bech32PrefixRequestSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: Bech32PrefixRequestAmino): Bech32PrefixRequest { + const message = createBaseBech32PrefixRequest(); + return message; + }, + toAmino(_: Bech32PrefixRequest): Bech32PrefixRequestAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: Bech32PrefixRequestAminoMsg): Bech32PrefixRequest { + return Bech32PrefixRequest.fromAmino(object.value); + }, + toAminoMsg(message: Bech32PrefixRequest): Bech32PrefixRequestAminoMsg { + return { + type: "cosmos-sdk/Bech32PrefixRequest", + value: Bech32PrefixRequest.toAmino(message) + }; + }, + fromProtoMsg(message: Bech32PrefixRequestProtoMsg): Bech32PrefixRequest { + return Bech32PrefixRequest.decode(message.value); + }, + toProto(message: Bech32PrefixRequest): Uint8Array { + return Bech32PrefixRequest.encode(message).finish(); + }, + toProtoMsg(message: Bech32PrefixRequest): Bech32PrefixRequestProtoMsg { + return { + typeUrl: "/cosmos.auth.v1beta1.Bech32PrefixRequest", + value: Bech32PrefixRequest.encode(message).finish() + }; + } +}; +function createBaseBech32PrefixResponse(): Bech32PrefixResponse { + return { + bech32Prefix: "" + }; +} +export const Bech32PrefixResponse = { + typeUrl: "/cosmos.auth.v1beta1.Bech32PrefixResponse", + encode(message: Bech32PrefixResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.bech32Prefix !== undefined) { + writer.uint32(10).string(message.bech32Prefix); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Bech32PrefixResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseBech32PrefixResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.bech32Prefix = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Bech32PrefixResponse { + const obj = createBaseBech32PrefixResponse(); + if (isSet(object.bech32Prefix)) obj.bech32Prefix = String(object.bech32Prefix); + return obj; + }, + toJSON(message: Bech32PrefixResponse): JsonSafe { + const obj: any = {}; + message.bech32Prefix !== undefined && (obj.bech32Prefix = message.bech32Prefix); + return obj; + }, + fromPartial(object: DeepPartial): Bech32PrefixResponse { + const message = createBaseBech32PrefixResponse(); + message.bech32Prefix = object.bech32Prefix ?? ""; + return message; + }, + fromSDK(object: Bech32PrefixResponseSDKType): Bech32PrefixResponse { + return { + bech32Prefix: object?.bech32_prefix + }; + }, + fromSDKJSON(object: any): Bech32PrefixResponseSDKType { + return { + bech32_prefix: isSet(object.bech32_prefix) ? String(object.bech32_prefix) : "" + }; + }, + toSDK(message: Bech32PrefixResponse): Bech32PrefixResponseSDKType { + const obj: any = {}; + obj.bech32_prefix = message.bech32Prefix; + return obj; + }, + fromAmino(object: Bech32PrefixResponseAmino): Bech32PrefixResponse { + const message = createBaseBech32PrefixResponse(); + if (object.bech32_prefix !== undefined && object.bech32_prefix !== null) { + message.bech32Prefix = object.bech32_prefix; + } + return message; + }, + toAmino(message: Bech32PrefixResponse): Bech32PrefixResponseAmino { + const obj: any = {}; + obj.bech32_prefix = message.bech32Prefix === "" ? undefined : message.bech32Prefix; + return obj; + }, + fromAminoMsg(object: Bech32PrefixResponseAminoMsg): Bech32PrefixResponse { + return Bech32PrefixResponse.fromAmino(object.value); + }, + toAminoMsg(message: Bech32PrefixResponse): Bech32PrefixResponseAminoMsg { + return { + type: "cosmos-sdk/Bech32PrefixResponse", + value: Bech32PrefixResponse.toAmino(message) + }; + }, + fromProtoMsg(message: Bech32PrefixResponseProtoMsg): Bech32PrefixResponse { + return Bech32PrefixResponse.decode(message.value); + }, + toProto(message: Bech32PrefixResponse): Uint8Array { + return Bech32PrefixResponse.encode(message).finish(); + }, + toProtoMsg(message: Bech32PrefixResponse): Bech32PrefixResponseProtoMsg { + return { + typeUrl: "/cosmos.auth.v1beta1.Bech32PrefixResponse", + value: Bech32PrefixResponse.encode(message).finish() + }; + } +}; +function createBaseAddressBytesToStringRequest(): AddressBytesToStringRequest { + return { + addressBytes: new Uint8Array() + }; +} +export const AddressBytesToStringRequest = { + typeUrl: "/cosmos.auth.v1beta1.AddressBytesToStringRequest", + encode(message: AddressBytesToStringRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.addressBytes.length !== 0) { + writer.uint32(10).bytes(message.addressBytes); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): AddressBytesToStringRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseAddressBytesToStringRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.addressBytes = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): AddressBytesToStringRequest { + const obj = createBaseAddressBytesToStringRequest(); + if (isSet(object.addressBytes)) obj.addressBytes = bytesFromBase64(object.addressBytes); + return obj; + }, + toJSON(message: AddressBytesToStringRequest): JsonSafe { + const obj: any = {}; + message.addressBytes !== undefined && (obj.addressBytes = base64FromBytes(message.addressBytes !== undefined ? message.addressBytes : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): AddressBytesToStringRequest { + const message = createBaseAddressBytesToStringRequest(); + message.addressBytes = object.addressBytes ?? new Uint8Array(); + return message; + }, + fromSDK(object: AddressBytesToStringRequestSDKType): AddressBytesToStringRequest { + return { + addressBytes: object?.address_bytes + }; + }, + fromSDKJSON(object: any): AddressBytesToStringRequestSDKType { + return { + address_bytes: isSet(object.address_bytes) ? bytesFromBase64(object.address_bytes) : new Uint8Array() + }; + }, + toSDK(message: AddressBytesToStringRequest): AddressBytesToStringRequestSDKType { + const obj: any = {}; + obj.address_bytes = message.addressBytes; + return obj; + }, + fromAmino(object: AddressBytesToStringRequestAmino): AddressBytesToStringRequest { + const message = createBaseAddressBytesToStringRequest(); + if (object.address_bytes !== undefined && object.address_bytes !== null) { + message.addressBytes = bytesFromBase64(object.address_bytes); + } + return message; + }, + toAmino(message: AddressBytesToStringRequest): AddressBytesToStringRequestAmino { + const obj: any = {}; + obj.address_bytes = message.addressBytes ? base64FromBytes(message.addressBytes) : undefined; + return obj; + }, + fromAminoMsg(object: AddressBytesToStringRequestAminoMsg): AddressBytesToStringRequest { + return AddressBytesToStringRequest.fromAmino(object.value); + }, + toAminoMsg(message: AddressBytesToStringRequest): AddressBytesToStringRequestAminoMsg { + return { + type: "cosmos-sdk/AddressBytesToStringRequest", + value: AddressBytesToStringRequest.toAmino(message) + }; + }, + fromProtoMsg(message: AddressBytesToStringRequestProtoMsg): AddressBytesToStringRequest { + return AddressBytesToStringRequest.decode(message.value); + }, + toProto(message: AddressBytesToStringRequest): Uint8Array { + return AddressBytesToStringRequest.encode(message).finish(); + }, + toProtoMsg(message: AddressBytesToStringRequest): AddressBytesToStringRequestProtoMsg { + return { + typeUrl: "/cosmos.auth.v1beta1.AddressBytesToStringRequest", + value: AddressBytesToStringRequest.encode(message).finish() + }; + } +}; +function createBaseAddressBytesToStringResponse(): AddressBytesToStringResponse { + return { + addressString: "" + }; +} +export const AddressBytesToStringResponse = { + typeUrl: "/cosmos.auth.v1beta1.AddressBytesToStringResponse", + encode(message: AddressBytesToStringResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.addressString !== undefined) { + writer.uint32(10).string(message.addressString); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): AddressBytesToStringResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseAddressBytesToStringResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.addressString = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): AddressBytesToStringResponse { + const obj = createBaseAddressBytesToStringResponse(); + if (isSet(object.addressString)) obj.addressString = String(object.addressString); + return obj; + }, + toJSON(message: AddressBytesToStringResponse): JsonSafe { + const obj: any = {}; + message.addressString !== undefined && (obj.addressString = message.addressString); + return obj; + }, + fromPartial(object: DeepPartial): AddressBytesToStringResponse { + const message = createBaseAddressBytesToStringResponse(); + message.addressString = object.addressString ?? ""; + return message; + }, + fromSDK(object: AddressBytesToStringResponseSDKType): AddressBytesToStringResponse { + return { + addressString: object?.address_string + }; + }, + fromSDKJSON(object: any): AddressBytesToStringResponseSDKType { + return { + address_string: isSet(object.address_string) ? String(object.address_string) : "" + }; + }, + toSDK(message: AddressBytesToStringResponse): AddressBytesToStringResponseSDKType { + const obj: any = {}; + obj.address_string = message.addressString; + return obj; + }, + fromAmino(object: AddressBytesToStringResponseAmino): AddressBytesToStringResponse { + const message = createBaseAddressBytesToStringResponse(); + if (object.address_string !== undefined && object.address_string !== null) { + message.addressString = object.address_string; + } + return message; + }, + toAmino(message: AddressBytesToStringResponse): AddressBytesToStringResponseAmino { + const obj: any = {}; + obj.address_string = message.addressString === "" ? undefined : message.addressString; + return obj; + }, + fromAminoMsg(object: AddressBytesToStringResponseAminoMsg): AddressBytesToStringResponse { + return AddressBytesToStringResponse.fromAmino(object.value); + }, + toAminoMsg(message: AddressBytesToStringResponse): AddressBytesToStringResponseAminoMsg { + return { + type: "cosmos-sdk/AddressBytesToStringResponse", + value: AddressBytesToStringResponse.toAmino(message) + }; + }, + fromProtoMsg(message: AddressBytesToStringResponseProtoMsg): AddressBytesToStringResponse { + return AddressBytesToStringResponse.decode(message.value); + }, + toProto(message: AddressBytesToStringResponse): Uint8Array { + return AddressBytesToStringResponse.encode(message).finish(); + }, + toProtoMsg(message: AddressBytesToStringResponse): AddressBytesToStringResponseProtoMsg { + return { + typeUrl: "/cosmos.auth.v1beta1.AddressBytesToStringResponse", + value: AddressBytesToStringResponse.encode(message).finish() + }; + } +}; +function createBaseAddressStringToBytesRequest(): AddressStringToBytesRequest { + return { + addressString: "" + }; +} +export const AddressStringToBytesRequest = { + typeUrl: "/cosmos.auth.v1beta1.AddressStringToBytesRequest", + encode(message: AddressStringToBytesRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.addressString !== undefined) { + writer.uint32(10).string(message.addressString); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): AddressStringToBytesRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseAddressStringToBytesRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.addressString = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): AddressStringToBytesRequest { + const obj = createBaseAddressStringToBytesRequest(); + if (isSet(object.addressString)) obj.addressString = String(object.addressString); + return obj; + }, + toJSON(message: AddressStringToBytesRequest): JsonSafe { + const obj: any = {}; + message.addressString !== undefined && (obj.addressString = message.addressString); + return obj; + }, + fromPartial(object: DeepPartial): AddressStringToBytesRequest { + const message = createBaseAddressStringToBytesRequest(); + message.addressString = object.addressString ?? ""; + return message; + }, + fromSDK(object: AddressStringToBytesRequestSDKType): AddressStringToBytesRequest { + return { + addressString: object?.address_string + }; + }, + fromSDKJSON(object: any): AddressStringToBytesRequestSDKType { + return { + address_string: isSet(object.address_string) ? String(object.address_string) : "" + }; + }, + toSDK(message: AddressStringToBytesRequest): AddressStringToBytesRequestSDKType { + const obj: any = {}; + obj.address_string = message.addressString; + return obj; + }, + fromAmino(object: AddressStringToBytesRequestAmino): AddressStringToBytesRequest { + const message = createBaseAddressStringToBytesRequest(); + if (object.address_string !== undefined && object.address_string !== null) { + message.addressString = object.address_string; + } + return message; + }, + toAmino(message: AddressStringToBytesRequest): AddressStringToBytesRequestAmino { + const obj: any = {}; + obj.address_string = message.addressString === "" ? undefined : message.addressString; + return obj; + }, + fromAminoMsg(object: AddressStringToBytesRequestAminoMsg): AddressStringToBytesRequest { + return AddressStringToBytesRequest.fromAmino(object.value); + }, + toAminoMsg(message: AddressStringToBytesRequest): AddressStringToBytesRequestAminoMsg { + return { + type: "cosmos-sdk/AddressStringToBytesRequest", + value: AddressStringToBytesRequest.toAmino(message) + }; + }, + fromProtoMsg(message: AddressStringToBytesRequestProtoMsg): AddressStringToBytesRequest { + return AddressStringToBytesRequest.decode(message.value); + }, + toProto(message: AddressStringToBytesRequest): Uint8Array { + return AddressStringToBytesRequest.encode(message).finish(); + }, + toProtoMsg(message: AddressStringToBytesRequest): AddressStringToBytesRequestProtoMsg { + return { + typeUrl: "/cosmos.auth.v1beta1.AddressStringToBytesRequest", + value: AddressStringToBytesRequest.encode(message).finish() + }; + } +}; +function createBaseAddressStringToBytesResponse(): AddressStringToBytesResponse { + return { + addressBytes: new Uint8Array() + }; +} +export const AddressStringToBytesResponse = { + typeUrl: "/cosmos.auth.v1beta1.AddressStringToBytesResponse", + encode(message: AddressStringToBytesResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.addressBytes.length !== 0) { + writer.uint32(10).bytes(message.addressBytes); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): AddressStringToBytesResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseAddressStringToBytesResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.addressBytes = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): AddressStringToBytesResponse { + const obj = createBaseAddressStringToBytesResponse(); + if (isSet(object.addressBytes)) obj.addressBytes = bytesFromBase64(object.addressBytes); + return obj; + }, + toJSON(message: AddressStringToBytesResponse): JsonSafe { + const obj: any = {}; + message.addressBytes !== undefined && (obj.addressBytes = base64FromBytes(message.addressBytes !== undefined ? message.addressBytes : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): AddressStringToBytesResponse { + const message = createBaseAddressStringToBytesResponse(); + message.addressBytes = object.addressBytes ?? new Uint8Array(); + return message; + }, + fromSDK(object: AddressStringToBytesResponseSDKType): AddressStringToBytesResponse { + return { + addressBytes: object?.address_bytes + }; + }, + fromSDKJSON(object: any): AddressStringToBytesResponseSDKType { + return { + address_bytes: isSet(object.address_bytes) ? bytesFromBase64(object.address_bytes) : new Uint8Array() + }; + }, + toSDK(message: AddressStringToBytesResponse): AddressStringToBytesResponseSDKType { + const obj: any = {}; + obj.address_bytes = message.addressBytes; + return obj; + }, + fromAmino(object: AddressStringToBytesResponseAmino): AddressStringToBytesResponse { + const message = createBaseAddressStringToBytesResponse(); + if (object.address_bytes !== undefined && object.address_bytes !== null) { + message.addressBytes = bytesFromBase64(object.address_bytes); + } + return message; + }, + toAmino(message: AddressStringToBytesResponse): AddressStringToBytesResponseAmino { + const obj: any = {}; + obj.address_bytes = message.addressBytes ? base64FromBytes(message.addressBytes) : undefined; + return obj; + }, + fromAminoMsg(object: AddressStringToBytesResponseAminoMsg): AddressStringToBytesResponse { + return AddressStringToBytesResponse.fromAmino(object.value); + }, + toAminoMsg(message: AddressStringToBytesResponse): AddressStringToBytesResponseAminoMsg { + return { + type: "cosmos-sdk/AddressStringToBytesResponse", + value: AddressStringToBytesResponse.toAmino(message) + }; + }, + fromProtoMsg(message: AddressStringToBytesResponseProtoMsg): AddressStringToBytesResponse { + return AddressStringToBytesResponse.decode(message.value); + }, + toProto(message: AddressStringToBytesResponse): Uint8Array { + return AddressStringToBytesResponse.encode(message).finish(); + }, + toProtoMsg(message: AddressStringToBytesResponse): AddressStringToBytesResponseProtoMsg { + return { + typeUrl: "/cosmos.auth.v1beta1.AddressStringToBytesResponse", + value: AddressStringToBytesResponse.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/authz/v1beta1/authz.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/authz/v1beta1/authz.ts new file mode 100644 index 0000000000..b29eecedfa --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/authz/v1beta1/authz.ts @@ -0,0 +1,545 @@ +import { Any, AnySDKType } from "../../../google/protobuf/any.js"; +import { Timestamp, TimestampSDKType } from "../../../google/protobuf/timestamp.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial, toTimestamp, fromTimestamp } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "cosmos.authz.v1beta1"; +/** + * GenericAuthorization gives the grantee unrestricted permissions to execute + * the provided method on behalf of the granter's account. + */ +export interface GenericAuthorization { + /** Msg, identified by it's type URL, to grant unrestricted permissions to execute */ + msg: string; +} +export interface GenericAuthorizationProtoMsg { + typeUrl: "/cosmos.authz.v1beta1.GenericAuthorization"; + value: Uint8Array; +} +/** + * GenericAuthorization gives the grantee unrestricted permissions to execute + * the provided method on behalf of the granter's account. + */ +export interface GenericAuthorizationSDKType { + msg: string; +} +/** + * Grant gives permissions to execute + * the provide method with expiration time. + */ +export interface Grant { + authorization?: Any; + /** + * time when the grant will expire and will be pruned. If null, then the grant + * doesn't have a time expiration (other conditions in `authorization` + * may apply to invalidate the grant) + */ + expiration?: Date; +} +export interface GrantProtoMsg { + typeUrl: "/cosmos.authz.v1beta1.Grant"; + value: Uint8Array; +} +/** + * Grant gives permissions to execute + * the provide method with expiration time. + */ +export interface GrantSDKType { + authorization?: AnySDKType; + expiration?: Date; +} +/** + * GrantAuthorization extends a grant with both the addresses of the grantee and granter. + * It is used in genesis.proto and query.proto + */ +export interface GrantAuthorization { + granter: string; + grantee: string; + authorization?: Any; + expiration?: Date; +} +export interface GrantAuthorizationProtoMsg { + typeUrl: "/cosmos.authz.v1beta1.GrantAuthorization"; + value: Uint8Array; +} +/** + * GrantAuthorization extends a grant with both the addresses of the grantee and granter. + * It is used in genesis.proto and query.proto + */ +export interface GrantAuthorizationSDKType { + granter: string; + grantee: string; + authorization?: AnySDKType; + expiration?: Date; +} +/** GrantQueueItem contains the list of TypeURL of a sdk.Msg. */ +export interface GrantQueueItem { + /** msg_type_urls contains the list of TypeURL of a sdk.Msg. */ + msgTypeUrls: string[]; +} +export interface GrantQueueItemProtoMsg { + typeUrl: "/cosmos.authz.v1beta1.GrantQueueItem"; + value: Uint8Array; +} +/** GrantQueueItem contains the list of TypeURL of a sdk.Msg. */ +export interface GrantQueueItemSDKType { + msg_type_urls: string[]; +} +function createBaseGenericAuthorization(): GenericAuthorization { + return { + msg: "" + }; +} +export const GenericAuthorization = { + typeUrl: "/cosmos.authz.v1beta1.GenericAuthorization", + encode(message: GenericAuthorization, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.msg !== undefined) { + writer.uint32(10).string(message.msg); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GenericAuthorization { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGenericAuthorization(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.msg = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GenericAuthorization { + const obj = createBaseGenericAuthorization(); + if (isSet(object.msg)) obj.msg = String(object.msg); + return obj; + }, + toJSON(message: GenericAuthorization): JsonSafe { + const obj: any = {}; + message.msg !== undefined && (obj.msg = message.msg); + return obj; + }, + fromPartial(object: DeepPartial): GenericAuthorization { + const message = createBaseGenericAuthorization(); + message.msg = object.msg ?? ""; + return message; + }, + fromSDK(object: GenericAuthorizationSDKType): GenericAuthorization { + return { + msg: object?.msg + }; + }, + fromSDKJSON(object: any): GenericAuthorizationSDKType { + return { + msg: isSet(object.msg) ? String(object.msg) : "" + }; + }, + toSDK(message: GenericAuthorization): GenericAuthorizationSDKType { + const obj: any = {}; + obj.msg = message.msg; + return obj; + }, + fromAmino(object: GenericAuthorizationAmino): GenericAuthorization { + const message = createBaseGenericAuthorization(); + if (object.msg !== undefined && object.msg !== null) { + message.msg = object.msg; + } + return message; + }, + toAmino(message: GenericAuthorization): GenericAuthorizationAmino { + const obj: any = {}; + obj.msg = message.msg === "" ? undefined : message.msg; + return obj; + }, + fromAminoMsg(object: GenericAuthorizationAminoMsg): GenericAuthorization { + return GenericAuthorization.fromAmino(object.value); + }, + toAminoMsg(message: GenericAuthorization): GenericAuthorizationAminoMsg { + return { + type: "cosmos-sdk/GenericAuthorization", + value: GenericAuthorization.toAmino(message) + }; + }, + fromProtoMsg(message: GenericAuthorizationProtoMsg): GenericAuthorization { + return GenericAuthorization.decode(message.value); + }, + toProto(message: GenericAuthorization): Uint8Array { + return GenericAuthorization.encode(message).finish(); + }, + toProtoMsg(message: GenericAuthorization): GenericAuthorizationProtoMsg { + return { + typeUrl: "/cosmos.authz.v1beta1.GenericAuthorization", + value: GenericAuthorization.encode(message).finish() + }; + } +}; +function createBaseGrant(): Grant { + return { + authorization: undefined, + expiration: undefined + }; +} +export const Grant = { + typeUrl: "/cosmos.authz.v1beta1.Grant", + encode(message: Grant, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.authorization !== undefined) { + Any.encode(message.authorization, writer.uint32(10).fork()).ldelim(); + } + if (message.expiration !== undefined) { + Timestamp.encode(toTimestamp(message.expiration), writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Grant { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGrant(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.authorization = Any.decode(reader, reader.uint32()); + break; + case 2: + message.expiration = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Grant { + const obj = createBaseGrant(); + if (isSet(object.authorization)) obj.authorization = Any.fromJSON(object.authorization); + if (isSet(object.expiration)) obj.expiration = new Date(object.expiration); + return obj; + }, + toJSON(message: Grant): JsonSafe { + const obj: any = {}; + message.authorization !== undefined && (obj.authorization = message.authorization ? Any.toJSON(message.authorization) : undefined); + message.expiration !== undefined && (obj.expiration = message.expiration.toISOString()); + return obj; + }, + fromPartial(object: DeepPartial): Grant { + const message = createBaseGrant(); + if (object.authorization !== undefined && object.authorization !== null) { + message.authorization = Any.fromPartial(object.authorization); + } + message.expiration = object.expiration ?? undefined; + return message; + }, + fromSDK(object: GrantSDKType): Grant { + return { + authorization: object.authorization ? Any.fromSDK(object.authorization) : undefined, + expiration: object.expiration ?? undefined + }; + }, + fromSDKJSON(object: any): GrantSDKType { + return { + authorization: isSet(object.authorization) ? Any.fromSDKJSON(object.authorization) : undefined, + expiration: isSet(object.expiration) ? new Date(object.expiration) : undefined + }; + }, + toSDK(message: Grant): GrantSDKType { + const obj: any = {}; + message.authorization !== undefined && (obj.authorization = message.authorization ? Any.toSDK(message.authorization) : undefined); + message.expiration !== undefined && (obj.expiration = message.expiration ?? undefined); + return obj; + }, + fromAmino(object: GrantAmino): Grant { + const message = createBaseGrant(); + if (object.authorization !== undefined && object.authorization !== null) { + message.authorization = Any.fromAmino(object.authorization); + } + if (object.expiration !== undefined && object.expiration !== null) { + message.expiration = fromTimestamp(Timestamp.fromAmino(object.expiration)); + } + return message; + }, + toAmino(message: Grant): GrantAmino { + const obj: any = {}; + obj.authorization = message.authorization ? Any.toAmino(message.authorization) : undefined; + obj.expiration = message.expiration ? Timestamp.toAmino(toTimestamp(message.expiration)) : undefined; + return obj; + }, + fromAminoMsg(object: GrantAminoMsg): Grant { + return Grant.fromAmino(object.value); + }, + toAminoMsg(message: Grant): GrantAminoMsg { + return { + type: "cosmos-sdk/Grant", + value: Grant.toAmino(message) + }; + }, + fromProtoMsg(message: GrantProtoMsg): Grant { + return Grant.decode(message.value); + }, + toProto(message: Grant): Uint8Array { + return Grant.encode(message).finish(); + }, + toProtoMsg(message: Grant): GrantProtoMsg { + return { + typeUrl: "/cosmos.authz.v1beta1.Grant", + value: Grant.encode(message).finish() + }; + } +}; +function createBaseGrantAuthorization(): GrantAuthorization { + return { + granter: "", + grantee: "", + authorization: undefined, + expiration: undefined + }; +} +export const GrantAuthorization = { + typeUrl: "/cosmos.authz.v1beta1.GrantAuthorization", + encode(message: GrantAuthorization, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.granter !== undefined) { + writer.uint32(10).string(message.granter); + } + if (message.grantee !== undefined) { + writer.uint32(18).string(message.grantee); + } + if (message.authorization !== undefined) { + Any.encode(message.authorization, writer.uint32(26).fork()).ldelim(); + } + if (message.expiration !== undefined) { + Timestamp.encode(toTimestamp(message.expiration), writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GrantAuthorization { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGrantAuthorization(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.granter = reader.string(); + break; + case 2: + message.grantee = reader.string(); + break; + case 3: + message.authorization = Any.decode(reader, reader.uint32()); + break; + case 4: + message.expiration = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GrantAuthorization { + const obj = createBaseGrantAuthorization(); + if (isSet(object.granter)) obj.granter = String(object.granter); + if (isSet(object.grantee)) obj.grantee = String(object.grantee); + if (isSet(object.authorization)) obj.authorization = Any.fromJSON(object.authorization); + if (isSet(object.expiration)) obj.expiration = new Date(object.expiration); + return obj; + }, + toJSON(message: GrantAuthorization): JsonSafe { + const obj: any = {}; + message.granter !== undefined && (obj.granter = message.granter); + message.grantee !== undefined && (obj.grantee = message.grantee); + message.authorization !== undefined && (obj.authorization = message.authorization ? Any.toJSON(message.authorization) : undefined); + message.expiration !== undefined && (obj.expiration = message.expiration.toISOString()); + return obj; + }, + fromPartial(object: DeepPartial): GrantAuthorization { + const message = createBaseGrantAuthorization(); + message.granter = object.granter ?? ""; + message.grantee = object.grantee ?? ""; + if (object.authorization !== undefined && object.authorization !== null) { + message.authorization = Any.fromPartial(object.authorization); + } + message.expiration = object.expiration ?? undefined; + return message; + }, + fromSDK(object: GrantAuthorizationSDKType): GrantAuthorization { + return { + granter: object?.granter, + grantee: object?.grantee, + authorization: object.authorization ? Any.fromSDK(object.authorization) : undefined, + expiration: object.expiration ?? undefined + }; + }, + fromSDKJSON(object: any): GrantAuthorizationSDKType { + return { + granter: isSet(object.granter) ? String(object.granter) : "", + grantee: isSet(object.grantee) ? String(object.grantee) : "", + authorization: isSet(object.authorization) ? Any.fromSDKJSON(object.authorization) : undefined, + expiration: isSet(object.expiration) ? new Date(object.expiration) : undefined + }; + }, + toSDK(message: GrantAuthorization): GrantAuthorizationSDKType { + const obj: any = {}; + obj.granter = message.granter; + obj.grantee = message.grantee; + message.authorization !== undefined && (obj.authorization = message.authorization ? Any.toSDK(message.authorization) : undefined); + message.expiration !== undefined && (obj.expiration = message.expiration ?? undefined); + return obj; + }, + fromAmino(object: GrantAuthorizationAmino): GrantAuthorization { + const message = createBaseGrantAuthorization(); + if (object.granter !== undefined && object.granter !== null) { + message.granter = object.granter; + } + if (object.grantee !== undefined && object.grantee !== null) { + message.grantee = object.grantee; + } + if (object.authorization !== undefined && object.authorization !== null) { + message.authorization = Any.fromAmino(object.authorization); + } + if (object.expiration !== undefined && object.expiration !== null) { + message.expiration = fromTimestamp(Timestamp.fromAmino(object.expiration)); + } + return message; + }, + toAmino(message: GrantAuthorization): GrantAuthorizationAmino { + const obj: any = {}; + obj.granter = message.granter === "" ? undefined : message.granter; + obj.grantee = message.grantee === "" ? undefined : message.grantee; + obj.authorization = message.authorization ? Any.toAmino(message.authorization) : undefined; + obj.expiration = message.expiration ? Timestamp.toAmino(toTimestamp(message.expiration)) : undefined; + return obj; + }, + fromAminoMsg(object: GrantAuthorizationAminoMsg): GrantAuthorization { + return GrantAuthorization.fromAmino(object.value); + }, + toAminoMsg(message: GrantAuthorization): GrantAuthorizationAminoMsg { + return { + type: "cosmos-sdk/GrantAuthorization", + value: GrantAuthorization.toAmino(message) + }; + }, + fromProtoMsg(message: GrantAuthorizationProtoMsg): GrantAuthorization { + return GrantAuthorization.decode(message.value); + }, + toProto(message: GrantAuthorization): Uint8Array { + return GrantAuthorization.encode(message).finish(); + }, + toProtoMsg(message: GrantAuthorization): GrantAuthorizationProtoMsg { + return { + typeUrl: "/cosmos.authz.v1beta1.GrantAuthorization", + value: GrantAuthorization.encode(message).finish() + }; + } +}; +function createBaseGrantQueueItem(): GrantQueueItem { + return { + msgTypeUrls: [] + }; +} +export const GrantQueueItem = { + typeUrl: "/cosmos.authz.v1beta1.GrantQueueItem", + encode(message: GrantQueueItem, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.msgTypeUrls) { + writer.uint32(10).string(v!); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GrantQueueItem { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGrantQueueItem(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.msgTypeUrls.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GrantQueueItem { + const obj = createBaseGrantQueueItem(); + if (Array.isArray(object?.msgTypeUrls)) obj.msgTypeUrls = object.msgTypeUrls.map((e: any) => String(e)); + return obj; + }, + toJSON(message: GrantQueueItem): JsonSafe { + const obj: any = {}; + if (message.msgTypeUrls) { + obj.msgTypeUrls = message.msgTypeUrls.map(e => e); + } else { + obj.msgTypeUrls = []; + } + return obj; + }, + fromPartial(object: DeepPartial): GrantQueueItem { + const message = createBaseGrantQueueItem(); + message.msgTypeUrls = object.msgTypeUrls?.map(e => e) || []; + return message; + }, + fromSDK(object: GrantQueueItemSDKType): GrantQueueItem { + return { + msgTypeUrls: Array.isArray(object?.msg_type_urls) ? object.msg_type_urls.map((e: any) => e) : [] + }; + }, + fromSDKJSON(object: any): GrantQueueItemSDKType { + return { + msg_type_urls: Array.isArray(object?.msg_type_urls) ? object.msg_type_urls.map((e: any) => String(e)) : [] + }; + }, + toSDK(message: GrantQueueItem): GrantQueueItemSDKType { + const obj: any = {}; + if (message.msgTypeUrls) { + obj.msg_type_urls = message.msgTypeUrls.map(e => e); + } else { + obj.msg_type_urls = []; + } + return obj; + }, + fromAmino(object: GrantQueueItemAmino): GrantQueueItem { + const message = createBaseGrantQueueItem(); + message.msgTypeUrls = object.msg_type_urls?.map(e => e) || []; + return message; + }, + toAmino(message: GrantQueueItem): GrantQueueItemAmino { + const obj: any = {}; + if (message.msgTypeUrls) { + obj.msg_type_urls = message.msgTypeUrls.map(e => e); + } else { + obj.msg_type_urls = message.msgTypeUrls; + } + return obj; + }, + fromAminoMsg(object: GrantQueueItemAminoMsg): GrantQueueItem { + return GrantQueueItem.fromAmino(object.value); + }, + toAminoMsg(message: GrantQueueItem): GrantQueueItemAminoMsg { + return { + type: "cosmos-sdk/GrantQueueItem", + value: GrantQueueItem.toAmino(message) + }; + }, + fromProtoMsg(message: GrantQueueItemProtoMsg): GrantQueueItem { + return GrantQueueItem.decode(message.value); + }, + toProto(message: GrantQueueItem): Uint8Array { + return GrantQueueItem.encode(message).finish(); + }, + toProtoMsg(message: GrantQueueItem): GrantQueueItemProtoMsg { + return { + typeUrl: "/cosmos.authz.v1beta1.GrantQueueItem", + value: GrantQueueItem.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/authz/v1beta1/event.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/authz/v1beta1/event.ts new file mode 100644 index 0000000000..2c69e9c51d --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/authz/v1beta1/event.ts @@ -0,0 +1,126 @@ +import { BinaryReader, BinaryWriter } from "../../../binary"; +import { DeepPartial } from "../../../helpers"; +/** EventGrant is emitted on Msg/Grant */ +export interface EventGrant { + /** Msg type URL for which an autorization is granted */ + msgTypeUrl: string; + /** Granter account address */ + granter: string; + /** Grantee account address */ + grantee: string; +} +/** EventRevoke is emitted on Msg/Revoke */ +export interface EventRevoke { + /** Msg type URL for which an autorization is revoked */ + msgTypeUrl: string; + /** Granter account address */ + granter: string; + /** Grantee account address */ + grantee: string; +} +function createBaseEventGrant(): EventGrant { + return { + msgTypeUrl: "", + granter: "", + grantee: "" + }; +} +export const EventGrant = { + typeUrl: "/cosmos.authz.v1beta1.EventGrant", + aminoType: "cosmos-sdk/EventGrant", + encode(message: EventGrant, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.msgTypeUrl !== "") { + writer.uint32(18).string(message.msgTypeUrl); + } + if (message.granter !== "") { + writer.uint32(26).string(message.granter); + } + if (message.grantee !== "") { + writer.uint32(34).string(message.grantee); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): EventGrant { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseEventGrant(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.msgTypeUrl = reader.string(); + break; + case 3: + message.granter = reader.string(); + break; + case 4: + message.grantee = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromPartial(object: DeepPartial): EventGrant { + const message = createBaseEventGrant(); + message.msgTypeUrl = object.msgTypeUrl ?? ""; + message.granter = object.granter ?? ""; + message.grantee = object.grantee ?? ""; + return message; + } +}; +function createBaseEventRevoke(): EventRevoke { + return { + msgTypeUrl: "", + granter: "", + grantee: "" + }; +} +export const EventRevoke = { + typeUrl: "/cosmos.authz.v1beta1.EventRevoke", + aminoType: "cosmos-sdk/EventRevoke", + encode(message: EventRevoke, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.msgTypeUrl !== "") { + writer.uint32(18).string(message.msgTypeUrl); + } + if (message.granter !== "") { + writer.uint32(26).string(message.granter); + } + if (message.grantee !== "") { + writer.uint32(34).string(message.grantee); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): EventRevoke { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseEventRevoke(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.msgTypeUrl = reader.string(); + break; + case 3: + message.granter = reader.string(); + break; + case 4: + message.grantee = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromPartial(object: DeepPartial): EventRevoke { + const message = createBaseEventRevoke(); + message.msgTypeUrl = object.msgTypeUrl ?? ""; + message.granter = object.granter ?? ""; + message.grantee = object.grantee ?? ""; + return message; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/authz/v1beta1/genesis.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/authz/v1beta1/genesis.ts new file mode 100644 index 0000000000..7ca6262d39 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/authz/v1beta1/genesis.ts @@ -0,0 +1,121 @@ +import { GrantAuthorization, GrantAuthorizationSDKType } from "./authz.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { JsonSafe } from "../../../json-safe.js"; +import { DeepPartial } from "../../../helpers.js"; +export const protobufPackage = "cosmos.authz.v1beta1"; +/** GenesisState defines the authz module's genesis state. */ +export interface GenesisState { + authorization: GrantAuthorization[]; +} +export interface GenesisStateProtoMsg { + typeUrl: "/cosmos.authz.v1beta1.GenesisState"; + value: Uint8Array; +} +/** GenesisState defines the authz module's genesis state. */ +export interface GenesisStateSDKType { + authorization: GrantAuthorizationSDKType[]; +} +function createBaseGenesisState(): GenesisState { + return { + authorization: [] + }; +} +export const GenesisState = { + typeUrl: "/cosmos.authz.v1beta1.GenesisState", + encode(message: GenesisState, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.authorization) { + GrantAuthorization.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GenesisState { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGenesisState(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.authorization.push(GrantAuthorization.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GenesisState { + const obj = createBaseGenesisState(); + if (Array.isArray(object?.authorization)) obj.authorization = object.authorization.map((e: any) => GrantAuthorization.fromJSON(e)); + return obj; + }, + toJSON(message: GenesisState): JsonSafe { + const obj: any = {}; + if (message.authorization) { + obj.authorization = message.authorization.map(e => e ? GrantAuthorization.toJSON(e) : undefined); + } else { + obj.authorization = []; + } + return obj; + }, + fromPartial(object: DeepPartial): GenesisState { + const message = createBaseGenesisState(); + message.authorization = object.authorization?.map(e => GrantAuthorization.fromPartial(e)) || []; + return message; + }, + fromSDK(object: GenesisStateSDKType): GenesisState { + return { + authorization: Array.isArray(object?.authorization) ? object.authorization.map((e: any) => GrantAuthorization.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): GenesisStateSDKType { + return { + authorization: Array.isArray(object?.authorization) ? object.authorization.map((e: any) => GrantAuthorization.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: GenesisState): GenesisStateSDKType { + const obj: any = {}; + if (message.authorization) { + obj.authorization = message.authorization.map(e => e ? GrantAuthorization.toSDK(e) : undefined); + } else { + obj.authorization = []; + } + return obj; + }, + fromAmino(object: GenesisStateAmino): GenesisState { + const message = createBaseGenesisState(); + message.authorization = object.authorization?.map(e => GrantAuthorization.fromAmino(e)) || []; + return message; + }, + toAmino(message: GenesisState): GenesisStateAmino { + const obj: any = {}; + if (message.authorization) { + obj.authorization = message.authorization.map(e => e ? GrantAuthorization.toAmino(e) : undefined); + } else { + obj.authorization = message.authorization; + } + return obj; + }, + fromAminoMsg(object: GenesisStateAminoMsg): GenesisState { + return GenesisState.fromAmino(object.value); + }, + toAminoMsg(message: GenesisState): GenesisStateAminoMsg { + return { + type: "cosmos-sdk/GenesisState", + value: GenesisState.toAmino(message) + }; + }, + fromProtoMsg(message: GenesisStateProtoMsg): GenesisState { + return GenesisState.decode(message.value); + }, + toProto(message: GenesisState): Uint8Array { + return GenesisState.encode(message).finish(); + }, + toProtoMsg(message: GenesisState): GenesisStateProtoMsg { + return { + typeUrl: "/cosmos.authz.v1beta1.GenesisState", + value: GenesisState.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/authz/v1beta1/query.lcd.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/authz/v1beta1/query.lcd.ts new file mode 100644 index 0000000000..97f6258383 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/authz/v1beta1/query.lcd.ts @@ -0,0 +1,64 @@ +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../base/query/v1beta1/pagination.js"; +import { Grant, GrantSDKType, GrantAuthorization, GrantAuthorizationSDKType } from "./authz.js"; +import { setPaginationParams } from "../../../helpers.js"; +import { LCDClient } from "@cosmology/lcd"; +import { QueryGrantsRequest, QueryGrantsRequestSDKType, QueryGrantsResponse, QueryGrantsResponseSDKType, QueryGranterGrantsRequest, QueryGranterGrantsRequestSDKType, QueryGranterGrantsResponse, QueryGranterGrantsResponseSDKType, QueryGranteeGrantsRequest, QueryGranteeGrantsRequestSDKType, QueryGranteeGrantsResponse, QueryGranteeGrantsResponseSDKType } from "./query.js"; +export class LCDQueryClient { + req: LCDClient; + constructor({ + requestClient + }: { + requestClient: LCDClient; + }) { + this.req = requestClient; + this.grants = this.grants.bind(this); + this.granterGrants = this.granterGrants.bind(this); + this.granteeGrants = this.granteeGrants.bind(this); + } + /* Returns list of `Authorization`, granted to the grantee by the granter. */ + async grants(params: QueryGrantsRequest): Promise { + const options: any = { + params: {} + }; + if (typeof params?.granter !== "undefined") { + options.params.granter = params.granter; + } + if (typeof params?.grantee !== "undefined") { + options.params.grantee = params.grantee; + } + if (typeof params?.msgTypeUrl !== "undefined") { + options.params.msg_type_url = params.msgTypeUrl; + } + if (typeof params?.pagination !== "undefined") { + setPaginationParams(options, params.pagination); + } + const endpoint = `cosmos/authz/v1beta1/grants`; + return QueryGrantsResponse.fromSDKJSON(await this.req.get(endpoint, options)); + } + /* GranterGrants returns list of `GrantAuthorization`, granted by granter. + + Since: cosmos-sdk 0.46 */ + async granterGrants(params: QueryGranterGrantsRequest): Promise { + const options: any = { + params: {} + }; + if (typeof params?.pagination !== "undefined") { + setPaginationParams(options, params.pagination); + } + const endpoint = `cosmos/authz/v1beta1/grants/granter/${params.granter}`; + return QueryGranterGrantsResponse.fromSDKJSON(await this.req.get(endpoint, options)); + } + /* GranteeGrants returns a list of `GrantAuthorization` by grantee. + + Since: cosmos-sdk 0.46 */ + async granteeGrants(params: QueryGranteeGrantsRequest): Promise { + const options: any = { + params: {} + }; + if (typeof params?.pagination !== "undefined") { + setPaginationParams(options, params.pagination); + } + const endpoint = `cosmos/authz/v1beta1/grants/grantee/${params.grantee}`; + return QueryGranteeGrantsResponse.fromSDKJSON(await this.req.get(endpoint, options)); + } +} \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/authz/v1beta1/query.rpc.Query.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/authz/v1beta1/query.rpc.Query.ts new file mode 100644 index 0000000000..e22e435eb1 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/authz/v1beta1/query.rpc.Query.ts @@ -0,0 +1,62 @@ +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../base/query/v1beta1/pagination.js"; +import { Grant, GrantSDKType, GrantAuthorization, GrantAuthorizationSDKType } from "./authz.js"; +import { Rpc } from "../../../helpers.js"; +import { BinaryReader } from "../../../binary.js"; +import { QueryClient, createProtobufRpcClient } from "@cosmjs/stargate"; +import { QueryGrantsRequest, QueryGrantsRequestSDKType, QueryGrantsResponse, QueryGrantsResponseSDKType, QueryGranterGrantsRequest, QueryGranterGrantsRequestSDKType, QueryGranterGrantsResponse, QueryGranterGrantsResponseSDKType, QueryGranteeGrantsRequest, QueryGranteeGrantsRequestSDKType, QueryGranteeGrantsResponse, QueryGranteeGrantsResponseSDKType } from "./query.js"; +/** Query defines the gRPC querier service. */ +export interface Query { + /** Returns list of `Authorization`, granted to the grantee by the granter. */ + grants(request: QueryGrantsRequest): Promise; + /** + * GranterGrants returns list of `GrantAuthorization`, granted by granter. + * + * Since: cosmos-sdk 0.46 + */ + granterGrants(request: QueryGranterGrantsRequest): Promise; + /** + * GranteeGrants returns a list of `GrantAuthorization` by grantee. + * + * Since: cosmos-sdk 0.46 + */ + granteeGrants(request: QueryGranteeGrantsRequest): Promise; +} +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + this.grants = this.grants.bind(this); + this.granterGrants = this.granterGrants.bind(this); + this.granteeGrants = this.granteeGrants.bind(this); + } + grants(request: QueryGrantsRequest): Promise { + const data = QueryGrantsRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.authz.v1beta1.Query", "Grants", data); + return promise.then(data => QueryGrantsResponse.decode(new BinaryReader(data))); + } + granterGrants(request: QueryGranterGrantsRequest): Promise { + const data = QueryGranterGrantsRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.authz.v1beta1.Query", "GranterGrants", data); + return promise.then(data => QueryGranterGrantsResponse.decode(new BinaryReader(data))); + } + granteeGrants(request: QueryGranteeGrantsRequest): Promise { + const data = QueryGranteeGrantsRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.authz.v1beta1.Query", "GranteeGrants", data); + return promise.then(data => QueryGranteeGrantsResponse.decode(new BinaryReader(data))); + } +} +export const createRpcQueryExtension = (base: QueryClient) => { + const rpc = createProtobufRpcClient(base); + const queryService = new QueryClientImpl(rpc); + return { + grants(request: QueryGrantsRequest): Promise { + return queryService.grants(request); + }, + granterGrants(request: QueryGranterGrantsRequest): Promise { + return queryService.granterGrants(request); + }, + granteeGrants(request: QueryGranteeGrantsRequest): Promise { + return queryService.granteeGrants(request); + } + }; +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/authz/v1beta1/query.rpc.func.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/authz/v1beta1/query.rpc.func.ts new file mode 100644 index 0000000000..5f40c3d6bb --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/authz/v1beta1/query.rpc.func.ts @@ -0,0 +1,36 @@ +import { RpcResolver, buildQuery } from "../../../helper-func-types"; +import { buildUseQuery } from "../../../react-query"; +import { QueryGrantsRequest, QueryGrantsResponse, QueryGranterGrantsRequest, QueryGranterGrantsResponse, QueryGranteeGrantsRequest, QueryGranteeGrantsResponse } from "./query"; +export const createGetGrants = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryGrantsRequest.encode, + decode: QueryGrantsResponse.decode, + service: "cosmos.authz.v1beta1.Query", + method: "Grants", + getRpcInstance: getRpcInstance +}); +export const useGetGrants = buildUseQuery({ + builderQueryFn: createGetGrants, + queryKeyPrefix: "GrantsQuery" +}); +export const createGetGranterGrants = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryGranterGrantsRequest.encode, + decode: QueryGranterGrantsResponse.decode, + service: "cosmos.authz.v1beta1.Query", + method: "GranterGrants", + getRpcInstance: getRpcInstance +}); +export const useGetGranterGrants = buildUseQuery({ + builderQueryFn: createGetGranterGrants, + queryKeyPrefix: "GranterGrantsQuery" +}); +export const createGetGranteeGrants = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryGranteeGrantsRequest.encode, + decode: QueryGranteeGrantsResponse.decode, + service: "cosmos.authz.v1beta1.Query", + method: "GranteeGrants", + getRpcInstance: getRpcInstance +}); +export const useGetGranteeGrants = buildUseQuery({ + builderQueryFn: createGetGranteeGrants, + queryKeyPrefix: "GranteeGrantsQuery" +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/authz/v1beta1/query.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/authz/v1beta1/query.ts new file mode 100644 index 0000000000..7cdddb1aa4 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/authz/v1beta1/query.ts @@ -0,0 +1,846 @@ +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../base/query/v1beta1/pagination.js"; +import { Grant, GrantSDKType, GrantAuthorization, GrantAuthorizationSDKType } from "./authz.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "cosmos.authz.v1beta1"; +/** QueryGrantsRequest is the request type for the Query/Grants RPC method. */ +export interface QueryGrantsRequest { + granter: string; + grantee: string; + /** Optional, msg_type_url, when set, will query only grants matching given msg type. */ + msgTypeUrl: string; + /** pagination defines an pagination for the request. */ + pagination?: PageRequest; +} +export interface QueryGrantsRequestProtoMsg { + typeUrl: "/cosmos.authz.v1beta1.QueryGrantsRequest"; + value: Uint8Array; +} +/** QueryGrantsRequest is the request type for the Query/Grants RPC method. */ +export interface QueryGrantsRequestSDKType { + granter: string; + grantee: string; + msg_type_url: string; + pagination?: PageRequestSDKType; +} +/** QueryGrantsResponse is the response type for the Query/Authorizations RPC method. */ +export interface QueryGrantsResponse { + /** authorizations is a list of grants granted for grantee by granter. */ + grants: Grant[]; + /** pagination defines an pagination for the response. */ + pagination?: PageResponse; +} +export interface QueryGrantsResponseProtoMsg { + typeUrl: "/cosmos.authz.v1beta1.QueryGrantsResponse"; + value: Uint8Array; +} +/** QueryGrantsResponse is the response type for the Query/Authorizations RPC method. */ +export interface QueryGrantsResponseSDKType { + grants: GrantSDKType[]; + pagination?: PageResponseSDKType; +} +/** QueryGranterGrantsRequest is the request type for the Query/GranterGrants RPC method. */ +export interface QueryGranterGrantsRequest { + granter: string; + /** pagination defines an pagination for the request. */ + pagination?: PageRequest; +} +export interface QueryGranterGrantsRequestProtoMsg { + typeUrl: "/cosmos.authz.v1beta1.QueryGranterGrantsRequest"; + value: Uint8Array; +} +/** QueryGranterGrantsRequest is the request type for the Query/GranterGrants RPC method. */ +export interface QueryGranterGrantsRequestSDKType { + granter: string; + pagination?: PageRequestSDKType; +} +/** QueryGranterGrantsResponse is the response type for the Query/GranterGrants RPC method. */ +export interface QueryGranterGrantsResponse { + /** grants is a list of grants granted by the granter. */ + grants: GrantAuthorization[]; + /** pagination defines an pagination for the response. */ + pagination?: PageResponse; +} +export interface QueryGranterGrantsResponseProtoMsg { + typeUrl: "/cosmos.authz.v1beta1.QueryGranterGrantsResponse"; + value: Uint8Array; +} +/** QueryGranterGrantsResponse is the response type for the Query/GranterGrants RPC method. */ +export interface QueryGranterGrantsResponseSDKType { + grants: GrantAuthorizationSDKType[]; + pagination?: PageResponseSDKType; +} +/** QueryGranteeGrantsRequest is the request type for the Query/IssuedGrants RPC method. */ +export interface QueryGranteeGrantsRequest { + grantee: string; + /** pagination defines an pagination for the request. */ + pagination?: PageRequest; +} +export interface QueryGranteeGrantsRequestProtoMsg { + typeUrl: "/cosmos.authz.v1beta1.QueryGranteeGrantsRequest"; + value: Uint8Array; +} +/** QueryGranteeGrantsRequest is the request type for the Query/IssuedGrants RPC method. */ +export interface QueryGranteeGrantsRequestSDKType { + grantee: string; + pagination?: PageRequestSDKType; +} +/** QueryGranteeGrantsResponse is the response type for the Query/GranteeGrants RPC method. */ +export interface QueryGranteeGrantsResponse { + /** grants is a list of grants granted to the grantee. */ + grants: GrantAuthorization[]; + /** pagination defines an pagination for the response. */ + pagination?: PageResponse; +} +export interface QueryGranteeGrantsResponseProtoMsg { + typeUrl: "/cosmos.authz.v1beta1.QueryGranteeGrantsResponse"; + value: Uint8Array; +} +/** QueryGranteeGrantsResponse is the response type for the Query/GranteeGrants RPC method. */ +export interface QueryGranteeGrantsResponseSDKType { + grants: GrantAuthorizationSDKType[]; + pagination?: PageResponseSDKType; +} +function createBaseQueryGrantsRequest(): QueryGrantsRequest { + return { + granter: "", + grantee: "", + msgTypeUrl: "", + pagination: undefined + }; +} +export const QueryGrantsRequest = { + typeUrl: "/cosmos.authz.v1beta1.QueryGrantsRequest", + encode(message: QueryGrantsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.granter !== undefined) { + writer.uint32(10).string(message.granter); + } + if (message.grantee !== undefined) { + writer.uint32(18).string(message.grantee); + } + if (message.msgTypeUrl !== undefined) { + writer.uint32(26).string(message.msgTypeUrl); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryGrantsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryGrantsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.granter = reader.string(); + break; + case 2: + message.grantee = reader.string(); + break; + case 3: + message.msgTypeUrl = reader.string(); + break; + case 4: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryGrantsRequest { + const obj = createBaseQueryGrantsRequest(); + if (isSet(object.granter)) obj.granter = String(object.granter); + if (isSet(object.grantee)) obj.grantee = String(object.grantee); + if (isSet(object.msgTypeUrl)) obj.msgTypeUrl = String(object.msgTypeUrl); + if (isSet(object.pagination)) obj.pagination = PageRequest.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryGrantsRequest): JsonSafe { + const obj: any = {}; + message.granter !== undefined && (obj.granter = message.granter); + message.grantee !== undefined && (obj.grantee = message.grantee); + message.msgTypeUrl !== undefined && (obj.msgTypeUrl = message.msgTypeUrl); + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryGrantsRequest { + const message = createBaseQueryGrantsRequest(); + message.granter = object.granter ?? ""; + message.grantee = object.grantee ?? ""; + message.msgTypeUrl = object.msgTypeUrl ?? ""; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryGrantsRequestSDKType): QueryGrantsRequest { + return { + granter: object?.granter, + grantee: object?.grantee, + msgTypeUrl: object?.msg_type_url, + pagination: object.pagination ? PageRequest.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryGrantsRequestSDKType { + return { + granter: isSet(object.granter) ? String(object.granter) : "", + grantee: isSet(object.grantee) ? String(object.grantee) : "", + msg_type_url: isSet(object.msg_type_url) ? String(object.msg_type_url) : "", + pagination: isSet(object.pagination) ? PageRequest.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryGrantsRequest): QueryGrantsRequestSDKType { + const obj: any = {}; + obj.granter = message.granter; + obj.grantee = message.grantee; + obj.msg_type_url = message.msgTypeUrl; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryGrantsRequestAmino): QueryGrantsRequest { + const message = createBaseQueryGrantsRequest(); + if (object.granter !== undefined && object.granter !== null) { + message.granter = object.granter; + } + if (object.grantee !== undefined && object.grantee !== null) { + message.grantee = object.grantee; + } + if (object.msg_type_url !== undefined && object.msg_type_url !== null) { + message.msgTypeUrl = object.msg_type_url; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryGrantsRequest): QueryGrantsRequestAmino { + const obj: any = {}; + obj.granter = message.granter === "" ? undefined : message.granter; + obj.grantee = message.grantee === "" ? undefined : message.grantee; + obj.msg_type_url = message.msgTypeUrl === "" ? undefined : message.msgTypeUrl; + obj.pagination = message.pagination ? PageRequest.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryGrantsRequestAminoMsg): QueryGrantsRequest { + return QueryGrantsRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryGrantsRequest): QueryGrantsRequestAminoMsg { + return { + type: "cosmos-sdk/QueryGrantsRequest", + value: QueryGrantsRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryGrantsRequestProtoMsg): QueryGrantsRequest { + return QueryGrantsRequest.decode(message.value); + }, + toProto(message: QueryGrantsRequest): Uint8Array { + return QueryGrantsRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryGrantsRequest): QueryGrantsRequestProtoMsg { + return { + typeUrl: "/cosmos.authz.v1beta1.QueryGrantsRequest", + value: QueryGrantsRequest.encode(message).finish() + }; + } +}; +function createBaseQueryGrantsResponse(): QueryGrantsResponse { + return { + grants: [], + pagination: undefined + }; +} +export const QueryGrantsResponse = { + typeUrl: "/cosmos.authz.v1beta1.QueryGrantsResponse", + encode(message: QueryGrantsResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.grants) { + Grant.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryGrantsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryGrantsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.grants.push(Grant.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryGrantsResponse { + const obj = createBaseQueryGrantsResponse(); + if (Array.isArray(object?.grants)) obj.grants = object.grants.map((e: any) => Grant.fromJSON(e)); + if (isSet(object.pagination)) obj.pagination = PageResponse.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryGrantsResponse): JsonSafe { + const obj: any = {}; + if (message.grants) { + obj.grants = message.grants.map(e => e ? Grant.toJSON(e) : undefined); + } else { + obj.grants = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryGrantsResponse { + const message = createBaseQueryGrantsResponse(); + message.grants = object.grants?.map(e => Grant.fromPartial(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryGrantsResponseSDKType): QueryGrantsResponse { + return { + grants: Array.isArray(object?.grants) ? object.grants.map((e: any) => Grant.fromSDK(e)) : [], + pagination: object.pagination ? PageResponse.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryGrantsResponseSDKType { + return { + grants: Array.isArray(object?.grants) ? object.grants.map((e: any) => Grant.fromSDKJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryGrantsResponse): QueryGrantsResponseSDKType { + const obj: any = {}; + if (message.grants) { + obj.grants = message.grants.map(e => e ? Grant.toSDK(e) : undefined); + } else { + obj.grants = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryGrantsResponseAmino): QueryGrantsResponse { + const message = createBaseQueryGrantsResponse(); + message.grants = object.grants?.map(e => Grant.fromAmino(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryGrantsResponse): QueryGrantsResponseAmino { + const obj: any = {}; + if (message.grants) { + obj.grants = message.grants.map(e => e ? Grant.toAmino(e) : undefined); + } else { + obj.grants = message.grants; + } + obj.pagination = message.pagination ? PageResponse.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryGrantsResponseAminoMsg): QueryGrantsResponse { + return QueryGrantsResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryGrantsResponse): QueryGrantsResponseAminoMsg { + return { + type: "cosmos-sdk/QueryGrantsResponse", + value: QueryGrantsResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryGrantsResponseProtoMsg): QueryGrantsResponse { + return QueryGrantsResponse.decode(message.value); + }, + toProto(message: QueryGrantsResponse): Uint8Array { + return QueryGrantsResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryGrantsResponse): QueryGrantsResponseProtoMsg { + return { + typeUrl: "/cosmos.authz.v1beta1.QueryGrantsResponse", + value: QueryGrantsResponse.encode(message).finish() + }; + } +}; +function createBaseQueryGranterGrantsRequest(): QueryGranterGrantsRequest { + return { + granter: "", + pagination: undefined + }; +} +export const QueryGranterGrantsRequest = { + typeUrl: "/cosmos.authz.v1beta1.QueryGranterGrantsRequest", + encode(message: QueryGranterGrantsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.granter !== undefined) { + writer.uint32(10).string(message.granter); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryGranterGrantsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryGranterGrantsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.granter = reader.string(); + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryGranterGrantsRequest { + const obj = createBaseQueryGranterGrantsRequest(); + if (isSet(object.granter)) obj.granter = String(object.granter); + if (isSet(object.pagination)) obj.pagination = PageRequest.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryGranterGrantsRequest): JsonSafe { + const obj: any = {}; + message.granter !== undefined && (obj.granter = message.granter); + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryGranterGrantsRequest { + const message = createBaseQueryGranterGrantsRequest(); + message.granter = object.granter ?? ""; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryGranterGrantsRequestSDKType): QueryGranterGrantsRequest { + return { + granter: object?.granter, + pagination: object.pagination ? PageRequest.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryGranterGrantsRequestSDKType { + return { + granter: isSet(object.granter) ? String(object.granter) : "", + pagination: isSet(object.pagination) ? PageRequest.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryGranterGrantsRequest): QueryGranterGrantsRequestSDKType { + const obj: any = {}; + obj.granter = message.granter; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryGranterGrantsRequestAmino): QueryGranterGrantsRequest { + const message = createBaseQueryGranterGrantsRequest(); + if (object.granter !== undefined && object.granter !== null) { + message.granter = object.granter; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryGranterGrantsRequest): QueryGranterGrantsRequestAmino { + const obj: any = {}; + obj.granter = message.granter === "" ? undefined : message.granter; + obj.pagination = message.pagination ? PageRequest.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryGranterGrantsRequestAminoMsg): QueryGranterGrantsRequest { + return QueryGranterGrantsRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryGranterGrantsRequest): QueryGranterGrantsRequestAminoMsg { + return { + type: "cosmos-sdk/QueryGranterGrantsRequest", + value: QueryGranterGrantsRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryGranterGrantsRequestProtoMsg): QueryGranterGrantsRequest { + return QueryGranterGrantsRequest.decode(message.value); + }, + toProto(message: QueryGranterGrantsRequest): Uint8Array { + return QueryGranterGrantsRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryGranterGrantsRequest): QueryGranterGrantsRequestProtoMsg { + return { + typeUrl: "/cosmos.authz.v1beta1.QueryGranterGrantsRequest", + value: QueryGranterGrantsRequest.encode(message).finish() + }; + } +}; +function createBaseQueryGranterGrantsResponse(): QueryGranterGrantsResponse { + return { + grants: [], + pagination: undefined + }; +} +export const QueryGranterGrantsResponse = { + typeUrl: "/cosmos.authz.v1beta1.QueryGranterGrantsResponse", + encode(message: QueryGranterGrantsResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.grants) { + GrantAuthorization.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryGranterGrantsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryGranterGrantsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.grants.push(GrantAuthorization.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryGranterGrantsResponse { + const obj = createBaseQueryGranterGrantsResponse(); + if (Array.isArray(object?.grants)) obj.grants = object.grants.map((e: any) => GrantAuthorization.fromJSON(e)); + if (isSet(object.pagination)) obj.pagination = PageResponse.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryGranterGrantsResponse): JsonSafe { + const obj: any = {}; + if (message.grants) { + obj.grants = message.grants.map(e => e ? GrantAuthorization.toJSON(e) : undefined); + } else { + obj.grants = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryGranterGrantsResponse { + const message = createBaseQueryGranterGrantsResponse(); + message.grants = object.grants?.map(e => GrantAuthorization.fromPartial(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryGranterGrantsResponseSDKType): QueryGranterGrantsResponse { + return { + grants: Array.isArray(object?.grants) ? object.grants.map((e: any) => GrantAuthorization.fromSDK(e)) : [], + pagination: object.pagination ? PageResponse.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryGranterGrantsResponseSDKType { + return { + grants: Array.isArray(object?.grants) ? object.grants.map((e: any) => GrantAuthorization.fromSDKJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryGranterGrantsResponse): QueryGranterGrantsResponseSDKType { + const obj: any = {}; + if (message.grants) { + obj.grants = message.grants.map(e => e ? GrantAuthorization.toSDK(e) : undefined); + } else { + obj.grants = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryGranterGrantsResponseAmino): QueryGranterGrantsResponse { + const message = createBaseQueryGranterGrantsResponse(); + message.grants = object.grants?.map(e => GrantAuthorization.fromAmino(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryGranterGrantsResponse): QueryGranterGrantsResponseAmino { + const obj: any = {}; + if (message.grants) { + obj.grants = message.grants.map(e => e ? GrantAuthorization.toAmino(e) : undefined); + } else { + obj.grants = message.grants; + } + obj.pagination = message.pagination ? PageResponse.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryGranterGrantsResponseAminoMsg): QueryGranterGrantsResponse { + return QueryGranterGrantsResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryGranterGrantsResponse): QueryGranterGrantsResponseAminoMsg { + return { + type: "cosmos-sdk/QueryGranterGrantsResponse", + value: QueryGranterGrantsResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryGranterGrantsResponseProtoMsg): QueryGranterGrantsResponse { + return QueryGranterGrantsResponse.decode(message.value); + }, + toProto(message: QueryGranterGrantsResponse): Uint8Array { + return QueryGranterGrantsResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryGranterGrantsResponse): QueryGranterGrantsResponseProtoMsg { + return { + typeUrl: "/cosmos.authz.v1beta1.QueryGranterGrantsResponse", + value: QueryGranterGrantsResponse.encode(message).finish() + }; + } +}; +function createBaseQueryGranteeGrantsRequest(): QueryGranteeGrantsRequest { + return { + grantee: "", + pagination: undefined + }; +} +export const QueryGranteeGrantsRequest = { + typeUrl: "/cosmos.authz.v1beta1.QueryGranteeGrantsRequest", + encode(message: QueryGranteeGrantsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.grantee !== undefined) { + writer.uint32(10).string(message.grantee); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryGranteeGrantsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryGranteeGrantsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.grantee = reader.string(); + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryGranteeGrantsRequest { + const obj = createBaseQueryGranteeGrantsRequest(); + if (isSet(object.grantee)) obj.grantee = String(object.grantee); + if (isSet(object.pagination)) obj.pagination = PageRequest.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryGranteeGrantsRequest): JsonSafe { + const obj: any = {}; + message.grantee !== undefined && (obj.grantee = message.grantee); + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryGranteeGrantsRequest { + const message = createBaseQueryGranteeGrantsRequest(); + message.grantee = object.grantee ?? ""; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryGranteeGrantsRequestSDKType): QueryGranteeGrantsRequest { + return { + grantee: object?.grantee, + pagination: object.pagination ? PageRequest.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryGranteeGrantsRequestSDKType { + return { + grantee: isSet(object.grantee) ? String(object.grantee) : "", + pagination: isSet(object.pagination) ? PageRequest.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryGranteeGrantsRequest): QueryGranteeGrantsRequestSDKType { + const obj: any = {}; + obj.grantee = message.grantee; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryGranteeGrantsRequestAmino): QueryGranteeGrantsRequest { + const message = createBaseQueryGranteeGrantsRequest(); + if (object.grantee !== undefined && object.grantee !== null) { + message.grantee = object.grantee; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryGranteeGrantsRequest): QueryGranteeGrantsRequestAmino { + const obj: any = {}; + obj.grantee = message.grantee === "" ? undefined : message.grantee; + obj.pagination = message.pagination ? PageRequest.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryGranteeGrantsRequestAminoMsg): QueryGranteeGrantsRequest { + return QueryGranteeGrantsRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryGranteeGrantsRequest): QueryGranteeGrantsRequestAminoMsg { + return { + type: "cosmos-sdk/QueryGranteeGrantsRequest", + value: QueryGranteeGrantsRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryGranteeGrantsRequestProtoMsg): QueryGranteeGrantsRequest { + return QueryGranteeGrantsRequest.decode(message.value); + }, + toProto(message: QueryGranteeGrantsRequest): Uint8Array { + return QueryGranteeGrantsRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryGranteeGrantsRequest): QueryGranteeGrantsRequestProtoMsg { + return { + typeUrl: "/cosmos.authz.v1beta1.QueryGranteeGrantsRequest", + value: QueryGranteeGrantsRequest.encode(message).finish() + }; + } +}; +function createBaseQueryGranteeGrantsResponse(): QueryGranteeGrantsResponse { + return { + grants: [], + pagination: undefined + }; +} +export const QueryGranteeGrantsResponse = { + typeUrl: "/cosmos.authz.v1beta1.QueryGranteeGrantsResponse", + encode(message: QueryGranteeGrantsResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.grants) { + GrantAuthorization.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryGranteeGrantsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryGranteeGrantsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.grants.push(GrantAuthorization.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryGranteeGrantsResponse { + const obj = createBaseQueryGranteeGrantsResponse(); + if (Array.isArray(object?.grants)) obj.grants = object.grants.map((e: any) => GrantAuthorization.fromJSON(e)); + if (isSet(object.pagination)) obj.pagination = PageResponse.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryGranteeGrantsResponse): JsonSafe { + const obj: any = {}; + if (message.grants) { + obj.grants = message.grants.map(e => e ? GrantAuthorization.toJSON(e) : undefined); + } else { + obj.grants = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryGranteeGrantsResponse { + const message = createBaseQueryGranteeGrantsResponse(); + message.grants = object.grants?.map(e => GrantAuthorization.fromPartial(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryGranteeGrantsResponseSDKType): QueryGranteeGrantsResponse { + return { + grants: Array.isArray(object?.grants) ? object.grants.map((e: any) => GrantAuthorization.fromSDK(e)) : [], + pagination: object.pagination ? PageResponse.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryGranteeGrantsResponseSDKType { + return { + grants: Array.isArray(object?.grants) ? object.grants.map((e: any) => GrantAuthorization.fromSDKJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryGranteeGrantsResponse): QueryGranteeGrantsResponseSDKType { + const obj: any = {}; + if (message.grants) { + obj.grants = message.grants.map(e => e ? GrantAuthorization.toSDK(e) : undefined); + } else { + obj.grants = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryGranteeGrantsResponseAmino): QueryGranteeGrantsResponse { + const message = createBaseQueryGranteeGrantsResponse(); + message.grants = object.grants?.map(e => GrantAuthorization.fromAmino(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryGranteeGrantsResponse): QueryGranteeGrantsResponseAmino { + const obj: any = {}; + if (message.grants) { + obj.grants = message.grants.map(e => e ? GrantAuthorization.toAmino(e) : undefined); + } else { + obj.grants = message.grants; + } + obj.pagination = message.pagination ? PageResponse.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryGranteeGrantsResponseAminoMsg): QueryGranteeGrantsResponse { + return QueryGranteeGrantsResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryGranteeGrantsResponse): QueryGranteeGrantsResponseAminoMsg { + return { + type: "cosmos-sdk/QueryGranteeGrantsResponse", + value: QueryGranteeGrantsResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryGranteeGrantsResponseProtoMsg): QueryGranteeGrantsResponse { + return QueryGranteeGrantsResponse.decode(message.value); + }, + toProto(message: QueryGranteeGrantsResponse): Uint8Array { + return QueryGranteeGrantsResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryGranteeGrantsResponse): QueryGranteeGrantsResponseProtoMsg { + return { + typeUrl: "/cosmos.authz.v1beta1.QueryGranteeGrantsResponse", + value: QueryGranteeGrantsResponse.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/authz/v1beta1/tx.amino.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/authz/v1beta1/tx.amino.ts new file mode 100644 index 0000000000..77bf642b30 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/authz/v1beta1/tx.amino.ts @@ -0,0 +1,127 @@ +import { Grant, GrantSDKType } from "./authz.js"; +import { Any, AnySDKType } from "../../../google/protobuf/any.js"; +import { ReadOnlyAminoMsg as AminoMsg } from "@interchainjs/ReadOnlyAminoMsg"; +import { MsgGrant, MsgGrantSDKType, MsgExec, MsgExecSDKType, MsgRevoke, MsgRevokeSDKType } from "./tx.js"; +export interface MsgGrantAminoType extends AminoMsg { + type: "cosmos-sdk/MsgGrant"; + value: { + granter: string; + grantee: string; + grant: { + authorization: { + type_url: string; + value: Uint8Array; + }; + expiration: string; + }; + }; +} +export interface MsgExecAminoType extends AminoMsg { + type: "cosmos-sdk/MsgExec"; + value: { + grantee: string; + msgs: { + type_url: string; + value: Uint8Array; + }[]; + }; +} +export interface MsgRevokeAminoType extends AminoMsg { + type: "cosmos-sdk/MsgRevoke"; + value: { + granter: string; + grantee: string; + msg_type_url: string; + }; +} +export const AminoConverter = { + "/cosmos.authz.v1beta1.MsgGrant": { + aminoType: "cosmos-sdk/MsgGrant", + toAmino: ({ + granter, + grantee, + grant + }: MsgGrant): MsgGrantAminoType["value"] => { + return { + granter, + grantee, + grant: { + authorization: { + type_url: grant.authorization.typeUrl, + value: grant.authorization.value + }, + expiration: grant.expiration + } + }; + }, + fromAmino: ({ + granter, + grantee, + grant + }: MsgGrantAminoType["value"]): MsgGrant => { + return { + granter, + grantee, + grant: { + authorization: { + typeUrl: grant.authorization.type_url, + value: grant.authorization.value + }, + expiration: grant.expiration + } + }; + } + }, + "/cosmos.authz.v1beta1.MsgExec": { + aminoType: "cosmos-sdk/MsgExec", + toAmino: ({ + grantee, + msgs + }: MsgExec): MsgExecAminoType["value"] => { + return { + grantee, + msgs: msgs.map(el0 => ({ + type_url: el0.typeUrl, + value: el0.value + })) + }; + }, + fromAmino: ({ + grantee, + msgs + }: MsgExecAminoType["value"]): MsgExec => { + return { + grantee, + msgs: msgs.map(el0 => ({ + typeUrl: el0.type_url, + value: el0.value + })) + }; + } + }, + "/cosmos.authz.v1beta1.MsgRevoke": { + aminoType: "cosmos-sdk/MsgRevoke", + toAmino: ({ + granter, + grantee, + msgTypeUrl + }: MsgRevoke): MsgRevokeAminoType["value"] => { + return { + granter, + grantee, + msg_type_url: msgTypeUrl + }; + }, + fromAmino: ({ + granter, + grantee, + msg_type_url + }: MsgRevokeAminoType["value"]): MsgRevoke => { + return { + granter, + grantee, + msgTypeUrl: msg_type_url + }; + } + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/authz/v1beta1/tx.registry.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/authz/v1beta1/tx.registry.ts new file mode 100644 index 0000000000..2aaa8a5465 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/authz/v1beta1/tx.registry.ts @@ -0,0 +1,112 @@ +import { Grant, GrantSDKType } from "./authz.js"; +import { Any, AnySDKType } from "../../../google/protobuf/any.js"; +import { GeneratedType, Registry } from "@cosmjs/proto-signing"; +import { MsgGrant, MsgGrantSDKType, MsgExec, MsgExecSDKType, MsgRevoke, MsgRevokeSDKType } from "./tx.js"; +export const registry: ReadonlyArray<[string, GeneratedType]> = [["/cosmos.authz.v1beta1.MsgGrant", MsgGrant], ["/cosmos.authz.v1beta1.MsgExec", MsgExec], ["/cosmos.authz.v1beta1.MsgRevoke", MsgRevoke]]; +export const load = (protoRegistry: Registry) => { + registry.forEach(([typeUrl, mod]) => { + protoRegistry.register(typeUrl, mod); + }); +}; +export const MessageComposer = { + encoded: { + grant(value: MsgGrant) { + return { + typeUrl: "/cosmos.authz.v1beta1.MsgGrant", + value: MsgGrant.encode(value).finish() + }; + }, + exec(value: MsgExec) { + return { + typeUrl: "/cosmos.authz.v1beta1.MsgExec", + value: MsgExec.encode(value).finish() + }; + }, + revoke(value: MsgRevoke) { + return { + typeUrl: "/cosmos.authz.v1beta1.MsgRevoke", + value: MsgRevoke.encode(value).finish() + }; + } + }, + withTypeUrl: { + grant(value: MsgGrant) { + return { + typeUrl: "/cosmos.authz.v1beta1.MsgGrant", + value + }; + }, + exec(value: MsgExec) { + return { + typeUrl: "/cosmos.authz.v1beta1.MsgExec", + value + }; + }, + revoke(value: MsgRevoke) { + return { + typeUrl: "/cosmos.authz.v1beta1.MsgRevoke", + value + }; + } + }, + toJSON: { + grant(value: MsgGrant) { + return { + typeUrl: "/cosmos.authz.v1beta1.MsgGrant", + value: MsgGrant.toJSON(value) + }; + }, + exec(value: MsgExec) { + return { + typeUrl: "/cosmos.authz.v1beta1.MsgExec", + value: MsgExec.toJSON(value) + }; + }, + revoke(value: MsgRevoke) { + return { + typeUrl: "/cosmos.authz.v1beta1.MsgRevoke", + value: MsgRevoke.toJSON(value) + }; + } + }, + fromJSON: { + grant(value: any) { + return { + typeUrl: "/cosmos.authz.v1beta1.MsgGrant", + value: MsgGrant.fromJSON(value) + }; + }, + exec(value: any) { + return { + typeUrl: "/cosmos.authz.v1beta1.MsgExec", + value: MsgExec.fromJSON(value) + }; + }, + revoke(value: any) { + return { + typeUrl: "/cosmos.authz.v1beta1.MsgRevoke", + value: MsgRevoke.fromJSON(value) + }; + } + }, + fromPartial: { + grant(value: MsgGrant) { + return { + typeUrl: "/cosmos.authz.v1beta1.MsgGrant", + value: MsgGrant.fromPartial(value) + }; + }, + exec(value: MsgExec) { + return { + typeUrl: "/cosmos.authz.v1beta1.MsgExec", + value: MsgExec.fromPartial(value) + }; + }, + revoke(value: MsgRevoke) { + return { + typeUrl: "/cosmos.authz.v1beta1.MsgRevoke", + value: MsgRevoke.fromPartial(value) + }; + } + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/authz/v1beta1/tx.rpc.func.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/authz/v1beta1/tx.rpc.func.ts new file mode 100644 index 0000000000..878d022622 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/authz/v1beta1/tx.rpc.func.ts @@ -0,0 +1,31 @@ +import { buildTx, SigningClientResolver } from "../../../helper-func-types"; +import { buildUseMutation } from "../../../react-query"; +import { toEncoders, toConverters } from "@interchainjs/cosmos/utils"; +import { MsgGrant, MsgExec, MsgRevoke } from "./tx"; +export const createGrant = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgGrant.typeUrl, + encoders: toEncoders(MsgGrant), + converters: toConverters(MsgGrant) +}); +export const useGrant = buildUseMutation({ + builderMutationFn: createGrant +}); +export const createExec = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgExec.typeUrl, + encoders: toEncoders(MsgExec), + converters: toConverters(MsgExec) +}); +export const useExec = buildUseMutation({ + builderMutationFn: createExec +}); +export const createRevoke = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgRevoke.typeUrl, + encoders: toEncoders(MsgRevoke), + converters: toConverters(MsgRevoke) +}); +export const useRevoke = buildUseMutation({ + builderMutationFn: createRevoke +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/authz/v1beta1/tx.rpc.msg.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/authz/v1beta1/tx.rpc.msg.ts new file mode 100644 index 0000000000..3dc11bc1c9 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/authz/v1beta1/tx.rpc.msg.ts @@ -0,0 +1,53 @@ +import { Grant, GrantSDKType } from "./authz.js"; +import { Any, AnySDKType } from "../../../google/protobuf/any.js"; +import { Rpc } from "../../../helpers.js"; +import { BinaryReader } from "../../../binary.js"; +import { MsgGrant, MsgGrantSDKType, MsgGrantResponse, MsgGrantResponseSDKType, MsgExec, MsgExecSDKType, MsgExecResponse, MsgExecResponseSDKType, MsgRevoke, MsgRevokeSDKType, MsgRevokeResponse, MsgRevokeResponseSDKType } from "./tx.js"; +/** Msg defines the authz Msg service. */ +export interface Msg { + /** + * Grant grants the provided authorization to the grantee on the granter's + * account with the provided expiration time. If there is already a grant + * for the given (granter, grantee, Authorization) triple, then the grant + * will be overwritten. + */ + grant(request: MsgGrant): Promise; + /** + * Exec attempts to execute the provided messages using + * authorizations granted to the grantee. Each message should have only + * one signer corresponding to the granter of the authorization. + */ + exec(request: MsgExec): Promise; + /** + * Revoke revokes any authorization corresponding to the provided method name on the + * granter's account that has been granted to the grantee. + */ + revoke(request: MsgRevoke): Promise; +} +export class MsgClientImpl implements Msg { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + this.grant = this.grant.bind(this); + this.exec = this.exec.bind(this); + this.revoke = this.revoke.bind(this); + } + grant(request: MsgGrant): Promise { + const data = MsgGrant.encode(request).finish(); + const promise = this.rpc.request("cosmos.authz.v1beta1.Msg", "Grant", data); + return promise.then(data => MsgGrantResponse.decode(new BinaryReader(data))); + } + exec(request: MsgExec): Promise { + const data = MsgExec.encode(request).finish(); + const promise = this.rpc.request("cosmos.authz.v1beta1.Msg", "Exec", data); + return promise.then(data => MsgExecResponse.decode(new BinaryReader(data))); + } + revoke(request: MsgRevoke): Promise { + const data = MsgRevoke.encode(request).finish(); + const promise = this.rpc.request("cosmos.authz.v1beta1.Msg", "Revoke", data); + return promise.then(data => MsgRevokeResponse.decode(new BinaryReader(data))); + } +} +export const createClientImpl = (rpc: Rpc) => { + return new MsgClientImpl(rpc); +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/authz/v1beta1/tx.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/authz/v1beta1/tx.ts new file mode 100644 index 0000000000..667deb9668 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/authz/v1beta1/tx.ts @@ -0,0 +1,736 @@ +import { Grant, GrantSDKType } from "./authz.js"; +import { Any, AnySDKType } from "../../../google/protobuf/any.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial, bytesFromBase64, base64FromBytes } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "cosmos.authz.v1beta1"; +/** + * MsgGrant is a request type for Grant method. It declares authorization to the grantee + * on behalf of the granter with the provided expiration time. + */ +export interface MsgGrant { + granter: string; + grantee: string; + grant: Grant; +} +export interface MsgGrantProtoMsg { + typeUrl: "/cosmos.authz.v1beta1.MsgGrant"; + value: Uint8Array; +} +/** + * MsgGrant is a request type for Grant method. It declares authorization to the grantee + * on behalf of the granter with the provided expiration time. + */ +export interface MsgGrantSDKType { + granter: string; + grantee: string; + grant: GrantSDKType; +} +/** MsgExecResponse defines the Msg/MsgExecResponse response type. */ +export interface MsgExecResponse { + results: Uint8Array[]; +} +export interface MsgExecResponseProtoMsg { + typeUrl: "/cosmos.authz.v1beta1.MsgExecResponse"; + value: Uint8Array; +} +/** MsgExecResponse defines the Msg/MsgExecResponse response type. */ +export interface MsgExecResponseSDKType { + results: Uint8Array[]; +} +/** + * MsgExec attempts to execute the provided messages using + * authorizations granted to the grantee. Each message should have only + * one signer corresponding to the granter of the authorization. + */ +export interface MsgExec { + grantee: string; + /** + * Authorization Msg requests to execute. Each msg must implement Authorization interface + * The x/authz will try to find a grant matching (msg.signers[0], grantee, MsgTypeURL(msg)) + * triple and validate it. + */ + msgs: Any[]; +} +export interface MsgExecProtoMsg { + typeUrl: "/cosmos.authz.v1beta1.MsgExec"; + value: Uint8Array; +} +/** + * MsgExec attempts to execute the provided messages using + * authorizations granted to the grantee. Each message should have only + * one signer corresponding to the granter of the authorization. + */ +export interface MsgExecSDKType { + grantee: string; + msgs: AnySDKType[]; +} +/** MsgGrantResponse defines the Msg/MsgGrant response type. */ +export interface MsgGrantResponse {} +export interface MsgGrantResponseProtoMsg { + typeUrl: "/cosmos.authz.v1beta1.MsgGrantResponse"; + value: Uint8Array; +} +/** MsgGrantResponse defines the Msg/MsgGrant response type. */ +export interface MsgGrantResponseSDKType {} +/** + * MsgRevoke revokes any authorization with the provided sdk.Msg type on the + * granter's account with that has been granted to the grantee. + */ +export interface MsgRevoke { + granter: string; + grantee: string; + msgTypeUrl: string; +} +export interface MsgRevokeProtoMsg { + typeUrl: "/cosmos.authz.v1beta1.MsgRevoke"; + value: Uint8Array; +} +/** + * MsgRevoke revokes any authorization with the provided sdk.Msg type on the + * granter's account with that has been granted to the grantee. + */ +export interface MsgRevokeSDKType { + granter: string; + grantee: string; + msg_type_url: string; +} +/** MsgRevokeResponse defines the Msg/MsgRevokeResponse response type. */ +export interface MsgRevokeResponse {} +export interface MsgRevokeResponseProtoMsg { + typeUrl: "/cosmos.authz.v1beta1.MsgRevokeResponse"; + value: Uint8Array; +} +/** MsgRevokeResponse defines the Msg/MsgRevokeResponse response type. */ +export interface MsgRevokeResponseSDKType {} +function createBaseMsgGrant(): MsgGrant { + return { + granter: "", + grantee: "", + grant: Grant.fromPartial({}) + }; +} +export const MsgGrant = { + typeUrl: "/cosmos.authz.v1beta1.MsgGrant", + encode(message: MsgGrant, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.granter !== undefined) { + writer.uint32(10).string(message.granter); + } + if (message.grantee !== undefined) { + writer.uint32(18).string(message.grantee); + } + if (message.grant !== undefined) { + Grant.encode(message.grant, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgGrant { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgGrant(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.granter = reader.string(); + break; + case 2: + message.grantee = reader.string(); + break; + case 3: + message.grant = Grant.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgGrant { + const obj = createBaseMsgGrant(); + if (isSet(object.granter)) obj.granter = String(object.granter); + if (isSet(object.grantee)) obj.grantee = String(object.grantee); + if (isSet(object.grant)) obj.grant = Grant.fromJSON(object.grant); + return obj; + }, + toJSON(message: MsgGrant): JsonSafe { + const obj: any = {}; + message.granter !== undefined && (obj.granter = message.granter); + message.grantee !== undefined && (obj.grantee = message.grantee); + message.grant !== undefined && (obj.grant = message.grant ? Grant.toJSON(message.grant) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): MsgGrant { + const message = createBaseMsgGrant(); + message.granter = object.granter ?? ""; + message.grantee = object.grantee ?? ""; + if (object.grant !== undefined && object.grant !== null) { + message.grant = Grant.fromPartial(object.grant); + } + return message; + }, + fromSDK(object: MsgGrantSDKType): MsgGrant { + return { + granter: object?.granter, + grantee: object?.grantee, + grant: object.grant ? Grant.fromSDK(object.grant) : undefined + }; + }, + fromSDKJSON(object: any): MsgGrantSDKType { + return { + granter: isSet(object.granter) ? String(object.granter) : "", + grantee: isSet(object.grantee) ? String(object.grantee) : "", + grant: isSet(object.grant) ? Grant.fromSDKJSON(object.grant) : undefined + }; + }, + toSDK(message: MsgGrant): MsgGrantSDKType { + const obj: any = {}; + obj.granter = message.granter; + obj.grantee = message.grantee; + message.grant !== undefined && (obj.grant = message.grant ? Grant.toSDK(message.grant) : undefined); + return obj; + }, + fromAmino(object: MsgGrantAmino): MsgGrant { + const message = createBaseMsgGrant(); + if (object.granter !== undefined && object.granter !== null) { + message.granter = object.granter; + } + if (object.grantee !== undefined && object.grantee !== null) { + message.grantee = object.grantee; + } + if (object.grant !== undefined && object.grant !== null) { + message.grant = Grant.fromAmino(object.grant); + } + return message; + }, + toAmino(message: MsgGrant): MsgGrantAmino { + const obj: any = {}; + obj.granter = message.granter === "" ? undefined : message.granter; + obj.grantee = message.grantee === "" ? undefined : message.grantee; + obj.grant = message.grant ? Grant.toAmino(message.grant) : undefined; + return obj; + }, + fromAminoMsg(object: MsgGrantAminoMsg): MsgGrant { + return MsgGrant.fromAmino(object.value); + }, + toAminoMsg(message: MsgGrant): MsgGrantAminoMsg { + return { + type: "cosmos-sdk/MsgGrant", + value: MsgGrant.toAmino(message) + }; + }, + fromProtoMsg(message: MsgGrantProtoMsg): MsgGrant { + return MsgGrant.decode(message.value); + }, + toProto(message: MsgGrant): Uint8Array { + return MsgGrant.encode(message).finish(); + }, + toProtoMsg(message: MsgGrant): MsgGrantProtoMsg { + return { + typeUrl: "/cosmos.authz.v1beta1.MsgGrant", + value: MsgGrant.encode(message).finish() + }; + } +}; +function createBaseMsgExecResponse(): MsgExecResponse { + return { + results: [] + }; +} +export const MsgExecResponse = { + typeUrl: "/cosmos.authz.v1beta1.MsgExecResponse", + encode(message: MsgExecResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.results) { + writer.uint32(10).bytes(v!); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgExecResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgExecResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.results.push(reader.bytes()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgExecResponse { + const obj = createBaseMsgExecResponse(); + if (Array.isArray(object?.results)) obj.results = object.results.map((e: any) => bytesFromBase64(e)); + return obj; + }, + toJSON(message: MsgExecResponse): JsonSafe { + const obj: any = {}; + if (message.results) { + obj.results = message.results.map(e => base64FromBytes(e !== undefined ? e : new Uint8Array())); + } else { + obj.results = []; + } + return obj; + }, + fromPartial(object: DeepPartial): MsgExecResponse { + const message = createBaseMsgExecResponse(); + message.results = object.results?.map(e => e) || []; + return message; + }, + fromSDK(object: MsgExecResponseSDKType): MsgExecResponse { + return { + results: Array.isArray(object?.results) ? object.results.map((e: any) => e) : [] + }; + }, + fromSDKJSON(object: any): MsgExecResponseSDKType { + return { + results: Array.isArray(object?.results) ? object.results.map((e: any) => bytesFromBase64(e)) : [] + }; + }, + toSDK(message: MsgExecResponse): MsgExecResponseSDKType { + const obj: any = {}; + if (message.results) { + obj.results = message.results.map(e => e); + } else { + obj.results = []; + } + return obj; + }, + fromAmino(object: MsgExecResponseAmino): MsgExecResponse { + const message = createBaseMsgExecResponse(); + message.results = object.results?.map(e => bytesFromBase64(e)) || []; + return message; + }, + toAmino(message: MsgExecResponse): MsgExecResponseAmino { + const obj: any = {}; + if (message.results) { + obj.results = message.results.map(e => base64FromBytes(e)); + } else { + obj.results = message.results; + } + return obj; + }, + fromAminoMsg(object: MsgExecResponseAminoMsg): MsgExecResponse { + return MsgExecResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgExecResponse): MsgExecResponseAminoMsg { + return { + type: "cosmos-sdk/MsgExecResponse", + value: MsgExecResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgExecResponseProtoMsg): MsgExecResponse { + return MsgExecResponse.decode(message.value); + }, + toProto(message: MsgExecResponse): Uint8Array { + return MsgExecResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgExecResponse): MsgExecResponseProtoMsg { + return { + typeUrl: "/cosmos.authz.v1beta1.MsgExecResponse", + value: MsgExecResponse.encode(message).finish() + }; + } +}; +function createBaseMsgExec(): MsgExec { + return { + grantee: "", + msgs: [] + }; +} +export const MsgExec = { + typeUrl: "/cosmos.authz.v1beta1.MsgExec", + encode(message: MsgExec, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.grantee !== undefined) { + writer.uint32(10).string(message.grantee); + } + for (const v of message.msgs) { + Any.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgExec { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgExec(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.grantee = reader.string(); + break; + case 2: + message.msgs.push(Any.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgExec { + const obj = createBaseMsgExec(); + if (isSet(object.grantee)) obj.grantee = String(object.grantee); + if (Array.isArray(object?.msgs)) obj.msgs = object.msgs.map((e: any) => Any.fromJSON(e)); + return obj; + }, + toJSON(message: MsgExec): JsonSafe { + const obj: any = {}; + message.grantee !== undefined && (obj.grantee = message.grantee); + if (message.msgs) { + obj.msgs = message.msgs.map(e => e ? Any.toJSON(e) : undefined); + } else { + obj.msgs = []; + } + return obj; + }, + fromPartial(object: DeepPartial): MsgExec { + const message = createBaseMsgExec(); + message.grantee = object.grantee ?? ""; + message.msgs = object.msgs?.map(e => Any.fromPartial(e)) || []; + return message; + }, + fromSDK(object: MsgExecSDKType): MsgExec { + return { + grantee: object?.grantee, + msgs: Array.isArray(object?.msgs) ? object.msgs.map((e: any) => Any.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): MsgExecSDKType { + return { + grantee: isSet(object.grantee) ? String(object.grantee) : "", + msgs: Array.isArray(object?.msgs) ? object.msgs.map((e: any) => Any.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: MsgExec): MsgExecSDKType { + const obj: any = {}; + obj.grantee = message.grantee; + if (message.msgs) { + obj.msgs = message.msgs.map(e => e ? Any.toSDK(e) : undefined); + } else { + obj.msgs = []; + } + return obj; + }, + fromAmino(object: MsgExecAmino): MsgExec { + const message = createBaseMsgExec(); + if (object.grantee !== undefined && object.grantee !== null) { + message.grantee = object.grantee; + } + message.msgs = object.msgs?.map(e => Any.fromAmino(e)) || []; + return message; + }, + toAmino(message: MsgExec): MsgExecAmino { + const obj: any = {}; + obj.grantee = message.grantee === "" ? undefined : message.grantee; + if (message.msgs) { + obj.msgs = message.msgs.map(e => e ? Any.toAmino(e) : undefined); + } else { + obj.msgs = message.msgs; + } + return obj; + }, + fromAminoMsg(object: MsgExecAminoMsg): MsgExec { + return MsgExec.fromAmino(object.value); + }, + toAminoMsg(message: MsgExec): MsgExecAminoMsg { + return { + type: "cosmos-sdk/MsgExec", + value: MsgExec.toAmino(message) + }; + }, + fromProtoMsg(message: MsgExecProtoMsg): MsgExec { + return MsgExec.decode(message.value); + }, + toProto(message: MsgExec): Uint8Array { + return MsgExec.encode(message).finish(); + }, + toProtoMsg(message: MsgExec): MsgExecProtoMsg { + return { + typeUrl: "/cosmos.authz.v1beta1.MsgExec", + value: MsgExec.encode(message).finish() + }; + } +}; +function createBaseMsgGrantResponse(): MsgGrantResponse { + return {}; +} +export const MsgGrantResponse = { + typeUrl: "/cosmos.authz.v1beta1.MsgGrantResponse", + encode(_: MsgGrantResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgGrantResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgGrantResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgGrantResponse { + const obj = createBaseMsgGrantResponse(); + return obj; + }, + toJSON(_: MsgGrantResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): MsgGrantResponse { + const message = createBaseMsgGrantResponse(); + return message; + }, + fromSDK(_: MsgGrantResponseSDKType): MsgGrantResponse { + return {}; + }, + fromSDKJSON(_: any): MsgGrantResponseSDKType { + return {}; + }, + toSDK(_: MsgGrantResponse): MsgGrantResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgGrantResponseAmino): MsgGrantResponse { + const message = createBaseMsgGrantResponse(); + return message; + }, + toAmino(_: MsgGrantResponse): MsgGrantResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgGrantResponseAminoMsg): MsgGrantResponse { + return MsgGrantResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgGrantResponse): MsgGrantResponseAminoMsg { + return { + type: "cosmos-sdk/MsgGrantResponse", + value: MsgGrantResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgGrantResponseProtoMsg): MsgGrantResponse { + return MsgGrantResponse.decode(message.value); + }, + toProto(message: MsgGrantResponse): Uint8Array { + return MsgGrantResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgGrantResponse): MsgGrantResponseProtoMsg { + return { + typeUrl: "/cosmos.authz.v1beta1.MsgGrantResponse", + value: MsgGrantResponse.encode(message).finish() + }; + } +}; +function createBaseMsgRevoke(): MsgRevoke { + return { + granter: "", + grantee: "", + msgTypeUrl: "" + }; +} +export const MsgRevoke = { + typeUrl: "/cosmos.authz.v1beta1.MsgRevoke", + encode(message: MsgRevoke, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.granter !== undefined) { + writer.uint32(10).string(message.granter); + } + if (message.grantee !== undefined) { + writer.uint32(18).string(message.grantee); + } + if (message.msgTypeUrl !== undefined) { + writer.uint32(26).string(message.msgTypeUrl); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgRevoke { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgRevoke(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.granter = reader.string(); + break; + case 2: + message.grantee = reader.string(); + break; + case 3: + message.msgTypeUrl = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgRevoke { + const obj = createBaseMsgRevoke(); + if (isSet(object.granter)) obj.granter = String(object.granter); + if (isSet(object.grantee)) obj.grantee = String(object.grantee); + if (isSet(object.msgTypeUrl)) obj.msgTypeUrl = String(object.msgTypeUrl); + return obj; + }, + toJSON(message: MsgRevoke): JsonSafe { + const obj: any = {}; + message.granter !== undefined && (obj.granter = message.granter); + message.grantee !== undefined && (obj.grantee = message.grantee); + message.msgTypeUrl !== undefined && (obj.msgTypeUrl = message.msgTypeUrl); + return obj; + }, + fromPartial(object: DeepPartial): MsgRevoke { + const message = createBaseMsgRevoke(); + message.granter = object.granter ?? ""; + message.grantee = object.grantee ?? ""; + message.msgTypeUrl = object.msgTypeUrl ?? ""; + return message; + }, + fromSDK(object: MsgRevokeSDKType): MsgRevoke { + return { + granter: object?.granter, + grantee: object?.grantee, + msgTypeUrl: object?.msg_type_url + }; + }, + fromSDKJSON(object: any): MsgRevokeSDKType { + return { + granter: isSet(object.granter) ? String(object.granter) : "", + grantee: isSet(object.grantee) ? String(object.grantee) : "", + msg_type_url: isSet(object.msg_type_url) ? String(object.msg_type_url) : "" + }; + }, + toSDK(message: MsgRevoke): MsgRevokeSDKType { + const obj: any = {}; + obj.granter = message.granter; + obj.grantee = message.grantee; + obj.msg_type_url = message.msgTypeUrl; + return obj; + }, + fromAmino(object: MsgRevokeAmino): MsgRevoke { + const message = createBaseMsgRevoke(); + if (object.granter !== undefined && object.granter !== null) { + message.granter = object.granter; + } + if (object.grantee !== undefined && object.grantee !== null) { + message.grantee = object.grantee; + } + if (object.msg_type_url !== undefined && object.msg_type_url !== null) { + message.msgTypeUrl = object.msg_type_url; + } + return message; + }, + toAmino(message: MsgRevoke): MsgRevokeAmino { + const obj: any = {}; + obj.granter = message.granter === "" ? undefined : message.granter; + obj.grantee = message.grantee === "" ? undefined : message.grantee; + obj.msg_type_url = message.msgTypeUrl === "" ? undefined : message.msgTypeUrl; + return obj; + }, + fromAminoMsg(object: MsgRevokeAminoMsg): MsgRevoke { + return MsgRevoke.fromAmino(object.value); + }, + toAminoMsg(message: MsgRevoke): MsgRevokeAminoMsg { + return { + type: "cosmos-sdk/MsgRevoke", + value: MsgRevoke.toAmino(message) + }; + }, + fromProtoMsg(message: MsgRevokeProtoMsg): MsgRevoke { + return MsgRevoke.decode(message.value); + }, + toProto(message: MsgRevoke): Uint8Array { + return MsgRevoke.encode(message).finish(); + }, + toProtoMsg(message: MsgRevoke): MsgRevokeProtoMsg { + return { + typeUrl: "/cosmos.authz.v1beta1.MsgRevoke", + value: MsgRevoke.encode(message).finish() + }; + } +}; +function createBaseMsgRevokeResponse(): MsgRevokeResponse { + return {}; +} +export const MsgRevokeResponse = { + typeUrl: "/cosmos.authz.v1beta1.MsgRevokeResponse", + encode(_: MsgRevokeResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgRevokeResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgRevokeResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgRevokeResponse { + const obj = createBaseMsgRevokeResponse(); + return obj; + }, + toJSON(_: MsgRevokeResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): MsgRevokeResponse { + const message = createBaseMsgRevokeResponse(); + return message; + }, + fromSDK(_: MsgRevokeResponseSDKType): MsgRevokeResponse { + return {}; + }, + fromSDKJSON(_: any): MsgRevokeResponseSDKType { + return {}; + }, + toSDK(_: MsgRevokeResponse): MsgRevokeResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgRevokeResponseAmino): MsgRevokeResponse { + const message = createBaseMsgRevokeResponse(); + return message; + }, + toAmino(_: MsgRevokeResponse): MsgRevokeResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgRevokeResponseAminoMsg): MsgRevokeResponse { + return MsgRevokeResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgRevokeResponse): MsgRevokeResponseAminoMsg { + return { + type: "cosmos-sdk/MsgRevokeResponse", + value: MsgRevokeResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgRevokeResponseProtoMsg): MsgRevokeResponse { + return MsgRevokeResponse.decode(message.value); + }, + toProto(message: MsgRevokeResponse): Uint8Array { + return MsgRevokeResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgRevokeResponse): MsgRevokeResponseProtoMsg { + return { + typeUrl: "/cosmos.authz.v1beta1.MsgRevokeResponse", + value: MsgRevokeResponse.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/bank/v1beta1/authz.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/bank/v1beta1/authz.ts new file mode 100644 index 0000000000..b7fb75d211 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/bank/v1beta1/authz.ts @@ -0,0 +1,131 @@ +import { Coin, CoinSDKType } from "../../base/v1beta1/coin.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { JsonSafe } from "../../../json-safe.js"; +import { DeepPartial } from "../../../helpers.js"; +export const protobufPackage = "cosmos.bank.v1beta1"; +/** + * SendAuthorization allows the grantee to spend up to spend_limit coins from + * the granter's account. + * + * Since: cosmos-sdk 0.43 + */ +export interface SendAuthorization { + spendLimit: Coin[]; +} +export interface SendAuthorizationProtoMsg { + typeUrl: "/cosmos.bank.v1beta1.SendAuthorization"; + value: Uint8Array; +} +/** + * SendAuthorization allows the grantee to spend up to spend_limit coins from + * the granter's account. + * + * Since: cosmos-sdk 0.43 + */ +export interface SendAuthorizationSDKType { + spend_limit: CoinSDKType[]; +} +function createBaseSendAuthorization(): SendAuthorization { + return { + spendLimit: [] + }; +} +export const SendAuthorization = { + typeUrl: "/cosmos.bank.v1beta1.SendAuthorization", + encode(message: SendAuthorization, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.spendLimit) { + Coin.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): SendAuthorization { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseSendAuthorization(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.spendLimit.push(Coin.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): SendAuthorization { + const obj = createBaseSendAuthorization(); + if (Array.isArray(object?.spendLimit)) obj.spendLimit = object.spendLimit.map((e: any) => Coin.fromJSON(e)); + return obj; + }, + toJSON(message: SendAuthorization): JsonSafe { + const obj: any = {}; + if (message.spendLimit) { + obj.spendLimit = message.spendLimit.map(e => e ? Coin.toJSON(e) : undefined); + } else { + obj.spendLimit = []; + } + return obj; + }, + fromPartial(object: DeepPartial): SendAuthorization { + const message = createBaseSendAuthorization(); + message.spendLimit = object.spendLimit?.map(e => Coin.fromPartial(e)) || []; + return message; + }, + fromSDK(object: SendAuthorizationSDKType): SendAuthorization { + return { + spendLimit: Array.isArray(object?.spend_limit) ? object.spend_limit.map((e: any) => Coin.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): SendAuthorizationSDKType { + return { + spend_limit: Array.isArray(object?.spend_limit) ? object.spend_limit.map((e: any) => Coin.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: SendAuthorization): SendAuthorizationSDKType { + const obj: any = {}; + if (message.spendLimit) { + obj.spend_limit = message.spendLimit.map(e => e ? Coin.toSDK(e) : undefined); + } else { + obj.spend_limit = []; + } + return obj; + }, + fromAmino(object: SendAuthorizationAmino): SendAuthorization { + const message = createBaseSendAuthorization(); + message.spendLimit = object.spend_limit?.map(e => Coin.fromAmino(e)) || []; + return message; + }, + toAmino(message: SendAuthorization): SendAuthorizationAmino { + const obj: any = {}; + if (message.spendLimit) { + obj.spend_limit = message.spendLimit.map(e => e ? Coin.toAmino(e) : undefined); + } else { + obj.spend_limit = message.spendLimit; + } + return obj; + }, + fromAminoMsg(object: SendAuthorizationAminoMsg): SendAuthorization { + return SendAuthorization.fromAmino(object.value); + }, + toAminoMsg(message: SendAuthorization): SendAuthorizationAminoMsg { + return { + type: "cosmos-sdk/SendAuthorization", + value: SendAuthorization.toAmino(message) + }; + }, + fromProtoMsg(message: SendAuthorizationProtoMsg): SendAuthorization { + return SendAuthorization.decode(message.value); + }, + toProto(message: SendAuthorization): Uint8Array { + return SendAuthorization.encode(message).finish(); + }, + toProtoMsg(message: SendAuthorization): SendAuthorizationProtoMsg { + return { + typeUrl: "/cosmos.bank.v1beta1.SendAuthorization", + value: SendAuthorization.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/bank/v1beta1/bank.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/bank/v1beta1/bank.ts new file mode 100644 index 0000000000..c7c7a9835d --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/bank/v1beta1/bank.ts @@ -0,0 +1,1119 @@ +import { Coin, CoinSDKType } from "../../base/v1beta1/coin.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "cosmos.bank.v1beta1"; +/** Params defines the parameters for the bank module. */ +export interface Params { + sendEnabled: SendEnabled[]; + defaultSendEnabled: boolean; +} +export interface ParamsProtoMsg { + typeUrl: "/cosmos.bank.v1beta1.Params"; + value: Uint8Array; +} +/** Params defines the parameters for the bank module. */ +export interface ParamsSDKType { + send_enabled: SendEnabledSDKType[]; + default_send_enabled: boolean; +} +/** + * SendEnabled maps coin denom to a send_enabled status (whether a denom is + * sendable). + */ +export interface SendEnabled { + denom: string; + enabled: boolean; +} +export interface SendEnabledProtoMsg { + typeUrl: "/cosmos.bank.v1beta1.SendEnabled"; + value: Uint8Array; +} +/** + * SendEnabled maps coin denom to a send_enabled status (whether a denom is + * sendable). + */ +export interface SendEnabledSDKType { + denom: string; + enabled: boolean; +} +/** Input models transaction input. */ +export interface Input { + address: string; + coins: Coin[]; +} +export interface InputProtoMsg { + typeUrl: "/cosmos.bank.v1beta1.Input"; + value: Uint8Array; +} +/** Input models transaction input. */ +export interface InputSDKType { + address: string; + coins: CoinSDKType[]; +} +/** Output models transaction outputs. */ +export interface Output { + address: string; + coins: Coin[]; +} +export interface OutputProtoMsg { + typeUrl: "/cosmos.bank.v1beta1.Output"; + value: Uint8Array; +} +/** Output models transaction outputs. */ +export interface OutputSDKType { + address: string; + coins: CoinSDKType[]; +} +/** + * Supply represents a struct that passively keeps track of the total supply + * amounts in the network. + * This message is deprecated now that supply is indexed by denom. + */ +/** @deprecated */ +export interface Supply { + total: Coin[]; +} +export interface SupplyProtoMsg { + typeUrl: "/cosmos.bank.v1beta1.Supply"; + value: Uint8Array; +} +/** + * Supply represents a struct that passively keeps track of the total supply + * amounts in the network. + * This message is deprecated now that supply is indexed by denom. + */ +/** @deprecated */ +export interface SupplySDKType { + total: CoinSDKType[]; +} +/** + * DenomUnit represents a struct that describes a given + * denomination unit of the basic token. + */ +export interface DenomUnit { + /** denom represents the string name of the given denom unit (e.g uatom). */ + denom: string; + /** + * exponent represents power of 10 exponent that one must + * raise the base_denom to in order to equal the given DenomUnit's denom + * 1 denom = 10^exponent base_denom + * (e.g. with a base_denom of uatom, one can create a DenomUnit of 'atom' with + * exponent = 6, thus: 1 atom = 10^6 uatom). + */ + exponent: number; + /** aliases is a list of string aliases for the given denom */ + aliases: string[]; +} +export interface DenomUnitProtoMsg { + typeUrl: "/cosmos.bank.v1beta1.DenomUnit"; + value: Uint8Array; +} +/** + * DenomUnit represents a struct that describes a given + * denomination unit of the basic token. + */ +export interface DenomUnitSDKType { + denom: string; + exponent: number; + aliases: string[]; +} +/** + * Metadata represents a struct that describes + * a basic token. + */ +export interface Metadata { + description: string; + /** denom_units represents the list of DenomUnit's for a given coin */ + denomUnits: DenomUnit[]; + /** base represents the base denom (should be the DenomUnit with exponent = 0). */ + base: string; + /** + * display indicates the suggested denom that should be + * displayed in clients. + */ + display: string; + /** + * name defines the name of the token (eg: Cosmos Atom) + * + * Since: cosmos-sdk 0.43 + */ + name: string; + /** + * symbol is the token symbol usually shown on exchanges (eg: ATOM). This can + * be the same as the display. + * + * Since: cosmos-sdk 0.43 + */ + symbol: string; + /** + * URI to a document (on or off-chain) that contains additional information. Optional. + * + * Since: cosmos-sdk 0.46 + */ + uri: string; + /** + * URIHash is a sha256 hash of a document pointed by URI. It's used to verify that + * the document didn't change. Optional. + * + * Since: cosmos-sdk 0.46 + */ + uriHash: string; +} +export interface MetadataProtoMsg { + typeUrl: "/cosmos.bank.v1beta1.Metadata"; + value: Uint8Array; +} +/** + * Metadata represents a struct that describes + * a basic token. + */ +export interface MetadataSDKType { + description: string; + denom_units: DenomUnitSDKType[]; + base: string; + display: string; + name: string; + symbol: string; + uri: string; + uri_hash: string; +} +function createBaseParams(): Params { + return { + sendEnabled: [], + defaultSendEnabled: false + }; +} +export const Params = { + typeUrl: "/cosmos.bank.v1beta1.Params", + encode(message: Params, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.sendEnabled) { + SendEnabled.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.defaultSendEnabled !== undefined) { + writer.uint32(16).bool(message.defaultSendEnabled); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Params { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseParams(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.sendEnabled.push(SendEnabled.decode(reader, reader.uint32())); + break; + case 2: + message.defaultSendEnabled = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Params { + const obj = createBaseParams(); + if (Array.isArray(object?.sendEnabled)) obj.sendEnabled = object.sendEnabled.map((e: any) => SendEnabled.fromJSON(e)); + if (isSet(object.defaultSendEnabled)) obj.defaultSendEnabled = Boolean(object.defaultSendEnabled); + return obj; + }, + toJSON(message: Params): JsonSafe { + const obj: any = {}; + if (message.sendEnabled) { + obj.sendEnabled = message.sendEnabled.map(e => e ? SendEnabled.toJSON(e) : undefined); + } else { + obj.sendEnabled = []; + } + message.defaultSendEnabled !== undefined && (obj.defaultSendEnabled = message.defaultSendEnabled); + return obj; + }, + fromPartial(object: DeepPartial): Params { + const message = createBaseParams(); + message.sendEnabled = object.sendEnabled?.map(e => SendEnabled.fromPartial(e)) || []; + message.defaultSendEnabled = object.defaultSendEnabled ?? false; + return message; + }, + fromSDK(object: ParamsSDKType): Params { + return { + sendEnabled: Array.isArray(object?.send_enabled) ? object.send_enabled.map((e: any) => SendEnabled.fromSDK(e)) : [], + defaultSendEnabled: object?.default_send_enabled + }; + }, + fromSDKJSON(object: any): ParamsSDKType { + return { + send_enabled: Array.isArray(object?.send_enabled) ? object.send_enabled.map((e: any) => SendEnabled.fromSDKJSON(e)) : [], + default_send_enabled: isSet(object.default_send_enabled) ? Boolean(object.default_send_enabled) : false + }; + }, + toSDK(message: Params): ParamsSDKType { + const obj: any = {}; + if (message.sendEnabled) { + obj.send_enabled = message.sendEnabled.map(e => e ? SendEnabled.toSDK(e) : undefined); + } else { + obj.send_enabled = []; + } + obj.default_send_enabled = message.defaultSendEnabled; + return obj; + }, + fromAmino(object: ParamsAmino): Params { + const message = createBaseParams(); + message.sendEnabled = object.send_enabled?.map(e => SendEnabled.fromAmino(e)) || []; + if (object.default_send_enabled !== undefined && object.default_send_enabled !== null) { + message.defaultSendEnabled = object.default_send_enabled; + } + return message; + }, + toAmino(message: Params): ParamsAmino { + const obj: any = {}; + if (message.sendEnabled) { + obj.send_enabled = message.sendEnabled.map(e => e ? SendEnabled.toAmino(e) : undefined); + } else { + obj.send_enabled = message.sendEnabled; + } + obj.default_send_enabled = message.defaultSendEnabled === false ? undefined : message.defaultSendEnabled; + return obj; + }, + fromAminoMsg(object: ParamsAminoMsg): Params { + return Params.fromAmino(object.value); + }, + toAminoMsg(message: Params): ParamsAminoMsg { + return { + type: "cosmos-sdk/Params", + value: Params.toAmino(message) + }; + }, + fromProtoMsg(message: ParamsProtoMsg): Params { + return Params.decode(message.value); + }, + toProto(message: Params): Uint8Array { + return Params.encode(message).finish(); + }, + toProtoMsg(message: Params): ParamsProtoMsg { + return { + typeUrl: "/cosmos.bank.v1beta1.Params", + value: Params.encode(message).finish() + }; + } +}; +function createBaseSendEnabled(): SendEnabled { + return { + denom: "", + enabled: false + }; +} +export const SendEnabled = { + typeUrl: "/cosmos.bank.v1beta1.SendEnabled", + encode(message: SendEnabled, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.denom !== undefined) { + writer.uint32(10).string(message.denom); + } + if (message.enabled !== undefined) { + writer.uint32(16).bool(message.enabled); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): SendEnabled { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseSendEnabled(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.denom = reader.string(); + break; + case 2: + message.enabled = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): SendEnabled { + const obj = createBaseSendEnabled(); + if (isSet(object.denom)) obj.denom = String(object.denom); + if (isSet(object.enabled)) obj.enabled = Boolean(object.enabled); + return obj; + }, + toJSON(message: SendEnabled): JsonSafe { + const obj: any = {}; + message.denom !== undefined && (obj.denom = message.denom); + message.enabled !== undefined && (obj.enabled = message.enabled); + return obj; + }, + fromPartial(object: DeepPartial): SendEnabled { + const message = createBaseSendEnabled(); + message.denom = object.denom ?? ""; + message.enabled = object.enabled ?? false; + return message; + }, + fromSDK(object: SendEnabledSDKType): SendEnabled { + return { + denom: object?.denom, + enabled: object?.enabled + }; + }, + fromSDKJSON(object: any): SendEnabledSDKType { + return { + denom: isSet(object.denom) ? String(object.denom) : "", + enabled: isSet(object.enabled) ? Boolean(object.enabled) : false + }; + }, + toSDK(message: SendEnabled): SendEnabledSDKType { + const obj: any = {}; + obj.denom = message.denom; + obj.enabled = message.enabled; + return obj; + }, + fromAmino(object: SendEnabledAmino): SendEnabled { + const message = createBaseSendEnabled(); + if (object.denom !== undefined && object.denom !== null) { + message.denom = object.denom; + } + if (object.enabled !== undefined && object.enabled !== null) { + message.enabled = object.enabled; + } + return message; + }, + toAmino(message: SendEnabled): SendEnabledAmino { + const obj: any = {}; + obj.denom = message.denom === "" ? undefined : message.denom; + obj.enabled = message.enabled === false ? undefined : message.enabled; + return obj; + }, + fromAminoMsg(object: SendEnabledAminoMsg): SendEnabled { + return SendEnabled.fromAmino(object.value); + }, + toAminoMsg(message: SendEnabled): SendEnabledAminoMsg { + return { + type: "cosmos-sdk/SendEnabled", + value: SendEnabled.toAmino(message) + }; + }, + fromProtoMsg(message: SendEnabledProtoMsg): SendEnabled { + return SendEnabled.decode(message.value); + }, + toProto(message: SendEnabled): Uint8Array { + return SendEnabled.encode(message).finish(); + }, + toProtoMsg(message: SendEnabled): SendEnabledProtoMsg { + return { + typeUrl: "/cosmos.bank.v1beta1.SendEnabled", + value: SendEnabled.encode(message).finish() + }; + } +}; +function createBaseInput(): Input { + return { + address: "", + coins: [] + }; +} +export const Input = { + typeUrl: "/cosmos.bank.v1beta1.Input", + encode(message: Input, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.address !== undefined) { + writer.uint32(10).string(message.address); + } + for (const v of message.coins) { + Coin.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Input { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseInput(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.string(); + break; + case 2: + message.coins.push(Coin.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Input { + const obj = createBaseInput(); + if (isSet(object.address)) obj.address = String(object.address); + if (Array.isArray(object?.coins)) obj.coins = object.coins.map((e: any) => Coin.fromJSON(e)); + return obj; + }, + toJSON(message: Input): JsonSafe { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + if (message.coins) { + obj.coins = message.coins.map(e => e ? Coin.toJSON(e) : undefined); + } else { + obj.coins = []; + } + return obj; + }, + fromPartial(object: DeepPartial): Input { + const message = createBaseInput(); + message.address = object.address ?? ""; + message.coins = object.coins?.map(e => Coin.fromPartial(e)) || []; + return message; + }, + fromSDK(object: InputSDKType): Input { + return { + address: object?.address, + coins: Array.isArray(object?.coins) ? object.coins.map((e: any) => Coin.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): InputSDKType { + return { + address: isSet(object.address) ? String(object.address) : "", + coins: Array.isArray(object?.coins) ? object.coins.map((e: any) => Coin.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: Input): InputSDKType { + const obj: any = {}; + obj.address = message.address; + if (message.coins) { + obj.coins = message.coins.map(e => e ? Coin.toSDK(e) : undefined); + } else { + obj.coins = []; + } + return obj; + }, + fromAmino(object: InputAmino): Input { + const message = createBaseInput(); + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } + message.coins = object.coins?.map(e => Coin.fromAmino(e)) || []; + return message; + }, + toAmino(message: Input): InputAmino { + const obj: any = {}; + obj.address = message.address === "" ? undefined : message.address; + if (message.coins) { + obj.coins = message.coins.map(e => e ? Coin.toAmino(e) : undefined); + } else { + obj.coins = message.coins; + } + return obj; + }, + fromAminoMsg(object: InputAminoMsg): Input { + return Input.fromAmino(object.value); + }, + toAminoMsg(message: Input): InputAminoMsg { + return { + type: "cosmos-sdk/Input", + value: Input.toAmino(message) + }; + }, + fromProtoMsg(message: InputProtoMsg): Input { + return Input.decode(message.value); + }, + toProto(message: Input): Uint8Array { + return Input.encode(message).finish(); + }, + toProtoMsg(message: Input): InputProtoMsg { + return { + typeUrl: "/cosmos.bank.v1beta1.Input", + value: Input.encode(message).finish() + }; + } +}; +function createBaseOutput(): Output { + return { + address: "", + coins: [] + }; +} +export const Output = { + typeUrl: "/cosmos.bank.v1beta1.Output", + encode(message: Output, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.address !== undefined) { + writer.uint32(10).string(message.address); + } + for (const v of message.coins) { + Coin.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Output { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseOutput(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.string(); + break; + case 2: + message.coins.push(Coin.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Output { + const obj = createBaseOutput(); + if (isSet(object.address)) obj.address = String(object.address); + if (Array.isArray(object?.coins)) obj.coins = object.coins.map((e: any) => Coin.fromJSON(e)); + return obj; + }, + toJSON(message: Output): JsonSafe { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + if (message.coins) { + obj.coins = message.coins.map(e => e ? Coin.toJSON(e) : undefined); + } else { + obj.coins = []; + } + return obj; + }, + fromPartial(object: DeepPartial): Output { + const message = createBaseOutput(); + message.address = object.address ?? ""; + message.coins = object.coins?.map(e => Coin.fromPartial(e)) || []; + return message; + }, + fromSDK(object: OutputSDKType): Output { + return { + address: object?.address, + coins: Array.isArray(object?.coins) ? object.coins.map((e: any) => Coin.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): OutputSDKType { + return { + address: isSet(object.address) ? String(object.address) : "", + coins: Array.isArray(object?.coins) ? object.coins.map((e: any) => Coin.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: Output): OutputSDKType { + const obj: any = {}; + obj.address = message.address; + if (message.coins) { + obj.coins = message.coins.map(e => e ? Coin.toSDK(e) : undefined); + } else { + obj.coins = []; + } + return obj; + }, + fromAmino(object: OutputAmino): Output { + const message = createBaseOutput(); + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } + message.coins = object.coins?.map(e => Coin.fromAmino(e)) || []; + return message; + }, + toAmino(message: Output): OutputAmino { + const obj: any = {}; + obj.address = message.address === "" ? undefined : message.address; + if (message.coins) { + obj.coins = message.coins.map(e => e ? Coin.toAmino(e) : undefined); + } else { + obj.coins = message.coins; + } + return obj; + }, + fromAminoMsg(object: OutputAminoMsg): Output { + return Output.fromAmino(object.value); + }, + toAminoMsg(message: Output): OutputAminoMsg { + return { + type: "cosmos-sdk/Output", + value: Output.toAmino(message) + }; + }, + fromProtoMsg(message: OutputProtoMsg): Output { + return Output.decode(message.value); + }, + toProto(message: Output): Uint8Array { + return Output.encode(message).finish(); + }, + toProtoMsg(message: Output): OutputProtoMsg { + return { + typeUrl: "/cosmos.bank.v1beta1.Output", + value: Output.encode(message).finish() + }; + } +}; +function createBaseSupply(): Supply { + return { + total: [] + }; +} +export const Supply = { + typeUrl: "/cosmos.bank.v1beta1.Supply", + encode(message: Supply, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.total) { + Coin.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Supply { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseSupply(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.total.push(Coin.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Supply { + const obj = createBaseSupply(); + if (Array.isArray(object?.total)) obj.total = object.total.map((e: any) => Coin.fromJSON(e)); + return obj; + }, + toJSON(message: Supply): JsonSafe { + const obj: any = {}; + if (message.total) { + obj.total = message.total.map(e => e ? Coin.toJSON(e) : undefined); + } else { + obj.total = []; + } + return obj; + }, + fromPartial(object: DeepPartial): Supply { + const message = createBaseSupply(); + message.total = object.total?.map(e => Coin.fromPartial(e)) || []; + return message; + }, + fromSDK(object: SupplySDKType): Supply { + return { + total: Array.isArray(object?.total) ? object.total.map((e: any) => Coin.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): SupplySDKType { + return { + total: Array.isArray(object?.total) ? object.total.map((e: any) => Coin.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: Supply): SupplySDKType { + const obj: any = {}; + if (message.total) { + obj.total = message.total.map(e => e ? Coin.toSDK(e) : undefined); + } else { + obj.total = []; + } + return obj; + }, + fromAmino(object: SupplyAmino): Supply { + const message = createBaseSupply(); + message.total = object.total?.map(e => Coin.fromAmino(e)) || []; + return message; + }, + toAmino(message: Supply): SupplyAmino { + const obj: any = {}; + if (message.total) { + obj.total = message.total.map(e => e ? Coin.toAmino(e) : undefined); + } else { + obj.total = message.total; + } + return obj; + }, + fromAminoMsg(object: SupplyAminoMsg): Supply { + return Supply.fromAmino(object.value); + }, + toAminoMsg(message: Supply): SupplyAminoMsg { + return { + type: "cosmos-sdk/Supply", + value: Supply.toAmino(message) + }; + }, + fromProtoMsg(message: SupplyProtoMsg): Supply { + return Supply.decode(message.value); + }, + toProto(message: Supply): Uint8Array { + return Supply.encode(message).finish(); + }, + toProtoMsg(message: Supply): SupplyProtoMsg { + return { + typeUrl: "/cosmos.bank.v1beta1.Supply", + value: Supply.encode(message).finish() + }; + } +}; +function createBaseDenomUnit(): DenomUnit { + return { + denom: "", + exponent: 0, + aliases: [] + }; +} +export const DenomUnit = { + typeUrl: "/cosmos.bank.v1beta1.DenomUnit", + encode(message: DenomUnit, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.denom !== undefined) { + writer.uint32(10).string(message.denom); + } + if (message.exponent !== undefined) { + writer.uint32(16).uint32(message.exponent); + } + for (const v of message.aliases) { + writer.uint32(26).string(v!); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): DenomUnit { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDenomUnit(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.denom = reader.string(); + break; + case 2: + message.exponent = reader.uint32(); + break; + case 3: + message.aliases.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): DenomUnit { + const obj = createBaseDenomUnit(); + if (isSet(object.denom)) obj.denom = String(object.denom); + if (isSet(object.exponent)) obj.exponent = Number(object.exponent); + if (Array.isArray(object?.aliases)) obj.aliases = object.aliases.map((e: any) => String(e)); + return obj; + }, + toJSON(message: DenomUnit): JsonSafe { + const obj: any = {}; + message.denom !== undefined && (obj.denom = message.denom); + message.exponent !== undefined && (obj.exponent = Math.round(message.exponent)); + if (message.aliases) { + obj.aliases = message.aliases.map(e => e); + } else { + obj.aliases = []; + } + return obj; + }, + fromPartial(object: DeepPartial): DenomUnit { + const message = createBaseDenomUnit(); + message.denom = object.denom ?? ""; + message.exponent = object.exponent ?? 0; + message.aliases = object.aliases?.map(e => e) || []; + return message; + }, + fromSDK(object: DenomUnitSDKType): DenomUnit { + return { + denom: object?.denom, + exponent: object?.exponent, + aliases: Array.isArray(object?.aliases) ? object.aliases.map((e: any) => e) : [] + }; + }, + fromSDKJSON(object: any): DenomUnitSDKType { + return { + denom: isSet(object.denom) ? String(object.denom) : "", + exponent: isSet(object.exponent) ? Number(object.exponent) : 0, + aliases: Array.isArray(object?.aliases) ? object.aliases.map((e: any) => String(e)) : [] + }; + }, + toSDK(message: DenomUnit): DenomUnitSDKType { + const obj: any = {}; + obj.denom = message.denom; + obj.exponent = message.exponent; + if (message.aliases) { + obj.aliases = message.aliases.map(e => e); + } else { + obj.aliases = []; + } + return obj; + }, + fromAmino(object: DenomUnitAmino): DenomUnit { + const message = createBaseDenomUnit(); + if (object.denom !== undefined && object.denom !== null) { + message.denom = object.denom; + } + if (object.exponent !== undefined && object.exponent !== null) { + message.exponent = object.exponent; + } + message.aliases = object.aliases?.map(e => e) || []; + return message; + }, + toAmino(message: DenomUnit): DenomUnitAmino { + const obj: any = {}; + obj.denom = message.denom === "" ? undefined : message.denom; + obj.exponent = message.exponent === 0 ? undefined : message.exponent; + if (message.aliases) { + obj.aliases = message.aliases.map(e => e); + } else { + obj.aliases = message.aliases; + } + return obj; + }, + fromAminoMsg(object: DenomUnitAminoMsg): DenomUnit { + return DenomUnit.fromAmino(object.value); + }, + toAminoMsg(message: DenomUnit): DenomUnitAminoMsg { + return { + type: "cosmos-sdk/DenomUnit", + value: DenomUnit.toAmino(message) + }; + }, + fromProtoMsg(message: DenomUnitProtoMsg): DenomUnit { + return DenomUnit.decode(message.value); + }, + toProto(message: DenomUnit): Uint8Array { + return DenomUnit.encode(message).finish(); + }, + toProtoMsg(message: DenomUnit): DenomUnitProtoMsg { + return { + typeUrl: "/cosmos.bank.v1beta1.DenomUnit", + value: DenomUnit.encode(message).finish() + }; + } +}; +function createBaseMetadata(): Metadata { + return { + description: "", + denomUnits: [], + base: "", + display: "", + name: "", + symbol: "", + uri: "", + uriHash: "" + }; +} +export const Metadata = { + typeUrl: "/cosmos.bank.v1beta1.Metadata", + encode(message: Metadata, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.description !== undefined) { + writer.uint32(10).string(message.description); + } + for (const v of message.denomUnits) { + DenomUnit.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.base !== undefined) { + writer.uint32(26).string(message.base); + } + if (message.display !== undefined) { + writer.uint32(34).string(message.display); + } + if (message.name !== undefined) { + writer.uint32(42).string(message.name); + } + if (message.symbol !== undefined) { + writer.uint32(50).string(message.symbol); + } + if (message.uri !== undefined) { + writer.uint32(58).string(message.uri); + } + if (message.uriHash !== undefined) { + writer.uint32(66).string(message.uriHash); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Metadata { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMetadata(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.description = reader.string(); + break; + case 2: + message.denomUnits.push(DenomUnit.decode(reader, reader.uint32())); + break; + case 3: + message.base = reader.string(); + break; + case 4: + message.display = reader.string(); + break; + case 5: + message.name = reader.string(); + break; + case 6: + message.symbol = reader.string(); + break; + case 7: + message.uri = reader.string(); + break; + case 8: + message.uriHash = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Metadata { + const obj = createBaseMetadata(); + if (isSet(object.description)) obj.description = String(object.description); + if (Array.isArray(object?.denomUnits)) obj.denomUnits = object.denomUnits.map((e: any) => DenomUnit.fromJSON(e)); + if (isSet(object.base)) obj.base = String(object.base); + if (isSet(object.display)) obj.display = String(object.display); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.symbol)) obj.symbol = String(object.symbol); + if (isSet(object.uri)) obj.uri = String(object.uri); + if (isSet(object.uriHash)) obj.uriHash = String(object.uriHash); + return obj; + }, + toJSON(message: Metadata): JsonSafe { + const obj: any = {}; + message.description !== undefined && (obj.description = message.description); + if (message.denomUnits) { + obj.denomUnits = message.denomUnits.map(e => e ? DenomUnit.toJSON(e) : undefined); + } else { + obj.denomUnits = []; + } + message.base !== undefined && (obj.base = message.base); + message.display !== undefined && (obj.display = message.display); + message.name !== undefined && (obj.name = message.name); + message.symbol !== undefined && (obj.symbol = message.symbol); + message.uri !== undefined && (obj.uri = message.uri); + message.uriHash !== undefined && (obj.uriHash = message.uriHash); + return obj; + }, + fromPartial(object: DeepPartial): Metadata { + const message = createBaseMetadata(); + message.description = object.description ?? ""; + message.denomUnits = object.denomUnits?.map(e => DenomUnit.fromPartial(e)) || []; + message.base = object.base ?? ""; + message.display = object.display ?? ""; + message.name = object.name ?? ""; + message.symbol = object.symbol ?? ""; + message.uri = object.uri ?? ""; + message.uriHash = object.uriHash ?? ""; + return message; + }, + fromSDK(object: MetadataSDKType): Metadata { + return { + description: object?.description, + denomUnits: Array.isArray(object?.denom_units) ? object.denom_units.map((e: any) => DenomUnit.fromSDK(e)) : [], + base: object?.base, + display: object?.display, + name: object?.name, + symbol: object?.symbol, + uri: object?.uri, + uriHash: object?.uri_hash + }; + }, + fromSDKJSON(object: any): MetadataSDKType { + return { + description: isSet(object.description) ? String(object.description) : "", + denom_units: Array.isArray(object?.denom_units) ? object.denom_units.map((e: any) => DenomUnit.fromSDKJSON(e)) : [], + base: isSet(object.base) ? String(object.base) : "", + display: isSet(object.display) ? String(object.display) : "", + name: isSet(object.name) ? String(object.name) : "", + symbol: isSet(object.symbol) ? String(object.symbol) : "", + uri: isSet(object.uri) ? String(object.uri) : "", + uri_hash: isSet(object.uri_hash) ? String(object.uri_hash) : "" + }; + }, + toSDK(message: Metadata): MetadataSDKType { + const obj: any = {}; + obj.description = message.description; + if (message.denomUnits) { + obj.denom_units = message.denomUnits.map(e => e ? DenomUnit.toSDK(e) : undefined); + } else { + obj.denom_units = []; + } + obj.base = message.base; + obj.display = message.display; + obj.name = message.name; + obj.symbol = message.symbol; + obj.uri = message.uri; + obj.uri_hash = message.uriHash; + return obj; + }, + fromAmino(object: MetadataAmino): Metadata { + const message = createBaseMetadata(); + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } + message.denomUnits = object.denom_units?.map(e => DenomUnit.fromAmino(e)) || []; + if (object.base !== undefined && object.base !== null) { + message.base = object.base; + } + if (object.display !== undefined && object.display !== null) { + message.display = object.display; + } + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + if (object.symbol !== undefined && object.symbol !== null) { + message.symbol = object.symbol; + } + if (object.uri !== undefined && object.uri !== null) { + message.uri = object.uri; + } + if (object.uri_hash !== undefined && object.uri_hash !== null) { + message.uriHash = object.uri_hash; + } + return message; + }, + toAmino(message: Metadata): MetadataAmino { + const obj: any = {}; + obj.description = message.description === "" ? undefined : message.description; + if (message.denomUnits) { + obj.denom_units = message.denomUnits.map(e => e ? DenomUnit.toAmino(e) : undefined); + } else { + obj.denom_units = message.denomUnits; + } + obj.base = message.base === "" ? undefined : message.base; + obj.display = message.display === "" ? undefined : message.display; + obj.name = message.name === "" ? undefined : message.name; + obj.symbol = message.symbol === "" ? undefined : message.symbol; + obj.uri = message.uri === "" ? undefined : message.uri; + obj.uri_hash = message.uriHash === "" ? undefined : message.uriHash; + return obj; + }, + fromAminoMsg(object: MetadataAminoMsg): Metadata { + return Metadata.fromAmino(object.value); + }, + toAminoMsg(message: Metadata): MetadataAminoMsg { + return { + type: "cosmos-sdk/Metadata", + value: Metadata.toAmino(message) + }; + }, + fromProtoMsg(message: MetadataProtoMsg): Metadata { + return Metadata.decode(message.value); + }, + toProto(message: Metadata): Uint8Array { + return Metadata.encode(message).finish(); + }, + toProtoMsg(message: Metadata): MetadataProtoMsg { + return { + typeUrl: "/cosmos.bank.v1beta1.Metadata", + value: Metadata.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/bank/v1beta1/genesis.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/bank/v1beta1/genesis.ts new file mode 100644 index 0000000000..4aa1c8a320 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/bank/v1beta1/genesis.ts @@ -0,0 +1,351 @@ +import { Params, ParamsSDKType, Metadata, MetadataSDKType } from "./bank.js"; +import { Coin, CoinSDKType } from "../../base/v1beta1/coin.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "cosmos.bank.v1beta1"; +/** GenesisState defines the bank module's genesis state. */ +export interface GenesisState { + /** params defines all the paramaters of the module. */ + params: Params; + /** balances is an array containing the balances of all the accounts. */ + balances: Balance[]; + /** + * supply represents the total supply. If it is left empty, then supply will be calculated based on the provided + * balances. Otherwise, it will be used to validate that the sum of the balances equals this amount. + */ + supply: Coin[]; + /** denom_metadata defines the metadata of the differents coins. */ + denomMetadata: Metadata[]; +} +export interface GenesisStateProtoMsg { + typeUrl: "/cosmos.bank.v1beta1.GenesisState"; + value: Uint8Array; +} +/** GenesisState defines the bank module's genesis state. */ +export interface GenesisStateSDKType { + params: ParamsSDKType; + balances: BalanceSDKType[]; + supply: CoinSDKType[]; + denom_metadata: MetadataSDKType[]; +} +/** + * Balance defines an account address and balance pair used in the bank module's + * genesis state. + */ +export interface Balance { + /** address is the address of the balance holder. */ + address: string; + /** coins defines the different coins this balance holds. */ + coins: Coin[]; +} +export interface BalanceProtoMsg { + typeUrl: "/cosmos.bank.v1beta1.Balance"; + value: Uint8Array; +} +/** + * Balance defines an account address and balance pair used in the bank module's + * genesis state. + */ +export interface BalanceSDKType { + address: string; + coins: CoinSDKType[]; +} +function createBaseGenesisState(): GenesisState { + return { + params: Params.fromPartial({}), + balances: [], + supply: [], + denomMetadata: [] + }; +} +export const GenesisState = { + typeUrl: "/cosmos.bank.v1beta1.GenesisState", + encode(message: GenesisState, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.balances) { + Balance.encode(v!, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.supply) { + Coin.encode(v!, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.denomMetadata) { + Metadata.encode(v!, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GenesisState { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGenesisState(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.params = Params.decode(reader, reader.uint32()); + break; + case 2: + message.balances.push(Balance.decode(reader, reader.uint32())); + break; + case 3: + message.supply.push(Coin.decode(reader, reader.uint32())); + break; + case 4: + message.denomMetadata.push(Metadata.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GenesisState { + const obj = createBaseGenesisState(); + if (isSet(object.params)) obj.params = Params.fromJSON(object.params); + if (Array.isArray(object?.balances)) obj.balances = object.balances.map((e: any) => Balance.fromJSON(e)); + if (Array.isArray(object?.supply)) obj.supply = object.supply.map((e: any) => Coin.fromJSON(e)); + if (Array.isArray(object?.denomMetadata)) obj.denomMetadata = object.denomMetadata.map((e: any) => Metadata.fromJSON(e)); + return obj; + }, + toJSON(message: GenesisState): JsonSafe { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); + if (message.balances) { + obj.balances = message.balances.map(e => e ? Balance.toJSON(e) : undefined); + } else { + obj.balances = []; + } + if (message.supply) { + obj.supply = message.supply.map(e => e ? Coin.toJSON(e) : undefined); + } else { + obj.supply = []; + } + if (message.denomMetadata) { + obj.denomMetadata = message.denomMetadata.map(e => e ? Metadata.toJSON(e) : undefined); + } else { + obj.denomMetadata = []; + } + return obj; + }, + fromPartial(object: DeepPartial): GenesisState { + const message = createBaseGenesisState(); + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } + message.balances = object.balances?.map(e => Balance.fromPartial(e)) || []; + message.supply = object.supply?.map(e => Coin.fromPartial(e)) || []; + message.denomMetadata = object.denomMetadata?.map(e => Metadata.fromPartial(e)) || []; + return message; + }, + fromSDK(object: GenesisStateSDKType): GenesisState { + return { + params: object.params ? Params.fromSDK(object.params) : undefined, + balances: Array.isArray(object?.balances) ? object.balances.map((e: any) => Balance.fromSDK(e)) : [], + supply: Array.isArray(object?.supply) ? object.supply.map((e: any) => Coin.fromSDK(e)) : [], + denomMetadata: Array.isArray(object?.denom_metadata) ? object.denom_metadata.map((e: any) => Metadata.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): GenesisStateSDKType { + return { + params: isSet(object.params) ? Params.fromSDKJSON(object.params) : undefined, + balances: Array.isArray(object?.balances) ? object.balances.map((e: any) => Balance.fromSDKJSON(e)) : [], + supply: Array.isArray(object?.supply) ? object.supply.map((e: any) => Coin.fromSDKJSON(e)) : [], + denom_metadata: Array.isArray(object?.denom_metadata) ? object.denom_metadata.map((e: any) => Metadata.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: GenesisState): GenesisStateSDKType { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toSDK(message.params) : undefined); + if (message.balances) { + obj.balances = message.balances.map(e => e ? Balance.toSDK(e) : undefined); + } else { + obj.balances = []; + } + if (message.supply) { + obj.supply = message.supply.map(e => e ? Coin.toSDK(e) : undefined); + } else { + obj.supply = []; + } + if (message.denomMetadata) { + obj.denom_metadata = message.denomMetadata.map(e => e ? Metadata.toSDK(e) : undefined); + } else { + obj.denom_metadata = []; + } + return obj; + }, + fromAmino(object: GenesisStateAmino): GenesisState { + const message = createBaseGenesisState(); + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromAmino(object.params); + } + message.balances = object.balances?.map(e => Balance.fromAmino(e)) || []; + message.supply = object.supply?.map(e => Coin.fromAmino(e)) || []; + message.denomMetadata = object.denom_metadata?.map(e => Metadata.fromAmino(e)) || []; + return message; + }, + toAmino(message: GenesisState): GenesisStateAmino { + const obj: any = {}; + obj.params = message.params ? Params.toAmino(message.params) : undefined; + if (message.balances) { + obj.balances = message.balances.map(e => e ? Balance.toAmino(e) : undefined); + } else { + obj.balances = message.balances; + } + if (message.supply) { + obj.supply = message.supply.map(e => e ? Coin.toAmino(e) : undefined); + } else { + obj.supply = message.supply; + } + if (message.denomMetadata) { + obj.denom_metadata = message.denomMetadata.map(e => e ? Metadata.toAmino(e) : undefined); + } else { + obj.denom_metadata = message.denomMetadata; + } + return obj; + }, + fromAminoMsg(object: GenesisStateAminoMsg): GenesisState { + return GenesisState.fromAmino(object.value); + }, + toAminoMsg(message: GenesisState): GenesisStateAminoMsg { + return { + type: "cosmos-sdk/GenesisState", + value: GenesisState.toAmino(message) + }; + }, + fromProtoMsg(message: GenesisStateProtoMsg): GenesisState { + return GenesisState.decode(message.value); + }, + toProto(message: GenesisState): Uint8Array { + return GenesisState.encode(message).finish(); + }, + toProtoMsg(message: GenesisState): GenesisStateProtoMsg { + return { + typeUrl: "/cosmos.bank.v1beta1.GenesisState", + value: GenesisState.encode(message).finish() + }; + } +}; +function createBaseBalance(): Balance { + return { + address: "", + coins: [] + }; +} +export const Balance = { + typeUrl: "/cosmos.bank.v1beta1.Balance", + encode(message: Balance, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.address !== undefined) { + writer.uint32(10).string(message.address); + } + for (const v of message.coins) { + Coin.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Balance { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseBalance(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.string(); + break; + case 2: + message.coins.push(Coin.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Balance { + const obj = createBaseBalance(); + if (isSet(object.address)) obj.address = String(object.address); + if (Array.isArray(object?.coins)) obj.coins = object.coins.map((e: any) => Coin.fromJSON(e)); + return obj; + }, + toJSON(message: Balance): JsonSafe { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + if (message.coins) { + obj.coins = message.coins.map(e => e ? Coin.toJSON(e) : undefined); + } else { + obj.coins = []; + } + return obj; + }, + fromPartial(object: DeepPartial): Balance { + const message = createBaseBalance(); + message.address = object.address ?? ""; + message.coins = object.coins?.map(e => Coin.fromPartial(e)) || []; + return message; + }, + fromSDK(object: BalanceSDKType): Balance { + return { + address: object?.address, + coins: Array.isArray(object?.coins) ? object.coins.map((e: any) => Coin.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): BalanceSDKType { + return { + address: isSet(object.address) ? String(object.address) : "", + coins: Array.isArray(object?.coins) ? object.coins.map((e: any) => Coin.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: Balance): BalanceSDKType { + const obj: any = {}; + obj.address = message.address; + if (message.coins) { + obj.coins = message.coins.map(e => e ? Coin.toSDK(e) : undefined); + } else { + obj.coins = []; + } + return obj; + }, + fromAmino(object: BalanceAmino): Balance { + const message = createBaseBalance(); + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } + message.coins = object.coins?.map(e => Coin.fromAmino(e)) || []; + return message; + }, + toAmino(message: Balance): BalanceAmino { + const obj: any = {}; + obj.address = message.address === "" ? undefined : message.address; + if (message.coins) { + obj.coins = message.coins.map(e => e ? Coin.toAmino(e) : undefined); + } else { + obj.coins = message.coins; + } + return obj; + }, + fromAminoMsg(object: BalanceAminoMsg): Balance { + return Balance.fromAmino(object.value); + }, + toAminoMsg(message: Balance): BalanceAminoMsg { + return { + type: "cosmos-sdk/Balance", + value: Balance.toAmino(message) + }; + }, + fromProtoMsg(message: BalanceProtoMsg): Balance { + return Balance.decode(message.value); + }, + toProto(message: Balance): Uint8Array { + return Balance.encode(message).finish(); + }, + toProtoMsg(message: Balance): BalanceProtoMsg { + return { + typeUrl: "/cosmos.bank.v1beta1.Balance", + value: Balance.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/bank/v1beta1/query.lcd.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/bank/v1beta1/query.lcd.ts new file mode 100644 index 0000000000..b79ca342a1 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/bank/v1beta1/query.lcd.ts @@ -0,0 +1,119 @@ +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../base/query/v1beta1/pagination.js"; +import { Coin, CoinSDKType } from "../../base/v1beta1/coin.js"; +import { Params, ParamsSDKType, Metadata, MetadataSDKType } from "./bank.js"; +import { setPaginationParams } from "../../../helpers.js"; +import { LCDClient } from "@cosmology/lcd"; +import { QueryBalanceRequest, QueryBalanceRequestSDKType, QueryBalanceResponse, QueryBalanceResponseSDKType, QueryAllBalancesRequest, QueryAllBalancesRequestSDKType, QueryAllBalancesResponse, QueryAllBalancesResponseSDKType, QuerySpendableBalancesRequest, QuerySpendableBalancesRequestSDKType, QuerySpendableBalancesResponse, QuerySpendableBalancesResponseSDKType, QueryTotalSupplyRequest, QueryTotalSupplyRequestSDKType, QueryTotalSupplyResponse, QueryTotalSupplyResponseSDKType, QuerySupplyOfRequest, QuerySupplyOfRequestSDKType, QuerySupplyOfResponse, QuerySupplyOfResponseSDKType, QueryParamsRequest, QueryParamsRequestSDKType, QueryParamsResponse, QueryParamsResponseSDKType, QueryDenomMetadataRequest, QueryDenomMetadataRequestSDKType, QueryDenomMetadataResponse, QueryDenomMetadataResponseSDKType, QueryDenomsMetadataRequest, QueryDenomsMetadataRequestSDKType, QueryDenomsMetadataResponse, QueryDenomsMetadataResponseSDKType, QueryDenomOwnersRequest, QueryDenomOwnersRequestSDKType, QueryDenomOwnersResponse, QueryDenomOwnersResponseSDKType } from "./query.js"; +export class LCDQueryClient { + req: LCDClient; + constructor({ + requestClient + }: { + requestClient: LCDClient; + }) { + this.req = requestClient; + this.balance = this.balance.bind(this); + this.allBalances = this.allBalances.bind(this); + this.spendableBalances = this.spendableBalances.bind(this); + this.totalSupply = this.totalSupply.bind(this); + this.supplyOf = this.supplyOf.bind(this); + this.params = this.params.bind(this); + this.denomMetadata = this.denomMetadata.bind(this); + this.denomsMetadata = this.denomsMetadata.bind(this); + this.denomOwners = this.denomOwners.bind(this); + } + /* Balance queries the balance of a single coin for a single account. */ + async balance(params: QueryBalanceRequest): Promise { + const options: any = { + params: {} + }; + if (typeof params?.denom !== "undefined") { + options.params.denom = params.denom; + } + const endpoint = `cosmos/bank/v1beta1/balances/${params.address}/by_denom`; + return QueryBalanceResponse.fromSDKJSON(await this.req.get(endpoint, options)); + } + /* AllBalances queries the balance of all coins for a single account. */ + async allBalances(params: QueryAllBalancesRequest): Promise { + const options: any = { + params: {} + }; + if (typeof params?.pagination !== "undefined") { + setPaginationParams(options, params.pagination); + } + const endpoint = `cosmos/bank/v1beta1/balances/${params.address}`; + return QueryAllBalancesResponse.fromSDKJSON(await this.req.get(endpoint, options)); + } + /* SpendableBalances queries the spenable balance of all coins for a single + account. */ + async spendableBalances(params: QuerySpendableBalancesRequest): Promise { + const options: any = { + params: {} + }; + if (typeof params?.pagination !== "undefined") { + setPaginationParams(options, params.pagination); + } + const endpoint = `cosmos/bank/v1beta1/spendable_balances/${params.address}`; + return QuerySpendableBalancesResponse.fromSDKJSON(await this.req.get(endpoint, options)); + } + /* TotalSupply queries the total supply of all coins. */ + async totalSupply(params: QueryTotalSupplyRequest = { + pagination: PageRequest.fromPartial({}) + }): Promise { + const options: any = { + params: {} + }; + if (typeof params?.pagination !== "undefined") { + setPaginationParams(options, params.pagination); + } + const endpoint = `cosmos/bank/v1beta1/supply`; + return QueryTotalSupplyResponse.fromSDKJSON(await this.req.get(endpoint, options)); + } + /* SupplyOf queries the supply of a single coin. */ + async supplyOf(params: QuerySupplyOfRequest): Promise { + const options: any = { + params: {} + }; + if (typeof params?.denom !== "undefined") { + options.params.denom = params.denom; + } + const endpoint = `cosmos/bank/v1beta1/supply/by_denom`; + return QuerySupplyOfResponse.fromSDKJSON(await this.req.get(endpoint, options)); + } + /* Params queries the parameters of x/bank module. */ + async params(_params: QueryParamsRequest = {}): Promise { + const endpoint = `cosmos/bank/v1beta1/params`; + return QueryParamsResponse.fromSDKJSON(await this.req.get(endpoint)); + } + /* DenomsMetadata queries the client metadata of a given coin denomination. */ + async denomMetadata(params: QueryDenomMetadataRequest): Promise { + const endpoint = `cosmos/bank/v1beta1/denoms_metadata/${params.denom}`; + return QueryDenomMetadataResponse.fromSDKJSON(await this.req.get(endpoint)); + } + /* DenomsMetadata queries the client metadata for all registered coin + denominations. */ + async denomsMetadata(params: QueryDenomsMetadataRequest = { + pagination: PageRequest.fromPartial({}) + }): Promise { + const options: any = { + params: {} + }; + if (typeof params?.pagination !== "undefined") { + setPaginationParams(options, params.pagination); + } + const endpoint = `cosmos/bank/v1beta1/denoms_metadata`; + return QueryDenomsMetadataResponse.fromSDKJSON(await this.req.get(endpoint, options)); + } + /* DenomOwners queries for all account addresses that own a particular token + denomination. */ + async denomOwners(params: QueryDenomOwnersRequest): Promise { + const options: any = { + params: {} + }; + if (typeof params?.pagination !== "undefined") { + setPaginationParams(options, params.pagination); + } + const endpoint = `cosmos/bank/v1beta1/denom_owners/${params.denom}`; + return QueryDenomOwnersResponse.fromSDKJSON(await this.req.get(endpoint, options)); + } +} \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/bank/v1beta1/query.rpc.Query.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/bank/v1beta1/query.rpc.Query.ts new file mode 100644 index 0000000000..a89321c1bb --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/bank/v1beta1/query.rpc.Query.ts @@ -0,0 +1,280 @@ +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../base/query/v1beta1/pagination.js"; +import { Coin, CoinSDKType } from "../../base/v1beta1/coin.js"; +import { Params, ParamsSDKType, Metadata, MetadataSDKType } from "./bank.js"; +import { Rpc } from "../../../helpers.js"; +import { BinaryReader } from "../../../binary.js"; +import { QueryClient, createProtobufRpcClient, ProtobufRpcClient } from "@cosmjs/stargate"; +import { ReactQueryParams } from "../../../react-query.js"; +import { useQuery } from "@tanstack/react-query"; +import { QueryBalanceRequest, QueryBalanceRequestSDKType, QueryBalanceResponse, QueryBalanceResponseSDKType, QueryAllBalancesRequest, QueryAllBalancesRequestSDKType, QueryAllBalancesResponse, QueryAllBalancesResponseSDKType, QuerySpendableBalancesRequest, QuerySpendableBalancesRequestSDKType, QuerySpendableBalancesResponse, QuerySpendableBalancesResponseSDKType, QueryTotalSupplyRequest, QueryTotalSupplyRequestSDKType, QueryTotalSupplyResponse, QueryTotalSupplyResponseSDKType, QuerySupplyOfRequest, QuerySupplyOfRequestSDKType, QuerySupplyOfResponse, QuerySupplyOfResponseSDKType, QueryParamsRequest, QueryParamsRequestSDKType, QueryParamsResponse, QueryParamsResponseSDKType, QueryDenomMetadataRequest, QueryDenomMetadataRequestSDKType, QueryDenomMetadataResponse, QueryDenomMetadataResponseSDKType, QueryDenomsMetadataRequest, QueryDenomsMetadataRequestSDKType, QueryDenomsMetadataResponse, QueryDenomsMetadataResponseSDKType, QueryDenomOwnersRequest, QueryDenomOwnersRequestSDKType, QueryDenomOwnersResponse, QueryDenomOwnersResponseSDKType } from "./query.js"; +/** Query defines the gRPC querier service. */ +export interface Query { + /** Balance queries the balance of a single coin for a single account. */ + balance(request: QueryBalanceRequest): Promise; + /** AllBalances queries the balance of all coins for a single account. */ + allBalances(request: QueryAllBalancesRequest): Promise; + /** + * SpendableBalances queries the spenable balance of all coins for a single + * account. + */ + spendableBalances(request: QuerySpendableBalancesRequest): Promise; + /** TotalSupply queries the total supply of all coins. */ + totalSupply(request?: QueryTotalSupplyRequest): Promise; + /** SupplyOf queries the supply of a single coin. */ + supplyOf(request: QuerySupplyOfRequest): Promise; + /** Params queries the parameters of x/bank module. */ + params(request?: QueryParamsRequest): Promise; + /** DenomsMetadata queries the client metadata of a given coin denomination. */ + denomMetadata(request: QueryDenomMetadataRequest): Promise; + /** + * DenomsMetadata queries the client metadata for all registered coin + * denominations. + */ + denomsMetadata(request?: QueryDenomsMetadataRequest): Promise; + /** + * DenomOwners queries for all account addresses that own a particular token + * denomination. + */ + denomOwners(request: QueryDenomOwnersRequest): Promise; +} +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + this.balance = this.balance.bind(this); + this.allBalances = this.allBalances.bind(this); + this.spendableBalances = this.spendableBalances.bind(this); + this.totalSupply = this.totalSupply.bind(this); + this.supplyOf = this.supplyOf.bind(this); + this.params = this.params.bind(this); + this.denomMetadata = this.denomMetadata.bind(this); + this.denomsMetadata = this.denomsMetadata.bind(this); + this.denomOwners = this.denomOwners.bind(this); + } + balance(request: QueryBalanceRequest): Promise { + const data = QueryBalanceRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.bank.v1beta1.Query", "Balance", data); + return promise.then(data => QueryBalanceResponse.decode(new BinaryReader(data))); + } + allBalances(request: QueryAllBalancesRequest): Promise { + const data = QueryAllBalancesRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.bank.v1beta1.Query", "AllBalances", data); + return promise.then(data => QueryAllBalancesResponse.decode(new BinaryReader(data))); + } + spendableBalances(request: QuerySpendableBalancesRequest): Promise { + const data = QuerySpendableBalancesRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.bank.v1beta1.Query", "SpendableBalances", data); + return promise.then(data => QuerySpendableBalancesResponse.decode(new BinaryReader(data))); + } + totalSupply(request: QueryTotalSupplyRequest = { + pagination: PageRequest.fromPartial({}) + }): Promise { + const data = QueryTotalSupplyRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.bank.v1beta1.Query", "TotalSupply", data); + return promise.then(data => QueryTotalSupplyResponse.decode(new BinaryReader(data))); + } + supplyOf(request: QuerySupplyOfRequest): Promise { + const data = QuerySupplyOfRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.bank.v1beta1.Query", "SupplyOf", data); + return promise.then(data => QuerySupplyOfResponse.decode(new BinaryReader(data))); + } + params(request: QueryParamsRequest = {}): Promise { + const data = QueryParamsRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.bank.v1beta1.Query", "Params", data); + return promise.then(data => QueryParamsResponse.decode(new BinaryReader(data))); + } + denomMetadata(request: QueryDenomMetadataRequest): Promise { + const data = QueryDenomMetadataRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.bank.v1beta1.Query", "DenomMetadata", data); + return promise.then(data => QueryDenomMetadataResponse.decode(new BinaryReader(data))); + } + denomsMetadata(request: QueryDenomsMetadataRequest = { + pagination: PageRequest.fromPartial({}) + }): Promise { + const data = QueryDenomsMetadataRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.bank.v1beta1.Query", "DenomsMetadata", data); + return promise.then(data => QueryDenomsMetadataResponse.decode(new BinaryReader(data))); + } + denomOwners(request: QueryDenomOwnersRequest): Promise { + const data = QueryDenomOwnersRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.bank.v1beta1.Query", "DenomOwners", data); + return promise.then(data => QueryDenomOwnersResponse.decode(new BinaryReader(data))); + } +} +export const createRpcQueryExtension = (base: QueryClient) => { + const rpc = createProtobufRpcClient(base); + const queryService = new QueryClientImpl(rpc); + return { + balance(request: QueryBalanceRequest): Promise { + return queryService.balance(request); + }, + allBalances(request: QueryAllBalancesRequest): Promise { + return queryService.allBalances(request); + }, + spendableBalances(request: QuerySpendableBalancesRequest): Promise { + return queryService.spendableBalances(request); + }, + totalSupply(request?: QueryTotalSupplyRequest): Promise { + return queryService.totalSupply(request); + }, + supplyOf(request: QuerySupplyOfRequest): Promise { + return queryService.supplyOf(request); + }, + params(request?: QueryParamsRequest): Promise { + return queryService.params(request); + }, + denomMetadata(request: QueryDenomMetadataRequest): Promise { + return queryService.denomMetadata(request); + }, + denomsMetadata(request?: QueryDenomsMetadataRequest): Promise { + return queryService.denomsMetadata(request); + }, + denomOwners(request: QueryDenomOwnersRequest): Promise { + return queryService.denomOwners(request); + } + }; +}; +export interface UseBalanceQuery extends ReactQueryParams { + request: QueryBalanceRequest; +} +export interface UseAllBalancesQuery extends ReactQueryParams { + request: QueryAllBalancesRequest; +} +export interface UseSpendableBalancesQuery extends ReactQueryParams { + request: QuerySpendableBalancesRequest; +} +export interface UseTotalSupplyQuery extends ReactQueryParams { + request?: QueryTotalSupplyRequest; +} +export interface UseSupplyOfQuery extends ReactQueryParams { + request: QuerySupplyOfRequest; +} +export interface UseParamsQuery extends ReactQueryParams { + request?: QueryParamsRequest; +} +export interface UseDenomMetadataQuery extends ReactQueryParams { + request: QueryDenomMetadataRequest; +} +export interface UseDenomsMetadataQuery extends ReactQueryParams { + request?: QueryDenomsMetadataRequest; +} +export interface UseDenomOwnersQuery extends ReactQueryParams { + request: QueryDenomOwnersRequest; +} +const _queryClients: WeakMap = new WeakMap(); +const getQueryService = (rpc: ProtobufRpcClient | undefined): QueryClientImpl | undefined => { + if (!rpc) return; + if (_queryClients.has(rpc)) { + return _queryClients.get(rpc); + } + const queryService = new QueryClientImpl(rpc); + _queryClients.set(rpc, queryService); + return queryService; +}; +export const createRpcQueryHooks = (rpc: ProtobufRpcClient | undefined) => { + const queryService = getQueryService(rpc); + const useBalance = ({ + request, + options + }: UseBalanceQuery) => { + return useQuery(["balanceQuery", request], () => { + if (!queryService) throw new Error("Query Service not initialized"); + return queryService.balance(request); + }, options); + }; + const useAllBalances = ({ + request, + options + }: UseAllBalancesQuery) => { + return useQuery(["allBalancesQuery", request], () => { + if (!queryService) throw new Error("Query Service not initialized"); + return queryService.allBalances(request); + }, options); + }; + const useSpendableBalances = ({ + request, + options + }: UseSpendableBalancesQuery) => { + return useQuery(["spendableBalancesQuery", request], () => { + if (!queryService) throw new Error("Query Service not initialized"); + return queryService.spendableBalances(request); + }, options); + }; + const useTotalSupply = ({ + request, + options + }: UseTotalSupplyQuery) => { + return useQuery(["totalSupplyQuery", request], () => { + if (!queryService) throw new Error("Query Service not initialized"); + return queryService.totalSupply(request); + }, options); + }; + const useSupplyOf = ({ + request, + options + }: UseSupplyOfQuery) => { + return useQuery(["supplyOfQuery", request], () => { + if (!queryService) throw new Error("Query Service not initialized"); + return queryService.supplyOf(request); + }, options); + }; + const useParams = ({ + request, + options + }: UseParamsQuery) => { + return useQuery(["paramsQuery", request], () => { + if (!queryService) throw new Error("Query Service not initialized"); + return queryService.params(request); + }, options); + }; + const useDenomMetadata = ({ + request, + options + }: UseDenomMetadataQuery) => { + return useQuery(["denomMetadataQuery", request], () => { + if (!queryService) throw new Error("Query Service not initialized"); + return queryService.denomMetadata(request); + }, options); + }; + const useDenomsMetadata = ({ + request, + options + }: UseDenomsMetadataQuery) => { + return useQuery(["denomsMetadataQuery", request], () => { + if (!queryService) throw new Error("Query Service not initialized"); + return queryService.denomsMetadata(request); + }, options); + }; + const useDenomOwners = ({ + request, + options + }: UseDenomOwnersQuery) => { + return useQuery(["denomOwnersQuery", request], () => { + if (!queryService) throw new Error("Query Service not initialized"); + return queryService.denomOwners(request); + }, options); + }; + return { + /** Balance queries the balance of a single coin for a single account. */useBalance, + /** AllBalances queries the balance of all coins for a single account. */useAllBalances, + /** + * SpendableBalances queries the spenable balance of all coins for a single + * account. + */ + useSpendableBalances, + /** TotalSupply queries the total supply of all coins. */useTotalSupply, + /** SupplyOf queries the supply of a single coin. */useSupplyOf, + /** Params queries the parameters of x/bank module. */useParams, + /** DenomsMetadata queries the client metadata of a given coin denomination. */useDenomMetadata, + /** + * DenomsMetadata queries the client metadata for all registered coin + * denominations. + */ + useDenomsMetadata, + /** + * DenomOwners queries for all account addresses that own a particular token + * denomination. + */ + useDenomOwners + }; +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/bank/v1beta1/query.rpc.func.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/bank/v1beta1/query.rpc.func.ts new file mode 100644 index 0000000000..5f2b9c6ae4 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/bank/v1beta1/query.rpc.func.ts @@ -0,0 +1,102 @@ +import { RpcResolver, buildQuery } from "../../../helper-func-types"; +import { buildUseQuery } from "../../../react-query"; +import { QueryBalanceRequest, QueryBalanceResponse, QueryAllBalancesRequest, QueryAllBalancesResponse, QuerySpendableBalancesRequest, QuerySpendableBalancesResponse, QueryTotalSupplyRequest, QueryTotalSupplyResponse, QuerySupplyOfRequest, QuerySupplyOfResponse, QueryParamsRequest, QueryParamsResponse, QueryDenomMetadataRequest, QueryDenomMetadataResponse, QueryDenomsMetadataRequest, QueryDenomsMetadataResponse, QueryDenomOwnersRequest, QueryDenomOwnersResponse } from "./query"; +export const createGetBalance = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryBalanceRequest.encode, + decode: QueryBalanceResponse.decode, + service: "cosmos.bank.v1beta1.Query", + method: "Balance", + getRpcInstance: getRpcInstance +}); +export const useGetBalance = buildUseQuery({ + builderQueryFn: createGetBalance, + queryKeyPrefix: "BalanceQuery" +}); +export const createGetAllBalances = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryAllBalancesRequest.encode, + decode: QueryAllBalancesResponse.decode, + service: "cosmos.bank.v1beta1.Query", + method: "AllBalances", + getRpcInstance: getRpcInstance +}); +export const useGetAllBalances = buildUseQuery({ + builderQueryFn: createGetAllBalances, + queryKeyPrefix: "AllBalancesQuery" +}); +export const createGetSpendableBalances = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QuerySpendableBalancesRequest.encode, + decode: QuerySpendableBalancesResponse.decode, + service: "cosmos.bank.v1beta1.Query", + method: "SpendableBalances", + getRpcInstance: getRpcInstance +}); +export const useGetSpendableBalances = buildUseQuery({ + builderQueryFn: createGetSpendableBalances, + queryKeyPrefix: "SpendableBalancesQuery" +}); +export const createGetTotalSupply = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryTotalSupplyRequest.encode, + decode: QueryTotalSupplyResponse.decode, + service: "cosmos.bank.v1beta1.Query", + method: "TotalSupply", + getRpcInstance: getRpcInstance +}); +export const useGetTotalSupply = buildUseQuery({ + builderQueryFn: createGetTotalSupply, + queryKeyPrefix: "TotalSupplyQuery" +}); +export const createGetSupplyOf = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QuerySupplyOfRequest.encode, + decode: QuerySupplyOfResponse.decode, + service: "cosmos.bank.v1beta1.Query", + method: "SupplyOf", + getRpcInstance: getRpcInstance +}); +export const useGetSupplyOf = buildUseQuery({ + builderQueryFn: createGetSupplyOf, + queryKeyPrefix: "SupplyOfQuery" +}); +export const createGetParams = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryParamsRequest.encode, + decode: QueryParamsResponse.decode, + service: "cosmos.bank.v1beta1.Query", + method: "Params", + getRpcInstance: getRpcInstance +}); +export const useGetParams = buildUseQuery({ + builderQueryFn: createGetParams, + queryKeyPrefix: "ParamsQuery" +}); +export const createGetDenomMetadata = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryDenomMetadataRequest.encode, + decode: QueryDenomMetadataResponse.decode, + service: "cosmos.bank.v1beta1.Query", + method: "DenomMetadata", + getRpcInstance: getRpcInstance +}); +export const useGetDenomMetadata = buildUseQuery({ + builderQueryFn: createGetDenomMetadata, + queryKeyPrefix: "DenomMetadataQuery" +}); +export const createGetDenomsMetadata = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryDenomsMetadataRequest.encode, + decode: QueryDenomsMetadataResponse.decode, + service: "cosmos.bank.v1beta1.Query", + method: "DenomsMetadata", + getRpcInstance: getRpcInstance +}); +export const useGetDenomsMetadata = buildUseQuery({ + builderQueryFn: createGetDenomsMetadata, + queryKeyPrefix: "DenomsMetadataQuery" +}); +export const createGetDenomOwners = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryDenomOwnersRequest.encode, + decode: QueryDenomOwnersResponse.decode, + service: "cosmos.bank.v1beta1.Query", + method: "DenomOwners", + getRpcInstance: getRpcInstance +}); +export const useGetDenomOwners = buildUseQuery({ + builderQueryFn: createGetDenomOwners, + queryKeyPrefix: "DenomOwnersQuery" +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/bank/v1beta1/query.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/bank/v1beta1/query.ts new file mode 100644 index 0000000000..5245f7ff3a --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/bank/v1beta1/query.ts @@ -0,0 +1,2359 @@ +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../base/query/v1beta1/pagination.js"; +import { Coin, CoinSDKType } from "../../base/v1beta1/coin.js"; +import { Params, ParamsSDKType, Metadata, MetadataSDKType } from "./bank.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "cosmos.bank.v1beta1"; +/** QueryBalanceRequest is the request type for the Query/Balance RPC method. */ +export interface QueryBalanceRequest { + /** address is the address to query balances for. */ + address: string; + /** denom is the coin denom to query balances for. */ + denom: string; +} +export interface QueryBalanceRequestProtoMsg { + typeUrl: "/cosmos.bank.v1beta1.QueryBalanceRequest"; + value: Uint8Array; +} +/** QueryBalanceRequest is the request type for the Query/Balance RPC method. */ +export interface QueryBalanceRequestSDKType { + address: string; + denom: string; +} +/** QueryBalanceResponse is the response type for the Query/Balance RPC method. */ +export interface QueryBalanceResponse { + /** balance is the balance of the coin. */ + balance?: Coin; +} +export interface QueryBalanceResponseProtoMsg { + typeUrl: "/cosmos.bank.v1beta1.QueryBalanceResponse"; + value: Uint8Array; +} +/** QueryBalanceResponse is the response type for the Query/Balance RPC method. */ +export interface QueryBalanceResponseSDKType { + balance?: CoinSDKType; +} +/** QueryBalanceRequest is the request type for the Query/AllBalances RPC method. */ +export interface QueryAllBalancesRequest { + /** address is the address to query balances for. */ + address: string; + /** pagination defines an optional pagination for the request. */ + pagination?: PageRequest; +} +export interface QueryAllBalancesRequestProtoMsg { + typeUrl: "/cosmos.bank.v1beta1.QueryAllBalancesRequest"; + value: Uint8Array; +} +/** QueryBalanceRequest is the request type for the Query/AllBalances RPC method. */ +export interface QueryAllBalancesRequestSDKType { + address: string; + pagination?: PageRequestSDKType; +} +/** + * QueryAllBalancesResponse is the response type for the Query/AllBalances RPC + * method. + */ +export interface QueryAllBalancesResponse { + /** balances is the balances of all the coins. */ + balances: Coin[]; + /** pagination defines the pagination in the response. */ + pagination?: PageResponse; +} +export interface QueryAllBalancesResponseProtoMsg { + typeUrl: "/cosmos.bank.v1beta1.QueryAllBalancesResponse"; + value: Uint8Array; +} +/** + * QueryAllBalancesResponse is the response type for the Query/AllBalances RPC + * method. + */ +export interface QueryAllBalancesResponseSDKType { + balances: CoinSDKType[]; + pagination?: PageResponseSDKType; +} +/** + * QuerySpendableBalancesRequest defines the gRPC request structure for querying + * an account's spendable balances. + */ +export interface QuerySpendableBalancesRequest { + /** address is the address to query spendable balances for. */ + address: string; + /** pagination defines an optional pagination for the request. */ + pagination?: PageRequest; +} +export interface QuerySpendableBalancesRequestProtoMsg { + typeUrl: "/cosmos.bank.v1beta1.QuerySpendableBalancesRequest"; + value: Uint8Array; +} +/** + * QuerySpendableBalancesRequest defines the gRPC request structure for querying + * an account's spendable balances. + */ +export interface QuerySpendableBalancesRequestSDKType { + address: string; + pagination?: PageRequestSDKType; +} +/** + * QuerySpendableBalancesResponse defines the gRPC response structure for querying + * an account's spendable balances. + */ +export interface QuerySpendableBalancesResponse { + /** balances is the spendable balances of all the coins. */ + balances: Coin[]; + /** pagination defines the pagination in the response. */ + pagination?: PageResponse; +} +export interface QuerySpendableBalancesResponseProtoMsg { + typeUrl: "/cosmos.bank.v1beta1.QuerySpendableBalancesResponse"; + value: Uint8Array; +} +/** + * QuerySpendableBalancesResponse defines the gRPC response structure for querying + * an account's spendable balances. + */ +export interface QuerySpendableBalancesResponseSDKType { + balances: CoinSDKType[]; + pagination?: PageResponseSDKType; +} +/** + * QueryTotalSupplyRequest is the request type for the Query/TotalSupply RPC + * method. + */ +export interface QueryTotalSupplyRequest { + /** + * pagination defines an optional pagination for the request. + * + * Since: cosmos-sdk 0.43 + */ + pagination?: PageRequest; +} +export interface QueryTotalSupplyRequestProtoMsg { + typeUrl: "/cosmos.bank.v1beta1.QueryTotalSupplyRequest"; + value: Uint8Array; +} +/** + * QueryTotalSupplyRequest is the request type for the Query/TotalSupply RPC + * method. + */ +export interface QueryTotalSupplyRequestSDKType { + pagination?: PageRequestSDKType; +} +/** + * QueryTotalSupplyResponse is the response type for the Query/TotalSupply RPC + * method + */ +export interface QueryTotalSupplyResponse { + /** supply is the supply of the coins */ + supply: Coin[]; + /** + * pagination defines the pagination in the response. + * + * Since: cosmos-sdk 0.43 + */ + pagination?: PageResponse; +} +export interface QueryTotalSupplyResponseProtoMsg { + typeUrl: "/cosmos.bank.v1beta1.QueryTotalSupplyResponse"; + value: Uint8Array; +} +/** + * QueryTotalSupplyResponse is the response type for the Query/TotalSupply RPC + * method + */ +export interface QueryTotalSupplyResponseSDKType { + supply: CoinSDKType[]; + pagination?: PageResponseSDKType; +} +/** QuerySupplyOfRequest is the request type for the Query/SupplyOf RPC method. */ +export interface QuerySupplyOfRequest { + /** denom is the coin denom to query balances for. */ + denom: string; +} +export interface QuerySupplyOfRequestProtoMsg { + typeUrl: "/cosmos.bank.v1beta1.QuerySupplyOfRequest"; + value: Uint8Array; +} +/** QuerySupplyOfRequest is the request type for the Query/SupplyOf RPC method. */ +export interface QuerySupplyOfRequestSDKType { + denom: string; +} +/** QuerySupplyOfResponse is the response type for the Query/SupplyOf RPC method. */ +export interface QuerySupplyOfResponse { + /** amount is the supply of the coin. */ + amount: Coin; +} +export interface QuerySupplyOfResponseProtoMsg { + typeUrl: "/cosmos.bank.v1beta1.QuerySupplyOfResponse"; + value: Uint8Array; +} +/** QuerySupplyOfResponse is the response type for the Query/SupplyOf RPC method. */ +export interface QuerySupplyOfResponseSDKType { + amount: CoinSDKType; +} +/** QueryParamsRequest defines the request type for querying x/bank parameters. */ +export interface QueryParamsRequest {} +export interface QueryParamsRequestProtoMsg { + typeUrl: "/cosmos.bank.v1beta1.QueryParamsRequest"; + value: Uint8Array; +} +/** QueryParamsRequest defines the request type for querying x/bank parameters. */ +export interface QueryParamsRequestSDKType {} +/** QueryParamsResponse defines the response type for querying x/bank parameters. */ +export interface QueryParamsResponse { + params: Params; +} +export interface QueryParamsResponseProtoMsg { + typeUrl: "/cosmos.bank.v1beta1.QueryParamsResponse"; + value: Uint8Array; +} +/** QueryParamsResponse defines the response type for querying x/bank parameters. */ +export interface QueryParamsResponseSDKType { + params: ParamsSDKType; +} +/** QueryDenomsMetadataRequest is the request type for the Query/DenomsMetadata RPC method. */ +export interface QueryDenomsMetadataRequest { + /** pagination defines an optional pagination for the request. */ + pagination?: PageRequest; +} +export interface QueryDenomsMetadataRequestProtoMsg { + typeUrl: "/cosmos.bank.v1beta1.QueryDenomsMetadataRequest"; + value: Uint8Array; +} +/** QueryDenomsMetadataRequest is the request type for the Query/DenomsMetadata RPC method. */ +export interface QueryDenomsMetadataRequestSDKType { + pagination?: PageRequestSDKType; +} +/** + * QueryDenomsMetadataResponse is the response type for the Query/DenomsMetadata RPC + * method. + */ +export interface QueryDenomsMetadataResponse { + /** metadata provides the client information for all the registered tokens. */ + metadatas: Metadata[]; + /** pagination defines the pagination in the response. */ + pagination?: PageResponse; +} +export interface QueryDenomsMetadataResponseProtoMsg { + typeUrl: "/cosmos.bank.v1beta1.QueryDenomsMetadataResponse"; + value: Uint8Array; +} +/** + * QueryDenomsMetadataResponse is the response type for the Query/DenomsMetadata RPC + * method. + */ +export interface QueryDenomsMetadataResponseSDKType { + metadatas: MetadataSDKType[]; + pagination?: PageResponseSDKType; +} +/** QueryDenomMetadataRequest is the request type for the Query/DenomMetadata RPC method. */ +export interface QueryDenomMetadataRequest { + /** denom is the coin denom to query the metadata for. */ + denom: string; +} +export interface QueryDenomMetadataRequestProtoMsg { + typeUrl: "/cosmos.bank.v1beta1.QueryDenomMetadataRequest"; + value: Uint8Array; +} +/** QueryDenomMetadataRequest is the request type for the Query/DenomMetadata RPC method. */ +export interface QueryDenomMetadataRequestSDKType { + denom: string; +} +/** + * QueryDenomMetadataResponse is the response type for the Query/DenomMetadata RPC + * method. + */ +export interface QueryDenomMetadataResponse { + /** metadata describes and provides all the client information for the requested token. */ + metadata: Metadata; +} +export interface QueryDenomMetadataResponseProtoMsg { + typeUrl: "/cosmos.bank.v1beta1.QueryDenomMetadataResponse"; + value: Uint8Array; +} +/** + * QueryDenomMetadataResponse is the response type for the Query/DenomMetadata RPC + * method. + */ +export interface QueryDenomMetadataResponseSDKType { + metadata: MetadataSDKType; +} +/** + * QueryDenomOwnersRequest defines the request type for the DenomOwners RPC query, + * which queries for a paginated set of all account holders of a particular + * denomination. + */ +export interface QueryDenomOwnersRequest { + /** denom defines the coin denomination to query all account holders for. */ + denom: string; + /** pagination defines an optional pagination for the request. */ + pagination?: PageRequest; +} +export interface QueryDenomOwnersRequestProtoMsg { + typeUrl: "/cosmos.bank.v1beta1.QueryDenomOwnersRequest"; + value: Uint8Array; +} +/** + * QueryDenomOwnersRequest defines the request type for the DenomOwners RPC query, + * which queries for a paginated set of all account holders of a particular + * denomination. + */ +export interface QueryDenomOwnersRequestSDKType { + denom: string; + pagination?: PageRequestSDKType; +} +/** + * DenomOwner defines structure representing an account that owns or holds a + * particular denominated token. It contains the account address and account + * balance of the denominated token. + */ +export interface DenomOwner { + /** address defines the address that owns a particular denomination. */ + address: string; + /** balance is the balance of the denominated coin for an account. */ + balance: Coin; +} +export interface DenomOwnerProtoMsg { + typeUrl: "/cosmos.bank.v1beta1.DenomOwner"; + value: Uint8Array; +} +/** + * DenomOwner defines structure representing an account that owns or holds a + * particular denominated token. It contains the account address and account + * balance of the denominated token. + */ +export interface DenomOwnerSDKType { + address: string; + balance: CoinSDKType; +} +/** QueryDenomOwnersResponse defines the RPC response of a DenomOwners RPC query. */ +export interface QueryDenomOwnersResponse { + denomOwners: DenomOwner[]; + /** pagination defines the pagination in the response. */ + pagination?: PageResponse; +} +export interface QueryDenomOwnersResponseProtoMsg { + typeUrl: "/cosmos.bank.v1beta1.QueryDenomOwnersResponse"; + value: Uint8Array; +} +/** QueryDenomOwnersResponse defines the RPC response of a DenomOwners RPC query. */ +export interface QueryDenomOwnersResponseSDKType { + denom_owners: DenomOwnerSDKType[]; + pagination?: PageResponseSDKType; +} +function createBaseQueryBalanceRequest(): QueryBalanceRequest { + return { + address: "", + denom: "" + }; +} +export const QueryBalanceRequest = { + typeUrl: "/cosmos.bank.v1beta1.QueryBalanceRequest", + encode(message: QueryBalanceRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.address !== undefined) { + writer.uint32(10).string(message.address); + } + if (message.denom !== undefined) { + writer.uint32(18).string(message.denom); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryBalanceRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryBalanceRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.string(); + break; + case 2: + message.denom = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryBalanceRequest { + const obj = createBaseQueryBalanceRequest(); + if (isSet(object.address)) obj.address = String(object.address); + if (isSet(object.denom)) obj.denom = String(object.denom); + return obj; + }, + toJSON(message: QueryBalanceRequest): JsonSafe { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + message.denom !== undefined && (obj.denom = message.denom); + return obj; + }, + fromPartial(object: DeepPartial): QueryBalanceRequest { + const message = createBaseQueryBalanceRequest(); + message.address = object.address ?? ""; + message.denom = object.denom ?? ""; + return message; + }, + fromSDK(object: QueryBalanceRequestSDKType): QueryBalanceRequest { + return { + address: object?.address, + denom: object?.denom + }; + }, + fromSDKJSON(object: any): QueryBalanceRequestSDKType { + return { + address: isSet(object.address) ? String(object.address) : "", + denom: isSet(object.denom) ? String(object.denom) : "" + }; + }, + toSDK(message: QueryBalanceRequest): QueryBalanceRequestSDKType { + const obj: any = {}; + obj.address = message.address; + obj.denom = message.denom; + return obj; + }, + fromAmino(object: QueryBalanceRequestAmino): QueryBalanceRequest { + const message = createBaseQueryBalanceRequest(); + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } + if (object.denom !== undefined && object.denom !== null) { + message.denom = object.denom; + } + return message; + }, + toAmino(message: QueryBalanceRequest): QueryBalanceRequestAmino { + const obj: any = {}; + obj.address = message.address === "" ? undefined : message.address; + obj.denom = message.denom === "" ? undefined : message.denom; + return obj; + }, + fromAminoMsg(object: QueryBalanceRequestAminoMsg): QueryBalanceRequest { + return QueryBalanceRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryBalanceRequest): QueryBalanceRequestAminoMsg { + return { + type: "cosmos-sdk/QueryBalanceRequest", + value: QueryBalanceRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryBalanceRequestProtoMsg): QueryBalanceRequest { + return QueryBalanceRequest.decode(message.value); + }, + toProto(message: QueryBalanceRequest): Uint8Array { + return QueryBalanceRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryBalanceRequest): QueryBalanceRequestProtoMsg { + return { + typeUrl: "/cosmos.bank.v1beta1.QueryBalanceRequest", + value: QueryBalanceRequest.encode(message).finish() + }; + } +}; +function createBaseQueryBalanceResponse(): QueryBalanceResponse { + return { + balance: undefined + }; +} +export const QueryBalanceResponse = { + typeUrl: "/cosmos.bank.v1beta1.QueryBalanceResponse", + encode(message: QueryBalanceResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.balance !== undefined) { + Coin.encode(message.balance, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryBalanceResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryBalanceResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.balance = Coin.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryBalanceResponse { + const obj = createBaseQueryBalanceResponse(); + if (isSet(object.balance)) obj.balance = Coin.fromJSON(object.balance); + return obj; + }, + toJSON(message: QueryBalanceResponse): JsonSafe { + const obj: any = {}; + message.balance !== undefined && (obj.balance = message.balance ? Coin.toJSON(message.balance) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryBalanceResponse { + const message = createBaseQueryBalanceResponse(); + if (object.balance !== undefined && object.balance !== null) { + message.balance = Coin.fromPartial(object.balance); + } + return message; + }, + fromSDK(object: QueryBalanceResponseSDKType): QueryBalanceResponse { + return { + balance: object.balance ? Coin.fromSDK(object.balance) : undefined + }; + }, + fromSDKJSON(object: any): QueryBalanceResponseSDKType { + return { + balance: isSet(object.balance) ? Coin.fromSDKJSON(object.balance) : undefined + }; + }, + toSDK(message: QueryBalanceResponse): QueryBalanceResponseSDKType { + const obj: any = {}; + message.balance !== undefined && (obj.balance = message.balance ? Coin.toSDK(message.balance) : undefined); + return obj; + }, + fromAmino(object: QueryBalanceResponseAmino): QueryBalanceResponse { + const message = createBaseQueryBalanceResponse(); + if (object.balance !== undefined && object.balance !== null) { + message.balance = Coin.fromAmino(object.balance); + } + return message; + }, + toAmino(message: QueryBalanceResponse): QueryBalanceResponseAmino { + const obj: any = {}; + obj.balance = message.balance ? Coin.toAmino(message.balance) : undefined; + return obj; + }, + fromAminoMsg(object: QueryBalanceResponseAminoMsg): QueryBalanceResponse { + return QueryBalanceResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryBalanceResponse): QueryBalanceResponseAminoMsg { + return { + type: "cosmos-sdk/QueryBalanceResponse", + value: QueryBalanceResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryBalanceResponseProtoMsg): QueryBalanceResponse { + return QueryBalanceResponse.decode(message.value); + }, + toProto(message: QueryBalanceResponse): Uint8Array { + return QueryBalanceResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryBalanceResponse): QueryBalanceResponseProtoMsg { + return { + typeUrl: "/cosmos.bank.v1beta1.QueryBalanceResponse", + value: QueryBalanceResponse.encode(message).finish() + }; + } +}; +function createBaseQueryAllBalancesRequest(): QueryAllBalancesRequest { + return { + address: "", + pagination: undefined + }; +} +export const QueryAllBalancesRequest = { + typeUrl: "/cosmos.bank.v1beta1.QueryAllBalancesRequest", + encode(message: QueryAllBalancesRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.address !== undefined) { + writer.uint32(10).string(message.address); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryAllBalancesRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryAllBalancesRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.string(); + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryAllBalancesRequest { + const obj = createBaseQueryAllBalancesRequest(); + if (isSet(object.address)) obj.address = String(object.address); + if (isSet(object.pagination)) obj.pagination = PageRequest.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryAllBalancesRequest): JsonSafe { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryAllBalancesRequest { + const message = createBaseQueryAllBalancesRequest(); + message.address = object.address ?? ""; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryAllBalancesRequestSDKType): QueryAllBalancesRequest { + return { + address: object?.address, + pagination: object.pagination ? PageRequest.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryAllBalancesRequestSDKType { + return { + address: isSet(object.address) ? String(object.address) : "", + pagination: isSet(object.pagination) ? PageRequest.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryAllBalancesRequest): QueryAllBalancesRequestSDKType { + const obj: any = {}; + obj.address = message.address; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryAllBalancesRequestAmino): QueryAllBalancesRequest { + const message = createBaseQueryAllBalancesRequest(); + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryAllBalancesRequest): QueryAllBalancesRequestAmino { + const obj: any = {}; + obj.address = message.address === "" ? undefined : message.address; + obj.pagination = message.pagination ? PageRequest.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryAllBalancesRequestAminoMsg): QueryAllBalancesRequest { + return QueryAllBalancesRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryAllBalancesRequest): QueryAllBalancesRequestAminoMsg { + return { + type: "cosmos-sdk/QueryAllBalancesRequest", + value: QueryAllBalancesRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryAllBalancesRequestProtoMsg): QueryAllBalancesRequest { + return QueryAllBalancesRequest.decode(message.value); + }, + toProto(message: QueryAllBalancesRequest): Uint8Array { + return QueryAllBalancesRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryAllBalancesRequest): QueryAllBalancesRequestProtoMsg { + return { + typeUrl: "/cosmos.bank.v1beta1.QueryAllBalancesRequest", + value: QueryAllBalancesRequest.encode(message).finish() + }; + } +}; +function createBaseQueryAllBalancesResponse(): QueryAllBalancesResponse { + return { + balances: [], + pagination: undefined + }; +} +export const QueryAllBalancesResponse = { + typeUrl: "/cosmos.bank.v1beta1.QueryAllBalancesResponse", + encode(message: QueryAllBalancesResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.balances) { + Coin.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryAllBalancesResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryAllBalancesResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.balances.push(Coin.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryAllBalancesResponse { + const obj = createBaseQueryAllBalancesResponse(); + if (Array.isArray(object?.balances)) obj.balances = object.balances.map((e: any) => Coin.fromJSON(e)); + if (isSet(object.pagination)) obj.pagination = PageResponse.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryAllBalancesResponse): JsonSafe { + const obj: any = {}; + if (message.balances) { + obj.balances = message.balances.map(e => e ? Coin.toJSON(e) : undefined); + } else { + obj.balances = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryAllBalancesResponse { + const message = createBaseQueryAllBalancesResponse(); + message.balances = object.balances?.map(e => Coin.fromPartial(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryAllBalancesResponseSDKType): QueryAllBalancesResponse { + return { + balances: Array.isArray(object?.balances) ? object.balances.map((e: any) => Coin.fromSDK(e)) : [], + pagination: object.pagination ? PageResponse.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryAllBalancesResponseSDKType { + return { + balances: Array.isArray(object?.balances) ? object.balances.map((e: any) => Coin.fromSDKJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryAllBalancesResponse): QueryAllBalancesResponseSDKType { + const obj: any = {}; + if (message.balances) { + obj.balances = message.balances.map(e => e ? Coin.toSDK(e) : undefined); + } else { + obj.balances = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryAllBalancesResponseAmino): QueryAllBalancesResponse { + const message = createBaseQueryAllBalancesResponse(); + message.balances = object.balances?.map(e => Coin.fromAmino(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryAllBalancesResponse): QueryAllBalancesResponseAmino { + const obj: any = {}; + if (message.balances) { + obj.balances = message.balances.map(e => e ? Coin.toAmino(e) : undefined); + } else { + obj.balances = message.balances; + } + obj.pagination = message.pagination ? PageResponse.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryAllBalancesResponseAminoMsg): QueryAllBalancesResponse { + return QueryAllBalancesResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryAllBalancesResponse): QueryAllBalancesResponseAminoMsg { + return { + type: "cosmos-sdk/QueryAllBalancesResponse", + value: QueryAllBalancesResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryAllBalancesResponseProtoMsg): QueryAllBalancesResponse { + return QueryAllBalancesResponse.decode(message.value); + }, + toProto(message: QueryAllBalancesResponse): Uint8Array { + return QueryAllBalancesResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryAllBalancesResponse): QueryAllBalancesResponseProtoMsg { + return { + typeUrl: "/cosmos.bank.v1beta1.QueryAllBalancesResponse", + value: QueryAllBalancesResponse.encode(message).finish() + }; + } +}; +function createBaseQuerySpendableBalancesRequest(): QuerySpendableBalancesRequest { + return { + address: "", + pagination: undefined + }; +} +export const QuerySpendableBalancesRequest = { + typeUrl: "/cosmos.bank.v1beta1.QuerySpendableBalancesRequest", + encode(message: QuerySpendableBalancesRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.address !== undefined) { + writer.uint32(10).string(message.address); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QuerySpendableBalancesRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQuerySpendableBalancesRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.string(); + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QuerySpendableBalancesRequest { + const obj = createBaseQuerySpendableBalancesRequest(); + if (isSet(object.address)) obj.address = String(object.address); + if (isSet(object.pagination)) obj.pagination = PageRequest.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QuerySpendableBalancesRequest): JsonSafe { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QuerySpendableBalancesRequest { + const message = createBaseQuerySpendableBalancesRequest(); + message.address = object.address ?? ""; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QuerySpendableBalancesRequestSDKType): QuerySpendableBalancesRequest { + return { + address: object?.address, + pagination: object.pagination ? PageRequest.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QuerySpendableBalancesRequestSDKType { + return { + address: isSet(object.address) ? String(object.address) : "", + pagination: isSet(object.pagination) ? PageRequest.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QuerySpendableBalancesRequest): QuerySpendableBalancesRequestSDKType { + const obj: any = {}; + obj.address = message.address; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QuerySpendableBalancesRequestAmino): QuerySpendableBalancesRequest { + const message = createBaseQuerySpendableBalancesRequest(); + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QuerySpendableBalancesRequest): QuerySpendableBalancesRequestAmino { + const obj: any = {}; + obj.address = message.address === "" ? undefined : message.address; + obj.pagination = message.pagination ? PageRequest.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QuerySpendableBalancesRequestAminoMsg): QuerySpendableBalancesRequest { + return QuerySpendableBalancesRequest.fromAmino(object.value); + }, + toAminoMsg(message: QuerySpendableBalancesRequest): QuerySpendableBalancesRequestAminoMsg { + return { + type: "cosmos-sdk/QuerySpendableBalancesRequest", + value: QuerySpendableBalancesRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QuerySpendableBalancesRequestProtoMsg): QuerySpendableBalancesRequest { + return QuerySpendableBalancesRequest.decode(message.value); + }, + toProto(message: QuerySpendableBalancesRequest): Uint8Array { + return QuerySpendableBalancesRequest.encode(message).finish(); + }, + toProtoMsg(message: QuerySpendableBalancesRequest): QuerySpendableBalancesRequestProtoMsg { + return { + typeUrl: "/cosmos.bank.v1beta1.QuerySpendableBalancesRequest", + value: QuerySpendableBalancesRequest.encode(message).finish() + }; + } +}; +function createBaseQuerySpendableBalancesResponse(): QuerySpendableBalancesResponse { + return { + balances: [], + pagination: undefined + }; +} +export const QuerySpendableBalancesResponse = { + typeUrl: "/cosmos.bank.v1beta1.QuerySpendableBalancesResponse", + encode(message: QuerySpendableBalancesResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.balances) { + Coin.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QuerySpendableBalancesResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQuerySpendableBalancesResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.balances.push(Coin.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QuerySpendableBalancesResponse { + const obj = createBaseQuerySpendableBalancesResponse(); + if (Array.isArray(object?.balances)) obj.balances = object.balances.map((e: any) => Coin.fromJSON(e)); + if (isSet(object.pagination)) obj.pagination = PageResponse.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QuerySpendableBalancesResponse): JsonSafe { + const obj: any = {}; + if (message.balances) { + obj.balances = message.balances.map(e => e ? Coin.toJSON(e) : undefined); + } else { + obj.balances = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QuerySpendableBalancesResponse { + const message = createBaseQuerySpendableBalancesResponse(); + message.balances = object.balances?.map(e => Coin.fromPartial(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QuerySpendableBalancesResponseSDKType): QuerySpendableBalancesResponse { + return { + balances: Array.isArray(object?.balances) ? object.balances.map((e: any) => Coin.fromSDK(e)) : [], + pagination: object.pagination ? PageResponse.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QuerySpendableBalancesResponseSDKType { + return { + balances: Array.isArray(object?.balances) ? object.balances.map((e: any) => Coin.fromSDKJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QuerySpendableBalancesResponse): QuerySpendableBalancesResponseSDKType { + const obj: any = {}; + if (message.balances) { + obj.balances = message.balances.map(e => e ? Coin.toSDK(e) : undefined); + } else { + obj.balances = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QuerySpendableBalancesResponseAmino): QuerySpendableBalancesResponse { + const message = createBaseQuerySpendableBalancesResponse(); + message.balances = object.balances?.map(e => Coin.fromAmino(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QuerySpendableBalancesResponse): QuerySpendableBalancesResponseAmino { + const obj: any = {}; + if (message.balances) { + obj.balances = message.balances.map(e => e ? Coin.toAmino(e) : undefined); + } else { + obj.balances = message.balances; + } + obj.pagination = message.pagination ? PageResponse.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QuerySpendableBalancesResponseAminoMsg): QuerySpendableBalancesResponse { + return QuerySpendableBalancesResponse.fromAmino(object.value); + }, + toAminoMsg(message: QuerySpendableBalancesResponse): QuerySpendableBalancesResponseAminoMsg { + return { + type: "cosmos-sdk/QuerySpendableBalancesResponse", + value: QuerySpendableBalancesResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QuerySpendableBalancesResponseProtoMsg): QuerySpendableBalancesResponse { + return QuerySpendableBalancesResponse.decode(message.value); + }, + toProto(message: QuerySpendableBalancesResponse): Uint8Array { + return QuerySpendableBalancesResponse.encode(message).finish(); + }, + toProtoMsg(message: QuerySpendableBalancesResponse): QuerySpendableBalancesResponseProtoMsg { + return { + typeUrl: "/cosmos.bank.v1beta1.QuerySpendableBalancesResponse", + value: QuerySpendableBalancesResponse.encode(message).finish() + }; + } +}; +function createBaseQueryTotalSupplyRequest(): QueryTotalSupplyRequest { + return { + pagination: undefined + }; +} +export const QueryTotalSupplyRequest = { + typeUrl: "/cosmos.bank.v1beta1.QueryTotalSupplyRequest", + encode(message: QueryTotalSupplyRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryTotalSupplyRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryTotalSupplyRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryTotalSupplyRequest { + const obj = createBaseQueryTotalSupplyRequest(); + if (isSet(object.pagination)) obj.pagination = PageRequest.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryTotalSupplyRequest): JsonSafe { + const obj: any = {}; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryTotalSupplyRequest { + const message = createBaseQueryTotalSupplyRequest(); + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryTotalSupplyRequestSDKType): QueryTotalSupplyRequest { + return { + pagination: object.pagination ? PageRequest.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryTotalSupplyRequestSDKType { + return { + pagination: isSet(object.pagination) ? PageRequest.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryTotalSupplyRequest): QueryTotalSupplyRequestSDKType { + const obj: any = {}; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryTotalSupplyRequestAmino): QueryTotalSupplyRequest { + const message = createBaseQueryTotalSupplyRequest(); + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryTotalSupplyRequest): QueryTotalSupplyRequestAmino { + const obj: any = {}; + obj.pagination = message.pagination ? PageRequest.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryTotalSupplyRequestAminoMsg): QueryTotalSupplyRequest { + return QueryTotalSupplyRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryTotalSupplyRequest): QueryTotalSupplyRequestAminoMsg { + return { + type: "cosmos-sdk/QueryTotalSupplyRequest", + value: QueryTotalSupplyRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryTotalSupplyRequestProtoMsg): QueryTotalSupplyRequest { + return QueryTotalSupplyRequest.decode(message.value); + }, + toProto(message: QueryTotalSupplyRequest): Uint8Array { + return QueryTotalSupplyRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryTotalSupplyRequest): QueryTotalSupplyRequestProtoMsg { + return { + typeUrl: "/cosmos.bank.v1beta1.QueryTotalSupplyRequest", + value: QueryTotalSupplyRequest.encode(message).finish() + }; + } +}; +function createBaseQueryTotalSupplyResponse(): QueryTotalSupplyResponse { + return { + supply: [], + pagination: undefined + }; +} +export const QueryTotalSupplyResponse = { + typeUrl: "/cosmos.bank.v1beta1.QueryTotalSupplyResponse", + encode(message: QueryTotalSupplyResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.supply) { + Coin.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryTotalSupplyResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryTotalSupplyResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.supply.push(Coin.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryTotalSupplyResponse { + const obj = createBaseQueryTotalSupplyResponse(); + if (Array.isArray(object?.supply)) obj.supply = object.supply.map((e: any) => Coin.fromJSON(e)); + if (isSet(object.pagination)) obj.pagination = PageResponse.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryTotalSupplyResponse): JsonSafe { + const obj: any = {}; + if (message.supply) { + obj.supply = message.supply.map(e => e ? Coin.toJSON(e) : undefined); + } else { + obj.supply = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryTotalSupplyResponse { + const message = createBaseQueryTotalSupplyResponse(); + message.supply = object.supply?.map(e => Coin.fromPartial(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryTotalSupplyResponseSDKType): QueryTotalSupplyResponse { + return { + supply: Array.isArray(object?.supply) ? object.supply.map((e: any) => Coin.fromSDK(e)) : [], + pagination: object.pagination ? PageResponse.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryTotalSupplyResponseSDKType { + return { + supply: Array.isArray(object?.supply) ? object.supply.map((e: any) => Coin.fromSDKJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryTotalSupplyResponse): QueryTotalSupplyResponseSDKType { + const obj: any = {}; + if (message.supply) { + obj.supply = message.supply.map(e => e ? Coin.toSDK(e) : undefined); + } else { + obj.supply = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryTotalSupplyResponseAmino): QueryTotalSupplyResponse { + const message = createBaseQueryTotalSupplyResponse(); + message.supply = object.supply?.map(e => Coin.fromAmino(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryTotalSupplyResponse): QueryTotalSupplyResponseAmino { + const obj: any = {}; + if (message.supply) { + obj.supply = message.supply.map(e => e ? Coin.toAmino(e) : undefined); + } else { + obj.supply = message.supply; + } + obj.pagination = message.pagination ? PageResponse.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryTotalSupplyResponseAminoMsg): QueryTotalSupplyResponse { + return QueryTotalSupplyResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryTotalSupplyResponse): QueryTotalSupplyResponseAminoMsg { + return { + type: "cosmos-sdk/QueryTotalSupplyResponse", + value: QueryTotalSupplyResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryTotalSupplyResponseProtoMsg): QueryTotalSupplyResponse { + return QueryTotalSupplyResponse.decode(message.value); + }, + toProto(message: QueryTotalSupplyResponse): Uint8Array { + return QueryTotalSupplyResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryTotalSupplyResponse): QueryTotalSupplyResponseProtoMsg { + return { + typeUrl: "/cosmos.bank.v1beta1.QueryTotalSupplyResponse", + value: QueryTotalSupplyResponse.encode(message).finish() + }; + } +}; +function createBaseQuerySupplyOfRequest(): QuerySupplyOfRequest { + return { + denom: "" + }; +} +export const QuerySupplyOfRequest = { + typeUrl: "/cosmos.bank.v1beta1.QuerySupplyOfRequest", + encode(message: QuerySupplyOfRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.denom !== undefined) { + writer.uint32(10).string(message.denom); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QuerySupplyOfRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQuerySupplyOfRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.denom = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QuerySupplyOfRequest { + const obj = createBaseQuerySupplyOfRequest(); + if (isSet(object.denom)) obj.denom = String(object.denom); + return obj; + }, + toJSON(message: QuerySupplyOfRequest): JsonSafe { + const obj: any = {}; + message.denom !== undefined && (obj.denom = message.denom); + return obj; + }, + fromPartial(object: DeepPartial): QuerySupplyOfRequest { + const message = createBaseQuerySupplyOfRequest(); + message.denom = object.denom ?? ""; + return message; + }, + fromSDK(object: QuerySupplyOfRequestSDKType): QuerySupplyOfRequest { + return { + denom: object?.denom + }; + }, + fromSDKJSON(object: any): QuerySupplyOfRequestSDKType { + return { + denom: isSet(object.denom) ? String(object.denom) : "" + }; + }, + toSDK(message: QuerySupplyOfRequest): QuerySupplyOfRequestSDKType { + const obj: any = {}; + obj.denom = message.denom; + return obj; + }, + fromAmino(object: QuerySupplyOfRequestAmino): QuerySupplyOfRequest { + const message = createBaseQuerySupplyOfRequest(); + if (object.denom !== undefined && object.denom !== null) { + message.denom = object.denom; + } + return message; + }, + toAmino(message: QuerySupplyOfRequest): QuerySupplyOfRequestAmino { + const obj: any = {}; + obj.denom = message.denom === "" ? undefined : message.denom; + return obj; + }, + fromAminoMsg(object: QuerySupplyOfRequestAminoMsg): QuerySupplyOfRequest { + return QuerySupplyOfRequest.fromAmino(object.value); + }, + toAminoMsg(message: QuerySupplyOfRequest): QuerySupplyOfRequestAminoMsg { + return { + type: "cosmos-sdk/QuerySupplyOfRequest", + value: QuerySupplyOfRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QuerySupplyOfRequestProtoMsg): QuerySupplyOfRequest { + return QuerySupplyOfRequest.decode(message.value); + }, + toProto(message: QuerySupplyOfRequest): Uint8Array { + return QuerySupplyOfRequest.encode(message).finish(); + }, + toProtoMsg(message: QuerySupplyOfRequest): QuerySupplyOfRequestProtoMsg { + return { + typeUrl: "/cosmos.bank.v1beta1.QuerySupplyOfRequest", + value: QuerySupplyOfRequest.encode(message).finish() + }; + } +}; +function createBaseQuerySupplyOfResponse(): QuerySupplyOfResponse { + return { + amount: Coin.fromPartial({}) + }; +} +export const QuerySupplyOfResponse = { + typeUrl: "/cosmos.bank.v1beta1.QuerySupplyOfResponse", + encode(message: QuerySupplyOfResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.amount !== undefined) { + Coin.encode(message.amount, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QuerySupplyOfResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQuerySupplyOfResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.amount = Coin.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QuerySupplyOfResponse { + const obj = createBaseQuerySupplyOfResponse(); + if (isSet(object.amount)) obj.amount = Coin.fromJSON(object.amount); + return obj; + }, + toJSON(message: QuerySupplyOfResponse): JsonSafe { + const obj: any = {}; + message.amount !== undefined && (obj.amount = message.amount ? Coin.toJSON(message.amount) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QuerySupplyOfResponse { + const message = createBaseQuerySupplyOfResponse(); + if (object.amount !== undefined && object.amount !== null) { + message.amount = Coin.fromPartial(object.amount); + } + return message; + }, + fromSDK(object: QuerySupplyOfResponseSDKType): QuerySupplyOfResponse { + return { + amount: object.amount ? Coin.fromSDK(object.amount) : undefined + }; + }, + fromSDKJSON(object: any): QuerySupplyOfResponseSDKType { + return { + amount: isSet(object.amount) ? Coin.fromSDKJSON(object.amount) : undefined + }; + }, + toSDK(message: QuerySupplyOfResponse): QuerySupplyOfResponseSDKType { + const obj: any = {}; + message.amount !== undefined && (obj.amount = message.amount ? Coin.toSDK(message.amount) : undefined); + return obj; + }, + fromAmino(object: QuerySupplyOfResponseAmino): QuerySupplyOfResponse { + const message = createBaseQuerySupplyOfResponse(); + if (object.amount !== undefined && object.amount !== null) { + message.amount = Coin.fromAmino(object.amount); + } + return message; + }, + toAmino(message: QuerySupplyOfResponse): QuerySupplyOfResponseAmino { + const obj: any = {}; + obj.amount = message.amount ? Coin.toAmino(message.amount) : undefined; + return obj; + }, + fromAminoMsg(object: QuerySupplyOfResponseAminoMsg): QuerySupplyOfResponse { + return QuerySupplyOfResponse.fromAmino(object.value); + }, + toAminoMsg(message: QuerySupplyOfResponse): QuerySupplyOfResponseAminoMsg { + return { + type: "cosmos-sdk/QuerySupplyOfResponse", + value: QuerySupplyOfResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QuerySupplyOfResponseProtoMsg): QuerySupplyOfResponse { + return QuerySupplyOfResponse.decode(message.value); + }, + toProto(message: QuerySupplyOfResponse): Uint8Array { + return QuerySupplyOfResponse.encode(message).finish(); + }, + toProtoMsg(message: QuerySupplyOfResponse): QuerySupplyOfResponseProtoMsg { + return { + typeUrl: "/cosmos.bank.v1beta1.QuerySupplyOfResponse", + value: QuerySupplyOfResponse.encode(message).finish() + }; + } +}; +function createBaseQueryParamsRequest(): QueryParamsRequest { + return {}; +} +export const QueryParamsRequest = { + typeUrl: "/cosmos.bank.v1beta1.QueryParamsRequest", + encode(_: QueryParamsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryParamsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryParamsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): QueryParamsRequest { + const obj = createBaseQueryParamsRequest(); + return obj; + }, + toJSON(_: QueryParamsRequest): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): QueryParamsRequest { + const message = createBaseQueryParamsRequest(); + return message; + }, + fromSDK(_: QueryParamsRequestSDKType): QueryParamsRequest { + return {}; + }, + fromSDKJSON(_: any): QueryParamsRequestSDKType { + return {}; + }, + toSDK(_: QueryParamsRequest): QueryParamsRequestSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: QueryParamsRequestAmino): QueryParamsRequest { + const message = createBaseQueryParamsRequest(); + return message; + }, + toAmino(_: QueryParamsRequest): QueryParamsRequestAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: QueryParamsRequestAminoMsg): QueryParamsRequest { + return QueryParamsRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryParamsRequest): QueryParamsRequestAminoMsg { + return { + type: "cosmos-sdk/QueryParamsRequest", + value: QueryParamsRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryParamsRequestProtoMsg): QueryParamsRequest { + return QueryParamsRequest.decode(message.value); + }, + toProto(message: QueryParamsRequest): Uint8Array { + return QueryParamsRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryParamsRequest): QueryParamsRequestProtoMsg { + return { + typeUrl: "/cosmos.bank.v1beta1.QueryParamsRequest", + value: QueryParamsRequest.encode(message).finish() + }; + } +}; +function createBaseQueryParamsResponse(): QueryParamsResponse { + return { + params: Params.fromPartial({}) + }; +} +export const QueryParamsResponse = { + typeUrl: "/cosmos.bank.v1beta1.QueryParamsResponse", + encode(message: QueryParamsResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryParamsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryParamsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.params = Params.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryParamsResponse { + const obj = createBaseQueryParamsResponse(); + if (isSet(object.params)) obj.params = Params.fromJSON(object.params); + return obj; + }, + toJSON(message: QueryParamsResponse): JsonSafe { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryParamsResponse { + const message = createBaseQueryParamsResponse(); + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } + return message; + }, + fromSDK(object: QueryParamsResponseSDKType): QueryParamsResponse { + return { + params: object.params ? Params.fromSDK(object.params) : undefined + }; + }, + fromSDKJSON(object: any): QueryParamsResponseSDKType { + return { + params: isSet(object.params) ? Params.fromSDKJSON(object.params) : undefined + }; + }, + toSDK(message: QueryParamsResponse): QueryParamsResponseSDKType { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toSDK(message.params) : undefined); + return obj; + }, + fromAmino(object: QueryParamsResponseAmino): QueryParamsResponse { + const message = createBaseQueryParamsResponse(); + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromAmino(object.params); + } + return message; + }, + toAmino(message: QueryParamsResponse): QueryParamsResponseAmino { + const obj: any = {}; + obj.params = message.params ? Params.toAmino(message.params) : undefined; + return obj; + }, + fromAminoMsg(object: QueryParamsResponseAminoMsg): QueryParamsResponse { + return QueryParamsResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryParamsResponse): QueryParamsResponseAminoMsg { + return { + type: "cosmos-sdk/QueryParamsResponse", + value: QueryParamsResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryParamsResponseProtoMsg): QueryParamsResponse { + return QueryParamsResponse.decode(message.value); + }, + toProto(message: QueryParamsResponse): Uint8Array { + return QueryParamsResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryParamsResponse): QueryParamsResponseProtoMsg { + return { + typeUrl: "/cosmos.bank.v1beta1.QueryParamsResponse", + value: QueryParamsResponse.encode(message).finish() + }; + } +}; +function createBaseQueryDenomsMetadataRequest(): QueryDenomsMetadataRequest { + return { + pagination: undefined + }; +} +export const QueryDenomsMetadataRequest = { + typeUrl: "/cosmos.bank.v1beta1.QueryDenomsMetadataRequest", + encode(message: QueryDenomsMetadataRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryDenomsMetadataRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryDenomsMetadataRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryDenomsMetadataRequest { + const obj = createBaseQueryDenomsMetadataRequest(); + if (isSet(object.pagination)) obj.pagination = PageRequest.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryDenomsMetadataRequest): JsonSafe { + const obj: any = {}; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryDenomsMetadataRequest { + const message = createBaseQueryDenomsMetadataRequest(); + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryDenomsMetadataRequestSDKType): QueryDenomsMetadataRequest { + return { + pagination: object.pagination ? PageRequest.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryDenomsMetadataRequestSDKType { + return { + pagination: isSet(object.pagination) ? PageRequest.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryDenomsMetadataRequest): QueryDenomsMetadataRequestSDKType { + const obj: any = {}; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryDenomsMetadataRequestAmino): QueryDenomsMetadataRequest { + const message = createBaseQueryDenomsMetadataRequest(); + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryDenomsMetadataRequest): QueryDenomsMetadataRequestAmino { + const obj: any = {}; + obj.pagination = message.pagination ? PageRequest.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryDenomsMetadataRequestAminoMsg): QueryDenomsMetadataRequest { + return QueryDenomsMetadataRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryDenomsMetadataRequest): QueryDenomsMetadataRequestAminoMsg { + return { + type: "cosmos-sdk/QueryDenomsMetadataRequest", + value: QueryDenomsMetadataRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryDenomsMetadataRequestProtoMsg): QueryDenomsMetadataRequest { + return QueryDenomsMetadataRequest.decode(message.value); + }, + toProto(message: QueryDenomsMetadataRequest): Uint8Array { + return QueryDenomsMetadataRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryDenomsMetadataRequest): QueryDenomsMetadataRequestProtoMsg { + return { + typeUrl: "/cosmos.bank.v1beta1.QueryDenomsMetadataRequest", + value: QueryDenomsMetadataRequest.encode(message).finish() + }; + } +}; +function createBaseQueryDenomsMetadataResponse(): QueryDenomsMetadataResponse { + return { + metadatas: [], + pagination: undefined + }; +} +export const QueryDenomsMetadataResponse = { + typeUrl: "/cosmos.bank.v1beta1.QueryDenomsMetadataResponse", + encode(message: QueryDenomsMetadataResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.metadatas) { + Metadata.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryDenomsMetadataResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryDenomsMetadataResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.metadatas.push(Metadata.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryDenomsMetadataResponse { + const obj = createBaseQueryDenomsMetadataResponse(); + if (Array.isArray(object?.metadatas)) obj.metadatas = object.metadatas.map((e: any) => Metadata.fromJSON(e)); + if (isSet(object.pagination)) obj.pagination = PageResponse.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryDenomsMetadataResponse): JsonSafe { + const obj: any = {}; + if (message.metadatas) { + obj.metadatas = message.metadatas.map(e => e ? Metadata.toJSON(e) : undefined); + } else { + obj.metadatas = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryDenomsMetadataResponse { + const message = createBaseQueryDenomsMetadataResponse(); + message.metadatas = object.metadatas?.map(e => Metadata.fromPartial(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryDenomsMetadataResponseSDKType): QueryDenomsMetadataResponse { + return { + metadatas: Array.isArray(object?.metadatas) ? object.metadatas.map((e: any) => Metadata.fromSDK(e)) : [], + pagination: object.pagination ? PageResponse.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryDenomsMetadataResponseSDKType { + return { + metadatas: Array.isArray(object?.metadatas) ? object.metadatas.map((e: any) => Metadata.fromSDKJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryDenomsMetadataResponse): QueryDenomsMetadataResponseSDKType { + const obj: any = {}; + if (message.metadatas) { + obj.metadatas = message.metadatas.map(e => e ? Metadata.toSDK(e) : undefined); + } else { + obj.metadatas = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryDenomsMetadataResponseAmino): QueryDenomsMetadataResponse { + const message = createBaseQueryDenomsMetadataResponse(); + message.metadatas = object.metadatas?.map(e => Metadata.fromAmino(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryDenomsMetadataResponse): QueryDenomsMetadataResponseAmino { + const obj: any = {}; + if (message.metadatas) { + obj.metadatas = message.metadatas.map(e => e ? Metadata.toAmino(e) : undefined); + } else { + obj.metadatas = message.metadatas; + } + obj.pagination = message.pagination ? PageResponse.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryDenomsMetadataResponseAminoMsg): QueryDenomsMetadataResponse { + return QueryDenomsMetadataResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryDenomsMetadataResponse): QueryDenomsMetadataResponseAminoMsg { + return { + type: "cosmos-sdk/QueryDenomsMetadataResponse", + value: QueryDenomsMetadataResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryDenomsMetadataResponseProtoMsg): QueryDenomsMetadataResponse { + return QueryDenomsMetadataResponse.decode(message.value); + }, + toProto(message: QueryDenomsMetadataResponse): Uint8Array { + return QueryDenomsMetadataResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryDenomsMetadataResponse): QueryDenomsMetadataResponseProtoMsg { + return { + typeUrl: "/cosmos.bank.v1beta1.QueryDenomsMetadataResponse", + value: QueryDenomsMetadataResponse.encode(message).finish() + }; + } +}; +function createBaseQueryDenomMetadataRequest(): QueryDenomMetadataRequest { + return { + denom: "" + }; +} +export const QueryDenomMetadataRequest = { + typeUrl: "/cosmos.bank.v1beta1.QueryDenomMetadataRequest", + encode(message: QueryDenomMetadataRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.denom !== undefined) { + writer.uint32(10).string(message.denom); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryDenomMetadataRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryDenomMetadataRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.denom = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryDenomMetadataRequest { + const obj = createBaseQueryDenomMetadataRequest(); + if (isSet(object.denom)) obj.denom = String(object.denom); + return obj; + }, + toJSON(message: QueryDenomMetadataRequest): JsonSafe { + const obj: any = {}; + message.denom !== undefined && (obj.denom = message.denom); + return obj; + }, + fromPartial(object: DeepPartial): QueryDenomMetadataRequest { + const message = createBaseQueryDenomMetadataRequest(); + message.denom = object.denom ?? ""; + return message; + }, + fromSDK(object: QueryDenomMetadataRequestSDKType): QueryDenomMetadataRequest { + return { + denom: object?.denom + }; + }, + fromSDKJSON(object: any): QueryDenomMetadataRequestSDKType { + return { + denom: isSet(object.denom) ? String(object.denom) : "" + }; + }, + toSDK(message: QueryDenomMetadataRequest): QueryDenomMetadataRequestSDKType { + const obj: any = {}; + obj.denom = message.denom; + return obj; + }, + fromAmino(object: QueryDenomMetadataRequestAmino): QueryDenomMetadataRequest { + const message = createBaseQueryDenomMetadataRequest(); + if (object.denom !== undefined && object.denom !== null) { + message.denom = object.denom; + } + return message; + }, + toAmino(message: QueryDenomMetadataRequest): QueryDenomMetadataRequestAmino { + const obj: any = {}; + obj.denom = message.denom === "" ? undefined : message.denom; + return obj; + }, + fromAminoMsg(object: QueryDenomMetadataRequestAminoMsg): QueryDenomMetadataRequest { + return QueryDenomMetadataRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryDenomMetadataRequest): QueryDenomMetadataRequestAminoMsg { + return { + type: "cosmos-sdk/QueryDenomMetadataRequest", + value: QueryDenomMetadataRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryDenomMetadataRequestProtoMsg): QueryDenomMetadataRequest { + return QueryDenomMetadataRequest.decode(message.value); + }, + toProto(message: QueryDenomMetadataRequest): Uint8Array { + return QueryDenomMetadataRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryDenomMetadataRequest): QueryDenomMetadataRequestProtoMsg { + return { + typeUrl: "/cosmos.bank.v1beta1.QueryDenomMetadataRequest", + value: QueryDenomMetadataRequest.encode(message).finish() + }; + } +}; +function createBaseQueryDenomMetadataResponse(): QueryDenomMetadataResponse { + return { + metadata: Metadata.fromPartial({}) + }; +} +export const QueryDenomMetadataResponse = { + typeUrl: "/cosmos.bank.v1beta1.QueryDenomMetadataResponse", + encode(message: QueryDenomMetadataResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.metadata !== undefined) { + Metadata.encode(message.metadata, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryDenomMetadataResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryDenomMetadataResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.metadata = Metadata.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryDenomMetadataResponse { + const obj = createBaseQueryDenomMetadataResponse(); + if (isSet(object.metadata)) obj.metadata = Metadata.fromJSON(object.metadata); + return obj; + }, + toJSON(message: QueryDenomMetadataResponse): JsonSafe { + const obj: any = {}; + message.metadata !== undefined && (obj.metadata = message.metadata ? Metadata.toJSON(message.metadata) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryDenomMetadataResponse { + const message = createBaseQueryDenomMetadataResponse(); + if (object.metadata !== undefined && object.metadata !== null) { + message.metadata = Metadata.fromPartial(object.metadata); + } + return message; + }, + fromSDK(object: QueryDenomMetadataResponseSDKType): QueryDenomMetadataResponse { + return { + metadata: object.metadata ? Metadata.fromSDK(object.metadata) : undefined + }; + }, + fromSDKJSON(object: any): QueryDenomMetadataResponseSDKType { + return { + metadata: isSet(object.metadata) ? Metadata.fromSDKJSON(object.metadata) : undefined + }; + }, + toSDK(message: QueryDenomMetadataResponse): QueryDenomMetadataResponseSDKType { + const obj: any = {}; + message.metadata !== undefined && (obj.metadata = message.metadata ? Metadata.toSDK(message.metadata) : undefined); + return obj; + }, + fromAmino(object: QueryDenomMetadataResponseAmino): QueryDenomMetadataResponse { + const message = createBaseQueryDenomMetadataResponse(); + if (object.metadata !== undefined && object.metadata !== null) { + message.metadata = Metadata.fromAmino(object.metadata); + } + return message; + }, + toAmino(message: QueryDenomMetadataResponse): QueryDenomMetadataResponseAmino { + const obj: any = {}; + obj.metadata = message.metadata ? Metadata.toAmino(message.metadata) : undefined; + return obj; + }, + fromAminoMsg(object: QueryDenomMetadataResponseAminoMsg): QueryDenomMetadataResponse { + return QueryDenomMetadataResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryDenomMetadataResponse): QueryDenomMetadataResponseAminoMsg { + return { + type: "cosmos-sdk/QueryDenomMetadataResponse", + value: QueryDenomMetadataResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryDenomMetadataResponseProtoMsg): QueryDenomMetadataResponse { + return QueryDenomMetadataResponse.decode(message.value); + }, + toProto(message: QueryDenomMetadataResponse): Uint8Array { + return QueryDenomMetadataResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryDenomMetadataResponse): QueryDenomMetadataResponseProtoMsg { + return { + typeUrl: "/cosmos.bank.v1beta1.QueryDenomMetadataResponse", + value: QueryDenomMetadataResponse.encode(message).finish() + }; + } +}; +function createBaseQueryDenomOwnersRequest(): QueryDenomOwnersRequest { + return { + denom: "", + pagination: undefined + }; +} +export const QueryDenomOwnersRequest = { + typeUrl: "/cosmos.bank.v1beta1.QueryDenomOwnersRequest", + encode(message: QueryDenomOwnersRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.denom !== undefined) { + writer.uint32(10).string(message.denom); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryDenomOwnersRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryDenomOwnersRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.denom = reader.string(); + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryDenomOwnersRequest { + const obj = createBaseQueryDenomOwnersRequest(); + if (isSet(object.denom)) obj.denom = String(object.denom); + if (isSet(object.pagination)) obj.pagination = PageRequest.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryDenomOwnersRequest): JsonSafe { + const obj: any = {}; + message.denom !== undefined && (obj.denom = message.denom); + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryDenomOwnersRequest { + const message = createBaseQueryDenomOwnersRequest(); + message.denom = object.denom ?? ""; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryDenomOwnersRequestSDKType): QueryDenomOwnersRequest { + return { + denom: object?.denom, + pagination: object.pagination ? PageRequest.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryDenomOwnersRequestSDKType { + return { + denom: isSet(object.denom) ? String(object.denom) : "", + pagination: isSet(object.pagination) ? PageRequest.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryDenomOwnersRequest): QueryDenomOwnersRequestSDKType { + const obj: any = {}; + obj.denom = message.denom; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryDenomOwnersRequestAmino): QueryDenomOwnersRequest { + const message = createBaseQueryDenomOwnersRequest(); + if (object.denom !== undefined && object.denom !== null) { + message.denom = object.denom; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryDenomOwnersRequest): QueryDenomOwnersRequestAmino { + const obj: any = {}; + obj.denom = message.denom === "" ? undefined : message.denom; + obj.pagination = message.pagination ? PageRequest.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryDenomOwnersRequestAminoMsg): QueryDenomOwnersRequest { + return QueryDenomOwnersRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryDenomOwnersRequest): QueryDenomOwnersRequestAminoMsg { + return { + type: "cosmos-sdk/QueryDenomOwnersRequest", + value: QueryDenomOwnersRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryDenomOwnersRequestProtoMsg): QueryDenomOwnersRequest { + return QueryDenomOwnersRequest.decode(message.value); + }, + toProto(message: QueryDenomOwnersRequest): Uint8Array { + return QueryDenomOwnersRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryDenomOwnersRequest): QueryDenomOwnersRequestProtoMsg { + return { + typeUrl: "/cosmos.bank.v1beta1.QueryDenomOwnersRequest", + value: QueryDenomOwnersRequest.encode(message).finish() + }; + } +}; +function createBaseDenomOwner(): DenomOwner { + return { + address: "", + balance: Coin.fromPartial({}) + }; +} +export const DenomOwner = { + typeUrl: "/cosmos.bank.v1beta1.DenomOwner", + encode(message: DenomOwner, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.address !== undefined) { + writer.uint32(10).string(message.address); + } + if (message.balance !== undefined) { + Coin.encode(message.balance, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): DenomOwner { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDenomOwner(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.string(); + break; + case 2: + message.balance = Coin.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): DenomOwner { + const obj = createBaseDenomOwner(); + if (isSet(object.address)) obj.address = String(object.address); + if (isSet(object.balance)) obj.balance = Coin.fromJSON(object.balance); + return obj; + }, + toJSON(message: DenomOwner): JsonSafe { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + message.balance !== undefined && (obj.balance = message.balance ? Coin.toJSON(message.balance) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): DenomOwner { + const message = createBaseDenomOwner(); + message.address = object.address ?? ""; + if (object.balance !== undefined && object.balance !== null) { + message.balance = Coin.fromPartial(object.balance); + } + return message; + }, + fromSDK(object: DenomOwnerSDKType): DenomOwner { + return { + address: object?.address, + balance: object.balance ? Coin.fromSDK(object.balance) : undefined + }; + }, + fromSDKJSON(object: any): DenomOwnerSDKType { + return { + address: isSet(object.address) ? String(object.address) : "", + balance: isSet(object.balance) ? Coin.fromSDKJSON(object.balance) : undefined + }; + }, + toSDK(message: DenomOwner): DenomOwnerSDKType { + const obj: any = {}; + obj.address = message.address; + message.balance !== undefined && (obj.balance = message.balance ? Coin.toSDK(message.balance) : undefined); + return obj; + }, + fromAmino(object: DenomOwnerAmino): DenomOwner { + const message = createBaseDenomOwner(); + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } + if (object.balance !== undefined && object.balance !== null) { + message.balance = Coin.fromAmino(object.balance); + } + return message; + }, + toAmino(message: DenomOwner): DenomOwnerAmino { + const obj: any = {}; + obj.address = message.address === "" ? undefined : message.address; + obj.balance = message.balance ? Coin.toAmino(message.balance) : undefined; + return obj; + }, + fromAminoMsg(object: DenomOwnerAminoMsg): DenomOwner { + return DenomOwner.fromAmino(object.value); + }, + toAminoMsg(message: DenomOwner): DenomOwnerAminoMsg { + return { + type: "cosmos-sdk/DenomOwner", + value: DenomOwner.toAmino(message) + }; + }, + fromProtoMsg(message: DenomOwnerProtoMsg): DenomOwner { + return DenomOwner.decode(message.value); + }, + toProto(message: DenomOwner): Uint8Array { + return DenomOwner.encode(message).finish(); + }, + toProtoMsg(message: DenomOwner): DenomOwnerProtoMsg { + return { + typeUrl: "/cosmos.bank.v1beta1.DenomOwner", + value: DenomOwner.encode(message).finish() + }; + } +}; +function createBaseQueryDenomOwnersResponse(): QueryDenomOwnersResponse { + return { + denomOwners: [], + pagination: undefined + }; +} +export const QueryDenomOwnersResponse = { + typeUrl: "/cosmos.bank.v1beta1.QueryDenomOwnersResponse", + encode(message: QueryDenomOwnersResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.denomOwners) { + DenomOwner.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryDenomOwnersResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryDenomOwnersResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.denomOwners.push(DenomOwner.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryDenomOwnersResponse { + const obj = createBaseQueryDenomOwnersResponse(); + if (Array.isArray(object?.denomOwners)) obj.denomOwners = object.denomOwners.map((e: any) => DenomOwner.fromJSON(e)); + if (isSet(object.pagination)) obj.pagination = PageResponse.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryDenomOwnersResponse): JsonSafe { + const obj: any = {}; + if (message.denomOwners) { + obj.denomOwners = message.denomOwners.map(e => e ? DenomOwner.toJSON(e) : undefined); + } else { + obj.denomOwners = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryDenomOwnersResponse { + const message = createBaseQueryDenomOwnersResponse(); + message.denomOwners = object.denomOwners?.map(e => DenomOwner.fromPartial(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryDenomOwnersResponseSDKType): QueryDenomOwnersResponse { + return { + denomOwners: Array.isArray(object?.denom_owners) ? object.denom_owners.map((e: any) => DenomOwner.fromSDK(e)) : [], + pagination: object.pagination ? PageResponse.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryDenomOwnersResponseSDKType { + return { + denom_owners: Array.isArray(object?.denom_owners) ? object.denom_owners.map((e: any) => DenomOwner.fromSDKJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryDenomOwnersResponse): QueryDenomOwnersResponseSDKType { + const obj: any = {}; + if (message.denomOwners) { + obj.denom_owners = message.denomOwners.map(e => e ? DenomOwner.toSDK(e) : undefined); + } else { + obj.denom_owners = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryDenomOwnersResponseAmino): QueryDenomOwnersResponse { + const message = createBaseQueryDenomOwnersResponse(); + message.denomOwners = object.denom_owners?.map(e => DenomOwner.fromAmino(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryDenomOwnersResponse): QueryDenomOwnersResponseAmino { + const obj: any = {}; + if (message.denomOwners) { + obj.denom_owners = message.denomOwners.map(e => e ? DenomOwner.toAmino(e) : undefined); + } else { + obj.denom_owners = message.denomOwners; + } + obj.pagination = message.pagination ? PageResponse.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryDenomOwnersResponseAminoMsg): QueryDenomOwnersResponse { + return QueryDenomOwnersResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryDenomOwnersResponse): QueryDenomOwnersResponseAminoMsg { + return { + type: "cosmos-sdk/QueryDenomOwnersResponse", + value: QueryDenomOwnersResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryDenomOwnersResponseProtoMsg): QueryDenomOwnersResponse { + return QueryDenomOwnersResponse.decode(message.value); + }, + toProto(message: QueryDenomOwnersResponse): Uint8Array { + return QueryDenomOwnersResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryDenomOwnersResponse): QueryDenomOwnersResponseProtoMsg { + return { + typeUrl: "/cosmos.bank.v1beta1.QueryDenomOwnersResponse", + value: QueryDenomOwnersResponse.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/bank/v1beta1/tx.amino.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/bank/v1beta1/tx.amino.ts new file mode 100644 index 0000000000..624fd43388 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/bank/v1beta1/tx.amino.ts @@ -0,0 +1,112 @@ +import { Coin, CoinSDKType } from "../../base/v1beta1/coin.js"; +import { Input, InputSDKType, Output, OutputSDKType } from "./bank.js"; +import { ReadOnlyAminoMsg as AminoMsg } from "@interchainjs/ReadOnlyAminoMsg"; +import { MsgSend, MsgSendSDKType, MsgMultiSend, MsgMultiSendSDKType } from "./tx.js"; +export interface MsgSendAminoType extends AminoMsg { + type: "cosmos-sdk/MsgSend"; + value: { + from_address: string; + to_address: string; + amount: { + denom: string; + amount: string; + }[]; + }; +} +export interface MsgMultiSendAminoType extends AminoMsg { + type: "cosmos-sdk/MsgMultiSend"; + value: { + inputs: { + address: string; + coins: { + denom: string; + amount: string; + }[]; + }[]; + outputs: { + address: string; + coins: { + denom: string; + amount: string; + }[]; + }[]; + }; +} +export const AminoConverter = { + "/cosmos.bank.v1beta1.MsgSend": { + aminoType: "cosmos-sdk/MsgSend", + toAmino: ({ + fromAddress, + toAddress, + amount + }: MsgSend): MsgSendAminoType["value"] => { + return { + from_address: fromAddress, + to_address: toAddress, + amount: amount.map(el0 => ({ + denom: el0.denom, + amount: el0.amount + })) + }; + }, + fromAmino: ({ + from_address, + to_address, + amount + }: MsgSendAminoType["value"]): MsgSend => { + return { + fromAddress: from_address, + toAddress: to_address, + amount: amount.map(el0 => ({ + denom: el0.denom, + amount: el0.amount + })) + }; + } + }, + "/cosmos.bank.v1beta1.MsgMultiSend": { + aminoType: "cosmos-sdk/MsgMultiSend", + toAmino: ({ + inputs, + outputs + }: MsgMultiSend): MsgMultiSendAminoType["value"] => { + return { + inputs: inputs.map(el0 => ({ + address: el0.address, + coins: el0.coins.map(el1 => ({ + denom: el1.denom, + amount: el1.amount + })) + })), + outputs: outputs.map(el0 => ({ + address: el0.address, + coins: el0.coins.map(el1 => ({ + denom: el1.denom, + amount: el1.amount + })) + })) + }; + }, + fromAmino: ({ + inputs, + outputs + }: MsgMultiSendAminoType["value"]): MsgMultiSend => { + return { + inputs: inputs.map(el0 => ({ + address: el0.address, + coins: el0.coins.map(el1 => ({ + denom: el1.denom, + amount: el1.amount + })) + })), + outputs: outputs.map(el0 => ({ + address: el0.address, + coins: el0.coins.map(el1 => ({ + denom: el1.denom, + amount: el1.amount + })) + })) + }; + } + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/bank/v1beta1/tx.registry.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/bank/v1beta1/tx.registry.ts new file mode 100644 index 0000000000..6ac4d5f72b --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/bank/v1beta1/tx.registry.ts @@ -0,0 +1,82 @@ +import { Coin, CoinSDKType } from "../../base/v1beta1/coin.js"; +import { Input, InputSDKType, Output, OutputSDKType } from "./bank.js"; +import { GeneratedType, Registry } from "@cosmjs/proto-signing"; +import { MsgSend, MsgSendSDKType, MsgMultiSend, MsgMultiSendSDKType } from "./tx.js"; +export const registry: ReadonlyArray<[string, GeneratedType]> = [["/cosmos.bank.v1beta1.MsgSend", MsgSend], ["/cosmos.bank.v1beta1.MsgMultiSend", MsgMultiSend]]; +export const load = (protoRegistry: Registry) => { + registry.forEach(([typeUrl, mod]) => { + protoRegistry.register(typeUrl, mod); + }); +}; +export const MessageComposer = { + encoded: { + send(value: MsgSend) { + return { + typeUrl: "/cosmos.bank.v1beta1.MsgSend", + value: MsgSend.encode(value).finish() + }; + }, + multiSend(value: MsgMultiSend) { + return { + typeUrl: "/cosmos.bank.v1beta1.MsgMultiSend", + value: MsgMultiSend.encode(value).finish() + }; + } + }, + withTypeUrl: { + send(value: MsgSend) { + return { + typeUrl: "/cosmos.bank.v1beta1.MsgSend", + value + }; + }, + multiSend(value: MsgMultiSend) { + return { + typeUrl: "/cosmos.bank.v1beta1.MsgMultiSend", + value + }; + } + }, + toJSON: { + send(value: MsgSend) { + return { + typeUrl: "/cosmos.bank.v1beta1.MsgSend", + value: MsgSend.toJSON(value) + }; + }, + multiSend(value: MsgMultiSend) { + return { + typeUrl: "/cosmos.bank.v1beta1.MsgMultiSend", + value: MsgMultiSend.toJSON(value) + }; + } + }, + fromJSON: { + send(value: any) { + return { + typeUrl: "/cosmos.bank.v1beta1.MsgSend", + value: MsgSend.fromJSON(value) + }; + }, + multiSend(value: any) { + return { + typeUrl: "/cosmos.bank.v1beta1.MsgMultiSend", + value: MsgMultiSend.fromJSON(value) + }; + } + }, + fromPartial: { + send(value: MsgSend) { + return { + typeUrl: "/cosmos.bank.v1beta1.MsgSend", + value: MsgSend.fromPartial(value) + }; + }, + multiSend(value: MsgMultiSend) { + return { + typeUrl: "/cosmos.bank.v1beta1.MsgMultiSend", + value: MsgMultiSend.fromPartial(value) + }; + } + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/bank/v1beta1/tx.rpc.func.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/bank/v1beta1/tx.rpc.func.ts new file mode 100644 index 0000000000..b3ba5e957d --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/bank/v1beta1/tx.rpc.func.ts @@ -0,0 +1,22 @@ +import { buildTx, SigningClientResolver } from "../../../helper-func-types"; +import { buildUseMutation } from "../../../react-query"; +import { toEncoders, toConverters } from "@interchainjs/cosmos/utils"; +import { MsgSend, MsgMultiSend } from "./tx"; +export const createSend = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgSend.typeUrl, + encoders: toEncoders(MsgSend), + converters: toConverters(MsgSend) +}); +export const useSend = buildUseMutation({ + builderMutationFn: createSend +}); +export const createMultiSend = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgMultiSend.typeUrl, + encoders: toEncoders(MsgMultiSend), + converters: toConverters(MsgMultiSend) +}); +export const useMultiSend = buildUseMutation({ + builderMutationFn: createMultiSend +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/bank/v1beta1/tx.rpc.msg.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/bank/v1beta1/tx.rpc.msg.ts new file mode 100644 index 0000000000..50076e3fcb --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/bank/v1beta1/tx.rpc.msg.ts @@ -0,0 +1,33 @@ +import { Coin, CoinSDKType } from "../../base/v1beta1/coin.js"; +import { Input, InputSDKType, Output, OutputSDKType } from "./bank.js"; +import { Rpc } from "../../../helpers.js"; +import { BinaryReader } from "../../../binary.js"; +import { MsgSend, MsgSendSDKType, MsgSendResponse, MsgSendResponseSDKType, MsgMultiSend, MsgMultiSendSDKType, MsgMultiSendResponse, MsgMultiSendResponseSDKType } from "./tx.js"; +/** Msg defines the bank Msg service. */ +export interface Msg { + /** Send defines a method for sending coins from one account to another account. */ + send(request: MsgSend): Promise; + /** MultiSend defines a method for sending coins from some accounts to other accounts. */ + multiSend(request: MsgMultiSend): Promise; +} +export class MsgClientImpl implements Msg { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + this.send = this.send.bind(this); + this.multiSend = this.multiSend.bind(this); + } + send(request: MsgSend): Promise { + const data = MsgSend.encode(request).finish(); + const promise = this.rpc.request("cosmos.bank.v1beta1.Msg", "Send", data); + return promise.then(data => MsgSendResponse.decode(new BinaryReader(data))); + } + multiSend(request: MsgMultiSend): Promise { + const data = MsgMultiSend.encode(request).finish(); + const promise = this.rpc.request("cosmos.bank.v1beta1.Msg", "MultiSend", data); + return promise.then(data => MsgMultiSendResponse.decode(new BinaryReader(data))); + } +} +export const createClientImpl = (rpc: Rpc) => { + return new MsgClientImpl(rpc); +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/bank/v1beta1/tx.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/bank/v1beta1/tx.ts new file mode 100644 index 0000000000..56a4850e78 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/bank/v1beta1/tx.ts @@ -0,0 +1,469 @@ +import { Coin, CoinSDKType } from "../../base/v1beta1/coin.js"; +import { Input, InputSDKType, Output, OutputSDKType } from "./bank.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "cosmos.bank.v1beta1"; +/** MsgSend represents a message to send coins from one account to another. */ +export interface MsgSend { + fromAddress: string; + toAddress: string; + amount: Coin[]; +} +export interface MsgSendProtoMsg { + typeUrl: "/cosmos.bank.v1beta1.MsgSend"; + value: Uint8Array; +} +/** MsgSend represents a message to send coins from one account to another. */ +export interface MsgSendSDKType { + from_address: string; + to_address: string; + amount: CoinSDKType[]; +} +/** MsgSendResponse defines the Msg/Send response type. */ +export interface MsgSendResponse {} +export interface MsgSendResponseProtoMsg { + typeUrl: "/cosmos.bank.v1beta1.MsgSendResponse"; + value: Uint8Array; +} +/** MsgSendResponse defines the Msg/Send response type. */ +export interface MsgSendResponseSDKType {} +/** MsgMultiSend represents an arbitrary multi-in, multi-out send message. */ +export interface MsgMultiSend { + inputs: Input[]; + outputs: Output[]; +} +export interface MsgMultiSendProtoMsg { + typeUrl: "/cosmos.bank.v1beta1.MsgMultiSend"; + value: Uint8Array; +} +/** MsgMultiSend represents an arbitrary multi-in, multi-out send message. */ +export interface MsgMultiSendSDKType { + inputs: InputSDKType[]; + outputs: OutputSDKType[]; +} +/** MsgMultiSendResponse defines the Msg/MultiSend response type. */ +export interface MsgMultiSendResponse {} +export interface MsgMultiSendResponseProtoMsg { + typeUrl: "/cosmos.bank.v1beta1.MsgMultiSendResponse"; + value: Uint8Array; +} +/** MsgMultiSendResponse defines the Msg/MultiSend response type. */ +export interface MsgMultiSendResponseSDKType {} +function createBaseMsgSend(): MsgSend { + return { + fromAddress: "", + toAddress: "", + amount: [] + }; +} +export const MsgSend = { + typeUrl: "/cosmos.bank.v1beta1.MsgSend", + encode(message: MsgSend, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.fromAddress !== undefined) { + writer.uint32(10).string(message.fromAddress); + } + if (message.toAddress !== undefined) { + writer.uint32(18).string(message.toAddress); + } + for (const v of message.amount) { + Coin.encode(v!, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgSend { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgSend(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.fromAddress = reader.string(); + break; + case 2: + message.toAddress = reader.string(); + break; + case 3: + message.amount.push(Coin.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgSend { + const obj = createBaseMsgSend(); + if (isSet(object.fromAddress)) obj.fromAddress = String(object.fromAddress); + if (isSet(object.toAddress)) obj.toAddress = String(object.toAddress); + if (Array.isArray(object?.amount)) obj.amount = object.amount.map((e: any) => Coin.fromJSON(e)); + return obj; + }, + toJSON(message: MsgSend): JsonSafe { + const obj: any = {}; + message.fromAddress !== undefined && (obj.fromAddress = message.fromAddress); + message.toAddress !== undefined && (obj.toAddress = message.toAddress); + if (message.amount) { + obj.amount = message.amount.map(e => e ? Coin.toJSON(e) : undefined); + } else { + obj.amount = []; + } + return obj; + }, + fromPartial(object: DeepPartial): MsgSend { + const message = createBaseMsgSend(); + message.fromAddress = object.fromAddress ?? ""; + message.toAddress = object.toAddress ?? ""; + message.amount = object.amount?.map(e => Coin.fromPartial(e)) || []; + return message; + }, + fromSDK(object: MsgSendSDKType): MsgSend { + return { + fromAddress: object?.from_address, + toAddress: object?.to_address, + amount: Array.isArray(object?.amount) ? object.amount.map((e: any) => Coin.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): MsgSendSDKType { + return { + from_address: isSet(object.from_address) ? String(object.from_address) : "", + to_address: isSet(object.to_address) ? String(object.to_address) : "", + amount: Array.isArray(object?.amount) ? object.amount.map((e: any) => Coin.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: MsgSend): MsgSendSDKType { + const obj: any = {}; + obj.from_address = message.fromAddress; + obj.to_address = message.toAddress; + if (message.amount) { + obj.amount = message.amount.map(e => e ? Coin.toSDK(e) : undefined); + } else { + obj.amount = []; + } + return obj; + }, + fromAmino(object: MsgSendAmino): MsgSend { + const message = createBaseMsgSend(); + if (object.from_address !== undefined && object.from_address !== null) { + message.fromAddress = object.from_address; + } + if (object.to_address !== undefined && object.to_address !== null) { + message.toAddress = object.to_address; + } + message.amount = object.amount?.map(e => Coin.fromAmino(e)) || []; + return message; + }, + toAmino(message: MsgSend): MsgSendAmino { + const obj: any = {}; + obj.from_address = message.fromAddress === "" ? undefined : message.fromAddress; + obj.to_address = message.toAddress === "" ? undefined : message.toAddress; + if (message.amount) { + obj.amount = message.amount.map(e => e ? Coin.toAmino(e) : undefined); + } else { + obj.amount = message.amount; + } + return obj; + }, + fromAminoMsg(object: MsgSendAminoMsg): MsgSend { + return MsgSend.fromAmino(object.value); + }, + toAminoMsg(message: MsgSend): MsgSendAminoMsg { + return { + type: "cosmos-sdk/MsgSend", + value: MsgSend.toAmino(message) + }; + }, + fromProtoMsg(message: MsgSendProtoMsg): MsgSend { + return MsgSend.decode(message.value); + }, + toProto(message: MsgSend): Uint8Array { + return MsgSend.encode(message).finish(); + }, + toProtoMsg(message: MsgSend): MsgSendProtoMsg { + return { + typeUrl: "/cosmos.bank.v1beta1.MsgSend", + value: MsgSend.encode(message).finish() + }; + } +}; +function createBaseMsgSendResponse(): MsgSendResponse { + return {}; +} +export const MsgSendResponse = { + typeUrl: "/cosmos.bank.v1beta1.MsgSendResponse", + encode(_: MsgSendResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgSendResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgSendResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgSendResponse { + const obj = createBaseMsgSendResponse(); + return obj; + }, + toJSON(_: MsgSendResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): MsgSendResponse { + const message = createBaseMsgSendResponse(); + return message; + }, + fromSDK(_: MsgSendResponseSDKType): MsgSendResponse { + return {}; + }, + fromSDKJSON(_: any): MsgSendResponseSDKType { + return {}; + }, + toSDK(_: MsgSendResponse): MsgSendResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgSendResponseAmino): MsgSendResponse { + const message = createBaseMsgSendResponse(); + return message; + }, + toAmino(_: MsgSendResponse): MsgSendResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgSendResponseAminoMsg): MsgSendResponse { + return MsgSendResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgSendResponse): MsgSendResponseAminoMsg { + return { + type: "cosmos-sdk/MsgSendResponse", + value: MsgSendResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgSendResponseProtoMsg): MsgSendResponse { + return MsgSendResponse.decode(message.value); + }, + toProto(message: MsgSendResponse): Uint8Array { + return MsgSendResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgSendResponse): MsgSendResponseProtoMsg { + return { + typeUrl: "/cosmos.bank.v1beta1.MsgSendResponse", + value: MsgSendResponse.encode(message).finish() + }; + } +}; +function createBaseMsgMultiSend(): MsgMultiSend { + return { + inputs: [], + outputs: [] + }; +} +export const MsgMultiSend = { + typeUrl: "/cosmos.bank.v1beta1.MsgMultiSend", + encode(message: MsgMultiSend, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.inputs) { + Input.encode(v!, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.outputs) { + Output.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgMultiSend { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgMultiSend(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.inputs.push(Input.decode(reader, reader.uint32())); + break; + case 2: + message.outputs.push(Output.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgMultiSend { + const obj = createBaseMsgMultiSend(); + if (Array.isArray(object?.inputs)) obj.inputs = object.inputs.map((e: any) => Input.fromJSON(e)); + if (Array.isArray(object?.outputs)) obj.outputs = object.outputs.map((e: any) => Output.fromJSON(e)); + return obj; + }, + toJSON(message: MsgMultiSend): JsonSafe { + const obj: any = {}; + if (message.inputs) { + obj.inputs = message.inputs.map(e => e ? Input.toJSON(e) : undefined); + } else { + obj.inputs = []; + } + if (message.outputs) { + obj.outputs = message.outputs.map(e => e ? Output.toJSON(e) : undefined); + } else { + obj.outputs = []; + } + return obj; + }, + fromPartial(object: DeepPartial): MsgMultiSend { + const message = createBaseMsgMultiSend(); + message.inputs = object.inputs?.map(e => Input.fromPartial(e)) || []; + message.outputs = object.outputs?.map(e => Output.fromPartial(e)) || []; + return message; + }, + fromSDK(object: MsgMultiSendSDKType): MsgMultiSend { + return { + inputs: Array.isArray(object?.inputs) ? object.inputs.map((e: any) => Input.fromSDK(e)) : [], + outputs: Array.isArray(object?.outputs) ? object.outputs.map((e: any) => Output.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): MsgMultiSendSDKType { + return { + inputs: Array.isArray(object?.inputs) ? object.inputs.map((e: any) => Input.fromSDKJSON(e)) : [], + outputs: Array.isArray(object?.outputs) ? object.outputs.map((e: any) => Output.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: MsgMultiSend): MsgMultiSendSDKType { + const obj: any = {}; + if (message.inputs) { + obj.inputs = message.inputs.map(e => e ? Input.toSDK(e) : undefined); + } else { + obj.inputs = []; + } + if (message.outputs) { + obj.outputs = message.outputs.map(e => e ? Output.toSDK(e) : undefined); + } else { + obj.outputs = []; + } + return obj; + }, + fromAmino(object: MsgMultiSendAmino): MsgMultiSend { + const message = createBaseMsgMultiSend(); + message.inputs = object.inputs?.map(e => Input.fromAmino(e)) || []; + message.outputs = object.outputs?.map(e => Output.fromAmino(e)) || []; + return message; + }, + toAmino(message: MsgMultiSend): MsgMultiSendAmino { + const obj: any = {}; + if (message.inputs) { + obj.inputs = message.inputs.map(e => e ? Input.toAmino(e) : undefined); + } else { + obj.inputs = message.inputs; + } + if (message.outputs) { + obj.outputs = message.outputs.map(e => e ? Output.toAmino(e) : undefined); + } else { + obj.outputs = message.outputs; + } + return obj; + }, + fromAminoMsg(object: MsgMultiSendAminoMsg): MsgMultiSend { + return MsgMultiSend.fromAmino(object.value); + }, + toAminoMsg(message: MsgMultiSend): MsgMultiSendAminoMsg { + return { + type: "cosmos-sdk/MsgMultiSend", + value: MsgMultiSend.toAmino(message) + }; + }, + fromProtoMsg(message: MsgMultiSendProtoMsg): MsgMultiSend { + return MsgMultiSend.decode(message.value); + }, + toProto(message: MsgMultiSend): Uint8Array { + return MsgMultiSend.encode(message).finish(); + }, + toProtoMsg(message: MsgMultiSend): MsgMultiSendProtoMsg { + return { + typeUrl: "/cosmos.bank.v1beta1.MsgMultiSend", + value: MsgMultiSend.encode(message).finish() + }; + } +}; +function createBaseMsgMultiSendResponse(): MsgMultiSendResponse { + return {}; +} +export const MsgMultiSendResponse = { + typeUrl: "/cosmos.bank.v1beta1.MsgMultiSendResponse", + encode(_: MsgMultiSendResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgMultiSendResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgMultiSendResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgMultiSendResponse { + const obj = createBaseMsgMultiSendResponse(); + return obj; + }, + toJSON(_: MsgMultiSendResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): MsgMultiSendResponse { + const message = createBaseMsgMultiSendResponse(); + return message; + }, + fromSDK(_: MsgMultiSendResponseSDKType): MsgMultiSendResponse { + return {}; + }, + fromSDKJSON(_: any): MsgMultiSendResponseSDKType { + return {}; + }, + toSDK(_: MsgMultiSendResponse): MsgMultiSendResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgMultiSendResponseAmino): MsgMultiSendResponse { + const message = createBaseMsgMultiSendResponse(); + return message; + }, + toAmino(_: MsgMultiSendResponse): MsgMultiSendResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgMultiSendResponseAminoMsg): MsgMultiSendResponse { + return MsgMultiSendResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgMultiSendResponse): MsgMultiSendResponseAminoMsg { + return { + type: "cosmos-sdk/MsgMultiSendResponse", + value: MsgMultiSendResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgMultiSendResponseProtoMsg): MsgMultiSendResponse { + return MsgMultiSendResponse.decode(message.value); + }, + toProto(message: MsgMultiSendResponse): Uint8Array { + return MsgMultiSendResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgMultiSendResponse): MsgMultiSendResponseProtoMsg { + return { + typeUrl: "/cosmos.bank.v1beta1.MsgMultiSendResponse", + value: MsgMultiSendResponse.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/base/abci/v1beta1/abci.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/base/abci/v1beta1/abci.ts new file mode 100644 index 0000000000..6386533ede --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/base/abci/v1beta1/abci.ts @@ -0,0 +1,1817 @@ +import { Any, AnySDKType } from "../../../../google/protobuf/any.js"; +import { Event, EventSDKType } from "../../../../tendermint/abci/types.js"; +import { BinaryReader, BinaryWriter } from "../../../../binary.js"; +import { isSet, DeepPartial, bytesFromBase64, base64FromBytes } from "../../../../helpers.js"; +import { JsonSafe } from "../../../../json-safe.js"; +export const protobufPackage = "cosmos.base.abci.v1beta1"; +/** + * TxResponse defines a structure containing relevant tx data and metadata. The + * tags are stringified and the log is JSON decoded. + */ +export interface TxResponse { + /** The block height */ + height: bigint; + /** The transaction hash. */ + txhash: string; + /** Namespace for the Code */ + codespace: string; + /** Response code. */ + code: number; + /** Result bytes, if any. */ + data: string; + /** + * The output of the application's logger (raw string). May be + * non-deterministic. + */ + rawLog: string; + /** The output of the application's logger (typed). May be non-deterministic. */ + logs: ABCIMessageLog[]; + /** Additional information. May be non-deterministic. */ + info: string; + /** Amount of gas requested for transaction. */ + gasWanted: bigint; + /** Amount of gas consumed by transaction. */ + gasUsed: bigint; + /** The request transaction bytes. */ + tx?: Any; + /** + * Time of the previous block. For heights > 1, it's the weighted median of + * the timestamps of the valid votes in the block.LastCommit. For height == 1, + * it's genesis time. + */ + timestamp: string; + /** + * Events defines all the events emitted by processing a transaction. Note, + * these events include those emitted by processing all the messages and those + * emitted from the ante handler. Whereas Logs contains the events, with + * additional metadata, emitted only by processing the messages. + * + * Since: cosmos-sdk 0.42.11, 0.44.5, 0.45 + */ + events: Event[]; +} +export interface TxResponseProtoMsg { + typeUrl: "/cosmos.base.abci.v1beta1.TxResponse"; + value: Uint8Array; +} +/** + * TxResponse defines a structure containing relevant tx data and metadata. The + * tags are stringified and the log is JSON decoded. + */ +export interface TxResponseSDKType { + height: bigint; + txhash: string; + codespace: string; + code: number; + data: string; + raw_log: string; + logs: ABCIMessageLogSDKType[]; + info: string; + gas_wanted: bigint; + gas_used: bigint; + tx?: AnySDKType; + timestamp: string; + events: EventSDKType[]; +} +/** ABCIMessageLog defines a structure containing an indexed tx ABCI message log. */ +export interface ABCIMessageLog { + msgIndex: number; + log: string; + /** + * Events contains a slice of Event objects that were emitted during some + * execution. + */ + events: StringEvent[]; +} +export interface ABCIMessageLogProtoMsg { + typeUrl: "/cosmos.base.abci.v1beta1.ABCIMessageLog"; + value: Uint8Array; +} +/** ABCIMessageLog defines a structure containing an indexed tx ABCI message log. */ +export interface ABCIMessageLogSDKType { + msg_index: number; + log: string; + events: StringEventSDKType[]; +} +/** + * StringEvent defines en Event object wrapper where all the attributes + * contain key/value pairs that are strings instead of raw bytes. + */ +export interface StringEvent { + type: string; + attributes: Attribute[]; +} +export interface StringEventProtoMsg { + typeUrl: "/cosmos.base.abci.v1beta1.StringEvent"; + value: Uint8Array; +} +/** + * StringEvent defines en Event object wrapper where all the attributes + * contain key/value pairs that are strings instead of raw bytes. + */ +export interface StringEventSDKType { + type: string; + attributes: AttributeSDKType[]; +} +/** + * Attribute defines an attribute wrapper where the key and value are + * strings instead of raw bytes. + */ +export interface Attribute { + key: string; + value: string; +} +export interface AttributeProtoMsg { + typeUrl: "/cosmos.base.abci.v1beta1.Attribute"; + value: Uint8Array; +} +/** + * Attribute defines an attribute wrapper where the key and value are + * strings instead of raw bytes. + */ +export interface AttributeSDKType { + key: string; + value: string; +} +/** GasInfo defines tx execution gas context. */ +export interface GasInfo { + /** GasWanted is the maximum units of work we allow this tx to perform. */ + gasWanted: bigint; + /** GasUsed is the amount of gas actually consumed. */ + gasUsed: bigint; +} +export interface GasInfoProtoMsg { + typeUrl: "/cosmos.base.abci.v1beta1.GasInfo"; + value: Uint8Array; +} +/** GasInfo defines tx execution gas context. */ +export interface GasInfoSDKType { + gas_wanted: bigint; + gas_used: bigint; +} +/** Result is the union of ResponseFormat and ResponseCheckTx. */ +export interface Result { + /** + * Data is any data returned from message or handler execution. It MUST be + * length prefixed in order to separate data from multiple message executions. + * Deprecated. This field is still populated, but prefer msg_response instead + * because it also contains the Msg response typeURL. + */ + /** @deprecated */ + data: Uint8Array; + /** Log contains the log information from message or handler execution. */ + log: string; + /** + * Events contains a slice of Event objects that were emitted during message + * or handler execution. + */ + events: Event[]; + /** + * msg_responses contains the Msg handler responses type packed in Anys. + * + * Since: cosmos-sdk 0.46 + */ + msgResponses: Any[]; +} +export interface ResultProtoMsg { + typeUrl: "/cosmos.base.abci.v1beta1.Result"; + value: Uint8Array; +} +/** Result is the union of ResponseFormat and ResponseCheckTx. */ +export interface ResultSDKType { + /** @deprecated */ + data: Uint8Array; + log: string; + events: EventSDKType[]; + msg_responses: AnySDKType[]; +} +/** + * SimulationResponse defines the response generated when a transaction is + * successfully simulated. + */ +export interface SimulationResponse { + gasInfo: GasInfo; + result?: Result; +} +export interface SimulationResponseProtoMsg { + typeUrl: "/cosmos.base.abci.v1beta1.SimulationResponse"; + value: Uint8Array; +} +/** + * SimulationResponse defines the response generated when a transaction is + * successfully simulated. + */ +export interface SimulationResponseSDKType { + gas_info: GasInfoSDKType; + result?: ResultSDKType; +} +/** + * MsgData defines the data returned in a Result object during message + * execution. + */ +/** @deprecated */ +export interface MsgData { + msgType: string; + data: Uint8Array; +} +export interface MsgDataProtoMsg { + typeUrl: "/cosmos.base.abci.v1beta1.MsgData"; + value: Uint8Array; +} +/** + * MsgData defines the data returned in a Result object during message + * execution. + */ +/** @deprecated */ +export interface MsgDataSDKType { + msg_type: string; + data: Uint8Array; +} +/** + * TxMsgData defines a list of MsgData. A transaction will have a MsgData object + * for each message. + */ +export interface TxMsgData { + /** data field is deprecated and not populated. */ + /** @deprecated */ + data: MsgData[]; + /** + * msg_responses contains the Msg handler responses packed into Anys. + * + * Since: cosmos-sdk 0.46 + */ + msgResponses: Any[]; +} +export interface TxMsgDataProtoMsg { + typeUrl: "/cosmos.base.abci.v1beta1.TxMsgData"; + value: Uint8Array; +} +/** + * TxMsgData defines a list of MsgData. A transaction will have a MsgData object + * for each message. + */ +export interface TxMsgDataSDKType { + /** @deprecated */ + data: MsgDataSDKType[]; + msg_responses: AnySDKType[]; +} +/** SearchTxsResult defines a structure for querying txs pageable */ +export interface SearchTxsResult { + /** Count of all txs */ + totalCount: bigint; + /** Count of txs in current page */ + count: bigint; + /** Index of current page, start from 1 */ + pageNumber: bigint; + /** Count of total pages */ + pageTotal: bigint; + /** Max count txs per page */ + limit: bigint; + /** List of txs in current page */ + txs: TxResponse[]; +} +export interface SearchTxsResultProtoMsg { + typeUrl: "/cosmos.base.abci.v1beta1.SearchTxsResult"; + value: Uint8Array; +} +/** SearchTxsResult defines a structure for querying txs pageable */ +export interface SearchTxsResultSDKType { + total_count: bigint; + count: bigint; + page_number: bigint; + page_total: bigint; + limit: bigint; + txs: TxResponseSDKType[]; +} +function createBaseTxResponse(): TxResponse { + return { + height: BigInt(0), + txhash: "", + codespace: "", + code: 0, + data: "", + rawLog: "", + logs: [], + info: "", + gasWanted: BigInt(0), + gasUsed: BigInt(0), + tx: undefined, + timestamp: "", + events: [] + }; +} +export const TxResponse = { + typeUrl: "/cosmos.base.abci.v1beta1.TxResponse", + encode(message: TxResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.height !== undefined) { + writer.uint32(8).int64(message.height); + } + if (message.txhash !== undefined) { + writer.uint32(18).string(message.txhash); + } + if (message.codespace !== undefined) { + writer.uint32(26).string(message.codespace); + } + if (message.code !== undefined) { + writer.uint32(32).uint32(message.code); + } + if (message.data !== undefined) { + writer.uint32(42).string(message.data); + } + if (message.rawLog !== undefined) { + writer.uint32(50).string(message.rawLog); + } + for (const v of message.logs) { + ABCIMessageLog.encode(v!, writer.uint32(58).fork()).ldelim(); + } + if (message.info !== undefined) { + writer.uint32(66).string(message.info); + } + if (message.gasWanted !== undefined) { + writer.uint32(72).int64(message.gasWanted); + } + if (message.gasUsed !== undefined) { + writer.uint32(80).int64(message.gasUsed); + } + if (message.tx !== undefined) { + Any.encode(message.tx, writer.uint32(90).fork()).ldelim(); + } + if (message.timestamp !== undefined) { + writer.uint32(98).string(message.timestamp); + } + for (const v of message.events) { + Event.encode(v!, writer.uint32(106).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): TxResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseTxResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.height = reader.int64(); + break; + case 2: + message.txhash = reader.string(); + break; + case 3: + message.codespace = reader.string(); + break; + case 4: + message.code = reader.uint32(); + break; + case 5: + message.data = reader.string(); + break; + case 6: + message.rawLog = reader.string(); + break; + case 7: + message.logs.push(ABCIMessageLog.decode(reader, reader.uint32())); + break; + case 8: + message.info = reader.string(); + break; + case 9: + message.gasWanted = reader.int64(); + break; + case 10: + message.gasUsed = reader.int64(); + break; + case 11: + message.tx = Any.decode(reader, reader.uint32()); + break; + case 12: + message.timestamp = reader.string(); + break; + case 13: + message.events.push(Event.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): TxResponse { + const obj = createBaseTxResponse(); + if (isSet(object.height)) obj.height = BigInt(object.height.toString()); + if (isSet(object.txhash)) obj.txhash = String(object.txhash); + if (isSet(object.codespace)) obj.codespace = String(object.codespace); + if (isSet(object.code)) obj.code = Number(object.code); + if (isSet(object.data)) obj.data = String(object.data); + if (isSet(object.rawLog)) obj.rawLog = String(object.rawLog); + if (Array.isArray(object?.logs)) obj.logs = object.logs.map((e: any) => ABCIMessageLog.fromJSON(e)); + if (isSet(object.info)) obj.info = String(object.info); + if (isSet(object.gasWanted)) obj.gasWanted = BigInt(object.gasWanted.toString()); + if (isSet(object.gasUsed)) obj.gasUsed = BigInt(object.gasUsed.toString()); + if (isSet(object.tx)) obj.tx = Any.fromJSON(object.tx); + if (isSet(object.timestamp)) obj.timestamp = String(object.timestamp); + if (Array.isArray(object?.events)) obj.events = object.events.map((e: any) => Event.fromJSON(e)); + return obj; + }, + toJSON(message: TxResponse): JsonSafe { + const obj: any = {}; + message.height !== undefined && (obj.height = (message.height || BigInt(0)).toString()); + message.txhash !== undefined && (obj.txhash = message.txhash); + message.codespace !== undefined && (obj.codespace = message.codespace); + message.code !== undefined && (obj.code = Math.round(message.code)); + message.data !== undefined && (obj.data = message.data); + message.rawLog !== undefined && (obj.rawLog = message.rawLog); + if (message.logs) { + obj.logs = message.logs.map(e => e ? ABCIMessageLog.toJSON(e) : undefined); + } else { + obj.logs = []; + } + message.info !== undefined && (obj.info = message.info); + message.gasWanted !== undefined && (obj.gasWanted = (message.gasWanted || BigInt(0)).toString()); + message.gasUsed !== undefined && (obj.gasUsed = (message.gasUsed || BigInt(0)).toString()); + message.tx !== undefined && (obj.tx = message.tx ? Any.toJSON(message.tx) : undefined); + message.timestamp !== undefined && (obj.timestamp = message.timestamp); + if (message.events) { + obj.events = message.events.map(e => e ? Event.toJSON(e) : undefined); + } else { + obj.events = []; + } + return obj; + }, + fromPartial(object: DeepPartial): TxResponse { + const message = createBaseTxResponse(); + if (object.height !== undefined && object.height !== null) { + message.height = BigInt(object.height.toString()); + } + message.txhash = object.txhash ?? ""; + message.codespace = object.codespace ?? ""; + message.code = object.code ?? 0; + message.data = object.data ?? ""; + message.rawLog = object.rawLog ?? ""; + message.logs = object.logs?.map(e => ABCIMessageLog.fromPartial(e)) || []; + message.info = object.info ?? ""; + if (object.gasWanted !== undefined && object.gasWanted !== null) { + message.gasWanted = BigInt(object.gasWanted.toString()); + } + if (object.gasUsed !== undefined && object.gasUsed !== null) { + message.gasUsed = BigInt(object.gasUsed.toString()); + } + if (object.tx !== undefined && object.tx !== null) { + message.tx = Any.fromPartial(object.tx); + } + message.timestamp = object.timestamp ?? ""; + message.events = object.events?.map(e => Event.fromPartial(e)) || []; + return message; + }, + fromSDK(object: TxResponseSDKType): TxResponse { + return { + height: object?.height, + txhash: object?.txhash, + codespace: object?.codespace, + code: object?.code, + data: object?.data, + rawLog: object?.raw_log, + logs: Array.isArray(object?.logs) ? object.logs.map((e: any) => ABCIMessageLog.fromSDK(e)) : [], + info: object?.info, + gasWanted: object?.gas_wanted, + gasUsed: object?.gas_used, + tx: object.tx ? Any.fromSDK(object.tx) : undefined, + timestamp: object?.timestamp, + events: Array.isArray(object?.events) ? object.events.map((e: any) => Event.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): TxResponseSDKType { + return { + height: isSet(object.height) ? BigInt(object.height.toString()) : BigInt(0), + txhash: isSet(object.txhash) ? String(object.txhash) : "", + codespace: isSet(object.codespace) ? String(object.codespace) : "", + code: isSet(object.code) ? Number(object.code) : 0, + data: isSet(object.data) ? String(object.data) : "", + raw_log: isSet(object.raw_log) ? String(object.raw_log) : "", + logs: Array.isArray(object?.logs) ? object.logs.map((e: any) => ABCIMessageLog.fromSDKJSON(e)) : [], + info: isSet(object.info) ? String(object.info) : "", + gas_wanted: isSet(object.gas_wanted) ? BigInt(object.gas_wanted.toString()) : BigInt(0), + gas_used: isSet(object.gas_used) ? BigInt(object.gas_used.toString()) : BigInt(0), + tx: isSet(object.tx) ? Any.fromSDKJSON(object.tx) : undefined, + timestamp: isSet(object.timestamp) ? String(object.timestamp) : "", + events: Array.isArray(object?.events) ? object.events.map((e: any) => Event.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: TxResponse): TxResponseSDKType { + const obj: any = {}; + obj.height = message.height; + obj.txhash = message.txhash; + obj.codespace = message.codespace; + obj.code = message.code; + obj.data = message.data; + obj.raw_log = message.rawLog; + if (message.logs) { + obj.logs = message.logs.map(e => e ? ABCIMessageLog.toSDK(e) : undefined); + } else { + obj.logs = []; + } + obj.info = message.info; + obj.gas_wanted = message.gasWanted; + obj.gas_used = message.gasUsed; + message.tx !== undefined && (obj.tx = message.tx ? Any.toSDK(message.tx) : undefined); + obj.timestamp = message.timestamp; + if (message.events) { + obj.events = message.events.map(e => e ? Event.toSDK(e) : undefined); + } else { + obj.events = []; + } + return obj; + }, + fromAmino(object: TxResponseAmino): TxResponse { + const message = createBaseTxResponse(); + if (object.height !== undefined && object.height !== null) { + message.height = BigInt(object.height); + } + if (object.txhash !== undefined && object.txhash !== null) { + message.txhash = object.txhash; + } + if (object.codespace !== undefined && object.codespace !== null) { + message.codespace = object.codespace; + } + if (object.code !== undefined && object.code !== null) { + message.code = object.code; + } + if (object.data !== undefined && object.data !== null) { + message.data = object.data; + } + if (object.raw_log !== undefined && object.raw_log !== null) { + message.rawLog = object.raw_log; + } + message.logs = object.logs?.map(e => ABCIMessageLog.fromAmino(e)) || []; + if (object.info !== undefined && object.info !== null) { + message.info = object.info; + } + if (object.gas_wanted !== undefined && object.gas_wanted !== null) { + message.gasWanted = BigInt(object.gas_wanted); + } + if (object.gas_used !== undefined && object.gas_used !== null) { + message.gasUsed = BigInt(object.gas_used); + } + if (object.tx !== undefined && object.tx !== null) { + message.tx = Any.fromAmino(object.tx); + } + if (object.timestamp !== undefined && object.timestamp !== null) { + message.timestamp = object.timestamp; + } + message.events = object.events?.map(e => Event.fromAmino(e)) || []; + return message; + }, + toAmino(message: TxResponse): TxResponseAmino { + const obj: any = {}; + obj.height = message.height !== BigInt(0) ? message.height?.toString() : undefined; + obj.txhash = message.txhash === "" ? undefined : message.txhash; + obj.codespace = message.codespace === "" ? undefined : message.codespace; + obj.code = message.code === 0 ? undefined : message.code; + obj.data = message.data === "" ? undefined : message.data; + obj.raw_log = message.rawLog === "" ? undefined : message.rawLog; + if (message.logs) { + obj.logs = message.logs.map(e => e ? ABCIMessageLog.toAmino(e) : undefined); + } else { + obj.logs = message.logs; + } + obj.info = message.info === "" ? undefined : message.info; + obj.gas_wanted = message.gasWanted !== BigInt(0) ? message.gasWanted?.toString() : undefined; + obj.gas_used = message.gasUsed !== BigInt(0) ? message.gasUsed?.toString() : undefined; + obj.tx = message.tx ? Any.toAmino(message.tx) : undefined; + obj.timestamp = message.timestamp === "" ? undefined : message.timestamp; + if (message.events) { + obj.events = message.events.map(e => e ? Event.toAmino(e) : undefined); + } else { + obj.events = message.events; + } + return obj; + }, + fromAminoMsg(object: TxResponseAminoMsg): TxResponse { + return TxResponse.fromAmino(object.value); + }, + toAminoMsg(message: TxResponse): TxResponseAminoMsg { + return { + type: "cosmos-sdk/TxResponse", + value: TxResponse.toAmino(message) + }; + }, + fromProtoMsg(message: TxResponseProtoMsg): TxResponse { + return TxResponse.decode(message.value); + }, + toProto(message: TxResponse): Uint8Array { + return TxResponse.encode(message).finish(); + }, + toProtoMsg(message: TxResponse): TxResponseProtoMsg { + return { + typeUrl: "/cosmos.base.abci.v1beta1.TxResponse", + value: TxResponse.encode(message).finish() + }; + } +}; +function createBaseABCIMessageLog(): ABCIMessageLog { + return { + msgIndex: 0, + log: "", + events: [] + }; +} +export const ABCIMessageLog = { + typeUrl: "/cosmos.base.abci.v1beta1.ABCIMessageLog", + encode(message: ABCIMessageLog, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.msgIndex !== undefined) { + writer.uint32(8).uint32(message.msgIndex); + } + if (message.log !== undefined) { + writer.uint32(18).string(message.log); + } + for (const v of message.events) { + StringEvent.encode(v!, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ABCIMessageLog { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseABCIMessageLog(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.msgIndex = reader.uint32(); + break; + case 2: + message.log = reader.string(); + break; + case 3: + message.events.push(StringEvent.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ABCIMessageLog { + const obj = createBaseABCIMessageLog(); + if (isSet(object.msgIndex)) obj.msgIndex = Number(object.msgIndex); + if (isSet(object.log)) obj.log = String(object.log); + if (Array.isArray(object?.events)) obj.events = object.events.map((e: any) => StringEvent.fromJSON(e)); + return obj; + }, + toJSON(message: ABCIMessageLog): JsonSafe { + const obj: any = {}; + message.msgIndex !== undefined && (obj.msgIndex = Math.round(message.msgIndex)); + message.log !== undefined && (obj.log = message.log); + if (message.events) { + obj.events = message.events.map(e => e ? StringEvent.toJSON(e) : undefined); + } else { + obj.events = []; + } + return obj; + }, + fromPartial(object: DeepPartial): ABCIMessageLog { + const message = createBaseABCIMessageLog(); + message.msgIndex = object.msgIndex ?? 0; + message.log = object.log ?? ""; + message.events = object.events?.map(e => StringEvent.fromPartial(e)) || []; + return message; + }, + fromSDK(object: ABCIMessageLogSDKType): ABCIMessageLog { + return { + msgIndex: object?.msg_index, + log: object?.log, + events: Array.isArray(object?.events) ? object.events.map((e: any) => StringEvent.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): ABCIMessageLogSDKType { + return { + msg_index: isSet(object.msg_index) ? Number(object.msg_index) : 0, + log: isSet(object.log) ? String(object.log) : "", + events: Array.isArray(object?.events) ? object.events.map((e: any) => StringEvent.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: ABCIMessageLog): ABCIMessageLogSDKType { + const obj: any = {}; + obj.msg_index = message.msgIndex; + obj.log = message.log; + if (message.events) { + obj.events = message.events.map(e => e ? StringEvent.toSDK(e) : undefined); + } else { + obj.events = []; + } + return obj; + }, + fromAmino(object: ABCIMessageLogAmino): ABCIMessageLog { + const message = createBaseABCIMessageLog(); + if (object.msg_index !== undefined && object.msg_index !== null) { + message.msgIndex = object.msg_index; + } + if (object.log !== undefined && object.log !== null) { + message.log = object.log; + } + message.events = object.events?.map(e => StringEvent.fromAmino(e)) || []; + return message; + }, + toAmino(message: ABCIMessageLog): ABCIMessageLogAmino { + const obj: any = {}; + obj.msg_index = message.msgIndex ?? 0; + obj.log = message.log === "" ? undefined : message.log; + if (message.events) { + obj.events = message.events.map(e => e ? StringEvent.toAmino(e) : undefined); + } else { + obj.events = message.events; + } + return obj; + }, + fromAminoMsg(object: ABCIMessageLogAminoMsg): ABCIMessageLog { + return ABCIMessageLog.fromAmino(object.value); + }, + toAminoMsg(message: ABCIMessageLog): ABCIMessageLogAminoMsg { + return { + type: "cosmos-sdk/ABCIMessageLog", + value: ABCIMessageLog.toAmino(message) + }; + }, + fromProtoMsg(message: ABCIMessageLogProtoMsg): ABCIMessageLog { + return ABCIMessageLog.decode(message.value); + }, + toProto(message: ABCIMessageLog): Uint8Array { + return ABCIMessageLog.encode(message).finish(); + }, + toProtoMsg(message: ABCIMessageLog): ABCIMessageLogProtoMsg { + return { + typeUrl: "/cosmos.base.abci.v1beta1.ABCIMessageLog", + value: ABCIMessageLog.encode(message).finish() + }; + } +}; +function createBaseStringEvent(): StringEvent { + return { + type: "", + attributes: [] + }; +} +export const StringEvent = { + typeUrl: "/cosmos.base.abci.v1beta1.StringEvent", + encode(message: StringEvent, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.type !== undefined) { + writer.uint32(10).string(message.type); + } + for (const v of message.attributes) { + Attribute.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): StringEvent { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseStringEvent(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.type = reader.string(); + break; + case 2: + message.attributes.push(Attribute.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): StringEvent { + const obj = createBaseStringEvent(); + if (isSet(object.type)) obj.type = String(object.type); + if (Array.isArray(object?.attributes)) obj.attributes = object.attributes.map((e: any) => Attribute.fromJSON(e)); + return obj; + }, + toJSON(message: StringEvent): JsonSafe { + const obj: any = {}; + message.type !== undefined && (obj.type = message.type); + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? Attribute.toJSON(e) : undefined); + } else { + obj.attributes = []; + } + return obj; + }, + fromPartial(object: DeepPartial): StringEvent { + const message = createBaseStringEvent(); + message.type = object.type ?? ""; + message.attributes = object.attributes?.map(e => Attribute.fromPartial(e)) || []; + return message; + }, + fromSDK(object: StringEventSDKType): StringEvent { + return { + type: object?.type, + attributes: Array.isArray(object?.attributes) ? object.attributes.map((e: any) => Attribute.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): StringEventSDKType { + return { + type: isSet(object.type) ? String(object.type) : "", + attributes: Array.isArray(object?.attributes) ? object.attributes.map((e: any) => Attribute.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: StringEvent): StringEventSDKType { + const obj: any = {}; + obj.type = message.type; + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? Attribute.toSDK(e) : undefined); + } else { + obj.attributes = []; + } + return obj; + }, + fromAmino(object: StringEventAmino): StringEvent { + const message = createBaseStringEvent(); + if (object.type !== undefined && object.type !== null) { + message.type = object.type; + } + message.attributes = object.attributes?.map(e => Attribute.fromAmino(e)) || []; + return message; + }, + toAmino(message: StringEvent): StringEventAmino { + const obj: any = {}; + obj.type = message.type === "" ? undefined : message.type; + if (message.attributes) { + obj.attributes = message.attributes.map(e => e ? Attribute.toAmino(e) : undefined); + } else { + obj.attributes = message.attributes; + } + return obj; + }, + fromAminoMsg(object: StringEventAminoMsg): StringEvent { + return StringEvent.fromAmino(object.value); + }, + toAminoMsg(message: StringEvent): StringEventAminoMsg { + return { + type: "cosmos-sdk/StringEvent", + value: StringEvent.toAmino(message) + }; + }, + fromProtoMsg(message: StringEventProtoMsg): StringEvent { + return StringEvent.decode(message.value); + }, + toProto(message: StringEvent): Uint8Array { + return StringEvent.encode(message).finish(); + }, + toProtoMsg(message: StringEvent): StringEventProtoMsg { + return { + typeUrl: "/cosmos.base.abci.v1beta1.StringEvent", + value: StringEvent.encode(message).finish() + }; + } +}; +function createBaseAttribute(): Attribute { + return { + key: "", + value: "" + }; +} +export const Attribute = { + typeUrl: "/cosmos.base.abci.v1beta1.Attribute", + encode(message: Attribute, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.key !== undefined) { + writer.uint32(10).string(message.key); + } + if (message.value !== undefined) { + writer.uint32(18).string(message.value); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Attribute { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseAttribute(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.string(); + break; + case 2: + message.value = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Attribute { + const obj = createBaseAttribute(); + if (isSet(object.key)) obj.key = String(object.key); + if (isSet(object.value)) obj.value = String(object.value); + return obj; + }, + toJSON(message: Attribute): JsonSafe { + const obj: any = {}; + message.key !== undefined && (obj.key = message.key); + message.value !== undefined && (obj.value = message.value); + return obj; + }, + fromPartial(object: DeepPartial): Attribute { + const message = createBaseAttribute(); + message.key = object.key ?? ""; + message.value = object.value ?? ""; + return message; + }, + fromSDK(object: AttributeSDKType): Attribute { + return { + key: object?.key, + value: object?.value + }; + }, + fromSDKJSON(object: any): AttributeSDKType { + return { + key: isSet(object.key) ? String(object.key) : "", + value: isSet(object.value) ? String(object.value) : "" + }; + }, + toSDK(message: Attribute): AttributeSDKType { + const obj: any = {}; + obj.key = message.key; + obj.value = message.value; + return obj; + }, + fromAmino(object: AttributeAmino): Attribute { + const message = createBaseAttribute(); + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } + if (object.value !== undefined && object.value !== null) { + message.value = object.value; + } + return message; + }, + toAmino(message: Attribute): AttributeAmino { + const obj: any = {}; + obj.key = message.key === "" ? undefined : message.key; + obj.value = message.value === "" ? undefined : message.value; + return obj; + }, + fromAminoMsg(object: AttributeAminoMsg): Attribute { + return Attribute.fromAmino(object.value); + }, + toAminoMsg(message: Attribute): AttributeAminoMsg { + return { + type: "cosmos-sdk/Attribute", + value: Attribute.toAmino(message) + }; + }, + fromProtoMsg(message: AttributeProtoMsg): Attribute { + return Attribute.decode(message.value); + }, + toProto(message: Attribute): Uint8Array { + return Attribute.encode(message).finish(); + }, + toProtoMsg(message: Attribute): AttributeProtoMsg { + return { + typeUrl: "/cosmos.base.abci.v1beta1.Attribute", + value: Attribute.encode(message).finish() + }; + } +}; +function createBaseGasInfo(): GasInfo { + return { + gasWanted: BigInt(0), + gasUsed: BigInt(0) + }; +} +export const GasInfo = { + typeUrl: "/cosmos.base.abci.v1beta1.GasInfo", + encode(message: GasInfo, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.gasWanted !== undefined) { + writer.uint32(8).uint64(message.gasWanted); + } + if (message.gasUsed !== undefined) { + writer.uint32(16).uint64(message.gasUsed); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GasInfo { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGasInfo(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.gasWanted = reader.uint64(); + break; + case 2: + message.gasUsed = reader.uint64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GasInfo { + const obj = createBaseGasInfo(); + if (isSet(object.gasWanted)) obj.gasWanted = BigInt(object.gasWanted.toString()); + if (isSet(object.gasUsed)) obj.gasUsed = BigInt(object.gasUsed.toString()); + return obj; + }, + toJSON(message: GasInfo): JsonSafe { + const obj: any = {}; + message.gasWanted !== undefined && (obj.gasWanted = (message.gasWanted || BigInt(0)).toString()); + message.gasUsed !== undefined && (obj.gasUsed = (message.gasUsed || BigInt(0)).toString()); + return obj; + }, + fromPartial(object: DeepPartial): GasInfo { + const message = createBaseGasInfo(); + if (object.gasWanted !== undefined && object.gasWanted !== null) { + message.gasWanted = BigInt(object.gasWanted.toString()); + } + if (object.gasUsed !== undefined && object.gasUsed !== null) { + message.gasUsed = BigInt(object.gasUsed.toString()); + } + return message; + }, + fromSDK(object: GasInfoSDKType): GasInfo { + return { + gasWanted: object?.gas_wanted, + gasUsed: object?.gas_used + }; + }, + fromSDKJSON(object: any): GasInfoSDKType { + return { + gas_wanted: isSet(object.gas_wanted) ? BigInt(object.gas_wanted.toString()) : BigInt(0), + gas_used: isSet(object.gas_used) ? BigInt(object.gas_used.toString()) : BigInt(0) + }; + }, + toSDK(message: GasInfo): GasInfoSDKType { + const obj: any = {}; + obj.gas_wanted = message.gasWanted; + obj.gas_used = message.gasUsed; + return obj; + }, + fromAmino(object: GasInfoAmino): GasInfo { + const message = createBaseGasInfo(); + if (object.gas_wanted !== undefined && object.gas_wanted !== null) { + message.gasWanted = BigInt(object.gas_wanted); + } + if (object.gas_used !== undefined && object.gas_used !== null) { + message.gasUsed = BigInt(object.gas_used); + } + return message; + }, + toAmino(message: GasInfo): GasInfoAmino { + const obj: any = {}; + obj.gas_wanted = message.gasWanted !== BigInt(0) ? message.gasWanted?.toString() : undefined; + obj.gas_used = message.gasUsed !== BigInt(0) ? message.gasUsed?.toString() : undefined; + return obj; + }, + fromAminoMsg(object: GasInfoAminoMsg): GasInfo { + return GasInfo.fromAmino(object.value); + }, + toAminoMsg(message: GasInfo): GasInfoAminoMsg { + return { + type: "cosmos-sdk/GasInfo", + value: GasInfo.toAmino(message) + }; + }, + fromProtoMsg(message: GasInfoProtoMsg): GasInfo { + return GasInfo.decode(message.value); + }, + toProto(message: GasInfo): Uint8Array { + return GasInfo.encode(message).finish(); + }, + toProtoMsg(message: GasInfo): GasInfoProtoMsg { + return { + typeUrl: "/cosmos.base.abci.v1beta1.GasInfo", + value: GasInfo.encode(message).finish() + }; + } +}; +function createBaseResult(): Result { + return { + data: new Uint8Array(), + log: "", + events: [], + msgResponses: [] + }; +} +export const Result = { + typeUrl: "/cosmos.base.abci.v1beta1.Result", + encode(message: Result, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.data.length !== 0) { + writer.uint32(10).bytes(message.data); + } + if (message.log !== undefined) { + writer.uint32(18).string(message.log); + } + for (const v of message.events) { + Event.encode(v!, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.msgResponses) { + Any.encode(v!, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Result { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseResult(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.data = reader.bytes(); + break; + case 2: + message.log = reader.string(); + break; + case 3: + message.events.push(Event.decode(reader, reader.uint32())); + break; + case 4: + message.msgResponses.push(Any.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Result { + const obj = createBaseResult(); + if (isSet(object.data)) obj.data = bytesFromBase64(object.data); + if (isSet(object.log)) obj.log = String(object.log); + if (Array.isArray(object?.events)) obj.events = object.events.map((e: any) => Event.fromJSON(e)); + if (Array.isArray(object?.msgResponses)) obj.msgResponses = object.msgResponses.map((e: any) => Any.fromJSON(e)); + return obj; + }, + toJSON(message: Result): JsonSafe { + const obj: any = {}; + message.data !== undefined && (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array())); + message.log !== undefined && (obj.log = message.log); + if (message.events) { + obj.events = message.events.map(e => e ? Event.toJSON(e) : undefined); + } else { + obj.events = []; + } + if (message.msgResponses) { + obj.msgResponses = message.msgResponses.map(e => e ? Any.toJSON(e) : undefined); + } else { + obj.msgResponses = []; + } + return obj; + }, + fromPartial(object: DeepPartial): Result { + const message = createBaseResult(); + message.data = object.data ?? new Uint8Array(); + message.log = object.log ?? ""; + message.events = object.events?.map(e => Event.fromPartial(e)) || []; + message.msgResponses = object.msgResponses?.map(e => Any.fromPartial(e)) || []; + return message; + }, + fromSDK(object: ResultSDKType): Result { + return { + data: object?.data, + log: object?.log, + events: Array.isArray(object?.events) ? object.events.map((e: any) => Event.fromSDK(e)) : [], + msgResponses: Array.isArray(object?.msg_responses) ? object.msg_responses.map((e: any) => Any.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): ResultSDKType { + return { + data: isSet(object.data) ? bytesFromBase64(object.data) : new Uint8Array(), + log: isSet(object.log) ? String(object.log) : "", + events: Array.isArray(object?.events) ? object.events.map((e: any) => Event.fromSDKJSON(e)) : [], + msg_responses: Array.isArray(object?.msg_responses) ? object.msg_responses.map((e: any) => Any.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: Result): ResultSDKType { + const obj: any = {}; + obj.data = message.data; + obj.log = message.log; + if (message.events) { + obj.events = message.events.map(e => e ? Event.toSDK(e) : undefined); + } else { + obj.events = []; + } + if (message.msgResponses) { + obj.msg_responses = message.msgResponses.map(e => e ? Any.toSDK(e) : undefined); + } else { + obj.msg_responses = []; + } + return obj; + }, + fromAmino(object: ResultAmino): Result { + const message = createBaseResult(); + if (object.data !== undefined && object.data !== null) { + message.data = bytesFromBase64(object.data); + } + if (object.log !== undefined && object.log !== null) { + message.log = object.log; + } + message.events = object.events?.map(e => Event.fromAmino(e)) || []; + message.msgResponses = object.msg_responses?.map(e => Any.fromAmino(e)) || []; + return message; + }, + toAmino(message: Result): ResultAmino { + const obj: any = {}; + obj.data = message.data ? base64FromBytes(message.data) : undefined; + obj.log = message.log === "" ? undefined : message.log; + if (message.events) { + obj.events = message.events.map(e => e ? Event.toAmino(e) : undefined); + } else { + obj.events = message.events; + } + if (message.msgResponses) { + obj.msg_responses = message.msgResponses.map(e => e ? Any.toAmino(e) : undefined); + } else { + obj.msg_responses = message.msgResponses; + } + return obj; + }, + fromAminoMsg(object: ResultAminoMsg): Result { + return Result.fromAmino(object.value); + }, + toAminoMsg(message: Result): ResultAminoMsg { + return { + type: "cosmos-sdk/Result", + value: Result.toAmino(message) + }; + }, + fromProtoMsg(message: ResultProtoMsg): Result { + return Result.decode(message.value); + }, + toProto(message: Result): Uint8Array { + return Result.encode(message).finish(); + }, + toProtoMsg(message: Result): ResultProtoMsg { + return { + typeUrl: "/cosmos.base.abci.v1beta1.Result", + value: Result.encode(message).finish() + }; + } +}; +function createBaseSimulationResponse(): SimulationResponse { + return { + gasInfo: GasInfo.fromPartial({}), + result: undefined + }; +} +export const SimulationResponse = { + typeUrl: "/cosmos.base.abci.v1beta1.SimulationResponse", + encode(message: SimulationResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.gasInfo !== undefined) { + GasInfo.encode(message.gasInfo, writer.uint32(10).fork()).ldelim(); + } + if (message.result !== undefined) { + Result.encode(message.result, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): SimulationResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseSimulationResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.gasInfo = GasInfo.decode(reader, reader.uint32()); + break; + case 2: + message.result = Result.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): SimulationResponse { + const obj = createBaseSimulationResponse(); + if (isSet(object.gasInfo)) obj.gasInfo = GasInfo.fromJSON(object.gasInfo); + if (isSet(object.result)) obj.result = Result.fromJSON(object.result); + return obj; + }, + toJSON(message: SimulationResponse): JsonSafe { + const obj: any = {}; + message.gasInfo !== undefined && (obj.gasInfo = message.gasInfo ? GasInfo.toJSON(message.gasInfo) : undefined); + message.result !== undefined && (obj.result = message.result ? Result.toJSON(message.result) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): SimulationResponse { + const message = createBaseSimulationResponse(); + if (object.gasInfo !== undefined && object.gasInfo !== null) { + message.gasInfo = GasInfo.fromPartial(object.gasInfo); + } + if (object.result !== undefined && object.result !== null) { + message.result = Result.fromPartial(object.result); + } + return message; + }, + fromSDK(object: SimulationResponseSDKType): SimulationResponse { + return { + gasInfo: object.gas_info ? GasInfo.fromSDK(object.gas_info) : undefined, + result: object.result ? Result.fromSDK(object.result) : undefined + }; + }, + fromSDKJSON(object: any): SimulationResponseSDKType { + return { + gas_info: isSet(object.gas_info) ? GasInfo.fromSDKJSON(object.gas_info) : undefined, + result: isSet(object.result) ? Result.fromSDKJSON(object.result) : undefined + }; + }, + toSDK(message: SimulationResponse): SimulationResponseSDKType { + const obj: any = {}; + message.gasInfo !== undefined && (obj.gas_info = message.gasInfo ? GasInfo.toSDK(message.gasInfo) : undefined); + message.result !== undefined && (obj.result = message.result ? Result.toSDK(message.result) : undefined); + return obj; + }, + fromAmino(object: SimulationResponseAmino): SimulationResponse { + const message = createBaseSimulationResponse(); + if (object.gas_info !== undefined && object.gas_info !== null) { + message.gasInfo = GasInfo.fromAmino(object.gas_info); + } + if (object.result !== undefined && object.result !== null) { + message.result = Result.fromAmino(object.result); + } + return message; + }, + toAmino(message: SimulationResponse): SimulationResponseAmino { + const obj: any = {}; + obj.gas_info = message.gasInfo ? GasInfo.toAmino(message.gasInfo) : undefined; + obj.result = message.result ? Result.toAmino(message.result) : undefined; + return obj; + }, + fromAminoMsg(object: SimulationResponseAminoMsg): SimulationResponse { + return SimulationResponse.fromAmino(object.value); + }, + toAminoMsg(message: SimulationResponse): SimulationResponseAminoMsg { + return { + type: "cosmos-sdk/SimulationResponse", + value: SimulationResponse.toAmino(message) + }; + }, + fromProtoMsg(message: SimulationResponseProtoMsg): SimulationResponse { + return SimulationResponse.decode(message.value); + }, + toProto(message: SimulationResponse): Uint8Array { + return SimulationResponse.encode(message).finish(); + }, + toProtoMsg(message: SimulationResponse): SimulationResponseProtoMsg { + return { + typeUrl: "/cosmos.base.abci.v1beta1.SimulationResponse", + value: SimulationResponse.encode(message).finish() + }; + } +}; +function createBaseMsgData(): MsgData { + return { + msgType: "", + data: new Uint8Array() + }; +} +export const MsgData = { + typeUrl: "/cosmos.base.abci.v1beta1.MsgData", + encode(message: MsgData, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.msgType !== undefined) { + writer.uint32(10).string(message.msgType); + } + if (message.data.length !== 0) { + writer.uint32(18).bytes(message.data); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgData { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgData(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.msgType = reader.string(); + break; + case 2: + message.data = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgData { + const obj = createBaseMsgData(); + if (isSet(object.msgType)) obj.msgType = String(object.msgType); + if (isSet(object.data)) obj.data = bytesFromBase64(object.data); + return obj; + }, + toJSON(message: MsgData): JsonSafe { + const obj: any = {}; + message.msgType !== undefined && (obj.msgType = message.msgType); + message.data !== undefined && (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): MsgData { + const message = createBaseMsgData(); + message.msgType = object.msgType ?? ""; + message.data = object.data ?? new Uint8Array(); + return message; + }, + fromSDK(object: MsgDataSDKType): MsgData { + return { + msgType: object?.msg_type, + data: object?.data + }; + }, + fromSDKJSON(object: any): MsgDataSDKType { + return { + msg_type: isSet(object.msg_type) ? String(object.msg_type) : "", + data: isSet(object.data) ? bytesFromBase64(object.data) : new Uint8Array() + }; + }, + toSDK(message: MsgData): MsgDataSDKType { + const obj: any = {}; + obj.msg_type = message.msgType; + obj.data = message.data; + return obj; + }, + fromAmino(object: MsgDataAmino): MsgData { + const message = createBaseMsgData(); + if (object.msg_type !== undefined && object.msg_type !== null) { + message.msgType = object.msg_type; + } + if (object.data !== undefined && object.data !== null) { + message.data = bytesFromBase64(object.data); + } + return message; + }, + toAmino(message: MsgData): MsgDataAmino { + const obj: any = {}; + obj.msg_type = message.msgType === "" ? undefined : message.msgType; + obj.data = message.data ? base64FromBytes(message.data) : undefined; + return obj; + }, + fromAminoMsg(object: MsgDataAminoMsg): MsgData { + return MsgData.fromAmino(object.value); + }, + toAminoMsg(message: MsgData): MsgDataAminoMsg { + return { + type: "cosmos-sdk/MsgData", + value: MsgData.toAmino(message) + }; + }, + fromProtoMsg(message: MsgDataProtoMsg): MsgData { + return MsgData.decode(message.value); + }, + toProto(message: MsgData): Uint8Array { + return MsgData.encode(message).finish(); + }, + toProtoMsg(message: MsgData): MsgDataProtoMsg { + return { + typeUrl: "/cosmos.base.abci.v1beta1.MsgData", + value: MsgData.encode(message).finish() + }; + } +}; +function createBaseTxMsgData(): TxMsgData { + return { + data: [], + msgResponses: [] + }; +} +export const TxMsgData = { + typeUrl: "/cosmos.base.abci.v1beta1.TxMsgData", + encode(message: TxMsgData, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.data) { + MsgData.encode(v!, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.msgResponses) { + Any.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): TxMsgData { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseTxMsgData(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.data.push(MsgData.decode(reader, reader.uint32())); + break; + case 2: + message.msgResponses.push(Any.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): TxMsgData { + const obj = createBaseTxMsgData(); + if (Array.isArray(object?.data)) obj.data = object.data.map((e: any) => MsgData.fromJSON(e)); + if (Array.isArray(object?.msgResponses)) obj.msgResponses = object.msgResponses.map((e: any) => Any.fromJSON(e)); + return obj; + }, + toJSON(message: TxMsgData): JsonSafe { + const obj: any = {}; + if (message.data) { + obj.data = message.data.map(e => e ? MsgData.toJSON(e) : undefined); + } else { + obj.data = []; + } + if (message.msgResponses) { + obj.msgResponses = message.msgResponses.map(e => e ? Any.toJSON(e) : undefined); + } else { + obj.msgResponses = []; + } + return obj; + }, + fromPartial(object: DeepPartial): TxMsgData { + const message = createBaseTxMsgData(); + message.data = object.data?.map(e => MsgData.fromPartial(e)) || []; + message.msgResponses = object.msgResponses?.map(e => Any.fromPartial(e)) || []; + return message; + }, + fromSDK(object: TxMsgDataSDKType): TxMsgData { + return { + data: Array.isArray(object?.data) ? object.data.map((e: any) => MsgData.fromSDK(e)) : [], + msgResponses: Array.isArray(object?.msg_responses) ? object.msg_responses.map((e: any) => Any.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): TxMsgDataSDKType { + return { + data: Array.isArray(object?.data) ? object.data.map((e: any) => MsgData.fromSDKJSON(e)) : [], + msg_responses: Array.isArray(object?.msg_responses) ? object.msg_responses.map((e: any) => Any.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: TxMsgData): TxMsgDataSDKType { + const obj: any = {}; + if (message.data) { + obj.data = message.data.map(e => e ? MsgData.toSDK(e) : undefined); + } else { + obj.data = []; + } + if (message.msgResponses) { + obj.msg_responses = message.msgResponses.map(e => e ? Any.toSDK(e) : undefined); + } else { + obj.msg_responses = []; + } + return obj; + }, + fromAmino(object: TxMsgDataAmino): TxMsgData { + const message = createBaseTxMsgData(); + message.data = object.data?.map(e => MsgData.fromAmino(e)) || []; + message.msgResponses = object.msg_responses?.map(e => Any.fromAmino(e)) || []; + return message; + }, + toAmino(message: TxMsgData): TxMsgDataAmino { + const obj: any = {}; + if (message.data) { + obj.data = message.data.map(e => e ? MsgData.toAmino(e) : undefined); + } else { + obj.data = message.data; + } + if (message.msgResponses) { + obj.msg_responses = message.msgResponses.map(e => e ? Any.toAmino(e) : undefined); + } else { + obj.msg_responses = message.msgResponses; + } + return obj; + }, + fromAminoMsg(object: TxMsgDataAminoMsg): TxMsgData { + return TxMsgData.fromAmino(object.value); + }, + toAminoMsg(message: TxMsgData): TxMsgDataAminoMsg { + return { + type: "cosmos-sdk/TxMsgData", + value: TxMsgData.toAmino(message) + }; + }, + fromProtoMsg(message: TxMsgDataProtoMsg): TxMsgData { + return TxMsgData.decode(message.value); + }, + toProto(message: TxMsgData): Uint8Array { + return TxMsgData.encode(message).finish(); + }, + toProtoMsg(message: TxMsgData): TxMsgDataProtoMsg { + return { + typeUrl: "/cosmos.base.abci.v1beta1.TxMsgData", + value: TxMsgData.encode(message).finish() + }; + } +}; +function createBaseSearchTxsResult(): SearchTxsResult { + return { + totalCount: BigInt(0), + count: BigInt(0), + pageNumber: BigInt(0), + pageTotal: BigInt(0), + limit: BigInt(0), + txs: [] + }; +} +export const SearchTxsResult = { + typeUrl: "/cosmos.base.abci.v1beta1.SearchTxsResult", + encode(message: SearchTxsResult, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.totalCount !== undefined) { + writer.uint32(8).uint64(message.totalCount); + } + if (message.count !== undefined) { + writer.uint32(16).uint64(message.count); + } + if (message.pageNumber !== undefined) { + writer.uint32(24).uint64(message.pageNumber); + } + if (message.pageTotal !== undefined) { + writer.uint32(32).uint64(message.pageTotal); + } + if (message.limit !== undefined) { + writer.uint32(40).uint64(message.limit); + } + for (const v of message.txs) { + TxResponse.encode(v!, writer.uint32(50).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): SearchTxsResult { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseSearchTxsResult(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.totalCount = reader.uint64(); + break; + case 2: + message.count = reader.uint64(); + break; + case 3: + message.pageNumber = reader.uint64(); + break; + case 4: + message.pageTotal = reader.uint64(); + break; + case 5: + message.limit = reader.uint64(); + break; + case 6: + message.txs.push(TxResponse.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): SearchTxsResult { + const obj = createBaseSearchTxsResult(); + if (isSet(object.totalCount)) obj.totalCount = BigInt(object.totalCount.toString()); + if (isSet(object.count)) obj.count = BigInt(object.count.toString()); + if (isSet(object.pageNumber)) obj.pageNumber = BigInt(object.pageNumber.toString()); + if (isSet(object.pageTotal)) obj.pageTotal = BigInt(object.pageTotal.toString()); + if (isSet(object.limit)) obj.limit = BigInt(object.limit.toString()); + if (Array.isArray(object?.txs)) obj.txs = object.txs.map((e: any) => TxResponse.fromJSON(e)); + return obj; + }, + toJSON(message: SearchTxsResult): JsonSafe { + const obj: any = {}; + message.totalCount !== undefined && (obj.totalCount = (message.totalCount || BigInt(0)).toString()); + message.count !== undefined && (obj.count = (message.count || BigInt(0)).toString()); + message.pageNumber !== undefined && (obj.pageNumber = (message.pageNumber || BigInt(0)).toString()); + message.pageTotal !== undefined && (obj.pageTotal = (message.pageTotal || BigInt(0)).toString()); + message.limit !== undefined && (obj.limit = (message.limit || BigInt(0)).toString()); + if (message.txs) { + obj.txs = message.txs.map(e => e ? TxResponse.toJSON(e) : undefined); + } else { + obj.txs = []; + } + return obj; + }, + fromPartial(object: DeepPartial): SearchTxsResult { + const message = createBaseSearchTxsResult(); + if (object.totalCount !== undefined && object.totalCount !== null) { + message.totalCount = BigInt(object.totalCount.toString()); + } + if (object.count !== undefined && object.count !== null) { + message.count = BigInt(object.count.toString()); + } + if (object.pageNumber !== undefined && object.pageNumber !== null) { + message.pageNumber = BigInt(object.pageNumber.toString()); + } + if (object.pageTotal !== undefined && object.pageTotal !== null) { + message.pageTotal = BigInt(object.pageTotal.toString()); + } + if (object.limit !== undefined && object.limit !== null) { + message.limit = BigInt(object.limit.toString()); + } + message.txs = object.txs?.map(e => TxResponse.fromPartial(e)) || []; + return message; + }, + fromSDK(object: SearchTxsResultSDKType): SearchTxsResult { + return { + totalCount: object?.total_count, + count: object?.count, + pageNumber: object?.page_number, + pageTotal: object?.page_total, + limit: object?.limit, + txs: Array.isArray(object?.txs) ? object.txs.map((e: any) => TxResponse.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): SearchTxsResultSDKType { + return { + total_count: isSet(object.total_count) ? BigInt(object.total_count.toString()) : BigInt(0), + count: isSet(object.count) ? BigInt(object.count.toString()) : BigInt(0), + page_number: isSet(object.page_number) ? BigInt(object.page_number.toString()) : BigInt(0), + page_total: isSet(object.page_total) ? BigInt(object.page_total.toString()) : BigInt(0), + limit: isSet(object.limit) ? BigInt(object.limit.toString()) : BigInt(0), + txs: Array.isArray(object?.txs) ? object.txs.map((e: any) => TxResponse.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: SearchTxsResult): SearchTxsResultSDKType { + const obj: any = {}; + obj.total_count = message.totalCount; + obj.count = message.count; + obj.page_number = message.pageNumber; + obj.page_total = message.pageTotal; + obj.limit = message.limit; + if (message.txs) { + obj.txs = message.txs.map(e => e ? TxResponse.toSDK(e) : undefined); + } else { + obj.txs = []; + } + return obj; + }, + fromAmino(object: SearchTxsResultAmino): SearchTxsResult { + const message = createBaseSearchTxsResult(); + if (object.total_count !== undefined && object.total_count !== null) { + message.totalCount = BigInt(object.total_count); + } + if (object.count !== undefined && object.count !== null) { + message.count = BigInt(object.count); + } + if (object.page_number !== undefined && object.page_number !== null) { + message.pageNumber = BigInt(object.page_number); + } + if (object.page_total !== undefined && object.page_total !== null) { + message.pageTotal = BigInt(object.page_total); + } + if (object.limit !== undefined && object.limit !== null) { + message.limit = BigInt(object.limit); + } + message.txs = object.txs?.map(e => TxResponse.fromAmino(e)) || []; + return message; + }, + toAmino(message: SearchTxsResult): SearchTxsResultAmino { + const obj: any = {}; + obj.total_count = message.totalCount !== BigInt(0) ? message.totalCount?.toString() : undefined; + obj.count = message.count !== BigInt(0) ? message.count?.toString() : undefined; + obj.page_number = message.pageNumber !== BigInt(0) ? message.pageNumber?.toString() : undefined; + obj.page_total = message.pageTotal !== BigInt(0) ? message.pageTotal?.toString() : undefined; + obj.limit = message.limit !== BigInt(0) ? message.limit?.toString() : undefined; + if (message.txs) { + obj.txs = message.txs.map(e => e ? TxResponse.toAmino(e) : undefined); + } else { + obj.txs = message.txs; + } + return obj; + }, + fromAminoMsg(object: SearchTxsResultAminoMsg): SearchTxsResult { + return SearchTxsResult.fromAmino(object.value); + }, + toAminoMsg(message: SearchTxsResult): SearchTxsResultAminoMsg { + return { + type: "cosmos-sdk/SearchTxsResult", + value: SearchTxsResult.toAmino(message) + }; + }, + fromProtoMsg(message: SearchTxsResultProtoMsg): SearchTxsResult { + return SearchTxsResult.decode(message.value); + }, + toProto(message: SearchTxsResult): Uint8Array { + return SearchTxsResult.encode(message).finish(); + }, + toProtoMsg(message: SearchTxsResult): SearchTxsResultProtoMsg { + return { + typeUrl: "/cosmos.base.abci.v1beta1.SearchTxsResult", + value: SearchTxsResult.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/base/kv/v1beta1/kv.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/base/kv/v1beta1/kv.ts new file mode 100644 index 0000000000..35623ceee7 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/base/kv/v1beta1/kv.ts @@ -0,0 +1,245 @@ +import { BinaryReader, BinaryWriter } from "../../../../binary.js"; +import { JsonSafe } from "../../../../json-safe.js"; +import { DeepPartial, isSet, bytesFromBase64, base64FromBytes } from "../../../../helpers.js"; +export const protobufPackage = "cosmos.base.kv.v1beta1"; +/** Pairs defines a repeated slice of Pair objects. */ +export interface Pairs { + pairs: Pair[]; +} +export interface PairsProtoMsg { + typeUrl: "/cosmos.base.kv.v1beta1.Pairs"; + value: Uint8Array; +} +/** Pairs defines a repeated slice of Pair objects. */ +export interface PairsSDKType { + pairs: PairSDKType[]; +} +/** Pair defines a key/value bytes tuple. */ +export interface Pair { + key: Uint8Array; + value: Uint8Array; +} +export interface PairProtoMsg { + typeUrl: "/cosmos.base.kv.v1beta1.Pair"; + value: Uint8Array; +} +/** Pair defines a key/value bytes tuple. */ +export interface PairSDKType { + key: Uint8Array; + value: Uint8Array; +} +function createBasePairs(): Pairs { + return { + pairs: [] + }; +} +export const Pairs = { + typeUrl: "/cosmos.base.kv.v1beta1.Pairs", + encode(message: Pairs, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.pairs) { + Pair.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Pairs { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBasePairs(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.pairs.push(Pair.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Pairs { + const obj = createBasePairs(); + if (Array.isArray(object?.pairs)) obj.pairs = object.pairs.map((e: any) => Pair.fromJSON(e)); + return obj; + }, + toJSON(message: Pairs): JsonSafe { + const obj: any = {}; + if (message.pairs) { + obj.pairs = message.pairs.map(e => e ? Pair.toJSON(e) : undefined); + } else { + obj.pairs = []; + } + return obj; + }, + fromPartial(object: DeepPartial): Pairs { + const message = createBasePairs(); + message.pairs = object.pairs?.map(e => Pair.fromPartial(e)) || []; + return message; + }, + fromSDK(object: PairsSDKType): Pairs { + return { + pairs: Array.isArray(object?.pairs) ? object.pairs.map((e: any) => Pair.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): PairsSDKType { + return { + pairs: Array.isArray(object?.pairs) ? object.pairs.map((e: any) => Pair.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: Pairs): PairsSDKType { + const obj: any = {}; + if (message.pairs) { + obj.pairs = message.pairs.map(e => e ? Pair.toSDK(e) : undefined); + } else { + obj.pairs = []; + } + return obj; + }, + fromAmino(object: PairsAmino): Pairs { + const message = createBasePairs(); + message.pairs = object.pairs?.map(e => Pair.fromAmino(e)) || []; + return message; + }, + toAmino(message: Pairs): PairsAmino { + const obj: any = {}; + if (message.pairs) { + obj.pairs = message.pairs.map(e => e ? Pair.toAmino(e) : undefined); + } else { + obj.pairs = message.pairs; + } + return obj; + }, + fromAminoMsg(object: PairsAminoMsg): Pairs { + return Pairs.fromAmino(object.value); + }, + toAminoMsg(message: Pairs): PairsAminoMsg { + return { + type: "cosmos-sdk/Pairs", + value: Pairs.toAmino(message) + }; + }, + fromProtoMsg(message: PairsProtoMsg): Pairs { + return Pairs.decode(message.value); + }, + toProto(message: Pairs): Uint8Array { + return Pairs.encode(message).finish(); + }, + toProtoMsg(message: Pairs): PairsProtoMsg { + return { + typeUrl: "/cosmos.base.kv.v1beta1.Pairs", + value: Pairs.encode(message).finish() + }; + } +}; +function createBasePair(): Pair { + return { + key: new Uint8Array(), + value: new Uint8Array() + }; +} +export const Pair = { + typeUrl: "/cosmos.base.kv.v1beta1.Pair", + encode(message: Pair, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.key.length !== 0) { + writer.uint32(10).bytes(message.key); + } + if (message.value.length !== 0) { + writer.uint32(18).bytes(message.value); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Pair { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBasePair(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.bytes(); + break; + case 2: + message.value = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Pair { + const obj = createBasePair(); + if (isSet(object.key)) obj.key = bytesFromBase64(object.key); + if (isSet(object.value)) obj.value = bytesFromBase64(object.value); + return obj; + }, + toJSON(message: Pair): JsonSafe { + const obj: any = {}; + message.key !== undefined && (obj.key = base64FromBytes(message.key !== undefined ? message.key : new Uint8Array())); + message.value !== undefined && (obj.value = base64FromBytes(message.value !== undefined ? message.value : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): Pair { + const message = createBasePair(); + message.key = object.key ?? new Uint8Array(); + message.value = object.value ?? new Uint8Array(); + return message; + }, + fromSDK(object: PairSDKType): Pair { + return { + key: object?.key, + value: object?.value + }; + }, + fromSDKJSON(object: any): PairSDKType { + return { + key: isSet(object.key) ? bytesFromBase64(object.key) : new Uint8Array(), + value: isSet(object.value) ? bytesFromBase64(object.value) : new Uint8Array() + }; + }, + toSDK(message: Pair): PairSDKType { + const obj: any = {}; + obj.key = message.key; + obj.value = message.value; + return obj; + }, + fromAmino(object: PairAmino): Pair { + const message = createBasePair(); + if (object.key !== undefined && object.key !== null) { + message.key = bytesFromBase64(object.key); + } + if (object.value !== undefined && object.value !== null) { + message.value = bytesFromBase64(object.value); + } + return message; + }, + toAmino(message: Pair): PairAmino { + const obj: any = {}; + obj.key = message.key ? base64FromBytes(message.key) : undefined; + obj.value = message.value ? base64FromBytes(message.value) : undefined; + return obj; + }, + fromAminoMsg(object: PairAminoMsg): Pair { + return Pair.fromAmino(object.value); + }, + toAminoMsg(message: Pair): PairAminoMsg { + return { + type: "cosmos-sdk/Pair", + value: Pair.toAmino(message) + }; + }, + fromProtoMsg(message: PairProtoMsg): Pair { + return Pair.decode(message.value); + }, + toProto(message: Pair): Uint8Array { + return Pair.encode(message).finish(); + }, + toProtoMsg(message: Pair): PairProtoMsg { + return { + typeUrl: "/cosmos.base.kv.v1beta1.Pair", + value: Pair.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/base/query/v1beta1/pagination.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/base/query/v1beta1/pagination.ts new file mode 100644 index 0000000000..9eae3d6ce2 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/base/query/v1beta1/pagination.ts @@ -0,0 +1,383 @@ +import { BinaryReader, BinaryWriter } from "../../../../binary.js"; +import { isSet, bytesFromBase64, base64FromBytes, DeepPartial } from "../../../../helpers.js"; +import { JsonSafe } from "../../../../json-safe.js"; +export const protobufPackage = "cosmos.base.query.v1beta1"; +/** + * PageRequest is to be embedded in gRPC request messages for efficient + * pagination. Ex: + * + * message SomeRequest { + * Foo some_parameter = 1; + * PageRequest pagination = 2; + * } + */ +export interface PageRequest { + /** + * key is a value returned in PageResponse.next_key to begin + * querying the next page most efficiently. Only one of offset or key + * should be set. + */ + key: Uint8Array; + /** + * offset is a numeric offset that can be used when key is unavailable. + * It is less efficient than using key. Only one of offset or key should + * be set. + */ + offset: bigint; + /** + * limit is the total number of results to be returned in the result page. + * If left empty it will default to a value to be set by each app. + */ + limit: bigint; + /** + * count_total is set to true to indicate that the result set should include + * a count of the total number of items available for pagination in UIs. + * count_total is only respected when offset is used. It is ignored when key + * is set. + */ + countTotal: boolean; + /** + * reverse is set to true if results are to be returned in the descending order. + * + * Since: cosmos-sdk 0.43 + */ + reverse: boolean; +} +export interface PageRequestProtoMsg { + typeUrl: "/cosmos.base.query.v1beta1.PageRequest"; + value: Uint8Array; +} +/** + * PageRequest is to be embedded in gRPC request messages for efficient + * pagination. Ex: + * + * message SomeRequest { + * Foo some_parameter = 1; + * PageRequest pagination = 2; + * } + */ +export interface PageRequestSDKType { + key: Uint8Array; + offset: bigint; + limit: bigint; + count_total: boolean; + reverse: boolean; +} +/** + * PageResponse is to be embedded in gRPC response messages where the + * corresponding request message has used PageRequest. + * + * message SomeResponse { + * repeated Bar results = 1; + * PageResponse page = 2; + * } + */ +export interface PageResponse { + /** + * next_key is the key to be passed to PageRequest.key to + * query the next page most efficiently. It will be empty if + * there are no more results. + */ + nextKey: Uint8Array; + /** + * total is total number of results available if PageRequest.count_total + * was set, its value is undefined otherwise + */ + total: bigint; +} +export interface PageResponseProtoMsg { + typeUrl: "/cosmos.base.query.v1beta1.PageResponse"; + value: Uint8Array; +} +/** + * PageResponse is to be embedded in gRPC response messages where the + * corresponding request message has used PageRequest. + * + * message SomeResponse { + * repeated Bar results = 1; + * PageResponse page = 2; + * } + */ +export interface PageResponseSDKType { + next_key: Uint8Array; + total: bigint; +} +function createBasePageRequest(): PageRequest { + return { + key: new Uint8Array(), + offset: BigInt(0), + limit: BigInt(0), + countTotal: false, + reverse: false + }; +} +export const PageRequest = { + typeUrl: "/cosmos.base.query.v1beta1.PageRequest", + encode(message: PageRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.key.length !== 0) { + writer.uint32(10).bytes(message.key); + } + if (message.offset !== undefined) { + writer.uint32(16).uint64(message.offset); + } + if (message.limit !== undefined) { + writer.uint32(24).uint64(message.limit); + } + if (message.countTotal !== undefined) { + writer.uint32(32).bool(message.countTotal); + } + if (message.reverse !== undefined) { + writer.uint32(40).bool(message.reverse); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): PageRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBasePageRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.bytes(); + break; + case 2: + message.offset = reader.uint64(); + break; + case 3: + message.limit = reader.uint64(); + break; + case 4: + message.countTotal = reader.bool(); + break; + case 5: + message.reverse = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): PageRequest { + const obj = createBasePageRequest(); + if (isSet(object.key)) obj.key = bytesFromBase64(object.key); + if (isSet(object.offset)) obj.offset = BigInt(object.offset.toString()); + if (isSet(object.limit)) obj.limit = BigInt(object.limit.toString()); + if (isSet(object.countTotal)) obj.countTotal = Boolean(object.countTotal); + if (isSet(object.reverse)) obj.reverse = Boolean(object.reverse); + return obj; + }, + toJSON(message: PageRequest): JsonSafe { + const obj: any = {}; + message.key !== undefined && (obj.key = base64FromBytes(message.key !== undefined ? message.key : new Uint8Array())); + message.offset !== undefined && (obj.offset = (message.offset || BigInt(0)).toString()); + message.limit !== undefined && (obj.limit = (message.limit || BigInt(0)).toString()); + message.countTotal !== undefined && (obj.countTotal = message.countTotal); + message.reverse !== undefined && (obj.reverse = message.reverse); + return obj; + }, + fromPartial(object: DeepPartial): PageRequest { + const message = createBasePageRequest(); + message.key = object.key ?? new Uint8Array(); + if (object.offset !== undefined && object.offset !== null) { + message.offset = BigInt(object.offset.toString()); + } + if (object.limit !== undefined && object.limit !== null) { + message.limit = BigInt(object.limit.toString()); + } + message.countTotal = object.countTotal ?? false; + message.reverse = object.reverse ?? false; + return message; + }, + fromSDK(object: PageRequestSDKType): PageRequest { + return { + key: object?.key, + offset: object?.offset, + limit: object?.limit, + countTotal: object?.count_total, + reverse: object?.reverse + }; + }, + fromSDKJSON(object: any): PageRequestSDKType { + return { + key: isSet(object.key) ? bytesFromBase64(object.key) : new Uint8Array(), + offset: isSet(object.offset) ? BigInt(object.offset.toString()) : BigInt(0), + limit: isSet(object.limit) ? BigInt(object.limit.toString()) : BigInt(0), + count_total: isSet(object.count_total) ? Boolean(object.count_total) : false, + reverse: isSet(object.reverse) ? Boolean(object.reverse) : false + }; + }, + toSDK(message: PageRequest): PageRequestSDKType { + const obj: any = {}; + obj.key = message.key; + obj.offset = message.offset; + obj.limit = message.limit; + obj.count_total = message.countTotal; + obj.reverse = message.reverse; + return obj; + }, + fromAmino(object: PageRequestAmino): PageRequest { + const message = createBasePageRequest(); + if (object.key !== undefined && object.key !== null) { + message.key = bytesFromBase64(object.key); + } + if (object.offset !== undefined && object.offset !== null) { + message.offset = BigInt(object.offset); + } + if (object.limit !== undefined && object.limit !== null) { + message.limit = BigInt(object.limit); + } + if (object.count_total !== undefined && object.count_total !== null) { + message.countTotal = object.count_total; + } + if (object.reverse !== undefined && object.reverse !== null) { + message.reverse = object.reverse; + } + return message; + }, + toAmino(message: PageRequest): PageRequestAmino { + const obj: any = {}; + obj.key = message.key ? base64FromBytes(message.key) : undefined; + obj.offset = message.offset !== BigInt(0) ? message.offset?.toString() : undefined; + obj.limit = message.limit !== BigInt(0) ? message.limit?.toString() : undefined; + obj.count_total = message.countTotal === false ? undefined : message.countTotal; + obj.reverse = message.reverse === false ? undefined : message.reverse; + return obj; + }, + fromAminoMsg(object: PageRequestAminoMsg): PageRequest { + return PageRequest.fromAmino(object.value); + }, + toAminoMsg(message: PageRequest): PageRequestAminoMsg { + return { + type: "cosmos-sdk/PageRequest", + value: PageRequest.toAmino(message) + }; + }, + fromProtoMsg(message: PageRequestProtoMsg): PageRequest { + return PageRequest.decode(message.value); + }, + toProto(message: PageRequest): Uint8Array { + return PageRequest.encode(message).finish(); + }, + toProtoMsg(message: PageRequest): PageRequestProtoMsg { + return { + typeUrl: "/cosmos.base.query.v1beta1.PageRequest", + value: PageRequest.encode(message).finish() + }; + } +}; +function createBasePageResponse(): PageResponse { + return { + nextKey: new Uint8Array(), + total: BigInt(0) + }; +} +export const PageResponse = { + typeUrl: "/cosmos.base.query.v1beta1.PageResponse", + encode(message: PageResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.nextKey.length !== 0) { + writer.uint32(10).bytes(message.nextKey); + } + if (message.total !== undefined) { + writer.uint32(16).uint64(message.total); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): PageResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBasePageResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.nextKey = reader.bytes(); + break; + case 2: + message.total = reader.uint64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): PageResponse { + const obj = createBasePageResponse(); + if (isSet(object.nextKey)) obj.nextKey = bytesFromBase64(object.nextKey); + if (isSet(object.total)) obj.total = BigInt(object.total.toString()); + return obj; + }, + toJSON(message: PageResponse): JsonSafe { + const obj: any = {}; + message.nextKey !== undefined && (obj.nextKey = base64FromBytes(message.nextKey !== undefined ? message.nextKey : new Uint8Array())); + message.total !== undefined && (obj.total = (message.total || BigInt(0)).toString()); + return obj; + }, + fromPartial(object: DeepPartial): PageResponse { + const message = createBasePageResponse(); + message.nextKey = object.nextKey ?? new Uint8Array(); + if (object.total !== undefined && object.total !== null) { + message.total = BigInt(object.total.toString()); + } + return message; + }, + fromSDK(object: PageResponseSDKType): PageResponse { + return { + nextKey: object?.next_key, + total: object?.total + }; + }, + fromSDKJSON(object: any): PageResponseSDKType { + return { + next_key: isSet(object.next_key) ? bytesFromBase64(object.next_key) : new Uint8Array(), + total: isSet(object.total) ? BigInt(object.total.toString()) : BigInt(0) + }; + }, + toSDK(message: PageResponse): PageResponseSDKType { + const obj: any = {}; + obj.next_key = message.nextKey; + obj.total = message.total; + return obj; + }, + fromAmino(object: PageResponseAmino): PageResponse { + const message = createBasePageResponse(); + if (object.next_key !== undefined && object.next_key !== null) { + message.nextKey = bytesFromBase64(object.next_key); + } + if (object.total !== undefined && object.total !== null) { + message.total = BigInt(object.total); + } + return message; + }, + toAmino(message: PageResponse): PageResponseAmino { + const obj: any = {}; + obj.next_key = message.nextKey ? base64FromBytes(message.nextKey) : undefined; + obj.total = message.total !== BigInt(0) ? message.total?.toString() : undefined; + return obj; + }, + fromAminoMsg(object: PageResponseAminoMsg): PageResponse { + return PageResponse.fromAmino(object.value); + }, + toAminoMsg(message: PageResponse): PageResponseAminoMsg { + return { + type: "cosmos-sdk/PageResponse", + value: PageResponse.toAmino(message) + }; + }, + fromProtoMsg(message: PageResponseProtoMsg): PageResponse { + return PageResponse.decode(message.value); + }, + toProto(message: PageResponse): Uint8Array { + return PageResponse.encode(message).finish(); + }, + toProtoMsg(message: PageResponse): PageResponseProtoMsg { + return { + typeUrl: "/cosmos.base.query.v1beta1.PageResponse", + value: PageResponse.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/base/reflection/v1beta1/reflection.lcd.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/base/reflection/v1beta1/reflection.lcd.ts new file mode 100644 index 0000000000..b8c9756f28 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/base/reflection/v1beta1/reflection.lcd.ts @@ -0,0 +1,26 @@ +import { LCDClient } from "@cosmology/lcd"; +import { ListAllInterfacesRequest, ListAllInterfacesRequestSDKType, ListAllInterfacesResponse, ListAllInterfacesResponseSDKType, ListImplementationsRequest, ListImplementationsRequestSDKType, ListImplementationsResponse, ListImplementationsResponseSDKType } from "./reflection.js"; +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 ListAllInterfacesResponse.fromSDKJSON(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 ListImplementationsResponse.fromSDKJSON(await this.req.get(endpoint)); + } +} \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/base/reflection/v1beta1/reflection.rpc.ReflectionService.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/base/reflection/v1beta1/reflection.rpc.ReflectionService.ts new file mode 100644 index 0000000000..6bdcf494ff --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/base/reflection/v1beta1/reflection.rpc.ReflectionService.ts @@ -0,0 +1,47 @@ +import { Rpc } from "../../../../helpers.js"; +import { BinaryReader } from "../../../../binary.js"; +import { QueryClient, createProtobufRpcClient } from "@cosmjs/stargate"; +import { ListAllInterfacesRequest, ListAllInterfacesRequestSDKType, ListAllInterfacesResponse, ListAllInterfacesResponseSDKType, ListImplementationsRequest, ListImplementationsRequestSDKType, ListImplementationsResponse, ListImplementationsResponseSDKType } from "./reflection.js"; +/** 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/__fixtures__/v-next/outputicjsdeps/cosmos/base/reflection/v1beta1/reflection.rpc.func.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/base/reflection/v1beta1/reflection.rpc.func.ts new file mode 100644 index 0000000000..9e44182764 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/base/reflection/v1beta1/reflection.rpc.func.ts @@ -0,0 +1,25 @@ +import { RpcResolver, buildQuery } from "../../../../helper-func-types"; +import { buildUseQuery } from "../../../../react-query"; +import { ListAllInterfacesRequest, ListAllInterfacesResponse, ListImplementationsRequest, ListImplementationsResponse } from "./reflection"; +export const createGetListAllInterfaces = (getRpcInstance: RpcResolver) => buildQuery({ + encode: ListAllInterfacesRequest.encode, + decode: ListAllInterfacesResponse.decode, + service: "cosmos.base.reflection.v1beta1.ReflectionService", + method: "ListAllInterfaces", + getRpcInstance: getRpcInstance +}); +export const useGetListAllInterfaces = buildUseQuery({ + builderQueryFn: createGetListAllInterfaces, + queryKeyPrefix: "ListAllInterfacesQuery" +}); +export const createGetListImplementations = (getRpcInstance: RpcResolver) => buildQuery({ + encode: ListImplementationsRequest.encode, + decode: ListImplementationsResponse.decode, + service: "cosmos.base.reflection.v1beta1.ReflectionService", + method: "ListImplementations", + getRpcInstance: getRpcInstance +}); +export const useGetListImplementations = buildUseQuery({ + builderQueryFn: createGetListImplementations, + queryKeyPrefix: "ListImplementationsQuery" +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/base/reflection/v1beta1/reflection.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/base/reflection/v1beta1/reflection.ts new file mode 100644 index 0000000000..c5ddf87e1d --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/base/reflection/v1beta1/reflection.ts @@ -0,0 +1,438 @@ +import { BinaryReader, BinaryWriter } from "../../../../binary.js"; +import { JsonSafe } from "../../../../json-safe.js"; +import { DeepPartial, isSet } from "../../../../helpers.js"; +export const protobufPackage = "cosmos.base.reflection.v1beta1"; +/** 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 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 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 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 ListImplementationsResponseSDKType { + implementation_message_names: string[]; +} +function createBaseListAllInterfacesRequest(): ListAllInterfacesRequest { + return {}; +} +export const ListAllInterfacesRequest = { + typeUrl: "/cosmos.base.reflection.v1beta1.ListAllInterfacesRequest", + 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; + }, + fromJSON(_: any): ListAllInterfacesRequest { + const obj = createBaseListAllInterfacesRequest(); + return obj; + }, + toJSON(_: ListAllInterfacesRequest): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): ListAllInterfacesRequest { + const message = createBaseListAllInterfacesRequest(); + return message; + }, + fromSDK(_: ListAllInterfacesRequestSDKType): ListAllInterfacesRequest { + return {}; + }, + fromSDKJSON(_: any): ListAllInterfacesRequestSDKType { + return {}; + }, + toSDK(_: ListAllInterfacesRequest): ListAllInterfacesRequestSDKType { + const obj: any = {}; + return obj; + }, + 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() + }; + } +}; +function createBaseListAllInterfacesResponse(): ListAllInterfacesResponse { + return { + interfaceNames: [] + }; +} +export const ListAllInterfacesResponse = { + typeUrl: "/cosmos.base.reflection.v1beta1.ListAllInterfacesResponse", + 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; + }, + fromJSON(object: any): ListAllInterfacesResponse { + const obj = createBaseListAllInterfacesResponse(); + if (Array.isArray(object?.interfaceNames)) obj.interfaceNames = object.interfaceNames.map((e: any) => String(e)); + return obj; + }, + toJSON(message: ListAllInterfacesResponse): JsonSafe { + const obj: any = {}; + if (message.interfaceNames) { + obj.interfaceNames = message.interfaceNames.map(e => e); + } else { + obj.interfaceNames = []; + } + return obj; + }, + fromPartial(object: DeepPartial): ListAllInterfacesResponse { + const message = createBaseListAllInterfacesResponse(); + message.interfaceNames = object.interfaceNames?.map(e => e) || []; + return message; + }, + fromSDK(object: ListAllInterfacesResponseSDKType): ListAllInterfacesResponse { + return { + interfaceNames: Array.isArray(object?.interface_names) ? object.interface_names.map((e: any) => e) : [] + }; + }, + fromSDKJSON(object: any): ListAllInterfacesResponseSDKType { + return { + interface_names: Array.isArray(object?.interface_names) ? object.interface_names.map((e: any) => String(e)) : [] + }; + }, + toSDK(message: ListAllInterfacesResponse): ListAllInterfacesResponseSDKType { + const obj: any = {}; + if (message.interfaceNames) { + obj.interface_names = message.interfaceNames.map(e => e); + } else { + obj.interface_names = []; + } + return obj; + }, + 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() + }; + } +}; +function createBaseListImplementationsRequest(): ListImplementationsRequest { + return { + interfaceName: "" + }; +} +export const ListImplementationsRequest = { + typeUrl: "/cosmos.base.reflection.v1beta1.ListImplementationsRequest", + encode(message: ListImplementationsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.interfaceName !== undefined) { + 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; + }, + fromJSON(object: any): ListImplementationsRequest { + const obj = createBaseListImplementationsRequest(); + if (isSet(object.interfaceName)) obj.interfaceName = String(object.interfaceName); + return obj; + }, + toJSON(message: ListImplementationsRequest): JsonSafe { + const obj: any = {}; + message.interfaceName !== undefined && (obj.interfaceName = message.interfaceName); + return obj; + }, + fromPartial(object: DeepPartial): ListImplementationsRequest { + const message = createBaseListImplementationsRequest(); + message.interfaceName = object.interfaceName ?? ""; + return message; + }, + fromSDK(object: ListImplementationsRequestSDKType): ListImplementationsRequest { + return { + interfaceName: object?.interface_name + }; + }, + fromSDKJSON(object: any): ListImplementationsRequestSDKType { + return { + interface_name: isSet(object.interface_name) ? String(object.interface_name) : "" + }; + }, + toSDK(message: ListImplementationsRequest): ListImplementationsRequestSDKType { + const obj: any = {}; + obj.interface_name = message.interfaceName; + return obj; + }, + 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() + }; + } +}; +function createBaseListImplementationsResponse(): ListImplementationsResponse { + return { + implementationMessageNames: [] + }; +} +export const ListImplementationsResponse = { + typeUrl: "/cosmos.base.reflection.v1beta1.ListImplementationsResponse", + 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; + }, + fromJSON(object: any): ListImplementationsResponse { + const obj = createBaseListImplementationsResponse(); + if (Array.isArray(object?.implementationMessageNames)) obj.implementationMessageNames = object.implementationMessageNames.map((e: any) => String(e)); + return obj; + }, + toJSON(message: ListImplementationsResponse): JsonSafe { + const obj: any = {}; + if (message.implementationMessageNames) { + obj.implementationMessageNames = message.implementationMessageNames.map(e => e); + } else { + obj.implementationMessageNames = []; + } + return obj; + }, + fromPartial(object: DeepPartial): ListImplementationsResponse { + const message = createBaseListImplementationsResponse(); + message.implementationMessageNames = object.implementationMessageNames?.map(e => e) || []; + return message; + }, + fromSDK(object: ListImplementationsResponseSDKType): ListImplementationsResponse { + return { + implementationMessageNames: Array.isArray(object?.implementation_message_names) ? object.implementation_message_names.map((e: any) => e) : [] + }; + }, + fromSDKJSON(object: any): ListImplementationsResponseSDKType { + return { + implementation_message_names: Array.isArray(object?.implementation_message_names) ? object.implementation_message_names.map((e: any) => String(e)) : [] + }; + }, + toSDK(message: ListImplementationsResponse): ListImplementationsResponseSDKType { + const obj: any = {}; + if (message.implementationMessageNames) { + obj.implementation_message_names = message.implementationMessageNames.map(e => e); + } else { + obj.implementation_message_names = []; + } + return obj; + }, + 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() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/base/reflection/v2alpha1/reflection.lcd.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/base/reflection/v2alpha1/reflection.lcd.ts new file mode 100644 index 0000000000..3277110496 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/base/reflection/v2alpha1/reflection.lcd.ts @@ -0,0 +1,50 @@ +import { LCDClient } from "@cosmology/lcd"; +import { GetAuthnDescriptorRequest, GetAuthnDescriptorRequestSDKType, GetAuthnDescriptorResponse, GetAuthnDescriptorResponseSDKType, GetChainDescriptorRequest, GetChainDescriptorRequestSDKType, GetChainDescriptorResponse, GetChainDescriptorResponseSDKType, GetCodecDescriptorRequest, GetCodecDescriptorRequestSDKType, GetCodecDescriptorResponse, GetCodecDescriptorResponseSDKType, GetConfigurationDescriptorRequest, GetConfigurationDescriptorRequestSDKType, GetConfigurationDescriptorResponse, GetConfigurationDescriptorResponseSDKType, GetQueryServicesDescriptorRequest, GetQueryServicesDescriptorRequestSDKType, GetQueryServicesDescriptorResponse, GetQueryServicesDescriptorResponseSDKType, GetTxDescriptorRequest, GetTxDescriptorRequestSDKType, GetTxDescriptorResponse, GetTxDescriptorResponseSDKType } from "./reflection.js"; +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 GetAuthnDescriptorResponse.fromSDKJSON(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 GetChainDescriptorResponse.fromSDKJSON(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 GetCodecDescriptorResponse.fromSDKJSON(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 GetConfigurationDescriptorResponse.fromSDKJSON(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 GetQueryServicesDescriptorResponse.fromSDKJSON(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 GetTxDescriptorResponse.fromSDKJSON(await this.req.get(endpoint)); + } +} \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/base/reflection/v2alpha1/reflection.rpc.ReflectionService.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/base/reflection/v2alpha1/reflection.rpc.ReflectionService.ts new file mode 100644 index 0000000000..84542cc6ea --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/base/reflection/v2alpha1/reflection.rpc.ReflectionService.ts @@ -0,0 +1,89 @@ +import { Rpc } from "../../../../helpers.js"; +import { BinaryReader } from "../../../../binary.js"; +import { QueryClient, createProtobufRpcClient } from "@cosmjs/stargate"; +import { GetAuthnDescriptorRequest, GetAuthnDescriptorRequestSDKType, GetAuthnDescriptorResponse, GetAuthnDescriptorResponseSDKType, GetChainDescriptorRequest, GetChainDescriptorRequestSDKType, GetChainDescriptorResponse, GetChainDescriptorResponseSDKType, GetCodecDescriptorRequest, GetCodecDescriptorRequestSDKType, GetCodecDescriptorResponse, GetCodecDescriptorResponseSDKType, GetConfigurationDescriptorRequest, GetConfigurationDescriptorRequestSDKType, GetConfigurationDescriptorResponse, GetConfigurationDescriptorResponseSDKType, GetQueryServicesDescriptorRequest, GetQueryServicesDescriptorRequestSDKType, GetQueryServicesDescriptorResponse, GetQueryServicesDescriptorResponseSDKType, GetTxDescriptorRequest, GetTxDescriptorRequestSDKType, GetTxDescriptorResponse, GetTxDescriptorResponseSDKType } from "./reflection.js"; +/** 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/__fixtures__/v-next/outputicjsdeps/cosmos/base/reflection/v2alpha1/reflection.rpc.func.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/base/reflection/v2alpha1/reflection.rpc.func.ts new file mode 100644 index 0000000000..a767a31197 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/base/reflection/v2alpha1/reflection.rpc.func.ts @@ -0,0 +1,69 @@ +import { RpcResolver, buildQuery } from "../../../../helper-func-types"; +import { buildUseQuery } from "../../../../react-query"; +import { GetAuthnDescriptorRequest, GetAuthnDescriptorResponse, GetChainDescriptorRequest, GetChainDescriptorResponse, GetCodecDescriptorRequest, GetCodecDescriptorResponse, GetConfigurationDescriptorRequest, GetConfigurationDescriptorResponse, GetQueryServicesDescriptorRequest, GetQueryServicesDescriptorResponse, GetTxDescriptorRequest, GetTxDescriptorResponse } from "./reflection"; +export const createGetGetAuthnDescriptor = (getRpcInstance: RpcResolver) => buildQuery({ + encode: GetAuthnDescriptorRequest.encode, + decode: GetAuthnDescriptorResponse.decode, + service: "cosmos.base.reflection.v2alpha1.ReflectionService", + method: "GetAuthnDescriptor", + getRpcInstance: getRpcInstance +}); +export const useGetGetAuthnDescriptor = buildUseQuery({ + builderQueryFn: createGetGetAuthnDescriptor, + queryKeyPrefix: "GetAuthnDescriptorQuery" +}); +export const createGetGetChainDescriptor = (getRpcInstance: RpcResolver) => buildQuery({ + encode: GetChainDescriptorRequest.encode, + decode: GetChainDescriptorResponse.decode, + service: "cosmos.base.reflection.v2alpha1.ReflectionService", + method: "GetChainDescriptor", + getRpcInstance: getRpcInstance +}); +export const useGetGetChainDescriptor = buildUseQuery({ + builderQueryFn: createGetGetChainDescriptor, + queryKeyPrefix: "GetChainDescriptorQuery" +}); +export const createGetGetCodecDescriptor = (getRpcInstance: RpcResolver) => buildQuery({ + encode: GetCodecDescriptorRequest.encode, + decode: GetCodecDescriptorResponse.decode, + service: "cosmos.base.reflection.v2alpha1.ReflectionService", + method: "GetCodecDescriptor", + getRpcInstance: getRpcInstance +}); +export const useGetGetCodecDescriptor = buildUseQuery({ + builderQueryFn: createGetGetCodecDescriptor, + queryKeyPrefix: "GetCodecDescriptorQuery" +}); +export const createGetGetConfigurationDescriptor = (getRpcInstance: RpcResolver) => buildQuery({ + encode: GetConfigurationDescriptorRequest.encode, + decode: GetConfigurationDescriptorResponse.decode, + service: "cosmos.base.reflection.v2alpha1.ReflectionService", + method: "GetConfigurationDescriptor", + getRpcInstance: getRpcInstance +}); +export const useGetGetConfigurationDescriptor = buildUseQuery({ + builderQueryFn: createGetGetConfigurationDescriptor, + queryKeyPrefix: "GetConfigurationDescriptorQuery" +}); +export const createGetGetQueryServicesDescriptor = (getRpcInstance: RpcResolver) => buildQuery({ + encode: GetQueryServicesDescriptorRequest.encode, + decode: GetQueryServicesDescriptorResponse.decode, + service: "cosmos.base.reflection.v2alpha1.ReflectionService", + method: "GetQueryServicesDescriptor", + getRpcInstance: getRpcInstance +}); +export const useGetGetQueryServicesDescriptor = buildUseQuery({ + builderQueryFn: createGetGetQueryServicesDescriptor, + queryKeyPrefix: "GetQueryServicesDescriptorQuery" +}); +export const createGetGetTxDescriptor = (getRpcInstance: RpcResolver) => buildQuery({ + encode: GetTxDescriptorRequest.encode, + decode: GetTxDescriptorResponse.decode, + service: "cosmos.base.reflection.v2alpha1.ReflectionService", + method: "GetTxDescriptor", + getRpcInstance: getRpcInstance +}); +export const useGetGetTxDescriptor = buildUseQuery({ + builderQueryFn: createGetGetTxDescriptor, + queryKeyPrefix: "GetTxDescriptorQuery" +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/base/reflection/v2alpha1/reflection.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/base/reflection/v2alpha1/reflection.ts new file mode 100644 index 0000000000..715868c0a0 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/base/reflection/v2alpha1/reflection.ts @@ -0,0 +1,3098 @@ +import { BinaryReader, BinaryWriter } from "../../../../binary.js"; +import { isSet, DeepPartial } from "../../../../helpers.js"; +import { JsonSafe } from "../../../../json-safe.js"; +export const protobufPackage = "cosmos.base.reflection.v2alpha1"; +/** AppDescriptor describes a cosmos-sdk based application */ +export interface AppDescriptor { + /** + * AuthnDescriptor provides information on how to authenticate transactions on the application + * NOTE: experimental and subject to change in future releases. + */ + authn?: AuthnDescriptor; + /** chain provides the chain descriptor */ + chain?: ChainDescriptor; + /** codec provides metadata information regarding codec related types */ + codec?: CodecDescriptor; + /** configuration provides metadata information regarding the sdk.Config type */ + configuration?: ConfigurationDescriptor; + /** query_services provides metadata information regarding the available queriable endpoints */ + queryServices?: QueryServicesDescriptor; + /** tx provides metadata information regarding how to send transactions to the given application */ + tx?: TxDescriptor; +} +export interface AppDescriptorProtoMsg { + typeUrl: "/cosmos.base.reflection.v2alpha1.AppDescriptor"; + value: Uint8Array; +} +/** AppDescriptor describes a cosmos-sdk based application */ +export interface AppDescriptorSDKType { + authn?: AuthnDescriptorSDKType; + chain?: ChainDescriptorSDKType; + codec?: CodecDescriptorSDKType; + configuration?: ConfigurationDescriptorSDKType; + query_services?: QueryServicesDescriptorSDKType; + tx?: TxDescriptorSDKType; +} +/** TxDescriptor describes the accepted transaction type */ +export interface TxDescriptor { + /** + * fullname is the protobuf fullname of the raw transaction type (for instance the tx.Tx type) + * it is not meant to support polymorphism of transaction types, it is supposed to be used by + * reflection clients to understand if they can handle a specific transaction type in an application. + */ + fullname: string; + /** msgs lists the accepted application messages (sdk.Msg) */ + msgs: MsgDescriptor[]; +} +export interface TxDescriptorProtoMsg { + typeUrl: "/cosmos.base.reflection.v2alpha1.TxDescriptor"; + value: Uint8Array; +} +/** TxDescriptor describes the accepted transaction type */ +export interface TxDescriptorSDKType { + fullname: string; + msgs: MsgDescriptorSDKType[]; +} +/** + * AuthnDescriptor provides information on how to sign transactions without relying + * on the online RPCs GetTxMetadata and CombineUnsignedTxAndSignatures + */ +export interface AuthnDescriptor { + /** sign_modes defines the supported signature algorithm */ + signModes: SigningModeDescriptor[]; +} +export interface AuthnDescriptorProtoMsg { + typeUrl: "/cosmos.base.reflection.v2alpha1.AuthnDescriptor"; + value: Uint8Array; +} +/** + * AuthnDescriptor provides information on how to sign transactions without relying + * on the online RPCs GetTxMetadata and CombineUnsignedTxAndSignatures + */ +export interface AuthnDescriptorSDKType { + sign_modes: SigningModeDescriptorSDKType[]; +} +/** + * SigningModeDescriptor provides information on a signing flow of the application + * NOTE(fdymylja): here we could go as far as providing an entire flow on how + * to sign a message given a SigningModeDescriptor, but it's better to think about + * this another time + */ +export interface SigningModeDescriptor { + /** name defines the unique name of the signing mode */ + name: string; + /** number is the unique int32 identifier for the sign_mode enum */ + number: number; + /** + * authn_info_provider_method_fullname defines the fullname of the method to call to get + * the metadata required to authenticate using the provided sign_modes + */ + authnInfoProviderMethodFullname: string; +} +export interface SigningModeDescriptorProtoMsg { + typeUrl: "/cosmos.base.reflection.v2alpha1.SigningModeDescriptor"; + value: Uint8Array; +} +/** + * SigningModeDescriptor provides information on a signing flow of the application + * NOTE(fdymylja): here we could go as far as providing an entire flow on how + * to sign a message given a SigningModeDescriptor, but it's better to think about + * this another time + */ +export interface SigningModeDescriptorSDKType { + name: string; + number: number; + authn_info_provider_method_fullname: string; +} +/** ChainDescriptor describes chain information of the application */ +export interface ChainDescriptor { + /** id is the chain id */ + id: string; +} +export interface ChainDescriptorProtoMsg { + typeUrl: "/cosmos.base.reflection.v2alpha1.ChainDescriptor"; + value: Uint8Array; +} +/** ChainDescriptor describes chain information of the application */ +export interface ChainDescriptorSDKType { + id: string; +} +/** CodecDescriptor describes the registered interfaces and provides metadata information on the types */ +export interface CodecDescriptor { + /** interfaces is a list of the registerted interfaces descriptors */ + interfaces: InterfaceDescriptor[]; +} +export interface CodecDescriptorProtoMsg { + typeUrl: "/cosmos.base.reflection.v2alpha1.CodecDescriptor"; + value: Uint8Array; +} +/** CodecDescriptor describes the registered interfaces and provides metadata information on the types */ +export interface CodecDescriptorSDKType { + interfaces: InterfaceDescriptorSDKType[]; +} +/** InterfaceDescriptor describes the implementation of an interface */ +export interface InterfaceDescriptor { + /** fullname is the name of the interface */ + fullname: string; + /** + * interface_accepting_messages contains information regarding the proto messages which contain the interface as + * google.protobuf.Any field + */ + interfaceAcceptingMessages: InterfaceAcceptingMessageDescriptor[]; + /** interface_implementers is a list of the descriptors of the interface implementers */ + interfaceImplementers: InterfaceImplementerDescriptor[]; +} +export interface InterfaceDescriptorProtoMsg { + typeUrl: "/cosmos.base.reflection.v2alpha1.InterfaceDescriptor"; + value: Uint8Array; +} +/** InterfaceDescriptor describes the implementation of an interface */ +export interface InterfaceDescriptorSDKType { + fullname: string; + interface_accepting_messages: InterfaceAcceptingMessageDescriptorSDKType[]; + interface_implementers: InterfaceImplementerDescriptorSDKType[]; +} +/** InterfaceImplementerDescriptor describes an interface implementer */ +export interface InterfaceImplementerDescriptor { + /** fullname is the protobuf queryable name of the interface implementer */ + fullname: string; + /** + * type_url defines the type URL used when marshalling the type as any + * this is required so we can provide type safe google.protobuf.Any marshalling and + * unmarshalling, making sure that we don't accept just 'any' type + * in our interface fields + */ + typeUrl: string; +} +export interface InterfaceImplementerDescriptorProtoMsg { + typeUrl: "/cosmos.base.reflection.v2alpha1.InterfaceImplementerDescriptor"; + value: Uint8Array; +} +/** InterfaceImplementerDescriptor describes an interface implementer */ +export interface InterfaceImplementerDescriptorSDKType { + fullname: string; + type_url: string; +} +/** + * InterfaceAcceptingMessageDescriptor describes a protobuf message which contains + * an interface represented as a google.protobuf.Any + */ +export interface InterfaceAcceptingMessageDescriptor { + /** fullname is the protobuf fullname of the type containing the interface */ + fullname: string; + /** + * field_descriptor_names is a list of the protobuf name (not fullname) of the field + * which contains the interface as google.protobuf.Any (the interface is the same, but + * it can be in multiple fields of the same proto message) + */ + fieldDescriptorNames: string[]; +} +export interface InterfaceAcceptingMessageDescriptorProtoMsg { + typeUrl: "/cosmos.base.reflection.v2alpha1.InterfaceAcceptingMessageDescriptor"; + value: Uint8Array; +} +/** + * InterfaceAcceptingMessageDescriptor describes a protobuf message which contains + * an interface represented as a google.protobuf.Any + */ +export interface InterfaceAcceptingMessageDescriptorSDKType { + fullname: string; + field_descriptor_names: string[]; +} +/** ConfigurationDescriptor contains metadata information on the sdk.Config */ +export interface ConfigurationDescriptor { + /** bech32_account_address_prefix is the account address prefix */ + bech32AccountAddressPrefix: string; +} +export interface ConfigurationDescriptorProtoMsg { + typeUrl: "/cosmos.base.reflection.v2alpha1.ConfigurationDescriptor"; + value: Uint8Array; +} +/** ConfigurationDescriptor contains metadata information on the sdk.Config */ +export interface ConfigurationDescriptorSDKType { + bech32_account_address_prefix: string; +} +/** MsgDescriptor describes a cosmos-sdk message that can be delivered with a transaction */ +export interface MsgDescriptor { + /** msg_type_url contains the TypeURL of a sdk.Msg. */ + msgTypeUrl: string; +} +export interface MsgDescriptorProtoMsg { + typeUrl: "/cosmos.base.reflection.v2alpha1.MsgDescriptor"; + value: Uint8Array; +} +/** MsgDescriptor describes a cosmos-sdk message that can be delivered with a transaction */ +export interface MsgDescriptorSDKType { + msg_type_url: string; +} +/** GetAuthnDescriptorRequest is the request used for the GetAuthnDescriptor RPC */ +export interface GetAuthnDescriptorRequest {} +export interface GetAuthnDescriptorRequestProtoMsg { + typeUrl: "/cosmos.base.reflection.v2alpha1.GetAuthnDescriptorRequest"; + value: Uint8Array; +} +/** GetAuthnDescriptorRequest is the request used for the GetAuthnDescriptor RPC */ +export interface GetAuthnDescriptorRequestSDKType {} +/** GetAuthnDescriptorResponse is the response returned by the GetAuthnDescriptor RPC */ +export interface GetAuthnDescriptorResponse { + /** authn describes how to authenticate to the application when sending transactions */ + authn?: AuthnDescriptor; +} +export interface GetAuthnDescriptorResponseProtoMsg { + typeUrl: "/cosmos.base.reflection.v2alpha1.GetAuthnDescriptorResponse"; + value: Uint8Array; +} +/** GetAuthnDescriptorResponse is the response returned by the GetAuthnDescriptor RPC */ +export interface GetAuthnDescriptorResponseSDKType { + authn?: AuthnDescriptorSDKType; +} +/** GetChainDescriptorRequest is the request used for the GetChainDescriptor RPC */ +export interface GetChainDescriptorRequest {} +export interface GetChainDescriptorRequestProtoMsg { + typeUrl: "/cosmos.base.reflection.v2alpha1.GetChainDescriptorRequest"; + value: Uint8Array; +} +/** GetChainDescriptorRequest is the request used for the GetChainDescriptor RPC */ +export interface GetChainDescriptorRequestSDKType {} +/** GetChainDescriptorResponse is the response returned by the GetChainDescriptor RPC */ +export interface GetChainDescriptorResponse { + /** chain describes application chain information */ + chain?: ChainDescriptor; +} +export interface GetChainDescriptorResponseProtoMsg { + typeUrl: "/cosmos.base.reflection.v2alpha1.GetChainDescriptorResponse"; + value: Uint8Array; +} +/** GetChainDescriptorResponse is the response returned by the GetChainDescriptor RPC */ +export interface GetChainDescriptorResponseSDKType { + chain?: ChainDescriptorSDKType; +} +/** GetCodecDescriptorRequest is the request used for the GetCodecDescriptor RPC */ +export interface GetCodecDescriptorRequest {} +export interface GetCodecDescriptorRequestProtoMsg { + typeUrl: "/cosmos.base.reflection.v2alpha1.GetCodecDescriptorRequest"; + value: Uint8Array; +} +/** GetCodecDescriptorRequest is the request used for the GetCodecDescriptor RPC */ +export interface GetCodecDescriptorRequestSDKType {} +/** GetCodecDescriptorResponse is the response returned by the GetCodecDescriptor RPC */ +export interface GetCodecDescriptorResponse { + /** codec describes the application codec such as registered interfaces and implementations */ + codec?: CodecDescriptor; +} +export interface GetCodecDescriptorResponseProtoMsg { + typeUrl: "/cosmos.base.reflection.v2alpha1.GetCodecDescriptorResponse"; + value: Uint8Array; +} +/** GetCodecDescriptorResponse is the response returned by the GetCodecDescriptor RPC */ +export interface GetCodecDescriptorResponseSDKType { + codec?: CodecDescriptorSDKType; +} +/** GetConfigurationDescriptorRequest is the request used for the GetConfigurationDescriptor RPC */ +export interface GetConfigurationDescriptorRequest {} +export interface GetConfigurationDescriptorRequestProtoMsg { + typeUrl: "/cosmos.base.reflection.v2alpha1.GetConfigurationDescriptorRequest"; + value: Uint8Array; +} +/** GetConfigurationDescriptorRequest is the request used for the GetConfigurationDescriptor RPC */ +export interface GetConfigurationDescriptorRequestSDKType {} +/** GetConfigurationDescriptorResponse is the response returned by the GetConfigurationDescriptor RPC */ +export interface GetConfigurationDescriptorResponse { + /** config describes the application's sdk.Config */ + config?: ConfigurationDescriptor; +} +export interface GetConfigurationDescriptorResponseProtoMsg { + typeUrl: "/cosmos.base.reflection.v2alpha1.GetConfigurationDescriptorResponse"; + value: Uint8Array; +} +/** GetConfigurationDescriptorResponse is the response returned by the GetConfigurationDescriptor RPC */ +export interface GetConfigurationDescriptorResponseSDKType { + config?: ConfigurationDescriptorSDKType; +} +/** GetQueryServicesDescriptorRequest is the request used for the GetQueryServicesDescriptor RPC */ +export interface GetQueryServicesDescriptorRequest {} +export interface GetQueryServicesDescriptorRequestProtoMsg { + typeUrl: "/cosmos.base.reflection.v2alpha1.GetQueryServicesDescriptorRequest"; + value: Uint8Array; +} +/** GetQueryServicesDescriptorRequest is the request used for the GetQueryServicesDescriptor RPC */ +export interface GetQueryServicesDescriptorRequestSDKType {} +/** GetQueryServicesDescriptorResponse is the response returned by the GetQueryServicesDescriptor RPC */ +export interface GetQueryServicesDescriptorResponse { + /** queries provides information on the available queryable services */ + queries?: QueryServicesDescriptor; +} +export interface GetQueryServicesDescriptorResponseProtoMsg { + typeUrl: "/cosmos.base.reflection.v2alpha1.GetQueryServicesDescriptorResponse"; + value: Uint8Array; +} +/** GetQueryServicesDescriptorResponse is the response returned by the GetQueryServicesDescriptor RPC */ +export interface GetQueryServicesDescriptorResponseSDKType { + queries?: QueryServicesDescriptorSDKType; +} +/** GetTxDescriptorRequest is the request used for the GetTxDescriptor RPC */ +export interface GetTxDescriptorRequest {} +export interface GetTxDescriptorRequestProtoMsg { + typeUrl: "/cosmos.base.reflection.v2alpha1.GetTxDescriptorRequest"; + value: Uint8Array; +} +/** GetTxDescriptorRequest is the request used for the GetTxDescriptor RPC */ +export interface GetTxDescriptorRequestSDKType {} +/** GetTxDescriptorResponse is the response returned by the GetTxDescriptor RPC */ +export interface GetTxDescriptorResponse { + /** + * tx provides information on msgs that can be forwarded to the application + * alongside the accepted transaction protobuf type + */ + tx?: TxDescriptor; +} +export interface GetTxDescriptorResponseProtoMsg { + typeUrl: "/cosmos.base.reflection.v2alpha1.GetTxDescriptorResponse"; + value: Uint8Array; +} +/** GetTxDescriptorResponse is the response returned by the GetTxDescriptor RPC */ +export interface GetTxDescriptorResponseSDKType { + tx?: TxDescriptorSDKType; +} +/** QueryServicesDescriptor contains the list of cosmos-sdk queriable services */ +export interface QueryServicesDescriptor { + /** query_services is a list of cosmos-sdk QueryServiceDescriptor */ + queryServices: QueryServiceDescriptor[]; +} +export interface QueryServicesDescriptorProtoMsg { + typeUrl: "/cosmos.base.reflection.v2alpha1.QueryServicesDescriptor"; + value: Uint8Array; +} +/** QueryServicesDescriptor contains the list of cosmos-sdk queriable services */ +export interface QueryServicesDescriptorSDKType { + query_services: QueryServiceDescriptorSDKType[]; +} +/** QueryServiceDescriptor describes a cosmos-sdk queryable service */ +export interface QueryServiceDescriptor { + /** fullname is the protobuf fullname of the service descriptor */ + fullname: string; + /** is_module describes if this service is actually exposed by an application's module */ + isModule: boolean; + /** methods provides a list of query service methods */ + methods: QueryMethodDescriptor[]; +} +export interface QueryServiceDescriptorProtoMsg { + typeUrl: "/cosmos.base.reflection.v2alpha1.QueryServiceDescriptor"; + value: Uint8Array; +} +/** QueryServiceDescriptor describes a cosmos-sdk queryable service */ +export interface QueryServiceDescriptorSDKType { + fullname: string; + is_module: boolean; + methods: QueryMethodDescriptorSDKType[]; +} +/** + * QueryMethodDescriptor describes a queryable method of a query service + * no other info is provided beside method name and tendermint queryable path + * because it would be redundant with the grpc reflection service + */ +export interface QueryMethodDescriptor { + /** name is the protobuf name (not fullname) of the method */ + name: string; + /** + * full_query_path is the path that can be used to query + * this method via tendermint abci.Query + */ + fullQueryPath: string; +} +export interface QueryMethodDescriptorProtoMsg { + typeUrl: "/cosmos.base.reflection.v2alpha1.QueryMethodDescriptor"; + value: Uint8Array; +} +/** + * QueryMethodDescriptor describes a queryable method of a query service + * no other info is provided beside method name and tendermint queryable path + * because it would be redundant with the grpc reflection service + */ +export interface QueryMethodDescriptorSDKType { + name: string; + full_query_path: string; +} +function createBaseAppDescriptor(): AppDescriptor { + return { + authn: undefined, + chain: undefined, + codec: undefined, + configuration: undefined, + queryServices: undefined, + tx: undefined + }; +} +export const AppDescriptor = { + typeUrl: "/cosmos.base.reflection.v2alpha1.AppDescriptor", + encode(message: AppDescriptor, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.authn !== undefined) { + AuthnDescriptor.encode(message.authn, writer.uint32(10).fork()).ldelim(); + } + if (message.chain !== undefined) { + ChainDescriptor.encode(message.chain, writer.uint32(18).fork()).ldelim(); + } + if (message.codec !== undefined) { + CodecDescriptor.encode(message.codec, writer.uint32(26).fork()).ldelim(); + } + if (message.configuration !== undefined) { + ConfigurationDescriptor.encode(message.configuration, writer.uint32(34).fork()).ldelim(); + } + if (message.queryServices !== undefined) { + QueryServicesDescriptor.encode(message.queryServices, writer.uint32(42).fork()).ldelim(); + } + if (message.tx !== undefined) { + TxDescriptor.encode(message.tx, writer.uint32(50).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): AppDescriptor { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseAppDescriptor(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.authn = AuthnDescriptor.decode(reader, reader.uint32()); + break; + case 2: + message.chain = ChainDescriptor.decode(reader, reader.uint32()); + break; + case 3: + message.codec = CodecDescriptor.decode(reader, reader.uint32()); + break; + case 4: + message.configuration = ConfigurationDescriptor.decode(reader, reader.uint32()); + break; + case 5: + message.queryServices = QueryServicesDescriptor.decode(reader, reader.uint32()); + break; + case 6: + message.tx = TxDescriptor.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): AppDescriptor { + const obj = createBaseAppDescriptor(); + if (isSet(object.authn)) obj.authn = AuthnDescriptor.fromJSON(object.authn); + if (isSet(object.chain)) obj.chain = ChainDescriptor.fromJSON(object.chain); + if (isSet(object.codec)) obj.codec = CodecDescriptor.fromJSON(object.codec); + if (isSet(object.configuration)) obj.configuration = ConfigurationDescriptor.fromJSON(object.configuration); + if (isSet(object.queryServices)) obj.queryServices = QueryServicesDescriptor.fromJSON(object.queryServices); + if (isSet(object.tx)) obj.tx = TxDescriptor.fromJSON(object.tx); + return obj; + }, + toJSON(message: AppDescriptor): JsonSafe { + const obj: any = {}; + message.authn !== undefined && (obj.authn = message.authn ? AuthnDescriptor.toJSON(message.authn) : undefined); + message.chain !== undefined && (obj.chain = message.chain ? ChainDescriptor.toJSON(message.chain) : undefined); + message.codec !== undefined && (obj.codec = message.codec ? CodecDescriptor.toJSON(message.codec) : undefined); + message.configuration !== undefined && (obj.configuration = message.configuration ? ConfigurationDescriptor.toJSON(message.configuration) : undefined); + message.queryServices !== undefined && (obj.queryServices = message.queryServices ? QueryServicesDescriptor.toJSON(message.queryServices) : undefined); + message.tx !== undefined && (obj.tx = message.tx ? TxDescriptor.toJSON(message.tx) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): AppDescriptor { + const message = createBaseAppDescriptor(); + if (object.authn !== undefined && object.authn !== null) { + message.authn = AuthnDescriptor.fromPartial(object.authn); + } + if (object.chain !== undefined && object.chain !== null) { + message.chain = ChainDescriptor.fromPartial(object.chain); + } + if (object.codec !== undefined && object.codec !== null) { + message.codec = CodecDescriptor.fromPartial(object.codec); + } + if (object.configuration !== undefined && object.configuration !== null) { + message.configuration = ConfigurationDescriptor.fromPartial(object.configuration); + } + if (object.queryServices !== undefined && object.queryServices !== null) { + message.queryServices = QueryServicesDescriptor.fromPartial(object.queryServices); + } + if (object.tx !== undefined && object.tx !== null) { + message.tx = TxDescriptor.fromPartial(object.tx); + } + return message; + }, + fromSDK(object: AppDescriptorSDKType): AppDescriptor { + return { + authn: object.authn ? AuthnDescriptor.fromSDK(object.authn) : undefined, + chain: object.chain ? ChainDescriptor.fromSDK(object.chain) : undefined, + codec: object.codec ? CodecDescriptor.fromSDK(object.codec) : undefined, + configuration: object.configuration ? ConfigurationDescriptor.fromSDK(object.configuration) : undefined, + queryServices: object.query_services ? QueryServicesDescriptor.fromSDK(object.query_services) : undefined, + tx: object.tx ? TxDescriptor.fromSDK(object.tx) : undefined + }; + }, + fromSDKJSON(object: any): AppDescriptorSDKType { + return { + authn: isSet(object.authn) ? AuthnDescriptor.fromSDKJSON(object.authn) : undefined, + chain: isSet(object.chain) ? ChainDescriptor.fromSDKJSON(object.chain) : undefined, + codec: isSet(object.codec) ? CodecDescriptor.fromSDKJSON(object.codec) : undefined, + configuration: isSet(object.configuration) ? ConfigurationDescriptor.fromSDKJSON(object.configuration) : undefined, + query_services: isSet(object.query_services) ? QueryServicesDescriptor.fromSDKJSON(object.query_services) : undefined, + tx: isSet(object.tx) ? TxDescriptor.fromSDKJSON(object.tx) : undefined + }; + }, + toSDK(message: AppDescriptor): AppDescriptorSDKType { + const obj: any = {}; + message.authn !== undefined && (obj.authn = message.authn ? AuthnDescriptor.toSDK(message.authn) : undefined); + message.chain !== undefined && (obj.chain = message.chain ? ChainDescriptor.toSDK(message.chain) : undefined); + message.codec !== undefined && (obj.codec = message.codec ? CodecDescriptor.toSDK(message.codec) : undefined); + message.configuration !== undefined && (obj.configuration = message.configuration ? ConfigurationDescriptor.toSDK(message.configuration) : undefined); + message.queryServices !== undefined && (obj.query_services = message.queryServices ? QueryServicesDescriptor.toSDK(message.queryServices) : undefined); + message.tx !== undefined && (obj.tx = message.tx ? TxDescriptor.toSDK(message.tx) : undefined); + return obj; + }, + fromAmino(object: AppDescriptorAmino): AppDescriptor { + const message = createBaseAppDescriptor(); + if (object.authn !== undefined && object.authn !== null) { + message.authn = AuthnDescriptor.fromAmino(object.authn); + } + if (object.chain !== undefined && object.chain !== null) { + message.chain = ChainDescriptor.fromAmino(object.chain); + } + if (object.codec !== undefined && object.codec !== null) { + message.codec = CodecDescriptor.fromAmino(object.codec); + } + if (object.configuration !== undefined && object.configuration !== null) { + message.configuration = ConfigurationDescriptor.fromAmino(object.configuration); + } + if (object.query_services !== undefined && object.query_services !== null) { + message.queryServices = QueryServicesDescriptor.fromAmino(object.query_services); + } + if (object.tx !== undefined && object.tx !== null) { + message.tx = TxDescriptor.fromAmino(object.tx); + } + return message; + }, + toAmino(message: AppDescriptor): AppDescriptorAmino { + const obj: any = {}; + obj.authn = message.authn ? AuthnDescriptor.toAmino(message.authn) : undefined; + obj.chain = message.chain ? ChainDescriptor.toAmino(message.chain) : undefined; + obj.codec = message.codec ? CodecDescriptor.toAmino(message.codec) : undefined; + obj.configuration = message.configuration ? ConfigurationDescriptor.toAmino(message.configuration) : undefined; + obj.query_services = message.queryServices ? QueryServicesDescriptor.toAmino(message.queryServices) : undefined; + obj.tx = message.tx ? TxDescriptor.toAmino(message.tx) : undefined; + return obj; + }, + fromAminoMsg(object: AppDescriptorAminoMsg): AppDescriptor { + return AppDescriptor.fromAmino(object.value); + }, + toAminoMsg(message: AppDescriptor): AppDescriptorAminoMsg { + return { + type: "cosmos-sdk/AppDescriptor", + value: AppDescriptor.toAmino(message) + }; + }, + fromProtoMsg(message: AppDescriptorProtoMsg): AppDescriptor { + return AppDescriptor.decode(message.value); + }, + toProto(message: AppDescriptor): Uint8Array { + return AppDescriptor.encode(message).finish(); + }, + toProtoMsg(message: AppDescriptor): AppDescriptorProtoMsg { + return { + typeUrl: "/cosmos.base.reflection.v2alpha1.AppDescriptor", + value: AppDescriptor.encode(message).finish() + }; + } +}; +function createBaseTxDescriptor(): TxDescriptor { + return { + fullname: "", + msgs: [] + }; +} +export const TxDescriptor = { + typeUrl: "/cosmos.base.reflection.v2alpha1.TxDescriptor", + encode(message: TxDescriptor, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.fullname !== undefined) { + writer.uint32(10).string(message.fullname); + } + for (const v of message.msgs) { + MsgDescriptor.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): TxDescriptor { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseTxDescriptor(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.fullname = reader.string(); + break; + case 2: + message.msgs.push(MsgDescriptor.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): TxDescriptor { + const obj = createBaseTxDescriptor(); + if (isSet(object.fullname)) obj.fullname = String(object.fullname); + if (Array.isArray(object?.msgs)) obj.msgs = object.msgs.map((e: any) => MsgDescriptor.fromJSON(e)); + return obj; + }, + toJSON(message: TxDescriptor): JsonSafe { + const obj: any = {}; + message.fullname !== undefined && (obj.fullname = message.fullname); + if (message.msgs) { + obj.msgs = message.msgs.map(e => e ? MsgDescriptor.toJSON(e) : undefined); + } else { + obj.msgs = []; + } + return obj; + }, + fromPartial(object: DeepPartial): TxDescriptor { + const message = createBaseTxDescriptor(); + message.fullname = object.fullname ?? ""; + message.msgs = object.msgs?.map(e => MsgDescriptor.fromPartial(e)) || []; + return message; + }, + fromSDK(object: TxDescriptorSDKType): TxDescriptor { + return { + fullname: object?.fullname, + msgs: Array.isArray(object?.msgs) ? object.msgs.map((e: any) => MsgDescriptor.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): TxDescriptorSDKType { + return { + fullname: isSet(object.fullname) ? String(object.fullname) : "", + msgs: Array.isArray(object?.msgs) ? object.msgs.map((e: any) => MsgDescriptor.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: TxDescriptor): TxDescriptorSDKType { + const obj: any = {}; + obj.fullname = message.fullname; + if (message.msgs) { + obj.msgs = message.msgs.map(e => e ? MsgDescriptor.toSDK(e) : undefined); + } else { + obj.msgs = []; + } + return obj; + }, + fromAmino(object: TxDescriptorAmino): TxDescriptor { + const message = createBaseTxDescriptor(); + if (object.fullname !== undefined && object.fullname !== null) { + message.fullname = object.fullname; + } + message.msgs = object.msgs?.map(e => MsgDescriptor.fromAmino(e)) || []; + return message; + }, + toAmino(message: TxDescriptor): TxDescriptorAmino { + const obj: any = {}; + obj.fullname = message.fullname === "" ? undefined : message.fullname; + if (message.msgs) { + obj.msgs = message.msgs.map(e => e ? MsgDescriptor.toAmino(e) : undefined); + } else { + obj.msgs = message.msgs; + } + return obj; + }, + fromAminoMsg(object: TxDescriptorAminoMsg): TxDescriptor { + return TxDescriptor.fromAmino(object.value); + }, + toAminoMsg(message: TxDescriptor): TxDescriptorAminoMsg { + return { + type: "cosmos-sdk/TxDescriptor", + value: TxDescriptor.toAmino(message) + }; + }, + fromProtoMsg(message: TxDescriptorProtoMsg): TxDescriptor { + return TxDescriptor.decode(message.value); + }, + toProto(message: TxDescriptor): Uint8Array { + return TxDescriptor.encode(message).finish(); + }, + toProtoMsg(message: TxDescriptor): TxDescriptorProtoMsg { + return { + typeUrl: "/cosmos.base.reflection.v2alpha1.TxDescriptor", + value: TxDescriptor.encode(message).finish() + }; + } +}; +function createBaseAuthnDescriptor(): AuthnDescriptor { + return { + signModes: [] + }; +} +export const AuthnDescriptor = { + typeUrl: "/cosmos.base.reflection.v2alpha1.AuthnDescriptor", + encode(message: AuthnDescriptor, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.signModes) { + SigningModeDescriptor.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): AuthnDescriptor { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseAuthnDescriptor(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.signModes.push(SigningModeDescriptor.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): AuthnDescriptor { + const obj = createBaseAuthnDescriptor(); + if (Array.isArray(object?.signModes)) obj.signModes = object.signModes.map((e: any) => SigningModeDescriptor.fromJSON(e)); + return obj; + }, + toJSON(message: AuthnDescriptor): JsonSafe { + const obj: any = {}; + if (message.signModes) { + obj.signModes = message.signModes.map(e => e ? SigningModeDescriptor.toJSON(e) : undefined); + } else { + obj.signModes = []; + } + return obj; + }, + fromPartial(object: DeepPartial): AuthnDescriptor { + const message = createBaseAuthnDescriptor(); + message.signModes = object.signModes?.map(e => SigningModeDescriptor.fromPartial(e)) || []; + return message; + }, + fromSDK(object: AuthnDescriptorSDKType): AuthnDescriptor { + return { + signModes: Array.isArray(object?.sign_modes) ? object.sign_modes.map((e: any) => SigningModeDescriptor.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): AuthnDescriptorSDKType { + return { + sign_modes: Array.isArray(object?.sign_modes) ? object.sign_modes.map((e: any) => SigningModeDescriptor.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: AuthnDescriptor): AuthnDescriptorSDKType { + const obj: any = {}; + if (message.signModes) { + obj.sign_modes = message.signModes.map(e => e ? SigningModeDescriptor.toSDK(e) : undefined); + } else { + obj.sign_modes = []; + } + return obj; + }, + fromAmino(object: AuthnDescriptorAmino): AuthnDescriptor { + const message = createBaseAuthnDescriptor(); + message.signModes = object.sign_modes?.map(e => SigningModeDescriptor.fromAmino(e)) || []; + return message; + }, + toAmino(message: AuthnDescriptor): AuthnDescriptorAmino { + const obj: any = {}; + if (message.signModes) { + obj.sign_modes = message.signModes.map(e => e ? SigningModeDescriptor.toAmino(e) : undefined); + } else { + obj.sign_modes = message.signModes; + } + return obj; + }, + fromAminoMsg(object: AuthnDescriptorAminoMsg): AuthnDescriptor { + return AuthnDescriptor.fromAmino(object.value); + }, + toAminoMsg(message: AuthnDescriptor): AuthnDescriptorAminoMsg { + return { + type: "cosmos-sdk/AuthnDescriptor", + value: AuthnDescriptor.toAmino(message) + }; + }, + fromProtoMsg(message: AuthnDescriptorProtoMsg): AuthnDescriptor { + return AuthnDescriptor.decode(message.value); + }, + toProto(message: AuthnDescriptor): Uint8Array { + return AuthnDescriptor.encode(message).finish(); + }, + toProtoMsg(message: AuthnDescriptor): AuthnDescriptorProtoMsg { + return { + typeUrl: "/cosmos.base.reflection.v2alpha1.AuthnDescriptor", + value: AuthnDescriptor.encode(message).finish() + }; + } +}; +function createBaseSigningModeDescriptor(): SigningModeDescriptor { + return { + name: "", + number: 0, + authnInfoProviderMethodFullname: "" + }; +} +export const SigningModeDescriptor = { + typeUrl: "/cosmos.base.reflection.v2alpha1.SigningModeDescriptor", + encode(message: SigningModeDescriptor, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + if (message.number !== undefined) { + writer.uint32(16).int32(message.number); + } + if (message.authnInfoProviderMethodFullname !== undefined) { + writer.uint32(26).string(message.authnInfoProviderMethodFullname); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): SigningModeDescriptor { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseSigningModeDescriptor(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.number = reader.int32(); + break; + case 3: + message.authnInfoProviderMethodFullname = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): SigningModeDescriptor { + const obj = createBaseSigningModeDescriptor(); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.number)) obj.number = Number(object.number); + if (isSet(object.authnInfoProviderMethodFullname)) obj.authnInfoProviderMethodFullname = String(object.authnInfoProviderMethodFullname); + return obj; + }, + toJSON(message: SigningModeDescriptor): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.number !== undefined && (obj.number = Math.round(message.number)); + message.authnInfoProviderMethodFullname !== undefined && (obj.authnInfoProviderMethodFullname = message.authnInfoProviderMethodFullname); + return obj; + }, + fromPartial(object: DeepPartial): SigningModeDescriptor { + const message = createBaseSigningModeDescriptor(); + message.name = object.name ?? ""; + message.number = object.number ?? 0; + message.authnInfoProviderMethodFullname = object.authnInfoProviderMethodFullname ?? ""; + return message; + }, + fromSDK(object: SigningModeDescriptorSDKType): SigningModeDescriptor { + return { + name: object?.name, + number: object?.number, + authnInfoProviderMethodFullname: object?.authn_info_provider_method_fullname + }; + }, + fromSDKJSON(object: any): SigningModeDescriptorSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + number: isSet(object.number) ? Number(object.number) : 0, + authn_info_provider_method_fullname: isSet(object.authn_info_provider_method_fullname) ? String(object.authn_info_provider_method_fullname) : "" + }; + }, + toSDK(message: SigningModeDescriptor): SigningModeDescriptorSDKType { + const obj: any = {}; + obj.name = message.name; + obj.number = message.number; + obj.authn_info_provider_method_fullname = message.authnInfoProviderMethodFullname; + return obj; + }, + fromAmino(object: SigningModeDescriptorAmino): SigningModeDescriptor { + const message = createBaseSigningModeDescriptor(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + if (object.number !== undefined && object.number !== null) { + message.number = object.number; + } + if (object.authn_info_provider_method_fullname !== undefined && object.authn_info_provider_method_fullname !== null) { + message.authnInfoProviderMethodFullname = object.authn_info_provider_method_fullname; + } + return message; + }, + toAmino(message: SigningModeDescriptor): SigningModeDescriptorAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + obj.number = message.number === 0 ? undefined : message.number; + obj.authn_info_provider_method_fullname = message.authnInfoProviderMethodFullname === "" ? undefined : message.authnInfoProviderMethodFullname; + return obj; + }, + fromAminoMsg(object: SigningModeDescriptorAminoMsg): SigningModeDescriptor { + return SigningModeDescriptor.fromAmino(object.value); + }, + toAminoMsg(message: SigningModeDescriptor): SigningModeDescriptorAminoMsg { + return { + type: "cosmos-sdk/SigningModeDescriptor", + value: SigningModeDescriptor.toAmino(message) + }; + }, + fromProtoMsg(message: SigningModeDescriptorProtoMsg): SigningModeDescriptor { + return SigningModeDescriptor.decode(message.value); + }, + toProto(message: SigningModeDescriptor): Uint8Array { + return SigningModeDescriptor.encode(message).finish(); + }, + toProtoMsg(message: SigningModeDescriptor): SigningModeDescriptorProtoMsg { + return { + typeUrl: "/cosmos.base.reflection.v2alpha1.SigningModeDescriptor", + value: SigningModeDescriptor.encode(message).finish() + }; + } +}; +function createBaseChainDescriptor(): ChainDescriptor { + return { + id: "" + }; +} +export const ChainDescriptor = { + typeUrl: "/cosmos.base.reflection.v2alpha1.ChainDescriptor", + encode(message: ChainDescriptor, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.id !== undefined) { + writer.uint32(10).string(message.id); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ChainDescriptor { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseChainDescriptor(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.id = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ChainDescriptor { + const obj = createBaseChainDescriptor(); + if (isSet(object.id)) obj.id = String(object.id); + return obj; + }, + toJSON(message: ChainDescriptor): JsonSafe { + const obj: any = {}; + message.id !== undefined && (obj.id = message.id); + return obj; + }, + fromPartial(object: DeepPartial): ChainDescriptor { + const message = createBaseChainDescriptor(); + message.id = object.id ?? ""; + return message; + }, + fromSDK(object: ChainDescriptorSDKType): ChainDescriptor { + return { + id: object?.id + }; + }, + fromSDKJSON(object: any): ChainDescriptorSDKType { + return { + id: isSet(object.id) ? String(object.id) : "" + }; + }, + toSDK(message: ChainDescriptor): ChainDescriptorSDKType { + const obj: any = {}; + obj.id = message.id; + return obj; + }, + fromAmino(object: ChainDescriptorAmino): ChainDescriptor { + const message = createBaseChainDescriptor(); + if (object.id !== undefined && object.id !== null) { + message.id = object.id; + } + return message; + }, + toAmino(message: ChainDescriptor): ChainDescriptorAmino { + const obj: any = {}; + obj.id = message.id === "" ? undefined : message.id; + return obj; + }, + fromAminoMsg(object: ChainDescriptorAminoMsg): ChainDescriptor { + return ChainDescriptor.fromAmino(object.value); + }, + toAminoMsg(message: ChainDescriptor): ChainDescriptorAminoMsg { + return { + type: "cosmos-sdk/ChainDescriptor", + value: ChainDescriptor.toAmino(message) + }; + }, + fromProtoMsg(message: ChainDescriptorProtoMsg): ChainDescriptor { + return ChainDescriptor.decode(message.value); + }, + toProto(message: ChainDescriptor): Uint8Array { + return ChainDescriptor.encode(message).finish(); + }, + toProtoMsg(message: ChainDescriptor): ChainDescriptorProtoMsg { + return { + typeUrl: "/cosmos.base.reflection.v2alpha1.ChainDescriptor", + value: ChainDescriptor.encode(message).finish() + }; + } +}; +function createBaseCodecDescriptor(): CodecDescriptor { + return { + interfaces: [] + }; +} +export const CodecDescriptor = { + typeUrl: "/cosmos.base.reflection.v2alpha1.CodecDescriptor", + encode(message: CodecDescriptor, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.interfaces) { + InterfaceDescriptor.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): CodecDescriptor { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCodecDescriptor(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.interfaces.push(InterfaceDescriptor.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): CodecDescriptor { + const obj = createBaseCodecDescriptor(); + if (Array.isArray(object?.interfaces)) obj.interfaces = object.interfaces.map((e: any) => InterfaceDescriptor.fromJSON(e)); + return obj; + }, + toJSON(message: CodecDescriptor): JsonSafe { + const obj: any = {}; + if (message.interfaces) { + obj.interfaces = message.interfaces.map(e => e ? InterfaceDescriptor.toJSON(e) : undefined); + } else { + obj.interfaces = []; + } + return obj; + }, + fromPartial(object: DeepPartial): CodecDescriptor { + const message = createBaseCodecDescriptor(); + message.interfaces = object.interfaces?.map(e => InterfaceDescriptor.fromPartial(e)) || []; + return message; + }, + fromSDK(object: CodecDescriptorSDKType): CodecDescriptor { + return { + interfaces: Array.isArray(object?.interfaces) ? object.interfaces.map((e: any) => InterfaceDescriptor.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): CodecDescriptorSDKType { + return { + interfaces: Array.isArray(object?.interfaces) ? object.interfaces.map((e: any) => InterfaceDescriptor.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: CodecDescriptor): CodecDescriptorSDKType { + const obj: any = {}; + if (message.interfaces) { + obj.interfaces = message.interfaces.map(e => e ? InterfaceDescriptor.toSDK(e) : undefined); + } else { + obj.interfaces = []; + } + return obj; + }, + fromAmino(object: CodecDescriptorAmino): CodecDescriptor { + const message = createBaseCodecDescriptor(); + message.interfaces = object.interfaces?.map(e => InterfaceDescriptor.fromAmino(e)) || []; + return message; + }, + toAmino(message: CodecDescriptor): CodecDescriptorAmino { + const obj: any = {}; + if (message.interfaces) { + obj.interfaces = message.interfaces.map(e => e ? InterfaceDescriptor.toAmino(e) : undefined); + } else { + obj.interfaces = message.interfaces; + } + return obj; + }, + fromAminoMsg(object: CodecDescriptorAminoMsg): CodecDescriptor { + return CodecDescriptor.fromAmino(object.value); + }, + toAminoMsg(message: CodecDescriptor): CodecDescriptorAminoMsg { + return { + type: "cosmos-sdk/CodecDescriptor", + value: CodecDescriptor.toAmino(message) + }; + }, + fromProtoMsg(message: CodecDescriptorProtoMsg): CodecDescriptor { + return CodecDescriptor.decode(message.value); + }, + toProto(message: CodecDescriptor): Uint8Array { + return CodecDescriptor.encode(message).finish(); + }, + toProtoMsg(message: CodecDescriptor): CodecDescriptorProtoMsg { + return { + typeUrl: "/cosmos.base.reflection.v2alpha1.CodecDescriptor", + value: CodecDescriptor.encode(message).finish() + }; + } +}; +function createBaseInterfaceDescriptor(): InterfaceDescriptor { + return { + fullname: "", + interfaceAcceptingMessages: [], + interfaceImplementers: [] + }; +} +export const InterfaceDescriptor = { + typeUrl: "/cosmos.base.reflection.v2alpha1.InterfaceDescriptor", + encode(message: InterfaceDescriptor, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.fullname !== undefined) { + writer.uint32(10).string(message.fullname); + } + for (const v of message.interfaceAcceptingMessages) { + InterfaceAcceptingMessageDescriptor.encode(v!, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.interfaceImplementers) { + InterfaceImplementerDescriptor.encode(v!, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): InterfaceDescriptor { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseInterfaceDescriptor(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.fullname = reader.string(); + break; + case 2: + message.interfaceAcceptingMessages.push(InterfaceAcceptingMessageDescriptor.decode(reader, reader.uint32())); + break; + case 3: + message.interfaceImplementers.push(InterfaceImplementerDescriptor.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): InterfaceDescriptor { + const obj = createBaseInterfaceDescriptor(); + if (isSet(object.fullname)) obj.fullname = String(object.fullname); + if (Array.isArray(object?.interfaceAcceptingMessages)) obj.interfaceAcceptingMessages = object.interfaceAcceptingMessages.map((e: any) => InterfaceAcceptingMessageDescriptor.fromJSON(e)); + if (Array.isArray(object?.interfaceImplementers)) obj.interfaceImplementers = object.interfaceImplementers.map((e: any) => InterfaceImplementerDescriptor.fromJSON(e)); + return obj; + }, + toJSON(message: InterfaceDescriptor): JsonSafe { + const obj: any = {}; + message.fullname !== undefined && (obj.fullname = message.fullname); + if (message.interfaceAcceptingMessages) { + obj.interfaceAcceptingMessages = message.interfaceAcceptingMessages.map(e => e ? InterfaceAcceptingMessageDescriptor.toJSON(e) : undefined); + } else { + obj.interfaceAcceptingMessages = []; + } + if (message.interfaceImplementers) { + obj.interfaceImplementers = message.interfaceImplementers.map(e => e ? InterfaceImplementerDescriptor.toJSON(e) : undefined); + } else { + obj.interfaceImplementers = []; + } + return obj; + }, + fromPartial(object: DeepPartial): InterfaceDescriptor { + const message = createBaseInterfaceDescriptor(); + message.fullname = object.fullname ?? ""; + message.interfaceAcceptingMessages = object.interfaceAcceptingMessages?.map(e => InterfaceAcceptingMessageDescriptor.fromPartial(e)) || []; + message.interfaceImplementers = object.interfaceImplementers?.map(e => InterfaceImplementerDescriptor.fromPartial(e)) || []; + return message; + }, + fromSDK(object: InterfaceDescriptorSDKType): InterfaceDescriptor { + return { + fullname: object?.fullname, + interfaceAcceptingMessages: Array.isArray(object?.interface_accepting_messages) ? object.interface_accepting_messages.map((e: any) => InterfaceAcceptingMessageDescriptor.fromSDK(e)) : [], + interfaceImplementers: Array.isArray(object?.interface_implementers) ? object.interface_implementers.map((e: any) => InterfaceImplementerDescriptor.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): InterfaceDescriptorSDKType { + return { + fullname: isSet(object.fullname) ? String(object.fullname) : "", + interface_accepting_messages: Array.isArray(object?.interface_accepting_messages) ? object.interface_accepting_messages.map((e: any) => InterfaceAcceptingMessageDescriptor.fromSDKJSON(e)) : [], + interface_implementers: Array.isArray(object?.interface_implementers) ? object.interface_implementers.map((e: any) => InterfaceImplementerDescriptor.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: InterfaceDescriptor): InterfaceDescriptorSDKType { + const obj: any = {}; + obj.fullname = message.fullname; + if (message.interfaceAcceptingMessages) { + obj.interface_accepting_messages = message.interfaceAcceptingMessages.map(e => e ? InterfaceAcceptingMessageDescriptor.toSDK(e) : undefined); + } else { + obj.interface_accepting_messages = []; + } + if (message.interfaceImplementers) { + obj.interface_implementers = message.interfaceImplementers.map(e => e ? InterfaceImplementerDescriptor.toSDK(e) : undefined); + } else { + obj.interface_implementers = []; + } + return obj; + }, + fromAmino(object: InterfaceDescriptorAmino): InterfaceDescriptor { + const message = createBaseInterfaceDescriptor(); + if (object.fullname !== undefined && object.fullname !== null) { + message.fullname = object.fullname; + } + message.interfaceAcceptingMessages = object.interface_accepting_messages?.map(e => InterfaceAcceptingMessageDescriptor.fromAmino(e)) || []; + message.interfaceImplementers = object.interface_implementers?.map(e => InterfaceImplementerDescriptor.fromAmino(e)) || []; + return message; + }, + toAmino(message: InterfaceDescriptor): InterfaceDescriptorAmino { + const obj: any = {}; + obj.fullname = message.fullname === "" ? undefined : message.fullname; + if (message.interfaceAcceptingMessages) { + obj.interface_accepting_messages = message.interfaceAcceptingMessages.map(e => e ? InterfaceAcceptingMessageDescriptor.toAmino(e) : undefined); + } else { + obj.interface_accepting_messages = message.interfaceAcceptingMessages; + } + if (message.interfaceImplementers) { + obj.interface_implementers = message.interfaceImplementers.map(e => e ? InterfaceImplementerDescriptor.toAmino(e) : undefined); + } else { + obj.interface_implementers = message.interfaceImplementers; + } + return obj; + }, + fromAminoMsg(object: InterfaceDescriptorAminoMsg): InterfaceDescriptor { + return InterfaceDescriptor.fromAmino(object.value); + }, + toAminoMsg(message: InterfaceDescriptor): InterfaceDescriptorAminoMsg { + return { + type: "cosmos-sdk/InterfaceDescriptor", + value: InterfaceDescriptor.toAmino(message) + }; + }, + fromProtoMsg(message: InterfaceDescriptorProtoMsg): InterfaceDescriptor { + return InterfaceDescriptor.decode(message.value); + }, + toProto(message: InterfaceDescriptor): Uint8Array { + return InterfaceDescriptor.encode(message).finish(); + }, + toProtoMsg(message: InterfaceDescriptor): InterfaceDescriptorProtoMsg { + return { + typeUrl: "/cosmos.base.reflection.v2alpha1.InterfaceDescriptor", + value: InterfaceDescriptor.encode(message).finish() + }; + } +}; +function createBaseInterfaceImplementerDescriptor(): InterfaceImplementerDescriptor { + return { + fullname: "", + typeUrl: "" + }; +} +export const InterfaceImplementerDescriptor = { + typeUrl: "/cosmos.base.reflection.v2alpha1.InterfaceImplementerDescriptor", + encode(message: InterfaceImplementerDescriptor, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.fullname !== undefined) { + writer.uint32(10).string(message.fullname); + } + if (message.typeUrl !== undefined) { + writer.uint32(18).string(message.typeUrl); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): InterfaceImplementerDescriptor { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseInterfaceImplementerDescriptor(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.fullname = reader.string(); + break; + case 2: + message.typeUrl = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): InterfaceImplementerDescriptor { + const obj = createBaseInterfaceImplementerDescriptor(); + if (isSet(object.fullname)) obj.fullname = String(object.fullname); + if (isSet(object.typeUrl)) obj.typeUrl = String(object.typeUrl); + return obj; + }, + toJSON(message: InterfaceImplementerDescriptor): JsonSafe { + const obj: any = {}; + message.fullname !== undefined && (obj.fullname = message.fullname); + message.typeUrl !== undefined && (obj.typeUrl = message.typeUrl); + return obj; + }, + fromPartial(object: DeepPartial): InterfaceImplementerDescriptor { + const message = createBaseInterfaceImplementerDescriptor(); + message.fullname = object.fullname ?? ""; + message.typeUrl = object.typeUrl ?? ""; + return message; + }, + fromSDK(object: InterfaceImplementerDescriptorSDKType): InterfaceImplementerDescriptor { + return { + fullname: object?.fullname, + typeUrl: object?.type_url + }; + }, + fromSDKJSON(object: any): InterfaceImplementerDescriptorSDKType { + return { + fullname: isSet(object.fullname) ? String(object.fullname) : "", + type_url: isSet(object.type_url) ? String(object.type_url) : "" + }; + }, + toSDK(message: InterfaceImplementerDescriptor): InterfaceImplementerDescriptorSDKType { + const obj: any = {}; + obj.fullname = message.fullname; + obj.type_url = message.typeUrl; + return obj; + }, + fromAmino(object: InterfaceImplementerDescriptorAmino): InterfaceImplementerDescriptor { + const message = createBaseInterfaceImplementerDescriptor(); + if (object.fullname !== undefined && object.fullname !== null) { + message.fullname = object.fullname; + } + if (object.type_url !== undefined && object.type_url !== null) { + message.typeUrl = object.type_url; + } + return message; + }, + toAmino(message: InterfaceImplementerDescriptor): InterfaceImplementerDescriptorAmino { + const obj: any = {}; + obj.fullname = message.fullname === "" ? undefined : message.fullname; + obj.type_url = message.typeUrl === "" ? undefined : message.typeUrl; + return obj; + }, + fromAminoMsg(object: InterfaceImplementerDescriptorAminoMsg): InterfaceImplementerDescriptor { + return InterfaceImplementerDescriptor.fromAmino(object.value); + }, + toAminoMsg(message: InterfaceImplementerDescriptor): InterfaceImplementerDescriptorAminoMsg { + return { + type: "cosmos-sdk/InterfaceImplementerDescriptor", + value: InterfaceImplementerDescriptor.toAmino(message) + }; + }, + fromProtoMsg(message: InterfaceImplementerDescriptorProtoMsg): InterfaceImplementerDescriptor { + return InterfaceImplementerDescriptor.decode(message.value); + }, + toProto(message: InterfaceImplementerDescriptor): Uint8Array { + return InterfaceImplementerDescriptor.encode(message).finish(); + }, + toProtoMsg(message: InterfaceImplementerDescriptor): InterfaceImplementerDescriptorProtoMsg { + return { + typeUrl: "/cosmos.base.reflection.v2alpha1.InterfaceImplementerDescriptor", + value: InterfaceImplementerDescriptor.encode(message).finish() + }; + } +}; +function createBaseInterfaceAcceptingMessageDescriptor(): InterfaceAcceptingMessageDescriptor { + return { + fullname: "", + fieldDescriptorNames: [] + }; +} +export const InterfaceAcceptingMessageDescriptor = { + typeUrl: "/cosmos.base.reflection.v2alpha1.InterfaceAcceptingMessageDescriptor", + encode(message: InterfaceAcceptingMessageDescriptor, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.fullname !== undefined) { + writer.uint32(10).string(message.fullname); + } + for (const v of message.fieldDescriptorNames) { + writer.uint32(18).string(v!); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): InterfaceAcceptingMessageDescriptor { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseInterfaceAcceptingMessageDescriptor(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.fullname = reader.string(); + break; + case 2: + message.fieldDescriptorNames.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): InterfaceAcceptingMessageDescriptor { + const obj = createBaseInterfaceAcceptingMessageDescriptor(); + if (isSet(object.fullname)) obj.fullname = String(object.fullname); + if (Array.isArray(object?.fieldDescriptorNames)) obj.fieldDescriptorNames = object.fieldDescriptorNames.map((e: any) => String(e)); + return obj; + }, + toJSON(message: InterfaceAcceptingMessageDescriptor): JsonSafe { + const obj: any = {}; + message.fullname !== undefined && (obj.fullname = message.fullname); + if (message.fieldDescriptorNames) { + obj.fieldDescriptorNames = message.fieldDescriptorNames.map(e => e); + } else { + obj.fieldDescriptorNames = []; + } + return obj; + }, + fromPartial(object: DeepPartial): InterfaceAcceptingMessageDescriptor { + const message = createBaseInterfaceAcceptingMessageDescriptor(); + message.fullname = object.fullname ?? ""; + message.fieldDescriptorNames = object.fieldDescriptorNames?.map(e => e) || []; + return message; + }, + fromSDK(object: InterfaceAcceptingMessageDescriptorSDKType): InterfaceAcceptingMessageDescriptor { + return { + fullname: object?.fullname, + fieldDescriptorNames: Array.isArray(object?.field_descriptor_names) ? object.field_descriptor_names.map((e: any) => e) : [] + }; + }, + fromSDKJSON(object: any): InterfaceAcceptingMessageDescriptorSDKType { + return { + fullname: isSet(object.fullname) ? String(object.fullname) : "", + field_descriptor_names: Array.isArray(object?.field_descriptor_names) ? object.field_descriptor_names.map((e: any) => String(e)) : [] + }; + }, + toSDK(message: InterfaceAcceptingMessageDescriptor): InterfaceAcceptingMessageDescriptorSDKType { + const obj: any = {}; + obj.fullname = message.fullname; + if (message.fieldDescriptorNames) { + obj.field_descriptor_names = message.fieldDescriptorNames.map(e => e); + } else { + obj.field_descriptor_names = []; + } + return obj; + }, + fromAmino(object: InterfaceAcceptingMessageDescriptorAmino): InterfaceAcceptingMessageDescriptor { + const message = createBaseInterfaceAcceptingMessageDescriptor(); + if (object.fullname !== undefined && object.fullname !== null) { + message.fullname = object.fullname; + } + message.fieldDescriptorNames = object.field_descriptor_names?.map(e => e) || []; + return message; + }, + toAmino(message: InterfaceAcceptingMessageDescriptor): InterfaceAcceptingMessageDescriptorAmino { + const obj: any = {}; + obj.fullname = message.fullname === "" ? undefined : message.fullname; + if (message.fieldDescriptorNames) { + obj.field_descriptor_names = message.fieldDescriptorNames.map(e => e); + } else { + obj.field_descriptor_names = message.fieldDescriptorNames; + } + return obj; + }, + fromAminoMsg(object: InterfaceAcceptingMessageDescriptorAminoMsg): InterfaceAcceptingMessageDescriptor { + return InterfaceAcceptingMessageDescriptor.fromAmino(object.value); + }, + toAminoMsg(message: InterfaceAcceptingMessageDescriptor): InterfaceAcceptingMessageDescriptorAminoMsg { + return { + type: "cosmos-sdk/InterfaceAcceptingMessageDescriptor", + value: InterfaceAcceptingMessageDescriptor.toAmino(message) + }; + }, + fromProtoMsg(message: InterfaceAcceptingMessageDescriptorProtoMsg): InterfaceAcceptingMessageDescriptor { + return InterfaceAcceptingMessageDescriptor.decode(message.value); + }, + toProto(message: InterfaceAcceptingMessageDescriptor): Uint8Array { + return InterfaceAcceptingMessageDescriptor.encode(message).finish(); + }, + toProtoMsg(message: InterfaceAcceptingMessageDescriptor): InterfaceAcceptingMessageDescriptorProtoMsg { + return { + typeUrl: "/cosmos.base.reflection.v2alpha1.InterfaceAcceptingMessageDescriptor", + value: InterfaceAcceptingMessageDescriptor.encode(message).finish() + }; + } +}; +function createBaseConfigurationDescriptor(): ConfigurationDescriptor { + return { + bech32AccountAddressPrefix: "" + }; +} +export const ConfigurationDescriptor = { + typeUrl: "/cosmos.base.reflection.v2alpha1.ConfigurationDescriptor", + encode(message: ConfigurationDescriptor, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.bech32AccountAddressPrefix !== undefined) { + writer.uint32(10).string(message.bech32AccountAddressPrefix); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ConfigurationDescriptor { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseConfigurationDescriptor(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.bech32AccountAddressPrefix = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ConfigurationDescriptor { + const obj = createBaseConfigurationDescriptor(); + if (isSet(object.bech32AccountAddressPrefix)) obj.bech32AccountAddressPrefix = String(object.bech32AccountAddressPrefix); + return obj; + }, + toJSON(message: ConfigurationDescriptor): JsonSafe { + const obj: any = {}; + message.bech32AccountAddressPrefix !== undefined && (obj.bech32AccountAddressPrefix = message.bech32AccountAddressPrefix); + return obj; + }, + fromPartial(object: DeepPartial): ConfigurationDescriptor { + const message = createBaseConfigurationDescriptor(); + message.bech32AccountAddressPrefix = object.bech32AccountAddressPrefix ?? ""; + return message; + }, + fromSDK(object: ConfigurationDescriptorSDKType): ConfigurationDescriptor { + return { + bech32AccountAddressPrefix: object?.bech32_account_address_prefix + }; + }, + fromSDKJSON(object: any): ConfigurationDescriptorSDKType { + return { + bech32_account_address_prefix: isSet(object.bech32_account_address_prefix) ? String(object.bech32_account_address_prefix) : "" + }; + }, + toSDK(message: ConfigurationDescriptor): ConfigurationDescriptorSDKType { + const obj: any = {}; + obj.bech32_account_address_prefix = message.bech32AccountAddressPrefix; + return obj; + }, + fromAmino(object: ConfigurationDescriptorAmino): ConfigurationDescriptor { + const message = createBaseConfigurationDescriptor(); + if (object.bech32_account_address_prefix !== undefined && object.bech32_account_address_prefix !== null) { + message.bech32AccountAddressPrefix = object.bech32_account_address_prefix; + } + return message; + }, + toAmino(message: ConfigurationDescriptor): ConfigurationDescriptorAmino { + const obj: any = {}; + obj.bech32_account_address_prefix = message.bech32AccountAddressPrefix === "" ? undefined : message.bech32AccountAddressPrefix; + return obj; + }, + fromAminoMsg(object: ConfigurationDescriptorAminoMsg): ConfigurationDescriptor { + return ConfigurationDescriptor.fromAmino(object.value); + }, + toAminoMsg(message: ConfigurationDescriptor): ConfigurationDescriptorAminoMsg { + return { + type: "cosmos-sdk/ConfigurationDescriptor", + value: ConfigurationDescriptor.toAmino(message) + }; + }, + fromProtoMsg(message: ConfigurationDescriptorProtoMsg): ConfigurationDescriptor { + return ConfigurationDescriptor.decode(message.value); + }, + toProto(message: ConfigurationDescriptor): Uint8Array { + return ConfigurationDescriptor.encode(message).finish(); + }, + toProtoMsg(message: ConfigurationDescriptor): ConfigurationDescriptorProtoMsg { + return { + typeUrl: "/cosmos.base.reflection.v2alpha1.ConfigurationDescriptor", + value: ConfigurationDescriptor.encode(message).finish() + }; + } +}; +function createBaseMsgDescriptor(): MsgDescriptor { + return { + msgTypeUrl: "" + }; +} +export const MsgDescriptor = { + typeUrl: "/cosmos.base.reflection.v2alpha1.MsgDescriptor", + encode(message: MsgDescriptor, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.msgTypeUrl !== undefined) { + writer.uint32(10).string(message.msgTypeUrl); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgDescriptor { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgDescriptor(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.msgTypeUrl = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgDescriptor { + const obj = createBaseMsgDescriptor(); + if (isSet(object.msgTypeUrl)) obj.msgTypeUrl = String(object.msgTypeUrl); + return obj; + }, + toJSON(message: MsgDescriptor): JsonSafe { + const obj: any = {}; + message.msgTypeUrl !== undefined && (obj.msgTypeUrl = message.msgTypeUrl); + return obj; + }, + fromPartial(object: DeepPartial): MsgDescriptor { + const message = createBaseMsgDescriptor(); + message.msgTypeUrl = object.msgTypeUrl ?? ""; + return message; + }, + fromSDK(object: MsgDescriptorSDKType): MsgDescriptor { + return { + msgTypeUrl: object?.msg_type_url + }; + }, + fromSDKJSON(object: any): MsgDescriptorSDKType { + return { + msg_type_url: isSet(object.msg_type_url) ? String(object.msg_type_url) : "" + }; + }, + toSDK(message: MsgDescriptor): MsgDescriptorSDKType { + const obj: any = {}; + obj.msg_type_url = message.msgTypeUrl; + return obj; + }, + fromAmino(object: MsgDescriptorAmino): MsgDescriptor { + const message = createBaseMsgDescriptor(); + if (object.msg_type_url !== undefined && object.msg_type_url !== null) { + message.msgTypeUrl = object.msg_type_url; + } + return message; + }, + toAmino(message: MsgDescriptor): MsgDescriptorAmino { + const obj: any = {}; + obj.msg_type_url = message.msgTypeUrl === "" ? undefined : message.msgTypeUrl; + return obj; + }, + fromAminoMsg(object: MsgDescriptorAminoMsg): MsgDescriptor { + return MsgDescriptor.fromAmino(object.value); + }, + toAminoMsg(message: MsgDescriptor): MsgDescriptorAminoMsg { + return { + type: "cosmos-sdk/MsgDescriptor", + value: MsgDescriptor.toAmino(message) + }; + }, + fromProtoMsg(message: MsgDescriptorProtoMsg): MsgDescriptor { + return MsgDescriptor.decode(message.value); + }, + toProto(message: MsgDescriptor): Uint8Array { + return MsgDescriptor.encode(message).finish(); + }, + toProtoMsg(message: MsgDescriptor): MsgDescriptorProtoMsg { + return { + typeUrl: "/cosmos.base.reflection.v2alpha1.MsgDescriptor", + value: MsgDescriptor.encode(message).finish() + }; + } +}; +function createBaseGetAuthnDescriptorRequest(): GetAuthnDescriptorRequest { + return {}; +} +export const GetAuthnDescriptorRequest = { + typeUrl: "/cosmos.base.reflection.v2alpha1.GetAuthnDescriptorRequest", + encode(_: GetAuthnDescriptorRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GetAuthnDescriptorRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGetAuthnDescriptorRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): GetAuthnDescriptorRequest { + const obj = createBaseGetAuthnDescriptorRequest(); + return obj; + }, + toJSON(_: GetAuthnDescriptorRequest): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): GetAuthnDescriptorRequest { + const message = createBaseGetAuthnDescriptorRequest(); + return message; + }, + fromSDK(_: GetAuthnDescriptorRequestSDKType): GetAuthnDescriptorRequest { + return {}; + }, + fromSDKJSON(_: any): GetAuthnDescriptorRequestSDKType { + return {}; + }, + toSDK(_: GetAuthnDescriptorRequest): GetAuthnDescriptorRequestSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: GetAuthnDescriptorRequestAmino): GetAuthnDescriptorRequest { + const message = createBaseGetAuthnDescriptorRequest(); + return message; + }, + toAmino(_: GetAuthnDescriptorRequest): GetAuthnDescriptorRequestAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: GetAuthnDescriptorRequestAminoMsg): GetAuthnDescriptorRequest { + return GetAuthnDescriptorRequest.fromAmino(object.value); + }, + toAminoMsg(message: GetAuthnDescriptorRequest): GetAuthnDescriptorRequestAminoMsg { + return { + type: "cosmos-sdk/GetAuthnDescriptorRequest", + value: GetAuthnDescriptorRequest.toAmino(message) + }; + }, + fromProtoMsg(message: GetAuthnDescriptorRequestProtoMsg): GetAuthnDescriptorRequest { + return GetAuthnDescriptorRequest.decode(message.value); + }, + toProto(message: GetAuthnDescriptorRequest): Uint8Array { + return GetAuthnDescriptorRequest.encode(message).finish(); + }, + toProtoMsg(message: GetAuthnDescriptorRequest): GetAuthnDescriptorRequestProtoMsg { + return { + typeUrl: "/cosmos.base.reflection.v2alpha1.GetAuthnDescriptorRequest", + value: GetAuthnDescriptorRequest.encode(message).finish() + }; + } +}; +function createBaseGetAuthnDescriptorResponse(): GetAuthnDescriptorResponse { + return { + authn: undefined + }; +} +export const GetAuthnDescriptorResponse = { + typeUrl: "/cosmos.base.reflection.v2alpha1.GetAuthnDescriptorResponse", + encode(message: GetAuthnDescriptorResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.authn !== undefined) { + AuthnDescriptor.encode(message.authn, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GetAuthnDescriptorResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGetAuthnDescriptorResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.authn = AuthnDescriptor.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GetAuthnDescriptorResponse { + const obj = createBaseGetAuthnDescriptorResponse(); + if (isSet(object.authn)) obj.authn = AuthnDescriptor.fromJSON(object.authn); + return obj; + }, + toJSON(message: GetAuthnDescriptorResponse): JsonSafe { + const obj: any = {}; + message.authn !== undefined && (obj.authn = message.authn ? AuthnDescriptor.toJSON(message.authn) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): GetAuthnDescriptorResponse { + const message = createBaseGetAuthnDescriptorResponse(); + if (object.authn !== undefined && object.authn !== null) { + message.authn = AuthnDescriptor.fromPartial(object.authn); + } + return message; + }, + fromSDK(object: GetAuthnDescriptorResponseSDKType): GetAuthnDescriptorResponse { + return { + authn: object.authn ? AuthnDescriptor.fromSDK(object.authn) : undefined + }; + }, + fromSDKJSON(object: any): GetAuthnDescriptorResponseSDKType { + return { + authn: isSet(object.authn) ? AuthnDescriptor.fromSDKJSON(object.authn) : undefined + }; + }, + toSDK(message: GetAuthnDescriptorResponse): GetAuthnDescriptorResponseSDKType { + const obj: any = {}; + message.authn !== undefined && (obj.authn = message.authn ? AuthnDescriptor.toSDK(message.authn) : undefined); + return obj; + }, + fromAmino(object: GetAuthnDescriptorResponseAmino): GetAuthnDescriptorResponse { + const message = createBaseGetAuthnDescriptorResponse(); + if (object.authn !== undefined && object.authn !== null) { + message.authn = AuthnDescriptor.fromAmino(object.authn); + } + return message; + }, + toAmino(message: GetAuthnDescriptorResponse): GetAuthnDescriptorResponseAmino { + const obj: any = {}; + obj.authn = message.authn ? AuthnDescriptor.toAmino(message.authn) : undefined; + return obj; + }, + fromAminoMsg(object: GetAuthnDescriptorResponseAminoMsg): GetAuthnDescriptorResponse { + return GetAuthnDescriptorResponse.fromAmino(object.value); + }, + toAminoMsg(message: GetAuthnDescriptorResponse): GetAuthnDescriptorResponseAminoMsg { + return { + type: "cosmos-sdk/GetAuthnDescriptorResponse", + value: GetAuthnDescriptorResponse.toAmino(message) + }; + }, + fromProtoMsg(message: GetAuthnDescriptorResponseProtoMsg): GetAuthnDescriptorResponse { + return GetAuthnDescriptorResponse.decode(message.value); + }, + toProto(message: GetAuthnDescriptorResponse): Uint8Array { + return GetAuthnDescriptorResponse.encode(message).finish(); + }, + toProtoMsg(message: GetAuthnDescriptorResponse): GetAuthnDescriptorResponseProtoMsg { + return { + typeUrl: "/cosmos.base.reflection.v2alpha1.GetAuthnDescriptorResponse", + value: GetAuthnDescriptorResponse.encode(message).finish() + }; + } +}; +function createBaseGetChainDescriptorRequest(): GetChainDescriptorRequest { + return {}; +} +export const GetChainDescriptorRequest = { + typeUrl: "/cosmos.base.reflection.v2alpha1.GetChainDescriptorRequest", + encode(_: GetChainDescriptorRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GetChainDescriptorRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGetChainDescriptorRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): GetChainDescriptorRequest { + const obj = createBaseGetChainDescriptorRequest(); + return obj; + }, + toJSON(_: GetChainDescriptorRequest): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): GetChainDescriptorRequest { + const message = createBaseGetChainDescriptorRequest(); + return message; + }, + fromSDK(_: GetChainDescriptorRequestSDKType): GetChainDescriptorRequest { + return {}; + }, + fromSDKJSON(_: any): GetChainDescriptorRequestSDKType { + return {}; + }, + toSDK(_: GetChainDescriptorRequest): GetChainDescriptorRequestSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: GetChainDescriptorRequestAmino): GetChainDescriptorRequest { + const message = createBaseGetChainDescriptorRequest(); + return message; + }, + toAmino(_: GetChainDescriptorRequest): GetChainDescriptorRequestAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: GetChainDescriptorRequestAminoMsg): GetChainDescriptorRequest { + return GetChainDescriptorRequest.fromAmino(object.value); + }, + toAminoMsg(message: GetChainDescriptorRequest): GetChainDescriptorRequestAminoMsg { + return { + type: "cosmos-sdk/GetChainDescriptorRequest", + value: GetChainDescriptorRequest.toAmino(message) + }; + }, + fromProtoMsg(message: GetChainDescriptorRequestProtoMsg): GetChainDescriptorRequest { + return GetChainDescriptorRequest.decode(message.value); + }, + toProto(message: GetChainDescriptorRequest): Uint8Array { + return GetChainDescriptorRequest.encode(message).finish(); + }, + toProtoMsg(message: GetChainDescriptorRequest): GetChainDescriptorRequestProtoMsg { + return { + typeUrl: "/cosmos.base.reflection.v2alpha1.GetChainDescriptorRequest", + value: GetChainDescriptorRequest.encode(message).finish() + }; + } +}; +function createBaseGetChainDescriptorResponse(): GetChainDescriptorResponse { + return { + chain: undefined + }; +} +export const GetChainDescriptorResponse = { + typeUrl: "/cosmos.base.reflection.v2alpha1.GetChainDescriptorResponse", + encode(message: GetChainDescriptorResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.chain !== undefined) { + ChainDescriptor.encode(message.chain, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GetChainDescriptorResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGetChainDescriptorResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.chain = ChainDescriptor.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GetChainDescriptorResponse { + const obj = createBaseGetChainDescriptorResponse(); + if (isSet(object.chain)) obj.chain = ChainDescriptor.fromJSON(object.chain); + return obj; + }, + toJSON(message: GetChainDescriptorResponse): JsonSafe { + const obj: any = {}; + message.chain !== undefined && (obj.chain = message.chain ? ChainDescriptor.toJSON(message.chain) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): GetChainDescriptorResponse { + const message = createBaseGetChainDescriptorResponse(); + if (object.chain !== undefined && object.chain !== null) { + message.chain = ChainDescriptor.fromPartial(object.chain); + } + return message; + }, + fromSDK(object: GetChainDescriptorResponseSDKType): GetChainDescriptorResponse { + return { + chain: object.chain ? ChainDescriptor.fromSDK(object.chain) : undefined + }; + }, + fromSDKJSON(object: any): GetChainDescriptorResponseSDKType { + return { + chain: isSet(object.chain) ? ChainDescriptor.fromSDKJSON(object.chain) : undefined + }; + }, + toSDK(message: GetChainDescriptorResponse): GetChainDescriptorResponseSDKType { + const obj: any = {}; + message.chain !== undefined && (obj.chain = message.chain ? ChainDescriptor.toSDK(message.chain) : undefined); + return obj; + }, + fromAmino(object: GetChainDescriptorResponseAmino): GetChainDescriptorResponse { + const message = createBaseGetChainDescriptorResponse(); + if (object.chain !== undefined && object.chain !== null) { + message.chain = ChainDescriptor.fromAmino(object.chain); + } + return message; + }, + toAmino(message: GetChainDescriptorResponse): GetChainDescriptorResponseAmino { + const obj: any = {}; + obj.chain = message.chain ? ChainDescriptor.toAmino(message.chain) : undefined; + return obj; + }, + fromAminoMsg(object: GetChainDescriptorResponseAminoMsg): GetChainDescriptorResponse { + return GetChainDescriptorResponse.fromAmino(object.value); + }, + toAminoMsg(message: GetChainDescriptorResponse): GetChainDescriptorResponseAminoMsg { + return { + type: "cosmos-sdk/GetChainDescriptorResponse", + value: GetChainDescriptorResponse.toAmino(message) + }; + }, + fromProtoMsg(message: GetChainDescriptorResponseProtoMsg): GetChainDescriptorResponse { + return GetChainDescriptorResponse.decode(message.value); + }, + toProto(message: GetChainDescriptorResponse): Uint8Array { + return GetChainDescriptorResponse.encode(message).finish(); + }, + toProtoMsg(message: GetChainDescriptorResponse): GetChainDescriptorResponseProtoMsg { + return { + typeUrl: "/cosmos.base.reflection.v2alpha1.GetChainDescriptorResponse", + value: GetChainDescriptorResponse.encode(message).finish() + }; + } +}; +function createBaseGetCodecDescriptorRequest(): GetCodecDescriptorRequest { + return {}; +} +export const GetCodecDescriptorRequest = { + typeUrl: "/cosmos.base.reflection.v2alpha1.GetCodecDescriptorRequest", + encode(_: GetCodecDescriptorRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GetCodecDescriptorRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGetCodecDescriptorRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): GetCodecDescriptorRequest { + const obj = createBaseGetCodecDescriptorRequest(); + return obj; + }, + toJSON(_: GetCodecDescriptorRequest): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): GetCodecDescriptorRequest { + const message = createBaseGetCodecDescriptorRequest(); + return message; + }, + fromSDK(_: GetCodecDescriptorRequestSDKType): GetCodecDescriptorRequest { + return {}; + }, + fromSDKJSON(_: any): GetCodecDescriptorRequestSDKType { + return {}; + }, + toSDK(_: GetCodecDescriptorRequest): GetCodecDescriptorRequestSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: GetCodecDescriptorRequestAmino): GetCodecDescriptorRequest { + const message = createBaseGetCodecDescriptorRequest(); + return message; + }, + toAmino(_: GetCodecDescriptorRequest): GetCodecDescriptorRequestAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: GetCodecDescriptorRequestAminoMsg): GetCodecDescriptorRequest { + return GetCodecDescriptorRequest.fromAmino(object.value); + }, + toAminoMsg(message: GetCodecDescriptorRequest): GetCodecDescriptorRequestAminoMsg { + return { + type: "cosmos-sdk/GetCodecDescriptorRequest", + value: GetCodecDescriptorRequest.toAmino(message) + }; + }, + fromProtoMsg(message: GetCodecDescriptorRequestProtoMsg): GetCodecDescriptorRequest { + return GetCodecDescriptorRequest.decode(message.value); + }, + toProto(message: GetCodecDescriptorRequest): Uint8Array { + return GetCodecDescriptorRequest.encode(message).finish(); + }, + toProtoMsg(message: GetCodecDescriptorRequest): GetCodecDescriptorRequestProtoMsg { + return { + typeUrl: "/cosmos.base.reflection.v2alpha1.GetCodecDescriptorRequest", + value: GetCodecDescriptorRequest.encode(message).finish() + }; + } +}; +function createBaseGetCodecDescriptorResponse(): GetCodecDescriptorResponse { + return { + codec: undefined + }; +} +export const GetCodecDescriptorResponse = { + typeUrl: "/cosmos.base.reflection.v2alpha1.GetCodecDescriptorResponse", + encode(message: GetCodecDescriptorResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.codec !== undefined) { + CodecDescriptor.encode(message.codec, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GetCodecDescriptorResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGetCodecDescriptorResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.codec = CodecDescriptor.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GetCodecDescriptorResponse { + const obj = createBaseGetCodecDescriptorResponse(); + if (isSet(object.codec)) obj.codec = CodecDescriptor.fromJSON(object.codec); + return obj; + }, + toJSON(message: GetCodecDescriptorResponse): JsonSafe { + const obj: any = {}; + message.codec !== undefined && (obj.codec = message.codec ? CodecDescriptor.toJSON(message.codec) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): GetCodecDescriptorResponse { + const message = createBaseGetCodecDescriptorResponse(); + if (object.codec !== undefined && object.codec !== null) { + message.codec = CodecDescriptor.fromPartial(object.codec); + } + return message; + }, + fromSDK(object: GetCodecDescriptorResponseSDKType): GetCodecDescriptorResponse { + return { + codec: object.codec ? CodecDescriptor.fromSDK(object.codec) : undefined + }; + }, + fromSDKJSON(object: any): GetCodecDescriptorResponseSDKType { + return { + codec: isSet(object.codec) ? CodecDescriptor.fromSDKJSON(object.codec) : undefined + }; + }, + toSDK(message: GetCodecDescriptorResponse): GetCodecDescriptorResponseSDKType { + const obj: any = {}; + message.codec !== undefined && (obj.codec = message.codec ? CodecDescriptor.toSDK(message.codec) : undefined); + return obj; + }, + fromAmino(object: GetCodecDescriptorResponseAmino): GetCodecDescriptorResponse { + const message = createBaseGetCodecDescriptorResponse(); + if (object.codec !== undefined && object.codec !== null) { + message.codec = CodecDescriptor.fromAmino(object.codec); + } + return message; + }, + toAmino(message: GetCodecDescriptorResponse): GetCodecDescriptorResponseAmino { + const obj: any = {}; + obj.codec = message.codec ? CodecDescriptor.toAmino(message.codec) : undefined; + return obj; + }, + fromAminoMsg(object: GetCodecDescriptorResponseAminoMsg): GetCodecDescriptorResponse { + return GetCodecDescriptorResponse.fromAmino(object.value); + }, + toAminoMsg(message: GetCodecDescriptorResponse): GetCodecDescriptorResponseAminoMsg { + return { + type: "cosmos-sdk/GetCodecDescriptorResponse", + value: GetCodecDescriptorResponse.toAmino(message) + }; + }, + fromProtoMsg(message: GetCodecDescriptorResponseProtoMsg): GetCodecDescriptorResponse { + return GetCodecDescriptorResponse.decode(message.value); + }, + toProto(message: GetCodecDescriptorResponse): Uint8Array { + return GetCodecDescriptorResponse.encode(message).finish(); + }, + toProtoMsg(message: GetCodecDescriptorResponse): GetCodecDescriptorResponseProtoMsg { + return { + typeUrl: "/cosmos.base.reflection.v2alpha1.GetCodecDescriptorResponse", + value: GetCodecDescriptorResponse.encode(message).finish() + }; + } +}; +function createBaseGetConfigurationDescriptorRequest(): GetConfigurationDescriptorRequest { + return {}; +} +export const GetConfigurationDescriptorRequest = { + typeUrl: "/cosmos.base.reflection.v2alpha1.GetConfigurationDescriptorRequest", + encode(_: GetConfigurationDescriptorRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GetConfigurationDescriptorRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGetConfigurationDescriptorRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): GetConfigurationDescriptorRequest { + const obj = createBaseGetConfigurationDescriptorRequest(); + return obj; + }, + toJSON(_: GetConfigurationDescriptorRequest): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): GetConfigurationDescriptorRequest { + const message = createBaseGetConfigurationDescriptorRequest(); + return message; + }, + fromSDK(_: GetConfigurationDescriptorRequestSDKType): GetConfigurationDescriptorRequest { + return {}; + }, + fromSDKJSON(_: any): GetConfigurationDescriptorRequestSDKType { + return {}; + }, + toSDK(_: GetConfigurationDescriptorRequest): GetConfigurationDescriptorRequestSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: GetConfigurationDescriptorRequestAmino): GetConfigurationDescriptorRequest { + const message = createBaseGetConfigurationDescriptorRequest(); + return message; + }, + toAmino(_: GetConfigurationDescriptorRequest): GetConfigurationDescriptorRequestAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: GetConfigurationDescriptorRequestAminoMsg): GetConfigurationDescriptorRequest { + return GetConfigurationDescriptorRequest.fromAmino(object.value); + }, + toAminoMsg(message: GetConfigurationDescriptorRequest): GetConfigurationDescriptorRequestAminoMsg { + return { + type: "cosmos-sdk/GetConfigurationDescriptorRequest", + value: GetConfigurationDescriptorRequest.toAmino(message) + }; + }, + fromProtoMsg(message: GetConfigurationDescriptorRequestProtoMsg): GetConfigurationDescriptorRequest { + return GetConfigurationDescriptorRequest.decode(message.value); + }, + toProto(message: GetConfigurationDescriptorRequest): Uint8Array { + return GetConfigurationDescriptorRequest.encode(message).finish(); + }, + toProtoMsg(message: GetConfigurationDescriptorRequest): GetConfigurationDescriptorRequestProtoMsg { + return { + typeUrl: "/cosmos.base.reflection.v2alpha1.GetConfigurationDescriptorRequest", + value: GetConfigurationDescriptorRequest.encode(message).finish() + }; + } +}; +function createBaseGetConfigurationDescriptorResponse(): GetConfigurationDescriptorResponse { + return { + config: undefined + }; +} +export const GetConfigurationDescriptorResponse = { + typeUrl: "/cosmos.base.reflection.v2alpha1.GetConfigurationDescriptorResponse", + encode(message: GetConfigurationDescriptorResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.config !== undefined) { + ConfigurationDescriptor.encode(message.config, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GetConfigurationDescriptorResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGetConfigurationDescriptorResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.config = ConfigurationDescriptor.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GetConfigurationDescriptorResponse { + const obj = createBaseGetConfigurationDescriptorResponse(); + if (isSet(object.config)) obj.config = ConfigurationDescriptor.fromJSON(object.config); + return obj; + }, + toJSON(message: GetConfigurationDescriptorResponse): JsonSafe { + const obj: any = {}; + message.config !== undefined && (obj.config = message.config ? ConfigurationDescriptor.toJSON(message.config) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): GetConfigurationDescriptorResponse { + const message = createBaseGetConfigurationDescriptorResponse(); + if (object.config !== undefined && object.config !== null) { + message.config = ConfigurationDescriptor.fromPartial(object.config); + } + return message; + }, + fromSDK(object: GetConfigurationDescriptorResponseSDKType): GetConfigurationDescriptorResponse { + return { + config: object.config ? ConfigurationDescriptor.fromSDK(object.config) : undefined + }; + }, + fromSDKJSON(object: any): GetConfigurationDescriptorResponseSDKType { + return { + config: isSet(object.config) ? ConfigurationDescriptor.fromSDKJSON(object.config) : undefined + }; + }, + toSDK(message: GetConfigurationDescriptorResponse): GetConfigurationDescriptorResponseSDKType { + const obj: any = {}; + message.config !== undefined && (obj.config = message.config ? ConfigurationDescriptor.toSDK(message.config) : undefined); + return obj; + }, + fromAmino(object: GetConfigurationDescriptorResponseAmino): GetConfigurationDescriptorResponse { + const message = createBaseGetConfigurationDescriptorResponse(); + if (object.config !== undefined && object.config !== null) { + message.config = ConfigurationDescriptor.fromAmino(object.config); + } + return message; + }, + toAmino(message: GetConfigurationDescriptorResponse): GetConfigurationDescriptorResponseAmino { + const obj: any = {}; + obj.config = message.config ? ConfigurationDescriptor.toAmino(message.config) : undefined; + return obj; + }, + fromAminoMsg(object: GetConfigurationDescriptorResponseAminoMsg): GetConfigurationDescriptorResponse { + return GetConfigurationDescriptorResponse.fromAmino(object.value); + }, + toAminoMsg(message: GetConfigurationDescriptorResponse): GetConfigurationDescriptorResponseAminoMsg { + return { + type: "cosmos-sdk/GetConfigurationDescriptorResponse", + value: GetConfigurationDescriptorResponse.toAmino(message) + }; + }, + fromProtoMsg(message: GetConfigurationDescriptorResponseProtoMsg): GetConfigurationDescriptorResponse { + return GetConfigurationDescriptorResponse.decode(message.value); + }, + toProto(message: GetConfigurationDescriptorResponse): Uint8Array { + return GetConfigurationDescriptorResponse.encode(message).finish(); + }, + toProtoMsg(message: GetConfigurationDescriptorResponse): GetConfigurationDescriptorResponseProtoMsg { + return { + typeUrl: "/cosmos.base.reflection.v2alpha1.GetConfigurationDescriptorResponse", + value: GetConfigurationDescriptorResponse.encode(message).finish() + }; + } +}; +function createBaseGetQueryServicesDescriptorRequest(): GetQueryServicesDescriptorRequest { + return {}; +} +export const GetQueryServicesDescriptorRequest = { + typeUrl: "/cosmos.base.reflection.v2alpha1.GetQueryServicesDescriptorRequest", + encode(_: GetQueryServicesDescriptorRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GetQueryServicesDescriptorRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGetQueryServicesDescriptorRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): GetQueryServicesDescriptorRequest { + const obj = createBaseGetQueryServicesDescriptorRequest(); + return obj; + }, + toJSON(_: GetQueryServicesDescriptorRequest): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): GetQueryServicesDescriptorRequest { + const message = createBaseGetQueryServicesDescriptorRequest(); + return message; + }, + fromSDK(_: GetQueryServicesDescriptorRequestSDKType): GetQueryServicesDescriptorRequest { + return {}; + }, + fromSDKJSON(_: any): GetQueryServicesDescriptorRequestSDKType { + return {}; + }, + toSDK(_: GetQueryServicesDescriptorRequest): GetQueryServicesDescriptorRequestSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: GetQueryServicesDescriptorRequestAmino): GetQueryServicesDescriptorRequest { + const message = createBaseGetQueryServicesDescriptorRequest(); + return message; + }, + toAmino(_: GetQueryServicesDescriptorRequest): GetQueryServicesDescriptorRequestAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: GetQueryServicesDescriptorRequestAminoMsg): GetQueryServicesDescriptorRequest { + return GetQueryServicesDescriptorRequest.fromAmino(object.value); + }, + toAminoMsg(message: GetQueryServicesDescriptorRequest): GetQueryServicesDescriptorRequestAminoMsg { + return { + type: "cosmos-sdk/GetQueryServicesDescriptorRequest", + value: GetQueryServicesDescriptorRequest.toAmino(message) + }; + }, + fromProtoMsg(message: GetQueryServicesDescriptorRequestProtoMsg): GetQueryServicesDescriptorRequest { + return GetQueryServicesDescriptorRequest.decode(message.value); + }, + toProto(message: GetQueryServicesDescriptorRequest): Uint8Array { + return GetQueryServicesDescriptorRequest.encode(message).finish(); + }, + toProtoMsg(message: GetQueryServicesDescriptorRequest): GetQueryServicesDescriptorRequestProtoMsg { + return { + typeUrl: "/cosmos.base.reflection.v2alpha1.GetQueryServicesDescriptorRequest", + value: GetQueryServicesDescriptorRequest.encode(message).finish() + }; + } +}; +function createBaseGetQueryServicesDescriptorResponse(): GetQueryServicesDescriptorResponse { + return { + queries: undefined + }; +} +export const GetQueryServicesDescriptorResponse = { + typeUrl: "/cosmos.base.reflection.v2alpha1.GetQueryServicesDescriptorResponse", + encode(message: GetQueryServicesDescriptorResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.queries !== undefined) { + QueryServicesDescriptor.encode(message.queries, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GetQueryServicesDescriptorResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGetQueryServicesDescriptorResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.queries = QueryServicesDescriptor.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GetQueryServicesDescriptorResponse { + const obj = createBaseGetQueryServicesDescriptorResponse(); + if (isSet(object.queries)) obj.queries = QueryServicesDescriptor.fromJSON(object.queries); + return obj; + }, + toJSON(message: GetQueryServicesDescriptorResponse): JsonSafe { + const obj: any = {}; + message.queries !== undefined && (obj.queries = message.queries ? QueryServicesDescriptor.toJSON(message.queries) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): GetQueryServicesDescriptorResponse { + const message = createBaseGetQueryServicesDescriptorResponse(); + if (object.queries !== undefined && object.queries !== null) { + message.queries = QueryServicesDescriptor.fromPartial(object.queries); + } + return message; + }, + fromSDK(object: GetQueryServicesDescriptorResponseSDKType): GetQueryServicesDescriptorResponse { + return { + queries: object.queries ? QueryServicesDescriptor.fromSDK(object.queries) : undefined + }; + }, + fromSDKJSON(object: any): GetQueryServicesDescriptorResponseSDKType { + return { + queries: isSet(object.queries) ? QueryServicesDescriptor.fromSDKJSON(object.queries) : undefined + }; + }, + toSDK(message: GetQueryServicesDescriptorResponse): GetQueryServicesDescriptorResponseSDKType { + const obj: any = {}; + message.queries !== undefined && (obj.queries = message.queries ? QueryServicesDescriptor.toSDK(message.queries) : undefined); + return obj; + }, + fromAmino(object: GetQueryServicesDescriptorResponseAmino): GetQueryServicesDescriptorResponse { + const message = createBaseGetQueryServicesDescriptorResponse(); + if (object.queries !== undefined && object.queries !== null) { + message.queries = QueryServicesDescriptor.fromAmino(object.queries); + } + return message; + }, + toAmino(message: GetQueryServicesDescriptorResponse): GetQueryServicesDescriptorResponseAmino { + const obj: any = {}; + obj.queries = message.queries ? QueryServicesDescriptor.toAmino(message.queries) : undefined; + return obj; + }, + fromAminoMsg(object: GetQueryServicesDescriptorResponseAminoMsg): GetQueryServicesDescriptorResponse { + return GetQueryServicesDescriptorResponse.fromAmino(object.value); + }, + toAminoMsg(message: GetQueryServicesDescriptorResponse): GetQueryServicesDescriptorResponseAminoMsg { + return { + type: "cosmos-sdk/GetQueryServicesDescriptorResponse", + value: GetQueryServicesDescriptorResponse.toAmino(message) + }; + }, + fromProtoMsg(message: GetQueryServicesDescriptorResponseProtoMsg): GetQueryServicesDescriptorResponse { + return GetQueryServicesDescriptorResponse.decode(message.value); + }, + toProto(message: GetQueryServicesDescriptorResponse): Uint8Array { + return GetQueryServicesDescriptorResponse.encode(message).finish(); + }, + toProtoMsg(message: GetQueryServicesDescriptorResponse): GetQueryServicesDescriptorResponseProtoMsg { + return { + typeUrl: "/cosmos.base.reflection.v2alpha1.GetQueryServicesDescriptorResponse", + value: GetQueryServicesDescriptorResponse.encode(message).finish() + }; + } +}; +function createBaseGetTxDescriptorRequest(): GetTxDescriptorRequest { + return {}; +} +export const GetTxDescriptorRequest = { + typeUrl: "/cosmos.base.reflection.v2alpha1.GetTxDescriptorRequest", + encode(_: GetTxDescriptorRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GetTxDescriptorRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGetTxDescriptorRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): GetTxDescriptorRequest { + const obj = createBaseGetTxDescriptorRequest(); + return obj; + }, + toJSON(_: GetTxDescriptorRequest): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): GetTxDescriptorRequest { + const message = createBaseGetTxDescriptorRequest(); + return message; + }, + fromSDK(_: GetTxDescriptorRequestSDKType): GetTxDescriptorRequest { + return {}; + }, + fromSDKJSON(_: any): GetTxDescriptorRequestSDKType { + return {}; + }, + toSDK(_: GetTxDescriptorRequest): GetTxDescriptorRequestSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: GetTxDescriptorRequestAmino): GetTxDescriptorRequest { + const message = createBaseGetTxDescriptorRequest(); + return message; + }, + toAmino(_: GetTxDescriptorRequest): GetTxDescriptorRequestAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: GetTxDescriptorRequestAminoMsg): GetTxDescriptorRequest { + return GetTxDescriptorRequest.fromAmino(object.value); + }, + toAminoMsg(message: GetTxDescriptorRequest): GetTxDescriptorRequestAminoMsg { + return { + type: "cosmos-sdk/GetTxDescriptorRequest", + value: GetTxDescriptorRequest.toAmino(message) + }; + }, + fromProtoMsg(message: GetTxDescriptorRequestProtoMsg): GetTxDescriptorRequest { + return GetTxDescriptorRequest.decode(message.value); + }, + toProto(message: GetTxDescriptorRequest): Uint8Array { + return GetTxDescriptorRequest.encode(message).finish(); + }, + toProtoMsg(message: GetTxDescriptorRequest): GetTxDescriptorRequestProtoMsg { + return { + typeUrl: "/cosmos.base.reflection.v2alpha1.GetTxDescriptorRequest", + value: GetTxDescriptorRequest.encode(message).finish() + }; + } +}; +function createBaseGetTxDescriptorResponse(): GetTxDescriptorResponse { + return { + tx: undefined + }; +} +export const GetTxDescriptorResponse = { + typeUrl: "/cosmos.base.reflection.v2alpha1.GetTxDescriptorResponse", + encode(message: GetTxDescriptorResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.tx !== undefined) { + TxDescriptor.encode(message.tx, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GetTxDescriptorResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGetTxDescriptorResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.tx = TxDescriptor.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GetTxDescriptorResponse { + const obj = createBaseGetTxDescriptorResponse(); + if (isSet(object.tx)) obj.tx = TxDescriptor.fromJSON(object.tx); + return obj; + }, + toJSON(message: GetTxDescriptorResponse): JsonSafe { + const obj: any = {}; + message.tx !== undefined && (obj.tx = message.tx ? TxDescriptor.toJSON(message.tx) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): GetTxDescriptorResponse { + const message = createBaseGetTxDescriptorResponse(); + if (object.tx !== undefined && object.tx !== null) { + message.tx = TxDescriptor.fromPartial(object.tx); + } + return message; + }, + fromSDK(object: GetTxDescriptorResponseSDKType): GetTxDescriptorResponse { + return { + tx: object.tx ? TxDescriptor.fromSDK(object.tx) : undefined + }; + }, + fromSDKJSON(object: any): GetTxDescriptorResponseSDKType { + return { + tx: isSet(object.tx) ? TxDescriptor.fromSDKJSON(object.tx) : undefined + }; + }, + toSDK(message: GetTxDescriptorResponse): GetTxDescriptorResponseSDKType { + const obj: any = {}; + message.tx !== undefined && (obj.tx = message.tx ? TxDescriptor.toSDK(message.tx) : undefined); + return obj; + }, + fromAmino(object: GetTxDescriptorResponseAmino): GetTxDescriptorResponse { + const message = createBaseGetTxDescriptorResponse(); + if (object.tx !== undefined && object.tx !== null) { + message.tx = TxDescriptor.fromAmino(object.tx); + } + return message; + }, + toAmino(message: GetTxDescriptorResponse): GetTxDescriptorResponseAmino { + const obj: any = {}; + obj.tx = message.tx ? TxDescriptor.toAmino(message.tx) : undefined; + return obj; + }, + fromAminoMsg(object: GetTxDescriptorResponseAminoMsg): GetTxDescriptorResponse { + return GetTxDescriptorResponse.fromAmino(object.value); + }, + toAminoMsg(message: GetTxDescriptorResponse): GetTxDescriptorResponseAminoMsg { + return { + type: "cosmos-sdk/GetTxDescriptorResponse", + value: GetTxDescriptorResponse.toAmino(message) + }; + }, + fromProtoMsg(message: GetTxDescriptorResponseProtoMsg): GetTxDescriptorResponse { + return GetTxDescriptorResponse.decode(message.value); + }, + toProto(message: GetTxDescriptorResponse): Uint8Array { + return GetTxDescriptorResponse.encode(message).finish(); + }, + toProtoMsg(message: GetTxDescriptorResponse): GetTxDescriptorResponseProtoMsg { + return { + typeUrl: "/cosmos.base.reflection.v2alpha1.GetTxDescriptorResponse", + value: GetTxDescriptorResponse.encode(message).finish() + }; + } +}; +function createBaseQueryServicesDescriptor(): QueryServicesDescriptor { + return { + queryServices: [] + }; +} +export const QueryServicesDescriptor = { + typeUrl: "/cosmos.base.reflection.v2alpha1.QueryServicesDescriptor", + encode(message: QueryServicesDescriptor, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.queryServices) { + QueryServiceDescriptor.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryServicesDescriptor { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryServicesDescriptor(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.queryServices.push(QueryServiceDescriptor.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryServicesDescriptor { + const obj = createBaseQueryServicesDescriptor(); + if (Array.isArray(object?.queryServices)) obj.queryServices = object.queryServices.map((e: any) => QueryServiceDescriptor.fromJSON(e)); + return obj; + }, + toJSON(message: QueryServicesDescriptor): JsonSafe { + const obj: any = {}; + if (message.queryServices) { + obj.queryServices = message.queryServices.map(e => e ? QueryServiceDescriptor.toJSON(e) : undefined); + } else { + obj.queryServices = []; + } + return obj; + }, + fromPartial(object: DeepPartial): QueryServicesDescriptor { + const message = createBaseQueryServicesDescriptor(); + message.queryServices = object.queryServices?.map(e => QueryServiceDescriptor.fromPartial(e)) || []; + return message; + }, + fromSDK(object: QueryServicesDescriptorSDKType): QueryServicesDescriptor { + return { + queryServices: Array.isArray(object?.query_services) ? object.query_services.map((e: any) => QueryServiceDescriptor.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): QueryServicesDescriptorSDKType { + return { + query_services: Array.isArray(object?.query_services) ? object.query_services.map((e: any) => QueryServiceDescriptor.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: QueryServicesDescriptor): QueryServicesDescriptorSDKType { + const obj: any = {}; + if (message.queryServices) { + obj.query_services = message.queryServices.map(e => e ? QueryServiceDescriptor.toSDK(e) : undefined); + } else { + obj.query_services = []; + } + return obj; + }, + fromAmino(object: QueryServicesDescriptorAmino): QueryServicesDescriptor { + const message = createBaseQueryServicesDescriptor(); + message.queryServices = object.query_services?.map(e => QueryServiceDescriptor.fromAmino(e)) || []; + return message; + }, + toAmino(message: QueryServicesDescriptor): QueryServicesDescriptorAmino { + const obj: any = {}; + if (message.queryServices) { + obj.query_services = message.queryServices.map(e => e ? QueryServiceDescriptor.toAmino(e) : undefined); + } else { + obj.query_services = message.queryServices; + } + return obj; + }, + fromAminoMsg(object: QueryServicesDescriptorAminoMsg): QueryServicesDescriptor { + return QueryServicesDescriptor.fromAmino(object.value); + }, + toAminoMsg(message: QueryServicesDescriptor): QueryServicesDescriptorAminoMsg { + return { + type: "cosmos-sdk/QueryServicesDescriptor", + value: QueryServicesDescriptor.toAmino(message) + }; + }, + fromProtoMsg(message: QueryServicesDescriptorProtoMsg): QueryServicesDescriptor { + return QueryServicesDescriptor.decode(message.value); + }, + toProto(message: QueryServicesDescriptor): Uint8Array { + return QueryServicesDescriptor.encode(message).finish(); + }, + toProtoMsg(message: QueryServicesDescriptor): QueryServicesDescriptorProtoMsg { + return { + typeUrl: "/cosmos.base.reflection.v2alpha1.QueryServicesDescriptor", + value: QueryServicesDescriptor.encode(message).finish() + }; + } +}; +function createBaseQueryServiceDescriptor(): QueryServiceDescriptor { + return { + fullname: "", + isModule: false, + methods: [] + }; +} +export const QueryServiceDescriptor = { + typeUrl: "/cosmos.base.reflection.v2alpha1.QueryServiceDescriptor", + encode(message: QueryServiceDescriptor, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.fullname !== undefined) { + writer.uint32(10).string(message.fullname); + } + if (message.isModule !== undefined) { + writer.uint32(16).bool(message.isModule); + } + for (const v of message.methods) { + QueryMethodDescriptor.encode(v!, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryServiceDescriptor { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryServiceDescriptor(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.fullname = reader.string(); + break; + case 2: + message.isModule = reader.bool(); + break; + case 3: + message.methods.push(QueryMethodDescriptor.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryServiceDescriptor { + const obj = createBaseQueryServiceDescriptor(); + if (isSet(object.fullname)) obj.fullname = String(object.fullname); + if (isSet(object.isModule)) obj.isModule = Boolean(object.isModule); + if (Array.isArray(object?.methods)) obj.methods = object.methods.map((e: any) => QueryMethodDescriptor.fromJSON(e)); + return obj; + }, + toJSON(message: QueryServiceDescriptor): JsonSafe { + const obj: any = {}; + message.fullname !== undefined && (obj.fullname = message.fullname); + message.isModule !== undefined && (obj.isModule = message.isModule); + if (message.methods) { + obj.methods = message.methods.map(e => e ? QueryMethodDescriptor.toJSON(e) : undefined); + } else { + obj.methods = []; + } + return obj; + }, + fromPartial(object: DeepPartial): QueryServiceDescriptor { + const message = createBaseQueryServiceDescriptor(); + message.fullname = object.fullname ?? ""; + message.isModule = object.isModule ?? false; + message.methods = object.methods?.map(e => QueryMethodDescriptor.fromPartial(e)) || []; + return message; + }, + fromSDK(object: QueryServiceDescriptorSDKType): QueryServiceDescriptor { + return { + fullname: object?.fullname, + isModule: object?.is_module, + methods: Array.isArray(object?.methods) ? object.methods.map((e: any) => QueryMethodDescriptor.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): QueryServiceDescriptorSDKType { + return { + fullname: isSet(object.fullname) ? String(object.fullname) : "", + is_module: isSet(object.is_module) ? Boolean(object.is_module) : false, + methods: Array.isArray(object?.methods) ? object.methods.map((e: any) => QueryMethodDescriptor.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: QueryServiceDescriptor): QueryServiceDescriptorSDKType { + const obj: any = {}; + obj.fullname = message.fullname; + obj.is_module = message.isModule; + if (message.methods) { + obj.methods = message.methods.map(e => e ? QueryMethodDescriptor.toSDK(e) : undefined); + } else { + obj.methods = []; + } + return obj; + }, + fromAmino(object: QueryServiceDescriptorAmino): QueryServiceDescriptor { + const message = createBaseQueryServiceDescriptor(); + if (object.fullname !== undefined && object.fullname !== null) { + message.fullname = object.fullname; + } + if (object.is_module !== undefined && object.is_module !== null) { + message.isModule = object.is_module; + } + message.methods = object.methods?.map(e => QueryMethodDescriptor.fromAmino(e)) || []; + return message; + }, + toAmino(message: QueryServiceDescriptor): QueryServiceDescriptorAmino { + const obj: any = {}; + obj.fullname = message.fullname === "" ? undefined : message.fullname; + obj.is_module = message.isModule === false ? undefined : message.isModule; + if (message.methods) { + obj.methods = message.methods.map(e => e ? QueryMethodDescriptor.toAmino(e) : undefined); + } else { + obj.methods = message.methods; + } + return obj; + }, + fromAminoMsg(object: QueryServiceDescriptorAminoMsg): QueryServiceDescriptor { + return QueryServiceDescriptor.fromAmino(object.value); + }, + toAminoMsg(message: QueryServiceDescriptor): QueryServiceDescriptorAminoMsg { + return { + type: "cosmos-sdk/QueryServiceDescriptor", + value: QueryServiceDescriptor.toAmino(message) + }; + }, + fromProtoMsg(message: QueryServiceDescriptorProtoMsg): QueryServiceDescriptor { + return QueryServiceDescriptor.decode(message.value); + }, + toProto(message: QueryServiceDescriptor): Uint8Array { + return QueryServiceDescriptor.encode(message).finish(); + }, + toProtoMsg(message: QueryServiceDescriptor): QueryServiceDescriptorProtoMsg { + return { + typeUrl: "/cosmos.base.reflection.v2alpha1.QueryServiceDescriptor", + value: QueryServiceDescriptor.encode(message).finish() + }; + } +}; +function createBaseQueryMethodDescriptor(): QueryMethodDescriptor { + return { + name: "", + fullQueryPath: "" + }; +} +export const QueryMethodDescriptor = { + typeUrl: "/cosmos.base.reflection.v2alpha1.QueryMethodDescriptor", + encode(message: QueryMethodDescriptor, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + if (message.fullQueryPath !== undefined) { + writer.uint32(18).string(message.fullQueryPath); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryMethodDescriptor { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryMethodDescriptor(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.fullQueryPath = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryMethodDescriptor { + const obj = createBaseQueryMethodDescriptor(); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.fullQueryPath)) obj.fullQueryPath = String(object.fullQueryPath); + return obj; + }, + toJSON(message: QueryMethodDescriptor): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.fullQueryPath !== undefined && (obj.fullQueryPath = message.fullQueryPath); + return obj; + }, + fromPartial(object: DeepPartial): QueryMethodDescriptor { + const message = createBaseQueryMethodDescriptor(); + message.name = object.name ?? ""; + message.fullQueryPath = object.fullQueryPath ?? ""; + return message; + }, + fromSDK(object: QueryMethodDescriptorSDKType): QueryMethodDescriptor { + return { + name: object?.name, + fullQueryPath: object?.full_query_path + }; + }, + fromSDKJSON(object: any): QueryMethodDescriptorSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + full_query_path: isSet(object.full_query_path) ? String(object.full_query_path) : "" + }; + }, + toSDK(message: QueryMethodDescriptor): QueryMethodDescriptorSDKType { + const obj: any = {}; + obj.name = message.name; + obj.full_query_path = message.fullQueryPath; + return obj; + }, + fromAmino(object: QueryMethodDescriptorAmino): QueryMethodDescriptor { + const message = createBaseQueryMethodDescriptor(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + if (object.full_query_path !== undefined && object.full_query_path !== null) { + message.fullQueryPath = object.full_query_path; + } + return message; + }, + toAmino(message: QueryMethodDescriptor): QueryMethodDescriptorAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + obj.full_query_path = message.fullQueryPath === "" ? undefined : message.fullQueryPath; + return obj; + }, + fromAminoMsg(object: QueryMethodDescriptorAminoMsg): QueryMethodDescriptor { + return QueryMethodDescriptor.fromAmino(object.value); + }, + toAminoMsg(message: QueryMethodDescriptor): QueryMethodDescriptorAminoMsg { + return { + type: "cosmos-sdk/QueryMethodDescriptor", + value: QueryMethodDescriptor.toAmino(message) + }; + }, + fromProtoMsg(message: QueryMethodDescriptorProtoMsg): QueryMethodDescriptor { + return QueryMethodDescriptor.decode(message.value); + }, + toProto(message: QueryMethodDescriptor): Uint8Array { + return QueryMethodDescriptor.encode(message).finish(); + }, + toProtoMsg(message: QueryMethodDescriptor): QueryMethodDescriptorProtoMsg { + return { + typeUrl: "/cosmos.base.reflection.v2alpha1.QueryMethodDescriptor", + value: QueryMethodDescriptor.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/base/snapshots/v1beta1/snapshot.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/base/snapshots/v1beta1/snapshot.ts new file mode 100644 index 0000000000..3cfc54bea2 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/base/snapshots/v1beta1/snapshot.ts @@ -0,0 +1,1265 @@ +import { BinaryReader, BinaryWriter } from "../../../../binary.js"; +import { isSet, bytesFromBase64, base64FromBytes, DeepPartial } from "../../../../helpers.js"; +import { JsonSafe } from "../../../../json-safe.js"; +export const protobufPackage = "cosmos.base.snapshots.v1beta1"; +/** Snapshot contains Tendermint state sync snapshot info. */ +export interface Snapshot { + height: bigint; + format: number; + chunks: number; + hash: Uint8Array; + metadata: Metadata; +} +export interface SnapshotProtoMsg { + typeUrl: "/cosmos.base.snapshots.v1beta1.Snapshot"; + value: Uint8Array; +} +/** Snapshot contains Tendermint state sync snapshot info. */ +export interface SnapshotSDKType { + height: bigint; + format: number; + chunks: number; + hash: Uint8Array; + metadata: MetadataSDKType; +} +/** Metadata contains SDK-specific snapshot metadata. */ +export interface Metadata { + /** SHA-256 chunk hashes */ + chunkHashes: Uint8Array[]; +} +export interface MetadataProtoMsg { + typeUrl: "/cosmos.base.snapshots.v1beta1.Metadata"; + value: Uint8Array; +} +/** Metadata contains SDK-specific snapshot metadata. */ +export interface MetadataSDKType { + chunk_hashes: Uint8Array[]; +} +/** SnapshotItem is an item contained in a rootmulti.Store snapshot. */ +export interface SnapshotItem { + store?: SnapshotStoreItem; + iavl?: SnapshotIAVLItem; + extension?: SnapshotExtensionMeta; + extensionPayload?: SnapshotExtensionPayload; + kv?: SnapshotKVItem; + schema?: SnapshotSchema; +} +export interface SnapshotItemProtoMsg { + typeUrl: "/cosmos.base.snapshots.v1beta1.SnapshotItem"; + value: Uint8Array; +} +/** SnapshotItem is an item contained in a rootmulti.Store snapshot. */ +export interface SnapshotItemSDKType { + store?: SnapshotStoreItemSDKType; + iavl?: SnapshotIAVLItemSDKType; + extension?: SnapshotExtensionMetaSDKType; + extension_payload?: SnapshotExtensionPayloadSDKType; + kv?: SnapshotKVItemSDKType; + schema?: SnapshotSchemaSDKType; +} +/** SnapshotStoreItem contains metadata about a snapshotted store. */ +export interface SnapshotStoreItem { + name: string; +} +export interface SnapshotStoreItemProtoMsg { + typeUrl: "/cosmos.base.snapshots.v1beta1.SnapshotStoreItem"; + value: Uint8Array; +} +/** SnapshotStoreItem contains metadata about a snapshotted store. */ +export interface SnapshotStoreItemSDKType { + name: string; +} +/** SnapshotIAVLItem is an exported IAVL node. */ +export interface SnapshotIAVLItem { + key: Uint8Array; + value: Uint8Array; + /** version is block height */ + version: bigint; + /** height is depth of the tree. */ + height: number; +} +export interface SnapshotIAVLItemProtoMsg { + typeUrl: "/cosmos.base.snapshots.v1beta1.SnapshotIAVLItem"; + value: Uint8Array; +} +/** SnapshotIAVLItem is an exported IAVL node. */ +export interface SnapshotIAVLItemSDKType { + key: Uint8Array; + value: Uint8Array; + version: bigint; + height: number; +} +/** SnapshotExtensionMeta contains metadata about an external snapshotter. */ +export interface SnapshotExtensionMeta { + name: string; + format: number; +} +export interface SnapshotExtensionMetaProtoMsg { + typeUrl: "/cosmos.base.snapshots.v1beta1.SnapshotExtensionMeta"; + value: Uint8Array; +} +/** SnapshotExtensionMeta contains metadata about an external snapshotter. */ +export interface SnapshotExtensionMetaSDKType { + name: string; + format: number; +} +/** SnapshotExtensionPayload contains payloads of an external snapshotter. */ +export interface SnapshotExtensionPayload { + payload: Uint8Array; +} +export interface SnapshotExtensionPayloadProtoMsg { + typeUrl: "/cosmos.base.snapshots.v1beta1.SnapshotExtensionPayload"; + value: Uint8Array; +} +/** SnapshotExtensionPayload contains payloads of an external snapshotter. */ +export interface SnapshotExtensionPayloadSDKType { + payload: Uint8Array; +} +/** SnapshotKVItem is an exported Key/Value Pair */ +export interface SnapshotKVItem { + key: Uint8Array; + value: Uint8Array; +} +export interface SnapshotKVItemProtoMsg { + typeUrl: "/cosmos.base.snapshots.v1beta1.SnapshotKVItem"; + value: Uint8Array; +} +/** SnapshotKVItem is an exported Key/Value Pair */ +export interface SnapshotKVItemSDKType { + key: Uint8Array; + value: Uint8Array; +} +/** SnapshotSchema is an exported schema of smt store */ +export interface SnapshotSchema { + keys: Uint8Array[]; +} +export interface SnapshotSchemaProtoMsg { + typeUrl: "/cosmos.base.snapshots.v1beta1.SnapshotSchema"; + value: Uint8Array; +} +/** SnapshotSchema is an exported schema of smt store */ +export interface SnapshotSchemaSDKType { + keys: Uint8Array[]; +} +function createBaseSnapshot(): Snapshot { + return { + height: BigInt(0), + format: 0, + chunks: 0, + hash: new Uint8Array(), + metadata: Metadata.fromPartial({}) + }; +} +export const Snapshot = { + typeUrl: "/cosmos.base.snapshots.v1beta1.Snapshot", + encode(message: Snapshot, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.height !== undefined) { + writer.uint32(8).uint64(message.height); + } + if (message.format !== undefined) { + writer.uint32(16).uint32(message.format); + } + if (message.chunks !== undefined) { + writer.uint32(24).uint32(message.chunks); + } + if (message.hash.length !== 0) { + writer.uint32(34).bytes(message.hash); + } + if (message.metadata !== undefined) { + Metadata.encode(message.metadata, writer.uint32(42).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Snapshot { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseSnapshot(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.height = reader.uint64(); + break; + case 2: + message.format = reader.uint32(); + break; + case 3: + message.chunks = reader.uint32(); + break; + case 4: + message.hash = reader.bytes(); + break; + case 5: + message.metadata = Metadata.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Snapshot { + const obj = createBaseSnapshot(); + if (isSet(object.height)) obj.height = BigInt(object.height.toString()); + if (isSet(object.format)) obj.format = Number(object.format); + if (isSet(object.chunks)) obj.chunks = Number(object.chunks); + if (isSet(object.hash)) obj.hash = bytesFromBase64(object.hash); + if (isSet(object.metadata)) obj.metadata = Metadata.fromJSON(object.metadata); + return obj; + }, + toJSON(message: Snapshot): JsonSafe { + const obj: any = {}; + message.height !== undefined && (obj.height = (message.height || BigInt(0)).toString()); + message.format !== undefined && (obj.format = Math.round(message.format)); + message.chunks !== undefined && (obj.chunks = Math.round(message.chunks)); + message.hash !== undefined && (obj.hash = base64FromBytes(message.hash !== undefined ? message.hash : new Uint8Array())); + message.metadata !== undefined && (obj.metadata = message.metadata ? Metadata.toJSON(message.metadata) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): Snapshot { + const message = createBaseSnapshot(); + if (object.height !== undefined && object.height !== null) { + message.height = BigInt(object.height.toString()); + } + message.format = object.format ?? 0; + message.chunks = object.chunks ?? 0; + message.hash = object.hash ?? new Uint8Array(); + if (object.metadata !== undefined && object.metadata !== null) { + message.metadata = Metadata.fromPartial(object.metadata); + } + return message; + }, + fromSDK(object: SnapshotSDKType): Snapshot { + return { + height: object?.height, + format: object?.format, + chunks: object?.chunks, + hash: object?.hash, + metadata: object.metadata ? Metadata.fromSDK(object.metadata) : undefined + }; + }, + fromSDKJSON(object: any): SnapshotSDKType { + return { + height: isSet(object.height) ? BigInt(object.height.toString()) : BigInt(0), + format: isSet(object.format) ? Number(object.format) : 0, + chunks: isSet(object.chunks) ? Number(object.chunks) : 0, + hash: isSet(object.hash) ? bytesFromBase64(object.hash) : new Uint8Array(), + metadata: isSet(object.metadata) ? Metadata.fromSDKJSON(object.metadata) : undefined + }; + }, + toSDK(message: Snapshot): SnapshotSDKType { + const obj: any = {}; + obj.height = message.height; + obj.format = message.format; + obj.chunks = message.chunks; + obj.hash = message.hash; + message.metadata !== undefined && (obj.metadata = message.metadata ? Metadata.toSDK(message.metadata) : undefined); + return obj; + }, + fromAmino(object: SnapshotAmino): Snapshot { + const message = createBaseSnapshot(); + if (object.height !== undefined && object.height !== null) { + message.height = BigInt(object.height); + } + if (object.format !== undefined && object.format !== null) { + message.format = object.format; + } + if (object.chunks !== undefined && object.chunks !== null) { + message.chunks = object.chunks; + } + if (object.hash !== undefined && object.hash !== null) { + message.hash = bytesFromBase64(object.hash); + } + if (object.metadata !== undefined && object.metadata !== null) { + message.metadata = Metadata.fromAmino(object.metadata); + } + return message; + }, + toAmino(message: Snapshot): SnapshotAmino { + const obj: any = {}; + obj.height = message.height !== BigInt(0) ? message.height?.toString() : undefined; + obj.format = message.format === 0 ? undefined : message.format; + obj.chunks = message.chunks === 0 ? undefined : message.chunks; + obj.hash = message.hash ? base64FromBytes(message.hash) : undefined; + obj.metadata = message.metadata ? Metadata.toAmino(message.metadata) : undefined; + return obj; + }, + fromAminoMsg(object: SnapshotAminoMsg): Snapshot { + return Snapshot.fromAmino(object.value); + }, + toAminoMsg(message: Snapshot): SnapshotAminoMsg { + return { + type: "cosmos-sdk/Snapshot", + value: Snapshot.toAmino(message) + }; + }, + fromProtoMsg(message: SnapshotProtoMsg): Snapshot { + return Snapshot.decode(message.value); + }, + toProto(message: Snapshot): Uint8Array { + return Snapshot.encode(message).finish(); + }, + toProtoMsg(message: Snapshot): SnapshotProtoMsg { + return { + typeUrl: "/cosmos.base.snapshots.v1beta1.Snapshot", + value: Snapshot.encode(message).finish() + }; + } +}; +function createBaseMetadata(): Metadata { + return { + chunkHashes: [] + }; +} +export const Metadata = { + typeUrl: "/cosmos.base.snapshots.v1beta1.Metadata", + encode(message: Metadata, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.chunkHashes) { + writer.uint32(10).bytes(v!); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Metadata { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMetadata(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.chunkHashes.push(reader.bytes()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Metadata { + const obj = createBaseMetadata(); + if (Array.isArray(object?.chunkHashes)) obj.chunkHashes = object.chunkHashes.map((e: any) => bytesFromBase64(e)); + return obj; + }, + toJSON(message: Metadata): JsonSafe { + const obj: any = {}; + if (message.chunkHashes) { + obj.chunkHashes = message.chunkHashes.map(e => base64FromBytes(e !== undefined ? e : new Uint8Array())); + } else { + obj.chunkHashes = []; + } + return obj; + }, + fromPartial(object: DeepPartial): Metadata { + const message = createBaseMetadata(); + message.chunkHashes = object.chunkHashes?.map(e => e) || []; + return message; + }, + fromSDK(object: MetadataSDKType): Metadata { + return { + chunkHashes: Array.isArray(object?.chunk_hashes) ? object.chunk_hashes.map((e: any) => e) : [] + }; + }, + fromSDKJSON(object: any): MetadataSDKType { + return { + chunk_hashes: Array.isArray(object?.chunk_hashes) ? object.chunk_hashes.map((e: any) => bytesFromBase64(e)) : [] + }; + }, + toSDK(message: Metadata): MetadataSDKType { + const obj: any = {}; + if (message.chunkHashes) { + obj.chunk_hashes = message.chunkHashes.map(e => e); + } else { + obj.chunk_hashes = []; + } + return obj; + }, + fromAmino(object: MetadataAmino): Metadata { + const message = createBaseMetadata(); + message.chunkHashes = object.chunk_hashes?.map(e => bytesFromBase64(e)) || []; + return message; + }, + toAmino(message: Metadata): MetadataAmino { + const obj: any = {}; + if (message.chunkHashes) { + obj.chunk_hashes = message.chunkHashes.map(e => base64FromBytes(e)); + } else { + obj.chunk_hashes = message.chunkHashes; + } + return obj; + }, + fromAminoMsg(object: MetadataAminoMsg): Metadata { + return Metadata.fromAmino(object.value); + }, + toAminoMsg(message: Metadata): MetadataAminoMsg { + return { + type: "cosmos-sdk/Metadata", + value: Metadata.toAmino(message) + }; + }, + fromProtoMsg(message: MetadataProtoMsg): Metadata { + return Metadata.decode(message.value); + }, + toProto(message: Metadata): Uint8Array { + return Metadata.encode(message).finish(); + }, + toProtoMsg(message: Metadata): MetadataProtoMsg { + return { + typeUrl: "/cosmos.base.snapshots.v1beta1.Metadata", + value: Metadata.encode(message).finish() + }; + } +}; +function createBaseSnapshotItem(): SnapshotItem { + return { + store: undefined, + iavl: undefined, + extension: undefined, + extensionPayload: undefined, + kv: undefined, + schema: undefined + }; +} +export const SnapshotItem = { + typeUrl: "/cosmos.base.snapshots.v1beta1.SnapshotItem", + encode(message: SnapshotItem, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.store !== undefined) { + SnapshotStoreItem.encode(message.store, writer.uint32(10).fork()).ldelim(); + } + if (message.iavl !== undefined) { + SnapshotIAVLItem.encode(message.iavl, writer.uint32(18).fork()).ldelim(); + } + if (message.extension !== undefined) { + SnapshotExtensionMeta.encode(message.extension, writer.uint32(26).fork()).ldelim(); + } + if (message.extensionPayload !== undefined) { + SnapshotExtensionPayload.encode(message.extensionPayload, writer.uint32(34).fork()).ldelim(); + } + if (message.kv !== undefined) { + SnapshotKVItem.encode(message.kv, writer.uint32(42).fork()).ldelim(); + } + if (message.schema !== undefined) { + SnapshotSchema.encode(message.schema, writer.uint32(50).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): SnapshotItem { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseSnapshotItem(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.store = SnapshotStoreItem.decode(reader, reader.uint32()); + break; + case 2: + message.iavl = SnapshotIAVLItem.decode(reader, reader.uint32()); + break; + case 3: + message.extension = SnapshotExtensionMeta.decode(reader, reader.uint32()); + break; + case 4: + message.extensionPayload = SnapshotExtensionPayload.decode(reader, reader.uint32()); + break; + case 5: + message.kv = SnapshotKVItem.decode(reader, reader.uint32()); + break; + case 6: + message.schema = SnapshotSchema.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): SnapshotItem { + const obj = createBaseSnapshotItem(); + if (isSet(object.store)) obj.store = SnapshotStoreItem.fromJSON(object.store); + if (isSet(object.iavl)) obj.iavl = SnapshotIAVLItem.fromJSON(object.iavl); + if (isSet(object.extension)) obj.extension = SnapshotExtensionMeta.fromJSON(object.extension); + if (isSet(object.extensionPayload)) obj.extensionPayload = SnapshotExtensionPayload.fromJSON(object.extensionPayload); + if (isSet(object.kv)) obj.kv = SnapshotKVItem.fromJSON(object.kv); + if (isSet(object.schema)) obj.schema = SnapshotSchema.fromJSON(object.schema); + return obj; + }, + toJSON(message: SnapshotItem): JsonSafe { + const obj: any = {}; + message.store !== undefined && (obj.store = message.store ? SnapshotStoreItem.toJSON(message.store) : undefined); + message.iavl !== undefined && (obj.iavl = message.iavl ? SnapshotIAVLItem.toJSON(message.iavl) : undefined); + message.extension !== undefined && (obj.extension = message.extension ? SnapshotExtensionMeta.toJSON(message.extension) : undefined); + message.extensionPayload !== undefined && (obj.extensionPayload = message.extensionPayload ? SnapshotExtensionPayload.toJSON(message.extensionPayload) : undefined); + message.kv !== undefined && (obj.kv = message.kv ? SnapshotKVItem.toJSON(message.kv) : undefined); + message.schema !== undefined && (obj.schema = message.schema ? SnapshotSchema.toJSON(message.schema) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): SnapshotItem { + const message = createBaseSnapshotItem(); + if (object.store !== undefined && object.store !== null) { + message.store = SnapshotStoreItem.fromPartial(object.store); + } + if (object.iavl !== undefined && object.iavl !== null) { + message.iavl = SnapshotIAVLItem.fromPartial(object.iavl); + } + if (object.extension !== undefined && object.extension !== null) { + message.extension = SnapshotExtensionMeta.fromPartial(object.extension); + } + if (object.extensionPayload !== undefined && object.extensionPayload !== null) { + message.extensionPayload = SnapshotExtensionPayload.fromPartial(object.extensionPayload); + } + if (object.kv !== undefined && object.kv !== null) { + message.kv = SnapshotKVItem.fromPartial(object.kv); + } + if (object.schema !== undefined && object.schema !== null) { + message.schema = SnapshotSchema.fromPartial(object.schema); + } + return message; + }, + fromSDK(object: SnapshotItemSDKType): SnapshotItem { + return { + store: object.store ? SnapshotStoreItem.fromSDK(object.store) : undefined, + iavl: object.iavl ? SnapshotIAVLItem.fromSDK(object.iavl) : undefined, + extension: object.extension ? SnapshotExtensionMeta.fromSDK(object.extension) : undefined, + extensionPayload: object.extension_payload ? SnapshotExtensionPayload.fromSDK(object.extension_payload) : undefined, + kv: object.kv ? SnapshotKVItem.fromSDK(object.kv) : undefined, + schema: object.schema ? SnapshotSchema.fromSDK(object.schema) : undefined + }; + }, + fromSDKJSON(object: any): SnapshotItemSDKType { + return { + store: isSet(object.store) ? SnapshotStoreItem.fromSDKJSON(object.store) : undefined, + iavl: isSet(object.iavl) ? SnapshotIAVLItem.fromSDKJSON(object.iavl) : undefined, + extension: isSet(object.extension) ? SnapshotExtensionMeta.fromSDKJSON(object.extension) : undefined, + extension_payload: isSet(object.extension_payload) ? SnapshotExtensionPayload.fromSDKJSON(object.extension_payload) : undefined, + kv: isSet(object.kv) ? SnapshotKVItem.fromSDKJSON(object.kv) : undefined, + schema: isSet(object.schema) ? SnapshotSchema.fromSDKJSON(object.schema) : undefined + }; + }, + toSDK(message: SnapshotItem): SnapshotItemSDKType { + const obj: any = {}; + message.store !== undefined && (obj.store = message.store ? SnapshotStoreItem.toSDK(message.store) : undefined); + message.iavl !== undefined && (obj.iavl = message.iavl ? SnapshotIAVLItem.toSDK(message.iavl) : undefined); + message.extension !== undefined && (obj.extension = message.extension ? SnapshotExtensionMeta.toSDK(message.extension) : undefined); + message.extensionPayload !== undefined && (obj.extension_payload = message.extensionPayload ? SnapshotExtensionPayload.toSDK(message.extensionPayload) : undefined); + message.kv !== undefined && (obj.kv = message.kv ? SnapshotKVItem.toSDK(message.kv) : undefined); + message.schema !== undefined && (obj.schema = message.schema ? SnapshotSchema.toSDK(message.schema) : undefined); + return obj; + }, + fromAmino(object: SnapshotItemAmino): SnapshotItem { + const message = createBaseSnapshotItem(); + if (object.store !== undefined && object.store !== null) { + message.store = SnapshotStoreItem.fromAmino(object.store); + } + if (object.iavl !== undefined && object.iavl !== null) { + message.iavl = SnapshotIAVLItem.fromAmino(object.iavl); + } + if (object.extension !== undefined && object.extension !== null) { + message.extension = SnapshotExtensionMeta.fromAmino(object.extension); + } + if (object.extension_payload !== undefined && object.extension_payload !== null) { + message.extensionPayload = SnapshotExtensionPayload.fromAmino(object.extension_payload); + } + if (object.kv !== undefined && object.kv !== null) { + message.kv = SnapshotKVItem.fromAmino(object.kv); + } + if (object.schema !== undefined && object.schema !== null) { + message.schema = SnapshotSchema.fromAmino(object.schema); + } + return message; + }, + toAmino(message: SnapshotItem): SnapshotItemAmino { + const obj: any = {}; + obj.store = message.store ? SnapshotStoreItem.toAmino(message.store) : undefined; + obj.iavl = message.iavl ? SnapshotIAVLItem.toAmino(message.iavl) : undefined; + obj.extension = message.extension ? SnapshotExtensionMeta.toAmino(message.extension) : undefined; + obj.extension_payload = message.extensionPayload ? SnapshotExtensionPayload.toAmino(message.extensionPayload) : undefined; + obj.kv = message.kv ? SnapshotKVItem.toAmino(message.kv) : undefined; + obj.schema = message.schema ? SnapshotSchema.toAmino(message.schema) : undefined; + return obj; + }, + fromAminoMsg(object: SnapshotItemAminoMsg): SnapshotItem { + return SnapshotItem.fromAmino(object.value); + }, + toAminoMsg(message: SnapshotItem): SnapshotItemAminoMsg { + return { + type: "cosmos-sdk/SnapshotItem", + value: SnapshotItem.toAmino(message) + }; + }, + fromProtoMsg(message: SnapshotItemProtoMsg): SnapshotItem { + return SnapshotItem.decode(message.value); + }, + toProto(message: SnapshotItem): Uint8Array { + return SnapshotItem.encode(message).finish(); + }, + toProtoMsg(message: SnapshotItem): SnapshotItemProtoMsg { + return { + typeUrl: "/cosmos.base.snapshots.v1beta1.SnapshotItem", + value: SnapshotItem.encode(message).finish() + }; + } +}; +function createBaseSnapshotStoreItem(): SnapshotStoreItem { + return { + name: "" + }; +} +export const SnapshotStoreItem = { + typeUrl: "/cosmos.base.snapshots.v1beta1.SnapshotStoreItem", + encode(message: SnapshotStoreItem, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): SnapshotStoreItem { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseSnapshotStoreItem(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): SnapshotStoreItem { + const obj = createBaseSnapshotStoreItem(); + if (isSet(object.name)) obj.name = String(object.name); + return obj; + }, + toJSON(message: SnapshotStoreItem): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + return obj; + }, + fromPartial(object: DeepPartial): SnapshotStoreItem { + const message = createBaseSnapshotStoreItem(); + message.name = object.name ?? ""; + return message; + }, + fromSDK(object: SnapshotStoreItemSDKType): SnapshotStoreItem { + return { + name: object?.name + }; + }, + fromSDKJSON(object: any): SnapshotStoreItemSDKType { + return { + name: isSet(object.name) ? String(object.name) : "" + }; + }, + toSDK(message: SnapshotStoreItem): SnapshotStoreItemSDKType { + const obj: any = {}; + obj.name = message.name; + return obj; + }, + fromAmino(object: SnapshotStoreItemAmino): SnapshotStoreItem { + const message = createBaseSnapshotStoreItem(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + return message; + }, + toAmino(message: SnapshotStoreItem): SnapshotStoreItemAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + return obj; + }, + fromAminoMsg(object: SnapshotStoreItemAminoMsg): SnapshotStoreItem { + return SnapshotStoreItem.fromAmino(object.value); + }, + toAminoMsg(message: SnapshotStoreItem): SnapshotStoreItemAminoMsg { + return { + type: "cosmos-sdk/SnapshotStoreItem", + value: SnapshotStoreItem.toAmino(message) + }; + }, + fromProtoMsg(message: SnapshotStoreItemProtoMsg): SnapshotStoreItem { + return SnapshotStoreItem.decode(message.value); + }, + toProto(message: SnapshotStoreItem): Uint8Array { + return SnapshotStoreItem.encode(message).finish(); + }, + toProtoMsg(message: SnapshotStoreItem): SnapshotStoreItemProtoMsg { + return { + typeUrl: "/cosmos.base.snapshots.v1beta1.SnapshotStoreItem", + value: SnapshotStoreItem.encode(message).finish() + }; + } +}; +function createBaseSnapshotIAVLItem(): SnapshotIAVLItem { + return { + key: new Uint8Array(), + value: new Uint8Array(), + version: BigInt(0), + height: 0 + }; +} +export const SnapshotIAVLItem = { + typeUrl: "/cosmos.base.snapshots.v1beta1.SnapshotIAVLItem", + encode(message: SnapshotIAVLItem, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.key.length !== 0) { + writer.uint32(10).bytes(message.key); + } + if (message.value.length !== 0) { + writer.uint32(18).bytes(message.value); + } + if (message.version !== undefined) { + writer.uint32(24).int64(message.version); + } + if (message.height !== undefined) { + writer.uint32(32).int32(message.height); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): SnapshotIAVLItem { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseSnapshotIAVLItem(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.bytes(); + break; + case 2: + message.value = reader.bytes(); + break; + case 3: + message.version = reader.int64(); + break; + case 4: + message.height = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): SnapshotIAVLItem { + const obj = createBaseSnapshotIAVLItem(); + if (isSet(object.key)) obj.key = bytesFromBase64(object.key); + if (isSet(object.value)) obj.value = bytesFromBase64(object.value); + if (isSet(object.version)) obj.version = BigInt(object.version.toString()); + if (isSet(object.height)) obj.height = Number(object.height); + return obj; + }, + toJSON(message: SnapshotIAVLItem): JsonSafe { + const obj: any = {}; + message.key !== undefined && (obj.key = base64FromBytes(message.key !== undefined ? message.key : new Uint8Array())); + message.value !== undefined && (obj.value = base64FromBytes(message.value !== undefined ? message.value : new Uint8Array())); + message.version !== undefined && (obj.version = (message.version || BigInt(0)).toString()); + message.height !== undefined && (obj.height = Math.round(message.height)); + return obj; + }, + fromPartial(object: DeepPartial): SnapshotIAVLItem { + const message = createBaseSnapshotIAVLItem(); + message.key = object.key ?? new Uint8Array(); + message.value = object.value ?? new Uint8Array(); + if (object.version !== undefined && object.version !== null) { + message.version = BigInt(object.version.toString()); + } + message.height = object.height ?? 0; + return message; + }, + fromSDK(object: SnapshotIAVLItemSDKType): SnapshotIAVLItem { + return { + key: object?.key, + value: object?.value, + version: object?.version, + height: object?.height + }; + }, + fromSDKJSON(object: any): SnapshotIAVLItemSDKType { + return { + key: isSet(object.key) ? bytesFromBase64(object.key) : new Uint8Array(), + value: isSet(object.value) ? bytesFromBase64(object.value) : new Uint8Array(), + version: isSet(object.version) ? BigInt(object.version.toString()) : BigInt(0), + height: isSet(object.height) ? Number(object.height) : 0 + }; + }, + toSDK(message: SnapshotIAVLItem): SnapshotIAVLItemSDKType { + const obj: any = {}; + obj.key = message.key; + obj.value = message.value; + obj.version = message.version; + obj.height = message.height; + return obj; + }, + fromAmino(object: SnapshotIAVLItemAmino): SnapshotIAVLItem { + const message = createBaseSnapshotIAVLItem(); + if (object.key !== undefined && object.key !== null) { + message.key = bytesFromBase64(object.key); + } + if (object.value !== undefined && object.value !== null) { + message.value = bytesFromBase64(object.value); + } + if (object.version !== undefined && object.version !== null) { + message.version = BigInt(object.version); + } + if (object.height !== undefined && object.height !== null) { + message.height = object.height; + } + return message; + }, + toAmino(message: SnapshotIAVLItem): SnapshotIAVLItemAmino { + const obj: any = {}; + obj.key = message.key ? base64FromBytes(message.key) : undefined; + obj.value = message.value ? base64FromBytes(message.value) : undefined; + obj.version = message.version !== BigInt(0) ? message.version?.toString() : undefined; + obj.height = message.height === 0 ? undefined : message.height; + return obj; + }, + fromAminoMsg(object: SnapshotIAVLItemAminoMsg): SnapshotIAVLItem { + return SnapshotIAVLItem.fromAmino(object.value); + }, + toAminoMsg(message: SnapshotIAVLItem): SnapshotIAVLItemAminoMsg { + return { + type: "cosmos-sdk/SnapshotIAVLItem", + value: SnapshotIAVLItem.toAmino(message) + }; + }, + fromProtoMsg(message: SnapshotIAVLItemProtoMsg): SnapshotIAVLItem { + return SnapshotIAVLItem.decode(message.value); + }, + toProto(message: SnapshotIAVLItem): Uint8Array { + return SnapshotIAVLItem.encode(message).finish(); + }, + toProtoMsg(message: SnapshotIAVLItem): SnapshotIAVLItemProtoMsg { + return { + typeUrl: "/cosmos.base.snapshots.v1beta1.SnapshotIAVLItem", + value: SnapshotIAVLItem.encode(message).finish() + }; + } +}; +function createBaseSnapshotExtensionMeta(): SnapshotExtensionMeta { + return { + name: "", + format: 0 + }; +} +export const SnapshotExtensionMeta = { + typeUrl: "/cosmos.base.snapshots.v1beta1.SnapshotExtensionMeta", + encode(message: SnapshotExtensionMeta, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + if (message.format !== undefined) { + writer.uint32(16).uint32(message.format); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): SnapshotExtensionMeta { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseSnapshotExtensionMeta(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.format = reader.uint32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): SnapshotExtensionMeta { + const obj = createBaseSnapshotExtensionMeta(); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.format)) obj.format = Number(object.format); + return obj; + }, + toJSON(message: SnapshotExtensionMeta): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.format !== undefined && (obj.format = Math.round(message.format)); + return obj; + }, + fromPartial(object: DeepPartial): SnapshotExtensionMeta { + const message = createBaseSnapshotExtensionMeta(); + message.name = object.name ?? ""; + message.format = object.format ?? 0; + return message; + }, + fromSDK(object: SnapshotExtensionMetaSDKType): SnapshotExtensionMeta { + return { + name: object?.name, + format: object?.format + }; + }, + fromSDKJSON(object: any): SnapshotExtensionMetaSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + format: isSet(object.format) ? Number(object.format) : 0 + }; + }, + toSDK(message: SnapshotExtensionMeta): SnapshotExtensionMetaSDKType { + const obj: any = {}; + obj.name = message.name; + obj.format = message.format; + return obj; + }, + fromAmino(object: SnapshotExtensionMetaAmino): SnapshotExtensionMeta { + const message = createBaseSnapshotExtensionMeta(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + if (object.format !== undefined && object.format !== null) { + message.format = object.format; + } + return message; + }, + toAmino(message: SnapshotExtensionMeta): SnapshotExtensionMetaAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + obj.format = message.format === 0 ? undefined : message.format; + return obj; + }, + fromAminoMsg(object: SnapshotExtensionMetaAminoMsg): SnapshotExtensionMeta { + return SnapshotExtensionMeta.fromAmino(object.value); + }, + toAminoMsg(message: SnapshotExtensionMeta): SnapshotExtensionMetaAminoMsg { + return { + type: "cosmos-sdk/SnapshotExtensionMeta", + value: SnapshotExtensionMeta.toAmino(message) + }; + }, + fromProtoMsg(message: SnapshotExtensionMetaProtoMsg): SnapshotExtensionMeta { + return SnapshotExtensionMeta.decode(message.value); + }, + toProto(message: SnapshotExtensionMeta): Uint8Array { + return SnapshotExtensionMeta.encode(message).finish(); + }, + toProtoMsg(message: SnapshotExtensionMeta): SnapshotExtensionMetaProtoMsg { + return { + typeUrl: "/cosmos.base.snapshots.v1beta1.SnapshotExtensionMeta", + value: SnapshotExtensionMeta.encode(message).finish() + }; + } +}; +function createBaseSnapshotExtensionPayload(): SnapshotExtensionPayload { + return { + payload: new Uint8Array() + }; +} +export const SnapshotExtensionPayload = { + typeUrl: "/cosmos.base.snapshots.v1beta1.SnapshotExtensionPayload", + encode(message: SnapshotExtensionPayload, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.payload.length !== 0) { + writer.uint32(10).bytes(message.payload); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): SnapshotExtensionPayload { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseSnapshotExtensionPayload(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.payload = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): SnapshotExtensionPayload { + const obj = createBaseSnapshotExtensionPayload(); + if (isSet(object.payload)) obj.payload = bytesFromBase64(object.payload); + return obj; + }, + toJSON(message: SnapshotExtensionPayload): JsonSafe { + const obj: any = {}; + message.payload !== undefined && (obj.payload = base64FromBytes(message.payload !== undefined ? message.payload : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): SnapshotExtensionPayload { + const message = createBaseSnapshotExtensionPayload(); + message.payload = object.payload ?? new Uint8Array(); + return message; + }, + fromSDK(object: SnapshotExtensionPayloadSDKType): SnapshotExtensionPayload { + return { + payload: object?.payload + }; + }, + fromSDKJSON(object: any): SnapshotExtensionPayloadSDKType { + return { + payload: isSet(object.payload) ? bytesFromBase64(object.payload) : new Uint8Array() + }; + }, + toSDK(message: SnapshotExtensionPayload): SnapshotExtensionPayloadSDKType { + const obj: any = {}; + obj.payload = message.payload; + return obj; + }, + fromAmino(object: SnapshotExtensionPayloadAmino): SnapshotExtensionPayload { + const message = createBaseSnapshotExtensionPayload(); + if (object.payload !== undefined && object.payload !== null) { + message.payload = bytesFromBase64(object.payload); + } + return message; + }, + toAmino(message: SnapshotExtensionPayload): SnapshotExtensionPayloadAmino { + const obj: any = {}; + obj.payload = message.payload ? base64FromBytes(message.payload) : undefined; + return obj; + }, + fromAminoMsg(object: SnapshotExtensionPayloadAminoMsg): SnapshotExtensionPayload { + return SnapshotExtensionPayload.fromAmino(object.value); + }, + toAminoMsg(message: SnapshotExtensionPayload): SnapshotExtensionPayloadAminoMsg { + return { + type: "cosmos-sdk/SnapshotExtensionPayload", + value: SnapshotExtensionPayload.toAmino(message) + }; + }, + fromProtoMsg(message: SnapshotExtensionPayloadProtoMsg): SnapshotExtensionPayload { + return SnapshotExtensionPayload.decode(message.value); + }, + toProto(message: SnapshotExtensionPayload): Uint8Array { + return SnapshotExtensionPayload.encode(message).finish(); + }, + toProtoMsg(message: SnapshotExtensionPayload): SnapshotExtensionPayloadProtoMsg { + return { + typeUrl: "/cosmos.base.snapshots.v1beta1.SnapshotExtensionPayload", + value: SnapshotExtensionPayload.encode(message).finish() + }; + } +}; +function createBaseSnapshotKVItem(): SnapshotKVItem { + return { + key: new Uint8Array(), + value: new Uint8Array() + }; +} +export const SnapshotKVItem = { + typeUrl: "/cosmos.base.snapshots.v1beta1.SnapshotKVItem", + encode(message: SnapshotKVItem, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.key.length !== 0) { + writer.uint32(10).bytes(message.key); + } + if (message.value.length !== 0) { + writer.uint32(18).bytes(message.value); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): SnapshotKVItem { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseSnapshotKVItem(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.bytes(); + break; + case 2: + message.value = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): SnapshotKVItem { + const obj = createBaseSnapshotKVItem(); + if (isSet(object.key)) obj.key = bytesFromBase64(object.key); + if (isSet(object.value)) obj.value = bytesFromBase64(object.value); + return obj; + }, + toJSON(message: SnapshotKVItem): JsonSafe { + const obj: any = {}; + message.key !== undefined && (obj.key = base64FromBytes(message.key !== undefined ? message.key : new Uint8Array())); + message.value !== undefined && (obj.value = base64FromBytes(message.value !== undefined ? message.value : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): SnapshotKVItem { + const message = createBaseSnapshotKVItem(); + message.key = object.key ?? new Uint8Array(); + message.value = object.value ?? new Uint8Array(); + return message; + }, + fromSDK(object: SnapshotKVItemSDKType): SnapshotKVItem { + return { + key: object?.key, + value: object?.value + }; + }, + fromSDKJSON(object: any): SnapshotKVItemSDKType { + return { + key: isSet(object.key) ? bytesFromBase64(object.key) : new Uint8Array(), + value: isSet(object.value) ? bytesFromBase64(object.value) : new Uint8Array() + }; + }, + toSDK(message: SnapshotKVItem): SnapshotKVItemSDKType { + const obj: any = {}; + obj.key = message.key; + obj.value = message.value; + return obj; + }, + fromAmino(object: SnapshotKVItemAmino): SnapshotKVItem { + const message = createBaseSnapshotKVItem(); + if (object.key !== undefined && object.key !== null) { + message.key = bytesFromBase64(object.key); + } + if (object.value !== undefined && object.value !== null) { + message.value = bytesFromBase64(object.value); + } + return message; + }, + toAmino(message: SnapshotKVItem): SnapshotKVItemAmino { + const obj: any = {}; + obj.key = message.key ? base64FromBytes(message.key) : undefined; + obj.value = message.value ? base64FromBytes(message.value) : undefined; + return obj; + }, + fromAminoMsg(object: SnapshotKVItemAminoMsg): SnapshotKVItem { + return SnapshotKVItem.fromAmino(object.value); + }, + toAminoMsg(message: SnapshotKVItem): SnapshotKVItemAminoMsg { + return { + type: "cosmos-sdk/SnapshotKVItem", + value: SnapshotKVItem.toAmino(message) + }; + }, + fromProtoMsg(message: SnapshotKVItemProtoMsg): SnapshotKVItem { + return SnapshotKVItem.decode(message.value); + }, + toProto(message: SnapshotKVItem): Uint8Array { + return SnapshotKVItem.encode(message).finish(); + }, + toProtoMsg(message: SnapshotKVItem): SnapshotKVItemProtoMsg { + return { + typeUrl: "/cosmos.base.snapshots.v1beta1.SnapshotKVItem", + value: SnapshotKVItem.encode(message).finish() + }; + } +}; +function createBaseSnapshotSchema(): SnapshotSchema { + return { + keys: [] + }; +} +export const SnapshotSchema = { + typeUrl: "/cosmos.base.snapshots.v1beta1.SnapshotSchema", + encode(message: SnapshotSchema, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.keys) { + writer.uint32(10).bytes(v!); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): SnapshotSchema { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseSnapshotSchema(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.keys.push(reader.bytes()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): SnapshotSchema { + const obj = createBaseSnapshotSchema(); + if (Array.isArray(object?.keys)) obj.keys = object.keys.map((e: any) => bytesFromBase64(e)); + return obj; + }, + toJSON(message: SnapshotSchema): JsonSafe { + const obj: any = {}; + if (message.keys) { + obj.keys = message.keys.map(e => base64FromBytes(e !== undefined ? e : new Uint8Array())); + } else { + obj.keys = []; + } + return obj; + }, + fromPartial(object: DeepPartial): SnapshotSchema { + const message = createBaseSnapshotSchema(); + message.keys = object.keys?.map(e => e) || []; + return message; + }, + fromSDK(object: SnapshotSchemaSDKType): SnapshotSchema { + return { + keys: Array.isArray(object?.keys) ? object.keys.map((e: any) => e) : [] + }; + }, + fromSDKJSON(object: any): SnapshotSchemaSDKType { + return { + keys: Array.isArray(object?.keys) ? object.keys.map((e: any) => bytesFromBase64(e)) : [] + }; + }, + toSDK(message: SnapshotSchema): SnapshotSchemaSDKType { + const obj: any = {}; + if (message.keys) { + obj.keys = message.keys.map(e => e); + } else { + obj.keys = []; + } + return obj; + }, + fromAmino(object: SnapshotSchemaAmino): SnapshotSchema { + const message = createBaseSnapshotSchema(); + message.keys = object.keys?.map(e => bytesFromBase64(e)) || []; + return message; + }, + toAmino(message: SnapshotSchema): SnapshotSchemaAmino { + const obj: any = {}; + if (message.keys) { + obj.keys = message.keys.map(e => base64FromBytes(e)); + } else { + obj.keys = message.keys; + } + return obj; + }, + fromAminoMsg(object: SnapshotSchemaAminoMsg): SnapshotSchema { + return SnapshotSchema.fromAmino(object.value); + }, + toAminoMsg(message: SnapshotSchema): SnapshotSchemaAminoMsg { + return { + type: "cosmos-sdk/SnapshotSchema", + value: SnapshotSchema.toAmino(message) + }; + }, + fromProtoMsg(message: SnapshotSchemaProtoMsg): SnapshotSchema { + return SnapshotSchema.decode(message.value); + }, + toProto(message: SnapshotSchema): Uint8Array { + return SnapshotSchema.encode(message).finish(); + }, + toProtoMsg(message: SnapshotSchema): SnapshotSchemaProtoMsg { + return { + typeUrl: "/cosmos.base.snapshots.v1beta1.SnapshotSchema", + value: SnapshotSchema.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/base/store/v1beta1/commit_info.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/base/store/v1beta1/commit_info.ts new file mode 100644 index 0000000000..9c8e1946f2 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/base/store/v1beta1/commit_info.ts @@ -0,0 +1,413 @@ +import { BinaryReader, BinaryWriter } from "../../../../binary.js"; +import { isSet, DeepPartial, bytesFromBase64, base64FromBytes } from "../../../../helpers.js"; +import { JsonSafe } from "../../../../json-safe.js"; +export const protobufPackage = "cosmos.base.store.v1beta1"; +/** + * CommitInfo defines commit information used by the multi-store when committing + * a version/height. + */ +export interface CommitInfo { + version: bigint; + storeInfos: StoreInfo[]; +} +export interface CommitInfoProtoMsg { + typeUrl: "/cosmos.base.store.v1beta1.CommitInfo"; + value: Uint8Array; +} +/** + * CommitInfo defines commit information used by the multi-store when committing + * a version/height. + */ +export interface CommitInfoSDKType { + version: bigint; + store_infos: StoreInfoSDKType[]; +} +/** + * StoreInfo defines store-specific commit information. It contains a reference + * between a store name and the commit ID. + */ +export interface StoreInfo { + name: string; + commitId: CommitID; +} +export interface StoreInfoProtoMsg { + typeUrl: "/cosmos.base.store.v1beta1.StoreInfo"; + value: Uint8Array; +} +/** + * StoreInfo defines store-specific commit information. It contains a reference + * between a store name and the commit ID. + */ +export interface StoreInfoSDKType { + name: string; + commit_id: CommitIDSDKType; +} +/** + * CommitID defines the committment information when a specific store is + * committed. + */ +export interface CommitID { + version: bigint; + hash: Uint8Array; +} +export interface CommitIDProtoMsg { + typeUrl: "/cosmos.base.store.v1beta1.CommitID"; + value: Uint8Array; +} +/** + * CommitID defines the committment information when a specific store is + * committed. + */ +export interface CommitIDSDKType { + version: bigint; + hash: Uint8Array; +} +function createBaseCommitInfo(): CommitInfo { + return { + version: BigInt(0), + storeInfos: [] + }; +} +export const CommitInfo = { + typeUrl: "/cosmos.base.store.v1beta1.CommitInfo", + encode(message: CommitInfo, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.version !== undefined) { + writer.uint32(8).int64(message.version); + } + for (const v of message.storeInfos) { + StoreInfo.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): CommitInfo { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCommitInfo(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.version = reader.int64(); + break; + case 2: + message.storeInfos.push(StoreInfo.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): CommitInfo { + const obj = createBaseCommitInfo(); + if (isSet(object.version)) obj.version = BigInt(object.version.toString()); + if (Array.isArray(object?.storeInfos)) obj.storeInfos = object.storeInfos.map((e: any) => StoreInfo.fromJSON(e)); + return obj; + }, + toJSON(message: CommitInfo): JsonSafe { + const obj: any = {}; + message.version !== undefined && (obj.version = (message.version || BigInt(0)).toString()); + if (message.storeInfos) { + obj.storeInfos = message.storeInfos.map(e => e ? StoreInfo.toJSON(e) : undefined); + } else { + obj.storeInfos = []; + } + return obj; + }, + fromPartial(object: DeepPartial): CommitInfo { + const message = createBaseCommitInfo(); + if (object.version !== undefined && object.version !== null) { + message.version = BigInt(object.version.toString()); + } + message.storeInfos = object.storeInfos?.map(e => StoreInfo.fromPartial(e)) || []; + return message; + }, + fromSDK(object: CommitInfoSDKType): CommitInfo { + return { + version: object?.version, + storeInfos: Array.isArray(object?.store_infos) ? object.store_infos.map((e: any) => StoreInfo.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): CommitInfoSDKType { + return { + version: isSet(object.version) ? BigInt(object.version.toString()) : BigInt(0), + store_infos: Array.isArray(object?.store_infos) ? object.store_infos.map((e: any) => StoreInfo.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: CommitInfo): CommitInfoSDKType { + const obj: any = {}; + obj.version = message.version; + if (message.storeInfos) { + obj.store_infos = message.storeInfos.map(e => e ? StoreInfo.toSDK(e) : undefined); + } else { + obj.store_infos = []; + } + return obj; + }, + fromAmino(object: CommitInfoAmino): CommitInfo { + const message = createBaseCommitInfo(); + if (object.version !== undefined && object.version !== null) { + message.version = BigInt(object.version); + } + message.storeInfos = object.store_infos?.map(e => StoreInfo.fromAmino(e)) || []; + return message; + }, + toAmino(message: CommitInfo): CommitInfoAmino { + const obj: any = {}; + obj.version = message.version !== BigInt(0) ? message.version?.toString() : undefined; + if (message.storeInfos) { + obj.store_infos = message.storeInfos.map(e => e ? StoreInfo.toAmino(e) : undefined); + } else { + obj.store_infos = message.storeInfos; + } + return obj; + }, + fromAminoMsg(object: CommitInfoAminoMsg): CommitInfo { + return CommitInfo.fromAmino(object.value); + }, + toAminoMsg(message: CommitInfo): CommitInfoAminoMsg { + return { + type: "cosmos-sdk/CommitInfo", + value: CommitInfo.toAmino(message) + }; + }, + fromProtoMsg(message: CommitInfoProtoMsg): CommitInfo { + return CommitInfo.decode(message.value); + }, + toProto(message: CommitInfo): Uint8Array { + return CommitInfo.encode(message).finish(); + }, + toProtoMsg(message: CommitInfo): CommitInfoProtoMsg { + return { + typeUrl: "/cosmos.base.store.v1beta1.CommitInfo", + value: CommitInfo.encode(message).finish() + }; + } +}; +function createBaseStoreInfo(): StoreInfo { + return { + name: "", + commitId: CommitID.fromPartial({}) + }; +} +export const StoreInfo = { + typeUrl: "/cosmos.base.store.v1beta1.StoreInfo", + encode(message: StoreInfo, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + if (message.commitId !== undefined) { + CommitID.encode(message.commitId, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): StoreInfo { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseStoreInfo(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.commitId = CommitID.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): StoreInfo { + const obj = createBaseStoreInfo(); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.commitId)) obj.commitId = CommitID.fromJSON(object.commitId); + return obj; + }, + toJSON(message: StoreInfo): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.commitId !== undefined && (obj.commitId = message.commitId ? CommitID.toJSON(message.commitId) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): StoreInfo { + const message = createBaseStoreInfo(); + message.name = object.name ?? ""; + if (object.commitId !== undefined && object.commitId !== null) { + message.commitId = CommitID.fromPartial(object.commitId); + } + return message; + }, + fromSDK(object: StoreInfoSDKType): StoreInfo { + return { + name: object?.name, + commitId: object.commit_id ? CommitID.fromSDK(object.commit_id) : undefined + }; + }, + fromSDKJSON(object: any): StoreInfoSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + commit_id: isSet(object.commit_id) ? CommitID.fromSDKJSON(object.commit_id) : undefined + }; + }, + toSDK(message: StoreInfo): StoreInfoSDKType { + const obj: any = {}; + obj.name = message.name; + message.commitId !== undefined && (obj.commit_id = message.commitId ? CommitID.toSDK(message.commitId) : undefined); + return obj; + }, + fromAmino(object: StoreInfoAmino): StoreInfo { + const message = createBaseStoreInfo(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + if (object.commit_id !== undefined && object.commit_id !== null) { + message.commitId = CommitID.fromAmino(object.commit_id); + } + return message; + }, + toAmino(message: StoreInfo): StoreInfoAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + obj.commit_id = message.commitId ? CommitID.toAmino(message.commitId) : undefined; + return obj; + }, + fromAminoMsg(object: StoreInfoAminoMsg): StoreInfo { + return StoreInfo.fromAmino(object.value); + }, + toAminoMsg(message: StoreInfo): StoreInfoAminoMsg { + return { + type: "cosmos-sdk/StoreInfo", + value: StoreInfo.toAmino(message) + }; + }, + fromProtoMsg(message: StoreInfoProtoMsg): StoreInfo { + return StoreInfo.decode(message.value); + }, + toProto(message: StoreInfo): Uint8Array { + return StoreInfo.encode(message).finish(); + }, + toProtoMsg(message: StoreInfo): StoreInfoProtoMsg { + return { + typeUrl: "/cosmos.base.store.v1beta1.StoreInfo", + value: StoreInfo.encode(message).finish() + }; + } +}; +function createBaseCommitID(): CommitID { + return { + version: BigInt(0), + hash: new Uint8Array() + }; +} +export const CommitID = { + typeUrl: "/cosmos.base.store.v1beta1.CommitID", + encode(message: CommitID, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.version !== undefined) { + writer.uint32(8).int64(message.version); + } + if (message.hash.length !== 0) { + writer.uint32(18).bytes(message.hash); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): CommitID { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCommitID(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.version = reader.int64(); + break; + case 2: + message.hash = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): CommitID { + const obj = createBaseCommitID(); + if (isSet(object.version)) obj.version = BigInt(object.version.toString()); + if (isSet(object.hash)) obj.hash = bytesFromBase64(object.hash); + return obj; + }, + toJSON(message: CommitID): JsonSafe { + const obj: any = {}; + message.version !== undefined && (obj.version = (message.version || BigInt(0)).toString()); + message.hash !== undefined && (obj.hash = base64FromBytes(message.hash !== undefined ? message.hash : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): CommitID { + const message = createBaseCommitID(); + if (object.version !== undefined && object.version !== null) { + message.version = BigInt(object.version.toString()); + } + message.hash = object.hash ?? new Uint8Array(); + return message; + }, + fromSDK(object: CommitIDSDKType): CommitID { + return { + version: object?.version, + hash: object?.hash + }; + }, + fromSDKJSON(object: any): CommitIDSDKType { + return { + version: isSet(object.version) ? BigInt(object.version.toString()) : BigInt(0), + hash: isSet(object.hash) ? bytesFromBase64(object.hash) : new Uint8Array() + }; + }, + toSDK(message: CommitID): CommitIDSDKType { + const obj: any = {}; + obj.version = message.version; + obj.hash = message.hash; + return obj; + }, + fromAmino(object: CommitIDAmino): CommitID { + const message = createBaseCommitID(); + if (object.version !== undefined && object.version !== null) { + message.version = BigInt(object.version); + } + if (object.hash !== undefined && object.hash !== null) { + message.hash = bytesFromBase64(object.hash); + } + return message; + }, + toAmino(message: CommitID): CommitIDAmino { + const obj: any = {}; + obj.version = message.version !== BigInt(0) ? message.version?.toString() : undefined; + obj.hash = message.hash ? base64FromBytes(message.hash) : undefined; + return obj; + }, + fromAminoMsg(object: CommitIDAminoMsg): CommitID { + return CommitID.fromAmino(object.value); + }, + toAminoMsg(message: CommitID): CommitIDAminoMsg { + return { + type: "cosmos-sdk/CommitID", + value: CommitID.toAmino(message) + }; + }, + fromProtoMsg(message: CommitIDProtoMsg): CommitID { + return CommitID.decode(message.value); + }, + toProto(message: CommitID): Uint8Array { + return CommitID.encode(message).finish(); + }, + toProtoMsg(message: CommitID): CommitIDProtoMsg { + return { + typeUrl: "/cosmos.base.store.v1beta1.CommitID", + value: CommitID.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/base/store/v1beta1/listening.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/base/store/v1beta1/listening.ts new file mode 100644 index 0000000000..5a9b392344 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/base/store/v1beta1/listening.ts @@ -0,0 +1,181 @@ +import { BinaryReader, BinaryWriter } from "../../../../binary.js"; +import { isSet, bytesFromBase64, base64FromBytes, DeepPartial } from "../../../../helpers.js"; +import { JsonSafe } from "../../../../json-safe.js"; +export const protobufPackage = "cosmos.base.store.v1beta1"; +/** + * StoreKVPair is a KVStore KVPair used for listening to state changes (Sets and Deletes) + * It optionally includes the StoreKey for the originating KVStore and a Boolean flag to distinguish between Sets and + * Deletes + * + * Since: cosmos-sdk 0.43 + */ +export interface StoreKVPair { + /** the store key for the KVStore this pair originates from */ + storeKey: string; + /** true indicates a delete operation, false indicates a set operation */ + delete: boolean; + key: Uint8Array; + value: Uint8Array; +} +export interface StoreKVPairProtoMsg { + typeUrl: "/cosmos.base.store.v1beta1.StoreKVPair"; + value: Uint8Array; +} +/** + * StoreKVPair is a KVStore KVPair used for listening to state changes (Sets and Deletes) + * It optionally includes the StoreKey for the originating KVStore and a Boolean flag to distinguish between Sets and + * Deletes + * + * Since: cosmos-sdk 0.43 + */ +export interface StoreKVPairSDKType { + store_key: string; + delete: boolean; + key: Uint8Array; + value: Uint8Array; +} +function createBaseStoreKVPair(): StoreKVPair { + return { + storeKey: "", + delete: false, + key: new Uint8Array(), + value: new Uint8Array() + }; +} +export const StoreKVPair = { + typeUrl: "/cosmos.base.store.v1beta1.StoreKVPair", + encode(message: StoreKVPair, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.storeKey !== undefined) { + writer.uint32(10).string(message.storeKey); + } + if (message.delete !== undefined) { + writer.uint32(16).bool(message.delete); + } + if (message.key.length !== 0) { + writer.uint32(26).bytes(message.key); + } + if (message.value.length !== 0) { + writer.uint32(34).bytes(message.value); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): StoreKVPair { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseStoreKVPair(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.storeKey = reader.string(); + break; + case 2: + message.delete = reader.bool(); + break; + case 3: + message.key = reader.bytes(); + break; + case 4: + message.value = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): StoreKVPair { + const obj = createBaseStoreKVPair(); + if (isSet(object.storeKey)) obj.storeKey = String(object.storeKey); + if (isSet(object.delete)) obj.delete = Boolean(object.delete); + if (isSet(object.key)) obj.key = bytesFromBase64(object.key); + if (isSet(object.value)) obj.value = bytesFromBase64(object.value); + return obj; + }, + toJSON(message: StoreKVPair): JsonSafe { + const obj: any = {}; + message.storeKey !== undefined && (obj.storeKey = message.storeKey); + message.delete !== undefined && (obj.delete = message.delete); + message.key !== undefined && (obj.key = base64FromBytes(message.key !== undefined ? message.key : new Uint8Array())); + message.value !== undefined && (obj.value = base64FromBytes(message.value !== undefined ? message.value : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): StoreKVPair { + const message = createBaseStoreKVPair(); + message.storeKey = object.storeKey ?? ""; + message.delete = object.delete ?? false; + message.key = object.key ?? new Uint8Array(); + message.value = object.value ?? new Uint8Array(); + return message; + }, + fromSDK(object: StoreKVPairSDKType): StoreKVPair { + return { + storeKey: object?.store_key, + delete: object?.delete, + key: object?.key, + value: object?.value + }; + }, + fromSDKJSON(object: any): StoreKVPairSDKType { + return { + store_key: isSet(object.store_key) ? String(object.store_key) : "", + delete: isSet(object.delete) ? Boolean(object.delete) : false, + key: isSet(object.key) ? bytesFromBase64(object.key) : new Uint8Array(), + value: isSet(object.value) ? bytesFromBase64(object.value) : new Uint8Array() + }; + }, + toSDK(message: StoreKVPair): StoreKVPairSDKType { + const obj: any = {}; + obj.store_key = message.storeKey; + obj.delete = message.delete; + obj.key = message.key; + obj.value = message.value; + return obj; + }, + fromAmino(object: StoreKVPairAmino): StoreKVPair { + const message = createBaseStoreKVPair(); + if (object.store_key !== undefined && object.store_key !== null) { + message.storeKey = object.store_key; + } + if (object.delete !== undefined && object.delete !== null) { + message.delete = object.delete; + } + if (object.key !== undefined && object.key !== null) { + message.key = bytesFromBase64(object.key); + } + if (object.value !== undefined && object.value !== null) { + message.value = bytesFromBase64(object.value); + } + return message; + }, + toAmino(message: StoreKVPair): StoreKVPairAmino { + const obj: any = {}; + obj.store_key = message.storeKey === "" ? undefined : message.storeKey; + obj.delete = message.delete === false ? undefined : message.delete; + obj.key = message.key ? base64FromBytes(message.key) : undefined; + obj.value = message.value ? base64FromBytes(message.value) : undefined; + return obj; + }, + fromAminoMsg(object: StoreKVPairAminoMsg): StoreKVPair { + return StoreKVPair.fromAmino(object.value); + }, + toAminoMsg(message: StoreKVPair): StoreKVPairAminoMsg { + return { + type: "cosmos-sdk/StoreKVPair", + value: StoreKVPair.toAmino(message) + }; + }, + fromProtoMsg(message: StoreKVPairProtoMsg): StoreKVPair { + return StoreKVPair.decode(message.value); + }, + toProto(message: StoreKVPair): Uint8Array { + return StoreKVPair.encode(message).finish(); + }, + toProtoMsg(message: StoreKVPair): StoreKVPairProtoMsg { + return { + typeUrl: "/cosmos.base.store.v1beta1.StoreKVPair", + value: StoreKVPair.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/base/tendermint/v1beta1/query.lcd.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/base/tendermint/v1beta1/query.lcd.ts new file mode 100644 index 0000000000..71ebde02c2 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/base/tendermint/v1beta1/query.lcd.ts @@ -0,0 +1,68 @@ +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../query/v1beta1/pagination.js"; +import { Any, AnySDKType } from "../../../../google/protobuf/any.js"; +import { BlockID, BlockIDSDKType } from "../../../../tendermint/types/types.js"; +import { Block, BlockSDKType } from "../../../../tendermint/types/block.js"; +import { NodeInfo, NodeInfoSDKType } from "../../../../tendermint/p2p/types.js"; +import { setPaginationParams } from "../../../../helpers.js"; +import { LCDClient } from "@cosmology/lcd"; +import { GetNodeInfoRequest, GetNodeInfoRequestSDKType, GetNodeInfoResponse, GetNodeInfoResponseSDKType, GetSyncingRequest, GetSyncingRequestSDKType, GetSyncingResponse, GetSyncingResponseSDKType, GetLatestBlockRequest, GetLatestBlockRequestSDKType, GetLatestBlockResponse, GetLatestBlockResponseSDKType, GetBlockByHeightRequest, GetBlockByHeightRequestSDKType, GetBlockByHeightResponse, GetBlockByHeightResponseSDKType, GetLatestValidatorSetRequest, GetLatestValidatorSetRequestSDKType, GetLatestValidatorSetResponse, GetLatestValidatorSetResponseSDKType, GetValidatorSetByHeightRequest, GetValidatorSetByHeightRequestSDKType, GetValidatorSetByHeightResponse, GetValidatorSetByHeightResponseSDKType } from "./query.js"; +export class LCDQueryClient { + req: LCDClient; + constructor({ + requestClient + }: { + requestClient: LCDClient; + }) { + this.req = requestClient; + this.getNodeInfo = this.getNodeInfo.bind(this); + this.getSyncing = this.getSyncing.bind(this); + this.getLatestBlock = this.getLatestBlock.bind(this); + this.getBlockByHeight = this.getBlockByHeight.bind(this); + this.getLatestValidatorSet = this.getLatestValidatorSet.bind(this); + this.getValidatorSetByHeight = this.getValidatorSetByHeight.bind(this); + } + /* GetNodeInfo queries the current node info. */ + async getNodeInfo(_params: GetNodeInfoRequest = {}): Promise { + const endpoint = `cosmos/base/tendermint/v1beta1/node_info`; + return GetNodeInfoResponse.fromSDKJSON(await this.req.get(endpoint)); + } + /* GetSyncing queries node syncing. */ + async getSyncing(_params: GetSyncingRequest = {}): Promise { + const endpoint = `cosmos/base/tendermint/v1beta1/syncing`; + return GetSyncingResponse.fromSDKJSON(await this.req.get(endpoint)); + } + /* GetLatestBlock returns the latest block. */ + async getLatestBlock(_params: GetLatestBlockRequest = {}): Promise { + const endpoint = `cosmos/base/tendermint/v1beta1/blocks/latest`; + return GetLatestBlockResponse.fromSDKJSON(await this.req.get(endpoint)); + } + /* GetBlockByHeight queries block for given height. */ + async getBlockByHeight(params: GetBlockByHeightRequest): Promise { + const endpoint = `cosmos/base/tendermint/v1beta1/blocks/${params.height}`; + return GetBlockByHeightResponse.fromSDKJSON(await this.req.get(endpoint)); + } + /* GetLatestValidatorSet queries latest validator-set. */ + async getLatestValidatorSet(params: GetLatestValidatorSetRequest = { + pagination: PageRequest.fromPartial({}) + }): Promise { + const options: any = { + params: {} + }; + if (typeof params?.pagination !== "undefined") { + setPaginationParams(options, params.pagination); + } + const endpoint = `cosmos/base/tendermint/v1beta1/validatorsets/latest`; + return GetLatestValidatorSetResponse.fromSDKJSON(await this.req.get(endpoint, options)); + } + /* GetValidatorSetByHeight queries validator-set at a given height. */ + async getValidatorSetByHeight(params: GetValidatorSetByHeightRequest): Promise { + const options: any = { + params: {} + }; + if (typeof params?.pagination !== "undefined") { + setPaginationParams(options, params.pagination); + } + const endpoint = `cosmos/base/tendermint/v1beta1/validatorsets/${params.height}`; + return GetValidatorSetByHeightResponse.fromSDKJSON(await this.req.get(endpoint, options)); + } +} \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/base/tendermint/v1beta1/query.rpc.Service.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/base/tendermint/v1beta1/query.rpc.Service.ts new file mode 100644 index 0000000000..cdfeebe4e2 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/base/tendermint/v1beta1/query.rpc.Service.ts @@ -0,0 +1,92 @@ +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../query/v1beta1/pagination.js"; +import { Any, AnySDKType } from "../../../../google/protobuf/any.js"; +import { BlockID, BlockIDSDKType } from "../../../../tendermint/types/types.js"; +import { Block, BlockSDKType } from "../../../../tendermint/types/block.js"; +import { NodeInfo, NodeInfoSDKType } from "../../../../tendermint/p2p/types.js"; +import { Rpc } from "../../../../helpers.js"; +import { BinaryReader } from "../../../../binary.js"; +import { QueryClient, createProtobufRpcClient } from "@cosmjs/stargate"; +import { GetNodeInfoRequest, GetNodeInfoRequestSDKType, GetNodeInfoResponse, GetNodeInfoResponseSDKType, GetSyncingRequest, GetSyncingRequestSDKType, GetSyncingResponse, GetSyncingResponseSDKType, GetLatestBlockRequest, GetLatestBlockRequestSDKType, GetLatestBlockResponse, GetLatestBlockResponseSDKType, GetBlockByHeightRequest, GetBlockByHeightRequestSDKType, GetBlockByHeightResponse, GetBlockByHeightResponseSDKType, GetLatestValidatorSetRequest, GetLatestValidatorSetRequestSDKType, GetLatestValidatorSetResponse, GetLatestValidatorSetResponseSDKType, GetValidatorSetByHeightRequest, GetValidatorSetByHeightRequestSDKType, GetValidatorSetByHeightResponse, GetValidatorSetByHeightResponseSDKType } from "./query.js"; +/** Service defines the gRPC querier service for tendermint queries. */ +export interface Service { + /** GetNodeInfo queries the current node info. */ + getNodeInfo(request?: GetNodeInfoRequest): Promise; + /** GetSyncing queries node syncing. */ + getSyncing(request?: GetSyncingRequest): Promise; + /** GetLatestBlock returns the latest block. */ + getLatestBlock(request?: GetLatestBlockRequest): Promise; + /** GetBlockByHeight queries block for given height. */ + getBlockByHeight(request: GetBlockByHeightRequest): Promise; + /** GetLatestValidatorSet queries latest validator-set. */ + getLatestValidatorSet(request?: GetLatestValidatorSetRequest): Promise; + /** GetValidatorSetByHeight queries validator-set at a given height. */ + getValidatorSetByHeight(request: GetValidatorSetByHeightRequest): Promise; +} +export class ServiceClientImpl implements Service { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + this.getNodeInfo = this.getNodeInfo.bind(this); + this.getSyncing = this.getSyncing.bind(this); + this.getLatestBlock = this.getLatestBlock.bind(this); + this.getBlockByHeight = this.getBlockByHeight.bind(this); + this.getLatestValidatorSet = this.getLatestValidatorSet.bind(this); + this.getValidatorSetByHeight = this.getValidatorSetByHeight.bind(this); + } + getNodeInfo(request: GetNodeInfoRequest = {}): Promise { + const data = GetNodeInfoRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.base.tendermint.v1beta1.Service", "GetNodeInfo", data); + return promise.then(data => GetNodeInfoResponse.decode(new BinaryReader(data))); + } + getSyncing(request: GetSyncingRequest = {}): Promise { + const data = GetSyncingRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.base.tendermint.v1beta1.Service", "GetSyncing", data); + return promise.then(data => GetSyncingResponse.decode(new BinaryReader(data))); + } + getLatestBlock(request: GetLatestBlockRequest = {}): Promise { + const data = GetLatestBlockRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.base.tendermint.v1beta1.Service", "GetLatestBlock", data); + return promise.then(data => GetLatestBlockResponse.decode(new BinaryReader(data))); + } + getBlockByHeight(request: GetBlockByHeightRequest): Promise { + const data = GetBlockByHeightRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.base.tendermint.v1beta1.Service", "GetBlockByHeight", data); + return promise.then(data => GetBlockByHeightResponse.decode(new BinaryReader(data))); + } + getLatestValidatorSet(request: GetLatestValidatorSetRequest = { + pagination: PageRequest.fromPartial({}) + }): Promise { + const data = GetLatestValidatorSetRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.base.tendermint.v1beta1.Service", "GetLatestValidatorSet", data); + return promise.then(data => GetLatestValidatorSetResponse.decode(new BinaryReader(data))); + } + getValidatorSetByHeight(request: GetValidatorSetByHeightRequest): Promise { + const data = GetValidatorSetByHeightRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.base.tendermint.v1beta1.Service", "GetValidatorSetByHeight", data); + return promise.then(data => GetValidatorSetByHeightResponse.decode(new BinaryReader(data))); + } +} +export const createRpcQueryExtension = (base: QueryClient) => { + const rpc = createProtobufRpcClient(base); + const queryService = new ServiceClientImpl(rpc); + return { + getNodeInfo(request?: GetNodeInfoRequest): Promise { + return queryService.getNodeInfo(request); + }, + getSyncing(request?: GetSyncingRequest): Promise { + return queryService.getSyncing(request); + }, + getLatestBlock(request?: GetLatestBlockRequest): Promise { + return queryService.getLatestBlock(request); + }, + getBlockByHeight(request: GetBlockByHeightRequest): Promise { + return queryService.getBlockByHeight(request); + }, + getLatestValidatorSet(request?: GetLatestValidatorSetRequest): Promise { + return queryService.getLatestValidatorSet(request); + }, + getValidatorSetByHeight(request: GetValidatorSetByHeightRequest): Promise { + return queryService.getValidatorSetByHeight(request); + } + }; +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/base/tendermint/v1beta1/query.rpc.func.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/base/tendermint/v1beta1/query.rpc.func.ts new file mode 100644 index 0000000000..6494808bae --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/base/tendermint/v1beta1/query.rpc.func.ts @@ -0,0 +1,69 @@ +import { RpcResolver, buildQuery } from "../../../../helper-func-types"; +import { buildUseQuery } from "../../../../react-query"; +import { GetNodeInfoRequest, GetNodeInfoResponse, GetSyncingRequest, GetSyncingResponse, GetLatestBlockRequest, GetLatestBlockResponse, GetBlockByHeightRequest, GetBlockByHeightResponse, GetLatestValidatorSetRequest, GetLatestValidatorSetResponse, GetValidatorSetByHeightRequest, GetValidatorSetByHeightResponse } from "./query"; +export const createGetGetNodeInfo = (getRpcInstance: RpcResolver) => buildQuery({ + encode: GetNodeInfoRequest.encode, + decode: GetNodeInfoResponse.decode, + service: "cosmos.base.tendermint.v1beta1.Service", + method: "GetNodeInfo", + getRpcInstance: getRpcInstance +}); +export const useGetGetNodeInfo = buildUseQuery({ + builderQueryFn: createGetGetNodeInfo, + queryKeyPrefix: "GetNodeInfoQuery" +}); +export const createGetGetSyncing = (getRpcInstance: RpcResolver) => buildQuery({ + encode: GetSyncingRequest.encode, + decode: GetSyncingResponse.decode, + service: "cosmos.base.tendermint.v1beta1.Service", + method: "GetSyncing", + getRpcInstance: getRpcInstance +}); +export const useGetGetSyncing = buildUseQuery({ + builderQueryFn: createGetGetSyncing, + queryKeyPrefix: "GetSyncingQuery" +}); +export const createGetGetLatestBlock = (getRpcInstance: RpcResolver) => buildQuery({ + encode: GetLatestBlockRequest.encode, + decode: GetLatestBlockResponse.decode, + service: "cosmos.base.tendermint.v1beta1.Service", + method: "GetLatestBlock", + getRpcInstance: getRpcInstance +}); +export const useGetGetLatestBlock = buildUseQuery({ + builderQueryFn: createGetGetLatestBlock, + queryKeyPrefix: "GetLatestBlockQuery" +}); +export const createGetGetBlockByHeight = (getRpcInstance: RpcResolver) => buildQuery({ + encode: GetBlockByHeightRequest.encode, + decode: GetBlockByHeightResponse.decode, + service: "cosmos.base.tendermint.v1beta1.Service", + method: "GetBlockByHeight", + getRpcInstance: getRpcInstance +}); +export const useGetGetBlockByHeight = buildUseQuery({ + builderQueryFn: createGetGetBlockByHeight, + queryKeyPrefix: "GetBlockByHeightQuery" +}); +export const createGetGetLatestValidatorSet = (getRpcInstance: RpcResolver) => buildQuery({ + encode: GetLatestValidatorSetRequest.encode, + decode: GetLatestValidatorSetResponse.decode, + service: "cosmos.base.tendermint.v1beta1.Service", + method: "GetLatestValidatorSet", + getRpcInstance: getRpcInstance +}); +export const useGetGetLatestValidatorSet = buildUseQuery({ + builderQueryFn: createGetGetLatestValidatorSet, + queryKeyPrefix: "GetLatestValidatorSetQuery" +}); +export const createGetGetValidatorSetByHeight = (getRpcInstance: RpcResolver) => buildQuery({ + encode: GetValidatorSetByHeightRequest.encode, + decode: GetValidatorSetByHeightResponse.decode, + service: "cosmos.base.tendermint.v1beta1.Service", + method: "GetValidatorSetByHeight", + getRpcInstance: getRpcInstance +}); +export const useGetGetValidatorSetByHeight = buildUseQuery({ + builderQueryFn: createGetGetValidatorSetByHeight, + queryKeyPrefix: "GetValidatorSetByHeightQuery" +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/base/tendermint/v1beta1/query.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/base/tendermint/v1beta1/query.ts new file mode 100644 index 0000000000..8c264dc512 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/base/tendermint/v1beta1/query.ts @@ -0,0 +1,1979 @@ +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../query/v1beta1/pagination.js"; +import { Any, AnySDKType } from "../../../../google/protobuf/any.js"; +import { BlockID, BlockIDSDKType } from "../../../../tendermint/types/types.js"; +import { Block, BlockSDKType } from "../../../../tendermint/types/block.js"; +import { NodeInfo, NodeInfoSDKType } from "../../../../tendermint/p2p/types.js"; +import { BinaryReader, BinaryWriter } from "../../../../binary.js"; +import { isSet, DeepPartial } from "../../../../helpers.js"; +import { JsonSafe } from "../../../../json-safe.js"; +export const protobufPackage = "cosmos.base.tendermint.v1beta1"; +/** GetValidatorSetByHeightRequest is the request type for the Query/GetValidatorSetByHeight RPC method. */ +export interface GetValidatorSetByHeightRequest { + height: bigint; + /** pagination defines an pagination for the request. */ + pagination?: PageRequest; +} +export interface GetValidatorSetByHeightRequestProtoMsg { + typeUrl: "/cosmos.base.tendermint.v1beta1.GetValidatorSetByHeightRequest"; + value: Uint8Array; +} +/** GetValidatorSetByHeightRequest is the request type for the Query/GetValidatorSetByHeight RPC method. */ +export interface GetValidatorSetByHeightRequestSDKType { + height: bigint; + pagination?: PageRequestSDKType; +} +/** GetValidatorSetByHeightResponse is the response type for the Query/GetValidatorSetByHeight RPC method. */ +export interface GetValidatorSetByHeightResponse { + blockHeight: bigint; + validators: Validator[]; + /** pagination defines an pagination for the response. */ + pagination?: PageResponse; +} +export interface GetValidatorSetByHeightResponseProtoMsg { + typeUrl: "/cosmos.base.tendermint.v1beta1.GetValidatorSetByHeightResponse"; + value: Uint8Array; +} +/** GetValidatorSetByHeightResponse is the response type for the Query/GetValidatorSetByHeight RPC method. */ +export interface GetValidatorSetByHeightResponseSDKType { + block_height: bigint; + validators: ValidatorSDKType[]; + pagination?: PageResponseSDKType; +} +/** GetLatestValidatorSetRequest is the request type for the Query/GetValidatorSetByHeight RPC method. */ +export interface GetLatestValidatorSetRequest { + /** pagination defines an pagination for the request. */ + pagination?: PageRequest; +} +export interface GetLatestValidatorSetRequestProtoMsg { + typeUrl: "/cosmos.base.tendermint.v1beta1.GetLatestValidatorSetRequest"; + value: Uint8Array; +} +/** GetLatestValidatorSetRequest is the request type for the Query/GetValidatorSetByHeight RPC method. */ +export interface GetLatestValidatorSetRequestSDKType { + pagination?: PageRequestSDKType; +} +/** GetLatestValidatorSetResponse is the response type for the Query/GetValidatorSetByHeight RPC method. */ +export interface GetLatestValidatorSetResponse { + blockHeight: bigint; + validators: Validator[]; + /** pagination defines an pagination for the response. */ + pagination?: PageResponse; +} +export interface GetLatestValidatorSetResponseProtoMsg { + typeUrl: "/cosmos.base.tendermint.v1beta1.GetLatestValidatorSetResponse"; + value: Uint8Array; +} +/** GetLatestValidatorSetResponse is the response type for the Query/GetValidatorSetByHeight RPC method. */ +export interface GetLatestValidatorSetResponseSDKType { + block_height: bigint; + validators: ValidatorSDKType[]; + pagination?: PageResponseSDKType; +} +/** Validator is the type for the validator-set. */ +export interface Validator { + address: string; + pubKey?: Any; + votingPower: bigint; + proposerPriority: bigint; +} +export interface ValidatorProtoMsg { + typeUrl: "/cosmos.base.tendermint.v1beta1.Validator"; + value: Uint8Array; +} +/** Validator is the type for the validator-set. */ +export interface ValidatorSDKType { + address: string; + pub_key?: AnySDKType; + voting_power: bigint; + proposer_priority: bigint; +} +/** GetBlockByHeightRequest is the request type for the Query/GetBlockByHeight RPC method. */ +export interface GetBlockByHeightRequest { + height: bigint; +} +export interface GetBlockByHeightRequestProtoMsg { + typeUrl: "/cosmos.base.tendermint.v1beta1.GetBlockByHeightRequest"; + value: Uint8Array; +} +/** GetBlockByHeightRequest is the request type for the Query/GetBlockByHeight RPC method. */ +export interface GetBlockByHeightRequestSDKType { + height: bigint; +} +/** GetBlockByHeightResponse is the response type for the Query/GetBlockByHeight RPC method. */ +export interface GetBlockByHeightResponse { + blockId?: BlockID; + block?: Block; +} +export interface GetBlockByHeightResponseProtoMsg { + typeUrl: "/cosmos.base.tendermint.v1beta1.GetBlockByHeightResponse"; + value: Uint8Array; +} +/** GetBlockByHeightResponse is the response type for the Query/GetBlockByHeight RPC method. */ +export interface GetBlockByHeightResponseSDKType { + block_id?: BlockIDSDKType; + block?: BlockSDKType; +} +/** GetLatestBlockRequest is the request type for the Query/GetLatestBlock RPC method. */ +export interface GetLatestBlockRequest {} +export interface GetLatestBlockRequestProtoMsg { + typeUrl: "/cosmos.base.tendermint.v1beta1.GetLatestBlockRequest"; + value: Uint8Array; +} +/** GetLatestBlockRequest is the request type for the Query/GetLatestBlock RPC method. */ +export interface GetLatestBlockRequestSDKType {} +/** GetLatestBlockResponse is the response type for the Query/GetLatestBlock RPC method. */ +export interface GetLatestBlockResponse { + blockId?: BlockID; + block?: Block; +} +export interface GetLatestBlockResponseProtoMsg { + typeUrl: "/cosmos.base.tendermint.v1beta1.GetLatestBlockResponse"; + value: Uint8Array; +} +/** GetLatestBlockResponse is the response type for the Query/GetLatestBlock RPC method. */ +export interface GetLatestBlockResponseSDKType { + block_id?: BlockIDSDKType; + block?: BlockSDKType; +} +/** GetSyncingRequest is the request type for the Query/GetSyncing RPC method. */ +export interface GetSyncingRequest {} +export interface GetSyncingRequestProtoMsg { + typeUrl: "/cosmos.base.tendermint.v1beta1.GetSyncingRequest"; + value: Uint8Array; +} +/** GetSyncingRequest is the request type for the Query/GetSyncing RPC method. */ +export interface GetSyncingRequestSDKType {} +/** GetSyncingResponse is the response type for the Query/GetSyncing RPC method. */ +export interface GetSyncingResponse { + syncing: boolean; +} +export interface GetSyncingResponseProtoMsg { + typeUrl: "/cosmos.base.tendermint.v1beta1.GetSyncingResponse"; + value: Uint8Array; +} +/** GetSyncingResponse is the response type for the Query/GetSyncing RPC method. */ +export interface GetSyncingResponseSDKType { + syncing: boolean; +} +/** GetNodeInfoRequest is the request type for the Query/GetNodeInfo RPC method. */ +export interface GetNodeInfoRequest {} +export interface GetNodeInfoRequestProtoMsg { + typeUrl: "/cosmos.base.tendermint.v1beta1.GetNodeInfoRequest"; + value: Uint8Array; +} +/** GetNodeInfoRequest is the request type for the Query/GetNodeInfo RPC method. */ +export interface GetNodeInfoRequestSDKType {} +/** GetNodeInfoResponse is the response type for the Query/GetNodeInfo RPC method. */ +export interface GetNodeInfoResponse { + nodeInfo?: NodeInfo; + applicationVersion?: VersionInfo; +} +export interface GetNodeInfoResponseProtoMsg { + typeUrl: "/cosmos.base.tendermint.v1beta1.GetNodeInfoResponse"; + value: Uint8Array; +} +/** GetNodeInfoResponse is the response type for the Query/GetNodeInfo RPC method. */ +export interface GetNodeInfoResponseSDKType { + node_info?: NodeInfoSDKType; + application_version?: VersionInfoSDKType; +} +/** VersionInfo is the type for the GetNodeInfoResponse message. */ +export interface VersionInfo { + name: string; + appName: string; + version: string; + gitCommit: string; + buildTags: string; + goVersion: string; + buildDeps: Module[]; + /** Since: cosmos-sdk 0.43 */ + cosmosSdkVersion: string; +} +export interface VersionInfoProtoMsg { + typeUrl: "/cosmos.base.tendermint.v1beta1.VersionInfo"; + value: Uint8Array; +} +/** VersionInfo is the type for the GetNodeInfoResponse message. */ +export interface VersionInfoSDKType { + name: string; + app_name: string; + version: string; + git_commit: string; + build_tags: string; + go_version: string; + build_deps: ModuleSDKType[]; + cosmos_sdk_version: string; +} +/** Module is the type for VersionInfo */ +export interface Module { + /** module path */ + path: string; + /** module version */ + version: string; + /** checksum */ + sum: string; +} +export interface ModuleProtoMsg { + typeUrl: "/cosmos.base.tendermint.v1beta1.Module"; + value: Uint8Array; +} +/** Module is the type for VersionInfo */ +export interface ModuleSDKType { + path: string; + version: string; + sum: string; +} +function createBaseGetValidatorSetByHeightRequest(): GetValidatorSetByHeightRequest { + return { + height: BigInt(0), + pagination: undefined + }; +} +export const GetValidatorSetByHeightRequest = { + typeUrl: "/cosmos.base.tendermint.v1beta1.GetValidatorSetByHeightRequest", + encode(message: GetValidatorSetByHeightRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.height !== undefined) { + writer.uint32(8).int64(message.height); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GetValidatorSetByHeightRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGetValidatorSetByHeightRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.height = reader.int64(); + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GetValidatorSetByHeightRequest { + const obj = createBaseGetValidatorSetByHeightRequest(); + if (isSet(object.height)) obj.height = BigInt(object.height.toString()); + if (isSet(object.pagination)) obj.pagination = PageRequest.fromJSON(object.pagination); + return obj; + }, + toJSON(message: GetValidatorSetByHeightRequest): JsonSafe { + const obj: any = {}; + message.height !== undefined && (obj.height = (message.height || BigInt(0)).toString()); + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): GetValidatorSetByHeightRequest { + const message = createBaseGetValidatorSetByHeightRequest(); + if (object.height !== undefined && object.height !== null) { + message.height = BigInt(object.height.toString()); + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: GetValidatorSetByHeightRequestSDKType): GetValidatorSetByHeightRequest { + return { + height: object?.height, + pagination: object.pagination ? PageRequest.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): GetValidatorSetByHeightRequestSDKType { + return { + height: isSet(object.height) ? BigInt(object.height.toString()) : BigInt(0), + pagination: isSet(object.pagination) ? PageRequest.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: GetValidatorSetByHeightRequest): GetValidatorSetByHeightRequestSDKType { + const obj: any = {}; + obj.height = message.height; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: GetValidatorSetByHeightRequestAmino): GetValidatorSetByHeightRequest { + const message = createBaseGetValidatorSetByHeightRequest(); + if (object.height !== undefined && object.height !== null) { + message.height = BigInt(object.height); + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: GetValidatorSetByHeightRequest): GetValidatorSetByHeightRequestAmino { + const obj: any = {}; + obj.height = message.height !== BigInt(0) ? message.height?.toString() : undefined; + obj.pagination = message.pagination ? PageRequest.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: GetValidatorSetByHeightRequestAminoMsg): GetValidatorSetByHeightRequest { + return GetValidatorSetByHeightRequest.fromAmino(object.value); + }, + toAminoMsg(message: GetValidatorSetByHeightRequest): GetValidatorSetByHeightRequestAminoMsg { + return { + type: "cosmos-sdk/GetValidatorSetByHeightRequest", + value: GetValidatorSetByHeightRequest.toAmino(message) + }; + }, + fromProtoMsg(message: GetValidatorSetByHeightRequestProtoMsg): GetValidatorSetByHeightRequest { + return GetValidatorSetByHeightRequest.decode(message.value); + }, + toProto(message: GetValidatorSetByHeightRequest): Uint8Array { + return GetValidatorSetByHeightRequest.encode(message).finish(); + }, + toProtoMsg(message: GetValidatorSetByHeightRequest): GetValidatorSetByHeightRequestProtoMsg { + return { + typeUrl: "/cosmos.base.tendermint.v1beta1.GetValidatorSetByHeightRequest", + value: GetValidatorSetByHeightRequest.encode(message).finish() + }; + } +}; +function createBaseGetValidatorSetByHeightResponse(): GetValidatorSetByHeightResponse { + return { + blockHeight: BigInt(0), + validators: [], + pagination: undefined + }; +} +export const GetValidatorSetByHeightResponse = { + typeUrl: "/cosmos.base.tendermint.v1beta1.GetValidatorSetByHeightResponse", + encode(message: GetValidatorSetByHeightResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.blockHeight !== undefined) { + writer.uint32(8).int64(message.blockHeight); + } + for (const v of message.validators) { + Validator.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GetValidatorSetByHeightResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGetValidatorSetByHeightResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.blockHeight = reader.int64(); + break; + case 2: + message.validators.push(Validator.decode(reader, reader.uint32())); + break; + case 3: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GetValidatorSetByHeightResponse { + const obj = createBaseGetValidatorSetByHeightResponse(); + if (isSet(object.blockHeight)) obj.blockHeight = BigInt(object.blockHeight.toString()); + if (Array.isArray(object?.validators)) obj.validators = object.validators.map((e: any) => Validator.fromJSON(e)); + if (isSet(object.pagination)) obj.pagination = PageResponse.fromJSON(object.pagination); + return obj; + }, + toJSON(message: GetValidatorSetByHeightResponse): JsonSafe { + const obj: any = {}; + message.blockHeight !== undefined && (obj.blockHeight = (message.blockHeight || BigInt(0)).toString()); + if (message.validators) { + obj.validators = message.validators.map(e => e ? Validator.toJSON(e) : undefined); + } else { + obj.validators = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): GetValidatorSetByHeightResponse { + const message = createBaseGetValidatorSetByHeightResponse(); + if (object.blockHeight !== undefined && object.blockHeight !== null) { + message.blockHeight = BigInt(object.blockHeight.toString()); + } + message.validators = object.validators?.map(e => Validator.fromPartial(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: GetValidatorSetByHeightResponseSDKType): GetValidatorSetByHeightResponse { + return { + blockHeight: object?.block_height, + validators: Array.isArray(object?.validators) ? object.validators.map((e: any) => Validator.fromSDK(e)) : [], + pagination: object.pagination ? PageResponse.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): GetValidatorSetByHeightResponseSDKType { + return { + block_height: isSet(object.block_height) ? BigInt(object.block_height.toString()) : BigInt(0), + validators: Array.isArray(object?.validators) ? object.validators.map((e: any) => Validator.fromSDKJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: GetValidatorSetByHeightResponse): GetValidatorSetByHeightResponseSDKType { + const obj: any = {}; + obj.block_height = message.blockHeight; + if (message.validators) { + obj.validators = message.validators.map(e => e ? Validator.toSDK(e) : undefined); + } else { + obj.validators = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: GetValidatorSetByHeightResponseAmino): GetValidatorSetByHeightResponse { + const message = createBaseGetValidatorSetByHeightResponse(); + if (object.block_height !== undefined && object.block_height !== null) { + message.blockHeight = BigInt(object.block_height); + } + message.validators = object.validators?.map(e => Validator.fromAmino(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: GetValidatorSetByHeightResponse): GetValidatorSetByHeightResponseAmino { + const obj: any = {}; + obj.block_height = message.blockHeight !== BigInt(0) ? message.blockHeight?.toString() : undefined; + if (message.validators) { + obj.validators = message.validators.map(e => e ? Validator.toAmino(e) : undefined); + } else { + obj.validators = message.validators; + } + obj.pagination = message.pagination ? PageResponse.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: GetValidatorSetByHeightResponseAminoMsg): GetValidatorSetByHeightResponse { + return GetValidatorSetByHeightResponse.fromAmino(object.value); + }, + toAminoMsg(message: GetValidatorSetByHeightResponse): GetValidatorSetByHeightResponseAminoMsg { + return { + type: "cosmos-sdk/GetValidatorSetByHeightResponse", + value: GetValidatorSetByHeightResponse.toAmino(message) + }; + }, + fromProtoMsg(message: GetValidatorSetByHeightResponseProtoMsg): GetValidatorSetByHeightResponse { + return GetValidatorSetByHeightResponse.decode(message.value); + }, + toProto(message: GetValidatorSetByHeightResponse): Uint8Array { + return GetValidatorSetByHeightResponse.encode(message).finish(); + }, + toProtoMsg(message: GetValidatorSetByHeightResponse): GetValidatorSetByHeightResponseProtoMsg { + return { + typeUrl: "/cosmos.base.tendermint.v1beta1.GetValidatorSetByHeightResponse", + value: GetValidatorSetByHeightResponse.encode(message).finish() + }; + } +}; +function createBaseGetLatestValidatorSetRequest(): GetLatestValidatorSetRequest { + return { + pagination: undefined + }; +} +export const GetLatestValidatorSetRequest = { + typeUrl: "/cosmos.base.tendermint.v1beta1.GetLatestValidatorSetRequest", + encode(message: GetLatestValidatorSetRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GetLatestValidatorSetRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGetLatestValidatorSetRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GetLatestValidatorSetRequest { + const obj = createBaseGetLatestValidatorSetRequest(); + if (isSet(object.pagination)) obj.pagination = PageRequest.fromJSON(object.pagination); + return obj; + }, + toJSON(message: GetLatestValidatorSetRequest): JsonSafe { + const obj: any = {}; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): GetLatestValidatorSetRequest { + const message = createBaseGetLatestValidatorSetRequest(); + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: GetLatestValidatorSetRequestSDKType): GetLatestValidatorSetRequest { + return { + pagination: object.pagination ? PageRequest.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): GetLatestValidatorSetRequestSDKType { + return { + pagination: isSet(object.pagination) ? PageRequest.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: GetLatestValidatorSetRequest): GetLatestValidatorSetRequestSDKType { + const obj: any = {}; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: GetLatestValidatorSetRequestAmino): GetLatestValidatorSetRequest { + const message = createBaseGetLatestValidatorSetRequest(); + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: GetLatestValidatorSetRequest): GetLatestValidatorSetRequestAmino { + const obj: any = {}; + obj.pagination = message.pagination ? PageRequest.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: GetLatestValidatorSetRequestAminoMsg): GetLatestValidatorSetRequest { + return GetLatestValidatorSetRequest.fromAmino(object.value); + }, + toAminoMsg(message: GetLatestValidatorSetRequest): GetLatestValidatorSetRequestAminoMsg { + return { + type: "cosmos-sdk/GetLatestValidatorSetRequest", + value: GetLatestValidatorSetRequest.toAmino(message) + }; + }, + fromProtoMsg(message: GetLatestValidatorSetRequestProtoMsg): GetLatestValidatorSetRequest { + return GetLatestValidatorSetRequest.decode(message.value); + }, + toProto(message: GetLatestValidatorSetRequest): Uint8Array { + return GetLatestValidatorSetRequest.encode(message).finish(); + }, + toProtoMsg(message: GetLatestValidatorSetRequest): GetLatestValidatorSetRequestProtoMsg { + return { + typeUrl: "/cosmos.base.tendermint.v1beta1.GetLatestValidatorSetRequest", + value: GetLatestValidatorSetRequest.encode(message).finish() + }; + } +}; +function createBaseGetLatestValidatorSetResponse(): GetLatestValidatorSetResponse { + return { + blockHeight: BigInt(0), + validators: [], + pagination: undefined + }; +} +export const GetLatestValidatorSetResponse = { + typeUrl: "/cosmos.base.tendermint.v1beta1.GetLatestValidatorSetResponse", + encode(message: GetLatestValidatorSetResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.blockHeight !== undefined) { + writer.uint32(8).int64(message.blockHeight); + } + for (const v of message.validators) { + Validator.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GetLatestValidatorSetResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGetLatestValidatorSetResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.blockHeight = reader.int64(); + break; + case 2: + message.validators.push(Validator.decode(reader, reader.uint32())); + break; + case 3: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GetLatestValidatorSetResponse { + const obj = createBaseGetLatestValidatorSetResponse(); + if (isSet(object.blockHeight)) obj.blockHeight = BigInt(object.blockHeight.toString()); + if (Array.isArray(object?.validators)) obj.validators = object.validators.map((e: any) => Validator.fromJSON(e)); + if (isSet(object.pagination)) obj.pagination = PageResponse.fromJSON(object.pagination); + return obj; + }, + toJSON(message: GetLatestValidatorSetResponse): JsonSafe { + const obj: any = {}; + message.blockHeight !== undefined && (obj.blockHeight = (message.blockHeight || BigInt(0)).toString()); + if (message.validators) { + obj.validators = message.validators.map(e => e ? Validator.toJSON(e) : undefined); + } else { + obj.validators = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): GetLatestValidatorSetResponse { + const message = createBaseGetLatestValidatorSetResponse(); + if (object.blockHeight !== undefined && object.blockHeight !== null) { + message.blockHeight = BigInt(object.blockHeight.toString()); + } + message.validators = object.validators?.map(e => Validator.fromPartial(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: GetLatestValidatorSetResponseSDKType): GetLatestValidatorSetResponse { + return { + blockHeight: object?.block_height, + validators: Array.isArray(object?.validators) ? object.validators.map((e: any) => Validator.fromSDK(e)) : [], + pagination: object.pagination ? PageResponse.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): GetLatestValidatorSetResponseSDKType { + return { + block_height: isSet(object.block_height) ? BigInt(object.block_height.toString()) : BigInt(0), + validators: Array.isArray(object?.validators) ? object.validators.map((e: any) => Validator.fromSDKJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: GetLatestValidatorSetResponse): GetLatestValidatorSetResponseSDKType { + const obj: any = {}; + obj.block_height = message.blockHeight; + if (message.validators) { + obj.validators = message.validators.map(e => e ? Validator.toSDK(e) : undefined); + } else { + obj.validators = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: GetLatestValidatorSetResponseAmino): GetLatestValidatorSetResponse { + const message = createBaseGetLatestValidatorSetResponse(); + if (object.block_height !== undefined && object.block_height !== null) { + message.blockHeight = BigInt(object.block_height); + } + message.validators = object.validators?.map(e => Validator.fromAmino(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: GetLatestValidatorSetResponse): GetLatestValidatorSetResponseAmino { + const obj: any = {}; + obj.block_height = message.blockHeight !== BigInt(0) ? message.blockHeight?.toString() : undefined; + if (message.validators) { + obj.validators = message.validators.map(e => e ? Validator.toAmino(e) : undefined); + } else { + obj.validators = message.validators; + } + obj.pagination = message.pagination ? PageResponse.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: GetLatestValidatorSetResponseAminoMsg): GetLatestValidatorSetResponse { + return GetLatestValidatorSetResponse.fromAmino(object.value); + }, + toAminoMsg(message: GetLatestValidatorSetResponse): GetLatestValidatorSetResponseAminoMsg { + return { + type: "cosmos-sdk/GetLatestValidatorSetResponse", + value: GetLatestValidatorSetResponse.toAmino(message) + }; + }, + fromProtoMsg(message: GetLatestValidatorSetResponseProtoMsg): GetLatestValidatorSetResponse { + return GetLatestValidatorSetResponse.decode(message.value); + }, + toProto(message: GetLatestValidatorSetResponse): Uint8Array { + return GetLatestValidatorSetResponse.encode(message).finish(); + }, + toProtoMsg(message: GetLatestValidatorSetResponse): GetLatestValidatorSetResponseProtoMsg { + return { + typeUrl: "/cosmos.base.tendermint.v1beta1.GetLatestValidatorSetResponse", + value: GetLatestValidatorSetResponse.encode(message).finish() + }; + } +}; +function createBaseValidator(): Validator { + return { + address: "", + pubKey: undefined, + votingPower: BigInt(0), + proposerPriority: BigInt(0) + }; +} +export const Validator = { + typeUrl: "/cosmos.base.tendermint.v1beta1.Validator", + encode(message: Validator, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.address !== undefined) { + writer.uint32(10).string(message.address); + } + if (message.pubKey !== undefined) { + Any.encode(message.pubKey, writer.uint32(18).fork()).ldelim(); + } + if (message.votingPower !== undefined) { + writer.uint32(24).int64(message.votingPower); + } + if (message.proposerPriority !== undefined) { + writer.uint32(32).int64(message.proposerPriority); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Validator { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseValidator(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.string(); + break; + case 2: + message.pubKey = Any.decode(reader, reader.uint32()); + break; + case 3: + message.votingPower = reader.int64(); + break; + case 4: + message.proposerPriority = reader.int64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Validator { + const obj = createBaseValidator(); + if (isSet(object.address)) obj.address = String(object.address); + if (isSet(object.pubKey)) obj.pubKey = Any.fromJSON(object.pubKey); + if (isSet(object.votingPower)) obj.votingPower = BigInt(object.votingPower.toString()); + if (isSet(object.proposerPriority)) obj.proposerPriority = BigInt(object.proposerPriority.toString()); + return obj; + }, + toJSON(message: Validator): JsonSafe { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + message.pubKey !== undefined && (obj.pubKey = message.pubKey ? Any.toJSON(message.pubKey) : undefined); + message.votingPower !== undefined && (obj.votingPower = (message.votingPower || BigInt(0)).toString()); + message.proposerPriority !== undefined && (obj.proposerPriority = (message.proposerPriority || BigInt(0)).toString()); + return obj; + }, + fromPartial(object: DeepPartial): Validator { + const message = createBaseValidator(); + message.address = object.address ?? ""; + if (object.pubKey !== undefined && object.pubKey !== null) { + message.pubKey = Any.fromPartial(object.pubKey); + } + if (object.votingPower !== undefined && object.votingPower !== null) { + message.votingPower = BigInt(object.votingPower.toString()); + } + if (object.proposerPriority !== undefined && object.proposerPriority !== null) { + message.proposerPriority = BigInt(object.proposerPriority.toString()); + } + return message; + }, + fromSDK(object: ValidatorSDKType): Validator { + return { + address: object?.address, + pubKey: object.pub_key ? Any.fromSDK(object.pub_key) : undefined, + votingPower: object?.voting_power, + proposerPriority: object?.proposer_priority + }; + }, + fromSDKJSON(object: any): ValidatorSDKType { + return { + address: isSet(object.address) ? String(object.address) : "", + pub_key: isSet(object.pub_key) ? Any.fromSDKJSON(object.pub_key) : undefined, + voting_power: isSet(object.voting_power) ? BigInt(object.voting_power.toString()) : BigInt(0), + proposer_priority: isSet(object.proposer_priority) ? BigInt(object.proposer_priority.toString()) : BigInt(0) + }; + }, + toSDK(message: Validator): ValidatorSDKType { + const obj: any = {}; + obj.address = message.address; + message.pubKey !== undefined && (obj.pub_key = message.pubKey ? Any.toSDK(message.pubKey) : undefined); + obj.voting_power = message.votingPower; + obj.proposer_priority = message.proposerPriority; + return obj; + }, + fromAmino(object: ValidatorAmino): Validator { + const message = createBaseValidator(); + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } + if (object.pub_key !== undefined && object.pub_key !== null) { + message.pubKey = Any.fromAmino(object.pub_key); + } + if (object.voting_power !== undefined && object.voting_power !== null) { + message.votingPower = BigInt(object.voting_power); + } + if (object.proposer_priority !== undefined && object.proposer_priority !== null) { + message.proposerPriority = BigInt(object.proposer_priority); + } + return message; + }, + toAmino(message: Validator): ValidatorAmino { + const obj: any = {}; + obj.address = message.address === "" ? undefined : message.address; + obj.pub_key = message.pubKey ? Any.toAmino(message.pubKey) : undefined; + obj.voting_power = message.votingPower !== BigInt(0) ? message.votingPower?.toString() : undefined; + obj.proposer_priority = message.proposerPriority !== BigInt(0) ? message.proposerPriority?.toString() : undefined; + return obj; + }, + fromAminoMsg(object: ValidatorAminoMsg): Validator { + return Validator.fromAmino(object.value); + }, + toAminoMsg(message: Validator): ValidatorAminoMsg { + return { + type: "cosmos-sdk/Validator", + value: Validator.toAmino(message) + }; + }, + fromProtoMsg(message: ValidatorProtoMsg): Validator { + return Validator.decode(message.value); + }, + toProto(message: Validator): Uint8Array { + return Validator.encode(message).finish(); + }, + toProtoMsg(message: Validator): ValidatorProtoMsg { + return { + typeUrl: "/cosmos.base.tendermint.v1beta1.Validator", + value: Validator.encode(message).finish() + }; + } +}; +function createBaseGetBlockByHeightRequest(): GetBlockByHeightRequest { + return { + height: BigInt(0) + }; +} +export const GetBlockByHeightRequest = { + typeUrl: "/cosmos.base.tendermint.v1beta1.GetBlockByHeightRequest", + encode(message: GetBlockByHeightRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.height !== undefined) { + writer.uint32(8).int64(message.height); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GetBlockByHeightRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGetBlockByHeightRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.height = reader.int64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GetBlockByHeightRequest { + const obj = createBaseGetBlockByHeightRequest(); + if (isSet(object.height)) obj.height = BigInt(object.height.toString()); + return obj; + }, + toJSON(message: GetBlockByHeightRequest): JsonSafe { + const obj: any = {}; + message.height !== undefined && (obj.height = (message.height || BigInt(0)).toString()); + return obj; + }, + fromPartial(object: DeepPartial): GetBlockByHeightRequest { + const message = createBaseGetBlockByHeightRequest(); + if (object.height !== undefined && object.height !== null) { + message.height = BigInt(object.height.toString()); + } + return message; + }, + fromSDK(object: GetBlockByHeightRequestSDKType): GetBlockByHeightRequest { + return { + height: object?.height + }; + }, + fromSDKJSON(object: any): GetBlockByHeightRequestSDKType { + return { + height: isSet(object.height) ? BigInt(object.height.toString()) : BigInt(0) + }; + }, + toSDK(message: GetBlockByHeightRequest): GetBlockByHeightRequestSDKType { + const obj: any = {}; + obj.height = message.height; + return obj; + }, + fromAmino(object: GetBlockByHeightRequestAmino): GetBlockByHeightRequest { + const message = createBaseGetBlockByHeightRequest(); + if (object.height !== undefined && object.height !== null) { + message.height = BigInt(object.height); + } + return message; + }, + toAmino(message: GetBlockByHeightRequest): GetBlockByHeightRequestAmino { + const obj: any = {}; + obj.height = message.height !== BigInt(0) ? message.height?.toString() : undefined; + return obj; + }, + fromAminoMsg(object: GetBlockByHeightRequestAminoMsg): GetBlockByHeightRequest { + return GetBlockByHeightRequest.fromAmino(object.value); + }, + toAminoMsg(message: GetBlockByHeightRequest): GetBlockByHeightRequestAminoMsg { + return { + type: "cosmos-sdk/GetBlockByHeightRequest", + value: GetBlockByHeightRequest.toAmino(message) + }; + }, + fromProtoMsg(message: GetBlockByHeightRequestProtoMsg): GetBlockByHeightRequest { + return GetBlockByHeightRequest.decode(message.value); + }, + toProto(message: GetBlockByHeightRequest): Uint8Array { + return GetBlockByHeightRequest.encode(message).finish(); + }, + toProtoMsg(message: GetBlockByHeightRequest): GetBlockByHeightRequestProtoMsg { + return { + typeUrl: "/cosmos.base.tendermint.v1beta1.GetBlockByHeightRequest", + value: GetBlockByHeightRequest.encode(message).finish() + }; + } +}; +function createBaseGetBlockByHeightResponse(): GetBlockByHeightResponse { + return { + blockId: undefined, + block: undefined + }; +} +export const GetBlockByHeightResponse = { + typeUrl: "/cosmos.base.tendermint.v1beta1.GetBlockByHeightResponse", + encode(message: GetBlockByHeightResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.blockId !== undefined) { + BlockID.encode(message.blockId, writer.uint32(10).fork()).ldelim(); + } + if (message.block !== undefined) { + Block.encode(message.block, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GetBlockByHeightResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGetBlockByHeightResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.blockId = BlockID.decode(reader, reader.uint32()); + break; + case 2: + message.block = Block.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GetBlockByHeightResponse { + const obj = createBaseGetBlockByHeightResponse(); + if (isSet(object.blockId)) obj.blockId = BlockID.fromJSON(object.blockId); + if (isSet(object.block)) obj.block = Block.fromJSON(object.block); + return obj; + }, + toJSON(message: GetBlockByHeightResponse): JsonSafe { + const obj: any = {}; + message.blockId !== undefined && (obj.blockId = message.blockId ? BlockID.toJSON(message.blockId) : undefined); + message.block !== undefined && (obj.block = message.block ? Block.toJSON(message.block) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): GetBlockByHeightResponse { + const message = createBaseGetBlockByHeightResponse(); + if (object.blockId !== undefined && object.blockId !== null) { + message.blockId = BlockID.fromPartial(object.blockId); + } + if (object.block !== undefined && object.block !== null) { + message.block = Block.fromPartial(object.block); + } + return message; + }, + fromSDK(object: GetBlockByHeightResponseSDKType): GetBlockByHeightResponse { + return { + blockId: object.block_id ? BlockID.fromSDK(object.block_id) : undefined, + block: object.block ? Block.fromSDK(object.block) : undefined + }; + }, + fromSDKJSON(object: any): GetBlockByHeightResponseSDKType { + return { + block_id: isSet(object.block_id) ? BlockID.fromSDKJSON(object.block_id) : undefined, + block: isSet(object.block) ? Block.fromSDKJSON(object.block) : undefined + }; + }, + toSDK(message: GetBlockByHeightResponse): GetBlockByHeightResponseSDKType { + const obj: any = {}; + message.blockId !== undefined && (obj.block_id = message.blockId ? BlockID.toSDK(message.blockId) : undefined); + message.block !== undefined && (obj.block = message.block ? Block.toSDK(message.block) : undefined); + return obj; + }, + fromAmino(object: GetBlockByHeightResponseAmino): GetBlockByHeightResponse { + const message = createBaseGetBlockByHeightResponse(); + if (object.block_id !== undefined && object.block_id !== null) { + message.blockId = BlockID.fromAmino(object.block_id); + } + if (object.block !== undefined && object.block !== null) { + message.block = Block.fromAmino(object.block); + } + return message; + }, + toAmino(message: GetBlockByHeightResponse): GetBlockByHeightResponseAmino { + const obj: any = {}; + obj.block_id = message.blockId ? BlockID.toAmino(message.blockId) : undefined; + obj.block = message.block ? Block.toAmino(message.block) : undefined; + return obj; + }, + fromAminoMsg(object: GetBlockByHeightResponseAminoMsg): GetBlockByHeightResponse { + return GetBlockByHeightResponse.fromAmino(object.value); + }, + toAminoMsg(message: GetBlockByHeightResponse): GetBlockByHeightResponseAminoMsg { + return { + type: "cosmos-sdk/GetBlockByHeightResponse", + value: GetBlockByHeightResponse.toAmino(message) + }; + }, + fromProtoMsg(message: GetBlockByHeightResponseProtoMsg): GetBlockByHeightResponse { + return GetBlockByHeightResponse.decode(message.value); + }, + toProto(message: GetBlockByHeightResponse): Uint8Array { + return GetBlockByHeightResponse.encode(message).finish(); + }, + toProtoMsg(message: GetBlockByHeightResponse): GetBlockByHeightResponseProtoMsg { + return { + typeUrl: "/cosmos.base.tendermint.v1beta1.GetBlockByHeightResponse", + value: GetBlockByHeightResponse.encode(message).finish() + }; + } +}; +function createBaseGetLatestBlockRequest(): GetLatestBlockRequest { + return {}; +} +export const GetLatestBlockRequest = { + typeUrl: "/cosmos.base.tendermint.v1beta1.GetLatestBlockRequest", + encode(_: GetLatestBlockRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GetLatestBlockRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGetLatestBlockRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): GetLatestBlockRequest { + const obj = createBaseGetLatestBlockRequest(); + return obj; + }, + toJSON(_: GetLatestBlockRequest): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): GetLatestBlockRequest { + const message = createBaseGetLatestBlockRequest(); + return message; + }, + fromSDK(_: GetLatestBlockRequestSDKType): GetLatestBlockRequest { + return {}; + }, + fromSDKJSON(_: any): GetLatestBlockRequestSDKType { + return {}; + }, + toSDK(_: GetLatestBlockRequest): GetLatestBlockRequestSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: GetLatestBlockRequestAmino): GetLatestBlockRequest { + const message = createBaseGetLatestBlockRequest(); + return message; + }, + toAmino(_: GetLatestBlockRequest): GetLatestBlockRequestAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: GetLatestBlockRequestAminoMsg): GetLatestBlockRequest { + return GetLatestBlockRequest.fromAmino(object.value); + }, + toAminoMsg(message: GetLatestBlockRequest): GetLatestBlockRequestAminoMsg { + return { + type: "cosmos-sdk/GetLatestBlockRequest", + value: GetLatestBlockRequest.toAmino(message) + }; + }, + fromProtoMsg(message: GetLatestBlockRequestProtoMsg): GetLatestBlockRequest { + return GetLatestBlockRequest.decode(message.value); + }, + toProto(message: GetLatestBlockRequest): Uint8Array { + return GetLatestBlockRequest.encode(message).finish(); + }, + toProtoMsg(message: GetLatestBlockRequest): GetLatestBlockRequestProtoMsg { + return { + typeUrl: "/cosmos.base.tendermint.v1beta1.GetLatestBlockRequest", + value: GetLatestBlockRequest.encode(message).finish() + }; + } +}; +function createBaseGetLatestBlockResponse(): GetLatestBlockResponse { + return { + blockId: undefined, + block: undefined + }; +} +export const GetLatestBlockResponse = { + typeUrl: "/cosmos.base.tendermint.v1beta1.GetLatestBlockResponse", + encode(message: GetLatestBlockResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.blockId !== undefined) { + BlockID.encode(message.blockId, writer.uint32(10).fork()).ldelim(); + } + if (message.block !== undefined) { + Block.encode(message.block, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GetLatestBlockResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGetLatestBlockResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.blockId = BlockID.decode(reader, reader.uint32()); + break; + case 2: + message.block = Block.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GetLatestBlockResponse { + const obj = createBaseGetLatestBlockResponse(); + if (isSet(object.blockId)) obj.blockId = BlockID.fromJSON(object.blockId); + if (isSet(object.block)) obj.block = Block.fromJSON(object.block); + return obj; + }, + toJSON(message: GetLatestBlockResponse): JsonSafe { + const obj: any = {}; + message.blockId !== undefined && (obj.blockId = message.blockId ? BlockID.toJSON(message.blockId) : undefined); + message.block !== undefined && (obj.block = message.block ? Block.toJSON(message.block) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): GetLatestBlockResponse { + const message = createBaseGetLatestBlockResponse(); + if (object.blockId !== undefined && object.blockId !== null) { + message.blockId = BlockID.fromPartial(object.blockId); + } + if (object.block !== undefined && object.block !== null) { + message.block = Block.fromPartial(object.block); + } + return message; + }, + fromSDK(object: GetLatestBlockResponseSDKType): GetLatestBlockResponse { + return { + blockId: object.block_id ? BlockID.fromSDK(object.block_id) : undefined, + block: object.block ? Block.fromSDK(object.block) : undefined + }; + }, + fromSDKJSON(object: any): GetLatestBlockResponseSDKType { + return { + block_id: isSet(object.block_id) ? BlockID.fromSDKJSON(object.block_id) : undefined, + block: isSet(object.block) ? Block.fromSDKJSON(object.block) : undefined + }; + }, + toSDK(message: GetLatestBlockResponse): GetLatestBlockResponseSDKType { + const obj: any = {}; + message.blockId !== undefined && (obj.block_id = message.blockId ? BlockID.toSDK(message.blockId) : undefined); + message.block !== undefined && (obj.block = message.block ? Block.toSDK(message.block) : undefined); + return obj; + }, + fromAmino(object: GetLatestBlockResponseAmino): GetLatestBlockResponse { + const message = createBaseGetLatestBlockResponse(); + if (object.block_id !== undefined && object.block_id !== null) { + message.blockId = BlockID.fromAmino(object.block_id); + } + if (object.block !== undefined && object.block !== null) { + message.block = Block.fromAmino(object.block); + } + return message; + }, + toAmino(message: GetLatestBlockResponse): GetLatestBlockResponseAmino { + const obj: any = {}; + obj.block_id = message.blockId ? BlockID.toAmino(message.blockId) : undefined; + obj.block = message.block ? Block.toAmino(message.block) : undefined; + return obj; + }, + fromAminoMsg(object: GetLatestBlockResponseAminoMsg): GetLatestBlockResponse { + return GetLatestBlockResponse.fromAmino(object.value); + }, + toAminoMsg(message: GetLatestBlockResponse): GetLatestBlockResponseAminoMsg { + return { + type: "cosmos-sdk/GetLatestBlockResponse", + value: GetLatestBlockResponse.toAmino(message) + }; + }, + fromProtoMsg(message: GetLatestBlockResponseProtoMsg): GetLatestBlockResponse { + return GetLatestBlockResponse.decode(message.value); + }, + toProto(message: GetLatestBlockResponse): Uint8Array { + return GetLatestBlockResponse.encode(message).finish(); + }, + toProtoMsg(message: GetLatestBlockResponse): GetLatestBlockResponseProtoMsg { + return { + typeUrl: "/cosmos.base.tendermint.v1beta1.GetLatestBlockResponse", + value: GetLatestBlockResponse.encode(message).finish() + }; + } +}; +function createBaseGetSyncingRequest(): GetSyncingRequest { + return {}; +} +export const GetSyncingRequest = { + typeUrl: "/cosmos.base.tendermint.v1beta1.GetSyncingRequest", + encode(_: GetSyncingRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GetSyncingRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGetSyncingRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): GetSyncingRequest { + const obj = createBaseGetSyncingRequest(); + return obj; + }, + toJSON(_: GetSyncingRequest): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): GetSyncingRequest { + const message = createBaseGetSyncingRequest(); + return message; + }, + fromSDK(_: GetSyncingRequestSDKType): GetSyncingRequest { + return {}; + }, + fromSDKJSON(_: any): GetSyncingRequestSDKType { + return {}; + }, + toSDK(_: GetSyncingRequest): GetSyncingRequestSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: GetSyncingRequestAmino): GetSyncingRequest { + const message = createBaseGetSyncingRequest(); + return message; + }, + toAmino(_: GetSyncingRequest): GetSyncingRequestAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: GetSyncingRequestAminoMsg): GetSyncingRequest { + return GetSyncingRequest.fromAmino(object.value); + }, + toAminoMsg(message: GetSyncingRequest): GetSyncingRequestAminoMsg { + return { + type: "cosmos-sdk/GetSyncingRequest", + value: GetSyncingRequest.toAmino(message) + }; + }, + fromProtoMsg(message: GetSyncingRequestProtoMsg): GetSyncingRequest { + return GetSyncingRequest.decode(message.value); + }, + toProto(message: GetSyncingRequest): Uint8Array { + return GetSyncingRequest.encode(message).finish(); + }, + toProtoMsg(message: GetSyncingRequest): GetSyncingRequestProtoMsg { + return { + typeUrl: "/cosmos.base.tendermint.v1beta1.GetSyncingRequest", + value: GetSyncingRequest.encode(message).finish() + }; + } +}; +function createBaseGetSyncingResponse(): GetSyncingResponse { + return { + syncing: false + }; +} +export const GetSyncingResponse = { + typeUrl: "/cosmos.base.tendermint.v1beta1.GetSyncingResponse", + encode(message: GetSyncingResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.syncing !== undefined) { + writer.uint32(8).bool(message.syncing); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GetSyncingResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGetSyncingResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.syncing = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GetSyncingResponse { + const obj = createBaseGetSyncingResponse(); + if (isSet(object.syncing)) obj.syncing = Boolean(object.syncing); + return obj; + }, + toJSON(message: GetSyncingResponse): JsonSafe { + const obj: any = {}; + message.syncing !== undefined && (obj.syncing = message.syncing); + return obj; + }, + fromPartial(object: DeepPartial): GetSyncingResponse { + const message = createBaseGetSyncingResponse(); + message.syncing = object.syncing ?? false; + return message; + }, + fromSDK(object: GetSyncingResponseSDKType): GetSyncingResponse { + return { + syncing: object?.syncing + }; + }, + fromSDKJSON(object: any): GetSyncingResponseSDKType { + return { + syncing: isSet(object.syncing) ? Boolean(object.syncing) : false + }; + }, + toSDK(message: GetSyncingResponse): GetSyncingResponseSDKType { + const obj: any = {}; + obj.syncing = message.syncing; + return obj; + }, + fromAmino(object: GetSyncingResponseAmino): GetSyncingResponse { + const message = createBaseGetSyncingResponse(); + if (object.syncing !== undefined && object.syncing !== null) { + message.syncing = object.syncing; + } + return message; + }, + toAmino(message: GetSyncingResponse): GetSyncingResponseAmino { + const obj: any = {}; + obj.syncing = message.syncing === false ? undefined : message.syncing; + return obj; + }, + fromAminoMsg(object: GetSyncingResponseAminoMsg): GetSyncingResponse { + return GetSyncingResponse.fromAmino(object.value); + }, + toAminoMsg(message: GetSyncingResponse): GetSyncingResponseAminoMsg { + return { + type: "cosmos-sdk/GetSyncingResponse", + value: GetSyncingResponse.toAmino(message) + }; + }, + fromProtoMsg(message: GetSyncingResponseProtoMsg): GetSyncingResponse { + return GetSyncingResponse.decode(message.value); + }, + toProto(message: GetSyncingResponse): Uint8Array { + return GetSyncingResponse.encode(message).finish(); + }, + toProtoMsg(message: GetSyncingResponse): GetSyncingResponseProtoMsg { + return { + typeUrl: "/cosmos.base.tendermint.v1beta1.GetSyncingResponse", + value: GetSyncingResponse.encode(message).finish() + }; + } +}; +function createBaseGetNodeInfoRequest(): GetNodeInfoRequest { + return {}; +} +export const GetNodeInfoRequest = { + typeUrl: "/cosmos.base.tendermint.v1beta1.GetNodeInfoRequest", + encode(_: GetNodeInfoRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GetNodeInfoRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGetNodeInfoRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): GetNodeInfoRequest { + const obj = createBaseGetNodeInfoRequest(); + return obj; + }, + toJSON(_: GetNodeInfoRequest): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): GetNodeInfoRequest { + const message = createBaseGetNodeInfoRequest(); + return message; + }, + fromSDK(_: GetNodeInfoRequestSDKType): GetNodeInfoRequest { + return {}; + }, + fromSDKJSON(_: any): GetNodeInfoRequestSDKType { + return {}; + }, + toSDK(_: GetNodeInfoRequest): GetNodeInfoRequestSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: GetNodeInfoRequestAmino): GetNodeInfoRequest { + const message = createBaseGetNodeInfoRequest(); + return message; + }, + toAmino(_: GetNodeInfoRequest): GetNodeInfoRequestAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: GetNodeInfoRequestAminoMsg): GetNodeInfoRequest { + return GetNodeInfoRequest.fromAmino(object.value); + }, + toAminoMsg(message: GetNodeInfoRequest): GetNodeInfoRequestAminoMsg { + return { + type: "cosmos-sdk/GetNodeInfoRequest", + value: GetNodeInfoRequest.toAmino(message) + }; + }, + fromProtoMsg(message: GetNodeInfoRequestProtoMsg): GetNodeInfoRequest { + return GetNodeInfoRequest.decode(message.value); + }, + toProto(message: GetNodeInfoRequest): Uint8Array { + return GetNodeInfoRequest.encode(message).finish(); + }, + toProtoMsg(message: GetNodeInfoRequest): GetNodeInfoRequestProtoMsg { + return { + typeUrl: "/cosmos.base.tendermint.v1beta1.GetNodeInfoRequest", + value: GetNodeInfoRequest.encode(message).finish() + }; + } +}; +function createBaseGetNodeInfoResponse(): GetNodeInfoResponse { + return { + nodeInfo: undefined, + applicationVersion: undefined + }; +} +export const GetNodeInfoResponse = { + typeUrl: "/cosmos.base.tendermint.v1beta1.GetNodeInfoResponse", + encode(message: GetNodeInfoResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.nodeInfo !== undefined) { + NodeInfo.encode(message.nodeInfo, writer.uint32(10).fork()).ldelim(); + } + if (message.applicationVersion !== undefined) { + VersionInfo.encode(message.applicationVersion, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GetNodeInfoResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGetNodeInfoResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.nodeInfo = NodeInfo.decode(reader, reader.uint32()); + break; + case 2: + message.applicationVersion = VersionInfo.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GetNodeInfoResponse { + const obj = createBaseGetNodeInfoResponse(); + if (isSet(object.nodeInfo)) obj.nodeInfo = NodeInfo.fromJSON(object.nodeInfo); + if (isSet(object.applicationVersion)) obj.applicationVersion = VersionInfo.fromJSON(object.applicationVersion); + return obj; + }, + toJSON(message: GetNodeInfoResponse): JsonSafe { + const obj: any = {}; + message.nodeInfo !== undefined && (obj.nodeInfo = message.nodeInfo ? NodeInfo.toJSON(message.nodeInfo) : undefined); + message.applicationVersion !== undefined && (obj.applicationVersion = message.applicationVersion ? VersionInfo.toJSON(message.applicationVersion) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): GetNodeInfoResponse { + const message = createBaseGetNodeInfoResponse(); + if (object.nodeInfo !== undefined && object.nodeInfo !== null) { + message.nodeInfo = NodeInfo.fromPartial(object.nodeInfo); + } + if (object.applicationVersion !== undefined && object.applicationVersion !== null) { + message.applicationVersion = VersionInfo.fromPartial(object.applicationVersion); + } + return message; + }, + fromSDK(object: GetNodeInfoResponseSDKType): GetNodeInfoResponse { + return { + nodeInfo: object.node_info ? NodeInfo.fromSDK(object.node_info) : undefined, + applicationVersion: object.application_version ? VersionInfo.fromSDK(object.application_version) : undefined + }; + }, + fromSDKJSON(object: any): GetNodeInfoResponseSDKType { + return { + node_info: isSet(object.node_info) ? NodeInfo.fromSDKJSON(object.node_info) : undefined, + application_version: isSet(object.application_version) ? VersionInfo.fromSDKJSON(object.application_version) : undefined + }; + }, + toSDK(message: GetNodeInfoResponse): GetNodeInfoResponseSDKType { + const obj: any = {}; + message.nodeInfo !== undefined && (obj.node_info = message.nodeInfo ? NodeInfo.toSDK(message.nodeInfo) : undefined); + message.applicationVersion !== undefined && (obj.application_version = message.applicationVersion ? VersionInfo.toSDK(message.applicationVersion) : undefined); + return obj; + }, + fromAmino(object: GetNodeInfoResponseAmino): GetNodeInfoResponse { + const message = createBaseGetNodeInfoResponse(); + if (object.node_info !== undefined && object.node_info !== null) { + message.nodeInfo = NodeInfo.fromAmino(object.node_info); + } + if (object.application_version !== undefined && object.application_version !== null) { + message.applicationVersion = VersionInfo.fromAmino(object.application_version); + } + return message; + }, + toAmino(message: GetNodeInfoResponse): GetNodeInfoResponseAmino { + const obj: any = {}; + obj.node_info = message.nodeInfo ? NodeInfo.toAmino(message.nodeInfo) : undefined; + obj.application_version = message.applicationVersion ? VersionInfo.toAmino(message.applicationVersion) : undefined; + return obj; + }, + fromAminoMsg(object: GetNodeInfoResponseAminoMsg): GetNodeInfoResponse { + return GetNodeInfoResponse.fromAmino(object.value); + }, + toAminoMsg(message: GetNodeInfoResponse): GetNodeInfoResponseAminoMsg { + return { + type: "cosmos-sdk/GetNodeInfoResponse", + value: GetNodeInfoResponse.toAmino(message) + }; + }, + fromProtoMsg(message: GetNodeInfoResponseProtoMsg): GetNodeInfoResponse { + return GetNodeInfoResponse.decode(message.value); + }, + toProto(message: GetNodeInfoResponse): Uint8Array { + return GetNodeInfoResponse.encode(message).finish(); + }, + toProtoMsg(message: GetNodeInfoResponse): GetNodeInfoResponseProtoMsg { + return { + typeUrl: "/cosmos.base.tendermint.v1beta1.GetNodeInfoResponse", + value: GetNodeInfoResponse.encode(message).finish() + }; + } +}; +function createBaseVersionInfo(): VersionInfo { + return { + name: "", + appName: "", + version: "", + gitCommit: "", + buildTags: "", + goVersion: "", + buildDeps: [], + cosmosSdkVersion: "" + }; +} +export const VersionInfo = { + typeUrl: "/cosmos.base.tendermint.v1beta1.VersionInfo", + encode(message: VersionInfo, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + if (message.appName !== undefined) { + writer.uint32(18).string(message.appName); + } + if (message.version !== undefined) { + writer.uint32(26).string(message.version); + } + if (message.gitCommit !== undefined) { + writer.uint32(34).string(message.gitCommit); + } + if (message.buildTags !== undefined) { + writer.uint32(42).string(message.buildTags); + } + if (message.goVersion !== undefined) { + writer.uint32(50).string(message.goVersion); + } + for (const v of message.buildDeps) { + Module.encode(v!, writer.uint32(58).fork()).ldelim(); + } + if (message.cosmosSdkVersion !== undefined) { + writer.uint32(66).string(message.cosmosSdkVersion); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): VersionInfo { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseVersionInfo(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.appName = reader.string(); + break; + case 3: + message.version = reader.string(); + break; + case 4: + message.gitCommit = reader.string(); + break; + case 5: + message.buildTags = reader.string(); + break; + case 6: + message.goVersion = reader.string(); + break; + case 7: + message.buildDeps.push(Module.decode(reader, reader.uint32())); + break; + case 8: + message.cosmosSdkVersion = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): VersionInfo { + const obj = createBaseVersionInfo(); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.appName)) obj.appName = String(object.appName); + if (isSet(object.version)) obj.version = String(object.version); + if (isSet(object.gitCommit)) obj.gitCommit = String(object.gitCommit); + if (isSet(object.buildTags)) obj.buildTags = String(object.buildTags); + if (isSet(object.goVersion)) obj.goVersion = String(object.goVersion); + if (Array.isArray(object?.buildDeps)) obj.buildDeps = object.buildDeps.map((e: any) => Module.fromJSON(e)); + if (isSet(object.cosmosSdkVersion)) obj.cosmosSdkVersion = String(object.cosmosSdkVersion); + return obj; + }, + toJSON(message: VersionInfo): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.appName !== undefined && (obj.appName = message.appName); + message.version !== undefined && (obj.version = message.version); + message.gitCommit !== undefined && (obj.gitCommit = message.gitCommit); + message.buildTags !== undefined && (obj.buildTags = message.buildTags); + message.goVersion !== undefined && (obj.goVersion = message.goVersion); + if (message.buildDeps) { + obj.buildDeps = message.buildDeps.map(e => e ? Module.toJSON(e) : undefined); + } else { + obj.buildDeps = []; + } + message.cosmosSdkVersion !== undefined && (obj.cosmosSdkVersion = message.cosmosSdkVersion); + return obj; + }, + fromPartial(object: DeepPartial): VersionInfo { + const message = createBaseVersionInfo(); + message.name = object.name ?? ""; + message.appName = object.appName ?? ""; + message.version = object.version ?? ""; + message.gitCommit = object.gitCommit ?? ""; + message.buildTags = object.buildTags ?? ""; + message.goVersion = object.goVersion ?? ""; + message.buildDeps = object.buildDeps?.map(e => Module.fromPartial(e)) || []; + message.cosmosSdkVersion = object.cosmosSdkVersion ?? ""; + return message; + }, + fromSDK(object: VersionInfoSDKType): VersionInfo { + return { + name: object?.name, + appName: object?.app_name, + version: object?.version, + gitCommit: object?.git_commit, + buildTags: object?.build_tags, + goVersion: object?.go_version, + buildDeps: Array.isArray(object?.build_deps) ? object.build_deps.map((e: any) => Module.fromSDK(e)) : [], + cosmosSdkVersion: object?.cosmos_sdk_version + }; + }, + fromSDKJSON(object: any): VersionInfoSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + app_name: isSet(object.app_name) ? String(object.app_name) : "", + version: isSet(object.version) ? String(object.version) : "", + git_commit: isSet(object.git_commit) ? String(object.git_commit) : "", + build_tags: isSet(object.build_tags) ? String(object.build_tags) : "", + go_version: isSet(object.go_version) ? String(object.go_version) : "", + build_deps: Array.isArray(object?.build_deps) ? object.build_deps.map((e: any) => Module.fromSDKJSON(e)) : [], + cosmos_sdk_version: isSet(object.cosmos_sdk_version) ? String(object.cosmos_sdk_version) : "" + }; + }, + toSDK(message: VersionInfo): VersionInfoSDKType { + const obj: any = {}; + obj.name = message.name; + obj.app_name = message.appName; + obj.version = message.version; + obj.git_commit = message.gitCommit; + obj.build_tags = message.buildTags; + obj.go_version = message.goVersion; + if (message.buildDeps) { + obj.build_deps = message.buildDeps.map(e => e ? Module.toSDK(e) : undefined); + } else { + obj.build_deps = []; + } + obj.cosmos_sdk_version = message.cosmosSdkVersion; + return obj; + }, + fromAmino(object: VersionInfoAmino): VersionInfo { + const message = createBaseVersionInfo(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + if (object.app_name !== undefined && object.app_name !== null) { + message.appName = object.app_name; + } + if (object.version !== undefined && object.version !== null) { + message.version = object.version; + } + if (object.git_commit !== undefined && object.git_commit !== null) { + message.gitCommit = object.git_commit; + } + if (object.build_tags !== undefined && object.build_tags !== null) { + message.buildTags = object.build_tags; + } + if (object.go_version !== undefined && object.go_version !== null) { + message.goVersion = object.go_version; + } + message.buildDeps = object.build_deps?.map(e => Module.fromAmino(e)) || []; + if (object.cosmos_sdk_version !== undefined && object.cosmos_sdk_version !== null) { + message.cosmosSdkVersion = object.cosmos_sdk_version; + } + return message; + }, + toAmino(message: VersionInfo): VersionInfoAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + obj.app_name = message.appName === "" ? undefined : message.appName; + obj.version = message.version === "" ? undefined : message.version; + obj.git_commit = message.gitCommit === "" ? undefined : message.gitCommit; + obj.build_tags = message.buildTags === "" ? undefined : message.buildTags; + obj.go_version = message.goVersion === "" ? undefined : message.goVersion; + if (message.buildDeps) { + obj.build_deps = message.buildDeps.map(e => e ? Module.toAmino(e) : undefined); + } else { + obj.build_deps = message.buildDeps; + } + obj.cosmos_sdk_version = message.cosmosSdkVersion === "" ? undefined : message.cosmosSdkVersion; + return obj; + }, + fromAminoMsg(object: VersionInfoAminoMsg): VersionInfo { + return VersionInfo.fromAmino(object.value); + }, + toAminoMsg(message: VersionInfo): VersionInfoAminoMsg { + return { + type: "cosmos-sdk/VersionInfo", + value: VersionInfo.toAmino(message) + }; + }, + fromProtoMsg(message: VersionInfoProtoMsg): VersionInfo { + return VersionInfo.decode(message.value); + }, + toProto(message: VersionInfo): Uint8Array { + return VersionInfo.encode(message).finish(); + }, + toProtoMsg(message: VersionInfo): VersionInfoProtoMsg { + return { + typeUrl: "/cosmos.base.tendermint.v1beta1.VersionInfo", + value: VersionInfo.encode(message).finish() + }; + } +}; +function createBaseModule(): Module { + return { + path: "", + version: "", + sum: "" + }; +} +export const Module = { + typeUrl: "/cosmos.base.tendermint.v1beta1.Module", + encode(message: Module, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.path !== undefined) { + writer.uint32(10).string(message.path); + } + if (message.version !== undefined) { + writer.uint32(18).string(message.version); + } + if (message.sum !== undefined) { + writer.uint32(26).string(message.sum); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Module { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseModule(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.path = reader.string(); + break; + case 2: + message.version = reader.string(); + break; + case 3: + message.sum = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Module { + const obj = createBaseModule(); + if (isSet(object.path)) obj.path = String(object.path); + if (isSet(object.version)) obj.version = String(object.version); + if (isSet(object.sum)) obj.sum = String(object.sum); + return obj; + }, + toJSON(message: Module): JsonSafe { + const obj: any = {}; + message.path !== undefined && (obj.path = message.path); + message.version !== undefined && (obj.version = message.version); + message.sum !== undefined && (obj.sum = message.sum); + return obj; + }, + fromPartial(object: DeepPartial): Module { + const message = createBaseModule(); + message.path = object.path ?? ""; + message.version = object.version ?? ""; + message.sum = object.sum ?? ""; + return message; + }, + fromSDK(object: ModuleSDKType): Module { + return { + path: object?.path, + version: object?.version, + sum: object?.sum + }; + }, + fromSDKJSON(object: any): ModuleSDKType { + return { + path: isSet(object.path) ? String(object.path) : "", + version: isSet(object.version) ? String(object.version) : "", + sum: isSet(object.sum) ? String(object.sum) : "" + }; + }, + toSDK(message: Module): ModuleSDKType { + const obj: any = {}; + obj.path = message.path; + obj.version = message.version; + obj.sum = message.sum; + return obj; + }, + fromAmino(object: ModuleAmino): Module { + const message = createBaseModule(); + if (object.path !== undefined && object.path !== null) { + message.path = object.path; + } + if (object.version !== undefined && object.version !== null) { + message.version = object.version; + } + if (object.sum !== undefined && object.sum !== null) { + message.sum = object.sum; + } + return message; + }, + toAmino(message: Module): ModuleAmino { + const obj: any = {}; + obj.path = message.path === "" ? undefined : message.path; + obj.version = message.version === "" ? undefined : message.version; + obj.sum = message.sum === "" ? undefined : message.sum; + return obj; + }, + fromAminoMsg(object: ModuleAminoMsg): Module { + return Module.fromAmino(object.value); + }, + toAminoMsg(message: Module): ModuleAminoMsg { + return { + type: "cosmos-sdk/Module", + value: Module.toAmino(message) + }; + }, + fromProtoMsg(message: ModuleProtoMsg): Module { + return Module.decode(message.value); + }, + toProto(message: Module): Uint8Array { + return Module.encode(message).finish(); + }, + toProtoMsg(message: Module): ModuleProtoMsg { + return { + typeUrl: "/cosmos.base.tendermint.v1beta1.Module", + value: Module.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/base/v1beta1/coin.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/base/v1beta1/coin.ts new file mode 100644 index 0000000000..407c9ff584 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/base/v1beta1/coin.ts @@ -0,0 +1,486 @@ +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "cosmos.base.v1beta1"; +/** + * Coin defines a token with a denomination and an amount. + * + * NOTE: The amount field is an Int which implements the custom method + * signatures required by gogoproto. + */ +export interface Coin { + denom: string; + amount: string; +} +export interface CoinProtoMsg { + typeUrl: "/cosmos.base.v1beta1.Coin"; + value: Uint8Array; +} +/** + * Coin defines a token with a denomination and an amount. + * + * NOTE: The amount field is an Int which implements the custom method + * signatures required by gogoproto. + */ +export interface CoinSDKType { + denom: string; + amount: string; +} +/** + * DecCoin defines a token with a denomination and a decimal amount. + * + * NOTE: The amount field is an Dec which implements the custom method + * signatures required by gogoproto. + */ +export interface DecCoin { + denom: string; + amount: string; +} +export interface DecCoinProtoMsg { + typeUrl: "/cosmos.base.v1beta1.DecCoin"; + value: Uint8Array; +} +/** + * DecCoin defines a token with a denomination and a decimal amount. + * + * NOTE: The amount field is an Dec which implements the custom method + * signatures required by gogoproto. + */ +export interface DecCoinSDKType { + denom: string; + amount: string; +} +/** IntProto defines a Protobuf wrapper around an Int object. */ +export interface IntProto { + int: string; +} +export interface IntProtoProtoMsg { + typeUrl: "/cosmos.base.v1beta1.IntProto"; + value: Uint8Array; +} +/** IntProto defines a Protobuf wrapper around an Int object. */ +export interface IntProtoSDKType { + int: string; +} +/** DecProto defines a Protobuf wrapper around a Dec object. */ +export interface DecProto { + dec: string; +} +export interface DecProtoProtoMsg { + typeUrl: "/cosmos.base.v1beta1.DecProto"; + value: Uint8Array; +} +/** DecProto defines a Protobuf wrapper around a Dec object. */ +export interface DecProtoSDKType { + dec: string; +} +function createBaseCoin(): Coin { + return { + denom: "", + amount: "" + }; +} +export const Coin = { + typeUrl: "/cosmos.base.v1beta1.Coin", + encode(message: Coin, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.denom !== undefined) { + writer.uint32(10).string(message.denom); + } + if (message.amount !== undefined) { + writer.uint32(18).string(message.amount); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Coin { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCoin(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.denom = reader.string(); + break; + case 2: + message.amount = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Coin { + const obj = createBaseCoin(); + if (isSet(object.denom)) obj.denom = String(object.denom); + if (isSet(object.amount)) obj.amount = String(object.amount); + return obj; + }, + toJSON(message: Coin): JsonSafe { + const obj: any = {}; + message.denom !== undefined && (obj.denom = message.denom); + message.amount !== undefined && (obj.amount = message.amount); + return obj; + }, + fromPartial(object: DeepPartial): Coin { + const message = createBaseCoin(); + message.denom = object.denom ?? ""; + message.amount = object.amount ?? ""; + return message; + }, + fromSDK(object: CoinSDKType): Coin { + return { + denom: object?.denom, + amount: object?.amount + }; + }, + fromSDKJSON(object: any): CoinSDKType { + return { + denom: isSet(object.denom) ? String(object.denom) : "", + amount: isSet(object.amount) ? String(object.amount) : "" + }; + }, + toSDK(message: Coin): CoinSDKType { + const obj: any = {}; + obj.denom = message.denom; + obj.amount = message.amount; + return obj; + }, + fromAmino(object: CoinAmino): Coin { + const message = createBaseCoin(); + if (object.denom !== undefined && object.denom !== null) { + message.denom = object.denom; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = object.amount; + } + return message; + }, + toAmino(message: Coin): CoinAmino { + const obj: any = {}; + obj.denom = message.denom === "" ? undefined : message.denom; + obj.amount = message.amount === "" ? undefined : message.amount; + return obj; + }, + fromAminoMsg(object: CoinAminoMsg): Coin { + return Coin.fromAmino(object.value); + }, + toAminoMsg(message: Coin): CoinAminoMsg { + return { + type: "cosmos-sdk/Coin", + value: Coin.toAmino(message) + }; + }, + fromProtoMsg(message: CoinProtoMsg): Coin { + return Coin.decode(message.value); + }, + toProto(message: Coin): Uint8Array { + return Coin.encode(message).finish(); + }, + toProtoMsg(message: Coin): CoinProtoMsg { + return { + typeUrl: "/cosmos.base.v1beta1.Coin", + value: Coin.encode(message).finish() + }; + } +}; +function createBaseDecCoin(): DecCoin { + return { + denom: "", + amount: "" + }; +} +export const DecCoin = { + typeUrl: "/cosmos.base.v1beta1.DecCoin", + encode(message: DecCoin, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.denom !== undefined) { + writer.uint32(10).string(message.denom); + } + if (message.amount !== undefined) { + writer.uint32(18).string(message.amount); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): DecCoin { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDecCoin(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.denom = reader.string(); + break; + case 2: + message.amount = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): DecCoin { + const obj = createBaseDecCoin(); + if (isSet(object.denom)) obj.denom = String(object.denom); + if (isSet(object.amount)) obj.amount = String(object.amount); + return obj; + }, + toJSON(message: DecCoin): JsonSafe { + const obj: any = {}; + message.denom !== undefined && (obj.denom = message.denom); + message.amount !== undefined && (obj.amount = message.amount); + return obj; + }, + fromPartial(object: DeepPartial): DecCoin { + const message = createBaseDecCoin(); + message.denom = object.denom ?? ""; + message.amount = object.amount ?? ""; + return message; + }, + fromSDK(object: DecCoinSDKType): DecCoin { + return { + denom: object?.denom, + amount: object?.amount + }; + }, + fromSDKJSON(object: any): DecCoinSDKType { + return { + denom: isSet(object.denom) ? String(object.denom) : "", + amount: isSet(object.amount) ? String(object.amount) : "" + }; + }, + toSDK(message: DecCoin): DecCoinSDKType { + const obj: any = {}; + obj.denom = message.denom; + obj.amount = message.amount; + return obj; + }, + fromAmino(object: DecCoinAmino): DecCoin { + const message = createBaseDecCoin(); + if (object.denom !== undefined && object.denom !== null) { + message.denom = object.denom; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = object.amount; + } + return message; + }, + toAmino(message: DecCoin): DecCoinAmino { + const obj: any = {}; + obj.denom = message.denom === "" ? undefined : message.denom; + obj.amount = message.amount === "" ? undefined : message.amount; + return obj; + }, + fromAminoMsg(object: DecCoinAminoMsg): DecCoin { + return DecCoin.fromAmino(object.value); + }, + toAminoMsg(message: DecCoin): DecCoinAminoMsg { + return { + type: "cosmos-sdk/DecCoin", + value: DecCoin.toAmino(message) + }; + }, + fromProtoMsg(message: DecCoinProtoMsg): DecCoin { + return DecCoin.decode(message.value); + }, + toProto(message: DecCoin): Uint8Array { + return DecCoin.encode(message).finish(); + }, + toProtoMsg(message: DecCoin): DecCoinProtoMsg { + return { + typeUrl: "/cosmos.base.v1beta1.DecCoin", + value: DecCoin.encode(message).finish() + }; + } +}; +function createBaseIntProto(): IntProto { + return { + int: "" + }; +} +export const IntProto = { + typeUrl: "/cosmos.base.v1beta1.IntProto", + encode(message: IntProto, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.int !== undefined) { + writer.uint32(10).string(message.int); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): IntProto { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseIntProto(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.int = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): IntProto { + const obj = createBaseIntProto(); + if (isSet(object.int)) obj.int = String(object.int); + return obj; + }, + toJSON(message: IntProto): JsonSafe { + const obj: any = {}; + message.int !== undefined && (obj.int = message.int); + return obj; + }, + fromPartial(object: DeepPartial): IntProto { + const message = createBaseIntProto(); + message.int = object.int ?? ""; + return message; + }, + fromSDK(object: IntProtoSDKType): IntProto { + return { + int: object?.int + }; + }, + fromSDKJSON(object: any): IntProtoSDKType { + return { + int: isSet(object.int) ? String(object.int) : "" + }; + }, + toSDK(message: IntProto): IntProtoSDKType { + const obj: any = {}; + obj.int = message.int; + return obj; + }, + fromAmino(object: IntProtoAmino): IntProto { + const message = createBaseIntProto(); + if (object.int !== undefined && object.int !== null) { + message.int = object.int; + } + return message; + }, + toAmino(message: IntProto): IntProtoAmino { + const obj: any = {}; + obj.int = message.int === "" ? undefined : message.int; + return obj; + }, + fromAminoMsg(object: IntProtoAminoMsg): IntProto { + return IntProto.fromAmino(object.value); + }, + toAminoMsg(message: IntProto): IntProtoAminoMsg { + return { + type: "cosmos-sdk/IntProto", + value: IntProto.toAmino(message) + }; + }, + fromProtoMsg(message: IntProtoProtoMsg): IntProto { + return IntProto.decode(message.value); + }, + toProto(message: IntProto): Uint8Array { + return IntProto.encode(message).finish(); + }, + toProtoMsg(message: IntProto): IntProtoProtoMsg { + return { + typeUrl: "/cosmos.base.v1beta1.IntProto", + value: IntProto.encode(message).finish() + }; + } +}; +function createBaseDecProto(): DecProto { + return { + dec: "" + }; +} +export const DecProto = { + typeUrl: "/cosmos.base.v1beta1.DecProto", + encode(message: DecProto, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.dec !== undefined) { + writer.uint32(10).string(message.dec); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): DecProto { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDecProto(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.dec = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): DecProto { + const obj = createBaseDecProto(); + if (isSet(object.dec)) obj.dec = String(object.dec); + return obj; + }, + toJSON(message: DecProto): JsonSafe { + const obj: any = {}; + message.dec !== undefined && (obj.dec = message.dec); + return obj; + }, + fromPartial(object: DeepPartial): DecProto { + const message = createBaseDecProto(); + message.dec = object.dec ?? ""; + return message; + }, + fromSDK(object: DecProtoSDKType): DecProto { + return { + dec: object?.dec + }; + }, + fromSDKJSON(object: any): DecProtoSDKType { + return { + dec: isSet(object.dec) ? String(object.dec) : "" + }; + }, + toSDK(message: DecProto): DecProtoSDKType { + const obj: any = {}; + obj.dec = message.dec; + return obj; + }, + fromAmino(object: DecProtoAmino): DecProto { + const message = createBaseDecProto(); + if (object.dec !== undefined && object.dec !== null) { + message.dec = object.dec; + } + return message; + }, + toAmino(message: DecProto): DecProtoAmino { + const obj: any = {}; + obj.dec = message.dec === "" ? undefined : message.dec; + return obj; + }, + fromAminoMsg(object: DecProtoAminoMsg): DecProto { + return DecProto.fromAmino(object.value); + }, + toAminoMsg(message: DecProto): DecProtoAminoMsg { + return { + type: "cosmos-sdk/DecProto", + value: DecProto.toAmino(message) + }; + }, + fromProtoMsg(message: DecProtoProtoMsg): DecProto { + return DecProto.decode(message.value); + }, + toProto(message: DecProto): Uint8Array { + return DecProto.encode(message).finish(); + }, + toProtoMsg(message: DecProto): DecProtoProtoMsg { + return { + typeUrl: "/cosmos.base.v1beta1.DecProto", + value: DecProto.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/bundle.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/bundle.ts new file mode 100644 index 0000000000..99a745f8a0 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/bundle.ts @@ -0,0 +1,512 @@ +import * as _55 from "./app/v1alpha1/config.js"; +import * as _56 from "./app/v1alpha1/module.js"; +import * as _57 from "./app/v1alpha1/query.js"; +import * as _58 from "./auth/v1beta1/auth.js"; +import * as _59 from "./auth/v1beta1/genesis.js"; +import * as _60 from "./auth/v1beta1/query.js"; +import * as _61 from "./authz/v1beta1/authz.js"; +import * as _62 from "./authz/v1beta1/genesis.js"; +import * as _63 from "./authz/v1beta1/query.js"; +import * as _64 from "./authz/v1beta1/tx.js"; +import * as _65 from "./bank/v1beta1/authz.js"; +import * as _66 from "./bank/v1beta1/bank.js"; +import * as _67 from "./bank/v1beta1/genesis.js"; +import * as _68 from "./bank/v1beta1/query.js"; +import * as _69 from "./bank/v1beta1/tx.js"; +import * as _70 from "./base/abci/v1beta1/abci.js"; +import * as _71 from "./base/kv/v1beta1/kv.js"; +import * as _72 from "./base/query/v1beta1/pagination.js"; +import * as _73 from "./base/reflection/v1beta1/reflection.js"; +import * as _74 from "./base/reflection/v2alpha1/reflection.js"; +import * as _75 from "./base/snapshots/v1beta1/snapshot.js"; +import * as _76 from "./base/store/v1beta1/commit_info.js"; +import * as _77 from "./base/store/v1beta1/listening.js"; +import * as _78 from "./base/tendermint/v1beta1/query.js"; +import * as _79 from "./base/v1beta1/coin.js"; +import * as _80 from "./capability/v1beta1/capability.js"; +import * as _81 from "./capability/v1beta1/genesis.js"; +import * as _82 from "./crisis/v1beta1/genesis.js"; +import * as _83 from "./crisis/v1beta1/tx.js"; +import * as _84 from "./crypto/ed25519/keys.js"; +import * as _85 from "./crypto/hd/v1/hd.js"; +import * as _86 from "./crypto/keyring/v1/record.js"; +import * as _87 from "./crypto/multisig/keys.js"; +import * as _88 from "./crypto/secp256k1/keys.js"; +import * as _89 from "./crypto/secp256r1/keys.js"; +import * as _90 from "./distribution/v1beta1/distribution.js"; +import * as _91 from "./distribution/v1beta1/genesis.js"; +import * as _92 from "./distribution/v1beta1/query.js"; +import * as _93 from "./distribution/v1beta1/tx.js"; +import * as _94 from "./evidence/v1beta1/evidence.js"; +import * as _95 from "./evidence/v1beta1/genesis.js"; +import * as _96 from "./evidence/v1beta1/query.js"; +import * as _97 from "./evidence/v1beta1/tx.js"; +import * as _98 from "./feegrant/v1beta1/feegrant.js"; +import * as _99 from "./feegrant/v1beta1/genesis.js"; +import * as _100 from "./feegrant/v1beta1/query.js"; +import * as _101 from "./feegrant/v1beta1/tx.js"; +import * as _102 from "./genutil/v1beta1/genesis.js"; +import * as _103 from "./gov/v1/genesis.js"; +import * as _104 from "./gov/v1/gov.js"; +import * as _105 from "./gov/v1/query.js"; +import * as _106 from "./gov/v1/tx.js"; +import * as _107 from "./gov/v1beta1/genesis.js"; +import * as _108 from "./gov/v1beta1/gov.js"; +import * as _109 from "./gov/v1beta1/query.js"; +import * as _110 from "./gov/v1beta1/tx.js"; +import * as _111 from "./group/v1/events.js"; +import * as _112 from "./group/v1/genesis.js"; +import * as _113 from "./group/v1/query.js"; +import * as _114 from "./group/v1/tx.js"; +import * as _115 from "./group/v1/types.js"; +import * as _116 from "./mint/v1beta1/genesis.js"; +import * as _117 from "./mint/v1beta1/mint.js"; +import * as _118 from "./mint/v1beta1/query.js"; +import * as _119 from "./msg/v1/msg.js"; +import * as _120 from "./nft/v1beta1/event.js"; +import * as _121 from "./nft/v1beta1/genesis.js"; +import * as _122 from "./nft/v1beta1/nft.js"; +import * as _123 from "./nft/v1beta1/query.js"; +import * as _124 from "./nft/v1beta1/tx.js"; +import * as _125 from "./orm/module/v1alpha1/module.js"; +import * as _126 from "./orm/v1/orm.js"; +import * as _127 from "./orm/v1alpha1/schema.js"; +import * as _128 from "./params/v1beta1/params.js"; +import * as _129 from "./params/v1beta1/query.js"; +import * as _130 from "./slashing/v1beta1/genesis.js"; +import * as _131 from "./slashing/v1beta1/query.js"; +import * as _132 from "./slashing/v1beta1/slashing.js"; +import * as _133 from "./slashing/v1beta1/tx.js"; +import * as _134 from "./staking/v1beta1/authz.js"; +import * as _135 from "./staking/v1beta1/genesis.js"; +import * as _136 from "./staking/v1beta1/query.js"; +import * as _137 from "./staking/v1beta1/staking.js"; +import * as _138 from "./staking/v1beta1/tx.js"; +import * as _139 from "./tx/signing/v1beta1/signing.js"; +import * as _140 from "./tx/v1beta1/service.js"; +import * as _141 from "./tx/v1beta1/tx.js"; +import * as _142 from "./upgrade/v1beta1/query.js"; +import * as _143 from "./upgrade/v1beta1/tx.js"; +import * as _144 from "./upgrade/v1beta1/upgrade.js"; +import * as _145 from "./vesting/v1beta1/tx.js"; +import * as _146 from "./vesting/v1beta1/vesting.js"; +import * as _353 from "./authz/v1beta1/tx.amino.js"; +import * as _354 from "./bank/v1beta1/tx.amino.js"; +import * as _355 from "./crisis/v1beta1/tx.amino.js"; +import * as _356 from "./distribution/v1beta1/tx.amino.js"; +import * as _357 from "./evidence/v1beta1/tx.amino.js"; +import * as _358 from "./feegrant/v1beta1/tx.amino.js"; +import * as _359 from "./gov/v1/tx.amino.js"; +import * as _360 from "./gov/v1beta1/tx.amino.js"; +import * as _361 from "./group/v1/tx.amino.js"; +import * as _362 from "./nft/v1beta1/tx.amino.js"; +import * as _363 from "./slashing/v1beta1/tx.amino.js"; +import * as _364 from "./staking/v1beta1/tx.amino.js"; +import * as _365 from "./upgrade/v1beta1/tx.amino.js"; +import * as _366 from "./vesting/v1beta1/tx.amino.js"; +import * as _367 from "./authz/v1beta1/tx.registry.js"; +import * as _368 from "./bank/v1beta1/tx.registry.js"; +import * as _369 from "./crisis/v1beta1/tx.registry.js"; +import * as _370 from "./distribution/v1beta1/tx.registry.js"; +import * as _371 from "./evidence/v1beta1/tx.registry.js"; +import * as _372 from "./feegrant/v1beta1/tx.registry.js"; +import * as _373 from "./gov/v1/tx.registry.js"; +import * as _374 from "./gov/v1beta1/tx.registry.js"; +import * as _375 from "./group/v1/tx.registry.js"; +import * as _376 from "./nft/v1beta1/tx.registry.js"; +import * as _377 from "./slashing/v1beta1/tx.registry.js"; +import * as _378 from "./staking/v1beta1/tx.registry.js"; +import * as _379 from "./upgrade/v1beta1/tx.registry.js"; +import * as _380 from "./vesting/v1beta1/tx.registry.js"; +import * as _381 from "./auth/v1beta1/query.lcd.js"; +import * as _382 from "./authz/v1beta1/query.lcd.js"; +import * as _383 from "./bank/v1beta1/query.lcd.js"; +import * as _384 from "./base/reflection/v1beta1/reflection.lcd.js"; +import * as _385 from "./base/reflection/v2alpha1/reflection.lcd.js"; +import * as _386 from "./base/tendermint/v1beta1/query.lcd.js"; +import * as _387 from "./distribution/v1beta1/query.lcd.js"; +import * as _388 from "./evidence/v1beta1/query.lcd.js"; +import * as _389 from "./feegrant/v1beta1/query.lcd.js"; +import * as _390 from "./gov/v1/query.lcd.js"; +import * as _391 from "./gov/v1beta1/query.lcd.js"; +import * as _392 from "./group/v1/query.lcd.js"; +import * as _393 from "./mint/v1beta1/query.lcd.js"; +import * as _394 from "./nft/v1beta1/query.lcd.js"; +import * as _395 from "./params/v1beta1/query.lcd.js"; +import * as _396 from "./slashing/v1beta1/query.lcd.js"; +import * as _397 from "./staking/v1beta1/query.lcd.js"; +import * as _398 from "./tx/v1beta1/service.lcd.js"; +import * as _399 from "./upgrade/v1beta1/query.lcd.js"; +import * as _400 from "./app/v1alpha1/query.rpc.Query.js"; +import * as _401 from "./auth/v1beta1/query.rpc.Query.js"; +import * as _402 from "./authz/v1beta1/query.rpc.Query.js"; +import * as _403 from "./bank/v1beta1/query.rpc.Query.js"; +import * as _404 from "./base/reflection/v1beta1/reflection.rpc.ReflectionService.js"; +import * as _405 from "./base/reflection/v2alpha1/reflection.rpc.ReflectionService.js"; +import * as _406 from "./base/tendermint/v1beta1/query.rpc.Service.js"; +import * as _407 from "./distribution/v1beta1/query.rpc.Query.js"; +import * as _408 from "./evidence/v1beta1/query.rpc.Query.js"; +import * as _409 from "./feegrant/v1beta1/query.rpc.Query.js"; +import * as _410 from "./gov/v1/query.rpc.Query.js"; +import * as _411 from "./gov/v1beta1/query.rpc.Query.js"; +import * as _412 from "./group/v1/query.rpc.Query.js"; +import * as _413 from "./mint/v1beta1/query.rpc.Query.js"; +import * as _414 from "./nft/v1beta1/query.rpc.Query.js"; +import * as _415 from "./params/v1beta1/query.rpc.Query.js"; +import * as _416 from "./slashing/v1beta1/query.rpc.Query.js"; +import * as _417 from "./staking/v1beta1/query.rpc.Query.js"; +import * as _418 from "./tx/v1beta1/service.rpc.Service.js"; +import * as _419 from "./upgrade/v1beta1/query.rpc.Query.js"; +import * as _420 from "./authz/v1beta1/tx.rpc.msg.js"; +import * as _421 from "./bank/v1beta1/tx.rpc.msg.js"; +import * as _422 from "./crisis/v1beta1/tx.rpc.msg.js"; +import * as _423 from "./distribution/v1beta1/tx.rpc.msg.js"; +import * as _424 from "./evidence/v1beta1/tx.rpc.msg.js"; +import * as _425 from "./feegrant/v1beta1/tx.rpc.msg.js"; +import * as _426 from "./gov/v1/tx.rpc.msg.js"; +import * as _427 from "./gov/v1beta1/tx.rpc.msg.js"; +import * as _428 from "./group/v1/tx.rpc.msg.js"; +import * as _429 from "./nft/v1beta1/tx.rpc.msg.js"; +import * as _430 from "./slashing/v1beta1/tx.rpc.msg.js"; +import * as _431 from "./staking/v1beta1/tx.rpc.msg.js"; +import * as _432 from "./upgrade/v1beta1/tx.rpc.msg.js"; +import * as _433 from "./vesting/v1beta1/tx.rpc.msg.js"; +import * as _539 from "./lcd.js"; +import * as _540 from "./rpc.query.js"; +import * as _541 from "./cosmos-rpc-client.query.js"; +import * as _542 from "./rpc.tx.js"; +import * as _543 from "./cosmos-rpc-client.tx.js"; +export namespace cosmos { + export namespace app { + export const v1alpha1 = { + ..._55, + ..._56, + ..._57, + ..._400 + }; + } + export namespace auth { + export const v1beta1 = { + ..._58, + ..._59, + ..._60, + ..._381, + ..._401 + }; + } + export namespace authz { + export const v1beta1 = { + ..._61, + ..._62, + ..._63, + ..._64, + ..._353, + ..._367, + ..._382, + ..._402, + ..._420 + }; + } + export namespace bank { + export const v1beta1 = { + ..._65, + ..._66, + ..._67, + ..._68, + ..._69, + ..._354, + ..._368, + ..._383, + ..._403, + ..._421 + }; + } + export namespace base { + export namespace abci { + export const v1beta1 = { + ..._70 + }; + } + export namespace kv { + export const v1beta1 = { + ..._71 + }; + } + export namespace query { + export const v1beta1 = { + ..._72 + }; + } + export namespace reflection { + export const v1beta1 = { + ..._73, + ..._384, + ..._404 + }; + export const v2alpha1 = { + ..._74, + ..._385, + ..._405 + }; + } + export namespace snapshots { + export const v1beta1 = { + ..._75 + }; + } + export namespace store { + export const v1beta1 = { + ..._76, + ..._77 + }; + } + export namespace tendermint { + export const v1beta1 = { + ..._78, + ..._386, + ..._406 + }; + } + export const v1beta1 = { + ..._79 + }; + } + export namespace capability { + export const v1beta1 = { + ..._80, + ..._81 + }; + } + export namespace crisis { + export const v1beta1 = { + ..._82, + ..._83, + ..._355, + ..._369, + ..._422 + }; + } + export namespace crypto { + export const ed25519 = { + ..._84 + }; + export namespace hd { + export const v1 = { + ..._85 + }; + } + export namespace keyring { + export const v1 = { + ..._86 + }; + } + export const multisig = { + ..._87 + }; + export const secp256k1 = { + ..._88 + }; + export const secp256r1 = { + ..._89 + }; + } + export namespace distribution { + export const v1beta1 = { + ..._90, + ..._91, + ..._92, + ..._93, + ..._356, + ..._370, + ..._387, + ..._407, + ..._423 + }; + } + export namespace evidence { + export const v1beta1 = { + ..._94, + ..._95, + ..._96, + ..._97, + ..._357, + ..._371, + ..._388, + ..._408, + ..._424 + }; + } + export namespace feegrant { + export const v1beta1 = { + ..._98, + ..._99, + ..._100, + ..._101, + ..._358, + ..._372, + ..._389, + ..._409, + ..._425 + }; + } + export namespace genutil { + export const v1beta1 = { + ..._102 + }; + } + export namespace gov { + export const v1 = { + ..._103, + ..._104, + ..._105, + ..._106, + ..._359, + ..._373, + ..._390, + ..._410, + ..._426 + }; + export const v1beta1 = { + ..._107, + ..._108, + ..._109, + ..._110, + ..._360, + ..._374, + ..._391, + ..._411, + ..._427 + }; + } + export namespace group { + export const v1 = { + ..._111, + ..._112, + ..._113, + ..._114, + ..._115, + ..._361, + ..._375, + ..._392, + ..._412, + ..._428 + }; + } + export namespace mint { + export const v1beta1 = { + ..._116, + ..._117, + ..._118, + ..._393, + ..._413 + }; + } + export namespace msg { + export const v1 = { + ..._119 + }; + } + export namespace nft { + export const v1beta1 = { + ..._120, + ..._121, + ..._122, + ..._123, + ..._124, + ..._362, + ..._376, + ..._394, + ..._414, + ..._429 + }; + } + export namespace orm { + export namespace module { + export const v1alpha1 = { + ..._125 + }; + } + export const v1 = { + ..._126 + }; + export const v1alpha1 = { + ..._127 + }; + } + export namespace params { + export const v1beta1 = { + ..._128, + ..._129, + ..._395, + ..._415 + }; + } + export namespace slashing { + export const v1beta1 = { + ..._130, + ..._131, + ..._132, + ..._133, + ..._363, + ..._377, + ..._396, + ..._416, + ..._430 + }; + } + export namespace staking { + export const v1beta1 = { + ..._134, + ..._135, + ..._136, + ..._137, + ..._138, + ..._364, + ..._378, + ..._397, + ..._417, + ..._431 + }; + } + export namespace tx { + export namespace signing { + export const v1beta1 = { + ..._139 + }; + } + export const v1beta1 = { + ..._140, + ..._141, + ..._398, + ..._418 + }; + } + export namespace upgrade { + export const v1beta1 = { + ..._142, + ..._143, + ..._144, + ..._365, + ..._379, + ..._399, + ..._419, + ..._432 + }; + } + export namespace vesting { + export const v1beta1 = { + ..._145, + ..._146, + ..._366, + ..._380, + ..._433 + }; + } + export const ClientFactory = { + ..._539, + ..._540, + ..._541, + ..._542, + ..._543 + }; +} \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/capability/v1beta1/capability.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/capability/v1beta1/capability.ts new file mode 100644 index 0000000000..3fde99f58a --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/capability/v1beta1/capability.ts @@ -0,0 +1,371 @@ +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "cosmos.capability.v1beta1"; +/** + * Capability defines an implementation of an object capability. The index + * provided to a Capability must be globally unique. + */ +export interface Capability { + index: bigint; +} +export interface CapabilityProtoMsg { + typeUrl: "/cosmos.capability.v1beta1.Capability"; + value: Uint8Array; +} +/** + * Capability defines an implementation of an object capability. The index + * provided to a Capability must be globally unique. + */ +export interface CapabilitySDKType { + index: bigint; +} +/** + * Owner defines a single capability owner. An owner is defined by the name of + * capability and the module name. + */ +export interface Owner { + module: string; + name: string; +} +export interface OwnerProtoMsg { + typeUrl: "/cosmos.capability.v1beta1.Owner"; + value: Uint8Array; +} +/** + * Owner defines a single capability owner. An owner is defined by the name of + * capability and the module name. + */ +export interface OwnerSDKType { + module: string; + name: string; +} +/** + * CapabilityOwners defines a set of owners of a single Capability. The set of + * owners must be unique. + */ +export interface CapabilityOwners { + owners: Owner[]; +} +export interface CapabilityOwnersProtoMsg { + typeUrl: "/cosmos.capability.v1beta1.CapabilityOwners"; + value: Uint8Array; +} +/** + * CapabilityOwners defines a set of owners of a single Capability. The set of + * owners must be unique. + */ +export interface CapabilityOwnersSDKType { + owners: OwnerSDKType[]; +} +function createBaseCapability(): Capability { + return { + index: BigInt(0) + }; +} +export const Capability = { + typeUrl: "/cosmos.capability.v1beta1.Capability", + encode(message: Capability, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.index !== undefined) { + writer.uint32(8).uint64(message.index); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Capability { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCapability(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.index = reader.uint64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Capability { + const obj = createBaseCapability(); + if (isSet(object.index)) obj.index = BigInt(object.index.toString()); + return obj; + }, + toJSON(message: Capability): JsonSafe { + const obj: any = {}; + message.index !== undefined && (obj.index = (message.index || BigInt(0)).toString()); + return obj; + }, + fromPartial(object: DeepPartial): Capability { + const message = createBaseCapability(); + if (object.index !== undefined && object.index !== null) { + message.index = BigInt(object.index.toString()); + } + return message; + }, + fromSDK(object: CapabilitySDKType): Capability { + return { + index: object?.index + }; + }, + fromSDKJSON(object: any): CapabilitySDKType { + return { + index: isSet(object.index) ? BigInt(object.index.toString()) : BigInt(0) + }; + }, + toSDK(message: Capability): CapabilitySDKType { + const obj: any = {}; + obj.index = message.index; + return obj; + }, + fromAmino(object: CapabilityAmino): Capability { + const message = createBaseCapability(); + if (object.index !== undefined && object.index !== null) { + message.index = BigInt(object.index); + } + return message; + }, + toAmino(message: Capability): CapabilityAmino { + const obj: any = {}; + obj.index = message.index !== BigInt(0) ? message.index?.toString() : undefined; + return obj; + }, + fromAminoMsg(object: CapabilityAminoMsg): Capability { + return Capability.fromAmino(object.value); + }, + toAminoMsg(message: Capability): CapabilityAminoMsg { + return { + type: "cosmos-sdk/Capability", + value: Capability.toAmino(message) + }; + }, + fromProtoMsg(message: CapabilityProtoMsg): Capability { + return Capability.decode(message.value); + }, + toProto(message: Capability): Uint8Array { + return Capability.encode(message).finish(); + }, + toProtoMsg(message: Capability): CapabilityProtoMsg { + return { + typeUrl: "/cosmos.capability.v1beta1.Capability", + value: Capability.encode(message).finish() + }; + } +}; +function createBaseOwner(): Owner { + return { + module: "", + name: "" + }; +} +export const Owner = { + typeUrl: "/cosmos.capability.v1beta1.Owner", + encode(message: Owner, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.module !== undefined) { + writer.uint32(10).string(message.module); + } + if (message.name !== undefined) { + writer.uint32(18).string(message.name); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Owner { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseOwner(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.module = reader.string(); + break; + case 2: + message.name = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Owner { + const obj = createBaseOwner(); + if (isSet(object.module)) obj.module = String(object.module); + if (isSet(object.name)) obj.name = String(object.name); + return obj; + }, + toJSON(message: Owner): JsonSafe { + const obj: any = {}; + message.module !== undefined && (obj.module = message.module); + message.name !== undefined && (obj.name = message.name); + return obj; + }, + fromPartial(object: DeepPartial): Owner { + const message = createBaseOwner(); + message.module = object.module ?? ""; + message.name = object.name ?? ""; + return message; + }, + fromSDK(object: OwnerSDKType): Owner { + return { + module: object?.module, + name: object?.name + }; + }, + fromSDKJSON(object: any): OwnerSDKType { + return { + module: isSet(object.module) ? String(object.module) : "", + name: isSet(object.name) ? String(object.name) : "" + }; + }, + toSDK(message: Owner): OwnerSDKType { + const obj: any = {}; + obj.module = message.module; + obj.name = message.name; + return obj; + }, + fromAmino(object: OwnerAmino): Owner { + const message = createBaseOwner(); + if (object.module !== undefined && object.module !== null) { + message.module = object.module; + } + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + return message; + }, + toAmino(message: Owner): OwnerAmino { + const obj: any = {}; + obj.module = message.module === "" ? undefined : message.module; + obj.name = message.name === "" ? undefined : message.name; + return obj; + }, + fromAminoMsg(object: OwnerAminoMsg): Owner { + return Owner.fromAmino(object.value); + }, + toAminoMsg(message: Owner): OwnerAminoMsg { + return { + type: "cosmos-sdk/Owner", + value: Owner.toAmino(message) + }; + }, + fromProtoMsg(message: OwnerProtoMsg): Owner { + return Owner.decode(message.value); + }, + toProto(message: Owner): Uint8Array { + return Owner.encode(message).finish(); + }, + toProtoMsg(message: Owner): OwnerProtoMsg { + return { + typeUrl: "/cosmos.capability.v1beta1.Owner", + value: Owner.encode(message).finish() + }; + } +}; +function createBaseCapabilityOwners(): CapabilityOwners { + return { + owners: [] + }; +} +export const CapabilityOwners = { + typeUrl: "/cosmos.capability.v1beta1.CapabilityOwners", + encode(message: CapabilityOwners, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.owners) { + Owner.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): CapabilityOwners { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCapabilityOwners(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.owners.push(Owner.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): CapabilityOwners { + const obj = createBaseCapabilityOwners(); + if (Array.isArray(object?.owners)) obj.owners = object.owners.map((e: any) => Owner.fromJSON(e)); + return obj; + }, + toJSON(message: CapabilityOwners): JsonSafe { + const obj: any = {}; + if (message.owners) { + obj.owners = message.owners.map(e => e ? Owner.toJSON(e) : undefined); + } else { + obj.owners = []; + } + return obj; + }, + fromPartial(object: DeepPartial): CapabilityOwners { + const message = createBaseCapabilityOwners(); + message.owners = object.owners?.map(e => Owner.fromPartial(e)) || []; + return message; + }, + fromSDK(object: CapabilityOwnersSDKType): CapabilityOwners { + return { + owners: Array.isArray(object?.owners) ? object.owners.map((e: any) => Owner.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): CapabilityOwnersSDKType { + return { + owners: Array.isArray(object?.owners) ? object.owners.map((e: any) => Owner.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: CapabilityOwners): CapabilityOwnersSDKType { + const obj: any = {}; + if (message.owners) { + obj.owners = message.owners.map(e => e ? Owner.toSDK(e) : undefined); + } else { + obj.owners = []; + } + return obj; + }, + fromAmino(object: CapabilityOwnersAmino): CapabilityOwners { + const message = createBaseCapabilityOwners(); + message.owners = object.owners?.map(e => Owner.fromAmino(e)) || []; + return message; + }, + toAmino(message: CapabilityOwners): CapabilityOwnersAmino { + const obj: any = {}; + if (message.owners) { + obj.owners = message.owners.map(e => e ? Owner.toAmino(e) : undefined); + } else { + obj.owners = message.owners; + } + return obj; + }, + fromAminoMsg(object: CapabilityOwnersAminoMsg): CapabilityOwners { + return CapabilityOwners.fromAmino(object.value); + }, + toAminoMsg(message: CapabilityOwners): CapabilityOwnersAminoMsg { + return { + type: "cosmos-sdk/CapabilityOwners", + value: CapabilityOwners.toAmino(message) + }; + }, + fromProtoMsg(message: CapabilityOwnersProtoMsg): CapabilityOwners { + return CapabilityOwners.decode(message.value); + }, + toProto(message: CapabilityOwners): Uint8Array { + return CapabilityOwners.encode(message).finish(); + }, + toProtoMsg(message: CapabilityOwners): CapabilityOwnersProtoMsg { + return { + typeUrl: "/cosmos.capability.v1beta1.CapabilityOwners", + value: CapabilityOwners.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/capability/v1beta1/genesis.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/capability/v1beta1/genesis.ts new file mode 100644 index 0000000000..79d97d8f70 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/capability/v1beta1/genesis.ts @@ -0,0 +1,278 @@ +import { CapabilityOwners, CapabilityOwnersSDKType } from "./capability.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "cosmos.capability.v1beta1"; +/** GenesisOwners defines the capability owners with their corresponding index. */ +export interface GenesisOwners { + /** index is the index of the capability owner. */ + index: bigint; + /** index_owners are the owners at the given index. */ + indexOwners: CapabilityOwners; +} +export interface GenesisOwnersProtoMsg { + typeUrl: "/cosmos.capability.v1beta1.GenesisOwners"; + value: Uint8Array; +} +/** GenesisOwners defines the capability owners with their corresponding index. */ +export interface GenesisOwnersSDKType { + index: bigint; + index_owners: CapabilityOwnersSDKType; +} +/** GenesisState defines the capability module's genesis state. */ +export interface GenesisState { + /** index is the capability global index. */ + index: bigint; + /** + * owners represents a map from index to owners of the capability index + * index key is string to allow amino marshalling. + */ + owners: GenesisOwners[]; +} +export interface GenesisStateProtoMsg { + typeUrl: "/cosmos.capability.v1beta1.GenesisState"; + value: Uint8Array; +} +/** GenesisState defines the capability module's genesis state. */ +export interface GenesisStateSDKType { + index: bigint; + owners: GenesisOwnersSDKType[]; +} +function createBaseGenesisOwners(): GenesisOwners { + return { + index: BigInt(0), + indexOwners: CapabilityOwners.fromPartial({}) + }; +} +export const GenesisOwners = { + typeUrl: "/cosmos.capability.v1beta1.GenesisOwners", + encode(message: GenesisOwners, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.index !== undefined) { + writer.uint32(8).uint64(message.index); + } + if (message.indexOwners !== undefined) { + CapabilityOwners.encode(message.indexOwners, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GenesisOwners { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGenesisOwners(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.index = reader.uint64(); + break; + case 2: + message.indexOwners = CapabilityOwners.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GenesisOwners { + const obj = createBaseGenesisOwners(); + if (isSet(object.index)) obj.index = BigInt(object.index.toString()); + if (isSet(object.indexOwners)) obj.indexOwners = CapabilityOwners.fromJSON(object.indexOwners); + return obj; + }, + toJSON(message: GenesisOwners): JsonSafe { + const obj: any = {}; + message.index !== undefined && (obj.index = (message.index || BigInt(0)).toString()); + message.indexOwners !== undefined && (obj.indexOwners = message.indexOwners ? CapabilityOwners.toJSON(message.indexOwners) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): GenesisOwners { + const message = createBaseGenesisOwners(); + if (object.index !== undefined && object.index !== null) { + message.index = BigInt(object.index.toString()); + } + if (object.indexOwners !== undefined && object.indexOwners !== null) { + message.indexOwners = CapabilityOwners.fromPartial(object.indexOwners); + } + return message; + }, + fromSDK(object: GenesisOwnersSDKType): GenesisOwners { + return { + index: object?.index, + indexOwners: object.index_owners ? CapabilityOwners.fromSDK(object.index_owners) : undefined + }; + }, + fromSDKJSON(object: any): GenesisOwnersSDKType { + return { + index: isSet(object.index) ? BigInt(object.index.toString()) : BigInt(0), + index_owners: isSet(object.index_owners) ? CapabilityOwners.fromSDKJSON(object.index_owners) : undefined + }; + }, + toSDK(message: GenesisOwners): GenesisOwnersSDKType { + const obj: any = {}; + obj.index = message.index; + message.indexOwners !== undefined && (obj.index_owners = message.indexOwners ? CapabilityOwners.toSDK(message.indexOwners) : undefined); + return obj; + }, + fromAmino(object: GenesisOwnersAmino): GenesisOwners { + const message = createBaseGenesisOwners(); + if (object.index !== undefined && object.index !== null) { + message.index = BigInt(object.index); + } + if (object.index_owners !== undefined && object.index_owners !== null) { + message.indexOwners = CapabilityOwners.fromAmino(object.index_owners); + } + return message; + }, + toAmino(message: GenesisOwners): GenesisOwnersAmino { + const obj: any = {}; + obj.index = message.index !== BigInt(0) ? message.index?.toString() : undefined; + obj.index_owners = message.indexOwners ? CapabilityOwners.toAmino(message.indexOwners) : undefined; + return obj; + }, + fromAminoMsg(object: GenesisOwnersAminoMsg): GenesisOwners { + return GenesisOwners.fromAmino(object.value); + }, + toAminoMsg(message: GenesisOwners): GenesisOwnersAminoMsg { + return { + type: "cosmos-sdk/GenesisOwners", + value: GenesisOwners.toAmino(message) + }; + }, + fromProtoMsg(message: GenesisOwnersProtoMsg): GenesisOwners { + return GenesisOwners.decode(message.value); + }, + toProto(message: GenesisOwners): Uint8Array { + return GenesisOwners.encode(message).finish(); + }, + toProtoMsg(message: GenesisOwners): GenesisOwnersProtoMsg { + return { + typeUrl: "/cosmos.capability.v1beta1.GenesisOwners", + value: GenesisOwners.encode(message).finish() + }; + } +}; +function createBaseGenesisState(): GenesisState { + return { + index: BigInt(0), + owners: [] + }; +} +export const GenesisState = { + typeUrl: "/cosmos.capability.v1beta1.GenesisState", + encode(message: GenesisState, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.index !== undefined) { + writer.uint32(8).uint64(message.index); + } + for (const v of message.owners) { + GenesisOwners.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GenesisState { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGenesisState(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.index = reader.uint64(); + break; + case 2: + message.owners.push(GenesisOwners.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GenesisState { + const obj = createBaseGenesisState(); + if (isSet(object.index)) obj.index = BigInt(object.index.toString()); + if (Array.isArray(object?.owners)) obj.owners = object.owners.map((e: any) => GenesisOwners.fromJSON(e)); + return obj; + }, + toJSON(message: GenesisState): JsonSafe { + const obj: any = {}; + message.index !== undefined && (obj.index = (message.index || BigInt(0)).toString()); + if (message.owners) { + obj.owners = message.owners.map(e => e ? GenesisOwners.toJSON(e) : undefined); + } else { + obj.owners = []; + } + return obj; + }, + fromPartial(object: DeepPartial): GenesisState { + const message = createBaseGenesisState(); + if (object.index !== undefined && object.index !== null) { + message.index = BigInt(object.index.toString()); + } + message.owners = object.owners?.map(e => GenesisOwners.fromPartial(e)) || []; + return message; + }, + fromSDK(object: GenesisStateSDKType): GenesisState { + return { + index: object?.index, + owners: Array.isArray(object?.owners) ? object.owners.map((e: any) => GenesisOwners.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): GenesisStateSDKType { + return { + index: isSet(object.index) ? BigInt(object.index.toString()) : BigInt(0), + owners: Array.isArray(object?.owners) ? object.owners.map((e: any) => GenesisOwners.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: GenesisState): GenesisStateSDKType { + const obj: any = {}; + obj.index = message.index; + if (message.owners) { + obj.owners = message.owners.map(e => e ? GenesisOwners.toSDK(e) : undefined); + } else { + obj.owners = []; + } + return obj; + }, + fromAmino(object: GenesisStateAmino): GenesisState { + const message = createBaseGenesisState(); + if (object.index !== undefined && object.index !== null) { + message.index = BigInt(object.index); + } + message.owners = object.owners?.map(e => GenesisOwners.fromAmino(e)) || []; + return message; + }, + toAmino(message: GenesisState): GenesisStateAmino { + const obj: any = {}; + obj.index = message.index !== BigInt(0) ? message.index?.toString() : undefined; + if (message.owners) { + obj.owners = message.owners.map(e => e ? GenesisOwners.toAmino(e) : undefined); + } else { + obj.owners = message.owners; + } + return obj; + }, + fromAminoMsg(object: GenesisStateAminoMsg): GenesisState { + return GenesisState.fromAmino(object.value); + }, + toAminoMsg(message: GenesisState): GenesisStateAminoMsg { + return { + type: "cosmos-sdk/GenesisState", + value: GenesisState.toAmino(message) + }; + }, + fromProtoMsg(message: GenesisStateProtoMsg): GenesisState { + return GenesisState.decode(message.value); + }, + toProto(message: GenesisState): Uint8Array { + return GenesisState.encode(message).finish(); + }, + toProtoMsg(message: GenesisState): GenesisStateProtoMsg { + return { + typeUrl: "/cosmos.capability.v1beta1.GenesisState", + value: GenesisState.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/client.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/client.ts new file mode 100644 index 0000000000..d0d7602d75 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/client.ts @@ -0,0 +1,78 @@ +import { GeneratedType, Registry, OfflineSigner } from "@cosmjs/proto-signing"; +import { AminoTypes, SigningStargateClient } from "@cosmjs/stargate"; +import { HttpEndpoint } from "@cosmjs/tendermint-rpc"; +import * as cosmosAuthzV1beta1TxRegistry from "./authz/v1beta1/tx.registry.js"; +import * as cosmosBankV1beta1TxRegistry from "./bank/v1beta1/tx.registry.js"; +import * as cosmosCrisisV1beta1TxRegistry from "./crisis/v1beta1/tx.registry.js"; +import * as cosmosDistributionV1beta1TxRegistry from "./distribution/v1beta1/tx.registry.js"; +import * as cosmosEvidenceV1beta1TxRegistry from "./evidence/v1beta1/tx.registry.js"; +import * as cosmosFeegrantV1beta1TxRegistry from "./feegrant/v1beta1/tx.registry.js"; +import * as cosmosGovV1TxRegistry from "./gov/v1/tx.registry.js"; +import * as cosmosGovV1beta1TxRegistry from "./gov/v1beta1/tx.registry.js"; +import * as cosmosGroupV1TxRegistry from "./group/v1/tx.registry.js"; +import * as cosmosNftV1beta1TxRegistry from "./nft/v1beta1/tx.registry.js"; +import * as cosmosSlashingV1beta1TxRegistry from "./slashing/v1beta1/tx.registry.js"; +import * as cosmosStakingV1beta1TxRegistry from "./staking/v1beta1/tx.registry.js"; +import * as cosmosUpgradeV1beta1TxRegistry from "./upgrade/v1beta1/tx.registry.js"; +import * as cosmosVestingV1beta1TxRegistry from "./vesting/v1beta1/tx.registry.js"; +import * as cosmosAuthzV1beta1TxAmino from "./authz/v1beta1/tx.amino.js"; +import * as cosmosBankV1beta1TxAmino from "./bank/v1beta1/tx.amino.js"; +import * as cosmosCrisisV1beta1TxAmino from "./crisis/v1beta1/tx.amino.js"; +import * as cosmosDistributionV1beta1TxAmino from "./distribution/v1beta1/tx.amino.js"; +import * as cosmosEvidenceV1beta1TxAmino from "./evidence/v1beta1/tx.amino.js"; +import * as cosmosFeegrantV1beta1TxAmino from "./feegrant/v1beta1/tx.amino.js"; +import * as cosmosGovV1TxAmino from "./gov/v1/tx.amino.js"; +import * as cosmosGovV1beta1TxAmino from "./gov/v1beta1/tx.amino.js"; +import * as cosmosGroupV1TxAmino from "./group/v1/tx.amino.js"; +import * as cosmosNftV1beta1TxAmino from "./nft/v1beta1/tx.amino.js"; +import * as cosmosSlashingV1beta1TxAmino from "./slashing/v1beta1/tx.amino.js"; +import * as cosmosStakingV1beta1TxAmino from "./staking/v1beta1/tx.amino.js"; +import * as cosmosUpgradeV1beta1TxAmino from "./upgrade/v1beta1/tx.amino.js"; +import * as cosmosVestingV1beta1TxAmino from "./vesting/v1beta1/tx.amino.js"; +export const cosmosAminoConverters = { + ...cosmosAuthzV1beta1TxAmino.AminoConverter, + ...cosmosBankV1beta1TxAmino.AminoConverter, + ...cosmosCrisisV1beta1TxAmino.AminoConverter, + ...cosmosDistributionV1beta1TxAmino.AminoConverter, + ...cosmosEvidenceV1beta1TxAmino.AminoConverter, + ...cosmosFeegrantV1beta1TxAmino.AminoConverter, + ...cosmosGovV1TxAmino.AminoConverter, + ...cosmosGovV1beta1TxAmino.AminoConverter, + ...cosmosGroupV1TxAmino.AminoConverter, + ...cosmosNftV1beta1TxAmino.AminoConverter, + ...cosmosSlashingV1beta1TxAmino.AminoConverter, + ...cosmosStakingV1beta1TxAmino.AminoConverter, + ...cosmosUpgradeV1beta1TxAmino.AminoConverter, + ...cosmosVestingV1beta1TxAmino.AminoConverter +}; +export const cosmosProtoRegistry: ReadonlyArray<[string, GeneratedType]> = [...cosmosAuthzV1beta1TxRegistry.registry, ...cosmosBankV1beta1TxRegistry.registry, ...cosmosCrisisV1beta1TxRegistry.registry, ...cosmosDistributionV1beta1TxRegistry.registry, ...cosmosEvidenceV1beta1TxRegistry.registry, ...cosmosFeegrantV1beta1TxRegistry.registry, ...cosmosGovV1TxRegistry.registry, ...cosmosGovV1beta1TxRegistry.registry, ...cosmosGroupV1TxRegistry.registry, ...cosmosNftV1beta1TxRegistry.registry, ...cosmosSlashingV1beta1TxRegistry.registry, ...cosmosStakingV1beta1TxRegistry.registry, ...cosmosUpgradeV1beta1TxRegistry.registry, ...cosmosVestingV1beta1TxRegistry.registry]; +export const getSigningCosmosClientOptions = (): { + registry: Registry; + aminoTypes: AminoTypes; +} => { + const registry = new Registry([...cosmosProtoRegistry]); + const aminoTypes = new AminoTypes({ + ...cosmosAminoConverters + }); + return { + registry, + aminoTypes + }; +}; +export const getSigningCosmosClient = async ({ + rpcEndpoint, + signer +}: { + rpcEndpoint: string | HttpEndpoint; + signer: OfflineSigner; +}) => { + const { + registry, + aminoTypes + } = getSigningCosmosClientOptions(); + const client = await SigningStargateClient.connectWithSigner(rpcEndpoint, signer, { + registry: (registry as any), + aminoTypes + }); + return client; +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/cosmos-rpc-client.query.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/cosmos-rpc-client.query.ts new file mode 100644 index 0000000000..bc37ce0db3 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/cosmos-rpc-client.query.ts @@ -0,0 +1,21 @@ +import { Rpc } from "../helpers.js"; +import { connectComet, HttpEndpoint } from "@cosmjs/tendermint-rpc"; +import { QueryClient } from "@cosmjs/stargate"; +export const createCosmicRPCQueryClient = async ({ + rpcEndpoint +}: { + rpcEndpoint: string | HttpEndpoint; +}) => { + const tmClient = await connectComet(rpcEndpoint); + const client = new QueryClient(tmClient); + return { + cosmos: { + bank: { + v1beta1: (await import("./bank/v1beta1/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + gov: { + v1beta1: (await import("./gov/v1beta1/query.rpc.Query.js")).createRpcQueryExtension(client) + } + } + }; +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/cosmos-rpc-client.tx.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/cosmos-rpc-client.tx.ts new file mode 100644 index 0000000000..c0ba0ed327 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/cosmos-rpc-client.tx.ts @@ -0,0 +1,15 @@ +import { Rpc } from "../helpers.js"; +export const createCosmicRPCTxClient = async ({ + rpc +}: { + rpc: Rpc; +}) => ({ + cosmos: { + bank: { + v1beta1: new (await import("./bank/v1beta1/tx.rpc.msg.js")).MsgClientImpl(rpc) + }, + gov: { + v1beta1: new (await import("./gov/v1beta1/tx.rpc.msg.js")).MsgClientImpl(rpc) + } + } +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/crisis/v1beta1/genesis.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/crisis/v1beta1/genesis.ts new file mode 100644 index 0000000000..154e7e2242 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/crisis/v1beta1/genesis.ts @@ -0,0 +1,117 @@ +import { Coin, CoinSDKType } from "../../base/v1beta1/coin.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "cosmos.crisis.v1beta1"; +/** GenesisState defines the crisis module's genesis state. */ +export interface GenesisState { + /** + * constant_fee is the fee used to verify the invariant in the crisis + * module. + */ + constantFee: Coin; +} +export interface GenesisStateProtoMsg { + typeUrl: "/cosmos.crisis.v1beta1.GenesisState"; + value: Uint8Array; +} +/** GenesisState defines the crisis module's genesis state. */ +export interface GenesisStateSDKType { + constant_fee: CoinSDKType; +} +function createBaseGenesisState(): GenesisState { + return { + constantFee: Coin.fromPartial({}) + }; +} +export const GenesisState = { + typeUrl: "/cosmos.crisis.v1beta1.GenesisState", + encode(message: GenesisState, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.constantFee !== undefined) { + Coin.encode(message.constantFee, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GenesisState { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGenesisState(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 3: + message.constantFee = Coin.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GenesisState { + const obj = createBaseGenesisState(); + if (isSet(object.constantFee)) obj.constantFee = Coin.fromJSON(object.constantFee); + return obj; + }, + toJSON(message: GenesisState): JsonSafe { + const obj: any = {}; + message.constantFee !== undefined && (obj.constantFee = message.constantFee ? Coin.toJSON(message.constantFee) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): GenesisState { + const message = createBaseGenesisState(); + if (object.constantFee !== undefined && object.constantFee !== null) { + message.constantFee = Coin.fromPartial(object.constantFee); + } + return message; + }, + fromSDK(object: GenesisStateSDKType): GenesisState { + return { + constantFee: object.constant_fee ? Coin.fromSDK(object.constant_fee) : undefined + }; + }, + fromSDKJSON(object: any): GenesisStateSDKType { + return { + constant_fee: isSet(object.constant_fee) ? Coin.fromSDKJSON(object.constant_fee) : undefined + }; + }, + toSDK(message: GenesisState): GenesisStateSDKType { + const obj: any = {}; + message.constantFee !== undefined && (obj.constant_fee = message.constantFee ? Coin.toSDK(message.constantFee) : undefined); + return obj; + }, + fromAmino(object: GenesisStateAmino): GenesisState { + const message = createBaseGenesisState(); + if (object.constant_fee !== undefined && object.constant_fee !== null) { + message.constantFee = Coin.fromAmino(object.constant_fee); + } + return message; + }, + toAmino(message: GenesisState): GenesisStateAmino { + const obj: any = {}; + obj.constant_fee = message.constantFee ? Coin.toAmino(message.constantFee) : undefined; + return obj; + }, + fromAminoMsg(object: GenesisStateAminoMsg): GenesisState { + return GenesisState.fromAmino(object.value); + }, + toAminoMsg(message: GenesisState): GenesisStateAminoMsg { + return { + type: "cosmos-sdk/GenesisState", + value: GenesisState.toAmino(message) + }; + }, + fromProtoMsg(message: GenesisStateProtoMsg): GenesisState { + return GenesisState.decode(message.value); + }, + toProto(message: GenesisState): Uint8Array { + return GenesisState.encode(message).finish(); + }, + toProtoMsg(message: GenesisState): GenesisStateProtoMsg { + return { + typeUrl: "/cosmos.crisis.v1beta1.GenesisState", + value: GenesisState.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/crisis/v1beta1/tx.amino.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/crisis/v1beta1/tx.amino.ts new file mode 100644 index 0000000000..7fa59fe106 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/crisis/v1beta1/tx.amino.ts @@ -0,0 +1,37 @@ +import { ReadOnlyAminoMsg as AminoMsg } from "@interchainjs/ReadOnlyAminoMsg"; +import { MsgVerifyInvariant, MsgVerifyInvariantSDKType } from "./tx.js"; +export interface MsgVerifyInvariantAminoType extends AminoMsg { + type: "cosmos-sdk/MsgVerifyInvariant"; + value: { + sender: string; + invariant_module_name: string; + invariant_route: string; + }; +} +export const AminoConverter = { + "/cosmos.crisis.v1beta1.MsgVerifyInvariant": { + aminoType: "cosmos-sdk/MsgVerifyInvariant", + toAmino: ({ + sender, + invariantModuleName, + invariantRoute + }: MsgVerifyInvariant): MsgVerifyInvariantAminoType["value"] => { + return { + sender, + invariant_module_name: invariantModuleName, + invariant_route: invariantRoute + }; + }, + fromAmino: ({ + sender, + invariant_module_name, + invariant_route + }: MsgVerifyInvariantAminoType["value"]): MsgVerifyInvariant => { + return { + sender, + invariantModuleName: invariant_module_name, + invariantRoute: invariant_route + }; + } + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/crisis/v1beta1/tx.registry.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/crisis/v1beta1/tx.registry.ts new file mode 100644 index 0000000000..19c8d0c9d5 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/crisis/v1beta1/tx.registry.ts @@ -0,0 +1,50 @@ +import { GeneratedType, Registry } from "@cosmjs/proto-signing"; +import { MsgVerifyInvariant, MsgVerifyInvariantSDKType } from "./tx.js"; +export const registry: ReadonlyArray<[string, GeneratedType]> = [["/cosmos.crisis.v1beta1.MsgVerifyInvariant", MsgVerifyInvariant]]; +export const load = (protoRegistry: Registry) => { + registry.forEach(([typeUrl, mod]) => { + protoRegistry.register(typeUrl, mod); + }); +}; +export const MessageComposer = { + encoded: { + verifyInvariant(value: MsgVerifyInvariant) { + return { + typeUrl: "/cosmos.crisis.v1beta1.MsgVerifyInvariant", + value: MsgVerifyInvariant.encode(value).finish() + }; + } + }, + withTypeUrl: { + verifyInvariant(value: MsgVerifyInvariant) { + return { + typeUrl: "/cosmos.crisis.v1beta1.MsgVerifyInvariant", + value + }; + } + }, + toJSON: { + verifyInvariant(value: MsgVerifyInvariant) { + return { + typeUrl: "/cosmos.crisis.v1beta1.MsgVerifyInvariant", + value: MsgVerifyInvariant.toJSON(value) + }; + } + }, + fromJSON: { + verifyInvariant(value: any) { + return { + typeUrl: "/cosmos.crisis.v1beta1.MsgVerifyInvariant", + value: MsgVerifyInvariant.fromJSON(value) + }; + } + }, + fromPartial: { + verifyInvariant(value: MsgVerifyInvariant) { + return { + typeUrl: "/cosmos.crisis.v1beta1.MsgVerifyInvariant", + value: MsgVerifyInvariant.fromPartial(value) + }; + } + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/crisis/v1beta1/tx.rpc.func.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/crisis/v1beta1/tx.rpc.func.ts new file mode 100644 index 0000000000..c02e19db99 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/crisis/v1beta1/tx.rpc.func.ts @@ -0,0 +1,13 @@ +import { buildTx, SigningClientResolver } from "../../../helper-func-types"; +import { buildUseMutation } from "../../../react-query"; +import { toEncoders, toConverters } from "@interchainjs/cosmos/utils"; +import { MsgVerifyInvariant } from "./tx"; +export const createVerifyInvariant = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgVerifyInvariant.typeUrl, + encoders: toEncoders(MsgVerifyInvariant), + converters: toConverters(MsgVerifyInvariant) +}); +export const useVerifyInvariant = buildUseMutation({ + builderMutationFn: createVerifyInvariant +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/crisis/v1beta1/tx.rpc.msg.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/crisis/v1beta1/tx.rpc.msg.ts new file mode 100644 index 0000000000..a0d77e7f67 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/crisis/v1beta1/tx.rpc.msg.ts @@ -0,0 +1,23 @@ +import { Rpc } from "../../../helpers.js"; +import { BinaryReader } from "../../../binary.js"; +import { MsgVerifyInvariant, MsgVerifyInvariantSDKType, MsgVerifyInvariantResponse, MsgVerifyInvariantResponseSDKType } from "./tx.js"; +/** Msg defines the bank Msg service. */ +export interface Msg { + /** VerifyInvariant defines a method to verify a particular invariance. */ + verifyInvariant(request: MsgVerifyInvariant): Promise; +} +export class MsgClientImpl implements Msg { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + this.verifyInvariant = this.verifyInvariant.bind(this); + } + verifyInvariant(request: MsgVerifyInvariant): Promise { + const data = MsgVerifyInvariant.encode(request).finish(); + const promise = this.rpc.request("cosmos.crisis.v1beta1.Msg", "VerifyInvariant", data); + return promise.then(data => MsgVerifyInvariantResponse.decode(new BinaryReader(data))); + } +} +export const createClientImpl = (rpc: Rpc) => { + return new MsgClientImpl(rpc); +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/crisis/v1beta1/tx.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/crisis/v1beta1/tx.ts new file mode 100644 index 0000000000..7e586b8d41 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/crisis/v1beta1/tx.ts @@ -0,0 +1,230 @@ +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "cosmos.crisis.v1beta1"; +/** MsgVerifyInvariant represents a message to verify a particular invariance. */ +export interface MsgVerifyInvariant { + sender: string; + invariantModuleName: string; + invariantRoute: string; +} +export interface MsgVerifyInvariantProtoMsg { + typeUrl: "/cosmos.crisis.v1beta1.MsgVerifyInvariant"; + value: Uint8Array; +} +/** MsgVerifyInvariant represents a message to verify a particular invariance. */ +export interface MsgVerifyInvariantSDKType { + sender: string; + invariant_module_name: string; + invariant_route: string; +} +/** MsgVerifyInvariantResponse defines the Msg/VerifyInvariant response type. */ +export interface MsgVerifyInvariantResponse {} +export interface MsgVerifyInvariantResponseProtoMsg { + typeUrl: "/cosmos.crisis.v1beta1.MsgVerifyInvariantResponse"; + value: Uint8Array; +} +/** MsgVerifyInvariantResponse defines the Msg/VerifyInvariant response type. */ +export interface MsgVerifyInvariantResponseSDKType {} +function createBaseMsgVerifyInvariant(): MsgVerifyInvariant { + return { + sender: "", + invariantModuleName: "", + invariantRoute: "" + }; +} +export const MsgVerifyInvariant = { + typeUrl: "/cosmos.crisis.v1beta1.MsgVerifyInvariant", + encode(message: MsgVerifyInvariant, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.sender !== undefined) { + writer.uint32(10).string(message.sender); + } + if (message.invariantModuleName !== undefined) { + writer.uint32(18).string(message.invariantModuleName); + } + if (message.invariantRoute !== undefined) { + writer.uint32(26).string(message.invariantRoute); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgVerifyInvariant { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgVerifyInvariant(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.sender = reader.string(); + break; + case 2: + message.invariantModuleName = reader.string(); + break; + case 3: + message.invariantRoute = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgVerifyInvariant { + const obj = createBaseMsgVerifyInvariant(); + if (isSet(object.sender)) obj.sender = String(object.sender); + if (isSet(object.invariantModuleName)) obj.invariantModuleName = String(object.invariantModuleName); + if (isSet(object.invariantRoute)) obj.invariantRoute = String(object.invariantRoute); + return obj; + }, + toJSON(message: MsgVerifyInvariant): JsonSafe { + const obj: any = {}; + message.sender !== undefined && (obj.sender = message.sender); + message.invariantModuleName !== undefined && (obj.invariantModuleName = message.invariantModuleName); + message.invariantRoute !== undefined && (obj.invariantRoute = message.invariantRoute); + return obj; + }, + fromPartial(object: DeepPartial): MsgVerifyInvariant { + const message = createBaseMsgVerifyInvariant(); + message.sender = object.sender ?? ""; + message.invariantModuleName = object.invariantModuleName ?? ""; + message.invariantRoute = object.invariantRoute ?? ""; + return message; + }, + fromSDK(object: MsgVerifyInvariantSDKType): MsgVerifyInvariant { + return { + sender: object?.sender, + invariantModuleName: object?.invariant_module_name, + invariantRoute: object?.invariant_route + }; + }, + fromSDKJSON(object: any): MsgVerifyInvariantSDKType { + return { + sender: isSet(object.sender) ? String(object.sender) : "", + invariant_module_name: isSet(object.invariant_module_name) ? String(object.invariant_module_name) : "", + invariant_route: isSet(object.invariant_route) ? String(object.invariant_route) : "" + }; + }, + toSDK(message: MsgVerifyInvariant): MsgVerifyInvariantSDKType { + const obj: any = {}; + obj.sender = message.sender; + obj.invariant_module_name = message.invariantModuleName; + obj.invariant_route = message.invariantRoute; + return obj; + }, + fromAmino(object: MsgVerifyInvariantAmino): MsgVerifyInvariant { + const message = createBaseMsgVerifyInvariant(); + if (object.sender !== undefined && object.sender !== null) { + message.sender = object.sender; + } + if (object.invariant_module_name !== undefined && object.invariant_module_name !== null) { + message.invariantModuleName = object.invariant_module_name; + } + if (object.invariant_route !== undefined && object.invariant_route !== null) { + message.invariantRoute = object.invariant_route; + } + return message; + }, + toAmino(message: MsgVerifyInvariant): MsgVerifyInvariantAmino { + const obj: any = {}; + obj.sender = message.sender === "" ? undefined : message.sender; + obj.invariant_module_name = message.invariantModuleName === "" ? undefined : message.invariantModuleName; + obj.invariant_route = message.invariantRoute === "" ? undefined : message.invariantRoute; + return obj; + }, + fromAminoMsg(object: MsgVerifyInvariantAminoMsg): MsgVerifyInvariant { + return MsgVerifyInvariant.fromAmino(object.value); + }, + toAminoMsg(message: MsgVerifyInvariant): MsgVerifyInvariantAminoMsg { + return { + type: "cosmos-sdk/MsgVerifyInvariant", + value: MsgVerifyInvariant.toAmino(message) + }; + }, + fromProtoMsg(message: MsgVerifyInvariantProtoMsg): MsgVerifyInvariant { + return MsgVerifyInvariant.decode(message.value); + }, + toProto(message: MsgVerifyInvariant): Uint8Array { + return MsgVerifyInvariant.encode(message).finish(); + }, + toProtoMsg(message: MsgVerifyInvariant): MsgVerifyInvariantProtoMsg { + return { + typeUrl: "/cosmos.crisis.v1beta1.MsgVerifyInvariant", + value: MsgVerifyInvariant.encode(message).finish() + }; + } +}; +function createBaseMsgVerifyInvariantResponse(): MsgVerifyInvariantResponse { + return {}; +} +export const MsgVerifyInvariantResponse = { + typeUrl: "/cosmos.crisis.v1beta1.MsgVerifyInvariantResponse", + encode(_: MsgVerifyInvariantResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgVerifyInvariantResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgVerifyInvariantResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgVerifyInvariantResponse { + const obj = createBaseMsgVerifyInvariantResponse(); + return obj; + }, + toJSON(_: MsgVerifyInvariantResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): MsgVerifyInvariantResponse { + const message = createBaseMsgVerifyInvariantResponse(); + return message; + }, + fromSDK(_: MsgVerifyInvariantResponseSDKType): MsgVerifyInvariantResponse { + return {}; + }, + fromSDKJSON(_: any): MsgVerifyInvariantResponseSDKType { + return {}; + }, + toSDK(_: MsgVerifyInvariantResponse): MsgVerifyInvariantResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgVerifyInvariantResponseAmino): MsgVerifyInvariantResponse { + const message = createBaseMsgVerifyInvariantResponse(); + return message; + }, + toAmino(_: MsgVerifyInvariantResponse): MsgVerifyInvariantResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgVerifyInvariantResponseAminoMsg): MsgVerifyInvariantResponse { + return MsgVerifyInvariantResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgVerifyInvariantResponse): MsgVerifyInvariantResponseAminoMsg { + return { + type: "cosmos-sdk/MsgVerifyInvariantResponse", + value: MsgVerifyInvariantResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgVerifyInvariantResponseProtoMsg): MsgVerifyInvariantResponse { + return MsgVerifyInvariantResponse.decode(message.value); + }, + toProto(message: MsgVerifyInvariantResponse): Uint8Array { + return MsgVerifyInvariantResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgVerifyInvariantResponse): MsgVerifyInvariantResponseProtoMsg { + return { + typeUrl: "/cosmos.crisis.v1beta1.MsgVerifyInvariantResponse", + value: MsgVerifyInvariantResponse.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/crypto/ed25519/keys.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/crypto/ed25519/keys.ts new file mode 100644 index 0000000000..efe200065e --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/crypto/ed25519/keys.ts @@ -0,0 +1,234 @@ +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, bytesFromBase64, base64FromBytes, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "cosmos.crypto.ed25519"; +/** + * PubKey is an ed25519 public key for handling Tendermint keys in SDK. + * It's needed for Any serialization and SDK compatibility. + * It must not be used in a non Tendermint key context because it doesn't implement + * ADR-28. Nevertheless, you will like to use ed25519 in app user level + * then you must create a new proto message and follow ADR-28 for Address construction. + */ +export interface PubKey { + key: Uint8Array; +} +export interface PubKeyProtoMsg { + typeUrl: "/cosmos.crypto.ed25519.PubKey"; + value: Uint8Array; +} +/** + * PubKey is an ed25519 public key for handling Tendermint keys in SDK. + * It's needed for Any serialization and SDK compatibility. + * It must not be used in a non Tendermint key context because it doesn't implement + * ADR-28. Nevertheless, you will like to use ed25519 in app user level + * then you must create a new proto message and follow ADR-28 for Address construction. + */ +export interface PubKeySDKType { + key: Uint8Array; +} +/** + * Deprecated: PrivKey defines a ed25519 private key. + * NOTE: ed25519 keys must not be used in SDK apps except in a tendermint validator context. + */ +export interface PrivKey { + key: Uint8Array; +} +export interface PrivKeyProtoMsg { + typeUrl: "/cosmos.crypto.ed25519.PrivKey"; + value: Uint8Array; +} +/** + * Deprecated: PrivKey defines a ed25519 private key. + * NOTE: ed25519 keys must not be used in SDK apps except in a tendermint validator context. + */ +export interface PrivKeySDKType { + key: Uint8Array; +} +function createBasePubKey(): PubKey { + return { + key: new Uint8Array() + }; +} +export const PubKey = { + typeUrl: "/cosmos.crypto.ed25519.PubKey", + encode(message: PubKey, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.key.length !== 0) { + writer.uint32(10).bytes(message.key); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): PubKey { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBasePubKey(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): PubKey { + const obj = createBasePubKey(); + if (isSet(object.key)) obj.key = bytesFromBase64(object.key); + return obj; + }, + toJSON(message: PubKey): JsonSafe { + const obj: any = {}; + message.key !== undefined && (obj.key = base64FromBytes(message.key !== undefined ? message.key : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): PubKey { + const message = createBasePubKey(); + message.key = object.key ?? new Uint8Array(); + return message; + }, + fromSDK(object: PubKeySDKType): PubKey { + return { + key: object?.key + }; + }, + fromSDKJSON(object: any): PubKeySDKType { + return { + key: isSet(object.key) ? bytesFromBase64(object.key) : new Uint8Array() + }; + }, + toSDK(message: PubKey): PubKeySDKType { + const obj: any = {}; + obj.key = message.key; + return obj; + }, + fromAmino(object: PubKeyAmino): PubKey { + const message = createBasePubKey(); + if (object.key !== undefined && object.key !== null) { + message.key = bytesFromBase64(object.key); + } + return message; + }, + toAmino(message: PubKey): PubKeyAmino { + const obj: any = {}; + obj.key = message.key ? base64FromBytes(message.key) : undefined; + return obj; + }, + fromAminoMsg(object: PubKeyAminoMsg): PubKey { + return PubKey.fromAmino(object.value); + }, + toAminoMsg(message: PubKey): PubKeyAminoMsg { + return { + type: "cosmos-sdk/PubKey", + value: PubKey.toAmino(message) + }; + }, + fromProtoMsg(message: PubKeyProtoMsg): PubKey { + return PubKey.decode(message.value); + }, + toProto(message: PubKey): Uint8Array { + return PubKey.encode(message).finish(); + }, + toProtoMsg(message: PubKey): PubKeyProtoMsg { + return { + typeUrl: "/cosmos.crypto.ed25519.PubKey", + value: PubKey.encode(message).finish() + }; + } +}; +function createBasePrivKey(): PrivKey { + return { + key: new Uint8Array() + }; +} +export const PrivKey = { + typeUrl: "/cosmos.crypto.ed25519.PrivKey", + encode(message: PrivKey, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.key.length !== 0) { + writer.uint32(10).bytes(message.key); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): PrivKey { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBasePrivKey(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): PrivKey { + const obj = createBasePrivKey(); + if (isSet(object.key)) obj.key = bytesFromBase64(object.key); + return obj; + }, + toJSON(message: PrivKey): JsonSafe { + const obj: any = {}; + message.key !== undefined && (obj.key = base64FromBytes(message.key !== undefined ? message.key : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): PrivKey { + const message = createBasePrivKey(); + message.key = object.key ?? new Uint8Array(); + return message; + }, + fromSDK(object: PrivKeySDKType): PrivKey { + return { + key: object?.key + }; + }, + fromSDKJSON(object: any): PrivKeySDKType { + return { + key: isSet(object.key) ? bytesFromBase64(object.key) : new Uint8Array() + }; + }, + toSDK(message: PrivKey): PrivKeySDKType { + const obj: any = {}; + obj.key = message.key; + return obj; + }, + fromAmino(object: PrivKeyAmino): PrivKey { + const message = createBasePrivKey(); + if (object.key !== undefined && object.key !== null) { + message.key = bytesFromBase64(object.key); + } + return message; + }, + toAmino(message: PrivKey): PrivKeyAmino { + const obj: any = {}; + obj.key = message.key ? base64FromBytes(message.key) : undefined; + return obj; + }, + fromAminoMsg(object: PrivKeyAminoMsg): PrivKey { + return PrivKey.fromAmino(object.value); + }, + toAminoMsg(message: PrivKey): PrivKeyAminoMsg { + return { + type: "cosmos-sdk/PrivKey", + value: PrivKey.toAmino(message) + }; + }, + fromProtoMsg(message: PrivKeyProtoMsg): PrivKey { + return PrivKey.decode(message.value); + }, + toProto(message: PrivKey): Uint8Array { + return PrivKey.encode(message).finish(); + }, + toProtoMsg(message: PrivKey): PrivKeyProtoMsg { + return { + typeUrl: "/cosmos.crypto.ed25519.PrivKey", + value: PrivKey.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/crypto/hd/v1/hd.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/crypto/hd/v1/hd.ts new file mode 100644 index 0000000000..8bf057ec74 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/crypto/hd/v1/hd.ts @@ -0,0 +1,194 @@ +import { BinaryReader, BinaryWriter } from "../../../../binary.js"; +import { isSet, DeepPartial } from "../../../../helpers.js"; +import { JsonSafe } from "../../../../json-safe.js"; +export const protobufPackage = "cosmos.crypto.hd.v1"; +/** BIP44Params is used as path field in ledger item in Record. */ +export interface BIP44Params { + /** purpose is a constant set to 44' (or 0x8000002C) following the BIP43 recommendation */ + purpose: number; + /** coin_type is a constant that improves privacy */ + coinType: number; + /** account splits the key space into independent user identities */ + account: number; + /** + * change is a constant used for public derivation. Constant 0 is used for external chain and constant 1 for internal + * chain. + */ + change: boolean; + /** address_index is used as child index in BIP32 derivation */ + addressIndex: number; +} +export interface BIP44ParamsProtoMsg { + typeUrl: "/cosmos.crypto.hd.v1.BIP44Params"; + value: Uint8Array; +} +/** BIP44Params is used as path field in ledger item in Record. */ +export interface BIP44ParamsSDKType { + purpose: number; + coin_type: number; + account: number; + change: boolean; + address_index: number; +} +function createBaseBIP44Params(): BIP44Params { + return { + purpose: 0, + coinType: 0, + account: 0, + change: false, + addressIndex: 0 + }; +} +export const BIP44Params = { + typeUrl: "/cosmos.crypto.hd.v1.BIP44Params", + encode(message: BIP44Params, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.purpose !== undefined) { + writer.uint32(8).uint32(message.purpose); + } + if (message.coinType !== undefined) { + writer.uint32(16).uint32(message.coinType); + } + if (message.account !== undefined) { + writer.uint32(24).uint32(message.account); + } + if (message.change !== undefined) { + writer.uint32(32).bool(message.change); + } + if (message.addressIndex !== undefined) { + writer.uint32(40).uint32(message.addressIndex); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): BIP44Params { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseBIP44Params(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.purpose = reader.uint32(); + break; + case 2: + message.coinType = reader.uint32(); + break; + case 3: + message.account = reader.uint32(); + break; + case 4: + message.change = reader.bool(); + break; + case 5: + message.addressIndex = reader.uint32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): BIP44Params { + const obj = createBaseBIP44Params(); + if (isSet(object.purpose)) obj.purpose = Number(object.purpose); + if (isSet(object.coinType)) obj.coinType = Number(object.coinType); + if (isSet(object.account)) obj.account = Number(object.account); + if (isSet(object.change)) obj.change = Boolean(object.change); + if (isSet(object.addressIndex)) obj.addressIndex = Number(object.addressIndex); + return obj; + }, + toJSON(message: BIP44Params): JsonSafe { + const obj: any = {}; + message.purpose !== undefined && (obj.purpose = Math.round(message.purpose)); + message.coinType !== undefined && (obj.coinType = Math.round(message.coinType)); + message.account !== undefined && (obj.account = Math.round(message.account)); + message.change !== undefined && (obj.change = message.change); + message.addressIndex !== undefined && (obj.addressIndex = Math.round(message.addressIndex)); + return obj; + }, + fromPartial(object: DeepPartial): BIP44Params { + const message = createBaseBIP44Params(); + message.purpose = object.purpose ?? 0; + message.coinType = object.coinType ?? 0; + message.account = object.account ?? 0; + message.change = object.change ?? false; + message.addressIndex = object.addressIndex ?? 0; + return message; + }, + fromSDK(object: BIP44ParamsSDKType): BIP44Params { + return { + purpose: object?.purpose, + coinType: object?.coin_type, + account: object?.account, + change: object?.change, + addressIndex: object?.address_index + }; + }, + fromSDKJSON(object: any): BIP44ParamsSDKType { + return { + purpose: isSet(object.purpose) ? Number(object.purpose) : 0, + coin_type: isSet(object.coin_type) ? Number(object.coin_type) : 0, + account: isSet(object.account) ? Number(object.account) : 0, + change: isSet(object.change) ? Boolean(object.change) : false, + address_index: isSet(object.address_index) ? Number(object.address_index) : 0 + }; + }, + toSDK(message: BIP44Params): BIP44ParamsSDKType { + const obj: any = {}; + obj.purpose = message.purpose; + obj.coin_type = message.coinType; + obj.account = message.account; + obj.change = message.change; + obj.address_index = message.addressIndex; + return obj; + }, + fromAmino(object: BIP44ParamsAmino): BIP44Params { + const message = createBaseBIP44Params(); + if (object.purpose !== undefined && object.purpose !== null) { + message.purpose = object.purpose; + } + if (object.coin_type !== undefined && object.coin_type !== null) { + message.coinType = object.coin_type; + } + if (object.account !== undefined && object.account !== null) { + message.account = object.account; + } + if (object.change !== undefined && object.change !== null) { + message.change = object.change; + } + if (object.address_index !== undefined && object.address_index !== null) { + message.addressIndex = object.address_index; + } + return message; + }, + toAmino(message: BIP44Params): BIP44ParamsAmino { + const obj: any = {}; + obj.purpose = message.purpose === 0 ? undefined : message.purpose; + obj.coin_type = message.coinType === 0 ? undefined : message.coinType; + obj.account = message.account === 0 ? undefined : message.account; + obj.change = message.change === false ? undefined : message.change; + obj.address_index = message.addressIndex === 0 ? undefined : message.addressIndex; + return obj; + }, + fromAminoMsg(object: BIP44ParamsAminoMsg): BIP44Params { + return BIP44Params.fromAmino(object.value); + }, + toAminoMsg(message: BIP44Params): BIP44ParamsAminoMsg { + return { + type: "cosmos-sdk/BIP44Params", + value: BIP44Params.toAmino(message) + }; + }, + fromProtoMsg(message: BIP44ParamsProtoMsg): BIP44Params { + return BIP44Params.decode(message.value); + }, + toProto(message: BIP44Params): Uint8Array { + return BIP44Params.encode(message).finish(); + }, + toProtoMsg(message: BIP44Params): BIP44ParamsProtoMsg { + return { + typeUrl: "/cosmos.crypto.hd.v1.BIP44Params", + value: BIP44Params.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/crypto/keyring/v1/record.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/crypto/keyring/v1/record.ts new file mode 100644 index 0000000000..12341d7b3e --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/crypto/keyring/v1/record.ts @@ -0,0 +1,628 @@ +import { Any, AnySDKType } from "../../../../google/protobuf/any.js"; +import { BIP44Params, BIP44ParamsSDKType } from "../../hd/v1/hd.js"; +import { BinaryReader, BinaryWriter } from "../../../../binary.js"; +import { isSet, DeepPartial } from "../../../../helpers.js"; +import { JsonSafe } from "../../../../json-safe.js"; +export const protobufPackage = "cosmos.crypto.keyring.v1"; +/** Record is used for representing a key in the keyring. */ +export interface Record { + /** name represents a name of Record */ + name: string; + /** pub_key represents a public key in any format */ + pubKey?: Any; + /** local stores the public information about a locally stored key */ + local?: Record_Local; + /** ledger stores the public information about a Ledger key */ + ledger?: Record_Ledger; + /** Multi does not store any information. */ + multi?: Record_Multi; + /** Offline does not store any information. */ + offline?: Record_Offline; +} +export interface RecordProtoMsg { + typeUrl: "/cosmos.crypto.keyring.v1.Record"; + value: Uint8Array; +} +/** Record is used for representing a key in the keyring. */ +export interface RecordSDKType { + name: string; + pub_key?: AnySDKType; + local?: Record_LocalSDKType; + ledger?: Record_LedgerSDKType; + multi?: Record_MultiSDKType; + offline?: Record_OfflineSDKType; +} +/** + * Item is a keyring item stored in a keyring backend. + * Local item + */ +export interface Record_Local { + privKey?: Any; + privKeyType: string; +} +export interface Record_LocalProtoMsg { + typeUrl: "/cosmos.crypto.keyring.v1.Local"; + value: Uint8Array; +} +/** + * Item is a keyring item stored in a keyring backend. + * Local item + */ +export interface Record_LocalSDKType { + priv_key?: AnySDKType; + priv_key_type: string; +} +/** Ledger item */ +export interface Record_Ledger { + path?: BIP44Params; +} +export interface Record_LedgerProtoMsg { + typeUrl: "/cosmos.crypto.keyring.v1.Ledger"; + value: Uint8Array; +} +/** Ledger item */ +export interface Record_LedgerSDKType { + path?: BIP44ParamsSDKType; +} +/** Multi item */ +export interface Record_Multi {} +export interface Record_MultiProtoMsg { + typeUrl: "/cosmos.crypto.keyring.v1.Multi"; + value: Uint8Array; +} +/** Multi item */ +export interface Record_MultiSDKType {} +/** Offline item */ +export interface Record_Offline {} +export interface Record_OfflineProtoMsg { + typeUrl: "/cosmos.crypto.keyring.v1.Offline"; + value: Uint8Array; +} +/** Offline item */ +export interface Record_OfflineSDKType {} +function createBaseRecord(): Record { + return { + name: "", + pubKey: undefined, + local: undefined, + ledger: undefined, + multi: undefined, + offline: undefined + }; +} +export const Record = { + typeUrl: "/cosmos.crypto.keyring.v1.Record", + encode(message: Record, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + if (message.pubKey !== undefined) { + Any.encode(message.pubKey, writer.uint32(18).fork()).ldelim(); + } + if (message.local !== undefined) { + Record_Local.encode(message.local, writer.uint32(26).fork()).ldelim(); + } + if (message.ledger !== undefined) { + Record_Ledger.encode(message.ledger, writer.uint32(34).fork()).ldelim(); + } + if (message.multi !== undefined) { + Record_Multi.encode(message.multi, writer.uint32(42).fork()).ldelim(); + } + if (message.offline !== undefined) { + Record_Offline.encode(message.offline, writer.uint32(50).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Record { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseRecord(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.pubKey = Any.decode(reader, reader.uint32()); + break; + case 3: + message.local = Record_Local.decode(reader, reader.uint32()); + break; + case 4: + message.ledger = Record_Ledger.decode(reader, reader.uint32()); + break; + case 5: + message.multi = Record_Multi.decode(reader, reader.uint32()); + break; + case 6: + message.offline = Record_Offline.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Record { + const obj = createBaseRecord(); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.pubKey)) obj.pubKey = Any.fromJSON(object.pubKey); + if (isSet(object.local)) obj.local = Record_Local.fromJSON(object.local); + if (isSet(object.ledger)) obj.ledger = Record_Ledger.fromJSON(object.ledger); + if (isSet(object.multi)) obj.multi = Record_Multi.fromJSON(object.multi); + if (isSet(object.offline)) obj.offline = Record_Offline.fromJSON(object.offline); + return obj; + }, + toJSON(message: Record): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.pubKey !== undefined && (obj.pubKey = message.pubKey ? Any.toJSON(message.pubKey) : undefined); + message.local !== undefined && (obj.local = message.local ? Record_Local.toJSON(message.local) : undefined); + message.ledger !== undefined && (obj.ledger = message.ledger ? Record_Ledger.toJSON(message.ledger) : undefined); + message.multi !== undefined && (obj.multi = message.multi ? Record_Multi.toJSON(message.multi) : undefined); + message.offline !== undefined && (obj.offline = message.offline ? Record_Offline.toJSON(message.offline) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): Record { + const message = createBaseRecord(); + message.name = object.name ?? ""; + if (object.pubKey !== undefined && object.pubKey !== null) { + message.pubKey = Any.fromPartial(object.pubKey); + } + if (object.local !== undefined && object.local !== null) { + message.local = Record_Local.fromPartial(object.local); + } + if (object.ledger !== undefined && object.ledger !== null) { + message.ledger = Record_Ledger.fromPartial(object.ledger); + } + if (object.multi !== undefined && object.multi !== null) { + message.multi = Record_Multi.fromPartial(object.multi); + } + if (object.offline !== undefined && object.offline !== null) { + message.offline = Record_Offline.fromPartial(object.offline); + } + return message; + }, + fromSDK(object: RecordSDKType): Record { + return { + name: object?.name, + pubKey: object.pub_key ? Any.fromSDK(object.pub_key) : undefined, + local: object.local ? Record_Local.fromSDK(object.local) : undefined, + ledger: object.ledger ? Record_Ledger.fromSDK(object.ledger) : undefined, + multi: object.multi ? Record_Multi.fromSDK(object.multi) : undefined, + offline: object.offline ? Record_Offline.fromSDK(object.offline) : undefined + }; + }, + fromSDKJSON(object: any): RecordSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + pub_key: isSet(object.pub_key) ? Any.fromSDKJSON(object.pub_key) : undefined, + local: isSet(object.local) ? Record_Local.fromSDKJSON(object.local) : undefined, + ledger: isSet(object.ledger) ? Record_Ledger.fromSDKJSON(object.ledger) : undefined, + multi: isSet(object.multi) ? Record_Multi.fromSDKJSON(object.multi) : undefined, + offline: isSet(object.offline) ? Record_Offline.fromSDKJSON(object.offline) : undefined + }; + }, + toSDK(message: Record): RecordSDKType { + const obj: any = {}; + obj.name = message.name; + message.pubKey !== undefined && (obj.pub_key = message.pubKey ? Any.toSDK(message.pubKey) : undefined); + message.local !== undefined && (obj.local = message.local ? Record_Local.toSDK(message.local) : undefined); + message.ledger !== undefined && (obj.ledger = message.ledger ? Record_Ledger.toSDK(message.ledger) : undefined); + message.multi !== undefined && (obj.multi = message.multi ? Record_Multi.toSDK(message.multi) : undefined); + message.offline !== undefined && (obj.offline = message.offline ? Record_Offline.toSDK(message.offline) : undefined); + return obj; + }, + fromAmino(object: RecordAmino): Record { + const message = createBaseRecord(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + if (object.pub_key !== undefined && object.pub_key !== null) { + message.pubKey = Any.fromAmino(object.pub_key); + } + if (object.local !== undefined && object.local !== null) { + message.local = Record_Local.fromAmino(object.local); + } + if (object.ledger !== undefined && object.ledger !== null) { + message.ledger = Record_Ledger.fromAmino(object.ledger); + } + if (object.multi !== undefined && object.multi !== null) { + message.multi = Record_Multi.fromAmino(object.multi); + } + if (object.offline !== undefined && object.offline !== null) { + message.offline = Record_Offline.fromAmino(object.offline); + } + return message; + }, + toAmino(message: Record): RecordAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + obj.pub_key = message.pubKey ? Any.toAmino(message.pubKey) : undefined; + obj.local = message.local ? Record_Local.toAmino(message.local) : undefined; + obj.ledger = message.ledger ? Record_Ledger.toAmino(message.ledger) : undefined; + obj.multi = message.multi ? Record_Multi.toAmino(message.multi) : undefined; + obj.offline = message.offline ? Record_Offline.toAmino(message.offline) : undefined; + return obj; + }, + fromAminoMsg(object: RecordAminoMsg): Record { + return Record.fromAmino(object.value); + }, + toAminoMsg(message: Record): RecordAminoMsg { + return { + type: "cosmos-sdk/Record", + value: Record.toAmino(message) + }; + }, + fromProtoMsg(message: RecordProtoMsg): Record { + return Record.decode(message.value); + }, + toProto(message: Record): Uint8Array { + return Record.encode(message).finish(); + }, + toProtoMsg(message: Record): RecordProtoMsg { + return { + typeUrl: "/cosmos.crypto.keyring.v1.Record", + value: Record.encode(message).finish() + }; + } +}; +function createBaseRecord_Local(): Record_Local { + return { + privKey: undefined, + privKeyType: "" + }; +} +export const Record_Local = { + typeUrl: "/cosmos.crypto.keyring.v1.Local", + encode(message: Record_Local, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.privKey !== undefined) { + Any.encode(message.privKey, writer.uint32(10).fork()).ldelim(); + } + if (message.privKeyType !== undefined) { + writer.uint32(18).string(message.privKeyType); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Record_Local { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseRecord_Local(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.privKey = Any.decode(reader, reader.uint32()); + break; + case 2: + message.privKeyType = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Record_Local { + const obj = createBaseRecord_Local(); + if (isSet(object.privKey)) obj.privKey = Any.fromJSON(object.privKey); + if (isSet(object.privKeyType)) obj.privKeyType = String(object.privKeyType); + return obj; + }, + toJSON(message: Record_Local): JsonSafe { + const obj: any = {}; + message.privKey !== undefined && (obj.privKey = message.privKey ? Any.toJSON(message.privKey) : undefined); + message.privKeyType !== undefined && (obj.privKeyType = message.privKeyType); + return obj; + }, + fromPartial(object: DeepPartial): Record_Local { + const message = createBaseRecord_Local(); + if (object.privKey !== undefined && object.privKey !== null) { + message.privKey = Any.fromPartial(object.privKey); + } + message.privKeyType = object.privKeyType ?? ""; + return message; + }, + fromSDK(object: Record_LocalSDKType): Record_Local { + return { + privKey: object.priv_key ? Any.fromSDK(object.priv_key) : undefined, + privKeyType: object?.priv_key_type + }; + }, + fromSDKJSON(object: any): Record_LocalSDKType { + return { + priv_key: isSet(object.priv_key) ? Any.fromSDKJSON(object.priv_key) : undefined, + priv_key_type: isSet(object.priv_key_type) ? String(object.priv_key_type) : "" + }; + }, + toSDK(message: Record_Local): Record_LocalSDKType { + const obj: any = {}; + message.privKey !== undefined && (obj.priv_key = message.privKey ? Any.toSDK(message.privKey) : undefined); + obj.priv_key_type = message.privKeyType; + return obj; + }, + fromAmino(object: Record_LocalAmino): Record_Local { + const message = createBaseRecord_Local(); + if (object.priv_key !== undefined && object.priv_key !== null) { + message.privKey = Any.fromAmino(object.priv_key); + } + if (object.priv_key_type !== undefined && object.priv_key_type !== null) { + message.privKeyType = object.priv_key_type; + } + return message; + }, + toAmino(message: Record_Local): Record_LocalAmino { + const obj: any = {}; + obj.priv_key = message.privKey ? Any.toAmino(message.privKey) : undefined; + obj.priv_key_type = message.privKeyType === "" ? undefined : message.privKeyType; + return obj; + }, + fromAminoMsg(object: Record_LocalAminoMsg): Record_Local { + return Record_Local.fromAmino(object.value); + }, + toAminoMsg(message: Record_Local): Record_LocalAminoMsg { + return { + type: "cosmos-sdk/Local", + value: Record_Local.toAmino(message) + }; + }, + fromProtoMsg(message: Record_LocalProtoMsg): Record_Local { + return Record_Local.decode(message.value); + }, + toProto(message: Record_Local): Uint8Array { + return Record_Local.encode(message).finish(); + }, + toProtoMsg(message: Record_Local): Record_LocalProtoMsg { + return { + typeUrl: "/cosmos.crypto.keyring.v1.Local", + value: Record_Local.encode(message).finish() + }; + } +}; +function createBaseRecord_Ledger(): Record_Ledger { + return { + path: undefined + }; +} +export const Record_Ledger = { + typeUrl: "/cosmos.crypto.keyring.v1.Ledger", + encode(message: Record_Ledger, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.path !== undefined) { + BIP44Params.encode(message.path, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Record_Ledger { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseRecord_Ledger(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.path = BIP44Params.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Record_Ledger { + const obj = createBaseRecord_Ledger(); + if (isSet(object.path)) obj.path = BIP44Params.fromJSON(object.path); + return obj; + }, + toJSON(message: Record_Ledger): JsonSafe { + const obj: any = {}; + message.path !== undefined && (obj.path = message.path ? BIP44Params.toJSON(message.path) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): Record_Ledger { + const message = createBaseRecord_Ledger(); + if (object.path !== undefined && object.path !== null) { + message.path = BIP44Params.fromPartial(object.path); + } + return message; + }, + fromSDK(object: Record_LedgerSDKType): Record_Ledger { + return { + path: object.path ? BIP44Params.fromSDK(object.path) : undefined + }; + }, + fromSDKJSON(object: any): Record_LedgerSDKType { + return { + path: isSet(object.path) ? BIP44Params.fromSDKJSON(object.path) : undefined + }; + }, + toSDK(message: Record_Ledger): Record_LedgerSDKType { + const obj: any = {}; + message.path !== undefined && (obj.path = message.path ? BIP44Params.toSDK(message.path) : undefined); + return obj; + }, + fromAmino(object: Record_LedgerAmino): Record_Ledger { + const message = createBaseRecord_Ledger(); + if (object.path !== undefined && object.path !== null) { + message.path = BIP44Params.fromAmino(object.path); + } + return message; + }, + toAmino(message: Record_Ledger): Record_LedgerAmino { + const obj: any = {}; + obj.path = message.path ? BIP44Params.toAmino(message.path) : undefined; + return obj; + }, + fromAminoMsg(object: Record_LedgerAminoMsg): Record_Ledger { + return Record_Ledger.fromAmino(object.value); + }, + toAminoMsg(message: Record_Ledger): Record_LedgerAminoMsg { + return { + type: "cosmos-sdk/Ledger", + value: Record_Ledger.toAmino(message) + }; + }, + fromProtoMsg(message: Record_LedgerProtoMsg): Record_Ledger { + return Record_Ledger.decode(message.value); + }, + toProto(message: Record_Ledger): Uint8Array { + return Record_Ledger.encode(message).finish(); + }, + toProtoMsg(message: Record_Ledger): Record_LedgerProtoMsg { + return { + typeUrl: "/cosmos.crypto.keyring.v1.Ledger", + value: Record_Ledger.encode(message).finish() + }; + } +}; +function createBaseRecord_Multi(): Record_Multi { + return {}; +} +export const Record_Multi = { + typeUrl: "/cosmos.crypto.keyring.v1.Multi", + encode(_: Record_Multi, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Record_Multi { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseRecord_Multi(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): Record_Multi { + const obj = createBaseRecord_Multi(); + return obj; + }, + toJSON(_: Record_Multi): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): Record_Multi { + const message = createBaseRecord_Multi(); + return message; + }, + fromSDK(_: Record_MultiSDKType): Record_Multi { + return {}; + }, + fromSDKJSON(_: any): Record_MultiSDKType { + return {}; + }, + toSDK(_: Record_Multi): Record_MultiSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: Record_MultiAmino): Record_Multi { + const message = createBaseRecord_Multi(); + return message; + }, + toAmino(_: Record_Multi): Record_MultiAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: Record_MultiAminoMsg): Record_Multi { + return Record_Multi.fromAmino(object.value); + }, + toAminoMsg(message: Record_Multi): Record_MultiAminoMsg { + return { + type: "cosmos-sdk/Multi", + value: Record_Multi.toAmino(message) + }; + }, + fromProtoMsg(message: Record_MultiProtoMsg): Record_Multi { + return Record_Multi.decode(message.value); + }, + toProto(message: Record_Multi): Uint8Array { + return Record_Multi.encode(message).finish(); + }, + toProtoMsg(message: Record_Multi): Record_MultiProtoMsg { + return { + typeUrl: "/cosmos.crypto.keyring.v1.Multi", + value: Record_Multi.encode(message).finish() + }; + } +}; +function createBaseRecord_Offline(): Record_Offline { + return {}; +} +export const Record_Offline = { + typeUrl: "/cosmos.crypto.keyring.v1.Offline", + encode(_: Record_Offline, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Record_Offline { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseRecord_Offline(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): Record_Offline { + const obj = createBaseRecord_Offline(); + return obj; + }, + toJSON(_: Record_Offline): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): Record_Offline { + const message = createBaseRecord_Offline(); + return message; + }, + fromSDK(_: Record_OfflineSDKType): Record_Offline { + return {}; + }, + fromSDKJSON(_: any): Record_OfflineSDKType { + return {}; + }, + toSDK(_: Record_Offline): Record_OfflineSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: Record_OfflineAmino): Record_Offline { + const message = createBaseRecord_Offline(); + return message; + }, + toAmino(_: Record_Offline): Record_OfflineAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: Record_OfflineAminoMsg): Record_Offline { + return Record_Offline.fromAmino(object.value); + }, + toAminoMsg(message: Record_Offline): Record_OfflineAminoMsg { + return { + type: "cosmos-sdk/Offline", + value: Record_Offline.toAmino(message) + }; + }, + fromProtoMsg(message: Record_OfflineProtoMsg): Record_Offline { + return Record_Offline.decode(message.value); + }, + toProto(message: Record_Offline): Uint8Array { + return Record_Offline.encode(message).finish(); + }, + toProtoMsg(message: Record_Offline): Record_OfflineProtoMsg { + return { + typeUrl: "/cosmos.crypto.keyring.v1.Offline", + value: Record_Offline.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/crypto/multisig/keys.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/crypto/multisig/keys.ts new file mode 100644 index 0000000000..2f0309f153 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/crypto/multisig/keys.ts @@ -0,0 +1,148 @@ +import { Any, AnySDKType } from "../../../google/protobuf/any.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "cosmos.crypto.multisig"; +/** + * LegacyAminoPubKey specifies a public key type + * which nests multiple public keys and a threshold, + * it uses legacy amino address rules. + */ +export interface LegacyAminoPubKey { + threshold: number; + publicKeys: Any[]; +} +export interface LegacyAminoPubKeyProtoMsg { + typeUrl: "/cosmos.crypto.multisig.LegacyAminoPubKey"; + value: Uint8Array; +} +/** + * LegacyAminoPubKey specifies a public key type + * which nests multiple public keys and a threshold, + * it uses legacy amino address rules. + */ +export interface LegacyAminoPubKeySDKType { + threshold: number; + public_keys: AnySDKType[]; +} +function createBaseLegacyAminoPubKey(): LegacyAminoPubKey { + return { + threshold: 0, + publicKeys: [] + }; +} +export const LegacyAminoPubKey = { + typeUrl: "/cosmos.crypto.multisig.LegacyAminoPubKey", + encode(message: LegacyAminoPubKey, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.threshold !== undefined) { + writer.uint32(8).uint32(message.threshold); + } + for (const v of message.publicKeys) { + Any.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): LegacyAminoPubKey { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseLegacyAminoPubKey(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.threshold = reader.uint32(); + break; + case 2: + message.publicKeys.push(Any.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): LegacyAminoPubKey { + const obj = createBaseLegacyAminoPubKey(); + if (isSet(object.threshold)) obj.threshold = Number(object.threshold); + if (Array.isArray(object?.publicKeys)) obj.publicKeys = object.publicKeys.map((e: any) => Any.fromJSON(e)); + return obj; + }, + toJSON(message: LegacyAminoPubKey): JsonSafe { + const obj: any = {}; + message.threshold !== undefined && (obj.threshold = Math.round(message.threshold)); + if (message.publicKeys) { + obj.publicKeys = message.publicKeys.map(e => e ? Any.toJSON(e) : undefined); + } else { + obj.publicKeys = []; + } + return obj; + }, + fromPartial(object: DeepPartial): LegacyAminoPubKey { + const message = createBaseLegacyAminoPubKey(); + message.threshold = object.threshold ?? 0; + message.publicKeys = object.publicKeys?.map(e => Any.fromPartial(e)) || []; + return message; + }, + fromSDK(object: LegacyAminoPubKeySDKType): LegacyAminoPubKey { + return { + threshold: object?.threshold, + publicKeys: Array.isArray(object?.public_keys) ? object.public_keys.map((e: any) => Any.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): LegacyAminoPubKeySDKType { + return { + threshold: isSet(object.threshold) ? Number(object.threshold) : 0, + public_keys: Array.isArray(object?.public_keys) ? object.public_keys.map((e: any) => Any.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: LegacyAminoPubKey): LegacyAminoPubKeySDKType { + const obj: any = {}; + obj.threshold = message.threshold; + if (message.publicKeys) { + obj.public_keys = message.publicKeys.map(e => e ? Any.toSDK(e) : undefined); + } else { + obj.public_keys = []; + } + return obj; + }, + fromAmino(object: LegacyAminoPubKeyAmino): LegacyAminoPubKey { + const message = createBaseLegacyAminoPubKey(); + if (object.threshold !== undefined && object.threshold !== null) { + message.threshold = object.threshold; + } + message.publicKeys = object.public_keys?.map(e => Any.fromAmino(e)) || []; + return message; + }, + toAmino(message: LegacyAminoPubKey): LegacyAminoPubKeyAmino { + const obj: any = {}; + obj.threshold = message.threshold === 0 ? undefined : message.threshold; + if (message.publicKeys) { + obj.public_keys = message.publicKeys.map(e => e ? Any.toAmino(e) : undefined); + } else { + obj.public_keys = message.publicKeys; + } + return obj; + }, + fromAminoMsg(object: LegacyAminoPubKeyAminoMsg): LegacyAminoPubKey { + return LegacyAminoPubKey.fromAmino(object.value); + }, + toAminoMsg(message: LegacyAminoPubKey): LegacyAminoPubKeyAminoMsg { + return { + type: "cosmos-sdk/LegacyAminoPubKey", + value: LegacyAminoPubKey.toAmino(message) + }; + }, + fromProtoMsg(message: LegacyAminoPubKeyProtoMsg): LegacyAminoPubKey { + return LegacyAminoPubKey.decode(message.value); + }, + toProto(message: LegacyAminoPubKey): Uint8Array { + return LegacyAminoPubKey.encode(message).finish(); + }, + toProtoMsg(message: LegacyAminoPubKey): LegacyAminoPubKeyProtoMsg { + return { + typeUrl: "/cosmos.crypto.multisig.LegacyAminoPubKey", + value: LegacyAminoPubKey.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/crypto/multisig/v1beta1/multisig.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/crypto/multisig/v1beta1/multisig.ts new file mode 100644 index 0000000000..4a98732634 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/crypto/multisig/v1beta1/multisig.ts @@ -0,0 +1,263 @@ +import { BinaryReader, BinaryWriter } from "../../../../binary.js"; +import { bytesFromBase64, base64FromBytes, DeepPartial, isSet } from "../../../../helpers.js"; +import { JsonSafe } from "../../../../json-safe.js"; +export const protobufPackage = "cosmos.crypto.multisig.v1beta1"; +/** + * MultiSignature wraps the signatures from a multisig.LegacyAminoPubKey. + * See cosmos.tx.v1betata1.ModeInfo.Multi for how to specify which signers + * signed and with which modes. + */ +export interface MultiSignature { + signatures: Uint8Array[]; +} +export interface MultiSignatureProtoMsg { + typeUrl: "/cosmos.crypto.multisig.v1beta1.MultiSignature"; + value: Uint8Array; +} +/** + * MultiSignature wraps the signatures from a multisig.LegacyAminoPubKey. + * See cosmos.tx.v1betata1.ModeInfo.Multi for how to specify which signers + * signed and with which modes. + */ +export interface MultiSignatureSDKType { + signatures: Uint8Array[]; +} +/** + * CompactBitArray is an implementation of a space efficient bit array. + * This is used to ensure that the encoded data takes up a minimal amount of + * space after proto encoding. + * This is not thread safe, and is not intended for concurrent usage. + */ +export interface CompactBitArray { + extraBitsStored: number; + elems: Uint8Array; +} +export interface CompactBitArrayProtoMsg { + typeUrl: "/cosmos.crypto.multisig.v1beta1.CompactBitArray"; + value: Uint8Array; +} +/** + * CompactBitArray is an implementation of a space efficient bit array. + * This is used to ensure that the encoded data takes up a minimal amount of + * space after proto encoding. + * This is not thread safe, and is not intended for concurrent usage. + */ +export interface CompactBitArraySDKType { + extra_bits_stored: number; + elems: Uint8Array; +} +function createBaseMultiSignature(): MultiSignature { + return { + signatures: [] + }; +} +export const MultiSignature = { + typeUrl: "/cosmos.crypto.multisig.v1beta1.MultiSignature", + encode(message: MultiSignature, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.signatures) { + writer.uint32(10).bytes(v!); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MultiSignature { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMultiSignature(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.signatures.push(reader.bytes()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MultiSignature { + const obj = createBaseMultiSignature(); + if (Array.isArray(object?.signatures)) obj.signatures = object.signatures.map((e: any) => bytesFromBase64(e)); + return obj; + }, + toJSON(message: MultiSignature): JsonSafe { + const obj: any = {}; + if (message.signatures) { + obj.signatures = message.signatures.map(e => base64FromBytes(e !== undefined ? e : new Uint8Array())); + } else { + obj.signatures = []; + } + return obj; + }, + fromPartial(object: DeepPartial): MultiSignature { + const message = createBaseMultiSignature(); + message.signatures = object.signatures?.map(e => e) || []; + return message; + }, + fromSDK(object: MultiSignatureSDKType): MultiSignature { + return { + signatures: Array.isArray(object?.signatures) ? object.signatures.map((e: any) => e) : [] + }; + }, + fromSDKJSON(object: any): MultiSignatureSDKType { + return { + signatures: Array.isArray(object?.signatures) ? object.signatures.map((e: any) => bytesFromBase64(e)) : [] + }; + }, + toSDK(message: MultiSignature): MultiSignatureSDKType { + const obj: any = {}; + if (message.signatures) { + obj.signatures = message.signatures.map(e => e); + } else { + obj.signatures = []; + } + return obj; + }, + fromAmino(object: MultiSignatureAmino): MultiSignature { + const message = createBaseMultiSignature(); + message.signatures = object.signatures?.map(e => bytesFromBase64(e)) || []; + return message; + }, + toAmino(message: MultiSignature): MultiSignatureAmino { + const obj: any = {}; + if (message.signatures) { + obj.signatures = message.signatures.map(e => base64FromBytes(e)); + } else { + obj.signatures = message.signatures; + } + return obj; + }, + fromAminoMsg(object: MultiSignatureAminoMsg): MultiSignature { + return MultiSignature.fromAmino(object.value); + }, + toAminoMsg(message: MultiSignature): MultiSignatureAminoMsg { + return { + type: "cosmos-sdk/MultiSignature", + value: MultiSignature.toAmino(message) + }; + }, + fromProtoMsg(message: MultiSignatureProtoMsg): MultiSignature { + return MultiSignature.decode(message.value); + }, + toProto(message: MultiSignature): Uint8Array { + return MultiSignature.encode(message).finish(); + }, + toProtoMsg(message: MultiSignature): MultiSignatureProtoMsg { + return { + typeUrl: "/cosmos.crypto.multisig.v1beta1.MultiSignature", + value: MultiSignature.encode(message).finish() + }; + } +}; +function createBaseCompactBitArray(): CompactBitArray { + return { + extraBitsStored: 0, + elems: new Uint8Array() + }; +} +export const CompactBitArray = { + typeUrl: "/cosmos.crypto.multisig.v1beta1.CompactBitArray", + encode(message: CompactBitArray, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.extraBitsStored !== undefined) { + writer.uint32(8).uint32(message.extraBitsStored); + } + if (message.elems.length !== 0) { + writer.uint32(18).bytes(message.elems); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): CompactBitArray { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCompactBitArray(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.extraBitsStored = reader.uint32(); + break; + case 2: + message.elems = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): CompactBitArray { + const obj = createBaseCompactBitArray(); + if (isSet(object.extraBitsStored)) obj.extraBitsStored = Number(object.extraBitsStored); + if (isSet(object.elems)) obj.elems = bytesFromBase64(object.elems); + return obj; + }, + toJSON(message: CompactBitArray): JsonSafe { + const obj: any = {}; + message.extraBitsStored !== undefined && (obj.extraBitsStored = Math.round(message.extraBitsStored)); + message.elems !== undefined && (obj.elems = base64FromBytes(message.elems !== undefined ? message.elems : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): CompactBitArray { + const message = createBaseCompactBitArray(); + message.extraBitsStored = object.extraBitsStored ?? 0; + message.elems = object.elems ?? new Uint8Array(); + return message; + }, + fromSDK(object: CompactBitArraySDKType): CompactBitArray { + return { + extraBitsStored: object?.extra_bits_stored, + elems: object?.elems + }; + }, + fromSDKJSON(object: any): CompactBitArraySDKType { + return { + extra_bits_stored: isSet(object.extra_bits_stored) ? Number(object.extra_bits_stored) : 0, + elems: isSet(object.elems) ? bytesFromBase64(object.elems) : new Uint8Array() + }; + }, + toSDK(message: CompactBitArray): CompactBitArraySDKType { + const obj: any = {}; + obj.extra_bits_stored = message.extraBitsStored; + obj.elems = message.elems; + return obj; + }, + fromAmino(object: CompactBitArrayAmino): CompactBitArray { + const message = createBaseCompactBitArray(); + if (object.extra_bits_stored !== undefined && object.extra_bits_stored !== null) { + message.extraBitsStored = object.extra_bits_stored; + } + if (object.elems !== undefined && object.elems !== null) { + message.elems = bytesFromBase64(object.elems); + } + return message; + }, + toAmino(message: CompactBitArray): CompactBitArrayAmino { + const obj: any = {}; + obj.extra_bits_stored = message.extraBitsStored === 0 ? undefined : message.extraBitsStored; + obj.elems = message.elems ? base64FromBytes(message.elems) : undefined; + return obj; + }, + fromAminoMsg(object: CompactBitArrayAminoMsg): CompactBitArray { + return CompactBitArray.fromAmino(object.value); + }, + toAminoMsg(message: CompactBitArray): CompactBitArrayAminoMsg { + return { + type: "cosmos-sdk/CompactBitArray", + value: CompactBitArray.toAmino(message) + }; + }, + fromProtoMsg(message: CompactBitArrayProtoMsg): CompactBitArray { + return CompactBitArray.decode(message.value); + }, + toProto(message: CompactBitArray): Uint8Array { + return CompactBitArray.encode(message).finish(); + }, + toProtoMsg(message: CompactBitArray): CompactBitArrayProtoMsg { + return { + typeUrl: "/cosmos.crypto.multisig.v1beta1.CompactBitArray", + value: CompactBitArray.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/crypto/secp256k1/keys.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/crypto/secp256k1/keys.ts new file mode 100644 index 0000000000..d76f05865d --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/crypto/secp256k1/keys.ts @@ -0,0 +1,228 @@ +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, bytesFromBase64, base64FromBytes, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "cosmos.crypto.secp256k1"; +/** + * PubKey defines a secp256k1 public key + * Key is the compressed form of the pubkey. The first byte depends is a 0x02 byte + * if the y-coordinate is the lexicographically largest of the two associated with + * the x-coordinate. Otherwise the first byte is a 0x03. + * This prefix is followed with the x-coordinate. + */ +export interface PubKey { + key: Uint8Array; +} +export interface PubKeyProtoMsg { + typeUrl: "/cosmos.crypto.secp256k1.PubKey"; + value: Uint8Array; +} +/** + * PubKey defines a secp256k1 public key + * Key is the compressed form of the pubkey. The first byte depends is a 0x02 byte + * if the y-coordinate is the lexicographically largest of the two associated with + * the x-coordinate. Otherwise the first byte is a 0x03. + * This prefix is followed with the x-coordinate. + */ +export interface PubKeySDKType { + key: Uint8Array; +} +/** PrivKey defines a secp256k1 private key. */ +export interface PrivKey { + key: Uint8Array; +} +export interface PrivKeyProtoMsg { + typeUrl: "/cosmos.crypto.secp256k1.PrivKey"; + value: Uint8Array; +} +/** PrivKey defines a secp256k1 private key. */ +export interface PrivKeySDKType { + key: Uint8Array; +} +function createBasePubKey(): PubKey { + return { + key: new Uint8Array() + }; +} +export const PubKey = { + typeUrl: "/cosmos.crypto.secp256k1.PubKey", + encode(message: PubKey, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.key.length !== 0) { + writer.uint32(10).bytes(message.key); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): PubKey { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBasePubKey(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): PubKey { + const obj = createBasePubKey(); + if (isSet(object.key)) obj.key = bytesFromBase64(object.key); + return obj; + }, + toJSON(message: PubKey): JsonSafe { + const obj: any = {}; + message.key !== undefined && (obj.key = base64FromBytes(message.key !== undefined ? message.key : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): PubKey { + const message = createBasePubKey(); + message.key = object.key ?? new Uint8Array(); + return message; + }, + fromSDK(object: PubKeySDKType): PubKey { + return { + key: object?.key + }; + }, + fromSDKJSON(object: any): PubKeySDKType { + return { + key: isSet(object.key) ? bytesFromBase64(object.key) : new Uint8Array() + }; + }, + toSDK(message: PubKey): PubKeySDKType { + const obj: any = {}; + obj.key = message.key; + return obj; + }, + fromAmino(object: PubKeyAmino): PubKey { + const message = createBasePubKey(); + if (object.key !== undefined && object.key !== null) { + message.key = bytesFromBase64(object.key); + } + return message; + }, + toAmino(message: PubKey): PubKeyAmino { + const obj: any = {}; + obj.key = message.key ? base64FromBytes(message.key) : undefined; + return obj; + }, + fromAminoMsg(object: PubKeyAminoMsg): PubKey { + return PubKey.fromAmino(object.value); + }, + toAminoMsg(message: PubKey): PubKeyAminoMsg { + return { + type: "cosmos-sdk/PubKey", + value: PubKey.toAmino(message) + }; + }, + fromProtoMsg(message: PubKeyProtoMsg): PubKey { + return PubKey.decode(message.value); + }, + toProto(message: PubKey): Uint8Array { + return PubKey.encode(message).finish(); + }, + toProtoMsg(message: PubKey): PubKeyProtoMsg { + return { + typeUrl: "/cosmos.crypto.secp256k1.PubKey", + value: PubKey.encode(message).finish() + }; + } +}; +function createBasePrivKey(): PrivKey { + return { + key: new Uint8Array() + }; +} +export const PrivKey = { + typeUrl: "/cosmos.crypto.secp256k1.PrivKey", + encode(message: PrivKey, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.key.length !== 0) { + writer.uint32(10).bytes(message.key); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): PrivKey { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBasePrivKey(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): PrivKey { + const obj = createBasePrivKey(); + if (isSet(object.key)) obj.key = bytesFromBase64(object.key); + return obj; + }, + toJSON(message: PrivKey): JsonSafe { + const obj: any = {}; + message.key !== undefined && (obj.key = base64FromBytes(message.key !== undefined ? message.key : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): PrivKey { + const message = createBasePrivKey(); + message.key = object.key ?? new Uint8Array(); + return message; + }, + fromSDK(object: PrivKeySDKType): PrivKey { + return { + key: object?.key + }; + }, + fromSDKJSON(object: any): PrivKeySDKType { + return { + key: isSet(object.key) ? bytesFromBase64(object.key) : new Uint8Array() + }; + }, + toSDK(message: PrivKey): PrivKeySDKType { + const obj: any = {}; + obj.key = message.key; + return obj; + }, + fromAmino(object: PrivKeyAmino): PrivKey { + const message = createBasePrivKey(); + if (object.key !== undefined && object.key !== null) { + message.key = bytesFromBase64(object.key); + } + return message; + }, + toAmino(message: PrivKey): PrivKeyAmino { + const obj: any = {}; + obj.key = message.key ? base64FromBytes(message.key) : undefined; + return obj; + }, + fromAminoMsg(object: PrivKeyAminoMsg): PrivKey { + return PrivKey.fromAmino(object.value); + }, + toAminoMsg(message: PrivKey): PrivKeyAminoMsg { + return { + type: "cosmos-sdk/PrivKey", + value: PrivKey.toAmino(message) + }; + }, + fromProtoMsg(message: PrivKeyProtoMsg): PrivKey { + return PrivKey.decode(message.value); + }, + toProto(message: PrivKey): Uint8Array { + return PrivKey.encode(message).finish(); + }, + toProtoMsg(message: PrivKey): PrivKeyProtoMsg { + return { + typeUrl: "/cosmos.crypto.secp256k1.PrivKey", + value: PrivKey.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/crypto/secp256r1/keys.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/crypto/secp256r1/keys.ts new file mode 100644 index 0000000000..4033485992 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/crypto/secp256r1/keys.ts @@ -0,0 +1,221 @@ +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, bytesFromBase64, base64FromBytes, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "cosmos.crypto.secp256r1"; +/** PubKey defines a secp256r1 ECDSA public key. */ +export interface PubKey { + /** + * Point on secp256r1 curve in a compressed representation as specified in section + * 4.3.6 of ANSI X9.62: https://webstore.ansi.org/standards/ascx9/ansix9621998 + */ + key: Uint8Array; +} +export interface PubKeyProtoMsg { + typeUrl: "/cosmos.crypto.secp256r1.PubKey"; + value: Uint8Array; +} +/** PubKey defines a secp256r1 ECDSA public key. */ +export interface PubKeySDKType { + key: Uint8Array; +} +/** PrivKey defines a secp256r1 ECDSA private key. */ +export interface PrivKey { + /** secret number serialized using big-endian encoding */ + secret: Uint8Array; +} +export interface PrivKeyProtoMsg { + typeUrl: "/cosmos.crypto.secp256r1.PrivKey"; + value: Uint8Array; +} +/** PrivKey defines a secp256r1 ECDSA private key. */ +export interface PrivKeySDKType { + secret: Uint8Array; +} +function createBasePubKey(): PubKey { + return { + key: new Uint8Array() + }; +} +export const PubKey = { + typeUrl: "/cosmos.crypto.secp256r1.PubKey", + encode(message: PubKey, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.key.length !== 0) { + writer.uint32(10).bytes(message.key); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): PubKey { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBasePubKey(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): PubKey { + const obj = createBasePubKey(); + if (isSet(object.key)) obj.key = bytesFromBase64(object.key); + return obj; + }, + toJSON(message: PubKey): JsonSafe { + const obj: any = {}; + message.key !== undefined && (obj.key = base64FromBytes(message.key !== undefined ? message.key : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): PubKey { + const message = createBasePubKey(); + message.key = object.key ?? new Uint8Array(); + return message; + }, + fromSDK(object: PubKeySDKType): PubKey { + return { + key: object?.key + }; + }, + fromSDKJSON(object: any): PubKeySDKType { + return { + key: isSet(object.key) ? bytesFromBase64(object.key) : new Uint8Array() + }; + }, + toSDK(message: PubKey): PubKeySDKType { + const obj: any = {}; + obj.key = message.key; + return obj; + }, + fromAmino(object: PubKeyAmino): PubKey { + const message = createBasePubKey(); + if (object.key !== undefined && object.key !== null) { + message.key = bytesFromBase64(object.key); + } + return message; + }, + toAmino(message: PubKey): PubKeyAmino { + const obj: any = {}; + obj.key = message.key ? base64FromBytes(message.key) : undefined; + return obj; + }, + fromAminoMsg(object: PubKeyAminoMsg): PubKey { + return PubKey.fromAmino(object.value); + }, + toAminoMsg(message: PubKey): PubKeyAminoMsg { + return { + type: "cosmos-sdk/PubKey", + value: PubKey.toAmino(message) + }; + }, + fromProtoMsg(message: PubKeyProtoMsg): PubKey { + return PubKey.decode(message.value); + }, + toProto(message: PubKey): Uint8Array { + return PubKey.encode(message).finish(); + }, + toProtoMsg(message: PubKey): PubKeyProtoMsg { + return { + typeUrl: "/cosmos.crypto.secp256r1.PubKey", + value: PubKey.encode(message).finish() + }; + } +}; +function createBasePrivKey(): PrivKey { + return { + secret: new Uint8Array() + }; +} +export const PrivKey = { + typeUrl: "/cosmos.crypto.secp256r1.PrivKey", + encode(message: PrivKey, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.secret.length !== 0) { + writer.uint32(10).bytes(message.secret); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): PrivKey { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBasePrivKey(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.secret = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): PrivKey { + const obj = createBasePrivKey(); + if (isSet(object.secret)) obj.secret = bytesFromBase64(object.secret); + return obj; + }, + toJSON(message: PrivKey): JsonSafe { + const obj: any = {}; + message.secret !== undefined && (obj.secret = base64FromBytes(message.secret !== undefined ? message.secret : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): PrivKey { + const message = createBasePrivKey(); + message.secret = object.secret ?? new Uint8Array(); + return message; + }, + fromSDK(object: PrivKeySDKType): PrivKey { + return { + secret: object?.secret + }; + }, + fromSDKJSON(object: any): PrivKeySDKType { + return { + secret: isSet(object.secret) ? bytesFromBase64(object.secret) : new Uint8Array() + }; + }, + toSDK(message: PrivKey): PrivKeySDKType { + const obj: any = {}; + obj.secret = message.secret; + return obj; + }, + fromAmino(object: PrivKeyAmino): PrivKey { + const message = createBasePrivKey(); + if (object.secret !== undefined && object.secret !== null) { + message.secret = bytesFromBase64(object.secret); + } + return message; + }, + toAmino(message: PrivKey): PrivKeyAmino { + const obj: any = {}; + obj.secret = message.secret ? base64FromBytes(message.secret) : undefined; + return obj; + }, + fromAminoMsg(object: PrivKeyAminoMsg): PrivKey { + return PrivKey.fromAmino(object.value); + }, + toAminoMsg(message: PrivKey): PrivKeyAminoMsg { + return { + type: "cosmos-sdk/PrivKey", + value: PrivKey.toAmino(message) + }; + }, + fromProtoMsg(message: PrivKeyProtoMsg): PrivKey { + return PrivKey.decode(message.value); + }, + toProto(message: PrivKey): Uint8Array { + return PrivKey.encode(message).finish(); + }, + toProtoMsg(message: PrivKey): PrivKeyProtoMsg { + return { + typeUrl: "/cosmos.crypto.secp256r1.PrivKey", + value: PrivKey.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/distribution/v1beta1/distribution.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/distribution/v1beta1/distribution.ts new file mode 100644 index 0000000000..730006fc36 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/distribution/v1beta1/distribution.ts @@ -0,0 +1,1760 @@ +import { DecCoin, DecCoinSDKType, Coin, CoinSDKType } from "../../base/v1beta1/coin.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { Decimal } from "@cosmjs/math"; +import { isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "cosmos.distribution.v1beta1"; +/** Params defines the set of params for the distribution module. */ +export interface Params { + communityTax: string; + baseProposerReward: string; + bonusProposerReward: string; + withdrawAddrEnabled: boolean; +} +export interface ParamsProtoMsg { + typeUrl: "/cosmos.distribution.v1beta1.Params"; + value: Uint8Array; +} +/** Params defines the set of params for the distribution module. */ +export interface ParamsSDKType { + community_tax: string; + base_proposer_reward: string; + bonus_proposer_reward: string; + withdraw_addr_enabled: boolean; +} +/** + * ValidatorHistoricalRewards represents historical rewards for a validator. + * Height is implicit within the store key. + * Cumulative reward ratio is the sum from the zeroeth period + * until this period of rewards / tokens, per the spec. + * The reference count indicates the number of objects + * which might need to reference this historical entry at any point. + * ReferenceCount = + * number of outstanding delegations which ended the associated period (and + * might need to read that record) + * + number of slashes which ended the associated period (and might need to + * read that record) + * + one per validator for the zeroeth period, set on initialization + */ +export interface ValidatorHistoricalRewards { + cumulativeRewardRatio: DecCoin[]; + referenceCount: number; +} +export interface ValidatorHistoricalRewardsProtoMsg { + typeUrl: "/cosmos.distribution.v1beta1.ValidatorHistoricalRewards"; + value: Uint8Array; +} +/** + * ValidatorHistoricalRewards represents historical rewards for a validator. + * Height is implicit within the store key. + * Cumulative reward ratio is the sum from the zeroeth period + * until this period of rewards / tokens, per the spec. + * The reference count indicates the number of objects + * which might need to reference this historical entry at any point. + * ReferenceCount = + * number of outstanding delegations which ended the associated period (and + * might need to read that record) + * + number of slashes which ended the associated period (and might need to + * read that record) + * + one per validator for the zeroeth period, set on initialization + */ +export interface ValidatorHistoricalRewardsSDKType { + cumulative_reward_ratio: DecCoinSDKType[]; + reference_count: number; +} +/** + * ValidatorCurrentRewards represents current rewards and current + * period for a validator kept as a running counter and incremented + * each block as long as the validator's tokens remain constant. + */ +export interface ValidatorCurrentRewards { + rewards: DecCoin[]; + period: bigint; +} +export interface ValidatorCurrentRewardsProtoMsg { + typeUrl: "/cosmos.distribution.v1beta1.ValidatorCurrentRewards"; + value: Uint8Array; +} +/** + * ValidatorCurrentRewards represents current rewards and current + * period for a validator kept as a running counter and incremented + * each block as long as the validator's tokens remain constant. + */ +export interface ValidatorCurrentRewardsSDKType { + rewards: DecCoinSDKType[]; + period: bigint; +} +/** + * ValidatorAccumulatedCommission represents accumulated commission + * for a validator kept as a running counter, can be withdrawn at any time. + */ +export interface ValidatorAccumulatedCommission { + commission: DecCoin[]; +} +export interface ValidatorAccumulatedCommissionProtoMsg { + typeUrl: "/cosmos.distribution.v1beta1.ValidatorAccumulatedCommission"; + value: Uint8Array; +} +/** + * ValidatorAccumulatedCommission represents accumulated commission + * for a validator kept as a running counter, can be withdrawn at any time. + */ +export interface ValidatorAccumulatedCommissionSDKType { + commission: DecCoinSDKType[]; +} +/** + * ValidatorOutstandingRewards represents outstanding (un-withdrawn) rewards + * for a validator inexpensive to track, allows simple sanity checks. + */ +export interface ValidatorOutstandingRewards { + rewards: DecCoin[]; +} +export interface ValidatorOutstandingRewardsProtoMsg { + typeUrl: "/cosmos.distribution.v1beta1.ValidatorOutstandingRewards"; + value: Uint8Array; +} +/** + * ValidatorOutstandingRewards represents outstanding (un-withdrawn) rewards + * for a validator inexpensive to track, allows simple sanity checks. + */ +export interface ValidatorOutstandingRewardsSDKType { + rewards: DecCoinSDKType[]; +} +/** + * ValidatorSlashEvent represents a validator slash event. + * Height is implicit within the store key. + * This is needed to calculate appropriate amount of staking tokens + * for delegations which are withdrawn after a slash has occurred. + */ +export interface ValidatorSlashEvent { + validatorPeriod: bigint; + fraction: string; +} +export interface ValidatorSlashEventProtoMsg { + typeUrl: "/cosmos.distribution.v1beta1.ValidatorSlashEvent"; + value: Uint8Array; +} +/** + * ValidatorSlashEvent represents a validator slash event. + * Height is implicit within the store key. + * This is needed to calculate appropriate amount of staking tokens + * for delegations which are withdrawn after a slash has occurred. + */ +export interface ValidatorSlashEventSDKType { + validator_period: bigint; + fraction: string; +} +/** ValidatorSlashEvents is a collection of ValidatorSlashEvent messages. */ +export interface ValidatorSlashEvents { + validatorSlashEvents: ValidatorSlashEvent[]; +} +export interface ValidatorSlashEventsProtoMsg { + typeUrl: "/cosmos.distribution.v1beta1.ValidatorSlashEvents"; + value: Uint8Array; +} +/** ValidatorSlashEvents is a collection of ValidatorSlashEvent messages. */ +export interface ValidatorSlashEventsSDKType { + validator_slash_events: ValidatorSlashEventSDKType[]; +} +/** FeePool is the global fee pool for distribution. */ +export interface FeePool { + communityPool: DecCoin[]; +} +export interface FeePoolProtoMsg { + typeUrl: "/cosmos.distribution.v1beta1.FeePool"; + value: Uint8Array; +} +/** FeePool is the global fee pool for distribution. */ +export interface FeePoolSDKType { + community_pool: DecCoinSDKType[]; +} +/** + * CommunityPoolSpendProposal details a proposal for use of community funds, + * together with how many coins are proposed to be spent, and to which + * recipient account. + */ +export interface CommunityPoolSpendProposal { + title: string; + description: string; + recipient: string; + amount: Coin[]; +} +export interface CommunityPoolSpendProposalProtoMsg { + typeUrl: "/cosmos.distribution.v1beta1.CommunityPoolSpendProposal"; + value: Uint8Array; +} +/** + * CommunityPoolSpendProposal details a proposal for use of community funds, + * together with how many coins are proposed to be spent, and to which + * recipient account. + */ +export interface CommunityPoolSpendProposalSDKType { + title: string; + description: string; + recipient: string; + amount: CoinSDKType[]; +} +/** + * DelegatorStartingInfo represents the starting info for a delegator reward + * period. It tracks the previous validator period, the delegation's amount of + * staking token, and the creation height (to check later on if any slashes have + * occurred). NOTE: Even though validators are slashed to whole staking tokens, + * the delegators within the validator may be left with less than a full token, + * thus sdk.Dec is used. + */ +export interface DelegatorStartingInfo { + previousPeriod: bigint; + stake: string; + height: bigint; +} +export interface DelegatorStartingInfoProtoMsg { + typeUrl: "/cosmos.distribution.v1beta1.DelegatorStartingInfo"; + value: Uint8Array; +} +/** + * DelegatorStartingInfo represents the starting info for a delegator reward + * period. It tracks the previous validator period, the delegation's amount of + * staking token, and the creation height (to check later on if any slashes have + * occurred). NOTE: Even though validators are slashed to whole staking tokens, + * the delegators within the validator may be left with less than a full token, + * thus sdk.Dec is used. + */ +export interface DelegatorStartingInfoSDKType { + previous_period: bigint; + stake: string; + height: bigint; +} +/** + * DelegationDelegatorReward represents the properties + * of a delegator's delegation reward. + */ +export interface DelegationDelegatorReward { + validatorAddress: string; + reward: DecCoin[]; +} +export interface DelegationDelegatorRewardProtoMsg { + typeUrl: "/cosmos.distribution.v1beta1.DelegationDelegatorReward"; + value: Uint8Array; +} +/** + * DelegationDelegatorReward represents the properties + * of a delegator's delegation reward. + */ +export interface DelegationDelegatorRewardSDKType { + validator_address: string; + reward: DecCoinSDKType[]; +} +/** + * CommunityPoolSpendProposalWithDeposit defines a CommunityPoolSpendProposal + * with a deposit + */ +export interface CommunityPoolSpendProposalWithDeposit { + title: string; + description: string; + recipient: string; + amount: string; + deposit: string; +} +export interface CommunityPoolSpendProposalWithDepositProtoMsg { + typeUrl: "/cosmos.distribution.v1beta1.CommunityPoolSpendProposalWithDeposit"; + value: Uint8Array; +} +/** + * CommunityPoolSpendProposalWithDeposit defines a CommunityPoolSpendProposal + * with a deposit + */ +export interface CommunityPoolSpendProposalWithDepositSDKType { + title: string; + description: string; + recipient: string; + amount: string; + deposit: string; +} +function createBaseParams(): Params { + return { + communityTax: "", + baseProposerReward: "", + bonusProposerReward: "", + withdrawAddrEnabled: false + }; +} +export const Params = { + typeUrl: "/cosmos.distribution.v1beta1.Params", + encode(message: Params, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.communityTax !== undefined) { + writer.uint32(10).string(Decimal.fromUserInput(message.communityTax, 18).atomics); + } + if (message.baseProposerReward !== undefined) { + writer.uint32(18).string(Decimal.fromUserInput(message.baseProposerReward, 18).atomics); + } + if (message.bonusProposerReward !== undefined) { + writer.uint32(26).string(Decimal.fromUserInput(message.bonusProposerReward, 18).atomics); + } + if (message.withdrawAddrEnabled !== undefined) { + writer.uint32(32).bool(message.withdrawAddrEnabled); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Params { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseParams(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.communityTax = Decimal.fromAtomics(reader.string(), 18).toString(); + break; + case 2: + message.baseProposerReward = Decimal.fromAtomics(reader.string(), 18).toString(); + break; + case 3: + message.bonusProposerReward = Decimal.fromAtomics(reader.string(), 18).toString(); + break; + case 4: + message.withdrawAddrEnabled = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Params { + const obj = createBaseParams(); + if (isSet(object.communityTax)) obj.communityTax = String(object.communityTax); + if (isSet(object.baseProposerReward)) obj.baseProposerReward = String(object.baseProposerReward); + if (isSet(object.bonusProposerReward)) obj.bonusProposerReward = String(object.bonusProposerReward); + if (isSet(object.withdrawAddrEnabled)) obj.withdrawAddrEnabled = Boolean(object.withdrawAddrEnabled); + return obj; + }, + toJSON(message: Params): JsonSafe { + const obj: any = {}; + message.communityTax !== undefined && (obj.communityTax = message.communityTax); + message.baseProposerReward !== undefined && (obj.baseProposerReward = message.baseProposerReward); + message.bonusProposerReward !== undefined && (obj.bonusProposerReward = message.bonusProposerReward); + message.withdrawAddrEnabled !== undefined && (obj.withdrawAddrEnabled = message.withdrawAddrEnabled); + return obj; + }, + fromPartial(object: DeepPartial): Params { + const message = createBaseParams(); + message.communityTax = object.communityTax ?? ""; + message.baseProposerReward = object.baseProposerReward ?? ""; + message.bonusProposerReward = object.bonusProposerReward ?? ""; + message.withdrawAddrEnabled = object.withdrawAddrEnabled ?? false; + return message; + }, + fromSDK(object: ParamsSDKType): Params { + return { + communityTax: object?.community_tax, + baseProposerReward: object?.base_proposer_reward, + bonusProposerReward: object?.bonus_proposer_reward, + withdrawAddrEnabled: object?.withdraw_addr_enabled + }; + }, + fromSDKJSON(object: any): ParamsSDKType { + return { + community_tax: isSet(object.community_tax) ? String(object.community_tax) : "", + base_proposer_reward: isSet(object.base_proposer_reward) ? String(object.base_proposer_reward) : "", + bonus_proposer_reward: isSet(object.bonus_proposer_reward) ? String(object.bonus_proposer_reward) : "", + withdraw_addr_enabled: isSet(object.withdraw_addr_enabled) ? Boolean(object.withdraw_addr_enabled) : false + }; + }, + toSDK(message: Params): ParamsSDKType { + const obj: any = {}; + obj.community_tax = message.communityTax; + obj.base_proposer_reward = message.baseProposerReward; + obj.bonus_proposer_reward = message.bonusProposerReward; + obj.withdraw_addr_enabled = message.withdrawAddrEnabled; + return obj; + }, + fromAmino(object: ParamsAmino): Params { + const message = createBaseParams(); + if (object.community_tax !== undefined && object.community_tax !== null) { + message.communityTax = object.community_tax; + } + if (object.base_proposer_reward !== undefined && object.base_proposer_reward !== null) { + message.baseProposerReward = object.base_proposer_reward; + } + if (object.bonus_proposer_reward !== undefined && object.bonus_proposer_reward !== null) { + message.bonusProposerReward = object.bonus_proposer_reward; + } + if (object.withdraw_addr_enabled !== undefined && object.withdraw_addr_enabled !== null) { + message.withdrawAddrEnabled = object.withdraw_addr_enabled; + } + return message; + }, + toAmino(message: Params): ParamsAmino { + const obj: any = {}; + obj.community_tax = message.communityTax === "" ? undefined : message.communityTax; + obj.base_proposer_reward = message.baseProposerReward === "" ? undefined : message.baseProposerReward; + obj.bonus_proposer_reward = message.bonusProposerReward === "" ? undefined : message.bonusProposerReward; + obj.withdraw_addr_enabled = message.withdrawAddrEnabled === false ? undefined : message.withdrawAddrEnabled; + return obj; + }, + fromAminoMsg(object: ParamsAminoMsg): Params { + return Params.fromAmino(object.value); + }, + toAminoMsg(message: Params): ParamsAminoMsg { + return { + type: "cosmos-sdk/Params", + value: Params.toAmino(message) + }; + }, + fromProtoMsg(message: ParamsProtoMsg): Params { + return Params.decode(message.value); + }, + toProto(message: Params): Uint8Array { + return Params.encode(message).finish(); + }, + toProtoMsg(message: Params): ParamsProtoMsg { + return { + typeUrl: "/cosmos.distribution.v1beta1.Params", + value: Params.encode(message).finish() + }; + } +}; +function createBaseValidatorHistoricalRewards(): ValidatorHistoricalRewards { + return { + cumulativeRewardRatio: [], + referenceCount: 0 + }; +} +export const ValidatorHistoricalRewards = { + typeUrl: "/cosmos.distribution.v1beta1.ValidatorHistoricalRewards", + encode(message: ValidatorHistoricalRewards, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.cumulativeRewardRatio) { + DecCoin.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.referenceCount !== undefined) { + writer.uint32(16).uint32(message.referenceCount); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ValidatorHistoricalRewards { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseValidatorHistoricalRewards(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.cumulativeRewardRatio.push(DecCoin.decode(reader, reader.uint32())); + break; + case 2: + message.referenceCount = reader.uint32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ValidatorHistoricalRewards { + const obj = createBaseValidatorHistoricalRewards(); + if (Array.isArray(object?.cumulativeRewardRatio)) obj.cumulativeRewardRatio = object.cumulativeRewardRatio.map((e: any) => DecCoin.fromJSON(e)); + if (isSet(object.referenceCount)) obj.referenceCount = Number(object.referenceCount); + return obj; + }, + toJSON(message: ValidatorHistoricalRewards): JsonSafe { + const obj: any = {}; + if (message.cumulativeRewardRatio) { + obj.cumulativeRewardRatio = message.cumulativeRewardRatio.map(e => e ? DecCoin.toJSON(e) : undefined); + } else { + obj.cumulativeRewardRatio = []; + } + message.referenceCount !== undefined && (obj.referenceCount = Math.round(message.referenceCount)); + return obj; + }, + fromPartial(object: DeepPartial): ValidatorHistoricalRewards { + const message = createBaseValidatorHistoricalRewards(); + message.cumulativeRewardRatio = object.cumulativeRewardRatio?.map(e => DecCoin.fromPartial(e)) || []; + message.referenceCount = object.referenceCount ?? 0; + return message; + }, + fromSDK(object: ValidatorHistoricalRewardsSDKType): ValidatorHistoricalRewards { + return { + cumulativeRewardRatio: Array.isArray(object?.cumulative_reward_ratio) ? object.cumulative_reward_ratio.map((e: any) => DecCoin.fromSDK(e)) : [], + referenceCount: object?.reference_count + }; + }, + fromSDKJSON(object: any): ValidatorHistoricalRewardsSDKType { + return { + cumulative_reward_ratio: Array.isArray(object?.cumulative_reward_ratio) ? object.cumulative_reward_ratio.map((e: any) => DecCoin.fromSDKJSON(e)) : [], + reference_count: isSet(object.reference_count) ? Number(object.reference_count) : 0 + }; + }, + toSDK(message: ValidatorHistoricalRewards): ValidatorHistoricalRewardsSDKType { + const obj: any = {}; + if (message.cumulativeRewardRatio) { + obj.cumulative_reward_ratio = message.cumulativeRewardRatio.map(e => e ? DecCoin.toSDK(e) : undefined); + } else { + obj.cumulative_reward_ratio = []; + } + obj.reference_count = message.referenceCount; + return obj; + }, + fromAmino(object: ValidatorHistoricalRewardsAmino): ValidatorHistoricalRewards { + const message = createBaseValidatorHistoricalRewards(); + message.cumulativeRewardRatio = object.cumulative_reward_ratio?.map(e => DecCoin.fromAmino(e)) || []; + if (object.reference_count !== undefined && object.reference_count !== null) { + message.referenceCount = object.reference_count; + } + return message; + }, + toAmino(message: ValidatorHistoricalRewards): ValidatorHistoricalRewardsAmino { + const obj: any = {}; + if (message.cumulativeRewardRatio) { + obj.cumulative_reward_ratio = message.cumulativeRewardRatio.map(e => e ? DecCoin.toAmino(e) : undefined); + } else { + obj.cumulative_reward_ratio = message.cumulativeRewardRatio; + } + obj.reference_count = message.referenceCount === 0 ? undefined : message.referenceCount; + return obj; + }, + fromAminoMsg(object: ValidatorHistoricalRewardsAminoMsg): ValidatorHistoricalRewards { + return ValidatorHistoricalRewards.fromAmino(object.value); + }, + toAminoMsg(message: ValidatorHistoricalRewards): ValidatorHistoricalRewardsAminoMsg { + return { + type: "cosmos-sdk/ValidatorHistoricalRewards", + value: ValidatorHistoricalRewards.toAmino(message) + }; + }, + fromProtoMsg(message: ValidatorHistoricalRewardsProtoMsg): ValidatorHistoricalRewards { + return ValidatorHistoricalRewards.decode(message.value); + }, + toProto(message: ValidatorHistoricalRewards): Uint8Array { + return ValidatorHistoricalRewards.encode(message).finish(); + }, + toProtoMsg(message: ValidatorHistoricalRewards): ValidatorHistoricalRewardsProtoMsg { + return { + typeUrl: "/cosmos.distribution.v1beta1.ValidatorHistoricalRewards", + value: ValidatorHistoricalRewards.encode(message).finish() + }; + } +}; +function createBaseValidatorCurrentRewards(): ValidatorCurrentRewards { + return { + rewards: [], + period: BigInt(0) + }; +} +export const ValidatorCurrentRewards = { + typeUrl: "/cosmos.distribution.v1beta1.ValidatorCurrentRewards", + encode(message: ValidatorCurrentRewards, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.rewards) { + DecCoin.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.period !== undefined) { + writer.uint32(16).uint64(message.period); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ValidatorCurrentRewards { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseValidatorCurrentRewards(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.rewards.push(DecCoin.decode(reader, reader.uint32())); + break; + case 2: + message.period = reader.uint64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ValidatorCurrentRewards { + const obj = createBaseValidatorCurrentRewards(); + if (Array.isArray(object?.rewards)) obj.rewards = object.rewards.map((e: any) => DecCoin.fromJSON(e)); + if (isSet(object.period)) obj.period = BigInt(object.period.toString()); + return obj; + }, + toJSON(message: ValidatorCurrentRewards): JsonSafe { + const obj: any = {}; + if (message.rewards) { + obj.rewards = message.rewards.map(e => e ? DecCoin.toJSON(e) : undefined); + } else { + obj.rewards = []; + } + message.period !== undefined && (obj.period = (message.period || BigInt(0)).toString()); + return obj; + }, + fromPartial(object: DeepPartial): ValidatorCurrentRewards { + const message = createBaseValidatorCurrentRewards(); + message.rewards = object.rewards?.map(e => DecCoin.fromPartial(e)) || []; + if (object.period !== undefined && object.period !== null) { + message.period = BigInt(object.period.toString()); + } + return message; + }, + fromSDK(object: ValidatorCurrentRewardsSDKType): ValidatorCurrentRewards { + return { + rewards: Array.isArray(object?.rewards) ? object.rewards.map((e: any) => DecCoin.fromSDK(e)) : [], + period: object?.period + }; + }, + fromSDKJSON(object: any): ValidatorCurrentRewardsSDKType { + return { + rewards: Array.isArray(object?.rewards) ? object.rewards.map((e: any) => DecCoin.fromSDKJSON(e)) : [], + period: isSet(object.period) ? BigInt(object.period.toString()) : BigInt(0) + }; + }, + toSDK(message: ValidatorCurrentRewards): ValidatorCurrentRewardsSDKType { + const obj: any = {}; + if (message.rewards) { + obj.rewards = message.rewards.map(e => e ? DecCoin.toSDK(e) : undefined); + } else { + obj.rewards = []; + } + obj.period = message.period; + return obj; + }, + fromAmino(object: ValidatorCurrentRewardsAmino): ValidatorCurrentRewards { + const message = createBaseValidatorCurrentRewards(); + message.rewards = object.rewards?.map(e => DecCoin.fromAmino(e)) || []; + if (object.period !== undefined && object.period !== null) { + message.period = BigInt(object.period); + } + return message; + }, + toAmino(message: ValidatorCurrentRewards): ValidatorCurrentRewardsAmino { + const obj: any = {}; + if (message.rewards) { + obj.rewards = message.rewards.map(e => e ? DecCoin.toAmino(e) : undefined); + } else { + obj.rewards = message.rewards; + } + obj.period = message.period !== BigInt(0) ? message.period?.toString() : undefined; + return obj; + }, + fromAminoMsg(object: ValidatorCurrentRewardsAminoMsg): ValidatorCurrentRewards { + return ValidatorCurrentRewards.fromAmino(object.value); + }, + toAminoMsg(message: ValidatorCurrentRewards): ValidatorCurrentRewardsAminoMsg { + return { + type: "cosmos-sdk/ValidatorCurrentRewards", + value: ValidatorCurrentRewards.toAmino(message) + }; + }, + fromProtoMsg(message: ValidatorCurrentRewardsProtoMsg): ValidatorCurrentRewards { + return ValidatorCurrentRewards.decode(message.value); + }, + toProto(message: ValidatorCurrentRewards): Uint8Array { + return ValidatorCurrentRewards.encode(message).finish(); + }, + toProtoMsg(message: ValidatorCurrentRewards): ValidatorCurrentRewardsProtoMsg { + return { + typeUrl: "/cosmos.distribution.v1beta1.ValidatorCurrentRewards", + value: ValidatorCurrentRewards.encode(message).finish() + }; + } +}; +function createBaseValidatorAccumulatedCommission(): ValidatorAccumulatedCommission { + return { + commission: [] + }; +} +export const ValidatorAccumulatedCommission = { + typeUrl: "/cosmos.distribution.v1beta1.ValidatorAccumulatedCommission", + encode(message: ValidatorAccumulatedCommission, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.commission) { + DecCoin.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ValidatorAccumulatedCommission { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseValidatorAccumulatedCommission(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.commission.push(DecCoin.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ValidatorAccumulatedCommission { + const obj = createBaseValidatorAccumulatedCommission(); + if (Array.isArray(object?.commission)) obj.commission = object.commission.map((e: any) => DecCoin.fromJSON(e)); + return obj; + }, + toJSON(message: ValidatorAccumulatedCommission): JsonSafe { + const obj: any = {}; + if (message.commission) { + obj.commission = message.commission.map(e => e ? DecCoin.toJSON(e) : undefined); + } else { + obj.commission = []; + } + return obj; + }, + fromPartial(object: DeepPartial): ValidatorAccumulatedCommission { + const message = createBaseValidatorAccumulatedCommission(); + message.commission = object.commission?.map(e => DecCoin.fromPartial(e)) || []; + return message; + }, + fromSDK(object: ValidatorAccumulatedCommissionSDKType): ValidatorAccumulatedCommission { + return { + commission: Array.isArray(object?.commission) ? object.commission.map((e: any) => DecCoin.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): ValidatorAccumulatedCommissionSDKType { + return { + commission: Array.isArray(object?.commission) ? object.commission.map((e: any) => DecCoin.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: ValidatorAccumulatedCommission): ValidatorAccumulatedCommissionSDKType { + const obj: any = {}; + if (message.commission) { + obj.commission = message.commission.map(e => e ? DecCoin.toSDK(e) : undefined); + } else { + obj.commission = []; + } + return obj; + }, + fromAmino(object: ValidatorAccumulatedCommissionAmino): ValidatorAccumulatedCommission { + const message = createBaseValidatorAccumulatedCommission(); + message.commission = object.commission?.map(e => DecCoin.fromAmino(e)) || []; + return message; + }, + toAmino(message: ValidatorAccumulatedCommission): ValidatorAccumulatedCommissionAmino { + const obj: any = {}; + if (message.commission) { + obj.commission = message.commission.map(e => e ? DecCoin.toAmino(e) : undefined); + } else { + obj.commission = message.commission; + } + return obj; + }, + fromAminoMsg(object: ValidatorAccumulatedCommissionAminoMsg): ValidatorAccumulatedCommission { + return ValidatorAccumulatedCommission.fromAmino(object.value); + }, + toAminoMsg(message: ValidatorAccumulatedCommission): ValidatorAccumulatedCommissionAminoMsg { + return { + type: "cosmos-sdk/ValidatorAccumulatedCommission", + value: ValidatorAccumulatedCommission.toAmino(message) + }; + }, + fromProtoMsg(message: ValidatorAccumulatedCommissionProtoMsg): ValidatorAccumulatedCommission { + return ValidatorAccumulatedCommission.decode(message.value); + }, + toProto(message: ValidatorAccumulatedCommission): Uint8Array { + return ValidatorAccumulatedCommission.encode(message).finish(); + }, + toProtoMsg(message: ValidatorAccumulatedCommission): ValidatorAccumulatedCommissionProtoMsg { + return { + typeUrl: "/cosmos.distribution.v1beta1.ValidatorAccumulatedCommission", + value: ValidatorAccumulatedCommission.encode(message).finish() + }; + } +}; +function createBaseValidatorOutstandingRewards(): ValidatorOutstandingRewards { + return { + rewards: [] + }; +} +export const ValidatorOutstandingRewards = { + typeUrl: "/cosmos.distribution.v1beta1.ValidatorOutstandingRewards", + encode(message: ValidatorOutstandingRewards, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.rewards) { + DecCoin.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ValidatorOutstandingRewards { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseValidatorOutstandingRewards(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.rewards.push(DecCoin.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ValidatorOutstandingRewards { + const obj = createBaseValidatorOutstandingRewards(); + if (Array.isArray(object?.rewards)) obj.rewards = object.rewards.map((e: any) => DecCoin.fromJSON(e)); + return obj; + }, + toJSON(message: ValidatorOutstandingRewards): JsonSafe { + const obj: any = {}; + if (message.rewards) { + obj.rewards = message.rewards.map(e => e ? DecCoin.toJSON(e) : undefined); + } else { + obj.rewards = []; + } + return obj; + }, + fromPartial(object: DeepPartial): ValidatorOutstandingRewards { + const message = createBaseValidatorOutstandingRewards(); + message.rewards = object.rewards?.map(e => DecCoin.fromPartial(e)) || []; + return message; + }, + fromSDK(object: ValidatorOutstandingRewardsSDKType): ValidatorOutstandingRewards { + return { + rewards: Array.isArray(object?.rewards) ? object.rewards.map((e: any) => DecCoin.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): ValidatorOutstandingRewardsSDKType { + return { + rewards: Array.isArray(object?.rewards) ? object.rewards.map((e: any) => DecCoin.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: ValidatorOutstandingRewards): ValidatorOutstandingRewardsSDKType { + const obj: any = {}; + if (message.rewards) { + obj.rewards = message.rewards.map(e => e ? DecCoin.toSDK(e) : undefined); + } else { + obj.rewards = []; + } + return obj; + }, + fromAmino(object: ValidatorOutstandingRewardsAmino): ValidatorOutstandingRewards { + const message = createBaseValidatorOutstandingRewards(); + message.rewards = object.rewards?.map(e => DecCoin.fromAmino(e)) || []; + return message; + }, + toAmino(message: ValidatorOutstandingRewards): ValidatorOutstandingRewardsAmino { + const obj: any = {}; + if (message.rewards) { + obj.rewards = message.rewards.map(e => e ? DecCoin.toAmino(e) : undefined); + } else { + obj.rewards = message.rewards; + } + return obj; + }, + fromAminoMsg(object: ValidatorOutstandingRewardsAminoMsg): ValidatorOutstandingRewards { + return ValidatorOutstandingRewards.fromAmino(object.value); + }, + toAminoMsg(message: ValidatorOutstandingRewards): ValidatorOutstandingRewardsAminoMsg { + return { + type: "cosmos-sdk/ValidatorOutstandingRewards", + value: ValidatorOutstandingRewards.toAmino(message) + }; + }, + fromProtoMsg(message: ValidatorOutstandingRewardsProtoMsg): ValidatorOutstandingRewards { + return ValidatorOutstandingRewards.decode(message.value); + }, + toProto(message: ValidatorOutstandingRewards): Uint8Array { + return ValidatorOutstandingRewards.encode(message).finish(); + }, + toProtoMsg(message: ValidatorOutstandingRewards): ValidatorOutstandingRewardsProtoMsg { + return { + typeUrl: "/cosmos.distribution.v1beta1.ValidatorOutstandingRewards", + value: ValidatorOutstandingRewards.encode(message).finish() + }; + } +}; +function createBaseValidatorSlashEvent(): ValidatorSlashEvent { + return { + validatorPeriod: BigInt(0), + fraction: "" + }; +} +export const ValidatorSlashEvent = { + typeUrl: "/cosmos.distribution.v1beta1.ValidatorSlashEvent", + encode(message: ValidatorSlashEvent, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.validatorPeriod !== undefined) { + writer.uint32(8).uint64(message.validatorPeriod); + } + if (message.fraction !== undefined) { + writer.uint32(18).string(Decimal.fromUserInput(message.fraction, 18).atomics); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ValidatorSlashEvent { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseValidatorSlashEvent(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.validatorPeriod = reader.uint64(); + break; + case 2: + message.fraction = Decimal.fromAtomics(reader.string(), 18).toString(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ValidatorSlashEvent { + const obj = createBaseValidatorSlashEvent(); + if (isSet(object.validatorPeriod)) obj.validatorPeriod = BigInt(object.validatorPeriod.toString()); + if (isSet(object.fraction)) obj.fraction = String(object.fraction); + return obj; + }, + toJSON(message: ValidatorSlashEvent): JsonSafe { + const obj: any = {}; + message.validatorPeriod !== undefined && (obj.validatorPeriod = (message.validatorPeriod || BigInt(0)).toString()); + message.fraction !== undefined && (obj.fraction = message.fraction); + return obj; + }, + fromPartial(object: DeepPartial): ValidatorSlashEvent { + const message = createBaseValidatorSlashEvent(); + if (object.validatorPeriod !== undefined && object.validatorPeriod !== null) { + message.validatorPeriod = BigInt(object.validatorPeriod.toString()); + } + message.fraction = object.fraction ?? ""; + return message; + }, + fromSDK(object: ValidatorSlashEventSDKType): ValidatorSlashEvent { + return { + validatorPeriod: object?.validator_period, + fraction: object?.fraction + }; + }, + fromSDKJSON(object: any): ValidatorSlashEventSDKType { + return { + validator_period: isSet(object.validator_period) ? BigInt(object.validator_period.toString()) : BigInt(0), + fraction: isSet(object.fraction) ? String(object.fraction) : "" + }; + }, + toSDK(message: ValidatorSlashEvent): ValidatorSlashEventSDKType { + const obj: any = {}; + obj.validator_period = message.validatorPeriod; + obj.fraction = message.fraction; + return obj; + }, + fromAmino(object: ValidatorSlashEventAmino): ValidatorSlashEvent { + const message = createBaseValidatorSlashEvent(); + if (object.validator_period !== undefined && object.validator_period !== null) { + message.validatorPeriod = BigInt(object.validator_period); + } + if (object.fraction !== undefined && object.fraction !== null) { + message.fraction = object.fraction; + } + return message; + }, + toAmino(message: ValidatorSlashEvent): ValidatorSlashEventAmino { + const obj: any = {}; + obj.validator_period = message.validatorPeriod !== BigInt(0) ? message.validatorPeriod?.toString() : undefined; + obj.fraction = message.fraction === "" ? undefined : message.fraction; + return obj; + }, + fromAminoMsg(object: ValidatorSlashEventAminoMsg): ValidatorSlashEvent { + return ValidatorSlashEvent.fromAmino(object.value); + }, + toAminoMsg(message: ValidatorSlashEvent): ValidatorSlashEventAminoMsg { + return { + type: "cosmos-sdk/ValidatorSlashEvent", + value: ValidatorSlashEvent.toAmino(message) + }; + }, + fromProtoMsg(message: ValidatorSlashEventProtoMsg): ValidatorSlashEvent { + return ValidatorSlashEvent.decode(message.value); + }, + toProto(message: ValidatorSlashEvent): Uint8Array { + return ValidatorSlashEvent.encode(message).finish(); + }, + toProtoMsg(message: ValidatorSlashEvent): ValidatorSlashEventProtoMsg { + return { + typeUrl: "/cosmos.distribution.v1beta1.ValidatorSlashEvent", + value: ValidatorSlashEvent.encode(message).finish() + }; + } +}; +function createBaseValidatorSlashEvents(): ValidatorSlashEvents { + return { + validatorSlashEvents: [] + }; +} +export const ValidatorSlashEvents = { + typeUrl: "/cosmos.distribution.v1beta1.ValidatorSlashEvents", + encode(message: ValidatorSlashEvents, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.validatorSlashEvents) { + ValidatorSlashEvent.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ValidatorSlashEvents { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseValidatorSlashEvents(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.validatorSlashEvents.push(ValidatorSlashEvent.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ValidatorSlashEvents { + const obj = createBaseValidatorSlashEvents(); + if (Array.isArray(object?.validatorSlashEvents)) obj.validatorSlashEvents = object.validatorSlashEvents.map((e: any) => ValidatorSlashEvent.fromJSON(e)); + return obj; + }, + toJSON(message: ValidatorSlashEvents): JsonSafe { + const obj: any = {}; + if (message.validatorSlashEvents) { + obj.validatorSlashEvents = message.validatorSlashEvents.map(e => e ? ValidatorSlashEvent.toJSON(e) : undefined); + } else { + obj.validatorSlashEvents = []; + } + return obj; + }, + fromPartial(object: DeepPartial): ValidatorSlashEvents { + const message = createBaseValidatorSlashEvents(); + message.validatorSlashEvents = object.validatorSlashEvents?.map(e => ValidatorSlashEvent.fromPartial(e)) || []; + return message; + }, + fromSDK(object: ValidatorSlashEventsSDKType): ValidatorSlashEvents { + return { + validatorSlashEvents: Array.isArray(object?.validator_slash_events) ? object.validator_slash_events.map((e: any) => ValidatorSlashEvent.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): ValidatorSlashEventsSDKType { + return { + validator_slash_events: Array.isArray(object?.validator_slash_events) ? object.validator_slash_events.map((e: any) => ValidatorSlashEvent.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: ValidatorSlashEvents): ValidatorSlashEventsSDKType { + const obj: any = {}; + if (message.validatorSlashEvents) { + obj.validator_slash_events = message.validatorSlashEvents.map(e => e ? ValidatorSlashEvent.toSDK(e) : undefined); + } else { + obj.validator_slash_events = []; + } + return obj; + }, + fromAmino(object: ValidatorSlashEventsAmino): ValidatorSlashEvents { + const message = createBaseValidatorSlashEvents(); + message.validatorSlashEvents = object.validator_slash_events?.map(e => ValidatorSlashEvent.fromAmino(e)) || []; + return message; + }, + toAmino(message: ValidatorSlashEvents): ValidatorSlashEventsAmino { + const obj: any = {}; + if (message.validatorSlashEvents) { + obj.validator_slash_events = message.validatorSlashEvents.map(e => e ? ValidatorSlashEvent.toAmino(e) : undefined); + } else { + obj.validator_slash_events = message.validatorSlashEvents; + } + return obj; + }, + fromAminoMsg(object: ValidatorSlashEventsAminoMsg): ValidatorSlashEvents { + return ValidatorSlashEvents.fromAmino(object.value); + }, + toAminoMsg(message: ValidatorSlashEvents): ValidatorSlashEventsAminoMsg { + return { + type: "cosmos-sdk/ValidatorSlashEvents", + value: ValidatorSlashEvents.toAmino(message) + }; + }, + fromProtoMsg(message: ValidatorSlashEventsProtoMsg): ValidatorSlashEvents { + return ValidatorSlashEvents.decode(message.value); + }, + toProto(message: ValidatorSlashEvents): Uint8Array { + return ValidatorSlashEvents.encode(message).finish(); + }, + toProtoMsg(message: ValidatorSlashEvents): ValidatorSlashEventsProtoMsg { + return { + typeUrl: "/cosmos.distribution.v1beta1.ValidatorSlashEvents", + value: ValidatorSlashEvents.encode(message).finish() + }; + } +}; +function createBaseFeePool(): FeePool { + return { + communityPool: [] + }; +} +export const FeePool = { + typeUrl: "/cosmos.distribution.v1beta1.FeePool", + encode(message: FeePool, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.communityPool) { + DecCoin.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): FeePool { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseFeePool(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.communityPool.push(DecCoin.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): FeePool { + const obj = createBaseFeePool(); + if (Array.isArray(object?.communityPool)) obj.communityPool = object.communityPool.map((e: any) => DecCoin.fromJSON(e)); + return obj; + }, + toJSON(message: FeePool): JsonSafe { + const obj: any = {}; + if (message.communityPool) { + obj.communityPool = message.communityPool.map(e => e ? DecCoin.toJSON(e) : undefined); + } else { + obj.communityPool = []; + } + return obj; + }, + fromPartial(object: DeepPartial): FeePool { + const message = createBaseFeePool(); + message.communityPool = object.communityPool?.map(e => DecCoin.fromPartial(e)) || []; + return message; + }, + fromSDK(object: FeePoolSDKType): FeePool { + return { + communityPool: Array.isArray(object?.community_pool) ? object.community_pool.map((e: any) => DecCoin.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): FeePoolSDKType { + return { + community_pool: Array.isArray(object?.community_pool) ? object.community_pool.map((e: any) => DecCoin.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: FeePool): FeePoolSDKType { + const obj: any = {}; + if (message.communityPool) { + obj.community_pool = message.communityPool.map(e => e ? DecCoin.toSDK(e) : undefined); + } else { + obj.community_pool = []; + } + return obj; + }, + fromAmino(object: FeePoolAmino): FeePool { + const message = createBaseFeePool(); + message.communityPool = object.community_pool?.map(e => DecCoin.fromAmino(e)) || []; + return message; + }, + toAmino(message: FeePool): FeePoolAmino { + const obj: any = {}; + if (message.communityPool) { + obj.community_pool = message.communityPool.map(e => e ? DecCoin.toAmino(e) : undefined); + } else { + obj.community_pool = message.communityPool; + } + return obj; + }, + fromAminoMsg(object: FeePoolAminoMsg): FeePool { + return FeePool.fromAmino(object.value); + }, + toAminoMsg(message: FeePool): FeePoolAminoMsg { + return { + type: "cosmos-sdk/FeePool", + value: FeePool.toAmino(message) + }; + }, + fromProtoMsg(message: FeePoolProtoMsg): FeePool { + return FeePool.decode(message.value); + }, + toProto(message: FeePool): Uint8Array { + return FeePool.encode(message).finish(); + }, + toProtoMsg(message: FeePool): FeePoolProtoMsg { + return { + typeUrl: "/cosmos.distribution.v1beta1.FeePool", + value: FeePool.encode(message).finish() + }; + } +}; +function createBaseCommunityPoolSpendProposal(): CommunityPoolSpendProposal { + return { + title: "", + description: "", + recipient: "", + amount: [] + }; +} +export const CommunityPoolSpendProposal = { + typeUrl: "/cosmos.distribution.v1beta1.CommunityPoolSpendProposal", + encode(message: CommunityPoolSpendProposal, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.title !== undefined) { + writer.uint32(10).string(message.title); + } + if (message.description !== undefined) { + writer.uint32(18).string(message.description); + } + if (message.recipient !== undefined) { + writer.uint32(26).string(message.recipient); + } + for (const v of message.amount) { + Coin.encode(v!, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): CommunityPoolSpendProposal { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCommunityPoolSpendProposal(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.title = reader.string(); + break; + case 2: + message.description = reader.string(); + break; + case 3: + message.recipient = reader.string(); + break; + case 4: + message.amount.push(Coin.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): CommunityPoolSpendProposal { + const obj = createBaseCommunityPoolSpendProposal(); + if (isSet(object.title)) obj.title = String(object.title); + if (isSet(object.description)) obj.description = String(object.description); + if (isSet(object.recipient)) obj.recipient = String(object.recipient); + if (Array.isArray(object?.amount)) obj.amount = object.amount.map((e: any) => Coin.fromJSON(e)); + return obj; + }, + toJSON(message: CommunityPoolSpendProposal): JsonSafe { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && (obj.description = message.description); + message.recipient !== undefined && (obj.recipient = message.recipient); + if (message.amount) { + obj.amount = message.amount.map(e => e ? Coin.toJSON(e) : undefined); + } else { + obj.amount = []; + } + return obj; + }, + fromPartial(object: DeepPartial): CommunityPoolSpendProposal { + const message = createBaseCommunityPoolSpendProposal(); + message.title = object.title ?? ""; + message.description = object.description ?? ""; + message.recipient = object.recipient ?? ""; + message.amount = object.amount?.map(e => Coin.fromPartial(e)) || []; + return message; + }, + fromSDK(object: CommunityPoolSpendProposalSDKType): CommunityPoolSpendProposal { + return { + title: object?.title, + description: object?.description, + recipient: object?.recipient, + amount: Array.isArray(object?.amount) ? object.amount.map((e: any) => Coin.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): CommunityPoolSpendProposalSDKType { + return { + title: isSet(object.title) ? String(object.title) : "", + description: isSet(object.description) ? String(object.description) : "", + recipient: isSet(object.recipient) ? String(object.recipient) : "", + amount: Array.isArray(object?.amount) ? object.amount.map((e: any) => Coin.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: CommunityPoolSpendProposal): CommunityPoolSpendProposalSDKType { + const obj: any = {}; + obj.title = message.title; + obj.description = message.description; + obj.recipient = message.recipient; + if (message.amount) { + obj.amount = message.amount.map(e => e ? Coin.toSDK(e) : undefined); + } else { + obj.amount = []; + } + return obj; + }, + fromAmino(object: CommunityPoolSpendProposalAmino): CommunityPoolSpendProposal { + const message = createBaseCommunityPoolSpendProposal(); + if (object.title !== undefined && object.title !== null) { + message.title = object.title; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } + if (object.recipient !== undefined && object.recipient !== null) { + message.recipient = object.recipient; + } + message.amount = object.amount?.map(e => Coin.fromAmino(e)) || []; + return message; + }, + toAmino(message: CommunityPoolSpendProposal): CommunityPoolSpendProposalAmino { + const obj: any = {}; + obj.title = message.title === "" ? undefined : message.title; + obj.description = message.description === "" ? undefined : message.description; + obj.recipient = message.recipient === "" ? undefined : message.recipient; + if (message.amount) { + obj.amount = message.amount.map(e => e ? Coin.toAmino(e) : undefined); + } else { + obj.amount = message.amount; + } + return obj; + }, + fromAminoMsg(object: CommunityPoolSpendProposalAminoMsg): CommunityPoolSpendProposal { + return CommunityPoolSpendProposal.fromAmino(object.value); + }, + toAminoMsg(message: CommunityPoolSpendProposal): CommunityPoolSpendProposalAminoMsg { + return { + type: "cosmos-sdk/CommunityPoolSpendProposal", + value: CommunityPoolSpendProposal.toAmino(message) + }; + }, + fromProtoMsg(message: CommunityPoolSpendProposalProtoMsg): CommunityPoolSpendProposal { + return CommunityPoolSpendProposal.decode(message.value); + }, + toProto(message: CommunityPoolSpendProposal): Uint8Array { + return CommunityPoolSpendProposal.encode(message).finish(); + }, + toProtoMsg(message: CommunityPoolSpendProposal): CommunityPoolSpendProposalProtoMsg { + return { + typeUrl: "/cosmos.distribution.v1beta1.CommunityPoolSpendProposal", + value: CommunityPoolSpendProposal.encode(message).finish() + }; + } +}; +function createBaseDelegatorStartingInfo(): DelegatorStartingInfo { + return { + previousPeriod: BigInt(0), + stake: "", + height: BigInt(0) + }; +} +export const DelegatorStartingInfo = { + typeUrl: "/cosmos.distribution.v1beta1.DelegatorStartingInfo", + encode(message: DelegatorStartingInfo, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.previousPeriod !== undefined) { + writer.uint32(8).uint64(message.previousPeriod); + } + if (message.stake !== undefined) { + writer.uint32(18).string(Decimal.fromUserInput(message.stake, 18).atomics); + } + if (message.height !== undefined) { + writer.uint32(24).uint64(message.height); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): DelegatorStartingInfo { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDelegatorStartingInfo(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.previousPeriod = reader.uint64(); + break; + case 2: + message.stake = Decimal.fromAtomics(reader.string(), 18).toString(); + break; + case 3: + message.height = reader.uint64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): DelegatorStartingInfo { + const obj = createBaseDelegatorStartingInfo(); + if (isSet(object.previousPeriod)) obj.previousPeriod = BigInt(object.previousPeriod.toString()); + if (isSet(object.stake)) obj.stake = String(object.stake); + if (isSet(object.height)) obj.height = BigInt(object.height.toString()); + return obj; + }, + toJSON(message: DelegatorStartingInfo): JsonSafe { + const obj: any = {}; + message.previousPeriod !== undefined && (obj.previousPeriod = (message.previousPeriod || BigInt(0)).toString()); + message.stake !== undefined && (obj.stake = message.stake); + message.height !== undefined && (obj.height = (message.height || BigInt(0)).toString()); + return obj; + }, + fromPartial(object: DeepPartial): DelegatorStartingInfo { + const message = createBaseDelegatorStartingInfo(); + if (object.previousPeriod !== undefined && object.previousPeriod !== null) { + message.previousPeriod = BigInt(object.previousPeriod.toString()); + } + message.stake = object.stake ?? ""; + if (object.height !== undefined && object.height !== null) { + message.height = BigInt(object.height.toString()); + } + return message; + }, + fromSDK(object: DelegatorStartingInfoSDKType): DelegatorStartingInfo { + return { + previousPeriod: object?.previous_period, + stake: object?.stake, + height: object?.height + }; + }, + fromSDKJSON(object: any): DelegatorStartingInfoSDKType { + return { + previous_period: isSet(object.previous_period) ? BigInt(object.previous_period.toString()) : BigInt(0), + stake: isSet(object.stake) ? String(object.stake) : "", + height: isSet(object.height) ? BigInt(object.height.toString()) : BigInt(0) + }; + }, + toSDK(message: DelegatorStartingInfo): DelegatorStartingInfoSDKType { + const obj: any = {}; + obj.previous_period = message.previousPeriod; + obj.stake = message.stake; + obj.height = message.height; + return obj; + }, + fromAmino(object: DelegatorStartingInfoAmino): DelegatorStartingInfo { + const message = createBaseDelegatorStartingInfo(); + if (object.previous_period !== undefined && object.previous_period !== null) { + message.previousPeriod = BigInt(object.previous_period); + } + if (object.stake !== undefined && object.stake !== null) { + message.stake = object.stake; + } + if (object.height !== undefined && object.height !== null) { + message.height = BigInt(object.height); + } + return message; + }, + toAmino(message: DelegatorStartingInfo): DelegatorStartingInfoAmino { + const obj: any = {}; + obj.previous_period = message.previousPeriod !== BigInt(0) ? message.previousPeriod?.toString() : undefined; + obj.stake = message.stake === "" ? undefined : message.stake; + obj.height = message.height ? message.height?.toString() : "0"; + return obj; + }, + fromAminoMsg(object: DelegatorStartingInfoAminoMsg): DelegatorStartingInfo { + return DelegatorStartingInfo.fromAmino(object.value); + }, + toAminoMsg(message: DelegatorStartingInfo): DelegatorStartingInfoAminoMsg { + return { + type: "cosmos-sdk/DelegatorStartingInfo", + value: DelegatorStartingInfo.toAmino(message) + }; + }, + fromProtoMsg(message: DelegatorStartingInfoProtoMsg): DelegatorStartingInfo { + return DelegatorStartingInfo.decode(message.value); + }, + toProto(message: DelegatorStartingInfo): Uint8Array { + return DelegatorStartingInfo.encode(message).finish(); + }, + toProtoMsg(message: DelegatorStartingInfo): DelegatorStartingInfoProtoMsg { + return { + typeUrl: "/cosmos.distribution.v1beta1.DelegatorStartingInfo", + value: DelegatorStartingInfo.encode(message).finish() + }; + } +}; +function createBaseDelegationDelegatorReward(): DelegationDelegatorReward { + return { + validatorAddress: "", + reward: [] + }; +} +export const DelegationDelegatorReward = { + typeUrl: "/cosmos.distribution.v1beta1.DelegationDelegatorReward", + encode(message: DelegationDelegatorReward, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.validatorAddress !== undefined) { + writer.uint32(10).string(message.validatorAddress); + } + for (const v of message.reward) { + DecCoin.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): DelegationDelegatorReward { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDelegationDelegatorReward(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.validatorAddress = reader.string(); + break; + case 2: + message.reward.push(DecCoin.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): DelegationDelegatorReward { + const obj = createBaseDelegationDelegatorReward(); + if (isSet(object.validatorAddress)) obj.validatorAddress = String(object.validatorAddress); + if (Array.isArray(object?.reward)) obj.reward = object.reward.map((e: any) => DecCoin.fromJSON(e)); + return obj; + }, + toJSON(message: DelegationDelegatorReward): JsonSafe { + const obj: any = {}; + message.validatorAddress !== undefined && (obj.validatorAddress = message.validatorAddress); + if (message.reward) { + obj.reward = message.reward.map(e => e ? DecCoin.toJSON(e) : undefined); + } else { + obj.reward = []; + } + return obj; + }, + fromPartial(object: DeepPartial): DelegationDelegatorReward { + const message = createBaseDelegationDelegatorReward(); + message.validatorAddress = object.validatorAddress ?? ""; + message.reward = object.reward?.map(e => DecCoin.fromPartial(e)) || []; + return message; + }, + fromSDK(object: DelegationDelegatorRewardSDKType): DelegationDelegatorReward { + return { + validatorAddress: object?.validator_address, + reward: Array.isArray(object?.reward) ? object.reward.map((e: any) => DecCoin.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): DelegationDelegatorRewardSDKType { + return { + validator_address: isSet(object.validator_address) ? String(object.validator_address) : "", + reward: Array.isArray(object?.reward) ? object.reward.map((e: any) => DecCoin.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: DelegationDelegatorReward): DelegationDelegatorRewardSDKType { + const obj: any = {}; + obj.validator_address = message.validatorAddress; + if (message.reward) { + obj.reward = message.reward.map(e => e ? DecCoin.toSDK(e) : undefined); + } else { + obj.reward = []; + } + return obj; + }, + fromAmino(object: DelegationDelegatorRewardAmino): DelegationDelegatorReward { + const message = createBaseDelegationDelegatorReward(); + if (object.validator_address !== undefined && object.validator_address !== null) { + message.validatorAddress = object.validator_address; + } + message.reward = object.reward?.map(e => DecCoin.fromAmino(e)) || []; + return message; + }, + toAmino(message: DelegationDelegatorReward): DelegationDelegatorRewardAmino { + const obj: any = {}; + obj.validator_address = message.validatorAddress === "" ? undefined : message.validatorAddress; + if (message.reward) { + obj.reward = message.reward.map(e => e ? DecCoin.toAmino(e) : undefined); + } else { + obj.reward = message.reward; + } + return obj; + }, + fromAminoMsg(object: DelegationDelegatorRewardAminoMsg): DelegationDelegatorReward { + return DelegationDelegatorReward.fromAmino(object.value); + }, + toAminoMsg(message: DelegationDelegatorReward): DelegationDelegatorRewardAminoMsg { + return { + type: "cosmos-sdk/DelegationDelegatorReward", + value: DelegationDelegatorReward.toAmino(message) + }; + }, + fromProtoMsg(message: DelegationDelegatorRewardProtoMsg): DelegationDelegatorReward { + return DelegationDelegatorReward.decode(message.value); + }, + toProto(message: DelegationDelegatorReward): Uint8Array { + return DelegationDelegatorReward.encode(message).finish(); + }, + toProtoMsg(message: DelegationDelegatorReward): DelegationDelegatorRewardProtoMsg { + return { + typeUrl: "/cosmos.distribution.v1beta1.DelegationDelegatorReward", + value: DelegationDelegatorReward.encode(message).finish() + }; + } +}; +function createBaseCommunityPoolSpendProposalWithDeposit(): CommunityPoolSpendProposalWithDeposit { + return { + title: "", + description: "", + recipient: "", + amount: "", + deposit: "" + }; +} +export const CommunityPoolSpendProposalWithDeposit = { + typeUrl: "/cosmos.distribution.v1beta1.CommunityPoolSpendProposalWithDeposit", + encode(message: CommunityPoolSpendProposalWithDeposit, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.title !== undefined) { + writer.uint32(10).string(message.title); + } + if (message.description !== undefined) { + writer.uint32(18).string(message.description); + } + if (message.recipient !== undefined) { + writer.uint32(26).string(message.recipient); + } + if (message.amount !== undefined) { + writer.uint32(34).string(message.amount); + } + if (message.deposit !== undefined) { + writer.uint32(42).string(message.deposit); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): CommunityPoolSpendProposalWithDeposit { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCommunityPoolSpendProposalWithDeposit(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.title = reader.string(); + break; + case 2: + message.description = reader.string(); + break; + case 3: + message.recipient = reader.string(); + break; + case 4: + message.amount = reader.string(); + break; + case 5: + message.deposit = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): CommunityPoolSpendProposalWithDeposit { + const obj = createBaseCommunityPoolSpendProposalWithDeposit(); + if (isSet(object.title)) obj.title = String(object.title); + if (isSet(object.description)) obj.description = String(object.description); + if (isSet(object.recipient)) obj.recipient = String(object.recipient); + if (isSet(object.amount)) obj.amount = String(object.amount); + if (isSet(object.deposit)) obj.deposit = String(object.deposit); + return obj; + }, + toJSON(message: CommunityPoolSpendProposalWithDeposit): JsonSafe { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && (obj.description = message.description); + message.recipient !== undefined && (obj.recipient = message.recipient); + message.amount !== undefined && (obj.amount = message.amount); + message.deposit !== undefined && (obj.deposit = message.deposit); + return obj; + }, + fromPartial(object: DeepPartial): CommunityPoolSpendProposalWithDeposit { + const message = createBaseCommunityPoolSpendProposalWithDeposit(); + message.title = object.title ?? ""; + message.description = object.description ?? ""; + message.recipient = object.recipient ?? ""; + message.amount = object.amount ?? ""; + message.deposit = object.deposit ?? ""; + return message; + }, + fromSDK(object: CommunityPoolSpendProposalWithDepositSDKType): CommunityPoolSpendProposalWithDeposit { + return { + title: object?.title, + description: object?.description, + recipient: object?.recipient, + amount: object?.amount, + deposit: object?.deposit + }; + }, + fromSDKJSON(object: any): CommunityPoolSpendProposalWithDepositSDKType { + return { + title: isSet(object.title) ? String(object.title) : "", + description: isSet(object.description) ? String(object.description) : "", + recipient: isSet(object.recipient) ? String(object.recipient) : "", + amount: isSet(object.amount) ? String(object.amount) : "", + deposit: isSet(object.deposit) ? String(object.deposit) : "" + }; + }, + toSDK(message: CommunityPoolSpendProposalWithDeposit): CommunityPoolSpendProposalWithDepositSDKType { + const obj: any = {}; + obj.title = message.title; + obj.description = message.description; + obj.recipient = message.recipient; + obj.amount = message.amount; + obj.deposit = message.deposit; + return obj; + }, + fromAmino(object: CommunityPoolSpendProposalWithDepositAmino): CommunityPoolSpendProposalWithDeposit { + const message = createBaseCommunityPoolSpendProposalWithDeposit(); + if (object.title !== undefined && object.title !== null) { + message.title = object.title; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } + if (object.recipient !== undefined && object.recipient !== null) { + message.recipient = object.recipient; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = object.amount; + } + if (object.deposit !== undefined && object.deposit !== null) { + message.deposit = object.deposit; + } + return message; + }, + toAmino(message: CommunityPoolSpendProposalWithDeposit): CommunityPoolSpendProposalWithDepositAmino { + const obj: any = {}; + obj.title = message.title === "" ? undefined : message.title; + obj.description = message.description === "" ? undefined : message.description; + obj.recipient = message.recipient === "" ? undefined : message.recipient; + obj.amount = message.amount === "" ? undefined : message.amount; + obj.deposit = message.deposit === "" ? undefined : message.deposit; + return obj; + }, + fromAminoMsg(object: CommunityPoolSpendProposalWithDepositAminoMsg): CommunityPoolSpendProposalWithDeposit { + return CommunityPoolSpendProposalWithDeposit.fromAmino(object.value); + }, + toAminoMsg(message: CommunityPoolSpendProposalWithDeposit): CommunityPoolSpendProposalWithDepositAminoMsg { + return { + type: "cosmos-sdk/CommunityPoolSpendProposalWithDeposit", + value: CommunityPoolSpendProposalWithDeposit.toAmino(message) + }; + }, + fromProtoMsg(message: CommunityPoolSpendProposalWithDepositProtoMsg): CommunityPoolSpendProposalWithDeposit { + return CommunityPoolSpendProposalWithDeposit.decode(message.value); + }, + toProto(message: CommunityPoolSpendProposalWithDeposit): Uint8Array { + return CommunityPoolSpendProposalWithDeposit.encode(message).finish(); + }, + toProtoMsg(message: CommunityPoolSpendProposalWithDeposit): CommunityPoolSpendProposalWithDepositProtoMsg { + return { + typeUrl: "/cosmos.distribution.v1beta1.CommunityPoolSpendProposalWithDeposit", + value: CommunityPoolSpendProposalWithDeposit.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/distribution/v1beta1/genesis.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/distribution/v1beta1/genesis.ts new file mode 100644 index 0000000000..3c27190861 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/distribution/v1beta1/genesis.ts @@ -0,0 +1,1382 @@ +import { DecCoin, DecCoinSDKType } from "../../base/v1beta1/coin.js"; +import { ValidatorAccumulatedCommission, ValidatorAccumulatedCommissionSDKType, ValidatorHistoricalRewards, ValidatorHistoricalRewardsSDKType, ValidatorCurrentRewards, ValidatorCurrentRewardsSDKType, DelegatorStartingInfo, DelegatorStartingInfoSDKType, ValidatorSlashEvent, ValidatorSlashEventSDKType, Params, ParamsSDKType, FeePool, FeePoolSDKType } from "./distribution.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "cosmos.distribution.v1beta1"; +/** + * DelegatorWithdrawInfo is the address for where distributions rewards are + * withdrawn to by default this struct is only used at genesis to feed in + * default withdraw addresses. + */ +export interface DelegatorWithdrawInfo { + /** delegator_address is the address of the delegator. */ + delegatorAddress: string; + /** withdraw_address is the address to withdraw the delegation rewards to. */ + withdrawAddress: string; +} +export interface DelegatorWithdrawInfoProtoMsg { + typeUrl: "/cosmos.distribution.v1beta1.DelegatorWithdrawInfo"; + value: Uint8Array; +} +/** + * DelegatorWithdrawInfo is the address for where distributions rewards are + * withdrawn to by default this struct is only used at genesis to feed in + * default withdraw addresses. + */ +export interface DelegatorWithdrawInfoSDKType { + delegator_address: string; + withdraw_address: string; +} +/** ValidatorOutstandingRewardsRecord is used for import/export via genesis json. */ +export interface ValidatorOutstandingRewardsRecord { + /** validator_address is the address of the validator. */ + validatorAddress: string; + /** outstanding_rewards represents the oustanding rewards of a validator. */ + outstandingRewards: DecCoin[]; +} +export interface ValidatorOutstandingRewardsRecordProtoMsg { + typeUrl: "/cosmos.distribution.v1beta1.ValidatorOutstandingRewardsRecord"; + value: Uint8Array; +} +/** ValidatorOutstandingRewardsRecord is used for import/export via genesis json. */ +export interface ValidatorOutstandingRewardsRecordSDKType { + validator_address: string; + outstanding_rewards: DecCoinSDKType[]; +} +/** + * ValidatorAccumulatedCommissionRecord is used for import / export via genesis + * json. + */ +export interface ValidatorAccumulatedCommissionRecord { + /** validator_address is the address of the validator. */ + validatorAddress: string; + /** accumulated is the accumulated commission of a validator. */ + accumulated: ValidatorAccumulatedCommission; +} +export interface ValidatorAccumulatedCommissionRecordProtoMsg { + typeUrl: "/cosmos.distribution.v1beta1.ValidatorAccumulatedCommissionRecord"; + value: Uint8Array; +} +/** + * ValidatorAccumulatedCommissionRecord is used for import / export via genesis + * json. + */ +export interface ValidatorAccumulatedCommissionRecordSDKType { + validator_address: string; + accumulated: ValidatorAccumulatedCommissionSDKType; +} +/** + * ValidatorHistoricalRewardsRecord is used for import / export via genesis + * json. + */ +export interface ValidatorHistoricalRewardsRecord { + /** validator_address is the address of the validator. */ + validatorAddress: string; + /** period defines the period the historical rewards apply to. */ + period: bigint; + /** rewards defines the historical rewards of a validator. */ + rewards: ValidatorHistoricalRewards; +} +export interface ValidatorHistoricalRewardsRecordProtoMsg { + typeUrl: "/cosmos.distribution.v1beta1.ValidatorHistoricalRewardsRecord"; + value: Uint8Array; +} +/** + * ValidatorHistoricalRewardsRecord is used for import / export via genesis + * json. + */ +export interface ValidatorHistoricalRewardsRecordSDKType { + validator_address: string; + period: bigint; + rewards: ValidatorHistoricalRewardsSDKType; +} +/** ValidatorCurrentRewardsRecord is used for import / export via genesis json. */ +export interface ValidatorCurrentRewardsRecord { + /** validator_address is the address of the validator. */ + validatorAddress: string; + /** rewards defines the current rewards of a validator. */ + rewards: ValidatorCurrentRewards; +} +export interface ValidatorCurrentRewardsRecordProtoMsg { + typeUrl: "/cosmos.distribution.v1beta1.ValidatorCurrentRewardsRecord"; + value: Uint8Array; +} +/** ValidatorCurrentRewardsRecord is used for import / export via genesis json. */ +export interface ValidatorCurrentRewardsRecordSDKType { + validator_address: string; + rewards: ValidatorCurrentRewardsSDKType; +} +/** DelegatorStartingInfoRecord used for import / export via genesis json. */ +export interface DelegatorStartingInfoRecord { + /** delegator_address is the address of the delegator. */ + delegatorAddress: string; + /** validator_address is the address of the validator. */ + validatorAddress: string; + /** starting_info defines the starting info of a delegator. */ + startingInfo: DelegatorStartingInfo; +} +export interface DelegatorStartingInfoRecordProtoMsg { + typeUrl: "/cosmos.distribution.v1beta1.DelegatorStartingInfoRecord"; + value: Uint8Array; +} +/** DelegatorStartingInfoRecord used for import / export via genesis json. */ +export interface DelegatorStartingInfoRecordSDKType { + delegator_address: string; + validator_address: string; + starting_info: DelegatorStartingInfoSDKType; +} +/** ValidatorSlashEventRecord is used for import / export via genesis json. */ +export interface ValidatorSlashEventRecord { + /** validator_address is the address of the validator. */ + validatorAddress: string; + /** height defines the block height at which the slash event occured. */ + height: bigint; + /** period is the period of the slash event. */ + period: bigint; + /** validator_slash_event describes the slash event. */ + validatorSlashEvent: ValidatorSlashEvent; +} +export interface ValidatorSlashEventRecordProtoMsg { + typeUrl: "/cosmos.distribution.v1beta1.ValidatorSlashEventRecord"; + value: Uint8Array; +} +/** ValidatorSlashEventRecord is used for import / export via genesis json. */ +export interface ValidatorSlashEventRecordSDKType { + validator_address: string; + height: bigint; + period: bigint; + validator_slash_event: ValidatorSlashEventSDKType; +} +/** GenesisState defines the distribution module's genesis state. */ +export interface GenesisState { + /** params defines all the paramaters of the module. */ + params: Params; + /** fee_pool defines the fee pool at genesis. */ + feePool: FeePool; + /** fee_pool defines the delegator withdraw infos at genesis. */ + delegatorWithdrawInfos: DelegatorWithdrawInfo[]; + /** fee_pool defines the previous proposer at genesis. */ + previousProposer: string; + /** fee_pool defines the outstanding rewards of all validators at genesis. */ + outstandingRewards: ValidatorOutstandingRewardsRecord[]; + /** fee_pool defines the accumulated commisions of all validators at genesis. */ + validatorAccumulatedCommissions: ValidatorAccumulatedCommissionRecord[]; + /** fee_pool defines the historical rewards of all validators at genesis. */ + validatorHistoricalRewards: ValidatorHistoricalRewardsRecord[]; + /** fee_pool defines the current rewards of all validators at genesis. */ + validatorCurrentRewards: ValidatorCurrentRewardsRecord[]; + /** fee_pool defines the delegator starting infos at genesis. */ + delegatorStartingInfos: DelegatorStartingInfoRecord[]; + /** fee_pool defines the validator slash events at genesis. */ + validatorSlashEvents: ValidatorSlashEventRecord[]; +} +export interface GenesisStateProtoMsg { + typeUrl: "/cosmos.distribution.v1beta1.GenesisState"; + value: Uint8Array; +} +/** GenesisState defines the distribution module's genesis state. */ +export interface GenesisStateSDKType { + params: ParamsSDKType; + fee_pool: FeePoolSDKType; + delegator_withdraw_infos: DelegatorWithdrawInfoSDKType[]; + previous_proposer: string; + outstanding_rewards: ValidatorOutstandingRewardsRecordSDKType[]; + validator_accumulated_commissions: ValidatorAccumulatedCommissionRecordSDKType[]; + validator_historical_rewards: ValidatorHistoricalRewardsRecordSDKType[]; + validator_current_rewards: ValidatorCurrentRewardsRecordSDKType[]; + delegator_starting_infos: DelegatorStartingInfoRecordSDKType[]; + validator_slash_events: ValidatorSlashEventRecordSDKType[]; +} +function createBaseDelegatorWithdrawInfo(): DelegatorWithdrawInfo { + return { + delegatorAddress: "", + withdrawAddress: "" + }; +} +export const DelegatorWithdrawInfo = { + typeUrl: "/cosmos.distribution.v1beta1.DelegatorWithdrawInfo", + encode(message: DelegatorWithdrawInfo, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.delegatorAddress !== undefined) { + writer.uint32(10).string(message.delegatorAddress); + } + if (message.withdrawAddress !== undefined) { + writer.uint32(18).string(message.withdrawAddress); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): DelegatorWithdrawInfo { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDelegatorWithdrawInfo(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.delegatorAddress = reader.string(); + break; + case 2: + message.withdrawAddress = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): DelegatorWithdrawInfo { + const obj = createBaseDelegatorWithdrawInfo(); + if (isSet(object.delegatorAddress)) obj.delegatorAddress = String(object.delegatorAddress); + if (isSet(object.withdrawAddress)) obj.withdrawAddress = String(object.withdrawAddress); + return obj; + }, + toJSON(message: DelegatorWithdrawInfo): JsonSafe { + const obj: any = {}; + message.delegatorAddress !== undefined && (obj.delegatorAddress = message.delegatorAddress); + message.withdrawAddress !== undefined && (obj.withdrawAddress = message.withdrawAddress); + return obj; + }, + fromPartial(object: DeepPartial): DelegatorWithdrawInfo { + const message = createBaseDelegatorWithdrawInfo(); + message.delegatorAddress = object.delegatorAddress ?? ""; + message.withdrawAddress = object.withdrawAddress ?? ""; + return message; + }, + fromSDK(object: DelegatorWithdrawInfoSDKType): DelegatorWithdrawInfo { + return { + delegatorAddress: object?.delegator_address, + withdrawAddress: object?.withdraw_address + }; + }, + fromSDKJSON(object: any): DelegatorWithdrawInfoSDKType { + return { + delegator_address: isSet(object.delegator_address) ? String(object.delegator_address) : "", + withdraw_address: isSet(object.withdraw_address) ? String(object.withdraw_address) : "" + }; + }, + toSDK(message: DelegatorWithdrawInfo): DelegatorWithdrawInfoSDKType { + const obj: any = {}; + obj.delegator_address = message.delegatorAddress; + obj.withdraw_address = message.withdrawAddress; + return obj; + }, + fromAmino(object: DelegatorWithdrawInfoAmino): DelegatorWithdrawInfo { + const message = createBaseDelegatorWithdrawInfo(); + if (object.delegator_address !== undefined && object.delegator_address !== null) { + message.delegatorAddress = object.delegator_address; + } + if (object.withdraw_address !== undefined && object.withdraw_address !== null) { + message.withdrawAddress = object.withdraw_address; + } + return message; + }, + toAmino(message: DelegatorWithdrawInfo): DelegatorWithdrawInfoAmino { + const obj: any = {}; + obj.delegator_address = message.delegatorAddress === "" ? undefined : message.delegatorAddress; + obj.withdraw_address = message.withdrawAddress === "" ? undefined : message.withdrawAddress; + return obj; + }, + fromAminoMsg(object: DelegatorWithdrawInfoAminoMsg): DelegatorWithdrawInfo { + return DelegatorWithdrawInfo.fromAmino(object.value); + }, + toAminoMsg(message: DelegatorWithdrawInfo): DelegatorWithdrawInfoAminoMsg { + return { + type: "cosmos-sdk/DelegatorWithdrawInfo", + value: DelegatorWithdrawInfo.toAmino(message) + }; + }, + fromProtoMsg(message: DelegatorWithdrawInfoProtoMsg): DelegatorWithdrawInfo { + return DelegatorWithdrawInfo.decode(message.value); + }, + toProto(message: DelegatorWithdrawInfo): Uint8Array { + return DelegatorWithdrawInfo.encode(message).finish(); + }, + toProtoMsg(message: DelegatorWithdrawInfo): DelegatorWithdrawInfoProtoMsg { + return { + typeUrl: "/cosmos.distribution.v1beta1.DelegatorWithdrawInfo", + value: DelegatorWithdrawInfo.encode(message).finish() + }; + } +}; +function createBaseValidatorOutstandingRewardsRecord(): ValidatorOutstandingRewardsRecord { + return { + validatorAddress: "", + outstandingRewards: [] + }; +} +export const ValidatorOutstandingRewardsRecord = { + typeUrl: "/cosmos.distribution.v1beta1.ValidatorOutstandingRewardsRecord", + encode(message: ValidatorOutstandingRewardsRecord, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.validatorAddress !== undefined) { + writer.uint32(10).string(message.validatorAddress); + } + for (const v of message.outstandingRewards) { + DecCoin.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ValidatorOutstandingRewardsRecord { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseValidatorOutstandingRewardsRecord(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.validatorAddress = reader.string(); + break; + case 2: + message.outstandingRewards.push(DecCoin.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ValidatorOutstandingRewardsRecord { + const obj = createBaseValidatorOutstandingRewardsRecord(); + if (isSet(object.validatorAddress)) obj.validatorAddress = String(object.validatorAddress); + if (Array.isArray(object?.outstandingRewards)) obj.outstandingRewards = object.outstandingRewards.map((e: any) => DecCoin.fromJSON(e)); + return obj; + }, + toJSON(message: ValidatorOutstandingRewardsRecord): JsonSafe { + const obj: any = {}; + message.validatorAddress !== undefined && (obj.validatorAddress = message.validatorAddress); + if (message.outstandingRewards) { + obj.outstandingRewards = message.outstandingRewards.map(e => e ? DecCoin.toJSON(e) : undefined); + } else { + obj.outstandingRewards = []; + } + return obj; + }, + fromPartial(object: DeepPartial): ValidatorOutstandingRewardsRecord { + const message = createBaseValidatorOutstandingRewardsRecord(); + message.validatorAddress = object.validatorAddress ?? ""; + message.outstandingRewards = object.outstandingRewards?.map(e => DecCoin.fromPartial(e)) || []; + return message; + }, + fromSDK(object: ValidatorOutstandingRewardsRecordSDKType): ValidatorOutstandingRewardsRecord { + return { + validatorAddress: object?.validator_address, + outstandingRewards: Array.isArray(object?.outstanding_rewards) ? object.outstanding_rewards.map((e: any) => DecCoin.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): ValidatorOutstandingRewardsRecordSDKType { + return { + validator_address: isSet(object.validator_address) ? String(object.validator_address) : "", + outstanding_rewards: Array.isArray(object?.outstanding_rewards) ? object.outstanding_rewards.map((e: any) => DecCoin.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: ValidatorOutstandingRewardsRecord): ValidatorOutstandingRewardsRecordSDKType { + const obj: any = {}; + obj.validator_address = message.validatorAddress; + if (message.outstandingRewards) { + obj.outstanding_rewards = message.outstandingRewards.map(e => e ? DecCoin.toSDK(e) : undefined); + } else { + obj.outstanding_rewards = []; + } + return obj; + }, + fromAmino(object: ValidatorOutstandingRewardsRecordAmino): ValidatorOutstandingRewardsRecord { + const message = createBaseValidatorOutstandingRewardsRecord(); + if (object.validator_address !== undefined && object.validator_address !== null) { + message.validatorAddress = object.validator_address; + } + message.outstandingRewards = object.outstanding_rewards?.map(e => DecCoin.fromAmino(e)) || []; + return message; + }, + toAmino(message: ValidatorOutstandingRewardsRecord): ValidatorOutstandingRewardsRecordAmino { + const obj: any = {}; + obj.validator_address = message.validatorAddress === "" ? undefined : message.validatorAddress; + if (message.outstandingRewards) { + obj.outstanding_rewards = message.outstandingRewards.map(e => e ? DecCoin.toAmino(e) : undefined); + } else { + obj.outstanding_rewards = message.outstandingRewards; + } + return obj; + }, + fromAminoMsg(object: ValidatorOutstandingRewardsRecordAminoMsg): ValidatorOutstandingRewardsRecord { + return ValidatorOutstandingRewardsRecord.fromAmino(object.value); + }, + toAminoMsg(message: ValidatorOutstandingRewardsRecord): ValidatorOutstandingRewardsRecordAminoMsg { + return { + type: "cosmos-sdk/ValidatorOutstandingRewardsRecord", + value: ValidatorOutstandingRewardsRecord.toAmino(message) + }; + }, + fromProtoMsg(message: ValidatorOutstandingRewardsRecordProtoMsg): ValidatorOutstandingRewardsRecord { + return ValidatorOutstandingRewardsRecord.decode(message.value); + }, + toProto(message: ValidatorOutstandingRewardsRecord): Uint8Array { + return ValidatorOutstandingRewardsRecord.encode(message).finish(); + }, + toProtoMsg(message: ValidatorOutstandingRewardsRecord): ValidatorOutstandingRewardsRecordProtoMsg { + return { + typeUrl: "/cosmos.distribution.v1beta1.ValidatorOutstandingRewardsRecord", + value: ValidatorOutstandingRewardsRecord.encode(message).finish() + }; + } +}; +function createBaseValidatorAccumulatedCommissionRecord(): ValidatorAccumulatedCommissionRecord { + return { + validatorAddress: "", + accumulated: ValidatorAccumulatedCommission.fromPartial({}) + }; +} +export const ValidatorAccumulatedCommissionRecord = { + typeUrl: "/cosmos.distribution.v1beta1.ValidatorAccumulatedCommissionRecord", + encode(message: ValidatorAccumulatedCommissionRecord, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.validatorAddress !== undefined) { + writer.uint32(10).string(message.validatorAddress); + } + if (message.accumulated !== undefined) { + ValidatorAccumulatedCommission.encode(message.accumulated, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ValidatorAccumulatedCommissionRecord { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseValidatorAccumulatedCommissionRecord(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.validatorAddress = reader.string(); + break; + case 2: + message.accumulated = ValidatorAccumulatedCommission.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ValidatorAccumulatedCommissionRecord { + const obj = createBaseValidatorAccumulatedCommissionRecord(); + if (isSet(object.validatorAddress)) obj.validatorAddress = String(object.validatorAddress); + if (isSet(object.accumulated)) obj.accumulated = ValidatorAccumulatedCommission.fromJSON(object.accumulated); + return obj; + }, + toJSON(message: ValidatorAccumulatedCommissionRecord): JsonSafe { + const obj: any = {}; + message.validatorAddress !== undefined && (obj.validatorAddress = message.validatorAddress); + message.accumulated !== undefined && (obj.accumulated = message.accumulated ? ValidatorAccumulatedCommission.toJSON(message.accumulated) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): ValidatorAccumulatedCommissionRecord { + const message = createBaseValidatorAccumulatedCommissionRecord(); + message.validatorAddress = object.validatorAddress ?? ""; + if (object.accumulated !== undefined && object.accumulated !== null) { + message.accumulated = ValidatorAccumulatedCommission.fromPartial(object.accumulated); + } + return message; + }, + fromSDK(object: ValidatorAccumulatedCommissionRecordSDKType): ValidatorAccumulatedCommissionRecord { + return { + validatorAddress: object?.validator_address, + accumulated: object.accumulated ? ValidatorAccumulatedCommission.fromSDK(object.accumulated) : undefined + }; + }, + fromSDKJSON(object: any): ValidatorAccumulatedCommissionRecordSDKType { + return { + validator_address: isSet(object.validator_address) ? String(object.validator_address) : "", + accumulated: isSet(object.accumulated) ? ValidatorAccumulatedCommission.fromSDKJSON(object.accumulated) : undefined + }; + }, + toSDK(message: ValidatorAccumulatedCommissionRecord): ValidatorAccumulatedCommissionRecordSDKType { + const obj: any = {}; + obj.validator_address = message.validatorAddress; + message.accumulated !== undefined && (obj.accumulated = message.accumulated ? ValidatorAccumulatedCommission.toSDK(message.accumulated) : undefined); + return obj; + }, + fromAmino(object: ValidatorAccumulatedCommissionRecordAmino): ValidatorAccumulatedCommissionRecord { + const message = createBaseValidatorAccumulatedCommissionRecord(); + if (object.validator_address !== undefined && object.validator_address !== null) { + message.validatorAddress = object.validator_address; + } + if (object.accumulated !== undefined && object.accumulated !== null) { + message.accumulated = ValidatorAccumulatedCommission.fromAmino(object.accumulated); + } + return message; + }, + toAmino(message: ValidatorAccumulatedCommissionRecord): ValidatorAccumulatedCommissionRecordAmino { + const obj: any = {}; + obj.validator_address = message.validatorAddress === "" ? undefined : message.validatorAddress; + obj.accumulated = message.accumulated ? ValidatorAccumulatedCommission.toAmino(message.accumulated) : undefined; + return obj; + }, + fromAminoMsg(object: ValidatorAccumulatedCommissionRecordAminoMsg): ValidatorAccumulatedCommissionRecord { + return ValidatorAccumulatedCommissionRecord.fromAmino(object.value); + }, + toAminoMsg(message: ValidatorAccumulatedCommissionRecord): ValidatorAccumulatedCommissionRecordAminoMsg { + return { + type: "cosmos-sdk/ValidatorAccumulatedCommissionRecord", + value: ValidatorAccumulatedCommissionRecord.toAmino(message) + }; + }, + fromProtoMsg(message: ValidatorAccumulatedCommissionRecordProtoMsg): ValidatorAccumulatedCommissionRecord { + return ValidatorAccumulatedCommissionRecord.decode(message.value); + }, + toProto(message: ValidatorAccumulatedCommissionRecord): Uint8Array { + return ValidatorAccumulatedCommissionRecord.encode(message).finish(); + }, + toProtoMsg(message: ValidatorAccumulatedCommissionRecord): ValidatorAccumulatedCommissionRecordProtoMsg { + return { + typeUrl: "/cosmos.distribution.v1beta1.ValidatorAccumulatedCommissionRecord", + value: ValidatorAccumulatedCommissionRecord.encode(message).finish() + }; + } +}; +function createBaseValidatorHistoricalRewardsRecord(): ValidatorHistoricalRewardsRecord { + return { + validatorAddress: "", + period: BigInt(0), + rewards: ValidatorHistoricalRewards.fromPartial({}) + }; +} +export const ValidatorHistoricalRewardsRecord = { + typeUrl: "/cosmos.distribution.v1beta1.ValidatorHistoricalRewardsRecord", + encode(message: ValidatorHistoricalRewardsRecord, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.validatorAddress !== undefined) { + writer.uint32(10).string(message.validatorAddress); + } + if (message.period !== undefined) { + writer.uint32(16).uint64(message.period); + } + if (message.rewards !== undefined) { + ValidatorHistoricalRewards.encode(message.rewards, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ValidatorHistoricalRewardsRecord { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseValidatorHistoricalRewardsRecord(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.validatorAddress = reader.string(); + break; + case 2: + message.period = reader.uint64(); + break; + case 3: + message.rewards = ValidatorHistoricalRewards.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ValidatorHistoricalRewardsRecord { + const obj = createBaseValidatorHistoricalRewardsRecord(); + if (isSet(object.validatorAddress)) obj.validatorAddress = String(object.validatorAddress); + if (isSet(object.period)) obj.period = BigInt(object.period.toString()); + if (isSet(object.rewards)) obj.rewards = ValidatorHistoricalRewards.fromJSON(object.rewards); + return obj; + }, + toJSON(message: ValidatorHistoricalRewardsRecord): JsonSafe { + const obj: any = {}; + message.validatorAddress !== undefined && (obj.validatorAddress = message.validatorAddress); + message.period !== undefined && (obj.period = (message.period || BigInt(0)).toString()); + message.rewards !== undefined && (obj.rewards = message.rewards ? ValidatorHistoricalRewards.toJSON(message.rewards) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): ValidatorHistoricalRewardsRecord { + const message = createBaseValidatorHistoricalRewardsRecord(); + message.validatorAddress = object.validatorAddress ?? ""; + if (object.period !== undefined && object.period !== null) { + message.period = BigInt(object.period.toString()); + } + if (object.rewards !== undefined && object.rewards !== null) { + message.rewards = ValidatorHistoricalRewards.fromPartial(object.rewards); + } + return message; + }, + fromSDK(object: ValidatorHistoricalRewardsRecordSDKType): ValidatorHistoricalRewardsRecord { + return { + validatorAddress: object?.validator_address, + period: object?.period, + rewards: object.rewards ? ValidatorHistoricalRewards.fromSDK(object.rewards) : undefined + }; + }, + fromSDKJSON(object: any): ValidatorHistoricalRewardsRecordSDKType { + return { + validator_address: isSet(object.validator_address) ? String(object.validator_address) : "", + period: isSet(object.period) ? BigInt(object.period.toString()) : BigInt(0), + rewards: isSet(object.rewards) ? ValidatorHistoricalRewards.fromSDKJSON(object.rewards) : undefined + }; + }, + toSDK(message: ValidatorHistoricalRewardsRecord): ValidatorHistoricalRewardsRecordSDKType { + const obj: any = {}; + obj.validator_address = message.validatorAddress; + obj.period = message.period; + message.rewards !== undefined && (obj.rewards = message.rewards ? ValidatorHistoricalRewards.toSDK(message.rewards) : undefined); + return obj; + }, + fromAmino(object: ValidatorHistoricalRewardsRecordAmino): ValidatorHistoricalRewardsRecord { + const message = createBaseValidatorHistoricalRewardsRecord(); + if (object.validator_address !== undefined && object.validator_address !== null) { + message.validatorAddress = object.validator_address; + } + if (object.period !== undefined && object.period !== null) { + message.period = BigInt(object.period); + } + if (object.rewards !== undefined && object.rewards !== null) { + message.rewards = ValidatorHistoricalRewards.fromAmino(object.rewards); + } + return message; + }, + toAmino(message: ValidatorHistoricalRewardsRecord): ValidatorHistoricalRewardsRecordAmino { + const obj: any = {}; + obj.validator_address = message.validatorAddress === "" ? undefined : message.validatorAddress; + obj.period = message.period !== BigInt(0) ? message.period?.toString() : undefined; + obj.rewards = message.rewards ? ValidatorHistoricalRewards.toAmino(message.rewards) : undefined; + return obj; + }, + fromAminoMsg(object: ValidatorHistoricalRewardsRecordAminoMsg): ValidatorHistoricalRewardsRecord { + return ValidatorHistoricalRewardsRecord.fromAmino(object.value); + }, + toAminoMsg(message: ValidatorHistoricalRewardsRecord): ValidatorHistoricalRewardsRecordAminoMsg { + return { + type: "cosmos-sdk/ValidatorHistoricalRewardsRecord", + value: ValidatorHistoricalRewardsRecord.toAmino(message) + }; + }, + fromProtoMsg(message: ValidatorHistoricalRewardsRecordProtoMsg): ValidatorHistoricalRewardsRecord { + return ValidatorHistoricalRewardsRecord.decode(message.value); + }, + toProto(message: ValidatorHistoricalRewardsRecord): Uint8Array { + return ValidatorHistoricalRewardsRecord.encode(message).finish(); + }, + toProtoMsg(message: ValidatorHistoricalRewardsRecord): ValidatorHistoricalRewardsRecordProtoMsg { + return { + typeUrl: "/cosmos.distribution.v1beta1.ValidatorHistoricalRewardsRecord", + value: ValidatorHistoricalRewardsRecord.encode(message).finish() + }; + } +}; +function createBaseValidatorCurrentRewardsRecord(): ValidatorCurrentRewardsRecord { + return { + validatorAddress: "", + rewards: ValidatorCurrentRewards.fromPartial({}) + }; +} +export const ValidatorCurrentRewardsRecord = { + typeUrl: "/cosmos.distribution.v1beta1.ValidatorCurrentRewardsRecord", + encode(message: ValidatorCurrentRewardsRecord, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.validatorAddress !== undefined) { + writer.uint32(10).string(message.validatorAddress); + } + if (message.rewards !== undefined) { + ValidatorCurrentRewards.encode(message.rewards, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ValidatorCurrentRewardsRecord { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseValidatorCurrentRewardsRecord(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.validatorAddress = reader.string(); + break; + case 2: + message.rewards = ValidatorCurrentRewards.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ValidatorCurrentRewardsRecord { + const obj = createBaseValidatorCurrentRewardsRecord(); + if (isSet(object.validatorAddress)) obj.validatorAddress = String(object.validatorAddress); + if (isSet(object.rewards)) obj.rewards = ValidatorCurrentRewards.fromJSON(object.rewards); + return obj; + }, + toJSON(message: ValidatorCurrentRewardsRecord): JsonSafe { + const obj: any = {}; + message.validatorAddress !== undefined && (obj.validatorAddress = message.validatorAddress); + message.rewards !== undefined && (obj.rewards = message.rewards ? ValidatorCurrentRewards.toJSON(message.rewards) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): ValidatorCurrentRewardsRecord { + const message = createBaseValidatorCurrentRewardsRecord(); + message.validatorAddress = object.validatorAddress ?? ""; + if (object.rewards !== undefined && object.rewards !== null) { + message.rewards = ValidatorCurrentRewards.fromPartial(object.rewards); + } + return message; + }, + fromSDK(object: ValidatorCurrentRewardsRecordSDKType): ValidatorCurrentRewardsRecord { + return { + validatorAddress: object?.validator_address, + rewards: object.rewards ? ValidatorCurrentRewards.fromSDK(object.rewards) : undefined + }; + }, + fromSDKJSON(object: any): ValidatorCurrentRewardsRecordSDKType { + return { + validator_address: isSet(object.validator_address) ? String(object.validator_address) : "", + rewards: isSet(object.rewards) ? ValidatorCurrentRewards.fromSDKJSON(object.rewards) : undefined + }; + }, + toSDK(message: ValidatorCurrentRewardsRecord): ValidatorCurrentRewardsRecordSDKType { + const obj: any = {}; + obj.validator_address = message.validatorAddress; + message.rewards !== undefined && (obj.rewards = message.rewards ? ValidatorCurrentRewards.toSDK(message.rewards) : undefined); + return obj; + }, + fromAmino(object: ValidatorCurrentRewardsRecordAmino): ValidatorCurrentRewardsRecord { + const message = createBaseValidatorCurrentRewardsRecord(); + if (object.validator_address !== undefined && object.validator_address !== null) { + message.validatorAddress = object.validator_address; + } + if (object.rewards !== undefined && object.rewards !== null) { + message.rewards = ValidatorCurrentRewards.fromAmino(object.rewards); + } + return message; + }, + toAmino(message: ValidatorCurrentRewardsRecord): ValidatorCurrentRewardsRecordAmino { + const obj: any = {}; + obj.validator_address = message.validatorAddress === "" ? undefined : message.validatorAddress; + obj.rewards = message.rewards ? ValidatorCurrentRewards.toAmino(message.rewards) : undefined; + return obj; + }, + fromAminoMsg(object: ValidatorCurrentRewardsRecordAminoMsg): ValidatorCurrentRewardsRecord { + return ValidatorCurrentRewardsRecord.fromAmino(object.value); + }, + toAminoMsg(message: ValidatorCurrentRewardsRecord): ValidatorCurrentRewardsRecordAminoMsg { + return { + type: "cosmos-sdk/ValidatorCurrentRewardsRecord", + value: ValidatorCurrentRewardsRecord.toAmino(message) + }; + }, + fromProtoMsg(message: ValidatorCurrentRewardsRecordProtoMsg): ValidatorCurrentRewardsRecord { + return ValidatorCurrentRewardsRecord.decode(message.value); + }, + toProto(message: ValidatorCurrentRewardsRecord): Uint8Array { + return ValidatorCurrentRewardsRecord.encode(message).finish(); + }, + toProtoMsg(message: ValidatorCurrentRewardsRecord): ValidatorCurrentRewardsRecordProtoMsg { + return { + typeUrl: "/cosmos.distribution.v1beta1.ValidatorCurrentRewardsRecord", + value: ValidatorCurrentRewardsRecord.encode(message).finish() + }; + } +}; +function createBaseDelegatorStartingInfoRecord(): DelegatorStartingInfoRecord { + return { + delegatorAddress: "", + validatorAddress: "", + startingInfo: DelegatorStartingInfo.fromPartial({}) + }; +} +export const DelegatorStartingInfoRecord = { + typeUrl: "/cosmos.distribution.v1beta1.DelegatorStartingInfoRecord", + encode(message: DelegatorStartingInfoRecord, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.delegatorAddress !== undefined) { + writer.uint32(10).string(message.delegatorAddress); + } + if (message.validatorAddress !== undefined) { + writer.uint32(18).string(message.validatorAddress); + } + if (message.startingInfo !== undefined) { + DelegatorStartingInfo.encode(message.startingInfo, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): DelegatorStartingInfoRecord { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDelegatorStartingInfoRecord(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.delegatorAddress = reader.string(); + break; + case 2: + message.validatorAddress = reader.string(); + break; + case 3: + message.startingInfo = DelegatorStartingInfo.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): DelegatorStartingInfoRecord { + const obj = createBaseDelegatorStartingInfoRecord(); + if (isSet(object.delegatorAddress)) obj.delegatorAddress = String(object.delegatorAddress); + if (isSet(object.validatorAddress)) obj.validatorAddress = String(object.validatorAddress); + if (isSet(object.startingInfo)) obj.startingInfo = DelegatorStartingInfo.fromJSON(object.startingInfo); + return obj; + }, + toJSON(message: DelegatorStartingInfoRecord): JsonSafe { + const obj: any = {}; + message.delegatorAddress !== undefined && (obj.delegatorAddress = message.delegatorAddress); + message.validatorAddress !== undefined && (obj.validatorAddress = message.validatorAddress); + message.startingInfo !== undefined && (obj.startingInfo = message.startingInfo ? DelegatorStartingInfo.toJSON(message.startingInfo) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): DelegatorStartingInfoRecord { + const message = createBaseDelegatorStartingInfoRecord(); + message.delegatorAddress = object.delegatorAddress ?? ""; + message.validatorAddress = object.validatorAddress ?? ""; + if (object.startingInfo !== undefined && object.startingInfo !== null) { + message.startingInfo = DelegatorStartingInfo.fromPartial(object.startingInfo); + } + return message; + }, + fromSDK(object: DelegatorStartingInfoRecordSDKType): DelegatorStartingInfoRecord { + return { + delegatorAddress: object?.delegator_address, + validatorAddress: object?.validator_address, + startingInfo: object.starting_info ? DelegatorStartingInfo.fromSDK(object.starting_info) : undefined + }; + }, + fromSDKJSON(object: any): DelegatorStartingInfoRecordSDKType { + return { + delegator_address: isSet(object.delegator_address) ? String(object.delegator_address) : "", + validator_address: isSet(object.validator_address) ? String(object.validator_address) : "", + starting_info: isSet(object.starting_info) ? DelegatorStartingInfo.fromSDKJSON(object.starting_info) : undefined + }; + }, + toSDK(message: DelegatorStartingInfoRecord): DelegatorStartingInfoRecordSDKType { + const obj: any = {}; + obj.delegator_address = message.delegatorAddress; + obj.validator_address = message.validatorAddress; + message.startingInfo !== undefined && (obj.starting_info = message.startingInfo ? DelegatorStartingInfo.toSDK(message.startingInfo) : undefined); + return obj; + }, + fromAmino(object: DelegatorStartingInfoRecordAmino): DelegatorStartingInfoRecord { + const message = createBaseDelegatorStartingInfoRecord(); + if (object.delegator_address !== undefined && object.delegator_address !== null) { + message.delegatorAddress = object.delegator_address; + } + if (object.validator_address !== undefined && object.validator_address !== null) { + message.validatorAddress = object.validator_address; + } + if (object.starting_info !== undefined && object.starting_info !== null) { + message.startingInfo = DelegatorStartingInfo.fromAmino(object.starting_info); + } + return message; + }, + toAmino(message: DelegatorStartingInfoRecord): DelegatorStartingInfoRecordAmino { + const obj: any = {}; + obj.delegator_address = message.delegatorAddress === "" ? undefined : message.delegatorAddress; + obj.validator_address = message.validatorAddress === "" ? undefined : message.validatorAddress; + obj.starting_info = message.startingInfo ? DelegatorStartingInfo.toAmino(message.startingInfo) : undefined; + return obj; + }, + fromAminoMsg(object: DelegatorStartingInfoRecordAminoMsg): DelegatorStartingInfoRecord { + return DelegatorStartingInfoRecord.fromAmino(object.value); + }, + toAminoMsg(message: DelegatorStartingInfoRecord): DelegatorStartingInfoRecordAminoMsg { + return { + type: "cosmos-sdk/DelegatorStartingInfoRecord", + value: DelegatorStartingInfoRecord.toAmino(message) + }; + }, + fromProtoMsg(message: DelegatorStartingInfoRecordProtoMsg): DelegatorStartingInfoRecord { + return DelegatorStartingInfoRecord.decode(message.value); + }, + toProto(message: DelegatorStartingInfoRecord): Uint8Array { + return DelegatorStartingInfoRecord.encode(message).finish(); + }, + toProtoMsg(message: DelegatorStartingInfoRecord): DelegatorStartingInfoRecordProtoMsg { + return { + typeUrl: "/cosmos.distribution.v1beta1.DelegatorStartingInfoRecord", + value: DelegatorStartingInfoRecord.encode(message).finish() + }; + } +}; +function createBaseValidatorSlashEventRecord(): ValidatorSlashEventRecord { + return { + validatorAddress: "", + height: BigInt(0), + period: BigInt(0), + validatorSlashEvent: ValidatorSlashEvent.fromPartial({}) + }; +} +export const ValidatorSlashEventRecord = { + typeUrl: "/cosmos.distribution.v1beta1.ValidatorSlashEventRecord", + encode(message: ValidatorSlashEventRecord, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.validatorAddress !== undefined) { + writer.uint32(10).string(message.validatorAddress); + } + if (message.height !== undefined) { + writer.uint32(16).uint64(message.height); + } + if (message.period !== undefined) { + writer.uint32(24).uint64(message.period); + } + if (message.validatorSlashEvent !== undefined) { + ValidatorSlashEvent.encode(message.validatorSlashEvent, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ValidatorSlashEventRecord { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseValidatorSlashEventRecord(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.validatorAddress = reader.string(); + break; + case 2: + message.height = reader.uint64(); + break; + case 3: + message.period = reader.uint64(); + break; + case 4: + message.validatorSlashEvent = ValidatorSlashEvent.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ValidatorSlashEventRecord { + const obj = createBaseValidatorSlashEventRecord(); + if (isSet(object.validatorAddress)) obj.validatorAddress = String(object.validatorAddress); + if (isSet(object.height)) obj.height = BigInt(object.height.toString()); + if (isSet(object.period)) obj.period = BigInt(object.period.toString()); + if (isSet(object.validatorSlashEvent)) obj.validatorSlashEvent = ValidatorSlashEvent.fromJSON(object.validatorSlashEvent); + return obj; + }, + toJSON(message: ValidatorSlashEventRecord): JsonSafe { + const obj: any = {}; + message.validatorAddress !== undefined && (obj.validatorAddress = message.validatorAddress); + message.height !== undefined && (obj.height = (message.height || BigInt(0)).toString()); + message.period !== undefined && (obj.period = (message.period || BigInt(0)).toString()); + message.validatorSlashEvent !== undefined && (obj.validatorSlashEvent = message.validatorSlashEvent ? ValidatorSlashEvent.toJSON(message.validatorSlashEvent) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): ValidatorSlashEventRecord { + const message = createBaseValidatorSlashEventRecord(); + message.validatorAddress = object.validatorAddress ?? ""; + if (object.height !== undefined && object.height !== null) { + message.height = BigInt(object.height.toString()); + } + if (object.period !== undefined && object.period !== null) { + message.period = BigInt(object.period.toString()); + } + if (object.validatorSlashEvent !== undefined && object.validatorSlashEvent !== null) { + message.validatorSlashEvent = ValidatorSlashEvent.fromPartial(object.validatorSlashEvent); + } + return message; + }, + fromSDK(object: ValidatorSlashEventRecordSDKType): ValidatorSlashEventRecord { + return { + validatorAddress: object?.validator_address, + height: object?.height, + period: object?.period, + validatorSlashEvent: object.validator_slash_event ? ValidatorSlashEvent.fromSDK(object.validator_slash_event) : undefined + }; + }, + fromSDKJSON(object: any): ValidatorSlashEventRecordSDKType { + return { + validator_address: isSet(object.validator_address) ? String(object.validator_address) : "", + height: isSet(object.height) ? BigInt(object.height.toString()) : BigInt(0), + period: isSet(object.period) ? BigInt(object.period.toString()) : BigInt(0), + validator_slash_event: isSet(object.validator_slash_event) ? ValidatorSlashEvent.fromSDKJSON(object.validator_slash_event) : undefined + }; + }, + toSDK(message: ValidatorSlashEventRecord): ValidatorSlashEventRecordSDKType { + const obj: any = {}; + obj.validator_address = message.validatorAddress; + obj.height = message.height; + obj.period = message.period; + message.validatorSlashEvent !== undefined && (obj.validator_slash_event = message.validatorSlashEvent ? ValidatorSlashEvent.toSDK(message.validatorSlashEvent) : undefined); + return obj; + }, + fromAmino(object: ValidatorSlashEventRecordAmino): ValidatorSlashEventRecord { + const message = createBaseValidatorSlashEventRecord(); + if (object.validator_address !== undefined && object.validator_address !== null) { + message.validatorAddress = object.validator_address; + } + if (object.height !== undefined && object.height !== null) { + message.height = BigInt(object.height); + } + if (object.period !== undefined && object.period !== null) { + message.period = BigInt(object.period); + } + if (object.validator_slash_event !== undefined && object.validator_slash_event !== null) { + message.validatorSlashEvent = ValidatorSlashEvent.fromAmino(object.validator_slash_event); + } + return message; + }, + toAmino(message: ValidatorSlashEventRecord): ValidatorSlashEventRecordAmino { + const obj: any = {}; + obj.validator_address = message.validatorAddress === "" ? undefined : message.validatorAddress; + obj.height = message.height !== BigInt(0) ? message.height?.toString() : undefined; + obj.period = message.period !== BigInt(0) ? message.period?.toString() : undefined; + obj.validator_slash_event = message.validatorSlashEvent ? ValidatorSlashEvent.toAmino(message.validatorSlashEvent) : undefined; + return obj; + }, + fromAminoMsg(object: ValidatorSlashEventRecordAminoMsg): ValidatorSlashEventRecord { + return ValidatorSlashEventRecord.fromAmino(object.value); + }, + toAminoMsg(message: ValidatorSlashEventRecord): ValidatorSlashEventRecordAminoMsg { + return { + type: "cosmos-sdk/ValidatorSlashEventRecord", + value: ValidatorSlashEventRecord.toAmino(message) + }; + }, + fromProtoMsg(message: ValidatorSlashEventRecordProtoMsg): ValidatorSlashEventRecord { + return ValidatorSlashEventRecord.decode(message.value); + }, + toProto(message: ValidatorSlashEventRecord): Uint8Array { + return ValidatorSlashEventRecord.encode(message).finish(); + }, + toProtoMsg(message: ValidatorSlashEventRecord): ValidatorSlashEventRecordProtoMsg { + return { + typeUrl: "/cosmos.distribution.v1beta1.ValidatorSlashEventRecord", + value: ValidatorSlashEventRecord.encode(message).finish() + }; + } +}; +function createBaseGenesisState(): GenesisState { + return { + params: Params.fromPartial({}), + feePool: FeePool.fromPartial({}), + delegatorWithdrawInfos: [], + previousProposer: "", + outstandingRewards: [], + validatorAccumulatedCommissions: [], + validatorHistoricalRewards: [], + validatorCurrentRewards: [], + delegatorStartingInfos: [], + validatorSlashEvents: [] + }; +} +export const GenesisState = { + typeUrl: "/cosmos.distribution.v1beta1.GenesisState", + encode(message: GenesisState, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(10).fork()).ldelim(); + } + if (message.feePool !== undefined) { + FeePool.encode(message.feePool, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.delegatorWithdrawInfos) { + DelegatorWithdrawInfo.encode(v!, writer.uint32(26).fork()).ldelim(); + } + if (message.previousProposer !== undefined) { + writer.uint32(34).string(message.previousProposer); + } + for (const v of message.outstandingRewards) { + ValidatorOutstandingRewardsRecord.encode(v!, writer.uint32(42).fork()).ldelim(); + } + for (const v of message.validatorAccumulatedCommissions) { + ValidatorAccumulatedCommissionRecord.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.validatorHistoricalRewards) { + ValidatorHistoricalRewardsRecord.encode(v!, writer.uint32(58).fork()).ldelim(); + } + for (const v of message.validatorCurrentRewards) { + ValidatorCurrentRewardsRecord.encode(v!, writer.uint32(66).fork()).ldelim(); + } + for (const v of message.delegatorStartingInfos) { + DelegatorStartingInfoRecord.encode(v!, writer.uint32(74).fork()).ldelim(); + } + for (const v of message.validatorSlashEvents) { + ValidatorSlashEventRecord.encode(v!, writer.uint32(82).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GenesisState { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGenesisState(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.params = Params.decode(reader, reader.uint32()); + break; + case 2: + message.feePool = FeePool.decode(reader, reader.uint32()); + break; + case 3: + message.delegatorWithdrawInfos.push(DelegatorWithdrawInfo.decode(reader, reader.uint32())); + break; + case 4: + message.previousProposer = reader.string(); + break; + case 5: + message.outstandingRewards.push(ValidatorOutstandingRewardsRecord.decode(reader, reader.uint32())); + break; + case 6: + message.validatorAccumulatedCommissions.push(ValidatorAccumulatedCommissionRecord.decode(reader, reader.uint32())); + break; + case 7: + message.validatorHistoricalRewards.push(ValidatorHistoricalRewardsRecord.decode(reader, reader.uint32())); + break; + case 8: + message.validatorCurrentRewards.push(ValidatorCurrentRewardsRecord.decode(reader, reader.uint32())); + break; + case 9: + message.delegatorStartingInfos.push(DelegatorStartingInfoRecord.decode(reader, reader.uint32())); + break; + case 10: + message.validatorSlashEvents.push(ValidatorSlashEventRecord.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GenesisState { + const obj = createBaseGenesisState(); + if (isSet(object.params)) obj.params = Params.fromJSON(object.params); + if (isSet(object.feePool)) obj.feePool = FeePool.fromJSON(object.feePool); + if (Array.isArray(object?.delegatorWithdrawInfos)) obj.delegatorWithdrawInfos = object.delegatorWithdrawInfos.map((e: any) => DelegatorWithdrawInfo.fromJSON(e)); + if (isSet(object.previousProposer)) obj.previousProposer = String(object.previousProposer); + if (Array.isArray(object?.outstandingRewards)) obj.outstandingRewards = object.outstandingRewards.map((e: any) => ValidatorOutstandingRewardsRecord.fromJSON(e)); + if (Array.isArray(object?.validatorAccumulatedCommissions)) obj.validatorAccumulatedCommissions = object.validatorAccumulatedCommissions.map((e: any) => ValidatorAccumulatedCommissionRecord.fromJSON(e)); + if (Array.isArray(object?.validatorHistoricalRewards)) obj.validatorHistoricalRewards = object.validatorHistoricalRewards.map((e: any) => ValidatorHistoricalRewardsRecord.fromJSON(e)); + if (Array.isArray(object?.validatorCurrentRewards)) obj.validatorCurrentRewards = object.validatorCurrentRewards.map((e: any) => ValidatorCurrentRewardsRecord.fromJSON(e)); + if (Array.isArray(object?.delegatorStartingInfos)) obj.delegatorStartingInfos = object.delegatorStartingInfos.map((e: any) => DelegatorStartingInfoRecord.fromJSON(e)); + if (Array.isArray(object?.validatorSlashEvents)) obj.validatorSlashEvents = object.validatorSlashEvents.map((e: any) => ValidatorSlashEventRecord.fromJSON(e)); + return obj; + }, + toJSON(message: GenesisState): JsonSafe { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); + message.feePool !== undefined && (obj.feePool = message.feePool ? FeePool.toJSON(message.feePool) : undefined); + if (message.delegatorWithdrawInfos) { + obj.delegatorWithdrawInfos = message.delegatorWithdrawInfos.map(e => e ? DelegatorWithdrawInfo.toJSON(e) : undefined); + } else { + obj.delegatorWithdrawInfos = []; + } + message.previousProposer !== undefined && (obj.previousProposer = message.previousProposer); + if (message.outstandingRewards) { + obj.outstandingRewards = message.outstandingRewards.map(e => e ? ValidatorOutstandingRewardsRecord.toJSON(e) : undefined); + } else { + obj.outstandingRewards = []; + } + if (message.validatorAccumulatedCommissions) { + obj.validatorAccumulatedCommissions = message.validatorAccumulatedCommissions.map(e => e ? ValidatorAccumulatedCommissionRecord.toJSON(e) : undefined); + } else { + obj.validatorAccumulatedCommissions = []; + } + if (message.validatorHistoricalRewards) { + obj.validatorHistoricalRewards = message.validatorHistoricalRewards.map(e => e ? ValidatorHistoricalRewardsRecord.toJSON(e) : undefined); + } else { + obj.validatorHistoricalRewards = []; + } + if (message.validatorCurrentRewards) { + obj.validatorCurrentRewards = message.validatorCurrentRewards.map(e => e ? ValidatorCurrentRewardsRecord.toJSON(e) : undefined); + } else { + obj.validatorCurrentRewards = []; + } + if (message.delegatorStartingInfos) { + obj.delegatorStartingInfos = message.delegatorStartingInfos.map(e => e ? DelegatorStartingInfoRecord.toJSON(e) : undefined); + } else { + obj.delegatorStartingInfos = []; + } + if (message.validatorSlashEvents) { + obj.validatorSlashEvents = message.validatorSlashEvents.map(e => e ? ValidatorSlashEventRecord.toJSON(e) : undefined); + } else { + obj.validatorSlashEvents = []; + } + return obj; + }, + fromPartial(object: DeepPartial): GenesisState { + const message = createBaseGenesisState(); + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } + if (object.feePool !== undefined && object.feePool !== null) { + message.feePool = FeePool.fromPartial(object.feePool); + } + message.delegatorWithdrawInfos = object.delegatorWithdrawInfos?.map(e => DelegatorWithdrawInfo.fromPartial(e)) || []; + message.previousProposer = object.previousProposer ?? ""; + message.outstandingRewards = object.outstandingRewards?.map(e => ValidatorOutstandingRewardsRecord.fromPartial(e)) || []; + message.validatorAccumulatedCommissions = object.validatorAccumulatedCommissions?.map(e => ValidatorAccumulatedCommissionRecord.fromPartial(e)) || []; + message.validatorHistoricalRewards = object.validatorHistoricalRewards?.map(e => ValidatorHistoricalRewardsRecord.fromPartial(e)) || []; + message.validatorCurrentRewards = object.validatorCurrentRewards?.map(e => ValidatorCurrentRewardsRecord.fromPartial(e)) || []; + message.delegatorStartingInfos = object.delegatorStartingInfos?.map(e => DelegatorStartingInfoRecord.fromPartial(e)) || []; + message.validatorSlashEvents = object.validatorSlashEvents?.map(e => ValidatorSlashEventRecord.fromPartial(e)) || []; + return message; + }, + fromSDK(object: GenesisStateSDKType): GenesisState { + return { + params: object.params ? Params.fromSDK(object.params) : undefined, + feePool: object.fee_pool ? FeePool.fromSDK(object.fee_pool) : undefined, + delegatorWithdrawInfos: Array.isArray(object?.delegator_withdraw_infos) ? object.delegator_withdraw_infos.map((e: any) => DelegatorWithdrawInfo.fromSDK(e)) : [], + previousProposer: object?.previous_proposer, + outstandingRewards: Array.isArray(object?.outstanding_rewards) ? object.outstanding_rewards.map((e: any) => ValidatorOutstandingRewardsRecord.fromSDK(e)) : [], + validatorAccumulatedCommissions: Array.isArray(object?.validator_accumulated_commissions) ? object.validator_accumulated_commissions.map((e: any) => ValidatorAccumulatedCommissionRecord.fromSDK(e)) : [], + validatorHistoricalRewards: Array.isArray(object?.validator_historical_rewards) ? object.validator_historical_rewards.map((e: any) => ValidatorHistoricalRewardsRecord.fromSDK(e)) : [], + validatorCurrentRewards: Array.isArray(object?.validator_current_rewards) ? object.validator_current_rewards.map((e: any) => ValidatorCurrentRewardsRecord.fromSDK(e)) : [], + delegatorStartingInfos: Array.isArray(object?.delegator_starting_infos) ? object.delegator_starting_infos.map((e: any) => DelegatorStartingInfoRecord.fromSDK(e)) : [], + validatorSlashEvents: Array.isArray(object?.validator_slash_events) ? object.validator_slash_events.map((e: any) => ValidatorSlashEventRecord.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): GenesisStateSDKType { + return { + params: isSet(object.params) ? Params.fromSDKJSON(object.params) : undefined, + fee_pool: isSet(object.fee_pool) ? FeePool.fromSDKJSON(object.fee_pool) : undefined, + delegator_withdraw_infos: Array.isArray(object?.delegator_withdraw_infos) ? object.delegator_withdraw_infos.map((e: any) => DelegatorWithdrawInfo.fromSDKJSON(e)) : [], + previous_proposer: isSet(object.previous_proposer) ? String(object.previous_proposer) : "", + outstanding_rewards: Array.isArray(object?.outstanding_rewards) ? object.outstanding_rewards.map((e: any) => ValidatorOutstandingRewardsRecord.fromSDKJSON(e)) : [], + validator_accumulated_commissions: Array.isArray(object?.validator_accumulated_commissions) ? object.validator_accumulated_commissions.map((e: any) => ValidatorAccumulatedCommissionRecord.fromSDKJSON(e)) : [], + validator_historical_rewards: Array.isArray(object?.validator_historical_rewards) ? object.validator_historical_rewards.map((e: any) => ValidatorHistoricalRewardsRecord.fromSDKJSON(e)) : [], + validator_current_rewards: Array.isArray(object?.validator_current_rewards) ? object.validator_current_rewards.map((e: any) => ValidatorCurrentRewardsRecord.fromSDKJSON(e)) : [], + delegator_starting_infos: Array.isArray(object?.delegator_starting_infos) ? object.delegator_starting_infos.map((e: any) => DelegatorStartingInfoRecord.fromSDKJSON(e)) : [], + validator_slash_events: Array.isArray(object?.validator_slash_events) ? object.validator_slash_events.map((e: any) => ValidatorSlashEventRecord.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: GenesisState): GenesisStateSDKType { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toSDK(message.params) : undefined); + message.feePool !== undefined && (obj.fee_pool = message.feePool ? FeePool.toSDK(message.feePool) : undefined); + if (message.delegatorWithdrawInfos) { + obj.delegator_withdraw_infos = message.delegatorWithdrawInfos.map(e => e ? DelegatorWithdrawInfo.toSDK(e) : undefined); + } else { + obj.delegator_withdraw_infos = []; + } + obj.previous_proposer = message.previousProposer; + if (message.outstandingRewards) { + obj.outstanding_rewards = message.outstandingRewards.map(e => e ? ValidatorOutstandingRewardsRecord.toSDK(e) : undefined); + } else { + obj.outstanding_rewards = []; + } + if (message.validatorAccumulatedCommissions) { + obj.validator_accumulated_commissions = message.validatorAccumulatedCommissions.map(e => e ? ValidatorAccumulatedCommissionRecord.toSDK(e) : undefined); + } else { + obj.validator_accumulated_commissions = []; + } + if (message.validatorHistoricalRewards) { + obj.validator_historical_rewards = message.validatorHistoricalRewards.map(e => e ? ValidatorHistoricalRewardsRecord.toSDK(e) : undefined); + } else { + obj.validator_historical_rewards = []; + } + if (message.validatorCurrentRewards) { + obj.validator_current_rewards = message.validatorCurrentRewards.map(e => e ? ValidatorCurrentRewardsRecord.toSDK(e) : undefined); + } else { + obj.validator_current_rewards = []; + } + if (message.delegatorStartingInfos) { + obj.delegator_starting_infos = message.delegatorStartingInfos.map(e => e ? DelegatorStartingInfoRecord.toSDK(e) : undefined); + } else { + obj.delegator_starting_infos = []; + } + if (message.validatorSlashEvents) { + obj.validator_slash_events = message.validatorSlashEvents.map(e => e ? ValidatorSlashEventRecord.toSDK(e) : undefined); + } else { + obj.validator_slash_events = []; + } + return obj; + }, + fromAmino(object: GenesisStateAmino): GenesisState { + const message = createBaseGenesisState(); + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromAmino(object.params); + } + if (object.fee_pool !== undefined && object.fee_pool !== null) { + message.feePool = FeePool.fromAmino(object.fee_pool); + } + message.delegatorWithdrawInfos = object.delegator_withdraw_infos?.map(e => DelegatorWithdrawInfo.fromAmino(e)) || []; + if (object.previous_proposer !== undefined && object.previous_proposer !== null) { + message.previousProposer = object.previous_proposer; + } + message.outstandingRewards = object.outstanding_rewards?.map(e => ValidatorOutstandingRewardsRecord.fromAmino(e)) || []; + message.validatorAccumulatedCommissions = object.validator_accumulated_commissions?.map(e => ValidatorAccumulatedCommissionRecord.fromAmino(e)) || []; + message.validatorHistoricalRewards = object.validator_historical_rewards?.map(e => ValidatorHistoricalRewardsRecord.fromAmino(e)) || []; + message.validatorCurrentRewards = object.validator_current_rewards?.map(e => ValidatorCurrentRewardsRecord.fromAmino(e)) || []; + message.delegatorStartingInfos = object.delegator_starting_infos?.map(e => DelegatorStartingInfoRecord.fromAmino(e)) || []; + message.validatorSlashEvents = object.validator_slash_events?.map(e => ValidatorSlashEventRecord.fromAmino(e)) || []; + return message; + }, + toAmino(message: GenesisState): GenesisStateAmino { + const obj: any = {}; + obj.params = message.params ? Params.toAmino(message.params) : undefined; + obj.fee_pool = message.feePool ? FeePool.toAmino(message.feePool) : undefined; + if (message.delegatorWithdrawInfos) { + obj.delegator_withdraw_infos = message.delegatorWithdrawInfos.map(e => e ? DelegatorWithdrawInfo.toAmino(e) : undefined); + } else { + obj.delegator_withdraw_infos = message.delegatorWithdrawInfos; + } + obj.previous_proposer = message.previousProposer === "" ? undefined : message.previousProposer; + if (message.outstandingRewards) { + obj.outstanding_rewards = message.outstandingRewards.map(e => e ? ValidatorOutstandingRewardsRecord.toAmino(e) : undefined); + } else { + obj.outstanding_rewards = message.outstandingRewards; + } + if (message.validatorAccumulatedCommissions) { + obj.validator_accumulated_commissions = message.validatorAccumulatedCommissions.map(e => e ? ValidatorAccumulatedCommissionRecord.toAmino(e) : undefined); + } else { + obj.validator_accumulated_commissions = message.validatorAccumulatedCommissions; + } + if (message.validatorHistoricalRewards) { + obj.validator_historical_rewards = message.validatorHistoricalRewards.map(e => e ? ValidatorHistoricalRewardsRecord.toAmino(e) : undefined); + } else { + obj.validator_historical_rewards = message.validatorHistoricalRewards; + } + if (message.validatorCurrentRewards) { + obj.validator_current_rewards = message.validatorCurrentRewards.map(e => e ? ValidatorCurrentRewardsRecord.toAmino(e) : undefined); + } else { + obj.validator_current_rewards = message.validatorCurrentRewards; + } + if (message.delegatorStartingInfos) { + obj.delegator_starting_infos = message.delegatorStartingInfos.map(e => e ? DelegatorStartingInfoRecord.toAmino(e) : undefined); + } else { + obj.delegator_starting_infos = message.delegatorStartingInfos; + } + if (message.validatorSlashEvents) { + obj.validator_slash_events = message.validatorSlashEvents.map(e => e ? ValidatorSlashEventRecord.toAmino(e) : undefined); + } else { + obj.validator_slash_events = message.validatorSlashEvents; + } + return obj; + }, + fromAminoMsg(object: GenesisStateAminoMsg): GenesisState { + return GenesisState.fromAmino(object.value); + }, + toAminoMsg(message: GenesisState): GenesisStateAminoMsg { + return { + type: "cosmos-sdk/GenesisState", + value: GenesisState.toAmino(message) + }; + }, + fromProtoMsg(message: GenesisStateProtoMsg): GenesisState { + return GenesisState.decode(message.value); + }, + toProto(message: GenesisState): Uint8Array { + return GenesisState.encode(message).finish(); + }, + toProtoMsg(message: GenesisState): GenesisStateProtoMsg { + return { + typeUrl: "/cosmos.distribution.v1beta1.GenesisState", + value: GenesisState.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/distribution/v1beta1/query.lcd.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/distribution/v1beta1/query.lcd.ts new file mode 100644 index 0000000000..671459f85d --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/distribution/v1beta1/query.lcd.ts @@ -0,0 +1,83 @@ +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../base/query/v1beta1/pagination.js"; +import { Params, ParamsSDKType, ValidatorOutstandingRewards, ValidatorOutstandingRewardsSDKType, ValidatorAccumulatedCommission, ValidatorAccumulatedCommissionSDKType, ValidatorSlashEvent, ValidatorSlashEventSDKType, DelegationDelegatorReward, DelegationDelegatorRewardSDKType } from "./distribution.js"; +import { DecCoin, DecCoinSDKType } from "../../base/v1beta1/coin.js"; +import { setPaginationParams } from "../../../helpers.js"; +import { LCDClient } from "@cosmology/lcd"; +import { QueryParamsRequest, QueryParamsRequestSDKType, QueryParamsResponse, QueryParamsResponseSDKType, QueryValidatorOutstandingRewardsRequest, QueryValidatorOutstandingRewardsRequestSDKType, QueryValidatorOutstandingRewardsResponse, QueryValidatorOutstandingRewardsResponseSDKType, QueryValidatorCommissionRequest, QueryValidatorCommissionRequestSDKType, QueryValidatorCommissionResponse, QueryValidatorCommissionResponseSDKType, QueryValidatorSlashesRequest, QueryValidatorSlashesRequestSDKType, QueryValidatorSlashesResponse, QueryValidatorSlashesResponseSDKType, QueryDelegationRewardsRequest, QueryDelegationRewardsRequestSDKType, QueryDelegationRewardsResponse, QueryDelegationRewardsResponseSDKType, QueryDelegationTotalRewardsRequest, QueryDelegationTotalRewardsRequestSDKType, QueryDelegationTotalRewardsResponse, QueryDelegationTotalRewardsResponseSDKType, QueryDelegatorValidatorsRequest, QueryDelegatorValidatorsRequestSDKType, QueryDelegatorValidatorsResponse, QueryDelegatorValidatorsResponseSDKType, QueryDelegatorWithdrawAddressRequest, QueryDelegatorWithdrawAddressRequestSDKType, QueryDelegatorWithdrawAddressResponse, QueryDelegatorWithdrawAddressResponseSDKType, QueryCommunityPoolRequest, QueryCommunityPoolRequestSDKType, QueryCommunityPoolResponse, QueryCommunityPoolResponseSDKType } from "./query.js"; +export class LCDQueryClient { + req: LCDClient; + constructor({ + requestClient + }: { + requestClient: LCDClient; + }) { + this.req = requestClient; + this.params = this.params.bind(this); + this.validatorOutstandingRewards = this.validatorOutstandingRewards.bind(this); + this.validatorCommission = this.validatorCommission.bind(this); + this.validatorSlashes = this.validatorSlashes.bind(this); + this.delegationRewards = this.delegationRewards.bind(this); + this.delegationTotalRewards = this.delegationTotalRewards.bind(this); + this.delegatorValidators = this.delegatorValidators.bind(this); + this.delegatorWithdrawAddress = this.delegatorWithdrawAddress.bind(this); + this.communityPool = this.communityPool.bind(this); + } + /* Params queries params of the distribution module. */ + async params(_params: QueryParamsRequest = {}): Promise { + const endpoint = `cosmos/distribution/v1beta1/params`; + return QueryParamsResponse.fromSDKJSON(await this.req.get(endpoint)); + } + /* ValidatorOutstandingRewards queries rewards of a validator address. */ + async validatorOutstandingRewards(params: QueryValidatorOutstandingRewardsRequest): Promise { + const endpoint = `cosmos/distribution/v1beta1/validators/${params.validatorAddress}/outstanding_rewards`; + return QueryValidatorOutstandingRewardsResponse.fromSDKJSON(await this.req.get(endpoint)); + } + /* ValidatorCommission queries accumulated commission for a validator. */ + async validatorCommission(params: QueryValidatorCommissionRequest): Promise { + const endpoint = `cosmos/distribution/v1beta1/validators/${params.validatorAddress}/commission`; + return QueryValidatorCommissionResponse.fromSDKJSON(await this.req.get(endpoint)); + } + /* ValidatorSlashes queries slash events of a validator. */ + async validatorSlashes(params: QueryValidatorSlashesRequest): Promise { + const options: any = { + params: {} + }; + if (typeof params?.startingHeight !== "undefined") { + options.params.starting_height = params.startingHeight; + } + if (typeof params?.endingHeight !== "undefined") { + options.params.ending_height = params.endingHeight; + } + if (typeof params?.pagination !== "undefined") { + setPaginationParams(options, params.pagination); + } + const endpoint = `cosmos/distribution/v1beta1/validators/${params.validatorAddress}/slashes`; + return QueryValidatorSlashesResponse.fromSDKJSON(await this.req.get(endpoint, options)); + } + /* DelegationRewards queries the total rewards accrued by a delegation. */ + async delegationRewards(params: QueryDelegationRewardsRequest): Promise { + const endpoint = `cosmos/distribution/v1beta1/delegators/${params.delegatorAddress}/rewards/${params.validatorAddress}`; + return QueryDelegationRewardsResponse.fromSDKJSON(await this.req.get(endpoint)); + } + /* DelegationTotalRewards queries the total rewards accrued by a each + validator. */ + async delegationTotalRewards(params: QueryDelegationTotalRewardsRequest): Promise { + const endpoint = `cosmos/distribution/v1beta1/delegators/${params.delegatorAddress}/rewards`; + return QueryDelegationTotalRewardsResponse.fromSDKJSON(await this.req.get(endpoint)); + } + /* DelegatorValidators queries the validators of a delegator. */ + async delegatorValidators(params: QueryDelegatorValidatorsRequest): Promise { + const endpoint = `cosmos/distribution/v1beta1/delegators/${params.delegatorAddress}/validators`; + return QueryDelegatorValidatorsResponse.fromSDKJSON(await this.req.get(endpoint)); + } + /* DelegatorWithdrawAddress queries withdraw address of a delegator. */ + async delegatorWithdrawAddress(params: QueryDelegatorWithdrawAddressRequest): Promise { + const endpoint = `cosmos/distribution/v1beta1/delegators/${params.delegatorAddress}/withdraw_address`; + return QueryDelegatorWithdrawAddressResponse.fromSDKJSON(await this.req.get(endpoint)); + } + /* CommunityPool queries the community pool coins. */ + async communityPool(_params: QueryCommunityPoolRequest = {}): Promise { + const endpoint = `cosmos/distribution/v1beta1/community_pool`; + return QueryCommunityPoolResponse.fromSDKJSON(await this.req.get(endpoint)); + } +} \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/distribution/v1beta1/query.rpc.Query.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/distribution/v1beta1/query.rpc.Query.ts new file mode 100644 index 0000000000..5226a4c28c --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/distribution/v1beta1/query.rpc.Query.ts @@ -0,0 +1,124 @@ +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../base/query/v1beta1/pagination.js"; +import { Params, ParamsSDKType, ValidatorOutstandingRewards, ValidatorOutstandingRewardsSDKType, ValidatorAccumulatedCommission, ValidatorAccumulatedCommissionSDKType, ValidatorSlashEvent, ValidatorSlashEventSDKType, DelegationDelegatorReward, DelegationDelegatorRewardSDKType } from "./distribution.js"; +import { DecCoin, DecCoinSDKType } from "../../base/v1beta1/coin.js"; +import { Rpc } from "../../../helpers.js"; +import { BinaryReader } from "../../../binary.js"; +import { QueryClient, createProtobufRpcClient } from "@cosmjs/stargate"; +import { QueryParamsRequest, QueryParamsRequestSDKType, QueryParamsResponse, QueryParamsResponseSDKType, QueryValidatorOutstandingRewardsRequest, QueryValidatorOutstandingRewardsRequestSDKType, QueryValidatorOutstandingRewardsResponse, QueryValidatorOutstandingRewardsResponseSDKType, QueryValidatorCommissionRequest, QueryValidatorCommissionRequestSDKType, QueryValidatorCommissionResponse, QueryValidatorCommissionResponseSDKType, QueryValidatorSlashesRequest, QueryValidatorSlashesRequestSDKType, QueryValidatorSlashesResponse, QueryValidatorSlashesResponseSDKType, QueryDelegationRewardsRequest, QueryDelegationRewardsRequestSDKType, QueryDelegationRewardsResponse, QueryDelegationRewardsResponseSDKType, QueryDelegationTotalRewardsRequest, QueryDelegationTotalRewardsRequestSDKType, QueryDelegationTotalRewardsResponse, QueryDelegationTotalRewardsResponseSDKType, QueryDelegatorValidatorsRequest, QueryDelegatorValidatorsRequestSDKType, QueryDelegatorValidatorsResponse, QueryDelegatorValidatorsResponseSDKType, QueryDelegatorWithdrawAddressRequest, QueryDelegatorWithdrawAddressRequestSDKType, QueryDelegatorWithdrawAddressResponse, QueryDelegatorWithdrawAddressResponseSDKType, QueryCommunityPoolRequest, QueryCommunityPoolRequestSDKType, QueryCommunityPoolResponse, QueryCommunityPoolResponseSDKType } from "./query.js"; +/** Query defines the gRPC querier service for distribution module. */ +export interface Query { + /** Params queries params of the distribution module. */ + params(request?: QueryParamsRequest): Promise; + /** ValidatorOutstandingRewards queries rewards of a validator address. */ + validatorOutstandingRewards(request: QueryValidatorOutstandingRewardsRequest): Promise; + /** ValidatorCommission queries accumulated commission for a validator. */ + validatorCommission(request: QueryValidatorCommissionRequest): Promise; + /** ValidatorSlashes queries slash events of a validator. */ + validatorSlashes(request: QueryValidatorSlashesRequest): Promise; + /** DelegationRewards queries the total rewards accrued by a delegation. */ + delegationRewards(request: QueryDelegationRewardsRequest): Promise; + /** + * DelegationTotalRewards queries the total rewards accrued by a each + * validator. + */ + delegationTotalRewards(request: QueryDelegationTotalRewardsRequest): Promise; + /** DelegatorValidators queries the validators of a delegator. */ + delegatorValidators(request: QueryDelegatorValidatorsRequest): Promise; + /** DelegatorWithdrawAddress queries withdraw address of a delegator. */ + delegatorWithdrawAddress(request: QueryDelegatorWithdrawAddressRequest): Promise; + /** CommunityPool queries the community pool coins. */ + communityPool(request?: QueryCommunityPoolRequest): Promise; +} +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + this.params = this.params.bind(this); + this.validatorOutstandingRewards = this.validatorOutstandingRewards.bind(this); + this.validatorCommission = this.validatorCommission.bind(this); + this.validatorSlashes = this.validatorSlashes.bind(this); + this.delegationRewards = this.delegationRewards.bind(this); + this.delegationTotalRewards = this.delegationTotalRewards.bind(this); + this.delegatorValidators = this.delegatorValidators.bind(this); + this.delegatorWithdrawAddress = this.delegatorWithdrawAddress.bind(this); + this.communityPool = this.communityPool.bind(this); + } + params(request: QueryParamsRequest = {}): Promise { + const data = QueryParamsRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.distribution.v1beta1.Query", "Params", data); + return promise.then(data => QueryParamsResponse.decode(new BinaryReader(data))); + } + validatorOutstandingRewards(request: QueryValidatorOutstandingRewardsRequest): Promise { + const data = QueryValidatorOutstandingRewardsRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.distribution.v1beta1.Query", "ValidatorOutstandingRewards", data); + return promise.then(data => QueryValidatorOutstandingRewardsResponse.decode(new BinaryReader(data))); + } + validatorCommission(request: QueryValidatorCommissionRequest): Promise { + const data = QueryValidatorCommissionRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.distribution.v1beta1.Query", "ValidatorCommission", data); + return promise.then(data => QueryValidatorCommissionResponse.decode(new BinaryReader(data))); + } + validatorSlashes(request: QueryValidatorSlashesRequest): Promise { + const data = QueryValidatorSlashesRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.distribution.v1beta1.Query", "ValidatorSlashes", data); + return promise.then(data => QueryValidatorSlashesResponse.decode(new BinaryReader(data))); + } + delegationRewards(request: QueryDelegationRewardsRequest): Promise { + const data = QueryDelegationRewardsRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.distribution.v1beta1.Query", "DelegationRewards", data); + return promise.then(data => QueryDelegationRewardsResponse.decode(new BinaryReader(data))); + } + delegationTotalRewards(request: QueryDelegationTotalRewardsRequest): Promise { + const data = QueryDelegationTotalRewardsRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.distribution.v1beta1.Query", "DelegationTotalRewards", data); + return promise.then(data => QueryDelegationTotalRewardsResponse.decode(new BinaryReader(data))); + } + delegatorValidators(request: QueryDelegatorValidatorsRequest): Promise { + const data = QueryDelegatorValidatorsRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.distribution.v1beta1.Query", "DelegatorValidators", data); + return promise.then(data => QueryDelegatorValidatorsResponse.decode(new BinaryReader(data))); + } + delegatorWithdrawAddress(request: QueryDelegatorWithdrawAddressRequest): Promise { + const data = QueryDelegatorWithdrawAddressRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.distribution.v1beta1.Query", "DelegatorWithdrawAddress", data); + return promise.then(data => QueryDelegatorWithdrawAddressResponse.decode(new BinaryReader(data))); + } + communityPool(request: QueryCommunityPoolRequest = {}): Promise { + const data = QueryCommunityPoolRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.distribution.v1beta1.Query", "CommunityPool", data); + return promise.then(data => QueryCommunityPoolResponse.decode(new BinaryReader(data))); + } +} +export const createRpcQueryExtension = (base: QueryClient) => { + const rpc = createProtobufRpcClient(base); + const queryService = new QueryClientImpl(rpc); + return { + params(request?: QueryParamsRequest): Promise { + return queryService.params(request); + }, + validatorOutstandingRewards(request: QueryValidatorOutstandingRewardsRequest): Promise { + return queryService.validatorOutstandingRewards(request); + }, + validatorCommission(request: QueryValidatorCommissionRequest): Promise { + return queryService.validatorCommission(request); + }, + validatorSlashes(request: QueryValidatorSlashesRequest): Promise { + return queryService.validatorSlashes(request); + }, + delegationRewards(request: QueryDelegationRewardsRequest): Promise { + return queryService.delegationRewards(request); + }, + delegationTotalRewards(request: QueryDelegationTotalRewardsRequest): Promise { + return queryService.delegationTotalRewards(request); + }, + delegatorValidators(request: QueryDelegatorValidatorsRequest): Promise { + return queryService.delegatorValidators(request); + }, + delegatorWithdrawAddress(request: QueryDelegatorWithdrawAddressRequest): Promise { + return queryService.delegatorWithdrawAddress(request); + }, + communityPool(request?: QueryCommunityPoolRequest): Promise { + return queryService.communityPool(request); + } + }; +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/distribution/v1beta1/query.rpc.func.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/distribution/v1beta1/query.rpc.func.ts new file mode 100644 index 0000000000..52eeee24bd --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/distribution/v1beta1/query.rpc.func.ts @@ -0,0 +1,102 @@ +import { RpcResolver, buildQuery } from "../../../helper-func-types"; +import { buildUseQuery } from "../../../react-query"; +import { QueryParamsRequest, QueryParamsResponse, QueryValidatorOutstandingRewardsRequest, QueryValidatorOutstandingRewardsResponse, QueryValidatorCommissionRequest, QueryValidatorCommissionResponse, QueryValidatorSlashesRequest, QueryValidatorSlashesResponse, QueryDelegationRewardsRequest, QueryDelegationRewardsResponse, QueryDelegationTotalRewardsRequest, QueryDelegationTotalRewardsResponse, QueryDelegatorValidatorsRequest, QueryDelegatorValidatorsResponse, QueryDelegatorWithdrawAddressRequest, QueryDelegatorWithdrawAddressResponse, QueryCommunityPoolRequest, QueryCommunityPoolResponse } from "./query"; +export const createGetParams = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryParamsRequest.encode, + decode: QueryParamsResponse.decode, + service: "cosmos.distribution.v1beta1.Query", + method: "Params", + getRpcInstance: getRpcInstance +}); +export const useGetParams = buildUseQuery({ + builderQueryFn: createGetParams, + queryKeyPrefix: "ParamsQuery" +}); +export const createGetValidatorOutstandingRewards = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryValidatorOutstandingRewardsRequest.encode, + decode: QueryValidatorOutstandingRewardsResponse.decode, + service: "cosmos.distribution.v1beta1.Query", + method: "ValidatorOutstandingRewards", + getRpcInstance: getRpcInstance +}); +export const useGetValidatorOutstandingRewards = buildUseQuery({ + builderQueryFn: createGetValidatorOutstandingRewards, + queryKeyPrefix: "ValidatorOutstandingRewardsQuery" +}); +export const createGetValidatorCommission = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryValidatorCommissionRequest.encode, + decode: QueryValidatorCommissionResponse.decode, + service: "cosmos.distribution.v1beta1.Query", + method: "ValidatorCommission", + getRpcInstance: getRpcInstance +}); +export const useGetValidatorCommission = buildUseQuery({ + builderQueryFn: createGetValidatorCommission, + queryKeyPrefix: "ValidatorCommissionQuery" +}); +export const createGetValidatorSlashes = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryValidatorSlashesRequest.encode, + decode: QueryValidatorSlashesResponse.decode, + service: "cosmos.distribution.v1beta1.Query", + method: "ValidatorSlashes", + getRpcInstance: getRpcInstance +}); +export const useGetValidatorSlashes = buildUseQuery({ + builderQueryFn: createGetValidatorSlashes, + queryKeyPrefix: "ValidatorSlashesQuery" +}); +export const createGetDelegationRewards = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryDelegationRewardsRequest.encode, + decode: QueryDelegationRewardsResponse.decode, + service: "cosmos.distribution.v1beta1.Query", + method: "DelegationRewards", + getRpcInstance: getRpcInstance +}); +export const useGetDelegationRewards = buildUseQuery({ + builderQueryFn: createGetDelegationRewards, + queryKeyPrefix: "DelegationRewardsQuery" +}); +export const createGetDelegationTotalRewards = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryDelegationTotalRewardsRequest.encode, + decode: QueryDelegationTotalRewardsResponse.decode, + service: "cosmos.distribution.v1beta1.Query", + method: "DelegationTotalRewards", + getRpcInstance: getRpcInstance +}); +export const useGetDelegationTotalRewards = buildUseQuery({ + builderQueryFn: createGetDelegationTotalRewards, + queryKeyPrefix: "DelegationTotalRewardsQuery" +}); +export const createGetDelegatorValidators = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryDelegatorValidatorsRequest.encode, + decode: QueryDelegatorValidatorsResponse.decode, + service: "cosmos.distribution.v1beta1.Query", + method: "DelegatorValidators", + getRpcInstance: getRpcInstance +}); +export const useGetDelegatorValidators = buildUseQuery({ + builderQueryFn: createGetDelegatorValidators, + queryKeyPrefix: "DelegatorValidatorsQuery" +}); +export const createGetDelegatorWithdrawAddress = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryDelegatorWithdrawAddressRequest.encode, + decode: QueryDelegatorWithdrawAddressResponse.decode, + service: "cosmos.distribution.v1beta1.Query", + method: "DelegatorWithdrawAddress", + getRpcInstance: getRpcInstance +}); +export const useGetDelegatorWithdrawAddress = buildUseQuery({ + builderQueryFn: createGetDelegatorWithdrawAddress, + queryKeyPrefix: "DelegatorWithdrawAddressQuery" +}); +export const createGetCommunityPool = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryCommunityPoolRequest.encode, + decode: QueryCommunityPoolResponse.decode, + service: "cosmos.distribution.v1beta1.Query", + method: "CommunityPool", + getRpcInstance: getRpcInstance +}); +export const useGetCommunityPool = buildUseQuery({ + builderQueryFn: createGetCommunityPool, + queryKeyPrefix: "CommunityPoolQuery" +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/distribution/v1beta1/query.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/distribution/v1beta1/query.ts new file mode 100644 index 0000000000..a3b02bf64b --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/distribution/v1beta1/query.ts @@ -0,0 +1,2172 @@ +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../base/query/v1beta1/pagination.js"; +import { Params, ParamsSDKType, ValidatorOutstandingRewards, ValidatorOutstandingRewardsSDKType, ValidatorAccumulatedCommission, ValidatorAccumulatedCommissionSDKType, ValidatorSlashEvent, ValidatorSlashEventSDKType, DelegationDelegatorReward, DelegationDelegatorRewardSDKType } from "./distribution.js"; +import { DecCoin, DecCoinSDKType } from "../../base/v1beta1/coin.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { JsonSafe } from "../../../json-safe.js"; +import { DeepPartial, isSet } from "../../../helpers.js"; +export const protobufPackage = "cosmos.distribution.v1beta1"; +/** QueryParamsRequest is the request type for the Query/Params RPC method. */ +export interface QueryParamsRequest {} +export interface QueryParamsRequestProtoMsg { + typeUrl: "/cosmos.distribution.v1beta1.QueryParamsRequest"; + value: Uint8Array; +} +/** QueryParamsRequest is the request type for the Query/Params RPC method. */ +export interface QueryParamsRequestSDKType {} +/** QueryParamsResponse is the response type for the Query/Params RPC method. */ +export interface QueryParamsResponse { + /** params defines the parameters of the module. */ + params: Params; +} +export interface QueryParamsResponseProtoMsg { + typeUrl: "/cosmos.distribution.v1beta1.QueryParamsResponse"; + value: Uint8Array; +} +/** QueryParamsResponse is the response type for the Query/Params RPC method. */ +export interface QueryParamsResponseSDKType { + params: ParamsSDKType; +} +/** + * QueryValidatorOutstandingRewardsRequest is the request type for the + * Query/ValidatorOutstandingRewards RPC method. + */ +export interface QueryValidatorOutstandingRewardsRequest { + /** validator_address defines the validator address to query for. */ + validatorAddress: string; +} +export interface QueryValidatorOutstandingRewardsRequestProtoMsg { + typeUrl: "/cosmos.distribution.v1beta1.QueryValidatorOutstandingRewardsRequest"; + value: Uint8Array; +} +/** + * QueryValidatorOutstandingRewardsRequest is the request type for the + * Query/ValidatorOutstandingRewards RPC method. + */ +export interface QueryValidatorOutstandingRewardsRequestSDKType { + validator_address: string; +} +/** + * QueryValidatorOutstandingRewardsResponse is the response type for the + * Query/ValidatorOutstandingRewards RPC method. + */ +export interface QueryValidatorOutstandingRewardsResponse { + rewards: ValidatorOutstandingRewards; +} +export interface QueryValidatorOutstandingRewardsResponseProtoMsg { + typeUrl: "/cosmos.distribution.v1beta1.QueryValidatorOutstandingRewardsResponse"; + value: Uint8Array; +} +/** + * QueryValidatorOutstandingRewardsResponse is the response type for the + * Query/ValidatorOutstandingRewards RPC method. + */ +export interface QueryValidatorOutstandingRewardsResponseSDKType { + rewards: ValidatorOutstandingRewardsSDKType; +} +/** + * QueryValidatorCommissionRequest is the request type for the + * Query/ValidatorCommission RPC method + */ +export interface QueryValidatorCommissionRequest { + /** validator_address defines the validator address to query for. */ + validatorAddress: string; +} +export interface QueryValidatorCommissionRequestProtoMsg { + typeUrl: "/cosmos.distribution.v1beta1.QueryValidatorCommissionRequest"; + value: Uint8Array; +} +/** + * QueryValidatorCommissionRequest is the request type for the + * Query/ValidatorCommission RPC method + */ +export interface QueryValidatorCommissionRequestSDKType { + validator_address: string; +} +/** + * QueryValidatorCommissionResponse is the response type for the + * Query/ValidatorCommission RPC method + */ +export interface QueryValidatorCommissionResponse { + /** commission defines the commision the validator received. */ + commission: ValidatorAccumulatedCommission; +} +export interface QueryValidatorCommissionResponseProtoMsg { + typeUrl: "/cosmos.distribution.v1beta1.QueryValidatorCommissionResponse"; + value: Uint8Array; +} +/** + * QueryValidatorCommissionResponse is the response type for the + * Query/ValidatorCommission RPC method + */ +export interface QueryValidatorCommissionResponseSDKType { + commission: ValidatorAccumulatedCommissionSDKType; +} +/** + * QueryValidatorSlashesRequest is the request type for the + * Query/ValidatorSlashes RPC method + */ +export interface QueryValidatorSlashesRequest { + /** validator_address defines the validator address to query for. */ + validatorAddress: string; + /** starting_height defines the optional starting height to query the slashes. */ + startingHeight: bigint; + /** starting_height defines the optional ending height to query the slashes. */ + endingHeight: bigint; + /** pagination defines an optional pagination for the request. */ + pagination?: PageRequest; +} +export interface QueryValidatorSlashesRequestProtoMsg { + typeUrl: "/cosmos.distribution.v1beta1.QueryValidatorSlashesRequest"; + value: Uint8Array; +} +/** + * QueryValidatorSlashesRequest is the request type for the + * Query/ValidatorSlashes RPC method + */ +export interface QueryValidatorSlashesRequestSDKType { + validator_address: string; + starting_height: bigint; + ending_height: bigint; + pagination?: PageRequestSDKType; +} +/** + * QueryValidatorSlashesResponse is the response type for the + * Query/ValidatorSlashes RPC method. + */ +export interface QueryValidatorSlashesResponse { + /** slashes defines the slashes the validator received. */ + slashes: ValidatorSlashEvent[]; + /** pagination defines the pagination in the response. */ + pagination?: PageResponse; +} +export interface QueryValidatorSlashesResponseProtoMsg { + typeUrl: "/cosmos.distribution.v1beta1.QueryValidatorSlashesResponse"; + value: Uint8Array; +} +/** + * QueryValidatorSlashesResponse is the response type for the + * Query/ValidatorSlashes RPC method. + */ +export interface QueryValidatorSlashesResponseSDKType { + slashes: ValidatorSlashEventSDKType[]; + pagination?: PageResponseSDKType; +} +/** + * QueryDelegationRewardsRequest is the request type for the + * Query/DelegationRewards RPC method. + */ +export interface QueryDelegationRewardsRequest { + /** delegator_address defines the delegator address to query for. */ + delegatorAddress: string; + /** validator_address defines the validator address to query for. */ + validatorAddress: string; +} +export interface QueryDelegationRewardsRequestProtoMsg { + typeUrl: "/cosmos.distribution.v1beta1.QueryDelegationRewardsRequest"; + value: Uint8Array; +} +/** + * QueryDelegationRewardsRequest is the request type for the + * Query/DelegationRewards RPC method. + */ +export interface QueryDelegationRewardsRequestSDKType { + delegator_address: string; + validator_address: string; +} +/** + * QueryDelegationRewardsResponse is the response type for the + * Query/DelegationRewards RPC method. + */ +export interface QueryDelegationRewardsResponse { + /** rewards defines the rewards accrued by a delegation. */ + rewards: DecCoin[]; +} +export interface QueryDelegationRewardsResponseProtoMsg { + typeUrl: "/cosmos.distribution.v1beta1.QueryDelegationRewardsResponse"; + value: Uint8Array; +} +/** + * QueryDelegationRewardsResponse is the response type for the + * Query/DelegationRewards RPC method. + */ +export interface QueryDelegationRewardsResponseSDKType { + rewards: DecCoinSDKType[]; +} +/** + * QueryDelegationTotalRewardsRequest is the request type for the + * Query/DelegationTotalRewards RPC method. + */ +export interface QueryDelegationTotalRewardsRequest { + /** delegator_address defines the delegator address to query for. */ + delegatorAddress: string; +} +export interface QueryDelegationTotalRewardsRequestProtoMsg { + typeUrl: "/cosmos.distribution.v1beta1.QueryDelegationTotalRewardsRequest"; + value: Uint8Array; +} +/** + * QueryDelegationTotalRewardsRequest is the request type for the + * Query/DelegationTotalRewards RPC method. + */ +export interface QueryDelegationTotalRewardsRequestSDKType { + delegator_address: string; +} +/** + * QueryDelegationTotalRewardsResponse is the response type for the + * Query/DelegationTotalRewards RPC method. + */ +export interface QueryDelegationTotalRewardsResponse { + /** rewards defines all the rewards accrued by a delegator. */ + rewards: DelegationDelegatorReward[]; + /** total defines the sum of all the rewards. */ + total: DecCoin[]; +} +export interface QueryDelegationTotalRewardsResponseProtoMsg { + typeUrl: "/cosmos.distribution.v1beta1.QueryDelegationTotalRewardsResponse"; + value: Uint8Array; +} +/** + * QueryDelegationTotalRewardsResponse is the response type for the + * Query/DelegationTotalRewards RPC method. + */ +export interface QueryDelegationTotalRewardsResponseSDKType { + rewards: DelegationDelegatorRewardSDKType[]; + total: DecCoinSDKType[]; +} +/** + * QueryDelegatorValidatorsRequest is the request type for the + * Query/DelegatorValidators RPC method. + */ +export interface QueryDelegatorValidatorsRequest { + /** delegator_address defines the delegator address to query for. */ + delegatorAddress: string; +} +export interface QueryDelegatorValidatorsRequestProtoMsg { + typeUrl: "/cosmos.distribution.v1beta1.QueryDelegatorValidatorsRequest"; + value: Uint8Array; +} +/** + * QueryDelegatorValidatorsRequest is the request type for the + * Query/DelegatorValidators RPC method. + */ +export interface QueryDelegatorValidatorsRequestSDKType { + delegator_address: string; +} +/** + * QueryDelegatorValidatorsResponse is the response type for the + * Query/DelegatorValidators RPC method. + */ +export interface QueryDelegatorValidatorsResponse { + /** validators defines the validators a delegator is delegating for. */ + validators: string[]; +} +export interface QueryDelegatorValidatorsResponseProtoMsg { + typeUrl: "/cosmos.distribution.v1beta1.QueryDelegatorValidatorsResponse"; + value: Uint8Array; +} +/** + * QueryDelegatorValidatorsResponse is the response type for the + * Query/DelegatorValidators RPC method. + */ +export interface QueryDelegatorValidatorsResponseSDKType { + validators: string[]; +} +/** + * QueryDelegatorWithdrawAddressRequest is the request type for the + * Query/DelegatorWithdrawAddress RPC method. + */ +export interface QueryDelegatorWithdrawAddressRequest { + /** delegator_address defines the delegator address to query for. */ + delegatorAddress: string; +} +export interface QueryDelegatorWithdrawAddressRequestProtoMsg { + typeUrl: "/cosmos.distribution.v1beta1.QueryDelegatorWithdrawAddressRequest"; + value: Uint8Array; +} +/** + * QueryDelegatorWithdrawAddressRequest is the request type for the + * Query/DelegatorWithdrawAddress RPC method. + */ +export interface QueryDelegatorWithdrawAddressRequestSDKType { + delegator_address: string; +} +/** + * QueryDelegatorWithdrawAddressResponse is the response type for the + * Query/DelegatorWithdrawAddress RPC method. + */ +export interface QueryDelegatorWithdrawAddressResponse { + /** withdraw_address defines the delegator address to query for. */ + withdrawAddress: string; +} +export interface QueryDelegatorWithdrawAddressResponseProtoMsg { + typeUrl: "/cosmos.distribution.v1beta1.QueryDelegatorWithdrawAddressResponse"; + value: Uint8Array; +} +/** + * QueryDelegatorWithdrawAddressResponse is the response type for the + * Query/DelegatorWithdrawAddress RPC method. + */ +export interface QueryDelegatorWithdrawAddressResponseSDKType { + withdraw_address: string; +} +/** + * QueryCommunityPoolRequest is the request type for the Query/CommunityPool RPC + * method. + */ +export interface QueryCommunityPoolRequest {} +export interface QueryCommunityPoolRequestProtoMsg { + typeUrl: "/cosmos.distribution.v1beta1.QueryCommunityPoolRequest"; + value: Uint8Array; +} +/** + * QueryCommunityPoolRequest is the request type for the Query/CommunityPool RPC + * method. + */ +export interface QueryCommunityPoolRequestSDKType {} +/** + * QueryCommunityPoolResponse is the response type for the Query/CommunityPool + * RPC method. + */ +export interface QueryCommunityPoolResponse { + /** pool defines community pool's coins. */ + pool: DecCoin[]; +} +export interface QueryCommunityPoolResponseProtoMsg { + typeUrl: "/cosmos.distribution.v1beta1.QueryCommunityPoolResponse"; + value: Uint8Array; +} +/** + * QueryCommunityPoolResponse is the response type for the Query/CommunityPool + * RPC method. + */ +export interface QueryCommunityPoolResponseSDKType { + pool: DecCoinSDKType[]; +} +function createBaseQueryParamsRequest(): QueryParamsRequest { + return {}; +} +export const QueryParamsRequest = { + typeUrl: "/cosmos.distribution.v1beta1.QueryParamsRequest", + encode(_: QueryParamsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryParamsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryParamsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): QueryParamsRequest { + const obj = createBaseQueryParamsRequest(); + return obj; + }, + toJSON(_: QueryParamsRequest): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): QueryParamsRequest { + const message = createBaseQueryParamsRequest(); + return message; + }, + fromSDK(_: QueryParamsRequestSDKType): QueryParamsRequest { + return {}; + }, + fromSDKJSON(_: any): QueryParamsRequestSDKType { + return {}; + }, + toSDK(_: QueryParamsRequest): QueryParamsRequestSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: QueryParamsRequestAmino): QueryParamsRequest { + const message = createBaseQueryParamsRequest(); + return message; + }, + toAmino(_: QueryParamsRequest): QueryParamsRequestAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: QueryParamsRequestAminoMsg): QueryParamsRequest { + return QueryParamsRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryParamsRequest): QueryParamsRequestAminoMsg { + return { + type: "cosmos-sdk/QueryParamsRequest", + value: QueryParamsRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryParamsRequestProtoMsg): QueryParamsRequest { + return QueryParamsRequest.decode(message.value); + }, + toProto(message: QueryParamsRequest): Uint8Array { + return QueryParamsRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryParamsRequest): QueryParamsRequestProtoMsg { + return { + typeUrl: "/cosmos.distribution.v1beta1.QueryParamsRequest", + value: QueryParamsRequest.encode(message).finish() + }; + } +}; +function createBaseQueryParamsResponse(): QueryParamsResponse { + return { + params: Params.fromPartial({}) + }; +} +export const QueryParamsResponse = { + typeUrl: "/cosmos.distribution.v1beta1.QueryParamsResponse", + encode(message: QueryParamsResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryParamsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryParamsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.params = Params.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryParamsResponse { + const obj = createBaseQueryParamsResponse(); + if (isSet(object.params)) obj.params = Params.fromJSON(object.params); + return obj; + }, + toJSON(message: QueryParamsResponse): JsonSafe { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryParamsResponse { + const message = createBaseQueryParamsResponse(); + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } + return message; + }, + fromSDK(object: QueryParamsResponseSDKType): QueryParamsResponse { + return { + params: object.params ? Params.fromSDK(object.params) : undefined + }; + }, + fromSDKJSON(object: any): QueryParamsResponseSDKType { + return { + params: isSet(object.params) ? Params.fromSDKJSON(object.params) : undefined + }; + }, + toSDK(message: QueryParamsResponse): QueryParamsResponseSDKType { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toSDK(message.params) : undefined); + return obj; + }, + fromAmino(object: QueryParamsResponseAmino): QueryParamsResponse { + const message = createBaseQueryParamsResponse(); + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromAmino(object.params); + } + return message; + }, + toAmino(message: QueryParamsResponse): QueryParamsResponseAmino { + const obj: any = {}; + obj.params = message.params ? Params.toAmino(message.params) : undefined; + return obj; + }, + fromAminoMsg(object: QueryParamsResponseAminoMsg): QueryParamsResponse { + return QueryParamsResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryParamsResponse): QueryParamsResponseAminoMsg { + return { + type: "cosmos-sdk/QueryParamsResponse", + value: QueryParamsResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryParamsResponseProtoMsg): QueryParamsResponse { + return QueryParamsResponse.decode(message.value); + }, + toProto(message: QueryParamsResponse): Uint8Array { + return QueryParamsResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryParamsResponse): QueryParamsResponseProtoMsg { + return { + typeUrl: "/cosmos.distribution.v1beta1.QueryParamsResponse", + value: QueryParamsResponse.encode(message).finish() + }; + } +}; +function createBaseQueryValidatorOutstandingRewardsRequest(): QueryValidatorOutstandingRewardsRequest { + return { + validatorAddress: "" + }; +} +export const QueryValidatorOutstandingRewardsRequest = { + typeUrl: "/cosmos.distribution.v1beta1.QueryValidatorOutstandingRewardsRequest", + encode(message: QueryValidatorOutstandingRewardsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.validatorAddress !== undefined) { + writer.uint32(10).string(message.validatorAddress); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryValidatorOutstandingRewardsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryValidatorOutstandingRewardsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.validatorAddress = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryValidatorOutstandingRewardsRequest { + const obj = createBaseQueryValidatorOutstandingRewardsRequest(); + if (isSet(object.validatorAddress)) obj.validatorAddress = String(object.validatorAddress); + return obj; + }, + toJSON(message: QueryValidatorOutstandingRewardsRequest): JsonSafe { + const obj: any = {}; + message.validatorAddress !== undefined && (obj.validatorAddress = message.validatorAddress); + return obj; + }, + fromPartial(object: DeepPartial): QueryValidatorOutstandingRewardsRequest { + const message = createBaseQueryValidatorOutstandingRewardsRequest(); + message.validatorAddress = object.validatorAddress ?? ""; + return message; + }, + fromSDK(object: QueryValidatorOutstandingRewardsRequestSDKType): QueryValidatorOutstandingRewardsRequest { + return { + validatorAddress: object?.validator_address + }; + }, + fromSDKJSON(object: any): QueryValidatorOutstandingRewardsRequestSDKType { + return { + validator_address: isSet(object.validator_address) ? String(object.validator_address) : "" + }; + }, + toSDK(message: QueryValidatorOutstandingRewardsRequest): QueryValidatorOutstandingRewardsRequestSDKType { + const obj: any = {}; + obj.validator_address = message.validatorAddress; + return obj; + }, + fromAmino(object: QueryValidatorOutstandingRewardsRequestAmino): QueryValidatorOutstandingRewardsRequest { + const message = createBaseQueryValidatorOutstandingRewardsRequest(); + if (object.validator_address !== undefined && object.validator_address !== null) { + message.validatorAddress = object.validator_address; + } + return message; + }, + toAmino(message: QueryValidatorOutstandingRewardsRequest): QueryValidatorOutstandingRewardsRequestAmino { + const obj: any = {}; + obj.validator_address = message.validatorAddress === "" ? undefined : message.validatorAddress; + return obj; + }, + fromAminoMsg(object: QueryValidatorOutstandingRewardsRequestAminoMsg): QueryValidatorOutstandingRewardsRequest { + return QueryValidatorOutstandingRewardsRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryValidatorOutstandingRewardsRequest): QueryValidatorOutstandingRewardsRequestAminoMsg { + return { + type: "cosmos-sdk/QueryValidatorOutstandingRewardsRequest", + value: QueryValidatorOutstandingRewardsRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryValidatorOutstandingRewardsRequestProtoMsg): QueryValidatorOutstandingRewardsRequest { + return QueryValidatorOutstandingRewardsRequest.decode(message.value); + }, + toProto(message: QueryValidatorOutstandingRewardsRequest): Uint8Array { + return QueryValidatorOutstandingRewardsRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryValidatorOutstandingRewardsRequest): QueryValidatorOutstandingRewardsRequestProtoMsg { + return { + typeUrl: "/cosmos.distribution.v1beta1.QueryValidatorOutstandingRewardsRequest", + value: QueryValidatorOutstandingRewardsRequest.encode(message).finish() + }; + } +}; +function createBaseQueryValidatorOutstandingRewardsResponse(): QueryValidatorOutstandingRewardsResponse { + return { + rewards: ValidatorOutstandingRewards.fromPartial({}) + }; +} +export const QueryValidatorOutstandingRewardsResponse = { + typeUrl: "/cosmos.distribution.v1beta1.QueryValidatorOutstandingRewardsResponse", + encode(message: QueryValidatorOutstandingRewardsResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.rewards !== undefined) { + ValidatorOutstandingRewards.encode(message.rewards, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryValidatorOutstandingRewardsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryValidatorOutstandingRewardsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.rewards = ValidatorOutstandingRewards.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryValidatorOutstandingRewardsResponse { + const obj = createBaseQueryValidatorOutstandingRewardsResponse(); + if (isSet(object.rewards)) obj.rewards = ValidatorOutstandingRewards.fromJSON(object.rewards); + return obj; + }, + toJSON(message: QueryValidatorOutstandingRewardsResponse): JsonSafe { + const obj: any = {}; + message.rewards !== undefined && (obj.rewards = message.rewards ? ValidatorOutstandingRewards.toJSON(message.rewards) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryValidatorOutstandingRewardsResponse { + const message = createBaseQueryValidatorOutstandingRewardsResponse(); + if (object.rewards !== undefined && object.rewards !== null) { + message.rewards = ValidatorOutstandingRewards.fromPartial(object.rewards); + } + return message; + }, + fromSDK(object: QueryValidatorOutstandingRewardsResponseSDKType): QueryValidatorOutstandingRewardsResponse { + return { + rewards: object.rewards ? ValidatorOutstandingRewards.fromSDK(object.rewards) : undefined + }; + }, + fromSDKJSON(object: any): QueryValidatorOutstandingRewardsResponseSDKType { + return { + rewards: isSet(object.rewards) ? ValidatorOutstandingRewards.fromSDKJSON(object.rewards) : undefined + }; + }, + toSDK(message: QueryValidatorOutstandingRewardsResponse): QueryValidatorOutstandingRewardsResponseSDKType { + const obj: any = {}; + message.rewards !== undefined && (obj.rewards = message.rewards ? ValidatorOutstandingRewards.toSDK(message.rewards) : undefined); + return obj; + }, + fromAmino(object: QueryValidatorOutstandingRewardsResponseAmino): QueryValidatorOutstandingRewardsResponse { + const message = createBaseQueryValidatorOutstandingRewardsResponse(); + if (object.rewards !== undefined && object.rewards !== null) { + message.rewards = ValidatorOutstandingRewards.fromAmino(object.rewards); + } + return message; + }, + toAmino(message: QueryValidatorOutstandingRewardsResponse): QueryValidatorOutstandingRewardsResponseAmino { + const obj: any = {}; + obj.rewards = message.rewards ? ValidatorOutstandingRewards.toAmino(message.rewards) : undefined; + return obj; + }, + fromAminoMsg(object: QueryValidatorOutstandingRewardsResponseAminoMsg): QueryValidatorOutstandingRewardsResponse { + return QueryValidatorOutstandingRewardsResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryValidatorOutstandingRewardsResponse): QueryValidatorOutstandingRewardsResponseAminoMsg { + return { + type: "cosmos-sdk/QueryValidatorOutstandingRewardsResponse", + value: QueryValidatorOutstandingRewardsResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryValidatorOutstandingRewardsResponseProtoMsg): QueryValidatorOutstandingRewardsResponse { + return QueryValidatorOutstandingRewardsResponse.decode(message.value); + }, + toProto(message: QueryValidatorOutstandingRewardsResponse): Uint8Array { + return QueryValidatorOutstandingRewardsResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryValidatorOutstandingRewardsResponse): QueryValidatorOutstandingRewardsResponseProtoMsg { + return { + typeUrl: "/cosmos.distribution.v1beta1.QueryValidatorOutstandingRewardsResponse", + value: QueryValidatorOutstandingRewardsResponse.encode(message).finish() + }; + } +}; +function createBaseQueryValidatorCommissionRequest(): QueryValidatorCommissionRequest { + return { + validatorAddress: "" + }; +} +export const QueryValidatorCommissionRequest = { + typeUrl: "/cosmos.distribution.v1beta1.QueryValidatorCommissionRequest", + encode(message: QueryValidatorCommissionRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.validatorAddress !== undefined) { + writer.uint32(10).string(message.validatorAddress); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryValidatorCommissionRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryValidatorCommissionRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.validatorAddress = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryValidatorCommissionRequest { + const obj = createBaseQueryValidatorCommissionRequest(); + if (isSet(object.validatorAddress)) obj.validatorAddress = String(object.validatorAddress); + return obj; + }, + toJSON(message: QueryValidatorCommissionRequest): JsonSafe { + const obj: any = {}; + message.validatorAddress !== undefined && (obj.validatorAddress = message.validatorAddress); + return obj; + }, + fromPartial(object: DeepPartial): QueryValidatorCommissionRequest { + const message = createBaseQueryValidatorCommissionRequest(); + message.validatorAddress = object.validatorAddress ?? ""; + return message; + }, + fromSDK(object: QueryValidatorCommissionRequestSDKType): QueryValidatorCommissionRequest { + return { + validatorAddress: object?.validator_address + }; + }, + fromSDKJSON(object: any): QueryValidatorCommissionRequestSDKType { + return { + validator_address: isSet(object.validator_address) ? String(object.validator_address) : "" + }; + }, + toSDK(message: QueryValidatorCommissionRequest): QueryValidatorCommissionRequestSDKType { + const obj: any = {}; + obj.validator_address = message.validatorAddress; + return obj; + }, + fromAmino(object: QueryValidatorCommissionRequestAmino): QueryValidatorCommissionRequest { + const message = createBaseQueryValidatorCommissionRequest(); + if (object.validator_address !== undefined && object.validator_address !== null) { + message.validatorAddress = object.validator_address; + } + return message; + }, + toAmino(message: QueryValidatorCommissionRequest): QueryValidatorCommissionRequestAmino { + const obj: any = {}; + obj.validator_address = message.validatorAddress === "" ? undefined : message.validatorAddress; + return obj; + }, + fromAminoMsg(object: QueryValidatorCommissionRequestAminoMsg): QueryValidatorCommissionRequest { + return QueryValidatorCommissionRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryValidatorCommissionRequest): QueryValidatorCommissionRequestAminoMsg { + return { + type: "cosmos-sdk/QueryValidatorCommissionRequest", + value: QueryValidatorCommissionRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryValidatorCommissionRequestProtoMsg): QueryValidatorCommissionRequest { + return QueryValidatorCommissionRequest.decode(message.value); + }, + toProto(message: QueryValidatorCommissionRequest): Uint8Array { + return QueryValidatorCommissionRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryValidatorCommissionRequest): QueryValidatorCommissionRequestProtoMsg { + return { + typeUrl: "/cosmos.distribution.v1beta1.QueryValidatorCommissionRequest", + value: QueryValidatorCommissionRequest.encode(message).finish() + }; + } +}; +function createBaseQueryValidatorCommissionResponse(): QueryValidatorCommissionResponse { + return { + commission: ValidatorAccumulatedCommission.fromPartial({}) + }; +} +export const QueryValidatorCommissionResponse = { + typeUrl: "/cosmos.distribution.v1beta1.QueryValidatorCommissionResponse", + encode(message: QueryValidatorCommissionResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.commission !== undefined) { + ValidatorAccumulatedCommission.encode(message.commission, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryValidatorCommissionResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryValidatorCommissionResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.commission = ValidatorAccumulatedCommission.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryValidatorCommissionResponse { + const obj = createBaseQueryValidatorCommissionResponse(); + if (isSet(object.commission)) obj.commission = ValidatorAccumulatedCommission.fromJSON(object.commission); + return obj; + }, + toJSON(message: QueryValidatorCommissionResponse): JsonSafe { + const obj: any = {}; + message.commission !== undefined && (obj.commission = message.commission ? ValidatorAccumulatedCommission.toJSON(message.commission) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryValidatorCommissionResponse { + const message = createBaseQueryValidatorCommissionResponse(); + if (object.commission !== undefined && object.commission !== null) { + message.commission = ValidatorAccumulatedCommission.fromPartial(object.commission); + } + return message; + }, + fromSDK(object: QueryValidatorCommissionResponseSDKType): QueryValidatorCommissionResponse { + return { + commission: object.commission ? ValidatorAccumulatedCommission.fromSDK(object.commission) : undefined + }; + }, + fromSDKJSON(object: any): QueryValidatorCommissionResponseSDKType { + return { + commission: isSet(object.commission) ? ValidatorAccumulatedCommission.fromSDKJSON(object.commission) : undefined + }; + }, + toSDK(message: QueryValidatorCommissionResponse): QueryValidatorCommissionResponseSDKType { + const obj: any = {}; + message.commission !== undefined && (obj.commission = message.commission ? ValidatorAccumulatedCommission.toSDK(message.commission) : undefined); + return obj; + }, + fromAmino(object: QueryValidatorCommissionResponseAmino): QueryValidatorCommissionResponse { + const message = createBaseQueryValidatorCommissionResponse(); + if (object.commission !== undefined && object.commission !== null) { + message.commission = ValidatorAccumulatedCommission.fromAmino(object.commission); + } + return message; + }, + toAmino(message: QueryValidatorCommissionResponse): QueryValidatorCommissionResponseAmino { + const obj: any = {}; + obj.commission = message.commission ? ValidatorAccumulatedCommission.toAmino(message.commission) : undefined; + return obj; + }, + fromAminoMsg(object: QueryValidatorCommissionResponseAminoMsg): QueryValidatorCommissionResponse { + return QueryValidatorCommissionResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryValidatorCommissionResponse): QueryValidatorCommissionResponseAminoMsg { + return { + type: "cosmos-sdk/QueryValidatorCommissionResponse", + value: QueryValidatorCommissionResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryValidatorCommissionResponseProtoMsg): QueryValidatorCommissionResponse { + return QueryValidatorCommissionResponse.decode(message.value); + }, + toProto(message: QueryValidatorCommissionResponse): Uint8Array { + return QueryValidatorCommissionResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryValidatorCommissionResponse): QueryValidatorCommissionResponseProtoMsg { + return { + typeUrl: "/cosmos.distribution.v1beta1.QueryValidatorCommissionResponse", + value: QueryValidatorCommissionResponse.encode(message).finish() + }; + } +}; +function createBaseQueryValidatorSlashesRequest(): QueryValidatorSlashesRequest { + return { + validatorAddress: "", + startingHeight: BigInt(0), + endingHeight: BigInt(0), + pagination: undefined + }; +} +export const QueryValidatorSlashesRequest = { + typeUrl: "/cosmos.distribution.v1beta1.QueryValidatorSlashesRequest", + encode(message: QueryValidatorSlashesRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.validatorAddress !== undefined) { + writer.uint32(10).string(message.validatorAddress); + } + if (message.startingHeight !== undefined) { + writer.uint32(16).uint64(message.startingHeight); + } + if (message.endingHeight !== undefined) { + writer.uint32(24).uint64(message.endingHeight); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryValidatorSlashesRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryValidatorSlashesRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.validatorAddress = reader.string(); + break; + case 2: + message.startingHeight = reader.uint64(); + break; + case 3: + message.endingHeight = reader.uint64(); + break; + case 4: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryValidatorSlashesRequest { + const obj = createBaseQueryValidatorSlashesRequest(); + if (isSet(object.validatorAddress)) obj.validatorAddress = String(object.validatorAddress); + if (isSet(object.startingHeight)) obj.startingHeight = BigInt(object.startingHeight.toString()); + if (isSet(object.endingHeight)) obj.endingHeight = BigInt(object.endingHeight.toString()); + if (isSet(object.pagination)) obj.pagination = PageRequest.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryValidatorSlashesRequest): JsonSafe { + const obj: any = {}; + message.validatorAddress !== undefined && (obj.validatorAddress = message.validatorAddress); + message.startingHeight !== undefined && (obj.startingHeight = (message.startingHeight || BigInt(0)).toString()); + message.endingHeight !== undefined && (obj.endingHeight = (message.endingHeight || BigInt(0)).toString()); + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryValidatorSlashesRequest { + const message = createBaseQueryValidatorSlashesRequest(); + message.validatorAddress = object.validatorAddress ?? ""; + if (object.startingHeight !== undefined && object.startingHeight !== null) { + message.startingHeight = BigInt(object.startingHeight.toString()); + } + if (object.endingHeight !== undefined && object.endingHeight !== null) { + message.endingHeight = BigInt(object.endingHeight.toString()); + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryValidatorSlashesRequestSDKType): QueryValidatorSlashesRequest { + return { + validatorAddress: object?.validator_address, + startingHeight: object?.starting_height, + endingHeight: object?.ending_height, + pagination: object.pagination ? PageRequest.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryValidatorSlashesRequestSDKType { + return { + validator_address: isSet(object.validator_address) ? String(object.validator_address) : "", + starting_height: isSet(object.starting_height) ? BigInt(object.starting_height.toString()) : BigInt(0), + ending_height: isSet(object.ending_height) ? BigInt(object.ending_height.toString()) : BigInt(0), + pagination: isSet(object.pagination) ? PageRequest.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryValidatorSlashesRequest): QueryValidatorSlashesRequestSDKType { + const obj: any = {}; + obj.validator_address = message.validatorAddress; + obj.starting_height = message.startingHeight; + obj.ending_height = message.endingHeight; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryValidatorSlashesRequestAmino): QueryValidatorSlashesRequest { + const message = createBaseQueryValidatorSlashesRequest(); + if (object.validator_address !== undefined && object.validator_address !== null) { + message.validatorAddress = object.validator_address; + } + if (object.starting_height !== undefined && object.starting_height !== null) { + message.startingHeight = BigInt(object.starting_height); + } + if (object.ending_height !== undefined && object.ending_height !== null) { + message.endingHeight = BigInt(object.ending_height); + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryValidatorSlashesRequest): QueryValidatorSlashesRequestAmino { + const obj: any = {}; + obj.validator_address = message.validatorAddress === "" ? undefined : message.validatorAddress; + obj.starting_height = message.startingHeight !== BigInt(0) ? message.startingHeight?.toString() : undefined; + obj.ending_height = message.endingHeight !== BigInt(0) ? message.endingHeight?.toString() : undefined; + obj.pagination = message.pagination ? PageRequest.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryValidatorSlashesRequestAminoMsg): QueryValidatorSlashesRequest { + return QueryValidatorSlashesRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryValidatorSlashesRequest): QueryValidatorSlashesRequestAminoMsg { + return { + type: "cosmos-sdk/QueryValidatorSlashesRequest", + value: QueryValidatorSlashesRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryValidatorSlashesRequestProtoMsg): QueryValidatorSlashesRequest { + return QueryValidatorSlashesRequest.decode(message.value); + }, + toProto(message: QueryValidatorSlashesRequest): Uint8Array { + return QueryValidatorSlashesRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryValidatorSlashesRequest): QueryValidatorSlashesRequestProtoMsg { + return { + typeUrl: "/cosmos.distribution.v1beta1.QueryValidatorSlashesRequest", + value: QueryValidatorSlashesRequest.encode(message).finish() + }; + } +}; +function createBaseQueryValidatorSlashesResponse(): QueryValidatorSlashesResponse { + return { + slashes: [], + pagination: undefined + }; +} +export const QueryValidatorSlashesResponse = { + typeUrl: "/cosmos.distribution.v1beta1.QueryValidatorSlashesResponse", + encode(message: QueryValidatorSlashesResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.slashes) { + ValidatorSlashEvent.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryValidatorSlashesResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryValidatorSlashesResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.slashes.push(ValidatorSlashEvent.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryValidatorSlashesResponse { + const obj = createBaseQueryValidatorSlashesResponse(); + if (Array.isArray(object?.slashes)) obj.slashes = object.slashes.map((e: any) => ValidatorSlashEvent.fromJSON(e)); + if (isSet(object.pagination)) obj.pagination = PageResponse.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryValidatorSlashesResponse): JsonSafe { + const obj: any = {}; + if (message.slashes) { + obj.slashes = message.slashes.map(e => e ? ValidatorSlashEvent.toJSON(e) : undefined); + } else { + obj.slashes = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryValidatorSlashesResponse { + const message = createBaseQueryValidatorSlashesResponse(); + message.slashes = object.slashes?.map(e => ValidatorSlashEvent.fromPartial(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryValidatorSlashesResponseSDKType): QueryValidatorSlashesResponse { + return { + slashes: Array.isArray(object?.slashes) ? object.slashes.map((e: any) => ValidatorSlashEvent.fromSDK(e)) : [], + pagination: object.pagination ? PageResponse.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryValidatorSlashesResponseSDKType { + return { + slashes: Array.isArray(object?.slashes) ? object.slashes.map((e: any) => ValidatorSlashEvent.fromSDKJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryValidatorSlashesResponse): QueryValidatorSlashesResponseSDKType { + const obj: any = {}; + if (message.slashes) { + obj.slashes = message.slashes.map(e => e ? ValidatorSlashEvent.toSDK(e) : undefined); + } else { + obj.slashes = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryValidatorSlashesResponseAmino): QueryValidatorSlashesResponse { + const message = createBaseQueryValidatorSlashesResponse(); + message.slashes = object.slashes?.map(e => ValidatorSlashEvent.fromAmino(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryValidatorSlashesResponse): QueryValidatorSlashesResponseAmino { + const obj: any = {}; + if (message.slashes) { + obj.slashes = message.slashes.map(e => e ? ValidatorSlashEvent.toAmino(e) : undefined); + } else { + obj.slashes = message.slashes; + } + obj.pagination = message.pagination ? PageResponse.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryValidatorSlashesResponseAminoMsg): QueryValidatorSlashesResponse { + return QueryValidatorSlashesResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryValidatorSlashesResponse): QueryValidatorSlashesResponseAminoMsg { + return { + type: "cosmos-sdk/QueryValidatorSlashesResponse", + value: QueryValidatorSlashesResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryValidatorSlashesResponseProtoMsg): QueryValidatorSlashesResponse { + return QueryValidatorSlashesResponse.decode(message.value); + }, + toProto(message: QueryValidatorSlashesResponse): Uint8Array { + return QueryValidatorSlashesResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryValidatorSlashesResponse): QueryValidatorSlashesResponseProtoMsg { + return { + typeUrl: "/cosmos.distribution.v1beta1.QueryValidatorSlashesResponse", + value: QueryValidatorSlashesResponse.encode(message).finish() + }; + } +}; +function createBaseQueryDelegationRewardsRequest(): QueryDelegationRewardsRequest { + return { + delegatorAddress: "", + validatorAddress: "" + }; +} +export const QueryDelegationRewardsRequest = { + typeUrl: "/cosmos.distribution.v1beta1.QueryDelegationRewardsRequest", + encode(message: QueryDelegationRewardsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.delegatorAddress !== undefined) { + writer.uint32(10).string(message.delegatorAddress); + } + if (message.validatorAddress !== undefined) { + writer.uint32(18).string(message.validatorAddress); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryDelegationRewardsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryDelegationRewardsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.delegatorAddress = reader.string(); + break; + case 2: + message.validatorAddress = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryDelegationRewardsRequest { + const obj = createBaseQueryDelegationRewardsRequest(); + if (isSet(object.delegatorAddress)) obj.delegatorAddress = String(object.delegatorAddress); + if (isSet(object.validatorAddress)) obj.validatorAddress = String(object.validatorAddress); + return obj; + }, + toJSON(message: QueryDelegationRewardsRequest): JsonSafe { + const obj: any = {}; + message.delegatorAddress !== undefined && (obj.delegatorAddress = message.delegatorAddress); + message.validatorAddress !== undefined && (obj.validatorAddress = message.validatorAddress); + return obj; + }, + fromPartial(object: DeepPartial): QueryDelegationRewardsRequest { + const message = createBaseQueryDelegationRewardsRequest(); + message.delegatorAddress = object.delegatorAddress ?? ""; + message.validatorAddress = object.validatorAddress ?? ""; + return message; + }, + fromSDK(object: QueryDelegationRewardsRequestSDKType): QueryDelegationRewardsRequest { + return { + delegatorAddress: object?.delegator_address, + validatorAddress: object?.validator_address + }; + }, + fromSDKJSON(object: any): QueryDelegationRewardsRequestSDKType { + return { + delegator_address: isSet(object.delegator_address) ? String(object.delegator_address) : "", + validator_address: isSet(object.validator_address) ? String(object.validator_address) : "" + }; + }, + toSDK(message: QueryDelegationRewardsRequest): QueryDelegationRewardsRequestSDKType { + const obj: any = {}; + obj.delegator_address = message.delegatorAddress; + obj.validator_address = message.validatorAddress; + return obj; + }, + fromAmino(object: QueryDelegationRewardsRequestAmino): QueryDelegationRewardsRequest { + const message = createBaseQueryDelegationRewardsRequest(); + if (object.delegator_address !== undefined && object.delegator_address !== null) { + message.delegatorAddress = object.delegator_address; + } + if (object.validator_address !== undefined && object.validator_address !== null) { + message.validatorAddress = object.validator_address; + } + return message; + }, + toAmino(message: QueryDelegationRewardsRequest): QueryDelegationRewardsRequestAmino { + const obj: any = {}; + obj.delegator_address = message.delegatorAddress === "" ? undefined : message.delegatorAddress; + obj.validator_address = message.validatorAddress === "" ? undefined : message.validatorAddress; + return obj; + }, + fromAminoMsg(object: QueryDelegationRewardsRequestAminoMsg): QueryDelegationRewardsRequest { + return QueryDelegationRewardsRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryDelegationRewardsRequest): QueryDelegationRewardsRequestAminoMsg { + return { + type: "cosmos-sdk/QueryDelegationRewardsRequest", + value: QueryDelegationRewardsRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryDelegationRewardsRequestProtoMsg): QueryDelegationRewardsRequest { + return QueryDelegationRewardsRequest.decode(message.value); + }, + toProto(message: QueryDelegationRewardsRequest): Uint8Array { + return QueryDelegationRewardsRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryDelegationRewardsRequest): QueryDelegationRewardsRequestProtoMsg { + return { + typeUrl: "/cosmos.distribution.v1beta1.QueryDelegationRewardsRequest", + value: QueryDelegationRewardsRequest.encode(message).finish() + }; + } +}; +function createBaseQueryDelegationRewardsResponse(): QueryDelegationRewardsResponse { + return { + rewards: [] + }; +} +export const QueryDelegationRewardsResponse = { + typeUrl: "/cosmos.distribution.v1beta1.QueryDelegationRewardsResponse", + encode(message: QueryDelegationRewardsResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.rewards) { + DecCoin.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryDelegationRewardsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryDelegationRewardsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.rewards.push(DecCoin.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryDelegationRewardsResponse { + const obj = createBaseQueryDelegationRewardsResponse(); + if (Array.isArray(object?.rewards)) obj.rewards = object.rewards.map((e: any) => DecCoin.fromJSON(e)); + return obj; + }, + toJSON(message: QueryDelegationRewardsResponse): JsonSafe { + const obj: any = {}; + if (message.rewards) { + obj.rewards = message.rewards.map(e => e ? DecCoin.toJSON(e) : undefined); + } else { + obj.rewards = []; + } + return obj; + }, + fromPartial(object: DeepPartial): QueryDelegationRewardsResponse { + const message = createBaseQueryDelegationRewardsResponse(); + message.rewards = object.rewards?.map(e => DecCoin.fromPartial(e)) || []; + return message; + }, + fromSDK(object: QueryDelegationRewardsResponseSDKType): QueryDelegationRewardsResponse { + return { + rewards: Array.isArray(object?.rewards) ? object.rewards.map((e: any) => DecCoin.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): QueryDelegationRewardsResponseSDKType { + return { + rewards: Array.isArray(object?.rewards) ? object.rewards.map((e: any) => DecCoin.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: QueryDelegationRewardsResponse): QueryDelegationRewardsResponseSDKType { + const obj: any = {}; + if (message.rewards) { + obj.rewards = message.rewards.map(e => e ? DecCoin.toSDK(e) : undefined); + } else { + obj.rewards = []; + } + return obj; + }, + fromAmino(object: QueryDelegationRewardsResponseAmino): QueryDelegationRewardsResponse { + const message = createBaseQueryDelegationRewardsResponse(); + message.rewards = object.rewards?.map(e => DecCoin.fromAmino(e)) || []; + return message; + }, + toAmino(message: QueryDelegationRewardsResponse): QueryDelegationRewardsResponseAmino { + const obj: any = {}; + if (message.rewards) { + obj.rewards = message.rewards.map(e => e ? DecCoin.toAmino(e) : undefined); + } else { + obj.rewards = message.rewards; + } + return obj; + }, + fromAminoMsg(object: QueryDelegationRewardsResponseAminoMsg): QueryDelegationRewardsResponse { + return QueryDelegationRewardsResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryDelegationRewardsResponse): QueryDelegationRewardsResponseAminoMsg { + return { + type: "cosmos-sdk/QueryDelegationRewardsResponse", + value: QueryDelegationRewardsResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryDelegationRewardsResponseProtoMsg): QueryDelegationRewardsResponse { + return QueryDelegationRewardsResponse.decode(message.value); + }, + toProto(message: QueryDelegationRewardsResponse): Uint8Array { + return QueryDelegationRewardsResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryDelegationRewardsResponse): QueryDelegationRewardsResponseProtoMsg { + return { + typeUrl: "/cosmos.distribution.v1beta1.QueryDelegationRewardsResponse", + value: QueryDelegationRewardsResponse.encode(message).finish() + }; + } +}; +function createBaseQueryDelegationTotalRewardsRequest(): QueryDelegationTotalRewardsRequest { + return { + delegatorAddress: "" + }; +} +export const QueryDelegationTotalRewardsRequest = { + typeUrl: "/cosmos.distribution.v1beta1.QueryDelegationTotalRewardsRequest", + encode(message: QueryDelegationTotalRewardsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.delegatorAddress !== undefined) { + writer.uint32(10).string(message.delegatorAddress); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryDelegationTotalRewardsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryDelegationTotalRewardsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.delegatorAddress = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryDelegationTotalRewardsRequest { + const obj = createBaseQueryDelegationTotalRewardsRequest(); + if (isSet(object.delegatorAddress)) obj.delegatorAddress = String(object.delegatorAddress); + return obj; + }, + toJSON(message: QueryDelegationTotalRewardsRequest): JsonSafe { + const obj: any = {}; + message.delegatorAddress !== undefined && (obj.delegatorAddress = message.delegatorAddress); + return obj; + }, + fromPartial(object: DeepPartial): QueryDelegationTotalRewardsRequest { + const message = createBaseQueryDelegationTotalRewardsRequest(); + message.delegatorAddress = object.delegatorAddress ?? ""; + return message; + }, + fromSDK(object: QueryDelegationTotalRewardsRequestSDKType): QueryDelegationTotalRewardsRequest { + return { + delegatorAddress: object?.delegator_address + }; + }, + fromSDKJSON(object: any): QueryDelegationTotalRewardsRequestSDKType { + return { + delegator_address: isSet(object.delegator_address) ? String(object.delegator_address) : "" + }; + }, + toSDK(message: QueryDelegationTotalRewardsRequest): QueryDelegationTotalRewardsRequestSDKType { + const obj: any = {}; + obj.delegator_address = message.delegatorAddress; + return obj; + }, + fromAmino(object: QueryDelegationTotalRewardsRequestAmino): QueryDelegationTotalRewardsRequest { + const message = createBaseQueryDelegationTotalRewardsRequest(); + if (object.delegator_address !== undefined && object.delegator_address !== null) { + message.delegatorAddress = object.delegator_address; + } + return message; + }, + toAmino(message: QueryDelegationTotalRewardsRequest): QueryDelegationTotalRewardsRequestAmino { + const obj: any = {}; + obj.delegator_address = message.delegatorAddress === "" ? undefined : message.delegatorAddress; + return obj; + }, + fromAminoMsg(object: QueryDelegationTotalRewardsRequestAminoMsg): QueryDelegationTotalRewardsRequest { + return QueryDelegationTotalRewardsRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryDelegationTotalRewardsRequest): QueryDelegationTotalRewardsRequestAminoMsg { + return { + type: "cosmos-sdk/QueryDelegationTotalRewardsRequest", + value: QueryDelegationTotalRewardsRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryDelegationTotalRewardsRequestProtoMsg): QueryDelegationTotalRewardsRequest { + return QueryDelegationTotalRewardsRequest.decode(message.value); + }, + toProto(message: QueryDelegationTotalRewardsRequest): Uint8Array { + return QueryDelegationTotalRewardsRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryDelegationTotalRewardsRequest): QueryDelegationTotalRewardsRequestProtoMsg { + return { + typeUrl: "/cosmos.distribution.v1beta1.QueryDelegationTotalRewardsRequest", + value: QueryDelegationTotalRewardsRequest.encode(message).finish() + }; + } +}; +function createBaseQueryDelegationTotalRewardsResponse(): QueryDelegationTotalRewardsResponse { + return { + rewards: [], + total: [] + }; +} +export const QueryDelegationTotalRewardsResponse = { + typeUrl: "/cosmos.distribution.v1beta1.QueryDelegationTotalRewardsResponse", + encode(message: QueryDelegationTotalRewardsResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.rewards) { + DelegationDelegatorReward.encode(v!, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.total) { + DecCoin.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryDelegationTotalRewardsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryDelegationTotalRewardsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.rewards.push(DelegationDelegatorReward.decode(reader, reader.uint32())); + break; + case 2: + message.total.push(DecCoin.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryDelegationTotalRewardsResponse { + const obj = createBaseQueryDelegationTotalRewardsResponse(); + if (Array.isArray(object?.rewards)) obj.rewards = object.rewards.map((e: any) => DelegationDelegatorReward.fromJSON(e)); + if (Array.isArray(object?.total)) obj.total = object.total.map((e: any) => DecCoin.fromJSON(e)); + return obj; + }, + toJSON(message: QueryDelegationTotalRewardsResponse): JsonSafe { + const obj: any = {}; + if (message.rewards) { + obj.rewards = message.rewards.map(e => e ? DelegationDelegatorReward.toJSON(e) : undefined); + } else { + obj.rewards = []; + } + if (message.total) { + obj.total = message.total.map(e => e ? DecCoin.toJSON(e) : undefined); + } else { + obj.total = []; + } + return obj; + }, + fromPartial(object: DeepPartial): QueryDelegationTotalRewardsResponse { + const message = createBaseQueryDelegationTotalRewardsResponse(); + message.rewards = object.rewards?.map(e => DelegationDelegatorReward.fromPartial(e)) || []; + message.total = object.total?.map(e => DecCoin.fromPartial(e)) || []; + return message; + }, + fromSDK(object: QueryDelegationTotalRewardsResponseSDKType): QueryDelegationTotalRewardsResponse { + return { + rewards: Array.isArray(object?.rewards) ? object.rewards.map((e: any) => DelegationDelegatorReward.fromSDK(e)) : [], + total: Array.isArray(object?.total) ? object.total.map((e: any) => DecCoin.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): QueryDelegationTotalRewardsResponseSDKType { + return { + rewards: Array.isArray(object?.rewards) ? object.rewards.map((e: any) => DelegationDelegatorReward.fromSDKJSON(e)) : [], + total: Array.isArray(object?.total) ? object.total.map((e: any) => DecCoin.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: QueryDelegationTotalRewardsResponse): QueryDelegationTotalRewardsResponseSDKType { + const obj: any = {}; + if (message.rewards) { + obj.rewards = message.rewards.map(e => e ? DelegationDelegatorReward.toSDK(e) : undefined); + } else { + obj.rewards = []; + } + if (message.total) { + obj.total = message.total.map(e => e ? DecCoin.toSDK(e) : undefined); + } else { + obj.total = []; + } + return obj; + }, + fromAmino(object: QueryDelegationTotalRewardsResponseAmino): QueryDelegationTotalRewardsResponse { + const message = createBaseQueryDelegationTotalRewardsResponse(); + message.rewards = object.rewards?.map(e => DelegationDelegatorReward.fromAmino(e)) || []; + message.total = object.total?.map(e => DecCoin.fromAmino(e)) || []; + return message; + }, + toAmino(message: QueryDelegationTotalRewardsResponse): QueryDelegationTotalRewardsResponseAmino { + const obj: any = {}; + if (message.rewards) { + obj.rewards = message.rewards.map(e => e ? DelegationDelegatorReward.toAmino(e) : undefined); + } else { + obj.rewards = message.rewards; + } + if (message.total) { + obj.total = message.total.map(e => e ? DecCoin.toAmino(e) : undefined); + } else { + obj.total = message.total; + } + return obj; + }, + fromAminoMsg(object: QueryDelegationTotalRewardsResponseAminoMsg): QueryDelegationTotalRewardsResponse { + return QueryDelegationTotalRewardsResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryDelegationTotalRewardsResponse): QueryDelegationTotalRewardsResponseAminoMsg { + return { + type: "cosmos-sdk/QueryDelegationTotalRewardsResponse", + value: QueryDelegationTotalRewardsResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryDelegationTotalRewardsResponseProtoMsg): QueryDelegationTotalRewardsResponse { + return QueryDelegationTotalRewardsResponse.decode(message.value); + }, + toProto(message: QueryDelegationTotalRewardsResponse): Uint8Array { + return QueryDelegationTotalRewardsResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryDelegationTotalRewardsResponse): QueryDelegationTotalRewardsResponseProtoMsg { + return { + typeUrl: "/cosmos.distribution.v1beta1.QueryDelegationTotalRewardsResponse", + value: QueryDelegationTotalRewardsResponse.encode(message).finish() + }; + } +}; +function createBaseQueryDelegatorValidatorsRequest(): QueryDelegatorValidatorsRequest { + return { + delegatorAddress: "" + }; +} +export const QueryDelegatorValidatorsRequest = { + typeUrl: "/cosmos.distribution.v1beta1.QueryDelegatorValidatorsRequest", + encode(message: QueryDelegatorValidatorsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.delegatorAddress !== undefined) { + writer.uint32(10).string(message.delegatorAddress); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryDelegatorValidatorsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryDelegatorValidatorsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.delegatorAddress = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryDelegatorValidatorsRequest { + const obj = createBaseQueryDelegatorValidatorsRequest(); + if (isSet(object.delegatorAddress)) obj.delegatorAddress = String(object.delegatorAddress); + return obj; + }, + toJSON(message: QueryDelegatorValidatorsRequest): JsonSafe { + const obj: any = {}; + message.delegatorAddress !== undefined && (obj.delegatorAddress = message.delegatorAddress); + return obj; + }, + fromPartial(object: DeepPartial): QueryDelegatorValidatorsRequest { + const message = createBaseQueryDelegatorValidatorsRequest(); + message.delegatorAddress = object.delegatorAddress ?? ""; + return message; + }, + fromSDK(object: QueryDelegatorValidatorsRequestSDKType): QueryDelegatorValidatorsRequest { + return { + delegatorAddress: object?.delegator_address + }; + }, + fromSDKJSON(object: any): QueryDelegatorValidatorsRequestSDKType { + return { + delegator_address: isSet(object.delegator_address) ? String(object.delegator_address) : "" + }; + }, + toSDK(message: QueryDelegatorValidatorsRequest): QueryDelegatorValidatorsRequestSDKType { + const obj: any = {}; + obj.delegator_address = message.delegatorAddress; + return obj; + }, + fromAmino(object: QueryDelegatorValidatorsRequestAmino): QueryDelegatorValidatorsRequest { + const message = createBaseQueryDelegatorValidatorsRequest(); + if (object.delegator_address !== undefined && object.delegator_address !== null) { + message.delegatorAddress = object.delegator_address; + } + return message; + }, + toAmino(message: QueryDelegatorValidatorsRequest): QueryDelegatorValidatorsRequestAmino { + const obj: any = {}; + obj.delegator_address = message.delegatorAddress === "" ? undefined : message.delegatorAddress; + return obj; + }, + fromAminoMsg(object: QueryDelegatorValidatorsRequestAminoMsg): QueryDelegatorValidatorsRequest { + return QueryDelegatorValidatorsRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryDelegatorValidatorsRequest): QueryDelegatorValidatorsRequestAminoMsg { + return { + type: "cosmos-sdk/QueryDelegatorValidatorsRequest", + value: QueryDelegatorValidatorsRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryDelegatorValidatorsRequestProtoMsg): QueryDelegatorValidatorsRequest { + return QueryDelegatorValidatorsRequest.decode(message.value); + }, + toProto(message: QueryDelegatorValidatorsRequest): Uint8Array { + return QueryDelegatorValidatorsRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryDelegatorValidatorsRequest): QueryDelegatorValidatorsRequestProtoMsg { + return { + typeUrl: "/cosmos.distribution.v1beta1.QueryDelegatorValidatorsRequest", + value: QueryDelegatorValidatorsRequest.encode(message).finish() + }; + } +}; +function createBaseQueryDelegatorValidatorsResponse(): QueryDelegatorValidatorsResponse { + return { + validators: [] + }; +} +export const QueryDelegatorValidatorsResponse = { + typeUrl: "/cosmos.distribution.v1beta1.QueryDelegatorValidatorsResponse", + encode(message: QueryDelegatorValidatorsResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.validators) { + writer.uint32(10).string(v!); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryDelegatorValidatorsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryDelegatorValidatorsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.validators.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryDelegatorValidatorsResponse { + const obj = createBaseQueryDelegatorValidatorsResponse(); + if (Array.isArray(object?.validators)) obj.validators = object.validators.map((e: any) => String(e)); + return obj; + }, + toJSON(message: QueryDelegatorValidatorsResponse): JsonSafe { + const obj: any = {}; + if (message.validators) { + obj.validators = message.validators.map(e => e); + } else { + obj.validators = []; + } + return obj; + }, + fromPartial(object: DeepPartial): QueryDelegatorValidatorsResponse { + const message = createBaseQueryDelegatorValidatorsResponse(); + message.validators = object.validators?.map(e => e) || []; + return message; + }, + fromSDK(object: QueryDelegatorValidatorsResponseSDKType): QueryDelegatorValidatorsResponse { + return { + validators: Array.isArray(object?.validators) ? object.validators.map((e: any) => e) : [] + }; + }, + fromSDKJSON(object: any): QueryDelegatorValidatorsResponseSDKType { + return { + validators: Array.isArray(object?.validators) ? object.validators.map((e: any) => String(e)) : [] + }; + }, + toSDK(message: QueryDelegatorValidatorsResponse): QueryDelegatorValidatorsResponseSDKType { + const obj: any = {}; + if (message.validators) { + obj.validators = message.validators.map(e => e); + } else { + obj.validators = []; + } + return obj; + }, + fromAmino(object: QueryDelegatorValidatorsResponseAmino): QueryDelegatorValidatorsResponse { + const message = createBaseQueryDelegatorValidatorsResponse(); + message.validators = object.validators?.map(e => e) || []; + return message; + }, + toAmino(message: QueryDelegatorValidatorsResponse): QueryDelegatorValidatorsResponseAmino { + const obj: any = {}; + if (message.validators) { + obj.validators = message.validators.map(e => e); + } else { + obj.validators = message.validators; + } + return obj; + }, + fromAminoMsg(object: QueryDelegatorValidatorsResponseAminoMsg): QueryDelegatorValidatorsResponse { + return QueryDelegatorValidatorsResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryDelegatorValidatorsResponse): QueryDelegatorValidatorsResponseAminoMsg { + return { + type: "cosmos-sdk/QueryDelegatorValidatorsResponse", + value: QueryDelegatorValidatorsResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryDelegatorValidatorsResponseProtoMsg): QueryDelegatorValidatorsResponse { + return QueryDelegatorValidatorsResponse.decode(message.value); + }, + toProto(message: QueryDelegatorValidatorsResponse): Uint8Array { + return QueryDelegatorValidatorsResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryDelegatorValidatorsResponse): QueryDelegatorValidatorsResponseProtoMsg { + return { + typeUrl: "/cosmos.distribution.v1beta1.QueryDelegatorValidatorsResponse", + value: QueryDelegatorValidatorsResponse.encode(message).finish() + }; + } +}; +function createBaseQueryDelegatorWithdrawAddressRequest(): QueryDelegatorWithdrawAddressRequest { + return { + delegatorAddress: "" + }; +} +export const QueryDelegatorWithdrawAddressRequest = { + typeUrl: "/cosmos.distribution.v1beta1.QueryDelegatorWithdrawAddressRequest", + encode(message: QueryDelegatorWithdrawAddressRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.delegatorAddress !== undefined) { + writer.uint32(10).string(message.delegatorAddress); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryDelegatorWithdrawAddressRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryDelegatorWithdrawAddressRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.delegatorAddress = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryDelegatorWithdrawAddressRequest { + const obj = createBaseQueryDelegatorWithdrawAddressRequest(); + if (isSet(object.delegatorAddress)) obj.delegatorAddress = String(object.delegatorAddress); + return obj; + }, + toJSON(message: QueryDelegatorWithdrawAddressRequest): JsonSafe { + const obj: any = {}; + message.delegatorAddress !== undefined && (obj.delegatorAddress = message.delegatorAddress); + return obj; + }, + fromPartial(object: DeepPartial): QueryDelegatorWithdrawAddressRequest { + const message = createBaseQueryDelegatorWithdrawAddressRequest(); + message.delegatorAddress = object.delegatorAddress ?? ""; + return message; + }, + fromSDK(object: QueryDelegatorWithdrawAddressRequestSDKType): QueryDelegatorWithdrawAddressRequest { + return { + delegatorAddress: object?.delegator_address + }; + }, + fromSDKJSON(object: any): QueryDelegatorWithdrawAddressRequestSDKType { + return { + delegator_address: isSet(object.delegator_address) ? String(object.delegator_address) : "" + }; + }, + toSDK(message: QueryDelegatorWithdrawAddressRequest): QueryDelegatorWithdrawAddressRequestSDKType { + const obj: any = {}; + obj.delegator_address = message.delegatorAddress; + return obj; + }, + fromAmino(object: QueryDelegatorWithdrawAddressRequestAmino): QueryDelegatorWithdrawAddressRequest { + const message = createBaseQueryDelegatorWithdrawAddressRequest(); + if (object.delegator_address !== undefined && object.delegator_address !== null) { + message.delegatorAddress = object.delegator_address; + } + return message; + }, + toAmino(message: QueryDelegatorWithdrawAddressRequest): QueryDelegatorWithdrawAddressRequestAmino { + const obj: any = {}; + obj.delegator_address = message.delegatorAddress === "" ? undefined : message.delegatorAddress; + return obj; + }, + fromAminoMsg(object: QueryDelegatorWithdrawAddressRequestAminoMsg): QueryDelegatorWithdrawAddressRequest { + return QueryDelegatorWithdrawAddressRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryDelegatorWithdrawAddressRequest): QueryDelegatorWithdrawAddressRequestAminoMsg { + return { + type: "cosmos-sdk/QueryDelegatorWithdrawAddressRequest", + value: QueryDelegatorWithdrawAddressRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryDelegatorWithdrawAddressRequestProtoMsg): QueryDelegatorWithdrawAddressRequest { + return QueryDelegatorWithdrawAddressRequest.decode(message.value); + }, + toProto(message: QueryDelegatorWithdrawAddressRequest): Uint8Array { + return QueryDelegatorWithdrawAddressRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryDelegatorWithdrawAddressRequest): QueryDelegatorWithdrawAddressRequestProtoMsg { + return { + typeUrl: "/cosmos.distribution.v1beta1.QueryDelegatorWithdrawAddressRequest", + value: QueryDelegatorWithdrawAddressRequest.encode(message).finish() + }; + } +}; +function createBaseQueryDelegatorWithdrawAddressResponse(): QueryDelegatorWithdrawAddressResponse { + return { + withdrawAddress: "" + }; +} +export const QueryDelegatorWithdrawAddressResponse = { + typeUrl: "/cosmos.distribution.v1beta1.QueryDelegatorWithdrawAddressResponse", + encode(message: QueryDelegatorWithdrawAddressResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.withdrawAddress !== undefined) { + writer.uint32(10).string(message.withdrawAddress); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryDelegatorWithdrawAddressResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryDelegatorWithdrawAddressResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.withdrawAddress = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryDelegatorWithdrawAddressResponse { + const obj = createBaseQueryDelegatorWithdrawAddressResponse(); + if (isSet(object.withdrawAddress)) obj.withdrawAddress = String(object.withdrawAddress); + return obj; + }, + toJSON(message: QueryDelegatorWithdrawAddressResponse): JsonSafe { + const obj: any = {}; + message.withdrawAddress !== undefined && (obj.withdrawAddress = message.withdrawAddress); + return obj; + }, + fromPartial(object: DeepPartial): QueryDelegatorWithdrawAddressResponse { + const message = createBaseQueryDelegatorWithdrawAddressResponse(); + message.withdrawAddress = object.withdrawAddress ?? ""; + return message; + }, + fromSDK(object: QueryDelegatorWithdrawAddressResponseSDKType): QueryDelegatorWithdrawAddressResponse { + return { + withdrawAddress: object?.withdraw_address + }; + }, + fromSDKJSON(object: any): QueryDelegatorWithdrawAddressResponseSDKType { + return { + withdraw_address: isSet(object.withdraw_address) ? String(object.withdraw_address) : "" + }; + }, + toSDK(message: QueryDelegatorWithdrawAddressResponse): QueryDelegatorWithdrawAddressResponseSDKType { + const obj: any = {}; + obj.withdraw_address = message.withdrawAddress; + return obj; + }, + fromAmino(object: QueryDelegatorWithdrawAddressResponseAmino): QueryDelegatorWithdrawAddressResponse { + const message = createBaseQueryDelegatorWithdrawAddressResponse(); + if (object.withdraw_address !== undefined && object.withdraw_address !== null) { + message.withdrawAddress = object.withdraw_address; + } + return message; + }, + toAmino(message: QueryDelegatorWithdrawAddressResponse): QueryDelegatorWithdrawAddressResponseAmino { + const obj: any = {}; + obj.withdraw_address = message.withdrawAddress === "" ? undefined : message.withdrawAddress; + return obj; + }, + fromAminoMsg(object: QueryDelegatorWithdrawAddressResponseAminoMsg): QueryDelegatorWithdrawAddressResponse { + return QueryDelegatorWithdrawAddressResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryDelegatorWithdrawAddressResponse): QueryDelegatorWithdrawAddressResponseAminoMsg { + return { + type: "cosmos-sdk/QueryDelegatorWithdrawAddressResponse", + value: QueryDelegatorWithdrawAddressResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryDelegatorWithdrawAddressResponseProtoMsg): QueryDelegatorWithdrawAddressResponse { + return QueryDelegatorWithdrawAddressResponse.decode(message.value); + }, + toProto(message: QueryDelegatorWithdrawAddressResponse): Uint8Array { + return QueryDelegatorWithdrawAddressResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryDelegatorWithdrawAddressResponse): QueryDelegatorWithdrawAddressResponseProtoMsg { + return { + typeUrl: "/cosmos.distribution.v1beta1.QueryDelegatorWithdrawAddressResponse", + value: QueryDelegatorWithdrawAddressResponse.encode(message).finish() + }; + } +}; +function createBaseQueryCommunityPoolRequest(): QueryCommunityPoolRequest { + return {}; +} +export const QueryCommunityPoolRequest = { + typeUrl: "/cosmos.distribution.v1beta1.QueryCommunityPoolRequest", + encode(_: QueryCommunityPoolRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryCommunityPoolRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryCommunityPoolRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): QueryCommunityPoolRequest { + const obj = createBaseQueryCommunityPoolRequest(); + return obj; + }, + toJSON(_: QueryCommunityPoolRequest): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): QueryCommunityPoolRequest { + const message = createBaseQueryCommunityPoolRequest(); + return message; + }, + fromSDK(_: QueryCommunityPoolRequestSDKType): QueryCommunityPoolRequest { + return {}; + }, + fromSDKJSON(_: any): QueryCommunityPoolRequestSDKType { + return {}; + }, + toSDK(_: QueryCommunityPoolRequest): QueryCommunityPoolRequestSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: QueryCommunityPoolRequestAmino): QueryCommunityPoolRequest { + const message = createBaseQueryCommunityPoolRequest(); + return message; + }, + toAmino(_: QueryCommunityPoolRequest): QueryCommunityPoolRequestAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: QueryCommunityPoolRequestAminoMsg): QueryCommunityPoolRequest { + return QueryCommunityPoolRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryCommunityPoolRequest): QueryCommunityPoolRequestAminoMsg { + return { + type: "cosmos-sdk/QueryCommunityPoolRequest", + value: QueryCommunityPoolRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryCommunityPoolRequestProtoMsg): QueryCommunityPoolRequest { + return QueryCommunityPoolRequest.decode(message.value); + }, + toProto(message: QueryCommunityPoolRequest): Uint8Array { + return QueryCommunityPoolRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryCommunityPoolRequest): QueryCommunityPoolRequestProtoMsg { + return { + typeUrl: "/cosmos.distribution.v1beta1.QueryCommunityPoolRequest", + value: QueryCommunityPoolRequest.encode(message).finish() + }; + } +}; +function createBaseQueryCommunityPoolResponse(): QueryCommunityPoolResponse { + return { + pool: [] + }; +} +export const QueryCommunityPoolResponse = { + typeUrl: "/cosmos.distribution.v1beta1.QueryCommunityPoolResponse", + encode(message: QueryCommunityPoolResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.pool) { + DecCoin.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryCommunityPoolResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryCommunityPoolResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.pool.push(DecCoin.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryCommunityPoolResponse { + const obj = createBaseQueryCommunityPoolResponse(); + if (Array.isArray(object?.pool)) obj.pool = object.pool.map((e: any) => DecCoin.fromJSON(e)); + return obj; + }, + toJSON(message: QueryCommunityPoolResponse): JsonSafe { + const obj: any = {}; + if (message.pool) { + obj.pool = message.pool.map(e => e ? DecCoin.toJSON(e) : undefined); + } else { + obj.pool = []; + } + return obj; + }, + fromPartial(object: DeepPartial): QueryCommunityPoolResponse { + const message = createBaseQueryCommunityPoolResponse(); + message.pool = object.pool?.map(e => DecCoin.fromPartial(e)) || []; + return message; + }, + fromSDK(object: QueryCommunityPoolResponseSDKType): QueryCommunityPoolResponse { + return { + pool: Array.isArray(object?.pool) ? object.pool.map((e: any) => DecCoin.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): QueryCommunityPoolResponseSDKType { + return { + pool: Array.isArray(object?.pool) ? object.pool.map((e: any) => DecCoin.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: QueryCommunityPoolResponse): QueryCommunityPoolResponseSDKType { + const obj: any = {}; + if (message.pool) { + obj.pool = message.pool.map(e => e ? DecCoin.toSDK(e) : undefined); + } else { + obj.pool = []; + } + return obj; + }, + fromAmino(object: QueryCommunityPoolResponseAmino): QueryCommunityPoolResponse { + const message = createBaseQueryCommunityPoolResponse(); + message.pool = object.pool?.map(e => DecCoin.fromAmino(e)) || []; + return message; + }, + toAmino(message: QueryCommunityPoolResponse): QueryCommunityPoolResponseAmino { + const obj: any = {}; + if (message.pool) { + obj.pool = message.pool.map(e => e ? DecCoin.toAmino(e) : undefined); + } else { + obj.pool = message.pool; + } + return obj; + }, + fromAminoMsg(object: QueryCommunityPoolResponseAminoMsg): QueryCommunityPoolResponse { + return QueryCommunityPoolResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryCommunityPoolResponse): QueryCommunityPoolResponseAminoMsg { + return { + type: "cosmos-sdk/QueryCommunityPoolResponse", + value: QueryCommunityPoolResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryCommunityPoolResponseProtoMsg): QueryCommunityPoolResponse { + return QueryCommunityPoolResponse.decode(message.value); + }, + toProto(message: QueryCommunityPoolResponse): Uint8Array { + return QueryCommunityPoolResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryCommunityPoolResponse): QueryCommunityPoolResponseProtoMsg { + return { + typeUrl: "/cosmos.distribution.v1beta1.QueryCommunityPoolResponse", + value: QueryCommunityPoolResponse.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/distribution/v1beta1/tx.amino.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/distribution/v1beta1/tx.amino.ts new file mode 100644 index 0000000000..0e005d1f34 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/distribution/v1beta1/tx.amino.ts @@ -0,0 +1,121 @@ +import { Coin, CoinSDKType } from "../../base/v1beta1/coin.js"; +import { ReadOnlyAminoMsg as AminoMsg } from "@interchainjs/ReadOnlyAminoMsg"; +import { MsgSetWithdrawAddress, MsgSetWithdrawAddressSDKType, MsgWithdrawDelegatorReward, MsgWithdrawDelegatorRewardSDKType, MsgWithdrawValidatorCommission, MsgWithdrawValidatorCommissionSDKType, MsgFundCommunityPool, MsgFundCommunityPoolSDKType } from "./tx.js"; +export interface MsgSetWithdrawAddressAminoType extends AminoMsg { + type: "cosmos-sdk/MsgModifyWithdrawAddress"; + value: { + delegator_address: string; + withdraw_address: string; + }; +} +export interface MsgWithdrawDelegatorRewardAminoType extends AminoMsg { + type: "cosmos-sdk/MsgWithdrawDelegationReward"; + value: { + delegator_address: string; + validator_address: string; + }; +} +export interface MsgWithdrawValidatorCommissionAminoType extends AminoMsg { + type: "cosmos-sdk/MsgWithdrawValidatorCommission"; + value: { + validator_address: string; + }; +} +export interface MsgFundCommunityPoolAminoType extends AminoMsg { + type: "cosmos-sdk/MsgFundCommunityPool"; + value: { + amount: { + denom: string; + amount: string; + }[]; + depositor: string; + }; +} +export const AminoConverter = { + "/cosmos.distribution.v1beta1.MsgSetWithdrawAddress": { + aminoType: "cosmos-sdk/MsgModifyWithdrawAddress", + toAmino: ({ + delegatorAddress, + withdrawAddress + }: MsgSetWithdrawAddress): MsgSetWithdrawAddressAminoType["value"] => { + return { + delegator_address: delegatorAddress, + withdraw_address: withdrawAddress + }; + }, + fromAmino: ({ + delegator_address, + withdraw_address + }: MsgSetWithdrawAddressAminoType["value"]): MsgSetWithdrawAddress => { + return { + delegatorAddress: delegator_address, + withdrawAddress: withdraw_address + }; + } + }, + "/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward": { + aminoType: "cosmos-sdk/MsgWithdrawDelegationReward", + toAmino: ({ + delegatorAddress, + validatorAddress + }: MsgWithdrawDelegatorReward): MsgWithdrawDelegatorRewardAminoType["value"] => { + return { + delegator_address: delegatorAddress, + validator_address: validatorAddress + }; + }, + fromAmino: ({ + delegator_address, + validator_address + }: MsgWithdrawDelegatorRewardAminoType["value"]): MsgWithdrawDelegatorReward => { + return { + delegatorAddress: delegator_address, + validatorAddress: validator_address + }; + } + }, + "/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission": { + aminoType: "cosmos-sdk/MsgWithdrawValidatorCommission", + toAmino: ({ + validatorAddress + }: MsgWithdrawValidatorCommission): MsgWithdrawValidatorCommissionAminoType["value"] => { + return { + validator_address: validatorAddress + }; + }, + fromAmino: ({ + validator_address + }: MsgWithdrawValidatorCommissionAminoType["value"]): MsgWithdrawValidatorCommission => { + return { + validatorAddress: validator_address + }; + } + }, + "/cosmos.distribution.v1beta1.MsgFundCommunityPool": { + aminoType: "cosmos-sdk/MsgFundCommunityPool", + toAmino: ({ + amount, + depositor + }: MsgFundCommunityPool): MsgFundCommunityPoolAminoType["value"] => { + return { + amount: amount.map(el0 => ({ + denom: el0.denom, + amount: el0.amount + })), + depositor + }; + }, + fromAmino: ({ + amount, + depositor + }: MsgFundCommunityPoolAminoType["value"]): MsgFundCommunityPool => { + return { + amount: amount.map(el0 => ({ + denom: el0.denom, + amount: el0.amount + })), + depositor + }; + } + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/distribution/v1beta1/tx.registry.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/distribution/v1beta1/tx.registry.ts new file mode 100644 index 0000000000..bba6fce4eb --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/distribution/v1beta1/tx.registry.ts @@ -0,0 +1,141 @@ +import { Coin, CoinSDKType } from "../../base/v1beta1/coin.js"; +import { GeneratedType, Registry } from "@cosmjs/proto-signing"; +import { MsgSetWithdrawAddress, MsgSetWithdrawAddressSDKType, MsgWithdrawDelegatorReward, MsgWithdrawDelegatorRewardSDKType, MsgWithdrawValidatorCommission, MsgWithdrawValidatorCommissionSDKType, MsgFundCommunityPool, MsgFundCommunityPoolSDKType } from "./tx.js"; +export const registry: ReadonlyArray<[string, GeneratedType]> = [["/cosmos.distribution.v1beta1.MsgSetWithdrawAddress", MsgSetWithdrawAddress], ["/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward", MsgWithdrawDelegatorReward], ["/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission", MsgWithdrawValidatorCommission], ["/cosmos.distribution.v1beta1.MsgFundCommunityPool", MsgFundCommunityPool]]; +export const load = (protoRegistry: Registry) => { + registry.forEach(([typeUrl, mod]) => { + protoRegistry.register(typeUrl, mod); + }); +}; +export const MessageComposer = { + encoded: { + setWithdrawAddress(value: MsgSetWithdrawAddress) { + return { + typeUrl: "/cosmos.distribution.v1beta1.MsgSetWithdrawAddress", + value: MsgSetWithdrawAddress.encode(value).finish() + }; + }, + withdrawDelegatorReward(value: MsgWithdrawDelegatorReward) { + return { + typeUrl: "/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward", + value: MsgWithdrawDelegatorReward.encode(value).finish() + }; + }, + withdrawValidatorCommission(value: MsgWithdrawValidatorCommission) { + return { + typeUrl: "/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission", + value: MsgWithdrawValidatorCommission.encode(value).finish() + }; + }, + fundCommunityPool(value: MsgFundCommunityPool) { + return { + typeUrl: "/cosmos.distribution.v1beta1.MsgFundCommunityPool", + value: MsgFundCommunityPool.encode(value).finish() + }; + } + }, + withTypeUrl: { + setWithdrawAddress(value: MsgSetWithdrawAddress) { + return { + typeUrl: "/cosmos.distribution.v1beta1.MsgSetWithdrawAddress", + value + }; + }, + withdrawDelegatorReward(value: MsgWithdrawDelegatorReward) { + return { + typeUrl: "/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward", + value + }; + }, + withdrawValidatorCommission(value: MsgWithdrawValidatorCommission) { + return { + typeUrl: "/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission", + value + }; + }, + fundCommunityPool(value: MsgFundCommunityPool) { + return { + typeUrl: "/cosmos.distribution.v1beta1.MsgFundCommunityPool", + value + }; + } + }, + toJSON: { + setWithdrawAddress(value: MsgSetWithdrawAddress) { + return { + typeUrl: "/cosmos.distribution.v1beta1.MsgSetWithdrawAddress", + value: MsgSetWithdrawAddress.toJSON(value) + }; + }, + withdrawDelegatorReward(value: MsgWithdrawDelegatorReward) { + return { + typeUrl: "/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward", + value: MsgWithdrawDelegatorReward.toJSON(value) + }; + }, + withdrawValidatorCommission(value: MsgWithdrawValidatorCommission) { + return { + typeUrl: "/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission", + value: MsgWithdrawValidatorCommission.toJSON(value) + }; + }, + fundCommunityPool(value: MsgFundCommunityPool) { + return { + typeUrl: "/cosmos.distribution.v1beta1.MsgFundCommunityPool", + value: MsgFundCommunityPool.toJSON(value) + }; + } + }, + fromJSON: { + setWithdrawAddress(value: any) { + return { + typeUrl: "/cosmos.distribution.v1beta1.MsgSetWithdrawAddress", + value: MsgSetWithdrawAddress.fromJSON(value) + }; + }, + withdrawDelegatorReward(value: any) { + return { + typeUrl: "/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward", + value: MsgWithdrawDelegatorReward.fromJSON(value) + }; + }, + withdrawValidatorCommission(value: any) { + return { + typeUrl: "/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission", + value: MsgWithdrawValidatorCommission.fromJSON(value) + }; + }, + fundCommunityPool(value: any) { + return { + typeUrl: "/cosmos.distribution.v1beta1.MsgFundCommunityPool", + value: MsgFundCommunityPool.fromJSON(value) + }; + } + }, + fromPartial: { + setWithdrawAddress(value: MsgSetWithdrawAddress) { + return { + typeUrl: "/cosmos.distribution.v1beta1.MsgSetWithdrawAddress", + value: MsgSetWithdrawAddress.fromPartial(value) + }; + }, + withdrawDelegatorReward(value: MsgWithdrawDelegatorReward) { + return { + typeUrl: "/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward", + value: MsgWithdrawDelegatorReward.fromPartial(value) + }; + }, + withdrawValidatorCommission(value: MsgWithdrawValidatorCommission) { + return { + typeUrl: "/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission", + value: MsgWithdrawValidatorCommission.fromPartial(value) + }; + }, + fundCommunityPool(value: MsgFundCommunityPool) { + return { + typeUrl: "/cosmos.distribution.v1beta1.MsgFundCommunityPool", + value: MsgFundCommunityPool.fromPartial(value) + }; + } + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/distribution/v1beta1/tx.rpc.func.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/distribution/v1beta1/tx.rpc.func.ts new file mode 100644 index 0000000000..884c3faf6d --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/distribution/v1beta1/tx.rpc.func.ts @@ -0,0 +1,40 @@ +import { buildTx, SigningClientResolver } from "../../../helper-func-types"; +import { buildUseMutation } from "../../../react-query"; +import { toEncoders, toConverters } from "@interchainjs/cosmos/utils"; +import { MsgSetWithdrawAddress, MsgWithdrawDelegatorReward, MsgWithdrawValidatorCommission, MsgFundCommunityPool } from "./tx"; +export const createSetWithdrawAddress = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgSetWithdrawAddress.typeUrl, + encoders: toEncoders(MsgSetWithdrawAddress), + converters: toConverters(MsgSetWithdrawAddress) +}); +export const useSetWithdrawAddress = buildUseMutation({ + builderMutationFn: createSetWithdrawAddress +}); +export const createWithdrawDelegatorReward = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgWithdrawDelegatorReward.typeUrl, + encoders: toEncoders(MsgWithdrawDelegatorReward), + converters: toConverters(MsgWithdrawDelegatorReward) +}); +export const useWithdrawDelegatorReward = buildUseMutation({ + builderMutationFn: createWithdrawDelegatorReward +}); +export const createWithdrawValidatorCommission = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgWithdrawValidatorCommission.typeUrl, + encoders: toEncoders(MsgWithdrawValidatorCommission), + converters: toConverters(MsgWithdrawValidatorCommission) +}); +export const useWithdrawValidatorCommission = buildUseMutation({ + builderMutationFn: createWithdrawValidatorCommission +}); +export const createFundCommunityPool = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgFundCommunityPool.typeUrl, + encoders: toEncoders(MsgFundCommunityPool), + converters: toConverters(MsgFundCommunityPool) +}); +export const useFundCommunityPool = buildUseMutation({ + builderMutationFn: createFundCommunityPool +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/distribution/v1beta1/tx.rpc.msg.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/distribution/v1beta1/tx.rpc.msg.ts new file mode 100644 index 0000000000..0701f88ef2 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/distribution/v1beta1/tx.rpc.msg.ts @@ -0,0 +1,60 @@ +import { Coin, CoinSDKType } from "../../base/v1beta1/coin.js"; +import { Rpc } from "../../../helpers.js"; +import { BinaryReader } from "../../../binary.js"; +import { MsgSetWithdrawAddress, MsgSetWithdrawAddressSDKType, MsgSetWithdrawAddressResponse, MsgSetWithdrawAddressResponseSDKType, MsgWithdrawDelegatorReward, MsgWithdrawDelegatorRewardSDKType, MsgWithdrawDelegatorRewardResponse, MsgWithdrawDelegatorRewardResponseSDKType, MsgWithdrawValidatorCommission, MsgWithdrawValidatorCommissionSDKType, MsgWithdrawValidatorCommissionResponse, MsgWithdrawValidatorCommissionResponseSDKType, MsgFundCommunityPool, MsgFundCommunityPoolSDKType, MsgFundCommunityPoolResponse, MsgFundCommunityPoolResponseSDKType } from "./tx.js"; +/** Msg defines the distribution Msg service. */ +export interface Msg { + /** + * SetWithdrawAddress defines a method to change the withdraw address + * for a delegator (or validator self-delegation). + */ + setWithdrawAddress(request: MsgSetWithdrawAddress): Promise; + /** + * WithdrawDelegatorReward defines a method to withdraw rewards of delegator + * from a single validator. + */ + withdrawDelegatorReward(request: MsgWithdrawDelegatorReward): Promise; + /** + * WithdrawValidatorCommission defines a method to withdraw the + * full commission to the validator address. + */ + withdrawValidatorCommission(request: MsgWithdrawValidatorCommission): Promise; + /** + * FundCommunityPool defines a method to allow an account to directly + * fund the community pool. + */ + fundCommunityPool(request: MsgFundCommunityPool): Promise; +} +export class MsgClientImpl implements Msg { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + this.setWithdrawAddress = this.setWithdrawAddress.bind(this); + this.withdrawDelegatorReward = this.withdrawDelegatorReward.bind(this); + this.withdrawValidatorCommission = this.withdrawValidatorCommission.bind(this); + this.fundCommunityPool = this.fundCommunityPool.bind(this); + } + setWithdrawAddress(request: MsgSetWithdrawAddress): Promise { + const data = MsgSetWithdrawAddress.encode(request).finish(); + const promise = this.rpc.request("cosmos.distribution.v1beta1.Msg", "SetWithdrawAddress", data); + return promise.then(data => MsgSetWithdrawAddressResponse.decode(new BinaryReader(data))); + } + withdrawDelegatorReward(request: MsgWithdrawDelegatorReward): Promise { + const data = MsgWithdrawDelegatorReward.encode(request).finish(); + const promise = this.rpc.request("cosmos.distribution.v1beta1.Msg", "WithdrawDelegatorReward", data); + return promise.then(data => MsgWithdrawDelegatorRewardResponse.decode(new BinaryReader(data))); + } + withdrawValidatorCommission(request: MsgWithdrawValidatorCommission): Promise { + const data = MsgWithdrawValidatorCommission.encode(request).finish(); + const promise = this.rpc.request("cosmos.distribution.v1beta1.Msg", "WithdrawValidatorCommission", data); + return promise.then(data => MsgWithdrawValidatorCommissionResponse.decode(new BinaryReader(data))); + } + fundCommunityPool(request: MsgFundCommunityPool): Promise { + const data = MsgFundCommunityPool.encode(request).finish(); + const promise = this.rpc.request("cosmos.distribution.v1beta1.Msg", "FundCommunityPool", data); + return promise.then(data => MsgFundCommunityPoolResponse.decode(new BinaryReader(data))); + } +} +export const createClientImpl = (rpc: Rpc) => { + return new MsgClientImpl(rpc); +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/distribution/v1beta1/tx.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/distribution/v1beta1/tx.ts new file mode 100644 index 0000000000..53fef0f09b --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/distribution/v1beta1/tx.ts @@ -0,0 +1,916 @@ +import { Coin, CoinSDKType } from "../../base/v1beta1/coin.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "cosmos.distribution.v1beta1"; +/** + * MsgSetWithdrawAddress sets the withdraw address for + * a delegator (or validator self-delegation). + */ +export interface MsgSetWithdrawAddress { + delegatorAddress: string; + withdrawAddress: string; +} +export interface MsgSetWithdrawAddressProtoMsg { + typeUrl: "/cosmos.distribution.v1beta1.MsgSetWithdrawAddress"; + value: Uint8Array; +} +/** + * MsgSetWithdrawAddress sets the withdraw address for + * a delegator (or validator self-delegation). + */ +export interface MsgSetWithdrawAddressSDKType { + delegator_address: string; + withdraw_address: string; +} +/** MsgSetWithdrawAddressResponse defines the Msg/SetWithdrawAddress response type. */ +export interface MsgSetWithdrawAddressResponse {} +export interface MsgSetWithdrawAddressResponseProtoMsg { + typeUrl: "/cosmos.distribution.v1beta1.MsgSetWithdrawAddressResponse"; + value: Uint8Array; +} +/** MsgSetWithdrawAddressResponse defines the Msg/SetWithdrawAddress response type. */ +export interface MsgSetWithdrawAddressResponseSDKType {} +/** + * MsgWithdrawDelegatorReward represents delegation withdrawal to a delegator + * from a single validator. + */ +export interface MsgWithdrawDelegatorReward { + delegatorAddress: string; + validatorAddress: string; +} +export interface MsgWithdrawDelegatorRewardProtoMsg { + typeUrl: "/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward"; + value: Uint8Array; +} +/** + * MsgWithdrawDelegatorReward represents delegation withdrawal to a delegator + * from a single validator. + */ +export interface MsgWithdrawDelegatorRewardSDKType { + delegator_address: string; + validator_address: string; +} +/** MsgWithdrawDelegatorRewardResponse defines the Msg/WithdrawDelegatorReward response type. */ +export interface MsgWithdrawDelegatorRewardResponse { + amount: Coin[]; +} +export interface MsgWithdrawDelegatorRewardResponseProtoMsg { + typeUrl: "/cosmos.distribution.v1beta1.MsgWithdrawDelegatorRewardResponse"; + value: Uint8Array; +} +/** MsgWithdrawDelegatorRewardResponse defines the Msg/WithdrawDelegatorReward response type. */ +export interface MsgWithdrawDelegatorRewardResponseSDKType { + amount: CoinSDKType[]; +} +/** + * MsgWithdrawValidatorCommission withdraws the full commission to the validator + * address. + */ +export interface MsgWithdrawValidatorCommission { + validatorAddress: string; +} +export interface MsgWithdrawValidatorCommissionProtoMsg { + typeUrl: "/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission"; + value: Uint8Array; +} +/** + * MsgWithdrawValidatorCommission withdraws the full commission to the validator + * address. + */ +export interface MsgWithdrawValidatorCommissionSDKType { + validator_address: string; +} +/** MsgWithdrawValidatorCommissionResponse defines the Msg/WithdrawValidatorCommission response type. */ +export interface MsgWithdrawValidatorCommissionResponse { + amount: Coin[]; +} +export interface MsgWithdrawValidatorCommissionResponseProtoMsg { + typeUrl: "/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommissionResponse"; + value: Uint8Array; +} +/** MsgWithdrawValidatorCommissionResponse defines the Msg/WithdrawValidatorCommission response type. */ +export interface MsgWithdrawValidatorCommissionResponseSDKType { + amount: CoinSDKType[]; +} +/** + * MsgFundCommunityPool allows an account to directly + * fund the community pool. + */ +export interface MsgFundCommunityPool { + amount: Coin[]; + depositor: string; +} +export interface MsgFundCommunityPoolProtoMsg { + typeUrl: "/cosmos.distribution.v1beta1.MsgFundCommunityPool"; + value: Uint8Array; +} +/** + * MsgFundCommunityPool allows an account to directly + * fund the community pool. + */ +export interface MsgFundCommunityPoolSDKType { + amount: CoinSDKType[]; + depositor: string; +} +/** MsgFundCommunityPoolResponse defines the Msg/FundCommunityPool response type. */ +export interface MsgFundCommunityPoolResponse {} +export interface MsgFundCommunityPoolResponseProtoMsg { + typeUrl: "/cosmos.distribution.v1beta1.MsgFundCommunityPoolResponse"; + value: Uint8Array; +} +/** MsgFundCommunityPoolResponse defines the Msg/FundCommunityPool response type. */ +export interface MsgFundCommunityPoolResponseSDKType {} +function createBaseMsgSetWithdrawAddress(): MsgSetWithdrawAddress { + return { + delegatorAddress: "", + withdrawAddress: "" + }; +} +export const MsgSetWithdrawAddress = { + typeUrl: "/cosmos.distribution.v1beta1.MsgSetWithdrawAddress", + encode(message: MsgSetWithdrawAddress, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.delegatorAddress !== undefined) { + writer.uint32(10).string(message.delegatorAddress); + } + if (message.withdrawAddress !== undefined) { + writer.uint32(18).string(message.withdrawAddress); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgSetWithdrawAddress { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgSetWithdrawAddress(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.delegatorAddress = reader.string(); + break; + case 2: + message.withdrawAddress = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgSetWithdrawAddress { + const obj = createBaseMsgSetWithdrawAddress(); + if (isSet(object.delegatorAddress)) obj.delegatorAddress = String(object.delegatorAddress); + if (isSet(object.withdrawAddress)) obj.withdrawAddress = String(object.withdrawAddress); + return obj; + }, + toJSON(message: MsgSetWithdrawAddress): JsonSafe { + const obj: any = {}; + message.delegatorAddress !== undefined && (obj.delegatorAddress = message.delegatorAddress); + message.withdrawAddress !== undefined && (obj.withdrawAddress = message.withdrawAddress); + return obj; + }, + fromPartial(object: DeepPartial): MsgSetWithdrawAddress { + const message = createBaseMsgSetWithdrawAddress(); + message.delegatorAddress = object.delegatorAddress ?? ""; + message.withdrawAddress = object.withdrawAddress ?? ""; + return message; + }, + fromSDK(object: MsgSetWithdrawAddressSDKType): MsgSetWithdrawAddress { + return { + delegatorAddress: object?.delegator_address, + withdrawAddress: object?.withdraw_address + }; + }, + fromSDKJSON(object: any): MsgSetWithdrawAddressSDKType { + return { + delegator_address: isSet(object.delegator_address) ? String(object.delegator_address) : "", + withdraw_address: isSet(object.withdraw_address) ? String(object.withdraw_address) : "" + }; + }, + toSDK(message: MsgSetWithdrawAddress): MsgSetWithdrawAddressSDKType { + const obj: any = {}; + obj.delegator_address = message.delegatorAddress; + obj.withdraw_address = message.withdrawAddress; + return obj; + }, + fromAmino(object: MsgSetWithdrawAddressAmino): MsgSetWithdrawAddress { + const message = createBaseMsgSetWithdrawAddress(); + if (object.delegator_address !== undefined && object.delegator_address !== null) { + message.delegatorAddress = object.delegator_address; + } + if (object.withdraw_address !== undefined && object.withdraw_address !== null) { + message.withdrawAddress = object.withdraw_address; + } + return message; + }, + toAmino(message: MsgSetWithdrawAddress): MsgSetWithdrawAddressAmino { + const obj: any = {}; + obj.delegator_address = message.delegatorAddress === "" ? undefined : message.delegatorAddress; + obj.withdraw_address = message.withdrawAddress === "" ? undefined : message.withdrawAddress; + return obj; + }, + fromAminoMsg(object: MsgSetWithdrawAddressAminoMsg): MsgSetWithdrawAddress { + return MsgSetWithdrawAddress.fromAmino(object.value); + }, + toAminoMsg(message: MsgSetWithdrawAddress): MsgSetWithdrawAddressAminoMsg { + return { + type: "cosmos-sdk/MsgModifyWithdrawAddress", + value: MsgSetWithdrawAddress.toAmino(message) + }; + }, + fromProtoMsg(message: MsgSetWithdrawAddressProtoMsg): MsgSetWithdrawAddress { + return MsgSetWithdrawAddress.decode(message.value); + }, + toProto(message: MsgSetWithdrawAddress): Uint8Array { + return MsgSetWithdrawAddress.encode(message).finish(); + }, + toProtoMsg(message: MsgSetWithdrawAddress): MsgSetWithdrawAddressProtoMsg { + return { + typeUrl: "/cosmos.distribution.v1beta1.MsgSetWithdrawAddress", + value: MsgSetWithdrawAddress.encode(message).finish() + }; + } +}; +function createBaseMsgSetWithdrawAddressResponse(): MsgSetWithdrawAddressResponse { + return {}; +} +export const MsgSetWithdrawAddressResponse = { + typeUrl: "/cosmos.distribution.v1beta1.MsgSetWithdrawAddressResponse", + encode(_: MsgSetWithdrawAddressResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgSetWithdrawAddressResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgSetWithdrawAddressResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgSetWithdrawAddressResponse { + const obj = createBaseMsgSetWithdrawAddressResponse(); + return obj; + }, + toJSON(_: MsgSetWithdrawAddressResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): MsgSetWithdrawAddressResponse { + const message = createBaseMsgSetWithdrawAddressResponse(); + return message; + }, + fromSDK(_: MsgSetWithdrawAddressResponseSDKType): MsgSetWithdrawAddressResponse { + return {}; + }, + fromSDKJSON(_: any): MsgSetWithdrawAddressResponseSDKType { + return {}; + }, + toSDK(_: MsgSetWithdrawAddressResponse): MsgSetWithdrawAddressResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgSetWithdrawAddressResponseAmino): MsgSetWithdrawAddressResponse { + const message = createBaseMsgSetWithdrawAddressResponse(); + return message; + }, + toAmino(_: MsgSetWithdrawAddressResponse): MsgSetWithdrawAddressResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgSetWithdrawAddressResponseAminoMsg): MsgSetWithdrawAddressResponse { + return MsgSetWithdrawAddressResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgSetWithdrawAddressResponse): MsgSetWithdrawAddressResponseAminoMsg { + return { + type: "cosmos-sdk/MsgSetWithdrawAddressResponse", + value: MsgSetWithdrawAddressResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgSetWithdrawAddressResponseProtoMsg): MsgSetWithdrawAddressResponse { + return MsgSetWithdrawAddressResponse.decode(message.value); + }, + toProto(message: MsgSetWithdrawAddressResponse): Uint8Array { + return MsgSetWithdrawAddressResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgSetWithdrawAddressResponse): MsgSetWithdrawAddressResponseProtoMsg { + return { + typeUrl: "/cosmos.distribution.v1beta1.MsgSetWithdrawAddressResponse", + value: MsgSetWithdrawAddressResponse.encode(message).finish() + }; + } +}; +function createBaseMsgWithdrawDelegatorReward(): MsgWithdrawDelegatorReward { + return { + delegatorAddress: "", + validatorAddress: "" + }; +} +export const MsgWithdrawDelegatorReward = { + typeUrl: "/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward", + encode(message: MsgWithdrawDelegatorReward, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.delegatorAddress !== undefined) { + writer.uint32(10).string(message.delegatorAddress); + } + if (message.validatorAddress !== undefined) { + writer.uint32(18).string(message.validatorAddress); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgWithdrawDelegatorReward { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgWithdrawDelegatorReward(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.delegatorAddress = reader.string(); + break; + case 2: + message.validatorAddress = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgWithdrawDelegatorReward { + const obj = createBaseMsgWithdrawDelegatorReward(); + if (isSet(object.delegatorAddress)) obj.delegatorAddress = String(object.delegatorAddress); + if (isSet(object.validatorAddress)) obj.validatorAddress = String(object.validatorAddress); + return obj; + }, + toJSON(message: MsgWithdrawDelegatorReward): JsonSafe { + const obj: any = {}; + message.delegatorAddress !== undefined && (obj.delegatorAddress = message.delegatorAddress); + message.validatorAddress !== undefined && (obj.validatorAddress = message.validatorAddress); + return obj; + }, + fromPartial(object: DeepPartial): MsgWithdrawDelegatorReward { + const message = createBaseMsgWithdrawDelegatorReward(); + message.delegatorAddress = object.delegatorAddress ?? ""; + message.validatorAddress = object.validatorAddress ?? ""; + return message; + }, + fromSDK(object: MsgWithdrawDelegatorRewardSDKType): MsgWithdrawDelegatorReward { + return { + delegatorAddress: object?.delegator_address, + validatorAddress: object?.validator_address + }; + }, + fromSDKJSON(object: any): MsgWithdrawDelegatorRewardSDKType { + return { + delegator_address: isSet(object.delegator_address) ? String(object.delegator_address) : "", + validator_address: isSet(object.validator_address) ? String(object.validator_address) : "" + }; + }, + toSDK(message: MsgWithdrawDelegatorReward): MsgWithdrawDelegatorRewardSDKType { + const obj: any = {}; + obj.delegator_address = message.delegatorAddress; + obj.validator_address = message.validatorAddress; + return obj; + }, + fromAmino(object: MsgWithdrawDelegatorRewardAmino): MsgWithdrawDelegatorReward { + const message = createBaseMsgWithdrawDelegatorReward(); + if (object.delegator_address !== undefined && object.delegator_address !== null) { + message.delegatorAddress = object.delegator_address; + } + if (object.validator_address !== undefined && object.validator_address !== null) { + message.validatorAddress = object.validator_address; + } + return message; + }, + toAmino(message: MsgWithdrawDelegatorReward): MsgWithdrawDelegatorRewardAmino { + const obj: any = {}; + obj.delegator_address = message.delegatorAddress === "" ? undefined : message.delegatorAddress; + obj.validator_address = message.validatorAddress === "" ? undefined : message.validatorAddress; + return obj; + }, + fromAminoMsg(object: MsgWithdrawDelegatorRewardAminoMsg): MsgWithdrawDelegatorReward { + return MsgWithdrawDelegatorReward.fromAmino(object.value); + }, + toAminoMsg(message: MsgWithdrawDelegatorReward): MsgWithdrawDelegatorRewardAminoMsg { + return { + type: "cosmos-sdk/MsgWithdrawDelegationReward", + value: MsgWithdrawDelegatorReward.toAmino(message) + }; + }, + fromProtoMsg(message: MsgWithdrawDelegatorRewardProtoMsg): MsgWithdrawDelegatorReward { + return MsgWithdrawDelegatorReward.decode(message.value); + }, + toProto(message: MsgWithdrawDelegatorReward): Uint8Array { + return MsgWithdrawDelegatorReward.encode(message).finish(); + }, + toProtoMsg(message: MsgWithdrawDelegatorReward): MsgWithdrawDelegatorRewardProtoMsg { + return { + typeUrl: "/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward", + value: MsgWithdrawDelegatorReward.encode(message).finish() + }; + } +}; +function createBaseMsgWithdrawDelegatorRewardResponse(): MsgWithdrawDelegatorRewardResponse { + return { + amount: [] + }; +} +export const MsgWithdrawDelegatorRewardResponse = { + typeUrl: "/cosmos.distribution.v1beta1.MsgWithdrawDelegatorRewardResponse", + encode(message: MsgWithdrawDelegatorRewardResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.amount) { + Coin.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgWithdrawDelegatorRewardResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgWithdrawDelegatorRewardResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.amount.push(Coin.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgWithdrawDelegatorRewardResponse { + const obj = createBaseMsgWithdrawDelegatorRewardResponse(); + if (Array.isArray(object?.amount)) obj.amount = object.amount.map((e: any) => Coin.fromJSON(e)); + return obj; + }, + toJSON(message: MsgWithdrawDelegatorRewardResponse): JsonSafe { + const obj: any = {}; + if (message.amount) { + obj.amount = message.amount.map(e => e ? Coin.toJSON(e) : undefined); + } else { + obj.amount = []; + } + return obj; + }, + fromPartial(object: DeepPartial): MsgWithdrawDelegatorRewardResponse { + const message = createBaseMsgWithdrawDelegatorRewardResponse(); + message.amount = object.amount?.map(e => Coin.fromPartial(e)) || []; + return message; + }, + fromSDK(object: MsgWithdrawDelegatorRewardResponseSDKType): MsgWithdrawDelegatorRewardResponse { + return { + amount: Array.isArray(object?.amount) ? object.amount.map((e: any) => Coin.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): MsgWithdrawDelegatorRewardResponseSDKType { + return { + amount: Array.isArray(object?.amount) ? object.amount.map((e: any) => Coin.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: MsgWithdrawDelegatorRewardResponse): MsgWithdrawDelegatorRewardResponseSDKType { + const obj: any = {}; + if (message.amount) { + obj.amount = message.amount.map(e => e ? Coin.toSDK(e) : undefined); + } else { + obj.amount = []; + } + return obj; + }, + fromAmino(object: MsgWithdrawDelegatorRewardResponseAmino): MsgWithdrawDelegatorRewardResponse { + const message = createBaseMsgWithdrawDelegatorRewardResponse(); + message.amount = object.amount?.map(e => Coin.fromAmino(e)) || []; + return message; + }, + toAmino(message: MsgWithdrawDelegatorRewardResponse): MsgWithdrawDelegatorRewardResponseAmino { + const obj: any = {}; + if (message.amount) { + obj.amount = message.amount.map(e => e ? Coin.toAmino(e) : undefined); + } else { + obj.amount = message.amount; + } + return obj; + }, + fromAminoMsg(object: MsgWithdrawDelegatorRewardResponseAminoMsg): MsgWithdrawDelegatorRewardResponse { + return MsgWithdrawDelegatorRewardResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgWithdrawDelegatorRewardResponse): MsgWithdrawDelegatorRewardResponseAminoMsg { + return { + type: "cosmos-sdk/MsgWithdrawDelegatorRewardResponse", + value: MsgWithdrawDelegatorRewardResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgWithdrawDelegatorRewardResponseProtoMsg): MsgWithdrawDelegatorRewardResponse { + return MsgWithdrawDelegatorRewardResponse.decode(message.value); + }, + toProto(message: MsgWithdrawDelegatorRewardResponse): Uint8Array { + return MsgWithdrawDelegatorRewardResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgWithdrawDelegatorRewardResponse): MsgWithdrawDelegatorRewardResponseProtoMsg { + return { + typeUrl: "/cosmos.distribution.v1beta1.MsgWithdrawDelegatorRewardResponse", + value: MsgWithdrawDelegatorRewardResponse.encode(message).finish() + }; + } +}; +function createBaseMsgWithdrawValidatorCommission(): MsgWithdrawValidatorCommission { + return { + validatorAddress: "" + }; +} +export const MsgWithdrawValidatorCommission = { + typeUrl: "/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission", + encode(message: MsgWithdrawValidatorCommission, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.validatorAddress !== undefined) { + writer.uint32(10).string(message.validatorAddress); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgWithdrawValidatorCommission { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgWithdrawValidatorCommission(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.validatorAddress = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgWithdrawValidatorCommission { + const obj = createBaseMsgWithdrawValidatorCommission(); + if (isSet(object.validatorAddress)) obj.validatorAddress = String(object.validatorAddress); + return obj; + }, + toJSON(message: MsgWithdrawValidatorCommission): JsonSafe { + const obj: any = {}; + message.validatorAddress !== undefined && (obj.validatorAddress = message.validatorAddress); + return obj; + }, + fromPartial(object: DeepPartial): MsgWithdrawValidatorCommission { + const message = createBaseMsgWithdrawValidatorCommission(); + message.validatorAddress = object.validatorAddress ?? ""; + return message; + }, + fromSDK(object: MsgWithdrawValidatorCommissionSDKType): MsgWithdrawValidatorCommission { + return { + validatorAddress: object?.validator_address + }; + }, + fromSDKJSON(object: any): MsgWithdrawValidatorCommissionSDKType { + return { + validator_address: isSet(object.validator_address) ? String(object.validator_address) : "" + }; + }, + toSDK(message: MsgWithdrawValidatorCommission): MsgWithdrawValidatorCommissionSDKType { + const obj: any = {}; + obj.validator_address = message.validatorAddress; + return obj; + }, + fromAmino(object: MsgWithdrawValidatorCommissionAmino): MsgWithdrawValidatorCommission { + const message = createBaseMsgWithdrawValidatorCommission(); + if (object.validator_address !== undefined && object.validator_address !== null) { + message.validatorAddress = object.validator_address; + } + return message; + }, + toAmino(message: MsgWithdrawValidatorCommission): MsgWithdrawValidatorCommissionAmino { + const obj: any = {}; + obj.validator_address = message.validatorAddress === "" ? undefined : message.validatorAddress; + return obj; + }, + fromAminoMsg(object: MsgWithdrawValidatorCommissionAminoMsg): MsgWithdrawValidatorCommission { + return MsgWithdrawValidatorCommission.fromAmino(object.value); + }, + toAminoMsg(message: MsgWithdrawValidatorCommission): MsgWithdrawValidatorCommissionAminoMsg { + return { + type: "cosmos-sdk/MsgWithdrawValidatorCommission", + value: MsgWithdrawValidatorCommission.toAmino(message) + }; + }, + fromProtoMsg(message: MsgWithdrawValidatorCommissionProtoMsg): MsgWithdrawValidatorCommission { + return MsgWithdrawValidatorCommission.decode(message.value); + }, + toProto(message: MsgWithdrawValidatorCommission): Uint8Array { + return MsgWithdrawValidatorCommission.encode(message).finish(); + }, + toProtoMsg(message: MsgWithdrawValidatorCommission): MsgWithdrawValidatorCommissionProtoMsg { + return { + typeUrl: "/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission", + value: MsgWithdrawValidatorCommission.encode(message).finish() + }; + } +}; +function createBaseMsgWithdrawValidatorCommissionResponse(): MsgWithdrawValidatorCommissionResponse { + return { + amount: [] + }; +} +export const MsgWithdrawValidatorCommissionResponse = { + typeUrl: "/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommissionResponse", + encode(message: MsgWithdrawValidatorCommissionResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.amount) { + Coin.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgWithdrawValidatorCommissionResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgWithdrawValidatorCommissionResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.amount.push(Coin.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgWithdrawValidatorCommissionResponse { + const obj = createBaseMsgWithdrawValidatorCommissionResponse(); + if (Array.isArray(object?.amount)) obj.amount = object.amount.map((e: any) => Coin.fromJSON(e)); + return obj; + }, + toJSON(message: MsgWithdrawValidatorCommissionResponse): JsonSafe { + const obj: any = {}; + if (message.amount) { + obj.amount = message.amount.map(e => e ? Coin.toJSON(e) : undefined); + } else { + obj.amount = []; + } + return obj; + }, + fromPartial(object: DeepPartial): MsgWithdrawValidatorCommissionResponse { + const message = createBaseMsgWithdrawValidatorCommissionResponse(); + message.amount = object.amount?.map(e => Coin.fromPartial(e)) || []; + return message; + }, + fromSDK(object: MsgWithdrawValidatorCommissionResponseSDKType): MsgWithdrawValidatorCommissionResponse { + return { + amount: Array.isArray(object?.amount) ? object.amount.map((e: any) => Coin.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): MsgWithdrawValidatorCommissionResponseSDKType { + return { + amount: Array.isArray(object?.amount) ? object.amount.map((e: any) => Coin.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: MsgWithdrawValidatorCommissionResponse): MsgWithdrawValidatorCommissionResponseSDKType { + const obj: any = {}; + if (message.amount) { + obj.amount = message.amount.map(e => e ? Coin.toSDK(e) : undefined); + } else { + obj.amount = []; + } + return obj; + }, + fromAmino(object: MsgWithdrawValidatorCommissionResponseAmino): MsgWithdrawValidatorCommissionResponse { + const message = createBaseMsgWithdrawValidatorCommissionResponse(); + message.amount = object.amount?.map(e => Coin.fromAmino(e)) || []; + return message; + }, + toAmino(message: MsgWithdrawValidatorCommissionResponse): MsgWithdrawValidatorCommissionResponseAmino { + const obj: any = {}; + if (message.amount) { + obj.amount = message.amount.map(e => e ? Coin.toAmino(e) : undefined); + } else { + obj.amount = message.amount; + } + return obj; + }, + fromAminoMsg(object: MsgWithdrawValidatorCommissionResponseAminoMsg): MsgWithdrawValidatorCommissionResponse { + return MsgWithdrawValidatorCommissionResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgWithdrawValidatorCommissionResponse): MsgWithdrawValidatorCommissionResponseAminoMsg { + return { + type: "cosmos-sdk/MsgWithdrawValidatorCommissionResponse", + value: MsgWithdrawValidatorCommissionResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgWithdrawValidatorCommissionResponseProtoMsg): MsgWithdrawValidatorCommissionResponse { + return MsgWithdrawValidatorCommissionResponse.decode(message.value); + }, + toProto(message: MsgWithdrawValidatorCommissionResponse): Uint8Array { + return MsgWithdrawValidatorCommissionResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgWithdrawValidatorCommissionResponse): MsgWithdrawValidatorCommissionResponseProtoMsg { + return { + typeUrl: "/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommissionResponse", + value: MsgWithdrawValidatorCommissionResponse.encode(message).finish() + }; + } +}; +function createBaseMsgFundCommunityPool(): MsgFundCommunityPool { + return { + amount: [], + depositor: "" + }; +} +export const MsgFundCommunityPool = { + typeUrl: "/cosmos.distribution.v1beta1.MsgFundCommunityPool", + encode(message: MsgFundCommunityPool, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.amount) { + Coin.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.depositor !== undefined) { + writer.uint32(18).string(message.depositor); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgFundCommunityPool { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgFundCommunityPool(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.amount.push(Coin.decode(reader, reader.uint32())); + break; + case 2: + message.depositor = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgFundCommunityPool { + const obj = createBaseMsgFundCommunityPool(); + if (Array.isArray(object?.amount)) obj.amount = object.amount.map((e: any) => Coin.fromJSON(e)); + if (isSet(object.depositor)) obj.depositor = String(object.depositor); + return obj; + }, + toJSON(message: MsgFundCommunityPool): JsonSafe { + const obj: any = {}; + if (message.amount) { + obj.amount = message.amount.map(e => e ? Coin.toJSON(e) : undefined); + } else { + obj.amount = []; + } + message.depositor !== undefined && (obj.depositor = message.depositor); + return obj; + }, + fromPartial(object: DeepPartial): MsgFundCommunityPool { + const message = createBaseMsgFundCommunityPool(); + message.amount = object.amount?.map(e => Coin.fromPartial(e)) || []; + message.depositor = object.depositor ?? ""; + return message; + }, + fromSDK(object: MsgFundCommunityPoolSDKType): MsgFundCommunityPool { + return { + amount: Array.isArray(object?.amount) ? object.amount.map((e: any) => Coin.fromSDK(e)) : [], + depositor: object?.depositor + }; + }, + fromSDKJSON(object: any): MsgFundCommunityPoolSDKType { + return { + amount: Array.isArray(object?.amount) ? object.amount.map((e: any) => Coin.fromSDKJSON(e)) : [], + depositor: isSet(object.depositor) ? String(object.depositor) : "" + }; + }, + toSDK(message: MsgFundCommunityPool): MsgFundCommunityPoolSDKType { + const obj: any = {}; + if (message.amount) { + obj.amount = message.amount.map(e => e ? Coin.toSDK(e) : undefined); + } else { + obj.amount = []; + } + obj.depositor = message.depositor; + return obj; + }, + fromAmino(object: MsgFundCommunityPoolAmino): MsgFundCommunityPool { + const message = createBaseMsgFundCommunityPool(); + message.amount = object.amount?.map(e => Coin.fromAmino(e)) || []; + if (object.depositor !== undefined && object.depositor !== null) { + message.depositor = object.depositor; + } + return message; + }, + toAmino(message: MsgFundCommunityPool): MsgFundCommunityPoolAmino { + const obj: any = {}; + if (message.amount) { + obj.amount = message.amount.map(e => e ? Coin.toAmino(e) : undefined); + } else { + obj.amount = message.amount; + } + obj.depositor = message.depositor === "" ? undefined : message.depositor; + return obj; + }, + fromAminoMsg(object: MsgFundCommunityPoolAminoMsg): MsgFundCommunityPool { + return MsgFundCommunityPool.fromAmino(object.value); + }, + toAminoMsg(message: MsgFundCommunityPool): MsgFundCommunityPoolAminoMsg { + return { + type: "cosmos-sdk/MsgFundCommunityPool", + value: MsgFundCommunityPool.toAmino(message) + }; + }, + fromProtoMsg(message: MsgFundCommunityPoolProtoMsg): MsgFundCommunityPool { + return MsgFundCommunityPool.decode(message.value); + }, + toProto(message: MsgFundCommunityPool): Uint8Array { + return MsgFundCommunityPool.encode(message).finish(); + }, + toProtoMsg(message: MsgFundCommunityPool): MsgFundCommunityPoolProtoMsg { + return { + typeUrl: "/cosmos.distribution.v1beta1.MsgFundCommunityPool", + value: MsgFundCommunityPool.encode(message).finish() + }; + } +}; +function createBaseMsgFundCommunityPoolResponse(): MsgFundCommunityPoolResponse { + return {}; +} +export const MsgFundCommunityPoolResponse = { + typeUrl: "/cosmos.distribution.v1beta1.MsgFundCommunityPoolResponse", + encode(_: MsgFundCommunityPoolResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgFundCommunityPoolResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgFundCommunityPoolResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgFundCommunityPoolResponse { + const obj = createBaseMsgFundCommunityPoolResponse(); + return obj; + }, + toJSON(_: MsgFundCommunityPoolResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): MsgFundCommunityPoolResponse { + const message = createBaseMsgFundCommunityPoolResponse(); + return message; + }, + fromSDK(_: MsgFundCommunityPoolResponseSDKType): MsgFundCommunityPoolResponse { + return {}; + }, + fromSDKJSON(_: any): MsgFundCommunityPoolResponseSDKType { + return {}; + }, + toSDK(_: MsgFundCommunityPoolResponse): MsgFundCommunityPoolResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgFundCommunityPoolResponseAmino): MsgFundCommunityPoolResponse { + const message = createBaseMsgFundCommunityPoolResponse(); + return message; + }, + toAmino(_: MsgFundCommunityPoolResponse): MsgFundCommunityPoolResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgFundCommunityPoolResponseAminoMsg): MsgFundCommunityPoolResponse { + return MsgFundCommunityPoolResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgFundCommunityPoolResponse): MsgFundCommunityPoolResponseAminoMsg { + return { + type: "cosmos-sdk/MsgFundCommunityPoolResponse", + value: MsgFundCommunityPoolResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgFundCommunityPoolResponseProtoMsg): MsgFundCommunityPoolResponse { + return MsgFundCommunityPoolResponse.decode(message.value); + }, + toProto(message: MsgFundCommunityPoolResponse): Uint8Array { + return MsgFundCommunityPoolResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgFundCommunityPoolResponse): MsgFundCommunityPoolResponseProtoMsg { + return { + typeUrl: "/cosmos.distribution.v1beta1.MsgFundCommunityPoolResponse", + value: MsgFundCommunityPoolResponse.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/evidence/v1beta1/evidence.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/evidence/v1beta1/evidence.ts new file mode 100644 index 0000000000..42ad777489 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/evidence/v1beta1/evidence.ts @@ -0,0 +1,178 @@ +import { Timestamp, TimestampSDKType } from "../../../google/protobuf/timestamp.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { toTimestamp, fromTimestamp, isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "cosmos.evidence.v1beta1"; +/** + * Equivocation implements the Evidence interface and defines evidence of double + * signing misbehavior. + */ +export interface Equivocation { + height: bigint; + time: Date; + power: bigint; + consensusAddress: string; +} +export interface EquivocationProtoMsg { + typeUrl: "/cosmos.evidence.v1beta1.Equivocation"; + value: Uint8Array; +} +/** + * Equivocation implements the Evidence interface and defines evidence of double + * signing misbehavior. + */ +export interface EquivocationSDKType { + height: bigint; + time: Date; + power: bigint; + consensus_address: string; +} +function createBaseEquivocation(): Equivocation { + return { + height: BigInt(0), + time: new Date(), + power: BigInt(0), + consensusAddress: "" + }; +} +export const Equivocation = { + typeUrl: "/cosmos.evidence.v1beta1.Equivocation", + encode(message: Equivocation, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.height !== undefined) { + writer.uint32(8).int64(message.height); + } + if (message.time !== undefined) { + Timestamp.encode(toTimestamp(message.time), writer.uint32(18).fork()).ldelim(); + } + if (message.power !== undefined) { + writer.uint32(24).int64(message.power); + } + if (message.consensusAddress !== undefined) { + writer.uint32(34).string(message.consensusAddress); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Equivocation { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseEquivocation(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.height = reader.int64(); + break; + case 2: + message.time = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + break; + case 3: + message.power = reader.int64(); + break; + case 4: + message.consensusAddress = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Equivocation { + const obj = createBaseEquivocation(); + if (isSet(object.height)) obj.height = BigInt(object.height.toString()); + if (isSet(object.time)) obj.time = new Date(object.time); + if (isSet(object.power)) obj.power = BigInt(object.power.toString()); + if (isSet(object.consensusAddress)) obj.consensusAddress = String(object.consensusAddress); + return obj; + }, + toJSON(message: Equivocation): JsonSafe { + const obj: any = {}; + message.height !== undefined && (obj.height = (message.height || BigInt(0)).toString()); + message.time !== undefined && (obj.time = message.time.toISOString()); + message.power !== undefined && (obj.power = (message.power || BigInt(0)).toString()); + message.consensusAddress !== undefined && (obj.consensusAddress = message.consensusAddress); + return obj; + }, + fromPartial(object: DeepPartial): Equivocation { + const message = createBaseEquivocation(); + if (object.height !== undefined && object.height !== null) { + message.height = BigInt(object.height.toString()); + } + message.time = object.time ?? undefined; + if (object.power !== undefined && object.power !== null) { + message.power = BigInt(object.power.toString()); + } + message.consensusAddress = object.consensusAddress ?? ""; + return message; + }, + fromSDK(object: EquivocationSDKType): Equivocation { + return { + height: object?.height, + time: object.time ?? undefined, + power: object?.power, + consensusAddress: object?.consensus_address + }; + }, + fromSDKJSON(object: any): EquivocationSDKType { + return { + height: isSet(object.height) ? BigInt(object.height.toString()) : BigInt(0), + time: isSet(object.time) ? new Date(object.time) : undefined, + power: isSet(object.power) ? BigInt(object.power.toString()) : BigInt(0), + consensus_address: isSet(object.consensus_address) ? String(object.consensus_address) : "" + }; + }, + toSDK(message: Equivocation): EquivocationSDKType { + const obj: any = {}; + obj.height = message.height; + message.time !== undefined && (obj.time = message.time ?? undefined); + obj.power = message.power; + obj.consensus_address = message.consensusAddress; + return obj; + }, + fromAmino(object: EquivocationAmino): Equivocation { + const message = createBaseEquivocation(); + if (object.height !== undefined && object.height !== null) { + message.height = BigInt(object.height); + } + if (object.time !== undefined && object.time !== null) { + message.time = fromTimestamp(Timestamp.fromAmino(object.time)); + } + if (object.power !== undefined && object.power !== null) { + message.power = BigInt(object.power); + } + if (object.consensus_address !== undefined && object.consensus_address !== null) { + message.consensusAddress = object.consensus_address; + } + return message; + }, + toAmino(message: Equivocation): EquivocationAmino { + const obj: any = {}; + obj.height = message.height !== BigInt(0) ? message.height?.toString() : undefined; + obj.time = message.time ? Timestamp.toAmino(toTimestamp(message.time)) : undefined; + obj.power = message.power !== BigInt(0) ? message.power?.toString() : undefined; + obj.consensus_address = message.consensusAddress === "" ? undefined : message.consensusAddress; + return obj; + }, + fromAminoMsg(object: EquivocationAminoMsg): Equivocation { + return Equivocation.fromAmino(object.value); + }, + toAminoMsg(message: Equivocation): EquivocationAminoMsg { + return { + type: "cosmos-sdk/Equivocation", + value: Equivocation.toAmino(message) + }; + }, + fromProtoMsg(message: EquivocationProtoMsg): Equivocation { + return Equivocation.decode(message.value); + }, + toProto(message: Equivocation): Uint8Array { + return Equivocation.encode(message).finish(); + }, + toProtoMsg(message: Equivocation): EquivocationProtoMsg { + return { + typeUrl: "/cosmos.evidence.v1beta1.Equivocation", + value: Equivocation.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/evidence/v1beta1/genesis.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/evidence/v1beta1/genesis.ts new file mode 100644 index 0000000000..7b0be1fb00 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/evidence/v1beta1/genesis.ts @@ -0,0 +1,122 @@ +import { Any, AnySDKType } from "../../../google/protobuf/any.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { JsonSafe } from "../../../json-safe.js"; +import { DeepPartial } from "../../../helpers.js"; +export const protobufPackage = "cosmos.evidence.v1beta1"; +/** GenesisState defines the evidence module's genesis state. */ +export interface GenesisState { + /** evidence defines all the evidence at genesis. */ + evidence: Any[]; +} +export interface GenesisStateProtoMsg { + typeUrl: "/cosmos.evidence.v1beta1.GenesisState"; + value: Uint8Array; +} +/** GenesisState defines the evidence module's genesis state. */ +export interface GenesisStateSDKType { + evidence: AnySDKType[]; +} +function createBaseGenesisState(): GenesisState { + return { + evidence: [] + }; +} +export const GenesisState = { + typeUrl: "/cosmos.evidence.v1beta1.GenesisState", + encode(message: GenesisState, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.evidence) { + Any.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GenesisState { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGenesisState(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.evidence.push(Any.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GenesisState { + const obj = createBaseGenesisState(); + if (Array.isArray(object?.evidence)) obj.evidence = object.evidence.map((e: any) => Any.fromJSON(e)); + return obj; + }, + toJSON(message: GenesisState): JsonSafe { + const obj: any = {}; + if (message.evidence) { + obj.evidence = message.evidence.map(e => e ? Any.toJSON(e) : undefined); + } else { + obj.evidence = []; + } + return obj; + }, + fromPartial(object: DeepPartial): GenesisState { + const message = createBaseGenesisState(); + message.evidence = object.evidence?.map(e => Any.fromPartial(e)) || []; + return message; + }, + fromSDK(object: GenesisStateSDKType): GenesisState { + return { + evidence: Array.isArray(object?.evidence) ? object.evidence.map((e: any) => Any.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): GenesisStateSDKType { + return { + evidence: Array.isArray(object?.evidence) ? object.evidence.map((e: any) => Any.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: GenesisState): GenesisStateSDKType { + const obj: any = {}; + if (message.evidence) { + obj.evidence = message.evidence.map(e => e ? Any.toSDK(e) : undefined); + } else { + obj.evidence = []; + } + return obj; + }, + fromAmino(object: GenesisStateAmino): GenesisState { + const message = createBaseGenesisState(); + message.evidence = object.evidence?.map(e => Any.fromAmino(e)) || []; + return message; + }, + toAmino(message: GenesisState): GenesisStateAmino { + const obj: any = {}; + if (message.evidence) { + obj.evidence = message.evidence.map(e => e ? Any.toAmino(e) : undefined); + } else { + obj.evidence = message.evidence; + } + return obj; + }, + fromAminoMsg(object: GenesisStateAminoMsg): GenesisState { + return GenesisState.fromAmino(object.value); + }, + toAminoMsg(message: GenesisState): GenesisStateAminoMsg { + return { + type: "cosmos-sdk/GenesisState", + value: GenesisState.toAmino(message) + }; + }, + fromProtoMsg(message: GenesisStateProtoMsg): GenesisState { + return GenesisState.decode(message.value); + }, + toProto(message: GenesisState): Uint8Array { + return GenesisState.encode(message).finish(); + }, + toProtoMsg(message: GenesisState): GenesisStateProtoMsg { + return { + typeUrl: "/cosmos.evidence.v1beta1.GenesisState", + value: GenesisState.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/evidence/v1beta1/query.lcd.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/evidence/v1beta1/query.lcd.ts new file mode 100644 index 0000000000..bb742ee30e --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/evidence/v1beta1/query.lcd.ts @@ -0,0 +1,35 @@ +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../base/query/v1beta1/pagination.js"; +import { Any, AnySDKType } from "../../../google/protobuf/any.js"; +import { setPaginationParams } from "../../../helpers.js"; +import { LCDClient } from "@cosmology/lcd"; +import { QueryEvidenceRequest, QueryEvidenceRequestSDKType, QueryEvidenceResponse, QueryEvidenceResponseSDKType, QueryAllEvidenceRequest, QueryAllEvidenceRequestSDKType, QueryAllEvidenceResponse, QueryAllEvidenceResponseSDKType } from "./query.js"; +export class LCDQueryClient { + req: LCDClient; + constructor({ + requestClient + }: { + requestClient: LCDClient; + }) { + this.req = requestClient; + this.evidence = this.evidence.bind(this); + this.allEvidence = this.allEvidence.bind(this); + } + /* Evidence queries evidence based on evidence hash. */ + async evidence(params: QueryEvidenceRequest): Promise { + const endpoint = `cosmos/evidence/v1beta1/evidence/${params.evidenceHash}`; + return QueryEvidenceResponse.fromSDKJSON(await this.req.get(endpoint)); + } + /* AllEvidence queries all evidence. */ + async allEvidence(params: QueryAllEvidenceRequest = { + pagination: PageRequest.fromPartial({}) + }): Promise { + const options: any = { + params: {} + }; + if (typeof params?.pagination !== "undefined") { + setPaginationParams(options, params.pagination); + } + const endpoint = `cosmos/evidence/v1beta1/evidence`; + return QueryAllEvidenceResponse.fromSDKJSON(await this.req.get(endpoint, options)); + } +} \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/evidence/v1beta1/query.rpc.Query.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/evidence/v1beta1/query.rpc.Query.ts new file mode 100644 index 0000000000..92090f9b74 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/evidence/v1beta1/query.rpc.Query.ts @@ -0,0 +1,45 @@ +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../base/query/v1beta1/pagination.js"; +import { Any, AnySDKType } from "../../../google/protobuf/any.js"; +import { Rpc } from "../../../helpers.js"; +import { BinaryReader } from "../../../binary.js"; +import { QueryClient, createProtobufRpcClient } from "@cosmjs/stargate"; +import { QueryEvidenceRequest, QueryEvidenceRequestSDKType, QueryEvidenceResponse, QueryEvidenceResponseSDKType, QueryAllEvidenceRequest, QueryAllEvidenceRequestSDKType, QueryAllEvidenceResponse, QueryAllEvidenceResponseSDKType } from "./query.js"; +/** Query defines the gRPC querier service. */ +export interface Query { + /** Evidence queries evidence based on evidence hash. */ + evidence(request: QueryEvidenceRequest): Promise; + /** AllEvidence queries all evidence. */ + allEvidence(request?: QueryAllEvidenceRequest): Promise; +} +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + this.evidence = this.evidence.bind(this); + this.allEvidence = this.allEvidence.bind(this); + } + evidence(request: QueryEvidenceRequest): Promise { + const data = QueryEvidenceRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.evidence.v1beta1.Query", "Evidence", data); + return promise.then(data => QueryEvidenceResponse.decode(new BinaryReader(data))); + } + allEvidence(request: QueryAllEvidenceRequest = { + pagination: PageRequest.fromPartial({}) + }): Promise { + const data = QueryAllEvidenceRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.evidence.v1beta1.Query", "AllEvidence", data); + return promise.then(data => QueryAllEvidenceResponse.decode(new BinaryReader(data))); + } +} +export const createRpcQueryExtension = (base: QueryClient) => { + const rpc = createProtobufRpcClient(base); + const queryService = new QueryClientImpl(rpc); + return { + evidence(request: QueryEvidenceRequest): Promise { + return queryService.evidence(request); + }, + allEvidence(request?: QueryAllEvidenceRequest): Promise { + return queryService.allEvidence(request); + } + }; +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/evidence/v1beta1/query.rpc.func.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/evidence/v1beta1/query.rpc.func.ts new file mode 100644 index 0000000000..94dd0c7dca --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/evidence/v1beta1/query.rpc.func.ts @@ -0,0 +1,25 @@ +import { RpcResolver, buildQuery } from "../../../helper-func-types"; +import { buildUseQuery } from "../../../react-query"; +import { QueryEvidenceRequest, QueryEvidenceResponse, QueryAllEvidenceRequest, QueryAllEvidenceResponse } from "./query"; +export const createGetEvidence = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryEvidenceRequest.encode, + decode: QueryEvidenceResponse.decode, + service: "cosmos.evidence.v1beta1.Query", + method: "Evidence", + getRpcInstance: getRpcInstance +}); +export const useGetEvidence = buildUseQuery({ + builderQueryFn: createGetEvidence, + queryKeyPrefix: "EvidenceQuery" +}); +export const createGetAllEvidence = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryAllEvidenceRequest.encode, + decode: QueryAllEvidenceResponse.decode, + service: "cosmos.evidence.v1beta1.Query", + method: "AllEvidence", + getRpcInstance: getRpcInstance +}); +export const useGetAllEvidence = buildUseQuery({ + builderQueryFn: createGetAllEvidence, + queryKeyPrefix: "AllEvidenceQuery" +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/evidence/v1beta1/query.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/evidence/v1beta1/query.ts new file mode 100644 index 0000000000..d7ac8657f3 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/evidence/v1beta1/query.ts @@ -0,0 +1,482 @@ +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../base/query/v1beta1/pagination.js"; +import { Any, AnySDKType } from "../../../google/protobuf/any.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, bytesFromBase64, base64FromBytes, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "cosmos.evidence.v1beta1"; +/** QueryEvidenceRequest is the request type for the Query/Evidence RPC method. */ +export interface QueryEvidenceRequest { + /** evidence_hash defines the hash of the requested evidence. */ + evidenceHash: Uint8Array; +} +export interface QueryEvidenceRequestProtoMsg { + typeUrl: "/cosmos.evidence.v1beta1.QueryEvidenceRequest"; + value: Uint8Array; +} +/** QueryEvidenceRequest is the request type for the Query/Evidence RPC method. */ +export interface QueryEvidenceRequestSDKType { + evidence_hash: Uint8Array; +} +/** QueryEvidenceResponse is the response type for the Query/Evidence RPC method. */ +export interface QueryEvidenceResponse { + /** evidence returns the requested evidence. */ + evidence?: Any; +} +export interface QueryEvidenceResponseProtoMsg { + typeUrl: "/cosmos.evidence.v1beta1.QueryEvidenceResponse"; + value: Uint8Array; +} +/** QueryEvidenceResponse is the response type for the Query/Evidence RPC method. */ +export interface QueryEvidenceResponseSDKType { + evidence?: AnySDKType; +} +/** + * QueryEvidenceRequest is the request type for the Query/AllEvidence RPC + * method. + */ +export interface QueryAllEvidenceRequest { + /** pagination defines an optional pagination for the request. */ + pagination?: PageRequest; +} +export interface QueryAllEvidenceRequestProtoMsg { + typeUrl: "/cosmos.evidence.v1beta1.QueryAllEvidenceRequest"; + value: Uint8Array; +} +/** + * QueryEvidenceRequest is the request type for the Query/AllEvidence RPC + * method. + */ +export interface QueryAllEvidenceRequestSDKType { + pagination?: PageRequestSDKType; +} +/** + * QueryAllEvidenceResponse is the response type for the Query/AllEvidence RPC + * method. + */ +export interface QueryAllEvidenceResponse { + /** evidence returns all evidences. */ + evidence: Any[]; + /** pagination defines the pagination in the response. */ + pagination?: PageResponse; +} +export interface QueryAllEvidenceResponseProtoMsg { + typeUrl: "/cosmos.evidence.v1beta1.QueryAllEvidenceResponse"; + value: Uint8Array; +} +/** + * QueryAllEvidenceResponse is the response type for the Query/AllEvidence RPC + * method. + */ +export interface QueryAllEvidenceResponseSDKType { + evidence: AnySDKType[]; + pagination?: PageResponseSDKType; +} +function createBaseQueryEvidenceRequest(): QueryEvidenceRequest { + return { + evidenceHash: new Uint8Array() + }; +} +export const QueryEvidenceRequest = { + typeUrl: "/cosmos.evidence.v1beta1.QueryEvidenceRequest", + encode(message: QueryEvidenceRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.evidenceHash.length !== 0) { + writer.uint32(10).bytes(message.evidenceHash); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryEvidenceRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryEvidenceRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.evidenceHash = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryEvidenceRequest { + const obj = createBaseQueryEvidenceRequest(); + if (isSet(object.evidenceHash)) obj.evidenceHash = bytesFromBase64(object.evidenceHash); + return obj; + }, + toJSON(message: QueryEvidenceRequest): JsonSafe { + const obj: any = {}; + message.evidenceHash !== undefined && (obj.evidenceHash = base64FromBytes(message.evidenceHash !== undefined ? message.evidenceHash : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): QueryEvidenceRequest { + const message = createBaseQueryEvidenceRequest(); + message.evidenceHash = object.evidenceHash ?? new Uint8Array(); + return message; + }, + fromSDK(object: QueryEvidenceRequestSDKType): QueryEvidenceRequest { + return { + evidenceHash: object?.evidence_hash + }; + }, + fromSDKJSON(object: any): QueryEvidenceRequestSDKType { + return { + evidence_hash: isSet(object.evidence_hash) ? bytesFromBase64(object.evidence_hash) : new Uint8Array() + }; + }, + toSDK(message: QueryEvidenceRequest): QueryEvidenceRequestSDKType { + const obj: any = {}; + obj.evidence_hash = message.evidenceHash; + return obj; + }, + fromAmino(object: QueryEvidenceRequestAmino): QueryEvidenceRequest { + const message = createBaseQueryEvidenceRequest(); + if (object.evidence_hash !== undefined && object.evidence_hash !== null) { + message.evidenceHash = bytesFromBase64(object.evidence_hash); + } + return message; + }, + toAmino(message: QueryEvidenceRequest): QueryEvidenceRequestAmino { + const obj: any = {}; + obj.evidence_hash = message.evidenceHash ? base64FromBytes(message.evidenceHash) : undefined; + return obj; + }, + fromAminoMsg(object: QueryEvidenceRequestAminoMsg): QueryEvidenceRequest { + return QueryEvidenceRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryEvidenceRequest): QueryEvidenceRequestAminoMsg { + return { + type: "cosmos-sdk/QueryEvidenceRequest", + value: QueryEvidenceRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryEvidenceRequestProtoMsg): QueryEvidenceRequest { + return QueryEvidenceRequest.decode(message.value); + }, + toProto(message: QueryEvidenceRequest): Uint8Array { + return QueryEvidenceRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryEvidenceRequest): QueryEvidenceRequestProtoMsg { + return { + typeUrl: "/cosmos.evidence.v1beta1.QueryEvidenceRequest", + value: QueryEvidenceRequest.encode(message).finish() + }; + } +}; +function createBaseQueryEvidenceResponse(): QueryEvidenceResponse { + return { + evidence: undefined + }; +} +export const QueryEvidenceResponse = { + typeUrl: "/cosmos.evidence.v1beta1.QueryEvidenceResponse", + encode(message: QueryEvidenceResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.evidence !== undefined) { + Any.encode(message.evidence, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryEvidenceResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryEvidenceResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.evidence = Any.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryEvidenceResponse { + const obj = createBaseQueryEvidenceResponse(); + if (isSet(object.evidence)) obj.evidence = Any.fromJSON(object.evidence); + return obj; + }, + toJSON(message: QueryEvidenceResponse): JsonSafe { + const obj: any = {}; + message.evidence !== undefined && (obj.evidence = message.evidence ? Any.toJSON(message.evidence) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryEvidenceResponse { + const message = createBaseQueryEvidenceResponse(); + if (object.evidence !== undefined && object.evidence !== null) { + message.evidence = Any.fromPartial(object.evidence); + } + return message; + }, + fromSDK(object: QueryEvidenceResponseSDKType): QueryEvidenceResponse { + return { + evidence: object.evidence ? Any.fromSDK(object.evidence) : undefined + }; + }, + fromSDKJSON(object: any): QueryEvidenceResponseSDKType { + return { + evidence: isSet(object.evidence) ? Any.fromSDKJSON(object.evidence) : undefined + }; + }, + toSDK(message: QueryEvidenceResponse): QueryEvidenceResponseSDKType { + const obj: any = {}; + message.evidence !== undefined && (obj.evidence = message.evidence ? Any.toSDK(message.evidence) : undefined); + return obj; + }, + fromAmino(object: QueryEvidenceResponseAmino): QueryEvidenceResponse { + const message = createBaseQueryEvidenceResponse(); + if (object.evidence !== undefined && object.evidence !== null) { + message.evidence = Any.fromAmino(object.evidence); + } + return message; + }, + toAmino(message: QueryEvidenceResponse): QueryEvidenceResponseAmino { + const obj: any = {}; + obj.evidence = message.evidence ? Any.toAmino(message.evidence) : undefined; + return obj; + }, + fromAminoMsg(object: QueryEvidenceResponseAminoMsg): QueryEvidenceResponse { + return QueryEvidenceResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryEvidenceResponse): QueryEvidenceResponseAminoMsg { + return { + type: "cosmos-sdk/QueryEvidenceResponse", + value: QueryEvidenceResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryEvidenceResponseProtoMsg): QueryEvidenceResponse { + return QueryEvidenceResponse.decode(message.value); + }, + toProto(message: QueryEvidenceResponse): Uint8Array { + return QueryEvidenceResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryEvidenceResponse): QueryEvidenceResponseProtoMsg { + return { + typeUrl: "/cosmos.evidence.v1beta1.QueryEvidenceResponse", + value: QueryEvidenceResponse.encode(message).finish() + }; + } +}; +function createBaseQueryAllEvidenceRequest(): QueryAllEvidenceRequest { + return { + pagination: undefined + }; +} +export const QueryAllEvidenceRequest = { + typeUrl: "/cosmos.evidence.v1beta1.QueryAllEvidenceRequest", + encode(message: QueryAllEvidenceRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryAllEvidenceRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryAllEvidenceRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryAllEvidenceRequest { + const obj = createBaseQueryAllEvidenceRequest(); + if (isSet(object.pagination)) obj.pagination = PageRequest.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryAllEvidenceRequest): JsonSafe { + const obj: any = {}; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryAllEvidenceRequest { + const message = createBaseQueryAllEvidenceRequest(); + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryAllEvidenceRequestSDKType): QueryAllEvidenceRequest { + return { + pagination: object.pagination ? PageRequest.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryAllEvidenceRequestSDKType { + return { + pagination: isSet(object.pagination) ? PageRequest.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryAllEvidenceRequest): QueryAllEvidenceRequestSDKType { + const obj: any = {}; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryAllEvidenceRequestAmino): QueryAllEvidenceRequest { + const message = createBaseQueryAllEvidenceRequest(); + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryAllEvidenceRequest): QueryAllEvidenceRequestAmino { + const obj: any = {}; + obj.pagination = message.pagination ? PageRequest.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryAllEvidenceRequestAminoMsg): QueryAllEvidenceRequest { + return QueryAllEvidenceRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryAllEvidenceRequest): QueryAllEvidenceRequestAminoMsg { + return { + type: "cosmos-sdk/QueryAllEvidenceRequest", + value: QueryAllEvidenceRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryAllEvidenceRequestProtoMsg): QueryAllEvidenceRequest { + return QueryAllEvidenceRequest.decode(message.value); + }, + toProto(message: QueryAllEvidenceRequest): Uint8Array { + return QueryAllEvidenceRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryAllEvidenceRequest): QueryAllEvidenceRequestProtoMsg { + return { + typeUrl: "/cosmos.evidence.v1beta1.QueryAllEvidenceRequest", + value: QueryAllEvidenceRequest.encode(message).finish() + }; + } +}; +function createBaseQueryAllEvidenceResponse(): QueryAllEvidenceResponse { + return { + evidence: [], + pagination: undefined + }; +} +export const QueryAllEvidenceResponse = { + typeUrl: "/cosmos.evidence.v1beta1.QueryAllEvidenceResponse", + encode(message: QueryAllEvidenceResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.evidence) { + Any.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryAllEvidenceResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryAllEvidenceResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.evidence.push(Any.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryAllEvidenceResponse { + const obj = createBaseQueryAllEvidenceResponse(); + if (Array.isArray(object?.evidence)) obj.evidence = object.evidence.map((e: any) => Any.fromJSON(e)); + if (isSet(object.pagination)) obj.pagination = PageResponse.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryAllEvidenceResponse): JsonSafe { + const obj: any = {}; + if (message.evidence) { + obj.evidence = message.evidence.map(e => e ? Any.toJSON(e) : undefined); + } else { + obj.evidence = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryAllEvidenceResponse { + const message = createBaseQueryAllEvidenceResponse(); + message.evidence = object.evidence?.map(e => Any.fromPartial(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryAllEvidenceResponseSDKType): QueryAllEvidenceResponse { + return { + evidence: Array.isArray(object?.evidence) ? object.evidence.map((e: any) => Any.fromSDK(e)) : [], + pagination: object.pagination ? PageResponse.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryAllEvidenceResponseSDKType { + return { + evidence: Array.isArray(object?.evidence) ? object.evidence.map((e: any) => Any.fromSDKJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryAllEvidenceResponse): QueryAllEvidenceResponseSDKType { + const obj: any = {}; + if (message.evidence) { + obj.evidence = message.evidence.map(e => e ? Any.toSDK(e) : undefined); + } else { + obj.evidence = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryAllEvidenceResponseAmino): QueryAllEvidenceResponse { + const message = createBaseQueryAllEvidenceResponse(); + message.evidence = object.evidence?.map(e => Any.fromAmino(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryAllEvidenceResponse): QueryAllEvidenceResponseAmino { + const obj: any = {}; + if (message.evidence) { + obj.evidence = message.evidence.map(e => e ? Any.toAmino(e) : undefined); + } else { + obj.evidence = message.evidence; + } + obj.pagination = message.pagination ? PageResponse.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryAllEvidenceResponseAminoMsg): QueryAllEvidenceResponse { + return QueryAllEvidenceResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryAllEvidenceResponse): QueryAllEvidenceResponseAminoMsg { + return { + type: "cosmos-sdk/QueryAllEvidenceResponse", + value: QueryAllEvidenceResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryAllEvidenceResponseProtoMsg): QueryAllEvidenceResponse { + return QueryAllEvidenceResponse.decode(message.value); + }, + toProto(message: QueryAllEvidenceResponse): Uint8Array { + return QueryAllEvidenceResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryAllEvidenceResponse): QueryAllEvidenceResponseProtoMsg { + return { + typeUrl: "/cosmos.evidence.v1beta1.QueryAllEvidenceResponse", + value: QueryAllEvidenceResponse.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/evidence/v1beta1/tx.amino.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/evidence/v1beta1/tx.amino.ts new file mode 100644 index 0000000000..6d67d8917a --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/evidence/v1beta1/tx.amino.ts @@ -0,0 +1,42 @@ +import { Any, AnySDKType } from "../../../google/protobuf/any.js"; +import { ReadOnlyAminoMsg as AminoMsg } from "@interchainjs/ReadOnlyAminoMsg"; +import { MsgSubmitEvidence, MsgSubmitEvidenceSDKType } from "./tx.js"; +export interface MsgSubmitEvidenceAminoType extends AminoMsg { + type: "cosmos-sdk/MsgSubmitEvidence"; + value: { + submitter: string; + evidence: { + type_url: string; + value: Uint8Array; + }; + }; +} +export const AminoConverter = { + "/cosmos.evidence.v1beta1.MsgSubmitEvidence": { + aminoType: "cosmos-sdk/MsgSubmitEvidence", + toAmino: ({ + submitter, + evidence + }: MsgSubmitEvidence): MsgSubmitEvidenceAminoType["value"] => { + return { + submitter, + evidence: { + type_url: evidence.typeUrl, + value: evidence.value + } + }; + }, + fromAmino: ({ + submitter, + evidence + }: MsgSubmitEvidenceAminoType["value"]): MsgSubmitEvidence => { + return { + submitter, + evidence: { + typeUrl: evidence.type_url, + value: evidence.value + } + }; + } + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/evidence/v1beta1/tx.registry.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/evidence/v1beta1/tx.registry.ts new file mode 100644 index 0000000000..6085b1e689 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/evidence/v1beta1/tx.registry.ts @@ -0,0 +1,51 @@ +import { Any, AnySDKType } from "../../../google/protobuf/any.js"; +import { GeneratedType, Registry } from "@cosmjs/proto-signing"; +import { MsgSubmitEvidence, MsgSubmitEvidenceSDKType } from "./tx.js"; +export const registry: ReadonlyArray<[string, GeneratedType]> = [["/cosmos.evidence.v1beta1.MsgSubmitEvidence", MsgSubmitEvidence]]; +export const load = (protoRegistry: Registry) => { + registry.forEach(([typeUrl, mod]) => { + protoRegistry.register(typeUrl, mod); + }); +}; +export const MessageComposer = { + encoded: { + submitEvidence(value: MsgSubmitEvidence) { + return { + typeUrl: "/cosmos.evidence.v1beta1.MsgSubmitEvidence", + value: MsgSubmitEvidence.encode(value).finish() + }; + } + }, + withTypeUrl: { + submitEvidence(value: MsgSubmitEvidence) { + return { + typeUrl: "/cosmos.evidence.v1beta1.MsgSubmitEvidence", + value + }; + } + }, + toJSON: { + submitEvidence(value: MsgSubmitEvidence) { + return { + typeUrl: "/cosmos.evidence.v1beta1.MsgSubmitEvidence", + value: MsgSubmitEvidence.toJSON(value) + }; + } + }, + fromJSON: { + submitEvidence(value: any) { + return { + typeUrl: "/cosmos.evidence.v1beta1.MsgSubmitEvidence", + value: MsgSubmitEvidence.fromJSON(value) + }; + } + }, + fromPartial: { + submitEvidence(value: MsgSubmitEvidence) { + return { + typeUrl: "/cosmos.evidence.v1beta1.MsgSubmitEvidence", + value: MsgSubmitEvidence.fromPartial(value) + }; + } + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/evidence/v1beta1/tx.rpc.func.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/evidence/v1beta1/tx.rpc.func.ts new file mode 100644 index 0000000000..2d622b6e9c --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/evidence/v1beta1/tx.rpc.func.ts @@ -0,0 +1,13 @@ +import { buildTx, SigningClientResolver } from "../../../helper-func-types"; +import { buildUseMutation } from "../../../react-query"; +import { toEncoders, toConverters } from "@interchainjs/cosmos/utils"; +import { MsgSubmitEvidence } from "./tx"; +export const createSubmitEvidence = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgSubmitEvidence.typeUrl, + encoders: toEncoders(MsgSubmitEvidence), + converters: toConverters(MsgSubmitEvidence) +}); +export const useSubmitEvidence = buildUseMutation({ + builderMutationFn: createSubmitEvidence +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/evidence/v1beta1/tx.rpc.msg.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/evidence/v1beta1/tx.rpc.msg.ts new file mode 100644 index 0000000000..b4f8d1e215 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/evidence/v1beta1/tx.rpc.msg.ts @@ -0,0 +1,27 @@ +import { Any, AnySDKType } from "../../../google/protobuf/any.js"; +import { Rpc } from "../../../helpers.js"; +import { BinaryReader } from "../../../binary.js"; +import { MsgSubmitEvidence, MsgSubmitEvidenceSDKType, MsgSubmitEvidenceResponse, MsgSubmitEvidenceResponseSDKType } from "./tx.js"; +/** Msg defines the evidence Msg service. */ +export interface Msg { + /** + * SubmitEvidence submits an arbitrary Evidence of misbehavior such as equivocation or + * counterfactual signing. + */ + submitEvidence(request: MsgSubmitEvidence): Promise; +} +export class MsgClientImpl implements Msg { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + this.submitEvidence = this.submitEvidence.bind(this); + } + submitEvidence(request: MsgSubmitEvidence): Promise { + const data = MsgSubmitEvidence.encode(request).finish(); + const promise = this.rpc.request("cosmos.evidence.v1beta1.Msg", "SubmitEvidence", data); + return promise.then(data => MsgSubmitEvidenceResponse.decode(new BinaryReader(data))); + } +} +export const createClientImpl = (rpc: Rpc) => { + return new MsgClientImpl(rpc); +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/evidence/v1beta1/tx.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/evidence/v1beta1/tx.ts new file mode 100644 index 0000000000..ba89cf9236 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/evidence/v1beta1/tx.ts @@ -0,0 +1,245 @@ +import { Any, AnySDKType } from "../../../google/protobuf/any.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial, bytesFromBase64, base64FromBytes } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "cosmos.evidence.v1beta1"; +/** + * MsgSubmitEvidence represents a message that supports submitting arbitrary + * Evidence of misbehavior such as equivocation or counterfactual signing. + */ +export interface MsgSubmitEvidence { + submitter: string; + evidence?: Any; +} +export interface MsgSubmitEvidenceProtoMsg { + typeUrl: "/cosmos.evidence.v1beta1.MsgSubmitEvidence"; + value: Uint8Array; +} +/** + * MsgSubmitEvidence represents a message that supports submitting arbitrary + * Evidence of misbehavior such as equivocation or counterfactual signing. + */ +export interface MsgSubmitEvidenceSDKType { + submitter: string; + evidence?: AnySDKType; +} +/** MsgSubmitEvidenceResponse defines the Msg/SubmitEvidence response type. */ +export interface MsgSubmitEvidenceResponse { + /** hash defines the hash of the evidence. */ + hash: Uint8Array; +} +export interface MsgSubmitEvidenceResponseProtoMsg { + typeUrl: "/cosmos.evidence.v1beta1.MsgSubmitEvidenceResponse"; + value: Uint8Array; +} +/** MsgSubmitEvidenceResponse defines the Msg/SubmitEvidence response type. */ +export interface MsgSubmitEvidenceResponseSDKType { + hash: Uint8Array; +} +function createBaseMsgSubmitEvidence(): MsgSubmitEvidence { + return { + submitter: "", + evidence: undefined + }; +} +export const MsgSubmitEvidence = { + typeUrl: "/cosmos.evidence.v1beta1.MsgSubmitEvidence", + encode(message: MsgSubmitEvidence, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.submitter !== undefined) { + writer.uint32(10).string(message.submitter); + } + if (message.evidence !== undefined) { + Any.encode(message.evidence, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgSubmitEvidence { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgSubmitEvidence(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.submitter = reader.string(); + break; + case 2: + message.evidence = Any.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgSubmitEvidence { + const obj = createBaseMsgSubmitEvidence(); + if (isSet(object.submitter)) obj.submitter = String(object.submitter); + if (isSet(object.evidence)) obj.evidence = Any.fromJSON(object.evidence); + return obj; + }, + toJSON(message: MsgSubmitEvidence): JsonSafe { + const obj: any = {}; + message.submitter !== undefined && (obj.submitter = message.submitter); + message.evidence !== undefined && (obj.evidence = message.evidence ? Any.toJSON(message.evidence) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): MsgSubmitEvidence { + const message = createBaseMsgSubmitEvidence(); + message.submitter = object.submitter ?? ""; + if (object.evidence !== undefined && object.evidence !== null) { + message.evidence = Any.fromPartial(object.evidence); + } + return message; + }, + fromSDK(object: MsgSubmitEvidenceSDKType): MsgSubmitEvidence { + return { + submitter: object?.submitter, + evidence: object.evidence ? Any.fromSDK(object.evidence) : undefined + }; + }, + fromSDKJSON(object: any): MsgSubmitEvidenceSDKType { + return { + submitter: isSet(object.submitter) ? String(object.submitter) : "", + evidence: isSet(object.evidence) ? Any.fromSDKJSON(object.evidence) : undefined + }; + }, + toSDK(message: MsgSubmitEvidence): MsgSubmitEvidenceSDKType { + const obj: any = {}; + obj.submitter = message.submitter; + message.evidence !== undefined && (obj.evidence = message.evidence ? Any.toSDK(message.evidence) : undefined); + return obj; + }, + fromAmino(object: MsgSubmitEvidenceAmino): MsgSubmitEvidence { + const message = createBaseMsgSubmitEvidence(); + if (object.submitter !== undefined && object.submitter !== null) { + message.submitter = object.submitter; + } + if (object.evidence !== undefined && object.evidence !== null) { + message.evidence = Any.fromAmino(object.evidence); + } + return message; + }, + toAmino(message: MsgSubmitEvidence): MsgSubmitEvidenceAmino { + const obj: any = {}; + obj.submitter = message.submitter === "" ? undefined : message.submitter; + obj.evidence = message.evidence ? Any.toAmino(message.evidence) : undefined; + return obj; + }, + fromAminoMsg(object: MsgSubmitEvidenceAminoMsg): MsgSubmitEvidence { + return MsgSubmitEvidence.fromAmino(object.value); + }, + toAminoMsg(message: MsgSubmitEvidence): MsgSubmitEvidenceAminoMsg { + return { + type: "cosmos-sdk/MsgSubmitEvidence", + value: MsgSubmitEvidence.toAmino(message) + }; + }, + fromProtoMsg(message: MsgSubmitEvidenceProtoMsg): MsgSubmitEvidence { + return MsgSubmitEvidence.decode(message.value); + }, + toProto(message: MsgSubmitEvidence): Uint8Array { + return MsgSubmitEvidence.encode(message).finish(); + }, + toProtoMsg(message: MsgSubmitEvidence): MsgSubmitEvidenceProtoMsg { + return { + typeUrl: "/cosmos.evidence.v1beta1.MsgSubmitEvidence", + value: MsgSubmitEvidence.encode(message).finish() + }; + } +}; +function createBaseMsgSubmitEvidenceResponse(): MsgSubmitEvidenceResponse { + return { + hash: new Uint8Array() + }; +} +export const MsgSubmitEvidenceResponse = { + typeUrl: "/cosmos.evidence.v1beta1.MsgSubmitEvidenceResponse", + encode(message: MsgSubmitEvidenceResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.hash.length !== 0) { + writer.uint32(34).bytes(message.hash); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgSubmitEvidenceResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgSubmitEvidenceResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 4: + message.hash = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgSubmitEvidenceResponse { + const obj = createBaseMsgSubmitEvidenceResponse(); + if (isSet(object.hash)) obj.hash = bytesFromBase64(object.hash); + return obj; + }, + toJSON(message: MsgSubmitEvidenceResponse): JsonSafe { + const obj: any = {}; + message.hash !== undefined && (obj.hash = base64FromBytes(message.hash !== undefined ? message.hash : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): MsgSubmitEvidenceResponse { + const message = createBaseMsgSubmitEvidenceResponse(); + message.hash = object.hash ?? new Uint8Array(); + return message; + }, + fromSDK(object: MsgSubmitEvidenceResponseSDKType): MsgSubmitEvidenceResponse { + return { + hash: object?.hash + }; + }, + fromSDKJSON(object: any): MsgSubmitEvidenceResponseSDKType { + return { + hash: isSet(object.hash) ? bytesFromBase64(object.hash) : new Uint8Array() + }; + }, + toSDK(message: MsgSubmitEvidenceResponse): MsgSubmitEvidenceResponseSDKType { + const obj: any = {}; + obj.hash = message.hash; + return obj; + }, + fromAmino(object: MsgSubmitEvidenceResponseAmino): MsgSubmitEvidenceResponse { + const message = createBaseMsgSubmitEvidenceResponse(); + if (object.hash !== undefined && object.hash !== null) { + message.hash = bytesFromBase64(object.hash); + } + return message; + }, + toAmino(message: MsgSubmitEvidenceResponse): MsgSubmitEvidenceResponseAmino { + const obj: any = {}; + obj.hash = message.hash ? base64FromBytes(message.hash) : undefined; + return obj; + }, + fromAminoMsg(object: MsgSubmitEvidenceResponseAminoMsg): MsgSubmitEvidenceResponse { + return MsgSubmitEvidenceResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgSubmitEvidenceResponse): MsgSubmitEvidenceResponseAminoMsg { + return { + type: "cosmos-sdk/MsgSubmitEvidenceResponse", + value: MsgSubmitEvidenceResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgSubmitEvidenceResponseProtoMsg): MsgSubmitEvidenceResponse { + return MsgSubmitEvidenceResponse.decode(message.value); + }, + toProto(message: MsgSubmitEvidenceResponse): Uint8Array { + return MsgSubmitEvidenceResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgSubmitEvidenceResponse): MsgSubmitEvidenceResponseProtoMsg { + return { + typeUrl: "/cosmos.evidence.v1beta1.MsgSubmitEvidenceResponse", + value: MsgSubmitEvidenceResponse.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/feegrant/v1beta1/feegrant.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/feegrant/v1beta1/feegrant.ts new file mode 100644 index 0000000000..6499a4e22c --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/feegrant/v1beta1/feegrant.ts @@ -0,0 +1,670 @@ +import { Coin, CoinSDKType } from "../../base/v1beta1/coin.js"; +import { Timestamp, TimestampSDKType } from "../../../google/protobuf/timestamp.js"; +import { Duration, DurationSDKType } from "../../../google/protobuf/duration.js"; +import { Any, AnySDKType } from "../../../google/protobuf/any.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { toTimestamp, fromTimestamp, isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "cosmos.feegrant.v1beta1"; +/** + * BasicAllowance implements Allowance with a one-time grant of tokens + * that optionally expires. The grantee can use up to SpendLimit to cover fees. + */ +export interface BasicAllowance { + /** + * spend_limit specifies the maximum amount of tokens that can be spent + * by this allowance and will be updated as tokens are spent. If it is + * empty, there is no spend limit and any amount of coins can be spent. + */ + spendLimit: Coin[]; + /** expiration specifies an optional time when this allowance expires */ + expiration?: Date; +} +export interface BasicAllowanceProtoMsg { + typeUrl: "/cosmos.feegrant.v1beta1.BasicAllowance"; + value: Uint8Array; +} +/** + * BasicAllowance implements Allowance with a one-time grant of tokens + * that optionally expires. The grantee can use up to SpendLimit to cover fees. + */ +export interface BasicAllowanceSDKType { + spend_limit: CoinSDKType[]; + expiration?: Date; +} +/** + * PeriodicAllowance extends Allowance to allow for both a maximum cap, + * as well as a limit per time period. + */ +export interface PeriodicAllowance { + /** basic specifies a struct of `BasicAllowance` */ + basic: BasicAllowance; + /** + * period specifies the time duration in which period_spend_limit coins can + * be spent before that allowance is reset + */ + period: Duration; + /** + * period_spend_limit specifies the maximum number of coins that can be spent + * in the period + */ + periodSpendLimit: Coin[]; + /** period_can_spend is the number of coins left to be spent before the period_reset time */ + periodCanSpend: Coin[]; + /** + * period_reset is the time at which this period resets and a new one begins, + * it is calculated from the start time of the first transaction after the + * last period ended + */ + periodReset: Date; +} +export interface PeriodicAllowanceProtoMsg { + typeUrl: "/cosmos.feegrant.v1beta1.PeriodicAllowance"; + value: Uint8Array; +} +/** + * PeriodicAllowance extends Allowance to allow for both a maximum cap, + * as well as a limit per time period. + */ +export interface PeriodicAllowanceSDKType { + basic: BasicAllowanceSDKType; + period: DurationSDKType; + period_spend_limit: CoinSDKType[]; + period_can_spend: CoinSDKType[]; + period_reset: Date; +} +/** AllowedMsgAllowance creates allowance only for specified message types. */ +export interface AllowedMsgAllowance { + /** allowance can be any of basic and periodic fee allowance. */ + allowance?: Any; + /** allowed_messages are the messages for which the grantee has the access. */ + allowedMessages: string[]; +} +export interface AllowedMsgAllowanceProtoMsg { + typeUrl: "/cosmos.feegrant.v1beta1.AllowedMsgAllowance"; + value: Uint8Array; +} +/** AllowedMsgAllowance creates allowance only for specified message types. */ +export interface AllowedMsgAllowanceSDKType { + allowance?: AnySDKType; + allowed_messages: string[]; +} +/** Grant is stored in the KVStore to record a grant with full context */ +export interface Grant { + /** granter is the address of the user granting an allowance of their funds. */ + granter: string; + /** grantee is the address of the user being granted an allowance of another user's funds. */ + grantee: string; + /** allowance can be any of basic, periodic, allowed fee allowance. */ + allowance?: Any; +} +export interface GrantProtoMsg { + typeUrl: "/cosmos.feegrant.v1beta1.Grant"; + value: Uint8Array; +} +/** Grant is stored in the KVStore to record a grant with full context */ +export interface GrantSDKType { + granter: string; + grantee: string; + allowance?: AnySDKType; +} +function createBaseBasicAllowance(): BasicAllowance { + return { + spendLimit: [], + expiration: undefined + }; +} +export const BasicAllowance = { + typeUrl: "/cosmos.feegrant.v1beta1.BasicAllowance", + encode(message: BasicAllowance, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.spendLimit) { + Coin.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.expiration !== undefined) { + Timestamp.encode(toTimestamp(message.expiration), writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): BasicAllowance { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseBasicAllowance(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.spendLimit.push(Coin.decode(reader, reader.uint32())); + break; + case 2: + message.expiration = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): BasicAllowance { + const obj = createBaseBasicAllowance(); + if (Array.isArray(object?.spendLimit)) obj.spendLimit = object.spendLimit.map((e: any) => Coin.fromJSON(e)); + if (isSet(object.expiration)) obj.expiration = new Date(object.expiration); + return obj; + }, + toJSON(message: BasicAllowance): JsonSafe { + const obj: any = {}; + if (message.spendLimit) { + obj.spendLimit = message.spendLimit.map(e => e ? Coin.toJSON(e) : undefined); + } else { + obj.spendLimit = []; + } + message.expiration !== undefined && (obj.expiration = message.expiration.toISOString()); + return obj; + }, + fromPartial(object: DeepPartial): BasicAllowance { + const message = createBaseBasicAllowance(); + message.spendLimit = object.spendLimit?.map(e => Coin.fromPartial(e)) || []; + message.expiration = object.expiration ?? undefined; + return message; + }, + fromSDK(object: BasicAllowanceSDKType): BasicAllowance { + return { + spendLimit: Array.isArray(object?.spend_limit) ? object.spend_limit.map((e: any) => Coin.fromSDK(e)) : [], + expiration: object.expiration ?? undefined + }; + }, + fromSDKJSON(object: any): BasicAllowanceSDKType { + return { + spend_limit: Array.isArray(object?.spend_limit) ? object.spend_limit.map((e: any) => Coin.fromSDKJSON(e)) : [], + expiration: isSet(object.expiration) ? new Date(object.expiration) : undefined + }; + }, + toSDK(message: BasicAllowance): BasicAllowanceSDKType { + const obj: any = {}; + if (message.spendLimit) { + obj.spend_limit = message.spendLimit.map(e => e ? Coin.toSDK(e) : undefined); + } else { + obj.spend_limit = []; + } + message.expiration !== undefined && (obj.expiration = message.expiration ?? undefined); + return obj; + }, + fromAmino(object: BasicAllowanceAmino): BasicAllowance { + const message = createBaseBasicAllowance(); + message.spendLimit = object.spend_limit?.map(e => Coin.fromAmino(e)) || []; + if (object.expiration !== undefined && object.expiration !== null) { + message.expiration = fromTimestamp(Timestamp.fromAmino(object.expiration)); + } + return message; + }, + toAmino(message: BasicAllowance): BasicAllowanceAmino { + const obj: any = {}; + if (message.spendLimit) { + obj.spend_limit = message.spendLimit.map(e => e ? Coin.toAmino(e) : undefined); + } else { + obj.spend_limit = message.spendLimit; + } + obj.expiration = message.expiration ? Timestamp.toAmino(toTimestamp(message.expiration)) : undefined; + return obj; + }, + fromAminoMsg(object: BasicAllowanceAminoMsg): BasicAllowance { + return BasicAllowance.fromAmino(object.value); + }, + toAminoMsg(message: BasicAllowance): BasicAllowanceAminoMsg { + return { + type: "cosmos-sdk/BasicAllowance", + value: BasicAllowance.toAmino(message) + }; + }, + fromProtoMsg(message: BasicAllowanceProtoMsg): BasicAllowance { + return BasicAllowance.decode(message.value); + }, + toProto(message: BasicAllowance): Uint8Array { + return BasicAllowance.encode(message).finish(); + }, + toProtoMsg(message: BasicAllowance): BasicAllowanceProtoMsg { + return { + typeUrl: "/cosmos.feegrant.v1beta1.BasicAllowance", + value: BasicAllowance.encode(message).finish() + }; + } +}; +function createBasePeriodicAllowance(): PeriodicAllowance { + return { + basic: BasicAllowance.fromPartial({}), + period: Duration.fromPartial({}), + periodSpendLimit: [], + periodCanSpend: [], + periodReset: new Date() + }; +} +export const PeriodicAllowance = { + typeUrl: "/cosmos.feegrant.v1beta1.PeriodicAllowance", + encode(message: PeriodicAllowance, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.basic !== undefined) { + BasicAllowance.encode(message.basic, writer.uint32(10).fork()).ldelim(); + } + if (message.period !== undefined) { + Duration.encode(message.period, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.periodSpendLimit) { + Coin.encode(v!, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.periodCanSpend) { + Coin.encode(v!, writer.uint32(34).fork()).ldelim(); + } + if (message.periodReset !== undefined) { + Timestamp.encode(toTimestamp(message.periodReset), writer.uint32(42).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): PeriodicAllowance { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBasePeriodicAllowance(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.basic = BasicAllowance.decode(reader, reader.uint32()); + break; + case 2: + message.period = Duration.decode(reader, reader.uint32()); + break; + case 3: + message.periodSpendLimit.push(Coin.decode(reader, reader.uint32())); + break; + case 4: + message.periodCanSpend.push(Coin.decode(reader, reader.uint32())); + break; + case 5: + message.periodReset = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): PeriodicAllowance { + const obj = createBasePeriodicAllowance(); + if (isSet(object.basic)) obj.basic = BasicAllowance.fromJSON(object.basic); + if (isSet(object.period)) obj.period = Duration.fromJSON(object.period); + if (Array.isArray(object?.periodSpendLimit)) obj.periodSpendLimit = object.periodSpendLimit.map((e: any) => Coin.fromJSON(e)); + if (Array.isArray(object?.periodCanSpend)) obj.periodCanSpend = object.periodCanSpend.map((e: any) => Coin.fromJSON(e)); + if (isSet(object.periodReset)) obj.periodReset = new Date(object.periodReset); + return obj; + }, + toJSON(message: PeriodicAllowance): JsonSafe { + const obj: any = {}; + message.basic !== undefined && (obj.basic = message.basic ? BasicAllowance.toJSON(message.basic) : undefined); + message.period !== undefined && (obj.period = message.period ? Duration.toJSON(message.period) : undefined); + if (message.periodSpendLimit) { + obj.periodSpendLimit = message.periodSpendLimit.map(e => e ? Coin.toJSON(e) : undefined); + } else { + obj.periodSpendLimit = []; + } + if (message.periodCanSpend) { + obj.periodCanSpend = message.periodCanSpend.map(e => e ? Coin.toJSON(e) : undefined); + } else { + obj.periodCanSpend = []; + } + message.periodReset !== undefined && (obj.periodReset = message.periodReset.toISOString()); + return obj; + }, + fromPartial(object: DeepPartial): PeriodicAllowance { + const message = createBasePeriodicAllowance(); + if (object.basic !== undefined && object.basic !== null) { + message.basic = BasicAllowance.fromPartial(object.basic); + } + if (object.period !== undefined && object.period !== null) { + message.period = Duration.fromPartial(object.period); + } + message.periodSpendLimit = object.periodSpendLimit?.map(e => Coin.fromPartial(e)) || []; + message.periodCanSpend = object.periodCanSpend?.map(e => Coin.fromPartial(e)) || []; + message.periodReset = object.periodReset ?? undefined; + return message; + }, + fromSDK(object: PeriodicAllowanceSDKType): PeriodicAllowance { + return { + basic: object.basic ? BasicAllowance.fromSDK(object.basic) : undefined, + period: object.period ? Duration.fromSDK(object.period) : undefined, + periodSpendLimit: Array.isArray(object?.period_spend_limit) ? object.period_spend_limit.map((e: any) => Coin.fromSDK(e)) : [], + periodCanSpend: Array.isArray(object?.period_can_spend) ? object.period_can_spend.map((e: any) => Coin.fromSDK(e)) : [], + periodReset: object.period_reset ?? undefined + }; + }, + fromSDKJSON(object: any): PeriodicAllowanceSDKType { + return { + basic: isSet(object.basic) ? BasicAllowance.fromSDKJSON(object.basic) : undefined, + period: isSet(object.period) ? Duration.fromSDKJSON(object.period) : undefined, + period_spend_limit: Array.isArray(object?.period_spend_limit) ? object.period_spend_limit.map((e: any) => Coin.fromSDKJSON(e)) : [], + period_can_spend: Array.isArray(object?.period_can_spend) ? object.period_can_spend.map((e: any) => Coin.fromSDKJSON(e)) : [], + period_reset: isSet(object.period_reset) ? new Date(object.period_reset) : undefined + }; + }, + toSDK(message: PeriodicAllowance): PeriodicAllowanceSDKType { + const obj: any = {}; + message.basic !== undefined && (obj.basic = message.basic ? BasicAllowance.toSDK(message.basic) : undefined); + message.period !== undefined && (obj.period = message.period ? Duration.toSDK(message.period) : undefined); + if (message.periodSpendLimit) { + obj.period_spend_limit = message.periodSpendLimit.map(e => e ? Coin.toSDK(e) : undefined); + } else { + obj.period_spend_limit = []; + } + if (message.periodCanSpend) { + obj.period_can_spend = message.periodCanSpend.map(e => e ? Coin.toSDK(e) : undefined); + } else { + obj.period_can_spend = []; + } + message.periodReset !== undefined && (obj.period_reset = message.periodReset ?? undefined); + return obj; + }, + fromAmino(object: PeriodicAllowanceAmino): PeriodicAllowance { + const message = createBasePeriodicAllowance(); + if (object.basic !== undefined && object.basic !== null) { + message.basic = BasicAllowance.fromAmino(object.basic); + } + if (object.period !== undefined && object.period !== null) { + message.period = Duration.fromAmino(object.period); + } + message.periodSpendLimit = object.period_spend_limit?.map(e => Coin.fromAmino(e)) || []; + message.periodCanSpend = object.period_can_spend?.map(e => Coin.fromAmino(e)) || []; + if (object.period_reset !== undefined && object.period_reset !== null) { + message.periodReset = fromTimestamp(Timestamp.fromAmino(object.period_reset)); + } + return message; + }, + toAmino(message: PeriodicAllowance): PeriodicAllowanceAmino { + const obj: any = {}; + obj.basic = message.basic ? BasicAllowance.toAmino(message.basic) : undefined; + obj.period = message.period ? Duration.toAmino(message.period) : undefined; + if (message.periodSpendLimit) { + obj.period_spend_limit = message.periodSpendLimit.map(e => e ? Coin.toAmino(e) : undefined); + } else { + obj.period_spend_limit = message.periodSpendLimit; + } + if (message.periodCanSpend) { + obj.period_can_spend = message.periodCanSpend.map(e => e ? Coin.toAmino(e) : undefined); + } else { + obj.period_can_spend = message.periodCanSpend; + } + obj.period_reset = message.periodReset ? Timestamp.toAmino(toTimestamp(message.periodReset)) : undefined; + return obj; + }, + fromAminoMsg(object: PeriodicAllowanceAminoMsg): PeriodicAllowance { + return PeriodicAllowance.fromAmino(object.value); + }, + toAminoMsg(message: PeriodicAllowance): PeriodicAllowanceAminoMsg { + return { + type: "cosmos-sdk/PeriodicAllowance", + value: PeriodicAllowance.toAmino(message) + }; + }, + fromProtoMsg(message: PeriodicAllowanceProtoMsg): PeriodicAllowance { + return PeriodicAllowance.decode(message.value); + }, + toProto(message: PeriodicAllowance): Uint8Array { + return PeriodicAllowance.encode(message).finish(); + }, + toProtoMsg(message: PeriodicAllowance): PeriodicAllowanceProtoMsg { + return { + typeUrl: "/cosmos.feegrant.v1beta1.PeriodicAllowance", + value: PeriodicAllowance.encode(message).finish() + }; + } +}; +function createBaseAllowedMsgAllowance(): AllowedMsgAllowance { + return { + allowance: undefined, + allowedMessages: [] + }; +} +export const AllowedMsgAllowance = { + typeUrl: "/cosmos.feegrant.v1beta1.AllowedMsgAllowance", + encode(message: AllowedMsgAllowance, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.allowance !== undefined) { + Any.encode(message.allowance, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.allowedMessages) { + writer.uint32(18).string(v!); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): AllowedMsgAllowance { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseAllowedMsgAllowance(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.allowance = Any.decode(reader, reader.uint32()); + break; + case 2: + message.allowedMessages.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): AllowedMsgAllowance { + const obj = createBaseAllowedMsgAllowance(); + if (isSet(object.allowance)) obj.allowance = Any.fromJSON(object.allowance); + if (Array.isArray(object?.allowedMessages)) obj.allowedMessages = object.allowedMessages.map((e: any) => String(e)); + return obj; + }, + toJSON(message: AllowedMsgAllowance): JsonSafe { + const obj: any = {}; + message.allowance !== undefined && (obj.allowance = message.allowance ? Any.toJSON(message.allowance) : undefined); + if (message.allowedMessages) { + obj.allowedMessages = message.allowedMessages.map(e => e); + } else { + obj.allowedMessages = []; + } + return obj; + }, + fromPartial(object: DeepPartial): AllowedMsgAllowance { + const message = createBaseAllowedMsgAllowance(); + if (object.allowance !== undefined && object.allowance !== null) { + message.allowance = Any.fromPartial(object.allowance); + } + message.allowedMessages = object.allowedMessages?.map(e => e) || []; + return message; + }, + fromSDK(object: AllowedMsgAllowanceSDKType): AllowedMsgAllowance { + return { + allowance: object.allowance ? Any.fromSDK(object.allowance) : undefined, + allowedMessages: Array.isArray(object?.allowed_messages) ? object.allowed_messages.map((e: any) => e) : [] + }; + }, + fromSDKJSON(object: any): AllowedMsgAllowanceSDKType { + return { + allowance: isSet(object.allowance) ? Any.fromSDKJSON(object.allowance) : undefined, + allowed_messages: Array.isArray(object?.allowed_messages) ? object.allowed_messages.map((e: any) => String(e)) : [] + }; + }, + toSDK(message: AllowedMsgAllowance): AllowedMsgAllowanceSDKType { + const obj: any = {}; + message.allowance !== undefined && (obj.allowance = message.allowance ? Any.toSDK(message.allowance) : undefined); + if (message.allowedMessages) { + obj.allowed_messages = message.allowedMessages.map(e => e); + } else { + obj.allowed_messages = []; + } + return obj; + }, + fromAmino(object: AllowedMsgAllowanceAmino): AllowedMsgAllowance { + const message = createBaseAllowedMsgAllowance(); + if (object.allowance !== undefined && object.allowance !== null) { + message.allowance = Any.fromAmino(object.allowance); + } + message.allowedMessages = object.allowed_messages?.map(e => e) || []; + return message; + }, + toAmino(message: AllowedMsgAllowance): AllowedMsgAllowanceAmino { + const obj: any = {}; + obj.allowance = message.allowance ? Any.toAmino(message.allowance) : undefined; + if (message.allowedMessages) { + obj.allowed_messages = message.allowedMessages.map(e => e); + } else { + obj.allowed_messages = message.allowedMessages; + } + return obj; + }, + fromAminoMsg(object: AllowedMsgAllowanceAminoMsg): AllowedMsgAllowance { + return AllowedMsgAllowance.fromAmino(object.value); + }, + toAminoMsg(message: AllowedMsgAllowance): AllowedMsgAllowanceAminoMsg { + return { + type: "cosmos-sdk/AllowedMsgAllowance", + value: AllowedMsgAllowance.toAmino(message) + }; + }, + fromProtoMsg(message: AllowedMsgAllowanceProtoMsg): AllowedMsgAllowance { + return AllowedMsgAllowance.decode(message.value); + }, + toProto(message: AllowedMsgAllowance): Uint8Array { + return AllowedMsgAllowance.encode(message).finish(); + }, + toProtoMsg(message: AllowedMsgAllowance): AllowedMsgAllowanceProtoMsg { + return { + typeUrl: "/cosmos.feegrant.v1beta1.AllowedMsgAllowance", + value: AllowedMsgAllowance.encode(message).finish() + }; + } +}; +function createBaseGrant(): Grant { + return { + granter: "", + grantee: "", + allowance: undefined + }; +} +export const Grant = { + typeUrl: "/cosmos.feegrant.v1beta1.Grant", + encode(message: Grant, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.granter !== undefined) { + writer.uint32(10).string(message.granter); + } + if (message.grantee !== undefined) { + writer.uint32(18).string(message.grantee); + } + if (message.allowance !== undefined) { + Any.encode(message.allowance, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Grant { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGrant(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.granter = reader.string(); + break; + case 2: + message.grantee = reader.string(); + break; + case 3: + message.allowance = Any.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Grant { + const obj = createBaseGrant(); + if (isSet(object.granter)) obj.granter = String(object.granter); + if (isSet(object.grantee)) obj.grantee = String(object.grantee); + if (isSet(object.allowance)) obj.allowance = Any.fromJSON(object.allowance); + return obj; + }, + toJSON(message: Grant): JsonSafe { + const obj: any = {}; + message.granter !== undefined && (obj.granter = message.granter); + message.grantee !== undefined && (obj.grantee = message.grantee); + message.allowance !== undefined && (obj.allowance = message.allowance ? Any.toJSON(message.allowance) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): Grant { + const message = createBaseGrant(); + message.granter = object.granter ?? ""; + message.grantee = object.grantee ?? ""; + if (object.allowance !== undefined && object.allowance !== null) { + message.allowance = Any.fromPartial(object.allowance); + } + return message; + }, + fromSDK(object: GrantSDKType): Grant { + return { + granter: object?.granter, + grantee: object?.grantee, + allowance: object.allowance ? Any.fromSDK(object.allowance) : undefined + }; + }, + fromSDKJSON(object: any): GrantSDKType { + return { + granter: isSet(object.granter) ? String(object.granter) : "", + grantee: isSet(object.grantee) ? String(object.grantee) : "", + allowance: isSet(object.allowance) ? Any.fromSDKJSON(object.allowance) : undefined + }; + }, + toSDK(message: Grant): GrantSDKType { + const obj: any = {}; + obj.granter = message.granter; + obj.grantee = message.grantee; + message.allowance !== undefined && (obj.allowance = message.allowance ? Any.toSDK(message.allowance) : undefined); + return obj; + }, + fromAmino(object: GrantAmino): Grant { + const message = createBaseGrant(); + if (object.granter !== undefined && object.granter !== null) { + message.granter = object.granter; + } + if (object.grantee !== undefined && object.grantee !== null) { + message.grantee = object.grantee; + } + if (object.allowance !== undefined && object.allowance !== null) { + message.allowance = Any.fromAmino(object.allowance); + } + return message; + }, + toAmino(message: Grant): GrantAmino { + const obj: any = {}; + obj.granter = message.granter === "" ? undefined : message.granter; + obj.grantee = message.grantee === "" ? undefined : message.grantee; + obj.allowance = message.allowance ? Any.toAmino(message.allowance) : undefined; + return obj; + }, + fromAminoMsg(object: GrantAminoMsg): Grant { + return Grant.fromAmino(object.value); + }, + toAminoMsg(message: Grant): GrantAminoMsg { + return { + type: "cosmos-sdk/Grant", + value: Grant.toAmino(message) + }; + }, + fromProtoMsg(message: GrantProtoMsg): Grant { + return Grant.decode(message.value); + }, + toProto(message: Grant): Uint8Array { + return Grant.encode(message).finish(); + }, + toProtoMsg(message: Grant): GrantProtoMsg { + return { + typeUrl: "/cosmos.feegrant.v1beta1.Grant", + value: Grant.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/feegrant/v1beta1/genesis.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/feegrant/v1beta1/genesis.ts new file mode 100644 index 0000000000..9befff2814 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/feegrant/v1beta1/genesis.ts @@ -0,0 +1,121 @@ +import { Grant, GrantSDKType } from "./feegrant.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { JsonSafe } from "../../../json-safe.js"; +import { DeepPartial } from "../../../helpers.js"; +export const protobufPackage = "cosmos.feegrant.v1beta1"; +/** GenesisState contains a set of fee allowances, persisted from the store */ +export interface GenesisState { + allowances: Grant[]; +} +export interface GenesisStateProtoMsg { + typeUrl: "/cosmos.feegrant.v1beta1.GenesisState"; + value: Uint8Array; +} +/** GenesisState contains a set of fee allowances, persisted from the store */ +export interface GenesisStateSDKType { + allowances: GrantSDKType[]; +} +function createBaseGenesisState(): GenesisState { + return { + allowances: [] + }; +} +export const GenesisState = { + typeUrl: "/cosmos.feegrant.v1beta1.GenesisState", + encode(message: GenesisState, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.allowances) { + Grant.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GenesisState { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGenesisState(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.allowances.push(Grant.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GenesisState { + const obj = createBaseGenesisState(); + if (Array.isArray(object?.allowances)) obj.allowances = object.allowances.map((e: any) => Grant.fromJSON(e)); + return obj; + }, + toJSON(message: GenesisState): JsonSafe { + const obj: any = {}; + if (message.allowances) { + obj.allowances = message.allowances.map(e => e ? Grant.toJSON(e) : undefined); + } else { + obj.allowances = []; + } + return obj; + }, + fromPartial(object: DeepPartial): GenesisState { + const message = createBaseGenesisState(); + message.allowances = object.allowances?.map(e => Grant.fromPartial(e)) || []; + return message; + }, + fromSDK(object: GenesisStateSDKType): GenesisState { + return { + allowances: Array.isArray(object?.allowances) ? object.allowances.map((e: any) => Grant.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): GenesisStateSDKType { + return { + allowances: Array.isArray(object?.allowances) ? object.allowances.map((e: any) => Grant.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: GenesisState): GenesisStateSDKType { + const obj: any = {}; + if (message.allowances) { + obj.allowances = message.allowances.map(e => e ? Grant.toSDK(e) : undefined); + } else { + obj.allowances = []; + } + return obj; + }, + fromAmino(object: GenesisStateAmino): GenesisState { + const message = createBaseGenesisState(); + message.allowances = object.allowances?.map(e => Grant.fromAmino(e)) || []; + return message; + }, + toAmino(message: GenesisState): GenesisStateAmino { + const obj: any = {}; + if (message.allowances) { + obj.allowances = message.allowances.map(e => e ? Grant.toAmino(e) : undefined); + } else { + obj.allowances = message.allowances; + } + return obj; + }, + fromAminoMsg(object: GenesisStateAminoMsg): GenesisState { + return GenesisState.fromAmino(object.value); + }, + toAminoMsg(message: GenesisState): GenesisStateAminoMsg { + return { + type: "cosmos-sdk/GenesisState", + value: GenesisState.toAmino(message) + }; + }, + fromProtoMsg(message: GenesisStateProtoMsg): GenesisState { + return GenesisState.decode(message.value); + }, + toProto(message: GenesisState): Uint8Array { + return GenesisState.encode(message).finish(); + }, + toProtoMsg(message: GenesisState): GenesisStateProtoMsg { + return { + typeUrl: "/cosmos.feegrant.v1beta1.GenesisState", + value: GenesisState.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/feegrant/v1beta1/query.lcd.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/feegrant/v1beta1/query.lcd.ts new file mode 100644 index 0000000000..0a922871b4 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/feegrant/v1beta1/query.lcd.ts @@ -0,0 +1,46 @@ +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../base/query/v1beta1/pagination.js"; +import { Grant, GrantSDKType } from "./feegrant.js"; +import { setPaginationParams } from "../../../helpers.js"; +import { LCDClient } from "@cosmology/lcd"; +import { QueryAllowanceRequest, QueryAllowanceRequestSDKType, QueryAllowanceResponse, QueryAllowanceResponseSDKType, QueryAllowancesRequest, QueryAllowancesRequestSDKType, QueryAllowancesResponse, QueryAllowancesResponseSDKType, QueryAllowancesByGranterRequest, QueryAllowancesByGranterRequestSDKType, QueryAllowancesByGranterResponse, QueryAllowancesByGranterResponseSDKType } from "./query.js"; +export class LCDQueryClient { + req: LCDClient; + constructor({ + requestClient + }: { + requestClient: LCDClient; + }) { + this.req = requestClient; + this.allowance = this.allowance.bind(this); + this.allowances = this.allowances.bind(this); + this.allowancesByGranter = this.allowancesByGranter.bind(this); + } + /* Allowance returns fee granted to the grantee by the granter. */ + async allowance(params: QueryAllowanceRequest): Promise { + const endpoint = `cosmos/feegrant/v1beta1/allowance/${params.granter}/${params.grantee}`; + return QueryAllowanceResponse.fromSDKJSON(await this.req.get(endpoint)); + } + /* Allowances returns all the grants for address. */ + async allowances(params: QueryAllowancesRequest): Promise { + const options: any = { + params: {} + }; + if (typeof params?.pagination !== "undefined") { + setPaginationParams(options, params.pagination); + } + const endpoint = `cosmos/feegrant/v1beta1/allowances/${params.grantee}`; + return QueryAllowancesResponse.fromSDKJSON(await this.req.get(endpoint, options)); + } + /* AllowancesByGranter returns all the grants given by an address + Since v0.46 */ + async allowancesByGranter(params: QueryAllowancesByGranterRequest): Promise { + const options: any = { + params: {} + }; + if (typeof params?.pagination !== "undefined") { + setPaginationParams(options, params.pagination); + } + const endpoint = `cosmos/feegrant/v1beta1/issued/${params.granter}`; + return QueryAllowancesByGranterResponse.fromSDKJSON(await this.req.get(endpoint, options)); + } +} \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/feegrant/v1beta1/query.rpc.Query.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/feegrant/v1beta1/query.rpc.Query.ts new file mode 100644 index 0000000000..ce3428cbd6 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/feegrant/v1beta1/query.rpc.Query.ts @@ -0,0 +1,57 @@ +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../base/query/v1beta1/pagination.js"; +import { Grant, GrantSDKType } from "./feegrant.js"; +import { Rpc } from "../../../helpers.js"; +import { BinaryReader } from "../../../binary.js"; +import { QueryClient, createProtobufRpcClient } from "@cosmjs/stargate"; +import { QueryAllowanceRequest, QueryAllowanceRequestSDKType, QueryAllowanceResponse, QueryAllowanceResponseSDKType, QueryAllowancesRequest, QueryAllowancesRequestSDKType, QueryAllowancesResponse, QueryAllowancesResponseSDKType, QueryAllowancesByGranterRequest, QueryAllowancesByGranterRequestSDKType, QueryAllowancesByGranterResponse, QueryAllowancesByGranterResponseSDKType } from "./query.js"; +/** Query defines the gRPC querier service. */ +export interface Query { + /** Allowance returns fee granted to the grantee by the granter. */ + allowance(request: QueryAllowanceRequest): Promise; + /** Allowances returns all the grants for address. */ + allowances(request: QueryAllowancesRequest): Promise; + /** + * AllowancesByGranter returns all the grants given by an address + * Since v0.46 + */ + allowancesByGranter(request: QueryAllowancesByGranterRequest): Promise; +} +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + this.allowance = this.allowance.bind(this); + this.allowances = this.allowances.bind(this); + this.allowancesByGranter = this.allowancesByGranter.bind(this); + } + allowance(request: QueryAllowanceRequest): Promise { + const data = QueryAllowanceRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.feegrant.v1beta1.Query", "Allowance", data); + return promise.then(data => QueryAllowanceResponse.decode(new BinaryReader(data))); + } + allowances(request: QueryAllowancesRequest): Promise { + const data = QueryAllowancesRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.feegrant.v1beta1.Query", "Allowances", data); + return promise.then(data => QueryAllowancesResponse.decode(new BinaryReader(data))); + } + allowancesByGranter(request: QueryAllowancesByGranterRequest): Promise { + const data = QueryAllowancesByGranterRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.feegrant.v1beta1.Query", "AllowancesByGranter", data); + return promise.then(data => QueryAllowancesByGranterResponse.decode(new BinaryReader(data))); + } +} +export const createRpcQueryExtension = (base: QueryClient) => { + const rpc = createProtobufRpcClient(base); + const queryService = new QueryClientImpl(rpc); + return { + allowance(request: QueryAllowanceRequest): Promise { + return queryService.allowance(request); + }, + allowances(request: QueryAllowancesRequest): Promise { + return queryService.allowances(request); + }, + allowancesByGranter(request: QueryAllowancesByGranterRequest): Promise { + return queryService.allowancesByGranter(request); + } + }; +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/feegrant/v1beta1/query.rpc.func.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/feegrant/v1beta1/query.rpc.func.ts new file mode 100644 index 0000000000..a4bb5dfa12 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/feegrant/v1beta1/query.rpc.func.ts @@ -0,0 +1,36 @@ +import { RpcResolver, buildQuery } from "../../../helper-func-types"; +import { buildUseQuery } from "../../../react-query"; +import { QueryAllowanceRequest, QueryAllowanceResponse, QueryAllowancesRequest, QueryAllowancesResponse, QueryAllowancesByGranterRequest, QueryAllowancesByGranterResponse } from "./query"; +export const createGetAllowance = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryAllowanceRequest.encode, + decode: QueryAllowanceResponse.decode, + service: "cosmos.feegrant.v1beta1.Query", + method: "Allowance", + getRpcInstance: getRpcInstance +}); +export const useGetAllowance = buildUseQuery({ + builderQueryFn: createGetAllowance, + queryKeyPrefix: "AllowanceQuery" +}); +export const createGetAllowances = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryAllowancesRequest.encode, + decode: QueryAllowancesResponse.decode, + service: "cosmos.feegrant.v1beta1.Query", + method: "Allowances", + getRpcInstance: getRpcInstance +}); +export const useGetAllowances = buildUseQuery({ + builderQueryFn: createGetAllowances, + queryKeyPrefix: "AllowancesQuery" +}); +export const createGetAllowancesByGranter = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryAllowancesByGranterRequest.encode, + decode: QueryAllowancesByGranterResponse.decode, + service: "cosmos.feegrant.v1beta1.Query", + method: "AllowancesByGranter", + getRpcInstance: getRpcInstance +}); +export const useGetAllowancesByGranter = buildUseQuery({ + builderQueryFn: createGetAllowancesByGranter, + queryKeyPrefix: "AllowancesByGranterQuery" +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/feegrant/v1beta1/query.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/feegrant/v1beta1/query.ts new file mode 100644 index 0000000000..73dae7790c --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/feegrant/v1beta1/query.ts @@ -0,0 +1,776 @@ +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../base/query/v1beta1/pagination.js"; +import { Grant, GrantSDKType } from "./feegrant.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "cosmos.feegrant.v1beta1"; +/** QueryAllowanceRequest is the request type for the Query/Allowance RPC method. */ +export interface QueryAllowanceRequest { + /** granter is the address of the user granting an allowance of their funds. */ + granter: string; + /** grantee is the address of the user being granted an allowance of another user's funds. */ + grantee: string; +} +export interface QueryAllowanceRequestProtoMsg { + typeUrl: "/cosmos.feegrant.v1beta1.QueryAllowanceRequest"; + value: Uint8Array; +} +/** QueryAllowanceRequest is the request type for the Query/Allowance RPC method. */ +export interface QueryAllowanceRequestSDKType { + granter: string; + grantee: string; +} +/** QueryAllowanceResponse is the response type for the Query/Allowance RPC method. */ +export interface QueryAllowanceResponse { + /** allowance is a allowance granted for grantee by granter. */ + allowance?: Grant; +} +export interface QueryAllowanceResponseProtoMsg { + typeUrl: "/cosmos.feegrant.v1beta1.QueryAllowanceResponse"; + value: Uint8Array; +} +/** QueryAllowanceResponse is the response type for the Query/Allowance RPC method. */ +export interface QueryAllowanceResponseSDKType { + allowance?: GrantSDKType; +} +/** QueryAllowancesRequest is the request type for the Query/Allowances RPC method. */ +export interface QueryAllowancesRequest { + grantee: string; + /** pagination defines an pagination for the request. */ + pagination?: PageRequest; +} +export interface QueryAllowancesRequestProtoMsg { + typeUrl: "/cosmos.feegrant.v1beta1.QueryAllowancesRequest"; + value: Uint8Array; +} +/** QueryAllowancesRequest is the request type for the Query/Allowances RPC method. */ +export interface QueryAllowancesRequestSDKType { + grantee: string; + pagination?: PageRequestSDKType; +} +/** QueryAllowancesResponse is the response type for the Query/Allowances RPC method. */ +export interface QueryAllowancesResponse { + /** allowances are allowance's granted for grantee by granter. */ + allowances: Grant[]; + /** pagination defines an pagination for the response. */ + pagination?: PageResponse; +} +export interface QueryAllowancesResponseProtoMsg { + typeUrl: "/cosmos.feegrant.v1beta1.QueryAllowancesResponse"; + value: Uint8Array; +} +/** QueryAllowancesResponse is the response type for the Query/Allowances RPC method. */ +export interface QueryAllowancesResponseSDKType { + allowances: GrantSDKType[]; + pagination?: PageResponseSDKType; +} +/** QueryAllowancesByGranterRequest is the request type for the Query/AllowancesByGranter RPC method. */ +export interface QueryAllowancesByGranterRequest { + granter: string; + /** pagination defines an pagination for the request. */ + pagination?: PageRequest; +} +export interface QueryAllowancesByGranterRequestProtoMsg { + typeUrl: "/cosmos.feegrant.v1beta1.QueryAllowancesByGranterRequest"; + value: Uint8Array; +} +/** QueryAllowancesByGranterRequest is the request type for the Query/AllowancesByGranter RPC method. */ +export interface QueryAllowancesByGranterRequestSDKType { + granter: string; + pagination?: PageRequestSDKType; +} +/** QueryAllowancesByGranterResponse is the response type for the Query/AllowancesByGranter RPC method. */ +export interface QueryAllowancesByGranterResponse { + /** allowances that have been issued by the granter. */ + allowances: Grant[]; + /** pagination defines an pagination for the response. */ + pagination?: PageResponse; +} +export interface QueryAllowancesByGranterResponseProtoMsg { + typeUrl: "/cosmos.feegrant.v1beta1.QueryAllowancesByGranterResponse"; + value: Uint8Array; +} +/** QueryAllowancesByGranterResponse is the response type for the Query/AllowancesByGranter RPC method. */ +export interface QueryAllowancesByGranterResponseSDKType { + allowances: GrantSDKType[]; + pagination?: PageResponseSDKType; +} +function createBaseQueryAllowanceRequest(): QueryAllowanceRequest { + return { + granter: "", + grantee: "" + }; +} +export const QueryAllowanceRequest = { + typeUrl: "/cosmos.feegrant.v1beta1.QueryAllowanceRequest", + encode(message: QueryAllowanceRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.granter !== undefined) { + writer.uint32(10).string(message.granter); + } + if (message.grantee !== undefined) { + writer.uint32(18).string(message.grantee); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryAllowanceRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryAllowanceRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.granter = reader.string(); + break; + case 2: + message.grantee = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryAllowanceRequest { + const obj = createBaseQueryAllowanceRequest(); + if (isSet(object.granter)) obj.granter = String(object.granter); + if (isSet(object.grantee)) obj.grantee = String(object.grantee); + return obj; + }, + toJSON(message: QueryAllowanceRequest): JsonSafe { + const obj: any = {}; + message.granter !== undefined && (obj.granter = message.granter); + message.grantee !== undefined && (obj.grantee = message.grantee); + return obj; + }, + fromPartial(object: DeepPartial): QueryAllowanceRequest { + const message = createBaseQueryAllowanceRequest(); + message.granter = object.granter ?? ""; + message.grantee = object.grantee ?? ""; + return message; + }, + fromSDK(object: QueryAllowanceRequestSDKType): QueryAllowanceRequest { + return { + granter: object?.granter, + grantee: object?.grantee + }; + }, + fromSDKJSON(object: any): QueryAllowanceRequestSDKType { + return { + granter: isSet(object.granter) ? String(object.granter) : "", + grantee: isSet(object.grantee) ? String(object.grantee) : "" + }; + }, + toSDK(message: QueryAllowanceRequest): QueryAllowanceRequestSDKType { + const obj: any = {}; + obj.granter = message.granter; + obj.grantee = message.grantee; + return obj; + }, + fromAmino(object: QueryAllowanceRequestAmino): QueryAllowanceRequest { + const message = createBaseQueryAllowanceRequest(); + if (object.granter !== undefined && object.granter !== null) { + message.granter = object.granter; + } + if (object.grantee !== undefined && object.grantee !== null) { + message.grantee = object.grantee; + } + return message; + }, + toAmino(message: QueryAllowanceRequest): QueryAllowanceRequestAmino { + const obj: any = {}; + obj.granter = message.granter === "" ? undefined : message.granter; + obj.grantee = message.grantee === "" ? undefined : message.grantee; + return obj; + }, + fromAminoMsg(object: QueryAllowanceRequestAminoMsg): QueryAllowanceRequest { + return QueryAllowanceRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryAllowanceRequest): QueryAllowanceRequestAminoMsg { + return { + type: "cosmos-sdk/QueryAllowanceRequest", + value: QueryAllowanceRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryAllowanceRequestProtoMsg): QueryAllowanceRequest { + return QueryAllowanceRequest.decode(message.value); + }, + toProto(message: QueryAllowanceRequest): Uint8Array { + return QueryAllowanceRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryAllowanceRequest): QueryAllowanceRequestProtoMsg { + return { + typeUrl: "/cosmos.feegrant.v1beta1.QueryAllowanceRequest", + value: QueryAllowanceRequest.encode(message).finish() + }; + } +}; +function createBaseQueryAllowanceResponse(): QueryAllowanceResponse { + return { + allowance: undefined + }; +} +export const QueryAllowanceResponse = { + typeUrl: "/cosmos.feegrant.v1beta1.QueryAllowanceResponse", + encode(message: QueryAllowanceResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.allowance !== undefined) { + Grant.encode(message.allowance, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryAllowanceResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryAllowanceResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.allowance = Grant.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryAllowanceResponse { + const obj = createBaseQueryAllowanceResponse(); + if (isSet(object.allowance)) obj.allowance = Grant.fromJSON(object.allowance); + return obj; + }, + toJSON(message: QueryAllowanceResponse): JsonSafe { + const obj: any = {}; + message.allowance !== undefined && (obj.allowance = message.allowance ? Grant.toJSON(message.allowance) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryAllowanceResponse { + const message = createBaseQueryAllowanceResponse(); + if (object.allowance !== undefined && object.allowance !== null) { + message.allowance = Grant.fromPartial(object.allowance); + } + return message; + }, + fromSDK(object: QueryAllowanceResponseSDKType): QueryAllowanceResponse { + return { + allowance: object.allowance ? Grant.fromSDK(object.allowance) : undefined + }; + }, + fromSDKJSON(object: any): QueryAllowanceResponseSDKType { + return { + allowance: isSet(object.allowance) ? Grant.fromSDKJSON(object.allowance) : undefined + }; + }, + toSDK(message: QueryAllowanceResponse): QueryAllowanceResponseSDKType { + const obj: any = {}; + message.allowance !== undefined && (obj.allowance = message.allowance ? Grant.toSDK(message.allowance) : undefined); + return obj; + }, + fromAmino(object: QueryAllowanceResponseAmino): QueryAllowanceResponse { + const message = createBaseQueryAllowanceResponse(); + if (object.allowance !== undefined && object.allowance !== null) { + message.allowance = Grant.fromAmino(object.allowance); + } + return message; + }, + toAmino(message: QueryAllowanceResponse): QueryAllowanceResponseAmino { + const obj: any = {}; + obj.allowance = message.allowance ? Grant.toAmino(message.allowance) : undefined; + return obj; + }, + fromAminoMsg(object: QueryAllowanceResponseAminoMsg): QueryAllowanceResponse { + return QueryAllowanceResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryAllowanceResponse): QueryAllowanceResponseAminoMsg { + return { + type: "cosmos-sdk/QueryAllowanceResponse", + value: QueryAllowanceResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryAllowanceResponseProtoMsg): QueryAllowanceResponse { + return QueryAllowanceResponse.decode(message.value); + }, + toProto(message: QueryAllowanceResponse): Uint8Array { + return QueryAllowanceResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryAllowanceResponse): QueryAllowanceResponseProtoMsg { + return { + typeUrl: "/cosmos.feegrant.v1beta1.QueryAllowanceResponse", + value: QueryAllowanceResponse.encode(message).finish() + }; + } +}; +function createBaseQueryAllowancesRequest(): QueryAllowancesRequest { + return { + grantee: "", + pagination: undefined + }; +} +export const QueryAllowancesRequest = { + typeUrl: "/cosmos.feegrant.v1beta1.QueryAllowancesRequest", + encode(message: QueryAllowancesRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.grantee !== undefined) { + writer.uint32(10).string(message.grantee); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryAllowancesRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryAllowancesRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.grantee = reader.string(); + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryAllowancesRequest { + const obj = createBaseQueryAllowancesRequest(); + if (isSet(object.grantee)) obj.grantee = String(object.grantee); + if (isSet(object.pagination)) obj.pagination = PageRequest.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryAllowancesRequest): JsonSafe { + const obj: any = {}; + message.grantee !== undefined && (obj.grantee = message.grantee); + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryAllowancesRequest { + const message = createBaseQueryAllowancesRequest(); + message.grantee = object.grantee ?? ""; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryAllowancesRequestSDKType): QueryAllowancesRequest { + return { + grantee: object?.grantee, + pagination: object.pagination ? PageRequest.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryAllowancesRequestSDKType { + return { + grantee: isSet(object.grantee) ? String(object.grantee) : "", + pagination: isSet(object.pagination) ? PageRequest.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryAllowancesRequest): QueryAllowancesRequestSDKType { + const obj: any = {}; + obj.grantee = message.grantee; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryAllowancesRequestAmino): QueryAllowancesRequest { + const message = createBaseQueryAllowancesRequest(); + if (object.grantee !== undefined && object.grantee !== null) { + message.grantee = object.grantee; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryAllowancesRequest): QueryAllowancesRequestAmino { + const obj: any = {}; + obj.grantee = message.grantee === "" ? undefined : message.grantee; + obj.pagination = message.pagination ? PageRequest.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryAllowancesRequestAminoMsg): QueryAllowancesRequest { + return QueryAllowancesRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryAllowancesRequest): QueryAllowancesRequestAminoMsg { + return { + type: "cosmos-sdk/QueryAllowancesRequest", + value: QueryAllowancesRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryAllowancesRequestProtoMsg): QueryAllowancesRequest { + return QueryAllowancesRequest.decode(message.value); + }, + toProto(message: QueryAllowancesRequest): Uint8Array { + return QueryAllowancesRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryAllowancesRequest): QueryAllowancesRequestProtoMsg { + return { + typeUrl: "/cosmos.feegrant.v1beta1.QueryAllowancesRequest", + value: QueryAllowancesRequest.encode(message).finish() + }; + } +}; +function createBaseQueryAllowancesResponse(): QueryAllowancesResponse { + return { + allowances: [], + pagination: undefined + }; +} +export const QueryAllowancesResponse = { + typeUrl: "/cosmos.feegrant.v1beta1.QueryAllowancesResponse", + encode(message: QueryAllowancesResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.allowances) { + Grant.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryAllowancesResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryAllowancesResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.allowances.push(Grant.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryAllowancesResponse { + const obj = createBaseQueryAllowancesResponse(); + if (Array.isArray(object?.allowances)) obj.allowances = object.allowances.map((e: any) => Grant.fromJSON(e)); + if (isSet(object.pagination)) obj.pagination = PageResponse.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryAllowancesResponse): JsonSafe { + const obj: any = {}; + if (message.allowances) { + obj.allowances = message.allowances.map(e => e ? Grant.toJSON(e) : undefined); + } else { + obj.allowances = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryAllowancesResponse { + const message = createBaseQueryAllowancesResponse(); + message.allowances = object.allowances?.map(e => Grant.fromPartial(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryAllowancesResponseSDKType): QueryAllowancesResponse { + return { + allowances: Array.isArray(object?.allowances) ? object.allowances.map((e: any) => Grant.fromSDK(e)) : [], + pagination: object.pagination ? PageResponse.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryAllowancesResponseSDKType { + return { + allowances: Array.isArray(object?.allowances) ? object.allowances.map((e: any) => Grant.fromSDKJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryAllowancesResponse): QueryAllowancesResponseSDKType { + const obj: any = {}; + if (message.allowances) { + obj.allowances = message.allowances.map(e => e ? Grant.toSDK(e) : undefined); + } else { + obj.allowances = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryAllowancesResponseAmino): QueryAllowancesResponse { + const message = createBaseQueryAllowancesResponse(); + message.allowances = object.allowances?.map(e => Grant.fromAmino(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryAllowancesResponse): QueryAllowancesResponseAmino { + const obj: any = {}; + if (message.allowances) { + obj.allowances = message.allowances.map(e => e ? Grant.toAmino(e) : undefined); + } else { + obj.allowances = message.allowances; + } + obj.pagination = message.pagination ? PageResponse.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryAllowancesResponseAminoMsg): QueryAllowancesResponse { + return QueryAllowancesResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryAllowancesResponse): QueryAllowancesResponseAminoMsg { + return { + type: "cosmos-sdk/QueryAllowancesResponse", + value: QueryAllowancesResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryAllowancesResponseProtoMsg): QueryAllowancesResponse { + return QueryAllowancesResponse.decode(message.value); + }, + toProto(message: QueryAllowancesResponse): Uint8Array { + return QueryAllowancesResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryAllowancesResponse): QueryAllowancesResponseProtoMsg { + return { + typeUrl: "/cosmos.feegrant.v1beta1.QueryAllowancesResponse", + value: QueryAllowancesResponse.encode(message).finish() + }; + } +}; +function createBaseQueryAllowancesByGranterRequest(): QueryAllowancesByGranterRequest { + return { + granter: "", + pagination: undefined + }; +} +export const QueryAllowancesByGranterRequest = { + typeUrl: "/cosmos.feegrant.v1beta1.QueryAllowancesByGranterRequest", + encode(message: QueryAllowancesByGranterRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.granter !== undefined) { + writer.uint32(10).string(message.granter); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryAllowancesByGranterRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryAllowancesByGranterRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.granter = reader.string(); + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryAllowancesByGranterRequest { + const obj = createBaseQueryAllowancesByGranterRequest(); + if (isSet(object.granter)) obj.granter = String(object.granter); + if (isSet(object.pagination)) obj.pagination = PageRequest.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryAllowancesByGranterRequest): JsonSafe { + const obj: any = {}; + message.granter !== undefined && (obj.granter = message.granter); + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryAllowancesByGranterRequest { + const message = createBaseQueryAllowancesByGranterRequest(); + message.granter = object.granter ?? ""; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryAllowancesByGranterRequestSDKType): QueryAllowancesByGranterRequest { + return { + granter: object?.granter, + pagination: object.pagination ? PageRequest.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryAllowancesByGranterRequestSDKType { + return { + granter: isSet(object.granter) ? String(object.granter) : "", + pagination: isSet(object.pagination) ? PageRequest.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryAllowancesByGranterRequest): QueryAllowancesByGranterRequestSDKType { + const obj: any = {}; + obj.granter = message.granter; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryAllowancesByGranterRequestAmino): QueryAllowancesByGranterRequest { + const message = createBaseQueryAllowancesByGranterRequest(); + if (object.granter !== undefined && object.granter !== null) { + message.granter = object.granter; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryAllowancesByGranterRequest): QueryAllowancesByGranterRequestAmino { + const obj: any = {}; + obj.granter = message.granter === "" ? undefined : message.granter; + obj.pagination = message.pagination ? PageRequest.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryAllowancesByGranterRequestAminoMsg): QueryAllowancesByGranterRequest { + return QueryAllowancesByGranterRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryAllowancesByGranterRequest): QueryAllowancesByGranterRequestAminoMsg { + return { + type: "cosmos-sdk/QueryAllowancesByGranterRequest", + value: QueryAllowancesByGranterRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryAllowancesByGranterRequestProtoMsg): QueryAllowancesByGranterRequest { + return QueryAllowancesByGranterRequest.decode(message.value); + }, + toProto(message: QueryAllowancesByGranterRequest): Uint8Array { + return QueryAllowancesByGranterRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryAllowancesByGranterRequest): QueryAllowancesByGranterRequestProtoMsg { + return { + typeUrl: "/cosmos.feegrant.v1beta1.QueryAllowancesByGranterRequest", + value: QueryAllowancesByGranterRequest.encode(message).finish() + }; + } +}; +function createBaseQueryAllowancesByGranterResponse(): QueryAllowancesByGranterResponse { + return { + allowances: [], + pagination: undefined + }; +} +export const QueryAllowancesByGranterResponse = { + typeUrl: "/cosmos.feegrant.v1beta1.QueryAllowancesByGranterResponse", + encode(message: QueryAllowancesByGranterResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.allowances) { + Grant.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryAllowancesByGranterResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryAllowancesByGranterResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.allowances.push(Grant.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryAllowancesByGranterResponse { + const obj = createBaseQueryAllowancesByGranterResponse(); + if (Array.isArray(object?.allowances)) obj.allowances = object.allowances.map((e: any) => Grant.fromJSON(e)); + if (isSet(object.pagination)) obj.pagination = PageResponse.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryAllowancesByGranterResponse): JsonSafe { + const obj: any = {}; + if (message.allowances) { + obj.allowances = message.allowances.map(e => e ? Grant.toJSON(e) : undefined); + } else { + obj.allowances = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryAllowancesByGranterResponse { + const message = createBaseQueryAllowancesByGranterResponse(); + message.allowances = object.allowances?.map(e => Grant.fromPartial(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryAllowancesByGranterResponseSDKType): QueryAllowancesByGranterResponse { + return { + allowances: Array.isArray(object?.allowances) ? object.allowances.map((e: any) => Grant.fromSDK(e)) : [], + pagination: object.pagination ? PageResponse.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryAllowancesByGranterResponseSDKType { + return { + allowances: Array.isArray(object?.allowances) ? object.allowances.map((e: any) => Grant.fromSDKJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryAllowancesByGranterResponse): QueryAllowancesByGranterResponseSDKType { + const obj: any = {}; + if (message.allowances) { + obj.allowances = message.allowances.map(e => e ? Grant.toSDK(e) : undefined); + } else { + obj.allowances = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryAllowancesByGranterResponseAmino): QueryAllowancesByGranterResponse { + const message = createBaseQueryAllowancesByGranterResponse(); + message.allowances = object.allowances?.map(e => Grant.fromAmino(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryAllowancesByGranterResponse): QueryAllowancesByGranterResponseAmino { + const obj: any = {}; + if (message.allowances) { + obj.allowances = message.allowances.map(e => e ? Grant.toAmino(e) : undefined); + } else { + obj.allowances = message.allowances; + } + obj.pagination = message.pagination ? PageResponse.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryAllowancesByGranterResponseAminoMsg): QueryAllowancesByGranterResponse { + return QueryAllowancesByGranterResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryAllowancesByGranterResponse): QueryAllowancesByGranterResponseAminoMsg { + return { + type: "cosmos-sdk/QueryAllowancesByGranterResponse", + value: QueryAllowancesByGranterResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryAllowancesByGranterResponseProtoMsg): QueryAllowancesByGranterResponse { + return QueryAllowancesByGranterResponse.decode(message.value); + }, + toProto(message: QueryAllowancesByGranterResponse): Uint8Array { + return QueryAllowancesByGranterResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryAllowancesByGranterResponse): QueryAllowancesByGranterResponseProtoMsg { + return { + typeUrl: "/cosmos.feegrant.v1beta1.QueryAllowancesByGranterResponse", + value: QueryAllowancesByGranterResponse.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/feegrant/v1beta1/tx.amino.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/feegrant/v1beta1/tx.amino.ts new file mode 100644 index 0000000000..0f506ed1b6 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/feegrant/v1beta1/tx.amino.ts @@ -0,0 +1,75 @@ +import { Any, AnySDKType } from "../../../google/protobuf/any.js"; +import { ReadOnlyAminoMsg as AminoMsg } from "@interchainjs/ReadOnlyAminoMsg"; +import { MsgGrantAllowance, MsgGrantAllowanceSDKType, MsgRevokeAllowance, MsgRevokeAllowanceSDKType } from "./tx.js"; +export interface MsgGrantAllowanceAminoType extends AminoMsg { + type: "cosmos-sdk/MsgGrantAllowance"; + value: { + granter: string; + grantee: string; + allowance: { + type_url: string; + value: Uint8Array; + }; + }; +} +export interface MsgRevokeAllowanceAminoType extends AminoMsg { + type: "cosmos-sdk/MsgRevokeAllowance"; + value: { + granter: string; + grantee: string; + }; +} +export const AminoConverter = { + "/cosmos.feegrant.v1beta1.MsgGrantAllowance": { + aminoType: "cosmos-sdk/MsgGrantAllowance", + toAmino: ({ + granter, + grantee, + allowance + }: MsgGrantAllowance): MsgGrantAllowanceAminoType["value"] => { + return { + granter, + grantee, + allowance: { + type_url: allowance.typeUrl, + value: allowance.value + } + }; + }, + fromAmino: ({ + granter, + grantee, + allowance + }: MsgGrantAllowanceAminoType["value"]): MsgGrantAllowance => { + return { + granter, + grantee, + allowance: { + typeUrl: allowance.type_url, + value: allowance.value + } + }; + } + }, + "/cosmos.feegrant.v1beta1.MsgRevokeAllowance": { + aminoType: "cosmos-sdk/MsgRevokeAllowance", + toAmino: ({ + granter, + grantee + }: MsgRevokeAllowance): MsgRevokeAllowanceAminoType["value"] => { + return { + granter, + grantee + }; + }, + fromAmino: ({ + granter, + grantee + }: MsgRevokeAllowanceAminoType["value"]): MsgRevokeAllowance => { + return { + granter, + grantee + }; + } + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/feegrant/v1beta1/tx.registry.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/feegrant/v1beta1/tx.registry.ts new file mode 100644 index 0000000000..0dc7e2d320 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/feegrant/v1beta1/tx.registry.ts @@ -0,0 +1,81 @@ +import { Any, AnySDKType } from "../../../google/protobuf/any.js"; +import { GeneratedType, Registry } from "@cosmjs/proto-signing"; +import { MsgGrantAllowance, MsgGrantAllowanceSDKType, MsgRevokeAllowance, MsgRevokeAllowanceSDKType } from "./tx.js"; +export const registry: ReadonlyArray<[string, GeneratedType]> = [["/cosmos.feegrant.v1beta1.MsgGrantAllowance", MsgGrantAllowance], ["/cosmos.feegrant.v1beta1.MsgRevokeAllowance", MsgRevokeAllowance]]; +export const load = (protoRegistry: Registry) => { + registry.forEach(([typeUrl, mod]) => { + protoRegistry.register(typeUrl, mod); + }); +}; +export const MessageComposer = { + encoded: { + grantAllowance(value: MsgGrantAllowance) { + return { + typeUrl: "/cosmos.feegrant.v1beta1.MsgGrantAllowance", + value: MsgGrantAllowance.encode(value).finish() + }; + }, + revokeAllowance(value: MsgRevokeAllowance) { + return { + typeUrl: "/cosmos.feegrant.v1beta1.MsgRevokeAllowance", + value: MsgRevokeAllowance.encode(value).finish() + }; + } + }, + withTypeUrl: { + grantAllowance(value: MsgGrantAllowance) { + return { + typeUrl: "/cosmos.feegrant.v1beta1.MsgGrantAllowance", + value + }; + }, + revokeAllowance(value: MsgRevokeAllowance) { + return { + typeUrl: "/cosmos.feegrant.v1beta1.MsgRevokeAllowance", + value + }; + } + }, + toJSON: { + grantAllowance(value: MsgGrantAllowance) { + return { + typeUrl: "/cosmos.feegrant.v1beta1.MsgGrantAllowance", + value: MsgGrantAllowance.toJSON(value) + }; + }, + revokeAllowance(value: MsgRevokeAllowance) { + return { + typeUrl: "/cosmos.feegrant.v1beta1.MsgRevokeAllowance", + value: MsgRevokeAllowance.toJSON(value) + }; + } + }, + fromJSON: { + grantAllowance(value: any) { + return { + typeUrl: "/cosmos.feegrant.v1beta1.MsgGrantAllowance", + value: MsgGrantAllowance.fromJSON(value) + }; + }, + revokeAllowance(value: any) { + return { + typeUrl: "/cosmos.feegrant.v1beta1.MsgRevokeAllowance", + value: MsgRevokeAllowance.fromJSON(value) + }; + } + }, + fromPartial: { + grantAllowance(value: MsgGrantAllowance) { + return { + typeUrl: "/cosmos.feegrant.v1beta1.MsgGrantAllowance", + value: MsgGrantAllowance.fromPartial(value) + }; + }, + revokeAllowance(value: MsgRevokeAllowance) { + return { + typeUrl: "/cosmos.feegrant.v1beta1.MsgRevokeAllowance", + value: MsgRevokeAllowance.fromPartial(value) + }; + } + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/feegrant/v1beta1/tx.rpc.func.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/feegrant/v1beta1/tx.rpc.func.ts new file mode 100644 index 0000000000..c384d58e73 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/feegrant/v1beta1/tx.rpc.func.ts @@ -0,0 +1,22 @@ +import { buildTx, SigningClientResolver } from "../../../helper-func-types"; +import { buildUseMutation } from "../../../react-query"; +import { toEncoders, toConverters } from "@interchainjs/cosmos/utils"; +import { MsgGrantAllowance, MsgRevokeAllowance } from "./tx"; +export const createGrantAllowance = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgGrantAllowance.typeUrl, + encoders: toEncoders(MsgGrantAllowance), + converters: toConverters(MsgGrantAllowance) +}); +export const useGrantAllowance = buildUseMutation({ + builderMutationFn: createGrantAllowance +}); +export const createRevokeAllowance = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgRevokeAllowance.typeUrl, + encoders: toEncoders(MsgRevokeAllowance), + converters: toConverters(MsgRevokeAllowance) +}); +export const useRevokeAllowance = buildUseMutation({ + builderMutationFn: createRevokeAllowance +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/feegrant/v1beta1/tx.rpc.msg.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/feegrant/v1beta1/tx.rpc.msg.ts new file mode 100644 index 0000000000..44ebe5cae3 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/feegrant/v1beta1/tx.rpc.msg.ts @@ -0,0 +1,38 @@ +import { Any, AnySDKType } from "../../../google/protobuf/any.js"; +import { Rpc } from "../../../helpers.js"; +import { BinaryReader } from "../../../binary.js"; +import { MsgGrantAllowance, MsgGrantAllowanceSDKType, MsgGrantAllowanceResponse, MsgGrantAllowanceResponseSDKType, MsgRevokeAllowance, MsgRevokeAllowanceSDKType, MsgRevokeAllowanceResponse, MsgRevokeAllowanceResponseSDKType } from "./tx.js"; +/** Msg defines the feegrant msg service. */ +export interface Msg { + /** + * GrantAllowance grants fee allowance to the grantee on the granter's + * account with the provided expiration time. + */ + grantAllowance(request: MsgGrantAllowance): Promise; + /** + * RevokeAllowance revokes any fee allowance of granter's account that + * has been granted to the grantee. + */ + revokeAllowance(request: MsgRevokeAllowance): Promise; +} +export class MsgClientImpl implements Msg { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + this.grantAllowance = this.grantAllowance.bind(this); + this.revokeAllowance = this.revokeAllowance.bind(this); + } + grantAllowance(request: MsgGrantAllowance): Promise { + const data = MsgGrantAllowance.encode(request).finish(); + const promise = this.rpc.request("cosmos.feegrant.v1beta1.Msg", "GrantAllowance", data); + return promise.then(data => MsgGrantAllowanceResponse.decode(new BinaryReader(data))); + } + revokeAllowance(request: MsgRevokeAllowance): Promise { + const data = MsgRevokeAllowance.encode(request).finish(); + const promise = this.rpc.request("cosmos.feegrant.v1beta1.Msg", "RevokeAllowance", data); + return promise.then(data => MsgRevokeAllowanceResponse.decode(new BinaryReader(data))); + } +} +export const createClientImpl = (rpc: Rpc) => { + return new MsgClientImpl(rpc); +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/feegrant/v1beta1/tx.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/feegrant/v1beta1/tx.ts new file mode 100644 index 0000000000..5f75d8f93a --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/feegrant/v1beta1/tx.ts @@ -0,0 +1,451 @@ +import { Any, AnySDKType } from "../../../google/protobuf/any.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "cosmos.feegrant.v1beta1"; +/** + * MsgGrantAllowance adds permission for Grantee to spend up to Allowance + * of fees from the account of Granter. + */ +export interface MsgGrantAllowance { + /** granter is the address of the user granting an allowance of their funds. */ + granter: string; + /** grantee is the address of the user being granted an allowance of another user's funds. */ + grantee: string; + /** allowance can be any of basic, periodic, allowed fee allowance. */ + allowance?: Any; +} +export interface MsgGrantAllowanceProtoMsg { + typeUrl: "/cosmos.feegrant.v1beta1.MsgGrantAllowance"; + value: Uint8Array; +} +/** + * MsgGrantAllowance adds permission for Grantee to spend up to Allowance + * of fees from the account of Granter. + */ +export interface MsgGrantAllowanceSDKType { + granter: string; + grantee: string; + allowance?: AnySDKType; +} +/** MsgGrantAllowanceResponse defines the Msg/GrantAllowanceResponse response type. */ +export interface MsgGrantAllowanceResponse {} +export interface MsgGrantAllowanceResponseProtoMsg { + typeUrl: "/cosmos.feegrant.v1beta1.MsgGrantAllowanceResponse"; + value: Uint8Array; +} +/** MsgGrantAllowanceResponse defines the Msg/GrantAllowanceResponse response type. */ +export interface MsgGrantAllowanceResponseSDKType {} +/** MsgRevokeAllowance removes any existing Allowance from Granter to Grantee. */ +export interface MsgRevokeAllowance { + /** granter is the address of the user granting an allowance of their funds. */ + granter: string; + /** grantee is the address of the user being granted an allowance of another user's funds. */ + grantee: string; +} +export interface MsgRevokeAllowanceProtoMsg { + typeUrl: "/cosmos.feegrant.v1beta1.MsgRevokeAllowance"; + value: Uint8Array; +} +/** MsgRevokeAllowance removes any existing Allowance from Granter to Grantee. */ +export interface MsgRevokeAllowanceSDKType { + granter: string; + grantee: string; +} +/** MsgRevokeAllowanceResponse defines the Msg/RevokeAllowanceResponse response type. */ +export interface MsgRevokeAllowanceResponse {} +export interface MsgRevokeAllowanceResponseProtoMsg { + typeUrl: "/cosmos.feegrant.v1beta1.MsgRevokeAllowanceResponse"; + value: Uint8Array; +} +/** MsgRevokeAllowanceResponse defines the Msg/RevokeAllowanceResponse response type. */ +export interface MsgRevokeAllowanceResponseSDKType {} +function createBaseMsgGrantAllowance(): MsgGrantAllowance { + return { + granter: "", + grantee: "", + allowance: undefined + }; +} +export const MsgGrantAllowance = { + typeUrl: "/cosmos.feegrant.v1beta1.MsgGrantAllowance", + encode(message: MsgGrantAllowance, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.granter !== undefined) { + writer.uint32(10).string(message.granter); + } + if (message.grantee !== undefined) { + writer.uint32(18).string(message.grantee); + } + if (message.allowance !== undefined) { + Any.encode(message.allowance, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgGrantAllowance { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgGrantAllowance(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.granter = reader.string(); + break; + case 2: + message.grantee = reader.string(); + break; + case 3: + message.allowance = Any.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgGrantAllowance { + const obj = createBaseMsgGrantAllowance(); + if (isSet(object.granter)) obj.granter = String(object.granter); + if (isSet(object.grantee)) obj.grantee = String(object.grantee); + if (isSet(object.allowance)) obj.allowance = Any.fromJSON(object.allowance); + return obj; + }, + toJSON(message: MsgGrantAllowance): JsonSafe { + const obj: any = {}; + message.granter !== undefined && (obj.granter = message.granter); + message.grantee !== undefined && (obj.grantee = message.grantee); + message.allowance !== undefined && (obj.allowance = message.allowance ? Any.toJSON(message.allowance) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): MsgGrantAllowance { + const message = createBaseMsgGrantAllowance(); + message.granter = object.granter ?? ""; + message.grantee = object.grantee ?? ""; + if (object.allowance !== undefined && object.allowance !== null) { + message.allowance = Any.fromPartial(object.allowance); + } + return message; + }, + fromSDK(object: MsgGrantAllowanceSDKType): MsgGrantAllowance { + return { + granter: object?.granter, + grantee: object?.grantee, + allowance: object.allowance ? Any.fromSDK(object.allowance) : undefined + }; + }, + fromSDKJSON(object: any): MsgGrantAllowanceSDKType { + return { + granter: isSet(object.granter) ? String(object.granter) : "", + grantee: isSet(object.grantee) ? String(object.grantee) : "", + allowance: isSet(object.allowance) ? Any.fromSDKJSON(object.allowance) : undefined + }; + }, + toSDK(message: MsgGrantAllowance): MsgGrantAllowanceSDKType { + const obj: any = {}; + obj.granter = message.granter; + obj.grantee = message.grantee; + message.allowance !== undefined && (obj.allowance = message.allowance ? Any.toSDK(message.allowance) : undefined); + return obj; + }, + fromAmino(object: MsgGrantAllowanceAmino): MsgGrantAllowance { + const message = createBaseMsgGrantAllowance(); + if (object.granter !== undefined && object.granter !== null) { + message.granter = object.granter; + } + if (object.grantee !== undefined && object.grantee !== null) { + message.grantee = object.grantee; + } + if (object.allowance !== undefined && object.allowance !== null) { + message.allowance = Any.fromAmino(object.allowance); + } + return message; + }, + toAmino(message: MsgGrantAllowance): MsgGrantAllowanceAmino { + const obj: any = {}; + obj.granter = message.granter === "" ? undefined : message.granter; + obj.grantee = message.grantee === "" ? undefined : message.grantee; + obj.allowance = message.allowance ? Any.toAmino(message.allowance) : undefined; + return obj; + }, + fromAminoMsg(object: MsgGrantAllowanceAminoMsg): MsgGrantAllowance { + return MsgGrantAllowance.fromAmino(object.value); + }, + toAminoMsg(message: MsgGrantAllowance): MsgGrantAllowanceAminoMsg { + return { + type: "cosmos-sdk/MsgGrantAllowance", + value: MsgGrantAllowance.toAmino(message) + }; + }, + fromProtoMsg(message: MsgGrantAllowanceProtoMsg): MsgGrantAllowance { + return MsgGrantAllowance.decode(message.value); + }, + toProto(message: MsgGrantAllowance): Uint8Array { + return MsgGrantAllowance.encode(message).finish(); + }, + toProtoMsg(message: MsgGrantAllowance): MsgGrantAllowanceProtoMsg { + return { + typeUrl: "/cosmos.feegrant.v1beta1.MsgGrantAllowance", + value: MsgGrantAllowance.encode(message).finish() + }; + } +}; +function createBaseMsgGrantAllowanceResponse(): MsgGrantAllowanceResponse { + return {}; +} +export const MsgGrantAllowanceResponse = { + typeUrl: "/cosmos.feegrant.v1beta1.MsgGrantAllowanceResponse", + encode(_: MsgGrantAllowanceResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgGrantAllowanceResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgGrantAllowanceResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgGrantAllowanceResponse { + const obj = createBaseMsgGrantAllowanceResponse(); + return obj; + }, + toJSON(_: MsgGrantAllowanceResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): MsgGrantAllowanceResponse { + const message = createBaseMsgGrantAllowanceResponse(); + return message; + }, + fromSDK(_: MsgGrantAllowanceResponseSDKType): MsgGrantAllowanceResponse { + return {}; + }, + fromSDKJSON(_: any): MsgGrantAllowanceResponseSDKType { + return {}; + }, + toSDK(_: MsgGrantAllowanceResponse): MsgGrantAllowanceResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgGrantAllowanceResponseAmino): MsgGrantAllowanceResponse { + const message = createBaseMsgGrantAllowanceResponse(); + return message; + }, + toAmino(_: MsgGrantAllowanceResponse): MsgGrantAllowanceResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgGrantAllowanceResponseAminoMsg): MsgGrantAllowanceResponse { + return MsgGrantAllowanceResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgGrantAllowanceResponse): MsgGrantAllowanceResponseAminoMsg { + return { + type: "cosmos-sdk/MsgGrantAllowanceResponse", + value: MsgGrantAllowanceResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgGrantAllowanceResponseProtoMsg): MsgGrantAllowanceResponse { + return MsgGrantAllowanceResponse.decode(message.value); + }, + toProto(message: MsgGrantAllowanceResponse): Uint8Array { + return MsgGrantAllowanceResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgGrantAllowanceResponse): MsgGrantAllowanceResponseProtoMsg { + return { + typeUrl: "/cosmos.feegrant.v1beta1.MsgGrantAllowanceResponse", + value: MsgGrantAllowanceResponse.encode(message).finish() + }; + } +}; +function createBaseMsgRevokeAllowance(): MsgRevokeAllowance { + return { + granter: "", + grantee: "" + }; +} +export const MsgRevokeAllowance = { + typeUrl: "/cosmos.feegrant.v1beta1.MsgRevokeAllowance", + encode(message: MsgRevokeAllowance, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.granter !== undefined) { + writer.uint32(10).string(message.granter); + } + if (message.grantee !== undefined) { + writer.uint32(18).string(message.grantee); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgRevokeAllowance { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgRevokeAllowance(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.granter = reader.string(); + break; + case 2: + message.grantee = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgRevokeAllowance { + const obj = createBaseMsgRevokeAllowance(); + if (isSet(object.granter)) obj.granter = String(object.granter); + if (isSet(object.grantee)) obj.grantee = String(object.grantee); + return obj; + }, + toJSON(message: MsgRevokeAllowance): JsonSafe { + const obj: any = {}; + message.granter !== undefined && (obj.granter = message.granter); + message.grantee !== undefined && (obj.grantee = message.grantee); + return obj; + }, + fromPartial(object: DeepPartial): MsgRevokeAllowance { + const message = createBaseMsgRevokeAllowance(); + message.granter = object.granter ?? ""; + message.grantee = object.grantee ?? ""; + return message; + }, + fromSDK(object: MsgRevokeAllowanceSDKType): MsgRevokeAllowance { + return { + granter: object?.granter, + grantee: object?.grantee + }; + }, + fromSDKJSON(object: any): MsgRevokeAllowanceSDKType { + return { + granter: isSet(object.granter) ? String(object.granter) : "", + grantee: isSet(object.grantee) ? String(object.grantee) : "" + }; + }, + toSDK(message: MsgRevokeAllowance): MsgRevokeAllowanceSDKType { + const obj: any = {}; + obj.granter = message.granter; + obj.grantee = message.grantee; + return obj; + }, + fromAmino(object: MsgRevokeAllowanceAmino): MsgRevokeAllowance { + const message = createBaseMsgRevokeAllowance(); + if (object.granter !== undefined && object.granter !== null) { + message.granter = object.granter; + } + if (object.grantee !== undefined && object.grantee !== null) { + message.grantee = object.grantee; + } + return message; + }, + toAmino(message: MsgRevokeAllowance): MsgRevokeAllowanceAmino { + const obj: any = {}; + obj.granter = message.granter === "" ? undefined : message.granter; + obj.grantee = message.grantee === "" ? undefined : message.grantee; + return obj; + }, + fromAminoMsg(object: MsgRevokeAllowanceAminoMsg): MsgRevokeAllowance { + return MsgRevokeAllowance.fromAmino(object.value); + }, + toAminoMsg(message: MsgRevokeAllowance): MsgRevokeAllowanceAminoMsg { + return { + type: "cosmos-sdk/MsgRevokeAllowance", + value: MsgRevokeAllowance.toAmino(message) + }; + }, + fromProtoMsg(message: MsgRevokeAllowanceProtoMsg): MsgRevokeAllowance { + return MsgRevokeAllowance.decode(message.value); + }, + toProto(message: MsgRevokeAllowance): Uint8Array { + return MsgRevokeAllowance.encode(message).finish(); + }, + toProtoMsg(message: MsgRevokeAllowance): MsgRevokeAllowanceProtoMsg { + return { + typeUrl: "/cosmos.feegrant.v1beta1.MsgRevokeAllowance", + value: MsgRevokeAllowance.encode(message).finish() + }; + } +}; +function createBaseMsgRevokeAllowanceResponse(): MsgRevokeAllowanceResponse { + return {}; +} +export const MsgRevokeAllowanceResponse = { + typeUrl: "/cosmos.feegrant.v1beta1.MsgRevokeAllowanceResponse", + encode(_: MsgRevokeAllowanceResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgRevokeAllowanceResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgRevokeAllowanceResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgRevokeAllowanceResponse { + const obj = createBaseMsgRevokeAllowanceResponse(); + return obj; + }, + toJSON(_: MsgRevokeAllowanceResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): MsgRevokeAllowanceResponse { + const message = createBaseMsgRevokeAllowanceResponse(); + return message; + }, + fromSDK(_: MsgRevokeAllowanceResponseSDKType): MsgRevokeAllowanceResponse { + return {}; + }, + fromSDKJSON(_: any): MsgRevokeAllowanceResponseSDKType { + return {}; + }, + toSDK(_: MsgRevokeAllowanceResponse): MsgRevokeAllowanceResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgRevokeAllowanceResponseAmino): MsgRevokeAllowanceResponse { + const message = createBaseMsgRevokeAllowanceResponse(); + return message; + }, + toAmino(_: MsgRevokeAllowanceResponse): MsgRevokeAllowanceResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgRevokeAllowanceResponseAminoMsg): MsgRevokeAllowanceResponse { + return MsgRevokeAllowanceResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgRevokeAllowanceResponse): MsgRevokeAllowanceResponseAminoMsg { + return { + type: "cosmos-sdk/MsgRevokeAllowanceResponse", + value: MsgRevokeAllowanceResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgRevokeAllowanceResponseProtoMsg): MsgRevokeAllowanceResponse { + return MsgRevokeAllowanceResponse.decode(message.value); + }, + toProto(message: MsgRevokeAllowanceResponse): Uint8Array { + return MsgRevokeAllowanceResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgRevokeAllowanceResponse): MsgRevokeAllowanceResponseProtoMsg { + return { + typeUrl: "/cosmos.feegrant.v1beta1.MsgRevokeAllowanceResponse", + value: MsgRevokeAllowanceResponse.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/genutil/v1beta1/genesis.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/genutil/v1beta1/genesis.ts new file mode 100644 index 0000000000..82a969fb99 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/genutil/v1beta1/genesis.ts @@ -0,0 +1,121 @@ +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { bytesFromBase64, base64FromBytes, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "cosmos.genutil.v1beta1"; +/** GenesisState defines the raw genesis transaction in JSON. */ +export interface GenesisState { + /** gen_txs defines the genesis transactions. */ + genTxs: Uint8Array[]; +} +export interface GenesisStateProtoMsg { + typeUrl: "/cosmos.genutil.v1beta1.GenesisState"; + value: Uint8Array; +} +/** GenesisState defines the raw genesis transaction in JSON. */ +export interface GenesisStateSDKType { + gen_txs: Uint8Array[]; +} +function createBaseGenesisState(): GenesisState { + return { + genTxs: [] + }; +} +export const GenesisState = { + typeUrl: "/cosmos.genutil.v1beta1.GenesisState", + encode(message: GenesisState, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.genTxs) { + writer.uint32(10).bytes(v!); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GenesisState { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGenesisState(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.genTxs.push(reader.bytes()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GenesisState { + const obj = createBaseGenesisState(); + if (Array.isArray(object?.genTxs)) obj.genTxs = object.genTxs.map((e: any) => bytesFromBase64(e)); + return obj; + }, + toJSON(message: GenesisState): JsonSafe { + const obj: any = {}; + if (message.genTxs) { + obj.genTxs = message.genTxs.map(e => base64FromBytes(e !== undefined ? e : new Uint8Array())); + } else { + obj.genTxs = []; + } + return obj; + }, + fromPartial(object: DeepPartial): GenesisState { + const message = createBaseGenesisState(); + message.genTxs = object.genTxs?.map(e => e) || []; + return message; + }, + fromSDK(object: GenesisStateSDKType): GenesisState { + return { + genTxs: Array.isArray(object?.gen_txs) ? object.gen_txs.map((e: any) => e) : [] + }; + }, + fromSDKJSON(object: any): GenesisStateSDKType { + return { + gen_txs: Array.isArray(object?.gen_txs) ? object.gen_txs.map((e: any) => bytesFromBase64(e)) : [] + }; + }, + toSDK(message: GenesisState): GenesisStateSDKType { + const obj: any = {}; + if (message.genTxs) { + obj.gen_txs = message.genTxs.map(e => e); + } else { + obj.gen_txs = []; + } + return obj; + }, + fromAmino(object: GenesisStateAmino): GenesisState { + const message = createBaseGenesisState(); + message.genTxs = object.gen_txs?.map(e => bytesFromBase64(e)) || []; + return message; + }, + toAmino(message: GenesisState): GenesisStateAmino { + const obj: any = {}; + if (message.genTxs) { + obj.gen_txs = message.genTxs.map(e => base64FromBytes(e)); + } else { + obj.gen_txs = message.genTxs; + } + return obj; + }, + fromAminoMsg(object: GenesisStateAminoMsg): GenesisState { + return GenesisState.fromAmino(object.value); + }, + toAminoMsg(message: GenesisState): GenesisStateAminoMsg { + return { + type: "cosmos-sdk/GenesisState", + value: GenesisState.toAmino(message) + }; + }, + fromProtoMsg(message: GenesisStateProtoMsg): GenesisState { + return GenesisState.decode(message.value); + }, + toProto(message: GenesisState): Uint8Array { + return GenesisState.encode(message).finish(); + }, + toProtoMsg(message: GenesisState): GenesisStateProtoMsg { + return { + typeUrl: "/cosmos.genutil.v1beta1.GenesisState", + value: GenesisState.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/gov/v1/genesis.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/gov/v1/genesis.ts new file mode 100644 index 0000000000..63a6c949db --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/gov/v1/genesis.ts @@ -0,0 +1,270 @@ +import { Deposit, DepositSDKType, Vote, VoteSDKType, Proposal, ProposalSDKType, DepositParams, DepositParamsSDKType, VotingParams, VotingParamsSDKType, TallyParams, TallyParamsSDKType } from "./gov.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "cosmos.gov.v1"; +/** GenesisState defines the gov module's genesis state. */ +export interface GenesisState { + /** starting_proposal_id is the ID of the starting proposal. */ + startingProposalId: bigint; + /** deposits defines all the deposits present at genesis. */ + deposits: Deposit[]; + /** votes defines all the votes present at genesis. */ + votes: Vote[]; + /** proposals defines all the proposals present at genesis. */ + proposals: Proposal[]; + /** params defines all the paramaters of related to deposit. */ + depositParams?: DepositParams; + /** params defines all the paramaters of related to voting. */ + votingParams?: VotingParams; + /** params defines all the paramaters of related to tally. */ + tallyParams?: TallyParams; +} +export interface GenesisStateProtoMsg { + typeUrl: "/cosmos.gov.v1.GenesisState"; + value: Uint8Array; +} +/** GenesisState defines the gov module's genesis state. */ +export interface GenesisStateSDKType { + starting_proposal_id: bigint; + deposits: DepositSDKType[]; + votes: VoteSDKType[]; + proposals: ProposalSDKType[]; + deposit_params?: DepositParamsSDKType; + voting_params?: VotingParamsSDKType; + tally_params?: TallyParamsSDKType; +} +function createBaseGenesisState(): GenesisState { + return { + startingProposalId: BigInt(0), + deposits: [], + votes: [], + proposals: [], + depositParams: undefined, + votingParams: undefined, + tallyParams: undefined + }; +} +export const GenesisState = { + typeUrl: "/cosmos.gov.v1.GenesisState", + encode(message: GenesisState, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.startingProposalId !== undefined) { + writer.uint32(8).uint64(message.startingProposalId); + } + for (const v of message.deposits) { + Deposit.encode(v!, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.votes) { + Vote.encode(v!, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.proposals) { + Proposal.encode(v!, writer.uint32(34).fork()).ldelim(); + } + if (message.depositParams !== undefined) { + DepositParams.encode(message.depositParams, writer.uint32(42).fork()).ldelim(); + } + if (message.votingParams !== undefined) { + VotingParams.encode(message.votingParams, writer.uint32(50).fork()).ldelim(); + } + if (message.tallyParams !== undefined) { + TallyParams.encode(message.tallyParams, writer.uint32(58).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GenesisState { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGenesisState(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.startingProposalId = reader.uint64(); + break; + case 2: + message.deposits.push(Deposit.decode(reader, reader.uint32())); + break; + case 3: + message.votes.push(Vote.decode(reader, reader.uint32())); + break; + case 4: + message.proposals.push(Proposal.decode(reader, reader.uint32())); + break; + case 5: + message.depositParams = DepositParams.decode(reader, reader.uint32()); + break; + case 6: + message.votingParams = VotingParams.decode(reader, reader.uint32()); + break; + case 7: + message.tallyParams = TallyParams.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GenesisState { + const obj = createBaseGenesisState(); + if (isSet(object.startingProposalId)) obj.startingProposalId = BigInt(object.startingProposalId.toString()); + if (Array.isArray(object?.deposits)) obj.deposits = object.deposits.map((e: any) => Deposit.fromJSON(e)); + if (Array.isArray(object?.votes)) obj.votes = object.votes.map((e: any) => Vote.fromJSON(e)); + if (Array.isArray(object?.proposals)) obj.proposals = object.proposals.map((e: any) => Proposal.fromJSON(e)); + if (isSet(object.depositParams)) obj.depositParams = DepositParams.fromJSON(object.depositParams); + if (isSet(object.votingParams)) obj.votingParams = VotingParams.fromJSON(object.votingParams); + if (isSet(object.tallyParams)) obj.tallyParams = TallyParams.fromJSON(object.tallyParams); + return obj; + }, + toJSON(message: GenesisState): JsonSafe { + const obj: any = {}; + message.startingProposalId !== undefined && (obj.startingProposalId = (message.startingProposalId || BigInt(0)).toString()); + if (message.deposits) { + obj.deposits = message.deposits.map(e => e ? Deposit.toJSON(e) : undefined); + } else { + obj.deposits = []; + } + if (message.votes) { + obj.votes = message.votes.map(e => e ? Vote.toJSON(e) : undefined); + } else { + obj.votes = []; + } + if (message.proposals) { + obj.proposals = message.proposals.map(e => e ? Proposal.toJSON(e) : undefined); + } else { + obj.proposals = []; + } + message.depositParams !== undefined && (obj.depositParams = message.depositParams ? DepositParams.toJSON(message.depositParams) : undefined); + message.votingParams !== undefined && (obj.votingParams = message.votingParams ? VotingParams.toJSON(message.votingParams) : undefined); + message.tallyParams !== undefined && (obj.tallyParams = message.tallyParams ? TallyParams.toJSON(message.tallyParams) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): GenesisState { + const message = createBaseGenesisState(); + if (object.startingProposalId !== undefined && object.startingProposalId !== null) { + message.startingProposalId = BigInt(object.startingProposalId.toString()); + } + message.deposits = object.deposits?.map(e => Deposit.fromPartial(e)) || []; + message.votes = object.votes?.map(e => Vote.fromPartial(e)) || []; + message.proposals = object.proposals?.map(e => Proposal.fromPartial(e)) || []; + if (object.depositParams !== undefined && object.depositParams !== null) { + message.depositParams = DepositParams.fromPartial(object.depositParams); + } + if (object.votingParams !== undefined && object.votingParams !== null) { + message.votingParams = VotingParams.fromPartial(object.votingParams); + } + if (object.tallyParams !== undefined && object.tallyParams !== null) { + message.tallyParams = TallyParams.fromPartial(object.tallyParams); + } + return message; + }, + fromSDK(object: GenesisStateSDKType): GenesisState { + return { + startingProposalId: object?.starting_proposal_id, + deposits: Array.isArray(object?.deposits) ? object.deposits.map((e: any) => Deposit.fromSDK(e)) : [], + votes: Array.isArray(object?.votes) ? object.votes.map((e: any) => Vote.fromSDK(e)) : [], + proposals: Array.isArray(object?.proposals) ? object.proposals.map((e: any) => Proposal.fromSDK(e)) : [], + depositParams: object.deposit_params ? DepositParams.fromSDK(object.deposit_params) : undefined, + votingParams: object.voting_params ? VotingParams.fromSDK(object.voting_params) : undefined, + tallyParams: object.tally_params ? TallyParams.fromSDK(object.tally_params) : undefined + }; + }, + fromSDKJSON(object: any): GenesisStateSDKType { + return { + starting_proposal_id: isSet(object.starting_proposal_id) ? BigInt(object.starting_proposal_id.toString()) : BigInt(0), + deposits: Array.isArray(object?.deposits) ? object.deposits.map((e: any) => Deposit.fromSDKJSON(e)) : [], + votes: Array.isArray(object?.votes) ? object.votes.map((e: any) => Vote.fromSDKJSON(e)) : [], + proposals: Array.isArray(object?.proposals) ? object.proposals.map((e: any) => Proposal.fromSDKJSON(e)) : [], + deposit_params: isSet(object.deposit_params) ? DepositParams.fromSDKJSON(object.deposit_params) : undefined, + voting_params: isSet(object.voting_params) ? VotingParams.fromSDKJSON(object.voting_params) : undefined, + tally_params: isSet(object.tally_params) ? TallyParams.fromSDKJSON(object.tally_params) : undefined + }; + }, + toSDK(message: GenesisState): GenesisStateSDKType { + const obj: any = {}; + obj.starting_proposal_id = message.startingProposalId; + if (message.deposits) { + obj.deposits = message.deposits.map(e => e ? Deposit.toSDK(e) : undefined); + } else { + obj.deposits = []; + } + if (message.votes) { + obj.votes = message.votes.map(e => e ? Vote.toSDK(e) : undefined); + } else { + obj.votes = []; + } + if (message.proposals) { + obj.proposals = message.proposals.map(e => e ? Proposal.toSDK(e) : undefined); + } else { + obj.proposals = []; + } + message.depositParams !== undefined && (obj.deposit_params = message.depositParams ? DepositParams.toSDK(message.depositParams) : undefined); + message.votingParams !== undefined && (obj.voting_params = message.votingParams ? VotingParams.toSDK(message.votingParams) : undefined); + message.tallyParams !== undefined && (obj.tally_params = message.tallyParams ? TallyParams.toSDK(message.tallyParams) : undefined); + return obj; + }, + fromAmino(object: GenesisStateAmino): GenesisState { + const message = createBaseGenesisState(); + if (object.starting_proposal_id !== undefined && object.starting_proposal_id !== null) { + message.startingProposalId = BigInt(object.starting_proposal_id); + } + message.deposits = object.deposits?.map(e => Deposit.fromAmino(e)) || []; + message.votes = object.votes?.map(e => Vote.fromAmino(e)) || []; + message.proposals = object.proposals?.map(e => Proposal.fromAmino(e)) || []; + if (object.deposit_params !== undefined && object.deposit_params !== null) { + message.depositParams = DepositParams.fromAmino(object.deposit_params); + } + if (object.voting_params !== undefined && object.voting_params !== null) { + message.votingParams = VotingParams.fromAmino(object.voting_params); + } + if (object.tally_params !== undefined && object.tally_params !== null) { + message.tallyParams = TallyParams.fromAmino(object.tally_params); + } + return message; + }, + toAmino(message: GenesisState): GenesisStateAmino { + const obj: any = {}; + obj.starting_proposal_id = message.startingProposalId !== BigInt(0) ? message.startingProposalId?.toString() : undefined; + if (message.deposits) { + obj.deposits = message.deposits.map(e => e ? Deposit.toAmino(e) : undefined); + } else { + obj.deposits = message.deposits; + } + if (message.votes) { + obj.votes = message.votes.map(e => e ? Vote.toAmino(e) : undefined); + } else { + obj.votes = message.votes; + } + if (message.proposals) { + obj.proposals = message.proposals.map(e => e ? Proposal.toAmino(e) : undefined); + } else { + obj.proposals = message.proposals; + } + obj.deposit_params = message.depositParams ? DepositParams.toAmino(message.depositParams) : undefined; + obj.voting_params = message.votingParams ? VotingParams.toAmino(message.votingParams) : undefined; + obj.tally_params = message.tallyParams ? TallyParams.toAmino(message.tallyParams) : undefined; + return obj; + }, + fromAminoMsg(object: GenesisStateAminoMsg): GenesisState { + return GenesisState.fromAmino(object.value); + }, + toAminoMsg(message: GenesisState): GenesisStateAminoMsg { + return { + type: "cosmos-sdk/v1/GenesisState", + value: GenesisState.toAmino(message) + }; + }, + fromProtoMsg(message: GenesisStateProtoMsg): GenesisState { + return GenesisState.decode(message.value); + }, + toProto(message: GenesisState): Uint8Array { + return GenesisState.encode(message).finish(); + }, + toProtoMsg(message: GenesisState): GenesisStateProtoMsg { + return { + typeUrl: "/cosmos.gov.v1.GenesisState", + value: GenesisState.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/gov/v1/gov.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/gov/v1/gov.ts new file mode 100644 index 0000000000..727f29ec9f --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/gov/v1/gov.ts @@ -0,0 +1,1483 @@ +import { Coin, CoinSDKType } from "../../base/v1beta1/coin.js"; +import { Any, AnySDKType } from "../../../google/protobuf/any.js"; +import { Timestamp, TimestampSDKType } from "../../../google/protobuf/timestamp.js"; +import { Duration, DurationSDKType } from "../../../google/protobuf/duration.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial, toTimestamp, fromTimestamp } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "cosmos.gov.v1"; +/** VoteOption enumerates the valid vote options for a given governance proposal. */ +export enum VoteOption { + /** VOTE_OPTION_UNSPECIFIED - VOTE_OPTION_UNSPECIFIED defines a no-op vote option. */ + VOTE_OPTION_UNSPECIFIED = 0, + /** VOTE_OPTION_YES - VOTE_OPTION_YES defines a yes vote option. */ + VOTE_OPTION_YES = 1, + /** VOTE_OPTION_ABSTAIN - VOTE_OPTION_ABSTAIN defines an abstain vote option. */ + VOTE_OPTION_ABSTAIN = 2, + /** VOTE_OPTION_NO - VOTE_OPTION_NO defines a no vote option. */ + VOTE_OPTION_NO = 3, + /** VOTE_OPTION_NO_WITH_VETO - VOTE_OPTION_NO_WITH_VETO defines a no with veto vote option. */ + VOTE_OPTION_NO_WITH_VETO = 4, + UNRECOGNIZED = -1, +} +export const VoteOptionSDKType = VoteOption; +export function voteOptionFromJSON(object: any): VoteOption { + switch (object) { + case 0: + case "VOTE_OPTION_UNSPECIFIED": + return VoteOption.VOTE_OPTION_UNSPECIFIED; + case 1: + case "VOTE_OPTION_YES": + return VoteOption.VOTE_OPTION_YES; + case 2: + case "VOTE_OPTION_ABSTAIN": + return VoteOption.VOTE_OPTION_ABSTAIN; + case 3: + case "VOTE_OPTION_NO": + return VoteOption.VOTE_OPTION_NO; + case 4: + case "VOTE_OPTION_NO_WITH_VETO": + return VoteOption.VOTE_OPTION_NO_WITH_VETO; + case -1: + case "UNRECOGNIZED": + default: + return VoteOption.UNRECOGNIZED; + } +} +export function voteOptionToJSON(object: VoteOption): string { + switch (object) { + case VoteOption.VOTE_OPTION_UNSPECIFIED: + return "VOTE_OPTION_UNSPECIFIED"; + case VoteOption.VOTE_OPTION_YES: + return "VOTE_OPTION_YES"; + case VoteOption.VOTE_OPTION_ABSTAIN: + return "VOTE_OPTION_ABSTAIN"; + case VoteOption.VOTE_OPTION_NO: + return "VOTE_OPTION_NO"; + case VoteOption.VOTE_OPTION_NO_WITH_VETO: + return "VOTE_OPTION_NO_WITH_VETO"; + case VoteOption.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** ProposalStatus enumerates the valid statuses of a proposal. */ +export enum ProposalStatus { + /** PROPOSAL_STATUS_UNSPECIFIED - PROPOSAL_STATUS_UNSPECIFIED defines the default propopsal status. */ + PROPOSAL_STATUS_UNSPECIFIED = 0, + /** + * PROPOSAL_STATUS_DEPOSIT_PERIOD - PROPOSAL_STATUS_DEPOSIT_PERIOD defines a proposal status during the deposit + * period. + */ + PROPOSAL_STATUS_DEPOSIT_PERIOD = 1, + /** + * PROPOSAL_STATUS_VOTING_PERIOD - PROPOSAL_STATUS_VOTING_PERIOD defines a proposal status during the voting + * period. + */ + PROPOSAL_STATUS_VOTING_PERIOD = 2, + /** + * PROPOSAL_STATUS_PASSED - PROPOSAL_STATUS_PASSED defines a proposal status of a proposal that has + * passed. + */ + PROPOSAL_STATUS_PASSED = 3, + /** + * PROPOSAL_STATUS_REJECTED - PROPOSAL_STATUS_REJECTED defines a proposal status of a proposal that has + * been rejected. + */ + PROPOSAL_STATUS_REJECTED = 4, + /** + * PROPOSAL_STATUS_FAILED - PROPOSAL_STATUS_FAILED defines a proposal status of a proposal that has + * failed. + */ + PROPOSAL_STATUS_FAILED = 5, + UNRECOGNIZED = -1, +} +export const ProposalStatusSDKType = ProposalStatus; +export function proposalStatusFromJSON(object: any): ProposalStatus { + switch (object) { + case 0: + case "PROPOSAL_STATUS_UNSPECIFIED": + return ProposalStatus.PROPOSAL_STATUS_UNSPECIFIED; + case 1: + case "PROPOSAL_STATUS_DEPOSIT_PERIOD": + return ProposalStatus.PROPOSAL_STATUS_DEPOSIT_PERIOD; + case 2: + case "PROPOSAL_STATUS_VOTING_PERIOD": + return ProposalStatus.PROPOSAL_STATUS_VOTING_PERIOD; + case 3: + case "PROPOSAL_STATUS_PASSED": + return ProposalStatus.PROPOSAL_STATUS_PASSED; + case 4: + case "PROPOSAL_STATUS_REJECTED": + return ProposalStatus.PROPOSAL_STATUS_REJECTED; + case 5: + case "PROPOSAL_STATUS_FAILED": + return ProposalStatus.PROPOSAL_STATUS_FAILED; + case -1: + case "UNRECOGNIZED": + default: + return ProposalStatus.UNRECOGNIZED; + } +} +export function proposalStatusToJSON(object: ProposalStatus): string { + switch (object) { + case ProposalStatus.PROPOSAL_STATUS_UNSPECIFIED: + return "PROPOSAL_STATUS_UNSPECIFIED"; + case ProposalStatus.PROPOSAL_STATUS_DEPOSIT_PERIOD: + return "PROPOSAL_STATUS_DEPOSIT_PERIOD"; + case ProposalStatus.PROPOSAL_STATUS_VOTING_PERIOD: + return "PROPOSAL_STATUS_VOTING_PERIOD"; + case ProposalStatus.PROPOSAL_STATUS_PASSED: + return "PROPOSAL_STATUS_PASSED"; + case ProposalStatus.PROPOSAL_STATUS_REJECTED: + return "PROPOSAL_STATUS_REJECTED"; + case ProposalStatus.PROPOSAL_STATUS_FAILED: + return "PROPOSAL_STATUS_FAILED"; + case ProposalStatus.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** WeightedVoteOption defines a unit of vote for vote split. */ +export interface WeightedVoteOption { + option: VoteOption; + weight: string; +} +export interface WeightedVoteOptionProtoMsg { + typeUrl: "/cosmos.gov.v1.WeightedVoteOption"; + value: Uint8Array; +} +/** WeightedVoteOption defines a unit of vote for vote split. */ +export interface WeightedVoteOptionSDKType { + option: VoteOption; + weight: string; +} +/** + * Deposit defines an amount deposited by an account address to an active + * proposal. + */ +export interface Deposit { + proposalId: bigint; + depositor: string; + amount: Coin[]; +} +export interface DepositProtoMsg { + typeUrl: "/cosmos.gov.v1.Deposit"; + value: Uint8Array; +} +/** + * Deposit defines an amount deposited by an account address to an active + * proposal. + */ +export interface DepositSDKType { + proposal_id: bigint; + depositor: string; + amount: CoinSDKType[]; +} +/** Proposal defines the core field members of a governance proposal. */ +export interface Proposal { + id: bigint; + messages: Any[]; + status: ProposalStatus; + /** + * final_tally_result is the final tally result of the proposal. When + * querying a proposal via gRPC, this field is not populated until the + * proposal's voting period has ended. + */ + finalTallyResult?: TallyResult; + submitTime?: Date; + depositEndTime?: Date; + totalDeposit: Coin[]; + votingStartTime?: Date; + votingEndTime?: Date; + /** metadata is any arbitrary metadata attached to the proposal. */ + metadata: string; +} +export interface ProposalProtoMsg { + typeUrl: "/cosmos.gov.v1.Proposal"; + value: Uint8Array; +} +/** Proposal defines the core field members of a governance proposal. */ +export interface ProposalSDKType { + id: bigint; + messages: AnySDKType[]; + status: ProposalStatus; + final_tally_result?: TallyResultSDKType; + submit_time?: Date; + deposit_end_time?: Date; + total_deposit: CoinSDKType[]; + voting_start_time?: Date; + voting_end_time?: Date; + metadata: string; +} +/** TallyResult defines a standard tally for a governance proposal. */ +export interface TallyResult { + yesCount: string; + abstainCount: string; + noCount: string; + noWithVetoCount: string; +} +export interface TallyResultProtoMsg { + typeUrl: "/cosmos.gov.v1.TallyResult"; + value: Uint8Array; +} +/** TallyResult defines a standard tally for a governance proposal. */ +export interface TallyResultSDKType { + yes_count: string; + abstain_count: string; + no_count: string; + no_with_veto_count: string; +} +/** + * Vote defines a vote on a governance proposal. + * A Vote consists of a proposal ID, the voter, and the vote option. + */ +export interface Vote { + proposalId: bigint; + voter: string; + options: WeightedVoteOption[]; + /** metadata is any arbitrary metadata to attached to the vote. */ + metadata: string; +} +export interface VoteProtoMsg { + typeUrl: "/cosmos.gov.v1.Vote"; + value: Uint8Array; +} +/** + * Vote defines a vote on a governance proposal. + * A Vote consists of a proposal ID, the voter, and the vote option. + */ +export interface VoteSDKType { + proposal_id: bigint; + voter: string; + options: WeightedVoteOptionSDKType[]; + metadata: string; +} +/** DepositParams defines the params for deposits on governance proposals. */ +export interface DepositParams { + /** Minimum deposit for a proposal to enter voting period. */ + minDeposit: Coin[]; + /** + * Maximum period for Atom holders to deposit on a proposal. Initial value: 2 + * months. + */ + maxDepositPeriod?: Duration; +} +export interface DepositParamsProtoMsg { + typeUrl: "/cosmos.gov.v1.DepositParams"; + value: Uint8Array; +} +/** DepositParams defines the params for deposits on governance proposals. */ +export interface DepositParamsSDKType { + min_deposit: CoinSDKType[]; + max_deposit_period?: DurationSDKType; +} +/** VotingParams defines the params for voting on governance proposals. */ +export interface VotingParams { + /** Length of the voting period. */ + votingPeriod?: Duration; +} +export interface VotingParamsProtoMsg { + typeUrl: "/cosmos.gov.v1.VotingParams"; + value: Uint8Array; +} +/** VotingParams defines the params for voting on governance proposals. */ +export interface VotingParamsSDKType { + voting_period?: DurationSDKType; +} +/** TallyParams defines the params for tallying votes on governance proposals. */ +export interface TallyParams { + /** + * Minimum percentage of total stake needed to vote for a result to be + * considered valid. + */ + quorum: string; + /** Minimum proportion of Yes votes for proposal to pass. Default value: 0.5. */ + threshold: string; + /** + * Minimum value of Veto votes to Total votes ratio for proposal to be + * vetoed. Default value: 1/3. + */ + vetoThreshold: string; +} +export interface TallyParamsProtoMsg { + typeUrl: "/cosmos.gov.v1.TallyParams"; + value: Uint8Array; +} +/** TallyParams defines the params for tallying votes on governance proposals. */ +export interface TallyParamsSDKType { + quorum: string; + threshold: string; + veto_threshold: string; +} +function createBaseWeightedVoteOption(): WeightedVoteOption { + return { + option: 0, + weight: "" + }; +} +export const WeightedVoteOption = { + typeUrl: "/cosmos.gov.v1.WeightedVoteOption", + encode(message: WeightedVoteOption, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.option !== 0) { + writer.uint32(8).int32(message.option); + } + if (message.weight !== undefined) { + writer.uint32(18).string(message.weight); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): WeightedVoteOption { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseWeightedVoteOption(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.option = (reader.int32() as any); + break; + case 2: + message.weight = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): WeightedVoteOption { + const obj = createBaseWeightedVoteOption(); + if (isSet(object.option)) obj.option = voteOptionFromJSON(object.option); + if (isSet(object.weight)) obj.weight = String(object.weight); + return obj; + }, + toJSON(message: WeightedVoteOption): JsonSafe { + const obj: any = {}; + message.option !== undefined && (obj.option = voteOptionToJSON(message.option)); + message.weight !== undefined && (obj.weight = message.weight); + return obj; + }, + fromPartial(object: DeepPartial): WeightedVoteOption { + const message = createBaseWeightedVoteOption(); + message.option = object.option ?? 0; + message.weight = object.weight ?? ""; + return message; + }, + fromSDK(object: WeightedVoteOptionSDKType): WeightedVoteOption { + return { + option: isSet(object.option) ? voteOptionFromJSON(object.option) : -1, + weight: object?.weight + }; + }, + fromSDKJSON(object: any): WeightedVoteOptionSDKType { + return { + option: isSet(object.option) ? voteOptionFromJSON(object.option) : -1, + weight: isSet(object.weight) ? String(object.weight) : "" + }; + }, + toSDK(message: WeightedVoteOption): WeightedVoteOptionSDKType { + const obj: any = {}; + message.option !== undefined && (obj.option = voteOptionToJSON(message.option)); + obj.weight = message.weight; + return obj; + }, + fromAmino(object: WeightedVoteOptionAmino): WeightedVoteOption { + const message = createBaseWeightedVoteOption(); + if (object.option !== undefined && object.option !== null) { + message.option = object.option; + } + if (object.weight !== undefined && object.weight !== null) { + message.weight = object.weight; + } + return message; + }, + toAmino(message: WeightedVoteOption): WeightedVoteOptionAmino { + const obj: any = {}; + obj.option = message.option === 0 ? undefined : message.option; + obj.weight = message.weight === "" ? undefined : message.weight; + return obj; + }, + fromAminoMsg(object: WeightedVoteOptionAminoMsg): WeightedVoteOption { + return WeightedVoteOption.fromAmino(object.value); + }, + toAminoMsg(message: WeightedVoteOption): WeightedVoteOptionAminoMsg { + return { + type: "cosmos-sdk/v1/WeightedVoteOption", + value: WeightedVoteOption.toAmino(message) + }; + }, + fromProtoMsg(message: WeightedVoteOptionProtoMsg): WeightedVoteOption { + return WeightedVoteOption.decode(message.value); + }, + toProto(message: WeightedVoteOption): Uint8Array { + return WeightedVoteOption.encode(message).finish(); + }, + toProtoMsg(message: WeightedVoteOption): WeightedVoteOptionProtoMsg { + return { + typeUrl: "/cosmos.gov.v1.WeightedVoteOption", + value: WeightedVoteOption.encode(message).finish() + }; + } +}; +function createBaseDeposit(): Deposit { + return { + proposalId: BigInt(0), + depositor: "", + amount: [] + }; +} +export const Deposit = { + typeUrl: "/cosmos.gov.v1.Deposit", + encode(message: Deposit, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.proposalId !== undefined) { + writer.uint32(8).uint64(message.proposalId); + } + if (message.depositor !== undefined) { + writer.uint32(18).string(message.depositor); + } + for (const v of message.amount) { + Coin.encode(v!, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Deposit { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDeposit(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.proposalId = reader.uint64(); + break; + case 2: + message.depositor = reader.string(); + break; + case 3: + message.amount.push(Coin.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Deposit { + const obj = createBaseDeposit(); + if (isSet(object.proposalId)) obj.proposalId = BigInt(object.proposalId.toString()); + if (isSet(object.depositor)) obj.depositor = String(object.depositor); + if (Array.isArray(object?.amount)) obj.amount = object.amount.map((e: any) => Coin.fromJSON(e)); + return obj; + }, + toJSON(message: Deposit): JsonSafe { + const obj: any = {}; + message.proposalId !== undefined && (obj.proposalId = (message.proposalId || BigInt(0)).toString()); + message.depositor !== undefined && (obj.depositor = message.depositor); + if (message.amount) { + obj.amount = message.amount.map(e => e ? Coin.toJSON(e) : undefined); + } else { + obj.amount = []; + } + return obj; + }, + fromPartial(object: DeepPartial): Deposit { + const message = createBaseDeposit(); + if (object.proposalId !== undefined && object.proposalId !== null) { + message.proposalId = BigInt(object.proposalId.toString()); + } + message.depositor = object.depositor ?? ""; + message.amount = object.amount?.map(e => Coin.fromPartial(e)) || []; + return message; + }, + fromSDK(object: DepositSDKType): Deposit { + return { + proposalId: object?.proposal_id, + depositor: object?.depositor, + amount: Array.isArray(object?.amount) ? object.amount.map((e: any) => Coin.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): DepositSDKType { + return { + proposal_id: isSet(object.proposal_id) ? BigInt(object.proposal_id.toString()) : BigInt(0), + depositor: isSet(object.depositor) ? String(object.depositor) : "", + amount: Array.isArray(object?.amount) ? object.amount.map((e: any) => Coin.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: Deposit): DepositSDKType { + const obj: any = {}; + obj.proposal_id = message.proposalId; + obj.depositor = message.depositor; + if (message.amount) { + obj.amount = message.amount.map(e => e ? Coin.toSDK(e) : undefined); + } else { + obj.amount = []; + } + return obj; + }, + fromAmino(object: DepositAmino): Deposit { + const message = createBaseDeposit(); + if (object.proposal_id !== undefined && object.proposal_id !== null) { + message.proposalId = BigInt(object.proposal_id); + } + if (object.depositor !== undefined && object.depositor !== null) { + message.depositor = object.depositor; + } + message.amount = object.amount?.map(e => Coin.fromAmino(e)) || []; + return message; + }, + toAmino(message: Deposit): DepositAmino { + const obj: any = {}; + obj.proposal_id = message.proposalId !== BigInt(0) ? message.proposalId?.toString() : undefined; + obj.depositor = message.depositor === "" ? undefined : message.depositor; + if (message.amount) { + obj.amount = message.amount.map(e => e ? Coin.toAmino(e) : undefined); + } else { + obj.amount = message.amount; + } + return obj; + }, + fromAminoMsg(object: DepositAminoMsg): Deposit { + return Deposit.fromAmino(object.value); + }, + toAminoMsg(message: Deposit): DepositAminoMsg { + return { + type: "cosmos-sdk/v1/Deposit", + value: Deposit.toAmino(message) + }; + }, + fromProtoMsg(message: DepositProtoMsg): Deposit { + return Deposit.decode(message.value); + }, + toProto(message: Deposit): Uint8Array { + return Deposit.encode(message).finish(); + }, + toProtoMsg(message: Deposit): DepositProtoMsg { + return { + typeUrl: "/cosmos.gov.v1.Deposit", + value: Deposit.encode(message).finish() + }; + } +}; +function createBaseProposal(): Proposal { + return { + id: BigInt(0), + messages: [], + status: 0, + finalTallyResult: undefined, + submitTime: undefined, + depositEndTime: undefined, + totalDeposit: [], + votingStartTime: undefined, + votingEndTime: undefined, + metadata: "" + }; +} +export const Proposal = { + typeUrl: "/cosmos.gov.v1.Proposal", + encode(message: Proposal, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.id !== undefined) { + writer.uint32(8).uint64(message.id); + } + for (const v of message.messages) { + Any.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.status !== 0) { + writer.uint32(24).int32(message.status); + } + if (message.finalTallyResult !== undefined) { + TallyResult.encode(message.finalTallyResult, writer.uint32(34).fork()).ldelim(); + } + if (message.submitTime !== undefined) { + Timestamp.encode(toTimestamp(message.submitTime), writer.uint32(42).fork()).ldelim(); + } + if (message.depositEndTime !== undefined) { + Timestamp.encode(toTimestamp(message.depositEndTime), writer.uint32(50).fork()).ldelim(); + } + for (const v of message.totalDeposit) { + Coin.encode(v!, writer.uint32(58).fork()).ldelim(); + } + if (message.votingStartTime !== undefined) { + Timestamp.encode(toTimestamp(message.votingStartTime), writer.uint32(66).fork()).ldelim(); + } + if (message.votingEndTime !== undefined) { + Timestamp.encode(toTimestamp(message.votingEndTime), writer.uint32(74).fork()).ldelim(); + } + if (message.metadata !== undefined) { + writer.uint32(82).string(message.metadata); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Proposal { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseProposal(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.id = reader.uint64(); + break; + case 2: + message.messages.push(Any.decode(reader, reader.uint32())); + break; + case 3: + message.status = (reader.int32() as any); + break; + case 4: + message.finalTallyResult = TallyResult.decode(reader, reader.uint32()); + break; + case 5: + message.submitTime = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + break; + case 6: + message.depositEndTime = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + break; + case 7: + message.totalDeposit.push(Coin.decode(reader, reader.uint32())); + break; + case 8: + message.votingStartTime = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + break; + case 9: + message.votingEndTime = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + break; + case 10: + message.metadata = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Proposal { + const obj = createBaseProposal(); + if (isSet(object.id)) obj.id = BigInt(object.id.toString()); + if (Array.isArray(object?.messages)) obj.messages = object.messages.map((e: any) => Any.fromJSON(e)); + if (isSet(object.status)) obj.status = proposalStatusFromJSON(object.status); + if (isSet(object.finalTallyResult)) obj.finalTallyResult = TallyResult.fromJSON(object.finalTallyResult); + if (isSet(object.submitTime)) obj.submitTime = new Date(object.submitTime); + if (isSet(object.depositEndTime)) obj.depositEndTime = new Date(object.depositEndTime); + if (Array.isArray(object?.totalDeposit)) obj.totalDeposit = object.totalDeposit.map((e: any) => Coin.fromJSON(e)); + if (isSet(object.votingStartTime)) obj.votingStartTime = new Date(object.votingStartTime); + if (isSet(object.votingEndTime)) obj.votingEndTime = new Date(object.votingEndTime); + if (isSet(object.metadata)) obj.metadata = String(object.metadata); + return obj; + }, + toJSON(message: Proposal): JsonSafe { + const obj: any = {}; + message.id !== undefined && (obj.id = (message.id || BigInt(0)).toString()); + if (message.messages) { + obj.messages = message.messages.map(e => e ? Any.toJSON(e) : undefined); + } else { + obj.messages = []; + } + message.status !== undefined && (obj.status = proposalStatusToJSON(message.status)); + message.finalTallyResult !== undefined && (obj.finalTallyResult = message.finalTallyResult ? TallyResult.toJSON(message.finalTallyResult) : undefined); + message.submitTime !== undefined && (obj.submitTime = message.submitTime.toISOString()); + message.depositEndTime !== undefined && (obj.depositEndTime = message.depositEndTime.toISOString()); + if (message.totalDeposit) { + obj.totalDeposit = message.totalDeposit.map(e => e ? Coin.toJSON(e) : undefined); + } else { + obj.totalDeposit = []; + } + message.votingStartTime !== undefined && (obj.votingStartTime = message.votingStartTime.toISOString()); + message.votingEndTime !== undefined && (obj.votingEndTime = message.votingEndTime.toISOString()); + message.metadata !== undefined && (obj.metadata = message.metadata); + return obj; + }, + fromPartial(object: DeepPartial): Proposal { + const message = createBaseProposal(); + if (object.id !== undefined && object.id !== null) { + message.id = BigInt(object.id.toString()); + } + message.messages = object.messages?.map(e => Any.fromPartial(e)) || []; + message.status = object.status ?? 0; + if (object.finalTallyResult !== undefined && object.finalTallyResult !== null) { + message.finalTallyResult = TallyResult.fromPartial(object.finalTallyResult); + } + message.submitTime = object.submitTime ?? undefined; + message.depositEndTime = object.depositEndTime ?? undefined; + message.totalDeposit = object.totalDeposit?.map(e => Coin.fromPartial(e)) || []; + message.votingStartTime = object.votingStartTime ?? undefined; + message.votingEndTime = object.votingEndTime ?? undefined; + message.metadata = object.metadata ?? ""; + return message; + }, + fromSDK(object: ProposalSDKType): Proposal { + return { + id: object?.id, + messages: Array.isArray(object?.messages) ? object.messages.map((e: any) => Any.fromSDK(e)) : [], + status: isSet(object.status) ? proposalStatusFromJSON(object.status) : -1, + finalTallyResult: object.final_tally_result ? TallyResult.fromSDK(object.final_tally_result) : undefined, + submitTime: object.submit_time ?? undefined, + depositEndTime: object.deposit_end_time ?? undefined, + totalDeposit: Array.isArray(object?.total_deposit) ? object.total_deposit.map((e: any) => Coin.fromSDK(e)) : [], + votingStartTime: object.voting_start_time ?? undefined, + votingEndTime: object.voting_end_time ?? undefined, + metadata: object?.metadata + }; + }, + fromSDKJSON(object: any): ProposalSDKType { + return { + id: isSet(object.id) ? BigInt(object.id.toString()) : BigInt(0), + messages: Array.isArray(object?.messages) ? object.messages.map((e: any) => Any.fromSDKJSON(e)) : [], + status: isSet(object.status) ? proposalStatusFromJSON(object.status) : -1, + final_tally_result: isSet(object.final_tally_result) ? TallyResult.fromSDKJSON(object.final_tally_result) : undefined, + submit_time: isSet(object.submit_time) ? new Date(object.submit_time) : undefined, + deposit_end_time: isSet(object.deposit_end_time) ? new Date(object.deposit_end_time) : undefined, + total_deposit: Array.isArray(object?.total_deposit) ? object.total_deposit.map((e: any) => Coin.fromSDKJSON(e)) : [], + voting_start_time: isSet(object.voting_start_time) ? new Date(object.voting_start_time) : undefined, + voting_end_time: isSet(object.voting_end_time) ? new Date(object.voting_end_time) : undefined, + metadata: isSet(object.metadata) ? String(object.metadata) : "" + }; + }, + toSDK(message: Proposal): ProposalSDKType { + const obj: any = {}; + obj.id = message.id; + if (message.messages) { + obj.messages = message.messages.map(e => e ? Any.toSDK(e) : undefined); + } else { + obj.messages = []; + } + message.status !== undefined && (obj.status = proposalStatusToJSON(message.status)); + message.finalTallyResult !== undefined && (obj.final_tally_result = message.finalTallyResult ? TallyResult.toSDK(message.finalTallyResult) : undefined); + message.submitTime !== undefined && (obj.submit_time = message.submitTime ?? undefined); + message.depositEndTime !== undefined && (obj.deposit_end_time = message.depositEndTime ?? undefined); + if (message.totalDeposit) { + obj.total_deposit = message.totalDeposit.map(e => e ? Coin.toSDK(e) : undefined); + } else { + obj.total_deposit = []; + } + message.votingStartTime !== undefined && (obj.voting_start_time = message.votingStartTime ?? undefined); + message.votingEndTime !== undefined && (obj.voting_end_time = message.votingEndTime ?? undefined); + obj.metadata = message.metadata; + return obj; + }, + fromAmino(object: ProposalAmino): Proposal { + const message = createBaseProposal(); + if (object.id !== undefined && object.id !== null) { + message.id = BigInt(object.id); + } + message.messages = object.messages?.map(e => Any.fromAmino(e)) || []; + if (object.status !== undefined && object.status !== null) { + message.status = object.status; + } + if (object.final_tally_result !== undefined && object.final_tally_result !== null) { + message.finalTallyResult = TallyResult.fromAmino(object.final_tally_result); + } + if (object.submit_time !== undefined && object.submit_time !== null) { + message.submitTime = fromTimestamp(Timestamp.fromAmino(object.submit_time)); + } + if (object.deposit_end_time !== undefined && object.deposit_end_time !== null) { + message.depositEndTime = fromTimestamp(Timestamp.fromAmino(object.deposit_end_time)); + } + message.totalDeposit = object.total_deposit?.map(e => Coin.fromAmino(e)) || []; + if (object.voting_start_time !== undefined && object.voting_start_time !== null) { + message.votingStartTime = fromTimestamp(Timestamp.fromAmino(object.voting_start_time)); + } + if (object.voting_end_time !== undefined && object.voting_end_time !== null) { + message.votingEndTime = fromTimestamp(Timestamp.fromAmino(object.voting_end_time)); + } + if (object.metadata !== undefined && object.metadata !== null) { + message.metadata = object.metadata; + } + return message; + }, + toAmino(message: Proposal): ProposalAmino { + const obj: any = {}; + obj.id = message.id !== BigInt(0) ? message.id?.toString() : undefined; + if (message.messages) { + obj.messages = message.messages.map(e => e ? Any.toAmino(e) : undefined); + } else { + obj.messages = message.messages; + } + obj.status = message.status === 0 ? undefined : message.status; + obj.final_tally_result = message.finalTallyResult ? TallyResult.toAmino(message.finalTallyResult) : undefined; + obj.submit_time = message.submitTime ? Timestamp.toAmino(toTimestamp(message.submitTime)) : undefined; + obj.deposit_end_time = message.depositEndTime ? Timestamp.toAmino(toTimestamp(message.depositEndTime)) : undefined; + if (message.totalDeposit) { + obj.total_deposit = message.totalDeposit.map(e => e ? Coin.toAmino(e) : undefined); + } else { + obj.total_deposit = message.totalDeposit; + } + obj.voting_start_time = message.votingStartTime ? Timestamp.toAmino(toTimestamp(message.votingStartTime)) : undefined; + obj.voting_end_time = message.votingEndTime ? Timestamp.toAmino(toTimestamp(message.votingEndTime)) : undefined; + obj.metadata = message.metadata === "" ? undefined : message.metadata; + return obj; + }, + fromAminoMsg(object: ProposalAminoMsg): Proposal { + return Proposal.fromAmino(object.value); + }, + toAminoMsg(message: Proposal): ProposalAminoMsg { + return { + type: "cosmos-sdk/v1/Proposal", + value: Proposal.toAmino(message) + }; + }, + fromProtoMsg(message: ProposalProtoMsg): Proposal { + return Proposal.decode(message.value); + }, + toProto(message: Proposal): Uint8Array { + return Proposal.encode(message).finish(); + }, + toProtoMsg(message: Proposal): ProposalProtoMsg { + return { + typeUrl: "/cosmos.gov.v1.Proposal", + value: Proposal.encode(message).finish() + }; + } +}; +function createBaseTallyResult(): TallyResult { + return { + yesCount: "", + abstainCount: "", + noCount: "", + noWithVetoCount: "" + }; +} +export const TallyResult = { + typeUrl: "/cosmos.gov.v1.TallyResult", + encode(message: TallyResult, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.yesCount !== undefined) { + writer.uint32(10).string(message.yesCount); + } + if (message.abstainCount !== undefined) { + writer.uint32(18).string(message.abstainCount); + } + if (message.noCount !== undefined) { + writer.uint32(26).string(message.noCount); + } + if (message.noWithVetoCount !== undefined) { + writer.uint32(34).string(message.noWithVetoCount); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): TallyResult { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseTallyResult(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.yesCount = reader.string(); + break; + case 2: + message.abstainCount = reader.string(); + break; + case 3: + message.noCount = reader.string(); + break; + case 4: + message.noWithVetoCount = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): TallyResult { + const obj = createBaseTallyResult(); + if (isSet(object.yesCount)) obj.yesCount = String(object.yesCount); + if (isSet(object.abstainCount)) obj.abstainCount = String(object.abstainCount); + if (isSet(object.noCount)) obj.noCount = String(object.noCount); + if (isSet(object.noWithVetoCount)) obj.noWithVetoCount = String(object.noWithVetoCount); + return obj; + }, + toJSON(message: TallyResult): JsonSafe { + const obj: any = {}; + message.yesCount !== undefined && (obj.yesCount = message.yesCount); + message.abstainCount !== undefined && (obj.abstainCount = message.abstainCount); + message.noCount !== undefined && (obj.noCount = message.noCount); + message.noWithVetoCount !== undefined && (obj.noWithVetoCount = message.noWithVetoCount); + return obj; + }, + fromPartial(object: DeepPartial): TallyResult { + const message = createBaseTallyResult(); + message.yesCount = object.yesCount ?? ""; + message.abstainCount = object.abstainCount ?? ""; + message.noCount = object.noCount ?? ""; + message.noWithVetoCount = object.noWithVetoCount ?? ""; + return message; + }, + fromSDK(object: TallyResultSDKType): TallyResult { + return { + yesCount: object?.yes_count, + abstainCount: object?.abstain_count, + noCount: object?.no_count, + noWithVetoCount: object?.no_with_veto_count + }; + }, + fromSDKJSON(object: any): TallyResultSDKType { + return { + yes_count: isSet(object.yes_count) ? String(object.yes_count) : "", + abstain_count: isSet(object.abstain_count) ? String(object.abstain_count) : "", + no_count: isSet(object.no_count) ? String(object.no_count) : "", + no_with_veto_count: isSet(object.no_with_veto_count) ? String(object.no_with_veto_count) : "" + }; + }, + toSDK(message: TallyResult): TallyResultSDKType { + const obj: any = {}; + obj.yes_count = message.yesCount; + obj.abstain_count = message.abstainCount; + obj.no_count = message.noCount; + obj.no_with_veto_count = message.noWithVetoCount; + return obj; + }, + fromAmino(object: TallyResultAmino): TallyResult { + const message = createBaseTallyResult(); + if (object.yes_count !== undefined && object.yes_count !== null) { + message.yesCount = object.yes_count; + } + if (object.abstain_count !== undefined && object.abstain_count !== null) { + message.abstainCount = object.abstain_count; + } + if (object.no_count !== undefined && object.no_count !== null) { + message.noCount = object.no_count; + } + if (object.no_with_veto_count !== undefined && object.no_with_veto_count !== null) { + message.noWithVetoCount = object.no_with_veto_count; + } + return message; + }, + toAmino(message: TallyResult): TallyResultAmino { + const obj: any = {}; + obj.yes_count = message.yesCount === "" ? undefined : message.yesCount; + obj.abstain_count = message.abstainCount === "" ? undefined : message.abstainCount; + obj.no_count = message.noCount === "" ? undefined : message.noCount; + obj.no_with_veto_count = message.noWithVetoCount === "" ? undefined : message.noWithVetoCount; + return obj; + }, + fromAminoMsg(object: TallyResultAminoMsg): TallyResult { + return TallyResult.fromAmino(object.value); + }, + toAminoMsg(message: TallyResult): TallyResultAminoMsg { + return { + type: "cosmos-sdk/v1/TallyResult", + value: TallyResult.toAmino(message) + }; + }, + fromProtoMsg(message: TallyResultProtoMsg): TallyResult { + return TallyResult.decode(message.value); + }, + toProto(message: TallyResult): Uint8Array { + return TallyResult.encode(message).finish(); + }, + toProtoMsg(message: TallyResult): TallyResultProtoMsg { + return { + typeUrl: "/cosmos.gov.v1.TallyResult", + value: TallyResult.encode(message).finish() + }; + } +}; +function createBaseVote(): Vote { + return { + proposalId: BigInt(0), + voter: "", + options: [], + metadata: "" + }; +} +export const Vote = { + typeUrl: "/cosmos.gov.v1.Vote", + encode(message: Vote, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.proposalId !== undefined) { + writer.uint32(8).uint64(message.proposalId); + } + if (message.voter !== undefined) { + writer.uint32(18).string(message.voter); + } + for (const v of message.options) { + WeightedVoteOption.encode(v!, writer.uint32(34).fork()).ldelim(); + } + if (message.metadata !== undefined) { + writer.uint32(42).string(message.metadata); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Vote { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseVote(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.proposalId = reader.uint64(); + break; + case 2: + message.voter = reader.string(); + break; + case 4: + message.options.push(WeightedVoteOption.decode(reader, reader.uint32())); + break; + case 5: + message.metadata = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Vote { + const obj = createBaseVote(); + if (isSet(object.proposalId)) obj.proposalId = BigInt(object.proposalId.toString()); + if (isSet(object.voter)) obj.voter = String(object.voter); + if (Array.isArray(object?.options)) obj.options = object.options.map((e: any) => WeightedVoteOption.fromJSON(e)); + if (isSet(object.metadata)) obj.metadata = String(object.metadata); + return obj; + }, + toJSON(message: Vote): JsonSafe { + const obj: any = {}; + message.proposalId !== undefined && (obj.proposalId = (message.proposalId || BigInt(0)).toString()); + message.voter !== undefined && (obj.voter = message.voter); + if (message.options) { + obj.options = message.options.map(e => e ? WeightedVoteOption.toJSON(e) : undefined); + } else { + obj.options = []; + } + message.metadata !== undefined && (obj.metadata = message.metadata); + return obj; + }, + fromPartial(object: DeepPartial): Vote { + const message = createBaseVote(); + if (object.proposalId !== undefined && object.proposalId !== null) { + message.proposalId = BigInt(object.proposalId.toString()); + } + message.voter = object.voter ?? ""; + message.options = object.options?.map(e => WeightedVoteOption.fromPartial(e)) || []; + message.metadata = object.metadata ?? ""; + return message; + }, + fromSDK(object: VoteSDKType): Vote { + return { + proposalId: object?.proposal_id, + voter: object?.voter, + options: Array.isArray(object?.options) ? object.options.map((e: any) => WeightedVoteOption.fromSDK(e)) : [], + metadata: object?.metadata + }; + }, + fromSDKJSON(object: any): VoteSDKType { + return { + proposal_id: isSet(object.proposal_id) ? BigInt(object.proposal_id.toString()) : BigInt(0), + voter: isSet(object.voter) ? String(object.voter) : "", + options: Array.isArray(object?.options) ? object.options.map((e: any) => WeightedVoteOption.fromSDKJSON(e)) : [], + metadata: isSet(object.metadata) ? String(object.metadata) : "" + }; + }, + toSDK(message: Vote): VoteSDKType { + const obj: any = {}; + obj.proposal_id = message.proposalId; + obj.voter = message.voter; + if (message.options) { + obj.options = message.options.map(e => e ? WeightedVoteOption.toSDK(e) : undefined); + } else { + obj.options = []; + } + obj.metadata = message.metadata; + return obj; + }, + fromAmino(object: VoteAmino): Vote { + const message = createBaseVote(); + if (object.proposal_id !== undefined && object.proposal_id !== null) { + message.proposalId = BigInt(object.proposal_id); + } + if (object.voter !== undefined && object.voter !== null) { + message.voter = object.voter; + } + message.options = object.options?.map(e => WeightedVoteOption.fromAmino(e)) || []; + if (object.metadata !== undefined && object.metadata !== null) { + message.metadata = object.metadata; + } + return message; + }, + toAmino(message: Vote): VoteAmino { + const obj: any = {}; + obj.proposal_id = message.proposalId !== BigInt(0) ? message.proposalId?.toString() : undefined; + obj.voter = message.voter === "" ? undefined : message.voter; + if (message.options) { + obj.options = message.options.map(e => e ? WeightedVoteOption.toAmino(e) : undefined); + } else { + obj.options = message.options; + } + obj.metadata = message.metadata === "" ? undefined : message.metadata; + return obj; + }, + fromAminoMsg(object: VoteAminoMsg): Vote { + return Vote.fromAmino(object.value); + }, + toAminoMsg(message: Vote): VoteAminoMsg { + return { + type: "cosmos-sdk/v1/Vote", + value: Vote.toAmino(message) + }; + }, + fromProtoMsg(message: VoteProtoMsg): Vote { + return Vote.decode(message.value); + }, + toProto(message: Vote): Uint8Array { + return Vote.encode(message).finish(); + }, + toProtoMsg(message: Vote): VoteProtoMsg { + return { + typeUrl: "/cosmos.gov.v1.Vote", + value: Vote.encode(message).finish() + }; + } +}; +function createBaseDepositParams(): DepositParams { + return { + minDeposit: [], + maxDepositPeriod: undefined + }; +} +export const DepositParams = { + typeUrl: "/cosmos.gov.v1.DepositParams", + encode(message: DepositParams, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.minDeposit) { + Coin.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.maxDepositPeriod !== undefined) { + Duration.encode(message.maxDepositPeriod, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): DepositParams { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDepositParams(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.minDeposit.push(Coin.decode(reader, reader.uint32())); + break; + case 2: + message.maxDepositPeriod = Duration.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): DepositParams { + const obj = createBaseDepositParams(); + if (Array.isArray(object?.minDeposit)) obj.minDeposit = object.minDeposit.map((e: any) => Coin.fromJSON(e)); + if (isSet(object.maxDepositPeriod)) obj.maxDepositPeriod = Duration.fromJSON(object.maxDepositPeriod); + return obj; + }, + toJSON(message: DepositParams): JsonSafe { + const obj: any = {}; + if (message.minDeposit) { + obj.minDeposit = message.minDeposit.map(e => e ? Coin.toJSON(e) : undefined); + } else { + obj.minDeposit = []; + } + message.maxDepositPeriod !== undefined && (obj.maxDepositPeriod = message.maxDepositPeriod ? Duration.toJSON(message.maxDepositPeriod) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): DepositParams { + const message = createBaseDepositParams(); + message.minDeposit = object.minDeposit?.map(e => Coin.fromPartial(e)) || []; + if (object.maxDepositPeriod !== undefined && object.maxDepositPeriod !== null) { + message.maxDepositPeriod = Duration.fromPartial(object.maxDepositPeriod); + } + return message; + }, + fromSDK(object: DepositParamsSDKType): DepositParams { + return { + minDeposit: Array.isArray(object?.min_deposit) ? object.min_deposit.map((e: any) => Coin.fromSDK(e)) : [], + maxDepositPeriod: object.max_deposit_period ? Duration.fromSDK(object.max_deposit_period) : undefined + }; + }, + fromSDKJSON(object: any): DepositParamsSDKType { + return { + min_deposit: Array.isArray(object?.min_deposit) ? object.min_deposit.map((e: any) => Coin.fromSDKJSON(e)) : [], + max_deposit_period: isSet(object.max_deposit_period) ? Duration.fromSDKJSON(object.max_deposit_period) : undefined + }; + }, + toSDK(message: DepositParams): DepositParamsSDKType { + const obj: any = {}; + if (message.minDeposit) { + obj.min_deposit = message.minDeposit.map(e => e ? Coin.toSDK(e) : undefined); + } else { + obj.min_deposit = []; + } + message.maxDepositPeriod !== undefined && (obj.max_deposit_period = message.maxDepositPeriod ? Duration.toSDK(message.maxDepositPeriod) : undefined); + return obj; + }, + fromAmino(object: DepositParamsAmino): DepositParams { + const message = createBaseDepositParams(); + message.minDeposit = object.min_deposit?.map(e => Coin.fromAmino(e)) || []; + if (object.max_deposit_period !== undefined && object.max_deposit_period !== null) { + message.maxDepositPeriod = Duration.fromAmino(object.max_deposit_period); + } + return message; + }, + toAmino(message: DepositParams): DepositParamsAmino { + const obj: any = {}; + if (message.minDeposit) { + obj.min_deposit = message.minDeposit.map(e => e ? Coin.toAmino(e) : undefined); + } else { + obj.min_deposit = message.minDeposit; + } + obj.max_deposit_period = message.maxDepositPeriod ? Duration.toAmino(message.maxDepositPeriod) : undefined; + return obj; + }, + fromAminoMsg(object: DepositParamsAminoMsg): DepositParams { + return DepositParams.fromAmino(object.value); + }, + toAminoMsg(message: DepositParams): DepositParamsAminoMsg { + return { + type: "cosmos-sdk/v1/DepositParams", + value: DepositParams.toAmino(message) + }; + }, + fromProtoMsg(message: DepositParamsProtoMsg): DepositParams { + return DepositParams.decode(message.value); + }, + toProto(message: DepositParams): Uint8Array { + return DepositParams.encode(message).finish(); + }, + toProtoMsg(message: DepositParams): DepositParamsProtoMsg { + return { + typeUrl: "/cosmos.gov.v1.DepositParams", + value: DepositParams.encode(message).finish() + }; + } +}; +function createBaseVotingParams(): VotingParams { + return { + votingPeriod: undefined + }; +} +export const VotingParams = { + typeUrl: "/cosmos.gov.v1.VotingParams", + encode(message: VotingParams, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.votingPeriod !== undefined) { + Duration.encode(message.votingPeriod, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): VotingParams { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseVotingParams(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.votingPeriod = Duration.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): VotingParams { + const obj = createBaseVotingParams(); + if (isSet(object.votingPeriod)) obj.votingPeriod = Duration.fromJSON(object.votingPeriod); + return obj; + }, + toJSON(message: VotingParams): JsonSafe { + const obj: any = {}; + message.votingPeriod !== undefined && (obj.votingPeriod = message.votingPeriod ? Duration.toJSON(message.votingPeriod) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): VotingParams { + const message = createBaseVotingParams(); + if (object.votingPeriod !== undefined && object.votingPeriod !== null) { + message.votingPeriod = Duration.fromPartial(object.votingPeriod); + } + return message; + }, + fromSDK(object: VotingParamsSDKType): VotingParams { + return { + votingPeriod: object.voting_period ? Duration.fromSDK(object.voting_period) : undefined + }; + }, + fromSDKJSON(object: any): VotingParamsSDKType { + return { + voting_period: isSet(object.voting_period) ? Duration.fromSDKJSON(object.voting_period) : undefined + }; + }, + toSDK(message: VotingParams): VotingParamsSDKType { + const obj: any = {}; + message.votingPeriod !== undefined && (obj.voting_period = message.votingPeriod ? Duration.toSDK(message.votingPeriod) : undefined); + return obj; + }, + fromAmino(object: VotingParamsAmino): VotingParams { + const message = createBaseVotingParams(); + if (object.voting_period !== undefined && object.voting_period !== null) { + message.votingPeriod = Duration.fromAmino(object.voting_period); + } + return message; + }, + toAmino(message: VotingParams): VotingParamsAmino { + const obj: any = {}; + obj.voting_period = message.votingPeriod ? Duration.toAmino(message.votingPeriod) : undefined; + return obj; + }, + fromAminoMsg(object: VotingParamsAminoMsg): VotingParams { + return VotingParams.fromAmino(object.value); + }, + toAminoMsg(message: VotingParams): VotingParamsAminoMsg { + return { + type: "cosmos-sdk/v1/VotingParams", + value: VotingParams.toAmino(message) + }; + }, + fromProtoMsg(message: VotingParamsProtoMsg): VotingParams { + return VotingParams.decode(message.value); + }, + toProto(message: VotingParams): Uint8Array { + return VotingParams.encode(message).finish(); + }, + toProtoMsg(message: VotingParams): VotingParamsProtoMsg { + return { + typeUrl: "/cosmos.gov.v1.VotingParams", + value: VotingParams.encode(message).finish() + }; + } +}; +function createBaseTallyParams(): TallyParams { + return { + quorum: "", + threshold: "", + vetoThreshold: "" + }; +} +export const TallyParams = { + typeUrl: "/cosmos.gov.v1.TallyParams", + encode(message: TallyParams, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.quorum !== undefined) { + writer.uint32(10).string(message.quorum); + } + if (message.threshold !== undefined) { + writer.uint32(18).string(message.threshold); + } + if (message.vetoThreshold !== undefined) { + writer.uint32(26).string(message.vetoThreshold); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): TallyParams { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseTallyParams(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.quorum = reader.string(); + break; + case 2: + message.threshold = reader.string(); + break; + case 3: + message.vetoThreshold = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): TallyParams { + const obj = createBaseTallyParams(); + if (isSet(object.quorum)) obj.quorum = String(object.quorum); + if (isSet(object.threshold)) obj.threshold = String(object.threshold); + if (isSet(object.vetoThreshold)) obj.vetoThreshold = String(object.vetoThreshold); + return obj; + }, + toJSON(message: TallyParams): JsonSafe { + const obj: any = {}; + message.quorum !== undefined && (obj.quorum = message.quorum); + message.threshold !== undefined && (obj.threshold = message.threshold); + message.vetoThreshold !== undefined && (obj.vetoThreshold = message.vetoThreshold); + return obj; + }, + fromPartial(object: DeepPartial): TallyParams { + const message = createBaseTallyParams(); + message.quorum = object.quorum ?? ""; + message.threshold = object.threshold ?? ""; + message.vetoThreshold = object.vetoThreshold ?? ""; + return message; + }, + fromSDK(object: TallyParamsSDKType): TallyParams { + return { + quorum: object?.quorum, + threshold: object?.threshold, + vetoThreshold: object?.veto_threshold + }; + }, + fromSDKJSON(object: any): TallyParamsSDKType { + return { + quorum: isSet(object.quorum) ? String(object.quorum) : "", + threshold: isSet(object.threshold) ? String(object.threshold) : "", + veto_threshold: isSet(object.veto_threshold) ? String(object.veto_threshold) : "" + }; + }, + toSDK(message: TallyParams): TallyParamsSDKType { + const obj: any = {}; + obj.quorum = message.quorum; + obj.threshold = message.threshold; + obj.veto_threshold = message.vetoThreshold; + return obj; + }, + fromAmino(object: TallyParamsAmino): TallyParams { + const message = createBaseTallyParams(); + if (object.quorum !== undefined && object.quorum !== null) { + message.quorum = object.quorum; + } + if (object.threshold !== undefined && object.threshold !== null) { + message.threshold = object.threshold; + } + if (object.veto_threshold !== undefined && object.veto_threshold !== null) { + message.vetoThreshold = object.veto_threshold; + } + return message; + }, + toAmino(message: TallyParams): TallyParamsAmino { + const obj: any = {}; + obj.quorum = message.quorum === "" ? undefined : message.quorum; + obj.threshold = message.threshold === "" ? undefined : message.threshold; + obj.veto_threshold = message.vetoThreshold === "" ? undefined : message.vetoThreshold; + return obj; + }, + fromAminoMsg(object: TallyParamsAminoMsg): TallyParams { + return TallyParams.fromAmino(object.value); + }, + toAminoMsg(message: TallyParams): TallyParamsAminoMsg { + return { + type: "cosmos-sdk/v1/TallyParams", + value: TallyParams.toAmino(message) + }; + }, + fromProtoMsg(message: TallyParamsProtoMsg): TallyParams { + return TallyParams.decode(message.value); + }, + toProto(message: TallyParams): Uint8Array { + return TallyParams.encode(message).finish(); + }, + toProtoMsg(message: TallyParams): TallyParamsProtoMsg { + return { + typeUrl: "/cosmos.gov.v1.TallyParams", + value: TallyParams.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/gov/v1/query.lcd.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/gov/v1/query.lcd.ts new file mode 100644 index 0000000000..6050fa1f4d --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/gov/v1/query.lcd.ts @@ -0,0 +1,90 @@ +import { ProposalStatus, ProposalStatusSDKType, Proposal, ProposalSDKType, Vote, VoteSDKType, VotingParams, VotingParamsSDKType, DepositParams, DepositParamsSDKType, TallyParams, TallyParamsSDKType, Deposit, DepositSDKType, TallyResult, TallyResultSDKType } from "./gov.js"; +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../base/query/v1beta1/pagination.js"; +import { setPaginationParams } from "../../../helpers.js"; +import { LCDClient } from "@cosmology/lcd"; +import { QueryProposalRequest, QueryProposalRequestSDKType, QueryProposalResponse, QueryProposalResponseSDKType, QueryProposalsRequest, QueryProposalsRequestSDKType, QueryProposalsResponse, QueryProposalsResponseSDKType, QueryVoteRequest, QueryVoteRequestSDKType, QueryVoteResponse, QueryVoteResponseSDKType, QueryVotesRequest, QueryVotesRequestSDKType, QueryVotesResponse, QueryVotesResponseSDKType, QueryParamsRequest, QueryParamsRequestSDKType, QueryParamsResponse, QueryParamsResponseSDKType, QueryDepositRequest, QueryDepositRequestSDKType, QueryDepositResponse, QueryDepositResponseSDKType, QueryDepositsRequest, QueryDepositsRequestSDKType, QueryDepositsResponse, QueryDepositsResponseSDKType, QueryTallyResultRequest, QueryTallyResultRequestSDKType, QueryTallyResultResponse, QueryTallyResultResponseSDKType } from "./query.js"; +export class LCDQueryClient { + req: LCDClient; + constructor({ + requestClient + }: { + requestClient: LCDClient; + }) { + this.req = requestClient; + this.proposal = this.proposal.bind(this); + this.proposals = this.proposals.bind(this); + this.vote = this.vote.bind(this); + this.votes = this.votes.bind(this); + this.params = this.params.bind(this); + this.deposit = this.deposit.bind(this); + this.deposits = this.deposits.bind(this); + this.tallyResult = this.tallyResult.bind(this); + } + /* Proposal queries proposal details based on ProposalID. */ + async proposal(params: QueryProposalRequest): Promise { + const endpoint = `cosmos/gov/v1/proposals/${params.proposalId}`; + return QueryProposalResponse.fromSDKJSON(await this.req.get(endpoint)); + } + /* Proposals queries all proposals based on given status. */ + async proposals(params: QueryProposalsRequest): Promise { + const options: any = { + params: {} + }; + if (typeof params?.proposalStatus !== "undefined") { + options.params.proposal_status = params.proposalStatus; + } + if (typeof params?.voter !== "undefined") { + options.params.voter = params.voter; + } + if (typeof params?.depositor !== "undefined") { + options.params.depositor = params.depositor; + } + if (typeof params?.pagination !== "undefined") { + setPaginationParams(options, params.pagination); + } + const endpoint = `cosmos/gov/v1/proposals`; + return QueryProposalsResponse.fromSDKJSON(await this.req.get(endpoint, options)); + } + /* Vote queries voted information based on proposalID, voterAddr. */ + async vote(params: QueryVoteRequest): Promise { + const endpoint = `cosmos/gov/v1/proposals/${params.proposalId}/votes/${params.voter}`; + return QueryVoteResponse.fromSDKJSON(await this.req.get(endpoint)); + } + /* Votes queries votes of a given proposal. */ + async votes(params: QueryVotesRequest): Promise { + const options: any = { + params: {} + }; + if (typeof params?.pagination !== "undefined") { + setPaginationParams(options, params.pagination); + } + const endpoint = `cosmos/gov/v1/proposals/${params.proposalId}/votes`; + return QueryVotesResponse.fromSDKJSON(await this.req.get(endpoint, options)); + } + /* Params queries all parameters of the gov module. */ + async params(params: QueryParamsRequest): Promise { + const endpoint = `cosmos/gov/v1/params/${params.paramsType}`; + return QueryParamsResponse.fromSDKJSON(await this.req.get(endpoint)); + } + /* Deposit queries single deposit information based proposalID, depositAddr. */ + async deposit(params: QueryDepositRequest): Promise { + const endpoint = `cosmos/gov/v1/proposals/${params.proposalId}/deposits/${params.depositor}`; + return QueryDepositResponse.fromSDKJSON(await this.req.get(endpoint)); + } + /* Deposits queries all deposits of a single proposal. */ + async deposits(params: QueryDepositsRequest): Promise { + const options: any = { + params: {} + }; + if (typeof params?.pagination !== "undefined") { + setPaginationParams(options, params.pagination); + } + const endpoint = `cosmos/gov/v1/proposals/${params.proposalId}/deposits`; + return QueryDepositsResponse.fromSDKJSON(await this.req.get(endpoint, options)); + } + /* TallyResult queries the tally of a proposal vote. */ + async tallyResult(params: QueryTallyResultRequest): Promise { + const endpoint = `cosmos/gov/v1/proposals/${params.proposalId}/tally`; + return QueryTallyResultResponse.fromSDKJSON(await this.req.get(endpoint)); + } +} \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/gov/v1/query.rpc.Query.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/gov/v1/query.rpc.Query.ts new file mode 100644 index 0000000000..a2c2f959ff --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/gov/v1/query.rpc.Query.ts @@ -0,0 +1,109 @@ +import { ProposalStatus, ProposalStatusSDKType, Proposal, ProposalSDKType, Vote, VoteSDKType, VotingParams, VotingParamsSDKType, DepositParams, DepositParamsSDKType, TallyParams, TallyParamsSDKType, Deposit, DepositSDKType, TallyResult, TallyResultSDKType } from "./gov.js"; +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../base/query/v1beta1/pagination.js"; +import { Rpc } from "../../../helpers.js"; +import { BinaryReader } from "../../../binary.js"; +import { QueryClient, createProtobufRpcClient } from "@cosmjs/stargate"; +import { QueryProposalRequest, QueryProposalRequestSDKType, QueryProposalResponse, QueryProposalResponseSDKType, QueryProposalsRequest, QueryProposalsRequestSDKType, QueryProposalsResponse, QueryProposalsResponseSDKType, QueryVoteRequest, QueryVoteRequestSDKType, QueryVoteResponse, QueryVoteResponseSDKType, QueryVotesRequest, QueryVotesRequestSDKType, QueryVotesResponse, QueryVotesResponseSDKType, QueryParamsRequest, QueryParamsRequestSDKType, QueryParamsResponse, QueryParamsResponseSDKType, QueryDepositRequest, QueryDepositRequestSDKType, QueryDepositResponse, QueryDepositResponseSDKType, QueryDepositsRequest, QueryDepositsRequestSDKType, QueryDepositsResponse, QueryDepositsResponseSDKType, QueryTallyResultRequest, QueryTallyResultRequestSDKType, QueryTallyResultResponse, QueryTallyResultResponseSDKType } from "./query.js"; +/** Query defines the gRPC querier service for gov module */ +export interface Query { + /** Proposal queries proposal details based on ProposalID. */ + proposal(request: QueryProposalRequest): Promise; + /** Proposals queries all proposals based on given status. */ + proposals(request: QueryProposalsRequest): Promise; + /** Vote queries voted information based on proposalID, voterAddr. */ + vote(request: QueryVoteRequest): Promise; + /** Votes queries votes of a given proposal. */ + votes(request: QueryVotesRequest): Promise; + /** Params queries all parameters of the gov module. */ + params(request: QueryParamsRequest): Promise; + /** Deposit queries single deposit information based proposalID, depositAddr. */ + deposit(request: QueryDepositRequest): Promise; + /** Deposits queries all deposits of a single proposal. */ + deposits(request: QueryDepositsRequest): Promise; + /** TallyResult queries the tally of a proposal vote. */ + tallyResult(request: QueryTallyResultRequest): Promise; +} +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + this.proposal = this.proposal.bind(this); + this.proposals = this.proposals.bind(this); + this.vote = this.vote.bind(this); + this.votes = this.votes.bind(this); + this.params = this.params.bind(this); + this.deposit = this.deposit.bind(this); + this.deposits = this.deposits.bind(this); + this.tallyResult = this.tallyResult.bind(this); + } + proposal(request: QueryProposalRequest): Promise { + const data = QueryProposalRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.gov.v1.Query", "Proposal", data); + return promise.then(data => QueryProposalResponse.decode(new BinaryReader(data))); + } + proposals(request: QueryProposalsRequest): Promise { + const data = QueryProposalsRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.gov.v1.Query", "Proposals", data); + return promise.then(data => QueryProposalsResponse.decode(new BinaryReader(data))); + } + vote(request: QueryVoteRequest): Promise { + const data = QueryVoteRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.gov.v1.Query", "Vote", data); + return promise.then(data => QueryVoteResponse.decode(new BinaryReader(data))); + } + votes(request: QueryVotesRequest): Promise { + const data = QueryVotesRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.gov.v1.Query", "Votes", data); + return promise.then(data => QueryVotesResponse.decode(new BinaryReader(data))); + } + params(request: QueryParamsRequest): Promise { + const data = QueryParamsRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.gov.v1.Query", "Params", data); + return promise.then(data => QueryParamsResponse.decode(new BinaryReader(data))); + } + deposit(request: QueryDepositRequest): Promise { + const data = QueryDepositRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.gov.v1.Query", "Deposit", data); + return promise.then(data => QueryDepositResponse.decode(new BinaryReader(data))); + } + deposits(request: QueryDepositsRequest): Promise { + const data = QueryDepositsRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.gov.v1.Query", "Deposits", data); + return promise.then(data => QueryDepositsResponse.decode(new BinaryReader(data))); + } + tallyResult(request: QueryTallyResultRequest): Promise { + const data = QueryTallyResultRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.gov.v1.Query", "TallyResult", data); + return promise.then(data => QueryTallyResultResponse.decode(new BinaryReader(data))); + } +} +export const createRpcQueryExtension = (base: QueryClient) => { + const rpc = createProtobufRpcClient(base); + const queryService = new QueryClientImpl(rpc); + return { + proposal(request: QueryProposalRequest): Promise { + return queryService.proposal(request); + }, + proposals(request: QueryProposalsRequest): Promise { + return queryService.proposals(request); + }, + vote(request: QueryVoteRequest): Promise { + return queryService.vote(request); + }, + votes(request: QueryVotesRequest): Promise { + return queryService.votes(request); + }, + params(request: QueryParamsRequest): Promise { + return queryService.params(request); + }, + deposit(request: QueryDepositRequest): Promise { + return queryService.deposit(request); + }, + deposits(request: QueryDepositsRequest): Promise { + return queryService.deposits(request); + }, + tallyResult(request: QueryTallyResultRequest): Promise { + return queryService.tallyResult(request); + } + }; +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/gov/v1/query.rpc.func.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/gov/v1/query.rpc.func.ts new file mode 100644 index 0000000000..e53c5f768b --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/gov/v1/query.rpc.func.ts @@ -0,0 +1,91 @@ +import { RpcResolver, buildQuery } from "../../../helper-func-types"; +import { buildUseQuery } from "../../../react-query"; +import { QueryProposalRequest, QueryProposalResponse, QueryProposalsRequest, QueryProposalsResponse, QueryVoteRequest, QueryVoteResponse, QueryVotesRequest, QueryVotesResponse, QueryParamsRequest, QueryParamsResponse, QueryDepositRequest, QueryDepositResponse, QueryDepositsRequest, QueryDepositsResponse, QueryTallyResultRequest, QueryTallyResultResponse } from "./query"; +export const createGetProposal = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryProposalRequest.encode, + decode: QueryProposalResponse.decode, + service: "cosmos.gov.v1.Query", + method: "Proposal", + getRpcInstance: getRpcInstance +}); +export const useGetProposal = buildUseQuery({ + builderQueryFn: createGetProposal, + queryKeyPrefix: "ProposalQuery" +}); +export const createGetProposals = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryProposalsRequest.encode, + decode: QueryProposalsResponse.decode, + service: "cosmos.gov.v1.Query", + method: "Proposals", + getRpcInstance: getRpcInstance +}); +export const useGetProposals = buildUseQuery({ + builderQueryFn: createGetProposals, + queryKeyPrefix: "ProposalsQuery" +}); +export const createGetVote = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryVoteRequest.encode, + decode: QueryVoteResponse.decode, + service: "cosmos.gov.v1.Query", + method: "Vote", + getRpcInstance: getRpcInstance +}); +export const useGetVote = buildUseQuery({ + builderQueryFn: createGetVote, + queryKeyPrefix: "VoteQuery" +}); +export const createGetVotes = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryVotesRequest.encode, + decode: QueryVotesResponse.decode, + service: "cosmos.gov.v1.Query", + method: "Votes", + getRpcInstance: getRpcInstance +}); +export const useGetVotes = buildUseQuery({ + builderQueryFn: createGetVotes, + queryKeyPrefix: "VotesQuery" +}); +export const createGetParams = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryParamsRequest.encode, + decode: QueryParamsResponse.decode, + service: "cosmos.gov.v1.Query", + method: "Params", + getRpcInstance: getRpcInstance +}); +export const useGetParams = buildUseQuery({ + builderQueryFn: createGetParams, + queryKeyPrefix: "ParamsQuery" +}); +export const createGetDeposit = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryDepositRequest.encode, + decode: QueryDepositResponse.decode, + service: "cosmos.gov.v1.Query", + method: "Deposit", + getRpcInstance: getRpcInstance +}); +export const useGetDeposit = buildUseQuery({ + builderQueryFn: createGetDeposit, + queryKeyPrefix: "DepositQuery" +}); +export const createGetDeposits = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryDepositsRequest.encode, + decode: QueryDepositsResponse.decode, + service: "cosmos.gov.v1.Query", + method: "Deposits", + getRpcInstance: getRpcInstance +}); +export const useGetDeposits = buildUseQuery({ + builderQueryFn: createGetDeposits, + queryKeyPrefix: "DepositsQuery" +}); +export const createGetTallyResult = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryTallyResultRequest.encode, + decode: QueryTallyResultResponse.decode, + service: "cosmos.gov.v1.Query", + method: "TallyResult", + getRpcInstance: getRpcInstance +}); +export const useGetTallyResult = buildUseQuery({ + builderQueryFn: createGetTallyResult, + queryKeyPrefix: "TallyResultQuery" +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/gov/v1/query.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/gov/v1/query.ts new file mode 100644 index 0000000000..b0032e8b67 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/gov/v1/query.ts @@ -0,0 +1,2032 @@ +import { ProposalStatus, ProposalStatusSDKType, Proposal, ProposalSDKType, Vote, VoteSDKType, VotingParams, VotingParamsSDKType, DepositParams, DepositParamsSDKType, TallyParams, TallyParamsSDKType, Deposit, DepositSDKType, TallyResult, TallyResultSDKType, proposalStatusFromJSON, proposalStatusToJSON } from "./gov.js"; +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../base/query/v1beta1/pagination.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "cosmos.gov.v1"; +/** QueryProposalRequest is the request type for the Query/Proposal RPC method. */ +export interface QueryProposalRequest { + /** proposal_id defines the unique id of the proposal. */ + proposalId: bigint; +} +export interface QueryProposalRequestProtoMsg { + typeUrl: "/cosmos.gov.v1.QueryProposalRequest"; + value: Uint8Array; +} +/** QueryProposalRequest is the request type for the Query/Proposal RPC method. */ +export interface QueryProposalRequestSDKType { + proposal_id: bigint; +} +/** QueryProposalResponse is the response type for the Query/Proposal RPC method. */ +export interface QueryProposalResponse { + proposal?: Proposal; +} +export interface QueryProposalResponseProtoMsg { + typeUrl: "/cosmos.gov.v1.QueryProposalResponse"; + value: Uint8Array; +} +/** QueryProposalResponse is the response type for the Query/Proposal RPC method. */ +export interface QueryProposalResponseSDKType { + proposal?: ProposalSDKType; +} +/** QueryProposalsRequest is the request type for the Query/Proposals RPC method. */ +export interface QueryProposalsRequest { + /** proposal_status defines the status of the proposals. */ + proposalStatus: ProposalStatus; + /** voter defines the voter address for the proposals. */ + voter: string; + /** depositor defines the deposit addresses from the proposals. */ + depositor: string; + /** pagination defines an optional pagination for the request. */ + pagination?: PageRequest; +} +export interface QueryProposalsRequestProtoMsg { + typeUrl: "/cosmos.gov.v1.QueryProposalsRequest"; + value: Uint8Array; +} +/** QueryProposalsRequest is the request type for the Query/Proposals RPC method. */ +export interface QueryProposalsRequestSDKType { + proposal_status: ProposalStatus; + voter: string; + depositor: string; + pagination?: PageRequestSDKType; +} +/** + * QueryProposalsResponse is the response type for the Query/Proposals RPC + * method. + */ +export interface QueryProposalsResponse { + proposals: Proposal[]; + /** pagination defines the pagination in the response. */ + pagination?: PageResponse; +} +export interface QueryProposalsResponseProtoMsg { + typeUrl: "/cosmos.gov.v1.QueryProposalsResponse"; + value: Uint8Array; +} +/** + * QueryProposalsResponse is the response type for the Query/Proposals RPC + * method. + */ +export interface QueryProposalsResponseSDKType { + proposals: ProposalSDKType[]; + pagination?: PageResponseSDKType; +} +/** QueryVoteRequest is the request type for the Query/Vote RPC method. */ +export interface QueryVoteRequest { + /** proposal_id defines the unique id of the proposal. */ + proposalId: bigint; + /** voter defines the oter address for the proposals. */ + voter: string; +} +export interface QueryVoteRequestProtoMsg { + typeUrl: "/cosmos.gov.v1.QueryVoteRequest"; + value: Uint8Array; +} +/** QueryVoteRequest is the request type for the Query/Vote RPC method. */ +export interface QueryVoteRequestSDKType { + proposal_id: bigint; + voter: string; +} +/** QueryVoteResponse is the response type for the Query/Vote RPC method. */ +export interface QueryVoteResponse { + /** vote defined the queried vote. */ + vote?: Vote; +} +export interface QueryVoteResponseProtoMsg { + typeUrl: "/cosmos.gov.v1.QueryVoteResponse"; + value: Uint8Array; +} +/** QueryVoteResponse is the response type for the Query/Vote RPC method. */ +export interface QueryVoteResponseSDKType { + vote?: VoteSDKType; +} +/** QueryVotesRequest is the request type for the Query/Votes RPC method. */ +export interface QueryVotesRequest { + /** proposal_id defines the unique id of the proposal. */ + proposalId: bigint; + /** pagination defines an optional pagination for the request. */ + pagination?: PageRequest; +} +export interface QueryVotesRequestProtoMsg { + typeUrl: "/cosmos.gov.v1.QueryVotesRequest"; + value: Uint8Array; +} +/** QueryVotesRequest is the request type for the Query/Votes RPC method. */ +export interface QueryVotesRequestSDKType { + proposal_id: bigint; + pagination?: PageRequestSDKType; +} +/** QueryVotesResponse is the response type for the Query/Votes RPC method. */ +export interface QueryVotesResponse { + /** votes defined the queried votes. */ + votes: Vote[]; + /** pagination defines the pagination in the response. */ + pagination?: PageResponse; +} +export interface QueryVotesResponseProtoMsg { + typeUrl: "/cosmos.gov.v1.QueryVotesResponse"; + value: Uint8Array; +} +/** QueryVotesResponse is the response type for the Query/Votes RPC method. */ +export interface QueryVotesResponseSDKType { + votes: VoteSDKType[]; + pagination?: PageResponseSDKType; +} +/** QueryParamsRequest is the request type for the Query/Params RPC method. */ +export interface QueryParamsRequest { + /** + * params_type defines which parameters to query for, can be one of "voting", + * "tallying" or "deposit". + */ + paramsType: string; +} +export interface QueryParamsRequestProtoMsg { + typeUrl: "/cosmos.gov.v1.QueryParamsRequest"; + value: Uint8Array; +} +/** QueryParamsRequest is the request type for the Query/Params RPC method. */ +export interface QueryParamsRequestSDKType { + params_type: string; +} +/** QueryParamsResponse is the response type for the Query/Params RPC method. */ +export interface QueryParamsResponse { + /** voting_params defines the parameters related to voting. */ + votingParams?: VotingParams; + /** deposit_params defines the parameters related to deposit. */ + depositParams?: DepositParams; + /** tally_params defines the parameters related to tally. */ + tallyParams?: TallyParams; +} +export interface QueryParamsResponseProtoMsg { + typeUrl: "/cosmos.gov.v1.QueryParamsResponse"; + value: Uint8Array; +} +/** QueryParamsResponse is the response type for the Query/Params RPC method. */ +export interface QueryParamsResponseSDKType { + voting_params?: VotingParamsSDKType; + deposit_params?: DepositParamsSDKType; + tally_params?: TallyParamsSDKType; +} +/** QueryDepositRequest is the request type for the Query/Deposit RPC method. */ +export interface QueryDepositRequest { + /** proposal_id defines the unique id of the proposal. */ + proposalId: bigint; + /** depositor defines the deposit addresses from the proposals. */ + depositor: string; +} +export interface QueryDepositRequestProtoMsg { + typeUrl: "/cosmos.gov.v1.QueryDepositRequest"; + value: Uint8Array; +} +/** QueryDepositRequest is the request type for the Query/Deposit RPC method. */ +export interface QueryDepositRequestSDKType { + proposal_id: bigint; + depositor: string; +} +/** QueryDepositResponse is the response type for the Query/Deposit RPC method. */ +export interface QueryDepositResponse { + /** deposit defines the requested deposit. */ + deposit?: Deposit; +} +export interface QueryDepositResponseProtoMsg { + typeUrl: "/cosmos.gov.v1.QueryDepositResponse"; + value: Uint8Array; +} +/** QueryDepositResponse is the response type for the Query/Deposit RPC method. */ +export interface QueryDepositResponseSDKType { + deposit?: DepositSDKType; +} +/** QueryDepositsRequest is the request type for the Query/Deposits RPC method. */ +export interface QueryDepositsRequest { + /** proposal_id defines the unique id of the proposal. */ + proposalId: bigint; + /** pagination defines an optional pagination for the request. */ + pagination?: PageRequest; +} +export interface QueryDepositsRequestProtoMsg { + typeUrl: "/cosmos.gov.v1.QueryDepositsRequest"; + value: Uint8Array; +} +/** QueryDepositsRequest is the request type for the Query/Deposits RPC method. */ +export interface QueryDepositsRequestSDKType { + proposal_id: bigint; + pagination?: PageRequestSDKType; +} +/** QueryDepositsResponse is the response type for the Query/Deposits RPC method. */ +export interface QueryDepositsResponse { + deposits: Deposit[]; + /** pagination defines the pagination in the response. */ + pagination?: PageResponse; +} +export interface QueryDepositsResponseProtoMsg { + typeUrl: "/cosmos.gov.v1.QueryDepositsResponse"; + value: Uint8Array; +} +/** QueryDepositsResponse is the response type for the Query/Deposits RPC method. */ +export interface QueryDepositsResponseSDKType { + deposits: DepositSDKType[]; + pagination?: PageResponseSDKType; +} +/** QueryTallyResultRequest is the request type for the Query/Tally RPC method. */ +export interface QueryTallyResultRequest { + /** proposal_id defines the unique id of the proposal. */ + proposalId: bigint; +} +export interface QueryTallyResultRequestProtoMsg { + typeUrl: "/cosmos.gov.v1.QueryTallyResultRequest"; + value: Uint8Array; +} +/** QueryTallyResultRequest is the request type for the Query/Tally RPC method. */ +export interface QueryTallyResultRequestSDKType { + proposal_id: bigint; +} +/** QueryTallyResultResponse is the response type for the Query/Tally RPC method. */ +export interface QueryTallyResultResponse { + /** tally defines the requested tally. */ + tally?: TallyResult; +} +export interface QueryTallyResultResponseProtoMsg { + typeUrl: "/cosmos.gov.v1.QueryTallyResultResponse"; + value: Uint8Array; +} +/** QueryTallyResultResponse is the response type for the Query/Tally RPC method. */ +export interface QueryTallyResultResponseSDKType { + tally?: TallyResultSDKType; +} +function createBaseQueryProposalRequest(): QueryProposalRequest { + return { + proposalId: BigInt(0) + }; +} +export const QueryProposalRequest = { + typeUrl: "/cosmos.gov.v1.QueryProposalRequest", + encode(message: QueryProposalRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.proposalId !== undefined) { + writer.uint32(8).uint64(message.proposalId); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryProposalRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryProposalRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.proposalId = reader.uint64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryProposalRequest { + const obj = createBaseQueryProposalRequest(); + if (isSet(object.proposalId)) obj.proposalId = BigInt(object.proposalId.toString()); + return obj; + }, + toJSON(message: QueryProposalRequest): JsonSafe { + const obj: any = {}; + message.proposalId !== undefined && (obj.proposalId = (message.proposalId || BigInt(0)).toString()); + return obj; + }, + fromPartial(object: DeepPartial): QueryProposalRequest { + const message = createBaseQueryProposalRequest(); + if (object.proposalId !== undefined && object.proposalId !== null) { + message.proposalId = BigInt(object.proposalId.toString()); + } + return message; + }, + fromSDK(object: QueryProposalRequestSDKType): QueryProposalRequest { + return { + proposalId: object?.proposal_id + }; + }, + fromSDKJSON(object: any): QueryProposalRequestSDKType { + return { + proposal_id: isSet(object.proposal_id) ? BigInt(object.proposal_id.toString()) : BigInt(0) + }; + }, + toSDK(message: QueryProposalRequest): QueryProposalRequestSDKType { + const obj: any = {}; + obj.proposal_id = message.proposalId; + return obj; + }, + fromAmino(object: QueryProposalRequestAmino): QueryProposalRequest { + const message = createBaseQueryProposalRequest(); + if (object.proposal_id !== undefined && object.proposal_id !== null) { + message.proposalId = BigInt(object.proposal_id); + } + return message; + }, + toAmino(message: QueryProposalRequest): QueryProposalRequestAmino { + const obj: any = {}; + obj.proposal_id = message.proposalId !== BigInt(0) ? message.proposalId?.toString() : undefined; + return obj; + }, + fromAminoMsg(object: QueryProposalRequestAminoMsg): QueryProposalRequest { + return QueryProposalRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryProposalRequest): QueryProposalRequestAminoMsg { + return { + type: "cosmos-sdk/v1/QueryProposalRequest", + value: QueryProposalRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryProposalRequestProtoMsg): QueryProposalRequest { + return QueryProposalRequest.decode(message.value); + }, + toProto(message: QueryProposalRequest): Uint8Array { + return QueryProposalRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryProposalRequest): QueryProposalRequestProtoMsg { + return { + typeUrl: "/cosmos.gov.v1.QueryProposalRequest", + value: QueryProposalRequest.encode(message).finish() + }; + } +}; +function createBaseQueryProposalResponse(): QueryProposalResponse { + return { + proposal: undefined + }; +} +export const QueryProposalResponse = { + typeUrl: "/cosmos.gov.v1.QueryProposalResponse", + encode(message: QueryProposalResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.proposal !== undefined) { + Proposal.encode(message.proposal, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryProposalResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryProposalResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.proposal = Proposal.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryProposalResponse { + const obj = createBaseQueryProposalResponse(); + if (isSet(object.proposal)) obj.proposal = Proposal.fromJSON(object.proposal); + return obj; + }, + toJSON(message: QueryProposalResponse): JsonSafe { + const obj: any = {}; + message.proposal !== undefined && (obj.proposal = message.proposal ? Proposal.toJSON(message.proposal) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryProposalResponse { + const message = createBaseQueryProposalResponse(); + if (object.proposal !== undefined && object.proposal !== null) { + message.proposal = Proposal.fromPartial(object.proposal); + } + return message; + }, + fromSDK(object: QueryProposalResponseSDKType): QueryProposalResponse { + return { + proposal: object.proposal ? Proposal.fromSDK(object.proposal) : undefined + }; + }, + fromSDKJSON(object: any): QueryProposalResponseSDKType { + return { + proposal: isSet(object.proposal) ? Proposal.fromSDKJSON(object.proposal) : undefined + }; + }, + toSDK(message: QueryProposalResponse): QueryProposalResponseSDKType { + const obj: any = {}; + message.proposal !== undefined && (obj.proposal = message.proposal ? Proposal.toSDK(message.proposal) : undefined); + return obj; + }, + fromAmino(object: QueryProposalResponseAmino): QueryProposalResponse { + const message = createBaseQueryProposalResponse(); + if (object.proposal !== undefined && object.proposal !== null) { + message.proposal = Proposal.fromAmino(object.proposal); + } + return message; + }, + toAmino(message: QueryProposalResponse): QueryProposalResponseAmino { + const obj: any = {}; + obj.proposal = message.proposal ? Proposal.toAmino(message.proposal) : undefined; + return obj; + }, + fromAminoMsg(object: QueryProposalResponseAminoMsg): QueryProposalResponse { + return QueryProposalResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryProposalResponse): QueryProposalResponseAminoMsg { + return { + type: "cosmos-sdk/v1/QueryProposalResponse", + value: QueryProposalResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryProposalResponseProtoMsg): QueryProposalResponse { + return QueryProposalResponse.decode(message.value); + }, + toProto(message: QueryProposalResponse): Uint8Array { + return QueryProposalResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryProposalResponse): QueryProposalResponseProtoMsg { + return { + typeUrl: "/cosmos.gov.v1.QueryProposalResponse", + value: QueryProposalResponse.encode(message).finish() + }; + } +}; +function createBaseQueryProposalsRequest(): QueryProposalsRequest { + return { + proposalStatus: 0, + voter: "", + depositor: "", + pagination: undefined + }; +} +export const QueryProposalsRequest = { + typeUrl: "/cosmos.gov.v1.QueryProposalsRequest", + encode(message: QueryProposalsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.proposalStatus !== 0) { + writer.uint32(8).int32(message.proposalStatus); + } + if (message.voter !== undefined) { + writer.uint32(18).string(message.voter); + } + if (message.depositor !== undefined) { + writer.uint32(26).string(message.depositor); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryProposalsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryProposalsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.proposalStatus = (reader.int32() as any); + break; + case 2: + message.voter = reader.string(); + break; + case 3: + message.depositor = reader.string(); + break; + case 4: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryProposalsRequest { + const obj = createBaseQueryProposalsRequest(); + if (isSet(object.proposalStatus)) obj.proposalStatus = proposalStatusFromJSON(object.proposalStatus); + if (isSet(object.voter)) obj.voter = String(object.voter); + if (isSet(object.depositor)) obj.depositor = String(object.depositor); + if (isSet(object.pagination)) obj.pagination = PageRequest.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryProposalsRequest): JsonSafe { + const obj: any = {}; + message.proposalStatus !== undefined && (obj.proposalStatus = proposalStatusToJSON(message.proposalStatus)); + message.voter !== undefined && (obj.voter = message.voter); + message.depositor !== undefined && (obj.depositor = message.depositor); + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryProposalsRequest { + const message = createBaseQueryProposalsRequest(); + message.proposalStatus = object.proposalStatus ?? 0; + message.voter = object.voter ?? ""; + message.depositor = object.depositor ?? ""; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryProposalsRequestSDKType): QueryProposalsRequest { + return { + proposalStatus: isSet(object.proposal_status) ? proposalStatusFromJSON(object.proposal_status) : -1, + voter: object?.voter, + depositor: object?.depositor, + pagination: object.pagination ? PageRequest.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryProposalsRequestSDKType { + return { + proposal_status: isSet(object.proposal_status) ? proposalStatusFromJSON(object.proposal_status) : -1, + voter: isSet(object.voter) ? String(object.voter) : "", + depositor: isSet(object.depositor) ? String(object.depositor) : "", + pagination: isSet(object.pagination) ? PageRequest.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryProposalsRequest): QueryProposalsRequestSDKType { + const obj: any = {}; + message.proposalStatus !== undefined && (obj.proposal_status = proposalStatusToJSON(message.proposalStatus)); + obj.voter = message.voter; + obj.depositor = message.depositor; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryProposalsRequestAmino): QueryProposalsRequest { + const message = createBaseQueryProposalsRequest(); + if (object.proposal_status !== undefined && object.proposal_status !== null) { + message.proposalStatus = object.proposal_status; + } + if (object.voter !== undefined && object.voter !== null) { + message.voter = object.voter; + } + if (object.depositor !== undefined && object.depositor !== null) { + message.depositor = object.depositor; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryProposalsRequest): QueryProposalsRequestAmino { + const obj: any = {}; + obj.proposal_status = message.proposalStatus === 0 ? undefined : message.proposalStatus; + obj.voter = message.voter === "" ? undefined : message.voter; + obj.depositor = message.depositor === "" ? undefined : message.depositor; + obj.pagination = message.pagination ? PageRequest.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryProposalsRequestAminoMsg): QueryProposalsRequest { + return QueryProposalsRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryProposalsRequest): QueryProposalsRequestAminoMsg { + return { + type: "cosmos-sdk/v1/QueryProposalsRequest", + value: QueryProposalsRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryProposalsRequestProtoMsg): QueryProposalsRequest { + return QueryProposalsRequest.decode(message.value); + }, + toProto(message: QueryProposalsRequest): Uint8Array { + return QueryProposalsRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryProposalsRequest): QueryProposalsRequestProtoMsg { + return { + typeUrl: "/cosmos.gov.v1.QueryProposalsRequest", + value: QueryProposalsRequest.encode(message).finish() + }; + } +}; +function createBaseQueryProposalsResponse(): QueryProposalsResponse { + return { + proposals: [], + pagination: undefined + }; +} +export const QueryProposalsResponse = { + typeUrl: "/cosmos.gov.v1.QueryProposalsResponse", + encode(message: QueryProposalsResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.proposals) { + Proposal.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryProposalsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryProposalsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.proposals.push(Proposal.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryProposalsResponse { + const obj = createBaseQueryProposalsResponse(); + if (Array.isArray(object?.proposals)) obj.proposals = object.proposals.map((e: any) => Proposal.fromJSON(e)); + if (isSet(object.pagination)) obj.pagination = PageResponse.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryProposalsResponse): JsonSafe { + const obj: any = {}; + if (message.proposals) { + obj.proposals = message.proposals.map(e => e ? Proposal.toJSON(e) : undefined); + } else { + obj.proposals = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryProposalsResponse { + const message = createBaseQueryProposalsResponse(); + message.proposals = object.proposals?.map(e => Proposal.fromPartial(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryProposalsResponseSDKType): QueryProposalsResponse { + return { + proposals: Array.isArray(object?.proposals) ? object.proposals.map((e: any) => Proposal.fromSDK(e)) : [], + pagination: object.pagination ? PageResponse.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryProposalsResponseSDKType { + return { + proposals: Array.isArray(object?.proposals) ? object.proposals.map((e: any) => Proposal.fromSDKJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryProposalsResponse): QueryProposalsResponseSDKType { + const obj: any = {}; + if (message.proposals) { + obj.proposals = message.proposals.map(e => e ? Proposal.toSDK(e) : undefined); + } else { + obj.proposals = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryProposalsResponseAmino): QueryProposalsResponse { + const message = createBaseQueryProposalsResponse(); + message.proposals = object.proposals?.map(e => Proposal.fromAmino(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryProposalsResponse): QueryProposalsResponseAmino { + const obj: any = {}; + if (message.proposals) { + obj.proposals = message.proposals.map(e => e ? Proposal.toAmino(e) : undefined); + } else { + obj.proposals = message.proposals; + } + obj.pagination = message.pagination ? PageResponse.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryProposalsResponseAminoMsg): QueryProposalsResponse { + return QueryProposalsResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryProposalsResponse): QueryProposalsResponseAminoMsg { + return { + type: "cosmos-sdk/v1/QueryProposalsResponse", + value: QueryProposalsResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryProposalsResponseProtoMsg): QueryProposalsResponse { + return QueryProposalsResponse.decode(message.value); + }, + toProto(message: QueryProposalsResponse): Uint8Array { + return QueryProposalsResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryProposalsResponse): QueryProposalsResponseProtoMsg { + return { + typeUrl: "/cosmos.gov.v1.QueryProposalsResponse", + value: QueryProposalsResponse.encode(message).finish() + }; + } +}; +function createBaseQueryVoteRequest(): QueryVoteRequest { + return { + proposalId: BigInt(0), + voter: "" + }; +} +export const QueryVoteRequest = { + typeUrl: "/cosmos.gov.v1.QueryVoteRequest", + encode(message: QueryVoteRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.proposalId !== undefined) { + writer.uint32(8).uint64(message.proposalId); + } + if (message.voter !== undefined) { + writer.uint32(18).string(message.voter); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryVoteRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryVoteRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.proposalId = reader.uint64(); + break; + case 2: + message.voter = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryVoteRequest { + const obj = createBaseQueryVoteRequest(); + if (isSet(object.proposalId)) obj.proposalId = BigInt(object.proposalId.toString()); + if (isSet(object.voter)) obj.voter = String(object.voter); + return obj; + }, + toJSON(message: QueryVoteRequest): JsonSafe { + const obj: any = {}; + message.proposalId !== undefined && (obj.proposalId = (message.proposalId || BigInt(0)).toString()); + message.voter !== undefined && (obj.voter = message.voter); + return obj; + }, + fromPartial(object: DeepPartial): QueryVoteRequest { + const message = createBaseQueryVoteRequest(); + if (object.proposalId !== undefined && object.proposalId !== null) { + message.proposalId = BigInt(object.proposalId.toString()); + } + message.voter = object.voter ?? ""; + return message; + }, + fromSDK(object: QueryVoteRequestSDKType): QueryVoteRequest { + return { + proposalId: object?.proposal_id, + voter: object?.voter + }; + }, + fromSDKJSON(object: any): QueryVoteRequestSDKType { + return { + proposal_id: isSet(object.proposal_id) ? BigInt(object.proposal_id.toString()) : BigInt(0), + voter: isSet(object.voter) ? String(object.voter) : "" + }; + }, + toSDK(message: QueryVoteRequest): QueryVoteRequestSDKType { + const obj: any = {}; + obj.proposal_id = message.proposalId; + obj.voter = message.voter; + return obj; + }, + fromAmino(object: QueryVoteRequestAmino): QueryVoteRequest { + const message = createBaseQueryVoteRequest(); + if (object.proposal_id !== undefined && object.proposal_id !== null) { + message.proposalId = BigInt(object.proposal_id); + } + if (object.voter !== undefined && object.voter !== null) { + message.voter = object.voter; + } + return message; + }, + toAmino(message: QueryVoteRequest): QueryVoteRequestAmino { + const obj: any = {}; + obj.proposal_id = message.proposalId !== BigInt(0) ? message.proposalId?.toString() : undefined; + obj.voter = message.voter === "" ? undefined : message.voter; + return obj; + }, + fromAminoMsg(object: QueryVoteRequestAminoMsg): QueryVoteRequest { + return QueryVoteRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryVoteRequest): QueryVoteRequestAminoMsg { + return { + type: "cosmos-sdk/v1/QueryVoteRequest", + value: QueryVoteRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryVoteRequestProtoMsg): QueryVoteRequest { + return QueryVoteRequest.decode(message.value); + }, + toProto(message: QueryVoteRequest): Uint8Array { + return QueryVoteRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryVoteRequest): QueryVoteRequestProtoMsg { + return { + typeUrl: "/cosmos.gov.v1.QueryVoteRequest", + value: QueryVoteRequest.encode(message).finish() + }; + } +}; +function createBaseQueryVoteResponse(): QueryVoteResponse { + return { + vote: undefined + }; +} +export const QueryVoteResponse = { + typeUrl: "/cosmos.gov.v1.QueryVoteResponse", + encode(message: QueryVoteResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.vote !== undefined) { + Vote.encode(message.vote, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryVoteResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryVoteResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.vote = Vote.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryVoteResponse { + const obj = createBaseQueryVoteResponse(); + if (isSet(object.vote)) obj.vote = Vote.fromJSON(object.vote); + return obj; + }, + toJSON(message: QueryVoteResponse): JsonSafe { + const obj: any = {}; + message.vote !== undefined && (obj.vote = message.vote ? Vote.toJSON(message.vote) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryVoteResponse { + const message = createBaseQueryVoteResponse(); + if (object.vote !== undefined && object.vote !== null) { + message.vote = Vote.fromPartial(object.vote); + } + return message; + }, + fromSDK(object: QueryVoteResponseSDKType): QueryVoteResponse { + return { + vote: object.vote ? Vote.fromSDK(object.vote) : undefined + }; + }, + fromSDKJSON(object: any): QueryVoteResponseSDKType { + return { + vote: isSet(object.vote) ? Vote.fromSDKJSON(object.vote) : undefined + }; + }, + toSDK(message: QueryVoteResponse): QueryVoteResponseSDKType { + const obj: any = {}; + message.vote !== undefined && (obj.vote = message.vote ? Vote.toSDK(message.vote) : undefined); + return obj; + }, + fromAmino(object: QueryVoteResponseAmino): QueryVoteResponse { + const message = createBaseQueryVoteResponse(); + if (object.vote !== undefined && object.vote !== null) { + message.vote = Vote.fromAmino(object.vote); + } + return message; + }, + toAmino(message: QueryVoteResponse): QueryVoteResponseAmino { + const obj: any = {}; + obj.vote = message.vote ? Vote.toAmino(message.vote) : undefined; + return obj; + }, + fromAminoMsg(object: QueryVoteResponseAminoMsg): QueryVoteResponse { + return QueryVoteResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryVoteResponse): QueryVoteResponseAminoMsg { + return { + type: "cosmos-sdk/v1/QueryVoteResponse", + value: QueryVoteResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryVoteResponseProtoMsg): QueryVoteResponse { + return QueryVoteResponse.decode(message.value); + }, + toProto(message: QueryVoteResponse): Uint8Array { + return QueryVoteResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryVoteResponse): QueryVoteResponseProtoMsg { + return { + typeUrl: "/cosmos.gov.v1.QueryVoteResponse", + value: QueryVoteResponse.encode(message).finish() + }; + } +}; +function createBaseQueryVotesRequest(): QueryVotesRequest { + return { + proposalId: BigInt(0), + pagination: undefined + }; +} +export const QueryVotesRequest = { + typeUrl: "/cosmos.gov.v1.QueryVotesRequest", + encode(message: QueryVotesRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.proposalId !== undefined) { + writer.uint32(8).uint64(message.proposalId); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryVotesRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryVotesRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.proposalId = reader.uint64(); + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryVotesRequest { + const obj = createBaseQueryVotesRequest(); + if (isSet(object.proposalId)) obj.proposalId = BigInt(object.proposalId.toString()); + if (isSet(object.pagination)) obj.pagination = PageRequest.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryVotesRequest): JsonSafe { + const obj: any = {}; + message.proposalId !== undefined && (obj.proposalId = (message.proposalId || BigInt(0)).toString()); + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryVotesRequest { + const message = createBaseQueryVotesRequest(); + if (object.proposalId !== undefined && object.proposalId !== null) { + message.proposalId = BigInt(object.proposalId.toString()); + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryVotesRequestSDKType): QueryVotesRequest { + return { + proposalId: object?.proposal_id, + pagination: object.pagination ? PageRequest.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryVotesRequestSDKType { + return { + proposal_id: isSet(object.proposal_id) ? BigInt(object.proposal_id.toString()) : BigInt(0), + pagination: isSet(object.pagination) ? PageRequest.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryVotesRequest): QueryVotesRequestSDKType { + const obj: any = {}; + obj.proposal_id = message.proposalId; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryVotesRequestAmino): QueryVotesRequest { + const message = createBaseQueryVotesRequest(); + if (object.proposal_id !== undefined && object.proposal_id !== null) { + message.proposalId = BigInt(object.proposal_id); + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryVotesRequest): QueryVotesRequestAmino { + const obj: any = {}; + obj.proposal_id = message.proposalId !== BigInt(0) ? message.proposalId?.toString() : undefined; + obj.pagination = message.pagination ? PageRequest.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryVotesRequestAminoMsg): QueryVotesRequest { + return QueryVotesRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryVotesRequest): QueryVotesRequestAminoMsg { + return { + type: "cosmos-sdk/v1/QueryVotesRequest", + value: QueryVotesRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryVotesRequestProtoMsg): QueryVotesRequest { + return QueryVotesRequest.decode(message.value); + }, + toProto(message: QueryVotesRequest): Uint8Array { + return QueryVotesRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryVotesRequest): QueryVotesRequestProtoMsg { + return { + typeUrl: "/cosmos.gov.v1.QueryVotesRequest", + value: QueryVotesRequest.encode(message).finish() + }; + } +}; +function createBaseQueryVotesResponse(): QueryVotesResponse { + return { + votes: [], + pagination: undefined + }; +} +export const QueryVotesResponse = { + typeUrl: "/cosmos.gov.v1.QueryVotesResponse", + encode(message: QueryVotesResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.votes) { + Vote.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryVotesResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryVotesResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.votes.push(Vote.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryVotesResponse { + const obj = createBaseQueryVotesResponse(); + if (Array.isArray(object?.votes)) obj.votes = object.votes.map((e: any) => Vote.fromJSON(e)); + if (isSet(object.pagination)) obj.pagination = PageResponse.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryVotesResponse): JsonSafe { + const obj: any = {}; + if (message.votes) { + obj.votes = message.votes.map(e => e ? Vote.toJSON(e) : undefined); + } else { + obj.votes = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryVotesResponse { + const message = createBaseQueryVotesResponse(); + message.votes = object.votes?.map(e => Vote.fromPartial(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryVotesResponseSDKType): QueryVotesResponse { + return { + votes: Array.isArray(object?.votes) ? object.votes.map((e: any) => Vote.fromSDK(e)) : [], + pagination: object.pagination ? PageResponse.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryVotesResponseSDKType { + return { + votes: Array.isArray(object?.votes) ? object.votes.map((e: any) => Vote.fromSDKJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryVotesResponse): QueryVotesResponseSDKType { + const obj: any = {}; + if (message.votes) { + obj.votes = message.votes.map(e => e ? Vote.toSDK(e) : undefined); + } else { + obj.votes = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryVotesResponseAmino): QueryVotesResponse { + const message = createBaseQueryVotesResponse(); + message.votes = object.votes?.map(e => Vote.fromAmino(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryVotesResponse): QueryVotesResponseAmino { + const obj: any = {}; + if (message.votes) { + obj.votes = message.votes.map(e => e ? Vote.toAmino(e) : undefined); + } else { + obj.votes = message.votes; + } + obj.pagination = message.pagination ? PageResponse.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryVotesResponseAminoMsg): QueryVotesResponse { + return QueryVotesResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryVotesResponse): QueryVotesResponseAminoMsg { + return { + type: "cosmos-sdk/v1/QueryVotesResponse", + value: QueryVotesResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryVotesResponseProtoMsg): QueryVotesResponse { + return QueryVotesResponse.decode(message.value); + }, + toProto(message: QueryVotesResponse): Uint8Array { + return QueryVotesResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryVotesResponse): QueryVotesResponseProtoMsg { + return { + typeUrl: "/cosmos.gov.v1.QueryVotesResponse", + value: QueryVotesResponse.encode(message).finish() + }; + } +}; +function createBaseQueryParamsRequest(): QueryParamsRequest { + return { + paramsType: "" + }; +} +export const QueryParamsRequest = { + typeUrl: "/cosmos.gov.v1.QueryParamsRequest", + encode(message: QueryParamsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.paramsType !== undefined) { + writer.uint32(10).string(message.paramsType); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryParamsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryParamsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.paramsType = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryParamsRequest { + const obj = createBaseQueryParamsRequest(); + if (isSet(object.paramsType)) obj.paramsType = String(object.paramsType); + return obj; + }, + toJSON(message: QueryParamsRequest): JsonSafe { + const obj: any = {}; + message.paramsType !== undefined && (obj.paramsType = message.paramsType); + return obj; + }, + fromPartial(object: DeepPartial): QueryParamsRequest { + const message = createBaseQueryParamsRequest(); + message.paramsType = object.paramsType ?? ""; + return message; + }, + fromSDK(object: QueryParamsRequestSDKType): QueryParamsRequest { + return { + paramsType: object?.params_type + }; + }, + fromSDKJSON(object: any): QueryParamsRequestSDKType { + return { + params_type: isSet(object.params_type) ? String(object.params_type) : "" + }; + }, + toSDK(message: QueryParamsRequest): QueryParamsRequestSDKType { + const obj: any = {}; + obj.params_type = message.paramsType; + return obj; + }, + fromAmino(object: QueryParamsRequestAmino): QueryParamsRequest { + const message = createBaseQueryParamsRequest(); + if (object.params_type !== undefined && object.params_type !== null) { + message.paramsType = object.params_type; + } + return message; + }, + toAmino(message: QueryParamsRequest): QueryParamsRequestAmino { + const obj: any = {}; + obj.params_type = message.paramsType === "" ? undefined : message.paramsType; + return obj; + }, + fromAminoMsg(object: QueryParamsRequestAminoMsg): QueryParamsRequest { + return QueryParamsRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryParamsRequest): QueryParamsRequestAminoMsg { + return { + type: "cosmos-sdk/v1/QueryParamsRequest", + value: QueryParamsRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryParamsRequestProtoMsg): QueryParamsRequest { + return QueryParamsRequest.decode(message.value); + }, + toProto(message: QueryParamsRequest): Uint8Array { + return QueryParamsRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryParamsRequest): QueryParamsRequestProtoMsg { + return { + typeUrl: "/cosmos.gov.v1.QueryParamsRequest", + value: QueryParamsRequest.encode(message).finish() + }; + } +}; +function createBaseQueryParamsResponse(): QueryParamsResponse { + return { + votingParams: undefined, + depositParams: undefined, + tallyParams: undefined + }; +} +export const QueryParamsResponse = { + typeUrl: "/cosmos.gov.v1.QueryParamsResponse", + encode(message: QueryParamsResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.votingParams !== undefined) { + VotingParams.encode(message.votingParams, writer.uint32(10).fork()).ldelim(); + } + if (message.depositParams !== undefined) { + DepositParams.encode(message.depositParams, writer.uint32(18).fork()).ldelim(); + } + if (message.tallyParams !== undefined) { + TallyParams.encode(message.tallyParams, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryParamsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryParamsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.votingParams = VotingParams.decode(reader, reader.uint32()); + break; + case 2: + message.depositParams = DepositParams.decode(reader, reader.uint32()); + break; + case 3: + message.tallyParams = TallyParams.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryParamsResponse { + const obj = createBaseQueryParamsResponse(); + if (isSet(object.votingParams)) obj.votingParams = VotingParams.fromJSON(object.votingParams); + if (isSet(object.depositParams)) obj.depositParams = DepositParams.fromJSON(object.depositParams); + if (isSet(object.tallyParams)) obj.tallyParams = TallyParams.fromJSON(object.tallyParams); + return obj; + }, + toJSON(message: QueryParamsResponse): JsonSafe { + const obj: any = {}; + message.votingParams !== undefined && (obj.votingParams = message.votingParams ? VotingParams.toJSON(message.votingParams) : undefined); + message.depositParams !== undefined && (obj.depositParams = message.depositParams ? DepositParams.toJSON(message.depositParams) : undefined); + message.tallyParams !== undefined && (obj.tallyParams = message.tallyParams ? TallyParams.toJSON(message.tallyParams) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryParamsResponse { + const message = createBaseQueryParamsResponse(); + if (object.votingParams !== undefined && object.votingParams !== null) { + message.votingParams = VotingParams.fromPartial(object.votingParams); + } + if (object.depositParams !== undefined && object.depositParams !== null) { + message.depositParams = DepositParams.fromPartial(object.depositParams); + } + if (object.tallyParams !== undefined && object.tallyParams !== null) { + message.tallyParams = TallyParams.fromPartial(object.tallyParams); + } + return message; + }, + fromSDK(object: QueryParamsResponseSDKType): QueryParamsResponse { + return { + votingParams: object.voting_params ? VotingParams.fromSDK(object.voting_params) : undefined, + depositParams: object.deposit_params ? DepositParams.fromSDK(object.deposit_params) : undefined, + tallyParams: object.tally_params ? TallyParams.fromSDK(object.tally_params) : undefined + }; + }, + fromSDKJSON(object: any): QueryParamsResponseSDKType { + return { + voting_params: isSet(object.voting_params) ? VotingParams.fromSDKJSON(object.voting_params) : undefined, + deposit_params: isSet(object.deposit_params) ? DepositParams.fromSDKJSON(object.deposit_params) : undefined, + tally_params: isSet(object.tally_params) ? TallyParams.fromSDKJSON(object.tally_params) : undefined + }; + }, + toSDK(message: QueryParamsResponse): QueryParamsResponseSDKType { + const obj: any = {}; + message.votingParams !== undefined && (obj.voting_params = message.votingParams ? VotingParams.toSDK(message.votingParams) : undefined); + message.depositParams !== undefined && (obj.deposit_params = message.depositParams ? DepositParams.toSDK(message.depositParams) : undefined); + message.tallyParams !== undefined && (obj.tally_params = message.tallyParams ? TallyParams.toSDK(message.tallyParams) : undefined); + return obj; + }, + fromAmino(object: QueryParamsResponseAmino): QueryParamsResponse { + const message = createBaseQueryParamsResponse(); + if (object.voting_params !== undefined && object.voting_params !== null) { + message.votingParams = VotingParams.fromAmino(object.voting_params); + } + if (object.deposit_params !== undefined && object.deposit_params !== null) { + message.depositParams = DepositParams.fromAmino(object.deposit_params); + } + if (object.tally_params !== undefined && object.tally_params !== null) { + message.tallyParams = TallyParams.fromAmino(object.tally_params); + } + return message; + }, + toAmino(message: QueryParamsResponse): QueryParamsResponseAmino { + const obj: any = {}; + obj.voting_params = message.votingParams ? VotingParams.toAmino(message.votingParams) : undefined; + obj.deposit_params = message.depositParams ? DepositParams.toAmino(message.depositParams) : undefined; + obj.tally_params = message.tallyParams ? TallyParams.toAmino(message.tallyParams) : undefined; + return obj; + }, + fromAminoMsg(object: QueryParamsResponseAminoMsg): QueryParamsResponse { + return QueryParamsResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryParamsResponse): QueryParamsResponseAminoMsg { + return { + type: "cosmos-sdk/v1/QueryParamsResponse", + value: QueryParamsResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryParamsResponseProtoMsg): QueryParamsResponse { + return QueryParamsResponse.decode(message.value); + }, + toProto(message: QueryParamsResponse): Uint8Array { + return QueryParamsResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryParamsResponse): QueryParamsResponseProtoMsg { + return { + typeUrl: "/cosmos.gov.v1.QueryParamsResponse", + value: QueryParamsResponse.encode(message).finish() + }; + } +}; +function createBaseQueryDepositRequest(): QueryDepositRequest { + return { + proposalId: BigInt(0), + depositor: "" + }; +} +export const QueryDepositRequest = { + typeUrl: "/cosmos.gov.v1.QueryDepositRequest", + encode(message: QueryDepositRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.proposalId !== undefined) { + writer.uint32(8).uint64(message.proposalId); + } + if (message.depositor !== undefined) { + writer.uint32(18).string(message.depositor); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryDepositRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryDepositRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.proposalId = reader.uint64(); + break; + case 2: + message.depositor = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryDepositRequest { + const obj = createBaseQueryDepositRequest(); + if (isSet(object.proposalId)) obj.proposalId = BigInt(object.proposalId.toString()); + if (isSet(object.depositor)) obj.depositor = String(object.depositor); + return obj; + }, + toJSON(message: QueryDepositRequest): JsonSafe { + const obj: any = {}; + message.proposalId !== undefined && (obj.proposalId = (message.proposalId || BigInt(0)).toString()); + message.depositor !== undefined && (obj.depositor = message.depositor); + return obj; + }, + fromPartial(object: DeepPartial): QueryDepositRequest { + const message = createBaseQueryDepositRequest(); + if (object.proposalId !== undefined && object.proposalId !== null) { + message.proposalId = BigInt(object.proposalId.toString()); + } + message.depositor = object.depositor ?? ""; + return message; + }, + fromSDK(object: QueryDepositRequestSDKType): QueryDepositRequest { + return { + proposalId: object?.proposal_id, + depositor: object?.depositor + }; + }, + fromSDKJSON(object: any): QueryDepositRequestSDKType { + return { + proposal_id: isSet(object.proposal_id) ? BigInt(object.proposal_id.toString()) : BigInt(0), + depositor: isSet(object.depositor) ? String(object.depositor) : "" + }; + }, + toSDK(message: QueryDepositRequest): QueryDepositRequestSDKType { + const obj: any = {}; + obj.proposal_id = message.proposalId; + obj.depositor = message.depositor; + return obj; + }, + fromAmino(object: QueryDepositRequestAmino): QueryDepositRequest { + const message = createBaseQueryDepositRequest(); + if (object.proposal_id !== undefined && object.proposal_id !== null) { + message.proposalId = BigInt(object.proposal_id); + } + if (object.depositor !== undefined && object.depositor !== null) { + message.depositor = object.depositor; + } + return message; + }, + toAmino(message: QueryDepositRequest): QueryDepositRequestAmino { + const obj: any = {}; + obj.proposal_id = message.proposalId !== BigInt(0) ? message.proposalId?.toString() : undefined; + obj.depositor = message.depositor === "" ? undefined : message.depositor; + return obj; + }, + fromAminoMsg(object: QueryDepositRequestAminoMsg): QueryDepositRequest { + return QueryDepositRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryDepositRequest): QueryDepositRequestAminoMsg { + return { + type: "cosmos-sdk/v1/QueryDepositRequest", + value: QueryDepositRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryDepositRequestProtoMsg): QueryDepositRequest { + return QueryDepositRequest.decode(message.value); + }, + toProto(message: QueryDepositRequest): Uint8Array { + return QueryDepositRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryDepositRequest): QueryDepositRequestProtoMsg { + return { + typeUrl: "/cosmos.gov.v1.QueryDepositRequest", + value: QueryDepositRequest.encode(message).finish() + }; + } +}; +function createBaseQueryDepositResponse(): QueryDepositResponse { + return { + deposit: undefined + }; +} +export const QueryDepositResponse = { + typeUrl: "/cosmos.gov.v1.QueryDepositResponse", + encode(message: QueryDepositResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.deposit !== undefined) { + Deposit.encode(message.deposit, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryDepositResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryDepositResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.deposit = Deposit.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryDepositResponse { + const obj = createBaseQueryDepositResponse(); + if (isSet(object.deposit)) obj.deposit = Deposit.fromJSON(object.deposit); + return obj; + }, + toJSON(message: QueryDepositResponse): JsonSafe { + const obj: any = {}; + message.deposit !== undefined && (obj.deposit = message.deposit ? Deposit.toJSON(message.deposit) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryDepositResponse { + const message = createBaseQueryDepositResponse(); + if (object.deposit !== undefined && object.deposit !== null) { + message.deposit = Deposit.fromPartial(object.deposit); + } + return message; + }, + fromSDK(object: QueryDepositResponseSDKType): QueryDepositResponse { + return { + deposit: object.deposit ? Deposit.fromSDK(object.deposit) : undefined + }; + }, + fromSDKJSON(object: any): QueryDepositResponseSDKType { + return { + deposit: isSet(object.deposit) ? Deposit.fromSDKJSON(object.deposit) : undefined + }; + }, + toSDK(message: QueryDepositResponse): QueryDepositResponseSDKType { + const obj: any = {}; + message.deposit !== undefined && (obj.deposit = message.deposit ? Deposit.toSDK(message.deposit) : undefined); + return obj; + }, + fromAmino(object: QueryDepositResponseAmino): QueryDepositResponse { + const message = createBaseQueryDepositResponse(); + if (object.deposit !== undefined && object.deposit !== null) { + message.deposit = Deposit.fromAmino(object.deposit); + } + return message; + }, + toAmino(message: QueryDepositResponse): QueryDepositResponseAmino { + const obj: any = {}; + obj.deposit = message.deposit ? Deposit.toAmino(message.deposit) : undefined; + return obj; + }, + fromAminoMsg(object: QueryDepositResponseAminoMsg): QueryDepositResponse { + return QueryDepositResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryDepositResponse): QueryDepositResponseAminoMsg { + return { + type: "cosmos-sdk/v1/QueryDepositResponse", + value: QueryDepositResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryDepositResponseProtoMsg): QueryDepositResponse { + return QueryDepositResponse.decode(message.value); + }, + toProto(message: QueryDepositResponse): Uint8Array { + return QueryDepositResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryDepositResponse): QueryDepositResponseProtoMsg { + return { + typeUrl: "/cosmos.gov.v1.QueryDepositResponse", + value: QueryDepositResponse.encode(message).finish() + }; + } +}; +function createBaseQueryDepositsRequest(): QueryDepositsRequest { + return { + proposalId: BigInt(0), + pagination: undefined + }; +} +export const QueryDepositsRequest = { + typeUrl: "/cosmos.gov.v1.QueryDepositsRequest", + encode(message: QueryDepositsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.proposalId !== undefined) { + writer.uint32(8).uint64(message.proposalId); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryDepositsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryDepositsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.proposalId = reader.uint64(); + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryDepositsRequest { + const obj = createBaseQueryDepositsRequest(); + if (isSet(object.proposalId)) obj.proposalId = BigInt(object.proposalId.toString()); + if (isSet(object.pagination)) obj.pagination = PageRequest.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryDepositsRequest): JsonSafe { + const obj: any = {}; + message.proposalId !== undefined && (obj.proposalId = (message.proposalId || BigInt(0)).toString()); + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryDepositsRequest { + const message = createBaseQueryDepositsRequest(); + if (object.proposalId !== undefined && object.proposalId !== null) { + message.proposalId = BigInt(object.proposalId.toString()); + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryDepositsRequestSDKType): QueryDepositsRequest { + return { + proposalId: object?.proposal_id, + pagination: object.pagination ? PageRequest.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryDepositsRequestSDKType { + return { + proposal_id: isSet(object.proposal_id) ? BigInt(object.proposal_id.toString()) : BigInt(0), + pagination: isSet(object.pagination) ? PageRequest.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryDepositsRequest): QueryDepositsRequestSDKType { + const obj: any = {}; + obj.proposal_id = message.proposalId; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryDepositsRequestAmino): QueryDepositsRequest { + const message = createBaseQueryDepositsRequest(); + if (object.proposal_id !== undefined && object.proposal_id !== null) { + message.proposalId = BigInt(object.proposal_id); + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryDepositsRequest): QueryDepositsRequestAmino { + const obj: any = {}; + obj.proposal_id = message.proposalId !== BigInt(0) ? message.proposalId?.toString() : undefined; + obj.pagination = message.pagination ? PageRequest.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryDepositsRequestAminoMsg): QueryDepositsRequest { + return QueryDepositsRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryDepositsRequest): QueryDepositsRequestAminoMsg { + return { + type: "cosmos-sdk/v1/QueryDepositsRequest", + value: QueryDepositsRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryDepositsRequestProtoMsg): QueryDepositsRequest { + return QueryDepositsRequest.decode(message.value); + }, + toProto(message: QueryDepositsRequest): Uint8Array { + return QueryDepositsRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryDepositsRequest): QueryDepositsRequestProtoMsg { + return { + typeUrl: "/cosmos.gov.v1.QueryDepositsRequest", + value: QueryDepositsRequest.encode(message).finish() + }; + } +}; +function createBaseQueryDepositsResponse(): QueryDepositsResponse { + return { + deposits: [], + pagination: undefined + }; +} +export const QueryDepositsResponse = { + typeUrl: "/cosmos.gov.v1.QueryDepositsResponse", + encode(message: QueryDepositsResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.deposits) { + Deposit.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryDepositsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryDepositsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.deposits.push(Deposit.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryDepositsResponse { + const obj = createBaseQueryDepositsResponse(); + if (Array.isArray(object?.deposits)) obj.deposits = object.deposits.map((e: any) => Deposit.fromJSON(e)); + if (isSet(object.pagination)) obj.pagination = PageResponse.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryDepositsResponse): JsonSafe { + const obj: any = {}; + if (message.deposits) { + obj.deposits = message.deposits.map(e => e ? Deposit.toJSON(e) : undefined); + } else { + obj.deposits = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryDepositsResponse { + const message = createBaseQueryDepositsResponse(); + message.deposits = object.deposits?.map(e => Deposit.fromPartial(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryDepositsResponseSDKType): QueryDepositsResponse { + return { + deposits: Array.isArray(object?.deposits) ? object.deposits.map((e: any) => Deposit.fromSDK(e)) : [], + pagination: object.pagination ? PageResponse.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryDepositsResponseSDKType { + return { + deposits: Array.isArray(object?.deposits) ? object.deposits.map((e: any) => Deposit.fromSDKJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryDepositsResponse): QueryDepositsResponseSDKType { + const obj: any = {}; + if (message.deposits) { + obj.deposits = message.deposits.map(e => e ? Deposit.toSDK(e) : undefined); + } else { + obj.deposits = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryDepositsResponseAmino): QueryDepositsResponse { + const message = createBaseQueryDepositsResponse(); + message.deposits = object.deposits?.map(e => Deposit.fromAmino(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryDepositsResponse): QueryDepositsResponseAmino { + const obj: any = {}; + if (message.deposits) { + obj.deposits = message.deposits.map(e => e ? Deposit.toAmino(e) : undefined); + } else { + obj.deposits = message.deposits; + } + obj.pagination = message.pagination ? PageResponse.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryDepositsResponseAminoMsg): QueryDepositsResponse { + return QueryDepositsResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryDepositsResponse): QueryDepositsResponseAminoMsg { + return { + type: "cosmos-sdk/v1/QueryDepositsResponse", + value: QueryDepositsResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryDepositsResponseProtoMsg): QueryDepositsResponse { + return QueryDepositsResponse.decode(message.value); + }, + toProto(message: QueryDepositsResponse): Uint8Array { + return QueryDepositsResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryDepositsResponse): QueryDepositsResponseProtoMsg { + return { + typeUrl: "/cosmos.gov.v1.QueryDepositsResponse", + value: QueryDepositsResponse.encode(message).finish() + }; + } +}; +function createBaseQueryTallyResultRequest(): QueryTallyResultRequest { + return { + proposalId: BigInt(0) + }; +} +export const QueryTallyResultRequest = { + typeUrl: "/cosmos.gov.v1.QueryTallyResultRequest", + encode(message: QueryTallyResultRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.proposalId !== undefined) { + writer.uint32(8).uint64(message.proposalId); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryTallyResultRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryTallyResultRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.proposalId = reader.uint64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryTallyResultRequest { + const obj = createBaseQueryTallyResultRequest(); + if (isSet(object.proposalId)) obj.proposalId = BigInt(object.proposalId.toString()); + return obj; + }, + toJSON(message: QueryTallyResultRequest): JsonSafe { + const obj: any = {}; + message.proposalId !== undefined && (obj.proposalId = (message.proposalId || BigInt(0)).toString()); + return obj; + }, + fromPartial(object: DeepPartial): QueryTallyResultRequest { + const message = createBaseQueryTallyResultRequest(); + if (object.proposalId !== undefined && object.proposalId !== null) { + message.proposalId = BigInt(object.proposalId.toString()); + } + return message; + }, + fromSDK(object: QueryTallyResultRequestSDKType): QueryTallyResultRequest { + return { + proposalId: object?.proposal_id + }; + }, + fromSDKJSON(object: any): QueryTallyResultRequestSDKType { + return { + proposal_id: isSet(object.proposal_id) ? BigInt(object.proposal_id.toString()) : BigInt(0) + }; + }, + toSDK(message: QueryTallyResultRequest): QueryTallyResultRequestSDKType { + const obj: any = {}; + obj.proposal_id = message.proposalId; + return obj; + }, + fromAmino(object: QueryTallyResultRequestAmino): QueryTallyResultRequest { + const message = createBaseQueryTallyResultRequest(); + if (object.proposal_id !== undefined && object.proposal_id !== null) { + message.proposalId = BigInt(object.proposal_id); + } + return message; + }, + toAmino(message: QueryTallyResultRequest): QueryTallyResultRequestAmino { + const obj: any = {}; + obj.proposal_id = message.proposalId !== BigInt(0) ? message.proposalId?.toString() : undefined; + return obj; + }, + fromAminoMsg(object: QueryTallyResultRequestAminoMsg): QueryTallyResultRequest { + return QueryTallyResultRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryTallyResultRequest): QueryTallyResultRequestAminoMsg { + return { + type: "cosmos-sdk/v1/QueryTallyResultRequest", + value: QueryTallyResultRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryTallyResultRequestProtoMsg): QueryTallyResultRequest { + return QueryTallyResultRequest.decode(message.value); + }, + toProto(message: QueryTallyResultRequest): Uint8Array { + return QueryTallyResultRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryTallyResultRequest): QueryTallyResultRequestProtoMsg { + return { + typeUrl: "/cosmos.gov.v1.QueryTallyResultRequest", + value: QueryTallyResultRequest.encode(message).finish() + }; + } +}; +function createBaseQueryTallyResultResponse(): QueryTallyResultResponse { + return { + tally: undefined + }; +} +export const QueryTallyResultResponse = { + typeUrl: "/cosmos.gov.v1.QueryTallyResultResponse", + encode(message: QueryTallyResultResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.tally !== undefined) { + TallyResult.encode(message.tally, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryTallyResultResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryTallyResultResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.tally = TallyResult.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryTallyResultResponse { + const obj = createBaseQueryTallyResultResponse(); + if (isSet(object.tally)) obj.tally = TallyResult.fromJSON(object.tally); + return obj; + }, + toJSON(message: QueryTallyResultResponse): JsonSafe { + const obj: any = {}; + message.tally !== undefined && (obj.tally = message.tally ? TallyResult.toJSON(message.tally) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryTallyResultResponse { + const message = createBaseQueryTallyResultResponse(); + if (object.tally !== undefined && object.tally !== null) { + message.tally = TallyResult.fromPartial(object.tally); + } + return message; + }, + fromSDK(object: QueryTallyResultResponseSDKType): QueryTallyResultResponse { + return { + tally: object.tally ? TallyResult.fromSDK(object.tally) : undefined + }; + }, + fromSDKJSON(object: any): QueryTallyResultResponseSDKType { + return { + tally: isSet(object.tally) ? TallyResult.fromSDKJSON(object.tally) : undefined + }; + }, + toSDK(message: QueryTallyResultResponse): QueryTallyResultResponseSDKType { + const obj: any = {}; + message.tally !== undefined && (obj.tally = message.tally ? TallyResult.toSDK(message.tally) : undefined); + return obj; + }, + fromAmino(object: QueryTallyResultResponseAmino): QueryTallyResultResponse { + const message = createBaseQueryTallyResultResponse(); + if (object.tally !== undefined && object.tally !== null) { + message.tally = TallyResult.fromAmino(object.tally); + } + return message; + }, + toAmino(message: QueryTallyResultResponse): QueryTallyResultResponseAmino { + const obj: any = {}; + obj.tally = message.tally ? TallyResult.toAmino(message.tally) : undefined; + return obj; + }, + fromAminoMsg(object: QueryTallyResultResponseAminoMsg): QueryTallyResultResponse { + return QueryTallyResultResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryTallyResultResponse): QueryTallyResultResponseAminoMsg { + return { + type: "cosmos-sdk/v1/QueryTallyResultResponse", + value: QueryTallyResultResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryTallyResultResponseProtoMsg): QueryTallyResultResponse { + return QueryTallyResultResponse.decode(message.value); + }, + toProto(message: QueryTallyResultResponse): Uint8Array { + return QueryTallyResultResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryTallyResultResponse): QueryTallyResultResponseProtoMsg { + return { + typeUrl: "/cosmos.gov.v1.QueryTallyResultResponse", + value: QueryTallyResultResponse.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/gov/v1/tx.amino.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/gov/v1/tx.amino.ts new file mode 100644 index 0000000000..a6e5c29721 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/gov/v1/tx.amino.ts @@ -0,0 +1,227 @@ +import { Any, AnySDKType } from "../../../google/protobuf/any.js"; +import { Coin, CoinSDKType } from "../../base/v1beta1/coin.js"; +import { VoteOption, VoteOptionSDKType, WeightedVoteOption, WeightedVoteOptionSDKType, voteOptionFromJSON } from "./gov.js"; +import { ReadOnlyAminoMsg as AminoMsg } from "@interchainjs/ReadOnlyAminoMsg"; +import { MsgSubmitProposal, MsgSubmitProposalSDKType, MsgExecLegacyContent, MsgExecLegacyContentSDKType, MsgVote, MsgVoteSDKType, MsgVoteWeighted, MsgVoteWeightedSDKType, MsgDeposit, MsgDepositSDKType } from "./tx.js"; +export interface MsgSubmitProposalAminoType extends AminoMsg { + type: "cosmos-sdk/v1/MsgSubmitProposal"; + value: { + messages: { + type_url: string; + value: Uint8Array; + }[]; + initial_deposit: { + denom: string; + amount: string; + }[]; + proposer: string; + metadata: string; + }; +} +export interface MsgExecLegacyContentAminoType extends AminoMsg { + type: "cosmos-sdk/v1/MsgExecLegacyContent"; + value: { + content: { + type_url: string; + value: Uint8Array; + }; + authority: string; + }; +} +export interface MsgVoteAminoType extends AminoMsg { + type: "cosmos-sdk/v1/MsgVote"; + value: { + proposal_id: string; + voter: string; + option: number; + metadata: string; + }; +} +export interface MsgVoteWeightedAminoType extends AminoMsg { + type: "cosmos-sdk/v1/MsgVoteWeighted"; + value: { + proposal_id: string; + voter: string; + options: { + option: number; + weight: string; + }[]; + metadata: string; + }; +} +export interface MsgDepositAminoType extends AminoMsg { + type: "cosmos-sdk/v1/MsgDeposit"; + value: { + proposal_id: string; + depositor: string; + amount: { + denom: string; + amount: string; + }[]; + }; +} +export const AminoConverter = { + "/cosmos.gov.v1.MsgSubmitProposal": { + aminoType: "cosmos-sdk/v1/MsgSubmitProposal", + toAmino: ({ + messages, + initialDeposit, + proposer, + metadata + }: MsgSubmitProposal): MsgSubmitProposalAminoType["value"] => { + return { + messages: messages.map(el0 => ({ + type_url: el0.typeUrl, + value: el0.value + })), + initial_deposit: initialDeposit.map(el0 => ({ + denom: el0.denom, + amount: el0.amount + })), + proposer, + metadata + }; + }, + fromAmino: ({ + messages, + initial_deposit, + proposer, + metadata + }: MsgSubmitProposalAminoType["value"]): MsgSubmitProposal => { + return { + messages: messages.map(el0 => ({ + typeUrl: el0.type_url, + value: el0.value + })), + initialDeposit: initial_deposit.map(el0 => ({ + denom: el0.denom, + amount: el0.amount + })), + proposer, + metadata + }; + } + }, + "/cosmos.gov.v1.MsgExecLegacyContent": { + aminoType: "cosmos-sdk/v1/MsgExecLegacyContent", + toAmino: ({ + content, + authority + }: MsgExecLegacyContent): MsgExecLegacyContentAminoType["value"] => { + return { + content: { + type_url: content.typeUrl, + value: content.value + }, + authority + }; + }, + fromAmino: ({ + content, + authority + }: MsgExecLegacyContentAminoType["value"]): MsgExecLegacyContent => { + return { + content: { + typeUrl: content.type_url, + value: content.value + }, + authority + }; + } + }, + "/cosmos.gov.v1.MsgVote": { + aminoType: "cosmos-sdk/v1/MsgVote", + toAmino: ({ + proposalId, + voter, + option, + metadata + }: MsgVote): MsgVoteAminoType["value"] => { + return { + proposal_id: proposalId.toString(), + voter, + option, + metadata + }; + }, + fromAmino: ({ + proposal_id, + voter, + option, + metadata + }: MsgVoteAminoType["value"]): MsgVote => { + return { + proposalId: BigInt(proposal_id), + voter, + option: voteOptionFromJSON(option), + metadata + }; + } + }, + "/cosmos.gov.v1.MsgVoteWeighted": { + aminoType: "cosmos-sdk/v1/MsgVoteWeighted", + toAmino: ({ + proposalId, + voter, + options, + metadata + }: MsgVoteWeighted): MsgVoteWeightedAminoType["value"] => { + return { + proposal_id: proposalId.toString(), + voter, + options: options.map(el0 => ({ + option: el0.option, + weight: el0.weight + })), + metadata + }; + }, + fromAmino: ({ + proposal_id, + voter, + options, + metadata + }: MsgVoteWeightedAminoType["value"]): MsgVoteWeighted => { + return { + proposalId: BigInt(proposal_id), + voter, + options: options.map(el0 => ({ + option: voteOptionFromJSON(el0.option), + weight: el0.weight + })), + metadata + }; + } + }, + "/cosmos.gov.v1.MsgDeposit": { + aminoType: "cosmos-sdk/v1/MsgDeposit", + toAmino: ({ + proposalId, + depositor, + amount + }: MsgDeposit): MsgDepositAminoType["value"] => { + return { + proposal_id: proposalId.toString(), + depositor, + amount: amount.map(el0 => ({ + denom: el0.denom, + amount: el0.amount + })) + }; + }, + fromAmino: ({ + proposal_id, + depositor, + amount + }: MsgDepositAminoType["value"]): MsgDeposit => { + return { + proposalId: BigInt(proposal_id), + depositor, + amount: amount.map(el0 => ({ + denom: el0.denom, + amount: el0.amount + })) + }; + } + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/gov/v1/tx.registry.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/gov/v1/tx.registry.ts new file mode 100644 index 0000000000..95857b5b68 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/gov/v1/tx.registry.ts @@ -0,0 +1,173 @@ +import { Any, AnySDKType } from "../../../google/protobuf/any.js"; +import { Coin, CoinSDKType } from "../../base/v1beta1/coin.js"; +import { VoteOption, VoteOptionSDKType, WeightedVoteOption, WeightedVoteOptionSDKType } from "./gov.js"; +import { GeneratedType, Registry } from "@cosmjs/proto-signing"; +import { MsgSubmitProposal, MsgSubmitProposalSDKType, MsgExecLegacyContent, MsgExecLegacyContentSDKType, MsgVote, MsgVoteSDKType, MsgVoteWeighted, MsgVoteWeightedSDKType, MsgDeposit, MsgDepositSDKType } from "./tx.js"; +export const registry: ReadonlyArray<[string, GeneratedType]> = [["/cosmos.gov.v1.MsgSubmitProposal", MsgSubmitProposal], ["/cosmos.gov.v1.MsgExecLegacyContent", MsgExecLegacyContent], ["/cosmos.gov.v1.MsgVote", MsgVote], ["/cosmos.gov.v1.MsgVoteWeighted", MsgVoteWeighted], ["/cosmos.gov.v1.MsgDeposit", MsgDeposit]]; +export const load = (protoRegistry: Registry) => { + registry.forEach(([typeUrl, mod]) => { + protoRegistry.register(typeUrl, mod); + }); +}; +export const MessageComposer = { + encoded: { + submitProposal(value: MsgSubmitProposal) { + return { + typeUrl: "/cosmos.gov.v1.MsgSubmitProposal", + value: MsgSubmitProposal.encode(value).finish() + }; + }, + execLegacyContent(value: MsgExecLegacyContent) { + return { + typeUrl: "/cosmos.gov.v1.MsgExecLegacyContent", + value: MsgExecLegacyContent.encode(value).finish() + }; + }, + vote(value: MsgVote) { + return { + typeUrl: "/cosmos.gov.v1.MsgVote", + value: MsgVote.encode(value).finish() + }; + }, + voteWeighted(value: MsgVoteWeighted) { + return { + typeUrl: "/cosmos.gov.v1.MsgVoteWeighted", + value: MsgVoteWeighted.encode(value).finish() + }; + }, + deposit(value: MsgDeposit) { + return { + typeUrl: "/cosmos.gov.v1.MsgDeposit", + value: MsgDeposit.encode(value).finish() + }; + } + }, + withTypeUrl: { + submitProposal(value: MsgSubmitProposal) { + return { + typeUrl: "/cosmos.gov.v1.MsgSubmitProposal", + value + }; + }, + execLegacyContent(value: MsgExecLegacyContent) { + return { + typeUrl: "/cosmos.gov.v1.MsgExecLegacyContent", + value + }; + }, + vote(value: MsgVote) { + return { + typeUrl: "/cosmos.gov.v1.MsgVote", + value + }; + }, + voteWeighted(value: MsgVoteWeighted) { + return { + typeUrl: "/cosmos.gov.v1.MsgVoteWeighted", + value + }; + }, + deposit(value: MsgDeposit) { + return { + typeUrl: "/cosmos.gov.v1.MsgDeposit", + value + }; + } + }, + toJSON: { + submitProposal(value: MsgSubmitProposal) { + return { + typeUrl: "/cosmos.gov.v1.MsgSubmitProposal", + value: MsgSubmitProposal.toJSON(value) + }; + }, + execLegacyContent(value: MsgExecLegacyContent) { + return { + typeUrl: "/cosmos.gov.v1.MsgExecLegacyContent", + value: MsgExecLegacyContent.toJSON(value) + }; + }, + vote(value: MsgVote) { + return { + typeUrl: "/cosmos.gov.v1.MsgVote", + value: MsgVote.toJSON(value) + }; + }, + voteWeighted(value: MsgVoteWeighted) { + return { + typeUrl: "/cosmos.gov.v1.MsgVoteWeighted", + value: MsgVoteWeighted.toJSON(value) + }; + }, + deposit(value: MsgDeposit) { + return { + typeUrl: "/cosmos.gov.v1.MsgDeposit", + value: MsgDeposit.toJSON(value) + }; + } + }, + fromJSON: { + submitProposal(value: any) { + return { + typeUrl: "/cosmos.gov.v1.MsgSubmitProposal", + value: MsgSubmitProposal.fromJSON(value) + }; + }, + execLegacyContent(value: any) { + return { + typeUrl: "/cosmos.gov.v1.MsgExecLegacyContent", + value: MsgExecLegacyContent.fromJSON(value) + }; + }, + vote(value: any) { + return { + typeUrl: "/cosmos.gov.v1.MsgVote", + value: MsgVote.fromJSON(value) + }; + }, + voteWeighted(value: any) { + return { + typeUrl: "/cosmos.gov.v1.MsgVoteWeighted", + value: MsgVoteWeighted.fromJSON(value) + }; + }, + deposit(value: any) { + return { + typeUrl: "/cosmos.gov.v1.MsgDeposit", + value: MsgDeposit.fromJSON(value) + }; + } + }, + fromPartial: { + submitProposal(value: MsgSubmitProposal) { + return { + typeUrl: "/cosmos.gov.v1.MsgSubmitProposal", + value: MsgSubmitProposal.fromPartial(value) + }; + }, + execLegacyContent(value: MsgExecLegacyContent) { + return { + typeUrl: "/cosmos.gov.v1.MsgExecLegacyContent", + value: MsgExecLegacyContent.fromPartial(value) + }; + }, + vote(value: MsgVote) { + return { + typeUrl: "/cosmos.gov.v1.MsgVote", + value: MsgVote.fromPartial(value) + }; + }, + voteWeighted(value: MsgVoteWeighted) { + return { + typeUrl: "/cosmos.gov.v1.MsgVoteWeighted", + value: MsgVoteWeighted.fromPartial(value) + }; + }, + deposit(value: MsgDeposit) { + return { + typeUrl: "/cosmos.gov.v1.MsgDeposit", + value: MsgDeposit.fromPartial(value) + }; + } + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/gov/v1/tx.rpc.func.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/gov/v1/tx.rpc.func.ts new file mode 100644 index 0000000000..2f5b5a68c8 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/gov/v1/tx.rpc.func.ts @@ -0,0 +1,49 @@ +import { buildTx, SigningClientResolver } from "../../../helper-func-types"; +import { buildUseMutation } from "../../../react-query"; +import { toEncoders, toConverters } from "@interchainjs/cosmos/utils"; +import { MsgSubmitProposal, MsgExecLegacyContent, MsgVote, MsgVoteWeighted, MsgDeposit } from "./tx"; +export const createSubmitProposal = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgSubmitProposal.typeUrl, + encoders: toEncoders(MsgSubmitProposal), + converters: toConverters(MsgSubmitProposal) +}); +export const useSubmitProposal = buildUseMutation({ + builderMutationFn: createSubmitProposal +}); +export const createExecLegacyContent = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgExecLegacyContent.typeUrl, + encoders: toEncoders(MsgExecLegacyContent), + converters: toConverters(MsgExecLegacyContent) +}); +export const useExecLegacyContent = buildUseMutation({ + builderMutationFn: createExecLegacyContent +}); +export const createVote = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgVote.typeUrl, + encoders: toEncoders(MsgVote), + converters: toConverters(MsgVote) +}); +export const useVote = buildUseMutation({ + builderMutationFn: createVote +}); +export const createVoteWeighted = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgVoteWeighted.typeUrl, + encoders: toEncoders(MsgVoteWeighted), + converters: toConverters(MsgVoteWeighted) +}); +export const useVoteWeighted = buildUseMutation({ + builderMutationFn: createVoteWeighted +}); +export const createDeposit = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgDeposit.typeUrl, + encoders: toEncoders(MsgDeposit), + converters: toConverters(MsgDeposit) +}); +export const useDeposit = buildUseMutation({ + builderMutationFn: createDeposit +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/gov/v1/tx.rpc.msg.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/gov/v1/tx.rpc.msg.ts new file mode 100644 index 0000000000..e12346b1ea --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/gov/v1/tx.rpc.msg.ts @@ -0,0 +1,61 @@ +import { Any, AnySDKType } from "../../../google/protobuf/any.js"; +import { Coin, CoinSDKType } from "../../base/v1beta1/coin.js"; +import { VoteOption, VoteOptionSDKType, WeightedVoteOption, WeightedVoteOptionSDKType } from "./gov.js"; +import { Rpc } from "../../../helpers.js"; +import { BinaryReader } from "../../../binary.js"; +import { MsgSubmitProposal, MsgSubmitProposalSDKType, MsgSubmitProposalResponse, MsgSubmitProposalResponseSDKType, MsgExecLegacyContent, MsgExecLegacyContentSDKType, MsgExecLegacyContentResponse, MsgExecLegacyContentResponseSDKType, MsgVote, MsgVoteSDKType, MsgVoteResponse, MsgVoteResponseSDKType, MsgVoteWeighted, MsgVoteWeightedSDKType, MsgVoteWeightedResponse, MsgVoteWeightedResponseSDKType, MsgDeposit, MsgDepositSDKType, MsgDepositResponse, MsgDepositResponseSDKType } from "./tx.js"; +/** Msg defines the gov Msg service. */ +export interface Msg { + /** SubmitProposal defines a method to create new proposal given a content. */ + submitProposal(request: MsgSubmitProposal): Promise; + /** + * ExecLegacyContent defines a Msg to be in included in a MsgSubmitProposal + * to execute a legacy content-based proposal. + */ + execLegacyContent(request: MsgExecLegacyContent): Promise; + /** Vote defines a method to add a vote on a specific proposal. */ + vote(request: MsgVote): Promise; + /** VoteWeighted defines a method to add a weighted vote on a specific proposal. */ + voteWeighted(request: MsgVoteWeighted): Promise; + /** Deposit defines a method to add deposit on a specific proposal. */ + deposit(request: MsgDeposit): Promise; +} +export class MsgClientImpl implements Msg { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + this.submitProposal = this.submitProposal.bind(this); + this.execLegacyContent = this.execLegacyContent.bind(this); + this.vote = this.vote.bind(this); + this.voteWeighted = this.voteWeighted.bind(this); + this.deposit = this.deposit.bind(this); + } + submitProposal(request: MsgSubmitProposal): Promise { + const data = MsgSubmitProposal.encode(request).finish(); + const promise = this.rpc.request("cosmos.gov.v1.Msg", "SubmitProposal", data); + return promise.then(data => MsgSubmitProposalResponse.decode(new BinaryReader(data))); + } + execLegacyContent(request: MsgExecLegacyContent): Promise { + const data = MsgExecLegacyContent.encode(request).finish(); + const promise = this.rpc.request("cosmos.gov.v1.Msg", "ExecLegacyContent", data); + return promise.then(data => MsgExecLegacyContentResponse.decode(new BinaryReader(data))); + } + vote(request: MsgVote): Promise { + const data = MsgVote.encode(request).finish(); + const promise = this.rpc.request("cosmos.gov.v1.Msg", "Vote", data); + return promise.then(data => MsgVoteResponse.decode(new BinaryReader(data))); + } + voteWeighted(request: MsgVoteWeighted): Promise { + const data = MsgVoteWeighted.encode(request).finish(); + const promise = this.rpc.request("cosmos.gov.v1.Msg", "VoteWeighted", data); + return promise.then(data => MsgVoteWeightedResponse.decode(new BinaryReader(data))); + } + deposit(request: MsgDeposit): Promise { + const data = MsgDeposit.encode(request).finish(); + const promise = this.rpc.request("cosmos.gov.v1.Msg", "Deposit", data); + return promise.then(data => MsgDepositResponse.decode(new BinaryReader(data))); + } +} +export const createClientImpl = (rpc: Rpc) => { + return new MsgClientImpl(rpc); +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/gov/v1/tx.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/gov/v1/tx.ts new file mode 100644 index 0000000000..2c23564371 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/gov/v1/tx.ts @@ -0,0 +1,1264 @@ +import { Any, AnySDKType } from "../../../google/protobuf/any.js"; +import { Coin, CoinSDKType } from "../../base/v1beta1/coin.js"; +import { VoteOption, VoteOptionSDKType, WeightedVoteOption, WeightedVoteOptionSDKType, voteOptionFromJSON, voteOptionToJSON } from "./gov.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "cosmos.gov.v1"; +/** + * MsgSubmitProposal defines an sdk.Msg type that supports submitting arbitrary + * proposal Content. + */ +export interface MsgSubmitProposal { + messages: Any[]; + initialDeposit: Coin[]; + proposer: string; + /** metadata is any arbitrary metadata attached to the proposal. */ + metadata: string; +} +export interface MsgSubmitProposalProtoMsg { + typeUrl: "/cosmos.gov.v1.MsgSubmitProposal"; + value: Uint8Array; +} +/** + * MsgSubmitProposal defines an sdk.Msg type that supports submitting arbitrary + * proposal Content. + */ +export interface MsgSubmitProposalSDKType { + messages: AnySDKType[]; + initial_deposit: CoinSDKType[]; + proposer: string; + metadata: string; +} +/** MsgSubmitProposalResponse defines the Msg/SubmitProposal response type. */ +export interface MsgSubmitProposalResponse { + proposalId: bigint; +} +export interface MsgSubmitProposalResponseProtoMsg { + typeUrl: "/cosmos.gov.v1.MsgSubmitProposalResponse"; + value: Uint8Array; +} +/** MsgSubmitProposalResponse defines the Msg/SubmitProposal response type. */ +export interface MsgSubmitProposalResponseSDKType { + proposal_id: bigint; +} +/** + * MsgExecLegacyContent is used to wrap the legacy content field into a message. + * This ensures backwards compatibility with v1beta1.MsgSubmitProposal. + */ +export interface MsgExecLegacyContent { + /** content is the proposal's content. */ + content?: Any; + /** authority must be the gov module address. */ + authority: string; +} +export interface MsgExecLegacyContentProtoMsg { + typeUrl: "/cosmos.gov.v1.MsgExecLegacyContent"; + value: Uint8Array; +} +/** + * MsgExecLegacyContent is used to wrap the legacy content field into a message. + * This ensures backwards compatibility with v1beta1.MsgSubmitProposal. + */ +export interface MsgExecLegacyContentSDKType { + content?: AnySDKType; + authority: string; +} +/** MsgExecLegacyContentResponse defines the Msg/ExecLegacyContent response type. */ +export interface MsgExecLegacyContentResponse {} +export interface MsgExecLegacyContentResponseProtoMsg { + typeUrl: "/cosmos.gov.v1.MsgExecLegacyContentResponse"; + value: Uint8Array; +} +/** MsgExecLegacyContentResponse defines the Msg/ExecLegacyContent response type. */ +export interface MsgExecLegacyContentResponseSDKType {} +/** MsgVote defines a message to cast a vote. */ +export interface MsgVote { + proposalId: bigint; + voter: string; + option: VoteOption; + metadata: string; +} +export interface MsgVoteProtoMsg { + typeUrl: "/cosmos.gov.v1.MsgVote"; + value: Uint8Array; +} +/** MsgVote defines a message to cast a vote. */ +export interface MsgVoteSDKType { + proposal_id: bigint; + voter: string; + option: VoteOption; + metadata: string; +} +/** MsgVoteResponse defines the Msg/Vote response type. */ +export interface MsgVoteResponse {} +export interface MsgVoteResponseProtoMsg { + typeUrl: "/cosmos.gov.v1.MsgVoteResponse"; + value: Uint8Array; +} +/** MsgVoteResponse defines the Msg/Vote response type. */ +export interface MsgVoteResponseSDKType {} +/** MsgVoteWeighted defines a message to cast a vote. */ +export interface MsgVoteWeighted { + proposalId: bigint; + voter: string; + options: WeightedVoteOption[]; + metadata: string; +} +export interface MsgVoteWeightedProtoMsg { + typeUrl: "/cosmos.gov.v1.MsgVoteWeighted"; + value: Uint8Array; +} +/** MsgVoteWeighted defines a message to cast a vote. */ +export interface MsgVoteWeightedSDKType { + proposal_id: bigint; + voter: string; + options: WeightedVoteOptionSDKType[]; + metadata: string; +} +/** MsgVoteWeightedResponse defines the Msg/VoteWeighted response type. */ +export interface MsgVoteWeightedResponse {} +export interface MsgVoteWeightedResponseProtoMsg { + typeUrl: "/cosmos.gov.v1.MsgVoteWeightedResponse"; + value: Uint8Array; +} +/** MsgVoteWeightedResponse defines the Msg/VoteWeighted response type. */ +export interface MsgVoteWeightedResponseSDKType {} +/** MsgDeposit defines a message to submit a deposit to an existing proposal. */ +export interface MsgDeposit { + proposalId: bigint; + depositor: string; + amount: Coin[]; +} +export interface MsgDepositProtoMsg { + typeUrl: "/cosmos.gov.v1.MsgDeposit"; + value: Uint8Array; +} +/** MsgDeposit defines a message to submit a deposit to an existing proposal. */ +export interface MsgDepositSDKType { + proposal_id: bigint; + depositor: string; + amount: CoinSDKType[]; +} +/** MsgDepositResponse defines the Msg/Deposit response type. */ +export interface MsgDepositResponse {} +export interface MsgDepositResponseProtoMsg { + typeUrl: "/cosmos.gov.v1.MsgDepositResponse"; + value: Uint8Array; +} +/** MsgDepositResponse defines the Msg/Deposit response type. */ +export interface MsgDepositResponseSDKType {} +function createBaseMsgSubmitProposal(): MsgSubmitProposal { + return { + messages: [], + initialDeposit: [], + proposer: "", + metadata: "" + }; +} +export const MsgSubmitProposal = { + typeUrl: "/cosmos.gov.v1.MsgSubmitProposal", + encode(message: MsgSubmitProposal, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.messages) { + Any.encode(v!, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.initialDeposit) { + Coin.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.proposer !== undefined) { + writer.uint32(26).string(message.proposer); + } + if (message.metadata !== undefined) { + writer.uint32(34).string(message.metadata); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgSubmitProposal { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgSubmitProposal(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.messages.push(Any.decode(reader, reader.uint32())); + break; + case 2: + message.initialDeposit.push(Coin.decode(reader, reader.uint32())); + break; + case 3: + message.proposer = reader.string(); + break; + case 4: + message.metadata = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgSubmitProposal { + const obj = createBaseMsgSubmitProposal(); + if (Array.isArray(object?.messages)) obj.messages = object.messages.map((e: any) => Any.fromJSON(e)); + if (Array.isArray(object?.initialDeposit)) obj.initialDeposit = object.initialDeposit.map((e: any) => Coin.fromJSON(e)); + if (isSet(object.proposer)) obj.proposer = String(object.proposer); + if (isSet(object.metadata)) obj.metadata = String(object.metadata); + return obj; + }, + toJSON(message: MsgSubmitProposal): JsonSafe { + const obj: any = {}; + if (message.messages) { + obj.messages = message.messages.map(e => e ? Any.toJSON(e) : undefined); + } else { + obj.messages = []; + } + if (message.initialDeposit) { + obj.initialDeposit = message.initialDeposit.map(e => e ? Coin.toJSON(e) : undefined); + } else { + obj.initialDeposit = []; + } + message.proposer !== undefined && (obj.proposer = message.proposer); + message.metadata !== undefined && (obj.metadata = message.metadata); + return obj; + }, + fromPartial(object: DeepPartial): MsgSubmitProposal { + const message = createBaseMsgSubmitProposal(); + message.messages = object.messages?.map(e => Any.fromPartial(e)) || []; + message.initialDeposit = object.initialDeposit?.map(e => Coin.fromPartial(e)) || []; + message.proposer = object.proposer ?? ""; + message.metadata = object.metadata ?? ""; + return message; + }, + fromSDK(object: MsgSubmitProposalSDKType): MsgSubmitProposal { + return { + messages: Array.isArray(object?.messages) ? object.messages.map((e: any) => Any.fromSDK(e)) : [], + initialDeposit: Array.isArray(object?.initial_deposit) ? object.initial_deposit.map((e: any) => Coin.fromSDK(e)) : [], + proposer: object?.proposer, + metadata: object?.metadata + }; + }, + fromSDKJSON(object: any): MsgSubmitProposalSDKType { + return { + messages: Array.isArray(object?.messages) ? object.messages.map((e: any) => Any.fromSDKJSON(e)) : [], + initial_deposit: Array.isArray(object?.initial_deposit) ? object.initial_deposit.map((e: any) => Coin.fromSDKJSON(e)) : [], + proposer: isSet(object.proposer) ? String(object.proposer) : "", + metadata: isSet(object.metadata) ? String(object.metadata) : "" + }; + }, + toSDK(message: MsgSubmitProposal): MsgSubmitProposalSDKType { + const obj: any = {}; + if (message.messages) { + obj.messages = message.messages.map(e => e ? Any.toSDK(e) : undefined); + } else { + obj.messages = []; + } + if (message.initialDeposit) { + obj.initial_deposit = message.initialDeposit.map(e => e ? Coin.toSDK(e) : undefined); + } else { + obj.initial_deposit = []; + } + obj.proposer = message.proposer; + obj.metadata = message.metadata; + return obj; + }, + fromAmino(object: MsgSubmitProposalAmino): MsgSubmitProposal { + const message = createBaseMsgSubmitProposal(); + message.messages = object.messages?.map(e => Any.fromAmino(e)) || []; + message.initialDeposit = object.initial_deposit?.map(e => Coin.fromAmino(e)) || []; + if (object.proposer !== undefined && object.proposer !== null) { + message.proposer = object.proposer; + } + if (object.metadata !== undefined && object.metadata !== null) { + message.metadata = object.metadata; + } + return message; + }, + toAmino(message: MsgSubmitProposal): MsgSubmitProposalAmino { + const obj: any = {}; + if (message.messages) { + obj.messages = message.messages.map(e => e ? Any.toAmino(e) : undefined); + } else { + obj.messages = message.messages; + } + if (message.initialDeposit) { + obj.initial_deposit = message.initialDeposit.map(e => e ? Coin.toAmino(e) : undefined); + } else { + obj.initial_deposit = message.initialDeposit; + } + obj.proposer = message.proposer === "" ? undefined : message.proposer; + obj.metadata = message.metadata === "" ? undefined : message.metadata; + return obj; + }, + fromAminoMsg(object: MsgSubmitProposalAminoMsg): MsgSubmitProposal { + return MsgSubmitProposal.fromAmino(object.value); + }, + toAminoMsg(message: MsgSubmitProposal): MsgSubmitProposalAminoMsg { + return { + type: "cosmos-sdk/v1/MsgSubmitProposal", + value: MsgSubmitProposal.toAmino(message) + }; + }, + fromProtoMsg(message: MsgSubmitProposalProtoMsg): MsgSubmitProposal { + return MsgSubmitProposal.decode(message.value); + }, + toProto(message: MsgSubmitProposal): Uint8Array { + return MsgSubmitProposal.encode(message).finish(); + }, + toProtoMsg(message: MsgSubmitProposal): MsgSubmitProposalProtoMsg { + return { + typeUrl: "/cosmos.gov.v1.MsgSubmitProposal", + value: MsgSubmitProposal.encode(message).finish() + }; + } +}; +function createBaseMsgSubmitProposalResponse(): MsgSubmitProposalResponse { + return { + proposalId: BigInt(0) + }; +} +export const MsgSubmitProposalResponse = { + typeUrl: "/cosmos.gov.v1.MsgSubmitProposalResponse", + encode(message: MsgSubmitProposalResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.proposalId !== undefined) { + writer.uint32(8).uint64(message.proposalId); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgSubmitProposalResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgSubmitProposalResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.proposalId = reader.uint64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgSubmitProposalResponse { + const obj = createBaseMsgSubmitProposalResponse(); + if (isSet(object.proposalId)) obj.proposalId = BigInt(object.proposalId.toString()); + return obj; + }, + toJSON(message: MsgSubmitProposalResponse): JsonSafe { + const obj: any = {}; + message.proposalId !== undefined && (obj.proposalId = (message.proposalId || BigInt(0)).toString()); + return obj; + }, + fromPartial(object: DeepPartial): MsgSubmitProposalResponse { + const message = createBaseMsgSubmitProposalResponse(); + if (object.proposalId !== undefined && object.proposalId !== null) { + message.proposalId = BigInt(object.proposalId.toString()); + } + return message; + }, + fromSDK(object: MsgSubmitProposalResponseSDKType): MsgSubmitProposalResponse { + return { + proposalId: object?.proposal_id + }; + }, + fromSDKJSON(object: any): MsgSubmitProposalResponseSDKType { + return { + proposal_id: isSet(object.proposal_id) ? BigInt(object.proposal_id.toString()) : BigInt(0) + }; + }, + toSDK(message: MsgSubmitProposalResponse): MsgSubmitProposalResponseSDKType { + const obj: any = {}; + obj.proposal_id = message.proposalId; + return obj; + }, + fromAmino(object: MsgSubmitProposalResponseAmino): MsgSubmitProposalResponse { + const message = createBaseMsgSubmitProposalResponse(); + if (object.proposal_id !== undefined && object.proposal_id !== null) { + message.proposalId = BigInt(object.proposal_id); + } + return message; + }, + toAmino(message: MsgSubmitProposalResponse): MsgSubmitProposalResponseAmino { + const obj: any = {}; + obj.proposal_id = message.proposalId !== BigInt(0) ? message.proposalId?.toString() : undefined; + return obj; + }, + fromAminoMsg(object: MsgSubmitProposalResponseAminoMsg): MsgSubmitProposalResponse { + return MsgSubmitProposalResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgSubmitProposalResponse): MsgSubmitProposalResponseAminoMsg { + return { + type: "cosmos-sdk/v1/MsgSubmitProposalResponse", + value: MsgSubmitProposalResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgSubmitProposalResponseProtoMsg): MsgSubmitProposalResponse { + return MsgSubmitProposalResponse.decode(message.value); + }, + toProto(message: MsgSubmitProposalResponse): Uint8Array { + return MsgSubmitProposalResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgSubmitProposalResponse): MsgSubmitProposalResponseProtoMsg { + return { + typeUrl: "/cosmos.gov.v1.MsgSubmitProposalResponse", + value: MsgSubmitProposalResponse.encode(message).finish() + }; + } +}; +function createBaseMsgExecLegacyContent(): MsgExecLegacyContent { + return { + content: undefined, + authority: "" + }; +} +export const MsgExecLegacyContent = { + typeUrl: "/cosmos.gov.v1.MsgExecLegacyContent", + encode(message: MsgExecLegacyContent, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.content !== undefined) { + Any.encode(message.content, writer.uint32(10).fork()).ldelim(); + } + if (message.authority !== undefined) { + writer.uint32(18).string(message.authority); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgExecLegacyContent { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgExecLegacyContent(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.content = Any.decode(reader, reader.uint32()); + break; + case 2: + message.authority = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgExecLegacyContent { + const obj = createBaseMsgExecLegacyContent(); + if (isSet(object.content)) obj.content = Any.fromJSON(object.content); + if (isSet(object.authority)) obj.authority = String(object.authority); + return obj; + }, + toJSON(message: MsgExecLegacyContent): JsonSafe { + const obj: any = {}; + message.content !== undefined && (obj.content = message.content ? Any.toJSON(message.content) : undefined); + message.authority !== undefined && (obj.authority = message.authority); + return obj; + }, + fromPartial(object: DeepPartial): MsgExecLegacyContent { + const message = createBaseMsgExecLegacyContent(); + if (object.content !== undefined && object.content !== null) { + message.content = Any.fromPartial(object.content); + } + message.authority = object.authority ?? ""; + return message; + }, + fromSDK(object: MsgExecLegacyContentSDKType): MsgExecLegacyContent { + return { + content: object.content ? Any.fromSDK(object.content) : undefined, + authority: object?.authority + }; + }, + fromSDKJSON(object: any): MsgExecLegacyContentSDKType { + return { + content: isSet(object.content) ? Any.fromSDKJSON(object.content) : undefined, + authority: isSet(object.authority) ? String(object.authority) : "" + }; + }, + toSDK(message: MsgExecLegacyContent): MsgExecLegacyContentSDKType { + const obj: any = {}; + message.content !== undefined && (obj.content = message.content ? Any.toSDK(message.content) : undefined); + obj.authority = message.authority; + return obj; + }, + fromAmino(object: MsgExecLegacyContentAmino): MsgExecLegacyContent { + const message = createBaseMsgExecLegacyContent(); + if (object.content !== undefined && object.content !== null) { + message.content = Any.fromAmino(object.content); + } + if (object.authority !== undefined && object.authority !== null) { + message.authority = object.authority; + } + return message; + }, + toAmino(message: MsgExecLegacyContent): MsgExecLegacyContentAmino { + const obj: any = {}; + obj.content = message.content ? Any.toAmino(message.content) : undefined; + obj.authority = message.authority === "" ? undefined : message.authority; + return obj; + }, + fromAminoMsg(object: MsgExecLegacyContentAminoMsg): MsgExecLegacyContent { + return MsgExecLegacyContent.fromAmino(object.value); + }, + toAminoMsg(message: MsgExecLegacyContent): MsgExecLegacyContentAminoMsg { + return { + type: "cosmos-sdk/v1/MsgExecLegacyContent", + value: MsgExecLegacyContent.toAmino(message) + }; + }, + fromProtoMsg(message: MsgExecLegacyContentProtoMsg): MsgExecLegacyContent { + return MsgExecLegacyContent.decode(message.value); + }, + toProto(message: MsgExecLegacyContent): Uint8Array { + return MsgExecLegacyContent.encode(message).finish(); + }, + toProtoMsg(message: MsgExecLegacyContent): MsgExecLegacyContentProtoMsg { + return { + typeUrl: "/cosmos.gov.v1.MsgExecLegacyContent", + value: MsgExecLegacyContent.encode(message).finish() + }; + } +}; +function createBaseMsgExecLegacyContentResponse(): MsgExecLegacyContentResponse { + return {}; +} +export const MsgExecLegacyContentResponse = { + typeUrl: "/cosmos.gov.v1.MsgExecLegacyContentResponse", + encode(_: MsgExecLegacyContentResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgExecLegacyContentResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgExecLegacyContentResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgExecLegacyContentResponse { + const obj = createBaseMsgExecLegacyContentResponse(); + return obj; + }, + toJSON(_: MsgExecLegacyContentResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): MsgExecLegacyContentResponse { + const message = createBaseMsgExecLegacyContentResponse(); + return message; + }, + fromSDK(_: MsgExecLegacyContentResponseSDKType): MsgExecLegacyContentResponse { + return {}; + }, + fromSDKJSON(_: any): MsgExecLegacyContentResponseSDKType { + return {}; + }, + toSDK(_: MsgExecLegacyContentResponse): MsgExecLegacyContentResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgExecLegacyContentResponseAmino): MsgExecLegacyContentResponse { + const message = createBaseMsgExecLegacyContentResponse(); + return message; + }, + toAmino(_: MsgExecLegacyContentResponse): MsgExecLegacyContentResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgExecLegacyContentResponseAminoMsg): MsgExecLegacyContentResponse { + return MsgExecLegacyContentResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgExecLegacyContentResponse): MsgExecLegacyContentResponseAminoMsg { + return { + type: "cosmos-sdk/v1/MsgExecLegacyContentResponse", + value: MsgExecLegacyContentResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgExecLegacyContentResponseProtoMsg): MsgExecLegacyContentResponse { + return MsgExecLegacyContentResponse.decode(message.value); + }, + toProto(message: MsgExecLegacyContentResponse): Uint8Array { + return MsgExecLegacyContentResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgExecLegacyContentResponse): MsgExecLegacyContentResponseProtoMsg { + return { + typeUrl: "/cosmos.gov.v1.MsgExecLegacyContentResponse", + value: MsgExecLegacyContentResponse.encode(message).finish() + }; + } +}; +function createBaseMsgVote(): MsgVote { + return { + proposalId: BigInt(0), + voter: "", + option: 0, + metadata: "" + }; +} +export const MsgVote = { + typeUrl: "/cosmos.gov.v1.MsgVote", + encode(message: MsgVote, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.proposalId !== undefined) { + writer.uint32(8).uint64(message.proposalId); + } + if (message.voter !== undefined) { + writer.uint32(18).string(message.voter); + } + if (message.option !== 0) { + writer.uint32(24).int32(message.option); + } + if (message.metadata !== undefined) { + writer.uint32(34).string(message.metadata); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgVote { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgVote(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.proposalId = reader.uint64(); + break; + case 2: + message.voter = reader.string(); + break; + case 3: + message.option = (reader.int32() as any); + break; + case 4: + message.metadata = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgVote { + const obj = createBaseMsgVote(); + if (isSet(object.proposalId)) obj.proposalId = BigInt(object.proposalId.toString()); + if (isSet(object.voter)) obj.voter = String(object.voter); + if (isSet(object.option)) obj.option = voteOptionFromJSON(object.option); + if (isSet(object.metadata)) obj.metadata = String(object.metadata); + return obj; + }, + toJSON(message: MsgVote): JsonSafe { + const obj: any = {}; + message.proposalId !== undefined && (obj.proposalId = (message.proposalId || BigInt(0)).toString()); + message.voter !== undefined && (obj.voter = message.voter); + message.option !== undefined && (obj.option = voteOptionToJSON(message.option)); + message.metadata !== undefined && (obj.metadata = message.metadata); + return obj; + }, + fromPartial(object: DeepPartial): MsgVote { + const message = createBaseMsgVote(); + if (object.proposalId !== undefined && object.proposalId !== null) { + message.proposalId = BigInt(object.proposalId.toString()); + } + message.voter = object.voter ?? ""; + message.option = object.option ?? 0; + message.metadata = object.metadata ?? ""; + return message; + }, + fromSDK(object: MsgVoteSDKType): MsgVote { + return { + proposalId: object?.proposal_id, + voter: object?.voter, + option: isSet(object.option) ? voteOptionFromJSON(object.option) : -1, + metadata: object?.metadata + }; + }, + fromSDKJSON(object: any): MsgVoteSDKType { + return { + proposal_id: isSet(object.proposal_id) ? BigInt(object.proposal_id.toString()) : BigInt(0), + voter: isSet(object.voter) ? String(object.voter) : "", + option: isSet(object.option) ? voteOptionFromJSON(object.option) : -1, + metadata: isSet(object.metadata) ? String(object.metadata) : "" + }; + }, + toSDK(message: MsgVote): MsgVoteSDKType { + const obj: any = {}; + obj.proposal_id = message.proposalId; + obj.voter = message.voter; + message.option !== undefined && (obj.option = voteOptionToJSON(message.option)); + obj.metadata = message.metadata; + return obj; + }, + fromAmino(object: MsgVoteAmino): MsgVote { + const message = createBaseMsgVote(); + if (object.proposal_id !== undefined && object.proposal_id !== null) { + message.proposalId = BigInt(object.proposal_id); + } + if (object.voter !== undefined && object.voter !== null) { + message.voter = object.voter; + } + if (object.option !== undefined && object.option !== null) { + message.option = object.option; + } + if (object.metadata !== undefined && object.metadata !== null) { + message.metadata = object.metadata; + } + return message; + }, + toAmino(message: MsgVote): MsgVoteAmino { + const obj: any = {}; + obj.proposal_id = message.proposalId ? message.proposalId?.toString() : "0"; + obj.voter = message.voter === "" ? undefined : message.voter; + obj.option = message.option === 0 ? undefined : message.option; + obj.metadata = message.metadata === "" ? undefined : message.metadata; + return obj; + }, + fromAminoMsg(object: MsgVoteAminoMsg): MsgVote { + return MsgVote.fromAmino(object.value); + }, + toAminoMsg(message: MsgVote): MsgVoteAminoMsg { + return { + type: "cosmos-sdk/v1/MsgVote", + value: MsgVote.toAmino(message) + }; + }, + fromProtoMsg(message: MsgVoteProtoMsg): MsgVote { + return MsgVote.decode(message.value); + }, + toProto(message: MsgVote): Uint8Array { + return MsgVote.encode(message).finish(); + }, + toProtoMsg(message: MsgVote): MsgVoteProtoMsg { + return { + typeUrl: "/cosmos.gov.v1.MsgVote", + value: MsgVote.encode(message).finish() + }; + } +}; +function createBaseMsgVoteResponse(): MsgVoteResponse { + return {}; +} +export const MsgVoteResponse = { + typeUrl: "/cosmos.gov.v1.MsgVoteResponse", + encode(_: MsgVoteResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgVoteResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgVoteResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgVoteResponse { + const obj = createBaseMsgVoteResponse(); + return obj; + }, + toJSON(_: MsgVoteResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): MsgVoteResponse { + const message = createBaseMsgVoteResponse(); + return message; + }, + fromSDK(_: MsgVoteResponseSDKType): MsgVoteResponse { + return {}; + }, + fromSDKJSON(_: any): MsgVoteResponseSDKType { + return {}; + }, + toSDK(_: MsgVoteResponse): MsgVoteResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgVoteResponseAmino): MsgVoteResponse { + const message = createBaseMsgVoteResponse(); + return message; + }, + toAmino(_: MsgVoteResponse): MsgVoteResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgVoteResponseAminoMsg): MsgVoteResponse { + return MsgVoteResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgVoteResponse): MsgVoteResponseAminoMsg { + return { + type: "cosmos-sdk/v1/MsgVoteResponse", + value: MsgVoteResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgVoteResponseProtoMsg): MsgVoteResponse { + return MsgVoteResponse.decode(message.value); + }, + toProto(message: MsgVoteResponse): Uint8Array { + return MsgVoteResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgVoteResponse): MsgVoteResponseProtoMsg { + return { + typeUrl: "/cosmos.gov.v1.MsgVoteResponse", + value: MsgVoteResponse.encode(message).finish() + }; + } +}; +function createBaseMsgVoteWeighted(): MsgVoteWeighted { + return { + proposalId: BigInt(0), + voter: "", + options: [], + metadata: "" + }; +} +export const MsgVoteWeighted = { + typeUrl: "/cosmos.gov.v1.MsgVoteWeighted", + encode(message: MsgVoteWeighted, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.proposalId !== undefined) { + writer.uint32(8).uint64(message.proposalId); + } + if (message.voter !== undefined) { + writer.uint32(18).string(message.voter); + } + for (const v of message.options) { + WeightedVoteOption.encode(v!, writer.uint32(26).fork()).ldelim(); + } + if (message.metadata !== undefined) { + writer.uint32(34).string(message.metadata); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgVoteWeighted { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgVoteWeighted(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.proposalId = reader.uint64(); + break; + case 2: + message.voter = reader.string(); + break; + case 3: + message.options.push(WeightedVoteOption.decode(reader, reader.uint32())); + break; + case 4: + message.metadata = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgVoteWeighted { + const obj = createBaseMsgVoteWeighted(); + if (isSet(object.proposalId)) obj.proposalId = BigInt(object.proposalId.toString()); + if (isSet(object.voter)) obj.voter = String(object.voter); + if (Array.isArray(object?.options)) obj.options = object.options.map((e: any) => WeightedVoteOption.fromJSON(e)); + if (isSet(object.metadata)) obj.metadata = String(object.metadata); + return obj; + }, + toJSON(message: MsgVoteWeighted): JsonSafe { + const obj: any = {}; + message.proposalId !== undefined && (obj.proposalId = (message.proposalId || BigInt(0)).toString()); + message.voter !== undefined && (obj.voter = message.voter); + if (message.options) { + obj.options = message.options.map(e => e ? WeightedVoteOption.toJSON(e) : undefined); + } else { + obj.options = []; + } + message.metadata !== undefined && (obj.metadata = message.metadata); + return obj; + }, + fromPartial(object: DeepPartial): MsgVoteWeighted { + const message = createBaseMsgVoteWeighted(); + if (object.proposalId !== undefined && object.proposalId !== null) { + message.proposalId = BigInt(object.proposalId.toString()); + } + message.voter = object.voter ?? ""; + message.options = object.options?.map(e => WeightedVoteOption.fromPartial(e)) || []; + message.metadata = object.metadata ?? ""; + return message; + }, + fromSDK(object: MsgVoteWeightedSDKType): MsgVoteWeighted { + return { + proposalId: object?.proposal_id, + voter: object?.voter, + options: Array.isArray(object?.options) ? object.options.map((e: any) => WeightedVoteOption.fromSDK(e)) : [], + metadata: object?.metadata + }; + }, + fromSDKJSON(object: any): MsgVoteWeightedSDKType { + return { + proposal_id: isSet(object.proposal_id) ? BigInt(object.proposal_id.toString()) : BigInt(0), + voter: isSet(object.voter) ? String(object.voter) : "", + options: Array.isArray(object?.options) ? object.options.map((e: any) => WeightedVoteOption.fromSDKJSON(e)) : [], + metadata: isSet(object.metadata) ? String(object.metadata) : "" + }; + }, + toSDK(message: MsgVoteWeighted): MsgVoteWeightedSDKType { + const obj: any = {}; + obj.proposal_id = message.proposalId; + obj.voter = message.voter; + if (message.options) { + obj.options = message.options.map(e => e ? WeightedVoteOption.toSDK(e) : undefined); + } else { + obj.options = []; + } + obj.metadata = message.metadata; + return obj; + }, + fromAmino(object: MsgVoteWeightedAmino): MsgVoteWeighted { + const message = createBaseMsgVoteWeighted(); + if (object.proposal_id !== undefined && object.proposal_id !== null) { + message.proposalId = BigInt(object.proposal_id); + } + if (object.voter !== undefined && object.voter !== null) { + message.voter = object.voter; + } + message.options = object.options?.map(e => WeightedVoteOption.fromAmino(e)) || []; + if (object.metadata !== undefined && object.metadata !== null) { + message.metadata = object.metadata; + } + return message; + }, + toAmino(message: MsgVoteWeighted): MsgVoteWeightedAmino { + const obj: any = {}; + obj.proposal_id = message.proposalId ? message.proposalId?.toString() : "0"; + obj.voter = message.voter === "" ? undefined : message.voter; + if (message.options) { + obj.options = message.options.map(e => e ? WeightedVoteOption.toAmino(e) : undefined); + } else { + obj.options = message.options; + } + obj.metadata = message.metadata === "" ? undefined : message.metadata; + return obj; + }, + fromAminoMsg(object: MsgVoteWeightedAminoMsg): MsgVoteWeighted { + return MsgVoteWeighted.fromAmino(object.value); + }, + toAminoMsg(message: MsgVoteWeighted): MsgVoteWeightedAminoMsg { + return { + type: "cosmos-sdk/v1/MsgVoteWeighted", + value: MsgVoteWeighted.toAmino(message) + }; + }, + fromProtoMsg(message: MsgVoteWeightedProtoMsg): MsgVoteWeighted { + return MsgVoteWeighted.decode(message.value); + }, + toProto(message: MsgVoteWeighted): Uint8Array { + return MsgVoteWeighted.encode(message).finish(); + }, + toProtoMsg(message: MsgVoteWeighted): MsgVoteWeightedProtoMsg { + return { + typeUrl: "/cosmos.gov.v1.MsgVoteWeighted", + value: MsgVoteWeighted.encode(message).finish() + }; + } +}; +function createBaseMsgVoteWeightedResponse(): MsgVoteWeightedResponse { + return {}; +} +export const MsgVoteWeightedResponse = { + typeUrl: "/cosmos.gov.v1.MsgVoteWeightedResponse", + encode(_: MsgVoteWeightedResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgVoteWeightedResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgVoteWeightedResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgVoteWeightedResponse { + const obj = createBaseMsgVoteWeightedResponse(); + return obj; + }, + toJSON(_: MsgVoteWeightedResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): MsgVoteWeightedResponse { + const message = createBaseMsgVoteWeightedResponse(); + return message; + }, + fromSDK(_: MsgVoteWeightedResponseSDKType): MsgVoteWeightedResponse { + return {}; + }, + fromSDKJSON(_: any): MsgVoteWeightedResponseSDKType { + return {}; + }, + toSDK(_: MsgVoteWeightedResponse): MsgVoteWeightedResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgVoteWeightedResponseAmino): MsgVoteWeightedResponse { + const message = createBaseMsgVoteWeightedResponse(); + return message; + }, + toAmino(_: MsgVoteWeightedResponse): MsgVoteWeightedResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgVoteWeightedResponseAminoMsg): MsgVoteWeightedResponse { + return MsgVoteWeightedResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgVoteWeightedResponse): MsgVoteWeightedResponseAminoMsg { + return { + type: "cosmos-sdk/v1/MsgVoteWeightedResponse", + value: MsgVoteWeightedResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgVoteWeightedResponseProtoMsg): MsgVoteWeightedResponse { + return MsgVoteWeightedResponse.decode(message.value); + }, + toProto(message: MsgVoteWeightedResponse): Uint8Array { + return MsgVoteWeightedResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgVoteWeightedResponse): MsgVoteWeightedResponseProtoMsg { + return { + typeUrl: "/cosmos.gov.v1.MsgVoteWeightedResponse", + value: MsgVoteWeightedResponse.encode(message).finish() + }; + } +}; +function createBaseMsgDeposit(): MsgDeposit { + return { + proposalId: BigInt(0), + depositor: "", + amount: [] + }; +} +export const MsgDeposit = { + typeUrl: "/cosmos.gov.v1.MsgDeposit", + encode(message: MsgDeposit, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.proposalId !== undefined) { + writer.uint32(8).uint64(message.proposalId); + } + if (message.depositor !== undefined) { + writer.uint32(18).string(message.depositor); + } + for (const v of message.amount) { + Coin.encode(v!, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgDeposit { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgDeposit(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.proposalId = reader.uint64(); + break; + case 2: + message.depositor = reader.string(); + break; + case 3: + message.amount.push(Coin.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgDeposit { + const obj = createBaseMsgDeposit(); + if (isSet(object.proposalId)) obj.proposalId = BigInt(object.proposalId.toString()); + if (isSet(object.depositor)) obj.depositor = String(object.depositor); + if (Array.isArray(object?.amount)) obj.amount = object.amount.map((e: any) => Coin.fromJSON(e)); + return obj; + }, + toJSON(message: MsgDeposit): JsonSafe { + const obj: any = {}; + message.proposalId !== undefined && (obj.proposalId = (message.proposalId || BigInt(0)).toString()); + message.depositor !== undefined && (obj.depositor = message.depositor); + if (message.amount) { + obj.amount = message.amount.map(e => e ? Coin.toJSON(e) : undefined); + } else { + obj.amount = []; + } + return obj; + }, + fromPartial(object: DeepPartial): MsgDeposit { + const message = createBaseMsgDeposit(); + if (object.proposalId !== undefined && object.proposalId !== null) { + message.proposalId = BigInt(object.proposalId.toString()); + } + message.depositor = object.depositor ?? ""; + message.amount = object.amount?.map(e => Coin.fromPartial(e)) || []; + return message; + }, + fromSDK(object: MsgDepositSDKType): MsgDeposit { + return { + proposalId: object?.proposal_id, + depositor: object?.depositor, + amount: Array.isArray(object?.amount) ? object.amount.map((e: any) => Coin.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): MsgDepositSDKType { + return { + proposal_id: isSet(object.proposal_id) ? BigInt(object.proposal_id.toString()) : BigInt(0), + depositor: isSet(object.depositor) ? String(object.depositor) : "", + amount: Array.isArray(object?.amount) ? object.amount.map((e: any) => Coin.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: MsgDeposit): MsgDepositSDKType { + const obj: any = {}; + obj.proposal_id = message.proposalId; + obj.depositor = message.depositor; + if (message.amount) { + obj.amount = message.amount.map(e => e ? Coin.toSDK(e) : undefined); + } else { + obj.amount = []; + } + return obj; + }, + fromAmino(object: MsgDepositAmino): MsgDeposit { + const message = createBaseMsgDeposit(); + if (object.proposal_id !== undefined && object.proposal_id !== null) { + message.proposalId = BigInt(object.proposal_id); + } + if (object.depositor !== undefined && object.depositor !== null) { + message.depositor = object.depositor; + } + message.amount = object.amount?.map(e => Coin.fromAmino(e)) || []; + return message; + }, + toAmino(message: MsgDeposit): MsgDepositAmino { + const obj: any = {}; + obj.proposal_id = message.proposalId ? message.proposalId?.toString() : "0"; + obj.depositor = message.depositor === "" ? undefined : message.depositor; + if (message.amount) { + obj.amount = message.amount.map(e => e ? Coin.toAmino(e) : undefined); + } else { + obj.amount = message.amount; + } + return obj; + }, + fromAminoMsg(object: MsgDepositAminoMsg): MsgDeposit { + return MsgDeposit.fromAmino(object.value); + }, + toAminoMsg(message: MsgDeposit): MsgDepositAminoMsg { + return { + type: "cosmos-sdk/v1/MsgDeposit", + value: MsgDeposit.toAmino(message) + }; + }, + fromProtoMsg(message: MsgDepositProtoMsg): MsgDeposit { + return MsgDeposit.decode(message.value); + }, + toProto(message: MsgDeposit): Uint8Array { + return MsgDeposit.encode(message).finish(); + }, + toProtoMsg(message: MsgDeposit): MsgDepositProtoMsg { + return { + typeUrl: "/cosmos.gov.v1.MsgDeposit", + value: MsgDeposit.encode(message).finish() + }; + } +}; +function createBaseMsgDepositResponse(): MsgDepositResponse { + return {}; +} +export const MsgDepositResponse = { + typeUrl: "/cosmos.gov.v1.MsgDepositResponse", + encode(_: MsgDepositResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgDepositResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgDepositResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgDepositResponse { + const obj = createBaseMsgDepositResponse(); + return obj; + }, + toJSON(_: MsgDepositResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): MsgDepositResponse { + const message = createBaseMsgDepositResponse(); + return message; + }, + fromSDK(_: MsgDepositResponseSDKType): MsgDepositResponse { + return {}; + }, + fromSDKJSON(_: any): MsgDepositResponseSDKType { + return {}; + }, + toSDK(_: MsgDepositResponse): MsgDepositResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgDepositResponseAmino): MsgDepositResponse { + const message = createBaseMsgDepositResponse(); + return message; + }, + toAmino(_: MsgDepositResponse): MsgDepositResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgDepositResponseAminoMsg): MsgDepositResponse { + return MsgDepositResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgDepositResponse): MsgDepositResponseAminoMsg { + return { + type: "cosmos-sdk/v1/MsgDepositResponse", + value: MsgDepositResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgDepositResponseProtoMsg): MsgDepositResponse { + return MsgDepositResponse.decode(message.value); + }, + toProto(message: MsgDepositResponse): Uint8Array { + return MsgDepositResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgDepositResponse): MsgDepositResponseProtoMsg { + return { + typeUrl: "/cosmos.gov.v1.MsgDepositResponse", + value: MsgDepositResponse.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/gov/v1beta1/genesis.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/gov/v1beta1/genesis.ts new file mode 100644 index 0000000000..75087fe5df --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/gov/v1beta1/genesis.ts @@ -0,0 +1,270 @@ +import { Deposit, DepositSDKType, Vote, VoteSDKType, Proposal, ProposalSDKType, DepositParams, DepositParamsSDKType, VotingParams, VotingParamsSDKType, TallyParams, TallyParamsSDKType } from "./gov.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "cosmos.gov.v1beta1"; +/** GenesisState defines the gov module's genesis state. */ +export interface GenesisState { + /** starting_proposal_id is the ID of the starting proposal. */ + startingProposalId: bigint; + /** deposits defines all the deposits present at genesis. */ + deposits: Deposit[]; + /** votes defines all the votes present at genesis. */ + votes: Vote[]; + /** proposals defines all the proposals present at genesis. */ + proposals: Proposal[]; + /** params defines all the paramaters of related to deposit. */ + depositParams: DepositParams; + /** params defines all the paramaters of related to voting. */ + votingParams: VotingParams; + /** params defines all the paramaters of related to tally. */ + tallyParams: TallyParams; +} +export interface GenesisStateProtoMsg { + typeUrl: "/cosmos.gov.v1beta1.GenesisState"; + value: Uint8Array; +} +/** GenesisState defines the gov module's genesis state. */ +export interface GenesisStateSDKType { + starting_proposal_id: bigint; + deposits: DepositSDKType[]; + votes: VoteSDKType[]; + proposals: ProposalSDKType[]; + deposit_params: DepositParamsSDKType; + voting_params: VotingParamsSDKType; + tally_params: TallyParamsSDKType; +} +function createBaseGenesisState(): GenesisState { + return { + startingProposalId: BigInt(0), + deposits: [], + votes: [], + proposals: [], + depositParams: DepositParams.fromPartial({}), + votingParams: VotingParams.fromPartial({}), + tallyParams: TallyParams.fromPartial({}) + }; +} +export const GenesisState = { + typeUrl: "/cosmos.gov.v1beta1.GenesisState", + encode(message: GenesisState, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.startingProposalId !== undefined) { + writer.uint32(8).uint64(message.startingProposalId); + } + for (const v of message.deposits) { + Deposit.encode(v!, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.votes) { + Vote.encode(v!, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.proposals) { + Proposal.encode(v!, writer.uint32(34).fork()).ldelim(); + } + if (message.depositParams !== undefined) { + DepositParams.encode(message.depositParams, writer.uint32(42).fork()).ldelim(); + } + if (message.votingParams !== undefined) { + VotingParams.encode(message.votingParams, writer.uint32(50).fork()).ldelim(); + } + if (message.tallyParams !== undefined) { + TallyParams.encode(message.tallyParams, writer.uint32(58).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GenesisState { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGenesisState(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.startingProposalId = reader.uint64(); + break; + case 2: + message.deposits.push(Deposit.decode(reader, reader.uint32())); + break; + case 3: + message.votes.push(Vote.decode(reader, reader.uint32())); + break; + case 4: + message.proposals.push(Proposal.decode(reader, reader.uint32())); + break; + case 5: + message.depositParams = DepositParams.decode(reader, reader.uint32()); + break; + case 6: + message.votingParams = VotingParams.decode(reader, reader.uint32()); + break; + case 7: + message.tallyParams = TallyParams.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GenesisState { + const obj = createBaseGenesisState(); + if (isSet(object.startingProposalId)) obj.startingProposalId = BigInt(object.startingProposalId.toString()); + if (Array.isArray(object?.deposits)) obj.deposits = object.deposits.map((e: any) => Deposit.fromJSON(e)); + if (Array.isArray(object?.votes)) obj.votes = object.votes.map((e: any) => Vote.fromJSON(e)); + if (Array.isArray(object?.proposals)) obj.proposals = object.proposals.map((e: any) => Proposal.fromJSON(e)); + if (isSet(object.depositParams)) obj.depositParams = DepositParams.fromJSON(object.depositParams); + if (isSet(object.votingParams)) obj.votingParams = VotingParams.fromJSON(object.votingParams); + if (isSet(object.tallyParams)) obj.tallyParams = TallyParams.fromJSON(object.tallyParams); + return obj; + }, + toJSON(message: GenesisState): JsonSafe { + const obj: any = {}; + message.startingProposalId !== undefined && (obj.startingProposalId = (message.startingProposalId || BigInt(0)).toString()); + if (message.deposits) { + obj.deposits = message.deposits.map(e => e ? Deposit.toJSON(e) : undefined); + } else { + obj.deposits = []; + } + if (message.votes) { + obj.votes = message.votes.map(e => e ? Vote.toJSON(e) : undefined); + } else { + obj.votes = []; + } + if (message.proposals) { + obj.proposals = message.proposals.map(e => e ? Proposal.toJSON(e) : undefined); + } else { + obj.proposals = []; + } + message.depositParams !== undefined && (obj.depositParams = message.depositParams ? DepositParams.toJSON(message.depositParams) : undefined); + message.votingParams !== undefined && (obj.votingParams = message.votingParams ? VotingParams.toJSON(message.votingParams) : undefined); + message.tallyParams !== undefined && (obj.tallyParams = message.tallyParams ? TallyParams.toJSON(message.tallyParams) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): GenesisState { + const message = createBaseGenesisState(); + if (object.startingProposalId !== undefined && object.startingProposalId !== null) { + message.startingProposalId = BigInt(object.startingProposalId.toString()); + } + message.deposits = object.deposits?.map(e => Deposit.fromPartial(e)) || []; + message.votes = object.votes?.map(e => Vote.fromPartial(e)) || []; + message.proposals = object.proposals?.map(e => Proposal.fromPartial(e)) || []; + if (object.depositParams !== undefined && object.depositParams !== null) { + message.depositParams = DepositParams.fromPartial(object.depositParams); + } + if (object.votingParams !== undefined && object.votingParams !== null) { + message.votingParams = VotingParams.fromPartial(object.votingParams); + } + if (object.tallyParams !== undefined && object.tallyParams !== null) { + message.tallyParams = TallyParams.fromPartial(object.tallyParams); + } + return message; + }, + fromSDK(object: GenesisStateSDKType): GenesisState { + return { + startingProposalId: object?.starting_proposal_id, + deposits: Array.isArray(object?.deposits) ? object.deposits.map((e: any) => Deposit.fromSDK(e)) : [], + votes: Array.isArray(object?.votes) ? object.votes.map((e: any) => Vote.fromSDK(e)) : [], + proposals: Array.isArray(object?.proposals) ? object.proposals.map((e: any) => Proposal.fromSDK(e)) : [], + depositParams: object.deposit_params ? DepositParams.fromSDK(object.deposit_params) : undefined, + votingParams: object.voting_params ? VotingParams.fromSDK(object.voting_params) : undefined, + tallyParams: object.tally_params ? TallyParams.fromSDK(object.tally_params) : undefined + }; + }, + fromSDKJSON(object: any): GenesisStateSDKType { + return { + starting_proposal_id: isSet(object.starting_proposal_id) ? BigInt(object.starting_proposal_id.toString()) : BigInt(0), + deposits: Array.isArray(object?.deposits) ? object.deposits.map((e: any) => Deposit.fromSDKJSON(e)) : [], + votes: Array.isArray(object?.votes) ? object.votes.map((e: any) => Vote.fromSDKJSON(e)) : [], + proposals: Array.isArray(object?.proposals) ? object.proposals.map((e: any) => Proposal.fromSDKJSON(e)) : [], + deposit_params: isSet(object.deposit_params) ? DepositParams.fromSDKJSON(object.deposit_params) : undefined, + voting_params: isSet(object.voting_params) ? VotingParams.fromSDKJSON(object.voting_params) : undefined, + tally_params: isSet(object.tally_params) ? TallyParams.fromSDKJSON(object.tally_params) : undefined + }; + }, + toSDK(message: GenesisState): GenesisStateSDKType { + const obj: any = {}; + obj.starting_proposal_id = message.startingProposalId; + if (message.deposits) { + obj.deposits = message.deposits.map(e => e ? Deposit.toSDK(e) : undefined); + } else { + obj.deposits = []; + } + if (message.votes) { + obj.votes = message.votes.map(e => e ? Vote.toSDK(e) : undefined); + } else { + obj.votes = []; + } + if (message.proposals) { + obj.proposals = message.proposals.map(e => e ? Proposal.toSDK(e) : undefined); + } else { + obj.proposals = []; + } + message.depositParams !== undefined && (obj.deposit_params = message.depositParams ? DepositParams.toSDK(message.depositParams) : undefined); + message.votingParams !== undefined && (obj.voting_params = message.votingParams ? VotingParams.toSDK(message.votingParams) : undefined); + message.tallyParams !== undefined && (obj.tally_params = message.tallyParams ? TallyParams.toSDK(message.tallyParams) : undefined); + return obj; + }, + fromAmino(object: GenesisStateAmino): GenesisState { + const message = createBaseGenesisState(); + if (object.starting_proposal_id !== undefined && object.starting_proposal_id !== null) { + message.startingProposalId = BigInt(object.starting_proposal_id); + } + message.deposits = object.deposits?.map(e => Deposit.fromAmino(e)) || []; + message.votes = object.votes?.map(e => Vote.fromAmino(e)) || []; + message.proposals = object.proposals?.map(e => Proposal.fromAmino(e)) || []; + if (object.deposit_params !== undefined && object.deposit_params !== null) { + message.depositParams = DepositParams.fromAmino(object.deposit_params); + } + if (object.voting_params !== undefined && object.voting_params !== null) { + message.votingParams = VotingParams.fromAmino(object.voting_params); + } + if (object.tally_params !== undefined && object.tally_params !== null) { + message.tallyParams = TallyParams.fromAmino(object.tally_params); + } + return message; + }, + toAmino(message: GenesisState): GenesisStateAmino { + const obj: any = {}; + obj.starting_proposal_id = message.startingProposalId !== BigInt(0) ? message.startingProposalId?.toString() : undefined; + if (message.deposits) { + obj.deposits = message.deposits.map(e => e ? Deposit.toAmino(e) : undefined); + } else { + obj.deposits = message.deposits; + } + if (message.votes) { + obj.votes = message.votes.map(e => e ? Vote.toAmino(e) : undefined); + } else { + obj.votes = message.votes; + } + if (message.proposals) { + obj.proposals = message.proposals.map(e => e ? Proposal.toAmino(e) : undefined); + } else { + obj.proposals = message.proposals; + } + obj.deposit_params = message.depositParams ? DepositParams.toAmino(message.depositParams) : undefined; + obj.voting_params = message.votingParams ? VotingParams.toAmino(message.votingParams) : undefined; + obj.tally_params = message.tallyParams ? TallyParams.toAmino(message.tallyParams) : undefined; + return obj; + }, + fromAminoMsg(object: GenesisStateAminoMsg): GenesisState { + return GenesisState.fromAmino(object.value); + }, + toAminoMsg(message: GenesisState): GenesisStateAminoMsg { + return { + type: "cosmos-sdk/GenesisState", + value: GenesisState.toAmino(message) + }; + }, + fromProtoMsg(message: GenesisStateProtoMsg): GenesisState { + return GenesisState.decode(message.value); + }, + toProto(message: GenesisState): Uint8Array { + return GenesisState.encode(message).finish(); + }, + toProtoMsg(message: GenesisState): GenesisStateProtoMsg { + return { + typeUrl: "/cosmos.gov.v1beta1.GenesisState", + value: GenesisState.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/gov/v1beta1/gov.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/gov/v1beta1/gov.ts new file mode 100644 index 0000000000..b1a3feeae6 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/gov/v1beta1/gov.ts @@ -0,0 +1,1602 @@ +import { Coin, CoinSDKType } from "../../base/v1beta1/coin.js"; +import { Any, AnySDKType } from "../../../google/protobuf/any.js"; +import { Timestamp, TimestampSDKType } from "../../../google/protobuf/timestamp.js"; +import { Duration, DurationSDKType } from "../../../google/protobuf/duration.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { Decimal } from "@cosmjs/math"; +import { isSet, DeepPartial, toTimestamp, fromTimestamp, bytesFromBase64, base64FromBytes } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "cosmos.gov.v1beta1"; +/** VoteOption enumerates the valid vote options for a given governance proposal. */ +export enum VoteOption { + /** VOTE_OPTION_UNSPECIFIED - VOTE_OPTION_UNSPECIFIED defines a no-op vote option. */ + VOTE_OPTION_UNSPECIFIED = 0, + /** VOTE_OPTION_YES - VOTE_OPTION_YES defines a yes vote option. */ + VOTE_OPTION_YES = 1, + /** VOTE_OPTION_ABSTAIN - VOTE_OPTION_ABSTAIN defines an abstain vote option. */ + VOTE_OPTION_ABSTAIN = 2, + /** VOTE_OPTION_NO - VOTE_OPTION_NO defines a no vote option. */ + VOTE_OPTION_NO = 3, + /** VOTE_OPTION_NO_WITH_VETO - VOTE_OPTION_NO_WITH_VETO defines a no with veto vote option. */ + VOTE_OPTION_NO_WITH_VETO = 4, + UNRECOGNIZED = -1, +} +export const VoteOptionSDKType = VoteOption; +export function voteOptionFromJSON(object: any): VoteOption { + switch (object) { + case 0: + case "VOTE_OPTION_UNSPECIFIED": + return VoteOption.VOTE_OPTION_UNSPECIFIED; + case 1: + case "VOTE_OPTION_YES": + return VoteOption.VOTE_OPTION_YES; + case 2: + case "VOTE_OPTION_ABSTAIN": + return VoteOption.VOTE_OPTION_ABSTAIN; + case 3: + case "VOTE_OPTION_NO": + return VoteOption.VOTE_OPTION_NO; + case 4: + case "VOTE_OPTION_NO_WITH_VETO": + return VoteOption.VOTE_OPTION_NO_WITH_VETO; + case -1: + case "UNRECOGNIZED": + default: + return VoteOption.UNRECOGNIZED; + } +} +export function voteOptionToJSON(object: VoteOption): string { + switch (object) { + case VoteOption.VOTE_OPTION_UNSPECIFIED: + return "VOTE_OPTION_UNSPECIFIED"; + case VoteOption.VOTE_OPTION_YES: + return "VOTE_OPTION_YES"; + case VoteOption.VOTE_OPTION_ABSTAIN: + return "VOTE_OPTION_ABSTAIN"; + case VoteOption.VOTE_OPTION_NO: + return "VOTE_OPTION_NO"; + case VoteOption.VOTE_OPTION_NO_WITH_VETO: + return "VOTE_OPTION_NO_WITH_VETO"; + case VoteOption.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** ProposalStatus enumerates the valid statuses of a proposal. */ +export enum ProposalStatus { + /** PROPOSAL_STATUS_UNSPECIFIED - PROPOSAL_STATUS_UNSPECIFIED defines the default propopsal status. */ + PROPOSAL_STATUS_UNSPECIFIED = 0, + /** + * PROPOSAL_STATUS_DEPOSIT_PERIOD - PROPOSAL_STATUS_DEPOSIT_PERIOD defines a proposal status during the deposit + * period. + */ + PROPOSAL_STATUS_DEPOSIT_PERIOD = 1, + /** + * PROPOSAL_STATUS_VOTING_PERIOD - PROPOSAL_STATUS_VOTING_PERIOD defines a proposal status during the voting + * period. + */ + PROPOSAL_STATUS_VOTING_PERIOD = 2, + /** + * PROPOSAL_STATUS_PASSED - PROPOSAL_STATUS_PASSED defines a proposal status of a proposal that has + * passed. + */ + PROPOSAL_STATUS_PASSED = 3, + /** + * PROPOSAL_STATUS_REJECTED - PROPOSAL_STATUS_REJECTED defines a proposal status of a proposal that has + * been rejected. + */ + PROPOSAL_STATUS_REJECTED = 4, + /** + * PROPOSAL_STATUS_FAILED - PROPOSAL_STATUS_FAILED defines a proposal status of a proposal that has + * failed. + */ + PROPOSAL_STATUS_FAILED = 5, + UNRECOGNIZED = -1, +} +export const ProposalStatusSDKType = ProposalStatus; +export function proposalStatusFromJSON(object: any): ProposalStatus { + switch (object) { + case 0: + case "PROPOSAL_STATUS_UNSPECIFIED": + return ProposalStatus.PROPOSAL_STATUS_UNSPECIFIED; + case 1: + case "PROPOSAL_STATUS_DEPOSIT_PERIOD": + return ProposalStatus.PROPOSAL_STATUS_DEPOSIT_PERIOD; + case 2: + case "PROPOSAL_STATUS_VOTING_PERIOD": + return ProposalStatus.PROPOSAL_STATUS_VOTING_PERIOD; + case 3: + case "PROPOSAL_STATUS_PASSED": + return ProposalStatus.PROPOSAL_STATUS_PASSED; + case 4: + case "PROPOSAL_STATUS_REJECTED": + return ProposalStatus.PROPOSAL_STATUS_REJECTED; + case 5: + case "PROPOSAL_STATUS_FAILED": + return ProposalStatus.PROPOSAL_STATUS_FAILED; + case -1: + case "UNRECOGNIZED": + default: + return ProposalStatus.UNRECOGNIZED; + } +} +export function proposalStatusToJSON(object: ProposalStatus): string { + switch (object) { + case ProposalStatus.PROPOSAL_STATUS_UNSPECIFIED: + return "PROPOSAL_STATUS_UNSPECIFIED"; + case ProposalStatus.PROPOSAL_STATUS_DEPOSIT_PERIOD: + return "PROPOSAL_STATUS_DEPOSIT_PERIOD"; + case ProposalStatus.PROPOSAL_STATUS_VOTING_PERIOD: + return "PROPOSAL_STATUS_VOTING_PERIOD"; + case ProposalStatus.PROPOSAL_STATUS_PASSED: + return "PROPOSAL_STATUS_PASSED"; + case ProposalStatus.PROPOSAL_STATUS_REJECTED: + return "PROPOSAL_STATUS_REJECTED"; + case ProposalStatus.PROPOSAL_STATUS_FAILED: + return "PROPOSAL_STATUS_FAILED"; + case ProposalStatus.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** + * WeightedVoteOption defines a unit of vote for vote split. + * + * Since: cosmos-sdk 0.43 + */ +export interface WeightedVoteOption { + option: VoteOption; + weight: string; +} +export interface WeightedVoteOptionProtoMsg { + typeUrl: "/cosmos.gov.v1beta1.WeightedVoteOption"; + value: Uint8Array; +} +/** + * WeightedVoteOption defines a unit of vote for vote split. + * + * Since: cosmos-sdk 0.43 + */ +export interface WeightedVoteOptionSDKType { + option: VoteOption; + weight: string; +} +/** + * TextProposal defines a standard text proposal whose changes need to be + * manually updated in case of approval. + */ +export interface TextProposal { + title: string; + description: string; +} +export interface TextProposalProtoMsg { + typeUrl: "/cosmos.gov.v1beta1.TextProposal"; + value: Uint8Array; +} +/** + * TextProposal defines a standard text proposal whose changes need to be + * manually updated in case of approval. + */ +export interface TextProposalSDKType { + title: string; + description: string; +} +/** + * Deposit defines an amount deposited by an account address to an active + * proposal. + */ +export interface Deposit { + proposalId: bigint; + depositor: string; + amount: Coin[]; +} +export interface DepositProtoMsg { + typeUrl: "/cosmos.gov.v1beta1.Deposit"; + value: Uint8Array; +} +/** + * Deposit defines an amount deposited by an account address to an active + * proposal. + */ +export interface DepositSDKType { + proposal_id: bigint; + depositor: string; + amount: CoinSDKType[]; +} +/** Proposal defines the core field members of a governance proposal. */ +export interface Proposal { + proposalId: bigint; + content?: Any; + status: ProposalStatus; + /** + * final_tally_result is the final tally result of the proposal. When + * querying a proposal via gRPC, this field is not populated until the + * proposal's voting period has ended. + */ + finalTallyResult: TallyResult; + submitTime: Date; + depositEndTime: Date; + totalDeposit: Coin[]; + votingStartTime: Date; + votingEndTime: Date; +} +export interface ProposalProtoMsg { + typeUrl: "/cosmos.gov.v1beta1.Proposal"; + value: Uint8Array; +} +/** Proposal defines the core field members of a governance proposal. */ +export interface ProposalSDKType { + proposal_id: bigint; + content?: AnySDKType; + status: ProposalStatus; + final_tally_result: TallyResultSDKType; + submit_time: Date; + deposit_end_time: Date; + total_deposit: CoinSDKType[]; + voting_start_time: Date; + voting_end_time: Date; +} +/** TallyResult defines a standard tally for a governance proposal. */ +export interface TallyResult { + yes: string; + abstain: string; + no: string; + noWithVeto: string; +} +export interface TallyResultProtoMsg { + typeUrl: "/cosmos.gov.v1beta1.TallyResult"; + value: Uint8Array; +} +/** TallyResult defines a standard tally for a governance proposal. */ +export interface TallyResultSDKType { + yes: string; + abstain: string; + no: string; + no_with_veto: string; +} +/** + * Vote defines a vote on a governance proposal. + * A Vote consists of a proposal ID, the voter, and the vote option. + */ +export interface Vote { + proposalId: bigint; + voter: string; + /** + * Deprecated: Prefer to use `options` instead. This field is set in queries + * if and only if `len(options) == 1` and that option has weight 1. In all + * other cases, this field will default to VOTE_OPTION_UNSPECIFIED. + */ + /** @deprecated */ + option: VoteOption; + /** Since: cosmos-sdk 0.43 */ + options: WeightedVoteOption[]; +} +export interface VoteProtoMsg { + typeUrl: "/cosmos.gov.v1beta1.Vote"; + value: Uint8Array; +} +/** + * Vote defines a vote on a governance proposal. + * A Vote consists of a proposal ID, the voter, and the vote option. + */ +export interface VoteSDKType { + proposal_id: bigint; + voter: string; + /** @deprecated */ + option: VoteOption; + options: WeightedVoteOptionSDKType[]; +} +/** DepositParams defines the params for deposits on governance proposals. */ +export interface DepositParams { + /** Minimum deposit for a proposal to enter voting period. */ + minDeposit: Coin[]; + /** + * Maximum period for Atom holders to deposit on a proposal. Initial value: 2 + * months. + */ + maxDepositPeriod: Duration; +} +export interface DepositParamsProtoMsg { + typeUrl: "/cosmos.gov.v1beta1.DepositParams"; + value: Uint8Array; +} +/** DepositParams defines the params for deposits on governance proposals. */ +export interface DepositParamsSDKType { + min_deposit: CoinSDKType[]; + max_deposit_period: DurationSDKType; +} +/** VotingParams defines the params for voting on governance proposals. */ +export interface VotingParams { + /** Length of the voting period. */ + votingPeriod: Duration; +} +export interface VotingParamsProtoMsg { + typeUrl: "/cosmos.gov.v1beta1.VotingParams"; + value: Uint8Array; +} +/** VotingParams defines the params for voting on governance proposals. */ +export interface VotingParamsSDKType { + voting_period: DurationSDKType; +} +/** TallyParams defines the params for tallying votes on governance proposals. */ +export interface TallyParams { + /** + * Minimum percentage of total stake needed to vote for a result to be + * considered valid. + */ + quorum: Uint8Array; + /** Minimum proportion of Yes votes for proposal to pass. Default value: 0.5. */ + threshold: Uint8Array; + /** + * Minimum value of Veto votes to Total votes ratio for proposal to be + * vetoed. Default value: 1/3. + */ + vetoThreshold: Uint8Array; +} +export interface TallyParamsProtoMsg { + typeUrl: "/cosmos.gov.v1beta1.TallyParams"; + value: Uint8Array; +} +/** TallyParams defines the params for tallying votes on governance proposals. */ +export interface TallyParamsSDKType { + quorum: Uint8Array; + threshold: Uint8Array; + veto_threshold: Uint8Array; +} +function createBaseWeightedVoteOption(): WeightedVoteOption { + return { + option: 0, + weight: "" + }; +} +export const WeightedVoteOption = { + typeUrl: "/cosmos.gov.v1beta1.WeightedVoteOption", + encode(message: WeightedVoteOption, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.option !== 0) { + writer.uint32(8).int32(message.option); + } + if (message.weight !== undefined) { + writer.uint32(18).string(Decimal.fromUserInput(message.weight, 18).atomics); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): WeightedVoteOption { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseWeightedVoteOption(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.option = (reader.int32() as any); + break; + case 2: + message.weight = Decimal.fromAtomics(reader.string(), 18).toString(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): WeightedVoteOption { + const obj = createBaseWeightedVoteOption(); + if (isSet(object.option)) obj.option = voteOptionFromJSON(object.option); + if (isSet(object.weight)) obj.weight = String(object.weight); + return obj; + }, + toJSON(message: WeightedVoteOption): JsonSafe { + const obj: any = {}; + message.option !== undefined && (obj.option = voteOptionToJSON(message.option)); + message.weight !== undefined && (obj.weight = message.weight); + return obj; + }, + fromPartial(object: DeepPartial): WeightedVoteOption { + const message = createBaseWeightedVoteOption(); + message.option = object.option ?? 0; + message.weight = object.weight ?? ""; + return message; + }, + fromSDK(object: WeightedVoteOptionSDKType): WeightedVoteOption { + return { + option: isSet(object.option) ? voteOptionFromJSON(object.option) : -1, + weight: object?.weight + }; + }, + fromSDKJSON(object: any): WeightedVoteOptionSDKType { + return { + option: isSet(object.option) ? voteOptionFromJSON(object.option) : -1, + weight: isSet(object.weight) ? String(object.weight) : "" + }; + }, + toSDK(message: WeightedVoteOption): WeightedVoteOptionSDKType { + const obj: any = {}; + message.option !== undefined && (obj.option = voteOptionToJSON(message.option)); + obj.weight = message.weight; + return obj; + }, + fromAmino(object: WeightedVoteOptionAmino): WeightedVoteOption { + const message = createBaseWeightedVoteOption(); + if (object.option !== undefined && object.option !== null) { + message.option = object.option; + } + if (object.weight !== undefined && object.weight !== null) { + message.weight = object.weight; + } + return message; + }, + toAmino(message: WeightedVoteOption): WeightedVoteOptionAmino { + const obj: any = {}; + obj.option = message.option === 0 ? undefined : message.option; + obj.weight = message.weight === "" ? undefined : message.weight; + return obj; + }, + fromAminoMsg(object: WeightedVoteOptionAminoMsg): WeightedVoteOption { + return WeightedVoteOption.fromAmino(object.value); + }, + toAminoMsg(message: WeightedVoteOption): WeightedVoteOptionAminoMsg { + return { + type: "cosmos-sdk/WeightedVoteOption", + value: WeightedVoteOption.toAmino(message) + }; + }, + fromProtoMsg(message: WeightedVoteOptionProtoMsg): WeightedVoteOption { + return WeightedVoteOption.decode(message.value); + }, + toProto(message: WeightedVoteOption): Uint8Array { + return WeightedVoteOption.encode(message).finish(); + }, + toProtoMsg(message: WeightedVoteOption): WeightedVoteOptionProtoMsg { + return { + typeUrl: "/cosmos.gov.v1beta1.WeightedVoteOption", + value: WeightedVoteOption.encode(message).finish() + }; + } +}; +function createBaseTextProposal(): TextProposal { + return { + title: "", + description: "" + }; +} +export const TextProposal = { + typeUrl: "/cosmos.gov.v1beta1.TextProposal", + encode(message: TextProposal, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.title !== undefined) { + writer.uint32(10).string(message.title); + } + if (message.description !== undefined) { + writer.uint32(18).string(message.description); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): TextProposal { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseTextProposal(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.title = reader.string(); + break; + case 2: + message.description = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): TextProposal { + const obj = createBaseTextProposal(); + if (isSet(object.title)) obj.title = String(object.title); + if (isSet(object.description)) obj.description = String(object.description); + return obj; + }, + toJSON(message: TextProposal): JsonSafe { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && (obj.description = message.description); + return obj; + }, + fromPartial(object: DeepPartial): TextProposal { + const message = createBaseTextProposal(); + message.title = object.title ?? ""; + message.description = object.description ?? ""; + return message; + }, + fromSDK(object: TextProposalSDKType): TextProposal { + return { + title: object?.title, + description: object?.description + }; + }, + fromSDKJSON(object: any): TextProposalSDKType { + return { + title: isSet(object.title) ? String(object.title) : "", + description: isSet(object.description) ? String(object.description) : "" + }; + }, + toSDK(message: TextProposal): TextProposalSDKType { + const obj: any = {}; + obj.title = message.title; + obj.description = message.description; + return obj; + }, + fromAmino(object: TextProposalAmino): TextProposal { + const message = createBaseTextProposal(); + if (object.title !== undefined && object.title !== null) { + message.title = object.title; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } + return message; + }, + toAmino(message: TextProposal): TextProposalAmino { + const obj: any = {}; + obj.title = message.title === "" ? undefined : message.title; + obj.description = message.description === "" ? undefined : message.description; + return obj; + }, + fromAminoMsg(object: TextProposalAminoMsg): TextProposal { + return TextProposal.fromAmino(object.value); + }, + toAminoMsg(message: TextProposal): TextProposalAminoMsg { + return { + type: "cosmos-sdk/TextProposal", + value: TextProposal.toAmino(message) + }; + }, + fromProtoMsg(message: TextProposalProtoMsg): TextProposal { + return TextProposal.decode(message.value); + }, + toProto(message: TextProposal): Uint8Array { + return TextProposal.encode(message).finish(); + }, + toProtoMsg(message: TextProposal): TextProposalProtoMsg { + return { + typeUrl: "/cosmos.gov.v1beta1.TextProposal", + value: TextProposal.encode(message).finish() + }; + } +}; +function createBaseDeposit(): Deposit { + return { + proposalId: BigInt(0), + depositor: "", + amount: [] + }; +} +export const Deposit = { + typeUrl: "/cosmos.gov.v1beta1.Deposit", + encode(message: Deposit, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.proposalId !== undefined) { + writer.uint32(8).uint64(message.proposalId); + } + if (message.depositor !== undefined) { + writer.uint32(18).string(message.depositor); + } + for (const v of message.amount) { + Coin.encode(v!, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Deposit { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDeposit(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.proposalId = reader.uint64(); + break; + case 2: + message.depositor = reader.string(); + break; + case 3: + message.amount.push(Coin.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Deposit { + const obj = createBaseDeposit(); + if (isSet(object.proposalId)) obj.proposalId = BigInt(object.proposalId.toString()); + if (isSet(object.depositor)) obj.depositor = String(object.depositor); + if (Array.isArray(object?.amount)) obj.amount = object.amount.map((e: any) => Coin.fromJSON(e)); + return obj; + }, + toJSON(message: Deposit): JsonSafe { + const obj: any = {}; + message.proposalId !== undefined && (obj.proposalId = (message.proposalId || BigInt(0)).toString()); + message.depositor !== undefined && (obj.depositor = message.depositor); + if (message.amount) { + obj.amount = message.amount.map(e => e ? Coin.toJSON(e) : undefined); + } else { + obj.amount = []; + } + return obj; + }, + fromPartial(object: DeepPartial): Deposit { + const message = createBaseDeposit(); + if (object.proposalId !== undefined && object.proposalId !== null) { + message.proposalId = BigInt(object.proposalId.toString()); + } + message.depositor = object.depositor ?? ""; + message.amount = object.amount?.map(e => Coin.fromPartial(e)) || []; + return message; + }, + fromSDK(object: DepositSDKType): Deposit { + return { + proposalId: object?.proposal_id, + depositor: object?.depositor, + amount: Array.isArray(object?.amount) ? object.amount.map((e: any) => Coin.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): DepositSDKType { + return { + proposal_id: isSet(object.proposal_id) ? BigInt(object.proposal_id.toString()) : BigInt(0), + depositor: isSet(object.depositor) ? String(object.depositor) : "", + amount: Array.isArray(object?.amount) ? object.amount.map((e: any) => Coin.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: Deposit): DepositSDKType { + const obj: any = {}; + obj.proposal_id = message.proposalId; + obj.depositor = message.depositor; + if (message.amount) { + obj.amount = message.amount.map(e => e ? Coin.toSDK(e) : undefined); + } else { + obj.amount = []; + } + return obj; + }, + fromAmino(object: DepositAmino): Deposit { + const message = createBaseDeposit(); + if (object.proposal_id !== undefined && object.proposal_id !== null) { + message.proposalId = BigInt(object.proposal_id); + } + if (object.depositor !== undefined && object.depositor !== null) { + message.depositor = object.depositor; + } + message.amount = object.amount?.map(e => Coin.fromAmino(e)) || []; + return message; + }, + toAmino(message: Deposit): DepositAmino { + const obj: any = {}; + obj.proposal_id = message.proposalId !== BigInt(0) ? message.proposalId?.toString() : undefined; + obj.depositor = message.depositor === "" ? undefined : message.depositor; + if (message.amount) { + obj.amount = message.amount.map(e => e ? Coin.toAmino(e) : undefined); + } else { + obj.amount = message.amount; + } + return obj; + }, + fromAminoMsg(object: DepositAminoMsg): Deposit { + return Deposit.fromAmino(object.value); + }, + toAminoMsg(message: Deposit): DepositAminoMsg { + return { + type: "cosmos-sdk/Deposit", + value: Deposit.toAmino(message) + }; + }, + fromProtoMsg(message: DepositProtoMsg): Deposit { + return Deposit.decode(message.value); + }, + toProto(message: Deposit): Uint8Array { + return Deposit.encode(message).finish(); + }, + toProtoMsg(message: Deposit): DepositProtoMsg { + return { + typeUrl: "/cosmos.gov.v1beta1.Deposit", + value: Deposit.encode(message).finish() + }; + } +}; +function createBaseProposal(): Proposal { + return { + proposalId: BigInt(0), + content: undefined, + status: 0, + finalTallyResult: TallyResult.fromPartial({}), + submitTime: new Date(), + depositEndTime: new Date(), + totalDeposit: [], + votingStartTime: new Date(), + votingEndTime: new Date() + }; +} +export const Proposal = { + typeUrl: "/cosmos.gov.v1beta1.Proposal", + encode(message: Proposal, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.proposalId !== undefined) { + writer.uint32(8).uint64(message.proposalId); + } + if (message.content !== undefined) { + Any.encode(message.content, writer.uint32(18).fork()).ldelim(); + } + if (message.status !== 0) { + writer.uint32(24).int32(message.status); + } + if (message.finalTallyResult !== undefined) { + TallyResult.encode(message.finalTallyResult, writer.uint32(34).fork()).ldelim(); + } + if (message.submitTime !== undefined) { + Timestamp.encode(toTimestamp(message.submitTime), writer.uint32(42).fork()).ldelim(); + } + if (message.depositEndTime !== undefined) { + Timestamp.encode(toTimestamp(message.depositEndTime), writer.uint32(50).fork()).ldelim(); + } + for (const v of message.totalDeposit) { + Coin.encode(v!, writer.uint32(58).fork()).ldelim(); + } + if (message.votingStartTime !== undefined) { + Timestamp.encode(toTimestamp(message.votingStartTime), writer.uint32(66).fork()).ldelim(); + } + if (message.votingEndTime !== undefined) { + Timestamp.encode(toTimestamp(message.votingEndTime), writer.uint32(74).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Proposal { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseProposal(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.proposalId = reader.uint64(); + break; + case 2: + message.content = Any.decode(reader, reader.uint32()); + break; + case 3: + message.status = (reader.int32() as any); + break; + case 4: + message.finalTallyResult = TallyResult.decode(reader, reader.uint32()); + break; + case 5: + message.submitTime = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + break; + case 6: + message.depositEndTime = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + break; + case 7: + message.totalDeposit.push(Coin.decode(reader, reader.uint32())); + break; + case 8: + message.votingStartTime = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + break; + case 9: + message.votingEndTime = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Proposal { + const obj = createBaseProposal(); + if (isSet(object.proposalId)) obj.proposalId = BigInt(object.proposalId.toString()); + if (isSet(object.content)) obj.content = Any.fromJSON(object.content); + if (isSet(object.status)) obj.status = proposalStatusFromJSON(object.status); + if (isSet(object.finalTallyResult)) obj.finalTallyResult = TallyResult.fromJSON(object.finalTallyResult); + if (isSet(object.submitTime)) obj.submitTime = new Date(object.submitTime); + if (isSet(object.depositEndTime)) obj.depositEndTime = new Date(object.depositEndTime); + if (Array.isArray(object?.totalDeposit)) obj.totalDeposit = object.totalDeposit.map((e: any) => Coin.fromJSON(e)); + if (isSet(object.votingStartTime)) obj.votingStartTime = new Date(object.votingStartTime); + if (isSet(object.votingEndTime)) obj.votingEndTime = new Date(object.votingEndTime); + return obj; + }, + toJSON(message: Proposal): JsonSafe { + const obj: any = {}; + message.proposalId !== undefined && (obj.proposalId = (message.proposalId || BigInt(0)).toString()); + message.content !== undefined && (obj.content = message.content ? Any.toJSON(message.content) : undefined); + message.status !== undefined && (obj.status = proposalStatusToJSON(message.status)); + message.finalTallyResult !== undefined && (obj.finalTallyResult = message.finalTallyResult ? TallyResult.toJSON(message.finalTallyResult) : undefined); + message.submitTime !== undefined && (obj.submitTime = message.submitTime.toISOString()); + message.depositEndTime !== undefined && (obj.depositEndTime = message.depositEndTime.toISOString()); + if (message.totalDeposit) { + obj.totalDeposit = message.totalDeposit.map(e => e ? Coin.toJSON(e) : undefined); + } else { + obj.totalDeposit = []; + } + message.votingStartTime !== undefined && (obj.votingStartTime = message.votingStartTime.toISOString()); + message.votingEndTime !== undefined && (obj.votingEndTime = message.votingEndTime.toISOString()); + return obj; + }, + fromPartial(object: DeepPartial): Proposal { + const message = createBaseProposal(); + if (object.proposalId !== undefined && object.proposalId !== null) { + message.proposalId = BigInt(object.proposalId.toString()); + } + if (object.content !== undefined && object.content !== null) { + message.content = Any.fromPartial(object.content); + } + message.status = object.status ?? 0; + if (object.finalTallyResult !== undefined && object.finalTallyResult !== null) { + message.finalTallyResult = TallyResult.fromPartial(object.finalTallyResult); + } + message.submitTime = object.submitTime ?? undefined; + message.depositEndTime = object.depositEndTime ?? undefined; + message.totalDeposit = object.totalDeposit?.map(e => Coin.fromPartial(e)) || []; + message.votingStartTime = object.votingStartTime ?? undefined; + message.votingEndTime = object.votingEndTime ?? undefined; + return message; + }, + fromSDK(object: ProposalSDKType): Proposal { + return { + proposalId: object?.proposal_id, + content: object.content ? Any.fromSDK(object.content) : undefined, + status: isSet(object.status) ? proposalStatusFromJSON(object.status) : -1, + finalTallyResult: object.final_tally_result ? TallyResult.fromSDK(object.final_tally_result) : undefined, + submitTime: object.submit_time ?? undefined, + depositEndTime: object.deposit_end_time ?? undefined, + totalDeposit: Array.isArray(object?.total_deposit) ? object.total_deposit.map((e: any) => Coin.fromSDK(e)) : [], + votingStartTime: object.voting_start_time ?? undefined, + votingEndTime: object.voting_end_time ?? undefined + }; + }, + fromSDKJSON(object: any): ProposalSDKType { + return { + proposal_id: isSet(object.proposal_id) ? BigInt(object.proposal_id.toString()) : BigInt(0), + content: isSet(object.content) ? Any.fromSDKJSON(object.content) : undefined, + status: isSet(object.status) ? proposalStatusFromJSON(object.status) : -1, + final_tally_result: isSet(object.final_tally_result) ? TallyResult.fromSDKJSON(object.final_tally_result) : undefined, + submit_time: isSet(object.submit_time) ? new Date(object.submit_time) : undefined, + deposit_end_time: isSet(object.deposit_end_time) ? new Date(object.deposit_end_time) : undefined, + total_deposit: Array.isArray(object?.total_deposit) ? object.total_deposit.map((e: any) => Coin.fromSDKJSON(e)) : [], + voting_start_time: isSet(object.voting_start_time) ? new Date(object.voting_start_time) : undefined, + voting_end_time: isSet(object.voting_end_time) ? new Date(object.voting_end_time) : undefined + }; + }, + toSDK(message: Proposal): ProposalSDKType { + const obj: any = {}; + obj.proposal_id = message.proposalId; + message.content !== undefined && (obj.content = message.content ? Any.toSDK(message.content) : undefined); + message.status !== undefined && (obj.status = proposalStatusToJSON(message.status)); + message.finalTallyResult !== undefined && (obj.final_tally_result = message.finalTallyResult ? TallyResult.toSDK(message.finalTallyResult) : undefined); + message.submitTime !== undefined && (obj.submit_time = message.submitTime ?? undefined); + message.depositEndTime !== undefined && (obj.deposit_end_time = message.depositEndTime ?? undefined); + if (message.totalDeposit) { + obj.total_deposit = message.totalDeposit.map(e => e ? Coin.toSDK(e) : undefined); + } else { + obj.total_deposit = []; + } + message.votingStartTime !== undefined && (obj.voting_start_time = message.votingStartTime ?? undefined); + message.votingEndTime !== undefined && (obj.voting_end_time = message.votingEndTime ?? undefined); + return obj; + }, + fromAmino(object: ProposalAmino): Proposal { + const message = createBaseProposal(); + if (object.proposal_id !== undefined && object.proposal_id !== null) { + message.proposalId = BigInt(object.proposal_id); + } + if (object.content !== undefined && object.content !== null) { + message.content = Any.fromAmino(object.content); + } + if (object.status !== undefined && object.status !== null) { + message.status = object.status; + } + if (object.final_tally_result !== undefined && object.final_tally_result !== null) { + message.finalTallyResult = TallyResult.fromAmino(object.final_tally_result); + } + if (object.submit_time !== undefined && object.submit_time !== null) { + message.submitTime = fromTimestamp(Timestamp.fromAmino(object.submit_time)); + } + if (object.deposit_end_time !== undefined && object.deposit_end_time !== null) { + message.depositEndTime = fromTimestamp(Timestamp.fromAmino(object.deposit_end_time)); + } + message.totalDeposit = object.total_deposit?.map(e => Coin.fromAmino(e)) || []; + if (object.voting_start_time !== undefined && object.voting_start_time !== null) { + message.votingStartTime = fromTimestamp(Timestamp.fromAmino(object.voting_start_time)); + } + if (object.voting_end_time !== undefined && object.voting_end_time !== null) { + message.votingEndTime = fromTimestamp(Timestamp.fromAmino(object.voting_end_time)); + } + return message; + }, + toAmino(message: Proposal): ProposalAmino { + const obj: any = {}; + obj.proposal_id = message.proposalId !== BigInt(0) ? message.proposalId?.toString() : undefined; + obj.content = message.content ? Any.toAmino(message.content) : undefined; + obj.status = message.status === 0 ? undefined : message.status; + obj.final_tally_result = message.finalTallyResult ? TallyResult.toAmino(message.finalTallyResult) : undefined; + obj.submit_time = message.submitTime ? Timestamp.toAmino(toTimestamp(message.submitTime)) : undefined; + obj.deposit_end_time = message.depositEndTime ? Timestamp.toAmino(toTimestamp(message.depositEndTime)) : undefined; + if (message.totalDeposit) { + obj.total_deposit = message.totalDeposit.map(e => e ? Coin.toAmino(e) : undefined); + } else { + obj.total_deposit = message.totalDeposit; + } + obj.voting_start_time = message.votingStartTime ? Timestamp.toAmino(toTimestamp(message.votingStartTime)) : undefined; + obj.voting_end_time = message.votingEndTime ? Timestamp.toAmino(toTimestamp(message.votingEndTime)) : undefined; + return obj; + }, + fromAminoMsg(object: ProposalAminoMsg): Proposal { + return Proposal.fromAmino(object.value); + }, + toAminoMsg(message: Proposal): ProposalAminoMsg { + return { + type: "cosmos-sdk/Proposal", + value: Proposal.toAmino(message) + }; + }, + fromProtoMsg(message: ProposalProtoMsg): Proposal { + return Proposal.decode(message.value); + }, + toProto(message: Proposal): Uint8Array { + return Proposal.encode(message).finish(); + }, + toProtoMsg(message: Proposal): ProposalProtoMsg { + return { + typeUrl: "/cosmos.gov.v1beta1.Proposal", + value: Proposal.encode(message).finish() + }; + } +}; +function createBaseTallyResult(): TallyResult { + return { + yes: "", + abstain: "", + no: "", + noWithVeto: "" + }; +} +export const TallyResult = { + typeUrl: "/cosmos.gov.v1beta1.TallyResult", + encode(message: TallyResult, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.yes !== undefined) { + writer.uint32(10).string(message.yes); + } + if (message.abstain !== undefined) { + writer.uint32(18).string(message.abstain); + } + if (message.no !== undefined) { + writer.uint32(26).string(message.no); + } + if (message.noWithVeto !== undefined) { + writer.uint32(34).string(message.noWithVeto); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): TallyResult { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseTallyResult(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.yes = reader.string(); + break; + case 2: + message.abstain = reader.string(); + break; + case 3: + message.no = reader.string(); + break; + case 4: + message.noWithVeto = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): TallyResult { + const obj = createBaseTallyResult(); + if (isSet(object.yes)) obj.yes = String(object.yes); + if (isSet(object.abstain)) obj.abstain = String(object.abstain); + if (isSet(object.no)) obj.no = String(object.no); + if (isSet(object.noWithVeto)) obj.noWithVeto = String(object.noWithVeto); + return obj; + }, + toJSON(message: TallyResult): JsonSafe { + const obj: any = {}; + message.yes !== undefined && (obj.yes = message.yes); + message.abstain !== undefined && (obj.abstain = message.abstain); + message.no !== undefined && (obj.no = message.no); + message.noWithVeto !== undefined && (obj.noWithVeto = message.noWithVeto); + return obj; + }, + fromPartial(object: DeepPartial): TallyResult { + const message = createBaseTallyResult(); + message.yes = object.yes ?? ""; + message.abstain = object.abstain ?? ""; + message.no = object.no ?? ""; + message.noWithVeto = object.noWithVeto ?? ""; + return message; + }, + fromSDK(object: TallyResultSDKType): TallyResult { + return { + yes: object?.yes, + abstain: object?.abstain, + no: object?.no, + noWithVeto: object?.no_with_veto + }; + }, + fromSDKJSON(object: any): TallyResultSDKType { + return { + yes: isSet(object.yes) ? String(object.yes) : "", + abstain: isSet(object.abstain) ? String(object.abstain) : "", + no: isSet(object.no) ? String(object.no) : "", + no_with_veto: isSet(object.no_with_veto) ? String(object.no_with_veto) : "" + }; + }, + toSDK(message: TallyResult): TallyResultSDKType { + const obj: any = {}; + obj.yes = message.yes; + obj.abstain = message.abstain; + obj.no = message.no; + obj.no_with_veto = message.noWithVeto; + return obj; + }, + fromAmino(object: TallyResultAmino): TallyResult { + const message = createBaseTallyResult(); + if (object.yes !== undefined && object.yes !== null) { + message.yes = object.yes; + } + if (object.abstain !== undefined && object.abstain !== null) { + message.abstain = object.abstain; + } + if (object.no !== undefined && object.no !== null) { + message.no = object.no; + } + if (object.no_with_veto !== undefined && object.no_with_veto !== null) { + message.noWithVeto = object.no_with_veto; + } + return message; + }, + toAmino(message: TallyResult): TallyResultAmino { + const obj: any = {}; + obj.yes = message.yes === "" ? undefined : message.yes; + obj.abstain = message.abstain === "" ? undefined : message.abstain; + obj.no = message.no === "" ? undefined : message.no; + obj.no_with_veto = message.noWithVeto === "" ? undefined : message.noWithVeto; + return obj; + }, + fromAminoMsg(object: TallyResultAminoMsg): TallyResult { + return TallyResult.fromAmino(object.value); + }, + toAminoMsg(message: TallyResult): TallyResultAminoMsg { + return { + type: "cosmos-sdk/TallyResult", + value: TallyResult.toAmino(message) + }; + }, + fromProtoMsg(message: TallyResultProtoMsg): TallyResult { + return TallyResult.decode(message.value); + }, + toProto(message: TallyResult): Uint8Array { + return TallyResult.encode(message).finish(); + }, + toProtoMsg(message: TallyResult): TallyResultProtoMsg { + return { + typeUrl: "/cosmos.gov.v1beta1.TallyResult", + value: TallyResult.encode(message).finish() + }; + } +}; +function createBaseVote(): Vote { + return { + proposalId: BigInt(0), + voter: "", + option: 0, + options: [] + }; +} +export const Vote = { + typeUrl: "/cosmos.gov.v1beta1.Vote", + encode(message: Vote, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.proposalId !== undefined) { + writer.uint32(8).uint64(message.proposalId); + } + if (message.voter !== undefined) { + writer.uint32(18).string(message.voter); + } + if (message.option !== 0) { + writer.uint32(24).int32(message.option); + } + for (const v of message.options) { + WeightedVoteOption.encode(v!, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Vote { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseVote(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.proposalId = reader.uint64(); + break; + case 2: + message.voter = reader.string(); + break; + case 3: + message.option = (reader.int32() as any); + break; + case 4: + message.options.push(WeightedVoteOption.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Vote { + const obj = createBaseVote(); + if (isSet(object.proposalId)) obj.proposalId = BigInt(object.proposalId.toString()); + if (isSet(object.voter)) obj.voter = String(object.voter); + if (isSet(object.option)) obj.option = voteOptionFromJSON(object.option); + if (Array.isArray(object?.options)) obj.options = object.options.map((e: any) => WeightedVoteOption.fromJSON(e)); + return obj; + }, + toJSON(message: Vote): JsonSafe { + const obj: any = {}; + message.proposalId !== undefined && (obj.proposalId = (message.proposalId || BigInt(0)).toString()); + message.voter !== undefined && (obj.voter = message.voter); + message.option !== undefined && (obj.option = voteOptionToJSON(message.option)); + if (message.options) { + obj.options = message.options.map(e => e ? WeightedVoteOption.toJSON(e) : undefined); + } else { + obj.options = []; + } + return obj; + }, + fromPartial(object: DeepPartial): Vote { + const message = createBaseVote(); + if (object.proposalId !== undefined && object.proposalId !== null) { + message.proposalId = BigInt(object.proposalId.toString()); + } + message.voter = object.voter ?? ""; + message.option = object.option ?? 0; + message.options = object.options?.map(e => WeightedVoteOption.fromPartial(e)) || []; + return message; + }, + fromSDK(object: VoteSDKType): Vote { + return { + proposalId: object?.proposal_id, + voter: object?.voter, + option: isSet(object.option) ? voteOptionFromJSON(object.option) : -1, + options: Array.isArray(object?.options) ? object.options.map((e: any) => WeightedVoteOption.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): VoteSDKType { + return { + proposal_id: isSet(object.proposal_id) ? BigInt(object.proposal_id.toString()) : BigInt(0), + voter: isSet(object.voter) ? String(object.voter) : "", + option: isSet(object.option) ? voteOptionFromJSON(object.option) : -1, + options: Array.isArray(object?.options) ? object.options.map((e: any) => WeightedVoteOption.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: Vote): VoteSDKType { + const obj: any = {}; + obj.proposal_id = message.proposalId; + obj.voter = message.voter; + message.option !== undefined && (obj.option = voteOptionToJSON(message.option)); + if (message.options) { + obj.options = message.options.map(e => e ? WeightedVoteOption.toSDK(e) : undefined); + } else { + obj.options = []; + } + return obj; + }, + fromAmino(object: VoteAmino): Vote { + const message = createBaseVote(); + if (object.proposal_id !== undefined && object.proposal_id !== null) { + message.proposalId = BigInt(object.proposal_id); + } + if (object.voter !== undefined && object.voter !== null) { + message.voter = object.voter; + } + if (object.option !== undefined && object.option !== null) { + message.option = object.option; + } + message.options = object.options?.map(e => WeightedVoteOption.fromAmino(e)) || []; + return message; + }, + toAmino(message: Vote): VoteAmino { + const obj: any = {}; + obj.proposal_id = message.proposalId ? message.proposalId?.toString() : "0"; + obj.voter = message.voter === "" ? undefined : message.voter; + obj.option = message.option === 0 ? undefined : message.option; + if (message.options) { + obj.options = message.options.map(e => e ? WeightedVoteOption.toAmino(e) : undefined); + } else { + obj.options = message.options; + } + return obj; + }, + fromAminoMsg(object: VoteAminoMsg): Vote { + return Vote.fromAmino(object.value); + }, + toAminoMsg(message: Vote): VoteAminoMsg { + return { + type: "cosmos-sdk/Vote", + value: Vote.toAmino(message) + }; + }, + fromProtoMsg(message: VoteProtoMsg): Vote { + return Vote.decode(message.value); + }, + toProto(message: Vote): Uint8Array { + return Vote.encode(message).finish(); + }, + toProtoMsg(message: Vote): VoteProtoMsg { + return { + typeUrl: "/cosmos.gov.v1beta1.Vote", + value: Vote.encode(message).finish() + }; + } +}; +function createBaseDepositParams(): DepositParams { + return { + minDeposit: [], + maxDepositPeriod: Duration.fromPartial({}) + }; +} +export const DepositParams = { + typeUrl: "/cosmos.gov.v1beta1.DepositParams", + encode(message: DepositParams, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.minDeposit) { + Coin.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.maxDepositPeriod !== undefined) { + Duration.encode(message.maxDepositPeriod, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): DepositParams { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDepositParams(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.minDeposit.push(Coin.decode(reader, reader.uint32())); + break; + case 2: + message.maxDepositPeriod = Duration.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): DepositParams { + const obj = createBaseDepositParams(); + if (Array.isArray(object?.minDeposit)) obj.minDeposit = object.minDeposit.map((e: any) => Coin.fromJSON(e)); + if (isSet(object.maxDepositPeriod)) obj.maxDepositPeriod = Duration.fromJSON(object.maxDepositPeriod); + return obj; + }, + toJSON(message: DepositParams): JsonSafe { + const obj: any = {}; + if (message.minDeposit) { + obj.minDeposit = message.minDeposit.map(e => e ? Coin.toJSON(e) : undefined); + } else { + obj.minDeposit = []; + } + message.maxDepositPeriod !== undefined && (obj.maxDepositPeriod = message.maxDepositPeriod ? Duration.toJSON(message.maxDepositPeriod) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): DepositParams { + const message = createBaseDepositParams(); + message.minDeposit = object.minDeposit?.map(e => Coin.fromPartial(e)) || []; + if (object.maxDepositPeriod !== undefined && object.maxDepositPeriod !== null) { + message.maxDepositPeriod = Duration.fromPartial(object.maxDepositPeriod); + } + return message; + }, + fromSDK(object: DepositParamsSDKType): DepositParams { + return { + minDeposit: Array.isArray(object?.min_deposit) ? object.min_deposit.map((e: any) => Coin.fromSDK(e)) : [], + maxDepositPeriod: object.max_deposit_period ? Duration.fromSDK(object.max_deposit_period) : undefined + }; + }, + fromSDKJSON(object: any): DepositParamsSDKType { + return { + min_deposit: Array.isArray(object?.min_deposit) ? object.min_deposit.map((e: any) => Coin.fromSDKJSON(e)) : [], + max_deposit_period: isSet(object.max_deposit_period) ? Duration.fromSDKJSON(object.max_deposit_period) : undefined + }; + }, + toSDK(message: DepositParams): DepositParamsSDKType { + const obj: any = {}; + if (message.minDeposit) { + obj.min_deposit = message.minDeposit.map(e => e ? Coin.toSDK(e) : undefined); + } else { + obj.min_deposit = []; + } + message.maxDepositPeriod !== undefined && (obj.max_deposit_period = message.maxDepositPeriod ? Duration.toSDK(message.maxDepositPeriod) : undefined); + return obj; + }, + fromAmino(object: DepositParamsAmino): DepositParams { + const message = createBaseDepositParams(); + message.minDeposit = object.min_deposit?.map(e => Coin.fromAmino(e)) || []; + if (object.max_deposit_period !== undefined && object.max_deposit_period !== null) { + message.maxDepositPeriod = Duration.fromAmino(object.max_deposit_period); + } + return message; + }, + toAmino(message: DepositParams): DepositParamsAmino { + const obj: any = {}; + if (message.minDeposit) { + obj.min_deposit = message.minDeposit.map(e => e ? Coin.toAmino(e) : undefined); + } else { + obj.min_deposit = message.minDeposit; + } + obj.max_deposit_period = message.maxDepositPeriod ? Duration.toAmino(message.maxDepositPeriod) : undefined; + return obj; + }, + fromAminoMsg(object: DepositParamsAminoMsg): DepositParams { + return DepositParams.fromAmino(object.value); + }, + toAminoMsg(message: DepositParams): DepositParamsAminoMsg { + return { + type: "cosmos-sdk/DepositParams", + value: DepositParams.toAmino(message) + }; + }, + fromProtoMsg(message: DepositParamsProtoMsg): DepositParams { + return DepositParams.decode(message.value); + }, + toProto(message: DepositParams): Uint8Array { + return DepositParams.encode(message).finish(); + }, + toProtoMsg(message: DepositParams): DepositParamsProtoMsg { + return { + typeUrl: "/cosmos.gov.v1beta1.DepositParams", + value: DepositParams.encode(message).finish() + }; + } +}; +function createBaseVotingParams(): VotingParams { + return { + votingPeriod: Duration.fromPartial({}) + }; +} +export const VotingParams = { + typeUrl: "/cosmos.gov.v1beta1.VotingParams", + encode(message: VotingParams, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.votingPeriod !== undefined) { + Duration.encode(message.votingPeriod, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): VotingParams { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseVotingParams(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.votingPeriod = Duration.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): VotingParams { + const obj = createBaseVotingParams(); + if (isSet(object.votingPeriod)) obj.votingPeriod = Duration.fromJSON(object.votingPeriod); + return obj; + }, + toJSON(message: VotingParams): JsonSafe { + const obj: any = {}; + message.votingPeriod !== undefined && (obj.votingPeriod = message.votingPeriod ? Duration.toJSON(message.votingPeriod) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): VotingParams { + const message = createBaseVotingParams(); + if (object.votingPeriod !== undefined && object.votingPeriod !== null) { + message.votingPeriod = Duration.fromPartial(object.votingPeriod); + } + return message; + }, + fromSDK(object: VotingParamsSDKType): VotingParams { + return { + votingPeriod: object.voting_period ? Duration.fromSDK(object.voting_period) : undefined + }; + }, + fromSDKJSON(object: any): VotingParamsSDKType { + return { + voting_period: isSet(object.voting_period) ? Duration.fromSDKJSON(object.voting_period) : undefined + }; + }, + toSDK(message: VotingParams): VotingParamsSDKType { + const obj: any = {}; + message.votingPeriod !== undefined && (obj.voting_period = message.votingPeriod ? Duration.toSDK(message.votingPeriod) : undefined); + return obj; + }, + fromAmino(object: VotingParamsAmino): VotingParams { + const message = createBaseVotingParams(); + if (object.voting_period !== undefined && object.voting_period !== null) { + message.votingPeriod = Duration.fromAmino(object.voting_period); + } + return message; + }, + toAmino(message: VotingParams): VotingParamsAmino { + const obj: any = {}; + obj.voting_period = message.votingPeriod ? Duration.toAmino(message.votingPeriod) : undefined; + return obj; + }, + fromAminoMsg(object: VotingParamsAminoMsg): VotingParams { + return VotingParams.fromAmino(object.value); + }, + toAminoMsg(message: VotingParams): VotingParamsAminoMsg { + return { + type: "cosmos-sdk/VotingParams", + value: VotingParams.toAmino(message) + }; + }, + fromProtoMsg(message: VotingParamsProtoMsg): VotingParams { + return VotingParams.decode(message.value); + }, + toProto(message: VotingParams): Uint8Array { + return VotingParams.encode(message).finish(); + }, + toProtoMsg(message: VotingParams): VotingParamsProtoMsg { + return { + typeUrl: "/cosmos.gov.v1beta1.VotingParams", + value: VotingParams.encode(message).finish() + }; + } +}; +function createBaseTallyParams(): TallyParams { + return { + quorum: new Uint8Array(), + threshold: new Uint8Array(), + vetoThreshold: new Uint8Array() + }; +} +export const TallyParams = { + typeUrl: "/cosmos.gov.v1beta1.TallyParams", + encode(message: TallyParams, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.quorum.length !== 0) { + writer.uint32(10).bytes(message.quorum); + } + if (message.threshold.length !== 0) { + writer.uint32(18).bytes(message.threshold); + } + if (message.vetoThreshold.length !== 0) { + writer.uint32(26).bytes(message.vetoThreshold); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): TallyParams { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseTallyParams(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.quorum = reader.bytes(); + break; + case 2: + message.threshold = reader.bytes(); + break; + case 3: + message.vetoThreshold = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): TallyParams { + const obj = createBaseTallyParams(); + if (isSet(object.quorum)) obj.quorum = bytesFromBase64(object.quorum); + if (isSet(object.threshold)) obj.threshold = bytesFromBase64(object.threshold); + if (isSet(object.vetoThreshold)) obj.vetoThreshold = bytesFromBase64(object.vetoThreshold); + return obj; + }, + toJSON(message: TallyParams): JsonSafe { + const obj: any = {}; + message.quorum !== undefined && (obj.quorum = base64FromBytes(message.quorum !== undefined ? message.quorum : new Uint8Array())); + message.threshold !== undefined && (obj.threshold = base64FromBytes(message.threshold !== undefined ? message.threshold : new Uint8Array())); + message.vetoThreshold !== undefined && (obj.vetoThreshold = base64FromBytes(message.vetoThreshold !== undefined ? message.vetoThreshold : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): TallyParams { + const message = createBaseTallyParams(); + message.quorum = object.quorum ?? new Uint8Array(); + message.threshold = object.threshold ?? new Uint8Array(); + message.vetoThreshold = object.vetoThreshold ?? new Uint8Array(); + return message; + }, + fromSDK(object: TallyParamsSDKType): TallyParams { + return { + quorum: object?.quorum, + threshold: object?.threshold, + vetoThreshold: object?.veto_threshold + }; + }, + fromSDKJSON(object: any): TallyParamsSDKType { + return { + quorum: isSet(object.quorum) ? bytesFromBase64(object.quorum) : new Uint8Array(), + threshold: isSet(object.threshold) ? bytesFromBase64(object.threshold) : new Uint8Array(), + veto_threshold: isSet(object.veto_threshold) ? bytesFromBase64(object.veto_threshold) : new Uint8Array() + }; + }, + toSDK(message: TallyParams): TallyParamsSDKType { + const obj: any = {}; + obj.quorum = message.quorum; + obj.threshold = message.threshold; + obj.veto_threshold = message.vetoThreshold; + return obj; + }, + fromAmino(object: TallyParamsAmino): TallyParams { + const message = createBaseTallyParams(); + if (object.quorum !== undefined && object.quorum !== null) { + message.quorum = bytesFromBase64(object.quorum); + } + if (object.threshold !== undefined && object.threshold !== null) { + message.threshold = bytesFromBase64(object.threshold); + } + if (object.veto_threshold !== undefined && object.veto_threshold !== null) { + message.vetoThreshold = bytesFromBase64(object.veto_threshold); + } + return message; + }, + toAmino(message: TallyParams): TallyParamsAmino { + const obj: any = {}; + obj.quorum = message.quorum ? base64FromBytes(message.quorum) : undefined; + obj.threshold = message.threshold ? base64FromBytes(message.threshold) : undefined; + obj.veto_threshold = message.vetoThreshold ? base64FromBytes(message.vetoThreshold) : undefined; + return obj; + }, + fromAminoMsg(object: TallyParamsAminoMsg): TallyParams { + return TallyParams.fromAmino(object.value); + }, + toAminoMsg(message: TallyParams): TallyParamsAminoMsg { + return { + type: "cosmos-sdk/TallyParams", + value: TallyParams.toAmino(message) + }; + }, + fromProtoMsg(message: TallyParamsProtoMsg): TallyParams { + return TallyParams.decode(message.value); + }, + toProto(message: TallyParams): Uint8Array { + return TallyParams.encode(message).finish(); + }, + toProtoMsg(message: TallyParams): TallyParamsProtoMsg { + return { + typeUrl: "/cosmos.gov.v1beta1.TallyParams", + value: TallyParams.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/gov/v1beta1/query.lcd.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/gov/v1beta1/query.lcd.ts new file mode 100644 index 0000000000..7eb6b46465 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/gov/v1beta1/query.lcd.ts @@ -0,0 +1,90 @@ +import { ProposalStatus, ProposalStatusSDKType, Proposal, ProposalSDKType, Vote, VoteSDKType, VotingParams, VotingParamsSDKType, DepositParams, DepositParamsSDKType, TallyParams, TallyParamsSDKType, Deposit, DepositSDKType, TallyResult, TallyResultSDKType } from "./gov.js"; +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../base/query/v1beta1/pagination.js"; +import { setPaginationParams } from "../../../helpers.js"; +import { LCDClient } from "@cosmology/lcd"; +import { QueryProposalRequest, QueryProposalRequestSDKType, QueryProposalResponse, QueryProposalResponseSDKType, QueryProposalsRequest, QueryProposalsRequestSDKType, QueryProposalsResponse, QueryProposalsResponseSDKType, QueryVoteRequest, QueryVoteRequestSDKType, QueryVoteResponse, QueryVoteResponseSDKType, QueryVotesRequest, QueryVotesRequestSDKType, QueryVotesResponse, QueryVotesResponseSDKType, QueryParamsRequest, QueryParamsRequestSDKType, QueryParamsResponse, QueryParamsResponseSDKType, QueryDepositRequest, QueryDepositRequestSDKType, QueryDepositResponse, QueryDepositResponseSDKType, QueryDepositsRequest, QueryDepositsRequestSDKType, QueryDepositsResponse, QueryDepositsResponseSDKType, QueryTallyResultRequest, QueryTallyResultRequestSDKType, QueryTallyResultResponse, QueryTallyResultResponseSDKType } from "./query.js"; +export class LCDQueryClient { + req: LCDClient; + constructor({ + requestClient + }: { + requestClient: LCDClient; + }) { + this.req = requestClient; + this.proposal = this.proposal.bind(this); + this.proposals = this.proposals.bind(this); + this.vote = this.vote.bind(this); + this.votes = this.votes.bind(this); + this.params = this.params.bind(this); + this.deposit = this.deposit.bind(this); + this.deposits = this.deposits.bind(this); + this.tallyResult = this.tallyResult.bind(this); + } + /* Proposal queries proposal details based on ProposalID. */ + async proposal(params: QueryProposalRequest): Promise { + const endpoint = `cosmos/gov/v1beta1/proposals/${params.proposalId}`; + return QueryProposalResponse.fromSDKJSON(await this.req.get(endpoint)); + } + /* Proposals queries all proposals based on given status. */ + async proposals(params: QueryProposalsRequest): Promise { + const options: any = { + params: {} + }; + if (typeof params?.proposalStatus !== "undefined") { + options.params.proposal_status = params.proposalStatus; + } + if (typeof params?.voter !== "undefined") { + options.params.voter = params.voter; + } + if (typeof params?.depositor !== "undefined") { + options.params.depositor = params.depositor; + } + if (typeof params?.pagination !== "undefined") { + setPaginationParams(options, params.pagination); + } + const endpoint = `cosmos/gov/v1beta1/proposals`; + return QueryProposalsResponse.fromSDKJSON(await this.req.get(endpoint, options)); + } + /* Vote queries voted information based on proposalID, voterAddr. */ + async vote(params: QueryVoteRequest): Promise { + const endpoint = `cosmos/gov/v1beta1/proposals/${params.proposalId}/votes/${params.voter}`; + return QueryVoteResponse.fromSDKJSON(await this.req.get(endpoint)); + } + /* Votes queries votes of a given proposal. */ + async votes(params: QueryVotesRequest): Promise { + const options: any = { + params: {} + }; + if (typeof params?.pagination !== "undefined") { + setPaginationParams(options, params.pagination); + } + const endpoint = `cosmos/gov/v1beta1/proposals/${params.proposalId}/votes`; + return QueryVotesResponse.fromSDKJSON(await this.req.get(endpoint, options)); + } + /* Params queries all parameters of the gov module. */ + async params(params: QueryParamsRequest): Promise { + const endpoint = `cosmos/gov/v1beta1/params/${params.paramsType}`; + return QueryParamsResponse.fromSDKJSON(await this.req.get(endpoint)); + } + /* Deposit queries single deposit information based proposalID, depositAddr. */ + async deposit(params: QueryDepositRequest): Promise { + const endpoint = `cosmos/gov/v1beta1/proposals/${params.proposalId}/deposits/${params.depositor}`; + return QueryDepositResponse.fromSDKJSON(await this.req.get(endpoint)); + } + /* Deposits queries all deposits of a single proposal. */ + async deposits(params: QueryDepositsRequest): Promise { + const options: any = { + params: {} + }; + if (typeof params?.pagination !== "undefined") { + setPaginationParams(options, params.pagination); + } + const endpoint = `cosmos/gov/v1beta1/proposals/${params.proposalId}/deposits`; + return QueryDepositsResponse.fromSDKJSON(await this.req.get(endpoint, options)); + } + /* TallyResult queries the tally of a proposal vote. */ + async tallyResult(params: QueryTallyResultRequest): Promise { + const endpoint = `cosmos/gov/v1beta1/proposals/${params.proposalId}/tally`; + return QueryTallyResultResponse.fromSDKJSON(await this.req.get(endpoint)); + } +} \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/gov/v1beta1/query.rpc.Query.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/gov/v1beta1/query.rpc.Query.ts new file mode 100644 index 0000000000..636bddd19b --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/gov/v1beta1/query.rpc.Query.ts @@ -0,0 +1,182 @@ +import { ProposalStatus, ProposalStatusSDKType, Proposal, ProposalSDKType, Vote, VoteSDKType, VotingParams, VotingParamsSDKType, DepositParams, DepositParamsSDKType, TallyParams, TallyParamsSDKType, Deposit, DepositSDKType, TallyResult, TallyResultSDKType } from "./gov.js"; +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../base/query/v1beta1/pagination.js"; +import { Rpc } from "../../../helpers.js"; +import { BinaryReader } from "../../../binary.js"; +import { QueryClient, createProtobufRpcClient, ProtobufRpcClient } from "@cosmjs/stargate"; +import { QueryStore, MobxResponse } from "../../../mobx.js"; +import { makeObservable, override } from "mobx"; +import { QueryProposalRequest, QueryProposalRequestSDKType, QueryProposalResponse, QueryProposalResponseSDKType, QueryProposalsRequest, QueryProposalsRequestSDKType, QueryProposalsResponse, QueryProposalsResponseSDKType, QueryVoteRequest, QueryVoteRequestSDKType, QueryVoteResponse, QueryVoteResponseSDKType, QueryVotesRequest, QueryVotesRequestSDKType, QueryVotesResponse, QueryVotesResponseSDKType, QueryParamsRequest, QueryParamsRequestSDKType, QueryParamsResponse, QueryParamsResponseSDKType, QueryDepositRequest, QueryDepositRequestSDKType, QueryDepositResponse, QueryDepositResponseSDKType, QueryDepositsRequest, QueryDepositsRequestSDKType, QueryDepositsResponse, QueryDepositsResponseSDKType, QueryTallyResultRequest, QueryTallyResultRequestSDKType, QueryTallyResultResponse, QueryTallyResultResponseSDKType } from "./query.js"; +/** Query defines the gRPC querier service for gov module */ +export interface Query { + /** Proposal queries proposal details based on ProposalID. */ + proposal(request: QueryProposalRequest): Promise; + /** Proposals queries all proposals based on given status. */ + proposals(request: QueryProposalsRequest): Promise; + /** Vote queries voted information based on proposalID, voterAddr. */ + vote(request: QueryVoteRequest): Promise; + /** Votes queries votes of a given proposal. */ + votes(request: QueryVotesRequest): Promise; + /** Params queries all parameters of the gov module. */ + params(request: QueryParamsRequest): Promise; + /** Deposit queries single deposit information based proposalID, depositAddr. */ + deposit(request: QueryDepositRequest): Promise; + /** Deposits queries all deposits of a single proposal. */ + deposits(request: QueryDepositsRequest): Promise; + /** TallyResult queries the tally of a proposal vote. */ + tallyResult(request: QueryTallyResultRequest): Promise; +} +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + this.proposal = this.proposal.bind(this); + this.proposals = this.proposals.bind(this); + this.vote = this.vote.bind(this); + this.votes = this.votes.bind(this); + this.params = this.params.bind(this); + this.deposit = this.deposit.bind(this); + this.deposits = this.deposits.bind(this); + this.tallyResult = this.tallyResult.bind(this); + } + proposal(request: QueryProposalRequest): Promise { + const data = QueryProposalRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.gov.v1beta1.Query", "Proposal", data); + return promise.then(data => QueryProposalResponse.decode(new BinaryReader(data))); + } + proposals(request: QueryProposalsRequest): Promise { + const data = QueryProposalsRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.gov.v1beta1.Query", "Proposals", data); + return promise.then(data => QueryProposalsResponse.decode(new BinaryReader(data))); + } + vote(request: QueryVoteRequest): Promise { + const data = QueryVoteRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.gov.v1beta1.Query", "Vote", data); + return promise.then(data => QueryVoteResponse.decode(new BinaryReader(data))); + } + votes(request: QueryVotesRequest): Promise { + const data = QueryVotesRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.gov.v1beta1.Query", "Votes", data); + return promise.then(data => QueryVotesResponse.decode(new BinaryReader(data))); + } + params(request: QueryParamsRequest): Promise { + const data = QueryParamsRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.gov.v1beta1.Query", "Params", data); + return promise.then(data => QueryParamsResponse.decode(new BinaryReader(data))); + } + deposit(request: QueryDepositRequest): Promise { + const data = QueryDepositRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.gov.v1beta1.Query", "Deposit", data); + return promise.then(data => QueryDepositResponse.decode(new BinaryReader(data))); + } + deposits(request: QueryDepositsRequest): Promise { + const data = QueryDepositsRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.gov.v1beta1.Query", "Deposits", data); + return promise.then(data => QueryDepositsResponse.decode(new BinaryReader(data))); + } + tallyResult(request: QueryTallyResultRequest): Promise { + const data = QueryTallyResultRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.gov.v1beta1.Query", "TallyResult", data); + return promise.then(data => QueryTallyResultResponse.decode(new BinaryReader(data))); + } +} +export const createRpcQueryExtension = (base: QueryClient) => { + const rpc = createProtobufRpcClient(base); + const queryService = new QueryClientImpl(rpc); + return { + proposal(request: QueryProposalRequest): Promise { + return queryService.proposal(request); + }, + proposals(request: QueryProposalsRequest): Promise { + return queryService.proposals(request); + }, + vote(request: QueryVoteRequest): Promise { + return queryService.vote(request); + }, + votes(request: QueryVotesRequest): Promise { + return queryService.votes(request); + }, + params(request: QueryParamsRequest): Promise { + return queryService.params(request); + }, + deposit(request: QueryDepositRequest): Promise { + return queryService.deposit(request); + }, + deposits(request: QueryDepositsRequest): Promise { + return queryService.deposits(request); + }, + tallyResult(request: QueryTallyResultRequest): Promise { + return queryService.tallyResult(request); + } + }; +}; +const _queryClients: WeakMap = new WeakMap(); +const getQueryService = (rpc: ProtobufRpcClient | undefined): QueryClientImpl | undefined => { + if (!rpc) return; + if (_queryClients.has(rpc)) { + return _queryClients.get(rpc); + } + const queryService = new QueryClientImpl(rpc); + _queryClients.set(rpc, queryService); + return queryService; +}; +export const createRpcQueryMobxStores = (rpc: ProtobufRpcClient | undefined) => { + const queryService = getQueryService(rpc); + class QueryProposalStore { + store = new QueryStore(queryService?.proposal); + proposal(request: QueryProposalRequest) { + return this.store.getData(request); + } + } + class QueryProposalsStore { + store = new QueryStore(queryService?.proposals); + proposals(request: QueryProposalsRequest) { + return this.store.getData(request); + } + } + class QueryVoteStore { + store = new QueryStore(queryService?.vote); + vote(request: QueryVoteRequest) { + return this.store.getData(request); + } + } + class QueryVotesStore { + store = new QueryStore(queryService?.votes); + votes(request: QueryVotesRequest) { + return this.store.getData(request); + } + } + class QueryParamsStore { + store = new QueryStore(queryService?.params); + params(request: QueryParamsRequest) { + return this.store.getData(request); + } + } + class QueryDepositStore { + store = new QueryStore(queryService?.deposit); + deposit(request: QueryDepositRequest) { + return this.store.getData(request); + } + } + class QueryDepositsStore { + store = new QueryStore(queryService?.deposits); + deposits(request: QueryDepositsRequest) { + return this.store.getData(request); + } + } + class QueryTallyResultStore { + store = new QueryStore(queryService?.tallyResult); + tallyResult(request: QueryTallyResultRequest) { + return this.store.getData(request); + } + } + return { + /** Proposal queries proposal details based on ProposalID. */QueryProposalStore, + /** Proposals queries all proposals based on given status. */QueryProposalsStore, + /** Vote queries voted information based on proposalID, voterAddr. */QueryVoteStore, + /** Votes queries votes of a given proposal. */QueryVotesStore, + /** Params queries all parameters of the gov module. */QueryParamsStore, + /** Deposit queries single deposit information based proposalID, depositAddr. */QueryDepositStore, + /** Deposits queries all deposits of a single proposal. */QueryDepositsStore, + /** TallyResult queries the tally of a proposal vote. */QueryTallyResultStore + }; +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/gov/v1beta1/query.rpc.func.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/gov/v1beta1/query.rpc.func.ts new file mode 100644 index 0000000000..5eaf754684 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/gov/v1beta1/query.rpc.func.ts @@ -0,0 +1,91 @@ +import { RpcResolver, buildQuery } from "../../../helper-func-types"; +import { buildUseQuery } from "../../../react-query"; +import { QueryProposalRequest, QueryProposalResponse, QueryProposalsRequest, QueryProposalsResponse, QueryVoteRequest, QueryVoteResponse, QueryVotesRequest, QueryVotesResponse, QueryParamsRequest, QueryParamsResponse, QueryDepositRequest, QueryDepositResponse, QueryDepositsRequest, QueryDepositsResponse, QueryTallyResultRequest, QueryTallyResultResponse } from "./query"; +export const createGetProposal = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryProposalRequest.encode, + decode: QueryProposalResponse.decode, + service: "cosmos.gov.v1beta1.Query", + method: "Proposal", + getRpcInstance: getRpcInstance +}); +export const useGetProposal = buildUseQuery({ + builderQueryFn: createGetProposal, + queryKeyPrefix: "ProposalQuery" +}); +export const createGetProposals = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryProposalsRequest.encode, + decode: QueryProposalsResponse.decode, + service: "cosmos.gov.v1beta1.Query", + method: "Proposals", + getRpcInstance: getRpcInstance +}); +export const useGetProposals = buildUseQuery({ + builderQueryFn: createGetProposals, + queryKeyPrefix: "ProposalsQuery" +}); +export const createGetVote = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryVoteRequest.encode, + decode: QueryVoteResponse.decode, + service: "cosmos.gov.v1beta1.Query", + method: "Vote", + getRpcInstance: getRpcInstance +}); +export const useGetVote = buildUseQuery({ + builderQueryFn: createGetVote, + queryKeyPrefix: "VoteQuery" +}); +export const createGetVotes = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryVotesRequest.encode, + decode: QueryVotesResponse.decode, + service: "cosmos.gov.v1beta1.Query", + method: "Votes", + getRpcInstance: getRpcInstance +}); +export const useGetVotes = buildUseQuery({ + builderQueryFn: createGetVotes, + queryKeyPrefix: "VotesQuery" +}); +export const createGetParams = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryParamsRequest.encode, + decode: QueryParamsResponse.decode, + service: "cosmos.gov.v1beta1.Query", + method: "Params", + getRpcInstance: getRpcInstance +}); +export const useGetParams = buildUseQuery({ + builderQueryFn: createGetParams, + queryKeyPrefix: "ParamsQuery" +}); +export const createGetDeposit = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryDepositRequest.encode, + decode: QueryDepositResponse.decode, + service: "cosmos.gov.v1beta1.Query", + method: "Deposit", + getRpcInstance: getRpcInstance +}); +export const useGetDeposit = buildUseQuery({ + builderQueryFn: createGetDeposit, + queryKeyPrefix: "DepositQuery" +}); +export const createGetDeposits = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryDepositsRequest.encode, + decode: QueryDepositsResponse.decode, + service: "cosmos.gov.v1beta1.Query", + method: "Deposits", + getRpcInstance: getRpcInstance +}); +export const useGetDeposits = buildUseQuery({ + builderQueryFn: createGetDeposits, + queryKeyPrefix: "DepositsQuery" +}); +export const createGetTallyResult = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryTallyResultRequest.encode, + decode: QueryTallyResultResponse.decode, + service: "cosmos.gov.v1beta1.Query", + method: "TallyResult", + getRpcInstance: getRpcInstance +}); +export const useGetTallyResult = buildUseQuery({ + builderQueryFn: createGetTallyResult, + queryKeyPrefix: "TallyResultQuery" +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/gov/v1beta1/query.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/gov/v1beta1/query.ts new file mode 100644 index 0000000000..d107c800b8 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/gov/v1beta1/query.ts @@ -0,0 +1,2032 @@ +import { ProposalStatus, ProposalStatusSDKType, Proposal, ProposalSDKType, Vote, VoteSDKType, VotingParams, VotingParamsSDKType, DepositParams, DepositParamsSDKType, TallyParams, TallyParamsSDKType, Deposit, DepositSDKType, TallyResult, TallyResultSDKType, proposalStatusFromJSON, proposalStatusToJSON } from "./gov.js"; +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../base/query/v1beta1/pagination.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "cosmos.gov.v1beta1"; +/** QueryProposalRequest is the request type for the Query/Proposal RPC method. */ +export interface QueryProposalRequest { + /** proposal_id defines the unique id of the proposal. */ + proposalId: bigint; +} +export interface QueryProposalRequestProtoMsg { + typeUrl: "/cosmos.gov.v1beta1.QueryProposalRequest"; + value: Uint8Array; +} +/** QueryProposalRequest is the request type for the Query/Proposal RPC method. */ +export interface QueryProposalRequestSDKType { + proposal_id: bigint; +} +/** QueryProposalResponse is the response type for the Query/Proposal RPC method. */ +export interface QueryProposalResponse { + proposal: Proposal; +} +export interface QueryProposalResponseProtoMsg { + typeUrl: "/cosmos.gov.v1beta1.QueryProposalResponse"; + value: Uint8Array; +} +/** QueryProposalResponse is the response type for the Query/Proposal RPC method. */ +export interface QueryProposalResponseSDKType { + proposal: ProposalSDKType; +} +/** QueryProposalsRequest is the request type for the Query/Proposals RPC method. */ +export interface QueryProposalsRequest { + /** proposal_status defines the status of the proposals. */ + proposalStatus: ProposalStatus; + /** voter defines the voter address for the proposals. */ + voter: string; + /** depositor defines the deposit addresses from the proposals. */ + depositor: string; + /** pagination defines an optional pagination for the request. */ + pagination?: PageRequest; +} +export interface QueryProposalsRequestProtoMsg { + typeUrl: "/cosmos.gov.v1beta1.QueryProposalsRequest"; + value: Uint8Array; +} +/** QueryProposalsRequest is the request type for the Query/Proposals RPC method. */ +export interface QueryProposalsRequestSDKType { + proposal_status: ProposalStatus; + voter: string; + depositor: string; + pagination?: PageRequestSDKType; +} +/** + * QueryProposalsResponse is the response type for the Query/Proposals RPC + * method. + */ +export interface QueryProposalsResponse { + proposals: Proposal[]; + /** pagination defines the pagination in the response. */ + pagination?: PageResponse; +} +export interface QueryProposalsResponseProtoMsg { + typeUrl: "/cosmos.gov.v1beta1.QueryProposalsResponse"; + value: Uint8Array; +} +/** + * QueryProposalsResponse is the response type for the Query/Proposals RPC + * method. + */ +export interface QueryProposalsResponseSDKType { + proposals: ProposalSDKType[]; + pagination?: PageResponseSDKType; +} +/** QueryVoteRequest is the request type for the Query/Vote RPC method. */ +export interface QueryVoteRequest { + /** proposal_id defines the unique id of the proposal. */ + proposalId: bigint; + /** voter defines the oter address for the proposals. */ + voter: string; +} +export interface QueryVoteRequestProtoMsg { + typeUrl: "/cosmos.gov.v1beta1.QueryVoteRequest"; + value: Uint8Array; +} +/** QueryVoteRequest is the request type for the Query/Vote RPC method. */ +export interface QueryVoteRequestSDKType { + proposal_id: bigint; + voter: string; +} +/** QueryVoteResponse is the response type for the Query/Vote RPC method. */ +export interface QueryVoteResponse { + /** vote defined the queried vote. */ + vote: Vote; +} +export interface QueryVoteResponseProtoMsg { + typeUrl: "/cosmos.gov.v1beta1.QueryVoteResponse"; + value: Uint8Array; +} +/** QueryVoteResponse is the response type for the Query/Vote RPC method. */ +export interface QueryVoteResponseSDKType { + vote: VoteSDKType; +} +/** QueryVotesRequest is the request type for the Query/Votes RPC method. */ +export interface QueryVotesRequest { + /** proposal_id defines the unique id of the proposal. */ + proposalId: bigint; + /** pagination defines an optional pagination for the request. */ + pagination?: PageRequest; +} +export interface QueryVotesRequestProtoMsg { + typeUrl: "/cosmos.gov.v1beta1.QueryVotesRequest"; + value: Uint8Array; +} +/** QueryVotesRequest is the request type for the Query/Votes RPC method. */ +export interface QueryVotesRequestSDKType { + proposal_id: bigint; + pagination?: PageRequestSDKType; +} +/** QueryVotesResponse is the response type for the Query/Votes RPC method. */ +export interface QueryVotesResponse { + /** votes defined the queried votes. */ + votes: Vote[]; + /** pagination defines the pagination in the response. */ + pagination?: PageResponse; +} +export interface QueryVotesResponseProtoMsg { + typeUrl: "/cosmos.gov.v1beta1.QueryVotesResponse"; + value: Uint8Array; +} +/** QueryVotesResponse is the response type for the Query/Votes RPC method. */ +export interface QueryVotesResponseSDKType { + votes: VoteSDKType[]; + pagination?: PageResponseSDKType; +} +/** QueryParamsRequest is the request type for the Query/Params RPC method. */ +export interface QueryParamsRequest { + /** + * params_type defines which parameters to query for, can be one of "voting", + * "tallying" or "deposit". + */ + paramsType: string; +} +export interface QueryParamsRequestProtoMsg { + typeUrl: "/cosmos.gov.v1beta1.QueryParamsRequest"; + value: Uint8Array; +} +/** QueryParamsRequest is the request type for the Query/Params RPC method. */ +export interface QueryParamsRequestSDKType { + params_type: string; +} +/** QueryParamsResponse is the response type for the Query/Params RPC method. */ +export interface QueryParamsResponse { + /** voting_params defines the parameters related to voting. */ + votingParams: VotingParams; + /** deposit_params defines the parameters related to deposit. */ + depositParams: DepositParams; + /** tally_params defines the parameters related to tally. */ + tallyParams: TallyParams; +} +export interface QueryParamsResponseProtoMsg { + typeUrl: "/cosmos.gov.v1beta1.QueryParamsResponse"; + value: Uint8Array; +} +/** QueryParamsResponse is the response type for the Query/Params RPC method. */ +export interface QueryParamsResponseSDKType { + voting_params: VotingParamsSDKType; + deposit_params: DepositParamsSDKType; + tally_params: TallyParamsSDKType; +} +/** QueryDepositRequest is the request type for the Query/Deposit RPC method. */ +export interface QueryDepositRequest { + /** proposal_id defines the unique id of the proposal. */ + proposalId: bigint; + /** depositor defines the deposit addresses from the proposals. */ + depositor: string; +} +export interface QueryDepositRequestProtoMsg { + typeUrl: "/cosmos.gov.v1beta1.QueryDepositRequest"; + value: Uint8Array; +} +/** QueryDepositRequest is the request type for the Query/Deposit RPC method. */ +export interface QueryDepositRequestSDKType { + proposal_id: bigint; + depositor: string; +} +/** QueryDepositResponse is the response type for the Query/Deposit RPC method. */ +export interface QueryDepositResponse { + /** deposit defines the requested deposit. */ + deposit: Deposit; +} +export interface QueryDepositResponseProtoMsg { + typeUrl: "/cosmos.gov.v1beta1.QueryDepositResponse"; + value: Uint8Array; +} +/** QueryDepositResponse is the response type for the Query/Deposit RPC method. */ +export interface QueryDepositResponseSDKType { + deposit: DepositSDKType; +} +/** QueryDepositsRequest is the request type for the Query/Deposits RPC method. */ +export interface QueryDepositsRequest { + /** proposal_id defines the unique id of the proposal. */ + proposalId: bigint; + /** pagination defines an optional pagination for the request. */ + pagination?: PageRequest; +} +export interface QueryDepositsRequestProtoMsg { + typeUrl: "/cosmos.gov.v1beta1.QueryDepositsRequest"; + value: Uint8Array; +} +/** QueryDepositsRequest is the request type for the Query/Deposits RPC method. */ +export interface QueryDepositsRequestSDKType { + proposal_id: bigint; + pagination?: PageRequestSDKType; +} +/** QueryDepositsResponse is the response type for the Query/Deposits RPC method. */ +export interface QueryDepositsResponse { + deposits: Deposit[]; + /** pagination defines the pagination in the response. */ + pagination?: PageResponse; +} +export interface QueryDepositsResponseProtoMsg { + typeUrl: "/cosmos.gov.v1beta1.QueryDepositsResponse"; + value: Uint8Array; +} +/** QueryDepositsResponse is the response type for the Query/Deposits RPC method. */ +export interface QueryDepositsResponseSDKType { + deposits: DepositSDKType[]; + pagination?: PageResponseSDKType; +} +/** QueryTallyResultRequest is the request type for the Query/Tally RPC method. */ +export interface QueryTallyResultRequest { + /** proposal_id defines the unique id of the proposal. */ + proposalId: bigint; +} +export interface QueryTallyResultRequestProtoMsg { + typeUrl: "/cosmos.gov.v1beta1.QueryTallyResultRequest"; + value: Uint8Array; +} +/** QueryTallyResultRequest is the request type for the Query/Tally RPC method. */ +export interface QueryTallyResultRequestSDKType { + proposal_id: bigint; +} +/** QueryTallyResultResponse is the response type for the Query/Tally RPC method. */ +export interface QueryTallyResultResponse { + /** tally defines the requested tally. */ + tally: TallyResult; +} +export interface QueryTallyResultResponseProtoMsg { + typeUrl: "/cosmos.gov.v1beta1.QueryTallyResultResponse"; + value: Uint8Array; +} +/** QueryTallyResultResponse is the response type for the Query/Tally RPC method. */ +export interface QueryTallyResultResponseSDKType { + tally: TallyResultSDKType; +} +function createBaseQueryProposalRequest(): QueryProposalRequest { + return { + proposalId: BigInt(0) + }; +} +export const QueryProposalRequest = { + typeUrl: "/cosmos.gov.v1beta1.QueryProposalRequest", + encode(message: QueryProposalRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.proposalId !== undefined) { + writer.uint32(8).uint64(message.proposalId); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryProposalRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryProposalRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.proposalId = reader.uint64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryProposalRequest { + const obj = createBaseQueryProposalRequest(); + if (isSet(object.proposalId)) obj.proposalId = BigInt(object.proposalId.toString()); + return obj; + }, + toJSON(message: QueryProposalRequest): JsonSafe { + const obj: any = {}; + message.proposalId !== undefined && (obj.proposalId = (message.proposalId || BigInt(0)).toString()); + return obj; + }, + fromPartial(object: DeepPartial): QueryProposalRequest { + const message = createBaseQueryProposalRequest(); + if (object.proposalId !== undefined && object.proposalId !== null) { + message.proposalId = BigInt(object.proposalId.toString()); + } + return message; + }, + fromSDK(object: QueryProposalRequestSDKType): QueryProposalRequest { + return { + proposalId: object?.proposal_id + }; + }, + fromSDKJSON(object: any): QueryProposalRequestSDKType { + return { + proposal_id: isSet(object.proposal_id) ? BigInt(object.proposal_id.toString()) : BigInt(0) + }; + }, + toSDK(message: QueryProposalRequest): QueryProposalRequestSDKType { + const obj: any = {}; + obj.proposal_id = message.proposalId; + return obj; + }, + fromAmino(object: QueryProposalRequestAmino): QueryProposalRequest { + const message = createBaseQueryProposalRequest(); + if (object.proposal_id !== undefined && object.proposal_id !== null) { + message.proposalId = BigInt(object.proposal_id); + } + return message; + }, + toAmino(message: QueryProposalRequest): QueryProposalRequestAmino { + const obj: any = {}; + obj.proposal_id = message.proposalId !== BigInt(0) ? message.proposalId?.toString() : undefined; + return obj; + }, + fromAminoMsg(object: QueryProposalRequestAminoMsg): QueryProposalRequest { + return QueryProposalRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryProposalRequest): QueryProposalRequestAminoMsg { + return { + type: "cosmos-sdk/QueryProposalRequest", + value: QueryProposalRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryProposalRequestProtoMsg): QueryProposalRequest { + return QueryProposalRequest.decode(message.value); + }, + toProto(message: QueryProposalRequest): Uint8Array { + return QueryProposalRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryProposalRequest): QueryProposalRequestProtoMsg { + return { + typeUrl: "/cosmos.gov.v1beta1.QueryProposalRequest", + value: QueryProposalRequest.encode(message).finish() + }; + } +}; +function createBaseQueryProposalResponse(): QueryProposalResponse { + return { + proposal: Proposal.fromPartial({}) + }; +} +export const QueryProposalResponse = { + typeUrl: "/cosmos.gov.v1beta1.QueryProposalResponse", + encode(message: QueryProposalResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.proposal !== undefined) { + Proposal.encode(message.proposal, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryProposalResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryProposalResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.proposal = Proposal.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryProposalResponse { + const obj = createBaseQueryProposalResponse(); + if (isSet(object.proposal)) obj.proposal = Proposal.fromJSON(object.proposal); + return obj; + }, + toJSON(message: QueryProposalResponse): JsonSafe { + const obj: any = {}; + message.proposal !== undefined && (obj.proposal = message.proposal ? Proposal.toJSON(message.proposal) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryProposalResponse { + const message = createBaseQueryProposalResponse(); + if (object.proposal !== undefined && object.proposal !== null) { + message.proposal = Proposal.fromPartial(object.proposal); + } + return message; + }, + fromSDK(object: QueryProposalResponseSDKType): QueryProposalResponse { + return { + proposal: object.proposal ? Proposal.fromSDK(object.proposal) : undefined + }; + }, + fromSDKJSON(object: any): QueryProposalResponseSDKType { + return { + proposal: isSet(object.proposal) ? Proposal.fromSDKJSON(object.proposal) : undefined + }; + }, + toSDK(message: QueryProposalResponse): QueryProposalResponseSDKType { + const obj: any = {}; + message.proposal !== undefined && (obj.proposal = message.proposal ? Proposal.toSDK(message.proposal) : undefined); + return obj; + }, + fromAmino(object: QueryProposalResponseAmino): QueryProposalResponse { + const message = createBaseQueryProposalResponse(); + if (object.proposal !== undefined && object.proposal !== null) { + message.proposal = Proposal.fromAmino(object.proposal); + } + return message; + }, + toAmino(message: QueryProposalResponse): QueryProposalResponseAmino { + const obj: any = {}; + obj.proposal = message.proposal ? Proposal.toAmino(message.proposal) : undefined; + return obj; + }, + fromAminoMsg(object: QueryProposalResponseAminoMsg): QueryProposalResponse { + return QueryProposalResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryProposalResponse): QueryProposalResponseAminoMsg { + return { + type: "cosmos-sdk/QueryProposalResponse", + value: QueryProposalResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryProposalResponseProtoMsg): QueryProposalResponse { + return QueryProposalResponse.decode(message.value); + }, + toProto(message: QueryProposalResponse): Uint8Array { + return QueryProposalResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryProposalResponse): QueryProposalResponseProtoMsg { + return { + typeUrl: "/cosmos.gov.v1beta1.QueryProposalResponse", + value: QueryProposalResponse.encode(message).finish() + }; + } +}; +function createBaseQueryProposalsRequest(): QueryProposalsRequest { + return { + proposalStatus: 0, + voter: "", + depositor: "", + pagination: undefined + }; +} +export const QueryProposalsRequest = { + typeUrl: "/cosmos.gov.v1beta1.QueryProposalsRequest", + encode(message: QueryProposalsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.proposalStatus !== 0) { + writer.uint32(8).int32(message.proposalStatus); + } + if (message.voter !== undefined) { + writer.uint32(18).string(message.voter); + } + if (message.depositor !== undefined) { + writer.uint32(26).string(message.depositor); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryProposalsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryProposalsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.proposalStatus = (reader.int32() as any); + break; + case 2: + message.voter = reader.string(); + break; + case 3: + message.depositor = reader.string(); + break; + case 4: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryProposalsRequest { + const obj = createBaseQueryProposalsRequest(); + if (isSet(object.proposalStatus)) obj.proposalStatus = proposalStatusFromJSON(object.proposalStatus); + if (isSet(object.voter)) obj.voter = String(object.voter); + if (isSet(object.depositor)) obj.depositor = String(object.depositor); + if (isSet(object.pagination)) obj.pagination = PageRequest.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryProposalsRequest): JsonSafe { + const obj: any = {}; + message.proposalStatus !== undefined && (obj.proposalStatus = proposalStatusToJSON(message.proposalStatus)); + message.voter !== undefined && (obj.voter = message.voter); + message.depositor !== undefined && (obj.depositor = message.depositor); + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryProposalsRequest { + const message = createBaseQueryProposalsRequest(); + message.proposalStatus = object.proposalStatus ?? 0; + message.voter = object.voter ?? ""; + message.depositor = object.depositor ?? ""; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryProposalsRequestSDKType): QueryProposalsRequest { + return { + proposalStatus: isSet(object.proposal_status) ? proposalStatusFromJSON(object.proposal_status) : -1, + voter: object?.voter, + depositor: object?.depositor, + pagination: object.pagination ? PageRequest.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryProposalsRequestSDKType { + return { + proposal_status: isSet(object.proposal_status) ? proposalStatusFromJSON(object.proposal_status) : -1, + voter: isSet(object.voter) ? String(object.voter) : "", + depositor: isSet(object.depositor) ? String(object.depositor) : "", + pagination: isSet(object.pagination) ? PageRequest.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryProposalsRequest): QueryProposalsRequestSDKType { + const obj: any = {}; + message.proposalStatus !== undefined && (obj.proposal_status = proposalStatusToJSON(message.proposalStatus)); + obj.voter = message.voter; + obj.depositor = message.depositor; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryProposalsRequestAmino): QueryProposalsRequest { + const message = createBaseQueryProposalsRequest(); + if (object.proposal_status !== undefined && object.proposal_status !== null) { + message.proposalStatus = object.proposal_status; + } + if (object.voter !== undefined && object.voter !== null) { + message.voter = object.voter; + } + if (object.depositor !== undefined && object.depositor !== null) { + message.depositor = object.depositor; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryProposalsRequest): QueryProposalsRequestAmino { + const obj: any = {}; + obj.proposal_status = message.proposalStatus === 0 ? undefined : message.proposalStatus; + obj.voter = message.voter === "" ? undefined : message.voter; + obj.depositor = message.depositor === "" ? undefined : message.depositor; + obj.pagination = message.pagination ? PageRequest.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryProposalsRequestAminoMsg): QueryProposalsRequest { + return QueryProposalsRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryProposalsRequest): QueryProposalsRequestAminoMsg { + return { + type: "cosmos-sdk/QueryProposalsRequest", + value: QueryProposalsRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryProposalsRequestProtoMsg): QueryProposalsRequest { + return QueryProposalsRequest.decode(message.value); + }, + toProto(message: QueryProposalsRequest): Uint8Array { + return QueryProposalsRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryProposalsRequest): QueryProposalsRequestProtoMsg { + return { + typeUrl: "/cosmos.gov.v1beta1.QueryProposalsRequest", + value: QueryProposalsRequest.encode(message).finish() + }; + } +}; +function createBaseQueryProposalsResponse(): QueryProposalsResponse { + return { + proposals: [], + pagination: undefined + }; +} +export const QueryProposalsResponse = { + typeUrl: "/cosmos.gov.v1beta1.QueryProposalsResponse", + encode(message: QueryProposalsResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.proposals) { + Proposal.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryProposalsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryProposalsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.proposals.push(Proposal.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryProposalsResponse { + const obj = createBaseQueryProposalsResponse(); + if (Array.isArray(object?.proposals)) obj.proposals = object.proposals.map((e: any) => Proposal.fromJSON(e)); + if (isSet(object.pagination)) obj.pagination = PageResponse.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryProposalsResponse): JsonSafe { + const obj: any = {}; + if (message.proposals) { + obj.proposals = message.proposals.map(e => e ? Proposal.toJSON(e) : undefined); + } else { + obj.proposals = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryProposalsResponse { + const message = createBaseQueryProposalsResponse(); + message.proposals = object.proposals?.map(e => Proposal.fromPartial(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryProposalsResponseSDKType): QueryProposalsResponse { + return { + proposals: Array.isArray(object?.proposals) ? object.proposals.map((e: any) => Proposal.fromSDK(e)) : [], + pagination: object.pagination ? PageResponse.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryProposalsResponseSDKType { + return { + proposals: Array.isArray(object?.proposals) ? object.proposals.map((e: any) => Proposal.fromSDKJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryProposalsResponse): QueryProposalsResponseSDKType { + const obj: any = {}; + if (message.proposals) { + obj.proposals = message.proposals.map(e => e ? Proposal.toSDK(e) : undefined); + } else { + obj.proposals = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryProposalsResponseAmino): QueryProposalsResponse { + const message = createBaseQueryProposalsResponse(); + message.proposals = object.proposals?.map(e => Proposal.fromAmino(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryProposalsResponse): QueryProposalsResponseAmino { + const obj: any = {}; + if (message.proposals) { + obj.proposals = message.proposals.map(e => e ? Proposal.toAmino(e) : undefined); + } else { + obj.proposals = message.proposals; + } + obj.pagination = message.pagination ? PageResponse.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryProposalsResponseAminoMsg): QueryProposalsResponse { + return QueryProposalsResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryProposalsResponse): QueryProposalsResponseAminoMsg { + return { + type: "cosmos-sdk/QueryProposalsResponse", + value: QueryProposalsResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryProposalsResponseProtoMsg): QueryProposalsResponse { + return QueryProposalsResponse.decode(message.value); + }, + toProto(message: QueryProposalsResponse): Uint8Array { + return QueryProposalsResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryProposalsResponse): QueryProposalsResponseProtoMsg { + return { + typeUrl: "/cosmos.gov.v1beta1.QueryProposalsResponse", + value: QueryProposalsResponse.encode(message).finish() + }; + } +}; +function createBaseQueryVoteRequest(): QueryVoteRequest { + return { + proposalId: BigInt(0), + voter: "" + }; +} +export const QueryVoteRequest = { + typeUrl: "/cosmos.gov.v1beta1.QueryVoteRequest", + encode(message: QueryVoteRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.proposalId !== undefined) { + writer.uint32(8).uint64(message.proposalId); + } + if (message.voter !== undefined) { + writer.uint32(18).string(message.voter); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryVoteRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryVoteRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.proposalId = reader.uint64(); + break; + case 2: + message.voter = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryVoteRequest { + const obj = createBaseQueryVoteRequest(); + if (isSet(object.proposalId)) obj.proposalId = BigInt(object.proposalId.toString()); + if (isSet(object.voter)) obj.voter = String(object.voter); + return obj; + }, + toJSON(message: QueryVoteRequest): JsonSafe { + const obj: any = {}; + message.proposalId !== undefined && (obj.proposalId = (message.proposalId || BigInt(0)).toString()); + message.voter !== undefined && (obj.voter = message.voter); + return obj; + }, + fromPartial(object: DeepPartial): QueryVoteRequest { + const message = createBaseQueryVoteRequest(); + if (object.proposalId !== undefined && object.proposalId !== null) { + message.proposalId = BigInt(object.proposalId.toString()); + } + message.voter = object.voter ?? ""; + return message; + }, + fromSDK(object: QueryVoteRequestSDKType): QueryVoteRequest { + return { + proposalId: object?.proposal_id, + voter: object?.voter + }; + }, + fromSDKJSON(object: any): QueryVoteRequestSDKType { + return { + proposal_id: isSet(object.proposal_id) ? BigInt(object.proposal_id.toString()) : BigInt(0), + voter: isSet(object.voter) ? String(object.voter) : "" + }; + }, + toSDK(message: QueryVoteRequest): QueryVoteRequestSDKType { + const obj: any = {}; + obj.proposal_id = message.proposalId; + obj.voter = message.voter; + return obj; + }, + fromAmino(object: QueryVoteRequestAmino): QueryVoteRequest { + const message = createBaseQueryVoteRequest(); + if (object.proposal_id !== undefined && object.proposal_id !== null) { + message.proposalId = BigInt(object.proposal_id); + } + if (object.voter !== undefined && object.voter !== null) { + message.voter = object.voter; + } + return message; + }, + toAmino(message: QueryVoteRequest): QueryVoteRequestAmino { + const obj: any = {}; + obj.proposal_id = message.proposalId !== BigInt(0) ? message.proposalId?.toString() : undefined; + obj.voter = message.voter === "" ? undefined : message.voter; + return obj; + }, + fromAminoMsg(object: QueryVoteRequestAminoMsg): QueryVoteRequest { + return QueryVoteRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryVoteRequest): QueryVoteRequestAminoMsg { + return { + type: "cosmos-sdk/QueryVoteRequest", + value: QueryVoteRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryVoteRequestProtoMsg): QueryVoteRequest { + return QueryVoteRequest.decode(message.value); + }, + toProto(message: QueryVoteRequest): Uint8Array { + return QueryVoteRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryVoteRequest): QueryVoteRequestProtoMsg { + return { + typeUrl: "/cosmos.gov.v1beta1.QueryVoteRequest", + value: QueryVoteRequest.encode(message).finish() + }; + } +}; +function createBaseQueryVoteResponse(): QueryVoteResponse { + return { + vote: Vote.fromPartial({}) + }; +} +export const QueryVoteResponse = { + typeUrl: "/cosmos.gov.v1beta1.QueryVoteResponse", + encode(message: QueryVoteResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.vote !== undefined) { + Vote.encode(message.vote, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryVoteResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryVoteResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.vote = Vote.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryVoteResponse { + const obj = createBaseQueryVoteResponse(); + if (isSet(object.vote)) obj.vote = Vote.fromJSON(object.vote); + return obj; + }, + toJSON(message: QueryVoteResponse): JsonSafe { + const obj: any = {}; + message.vote !== undefined && (obj.vote = message.vote ? Vote.toJSON(message.vote) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryVoteResponse { + const message = createBaseQueryVoteResponse(); + if (object.vote !== undefined && object.vote !== null) { + message.vote = Vote.fromPartial(object.vote); + } + return message; + }, + fromSDK(object: QueryVoteResponseSDKType): QueryVoteResponse { + return { + vote: object.vote ? Vote.fromSDK(object.vote) : undefined + }; + }, + fromSDKJSON(object: any): QueryVoteResponseSDKType { + return { + vote: isSet(object.vote) ? Vote.fromSDKJSON(object.vote) : undefined + }; + }, + toSDK(message: QueryVoteResponse): QueryVoteResponseSDKType { + const obj: any = {}; + message.vote !== undefined && (obj.vote = message.vote ? Vote.toSDK(message.vote) : undefined); + return obj; + }, + fromAmino(object: QueryVoteResponseAmino): QueryVoteResponse { + const message = createBaseQueryVoteResponse(); + if (object.vote !== undefined && object.vote !== null) { + message.vote = Vote.fromAmino(object.vote); + } + return message; + }, + toAmino(message: QueryVoteResponse): QueryVoteResponseAmino { + const obj: any = {}; + obj.vote = message.vote ? Vote.toAmino(message.vote) : undefined; + return obj; + }, + fromAminoMsg(object: QueryVoteResponseAminoMsg): QueryVoteResponse { + return QueryVoteResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryVoteResponse): QueryVoteResponseAminoMsg { + return { + type: "cosmos-sdk/QueryVoteResponse", + value: QueryVoteResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryVoteResponseProtoMsg): QueryVoteResponse { + return QueryVoteResponse.decode(message.value); + }, + toProto(message: QueryVoteResponse): Uint8Array { + return QueryVoteResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryVoteResponse): QueryVoteResponseProtoMsg { + return { + typeUrl: "/cosmos.gov.v1beta1.QueryVoteResponse", + value: QueryVoteResponse.encode(message).finish() + }; + } +}; +function createBaseQueryVotesRequest(): QueryVotesRequest { + return { + proposalId: BigInt(0), + pagination: undefined + }; +} +export const QueryVotesRequest = { + typeUrl: "/cosmos.gov.v1beta1.QueryVotesRequest", + encode(message: QueryVotesRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.proposalId !== undefined) { + writer.uint32(8).uint64(message.proposalId); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryVotesRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryVotesRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.proposalId = reader.uint64(); + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryVotesRequest { + const obj = createBaseQueryVotesRequest(); + if (isSet(object.proposalId)) obj.proposalId = BigInt(object.proposalId.toString()); + if (isSet(object.pagination)) obj.pagination = PageRequest.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryVotesRequest): JsonSafe { + const obj: any = {}; + message.proposalId !== undefined && (obj.proposalId = (message.proposalId || BigInt(0)).toString()); + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryVotesRequest { + const message = createBaseQueryVotesRequest(); + if (object.proposalId !== undefined && object.proposalId !== null) { + message.proposalId = BigInt(object.proposalId.toString()); + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryVotesRequestSDKType): QueryVotesRequest { + return { + proposalId: object?.proposal_id, + pagination: object.pagination ? PageRequest.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryVotesRequestSDKType { + return { + proposal_id: isSet(object.proposal_id) ? BigInt(object.proposal_id.toString()) : BigInt(0), + pagination: isSet(object.pagination) ? PageRequest.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryVotesRequest): QueryVotesRequestSDKType { + const obj: any = {}; + obj.proposal_id = message.proposalId; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryVotesRequestAmino): QueryVotesRequest { + const message = createBaseQueryVotesRequest(); + if (object.proposal_id !== undefined && object.proposal_id !== null) { + message.proposalId = BigInt(object.proposal_id); + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryVotesRequest): QueryVotesRequestAmino { + const obj: any = {}; + obj.proposal_id = message.proposalId !== BigInt(0) ? message.proposalId?.toString() : undefined; + obj.pagination = message.pagination ? PageRequest.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryVotesRequestAminoMsg): QueryVotesRequest { + return QueryVotesRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryVotesRequest): QueryVotesRequestAminoMsg { + return { + type: "cosmos-sdk/QueryVotesRequest", + value: QueryVotesRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryVotesRequestProtoMsg): QueryVotesRequest { + return QueryVotesRequest.decode(message.value); + }, + toProto(message: QueryVotesRequest): Uint8Array { + return QueryVotesRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryVotesRequest): QueryVotesRequestProtoMsg { + return { + typeUrl: "/cosmos.gov.v1beta1.QueryVotesRequest", + value: QueryVotesRequest.encode(message).finish() + }; + } +}; +function createBaseQueryVotesResponse(): QueryVotesResponse { + return { + votes: [], + pagination: undefined + }; +} +export const QueryVotesResponse = { + typeUrl: "/cosmos.gov.v1beta1.QueryVotesResponse", + encode(message: QueryVotesResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.votes) { + Vote.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryVotesResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryVotesResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.votes.push(Vote.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryVotesResponse { + const obj = createBaseQueryVotesResponse(); + if (Array.isArray(object?.votes)) obj.votes = object.votes.map((e: any) => Vote.fromJSON(e)); + if (isSet(object.pagination)) obj.pagination = PageResponse.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryVotesResponse): JsonSafe { + const obj: any = {}; + if (message.votes) { + obj.votes = message.votes.map(e => e ? Vote.toJSON(e) : undefined); + } else { + obj.votes = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryVotesResponse { + const message = createBaseQueryVotesResponse(); + message.votes = object.votes?.map(e => Vote.fromPartial(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryVotesResponseSDKType): QueryVotesResponse { + return { + votes: Array.isArray(object?.votes) ? object.votes.map((e: any) => Vote.fromSDK(e)) : [], + pagination: object.pagination ? PageResponse.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryVotesResponseSDKType { + return { + votes: Array.isArray(object?.votes) ? object.votes.map((e: any) => Vote.fromSDKJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryVotesResponse): QueryVotesResponseSDKType { + const obj: any = {}; + if (message.votes) { + obj.votes = message.votes.map(e => e ? Vote.toSDK(e) : undefined); + } else { + obj.votes = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryVotesResponseAmino): QueryVotesResponse { + const message = createBaseQueryVotesResponse(); + message.votes = object.votes?.map(e => Vote.fromAmino(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryVotesResponse): QueryVotesResponseAmino { + const obj: any = {}; + if (message.votes) { + obj.votes = message.votes.map(e => e ? Vote.toAmino(e) : undefined); + } else { + obj.votes = message.votes; + } + obj.pagination = message.pagination ? PageResponse.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryVotesResponseAminoMsg): QueryVotesResponse { + return QueryVotesResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryVotesResponse): QueryVotesResponseAminoMsg { + return { + type: "cosmos-sdk/QueryVotesResponse", + value: QueryVotesResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryVotesResponseProtoMsg): QueryVotesResponse { + return QueryVotesResponse.decode(message.value); + }, + toProto(message: QueryVotesResponse): Uint8Array { + return QueryVotesResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryVotesResponse): QueryVotesResponseProtoMsg { + return { + typeUrl: "/cosmos.gov.v1beta1.QueryVotesResponse", + value: QueryVotesResponse.encode(message).finish() + }; + } +}; +function createBaseQueryParamsRequest(): QueryParamsRequest { + return { + paramsType: "" + }; +} +export const QueryParamsRequest = { + typeUrl: "/cosmos.gov.v1beta1.QueryParamsRequest", + encode(message: QueryParamsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.paramsType !== undefined) { + writer.uint32(10).string(message.paramsType); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryParamsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryParamsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.paramsType = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryParamsRequest { + const obj = createBaseQueryParamsRequest(); + if (isSet(object.paramsType)) obj.paramsType = String(object.paramsType); + return obj; + }, + toJSON(message: QueryParamsRequest): JsonSafe { + const obj: any = {}; + message.paramsType !== undefined && (obj.paramsType = message.paramsType); + return obj; + }, + fromPartial(object: DeepPartial): QueryParamsRequest { + const message = createBaseQueryParamsRequest(); + message.paramsType = object.paramsType ?? ""; + return message; + }, + fromSDK(object: QueryParamsRequestSDKType): QueryParamsRequest { + return { + paramsType: object?.params_type + }; + }, + fromSDKJSON(object: any): QueryParamsRequestSDKType { + return { + params_type: isSet(object.params_type) ? String(object.params_type) : "" + }; + }, + toSDK(message: QueryParamsRequest): QueryParamsRequestSDKType { + const obj: any = {}; + obj.params_type = message.paramsType; + return obj; + }, + fromAmino(object: QueryParamsRequestAmino): QueryParamsRequest { + const message = createBaseQueryParamsRequest(); + if (object.params_type !== undefined && object.params_type !== null) { + message.paramsType = object.params_type; + } + return message; + }, + toAmino(message: QueryParamsRequest): QueryParamsRequestAmino { + const obj: any = {}; + obj.params_type = message.paramsType === "" ? undefined : message.paramsType; + return obj; + }, + fromAminoMsg(object: QueryParamsRequestAminoMsg): QueryParamsRequest { + return QueryParamsRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryParamsRequest): QueryParamsRequestAminoMsg { + return { + type: "cosmos-sdk/QueryParamsRequest", + value: QueryParamsRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryParamsRequestProtoMsg): QueryParamsRequest { + return QueryParamsRequest.decode(message.value); + }, + toProto(message: QueryParamsRequest): Uint8Array { + return QueryParamsRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryParamsRequest): QueryParamsRequestProtoMsg { + return { + typeUrl: "/cosmos.gov.v1beta1.QueryParamsRequest", + value: QueryParamsRequest.encode(message).finish() + }; + } +}; +function createBaseQueryParamsResponse(): QueryParamsResponse { + return { + votingParams: VotingParams.fromPartial({}), + depositParams: DepositParams.fromPartial({}), + tallyParams: TallyParams.fromPartial({}) + }; +} +export const QueryParamsResponse = { + typeUrl: "/cosmos.gov.v1beta1.QueryParamsResponse", + encode(message: QueryParamsResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.votingParams !== undefined) { + VotingParams.encode(message.votingParams, writer.uint32(10).fork()).ldelim(); + } + if (message.depositParams !== undefined) { + DepositParams.encode(message.depositParams, writer.uint32(18).fork()).ldelim(); + } + if (message.tallyParams !== undefined) { + TallyParams.encode(message.tallyParams, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryParamsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryParamsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.votingParams = VotingParams.decode(reader, reader.uint32()); + break; + case 2: + message.depositParams = DepositParams.decode(reader, reader.uint32()); + break; + case 3: + message.tallyParams = TallyParams.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryParamsResponse { + const obj = createBaseQueryParamsResponse(); + if (isSet(object.votingParams)) obj.votingParams = VotingParams.fromJSON(object.votingParams); + if (isSet(object.depositParams)) obj.depositParams = DepositParams.fromJSON(object.depositParams); + if (isSet(object.tallyParams)) obj.tallyParams = TallyParams.fromJSON(object.tallyParams); + return obj; + }, + toJSON(message: QueryParamsResponse): JsonSafe { + const obj: any = {}; + message.votingParams !== undefined && (obj.votingParams = message.votingParams ? VotingParams.toJSON(message.votingParams) : undefined); + message.depositParams !== undefined && (obj.depositParams = message.depositParams ? DepositParams.toJSON(message.depositParams) : undefined); + message.tallyParams !== undefined && (obj.tallyParams = message.tallyParams ? TallyParams.toJSON(message.tallyParams) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryParamsResponse { + const message = createBaseQueryParamsResponse(); + if (object.votingParams !== undefined && object.votingParams !== null) { + message.votingParams = VotingParams.fromPartial(object.votingParams); + } + if (object.depositParams !== undefined && object.depositParams !== null) { + message.depositParams = DepositParams.fromPartial(object.depositParams); + } + if (object.tallyParams !== undefined && object.tallyParams !== null) { + message.tallyParams = TallyParams.fromPartial(object.tallyParams); + } + return message; + }, + fromSDK(object: QueryParamsResponseSDKType): QueryParamsResponse { + return { + votingParams: object.voting_params ? VotingParams.fromSDK(object.voting_params) : undefined, + depositParams: object.deposit_params ? DepositParams.fromSDK(object.deposit_params) : undefined, + tallyParams: object.tally_params ? TallyParams.fromSDK(object.tally_params) : undefined + }; + }, + fromSDKJSON(object: any): QueryParamsResponseSDKType { + return { + voting_params: isSet(object.voting_params) ? VotingParams.fromSDKJSON(object.voting_params) : undefined, + deposit_params: isSet(object.deposit_params) ? DepositParams.fromSDKJSON(object.deposit_params) : undefined, + tally_params: isSet(object.tally_params) ? TallyParams.fromSDKJSON(object.tally_params) : undefined + }; + }, + toSDK(message: QueryParamsResponse): QueryParamsResponseSDKType { + const obj: any = {}; + message.votingParams !== undefined && (obj.voting_params = message.votingParams ? VotingParams.toSDK(message.votingParams) : undefined); + message.depositParams !== undefined && (obj.deposit_params = message.depositParams ? DepositParams.toSDK(message.depositParams) : undefined); + message.tallyParams !== undefined && (obj.tally_params = message.tallyParams ? TallyParams.toSDK(message.tallyParams) : undefined); + return obj; + }, + fromAmino(object: QueryParamsResponseAmino): QueryParamsResponse { + const message = createBaseQueryParamsResponse(); + if (object.voting_params !== undefined && object.voting_params !== null) { + message.votingParams = VotingParams.fromAmino(object.voting_params); + } + if (object.deposit_params !== undefined && object.deposit_params !== null) { + message.depositParams = DepositParams.fromAmino(object.deposit_params); + } + if (object.tally_params !== undefined && object.tally_params !== null) { + message.tallyParams = TallyParams.fromAmino(object.tally_params); + } + return message; + }, + toAmino(message: QueryParamsResponse): QueryParamsResponseAmino { + const obj: any = {}; + obj.voting_params = message.votingParams ? VotingParams.toAmino(message.votingParams) : undefined; + obj.deposit_params = message.depositParams ? DepositParams.toAmino(message.depositParams) : undefined; + obj.tally_params = message.tallyParams ? TallyParams.toAmino(message.tallyParams) : undefined; + return obj; + }, + fromAminoMsg(object: QueryParamsResponseAminoMsg): QueryParamsResponse { + return QueryParamsResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryParamsResponse): QueryParamsResponseAminoMsg { + return { + type: "cosmos-sdk/QueryParamsResponse", + value: QueryParamsResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryParamsResponseProtoMsg): QueryParamsResponse { + return QueryParamsResponse.decode(message.value); + }, + toProto(message: QueryParamsResponse): Uint8Array { + return QueryParamsResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryParamsResponse): QueryParamsResponseProtoMsg { + return { + typeUrl: "/cosmos.gov.v1beta1.QueryParamsResponse", + value: QueryParamsResponse.encode(message).finish() + }; + } +}; +function createBaseQueryDepositRequest(): QueryDepositRequest { + return { + proposalId: BigInt(0), + depositor: "" + }; +} +export const QueryDepositRequest = { + typeUrl: "/cosmos.gov.v1beta1.QueryDepositRequest", + encode(message: QueryDepositRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.proposalId !== undefined) { + writer.uint32(8).uint64(message.proposalId); + } + if (message.depositor !== undefined) { + writer.uint32(18).string(message.depositor); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryDepositRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryDepositRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.proposalId = reader.uint64(); + break; + case 2: + message.depositor = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryDepositRequest { + const obj = createBaseQueryDepositRequest(); + if (isSet(object.proposalId)) obj.proposalId = BigInt(object.proposalId.toString()); + if (isSet(object.depositor)) obj.depositor = String(object.depositor); + return obj; + }, + toJSON(message: QueryDepositRequest): JsonSafe { + const obj: any = {}; + message.proposalId !== undefined && (obj.proposalId = (message.proposalId || BigInt(0)).toString()); + message.depositor !== undefined && (obj.depositor = message.depositor); + return obj; + }, + fromPartial(object: DeepPartial): QueryDepositRequest { + const message = createBaseQueryDepositRequest(); + if (object.proposalId !== undefined && object.proposalId !== null) { + message.proposalId = BigInt(object.proposalId.toString()); + } + message.depositor = object.depositor ?? ""; + return message; + }, + fromSDK(object: QueryDepositRequestSDKType): QueryDepositRequest { + return { + proposalId: object?.proposal_id, + depositor: object?.depositor + }; + }, + fromSDKJSON(object: any): QueryDepositRequestSDKType { + return { + proposal_id: isSet(object.proposal_id) ? BigInt(object.proposal_id.toString()) : BigInt(0), + depositor: isSet(object.depositor) ? String(object.depositor) : "" + }; + }, + toSDK(message: QueryDepositRequest): QueryDepositRequestSDKType { + const obj: any = {}; + obj.proposal_id = message.proposalId; + obj.depositor = message.depositor; + return obj; + }, + fromAmino(object: QueryDepositRequestAmino): QueryDepositRequest { + const message = createBaseQueryDepositRequest(); + if (object.proposal_id !== undefined && object.proposal_id !== null) { + message.proposalId = BigInt(object.proposal_id); + } + if (object.depositor !== undefined && object.depositor !== null) { + message.depositor = object.depositor; + } + return message; + }, + toAmino(message: QueryDepositRequest): QueryDepositRequestAmino { + const obj: any = {}; + obj.proposal_id = message.proposalId !== BigInt(0) ? message.proposalId?.toString() : undefined; + obj.depositor = message.depositor === "" ? undefined : message.depositor; + return obj; + }, + fromAminoMsg(object: QueryDepositRequestAminoMsg): QueryDepositRequest { + return QueryDepositRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryDepositRequest): QueryDepositRequestAminoMsg { + return { + type: "cosmos-sdk/QueryDepositRequest", + value: QueryDepositRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryDepositRequestProtoMsg): QueryDepositRequest { + return QueryDepositRequest.decode(message.value); + }, + toProto(message: QueryDepositRequest): Uint8Array { + return QueryDepositRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryDepositRequest): QueryDepositRequestProtoMsg { + return { + typeUrl: "/cosmos.gov.v1beta1.QueryDepositRequest", + value: QueryDepositRequest.encode(message).finish() + }; + } +}; +function createBaseQueryDepositResponse(): QueryDepositResponse { + return { + deposit: Deposit.fromPartial({}) + }; +} +export const QueryDepositResponse = { + typeUrl: "/cosmos.gov.v1beta1.QueryDepositResponse", + encode(message: QueryDepositResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.deposit !== undefined) { + Deposit.encode(message.deposit, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryDepositResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryDepositResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.deposit = Deposit.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryDepositResponse { + const obj = createBaseQueryDepositResponse(); + if (isSet(object.deposit)) obj.deposit = Deposit.fromJSON(object.deposit); + return obj; + }, + toJSON(message: QueryDepositResponse): JsonSafe { + const obj: any = {}; + message.deposit !== undefined && (obj.deposit = message.deposit ? Deposit.toJSON(message.deposit) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryDepositResponse { + const message = createBaseQueryDepositResponse(); + if (object.deposit !== undefined && object.deposit !== null) { + message.deposit = Deposit.fromPartial(object.deposit); + } + return message; + }, + fromSDK(object: QueryDepositResponseSDKType): QueryDepositResponse { + return { + deposit: object.deposit ? Deposit.fromSDK(object.deposit) : undefined + }; + }, + fromSDKJSON(object: any): QueryDepositResponseSDKType { + return { + deposit: isSet(object.deposit) ? Deposit.fromSDKJSON(object.deposit) : undefined + }; + }, + toSDK(message: QueryDepositResponse): QueryDepositResponseSDKType { + const obj: any = {}; + message.deposit !== undefined && (obj.deposit = message.deposit ? Deposit.toSDK(message.deposit) : undefined); + return obj; + }, + fromAmino(object: QueryDepositResponseAmino): QueryDepositResponse { + const message = createBaseQueryDepositResponse(); + if (object.deposit !== undefined && object.deposit !== null) { + message.deposit = Deposit.fromAmino(object.deposit); + } + return message; + }, + toAmino(message: QueryDepositResponse): QueryDepositResponseAmino { + const obj: any = {}; + obj.deposit = message.deposit ? Deposit.toAmino(message.deposit) : undefined; + return obj; + }, + fromAminoMsg(object: QueryDepositResponseAminoMsg): QueryDepositResponse { + return QueryDepositResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryDepositResponse): QueryDepositResponseAminoMsg { + return { + type: "cosmos-sdk/QueryDepositResponse", + value: QueryDepositResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryDepositResponseProtoMsg): QueryDepositResponse { + return QueryDepositResponse.decode(message.value); + }, + toProto(message: QueryDepositResponse): Uint8Array { + return QueryDepositResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryDepositResponse): QueryDepositResponseProtoMsg { + return { + typeUrl: "/cosmos.gov.v1beta1.QueryDepositResponse", + value: QueryDepositResponse.encode(message).finish() + }; + } +}; +function createBaseQueryDepositsRequest(): QueryDepositsRequest { + return { + proposalId: BigInt(0), + pagination: undefined + }; +} +export const QueryDepositsRequest = { + typeUrl: "/cosmos.gov.v1beta1.QueryDepositsRequest", + encode(message: QueryDepositsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.proposalId !== undefined) { + writer.uint32(8).uint64(message.proposalId); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryDepositsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryDepositsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.proposalId = reader.uint64(); + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryDepositsRequest { + const obj = createBaseQueryDepositsRequest(); + if (isSet(object.proposalId)) obj.proposalId = BigInt(object.proposalId.toString()); + if (isSet(object.pagination)) obj.pagination = PageRequest.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryDepositsRequest): JsonSafe { + const obj: any = {}; + message.proposalId !== undefined && (obj.proposalId = (message.proposalId || BigInt(0)).toString()); + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryDepositsRequest { + const message = createBaseQueryDepositsRequest(); + if (object.proposalId !== undefined && object.proposalId !== null) { + message.proposalId = BigInt(object.proposalId.toString()); + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryDepositsRequestSDKType): QueryDepositsRequest { + return { + proposalId: object?.proposal_id, + pagination: object.pagination ? PageRequest.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryDepositsRequestSDKType { + return { + proposal_id: isSet(object.proposal_id) ? BigInt(object.proposal_id.toString()) : BigInt(0), + pagination: isSet(object.pagination) ? PageRequest.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryDepositsRequest): QueryDepositsRequestSDKType { + const obj: any = {}; + obj.proposal_id = message.proposalId; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryDepositsRequestAmino): QueryDepositsRequest { + const message = createBaseQueryDepositsRequest(); + if (object.proposal_id !== undefined && object.proposal_id !== null) { + message.proposalId = BigInt(object.proposal_id); + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryDepositsRequest): QueryDepositsRequestAmino { + const obj: any = {}; + obj.proposal_id = message.proposalId !== BigInt(0) ? message.proposalId?.toString() : undefined; + obj.pagination = message.pagination ? PageRequest.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryDepositsRequestAminoMsg): QueryDepositsRequest { + return QueryDepositsRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryDepositsRequest): QueryDepositsRequestAminoMsg { + return { + type: "cosmos-sdk/QueryDepositsRequest", + value: QueryDepositsRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryDepositsRequestProtoMsg): QueryDepositsRequest { + return QueryDepositsRequest.decode(message.value); + }, + toProto(message: QueryDepositsRequest): Uint8Array { + return QueryDepositsRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryDepositsRequest): QueryDepositsRequestProtoMsg { + return { + typeUrl: "/cosmos.gov.v1beta1.QueryDepositsRequest", + value: QueryDepositsRequest.encode(message).finish() + }; + } +}; +function createBaseQueryDepositsResponse(): QueryDepositsResponse { + return { + deposits: [], + pagination: undefined + }; +} +export const QueryDepositsResponse = { + typeUrl: "/cosmos.gov.v1beta1.QueryDepositsResponse", + encode(message: QueryDepositsResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.deposits) { + Deposit.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryDepositsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryDepositsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.deposits.push(Deposit.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryDepositsResponse { + const obj = createBaseQueryDepositsResponse(); + if (Array.isArray(object?.deposits)) obj.deposits = object.deposits.map((e: any) => Deposit.fromJSON(e)); + if (isSet(object.pagination)) obj.pagination = PageResponse.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryDepositsResponse): JsonSafe { + const obj: any = {}; + if (message.deposits) { + obj.deposits = message.deposits.map(e => e ? Deposit.toJSON(e) : undefined); + } else { + obj.deposits = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryDepositsResponse { + const message = createBaseQueryDepositsResponse(); + message.deposits = object.deposits?.map(e => Deposit.fromPartial(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryDepositsResponseSDKType): QueryDepositsResponse { + return { + deposits: Array.isArray(object?.deposits) ? object.deposits.map((e: any) => Deposit.fromSDK(e)) : [], + pagination: object.pagination ? PageResponse.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryDepositsResponseSDKType { + return { + deposits: Array.isArray(object?.deposits) ? object.deposits.map((e: any) => Deposit.fromSDKJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryDepositsResponse): QueryDepositsResponseSDKType { + const obj: any = {}; + if (message.deposits) { + obj.deposits = message.deposits.map(e => e ? Deposit.toSDK(e) : undefined); + } else { + obj.deposits = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryDepositsResponseAmino): QueryDepositsResponse { + const message = createBaseQueryDepositsResponse(); + message.deposits = object.deposits?.map(e => Deposit.fromAmino(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryDepositsResponse): QueryDepositsResponseAmino { + const obj: any = {}; + if (message.deposits) { + obj.deposits = message.deposits.map(e => e ? Deposit.toAmino(e) : undefined); + } else { + obj.deposits = message.deposits; + } + obj.pagination = message.pagination ? PageResponse.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryDepositsResponseAminoMsg): QueryDepositsResponse { + return QueryDepositsResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryDepositsResponse): QueryDepositsResponseAminoMsg { + return { + type: "cosmos-sdk/QueryDepositsResponse", + value: QueryDepositsResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryDepositsResponseProtoMsg): QueryDepositsResponse { + return QueryDepositsResponse.decode(message.value); + }, + toProto(message: QueryDepositsResponse): Uint8Array { + return QueryDepositsResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryDepositsResponse): QueryDepositsResponseProtoMsg { + return { + typeUrl: "/cosmos.gov.v1beta1.QueryDepositsResponse", + value: QueryDepositsResponse.encode(message).finish() + }; + } +}; +function createBaseQueryTallyResultRequest(): QueryTallyResultRequest { + return { + proposalId: BigInt(0) + }; +} +export const QueryTallyResultRequest = { + typeUrl: "/cosmos.gov.v1beta1.QueryTallyResultRequest", + encode(message: QueryTallyResultRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.proposalId !== undefined) { + writer.uint32(8).uint64(message.proposalId); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryTallyResultRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryTallyResultRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.proposalId = reader.uint64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryTallyResultRequest { + const obj = createBaseQueryTallyResultRequest(); + if (isSet(object.proposalId)) obj.proposalId = BigInt(object.proposalId.toString()); + return obj; + }, + toJSON(message: QueryTallyResultRequest): JsonSafe { + const obj: any = {}; + message.proposalId !== undefined && (obj.proposalId = (message.proposalId || BigInt(0)).toString()); + return obj; + }, + fromPartial(object: DeepPartial): QueryTallyResultRequest { + const message = createBaseQueryTallyResultRequest(); + if (object.proposalId !== undefined && object.proposalId !== null) { + message.proposalId = BigInt(object.proposalId.toString()); + } + return message; + }, + fromSDK(object: QueryTallyResultRequestSDKType): QueryTallyResultRequest { + return { + proposalId: object?.proposal_id + }; + }, + fromSDKJSON(object: any): QueryTallyResultRequestSDKType { + return { + proposal_id: isSet(object.proposal_id) ? BigInt(object.proposal_id.toString()) : BigInt(0) + }; + }, + toSDK(message: QueryTallyResultRequest): QueryTallyResultRequestSDKType { + const obj: any = {}; + obj.proposal_id = message.proposalId; + return obj; + }, + fromAmino(object: QueryTallyResultRequestAmino): QueryTallyResultRequest { + const message = createBaseQueryTallyResultRequest(); + if (object.proposal_id !== undefined && object.proposal_id !== null) { + message.proposalId = BigInt(object.proposal_id); + } + return message; + }, + toAmino(message: QueryTallyResultRequest): QueryTallyResultRequestAmino { + const obj: any = {}; + obj.proposal_id = message.proposalId !== BigInt(0) ? message.proposalId?.toString() : undefined; + return obj; + }, + fromAminoMsg(object: QueryTallyResultRequestAminoMsg): QueryTallyResultRequest { + return QueryTallyResultRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryTallyResultRequest): QueryTallyResultRequestAminoMsg { + return { + type: "cosmos-sdk/QueryTallyResultRequest", + value: QueryTallyResultRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryTallyResultRequestProtoMsg): QueryTallyResultRequest { + return QueryTallyResultRequest.decode(message.value); + }, + toProto(message: QueryTallyResultRequest): Uint8Array { + return QueryTallyResultRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryTallyResultRequest): QueryTallyResultRequestProtoMsg { + return { + typeUrl: "/cosmos.gov.v1beta1.QueryTallyResultRequest", + value: QueryTallyResultRequest.encode(message).finish() + }; + } +}; +function createBaseQueryTallyResultResponse(): QueryTallyResultResponse { + return { + tally: TallyResult.fromPartial({}) + }; +} +export const QueryTallyResultResponse = { + typeUrl: "/cosmos.gov.v1beta1.QueryTallyResultResponse", + encode(message: QueryTallyResultResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.tally !== undefined) { + TallyResult.encode(message.tally, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryTallyResultResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryTallyResultResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.tally = TallyResult.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryTallyResultResponse { + const obj = createBaseQueryTallyResultResponse(); + if (isSet(object.tally)) obj.tally = TallyResult.fromJSON(object.tally); + return obj; + }, + toJSON(message: QueryTallyResultResponse): JsonSafe { + const obj: any = {}; + message.tally !== undefined && (obj.tally = message.tally ? TallyResult.toJSON(message.tally) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryTallyResultResponse { + const message = createBaseQueryTallyResultResponse(); + if (object.tally !== undefined && object.tally !== null) { + message.tally = TallyResult.fromPartial(object.tally); + } + return message; + }, + fromSDK(object: QueryTallyResultResponseSDKType): QueryTallyResultResponse { + return { + tally: object.tally ? TallyResult.fromSDK(object.tally) : undefined + }; + }, + fromSDKJSON(object: any): QueryTallyResultResponseSDKType { + return { + tally: isSet(object.tally) ? TallyResult.fromSDKJSON(object.tally) : undefined + }; + }, + toSDK(message: QueryTallyResultResponse): QueryTallyResultResponseSDKType { + const obj: any = {}; + message.tally !== undefined && (obj.tally = message.tally ? TallyResult.toSDK(message.tally) : undefined); + return obj; + }, + fromAmino(object: QueryTallyResultResponseAmino): QueryTallyResultResponse { + const message = createBaseQueryTallyResultResponse(); + if (object.tally !== undefined && object.tally !== null) { + message.tally = TallyResult.fromAmino(object.tally); + } + return message; + }, + toAmino(message: QueryTallyResultResponse): QueryTallyResultResponseAmino { + const obj: any = {}; + obj.tally = message.tally ? TallyResult.toAmino(message.tally) : undefined; + return obj; + }, + fromAminoMsg(object: QueryTallyResultResponseAminoMsg): QueryTallyResultResponse { + return QueryTallyResultResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryTallyResultResponse): QueryTallyResultResponseAminoMsg { + return { + type: "cosmos-sdk/QueryTallyResultResponse", + value: QueryTallyResultResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryTallyResultResponseProtoMsg): QueryTallyResultResponse { + return QueryTallyResultResponse.decode(message.value); + }, + toProto(message: QueryTallyResultResponse): Uint8Array { + return QueryTallyResultResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryTallyResultResponse): QueryTallyResultResponseProtoMsg { + return { + typeUrl: "/cosmos.gov.v1beta1.QueryTallyResultResponse", + value: QueryTallyResultResponse.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/gov/v1beta1/tx.amino.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/gov/v1beta1/tx.amino.ts new file mode 100644 index 0000000000..43c556554b --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/gov/v1beta1/tx.amino.ts @@ -0,0 +1,175 @@ +import { Any, AnySDKType } from "../../../google/protobuf/any.js"; +import { Coin, CoinSDKType } from "../../base/v1beta1/coin.js"; +import { VoteOption, VoteOptionSDKType, WeightedVoteOption, WeightedVoteOptionSDKType, voteOptionFromJSON } from "./gov.js"; +import { ReadOnlyAminoMsg as AminoMsg } from "@interchainjs/ReadOnlyAminoMsg"; +import { MsgSubmitProposal, MsgSubmitProposalSDKType, MsgVote, MsgVoteSDKType, MsgVoteWeighted, MsgVoteWeightedSDKType, MsgDeposit, MsgDepositSDKType } from "./tx.js"; +export interface MsgSubmitProposalAminoType extends AminoMsg { + type: "cosmos-sdk/MsgSubmitProposal"; + value: { + content: { + type_url: string; + value: Uint8Array; + }; + initial_deposit: { + denom: string; + amount: string; + }[]; + proposer: string; + }; +} +export interface MsgVoteAminoType extends AminoMsg { + type: "cosmos-sdk/MsgVote"; + value: { + proposal_id: string; + voter: string; + option: number; + }; +} +export interface MsgVoteWeightedAminoType extends AminoMsg { + type: "cosmos-sdk/MsgVoteWeighted"; + value: { + proposal_id: string; + voter: string; + options: { + option: number; + weight: string; + }[]; + }; +} +export interface MsgDepositAminoType extends AminoMsg { + type: "cosmos-sdk/MsgDeposit"; + value: { + proposal_id: string; + depositor: string; + amount: { + denom: string; + amount: string; + }[]; + }; +} +export const AminoConverter = { + "/cosmos.gov.v1beta1.MsgSubmitProposal": { + aminoType: "cosmos-sdk/MsgSubmitProposal", + toAmino: ({ + content, + initialDeposit, + proposer + }: MsgSubmitProposal): MsgSubmitProposalAminoType["value"] => { + return { + content: { + type_url: content.typeUrl, + value: content.value + }, + initial_deposit: initialDeposit.map(el0 => ({ + denom: el0.denom, + amount: el0.amount + })), + proposer + }; + }, + fromAmino: ({ + content, + initial_deposit, + proposer + }: MsgSubmitProposalAminoType["value"]): MsgSubmitProposal => { + return { + content: { + typeUrl: content.type_url, + value: content.value + }, + initialDeposit: initial_deposit.map(el0 => ({ + denom: el0.denom, + amount: el0.amount + })), + proposer + }; + } + }, + "/cosmos.gov.v1beta1.MsgVote": { + aminoType: "cosmos-sdk/MsgVote", + toAmino: ({ + proposalId, + voter, + option + }: MsgVote): MsgVoteAminoType["value"] => { + return { + proposal_id: proposalId.toString(), + voter, + option + }; + }, + fromAmino: ({ + proposal_id, + voter, + option + }: MsgVoteAminoType["value"]): MsgVote => { + return { + proposalId: BigInt(proposal_id), + voter, + option: voteOptionFromJSON(option) + }; + } + }, + "/cosmos.gov.v1beta1.MsgVoteWeighted": { + aminoType: "cosmos-sdk/MsgVoteWeighted", + toAmino: ({ + proposalId, + voter, + options + }: MsgVoteWeighted): MsgVoteWeightedAminoType["value"] => { + return { + proposal_id: proposalId.toString(), + voter, + options: options.map(el0 => ({ + option: el0.option, + weight: el0.weight + })) + }; + }, + fromAmino: ({ + proposal_id, + voter, + options + }: MsgVoteWeightedAminoType["value"]): MsgVoteWeighted => { + return { + proposalId: BigInt(proposal_id), + voter, + options: options.map(el0 => ({ + option: voteOptionFromJSON(el0.option), + weight: el0.weight + })) + }; + } + }, + "/cosmos.gov.v1beta1.MsgDeposit": { + aminoType: "cosmos-sdk/MsgDeposit", + toAmino: ({ + proposalId, + depositor, + amount + }: MsgDeposit): MsgDepositAminoType["value"] => { + return { + proposal_id: proposalId.toString(), + depositor, + amount: amount.map(el0 => ({ + denom: el0.denom, + amount: el0.amount + })) + }; + }, + fromAmino: ({ + proposal_id, + depositor, + amount + }: MsgDepositAminoType["value"]): MsgDeposit => { + return { + proposalId: BigInt(proposal_id), + depositor, + amount: amount.map(el0 => ({ + denom: el0.denom, + amount: el0.amount + })) + }; + } + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/gov/v1beta1/tx.registry.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/gov/v1beta1/tx.registry.ts new file mode 100644 index 0000000000..ed11331d36 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/gov/v1beta1/tx.registry.ts @@ -0,0 +1,143 @@ +import { Any, AnySDKType } from "../../../google/protobuf/any.js"; +import { Coin, CoinSDKType } from "../../base/v1beta1/coin.js"; +import { VoteOption, VoteOptionSDKType, WeightedVoteOption, WeightedVoteOptionSDKType } from "./gov.js"; +import { GeneratedType, Registry } from "@cosmjs/proto-signing"; +import { MsgSubmitProposal, MsgSubmitProposalSDKType, MsgVote, MsgVoteSDKType, MsgVoteWeighted, MsgVoteWeightedSDKType, MsgDeposit, MsgDepositSDKType } from "./tx.js"; +export const registry: ReadonlyArray<[string, GeneratedType]> = [["/cosmos.gov.v1beta1.MsgSubmitProposal", MsgSubmitProposal], ["/cosmos.gov.v1beta1.MsgVote", MsgVote], ["/cosmos.gov.v1beta1.MsgVoteWeighted", MsgVoteWeighted], ["/cosmos.gov.v1beta1.MsgDeposit", MsgDeposit]]; +export const load = (protoRegistry: Registry) => { + registry.forEach(([typeUrl, mod]) => { + protoRegistry.register(typeUrl, mod); + }); +}; +export const MessageComposer = { + encoded: { + submitProposal(value: MsgSubmitProposal) { + return { + typeUrl: "/cosmos.gov.v1beta1.MsgSubmitProposal", + value: MsgSubmitProposal.encode(value).finish() + }; + }, + vote(value: MsgVote) { + return { + typeUrl: "/cosmos.gov.v1beta1.MsgVote", + value: MsgVote.encode(value).finish() + }; + }, + voteWeighted(value: MsgVoteWeighted) { + return { + typeUrl: "/cosmos.gov.v1beta1.MsgVoteWeighted", + value: MsgVoteWeighted.encode(value).finish() + }; + }, + deposit(value: MsgDeposit) { + return { + typeUrl: "/cosmos.gov.v1beta1.MsgDeposit", + value: MsgDeposit.encode(value).finish() + }; + } + }, + withTypeUrl: { + submitProposal(value: MsgSubmitProposal) { + return { + typeUrl: "/cosmos.gov.v1beta1.MsgSubmitProposal", + value + }; + }, + vote(value: MsgVote) { + return { + typeUrl: "/cosmos.gov.v1beta1.MsgVote", + value + }; + }, + voteWeighted(value: MsgVoteWeighted) { + return { + typeUrl: "/cosmos.gov.v1beta1.MsgVoteWeighted", + value + }; + }, + deposit(value: MsgDeposit) { + return { + typeUrl: "/cosmos.gov.v1beta1.MsgDeposit", + value + }; + } + }, + toJSON: { + submitProposal(value: MsgSubmitProposal) { + return { + typeUrl: "/cosmos.gov.v1beta1.MsgSubmitProposal", + value: MsgSubmitProposal.toJSON(value) + }; + }, + vote(value: MsgVote) { + return { + typeUrl: "/cosmos.gov.v1beta1.MsgVote", + value: MsgVote.toJSON(value) + }; + }, + voteWeighted(value: MsgVoteWeighted) { + return { + typeUrl: "/cosmos.gov.v1beta1.MsgVoteWeighted", + value: MsgVoteWeighted.toJSON(value) + }; + }, + deposit(value: MsgDeposit) { + return { + typeUrl: "/cosmos.gov.v1beta1.MsgDeposit", + value: MsgDeposit.toJSON(value) + }; + } + }, + fromJSON: { + submitProposal(value: any) { + return { + typeUrl: "/cosmos.gov.v1beta1.MsgSubmitProposal", + value: MsgSubmitProposal.fromJSON(value) + }; + }, + vote(value: any) { + return { + typeUrl: "/cosmos.gov.v1beta1.MsgVote", + value: MsgVote.fromJSON(value) + }; + }, + voteWeighted(value: any) { + return { + typeUrl: "/cosmos.gov.v1beta1.MsgVoteWeighted", + value: MsgVoteWeighted.fromJSON(value) + }; + }, + deposit(value: any) { + return { + typeUrl: "/cosmos.gov.v1beta1.MsgDeposit", + value: MsgDeposit.fromJSON(value) + }; + } + }, + fromPartial: { + submitProposal(value: MsgSubmitProposal) { + return { + typeUrl: "/cosmos.gov.v1beta1.MsgSubmitProposal", + value: MsgSubmitProposal.fromPartial(value) + }; + }, + vote(value: MsgVote) { + return { + typeUrl: "/cosmos.gov.v1beta1.MsgVote", + value: MsgVote.fromPartial(value) + }; + }, + voteWeighted(value: MsgVoteWeighted) { + return { + typeUrl: "/cosmos.gov.v1beta1.MsgVoteWeighted", + value: MsgVoteWeighted.fromPartial(value) + }; + }, + deposit(value: MsgDeposit) { + return { + typeUrl: "/cosmos.gov.v1beta1.MsgDeposit", + value: MsgDeposit.fromPartial(value) + }; + } + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/gov/v1beta1/tx.rpc.func.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/gov/v1beta1/tx.rpc.func.ts new file mode 100644 index 0000000000..f5034e448d --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/gov/v1beta1/tx.rpc.func.ts @@ -0,0 +1,40 @@ +import { buildTx, SigningClientResolver } from "../../../helper-func-types"; +import { buildUseMutation } from "../../../react-query"; +import { toEncoders, toConverters } from "@interchainjs/cosmos/utils"; +import { MsgSubmitProposal, MsgVote, MsgVoteWeighted, MsgDeposit } from "./tx"; +export const createSubmitProposal = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgSubmitProposal.typeUrl, + encoders: toEncoders(MsgSubmitProposal), + converters: toConverters(MsgSubmitProposal) +}); +export const useSubmitProposal = buildUseMutation({ + builderMutationFn: createSubmitProposal +}); +export const createVote = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgVote.typeUrl, + encoders: toEncoders(MsgVote), + converters: toConverters(MsgVote) +}); +export const useVote = buildUseMutation({ + builderMutationFn: createVote +}); +export const createVoteWeighted = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgVoteWeighted.typeUrl, + encoders: toEncoders(MsgVoteWeighted), + converters: toConverters(MsgVoteWeighted) +}); +export const useVoteWeighted = buildUseMutation({ + builderMutationFn: createVoteWeighted +}); +export const createDeposit = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgDeposit.typeUrl, + encoders: toEncoders(MsgDeposit), + converters: toConverters(MsgDeposit) +}); +export const useDeposit = buildUseMutation({ + builderMutationFn: createDeposit +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/gov/v1beta1/tx.rpc.msg.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/gov/v1beta1/tx.rpc.msg.ts new file mode 100644 index 0000000000..604dbe4e16 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/gov/v1beta1/tx.rpc.msg.ts @@ -0,0 +1,54 @@ +import { Any, AnySDKType } from "../../../google/protobuf/any.js"; +import { Coin, CoinSDKType } from "../../base/v1beta1/coin.js"; +import { VoteOption, VoteOptionSDKType, WeightedVoteOption, WeightedVoteOptionSDKType } from "./gov.js"; +import { Rpc } from "../../../helpers.js"; +import { BinaryReader } from "../../../binary.js"; +import { MsgSubmitProposal, MsgSubmitProposalSDKType, MsgSubmitProposalResponse, MsgSubmitProposalResponseSDKType, MsgVote, MsgVoteSDKType, MsgVoteResponse, MsgVoteResponseSDKType, MsgVoteWeighted, MsgVoteWeightedSDKType, MsgVoteWeightedResponse, MsgVoteWeightedResponseSDKType, MsgDeposit, MsgDepositSDKType, MsgDepositResponse, MsgDepositResponseSDKType } from "./tx.js"; +/** Msg defines the bank Msg service. */ +export interface Msg { + /** SubmitProposal defines a method to create new proposal given a content. */ + submitProposal(request: MsgSubmitProposal): Promise; + /** Vote defines a method to add a vote on a specific proposal. */ + vote(request: MsgVote): Promise; + /** + * VoteWeighted defines a method to add a weighted vote on a specific proposal. + * + * Since: cosmos-sdk 0.43 + */ + voteWeighted(request: MsgVoteWeighted): Promise; + /** Deposit defines a method to add deposit on a specific proposal. */ + deposit(request: MsgDeposit): Promise; +} +export class MsgClientImpl implements Msg { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + this.submitProposal = this.submitProposal.bind(this); + this.vote = this.vote.bind(this); + this.voteWeighted = this.voteWeighted.bind(this); + this.deposit = this.deposit.bind(this); + } + submitProposal(request: MsgSubmitProposal): Promise { + const data = MsgSubmitProposal.encode(request).finish(); + const promise = this.rpc.request("cosmos.gov.v1beta1.Msg", "SubmitProposal", data); + return promise.then(data => MsgSubmitProposalResponse.decode(new BinaryReader(data))); + } + vote(request: MsgVote): Promise { + const data = MsgVote.encode(request).finish(); + const promise = this.rpc.request("cosmos.gov.v1beta1.Msg", "Vote", data); + return promise.then(data => MsgVoteResponse.decode(new BinaryReader(data))); + } + voteWeighted(request: MsgVoteWeighted): Promise { + const data = MsgVoteWeighted.encode(request).finish(); + const promise = this.rpc.request("cosmos.gov.v1beta1.Msg", "VoteWeighted", data); + return promise.then(data => MsgVoteWeightedResponse.decode(new BinaryReader(data))); + } + deposit(request: MsgDeposit): Promise { + const data = MsgDeposit.encode(request).finish(); + const promise = this.rpc.request("cosmos.gov.v1beta1.Msg", "Deposit", data); + return promise.then(data => MsgDepositResponse.decode(new BinaryReader(data))); + } +} +export const createClientImpl = (rpc: Rpc) => { + return new MsgClientImpl(rpc); +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/gov/v1beta1/tx.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/gov/v1beta1/tx.ts new file mode 100644 index 0000000000..e4600c0f18 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/gov/v1beta1/tx.ts @@ -0,0 +1,997 @@ +import { Any, AnySDKType } from "../../../google/protobuf/any.js"; +import { Coin, CoinSDKType } from "../../base/v1beta1/coin.js"; +import { VoteOption, VoteOptionSDKType, WeightedVoteOption, WeightedVoteOptionSDKType, voteOptionFromJSON, voteOptionToJSON } from "./gov.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "cosmos.gov.v1beta1"; +/** + * MsgSubmitProposal defines an sdk.Msg type that supports submitting arbitrary + * proposal Content. + */ +export interface MsgSubmitProposal { + content?: Any; + initialDeposit: Coin[]; + proposer: string; +} +export interface MsgSubmitProposalProtoMsg { + typeUrl: "/cosmos.gov.v1beta1.MsgSubmitProposal"; + value: Uint8Array; +} +/** + * MsgSubmitProposal defines an sdk.Msg type that supports submitting arbitrary + * proposal Content. + */ +export interface MsgSubmitProposalSDKType { + content?: AnySDKType; + initial_deposit: CoinSDKType[]; + proposer: string; +} +/** MsgSubmitProposalResponse defines the Msg/SubmitProposal response type. */ +export interface MsgSubmitProposalResponse { + proposalId: bigint; +} +export interface MsgSubmitProposalResponseProtoMsg { + typeUrl: "/cosmos.gov.v1beta1.MsgSubmitProposalResponse"; + value: Uint8Array; +} +/** MsgSubmitProposalResponse defines the Msg/SubmitProposal response type. */ +export interface MsgSubmitProposalResponseSDKType { + proposal_id: bigint; +} +/** MsgVote defines a message to cast a vote. */ +export interface MsgVote { + proposalId: bigint; + voter: string; + option: VoteOption; +} +export interface MsgVoteProtoMsg { + typeUrl: "/cosmos.gov.v1beta1.MsgVote"; + value: Uint8Array; +} +/** MsgVote defines a message to cast a vote. */ +export interface MsgVoteSDKType { + proposal_id: bigint; + voter: string; + option: VoteOption; +} +/** MsgVoteResponse defines the Msg/Vote response type. */ +export interface MsgVoteResponse {} +export interface MsgVoteResponseProtoMsg { + typeUrl: "/cosmos.gov.v1beta1.MsgVoteResponse"; + value: Uint8Array; +} +/** MsgVoteResponse defines the Msg/Vote response type. */ +export interface MsgVoteResponseSDKType {} +/** + * MsgVoteWeighted defines a message to cast a vote. + * + * Since: cosmos-sdk 0.43 + */ +export interface MsgVoteWeighted { + proposalId: bigint; + voter: string; + options: WeightedVoteOption[]; +} +export interface MsgVoteWeightedProtoMsg { + typeUrl: "/cosmos.gov.v1beta1.MsgVoteWeighted"; + value: Uint8Array; +} +/** + * MsgVoteWeighted defines a message to cast a vote. + * + * Since: cosmos-sdk 0.43 + */ +export interface MsgVoteWeightedSDKType { + proposal_id: bigint; + voter: string; + options: WeightedVoteOptionSDKType[]; +} +/** + * MsgVoteWeightedResponse defines the Msg/VoteWeighted response type. + * + * Since: cosmos-sdk 0.43 + */ +export interface MsgVoteWeightedResponse {} +export interface MsgVoteWeightedResponseProtoMsg { + typeUrl: "/cosmos.gov.v1beta1.MsgVoteWeightedResponse"; + value: Uint8Array; +} +/** + * MsgVoteWeightedResponse defines the Msg/VoteWeighted response type. + * + * Since: cosmos-sdk 0.43 + */ +export interface MsgVoteWeightedResponseSDKType {} +/** MsgDeposit defines a message to submit a deposit to an existing proposal. */ +export interface MsgDeposit { + proposalId: bigint; + depositor: string; + amount: Coin[]; +} +export interface MsgDepositProtoMsg { + typeUrl: "/cosmos.gov.v1beta1.MsgDeposit"; + value: Uint8Array; +} +/** MsgDeposit defines a message to submit a deposit to an existing proposal. */ +export interface MsgDepositSDKType { + proposal_id: bigint; + depositor: string; + amount: CoinSDKType[]; +} +/** MsgDepositResponse defines the Msg/Deposit response type. */ +export interface MsgDepositResponse {} +export interface MsgDepositResponseProtoMsg { + typeUrl: "/cosmos.gov.v1beta1.MsgDepositResponse"; + value: Uint8Array; +} +/** MsgDepositResponse defines the Msg/Deposit response type. */ +export interface MsgDepositResponseSDKType {} +function createBaseMsgSubmitProposal(): MsgSubmitProposal { + return { + content: undefined, + initialDeposit: [], + proposer: "" + }; +} +export const MsgSubmitProposal = { + typeUrl: "/cosmos.gov.v1beta1.MsgSubmitProposal", + encode(message: MsgSubmitProposal, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.content !== undefined) { + Any.encode(message.content, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.initialDeposit) { + Coin.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.proposer !== undefined) { + writer.uint32(26).string(message.proposer); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgSubmitProposal { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgSubmitProposal(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.content = Any.decode(reader, reader.uint32()); + break; + case 2: + message.initialDeposit.push(Coin.decode(reader, reader.uint32())); + break; + case 3: + message.proposer = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgSubmitProposal { + const obj = createBaseMsgSubmitProposal(); + if (isSet(object.content)) obj.content = Any.fromJSON(object.content); + if (Array.isArray(object?.initialDeposit)) obj.initialDeposit = object.initialDeposit.map((e: any) => Coin.fromJSON(e)); + if (isSet(object.proposer)) obj.proposer = String(object.proposer); + return obj; + }, + toJSON(message: MsgSubmitProposal): JsonSafe { + const obj: any = {}; + message.content !== undefined && (obj.content = message.content ? Any.toJSON(message.content) : undefined); + if (message.initialDeposit) { + obj.initialDeposit = message.initialDeposit.map(e => e ? Coin.toJSON(e) : undefined); + } else { + obj.initialDeposit = []; + } + message.proposer !== undefined && (obj.proposer = message.proposer); + return obj; + }, + fromPartial(object: DeepPartial): MsgSubmitProposal { + const message = createBaseMsgSubmitProposal(); + if (object.content !== undefined && object.content !== null) { + message.content = Any.fromPartial(object.content); + } + message.initialDeposit = object.initialDeposit?.map(e => Coin.fromPartial(e)) || []; + message.proposer = object.proposer ?? ""; + return message; + }, + fromSDK(object: MsgSubmitProposalSDKType): MsgSubmitProposal { + return { + content: object.content ? Any.fromSDK(object.content) : undefined, + initialDeposit: Array.isArray(object?.initial_deposit) ? object.initial_deposit.map((e: any) => Coin.fromSDK(e)) : [], + proposer: object?.proposer + }; + }, + fromSDKJSON(object: any): MsgSubmitProposalSDKType { + return { + content: isSet(object.content) ? Any.fromSDKJSON(object.content) : undefined, + initial_deposit: Array.isArray(object?.initial_deposit) ? object.initial_deposit.map((e: any) => Coin.fromSDKJSON(e)) : [], + proposer: isSet(object.proposer) ? String(object.proposer) : "" + }; + }, + toSDK(message: MsgSubmitProposal): MsgSubmitProposalSDKType { + const obj: any = {}; + message.content !== undefined && (obj.content = message.content ? Any.toSDK(message.content) : undefined); + if (message.initialDeposit) { + obj.initial_deposit = message.initialDeposit.map(e => e ? Coin.toSDK(e) : undefined); + } else { + obj.initial_deposit = []; + } + obj.proposer = message.proposer; + return obj; + }, + fromAmino(object: MsgSubmitProposalAmino): MsgSubmitProposal { + const message = createBaseMsgSubmitProposal(); + if (object.content !== undefined && object.content !== null) { + message.content = Any.fromAmino(object.content); + } + message.initialDeposit = object.initial_deposit?.map(e => Coin.fromAmino(e)) || []; + if (object.proposer !== undefined && object.proposer !== null) { + message.proposer = object.proposer; + } + return message; + }, + toAmino(message: MsgSubmitProposal): MsgSubmitProposalAmino { + const obj: any = {}; + obj.content = message.content ? Any.toAmino(message.content) : undefined; + if (message.initialDeposit) { + obj.initial_deposit = message.initialDeposit.map(e => e ? Coin.toAmino(e) : undefined); + } else { + obj.initial_deposit = message.initialDeposit; + } + obj.proposer = message.proposer === "" ? undefined : message.proposer; + return obj; + }, + fromAminoMsg(object: MsgSubmitProposalAminoMsg): MsgSubmitProposal { + return MsgSubmitProposal.fromAmino(object.value); + }, + toAminoMsg(message: MsgSubmitProposal): MsgSubmitProposalAminoMsg { + return { + type: "cosmos-sdk/MsgSubmitProposal", + value: MsgSubmitProposal.toAmino(message) + }; + }, + fromProtoMsg(message: MsgSubmitProposalProtoMsg): MsgSubmitProposal { + return MsgSubmitProposal.decode(message.value); + }, + toProto(message: MsgSubmitProposal): Uint8Array { + return MsgSubmitProposal.encode(message).finish(); + }, + toProtoMsg(message: MsgSubmitProposal): MsgSubmitProposalProtoMsg { + return { + typeUrl: "/cosmos.gov.v1beta1.MsgSubmitProposal", + value: MsgSubmitProposal.encode(message).finish() + }; + } +}; +function createBaseMsgSubmitProposalResponse(): MsgSubmitProposalResponse { + return { + proposalId: BigInt(0) + }; +} +export const MsgSubmitProposalResponse = { + typeUrl: "/cosmos.gov.v1beta1.MsgSubmitProposalResponse", + encode(message: MsgSubmitProposalResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.proposalId !== undefined) { + writer.uint32(8).uint64(message.proposalId); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgSubmitProposalResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgSubmitProposalResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.proposalId = reader.uint64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgSubmitProposalResponse { + const obj = createBaseMsgSubmitProposalResponse(); + if (isSet(object.proposalId)) obj.proposalId = BigInt(object.proposalId.toString()); + return obj; + }, + toJSON(message: MsgSubmitProposalResponse): JsonSafe { + const obj: any = {}; + message.proposalId !== undefined && (obj.proposalId = (message.proposalId || BigInt(0)).toString()); + return obj; + }, + fromPartial(object: DeepPartial): MsgSubmitProposalResponse { + const message = createBaseMsgSubmitProposalResponse(); + if (object.proposalId !== undefined && object.proposalId !== null) { + message.proposalId = BigInt(object.proposalId.toString()); + } + return message; + }, + fromSDK(object: MsgSubmitProposalResponseSDKType): MsgSubmitProposalResponse { + return { + proposalId: object?.proposal_id + }; + }, + fromSDKJSON(object: any): MsgSubmitProposalResponseSDKType { + return { + proposal_id: isSet(object.proposal_id) ? BigInt(object.proposal_id.toString()) : BigInt(0) + }; + }, + toSDK(message: MsgSubmitProposalResponse): MsgSubmitProposalResponseSDKType { + const obj: any = {}; + obj.proposal_id = message.proposalId; + return obj; + }, + fromAmino(object: MsgSubmitProposalResponseAmino): MsgSubmitProposalResponse { + const message = createBaseMsgSubmitProposalResponse(); + if (object.proposal_id !== undefined && object.proposal_id !== null) { + message.proposalId = BigInt(object.proposal_id); + } + return message; + }, + toAmino(message: MsgSubmitProposalResponse): MsgSubmitProposalResponseAmino { + const obj: any = {}; + obj.proposal_id = message.proposalId ? message.proposalId?.toString() : "0"; + return obj; + }, + fromAminoMsg(object: MsgSubmitProposalResponseAminoMsg): MsgSubmitProposalResponse { + return MsgSubmitProposalResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgSubmitProposalResponse): MsgSubmitProposalResponseAminoMsg { + return { + type: "cosmos-sdk/MsgSubmitProposalResponse", + value: MsgSubmitProposalResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgSubmitProposalResponseProtoMsg): MsgSubmitProposalResponse { + return MsgSubmitProposalResponse.decode(message.value); + }, + toProto(message: MsgSubmitProposalResponse): Uint8Array { + return MsgSubmitProposalResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgSubmitProposalResponse): MsgSubmitProposalResponseProtoMsg { + return { + typeUrl: "/cosmos.gov.v1beta1.MsgSubmitProposalResponse", + value: MsgSubmitProposalResponse.encode(message).finish() + }; + } +}; +function createBaseMsgVote(): MsgVote { + return { + proposalId: BigInt(0), + voter: "", + option: 0 + }; +} +export const MsgVote = { + typeUrl: "/cosmos.gov.v1beta1.MsgVote", + encode(message: MsgVote, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.proposalId !== undefined) { + writer.uint32(8).uint64(message.proposalId); + } + if (message.voter !== undefined) { + writer.uint32(18).string(message.voter); + } + if (message.option !== 0) { + writer.uint32(24).int32(message.option); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgVote { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgVote(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.proposalId = reader.uint64(); + break; + case 2: + message.voter = reader.string(); + break; + case 3: + message.option = (reader.int32() as any); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgVote { + const obj = createBaseMsgVote(); + if (isSet(object.proposalId)) obj.proposalId = BigInt(object.proposalId.toString()); + if (isSet(object.voter)) obj.voter = String(object.voter); + if (isSet(object.option)) obj.option = voteOptionFromJSON(object.option); + return obj; + }, + toJSON(message: MsgVote): JsonSafe { + const obj: any = {}; + message.proposalId !== undefined && (obj.proposalId = (message.proposalId || BigInt(0)).toString()); + message.voter !== undefined && (obj.voter = message.voter); + message.option !== undefined && (obj.option = voteOptionToJSON(message.option)); + return obj; + }, + fromPartial(object: DeepPartial): MsgVote { + const message = createBaseMsgVote(); + if (object.proposalId !== undefined && object.proposalId !== null) { + message.proposalId = BigInt(object.proposalId.toString()); + } + message.voter = object.voter ?? ""; + message.option = object.option ?? 0; + return message; + }, + fromSDK(object: MsgVoteSDKType): MsgVote { + return { + proposalId: object?.proposal_id, + voter: object?.voter, + option: isSet(object.option) ? voteOptionFromJSON(object.option) : -1 + }; + }, + fromSDKJSON(object: any): MsgVoteSDKType { + return { + proposal_id: isSet(object.proposal_id) ? BigInt(object.proposal_id.toString()) : BigInt(0), + voter: isSet(object.voter) ? String(object.voter) : "", + option: isSet(object.option) ? voteOptionFromJSON(object.option) : -1 + }; + }, + toSDK(message: MsgVote): MsgVoteSDKType { + const obj: any = {}; + obj.proposal_id = message.proposalId; + obj.voter = message.voter; + message.option !== undefined && (obj.option = voteOptionToJSON(message.option)); + return obj; + }, + fromAmino(object: MsgVoteAmino): MsgVote { + const message = createBaseMsgVote(); + if (object.proposal_id !== undefined && object.proposal_id !== null) { + message.proposalId = BigInt(object.proposal_id); + } + if (object.voter !== undefined && object.voter !== null) { + message.voter = object.voter; + } + if (object.option !== undefined && object.option !== null) { + message.option = object.option; + } + return message; + }, + toAmino(message: MsgVote): MsgVoteAmino { + const obj: any = {}; + obj.proposal_id = message.proposalId !== BigInt(0) ? message.proposalId?.toString() : undefined; + obj.voter = message.voter === "" ? undefined : message.voter; + obj.option = message.option === 0 ? undefined : message.option; + return obj; + }, + fromAminoMsg(object: MsgVoteAminoMsg): MsgVote { + return MsgVote.fromAmino(object.value); + }, + toAminoMsg(message: MsgVote): MsgVoteAminoMsg { + return { + type: "cosmos-sdk/MsgVote", + value: MsgVote.toAmino(message) + }; + }, + fromProtoMsg(message: MsgVoteProtoMsg): MsgVote { + return MsgVote.decode(message.value); + }, + toProto(message: MsgVote): Uint8Array { + return MsgVote.encode(message).finish(); + }, + toProtoMsg(message: MsgVote): MsgVoteProtoMsg { + return { + typeUrl: "/cosmos.gov.v1beta1.MsgVote", + value: MsgVote.encode(message).finish() + }; + } +}; +function createBaseMsgVoteResponse(): MsgVoteResponse { + return {}; +} +export const MsgVoteResponse = { + typeUrl: "/cosmos.gov.v1beta1.MsgVoteResponse", + encode(_: MsgVoteResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgVoteResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgVoteResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgVoteResponse { + const obj = createBaseMsgVoteResponse(); + return obj; + }, + toJSON(_: MsgVoteResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): MsgVoteResponse { + const message = createBaseMsgVoteResponse(); + return message; + }, + fromSDK(_: MsgVoteResponseSDKType): MsgVoteResponse { + return {}; + }, + fromSDKJSON(_: any): MsgVoteResponseSDKType { + return {}; + }, + toSDK(_: MsgVoteResponse): MsgVoteResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgVoteResponseAmino): MsgVoteResponse { + const message = createBaseMsgVoteResponse(); + return message; + }, + toAmino(_: MsgVoteResponse): MsgVoteResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgVoteResponseAminoMsg): MsgVoteResponse { + return MsgVoteResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgVoteResponse): MsgVoteResponseAminoMsg { + return { + type: "cosmos-sdk/MsgVoteResponse", + value: MsgVoteResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgVoteResponseProtoMsg): MsgVoteResponse { + return MsgVoteResponse.decode(message.value); + }, + toProto(message: MsgVoteResponse): Uint8Array { + return MsgVoteResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgVoteResponse): MsgVoteResponseProtoMsg { + return { + typeUrl: "/cosmos.gov.v1beta1.MsgVoteResponse", + value: MsgVoteResponse.encode(message).finish() + }; + } +}; +function createBaseMsgVoteWeighted(): MsgVoteWeighted { + return { + proposalId: BigInt(0), + voter: "", + options: [] + }; +} +export const MsgVoteWeighted = { + typeUrl: "/cosmos.gov.v1beta1.MsgVoteWeighted", + encode(message: MsgVoteWeighted, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.proposalId !== undefined) { + writer.uint32(8).uint64(message.proposalId); + } + if (message.voter !== undefined) { + writer.uint32(18).string(message.voter); + } + for (const v of message.options) { + WeightedVoteOption.encode(v!, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgVoteWeighted { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgVoteWeighted(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.proposalId = reader.uint64(); + break; + case 2: + message.voter = reader.string(); + break; + case 3: + message.options.push(WeightedVoteOption.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgVoteWeighted { + const obj = createBaseMsgVoteWeighted(); + if (isSet(object.proposalId)) obj.proposalId = BigInt(object.proposalId.toString()); + if (isSet(object.voter)) obj.voter = String(object.voter); + if (Array.isArray(object?.options)) obj.options = object.options.map((e: any) => WeightedVoteOption.fromJSON(e)); + return obj; + }, + toJSON(message: MsgVoteWeighted): JsonSafe { + const obj: any = {}; + message.proposalId !== undefined && (obj.proposalId = (message.proposalId || BigInt(0)).toString()); + message.voter !== undefined && (obj.voter = message.voter); + if (message.options) { + obj.options = message.options.map(e => e ? WeightedVoteOption.toJSON(e) : undefined); + } else { + obj.options = []; + } + return obj; + }, + fromPartial(object: DeepPartial): MsgVoteWeighted { + const message = createBaseMsgVoteWeighted(); + if (object.proposalId !== undefined && object.proposalId !== null) { + message.proposalId = BigInt(object.proposalId.toString()); + } + message.voter = object.voter ?? ""; + message.options = object.options?.map(e => WeightedVoteOption.fromPartial(e)) || []; + return message; + }, + fromSDK(object: MsgVoteWeightedSDKType): MsgVoteWeighted { + return { + proposalId: object?.proposal_id, + voter: object?.voter, + options: Array.isArray(object?.options) ? object.options.map((e: any) => WeightedVoteOption.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): MsgVoteWeightedSDKType { + return { + proposal_id: isSet(object.proposal_id) ? BigInt(object.proposal_id.toString()) : BigInt(0), + voter: isSet(object.voter) ? String(object.voter) : "", + options: Array.isArray(object?.options) ? object.options.map((e: any) => WeightedVoteOption.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: MsgVoteWeighted): MsgVoteWeightedSDKType { + const obj: any = {}; + obj.proposal_id = message.proposalId; + obj.voter = message.voter; + if (message.options) { + obj.options = message.options.map(e => e ? WeightedVoteOption.toSDK(e) : undefined); + } else { + obj.options = []; + } + return obj; + }, + fromAmino(object: MsgVoteWeightedAmino): MsgVoteWeighted { + const message = createBaseMsgVoteWeighted(); + if (object.proposal_id !== undefined && object.proposal_id !== null) { + message.proposalId = BigInt(object.proposal_id); + } + if (object.voter !== undefined && object.voter !== null) { + message.voter = object.voter; + } + message.options = object.options?.map(e => WeightedVoteOption.fromAmino(e)) || []; + return message; + }, + toAmino(message: MsgVoteWeighted): MsgVoteWeightedAmino { + const obj: any = {}; + obj.proposal_id = message.proposalId ? message.proposalId?.toString() : "0"; + obj.voter = message.voter === "" ? undefined : message.voter; + if (message.options) { + obj.options = message.options.map(e => e ? WeightedVoteOption.toAmino(e) : undefined); + } else { + obj.options = message.options; + } + return obj; + }, + fromAminoMsg(object: MsgVoteWeightedAminoMsg): MsgVoteWeighted { + return MsgVoteWeighted.fromAmino(object.value); + }, + toAminoMsg(message: MsgVoteWeighted): MsgVoteWeightedAminoMsg { + return { + type: "cosmos-sdk/MsgVoteWeighted", + value: MsgVoteWeighted.toAmino(message) + }; + }, + fromProtoMsg(message: MsgVoteWeightedProtoMsg): MsgVoteWeighted { + return MsgVoteWeighted.decode(message.value); + }, + toProto(message: MsgVoteWeighted): Uint8Array { + return MsgVoteWeighted.encode(message).finish(); + }, + toProtoMsg(message: MsgVoteWeighted): MsgVoteWeightedProtoMsg { + return { + typeUrl: "/cosmos.gov.v1beta1.MsgVoteWeighted", + value: MsgVoteWeighted.encode(message).finish() + }; + } +}; +function createBaseMsgVoteWeightedResponse(): MsgVoteWeightedResponse { + return {}; +} +export const MsgVoteWeightedResponse = { + typeUrl: "/cosmos.gov.v1beta1.MsgVoteWeightedResponse", + encode(_: MsgVoteWeightedResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgVoteWeightedResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgVoteWeightedResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgVoteWeightedResponse { + const obj = createBaseMsgVoteWeightedResponse(); + return obj; + }, + toJSON(_: MsgVoteWeightedResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): MsgVoteWeightedResponse { + const message = createBaseMsgVoteWeightedResponse(); + return message; + }, + fromSDK(_: MsgVoteWeightedResponseSDKType): MsgVoteWeightedResponse { + return {}; + }, + fromSDKJSON(_: any): MsgVoteWeightedResponseSDKType { + return {}; + }, + toSDK(_: MsgVoteWeightedResponse): MsgVoteWeightedResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgVoteWeightedResponseAmino): MsgVoteWeightedResponse { + const message = createBaseMsgVoteWeightedResponse(); + return message; + }, + toAmino(_: MsgVoteWeightedResponse): MsgVoteWeightedResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgVoteWeightedResponseAminoMsg): MsgVoteWeightedResponse { + return MsgVoteWeightedResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgVoteWeightedResponse): MsgVoteWeightedResponseAminoMsg { + return { + type: "cosmos-sdk/MsgVoteWeightedResponse", + value: MsgVoteWeightedResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgVoteWeightedResponseProtoMsg): MsgVoteWeightedResponse { + return MsgVoteWeightedResponse.decode(message.value); + }, + toProto(message: MsgVoteWeightedResponse): Uint8Array { + return MsgVoteWeightedResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgVoteWeightedResponse): MsgVoteWeightedResponseProtoMsg { + return { + typeUrl: "/cosmos.gov.v1beta1.MsgVoteWeightedResponse", + value: MsgVoteWeightedResponse.encode(message).finish() + }; + } +}; +function createBaseMsgDeposit(): MsgDeposit { + return { + proposalId: BigInt(0), + depositor: "", + amount: [] + }; +} +export const MsgDeposit = { + typeUrl: "/cosmos.gov.v1beta1.MsgDeposit", + encode(message: MsgDeposit, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.proposalId !== undefined) { + writer.uint32(8).uint64(message.proposalId); + } + if (message.depositor !== undefined) { + writer.uint32(18).string(message.depositor); + } + for (const v of message.amount) { + Coin.encode(v!, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgDeposit { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgDeposit(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.proposalId = reader.uint64(); + break; + case 2: + message.depositor = reader.string(); + break; + case 3: + message.amount.push(Coin.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgDeposit { + const obj = createBaseMsgDeposit(); + if (isSet(object.proposalId)) obj.proposalId = BigInt(object.proposalId.toString()); + if (isSet(object.depositor)) obj.depositor = String(object.depositor); + if (Array.isArray(object?.amount)) obj.amount = object.amount.map((e: any) => Coin.fromJSON(e)); + return obj; + }, + toJSON(message: MsgDeposit): JsonSafe { + const obj: any = {}; + message.proposalId !== undefined && (obj.proposalId = (message.proposalId || BigInt(0)).toString()); + message.depositor !== undefined && (obj.depositor = message.depositor); + if (message.amount) { + obj.amount = message.amount.map(e => e ? Coin.toJSON(e) : undefined); + } else { + obj.amount = []; + } + return obj; + }, + fromPartial(object: DeepPartial): MsgDeposit { + const message = createBaseMsgDeposit(); + if (object.proposalId !== undefined && object.proposalId !== null) { + message.proposalId = BigInt(object.proposalId.toString()); + } + message.depositor = object.depositor ?? ""; + message.amount = object.amount?.map(e => Coin.fromPartial(e)) || []; + return message; + }, + fromSDK(object: MsgDepositSDKType): MsgDeposit { + return { + proposalId: object?.proposal_id, + depositor: object?.depositor, + amount: Array.isArray(object?.amount) ? object.amount.map((e: any) => Coin.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): MsgDepositSDKType { + return { + proposal_id: isSet(object.proposal_id) ? BigInt(object.proposal_id.toString()) : BigInt(0), + depositor: isSet(object.depositor) ? String(object.depositor) : "", + amount: Array.isArray(object?.amount) ? object.amount.map((e: any) => Coin.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: MsgDeposit): MsgDepositSDKType { + const obj: any = {}; + obj.proposal_id = message.proposalId; + obj.depositor = message.depositor; + if (message.amount) { + obj.amount = message.amount.map(e => e ? Coin.toSDK(e) : undefined); + } else { + obj.amount = []; + } + return obj; + }, + fromAmino(object: MsgDepositAmino): MsgDeposit { + const message = createBaseMsgDeposit(); + if (object.proposal_id !== undefined && object.proposal_id !== null) { + message.proposalId = BigInt(object.proposal_id); + } + if (object.depositor !== undefined && object.depositor !== null) { + message.depositor = object.depositor; + } + message.amount = object.amount?.map(e => Coin.fromAmino(e)) || []; + return message; + }, + toAmino(message: MsgDeposit): MsgDepositAmino { + const obj: any = {}; + obj.proposal_id = message.proposalId ? message.proposalId?.toString() : "0"; + obj.depositor = message.depositor === "" ? undefined : message.depositor; + if (message.amount) { + obj.amount = message.amount.map(e => e ? Coin.toAmino(e) : undefined); + } else { + obj.amount = message.amount; + } + return obj; + }, + fromAminoMsg(object: MsgDepositAminoMsg): MsgDeposit { + return MsgDeposit.fromAmino(object.value); + }, + toAminoMsg(message: MsgDeposit): MsgDepositAminoMsg { + return { + type: "cosmos-sdk/MsgDeposit", + value: MsgDeposit.toAmino(message) + }; + }, + fromProtoMsg(message: MsgDepositProtoMsg): MsgDeposit { + return MsgDeposit.decode(message.value); + }, + toProto(message: MsgDeposit): Uint8Array { + return MsgDeposit.encode(message).finish(); + }, + toProtoMsg(message: MsgDeposit): MsgDepositProtoMsg { + return { + typeUrl: "/cosmos.gov.v1beta1.MsgDeposit", + value: MsgDeposit.encode(message).finish() + }; + } +}; +function createBaseMsgDepositResponse(): MsgDepositResponse { + return {}; +} +export const MsgDepositResponse = { + typeUrl: "/cosmos.gov.v1beta1.MsgDepositResponse", + encode(_: MsgDepositResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgDepositResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgDepositResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgDepositResponse { + const obj = createBaseMsgDepositResponse(); + return obj; + }, + toJSON(_: MsgDepositResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): MsgDepositResponse { + const message = createBaseMsgDepositResponse(); + return message; + }, + fromSDK(_: MsgDepositResponseSDKType): MsgDepositResponse { + return {}; + }, + fromSDKJSON(_: any): MsgDepositResponseSDKType { + return {}; + }, + toSDK(_: MsgDepositResponse): MsgDepositResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgDepositResponseAmino): MsgDepositResponse { + const message = createBaseMsgDepositResponse(); + return message; + }, + toAmino(_: MsgDepositResponse): MsgDepositResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgDepositResponseAminoMsg): MsgDepositResponse { + return MsgDepositResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgDepositResponse): MsgDepositResponseAminoMsg { + return { + type: "cosmos-sdk/MsgDepositResponse", + value: MsgDepositResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgDepositResponseProtoMsg): MsgDepositResponse { + return MsgDepositResponse.decode(message.value); + }, + toProto(message: MsgDepositResponse): Uint8Array { + return MsgDepositResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgDepositResponse): MsgDepositResponseProtoMsg { + return { + typeUrl: "/cosmos.gov.v1beta1.MsgDepositResponse", + value: MsgDepositResponse.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/group/v1/events.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/group/v1/events.ts new file mode 100644 index 0000000000..4218f5633e --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/group/v1/events.ts @@ -0,0 +1,1022 @@ +import { ProposalExecutorResult, ProposalExecutorResultSDKType, proposalExecutorResultFromJSON, proposalExecutorResultToJSON } from "./types.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "cosmos.group.v1"; +/** EventCreateGroup is an event emitted when a group is created. */ +export interface EventCreateGroup { + /** group_id is the unique ID of the group. */ + groupId: bigint; +} +export interface EventCreateGroupProtoMsg { + typeUrl: "/cosmos.group.v1.EventCreateGroup"; + value: Uint8Array; +} +/** EventCreateGroup is an event emitted when a group is created. */ +export interface EventCreateGroupSDKType { + group_id: bigint; +} +/** EventUpdateGroup is an event emitted when a group is updated. */ +export interface EventUpdateGroup { + /** group_id is the unique ID of the group. */ + groupId: bigint; +} +export interface EventUpdateGroupProtoMsg { + typeUrl: "/cosmos.group.v1.EventUpdateGroup"; + value: Uint8Array; +} +/** EventUpdateGroup is an event emitted when a group is updated. */ +export interface EventUpdateGroupSDKType { + group_id: bigint; +} +/** EventCreateGroupPolicy is an event emitted when a group policy is created. */ +export interface EventCreateGroupPolicy { + /** address is the account address of the group policy. */ + address: string; +} +export interface EventCreateGroupPolicyProtoMsg { + typeUrl: "/cosmos.group.v1.EventCreateGroupPolicy"; + value: Uint8Array; +} +/** EventCreateGroupPolicy is an event emitted when a group policy is created. */ +export interface EventCreateGroupPolicySDKType { + address: string; +} +/** EventUpdateGroupPolicy is an event emitted when a group policy is updated. */ +export interface EventUpdateGroupPolicy { + /** address is the account address of the group policy. */ + address: string; +} +export interface EventUpdateGroupPolicyProtoMsg { + typeUrl: "/cosmos.group.v1.EventUpdateGroupPolicy"; + value: Uint8Array; +} +/** EventUpdateGroupPolicy is an event emitted when a group policy is updated. */ +export interface EventUpdateGroupPolicySDKType { + address: string; +} +/** EventSubmitProposal is an event emitted when a proposal is created. */ +export interface EventSubmitProposal { + /** proposal_id is the unique ID of the proposal. */ + proposalId: bigint; +} +export interface EventSubmitProposalProtoMsg { + typeUrl: "/cosmos.group.v1.EventSubmitProposal"; + value: Uint8Array; +} +/** EventSubmitProposal is an event emitted when a proposal is created. */ +export interface EventSubmitProposalSDKType { + proposal_id: bigint; +} +/** EventWithdrawProposal is an event emitted when a proposal is withdrawn. */ +export interface EventWithdrawProposal { + /** proposal_id is the unique ID of the proposal. */ + proposalId: bigint; +} +export interface EventWithdrawProposalProtoMsg { + typeUrl: "/cosmos.group.v1.EventWithdrawProposal"; + value: Uint8Array; +} +/** EventWithdrawProposal is an event emitted when a proposal is withdrawn. */ +export interface EventWithdrawProposalSDKType { + proposal_id: bigint; +} +/** EventVote is an event emitted when a voter votes on a proposal. */ +export interface EventVote { + /** proposal_id is the unique ID of the proposal. */ + proposalId: bigint; +} +export interface EventVoteProtoMsg { + typeUrl: "/cosmos.group.v1.EventVote"; + value: Uint8Array; +} +/** EventVote is an event emitted when a voter votes on a proposal. */ +export interface EventVoteSDKType { + proposal_id: bigint; +} +/** EventExec is an event emitted when a proposal is executed. */ +export interface EventExec { + /** proposal_id is the unique ID of the proposal. */ + proposalId: bigint; + /** result is the proposal execution result. */ + result: ProposalExecutorResult; +} +export interface EventExecProtoMsg { + typeUrl: "/cosmos.group.v1.EventExec"; + value: Uint8Array; +} +/** EventExec is an event emitted when a proposal is executed. */ +export interface EventExecSDKType { + proposal_id: bigint; + result: ProposalExecutorResult; +} +/** EventLeaveGroup is an event emitted when group member leaves the group. */ +export interface EventLeaveGroup { + /** group_id is the unique ID of the group. */ + groupId: bigint; + /** address is the account address of the group member. */ + address: string; +} +export interface EventLeaveGroupProtoMsg { + typeUrl: "/cosmos.group.v1.EventLeaveGroup"; + value: Uint8Array; +} +/** EventLeaveGroup is an event emitted when group member leaves the group. */ +export interface EventLeaveGroupSDKType { + group_id: bigint; + address: string; +} +function createBaseEventCreateGroup(): EventCreateGroup { + return { + groupId: BigInt(0) + }; +} +export const EventCreateGroup = { + typeUrl: "/cosmos.group.v1.EventCreateGroup", + encode(message: EventCreateGroup, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.groupId !== undefined) { + writer.uint32(8).uint64(message.groupId); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): EventCreateGroup { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseEventCreateGroup(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.groupId = reader.uint64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): EventCreateGroup { + const obj = createBaseEventCreateGroup(); + if (isSet(object.groupId)) obj.groupId = BigInt(object.groupId.toString()); + return obj; + }, + toJSON(message: EventCreateGroup): JsonSafe { + const obj: any = {}; + message.groupId !== undefined && (obj.groupId = (message.groupId || BigInt(0)).toString()); + return obj; + }, + fromPartial(object: DeepPartial): EventCreateGroup { + const message = createBaseEventCreateGroup(); + if (object.groupId !== undefined && object.groupId !== null) { + message.groupId = BigInt(object.groupId.toString()); + } + return message; + }, + fromSDK(object: EventCreateGroupSDKType): EventCreateGroup { + return { + groupId: object?.group_id + }; + }, + fromSDKJSON(object: any): EventCreateGroupSDKType { + return { + group_id: isSet(object.group_id) ? BigInt(object.group_id.toString()) : BigInt(0) + }; + }, + toSDK(message: EventCreateGroup): EventCreateGroupSDKType { + const obj: any = {}; + obj.group_id = message.groupId; + return obj; + }, + fromAmino(object: EventCreateGroupAmino): EventCreateGroup { + const message = createBaseEventCreateGroup(); + if (object.group_id !== undefined && object.group_id !== null) { + message.groupId = BigInt(object.group_id); + } + return message; + }, + toAmino(message: EventCreateGroup): EventCreateGroupAmino { + const obj: any = {}; + obj.group_id = message.groupId !== BigInt(0) ? message.groupId?.toString() : undefined; + return obj; + }, + fromAminoMsg(object: EventCreateGroupAminoMsg): EventCreateGroup { + return EventCreateGroup.fromAmino(object.value); + }, + toAminoMsg(message: EventCreateGroup): EventCreateGroupAminoMsg { + return { + type: "cosmos-sdk/EventCreateGroup", + value: EventCreateGroup.toAmino(message) + }; + }, + fromProtoMsg(message: EventCreateGroupProtoMsg): EventCreateGroup { + return EventCreateGroup.decode(message.value); + }, + toProto(message: EventCreateGroup): Uint8Array { + return EventCreateGroup.encode(message).finish(); + }, + toProtoMsg(message: EventCreateGroup): EventCreateGroupProtoMsg { + return { + typeUrl: "/cosmos.group.v1.EventCreateGroup", + value: EventCreateGroup.encode(message).finish() + }; + } +}; +function createBaseEventUpdateGroup(): EventUpdateGroup { + return { + groupId: BigInt(0) + }; +} +export const EventUpdateGroup = { + typeUrl: "/cosmos.group.v1.EventUpdateGroup", + encode(message: EventUpdateGroup, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.groupId !== undefined) { + writer.uint32(8).uint64(message.groupId); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): EventUpdateGroup { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseEventUpdateGroup(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.groupId = reader.uint64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): EventUpdateGroup { + const obj = createBaseEventUpdateGroup(); + if (isSet(object.groupId)) obj.groupId = BigInt(object.groupId.toString()); + return obj; + }, + toJSON(message: EventUpdateGroup): JsonSafe { + const obj: any = {}; + message.groupId !== undefined && (obj.groupId = (message.groupId || BigInt(0)).toString()); + return obj; + }, + fromPartial(object: DeepPartial): EventUpdateGroup { + const message = createBaseEventUpdateGroup(); + if (object.groupId !== undefined && object.groupId !== null) { + message.groupId = BigInt(object.groupId.toString()); + } + return message; + }, + fromSDK(object: EventUpdateGroupSDKType): EventUpdateGroup { + return { + groupId: object?.group_id + }; + }, + fromSDKJSON(object: any): EventUpdateGroupSDKType { + return { + group_id: isSet(object.group_id) ? BigInt(object.group_id.toString()) : BigInt(0) + }; + }, + toSDK(message: EventUpdateGroup): EventUpdateGroupSDKType { + const obj: any = {}; + obj.group_id = message.groupId; + return obj; + }, + fromAmino(object: EventUpdateGroupAmino): EventUpdateGroup { + const message = createBaseEventUpdateGroup(); + if (object.group_id !== undefined && object.group_id !== null) { + message.groupId = BigInt(object.group_id); + } + return message; + }, + toAmino(message: EventUpdateGroup): EventUpdateGroupAmino { + const obj: any = {}; + obj.group_id = message.groupId !== BigInt(0) ? message.groupId?.toString() : undefined; + return obj; + }, + fromAminoMsg(object: EventUpdateGroupAminoMsg): EventUpdateGroup { + return EventUpdateGroup.fromAmino(object.value); + }, + toAminoMsg(message: EventUpdateGroup): EventUpdateGroupAminoMsg { + return { + type: "cosmos-sdk/EventUpdateGroup", + value: EventUpdateGroup.toAmino(message) + }; + }, + fromProtoMsg(message: EventUpdateGroupProtoMsg): EventUpdateGroup { + return EventUpdateGroup.decode(message.value); + }, + toProto(message: EventUpdateGroup): Uint8Array { + return EventUpdateGroup.encode(message).finish(); + }, + toProtoMsg(message: EventUpdateGroup): EventUpdateGroupProtoMsg { + return { + typeUrl: "/cosmos.group.v1.EventUpdateGroup", + value: EventUpdateGroup.encode(message).finish() + }; + } +}; +function createBaseEventCreateGroupPolicy(): EventCreateGroupPolicy { + return { + address: "" + }; +} +export const EventCreateGroupPolicy = { + typeUrl: "/cosmos.group.v1.EventCreateGroupPolicy", + encode(message: EventCreateGroupPolicy, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.address !== undefined) { + writer.uint32(10).string(message.address); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): EventCreateGroupPolicy { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseEventCreateGroupPolicy(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): EventCreateGroupPolicy { + const obj = createBaseEventCreateGroupPolicy(); + if (isSet(object.address)) obj.address = String(object.address); + return obj; + }, + toJSON(message: EventCreateGroupPolicy): JsonSafe { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + return obj; + }, + fromPartial(object: DeepPartial): EventCreateGroupPolicy { + const message = createBaseEventCreateGroupPolicy(); + message.address = object.address ?? ""; + return message; + }, + fromSDK(object: EventCreateGroupPolicySDKType): EventCreateGroupPolicy { + return { + address: object?.address + }; + }, + fromSDKJSON(object: any): EventCreateGroupPolicySDKType { + return { + address: isSet(object.address) ? String(object.address) : "" + }; + }, + toSDK(message: EventCreateGroupPolicy): EventCreateGroupPolicySDKType { + const obj: any = {}; + obj.address = message.address; + return obj; + }, + fromAmino(object: EventCreateGroupPolicyAmino): EventCreateGroupPolicy { + const message = createBaseEventCreateGroupPolicy(); + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } + return message; + }, + toAmino(message: EventCreateGroupPolicy): EventCreateGroupPolicyAmino { + const obj: any = {}; + obj.address = message.address === "" ? undefined : message.address; + return obj; + }, + fromAminoMsg(object: EventCreateGroupPolicyAminoMsg): EventCreateGroupPolicy { + return EventCreateGroupPolicy.fromAmino(object.value); + }, + toAminoMsg(message: EventCreateGroupPolicy): EventCreateGroupPolicyAminoMsg { + return { + type: "cosmos-sdk/EventCreateGroupPolicy", + value: EventCreateGroupPolicy.toAmino(message) + }; + }, + fromProtoMsg(message: EventCreateGroupPolicyProtoMsg): EventCreateGroupPolicy { + return EventCreateGroupPolicy.decode(message.value); + }, + toProto(message: EventCreateGroupPolicy): Uint8Array { + return EventCreateGroupPolicy.encode(message).finish(); + }, + toProtoMsg(message: EventCreateGroupPolicy): EventCreateGroupPolicyProtoMsg { + return { + typeUrl: "/cosmos.group.v1.EventCreateGroupPolicy", + value: EventCreateGroupPolicy.encode(message).finish() + }; + } +}; +function createBaseEventUpdateGroupPolicy(): EventUpdateGroupPolicy { + return { + address: "" + }; +} +export const EventUpdateGroupPolicy = { + typeUrl: "/cosmos.group.v1.EventUpdateGroupPolicy", + encode(message: EventUpdateGroupPolicy, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.address !== undefined) { + writer.uint32(10).string(message.address); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): EventUpdateGroupPolicy { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseEventUpdateGroupPolicy(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): EventUpdateGroupPolicy { + const obj = createBaseEventUpdateGroupPolicy(); + if (isSet(object.address)) obj.address = String(object.address); + return obj; + }, + toJSON(message: EventUpdateGroupPolicy): JsonSafe { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + return obj; + }, + fromPartial(object: DeepPartial): EventUpdateGroupPolicy { + const message = createBaseEventUpdateGroupPolicy(); + message.address = object.address ?? ""; + return message; + }, + fromSDK(object: EventUpdateGroupPolicySDKType): EventUpdateGroupPolicy { + return { + address: object?.address + }; + }, + fromSDKJSON(object: any): EventUpdateGroupPolicySDKType { + return { + address: isSet(object.address) ? String(object.address) : "" + }; + }, + toSDK(message: EventUpdateGroupPolicy): EventUpdateGroupPolicySDKType { + const obj: any = {}; + obj.address = message.address; + return obj; + }, + fromAmino(object: EventUpdateGroupPolicyAmino): EventUpdateGroupPolicy { + const message = createBaseEventUpdateGroupPolicy(); + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } + return message; + }, + toAmino(message: EventUpdateGroupPolicy): EventUpdateGroupPolicyAmino { + const obj: any = {}; + obj.address = message.address === "" ? undefined : message.address; + return obj; + }, + fromAminoMsg(object: EventUpdateGroupPolicyAminoMsg): EventUpdateGroupPolicy { + return EventUpdateGroupPolicy.fromAmino(object.value); + }, + toAminoMsg(message: EventUpdateGroupPolicy): EventUpdateGroupPolicyAminoMsg { + return { + type: "cosmos-sdk/EventUpdateGroupPolicy", + value: EventUpdateGroupPolicy.toAmino(message) + }; + }, + fromProtoMsg(message: EventUpdateGroupPolicyProtoMsg): EventUpdateGroupPolicy { + return EventUpdateGroupPolicy.decode(message.value); + }, + toProto(message: EventUpdateGroupPolicy): Uint8Array { + return EventUpdateGroupPolicy.encode(message).finish(); + }, + toProtoMsg(message: EventUpdateGroupPolicy): EventUpdateGroupPolicyProtoMsg { + return { + typeUrl: "/cosmos.group.v1.EventUpdateGroupPolicy", + value: EventUpdateGroupPolicy.encode(message).finish() + }; + } +}; +function createBaseEventSubmitProposal(): EventSubmitProposal { + return { + proposalId: BigInt(0) + }; +} +export const EventSubmitProposal = { + typeUrl: "/cosmos.group.v1.EventSubmitProposal", + encode(message: EventSubmitProposal, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.proposalId !== undefined) { + writer.uint32(8).uint64(message.proposalId); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): EventSubmitProposal { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseEventSubmitProposal(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.proposalId = reader.uint64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): EventSubmitProposal { + const obj = createBaseEventSubmitProposal(); + if (isSet(object.proposalId)) obj.proposalId = BigInt(object.proposalId.toString()); + return obj; + }, + toJSON(message: EventSubmitProposal): JsonSafe { + const obj: any = {}; + message.proposalId !== undefined && (obj.proposalId = (message.proposalId || BigInt(0)).toString()); + return obj; + }, + fromPartial(object: DeepPartial): EventSubmitProposal { + const message = createBaseEventSubmitProposal(); + if (object.proposalId !== undefined && object.proposalId !== null) { + message.proposalId = BigInt(object.proposalId.toString()); + } + return message; + }, + fromSDK(object: EventSubmitProposalSDKType): EventSubmitProposal { + return { + proposalId: object?.proposal_id + }; + }, + fromSDKJSON(object: any): EventSubmitProposalSDKType { + return { + proposal_id: isSet(object.proposal_id) ? BigInt(object.proposal_id.toString()) : BigInt(0) + }; + }, + toSDK(message: EventSubmitProposal): EventSubmitProposalSDKType { + const obj: any = {}; + obj.proposal_id = message.proposalId; + return obj; + }, + fromAmino(object: EventSubmitProposalAmino): EventSubmitProposal { + const message = createBaseEventSubmitProposal(); + if (object.proposal_id !== undefined && object.proposal_id !== null) { + message.proposalId = BigInt(object.proposal_id); + } + return message; + }, + toAmino(message: EventSubmitProposal): EventSubmitProposalAmino { + const obj: any = {}; + obj.proposal_id = message.proposalId !== BigInt(0) ? message.proposalId?.toString() : undefined; + return obj; + }, + fromAminoMsg(object: EventSubmitProposalAminoMsg): EventSubmitProposal { + return EventSubmitProposal.fromAmino(object.value); + }, + toAminoMsg(message: EventSubmitProposal): EventSubmitProposalAminoMsg { + return { + type: "cosmos-sdk/EventSubmitProposal", + value: EventSubmitProposal.toAmino(message) + }; + }, + fromProtoMsg(message: EventSubmitProposalProtoMsg): EventSubmitProposal { + return EventSubmitProposal.decode(message.value); + }, + toProto(message: EventSubmitProposal): Uint8Array { + return EventSubmitProposal.encode(message).finish(); + }, + toProtoMsg(message: EventSubmitProposal): EventSubmitProposalProtoMsg { + return { + typeUrl: "/cosmos.group.v1.EventSubmitProposal", + value: EventSubmitProposal.encode(message).finish() + }; + } +}; +function createBaseEventWithdrawProposal(): EventWithdrawProposal { + return { + proposalId: BigInt(0) + }; +} +export const EventWithdrawProposal = { + typeUrl: "/cosmos.group.v1.EventWithdrawProposal", + encode(message: EventWithdrawProposal, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.proposalId !== undefined) { + writer.uint32(8).uint64(message.proposalId); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): EventWithdrawProposal { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseEventWithdrawProposal(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.proposalId = reader.uint64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): EventWithdrawProposal { + const obj = createBaseEventWithdrawProposal(); + if (isSet(object.proposalId)) obj.proposalId = BigInt(object.proposalId.toString()); + return obj; + }, + toJSON(message: EventWithdrawProposal): JsonSafe { + const obj: any = {}; + message.proposalId !== undefined && (obj.proposalId = (message.proposalId || BigInt(0)).toString()); + return obj; + }, + fromPartial(object: DeepPartial): EventWithdrawProposal { + const message = createBaseEventWithdrawProposal(); + if (object.proposalId !== undefined && object.proposalId !== null) { + message.proposalId = BigInt(object.proposalId.toString()); + } + return message; + }, + fromSDK(object: EventWithdrawProposalSDKType): EventWithdrawProposal { + return { + proposalId: object?.proposal_id + }; + }, + fromSDKJSON(object: any): EventWithdrawProposalSDKType { + return { + proposal_id: isSet(object.proposal_id) ? BigInt(object.proposal_id.toString()) : BigInt(0) + }; + }, + toSDK(message: EventWithdrawProposal): EventWithdrawProposalSDKType { + const obj: any = {}; + obj.proposal_id = message.proposalId; + return obj; + }, + fromAmino(object: EventWithdrawProposalAmino): EventWithdrawProposal { + const message = createBaseEventWithdrawProposal(); + if (object.proposal_id !== undefined && object.proposal_id !== null) { + message.proposalId = BigInt(object.proposal_id); + } + return message; + }, + toAmino(message: EventWithdrawProposal): EventWithdrawProposalAmino { + const obj: any = {}; + obj.proposal_id = message.proposalId !== BigInt(0) ? message.proposalId?.toString() : undefined; + return obj; + }, + fromAminoMsg(object: EventWithdrawProposalAminoMsg): EventWithdrawProposal { + return EventWithdrawProposal.fromAmino(object.value); + }, + toAminoMsg(message: EventWithdrawProposal): EventWithdrawProposalAminoMsg { + return { + type: "cosmos-sdk/EventWithdrawProposal", + value: EventWithdrawProposal.toAmino(message) + }; + }, + fromProtoMsg(message: EventWithdrawProposalProtoMsg): EventWithdrawProposal { + return EventWithdrawProposal.decode(message.value); + }, + toProto(message: EventWithdrawProposal): Uint8Array { + return EventWithdrawProposal.encode(message).finish(); + }, + toProtoMsg(message: EventWithdrawProposal): EventWithdrawProposalProtoMsg { + return { + typeUrl: "/cosmos.group.v1.EventWithdrawProposal", + value: EventWithdrawProposal.encode(message).finish() + }; + } +}; +function createBaseEventVote(): EventVote { + return { + proposalId: BigInt(0) + }; +} +export const EventVote = { + typeUrl: "/cosmos.group.v1.EventVote", + encode(message: EventVote, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.proposalId !== undefined) { + writer.uint32(8).uint64(message.proposalId); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): EventVote { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseEventVote(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.proposalId = reader.uint64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): EventVote { + const obj = createBaseEventVote(); + if (isSet(object.proposalId)) obj.proposalId = BigInt(object.proposalId.toString()); + return obj; + }, + toJSON(message: EventVote): JsonSafe { + const obj: any = {}; + message.proposalId !== undefined && (obj.proposalId = (message.proposalId || BigInt(0)).toString()); + return obj; + }, + fromPartial(object: DeepPartial): EventVote { + const message = createBaseEventVote(); + if (object.proposalId !== undefined && object.proposalId !== null) { + message.proposalId = BigInt(object.proposalId.toString()); + } + return message; + }, + fromSDK(object: EventVoteSDKType): EventVote { + return { + proposalId: object?.proposal_id + }; + }, + fromSDKJSON(object: any): EventVoteSDKType { + return { + proposal_id: isSet(object.proposal_id) ? BigInt(object.proposal_id.toString()) : BigInt(0) + }; + }, + toSDK(message: EventVote): EventVoteSDKType { + const obj: any = {}; + obj.proposal_id = message.proposalId; + return obj; + }, + fromAmino(object: EventVoteAmino): EventVote { + const message = createBaseEventVote(); + if (object.proposal_id !== undefined && object.proposal_id !== null) { + message.proposalId = BigInt(object.proposal_id); + } + return message; + }, + toAmino(message: EventVote): EventVoteAmino { + const obj: any = {}; + obj.proposal_id = message.proposalId !== BigInt(0) ? message.proposalId?.toString() : undefined; + return obj; + }, + fromAminoMsg(object: EventVoteAminoMsg): EventVote { + return EventVote.fromAmino(object.value); + }, + toAminoMsg(message: EventVote): EventVoteAminoMsg { + return { + type: "cosmos-sdk/EventVote", + value: EventVote.toAmino(message) + }; + }, + fromProtoMsg(message: EventVoteProtoMsg): EventVote { + return EventVote.decode(message.value); + }, + toProto(message: EventVote): Uint8Array { + return EventVote.encode(message).finish(); + }, + toProtoMsg(message: EventVote): EventVoteProtoMsg { + return { + typeUrl: "/cosmos.group.v1.EventVote", + value: EventVote.encode(message).finish() + }; + } +}; +function createBaseEventExec(): EventExec { + return { + proposalId: BigInt(0), + result: 0 + }; +} +export const EventExec = { + typeUrl: "/cosmos.group.v1.EventExec", + encode(message: EventExec, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.proposalId !== undefined) { + writer.uint32(8).uint64(message.proposalId); + } + if (message.result !== 0) { + writer.uint32(16).int32(message.result); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): EventExec { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseEventExec(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.proposalId = reader.uint64(); + break; + case 2: + message.result = (reader.int32() as any); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): EventExec { + const obj = createBaseEventExec(); + if (isSet(object.proposalId)) obj.proposalId = BigInt(object.proposalId.toString()); + if (isSet(object.result)) obj.result = proposalExecutorResultFromJSON(object.result); + return obj; + }, + toJSON(message: EventExec): JsonSafe { + const obj: any = {}; + message.proposalId !== undefined && (obj.proposalId = (message.proposalId || BigInt(0)).toString()); + message.result !== undefined && (obj.result = proposalExecutorResultToJSON(message.result)); + return obj; + }, + fromPartial(object: DeepPartial): EventExec { + const message = createBaseEventExec(); + if (object.proposalId !== undefined && object.proposalId !== null) { + message.proposalId = BigInt(object.proposalId.toString()); + } + message.result = object.result ?? 0; + return message; + }, + fromSDK(object: EventExecSDKType): EventExec { + return { + proposalId: object?.proposal_id, + result: isSet(object.result) ? proposalExecutorResultFromJSON(object.result) : -1 + }; + }, + fromSDKJSON(object: any): EventExecSDKType { + return { + proposal_id: isSet(object.proposal_id) ? BigInt(object.proposal_id.toString()) : BigInt(0), + result: isSet(object.result) ? proposalExecutorResultFromJSON(object.result) : -1 + }; + }, + toSDK(message: EventExec): EventExecSDKType { + const obj: any = {}; + obj.proposal_id = message.proposalId; + message.result !== undefined && (obj.result = proposalExecutorResultToJSON(message.result)); + return obj; + }, + fromAmino(object: EventExecAmino): EventExec { + const message = createBaseEventExec(); + if (object.proposal_id !== undefined && object.proposal_id !== null) { + message.proposalId = BigInt(object.proposal_id); + } + if (object.result !== undefined && object.result !== null) { + message.result = object.result; + } + return message; + }, + toAmino(message: EventExec): EventExecAmino { + const obj: any = {}; + obj.proposal_id = message.proposalId !== BigInt(0) ? message.proposalId?.toString() : undefined; + obj.result = message.result === 0 ? undefined : message.result; + return obj; + }, + fromAminoMsg(object: EventExecAminoMsg): EventExec { + return EventExec.fromAmino(object.value); + }, + toAminoMsg(message: EventExec): EventExecAminoMsg { + return { + type: "cosmos-sdk/EventExec", + value: EventExec.toAmino(message) + }; + }, + fromProtoMsg(message: EventExecProtoMsg): EventExec { + return EventExec.decode(message.value); + }, + toProto(message: EventExec): Uint8Array { + return EventExec.encode(message).finish(); + }, + toProtoMsg(message: EventExec): EventExecProtoMsg { + return { + typeUrl: "/cosmos.group.v1.EventExec", + value: EventExec.encode(message).finish() + }; + } +}; +function createBaseEventLeaveGroup(): EventLeaveGroup { + return { + groupId: BigInt(0), + address: "" + }; +} +export const EventLeaveGroup = { + typeUrl: "/cosmos.group.v1.EventLeaveGroup", + encode(message: EventLeaveGroup, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.groupId !== undefined) { + writer.uint32(8).uint64(message.groupId); + } + if (message.address !== undefined) { + writer.uint32(18).string(message.address); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): EventLeaveGroup { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseEventLeaveGroup(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.groupId = reader.uint64(); + break; + case 2: + message.address = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): EventLeaveGroup { + const obj = createBaseEventLeaveGroup(); + if (isSet(object.groupId)) obj.groupId = BigInt(object.groupId.toString()); + if (isSet(object.address)) obj.address = String(object.address); + return obj; + }, + toJSON(message: EventLeaveGroup): JsonSafe { + const obj: any = {}; + message.groupId !== undefined && (obj.groupId = (message.groupId || BigInt(0)).toString()); + message.address !== undefined && (obj.address = message.address); + return obj; + }, + fromPartial(object: DeepPartial): EventLeaveGroup { + const message = createBaseEventLeaveGroup(); + if (object.groupId !== undefined && object.groupId !== null) { + message.groupId = BigInt(object.groupId.toString()); + } + message.address = object.address ?? ""; + return message; + }, + fromSDK(object: EventLeaveGroupSDKType): EventLeaveGroup { + return { + groupId: object?.group_id, + address: object?.address + }; + }, + fromSDKJSON(object: any): EventLeaveGroupSDKType { + return { + group_id: isSet(object.group_id) ? BigInt(object.group_id.toString()) : BigInt(0), + address: isSet(object.address) ? String(object.address) : "" + }; + }, + toSDK(message: EventLeaveGroup): EventLeaveGroupSDKType { + const obj: any = {}; + obj.group_id = message.groupId; + obj.address = message.address; + return obj; + }, + fromAmino(object: EventLeaveGroupAmino): EventLeaveGroup { + const message = createBaseEventLeaveGroup(); + if (object.group_id !== undefined && object.group_id !== null) { + message.groupId = BigInt(object.group_id); + } + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } + return message; + }, + toAmino(message: EventLeaveGroup): EventLeaveGroupAmino { + const obj: any = {}; + obj.group_id = message.groupId !== BigInt(0) ? message.groupId?.toString() : undefined; + obj.address = message.address === "" ? undefined : message.address; + return obj; + }, + fromAminoMsg(object: EventLeaveGroupAminoMsg): EventLeaveGroup { + return EventLeaveGroup.fromAmino(object.value); + }, + toAminoMsg(message: EventLeaveGroup): EventLeaveGroupAminoMsg { + return { + type: "cosmos-sdk/EventLeaveGroup", + value: EventLeaveGroup.toAmino(message) + }; + }, + fromProtoMsg(message: EventLeaveGroupProtoMsg): EventLeaveGroup { + return EventLeaveGroup.decode(message.value); + }, + toProto(message: EventLeaveGroup): Uint8Array { + return EventLeaveGroup.encode(message).finish(); + }, + toProtoMsg(message: EventLeaveGroup): EventLeaveGroupProtoMsg { + return { + typeUrl: "/cosmos.group.v1.EventLeaveGroup", + value: EventLeaveGroup.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/group/v1/genesis.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/group/v1/genesis.ts new file mode 100644 index 0000000000..1c6320c3fd --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/group/v1/genesis.ts @@ -0,0 +1,317 @@ +import { GroupInfo, GroupInfoSDKType, GroupMember, GroupMemberSDKType, GroupPolicyInfo, GroupPolicyInfoSDKType, Proposal, ProposalSDKType, Vote, VoteSDKType } from "./types.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "cosmos.group.v1"; +/** GenesisState defines the group module's genesis state. */ +export interface GenesisState { + /** + * group_seq is the group table orm.Sequence, + * it is used to get the next group ID. + */ + groupSeq: bigint; + /** groups is the list of groups info. */ + groups: GroupInfo[]; + /** group_members is the list of groups members. */ + groupMembers: GroupMember[]; + /** + * group_policy_seq is the group policy table orm.Sequence, + * it is used to generate the next group policy account address. + */ + groupPolicySeq: bigint; + /** group_policies is the list of group policies info. */ + groupPolicies: GroupPolicyInfo[]; + /** + * proposal_seq is the proposal table orm.Sequence, + * it is used to get the next proposal ID. + */ + proposalSeq: bigint; + /** proposals is the list of proposals. */ + proposals: Proposal[]; + /** votes is the list of votes. */ + votes: Vote[]; +} +export interface GenesisStateProtoMsg { + typeUrl: "/cosmos.group.v1.GenesisState"; + value: Uint8Array; +} +/** GenesisState defines the group module's genesis state. */ +export interface GenesisStateSDKType { + group_seq: bigint; + groups: GroupInfoSDKType[]; + group_members: GroupMemberSDKType[]; + group_policy_seq: bigint; + group_policies: GroupPolicyInfoSDKType[]; + proposal_seq: bigint; + proposals: ProposalSDKType[]; + votes: VoteSDKType[]; +} +function createBaseGenesisState(): GenesisState { + return { + groupSeq: BigInt(0), + groups: [], + groupMembers: [], + groupPolicySeq: BigInt(0), + groupPolicies: [], + proposalSeq: BigInt(0), + proposals: [], + votes: [] + }; +} +export const GenesisState = { + typeUrl: "/cosmos.group.v1.GenesisState", + encode(message: GenesisState, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.groupSeq !== undefined) { + writer.uint32(8).uint64(message.groupSeq); + } + for (const v of message.groups) { + GroupInfo.encode(v!, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.groupMembers) { + GroupMember.encode(v!, writer.uint32(26).fork()).ldelim(); + } + if (message.groupPolicySeq !== undefined) { + writer.uint32(32).uint64(message.groupPolicySeq); + } + for (const v of message.groupPolicies) { + GroupPolicyInfo.encode(v!, writer.uint32(42).fork()).ldelim(); + } + if (message.proposalSeq !== undefined) { + writer.uint32(48).uint64(message.proposalSeq); + } + for (const v of message.proposals) { + Proposal.encode(v!, writer.uint32(58).fork()).ldelim(); + } + for (const v of message.votes) { + Vote.encode(v!, writer.uint32(66).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GenesisState { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGenesisState(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.groupSeq = reader.uint64(); + break; + case 2: + message.groups.push(GroupInfo.decode(reader, reader.uint32())); + break; + case 3: + message.groupMembers.push(GroupMember.decode(reader, reader.uint32())); + break; + case 4: + message.groupPolicySeq = reader.uint64(); + break; + case 5: + message.groupPolicies.push(GroupPolicyInfo.decode(reader, reader.uint32())); + break; + case 6: + message.proposalSeq = reader.uint64(); + break; + case 7: + message.proposals.push(Proposal.decode(reader, reader.uint32())); + break; + case 8: + message.votes.push(Vote.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GenesisState { + const obj = createBaseGenesisState(); + if (isSet(object.groupSeq)) obj.groupSeq = BigInt(object.groupSeq.toString()); + if (Array.isArray(object?.groups)) obj.groups = object.groups.map((e: any) => GroupInfo.fromJSON(e)); + if (Array.isArray(object?.groupMembers)) obj.groupMembers = object.groupMembers.map((e: any) => GroupMember.fromJSON(e)); + if (isSet(object.groupPolicySeq)) obj.groupPolicySeq = BigInt(object.groupPolicySeq.toString()); + if (Array.isArray(object?.groupPolicies)) obj.groupPolicies = object.groupPolicies.map((e: any) => GroupPolicyInfo.fromJSON(e)); + if (isSet(object.proposalSeq)) obj.proposalSeq = BigInt(object.proposalSeq.toString()); + if (Array.isArray(object?.proposals)) obj.proposals = object.proposals.map((e: any) => Proposal.fromJSON(e)); + if (Array.isArray(object?.votes)) obj.votes = object.votes.map((e: any) => Vote.fromJSON(e)); + return obj; + }, + toJSON(message: GenesisState): JsonSafe { + const obj: any = {}; + message.groupSeq !== undefined && (obj.groupSeq = (message.groupSeq || BigInt(0)).toString()); + if (message.groups) { + obj.groups = message.groups.map(e => e ? GroupInfo.toJSON(e) : undefined); + } else { + obj.groups = []; + } + if (message.groupMembers) { + obj.groupMembers = message.groupMembers.map(e => e ? GroupMember.toJSON(e) : undefined); + } else { + obj.groupMembers = []; + } + message.groupPolicySeq !== undefined && (obj.groupPolicySeq = (message.groupPolicySeq || BigInt(0)).toString()); + if (message.groupPolicies) { + obj.groupPolicies = message.groupPolicies.map(e => e ? GroupPolicyInfo.toJSON(e) : undefined); + } else { + obj.groupPolicies = []; + } + message.proposalSeq !== undefined && (obj.proposalSeq = (message.proposalSeq || BigInt(0)).toString()); + if (message.proposals) { + obj.proposals = message.proposals.map(e => e ? Proposal.toJSON(e) : undefined); + } else { + obj.proposals = []; + } + if (message.votes) { + obj.votes = message.votes.map(e => e ? Vote.toJSON(e) : undefined); + } else { + obj.votes = []; + } + return obj; + }, + fromPartial(object: DeepPartial): GenesisState { + const message = createBaseGenesisState(); + if (object.groupSeq !== undefined && object.groupSeq !== null) { + message.groupSeq = BigInt(object.groupSeq.toString()); + } + message.groups = object.groups?.map(e => GroupInfo.fromPartial(e)) || []; + message.groupMembers = object.groupMembers?.map(e => GroupMember.fromPartial(e)) || []; + if (object.groupPolicySeq !== undefined && object.groupPolicySeq !== null) { + message.groupPolicySeq = BigInt(object.groupPolicySeq.toString()); + } + message.groupPolicies = object.groupPolicies?.map(e => GroupPolicyInfo.fromPartial(e)) || []; + if (object.proposalSeq !== undefined && object.proposalSeq !== null) { + message.proposalSeq = BigInt(object.proposalSeq.toString()); + } + message.proposals = object.proposals?.map(e => Proposal.fromPartial(e)) || []; + message.votes = object.votes?.map(e => Vote.fromPartial(e)) || []; + return message; + }, + fromSDK(object: GenesisStateSDKType): GenesisState { + return { + groupSeq: object?.group_seq, + groups: Array.isArray(object?.groups) ? object.groups.map((e: any) => GroupInfo.fromSDK(e)) : [], + groupMembers: Array.isArray(object?.group_members) ? object.group_members.map((e: any) => GroupMember.fromSDK(e)) : [], + groupPolicySeq: object?.group_policy_seq, + groupPolicies: Array.isArray(object?.group_policies) ? object.group_policies.map((e: any) => GroupPolicyInfo.fromSDK(e)) : [], + proposalSeq: object?.proposal_seq, + proposals: Array.isArray(object?.proposals) ? object.proposals.map((e: any) => Proposal.fromSDK(e)) : [], + votes: Array.isArray(object?.votes) ? object.votes.map((e: any) => Vote.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): GenesisStateSDKType { + return { + group_seq: isSet(object.group_seq) ? BigInt(object.group_seq.toString()) : BigInt(0), + groups: Array.isArray(object?.groups) ? object.groups.map((e: any) => GroupInfo.fromSDKJSON(e)) : [], + group_members: Array.isArray(object?.group_members) ? object.group_members.map((e: any) => GroupMember.fromSDKJSON(e)) : [], + group_policy_seq: isSet(object.group_policy_seq) ? BigInt(object.group_policy_seq.toString()) : BigInt(0), + group_policies: Array.isArray(object?.group_policies) ? object.group_policies.map((e: any) => GroupPolicyInfo.fromSDKJSON(e)) : [], + proposal_seq: isSet(object.proposal_seq) ? BigInt(object.proposal_seq.toString()) : BigInt(0), + proposals: Array.isArray(object?.proposals) ? object.proposals.map((e: any) => Proposal.fromSDKJSON(e)) : [], + votes: Array.isArray(object?.votes) ? object.votes.map((e: any) => Vote.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: GenesisState): GenesisStateSDKType { + const obj: any = {}; + obj.group_seq = message.groupSeq; + if (message.groups) { + obj.groups = message.groups.map(e => e ? GroupInfo.toSDK(e) : undefined); + } else { + obj.groups = []; + } + if (message.groupMembers) { + obj.group_members = message.groupMembers.map(e => e ? GroupMember.toSDK(e) : undefined); + } else { + obj.group_members = []; + } + obj.group_policy_seq = message.groupPolicySeq; + if (message.groupPolicies) { + obj.group_policies = message.groupPolicies.map(e => e ? GroupPolicyInfo.toSDK(e) : undefined); + } else { + obj.group_policies = []; + } + obj.proposal_seq = message.proposalSeq; + if (message.proposals) { + obj.proposals = message.proposals.map(e => e ? Proposal.toSDK(e) : undefined); + } else { + obj.proposals = []; + } + if (message.votes) { + obj.votes = message.votes.map(e => e ? Vote.toSDK(e) : undefined); + } else { + obj.votes = []; + } + return obj; + }, + fromAmino(object: GenesisStateAmino): GenesisState { + const message = createBaseGenesisState(); + if (object.group_seq !== undefined && object.group_seq !== null) { + message.groupSeq = BigInt(object.group_seq); + } + message.groups = object.groups?.map(e => GroupInfo.fromAmino(e)) || []; + message.groupMembers = object.group_members?.map(e => GroupMember.fromAmino(e)) || []; + if (object.group_policy_seq !== undefined && object.group_policy_seq !== null) { + message.groupPolicySeq = BigInt(object.group_policy_seq); + } + message.groupPolicies = object.group_policies?.map(e => GroupPolicyInfo.fromAmino(e)) || []; + if (object.proposal_seq !== undefined && object.proposal_seq !== null) { + message.proposalSeq = BigInt(object.proposal_seq); + } + message.proposals = object.proposals?.map(e => Proposal.fromAmino(e)) || []; + message.votes = object.votes?.map(e => Vote.fromAmino(e)) || []; + return message; + }, + toAmino(message: GenesisState): GenesisStateAmino { + const obj: any = {}; + obj.group_seq = message.groupSeq !== BigInt(0) ? message.groupSeq?.toString() : undefined; + if (message.groups) { + obj.groups = message.groups.map(e => e ? GroupInfo.toAmino(e) : undefined); + } else { + obj.groups = message.groups; + } + if (message.groupMembers) { + obj.group_members = message.groupMembers.map(e => e ? GroupMember.toAmino(e) : undefined); + } else { + obj.group_members = message.groupMembers; + } + obj.group_policy_seq = message.groupPolicySeq !== BigInt(0) ? message.groupPolicySeq?.toString() : undefined; + if (message.groupPolicies) { + obj.group_policies = message.groupPolicies.map(e => e ? GroupPolicyInfo.toAmino(e) : undefined); + } else { + obj.group_policies = message.groupPolicies; + } + obj.proposal_seq = message.proposalSeq !== BigInt(0) ? message.proposalSeq?.toString() : undefined; + if (message.proposals) { + obj.proposals = message.proposals.map(e => e ? Proposal.toAmino(e) : undefined); + } else { + obj.proposals = message.proposals; + } + if (message.votes) { + obj.votes = message.votes.map(e => e ? Vote.toAmino(e) : undefined); + } else { + obj.votes = message.votes; + } + return obj; + }, + fromAminoMsg(object: GenesisStateAminoMsg): GenesisState { + return GenesisState.fromAmino(object.value); + }, + toAminoMsg(message: GenesisState): GenesisStateAminoMsg { + return { + type: "cosmos-sdk/GenesisState", + value: GenesisState.toAmino(message) + }; + }, + fromProtoMsg(message: GenesisStateProtoMsg): GenesisState { + return GenesisState.decode(message.value); + }, + toProto(message: GenesisState): Uint8Array { + return GenesisState.encode(message).finish(); + }, + toProtoMsg(message: GenesisState): GenesisStateProtoMsg { + return { + typeUrl: "/cosmos.group.v1.GenesisState", + value: GenesisState.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/group/v1/query.lcd.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/group/v1/query.lcd.ts new file mode 100644 index 0000000000..edf01079c2 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/group/v1/query.lcd.ts @@ -0,0 +1,141 @@ +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../base/query/v1beta1/pagination.js"; +import { GroupInfo, GroupInfoSDKType, GroupPolicyInfo, GroupPolicyInfoSDKType, GroupMember, GroupMemberSDKType, Proposal, ProposalSDKType, Vote, VoteSDKType, TallyResult, TallyResultSDKType } from "./types.js"; +import { setPaginationParams } from "../../../helpers.js"; +import { LCDClient } from "@cosmology/lcd"; +import { QueryGroupInfoRequest, QueryGroupInfoRequestSDKType, QueryGroupInfoResponse, QueryGroupInfoResponseSDKType, QueryGroupPolicyInfoRequest, QueryGroupPolicyInfoRequestSDKType, QueryGroupPolicyInfoResponse, QueryGroupPolicyInfoResponseSDKType, QueryGroupMembersRequest, QueryGroupMembersRequestSDKType, QueryGroupMembersResponse, QueryGroupMembersResponseSDKType, QueryGroupsByAdminRequest, QueryGroupsByAdminRequestSDKType, QueryGroupsByAdminResponse, QueryGroupsByAdminResponseSDKType, QueryGroupPoliciesByGroupRequest, QueryGroupPoliciesByGroupRequestSDKType, QueryGroupPoliciesByGroupResponse, QueryGroupPoliciesByGroupResponseSDKType, QueryGroupPoliciesByAdminRequest, QueryGroupPoliciesByAdminRequestSDKType, QueryGroupPoliciesByAdminResponse, QueryGroupPoliciesByAdminResponseSDKType, QueryProposalRequest, QueryProposalRequestSDKType, QueryProposalResponse, QueryProposalResponseSDKType, QueryProposalsByGroupPolicyRequest, QueryProposalsByGroupPolicyRequestSDKType, QueryProposalsByGroupPolicyResponse, QueryProposalsByGroupPolicyResponseSDKType, QueryVoteByProposalVoterRequest, QueryVoteByProposalVoterRequestSDKType, QueryVoteByProposalVoterResponse, QueryVoteByProposalVoterResponseSDKType, QueryVotesByProposalRequest, QueryVotesByProposalRequestSDKType, QueryVotesByProposalResponse, QueryVotesByProposalResponseSDKType, QueryVotesByVoterRequest, QueryVotesByVoterRequestSDKType, QueryVotesByVoterResponse, QueryVotesByVoterResponseSDKType, QueryGroupsByMemberRequest, QueryGroupsByMemberRequestSDKType, QueryGroupsByMemberResponse, QueryGroupsByMemberResponseSDKType, QueryTallyResultRequest, QueryTallyResultRequestSDKType, QueryTallyResultResponse, QueryTallyResultResponseSDKType } from "./query.js"; +export class LCDQueryClient { + req: LCDClient; + constructor({ + requestClient + }: { + requestClient: LCDClient; + }) { + this.req = requestClient; + this.groupInfo = this.groupInfo.bind(this); + this.groupPolicyInfo = this.groupPolicyInfo.bind(this); + this.groupMembers = this.groupMembers.bind(this); + this.groupsByAdmin = this.groupsByAdmin.bind(this); + this.groupPoliciesByGroup = this.groupPoliciesByGroup.bind(this); + this.groupPoliciesByAdmin = this.groupPoliciesByAdmin.bind(this); + this.proposal = this.proposal.bind(this); + this.proposalsByGroupPolicy = this.proposalsByGroupPolicy.bind(this); + this.voteByProposalVoter = this.voteByProposalVoter.bind(this); + this.votesByProposal = this.votesByProposal.bind(this); + this.votesByVoter = this.votesByVoter.bind(this); + this.groupsByMember = this.groupsByMember.bind(this); + this.tallyResult = this.tallyResult.bind(this); + } + /* GroupInfo queries group info based on group id. */ + async groupInfo(params: QueryGroupInfoRequest): Promise { + const endpoint = `cosmos/group/v1/group_info/${params.groupId}`; + return QueryGroupInfoResponse.fromSDKJSON(await this.req.get(endpoint)); + } + /* GroupPolicyInfo queries group policy info based on account address of group policy. */ + async groupPolicyInfo(params: QueryGroupPolicyInfoRequest): Promise { + const endpoint = `cosmos/group/v1/group_policy_info/${params.address}`; + return QueryGroupPolicyInfoResponse.fromSDKJSON(await this.req.get(endpoint)); + } + /* GroupMembers queries members of a group */ + async groupMembers(params: QueryGroupMembersRequest): Promise { + const options: any = { + params: {} + }; + if (typeof params?.pagination !== "undefined") { + setPaginationParams(options, params.pagination); + } + const endpoint = `cosmos/group/v1/group_members/${params.groupId}`; + return QueryGroupMembersResponse.fromSDKJSON(await this.req.get(endpoint, options)); + } + /* GroupsByAdmin queries groups by admin address. */ + async groupsByAdmin(params: QueryGroupsByAdminRequest): Promise { + const options: any = { + params: {} + }; + if (typeof params?.pagination !== "undefined") { + setPaginationParams(options, params.pagination); + } + const endpoint = `cosmos/group/v1/groups_by_admin/${params.admin}`; + return QueryGroupsByAdminResponse.fromSDKJSON(await this.req.get(endpoint, options)); + } + /* GroupPoliciesByGroup queries group policies by group id. */ + async groupPoliciesByGroup(params: QueryGroupPoliciesByGroupRequest): Promise { + const options: any = { + params: {} + }; + if (typeof params?.pagination !== "undefined") { + setPaginationParams(options, params.pagination); + } + const endpoint = `cosmos/group/v1/group_policies_by_group/${params.groupId}`; + return QueryGroupPoliciesByGroupResponse.fromSDKJSON(await this.req.get(endpoint, options)); + } + /* GroupsByAdmin queries group policies by admin address. */ + async groupPoliciesByAdmin(params: QueryGroupPoliciesByAdminRequest): Promise { + const options: any = { + params: {} + }; + if (typeof params?.pagination !== "undefined") { + setPaginationParams(options, params.pagination); + } + const endpoint = `cosmos/group/v1/group_policies_by_admin/${params.admin}`; + return QueryGroupPoliciesByAdminResponse.fromSDKJSON(await this.req.get(endpoint, options)); + } + /* Proposal queries a proposal based on proposal id. */ + async proposal(params: QueryProposalRequest): Promise { + const endpoint = `cosmos/group/v1/proposal/${params.proposalId}`; + return QueryProposalResponse.fromSDKJSON(await this.req.get(endpoint)); + } + /* ProposalsByGroupPolicy queries proposals based on account address of group policy. */ + async proposalsByGroupPolicy(params: QueryProposalsByGroupPolicyRequest): Promise { + const options: any = { + params: {} + }; + if (typeof params?.pagination !== "undefined") { + setPaginationParams(options, params.pagination); + } + const endpoint = `cosmos/group/v1/proposals_by_group_policy/${params.address}`; + return QueryProposalsByGroupPolicyResponse.fromSDKJSON(await this.req.get(endpoint, options)); + } + /* VoteByProposalVoter queries a vote by proposal id and voter. */ + async voteByProposalVoter(params: QueryVoteByProposalVoterRequest): Promise { + const endpoint = `cosmos/group/v1/vote_by_proposal_voter/${params.proposalId}/${params.voter}`; + return QueryVoteByProposalVoterResponse.fromSDKJSON(await this.req.get(endpoint)); + } + /* VotesByProposal queries a vote by proposal. */ + async votesByProposal(params: QueryVotesByProposalRequest): Promise { + const options: any = { + params: {} + }; + if (typeof params?.pagination !== "undefined") { + setPaginationParams(options, params.pagination); + } + const endpoint = `cosmos/group/v1/votes_by_proposal/${params.proposalId}`; + return QueryVotesByProposalResponse.fromSDKJSON(await this.req.get(endpoint, options)); + } + /* VotesByVoter queries a vote by voter. */ + async votesByVoter(params: QueryVotesByVoterRequest): Promise { + const options: any = { + params: {} + }; + if (typeof params?.pagination !== "undefined") { + setPaginationParams(options, params.pagination); + } + const endpoint = `cosmos/group/v1/votes_by_voter/${params.voter}`; + return QueryVotesByVoterResponse.fromSDKJSON(await this.req.get(endpoint, options)); + } + /* GroupsByMember queries groups by member address. */ + async groupsByMember(params: QueryGroupsByMemberRequest): Promise { + const options: any = { + params: {} + }; + if (typeof params?.pagination !== "undefined") { + setPaginationParams(options, params.pagination); + } + const endpoint = `cosmos/group/v1/groups_by_member/${params.address}`; + return QueryGroupsByMemberResponse.fromSDKJSON(await this.req.get(endpoint, options)); + } + /* TallyResult queries the tally of a proposal votes. */ + async tallyResult(params: QueryTallyResultRequest): Promise { + const endpoint = `cosmos/group/v1/proposals/${params.proposalId}/tally`; + return QueryTallyResultResponse.fromSDKJSON(await this.req.get(endpoint)); + } +} \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/group/v1/query.rpc.Query.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/group/v1/query.rpc.Query.ts new file mode 100644 index 0000000000..9c11b2042f --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/group/v1/query.rpc.Query.ts @@ -0,0 +1,164 @@ +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../base/query/v1beta1/pagination.js"; +import { GroupInfo, GroupInfoSDKType, GroupPolicyInfo, GroupPolicyInfoSDKType, GroupMember, GroupMemberSDKType, Proposal, ProposalSDKType, Vote, VoteSDKType, TallyResult, TallyResultSDKType } from "./types.js"; +import { Rpc } from "../../../helpers.js"; +import { BinaryReader } from "../../../binary.js"; +import { QueryClient, createProtobufRpcClient } from "@cosmjs/stargate"; +import { QueryGroupInfoRequest, QueryGroupInfoRequestSDKType, QueryGroupInfoResponse, QueryGroupInfoResponseSDKType, QueryGroupPolicyInfoRequest, QueryGroupPolicyInfoRequestSDKType, QueryGroupPolicyInfoResponse, QueryGroupPolicyInfoResponseSDKType, QueryGroupMembersRequest, QueryGroupMembersRequestSDKType, QueryGroupMembersResponse, QueryGroupMembersResponseSDKType, QueryGroupsByAdminRequest, QueryGroupsByAdminRequestSDKType, QueryGroupsByAdminResponse, QueryGroupsByAdminResponseSDKType, QueryGroupPoliciesByGroupRequest, QueryGroupPoliciesByGroupRequestSDKType, QueryGroupPoliciesByGroupResponse, QueryGroupPoliciesByGroupResponseSDKType, QueryGroupPoliciesByAdminRequest, QueryGroupPoliciesByAdminRequestSDKType, QueryGroupPoliciesByAdminResponse, QueryGroupPoliciesByAdminResponseSDKType, QueryProposalRequest, QueryProposalRequestSDKType, QueryProposalResponse, QueryProposalResponseSDKType, QueryProposalsByGroupPolicyRequest, QueryProposalsByGroupPolicyRequestSDKType, QueryProposalsByGroupPolicyResponse, QueryProposalsByGroupPolicyResponseSDKType, QueryVoteByProposalVoterRequest, QueryVoteByProposalVoterRequestSDKType, QueryVoteByProposalVoterResponse, QueryVoteByProposalVoterResponseSDKType, QueryVotesByProposalRequest, QueryVotesByProposalRequestSDKType, QueryVotesByProposalResponse, QueryVotesByProposalResponseSDKType, QueryVotesByVoterRequest, QueryVotesByVoterRequestSDKType, QueryVotesByVoterResponse, QueryVotesByVoterResponseSDKType, QueryGroupsByMemberRequest, QueryGroupsByMemberRequestSDKType, QueryGroupsByMemberResponse, QueryGroupsByMemberResponseSDKType, QueryTallyResultRequest, QueryTallyResultRequestSDKType, QueryTallyResultResponse, QueryTallyResultResponseSDKType } from "./query.js"; +/** Query is the cosmos.group.v1 Query service. */ +export interface Query { + /** GroupInfo queries group info based on group id. */ + groupInfo(request: QueryGroupInfoRequest): Promise; + /** GroupPolicyInfo queries group policy info based on account address of group policy. */ + groupPolicyInfo(request: QueryGroupPolicyInfoRequest): Promise; + /** GroupMembers queries members of a group */ + groupMembers(request: QueryGroupMembersRequest): Promise; + /** GroupsByAdmin queries groups by admin address. */ + groupsByAdmin(request: QueryGroupsByAdminRequest): Promise; + /** GroupPoliciesByGroup queries group policies by group id. */ + groupPoliciesByGroup(request: QueryGroupPoliciesByGroupRequest): Promise; + /** GroupsByAdmin queries group policies by admin address. */ + groupPoliciesByAdmin(request: QueryGroupPoliciesByAdminRequest): Promise; + /** Proposal queries a proposal based on proposal id. */ + proposal(request: QueryProposalRequest): Promise; + /** ProposalsByGroupPolicy queries proposals based on account address of group policy. */ + proposalsByGroupPolicy(request: QueryProposalsByGroupPolicyRequest): Promise; + /** VoteByProposalVoter queries a vote by proposal id and voter. */ + voteByProposalVoter(request: QueryVoteByProposalVoterRequest): Promise; + /** VotesByProposal queries a vote by proposal. */ + votesByProposal(request: QueryVotesByProposalRequest): Promise; + /** VotesByVoter queries a vote by voter. */ + votesByVoter(request: QueryVotesByVoterRequest): Promise; + /** GroupsByMember queries groups by member address. */ + groupsByMember(request: QueryGroupsByMemberRequest): Promise; + /** TallyResult queries the tally of a proposal votes. */ + tallyResult(request: QueryTallyResultRequest): Promise; +} +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + this.groupInfo = this.groupInfo.bind(this); + this.groupPolicyInfo = this.groupPolicyInfo.bind(this); + this.groupMembers = this.groupMembers.bind(this); + this.groupsByAdmin = this.groupsByAdmin.bind(this); + this.groupPoliciesByGroup = this.groupPoliciesByGroup.bind(this); + this.groupPoliciesByAdmin = this.groupPoliciesByAdmin.bind(this); + this.proposal = this.proposal.bind(this); + this.proposalsByGroupPolicy = this.proposalsByGroupPolicy.bind(this); + this.voteByProposalVoter = this.voteByProposalVoter.bind(this); + this.votesByProposal = this.votesByProposal.bind(this); + this.votesByVoter = this.votesByVoter.bind(this); + this.groupsByMember = this.groupsByMember.bind(this); + this.tallyResult = this.tallyResult.bind(this); + } + groupInfo(request: QueryGroupInfoRequest): Promise { + const data = QueryGroupInfoRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.group.v1.Query", "GroupInfo", data); + return promise.then(data => QueryGroupInfoResponse.decode(new BinaryReader(data))); + } + groupPolicyInfo(request: QueryGroupPolicyInfoRequest): Promise { + const data = QueryGroupPolicyInfoRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.group.v1.Query", "GroupPolicyInfo", data); + return promise.then(data => QueryGroupPolicyInfoResponse.decode(new BinaryReader(data))); + } + groupMembers(request: QueryGroupMembersRequest): Promise { + const data = QueryGroupMembersRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.group.v1.Query", "GroupMembers", data); + return promise.then(data => QueryGroupMembersResponse.decode(new BinaryReader(data))); + } + groupsByAdmin(request: QueryGroupsByAdminRequest): Promise { + const data = QueryGroupsByAdminRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.group.v1.Query", "GroupsByAdmin", data); + return promise.then(data => QueryGroupsByAdminResponse.decode(new BinaryReader(data))); + } + groupPoliciesByGroup(request: QueryGroupPoliciesByGroupRequest): Promise { + const data = QueryGroupPoliciesByGroupRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.group.v1.Query", "GroupPoliciesByGroup", data); + return promise.then(data => QueryGroupPoliciesByGroupResponse.decode(new BinaryReader(data))); + } + groupPoliciesByAdmin(request: QueryGroupPoliciesByAdminRequest): Promise { + const data = QueryGroupPoliciesByAdminRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.group.v1.Query", "GroupPoliciesByAdmin", data); + return promise.then(data => QueryGroupPoliciesByAdminResponse.decode(new BinaryReader(data))); + } + proposal(request: QueryProposalRequest): Promise { + const data = QueryProposalRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.group.v1.Query", "Proposal", data); + return promise.then(data => QueryProposalResponse.decode(new BinaryReader(data))); + } + proposalsByGroupPolicy(request: QueryProposalsByGroupPolicyRequest): Promise { + const data = QueryProposalsByGroupPolicyRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.group.v1.Query", "ProposalsByGroupPolicy", data); + return promise.then(data => QueryProposalsByGroupPolicyResponse.decode(new BinaryReader(data))); + } + voteByProposalVoter(request: QueryVoteByProposalVoterRequest): Promise { + const data = QueryVoteByProposalVoterRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.group.v1.Query", "VoteByProposalVoter", data); + return promise.then(data => QueryVoteByProposalVoterResponse.decode(new BinaryReader(data))); + } + votesByProposal(request: QueryVotesByProposalRequest): Promise { + const data = QueryVotesByProposalRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.group.v1.Query", "VotesByProposal", data); + return promise.then(data => QueryVotesByProposalResponse.decode(new BinaryReader(data))); + } + votesByVoter(request: QueryVotesByVoterRequest): Promise { + const data = QueryVotesByVoterRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.group.v1.Query", "VotesByVoter", data); + return promise.then(data => QueryVotesByVoterResponse.decode(new BinaryReader(data))); + } + groupsByMember(request: QueryGroupsByMemberRequest): Promise { + const data = QueryGroupsByMemberRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.group.v1.Query", "GroupsByMember", data); + return promise.then(data => QueryGroupsByMemberResponse.decode(new BinaryReader(data))); + } + tallyResult(request: QueryTallyResultRequest): Promise { + const data = QueryTallyResultRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.group.v1.Query", "TallyResult", data); + return promise.then(data => QueryTallyResultResponse.decode(new BinaryReader(data))); + } +} +export const createRpcQueryExtension = (base: QueryClient) => { + const rpc = createProtobufRpcClient(base); + const queryService = new QueryClientImpl(rpc); + return { + groupInfo(request: QueryGroupInfoRequest): Promise { + return queryService.groupInfo(request); + }, + groupPolicyInfo(request: QueryGroupPolicyInfoRequest): Promise { + return queryService.groupPolicyInfo(request); + }, + groupMembers(request: QueryGroupMembersRequest): Promise { + return queryService.groupMembers(request); + }, + groupsByAdmin(request: QueryGroupsByAdminRequest): Promise { + return queryService.groupsByAdmin(request); + }, + groupPoliciesByGroup(request: QueryGroupPoliciesByGroupRequest): Promise { + return queryService.groupPoliciesByGroup(request); + }, + groupPoliciesByAdmin(request: QueryGroupPoliciesByAdminRequest): Promise { + return queryService.groupPoliciesByAdmin(request); + }, + proposal(request: QueryProposalRequest): Promise { + return queryService.proposal(request); + }, + proposalsByGroupPolicy(request: QueryProposalsByGroupPolicyRequest): Promise { + return queryService.proposalsByGroupPolicy(request); + }, + voteByProposalVoter(request: QueryVoteByProposalVoterRequest): Promise { + return queryService.voteByProposalVoter(request); + }, + votesByProposal(request: QueryVotesByProposalRequest): Promise { + return queryService.votesByProposal(request); + }, + votesByVoter(request: QueryVotesByVoterRequest): Promise { + return queryService.votesByVoter(request); + }, + groupsByMember(request: QueryGroupsByMemberRequest): Promise { + return queryService.groupsByMember(request); + }, + tallyResult(request: QueryTallyResultRequest): Promise { + return queryService.tallyResult(request); + } + }; +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/group/v1/query.rpc.func.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/group/v1/query.rpc.func.ts new file mode 100644 index 0000000000..95b1c3efcc --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/group/v1/query.rpc.func.ts @@ -0,0 +1,146 @@ +import { RpcResolver, buildQuery } from "../../../helper-func-types"; +import { buildUseQuery } from "../../../react-query"; +import { QueryGroupInfoRequest, QueryGroupInfoResponse, QueryGroupPolicyInfoRequest, QueryGroupPolicyInfoResponse, QueryGroupMembersRequest, QueryGroupMembersResponse, QueryGroupsByAdminRequest, QueryGroupsByAdminResponse, QueryGroupPoliciesByGroupRequest, QueryGroupPoliciesByGroupResponse, QueryGroupPoliciesByAdminRequest, QueryGroupPoliciesByAdminResponse, QueryProposalRequest, QueryProposalResponse, QueryProposalsByGroupPolicyRequest, QueryProposalsByGroupPolicyResponse, QueryVoteByProposalVoterRequest, QueryVoteByProposalVoterResponse, QueryVotesByProposalRequest, QueryVotesByProposalResponse, QueryVotesByVoterRequest, QueryVotesByVoterResponse, QueryGroupsByMemberRequest, QueryGroupsByMemberResponse, QueryTallyResultRequest, QueryTallyResultResponse } from "./query"; +export const createGetGroupInfo = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryGroupInfoRequest.encode, + decode: QueryGroupInfoResponse.decode, + service: "cosmos.group.v1.Query", + method: "GroupInfo", + getRpcInstance: getRpcInstance +}); +export const useGetGroupInfo = buildUseQuery({ + builderQueryFn: createGetGroupInfo, + queryKeyPrefix: "GroupInfoQuery" +}); +export const createGetGroupPolicyInfo = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryGroupPolicyInfoRequest.encode, + decode: QueryGroupPolicyInfoResponse.decode, + service: "cosmos.group.v1.Query", + method: "GroupPolicyInfo", + getRpcInstance: getRpcInstance +}); +export const useGetGroupPolicyInfo = buildUseQuery({ + builderQueryFn: createGetGroupPolicyInfo, + queryKeyPrefix: "GroupPolicyInfoQuery" +}); +export const createGetGroupMembers = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryGroupMembersRequest.encode, + decode: QueryGroupMembersResponse.decode, + service: "cosmos.group.v1.Query", + method: "GroupMembers", + getRpcInstance: getRpcInstance +}); +export const useGetGroupMembers = buildUseQuery({ + builderQueryFn: createGetGroupMembers, + queryKeyPrefix: "GroupMembersQuery" +}); +export const createGetGroupsByAdmin = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryGroupsByAdminRequest.encode, + decode: QueryGroupsByAdminResponse.decode, + service: "cosmos.group.v1.Query", + method: "GroupsByAdmin", + getRpcInstance: getRpcInstance +}); +export const useGetGroupsByAdmin = buildUseQuery({ + builderQueryFn: createGetGroupsByAdmin, + queryKeyPrefix: "GroupsByAdminQuery" +}); +export const createGetGroupPoliciesByGroup = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryGroupPoliciesByGroupRequest.encode, + decode: QueryGroupPoliciesByGroupResponse.decode, + service: "cosmos.group.v1.Query", + method: "GroupPoliciesByGroup", + getRpcInstance: getRpcInstance +}); +export const useGetGroupPoliciesByGroup = buildUseQuery({ + builderQueryFn: createGetGroupPoliciesByGroup, + queryKeyPrefix: "GroupPoliciesByGroupQuery" +}); +export const createGetGroupPoliciesByAdmin = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryGroupPoliciesByAdminRequest.encode, + decode: QueryGroupPoliciesByAdminResponse.decode, + service: "cosmos.group.v1.Query", + method: "GroupPoliciesByAdmin", + getRpcInstance: getRpcInstance +}); +export const useGetGroupPoliciesByAdmin = buildUseQuery({ + builderQueryFn: createGetGroupPoliciesByAdmin, + queryKeyPrefix: "GroupPoliciesByAdminQuery" +}); +export const createGetProposal = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryProposalRequest.encode, + decode: QueryProposalResponse.decode, + service: "cosmos.group.v1.Query", + method: "Proposal", + getRpcInstance: getRpcInstance +}); +export const useGetProposal = buildUseQuery({ + builderQueryFn: createGetProposal, + queryKeyPrefix: "ProposalQuery" +}); +export const createGetProposalsByGroupPolicy = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryProposalsByGroupPolicyRequest.encode, + decode: QueryProposalsByGroupPolicyResponse.decode, + service: "cosmos.group.v1.Query", + method: "ProposalsByGroupPolicy", + getRpcInstance: getRpcInstance +}); +export const useGetProposalsByGroupPolicy = buildUseQuery({ + builderQueryFn: createGetProposalsByGroupPolicy, + queryKeyPrefix: "ProposalsByGroupPolicyQuery" +}); +export const createGetVoteByProposalVoter = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryVoteByProposalVoterRequest.encode, + decode: QueryVoteByProposalVoterResponse.decode, + service: "cosmos.group.v1.Query", + method: "VoteByProposalVoter", + getRpcInstance: getRpcInstance +}); +export const useGetVoteByProposalVoter = buildUseQuery({ + builderQueryFn: createGetVoteByProposalVoter, + queryKeyPrefix: "VoteByProposalVoterQuery" +}); +export const createGetVotesByProposal = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryVotesByProposalRequest.encode, + decode: QueryVotesByProposalResponse.decode, + service: "cosmos.group.v1.Query", + method: "VotesByProposal", + getRpcInstance: getRpcInstance +}); +export const useGetVotesByProposal = buildUseQuery({ + builderQueryFn: createGetVotesByProposal, + queryKeyPrefix: "VotesByProposalQuery" +}); +export const createGetVotesByVoter = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryVotesByVoterRequest.encode, + decode: QueryVotesByVoterResponse.decode, + service: "cosmos.group.v1.Query", + method: "VotesByVoter", + getRpcInstance: getRpcInstance +}); +export const useGetVotesByVoter = buildUseQuery({ + builderQueryFn: createGetVotesByVoter, + queryKeyPrefix: "VotesByVoterQuery" +}); +export const createGetGroupsByMember = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryGroupsByMemberRequest.encode, + decode: QueryGroupsByMemberResponse.decode, + service: "cosmos.group.v1.Query", + method: "GroupsByMember", + getRpcInstance: getRpcInstance +}); +export const useGetGroupsByMember = buildUseQuery({ + builderQueryFn: createGetGroupsByMember, + queryKeyPrefix: "GroupsByMemberQuery" +}); +export const createGetTallyResult = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryTallyResultRequest.encode, + decode: QueryTallyResultResponse.decode, + service: "cosmos.group.v1.Query", + method: "TallyResult", + getRpcInstance: getRpcInstance +}); +export const useGetTallyResult = buildUseQuery({ + builderQueryFn: createGetTallyResult, + queryKeyPrefix: "TallyResultQuery" +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/group/v1/query.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/group/v1/query.ts new file mode 100644 index 0000000000..562060d013 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/group/v1/query.ts @@ -0,0 +1,3264 @@ +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../base/query/v1beta1/pagination.js"; +import { GroupInfo, GroupInfoSDKType, GroupPolicyInfo, GroupPolicyInfoSDKType, GroupMember, GroupMemberSDKType, Proposal, ProposalSDKType, Vote, VoteSDKType, TallyResult, TallyResultSDKType } from "./types.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "cosmos.group.v1"; +/** QueryGroupInfoRequest is the Query/GroupInfo request type. */ +export interface QueryGroupInfoRequest { + /** group_id is the unique ID of the group. */ + groupId: bigint; +} +export interface QueryGroupInfoRequestProtoMsg { + typeUrl: "/cosmos.group.v1.QueryGroupInfoRequest"; + value: Uint8Array; +} +/** QueryGroupInfoRequest is the Query/GroupInfo request type. */ +export interface QueryGroupInfoRequestSDKType { + group_id: bigint; +} +/** QueryGroupInfoResponse is the Query/GroupInfo response type. */ +export interface QueryGroupInfoResponse { + /** info is the GroupInfo for the group. */ + info?: GroupInfo; +} +export interface QueryGroupInfoResponseProtoMsg { + typeUrl: "/cosmos.group.v1.QueryGroupInfoResponse"; + value: Uint8Array; +} +/** QueryGroupInfoResponse is the Query/GroupInfo response type. */ +export interface QueryGroupInfoResponseSDKType { + info?: GroupInfoSDKType; +} +/** QueryGroupPolicyInfoRequest is the Query/GroupPolicyInfo request type. */ +export interface QueryGroupPolicyInfoRequest { + /** address is the account address of the group policy. */ + address: string; +} +export interface QueryGroupPolicyInfoRequestProtoMsg { + typeUrl: "/cosmos.group.v1.QueryGroupPolicyInfoRequest"; + value: Uint8Array; +} +/** QueryGroupPolicyInfoRequest is the Query/GroupPolicyInfo request type. */ +export interface QueryGroupPolicyInfoRequestSDKType { + address: string; +} +/** QueryGroupPolicyInfoResponse is the Query/GroupPolicyInfo response type. */ +export interface QueryGroupPolicyInfoResponse { + /** info is the GroupPolicyInfo for the group policy. */ + info?: GroupPolicyInfo; +} +export interface QueryGroupPolicyInfoResponseProtoMsg { + typeUrl: "/cosmos.group.v1.QueryGroupPolicyInfoResponse"; + value: Uint8Array; +} +/** QueryGroupPolicyInfoResponse is the Query/GroupPolicyInfo response type. */ +export interface QueryGroupPolicyInfoResponseSDKType { + info?: GroupPolicyInfoSDKType; +} +/** QueryGroupMembersRequest is the Query/GroupMembers request type. */ +export interface QueryGroupMembersRequest { + /** group_id is the unique ID of the group. */ + groupId: bigint; + /** pagination defines an optional pagination for the request. */ + pagination?: PageRequest; +} +export interface QueryGroupMembersRequestProtoMsg { + typeUrl: "/cosmos.group.v1.QueryGroupMembersRequest"; + value: Uint8Array; +} +/** QueryGroupMembersRequest is the Query/GroupMembers request type. */ +export interface QueryGroupMembersRequestSDKType { + group_id: bigint; + pagination?: PageRequestSDKType; +} +/** QueryGroupMembersResponse is the Query/GroupMembersResponse response type. */ +export interface QueryGroupMembersResponse { + /** members are the members of the group with given group_id. */ + members: GroupMember[]; + /** pagination defines the pagination in the response. */ + pagination?: PageResponse; +} +export interface QueryGroupMembersResponseProtoMsg { + typeUrl: "/cosmos.group.v1.QueryGroupMembersResponse"; + value: Uint8Array; +} +/** QueryGroupMembersResponse is the Query/GroupMembersResponse response type. */ +export interface QueryGroupMembersResponseSDKType { + members: GroupMemberSDKType[]; + pagination?: PageResponseSDKType; +} +/** QueryGroupsByAdminRequest is the Query/GroupsByAdmin request type. */ +export interface QueryGroupsByAdminRequest { + /** admin is the account address of a group's admin. */ + admin: string; + /** pagination defines an optional pagination for the request. */ + pagination?: PageRequest; +} +export interface QueryGroupsByAdminRequestProtoMsg { + typeUrl: "/cosmos.group.v1.QueryGroupsByAdminRequest"; + value: Uint8Array; +} +/** QueryGroupsByAdminRequest is the Query/GroupsByAdmin request type. */ +export interface QueryGroupsByAdminRequestSDKType { + admin: string; + pagination?: PageRequestSDKType; +} +/** QueryGroupsByAdminResponse is the Query/GroupsByAdminResponse response type. */ +export interface QueryGroupsByAdminResponse { + /** groups are the groups info with the provided admin. */ + groups: GroupInfo[]; + /** pagination defines the pagination in the response. */ + pagination?: PageResponse; +} +export interface QueryGroupsByAdminResponseProtoMsg { + typeUrl: "/cosmos.group.v1.QueryGroupsByAdminResponse"; + value: Uint8Array; +} +/** QueryGroupsByAdminResponse is the Query/GroupsByAdminResponse response type. */ +export interface QueryGroupsByAdminResponseSDKType { + groups: GroupInfoSDKType[]; + pagination?: PageResponseSDKType; +} +/** QueryGroupPoliciesByGroupRequest is the Query/GroupPoliciesByGroup request type. */ +export interface QueryGroupPoliciesByGroupRequest { + /** group_id is the unique ID of the group policy's group. */ + groupId: bigint; + /** pagination defines an optional pagination for the request. */ + pagination?: PageRequest; +} +export interface QueryGroupPoliciesByGroupRequestProtoMsg { + typeUrl: "/cosmos.group.v1.QueryGroupPoliciesByGroupRequest"; + value: Uint8Array; +} +/** QueryGroupPoliciesByGroupRequest is the Query/GroupPoliciesByGroup request type. */ +export interface QueryGroupPoliciesByGroupRequestSDKType { + group_id: bigint; + pagination?: PageRequestSDKType; +} +/** QueryGroupPoliciesByGroupResponse is the Query/GroupPoliciesByGroup response type. */ +export interface QueryGroupPoliciesByGroupResponse { + /** group_policies are the group policies info associated with the provided group. */ + groupPolicies: GroupPolicyInfo[]; + /** pagination defines the pagination in the response. */ + pagination?: PageResponse; +} +export interface QueryGroupPoliciesByGroupResponseProtoMsg { + typeUrl: "/cosmos.group.v1.QueryGroupPoliciesByGroupResponse"; + value: Uint8Array; +} +/** QueryGroupPoliciesByGroupResponse is the Query/GroupPoliciesByGroup response type. */ +export interface QueryGroupPoliciesByGroupResponseSDKType { + group_policies: GroupPolicyInfoSDKType[]; + pagination?: PageResponseSDKType; +} +/** QueryGroupPoliciesByAdminRequest is the Query/GroupPoliciesByAdmin request type. */ +export interface QueryGroupPoliciesByAdminRequest { + /** admin is the admin address of the group policy. */ + admin: string; + /** pagination defines an optional pagination for the request. */ + pagination?: PageRequest; +} +export interface QueryGroupPoliciesByAdminRequestProtoMsg { + typeUrl: "/cosmos.group.v1.QueryGroupPoliciesByAdminRequest"; + value: Uint8Array; +} +/** QueryGroupPoliciesByAdminRequest is the Query/GroupPoliciesByAdmin request type. */ +export interface QueryGroupPoliciesByAdminRequestSDKType { + admin: string; + pagination?: PageRequestSDKType; +} +/** QueryGroupPoliciesByAdminResponse is the Query/GroupPoliciesByAdmin response type. */ +export interface QueryGroupPoliciesByAdminResponse { + /** group_policies are the group policies info with provided admin. */ + groupPolicies: GroupPolicyInfo[]; + /** pagination defines the pagination in the response. */ + pagination?: PageResponse; +} +export interface QueryGroupPoliciesByAdminResponseProtoMsg { + typeUrl: "/cosmos.group.v1.QueryGroupPoliciesByAdminResponse"; + value: Uint8Array; +} +/** QueryGroupPoliciesByAdminResponse is the Query/GroupPoliciesByAdmin response type. */ +export interface QueryGroupPoliciesByAdminResponseSDKType { + group_policies: GroupPolicyInfoSDKType[]; + pagination?: PageResponseSDKType; +} +/** QueryProposalRequest is the Query/Proposal request type. */ +export interface QueryProposalRequest { + /** proposal_id is the unique ID of a proposal. */ + proposalId: bigint; +} +export interface QueryProposalRequestProtoMsg { + typeUrl: "/cosmos.group.v1.QueryProposalRequest"; + value: Uint8Array; +} +/** QueryProposalRequest is the Query/Proposal request type. */ +export interface QueryProposalRequestSDKType { + proposal_id: bigint; +} +/** QueryProposalResponse is the Query/Proposal response type. */ +export interface QueryProposalResponse { + /** proposal is the proposal info. */ + proposal?: Proposal; +} +export interface QueryProposalResponseProtoMsg { + typeUrl: "/cosmos.group.v1.QueryProposalResponse"; + value: Uint8Array; +} +/** QueryProposalResponse is the Query/Proposal response type. */ +export interface QueryProposalResponseSDKType { + proposal?: ProposalSDKType; +} +/** QueryProposalsByGroupPolicyRequest is the Query/ProposalByGroupPolicy request type. */ +export interface QueryProposalsByGroupPolicyRequest { + /** address is the account address of the group policy related to proposals. */ + address: string; + /** pagination defines an optional pagination for the request. */ + pagination?: PageRequest; +} +export interface QueryProposalsByGroupPolicyRequestProtoMsg { + typeUrl: "/cosmos.group.v1.QueryProposalsByGroupPolicyRequest"; + value: Uint8Array; +} +/** QueryProposalsByGroupPolicyRequest is the Query/ProposalByGroupPolicy request type. */ +export interface QueryProposalsByGroupPolicyRequestSDKType { + address: string; + pagination?: PageRequestSDKType; +} +/** QueryProposalsByGroupPolicyResponse is the Query/ProposalByGroupPolicy response type. */ +export interface QueryProposalsByGroupPolicyResponse { + /** proposals are the proposals with given group policy. */ + proposals: Proposal[]; + /** pagination defines the pagination in the response. */ + pagination?: PageResponse; +} +export interface QueryProposalsByGroupPolicyResponseProtoMsg { + typeUrl: "/cosmos.group.v1.QueryProposalsByGroupPolicyResponse"; + value: Uint8Array; +} +/** QueryProposalsByGroupPolicyResponse is the Query/ProposalByGroupPolicy response type. */ +export interface QueryProposalsByGroupPolicyResponseSDKType { + proposals: ProposalSDKType[]; + pagination?: PageResponseSDKType; +} +/** QueryVoteByProposalVoterRequest is the Query/VoteByProposalVoter request type. */ +export interface QueryVoteByProposalVoterRequest { + /** proposal_id is the unique ID of a proposal. */ + proposalId: bigint; + /** voter is a proposal voter account address. */ + voter: string; +} +export interface QueryVoteByProposalVoterRequestProtoMsg { + typeUrl: "/cosmos.group.v1.QueryVoteByProposalVoterRequest"; + value: Uint8Array; +} +/** QueryVoteByProposalVoterRequest is the Query/VoteByProposalVoter request type. */ +export interface QueryVoteByProposalVoterRequestSDKType { + proposal_id: bigint; + voter: string; +} +/** QueryVoteByProposalVoterResponse is the Query/VoteByProposalVoter response type. */ +export interface QueryVoteByProposalVoterResponse { + /** vote is the vote with given proposal_id and voter. */ + vote?: Vote; +} +export interface QueryVoteByProposalVoterResponseProtoMsg { + typeUrl: "/cosmos.group.v1.QueryVoteByProposalVoterResponse"; + value: Uint8Array; +} +/** QueryVoteByProposalVoterResponse is the Query/VoteByProposalVoter response type. */ +export interface QueryVoteByProposalVoterResponseSDKType { + vote?: VoteSDKType; +} +/** QueryVotesByProposalRequest is the Query/VotesByProposal request type. */ +export interface QueryVotesByProposalRequest { + /** proposal_id is the unique ID of a proposal. */ + proposalId: bigint; + /** pagination defines an optional pagination for the request. */ + pagination?: PageRequest; +} +export interface QueryVotesByProposalRequestProtoMsg { + typeUrl: "/cosmos.group.v1.QueryVotesByProposalRequest"; + value: Uint8Array; +} +/** QueryVotesByProposalRequest is the Query/VotesByProposal request type. */ +export interface QueryVotesByProposalRequestSDKType { + proposal_id: bigint; + pagination?: PageRequestSDKType; +} +/** QueryVotesByProposalResponse is the Query/VotesByProposal response type. */ +export interface QueryVotesByProposalResponse { + /** votes are the list of votes for given proposal_id. */ + votes: Vote[]; + /** pagination defines the pagination in the response. */ + pagination?: PageResponse; +} +export interface QueryVotesByProposalResponseProtoMsg { + typeUrl: "/cosmos.group.v1.QueryVotesByProposalResponse"; + value: Uint8Array; +} +/** QueryVotesByProposalResponse is the Query/VotesByProposal response type. */ +export interface QueryVotesByProposalResponseSDKType { + votes: VoteSDKType[]; + pagination?: PageResponseSDKType; +} +/** QueryVotesByVoterRequest is the Query/VotesByVoter request type. */ +export interface QueryVotesByVoterRequest { + /** voter is a proposal voter account address. */ + voter: string; + /** pagination defines an optional pagination for the request. */ + pagination?: PageRequest; +} +export interface QueryVotesByVoterRequestProtoMsg { + typeUrl: "/cosmos.group.v1.QueryVotesByVoterRequest"; + value: Uint8Array; +} +/** QueryVotesByVoterRequest is the Query/VotesByVoter request type. */ +export interface QueryVotesByVoterRequestSDKType { + voter: string; + pagination?: PageRequestSDKType; +} +/** QueryVotesByVoterResponse is the Query/VotesByVoter response type. */ +export interface QueryVotesByVoterResponse { + /** votes are the list of votes by given voter. */ + votes: Vote[]; + /** pagination defines the pagination in the response. */ + pagination?: PageResponse; +} +export interface QueryVotesByVoterResponseProtoMsg { + typeUrl: "/cosmos.group.v1.QueryVotesByVoterResponse"; + value: Uint8Array; +} +/** QueryVotesByVoterResponse is the Query/VotesByVoter response type. */ +export interface QueryVotesByVoterResponseSDKType { + votes: VoteSDKType[]; + pagination?: PageResponseSDKType; +} +/** QueryGroupsByMemberRequest is the Query/GroupsByMember request type. */ +export interface QueryGroupsByMemberRequest { + /** address is the group member address. */ + address: string; + /** pagination defines an optional pagination for the request. */ + pagination?: PageRequest; +} +export interface QueryGroupsByMemberRequestProtoMsg { + typeUrl: "/cosmos.group.v1.QueryGroupsByMemberRequest"; + value: Uint8Array; +} +/** QueryGroupsByMemberRequest is the Query/GroupsByMember request type. */ +export interface QueryGroupsByMemberRequestSDKType { + address: string; + pagination?: PageRequestSDKType; +} +/** QueryGroupsByMemberResponse is the Query/GroupsByMember response type. */ +export interface QueryGroupsByMemberResponse { + /** groups are the groups info with the provided group member. */ + groups: GroupInfo[]; + /** pagination defines the pagination in the response. */ + pagination?: PageResponse; +} +export interface QueryGroupsByMemberResponseProtoMsg { + typeUrl: "/cosmos.group.v1.QueryGroupsByMemberResponse"; + value: Uint8Array; +} +/** QueryGroupsByMemberResponse is the Query/GroupsByMember response type. */ +export interface QueryGroupsByMemberResponseSDKType { + groups: GroupInfoSDKType[]; + pagination?: PageResponseSDKType; +} +/** QueryTallyResultRequest is the Query/TallyResult request type. */ +export interface QueryTallyResultRequest { + /** proposal_id is the unique id of a proposal. */ + proposalId: bigint; +} +export interface QueryTallyResultRequestProtoMsg { + typeUrl: "/cosmos.group.v1.QueryTallyResultRequest"; + value: Uint8Array; +} +/** QueryTallyResultRequest is the Query/TallyResult request type. */ +export interface QueryTallyResultRequestSDKType { + proposal_id: bigint; +} +/** QueryTallyResultResponse is the Query/TallyResult response type. */ +export interface QueryTallyResultResponse { + /** tally defines the requested tally. */ + tally: TallyResult; +} +export interface QueryTallyResultResponseProtoMsg { + typeUrl: "/cosmos.group.v1.QueryTallyResultResponse"; + value: Uint8Array; +} +/** QueryTallyResultResponse is the Query/TallyResult response type. */ +export interface QueryTallyResultResponseSDKType { + tally: TallyResultSDKType; +} +function createBaseQueryGroupInfoRequest(): QueryGroupInfoRequest { + return { + groupId: BigInt(0) + }; +} +export const QueryGroupInfoRequest = { + typeUrl: "/cosmos.group.v1.QueryGroupInfoRequest", + encode(message: QueryGroupInfoRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.groupId !== undefined) { + writer.uint32(8).uint64(message.groupId); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryGroupInfoRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryGroupInfoRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.groupId = reader.uint64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryGroupInfoRequest { + const obj = createBaseQueryGroupInfoRequest(); + if (isSet(object.groupId)) obj.groupId = BigInt(object.groupId.toString()); + return obj; + }, + toJSON(message: QueryGroupInfoRequest): JsonSafe { + const obj: any = {}; + message.groupId !== undefined && (obj.groupId = (message.groupId || BigInt(0)).toString()); + return obj; + }, + fromPartial(object: DeepPartial): QueryGroupInfoRequest { + const message = createBaseQueryGroupInfoRequest(); + if (object.groupId !== undefined && object.groupId !== null) { + message.groupId = BigInt(object.groupId.toString()); + } + return message; + }, + fromSDK(object: QueryGroupInfoRequestSDKType): QueryGroupInfoRequest { + return { + groupId: object?.group_id + }; + }, + fromSDKJSON(object: any): QueryGroupInfoRequestSDKType { + return { + group_id: isSet(object.group_id) ? BigInt(object.group_id.toString()) : BigInt(0) + }; + }, + toSDK(message: QueryGroupInfoRequest): QueryGroupInfoRequestSDKType { + const obj: any = {}; + obj.group_id = message.groupId; + return obj; + }, + fromAmino(object: QueryGroupInfoRequestAmino): QueryGroupInfoRequest { + const message = createBaseQueryGroupInfoRequest(); + if (object.group_id !== undefined && object.group_id !== null) { + message.groupId = BigInt(object.group_id); + } + return message; + }, + toAmino(message: QueryGroupInfoRequest): QueryGroupInfoRequestAmino { + const obj: any = {}; + obj.group_id = message.groupId !== BigInt(0) ? message.groupId?.toString() : undefined; + return obj; + }, + fromAminoMsg(object: QueryGroupInfoRequestAminoMsg): QueryGroupInfoRequest { + return QueryGroupInfoRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryGroupInfoRequest): QueryGroupInfoRequestAminoMsg { + return { + type: "cosmos-sdk/QueryGroupInfoRequest", + value: QueryGroupInfoRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryGroupInfoRequestProtoMsg): QueryGroupInfoRequest { + return QueryGroupInfoRequest.decode(message.value); + }, + toProto(message: QueryGroupInfoRequest): Uint8Array { + return QueryGroupInfoRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryGroupInfoRequest): QueryGroupInfoRequestProtoMsg { + return { + typeUrl: "/cosmos.group.v1.QueryGroupInfoRequest", + value: QueryGroupInfoRequest.encode(message).finish() + }; + } +}; +function createBaseQueryGroupInfoResponse(): QueryGroupInfoResponse { + return { + info: undefined + }; +} +export const QueryGroupInfoResponse = { + typeUrl: "/cosmos.group.v1.QueryGroupInfoResponse", + encode(message: QueryGroupInfoResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.info !== undefined) { + GroupInfo.encode(message.info, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryGroupInfoResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryGroupInfoResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.info = GroupInfo.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryGroupInfoResponse { + const obj = createBaseQueryGroupInfoResponse(); + if (isSet(object.info)) obj.info = GroupInfo.fromJSON(object.info); + return obj; + }, + toJSON(message: QueryGroupInfoResponse): JsonSafe { + const obj: any = {}; + message.info !== undefined && (obj.info = message.info ? GroupInfo.toJSON(message.info) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryGroupInfoResponse { + const message = createBaseQueryGroupInfoResponse(); + if (object.info !== undefined && object.info !== null) { + message.info = GroupInfo.fromPartial(object.info); + } + return message; + }, + fromSDK(object: QueryGroupInfoResponseSDKType): QueryGroupInfoResponse { + return { + info: object.info ? GroupInfo.fromSDK(object.info) : undefined + }; + }, + fromSDKJSON(object: any): QueryGroupInfoResponseSDKType { + return { + info: isSet(object.info) ? GroupInfo.fromSDKJSON(object.info) : undefined + }; + }, + toSDK(message: QueryGroupInfoResponse): QueryGroupInfoResponseSDKType { + const obj: any = {}; + message.info !== undefined && (obj.info = message.info ? GroupInfo.toSDK(message.info) : undefined); + return obj; + }, + fromAmino(object: QueryGroupInfoResponseAmino): QueryGroupInfoResponse { + const message = createBaseQueryGroupInfoResponse(); + if (object.info !== undefined && object.info !== null) { + message.info = GroupInfo.fromAmino(object.info); + } + return message; + }, + toAmino(message: QueryGroupInfoResponse): QueryGroupInfoResponseAmino { + const obj: any = {}; + obj.info = message.info ? GroupInfo.toAmino(message.info) : undefined; + return obj; + }, + fromAminoMsg(object: QueryGroupInfoResponseAminoMsg): QueryGroupInfoResponse { + return QueryGroupInfoResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryGroupInfoResponse): QueryGroupInfoResponseAminoMsg { + return { + type: "cosmos-sdk/QueryGroupInfoResponse", + value: QueryGroupInfoResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryGroupInfoResponseProtoMsg): QueryGroupInfoResponse { + return QueryGroupInfoResponse.decode(message.value); + }, + toProto(message: QueryGroupInfoResponse): Uint8Array { + return QueryGroupInfoResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryGroupInfoResponse): QueryGroupInfoResponseProtoMsg { + return { + typeUrl: "/cosmos.group.v1.QueryGroupInfoResponse", + value: QueryGroupInfoResponse.encode(message).finish() + }; + } +}; +function createBaseQueryGroupPolicyInfoRequest(): QueryGroupPolicyInfoRequest { + return { + address: "" + }; +} +export const QueryGroupPolicyInfoRequest = { + typeUrl: "/cosmos.group.v1.QueryGroupPolicyInfoRequest", + encode(message: QueryGroupPolicyInfoRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.address !== undefined) { + writer.uint32(10).string(message.address); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryGroupPolicyInfoRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryGroupPolicyInfoRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryGroupPolicyInfoRequest { + const obj = createBaseQueryGroupPolicyInfoRequest(); + if (isSet(object.address)) obj.address = String(object.address); + return obj; + }, + toJSON(message: QueryGroupPolicyInfoRequest): JsonSafe { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + return obj; + }, + fromPartial(object: DeepPartial): QueryGroupPolicyInfoRequest { + const message = createBaseQueryGroupPolicyInfoRequest(); + message.address = object.address ?? ""; + return message; + }, + fromSDK(object: QueryGroupPolicyInfoRequestSDKType): QueryGroupPolicyInfoRequest { + return { + address: object?.address + }; + }, + fromSDKJSON(object: any): QueryGroupPolicyInfoRequestSDKType { + return { + address: isSet(object.address) ? String(object.address) : "" + }; + }, + toSDK(message: QueryGroupPolicyInfoRequest): QueryGroupPolicyInfoRequestSDKType { + const obj: any = {}; + obj.address = message.address; + return obj; + }, + fromAmino(object: QueryGroupPolicyInfoRequestAmino): QueryGroupPolicyInfoRequest { + const message = createBaseQueryGroupPolicyInfoRequest(); + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } + return message; + }, + toAmino(message: QueryGroupPolicyInfoRequest): QueryGroupPolicyInfoRequestAmino { + const obj: any = {}; + obj.address = message.address === "" ? undefined : message.address; + return obj; + }, + fromAminoMsg(object: QueryGroupPolicyInfoRequestAminoMsg): QueryGroupPolicyInfoRequest { + return QueryGroupPolicyInfoRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryGroupPolicyInfoRequest): QueryGroupPolicyInfoRequestAminoMsg { + return { + type: "cosmos-sdk/QueryGroupPolicyInfoRequest", + value: QueryGroupPolicyInfoRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryGroupPolicyInfoRequestProtoMsg): QueryGroupPolicyInfoRequest { + return QueryGroupPolicyInfoRequest.decode(message.value); + }, + toProto(message: QueryGroupPolicyInfoRequest): Uint8Array { + return QueryGroupPolicyInfoRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryGroupPolicyInfoRequest): QueryGroupPolicyInfoRequestProtoMsg { + return { + typeUrl: "/cosmos.group.v1.QueryGroupPolicyInfoRequest", + value: QueryGroupPolicyInfoRequest.encode(message).finish() + }; + } +}; +function createBaseQueryGroupPolicyInfoResponse(): QueryGroupPolicyInfoResponse { + return { + info: undefined + }; +} +export const QueryGroupPolicyInfoResponse = { + typeUrl: "/cosmos.group.v1.QueryGroupPolicyInfoResponse", + encode(message: QueryGroupPolicyInfoResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.info !== undefined) { + GroupPolicyInfo.encode(message.info, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryGroupPolicyInfoResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryGroupPolicyInfoResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.info = GroupPolicyInfo.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryGroupPolicyInfoResponse { + const obj = createBaseQueryGroupPolicyInfoResponse(); + if (isSet(object.info)) obj.info = GroupPolicyInfo.fromJSON(object.info); + return obj; + }, + toJSON(message: QueryGroupPolicyInfoResponse): JsonSafe { + const obj: any = {}; + message.info !== undefined && (obj.info = message.info ? GroupPolicyInfo.toJSON(message.info) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryGroupPolicyInfoResponse { + const message = createBaseQueryGroupPolicyInfoResponse(); + if (object.info !== undefined && object.info !== null) { + message.info = GroupPolicyInfo.fromPartial(object.info); + } + return message; + }, + fromSDK(object: QueryGroupPolicyInfoResponseSDKType): QueryGroupPolicyInfoResponse { + return { + info: object.info ? GroupPolicyInfo.fromSDK(object.info) : undefined + }; + }, + fromSDKJSON(object: any): QueryGroupPolicyInfoResponseSDKType { + return { + info: isSet(object.info) ? GroupPolicyInfo.fromSDKJSON(object.info) : undefined + }; + }, + toSDK(message: QueryGroupPolicyInfoResponse): QueryGroupPolicyInfoResponseSDKType { + const obj: any = {}; + message.info !== undefined && (obj.info = message.info ? GroupPolicyInfo.toSDK(message.info) : undefined); + return obj; + }, + fromAmino(object: QueryGroupPolicyInfoResponseAmino): QueryGroupPolicyInfoResponse { + const message = createBaseQueryGroupPolicyInfoResponse(); + if (object.info !== undefined && object.info !== null) { + message.info = GroupPolicyInfo.fromAmino(object.info); + } + return message; + }, + toAmino(message: QueryGroupPolicyInfoResponse): QueryGroupPolicyInfoResponseAmino { + const obj: any = {}; + obj.info = message.info ? GroupPolicyInfo.toAmino(message.info) : undefined; + return obj; + }, + fromAminoMsg(object: QueryGroupPolicyInfoResponseAminoMsg): QueryGroupPolicyInfoResponse { + return QueryGroupPolicyInfoResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryGroupPolicyInfoResponse): QueryGroupPolicyInfoResponseAminoMsg { + return { + type: "cosmos-sdk/QueryGroupPolicyInfoResponse", + value: QueryGroupPolicyInfoResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryGroupPolicyInfoResponseProtoMsg): QueryGroupPolicyInfoResponse { + return QueryGroupPolicyInfoResponse.decode(message.value); + }, + toProto(message: QueryGroupPolicyInfoResponse): Uint8Array { + return QueryGroupPolicyInfoResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryGroupPolicyInfoResponse): QueryGroupPolicyInfoResponseProtoMsg { + return { + typeUrl: "/cosmos.group.v1.QueryGroupPolicyInfoResponse", + value: QueryGroupPolicyInfoResponse.encode(message).finish() + }; + } +}; +function createBaseQueryGroupMembersRequest(): QueryGroupMembersRequest { + return { + groupId: BigInt(0), + pagination: undefined + }; +} +export const QueryGroupMembersRequest = { + typeUrl: "/cosmos.group.v1.QueryGroupMembersRequest", + encode(message: QueryGroupMembersRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.groupId !== undefined) { + writer.uint32(8).uint64(message.groupId); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryGroupMembersRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryGroupMembersRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.groupId = reader.uint64(); + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryGroupMembersRequest { + const obj = createBaseQueryGroupMembersRequest(); + if (isSet(object.groupId)) obj.groupId = BigInt(object.groupId.toString()); + if (isSet(object.pagination)) obj.pagination = PageRequest.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryGroupMembersRequest): JsonSafe { + const obj: any = {}; + message.groupId !== undefined && (obj.groupId = (message.groupId || BigInt(0)).toString()); + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryGroupMembersRequest { + const message = createBaseQueryGroupMembersRequest(); + if (object.groupId !== undefined && object.groupId !== null) { + message.groupId = BigInt(object.groupId.toString()); + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryGroupMembersRequestSDKType): QueryGroupMembersRequest { + return { + groupId: object?.group_id, + pagination: object.pagination ? PageRequest.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryGroupMembersRequestSDKType { + return { + group_id: isSet(object.group_id) ? BigInt(object.group_id.toString()) : BigInt(0), + pagination: isSet(object.pagination) ? PageRequest.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryGroupMembersRequest): QueryGroupMembersRequestSDKType { + const obj: any = {}; + obj.group_id = message.groupId; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryGroupMembersRequestAmino): QueryGroupMembersRequest { + const message = createBaseQueryGroupMembersRequest(); + if (object.group_id !== undefined && object.group_id !== null) { + message.groupId = BigInt(object.group_id); + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryGroupMembersRequest): QueryGroupMembersRequestAmino { + const obj: any = {}; + obj.group_id = message.groupId !== BigInt(0) ? message.groupId?.toString() : undefined; + obj.pagination = message.pagination ? PageRequest.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryGroupMembersRequestAminoMsg): QueryGroupMembersRequest { + return QueryGroupMembersRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryGroupMembersRequest): QueryGroupMembersRequestAminoMsg { + return { + type: "cosmos-sdk/QueryGroupMembersRequest", + value: QueryGroupMembersRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryGroupMembersRequestProtoMsg): QueryGroupMembersRequest { + return QueryGroupMembersRequest.decode(message.value); + }, + toProto(message: QueryGroupMembersRequest): Uint8Array { + return QueryGroupMembersRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryGroupMembersRequest): QueryGroupMembersRequestProtoMsg { + return { + typeUrl: "/cosmos.group.v1.QueryGroupMembersRequest", + value: QueryGroupMembersRequest.encode(message).finish() + }; + } +}; +function createBaseQueryGroupMembersResponse(): QueryGroupMembersResponse { + return { + members: [], + pagination: undefined + }; +} +export const QueryGroupMembersResponse = { + typeUrl: "/cosmos.group.v1.QueryGroupMembersResponse", + encode(message: QueryGroupMembersResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.members) { + GroupMember.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryGroupMembersResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryGroupMembersResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.members.push(GroupMember.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryGroupMembersResponse { + const obj = createBaseQueryGroupMembersResponse(); + if (Array.isArray(object?.members)) obj.members = object.members.map((e: any) => GroupMember.fromJSON(e)); + if (isSet(object.pagination)) obj.pagination = PageResponse.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryGroupMembersResponse): JsonSafe { + const obj: any = {}; + if (message.members) { + obj.members = message.members.map(e => e ? GroupMember.toJSON(e) : undefined); + } else { + obj.members = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryGroupMembersResponse { + const message = createBaseQueryGroupMembersResponse(); + message.members = object.members?.map(e => GroupMember.fromPartial(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryGroupMembersResponseSDKType): QueryGroupMembersResponse { + return { + members: Array.isArray(object?.members) ? object.members.map((e: any) => GroupMember.fromSDK(e)) : [], + pagination: object.pagination ? PageResponse.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryGroupMembersResponseSDKType { + return { + members: Array.isArray(object?.members) ? object.members.map((e: any) => GroupMember.fromSDKJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryGroupMembersResponse): QueryGroupMembersResponseSDKType { + const obj: any = {}; + if (message.members) { + obj.members = message.members.map(e => e ? GroupMember.toSDK(e) : undefined); + } else { + obj.members = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryGroupMembersResponseAmino): QueryGroupMembersResponse { + const message = createBaseQueryGroupMembersResponse(); + message.members = object.members?.map(e => GroupMember.fromAmino(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryGroupMembersResponse): QueryGroupMembersResponseAmino { + const obj: any = {}; + if (message.members) { + obj.members = message.members.map(e => e ? GroupMember.toAmino(e) : undefined); + } else { + obj.members = message.members; + } + obj.pagination = message.pagination ? PageResponse.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryGroupMembersResponseAminoMsg): QueryGroupMembersResponse { + return QueryGroupMembersResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryGroupMembersResponse): QueryGroupMembersResponseAminoMsg { + return { + type: "cosmos-sdk/QueryGroupMembersResponse", + value: QueryGroupMembersResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryGroupMembersResponseProtoMsg): QueryGroupMembersResponse { + return QueryGroupMembersResponse.decode(message.value); + }, + toProto(message: QueryGroupMembersResponse): Uint8Array { + return QueryGroupMembersResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryGroupMembersResponse): QueryGroupMembersResponseProtoMsg { + return { + typeUrl: "/cosmos.group.v1.QueryGroupMembersResponse", + value: QueryGroupMembersResponse.encode(message).finish() + }; + } +}; +function createBaseQueryGroupsByAdminRequest(): QueryGroupsByAdminRequest { + return { + admin: "", + pagination: undefined + }; +} +export const QueryGroupsByAdminRequest = { + typeUrl: "/cosmos.group.v1.QueryGroupsByAdminRequest", + encode(message: QueryGroupsByAdminRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.admin !== undefined) { + writer.uint32(10).string(message.admin); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryGroupsByAdminRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryGroupsByAdminRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.admin = reader.string(); + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryGroupsByAdminRequest { + const obj = createBaseQueryGroupsByAdminRequest(); + if (isSet(object.admin)) obj.admin = String(object.admin); + if (isSet(object.pagination)) obj.pagination = PageRequest.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryGroupsByAdminRequest): JsonSafe { + const obj: any = {}; + message.admin !== undefined && (obj.admin = message.admin); + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryGroupsByAdminRequest { + const message = createBaseQueryGroupsByAdminRequest(); + message.admin = object.admin ?? ""; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryGroupsByAdminRequestSDKType): QueryGroupsByAdminRequest { + return { + admin: object?.admin, + pagination: object.pagination ? PageRequest.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryGroupsByAdminRequestSDKType { + return { + admin: isSet(object.admin) ? String(object.admin) : "", + pagination: isSet(object.pagination) ? PageRequest.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryGroupsByAdminRequest): QueryGroupsByAdminRequestSDKType { + const obj: any = {}; + obj.admin = message.admin; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryGroupsByAdminRequestAmino): QueryGroupsByAdminRequest { + const message = createBaseQueryGroupsByAdminRequest(); + if (object.admin !== undefined && object.admin !== null) { + message.admin = object.admin; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryGroupsByAdminRequest): QueryGroupsByAdminRequestAmino { + const obj: any = {}; + obj.admin = message.admin === "" ? undefined : message.admin; + obj.pagination = message.pagination ? PageRequest.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryGroupsByAdminRequestAminoMsg): QueryGroupsByAdminRequest { + return QueryGroupsByAdminRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryGroupsByAdminRequest): QueryGroupsByAdminRequestAminoMsg { + return { + type: "cosmos-sdk/QueryGroupsByAdminRequest", + value: QueryGroupsByAdminRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryGroupsByAdminRequestProtoMsg): QueryGroupsByAdminRequest { + return QueryGroupsByAdminRequest.decode(message.value); + }, + toProto(message: QueryGroupsByAdminRequest): Uint8Array { + return QueryGroupsByAdminRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryGroupsByAdminRequest): QueryGroupsByAdminRequestProtoMsg { + return { + typeUrl: "/cosmos.group.v1.QueryGroupsByAdminRequest", + value: QueryGroupsByAdminRequest.encode(message).finish() + }; + } +}; +function createBaseQueryGroupsByAdminResponse(): QueryGroupsByAdminResponse { + return { + groups: [], + pagination: undefined + }; +} +export const QueryGroupsByAdminResponse = { + typeUrl: "/cosmos.group.v1.QueryGroupsByAdminResponse", + encode(message: QueryGroupsByAdminResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.groups) { + GroupInfo.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryGroupsByAdminResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryGroupsByAdminResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.groups.push(GroupInfo.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryGroupsByAdminResponse { + const obj = createBaseQueryGroupsByAdminResponse(); + if (Array.isArray(object?.groups)) obj.groups = object.groups.map((e: any) => GroupInfo.fromJSON(e)); + if (isSet(object.pagination)) obj.pagination = PageResponse.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryGroupsByAdminResponse): JsonSafe { + const obj: any = {}; + if (message.groups) { + obj.groups = message.groups.map(e => e ? GroupInfo.toJSON(e) : undefined); + } else { + obj.groups = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryGroupsByAdminResponse { + const message = createBaseQueryGroupsByAdminResponse(); + message.groups = object.groups?.map(e => GroupInfo.fromPartial(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryGroupsByAdminResponseSDKType): QueryGroupsByAdminResponse { + return { + groups: Array.isArray(object?.groups) ? object.groups.map((e: any) => GroupInfo.fromSDK(e)) : [], + pagination: object.pagination ? PageResponse.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryGroupsByAdminResponseSDKType { + return { + groups: Array.isArray(object?.groups) ? object.groups.map((e: any) => GroupInfo.fromSDKJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryGroupsByAdminResponse): QueryGroupsByAdminResponseSDKType { + const obj: any = {}; + if (message.groups) { + obj.groups = message.groups.map(e => e ? GroupInfo.toSDK(e) : undefined); + } else { + obj.groups = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryGroupsByAdminResponseAmino): QueryGroupsByAdminResponse { + const message = createBaseQueryGroupsByAdminResponse(); + message.groups = object.groups?.map(e => GroupInfo.fromAmino(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryGroupsByAdminResponse): QueryGroupsByAdminResponseAmino { + const obj: any = {}; + if (message.groups) { + obj.groups = message.groups.map(e => e ? GroupInfo.toAmino(e) : undefined); + } else { + obj.groups = message.groups; + } + obj.pagination = message.pagination ? PageResponse.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryGroupsByAdminResponseAminoMsg): QueryGroupsByAdminResponse { + return QueryGroupsByAdminResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryGroupsByAdminResponse): QueryGroupsByAdminResponseAminoMsg { + return { + type: "cosmos-sdk/QueryGroupsByAdminResponse", + value: QueryGroupsByAdminResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryGroupsByAdminResponseProtoMsg): QueryGroupsByAdminResponse { + return QueryGroupsByAdminResponse.decode(message.value); + }, + toProto(message: QueryGroupsByAdminResponse): Uint8Array { + return QueryGroupsByAdminResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryGroupsByAdminResponse): QueryGroupsByAdminResponseProtoMsg { + return { + typeUrl: "/cosmos.group.v1.QueryGroupsByAdminResponse", + value: QueryGroupsByAdminResponse.encode(message).finish() + }; + } +}; +function createBaseQueryGroupPoliciesByGroupRequest(): QueryGroupPoliciesByGroupRequest { + return { + groupId: BigInt(0), + pagination: undefined + }; +} +export const QueryGroupPoliciesByGroupRequest = { + typeUrl: "/cosmos.group.v1.QueryGroupPoliciesByGroupRequest", + encode(message: QueryGroupPoliciesByGroupRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.groupId !== undefined) { + writer.uint32(8).uint64(message.groupId); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryGroupPoliciesByGroupRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryGroupPoliciesByGroupRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.groupId = reader.uint64(); + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryGroupPoliciesByGroupRequest { + const obj = createBaseQueryGroupPoliciesByGroupRequest(); + if (isSet(object.groupId)) obj.groupId = BigInt(object.groupId.toString()); + if (isSet(object.pagination)) obj.pagination = PageRequest.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryGroupPoliciesByGroupRequest): JsonSafe { + const obj: any = {}; + message.groupId !== undefined && (obj.groupId = (message.groupId || BigInt(0)).toString()); + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryGroupPoliciesByGroupRequest { + const message = createBaseQueryGroupPoliciesByGroupRequest(); + if (object.groupId !== undefined && object.groupId !== null) { + message.groupId = BigInt(object.groupId.toString()); + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryGroupPoliciesByGroupRequestSDKType): QueryGroupPoliciesByGroupRequest { + return { + groupId: object?.group_id, + pagination: object.pagination ? PageRequest.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryGroupPoliciesByGroupRequestSDKType { + return { + group_id: isSet(object.group_id) ? BigInt(object.group_id.toString()) : BigInt(0), + pagination: isSet(object.pagination) ? PageRequest.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryGroupPoliciesByGroupRequest): QueryGroupPoliciesByGroupRequestSDKType { + const obj: any = {}; + obj.group_id = message.groupId; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryGroupPoliciesByGroupRequestAmino): QueryGroupPoliciesByGroupRequest { + const message = createBaseQueryGroupPoliciesByGroupRequest(); + if (object.group_id !== undefined && object.group_id !== null) { + message.groupId = BigInt(object.group_id); + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryGroupPoliciesByGroupRequest): QueryGroupPoliciesByGroupRequestAmino { + const obj: any = {}; + obj.group_id = message.groupId !== BigInt(0) ? message.groupId?.toString() : undefined; + obj.pagination = message.pagination ? PageRequest.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryGroupPoliciesByGroupRequestAminoMsg): QueryGroupPoliciesByGroupRequest { + return QueryGroupPoliciesByGroupRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryGroupPoliciesByGroupRequest): QueryGroupPoliciesByGroupRequestAminoMsg { + return { + type: "cosmos-sdk/QueryGroupPoliciesByGroupRequest", + value: QueryGroupPoliciesByGroupRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryGroupPoliciesByGroupRequestProtoMsg): QueryGroupPoliciesByGroupRequest { + return QueryGroupPoliciesByGroupRequest.decode(message.value); + }, + toProto(message: QueryGroupPoliciesByGroupRequest): Uint8Array { + return QueryGroupPoliciesByGroupRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryGroupPoliciesByGroupRequest): QueryGroupPoliciesByGroupRequestProtoMsg { + return { + typeUrl: "/cosmos.group.v1.QueryGroupPoliciesByGroupRequest", + value: QueryGroupPoliciesByGroupRequest.encode(message).finish() + }; + } +}; +function createBaseQueryGroupPoliciesByGroupResponse(): QueryGroupPoliciesByGroupResponse { + return { + groupPolicies: [], + pagination: undefined + }; +} +export const QueryGroupPoliciesByGroupResponse = { + typeUrl: "/cosmos.group.v1.QueryGroupPoliciesByGroupResponse", + encode(message: QueryGroupPoliciesByGroupResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.groupPolicies) { + GroupPolicyInfo.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryGroupPoliciesByGroupResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryGroupPoliciesByGroupResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.groupPolicies.push(GroupPolicyInfo.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryGroupPoliciesByGroupResponse { + const obj = createBaseQueryGroupPoliciesByGroupResponse(); + if (Array.isArray(object?.groupPolicies)) obj.groupPolicies = object.groupPolicies.map((e: any) => GroupPolicyInfo.fromJSON(e)); + if (isSet(object.pagination)) obj.pagination = PageResponse.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryGroupPoliciesByGroupResponse): JsonSafe { + const obj: any = {}; + if (message.groupPolicies) { + obj.groupPolicies = message.groupPolicies.map(e => e ? GroupPolicyInfo.toJSON(e) : undefined); + } else { + obj.groupPolicies = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryGroupPoliciesByGroupResponse { + const message = createBaseQueryGroupPoliciesByGroupResponse(); + message.groupPolicies = object.groupPolicies?.map(e => GroupPolicyInfo.fromPartial(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryGroupPoliciesByGroupResponseSDKType): QueryGroupPoliciesByGroupResponse { + return { + groupPolicies: Array.isArray(object?.group_policies) ? object.group_policies.map((e: any) => GroupPolicyInfo.fromSDK(e)) : [], + pagination: object.pagination ? PageResponse.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryGroupPoliciesByGroupResponseSDKType { + return { + group_policies: Array.isArray(object?.group_policies) ? object.group_policies.map((e: any) => GroupPolicyInfo.fromSDKJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryGroupPoliciesByGroupResponse): QueryGroupPoliciesByGroupResponseSDKType { + const obj: any = {}; + if (message.groupPolicies) { + obj.group_policies = message.groupPolicies.map(e => e ? GroupPolicyInfo.toSDK(e) : undefined); + } else { + obj.group_policies = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryGroupPoliciesByGroupResponseAmino): QueryGroupPoliciesByGroupResponse { + const message = createBaseQueryGroupPoliciesByGroupResponse(); + message.groupPolicies = object.group_policies?.map(e => GroupPolicyInfo.fromAmino(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryGroupPoliciesByGroupResponse): QueryGroupPoliciesByGroupResponseAmino { + const obj: any = {}; + if (message.groupPolicies) { + obj.group_policies = message.groupPolicies.map(e => e ? GroupPolicyInfo.toAmino(e) : undefined); + } else { + obj.group_policies = message.groupPolicies; + } + obj.pagination = message.pagination ? PageResponse.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryGroupPoliciesByGroupResponseAminoMsg): QueryGroupPoliciesByGroupResponse { + return QueryGroupPoliciesByGroupResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryGroupPoliciesByGroupResponse): QueryGroupPoliciesByGroupResponseAminoMsg { + return { + type: "cosmos-sdk/QueryGroupPoliciesByGroupResponse", + value: QueryGroupPoliciesByGroupResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryGroupPoliciesByGroupResponseProtoMsg): QueryGroupPoliciesByGroupResponse { + return QueryGroupPoliciesByGroupResponse.decode(message.value); + }, + toProto(message: QueryGroupPoliciesByGroupResponse): Uint8Array { + return QueryGroupPoliciesByGroupResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryGroupPoliciesByGroupResponse): QueryGroupPoliciesByGroupResponseProtoMsg { + return { + typeUrl: "/cosmos.group.v1.QueryGroupPoliciesByGroupResponse", + value: QueryGroupPoliciesByGroupResponse.encode(message).finish() + }; + } +}; +function createBaseQueryGroupPoliciesByAdminRequest(): QueryGroupPoliciesByAdminRequest { + return { + admin: "", + pagination: undefined + }; +} +export const QueryGroupPoliciesByAdminRequest = { + typeUrl: "/cosmos.group.v1.QueryGroupPoliciesByAdminRequest", + encode(message: QueryGroupPoliciesByAdminRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.admin !== undefined) { + writer.uint32(10).string(message.admin); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryGroupPoliciesByAdminRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryGroupPoliciesByAdminRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.admin = reader.string(); + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryGroupPoliciesByAdminRequest { + const obj = createBaseQueryGroupPoliciesByAdminRequest(); + if (isSet(object.admin)) obj.admin = String(object.admin); + if (isSet(object.pagination)) obj.pagination = PageRequest.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryGroupPoliciesByAdminRequest): JsonSafe { + const obj: any = {}; + message.admin !== undefined && (obj.admin = message.admin); + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryGroupPoliciesByAdminRequest { + const message = createBaseQueryGroupPoliciesByAdminRequest(); + message.admin = object.admin ?? ""; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryGroupPoliciesByAdminRequestSDKType): QueryGroupPoliciesByAdminRequest { + return { + admin: object?.admin, + pagination: object.pagination ? PageRequest.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryGroupPoliciesByAdminRequestSDKType { + return { + admin: isSet(object.admin) ? String(object.admin) : "", + pagination: isSet(object.pagination) ? PageRequest.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryGroupPoliciesByAdminRequest): QueryGroupPoliciesByAdminRequestSDKType { + const obj: any = {}; + obj.admin = message.admin; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryGroupPoliciesByAdminRequestAmino): QueryGroupPoliciesByAdminRequest { + const message = createBaseQueryGroupPoliciesByAdminRequest(); + if (object.admin !== undefined && object.admin !== null) { + message.admin = object.admin; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryGroupPoliciesByAdminRequest): QueryGroupPoliciesByAdminRequestAmino { + const obj: any = {}; + obj.admin = message.admin === "" ? undefined : message.admin; + obj.pagination = message.pagination ? PageRequest.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryGroupPoliciesByAdminRequestAminoMsg): QueryGroupPoliciesByAdminRequest { + return QueryGroupPoliciesByAdminRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryGroupPoliciesByAdminRequest): QueryGroupPoliciesByAdminRequestAminoMsg { + return { + type: "cosmos-sdk/QueryGroupPoliciesByAdminRequest", + value: QueryGroupPoliciesByAdminRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryGroupPoliciesByAdminRequestProtoMsg): QueryGroupPoliciesByAdminRequest { + return QueryGroupPoliciesByAdminRequest.decode(message.value); + }, + toProto(message: QueryGroupPoliciesByAdminRequest): Uint8Array { + return QueryGroupPoliciesByAdminRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryGroupPoliciesByAdminRequest): QueryGroupPoliciesByAdminRequestProtoMsg { + return { + typeUrl: "/cosmos.group.v1.QueryGroupPoliciesByAdminRequest", + value: QueryGroupPoliciesByAdminRequest.encode(message).finish() + }; + } +}; +function createBaseQueryGroupPoliciesByAdminResponse(): QueryGroupPoliciesByAdminResponse { + return { + groupPolicies: [], + pagination: undefined + }; +} +export const QueryGroupPoliciesByAdminResponse = { + typeUrl: "/cosmos.group.v1.QueryGroupPoliciesByAdminResponse", + encode(message: QueryGroupPoliciesByAdminResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.groupPolicies) { + GroupPolicyInfo.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryGroupPoliciesByAdminResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryGroupPoliciesByAdminResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.groupPolicies.push(GroupPolicyInfo.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryGroupPoliciesByAdminResponse { + const obj = createBaseQueryGroupPoliciesByAdminResponse(); + if (Array.isArray(object?.groupPolicies)) obj.groupPolicies = object.groupPolicies.map((e: any) => GroupPolicyInfo.fromJSON(e)); + if (isSet(object.pagination)) obj.pagination = PageResponse.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryGroupPoliciesByAdminResponse): JsonSafe { + const obj: any = {}; + if (message.groupPolicies) { + obj.groupPolicies = message.groupPolicies.map(e => e ? GroupPolicyInfo.toJSON(e) : undefined); + } else { + obj.groupPolicies = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryGroupPoliciesByAdminResponse { + const message = createBaseQueryGroupPoliciesByAdminResponse(); + message.groupPolicies = object.groupPolicies?.map(e => GroupPolicyInfo.fromPartial(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryGroupPoliciesByAdminResponseSDKType): QueryGroupPoliciesByAdminResponse { + return { + groupPolicies: Array.isArray(object?.group_policies) ? object.group_policies.map((e: any) => GroupPolicyInfo.fromSDK(e)) : [], + pagination: object.pagination ? PageResponse.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryGroupPoliciesByAdminResponseSDKType { + return { + group_policies: Array.isArray(object?.group_policies) ? object.group_policies.map((e: any) => GroupPolicyInfo.fromSDKJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryGroupPoliciesByAdminResponse): QueryGroupPoliciesByAdminResponseSDKType { + const obj: any = {}; + if (message.groupPolicies) { + obj.group_policies = message.groupPolicies.map(e => e ? GroupPolicyInfo.toSDK(e) : undefined); + } else { + obj.group_policies = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryGroupPoliciesByAdminResponseAmino): QueryGroupPoliciesByAdminResponse { + const message = createBaseQueryGroupPoliciesByAdminResponse(); + message.groupPolicies = object.group_policies?.map(e => GroupPolicyInfo.fromAmino(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryGroupPoliciesByAdminResponse): QueryGroupPoliciesByAdminResponseAmino { + const obj: any = {}; + if (message.groupPolicies) { + obj.group_policies = message.groupPolicies.map(e => e ? GroupPolicyInfo.toAmino(e) : undefined); + } else { + obj.group_policies = message.groupPolicies; + } + obj.pagination = message.pagination ? PageResponse.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryGroupPoliciesByAdminResponseAminoMsg): QueryGroupPoliciesByAdminResponse { + return QueryGroupPoliciesByAdminResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryGroupPoliciesByAdminResponse): QueryGroupPoliciesByAdminResponseAminoMsg { + return { + type: "cosmos-sdk/QueryGroupPoliciesByAdminResponse", + value: QueryGroupPoliciesByAdminResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryGroupPoliciesByAdminResponseProtoMsg): QueryGroupPoliciesByAdminResponse { + return QueryGroupPoliciesByAdminResponse.decode(message.value); + }, + toProto(message: QueryGroupPoliciesByAdminResponse): Uint8Array { + return QueryGroupPoliciesByAdminResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryGroupPoliciesByAdminResponse): QueryGroupPoliciesByAdminResponseProtoMsg { + return { + typeUrl: "/cosmos.group.v1.QueryGroupPoliciesByAdminResponse", + value: QueryGroupPoliciesByAdminResponse.encode(message).finish() + }; + } +}; +function createBaseQueryProposalRequest(): QueryProposalRequest { + return { + proposalId: BigInt(0) + }; +} +export const QueryProposalRequest = { + typeUrl: "/cosmos.group.v1.QueryProposalRequest", + encode(message: QueryProposalRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.proposalId !== undefined) { + writer.uint32(8).uint64(message.proposalId); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryProposalRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryProposalRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.proposalId = reader.uint64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryProposalRequest { + const obj = createBaseQueryProposalRequest(); + if (isSet(object.proposalId)) obj.proposalId = BigInt(object.proposalId.toString()); + return obj; + }, + toJSON(message: QueryProposalRequest): JsonSafe { + const obj: any = {}; + message.proposalId !== undefined && (obj.proposalId = (message.proposalId || BigInt(0)).toString()); + return obj; + }, + fromPartial(object: DeepPartial): QueryProposalRequest { + const message = createBaseQueryProposalRequest(); + if (object.proposalId !== undefined && object.proposalId !== null) { + message.proposalId = BigInt(object.proposalId.toString()); + } + return message; + }, + fromSDK(object: QueryProposalRequestSDKType): QueryProposalRequest { + return { + proposalId: object?.proposal_id + }; + }, + fromSDKJSON(object: any): QueryProposalRequestSDKType { + return { + proposal_id: isSet(object.proposal_id) ? BigInt(object.proposal_id.toString()) : BigInt(0) + }; + }, + toSDK(message: QueryProposalRequest): QueryProposalRequestSDKType { + const obj: any = {}; + obj.proposal_id = message.proposalId; + return obj; + }, + fromAmino(object: QueryProposalRequestAmino): QueryProposalRequest { + const message = createBaseQueryProposalRequest(); + if (object.proposal_id !== undefined && object.proposal_id !== null) { + message.proposalId = BigInt(object.proposal_id); + } + return message; + }, + toAmino(message: QueryProposalRequest): QueryProposalRequestAmino { + const obj: any = {}; + obj.proposal_id = message.proposalId !== BigInt(0) ? message.proposalId?.toString() : undefined; + return obj; + }, + fromAminoMsg(object: QueryProposalRequestAminoMsg): QueryProposalRequest { + return QueryProposalRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryProposalRequest): QueryProposalRequestAminoMsg { + return { + type: "cosmos-sdk/QueryProposalRequest", + value: QueryProposalRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryProposalRequestProtoMsg): QueryProposalRequest { + return QueryProposalRequest.decode(message.value); + }, + toProto(message: QueryProposalRequest): Uint8Array { + return QueryProposalRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryProposalRequest): QueryProposalRequestProtoMsg { + return { + typeUrl: "/cosmos.group.v1.QueryProposalRequest", + value: QueryProposalRequest.encode(message).finish() + }; + } +}; +function createBaseQueryProposalResponse(): QueryProposalResponse { + return { + proposal: undefined + }; +} +export const QueryProposalResponse = { + typeUrl: "/cosmos.group.v1.QueryProposalResponse", + encode(message: QueryProposalResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.proposal !== undefined) { + Proposal.encode(message.proposal, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryProposalResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryProposalResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.proposal = Proposal.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryProposalResponse { + const obj = createBaseQueryProposalResponse(); + if (isSet(object.proposal)) obj.proposal = Proposal.fromJSON(object.proposal); + return obj; + }, + toJSON(message: QueryProposalResponse): JsonSafe { + const obj: any = {}; + message.proposal !== undefined && (obj.proposal = message.proposal ? Proposal.toJSON(message.proposal) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryProposalResponse { + const message = createBaseQueryProposalResponse(); + if (object.proposal !== undefined && object.proposal !== null) { + message.proposal = Proposal.fromPartial(object.proposal); + } + return message; + }, + fromSDK(object: QueryProposalResponseSDKType): QueryProposalResponse { + return { + proposal: object.proposal ? Proposal.fromSDK(object.proposal) : undefined + }; + }, + fromSDKJSON(object: any): QueryProposalResponseSDKType { + return { + proposal: isSet(object.proposal) ? Proposal.fromSDKJSON(object.proposal) : undefined + }; + }, + toSDK(message: QueryProposalResponse): QueryProposalResponseSDKType { + const obj: any = {}; + message.proposal !== undefined && (obj.proposal = message.proposal ? Proposal.toSDK(message.proposal) : undefined); + return obj; + }, + fromAmino(object: QueryProposalResponseAmino): QueryProposalResponse { + const message = createBaseQueryProposalResponse(); + if (object.proposal !== undefined && object.proposal !== null) { + message.proposal = Proposal.fromAmino(object.proposal); + } + return message; + }, + toAmino(message: QueryProposalResponse): QueryProposalResponseAmino { + const obj: any = {}; + obj.proposal = message.proposal ? Proposal.toAmino(message.proposal) : undefined; + return obj; + }, + fromAminoMsg(object: QueryProposalResponseAminoMsg): QueryProposalResponse { + return QueryProposalResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryProposalResponse): QueryProposalResponseAminoMsg { + return { + type: "cosmos-sdk/QueryProposalResponse", + value: QueryProposalResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryProposalResponseProtoMsg): QueryProposalResponse { + return QueryProposalResponse.decode(message.value); + }, + toProto(message: QueryProposalResponse): Uint8Array { + return QueryProposalResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryProposalResponse): QueryProposalResponseProtoMsg { + return { + typeUrl: "/cosmos.group.v1.QueryProposalResponse", + value: QueryProposalResponse.encode(message).finish() + }; + } +}; +function createBaseQueryProposalsByGroupPolicyRequest(): QueryProposalsByGroupPolicyRequest { + return { + address: "", + pagination: undefined + }; +} +export const QueryProposalsByGroupPolicyRequest = { + typeUrl: "/cosmos.group.v1.QueryProposalsByGroupPolicyRequest", + encode(message: QueryProposalsByGroupPolicyRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.address !== undefined) { + writer.uint32(10).string(message.address); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryProposalsByGroupPolicyRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryProposalsByGroupPolicyRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.string(); + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryProposalsByGroupPolicyRequest { + const obj = createBaseQueryProposalsByGroupPolicyRequest(); + if (isSet(object.address)) obj.address = String(object.address); + if (isSet(object.pagination)) obj.pagination = PageRequest.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryProposalsByGroupPolicyRequest): JsonSafe { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryProposalsByGroupPolicyRequest { + const message = createBaseQueryProposalsByGroupPolicyRequest(); + message.address = object.address ?? ""; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryProposalsByGroupPolicyRequestSDKType): QueryProposalsByGroupPolicyRequest { + return { + address: object?.address, + pagination: object.pagination ? PageRequest.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryProposalsByGroupPolicyRequestSDKType { + return { + address: isSet(object.address) ? String(object.address) : "", + pagination: isSet(object.pagination) ? PageRequest.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryProposalsByGroupPolicyRequest): QueryProposalsByGroupPolicyRequestSDKType { + const obj: any = {}; + obj.address = message.address; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryProposalsByGroupPolicyRequestAmino): QueryProposalsByGroupPolicyRequest { + const message = createBaseQueryProposalsByGroupPolicyRequest(); + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryProposalsByGroupPolicyRequest): QueryProposalsByGroupPolicyRequestAmino { + const obj: any = {}; + obj.address = message.address === "" ? undefined : message.address; + obj.pagination = message.pagination ? PageRequest.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryProposalsByGroupPolicyRequestAminoMsg): QueryProposalsByGroupPolicyRequest { + return QueryProposalsByGroupPolicyRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryProposalsByGroupPolicyRequest): QueryProposalsByGroupPolicyRequestAminoMsg { + return { + type: "cosmos-sdk/QueryProposalsByGroupPolicyRequest", + value: QueryProposalsByGroupPolicyRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryProposalsByGroupPolicyRequestProtoMsg): QueryProposalsByGroupPolicyRequest { + return QueryProposalsByGroupPolicyRequest.decode(message.value); + }, + toProto(message: QueryProposalsByGroupPolicyRequest): Uint8Array { + return QueryProposalsByGroupPolicyRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryProposalsByGroupPolicyRequest): QueryProposalsByGroupPolicyRequestProtoMsg { + return { + typeUrl: "/cosmos.group.v1.QueryProposalsByGroupPolicyRequest", + value: QueryProposalsByGroupPolicyRequest.encode(message).finish() + }; + } +}; +function createBaseQueryProposalsByGroupPolicyResponse(): QueryProposalsByGroupPolicyResponse { + return { + proposals: [], + pagination: undefined + }; +} +export const QueryProposalsByGroupPolicyResponse = { + typeUrl: "/cosmos.group.v1.QueryProposalsByGroupPolicyResponse", + encode(message: QueryProposalsByGroupPolicyResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.proposals) { + Proposal.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryProposalsByGroupPolicyResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryProposalsByGroupPolicyResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.proposals.push(Proposal.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryProposalsByGroupPolicyResponse { + const obj = createBaseQueryProposalsByGroupPolicyResponse(); + if (Array.isArray(object?.proposals)) obj.proposals = object.proposals.map((e: any) => Proposal.fromJSON(e)); + if (isSet(object.pagination)) obj.pagination = PageResponse.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryProposalsByGroupPolicyResponse): JsonSafe { + const obj: any = {}; + if (message.proposals) { + obj.proposals = message.proposals.map(e => e ? Proposal.toJSON(e) : undefined); + } else { + obj.proposals = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryProposalsByGroupPolicyResponse { + const message = createBaseQueryProposalsByGroupPolicyResponse(); + message.proposals = object.proposals?.map(e => Proposal.fromPartial(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryProposalsByGroupPolicyResponseSDKType): QueryProposalsByGroupPolicyResponse { + return { + proposals: Array.isArray(object?.proposals) ? object.proposals.map((e: any) => Proposal.fromSDK(e)) : [], + pagination: object.pagination ? PageResponse.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryProposalsByGroupPolicyResponseSDKType { + return { + proposals: Array.isArray(object?.proposals) ? object.proposals.map((e: any) => Proposal.fromSDKJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryProposalsByGroupPolicyResponse): QueryProposalsByGroupPolicyResponseSDKType { + const obj: any = {}; + if (message.proposals) { + obj.proposals = message.proposals.map(e => e ? Proposal.toSDK(e) : undefined); + } else { + obj.proposals = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryProposalsByGroupPolicyResponseAmino): QueryProposalsByGroupPolicyResponse { + const message = createBaseQueryProposalsByGroupPolicyResponse(); + message.proposals = object.proposals?.map(e => Proposal.fromAmino(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryProposalsByGroupPolicyResponse): QueryProposalsByGroupPolicyResponseAmino { + const obj: any = {}; + if (message.proposals) { + obj.proposals = message.proposals.map(e => e ? Proposal.toAmino(e) : undefined); + } else { + obj.proposals = message.proposals; + } + obj.pagination = message.pagination ? PageResponse.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryProposalsByGroupPolicyResponseAminoMsg): QueryProposalsByGroupPolicyResponse { + return QueryProposalsByGroupPolicyResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryProposalsByGroupPolicyResponse): QueryProposalsByGroupPolicyResponseAminoMsg { + return { + type: "cosmos-sdk/QueryProposalsByGroupPolicyResponse", + value: QueryProposalsByGroupPolicyResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryProposalsByGroupPolicyResponseProtoMsg): QueryProposalsByGroupPolicyResponse { + return QueryProposalsByGroupPolicyResponse.decode(message.value); + }, + toProto(message: QueryProposalsByGroupPolicyResponse): Uint8Array { + return QueryProposalsByGroupPolicyResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryProposalsByGroupPolicyResponse): QueryProposalsByGroupPolicyResponseProtoMsg { + return { + typeUrl: "/cosmos.group.v1.QueryProposalsByGroupPolicyResponse", + value: QueryProposalsByGroupPolicyResponse.encode(message).finish() + }; + } +}; +function createBaseQueryVoteByProposalVoterRequest(): QueryVoteByProposalVoterRequest { + return { + proposalId: BigInt(0), + voter: "" + }; +} +export const QueryVoteByProposalVoterRequest = { + typeUrl: "/cosmos.group.v1.QueryVoteByProposalVoterRequest", + encode(message: QueryVoteByProposalVoterRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.proposalId !== undefined) { + writer.uint32(8).uint64(message.proposalId); + } + if (message.voter !== undefined) { + writer.uint32(18).string(message.voter); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryVoteByProposalVoterRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryVoteByProposalVoterRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.proposalId = reader.uint64(); + break; + case 2: + message.voter = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryVoteByProposalVoterRequest { + const obj = createBaseQueryVoteByProposalVoterRequest(); + if (isSet(object.proposalId)) obj.proposalId = BigInt(object.proposalId.toString()); + if (isSet(object.voter)) obj.voter = String(object.voter); + return obj; + }, + toJSON(message: QueryVoteByProposalVoterRequest): JsonSafe { + const obj: any = {}; + message.proposalId !== undefined && (obj.proposalId = (message.proposalId || BigInt(0)).toString()); + message.voter !== undefined && (obj.voter = message.voter); + return obj; + }, + fromPartial(object: DeepPartial): QueryVoteByProposalVoterRequest { + const message = createBaseQueryVoteByProposalVoterRequest(); + if (object.proposalId !== undefined && object.proposalId !== null) { + message.proposalId = BigInt(object.proposalId.toString()); + } + message.voter = object.voter ?? ""; + return message; + }, + fromSDK(object: QueryVoteByProposalVoterRequestSDKType): QueryVoteByProposalVoterRequest { + return { + proposalId: object?.proposal_id, + voter: object?.voter + }; + }, + fromSDKJSON(object: any): QueryVoteByProposalVoterRequestSDKType { + return { + proposal_id: isSet(object.proposal_id) ? BigInt(object.proposal_id.toString()) : BigInt(0), + voter: isSet(object.voter) ? String(object.voter) : "" + }; + }, + toSDK(message: QueryVoteByProposalVoterRequest): QueryVoteByProposalVoterRequestSDKType { + const obj: any = {}; + obj.proposal_id = message.proposalId; + obj.voter = message.voter; + return obj; + }, + fromAmino(object: QueryVoteByProposalVoterRequestAmino): QueryVoteByProposalVoterRequest { + const message = createBaseQueryVoteByProposalVoterRequest(); + if (object.proposal_id !== undefined && object.proposal_id !== null) { + message.proposalId = BigInt(object.proposal_id); + } + if (object.voter !== undefined && object.voter !== null) { + message.voter = object.voter; + } + return message; + }, + toAmino(message: QueryVoteByProposalVoterRequest): QueryVoteByProposalVoterRequestAmino { + const obj: any = {}; + obj.proposal_id = message.proposalId !== BigInt(0) ? message.proposalId?.toString() : undefined; + obj.voter = message.voter === "" ? undefined : message.voter; + return obj; + }, + fromAminoMsg(object: QueryVoteByProposalVoterRequestAminoMsg): QueryVoteByProposalVoterRequest { + return QueryVoteByProposalVoterRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryVoteByProposalVoterRequest): QueryVoteByProposalVoterRequestAminoMsg { + return { + type: "cosmos-sdk/QueryVoteByProposalVoterRequest", + value: QueryVoteByProposalVoterRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryVoteByProposalVoterRequestProtoMsg): QueryVoteByProposalVoterRequest { + return QueryVoteByProposalVoterRequest.decode(message.value); + }, + toProto(message: QueryVoteByProposalVoterRequest): Uint8Array { + return QueryVoteByProposalVoterRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryVoteByProposalVoterRequest): QueryVoteByProposalVoterRequestProtoMsg { + return { + typeUrl: "/cosmos.group.v1.QueryVoteByProposalVoterRequest", + value: QueryVoteByProposalVoterRequest.encode(message).finish() + }; + } +}; +function createBaseQueryVoteByProposalVoterResponse(): QueryVoteByProposalVoterResponse { + return { + vote: undefined + }; +} +export const QueryVoteByProposalVoterResponse = { + typeUrl: "/cosmos.group.v1.QueryVoteByProposalVoterResponse", + encode(message: QueryVoteByProposalVoterResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.vote !== undefined) { + Vote.encode(message.vote, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryVoteByProposalVoterResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryVoteByProposalVoterResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.vote = Vote.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryVoteByProposalVoterResponse { + const obj = createBaseQueryVoteByProposalVoterResponse(); + if (isSet(object.vote)) obj.vote = Vote.fromJSON(object.vote); + return obj; + }, + toJSON(message: QueryVoteByProposalVoterResponse): JsonSafe { + const obj: any = {}; + message.vote !== undefined && (obj.vote = message.vote ? Vote.toJSON(message.vote) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryVoteByProposalVoterResponse { + const message = createBaseQueryVoteByProposalVoterResponse(); + if (object.vote !== undefined && object.vote !== null) { + message.vote = Vote.fromPartial(object.vote); + } + return message; + }, + fromSDK(object: QueryVoteByProposalVoterResponseSDKType): QueryVoteByProposalVoterResponse { + return { + vote: object.vote ? Vote.fromSDK(object.vote) : undefined + }; + }, + fromSDKJSON(object: any): QueryVoteByProposalVoterResponseSDKType { + return { + vote: isSet(object.vote) ? Vote.fromSDKJSON(object.vote) : undefined + }; + }, + toSDK(message: QueryVoteByProposalVoterResponse): QueryVoteByProposalVoterResponseSDKType { + const obj: any = {}; + message.vote !== undefined && (obj.vote = message.vote ? Vote.toSDK(message.vote) : undefined); + return obj; + }, + fromAmino(object: QueryVoteByProposalVoterResponseAmino): QueryVoteByProposalVoterResponse { + const message = createBaseQueryVoteByProposalVoterResponse(); + if (object.vote !== undefined && object.vote !== null) { + message.vote = Vote.fromAmino(object.vote); + } + return message; + }, + toAmino(message: QueryVoteByProposalVoterResponse): QueryVoteByProposalVoterResponseAmino { + const obj: any = {}; + obj.vote = message.vote ? Vote.toAmino(message.vote) : undefined; + return obj; + }, + fromAminoMsg(object: QueryVoteByProposalVoterResponseAminoMsg): QueryVoteByProposalVoterResponse { + return QueryVoteByProposalVoterResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryVoteByProposalVoterResponse): QueryVoteByProposalVoterResponseAminoMsg { + return { + type: "cosmos-sdk/QueryVoteByProposalVoterResponse", + value: QueryVoteByProposalVoterResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryVoteByProposalVoterResponseProtoMsg): QueryVoteByProposalVoterResponse { + return QueryVoteByProposalVoterResponse.decode(message.value); + }, + toProto(message: QueryVoteByProposalVoterResponse): Uint8Array { + return QueryVoteByProposalVoterResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryVoteByProposalVoterResponse): QueryVoteByProposalVoterResponseProtoMsg { + return { + typeUrl: "/cosmos.group.v1.QueryVoteByProposalVoterResponse", + value: QueryVoteByProposalVoterResponse.encode(message).finish() + }; + } +}; +function createBaseQueryVotesByProposalRequest(): QueryVotesByProposalRequest { + return { + proposalId: BigInt(0), + pagination: undefined + }; +} +export const QueryVotesByProposalRequest = { + typeUrl: "/cosmos.group.v1.QueryVotesByProposalRequest", + encode(message: QueryVotesByProposalRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.proposalId !== undefined) { + writer.uint32(8).uint64(message.proposalId); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryVotesByProposalRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryVotesByProposalRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.proposalId = reader.uint64(); + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryVotesByProposalRequest { + const obj = createBaseQueryVotesByProposalRequest(); + if (isSet(object.proposalId)) obj.proposalId = BigInt(object.proposalId.toString()); + if (isSet(object.pagination)) obj.pagination = PageRequest.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryVotesByProposalRequest): JsonSafe { + const obj: any = {}; + message.proposalId !== undefined && (obj.proposalId = (message.proposalId || BigInt(0)).toString()); + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryVotesByProposalRequest { + const message = createBaseQueryVotesByProposalRequest(); + if (object.proposalId !== undefined && object.proposalId !== null) { + message.proposalId = BigInt(object.proposalId.toString()); + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryVotesByProposalRequestSDKType): QueryVotesByProposalRequest { + return { + proposalId: object?.proposal_id, + pagination: object.pagination ? PageRequest.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryVotesByProposalRequestSDKType { + return { + proposal_id: isSet(object.proposal_id) ? BigInt(object.proposal_id.toString()) : BigInt(0), + pagination: isSet(object.pagination) ? PageRequest.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryVotesByProposalRequest): QueryVotesByProposalRequestSDKType { + const obj: any = {}; + obj.proposal_id = message.proposalId; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryVotesByProposalRequestAmino): QueryVotesByProposalRequest { + const message = createBaseQueryVotesByProposalRequest(); + if (object.proposal_id !== undefined && object.proposal_id !== null) { + message.proposalId = BigInt(object.proposal_id); + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryVotesByProposalRequest): QueryVotesByProposalRequestAmino { + const obj: any = {}; + obj.proposal_id = message.proposalId !== BigInt(0) ? message.proposalId?.toString() : undefined; + obj.pagination = message.pagination ? PageRequest.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryVotesByProposalRequestAminoMsg): QueryVotesByProposalRequest { + return QueryVotesByProposalRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryVotesByProposalRequest): QueryVotesByProposalRequestAminoMsg { + return { + type: "cosmos-sdk/QueryVotesByProposalRequest", + value: QueryVotesByProposalRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryVotesByProposalRequestProtoMsg): QueryVotesByProposalRequest { + return QueryVotesByProposalRequest.decode(message.value); + }, + toProto(message: QueryVotesByProposalRequest): Uint8Array { + return QueryVotesByProposalRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryVotesByProposalRequest): QueryVotesByProposalRequestProtoMsg { + return { + typeUrl: "/cosmos.group.v1.QueryVotesByProposalRequest", + value: QueryVotesByProposalRequest.encode(message).finish() + }; + } +}; +function createBaseQueryVotesByProposalResponse(): QueryVotesByProposalResponse { + return { + votes: [], + pagination: undefined + }; +} +export const QueryVotesByProposalResponse = { + typeUrl: "/cosmos.group.v1.QueryVotesByProposalResponse", + encode(message: QueryVotesByProposalResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.votes) { + Vote.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryVotesByProposalResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryVotesByProposalResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.votes.push(Vote.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryVotesByProposalResponse { + const obj = createBaseQueryVotesByProposalResponse(); + if (Array.isArray(object?.votes)) obj.votes = object.votes.map((e: any) => Vote.fromJSON(e)); + if (isSet(object.pagination)) obj.pagination = PageResponse.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryVotesByProposalResponse): JsonSafe { + const obj: any = {}; + if (message.votes) { + obj.votes = message.votes.map(e => e ? Vote.toJSON(e) : undefined); + } else { + obj.votes = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryVotesByProposalResponse { + const message = createBaseQueryVotesByProposalResponse(); + message.votes = object.votes?.map(e => Vote.fromPartial(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryVotesByProposalResponseSDKType): QueryVotesByProposalResponse { + return { + votes: Array.isArray(object?.votes) ? object.votes.map((e: any) => Vote.fromSDK(e)) : [], + pagination: object.pagination ? PageResponse.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryVotesByProposalResponseSDKType { + return { + votes: Array.isArray(object?.votes) ? object.votes.map((e: any) => Vote.fromSDKJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryVotesByProposalResponse): QueryVotesByProposalResponseSDKType { + const obj: any = {}; + if (message.votes) { + obj.votes = message.votes.map(e => e ? Vote.toSDK(e) : undefined); + } else { + obj.votes = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryVotesByProposalResponseAmino): QueryVotesByProposalResponse { + const message = createBaseQueryVotesByProposalResponse(); + message.votes = object.votes?.map(e => Vote.fromAmino(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryVotesByProposalResponse): QueryVotesByProposalResponseAmino { + const obj: any = {}; + if (message.votes) { + obj.votes = message.votes.map(e => e ? Vote.toAmino(e) : undefined); + } else { + obj.votes = message.votes; + } + obj.pagination = message.pagination ? PageResponse.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryVotesByProposalResponseAminoMsg): QueryVotesByProposalResponse { + return QueryVotesByProposalResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryVotesByProposalResponse): QueryVotesByProposalResponseAminoMsg { + return { + type: "cosmos-sdk/QueryVotesByProposalResponse", + value: QueryVotesByProposalResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryVotesByProposalResponseProtoMsg): QueryVotesByProposalResponse { + return QueryVotesByProposalResponse.decode(message.value); + }, + toProto(message: QueryVotesByProposalResponse): Uint8Array { + return QueryVotesByProposalResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryVotesByProposalResponse): QueryVotesByProposalResponseProtoMsg { + return { + typeUrl: "/cosmos.group.v1.QueryVotesByProposalResponse", + value: QueryVotesByProposalResponse.encode(message).finish() + }; + } +}; +function createBaseQueryVotesByVoterRequest(): QueryVotesByVoterRequest { + return { + voter: "", + pagination: undefined + }; +} +export const QueryVotesByVoterRequest = { + typeUrl: "/cosmos.group.v1.QueryVotesByVoterRequest", + encode(message: QueryVotesByVoterRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.voter !== undefined) { + writer.uint32(10).string(message.voter); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryVotesByVoterRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryVotesByVoterRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.voter = reader.string(); + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryVotesByVoterRequest { + const obj = createBaseQueryVotesByVoterRequest(); + if (isSet(object.voter)) obj.voter = String(object.voter); + if (isSet(object.pagination)) obj.pagination = PageRequest.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryVotesByVoterRequest): JsonSafe { + const obj: any = {}; + message.voter !== undefined && (obj.voter = message.voter); + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryVotesByVoterRequest { + const message = createBaseQueryVotesByVoterRequest(); + message.voter = object.voter ?? ""; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryVotesByVoterRequestSDKType): QueryVotesByVoterRequest { + return { + voter: object?.voter, + pagination: object.pagination ? PageRequest.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryVotesByVoterRequestSDKType { + return { + voter: isSet(object.voter) ? String(object.voter) : "", + pagination: isSet(object.pagination) ? PageRequest.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryVotesByVoterRequest): QueryVotesByVoterRequestSDKType { + const obj: any = {}; + obj.voter = message.voter; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryVotesByVoterRequestAmino): QueryVotesByVoterRequest { + const message = createBaseQueryVotesByVoterRequest(); + if (object.voter !== undefined && object.voter !== null) { + message.voter = object.voter; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryVotesByVoterRequest): QueryVotesByVoterRequestAmino { + const obj: any = {}; + obj.voter = message.voter === "" ? undefined : message.voter; + obj.pagination = message.pagination ? PageRequest.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryVotesByVoterRequestAminoMsg): QueryVotesByVoterRequest { + return QueryVotesByVoterRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryVotesByVoterRequest): QueryVotesByVoterRequestAminoMsg { + return { + type: "cosmos-sdk/QueryVotesByVoterRequest", + value: QueryVotesByVoterRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryVotesByVoterRequestProtoMsg): QueryVotesByVoterRequest { + return QueryVotesByVoterRequest.decode(message.value); + }, + toProto(message: QueryVotesByVoterRequest): Uint8Array { + return QueryVotesByVoterRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryVotesByVoterRequest): QueryVotesByVoterRequestProtoMsg { + return { + typeUrl: "/cosmos.group.v1.QueryVotesByVoterRequest", + value: QueryVotesByVoterRequest.encode(message).finish() + }; + } +}; +function createBaseQueryVotesByVoterResponse(): QueryVotesByVoterResponse { + return { + votes: [], + pagination: undefined + }; +} +export const QueryVotesByVoterResponse = { + typeUrl: "/cosmos.group.v1.QueryVotesByVoterResponse", + encode(message: QueryVotesByVoterResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.votes) { + Vote.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryVotesByVoterResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryVotesByVoterResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.votes.push(Vote.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryVotesByVoterResponse { + const obj = createBaseQueryVotesByVoterResponse(); + if (Array.isArray(object?.votes)) obj.votes = object.votes.map((e: any) => Vote.fromJSON(e)); + if (isSet(object.pagination)) obj.pagination = PageResponse.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryVotesByVoterResponse): JsonSafe { + const obj: any = {}; + if (message.votes) { + obj.votes = message.votes.map(e => e ? Vote.toJSON(e) : undefined); + } else { + obj.votes = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryVotesByVoterResponse { + const message = createBaseQueryVotesByVoterResponse(); + message.votes = object.votes?.map(e => Vote.fromPartial(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryVotesByVoterResponseSDKType): QueryVotesByVoterResponse { + return { + votes: Array.isArray(object?.votes) ? object.votes.map((e: any) => Vote.fromSDK(e)) : [], + pagination: object.pagination ? PageResponse.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryVotesByVoterResponseSDKType { + return { + votes: Array.isArray(object?.votes) ? object.votes.map((e: any) => Vote.fromSDKJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryVotesByVoterResponse): QueryVotesByVoterResponseSDKType { + const obj: any = {}; + if (message.votes) { + obj.votes = message.votes.map(e => e ? Vote.toSDK(e) : undefined); + } else { + obj.votes = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryVotesByVoterResponseAmino): QueryVotesByVoterResponse { + const message = createBaseQueryVotesByVoterResponse(); + message.votes = object.votes?.map(e => Vote.fromAmino(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryVotesByVoterResponse): QueryVotesByVoterResponseAmino { + const obj: any = {}; + if (message.votes) { + obj.votes = message.votes.map(e => e ? Vote.toAmino(e) : undefined); + } else { + obj.votes = message.votes; + } + obj.pagination = message.pagination ? PageResponse.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryVotesByVoterResponseAminoMsg): QueryVotesByVoterResponse { + return QueryVotesByVoterResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryVotesByVoterResponse): QueryVotesByVoterResponseAminoMsg { + return { + type: "cosmos-sdk/QueryVotesByVoterResponse", + value: QueryVotesByVoterResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryVotesByVoterResponseProtoMsg): QueryVotesByVoterResponse { + return QueryVotesByVoterResponse.decode(message.value); + }, + toProto(message: QueryVotesByVoterResponse): Uint8Array { + return QueryVotesByVoterResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryVotesByVoterResponse): QueryVotesByVoterResponseProtoMsg { + return { + typeUrl: "/cosmos.group.v1.QueryVotesByVoterResponse", + value: QueryVotesByVoterResponse.encode(message).finish() + }; + } +}; +function createBaseQueryGroupsByMemberRequest(): QueryGroupsByMemberRequest { + return { + address: "", + pagination: undefined + }; +} +export const QueryGroupsByMemberRequest = { + typeUrl: "/cosmos.group.v1.QueryGroupsByMemberRequest", + encode(message: QueryGroupsByMemberRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.address !== undefined) { + writer.uint32(10).string(message.address); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryGroupsByMemberRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryGroupsByMemberRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.string(); + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryGroupsByMemberRequest { + const obj = createBaseQueryGroupsByMemberRequest(); + if (isSet(object.address)) obj.address = String(object.address); + if (isSet(object.pagination)) obj.pagination = PageRequest.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryGroupsByMemberRequest): JsonSafe { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryGroupsByMemberRequest { + const message = createBaseQueryGroupsByMemberRequest(); + message.address = object.address ?? ""; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryGroupsByMemberRequestSDKType): QueryGroupsByMemberRequest { + return { + address: object?.address, + pagination: object.pagination ? PageRequest.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryGroupsByMemberRequestSDKType { + return { + address: isSet(object.address) ? String(object.address) : "", + pagination: isSet(object.pagination) ? PageRequest.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryGroupsByMemberRequest): QueryGroupsByMemberRequestSDKType { + const obj: any = {}; + obj.address = message.address; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryGroupsByMemberRequestAmino): QueryGroupsByMemberRequest { + const message = createBaseQueryGroupsByMemberRequest(); + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryGroupsByMemberRequest): QueryGroupsByMemberRequestAmino { + const obj: any = {}; + obj.address = message.address === "" ? undefined : message.address; + obj.pagination = message.pagination ? PageRequest.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryGroupsByMemberRequestAminoMsg): QueryGroupsByMemberRequest { + return QueryGroupsByMemberRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryGroupsByMemberRequest): QueryGroupsByMemberRequestAminoMsg { + return { + type: "cosmos-sdk/QueryGroupsByMemberRequest", + value: QueryGroupsByMemberRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryGroupsByMemberRequestProtoMsg): QueryGroupsByMemberRequest { + return QueryGroupsByMemberRequest.decode(message.value); + }, + toProto(message: QueryGroupsByMemberRequest): Uint8Array { + return QueryGroupsByMemberRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryGroupsByMemberRequest): QueryGroupsByMemberRequestProtoMsg { + return { + typeUrl: "/cosmos.group.v1.QueryGroupsByMemberRequest", + value: QueryGroupsByMemberRequest.encode(message).finish() + }; + } +}; +function createBaseQueryGroupsByMemberResponse(): QueryGroupsByMemberResponse { + return { + groups: [], + pagination: undefined + }; +} +export const QueryGroupsByMemberResponse = { + typeUrl: "/cosmos.group.v1.QueryGroupsByMemberResponse", + encode(message: QueryGroupsByMemberResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.groups) { + GroupInfo.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryGroupsByMemberResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryGroupsByMemberResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.groups.push(GroupInfo.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryGroupsByMemberResponse { + const obj = createBaseQueryGroupsByMemberResponse(); + if (Array.isArray(object?.groups)) obj.groups = object.groups.map((e: any) => GroupInfo.fromJSON(e)); + if (isSet(object.pagination)) obj.pagination = PageResponse.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryGroupsByMemberResponse): JsonSafe { + const obj: any = {}; + if (message.groups) { + obj.groups = message.groups.map(e => e ? GroupInfo.toJSON(e) : undefined); + } else { + obj.groups = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryGroupsByMemberResponse { + const message = createBaseQueryGroupsByMemberResponse(); + message.groups = object.groups?.map(e => GroupInfo.fromPartial(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryGroupsByMemberResponseSDKType): QueryGroupsByMemberResponse { + return { + groups: Array.isArray(object?.groups) ? object.groups.map((e: any) => GroupInfo.fromSDK(e)) : [], + pagination: object.pagination ? PageResponse.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryGroupsByMemberResponseSDKType { + return { + groups: Array.isArray(object?.groups) ? object.groups.map((e: any) => GroupInfo.fromSDKJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryGroupsByMemberResponse): QueryGroupsByMemberResponseSDKType { + const obj: any = {}; + if (message.groups) { + obj.groups = message.groups.map(e => e ? GroupInfo.toSDK(e) : undefined); + } else { + obj.groups = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryGroupsByMemberResponseAmino): QueryGroupsByMemberResponse { + const message = createBaseQueryGroupsByMemberResponse(); + message.groups = object.groups?.map(e => GroupInfo.fromAmino(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryGroupsByMemberResponse): QueryGroupsByMemberResponseAmino { + const obj: any = {}; + if (message.groups) { + obj.groups = message.groups.map(e => e ? GroupInfo.toAmino(e) : undefined); + } else { + obj.groups = message.groups; + } + obj.pagination = message.pagination ? PageResponse.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryGroupsByMemberResponseAminoMsg): QueryGroupsByMemberResponse { + return QueryGroupsByMemberResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryGroupsByMemberResponse): QueryGroupsByMemberResponseAminoMsg { + return { + type: "cosmos-sdk/QueryGroupsByMemberResponse", + value: QueryGroupsByMemberResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryGroupsByMemberResponseProtoMsg): QueryGroupsByMemberResponse { + return QueryGroupsByMemberResponse.decode(message.value); + }, + toProto(message: QueryGroupsByMemberResponse): Uint8Array { + return QueryGroupsByMemberResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryGroupsByMemberResponse): QueryGroupsByMemberResponseProtoMsg { + return { + typeUrl: "/cosmos.group.v1.QueryGroupsByMemberResponse", + value: QueryGroupsByMemberResponse.encode(message).finish() + }; + } +}; +function createBaseQueryTallyResultRequest(): QueryTallyResultRequest { + return { + proposalId: BigInt(0) + }; +} +export const QueryTallyResultRequest = { + typeUrl: "/cosmos.group.v1.QueryTallyResultRequest", + encode(message: QueryTallyResultRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.proposalId !== undefined) { + writer.uint32(8).uint64(message.proposalId); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryTallyResultRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryTallyResultRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.proposalId = reader.uint64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryTallyResultRequest { + const obj = createBaseQueryTallyResultRequest(); + if (isSet(object.proposalId)) obj.proposalId = BigInt(object.proposalId.toString()); + return obj; + }, + toJSON(message: QueryTallyResultRequest): JsonSafe { + const obj: any = {}; + message.proposalId !== undefined && (obj.proposalId = (message.proposalId || BigInt(0)).toString()); + return obj; + }, + fromPartial(object: DeepPartial): QueryTallyResultRequest { + const message = createBaseQueryTallyResultRequest(); + if (object.proposalId !== undefined && object.proposalId !== null) { + message.proposalId = BigInt(object.proposalId.toString()); + } + return message; + }, + fromSDK(object: QueryTallyResultRequestSDKType): QueryTallyResultRequest { + return { + proposalId: object?.proposal_id + }; + }, + fromSDKJSON(object: any): QueryTallyResultRequestSDKType { + return { + proposal_id: isSet(object.proposal_id) ? BigInt(object.proposal_id.toString()) : BigInt(0) + }; + }, + toSDK(message: QueryTallyResultRequest): QueryTallyResultRequestSDKType { + const obj: any = {}; + obj.proposal_id = message.proposalId; + return obj; + }, + fromAmino(object: QueryTallyResultRequestAmino): QueryTallyResultRequest { + const message = createBaseQueryTallyResultRequest(); + if (object.proposal_id !== undefined && object.proposal_id !== null) { + message.proposalId = BigInt(object.proposal_id); + } + return message; + }, + toAmino(message: QueryTallyResultRequest): QueryTallyResultRequestAmino { + const obj: any = {}; + obj.proposal_id = message.proposalId !== BigInt(0) ? message.proposalId?.toString() : undefined; + return obj; + }, + fromAminoMsg(object: QueryTallyResultRequestAminoMsg): QueryTallyResultRequest { + return QueryTallyResultRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryTallyResultRequest): QueryTallyResultRequestAminoMsg { + return { + type: "cosmos-sdk/QueryTallyResultRequest", + value: QueryTallyResultRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryTallyResultRequestProtoMsg): QueryTallyResultRequest { + return QueryTallyResultRequest.decode(message.value); + }, + toProto(message: QueryTallyResultRequest): Uint8Array { + return QueryTallyResultRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryTallyResultRequest): QueryTallyResultRequestProtoMsg { + return { + typeUrl: "/cosmos.group.v1.QueryTallyResultRequest", + value: QueryTallyResultRequest.encode(message).finish() + }; + } +}; +function createBaseQueryTallyResultResponse(): QueryTallyResultResponse { + return { + tally: TallyResult.fromPartial({}) + }; +} +export const QueryTallyResultResponse = { + typeUrl: "/cosmos.group.v1.QueryTallyResultResponse", + encode(message: QueryTallyResultResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.tally !== undefined) { + TallyResult.encode(message.tally, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryTallyResultResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryTallyResultResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.tally = TallyResult.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryTallyResultResponse { + const obj = createBaseQueryTallyResultResponse(); + if (isSet(object.tally)) obj.tally = TallyResult.fromJSON(object.tally); + return obj; + }, + toJSON(message: QueryTallyResultResponse): JsonSafe { + const obj: any = {}; + message.tally !== undefined && (obj.tally = message.tally ? TallyResult.toJSON(message.tally) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryTallyResultResponse { + const message = createBaseQueryTallyResultResponse(); + if (object.tally !== undefined && object.tally !== null) { + message.tally = TallyResult.fromPartial(object.tally); + } + return message; + }, + fromSDK(object: QueryTallyResultResponseSDKType): QueryTallyResultResponse { + return { + tally: object.tally ? TallyResult.fromSDK(object.tally) : undefined + }; + }, + fromSDKJSON(object: any): QueryTallyResultResponseSDKType { + return { + tally: isSet(object.tally) ? TallyResult.fromSDKJSON(object.tally) : undefined + }; + }, + toSDK(message: QueryTallyResultResponse): QueryTallyResultResponseSDKType { + const obj: any = {}; + message.tally !== undefined && (obj.tally = message.tally ? TallyResult.toSDK(message.tally) : undefined); + return obj; + }, + fromAmino(object: QueryTallyResultResponseAmino): QueryTallyResultResponse { + const message = createBaseQueryTallyResultResponse(); + if (object.tally !== undefined && object.tally !== null) { + message.tally = TallyResult.fromAmino(object.tally); + } + return message; + }, + toAmino(message: QueryTallyResultResponse): QueryTallyResultResponseAmino { + const obj: any = {}; + obj.tally = message.tally ? TallyResult.toAmino(message.tally) : undefined; + return obj; + }, + fromAminoMsg(object: QueryTallyResultResponseAminoMsg): QueryTallyResultResponse { + return QueryTallyResultResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryTallyResultResponse): QueryTallyResultResponseAminoMsg { + return { + type: "cosmos-sdk/QueryTallyResultResponse", + value: QueryTallyResultResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryTallyResultResponseProtoMsg): QueryTallyResultResponse { + return QueryTallyResultResponse.decode(message.value); + }, + toProto(message: QueryTallyResultResponse): Uint8Array { + return QueryTallyResultResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryTallyResultResponse): QueryTallyResultResponseProtoMsg { + return { + typeUrl: "/cosmos.group.v1.QueryTallyResultResponse", + value: QueryTallyResultResponse.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/group/v1/tx.amino.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/group/v1/tx.amino.ts new file mode 100644 index 0000000000..dad8ce4ef6 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/group/v1/tx.amino.ts @@ -0,0 +1,574 @@ +import { Member, MemberSDKType, VoteOption, VoteOptionSDKType, voteOptionFromJSON } from "./types.js"; +import { Any, AnySDKType } from "../../../google/protobuf/any.js"; +import { ReadOnlyAminoMsg as AminoMsg } from "@interchainjs/ReadOnlyAminoMsg"; +import { execFromJSON, MsgCreateGroup, MsgCreateGroupSDKType, MsgUpdateGroupMembers, MsgUpdateGroupMembersSDKType, MsgUpdateGroupAdmin, MsgUpdateGroupAdminSDKType, MsgUpdateGroupMetadata, MsgUpdateGroupMetadataSDKType, MsgCreateGroupPolicy, MsgCreateGroupPolicySDKType, MsgCreateGroupWithPolicy, MsgCreateGroupWithPolicySDKType, MsgUpdateGroupPolicyAdmin, MsgUpdateGroupPolicyAdminSDKType, MsgUpdateGroupPolicyDecisionPolicy, MsgUpdateGroupPolicyDecisionPolicySDKType, MsgUpdateGroupPolicyMetadata, MsgUpdateGroupPolicyMetadataSDKType, MsgSubmitProposal, MsgSubmitProposalSDKType, MsgWithdrawProposal, MsgWithdrawProposalSDKType, MsgVote, MsgVoteSDKType, MsgExec, MsgExecSDKType, MsgLeaveGroup, MsgLeaveGroupSDKType } from "./tx.js"; +export interface MsgCreateGroupAminoType extends AminoMsg { + type: "cosmos-sdk/MsgCreateGroup"; + value: { + admin: string; + members: { + address: string; + weight: string; + metadata: string; + added_at: string; + }[]; + metadata: string; + }; +} +export interface MsgUpdateGroupMembersAminoType extends AminoMsg { + type: "cosmos-sdk/MsgUpdateGroupMembers"; + value: { + admin: string; + group_id: string; + member_updates: { + address: string; + weight: string; + metadata: string; + added_at: string; + }[]; + }; +} +export interface MsgUpdateGroupAdminAminoType extends AminoMsg { + type: "cosmos-sdk/MsgUpdateGroupAdmin"; + value: { + admin: string; + group_id: string; + new_admin: string; + }; +} +export interface MsgUpdateGroupMetadataAminoType extends AminoMsg { + type: "cosmos-sdk/MsgUpdateGroupMetadata"; + value: { + admin: string; + group_id: string; + metadata: string; + }; +} +export interface MsgCreateGroupPolicyAminoType extends AminoMsg { + type: "cosmos-sdk/MsgCreateGroupPolicy"; + value: { + admin: string; + group_id: string; + metadata: string; + decision_policy: { + type_url: string; + value: Uint8Array; + }; + }; +} +export interface MsgCreateGroupWithPolicyAminoType extends AminoMsg { + type: "cosmos-sdk/MsgCreateGroupWithPolicy"; + value: { + admin: string; + members: { + address: string; + weight: string; + metadata: string; + added_at: string; + }[]; + group_metadata: string; + group_policy_metadata: string; + group_policy_as_admin: boolean; + decision_policy: { + type_url: string; + value: Uint8Array; + }; + }; +} +export interface MsgUpdateGroupPolicyAdminAminoType extends AminoMsg { + type: "cosmos-sdk/MsgUpdateGroupPolicyAdmin"; + value: { + admin: string; + address: string; + new_admin: string; + }; +} +export interface MsgUpdateGroupPolicyDecisionPolicyAminoType extends AminoMsg { + type: "cosmos-sdk/MsgUpdateGroupPolicyDecisionPolicy"; + value: { + admin: string; + address: string; + decision_policy: { + type_url: string; + value: Uint8Array; + }; + }; +} +export interface MsgUpdateGroupPolicyMetadataAminoType extends AminoMsg { + type: "cosmos-sdk/MsgUpdateGroupPolicyMetadata"; + value: { + admin: string; + address: string; + metadata: string; + }; +} +export interface MsgSubmitProposalAminoType extends AminoMsg { + type: "cosmos-sdk/group/MsgSubmitProposal"; + value: { + address: string; + proposers: string[]; + metadata: string; + messages: { + type_url: string; + value: Uint8Array; + }[]; + exec: number; + }; +} +export interface MsgWithdrawProposalAminoType extends AminoMsg { + type: "cosmos-sdk/group/MsgWithdrawProposal"; + value: { + proposal_id: string; + address: string; + }; +} +export interface MsgVoteAminoType extends AminoMsg { + type: "cosmos-sdk/group/MsgVote"; + value: { + proposal_id: string; + voter: string; + option: number; + metadata: string; + exec: number; + }; +} +export interface MsgExecAminoType extends AminoMsg { + type: "cosmos-sdk/group/MsgExec"; + value: { + proposal_id: string; + signer: string; + }; +} +export interface MsgLeaveGroupAminoType extends AminoMsg { + type: "cosmos-sdk/group/MsgLeaveGroup"; + value: { + address: string; + group_id: string; + }; +} +export const AminoConverter = { + "/cosmos.group.v1.MsgCreateGroup": { + aminoType: "cosmos-sdk/MsgCreateGroup", + toAmino: ({ + admin, + members, + metadata + }: MsgCreateGroup): MsgCreateGroupAminoType["value"] => { + return { + admin, + members: members.map(el0 => ({ + address: el0.address, + weight: el0.weight, + metadata: el0.metadata, + added_at: el0.addedAt + })), + metadata + }; + }, + fromAmino: ({ + admin, + members, + metadata + }: MsgCreateGroupAminoType["value"]): MsgCreateGroup => { + return { + admin, + members: members.map(el0 => ({ + address: el0.address, + weight: el0.weight, + metadata: el0.metadata, + addedAt: el0.added_at + })), + metadata + }; + } + }, + "/cosmos.group.v1.MsgUpdateGroupMembers": { + aminoType: "cosmos-sdk/MsgUpdateGroupMembers", + toAmino: ({ + admin, + groupId, + memberUpdates + }: MsgUpdateGroupMembers): MsgUpdateGroupMembersAminoType["value"] => { + return { + admin, + group_id: groupId.toString(), + member_updates: memberUpdates.map(el0 => ({ + address: el0.address, + weight: el0.weight, + metadata: el0.metadata, + added_at: el0.addedAt + })) + }; + }, + fromAmino: ({ + admin, + group_id, + member_updates + }: MsgUpdateGroupMembersAminoType["value"]): MsgUpdateGroupMembers => { + return { + admin, + groupId: BigInt(group_id), + memberUpdates: member_updates.map(el0 => ({ + address: el0.address, + weight: el0.weight, + metadata: el0.metadata, + addedAt: el0.added_at + })) + }; + } + }, + "/cosmos.group.v1.MsgUpdateGroupAdmin": { + aminoType: "cosmos-sdk/MsgUpdateGroupAdmin", + toAmino: ({ + admin, + groupId, + newAdmin + }: MsgUpdateGroupAdmin): MsgUpdateGroupAdminAminoType["value"] => { + return { + admin, + group_id: groupId.toString(), + new_admin: newAdmin + }; + }, + fromAmino: ({ + admin, + group_id, + new_admin + }: MsgUpdateGroupAdminAminoType["value"]): MsgUpdateGroupAdmin => { + return { + admin, + groupId: BigInt(group_id), + newAdmin: new_admin + }; + } + }, + "/cosmos.group.v1.MsgUpdateGroupMetadata": { + aminoType: "cosmos-sdk/MsgUpdateGroupMetadata", + toAmino: ({ + admin, + groupId, + metadata + }: MsgUpdateGroupMetadata): MsgUpdateGroupMetadataAminoType["value"] => { + return { + admin, + group_id: groupId.toString(), + metadata + }; + }, + fromAmino: ({ + admin, + group_id, + metadata + }: MsgUpdateGroupMetadataAminoType["value"]): MsgUpdateGroupMetadata => { + return { + admin, + groupId: BigInt(group_id), + metadata + }; + } + }, + "/cosmos.group.v1.MsgCreateGroupPolicy": { + aminoType: "cosmos-sdk/MsgCreateGroupPolicy", + toAmino: ({ + admin, + groupId, + metadata, + decisionPolicy + }: MsgCreateGroupPolicy): MsgCreateGroupPolicyAminoType["value"] => { + return { + admin, + group_id: groupId.toString(), + metadata, + decision_policy: { + type_url: decisionPolicy.typeUrl, + value: decisionPolicy.value + } + }; + }, + fromAmino: ({ + admin, + group_id, + metadata, + decision_policy + }: MsgCreateGroupPolicyAminoType["value"]): MsgCreateGroupPolicy => { + return { + admin, + groupId: BigInt(group_id), + metadata, + decisionPolicy: { + typeUrl: decision_policy.type_url, + value: decision_policy.value + } + }; + } + }, + "/cosmos.group.v1.MsgCreateGroupWithPolicy": { + aminoType: "cosmos-sdk/MsgCreateGroupWithPolicy", + toAmino: ({ + admin, + members, + groupMetadata, + groupPolicyMetadata, + groupPolicyAsAdmin, + decisionPolicy + }: MsgCreateGroupWithPolicy): MsgCreateGroupWithPolicyAminoType["value"] => { + return { + admin, + members: members.map(el0 => ({ + address: el0.address, + weight: el0.weight, + metadata: el0.metadata, + added_at: el0.addedAt + })), + group_metadata: groupMetadata, + group_policy_metadata: groupPolicyMetadata, + group_policy_as_admin: groupPolicyAsAdmin, + decision_policy: { + type_url: decisionPolicy.typeUrl, + value: decisionPolicy.value + } + }; + }, + fromAmino: ({ + admin, + members, + group_metadata, + group_policy_metadata, + group_policy_as_admin, + decision_policy + }: MsgCreateGroupWithPolicyAminoType["value"]): MsgCreateGroupWithPolicy => { + return { + admin, + members: members.map(el0 => ({ + address: el0.address, + weight: el0.weight, + metadata: el0.metadata, + addedAt: el0.added_at + })), + groupMetadata: group_metadata, + groupPolicyMetadata: group_policy_metadata, + groupPolicyAsAdmin: group_policy_as_admin, + decisionPolicy: { + typeUrl: decision_policy.type_url, + value: decision_policy.value + } + }; + } + }, + "/cosmos.group.v1.MsgUpdateGroupPolicyAdmin": { + aminoType: "cosmos-sdk/MsgUpdateGroupPolicyAdmin", + toAmino: ({ + admin, + address, + newAdmin + }: MsgUpdateGroupPolicyAdmin): MsgUpdateGroupPolicyAdminAminoType["value"] => { + return { + admin, + address, + new_admin: newAdmin + }; + }, + fromAmino: ({ + admin, + address, + new_admin + }: MsgUpdateGroupPolicyAdminAminoType["value"]): MsgUpdateGroupPolicyAdmin => { + return { + admin, + address, + newAdmin: new_admin + }; + } + }, + "/cosmos.group.v1.MsgUpdateGroupPolicyDecisionPolicy": { + aminoType: "cosmos-sdk/MsgUpdateGroupPolicyDecisionPolicy", + toAmino: ({ + admin, + address, + decisionPolicy + }: MsgUpdateGroupPolicyDecisionPolicy): MsgUpdateGroupPolicyDecisionPolicyAminoType["value"] => { + return { + admin, + address, + decision_policy: { + type_url: decisionPolicy.typeUrl, + value: decisionPolicy.value + } + }; + }, + fromAmino: ({ + admin, + address, + decision_policy + }: MsgUpdateGroupPolicyDecisionPolicyAminoType["value"]): MsgUpdateGroupPolicyDecisionPolicy => { + return { + admin, + address, + decisionPolicy: { + typeUrl: decision_policy.type_url, + value: decision_policy.value + } + }; + } + }, + "/cosmos.group.v1.MsgUpdateGroupPolicyMetadata": { + aminoType: "cosmos-sdk/MsgUpdateGroupPolicyMetadata", + toAmino: ({ + admin, + address, + metadata + }: MsgUpdateGroupPolicyMetadata): MsgUpdateGroupPolicyMetadataAminoType["value"] => { + return { + admin, + address, + metadata + }; + }, + fromAmino: ({ + admin, + address, + metadata + }: MsgUpdateGroupPolicyMetadataAminoType["value"]): MsgUpdateGroupPolicyMetadata => { + return { + admin, + address, + metadata + }; + } + }, + "/cosmos.group.v1.MsgSubmitProposal": { + aminoType: "cosmos-sdk/group/MsgSubmitProposal", + toAmino: ({ + address, + proposers, + metadata, + messages, + exec + }: MsgSubmitProposal): MsgSubmitProposalAminoType["value"] => { + return { + address, + proposers, + metadata, + messages: messages.map(el0 => ({ + type_url: el0.typeUrl, + value: el0.value + })), + exec + }; + }, + fromAmino: ({ + address, + proposers, + metadata, + messages, + exec + }: MsgSubmitProposalAminoType["value"]): MsgSubmitProposal => { + return { + address, + proposers, + metadata, + messages: messages.map(el0 => ({ + typeUrl: el0.type_url, + value: el0.value + })), + exec: execFromJSON(exec) + }; + } + }, + "/cosmos.group.v1.MsgWithdrawProposal": { + aminoType: "cosmos-sdk/group/MsgWithdrawProposal", + toAmino: ({ + proposalId, + address + }: MsgWithdrawProposal): MsgWithdrawProposalAminoType["value"] => { + return { + proposal_id: proposalId.toString(), + address + }; + }, + fromAmino: ({ + proposal_id, + address + }: MsgWithdrawProposalAminoType["value"]): MsgWithdrawProposal => { + return { + proposalId: BigInt(proposal_id), + address + }; + } + }, + "/cosmos.group.v1.MsgVote": { + aminoType: "cosmos-sdk/group/MsgVote", + toAmino: ({ + proposalId, + voter, + option, + metadata, + exec + }: MsgVote): MsgVoteAminoType["value"] => { + return { + proposal_id: proposalId.toString(), + voter, + option, + metadata, + exec + }; + }, + fromAmino: ({ + proposal_id, + voter, + option, + metadata, + exec + }: MsgVoteAminoType["value"]): MsgVote => { + return { + proposalId: BigInt(proposal_id), + voter, + option: voteOptionFromJSON(option), + metadata, + exec: execFromJSON(exec) + }; + } + }, + "/cosmos.group.v1.MsgExec": { + aminoType: "cosmos-sdk/group/MsgExec", + toAmino: ({ + proposalId, + signer + }: MsgExec): MsgExecAminoType["value"] => { + return { + proposal_id: proposalId.toString(), + signer + }; + }, + fromAmino: ({ + proposal_id, + signer + }: MsgExecAminoType["value"]): MsgExec => { + return { + proposalId: BigInt(proposal_id), + signer + }; + } + }, + "/cosmos.group.v1.MsgLeaveGroup": { + aminoType: "cosmos-sdk/group/MsgLeaveGroup", + toAmino: ({ + address, + groupId + }: MsgLeaveGroup): MsgLeaveGroupAminoType["value"] => { + return { + address, + group_id: groupId.toString() + }; + }, + fromAmino: ({ + address, + group_id + }: MsgLeaveGroupAminoType["value"]): MsgLeaveGroup => { + return { + address, + groupId: BigInt(group_id) + }; + } + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/group/v1/tx.registry.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/group/v1/tx.registry.ts new file mode 100644 index 0000000000..b821652035 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/group/v1/tx.registry.ts @@ -0,0 +1,442 @@ +import { Member, MemberSDKType, VoteOption, VoteOptionSDKType } from "./types.js"; +import { Any, AnySDKType } from "../../../google/protobuf/any.js"; +import { GeneratedType, Registry } from "@cosmjs/proto-signing"; +import { MsgCreateGroup, MsgCreateGroupSDKType, MsgUpdateGroupMembers, MsgUpdateGroupMembersSDKType, MsgUpdateGroupAdmin, MsgUpdateGroupAdminSDKType, MsgUpdateGroupMetadata, MsgUpdateGroupMetadataSDKType, MsgCreateGroupPolicy, MsgCreateGroupPolicySDKType, MsgCreateGroupWithPolicy, MsgCreateGroupWithPolicySDKType, MsgUpdateGroupPolicyAdmin, MsgUpdateGroupPolicyAdminSDKType, MsgUpdateGroupPolicyDecisionPolicy, MsgUpdateGroupPolicyDecisionPolicySDKType, MsgUpdateGroupPolicyMetadata, MsgUpdateGroupPolicyMetadataSDKType, MsgSubmitProposal, MsgSubmitProposalSDKType, MsgWithdrawProposal, MsgWithdrawProposalSDKType, MsgVote, MsgVoteSDKType, MsgExec, MsgExecSDKType, MsgLeaveGroup, MsgLeaveGroupSDKType } from "./tx.js"; +export const registry: ReadonlyArray<[string, GeneratedType]> = [["/cosmos.group.v1.MsgCreateGroup", MsgCreateGroup], ["/cosmos.group.v1.MsgUpdateGroupMembers", MsgUpdateGroupMembers], ["/cosmos.group.v1.MsgUpdateGroupAdmin", MsgUpdateGroupAdmin], ["/cosmos.group.v1.MsgUpdateGroupMetadata", MsgUpdateGroupMetadata], ["/cosmos.group.v1.MsgCreateGroupPolicy", MsgCreateGroupPolicy], ["/cosmos.group.v1.MsgCreateGroupWithPolicy", MsgCreateGroupWithPolicy], ["/cosmos.group.v1.MsgUpdateGroupPolicyAdmin", MsgUpdateGroupPolicyAdmin], ["/cosmos.group.v1.MsgUpdateGroupPolicyDecisionPolicy", MsgUpdateGroupPolicyDecisionPolicy], ["/cosmos.group.v1.MsgUpdateGroupPolicyMetadata", MsgUpdateGroupPolicyMetadata], ["/cosmos.group.v1.MsgSubmitProposal", MsgSubmitProposal], ["/cosmos.group.v1.MsgWithdrawProposal", MsgWithdrawProposal], ["/cosmos.group.v1.MsgVote", MsgVote], ["/cosmos.group.v1.MsgExec", MsgExec], ["/cosmos.group.v1.MsgLeaveGroup", MsgLeaveGroup]]; +export const load = (protoRegistry: Registry) => { + registry.forEach(([typeUrl, mod]) => { + protoRegistry.register(typeUrl, mod); + }); +}; +export const MessageComposer = { + encoded: { + createGroup(value: MsgCreateGroup) { + return { + typeUrl: "/cosmos.group.v1.MsgCreateGroup", + value: MsgCreateGroup.encode(value).finish() + }; + }, + updateGroupMembers(value: MsgUpdateGroupMembers) { + return { + typeUrl: "/cosmos.group.v1.MsgUpdateGroupMembers", + value: MsgUpdateGroupMembers.encode(value).finish() + }; + }, + updateGroupAdmin(value: MsgUpdateGroupAdmin) { + return { + typeUrl: "/cosmos.group.v1.MsgUpdateGroupAdmin", + value: MsgUpdateGroupAdmin.encode(value).finish() + }; + }, + updateGroupMetadata(value: MsgUpdateGroupMetadata) { + return { + typeUrl: "/cosmos.group.v1.MsgUpdateGroupMetadata", + value: MsgUpdateGroupMetadata.encode(value).finish() + }; + }, + createGroupPolicy(value: MsgCreateGroupPolicy) { + return { + typeUrl: "/cosmos.group.v1.MsgCreateGroupPolicy", + value: MsgCreateGroupPolicy.encode(value).finish() + }; + }, + createGroupWithPolicy(value: MsgCreateGroupWithPolicy) { + return { + typeUrl: "/cosmos.group.v1.MsgCreateGroupWithPolicy", + value: MsgCreateGroupWithPolicy.encode(value).finish() + }; + }, + updateGroupPolicyAdmin(value: MsgUpdateGroupPolicyAdmin) { + return { + typeUrl: "/cosmos.group.v1.MsgUpdateGroupPolicyAdmin", + value: MsgUpdateGroupPolicyAdmin.encode(value).finish() + }; + }, + updateGroupPolicyDecisionPolicy(value: MsgUpdateGroupPolicyDecisionPolicy) { + return { + typeUrl: "/cosmos.group.v1.MsgUpdateGroupPolicyDecisionPolicy", + value: MsgUpdateGroupPolicyDecisionPolicy.encode(value).finish() + }; + }, + updateGroupPolicyMetadata(value: MsgUpdateGroupPolicyMetadata) { + return { + typeUrl: "/cosmos.group.v1.MsgUpdateGroupPolicyMetadata", + value: MsgUpdateGroupPolicyMetadata.encode(value).finish() + }; + }, + submitProposal(value: MsgSubmitProposal) { + return { + typeUrl: "/cosmos.group.v1.MsgSubmitProposal", + value: MsgSubmitProposal.encode(value).finish() + }; + }, + withdrawProposal(value: MsgWithdrawProposal) { + return { + typeUrl: "/cosmos.group.v1.MsgWithdrawProposal", + value: MsgWithdrawProposal.encode(value).finish() + }; + }, + vote(value: MsgVote) { + return { + typeUrl: "/cosmos.group.v1.MsgVote", + value: MsgVote.encode(value).finish() + }; + }, + exec(value: MsgExec) { + return { + typeUrl: "/cosmos.group.v1.MsgExec", + value: MsgExec.encode(value).finish() + }; + }, + leaveGroup(value: MsgLeaveGroup) { + return { + typeUrl: "/cosmos.group.v1.MsgLeaveGroup", + value: MsgLeaveGroup.encode(value).finish() + }; + } + }, + withTypeUrl: { + createGroup(value: MsgCreateGroup) { + return { + typeUrl: "/cosmos.group.v1.MsgCreateGroup", + value + }; + }, + updateGroupMembers(value: MsgUpdateGroupMembers) { + return { + typeUrl: "/cosmos.group.v1.MsgUpdateGroupMembers", + value + }; + }, + updateGroupAdmin(value: MsgUpdateGroupAdmin) { + return { + typeUrl: "/cosmos.group.v1.MsgUpdateGroupAdmin", + value + }; + }, + updateGroupMetadata(value: MsgUpdateGroupMetadata) { + return { + typeUrl: "/cosmos.group.v1.MsgUpdateGroupMetadata", + value + }; + }, + createGroupPolicy(value: MsgCreateGroupPolicy) { + return { + typeUrl: "/cosmos.group.v1.MsgCreateGroupPolicy", + value + }; + }, + createGroupWithPolicy(value: MsgCreateGroupWithPolicy) { + return { + typeUrl: "/cosmos.group.v1.MsgCreateGroupWithPolicy", + value + }; + }, + updateGroupPolicyAdmin(value: MsgUpdateGroupPolicyAdmin) { + return { + typeUrl: "/cosmos.group.v1.MsgUpdateGroupPolicyAdmin", + value + }; + }, + updateGroupPolicyDecisionPolicy(value: MsgUpdateGroupPolicyDecisionPolicy) { + return { + typeUrl: "/cosmos.group.v1.MsgUpdateGroupPolicyDecisionPolicy", + value + }; + }, + updateGroupPolicyMetadata(value: MsgUpdateGroupPolicyMetadata) { + return { + typeUrl: "/cosmos.group.v1.MsgUpdateGroupPolicyMetadata", + value + }; + }, + submitProposal(value: MsgSubmitProposal) { + return { + typeUrl: "/cosmos.group.v1.MsgSubmitProposal", + value + }; + }, + withdrawProposal(value: MsgWithdrawProposal) { + return { + typeUrl: "/cosmos.group.v1.MsgWithdrawProposal", + value + }; + }, + vote(value: MsgVote) { + return { + typeUrl: "/cosmos.group.v1.MsgVote", + value + }; + }, + exec(value: MsgExec) { + return { + typeUrl: "/cosmos.group.v1.MsgExec", + value + }; + }, + leaveGroup(value: MsgLeaveGroup) { + return { + typeUrl: "/cosmos.group.v1.MsgLeaveGroup", + value + }; + } + }, + toJSON: { + createGroup(value: MsgCreateGroup) { + return { + typeUrl: "/cosmos.group.v1.MsgCreateGroup", + value: MsgCreateGroup.toJSON(value) + }; + }, + updateGroupMembers(value: MsgUpdateGroupMembers) { + return { + typeUrl: "/cosmos.group.v1.MsgUpdateGroupMembers", + value: MsgUpdateGroupMembers.toJSON(value) + }; + }, + updateGroupAdmin(value: MsgUpdateGroupAdmin) { + return { + typeUrl: "/cosmos.group.v1.MsgUpdateGroupAdmin", + value: MsgUpdateGroupAdmin.toJSON(value) + }; + }, + updateGroupMetadata(value: MsgUpdateGroupMetadata) { + return { + typeUrl: "/cosmos.group.v1.MsgUpdateGroupMetadata", + value: MsgUpdateGroupMetadata.toJSON(value) + }; + }, + createGroupPolicy(value: MsgCreateGroupPolicy) { + return { + typeUrl: "/cosmos.group.v1.MsgCreateGroupPolicy", + value: MsgCreateGroupPolicy.toJSON(value) + }; + }, + createGroupWithPolicy(value: MsgCreateGroupWithPolicy) { + return { + typeUrl: "/cosmos.group.v1.MsgCreateGroupWithPolicy", + value: MsgCreateGroupWithPolicy.toJSON(value) + }; + }, + updateGroupPolicyAdmin(value: MsgUpdateGroupPolicyAdmin) { + return { + typeUrl: "/cosmos.group.v1.MsgUpdateGroupPolicyAdmin", + value: MsgUpdateGroupPolicyAdmin.toJSON(value) + }; + }, + updateGroupPolicyDecisionPolicy(value: MsgUpdateGroupPolicyDecisionPolicy) { + return { + typeUrl: "/cosmos.group.v1.MsgUpdateGroupPolicyDecisionPolicy", + value: MsgUpdateGroupPolicyDecisionPolicy.toJSON(value) + }; + }, + updateGroupPolicyMetadata(value: MsgUpdateGroupPolicyMetadata) { + return { + typeUrl: "/cosmos.group.v1.MsgUpdateGroupPolicyMetadata", + value: MsgUpdateGroupPolicyMetadata.toJSON(value) + }; + }, + submitProposal(value: MsgSubmitProposal) { + return { + typeUrl: "/cosmos.group.v1.MsgSubmitProposal", + value: MsgSubmitProposal.toJSON(value) + }; + }, + withdrawProposal(value: MsgWithdrawProposal) { + return { + typeUrl: "/cosmos.group.v1.MsgWithdrawProposal", + value: MsgWithdrawProposal.toJSON(value) + }; + }, + vote(value: MsgVote) { + return { + typeUrl: "/cosmos.group.v1.MsgVote", + value: MsgVote.toJSON(value) + }; + }, + exec(value: MsgExec) { + return { + typeUrl: "/cosmos.group.v1.MsgExec", + value: MsgExec.toJSON(value) + }; + }, + leaveGroup(value: MsgLeaveGroup) { + return { + typeUrl: "/cosmos.group.v1.MsgLeaveGroup", + value: MsgLeaveGroup.toJSON(value) + }; + } + }, + fromJSON: { + createGroup(value: any) { + return { + typeUrl: "/cosmos.group.v1.MsgCreateGroup", + value: MsgCreateGroup.fromJSON(value) + }; + }, + updateGroupMembers(value: any) { + return { + typeUrl: "/cosmos.group.v1.MsgUpdateGroupMembers", + value: MsgUpdateGroupMembers.fromJSON(value) + }; + }, + updateGroupAdmin(value: any) { + return { + typeUrl: "/cosmos.group.v1.MsgUpdateGroupAdmin", + value: MsgUpdateGroupAdmin.fromJSON(value) + }; + }, + updateGroupMetadata(value: any) { + return { + typeUrl: "/cosmos.group.v1.MsgUpdateGroupMetadata", + value: MsgUpdateGroupMetadata.fromJSON(value) + }; + }, + createGroupPolicy(value: any) { + return { + typeUrl: "/cosmos.group.v1.MsgCreateGroupPolicy", + value: MsgCreateGroupPolicy.fromJSON(value) + }; + }, + createGroupWithPolicy(value: any) { + return { + typeUrl: "/cosmos.group.v1.MsgCreateGroupWithPolicy", + value: MsgCreateGroupWithPolicy.fromJSON(value) + }; + }, + updateGroupPolicyAdmin(value: any) { + return { + typeUrl: "/cosmos.group.v1.MsgUpdateGroupPolicyAdmin", + value: MsgUpdateGroupPolicyAdmin.fromJSON(value) + }; + }, + updateGroupPolicyDecisionPolicy(value: any) { + return { + typeUrl: "/cosmos.group.v1.MsgUpdateGroupPolicyDecisionPolicy", + value: MsgUpdateGroupPolicyDecisionPolicy.fromJSON(value) + }; + }, + updateGroupPolicyMetadata(value: any) { + return { + typeUrl: "/cosmos.group.v1.MsgUpdateGroupPolicyMetadata", + value: MsgUpdateGroupPolicyMetadata.fromJSON(value) + }; + }, + submitProposal(value: any) { + return { + typeUrl: "/cosmos.group.v1.MsgSubmitProposal", + value: MsgSubmitProposal.fromJSON(value) + }; + }, + withdrawProposal(value: any) { + return { + typeUrl: "/cosmos.group.v1.MsgWithdrawProposal", + value: MsgWithdrawProposal.fromJSON(value) + }; + }, + vote(value: any) { + return { + typeUrl: "/cosmos.group.v1.MsgVote", + value: MsgVote.fromJSON(value) + }; + }, + exec(value: any) { + return { + typeUrl: "/cosmos.group.v1.MsgExec", + value: MsgExec.fromJSON(value) + }; + }, + leaveGroup(value: any) { + return { + typeUrl: "/cosmos.group.v1.MsgLeaveGroup", + value: MsgLeaveGroup.fromJSON(value) + }; + } + }, + fromPartial: { + createGroup(value: MsgCreateGroup) { + return { + typeUrl: "/cosmos.group.v1.MsgCreateGroup", + value: MsgCreateGroup.fromPartial(value) + }; + }, + updateGroupMembers(value: MsgUpdateGroupMembers) { + return { + typeUrl: "/cosmos.group.v1.MsgUpdateGroupMembers", + value: MsgUpdateGroupMembers.fromPartial(value) + }; + }, + updateGroupAdmin(value: MsgUpdateGroupAdmin) { + return { + typeUrl: "/cosmos.group.v1.MsgUpdateGroupAdmin", + value: MsgUpdateGroupAdmin.fromPartial(value) + }; + }, + updateGroupMetadata(value: MsgUpdateGroupMetadata) { + return { + typeUrl: "/cosmos.group.v1.MsgUpdateGroupMetadata", + value: MsgUpdateGroupMetadata.fromPartial(value) + }; + }, + createGroupPolicy(value: MsgCreateGroupPolicy) { + return { + typeUrl: "/cosmos.group.v1.MsgCreateGroupPolicy", + value: MsgCreateGroupPolicy.fromPartial(value) + }; + }, + createGroupWithPolicy(value: MsgCreateGroupWithPolicy) { + return { + typeUrl: "/cosmos.group.v1.MsgCreateGroupWithPolicy", + value: MsgCreateGroupWithPolicy.fromPartial(value) + }; + }, + updateGroupPolicyAdmin(value: MsgUpdateGroupPolicyAdmin) { + return { + typeUrl: "/cosmos.group.v1.MsgUpdateGroupPolicyAdmin", + value: MsgUpdateGroupPolicyAdmin.fromPartial(value) + }; + }, + updateGroupPolicyDecisionPolicy(value: MsgUpdateGroupPolicyDecisionPolicy) { + return { + typeUrl: "/cosmos.group.v1.MsgUpdateGroupPolicyDecisionPolicy", + value: MsgUpdateGroupPolicyDecisionPolicy.fromPartial(value) + }; + }, + updateGroupPolicyMetadata(value: MsgUpdateGroupPolicyMetadata) { + return { + typeUrl: "/cosmos.group.v1.MsgUpdateGroupPolicyMetadata", + value: MsgUpdateGroupPolicyMetadata.fromPartial(value) + }; + }, + submitProposal(value: MsgSubmitProposal) { + return { + typeUrl: "/cosmos.group.v1.MsgSubmitProposal", + value: MsgSubmitProposal.fromPartial(value) + }; + }, + withdrawProposal(value: MsgWithdrawProposal) { + return { + typeUrl: "/cosmos.group.v1.MsgWithdrawProposal", + value: MsgWithdrawProposal.fromPartial(value) + }; + }, + vote(value: MsgVote) { + return { + typeUrl: "/cosmos.group.v1.MsgVote", + value: MsgVote.fromPartial(value) + }; + }, + exec(value: MsgExec) { + return { + typeUrl: "/cosmos.group.v1.MsgExec", + value: MsgExec.fromPartial(value) + }; + }, + leaveGroup(value: MsgLeaveGroup) { + return { + typeUrl: "/cosmos.group.v1.MsgLeaveGroup", + value: MsgLeaveGroup.fromPartial(value) + }; + } + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/group/v1/tx.rpc.func.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/group/v1/tx.rpc.func.ts new file mode 100644 index 0000000000..82fab8b301 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/group/v1/tx.rpc.func.ts @@ -0,0 +1,130 @@ +import { buildTx, SigningClientResolver } from "../../../helper-func-types"; +import { buildUseMutation } from "../../../react-query"; +import { toEncoders, toConverters } from "@interchainjs/cosmos/utils"; +import { MsgCreateGroup, MsgUpdateGroupMembers, MsgUpdateGroupAdmin, MsgUpdateGroupMetadata, MsgCreateGroupPolicy, MsgCreateGroupWithPolicy, MsgUpdateGroupPolicyAdmin, MsgUpdateGroupPolicyDecisionPolicy, MsgUpdateGroupPolicyMetadata, MsgSubmitProposal, MsgWithdrawProposal, MsgVote, MsgExec, MsgLeaveGroup } from "./tx"; +export const createCreateGroup = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgCreateGroup.typeUrl, + encoders: toEncoders(MsgCreateGroup), + converters: toConverters(MsgCreateGroup) +}); +export const useCreateGroup = buildUseMutation({ + builderMutationFn: createCreateGroup +}); +export const createUpdateGroupMembers = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgUpdateGroupMembers.typeUrl, + encoders: toEncoders(MsgUpdateGroupMembers), + converters: toConverters(MsgUpdateGroupMembers) +}); +export const useUpdateGroupMembers = buildUseMutation({ + builderMutationFn: createUpdateGroupMembers +}); +export const createUpdateGroupAdmin = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgUpdateGroupAdmin.typeUrl, + encoders: toEncoders(MsgUpdateGroupAdmin), + converters: toConverters(MsgUpdateGroupAdmin) +}); +export const useUpdateGroupAdmin = buildUseMutation({ + builderMutationFn: createUpdateGroupAdmin +}); +export const createUpdateGroupMetadata = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgUpdateGroupMetadata.typeUrl, + encoders: toEncoders(MsgUpdateGroupMetadata), + converters: toConverters(MsgUpdateGroupMetadata) +}); +export const useUpdateGroupMetadata = buildUseMutation({ + builderMutationFn: createUpdateGroupMetadata +}); +export const createCreateGroupPolicy = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgCreateGroupPolicy.typeUrl, + encoders: toEncoders(MsgCreateGroupPolicy), + converters: toConverters(MsgCreateGroupPolicy) +}); +export const useCreateGroupPolicy = buildUseMutation({ + builderMutationFn: createCreateGroupPolicy +}); +export const createCreateGroupWithPolicy = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgCreateGroupWithPolicy.typeUrl, + encoders: toEncoders(MsgCreateGroupWithPolicy), + converters: toConverters(MsgCreateGroupWithPolicy) +}); +export const useCreateGroupWithPolicy = buildUseMutation({ + builderMutationFn: createCreateGroupWithPolicy +}); +export const createUpdateGroupPolicyAdmin = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgUpdateGroupPolicyAdmin.typeUrl, + encoders: toEncoders(MsgUpdateGroupPolicyAdmin), + converters: toConverters(MsgUpdateGroupPolicyAdmin) +}); +export const useUpdateGroupPolicyAdmin = buildUseMutation({ + builderMutationFn: createUpdateGroupPolicyAdmin +}); +export const createUpdateGroupPolicyDecisionPolicy = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgUpdateGroupPolicyDecisionPolicy.typeUrl, + encoders: toEncoders(MsgUpdateGroupPolicyDecisionPolicy), + converters: toConverters(MsgUpdateGroupPolicyDecisionPolicy) +}); +export const useUpdateGroupPolicyDecisionPolicy = buildUseMutation({ + builderMutationFn: createUpdateGroupPolicyDecisionPolicy +}); +export const createUpdateGroupPolicyMetadata = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgUpdateGroupPolicyMetadata.typeUrl, + encoders: toEncoders(MsgUpdateGroupPolicyMetadata), + converters: toConverters(MsgUpdateGroupPolicyMetadata) +}); +export const useUpdateGroupPolicyMetadata = buildUseMutation({ + builderMutationFn: createUpdateGroupPolicyMetadata +}); +export const createSubmitProposal = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgSubmitProposal.typeUrl, + encoders: toEncoders(MsgSubmitProposal), + converters: toConverters(MsgSubmitProposal) +}); +export const useSubmitProposal = buildUseMutation({ + builderMutationFn: createSubmitProposal +}); +export const createWithdrawProposal = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgWithdrawProposal.typeUrl, + encoders: toEncoders(MsgWithdrawProposal), + converters: toConverters(MsgWithdrawProposal) +}); +export const useWithdrawProposal = buildUseMutation({ + builderMutationFn: createWithdrawProposal +}); +export const createVote = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgVote.typeUrl, + encoders: toEncoders(MsgVote), + converters: toConverters(MsgVote) +}); +export const useVote = buildUseMutation({ + builderMutationFn: createVote +}); +export const createExec = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgExec.typeUrl, + encoders: toEncoders(MsgExec), + converters: toConverters(MsgExec) +}); +export const useExec = buildUseMutation({ + builderMutationFn: createExec +}); +export const createLeaveGroup = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgLeaveGroup.typeUrl, + encoders: toEncoders(MsgLeaveGroup), + converters: toConverters(MsgLeaveGroup) +}); +export const useLeaveGroup = buildUseMutation({ + builderMutationFn: createLeaveGroup +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/group/v1/tx.rpc.msg.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/group/v1/tx.rpc.msg.ts new file mode 100644 index 0000000000..fb494e3543 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/group/v1/tx.rpc.msg.ts @@ -0,0 +1,129 @@ +import { Member, MemberSDKType, VoteOption, VoteOptionSDKType } from "./types.js"; +import { Any, AnySDKType } from "../../../google/protobuf/any.js"; +import { Rpc } from "../../../helpers.js"; +import { BinaryReader } from "../../../binary.js"; +import { MsgCreateGroup, MsgCreateGroupSDKType, MsgCreateGroupResponse, MsgCreateGroupResponseSDKType, MsgUpdateGroupMembers, MsgUpdateGroupMembersSDKType, MsgUpdateGroupMembersResponse, MsgUpdateGroupMembersResponseSDKType, MsgUpdateGroupAdmin, MsgUpdateGroupAdminSDKType, MsgUpdateGroupAdminResponse, MsgUpdateGroupAdminResponseSDKType, MsgUpdateGroupMetadata, MsgUpdateGroupMetadataSDKType, MsgUpdateGroupMetadataResponse, MsgUpdateGroupMetadataResponseSDKType, MsgCreateGroupPolicy, MsgCreateGroupPolicySDKType, MsgCreateGroupPolicyResponse, MsgCreateGroupPolicyResponseSDKType, MsgCreateGroupWithPolicy, MsgCreateGroupWithPolicySDKType, MsgCreateGroupWithPolicyResponse, MsgCreateGroupWithPolicyResponseSDKType, MsgUpdateGroupPolicyAdmin, MsgUpdateGroupPolicyAdminSDKType, MsgUpdateGroupPolicyAdminResponse, MsgUpdateGroupPolicyAdminResponseSDKType, MsgUpdateGroupPolicyDecisionPolicy, MsgUpdateGroupPolicyDecisionPolicySDKType, MsgUpdateGroupPolicyDecisionPolicyResponse, MsgUpdateGroupPolicyDecisionPolicyResponseSDKType, MsgUpdateGroupPolicyMetadata, MsgUpdateGroupPolicyMetadataSDKType, MsgUpdateGroupPolicyMetadataResponse, MsgUpdateGroupPolicyMetadataResponseSDKType, MsgSubmitProposal, MsgSubmitProposalSDKType, MsgSubmitProposalResponse, MsgSubmitProposalResponseSDKType, MsgWithdrawProposal, MsgWithdrawProposalSDKType, MsgWithdrawProposalResponse, MsgWithdrawProposalResponseSDKType, MsgVote, MsgVoteSDKType, MsgVoteResponse, MsgVoteResponseSDKType, MsgExec, MsgExecSDKType, MsgExecResponse, MsgExecResponseSDKType, MsgLeaveGroup, MsgLeaveGroupSDKType, MsgLeaveGroupResponse, MsgLeaveGroupResponseSDKType } from "./tx.js"; +/** Msg is the cosmos.group.v1 Msg service. */ +export interface Msg { + /** CreateGroup creates a new group with an admin account address, a list of members and some optional metadata. */ + createGroup(request: MsgCreateGroup): Promise; + /** UpdateGroupMembers updates the group members with given group id and admin address. */ + updateGroupMembers(request: MsgUpdateGroupMembers): Promise; + /** UpdateGroupAdmin updates the group admin with given group id and previous admin address. */ + updateGroupAdmin(request: MsgUpdateGroupAdmin): Promise; + /** UpdateGroupMetadata updates the group metadata with given group id and admin address. */ + updateGroupMetadata(request: MsgUpdateGroupMetadata): Promise; + /** CreateGroupPolicy creates a new group policy using given DecisionPolicy. */ + createGroupPolicy(request: MsgCreateGroupPolicy): Promise; + /** CreateGroupWithPolicy creates a new group with policy. */ + createGroupWithPolicy(request: MsgCreateGroupWithPolicy): Promise; + /** UpdateGroupPolicyAdmin updates a group policy admin. */ + updateGroupPolicyAdmin(request: MsgUpdateGroupPolicyAdmin): Promise; + /** UpdateGroupPolicyDecisionPolicy allows a group policy's decision policy to be updated. */ + updateGroupPolicyDecisionPolicy(request: MsgUpdateGroupPolicyDecisionPolicy): Promise; + /** UpdateGroupPolicyMetadata updates a group policy metadata. */ + updateGroupPolicyMetadata(request: MsgUpdateGroupPolicyMetadata): Promise; + /** SubmitProposal submits a new proposal. */ + submitProposal(request: MsgSubmitProposal): Promise; + /** WithdrawProposal aborts a proposal. */ + withdrawProposal(request: MsgWithdrawProposal): Promise; + /** Vote allows a voter to vote on a proposal. */ + vote(request: MsgVote): Promise; + /** Exec executes a proposal. */ + exec(request: MsgExec): Promise; + /** LeaveGroup allows a group member to leave the group. */ + leaveGroup(request: MsgLeaveGroup): Promise; +} +export class MsgClientImpl implements Msg { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + this.createGroup = this.createGroup.bind(this); + this.updateGroupMembers = this.updateGroupMembers.bind(this); + this.updateGroupAdmin = this.updateGroupAdmin.bind(this); + this.updateGroupMetadata = this.updateGroupMetadata.bind(this); + this.createGroupPolicy = this.createGroupPolicy.bind(this); + this.createGroupWithPolicy = this.createGroupWithPolicy.bind(this); + this.updateGroupPolicyAdmin = this.updateGroupPolicyAdmin.bind(this); + this.updateGroupPolicyDecisionPolicy = this.updateGroupPolicyDecisionPolicy.bind(this); + this.updateGroupPolicyMetadata = this.updateGroupPolicyMetadata.bind(this); + this.submitProposal = this.submitProposal.bind(this); + this.withdrawProposal = this.withdrawProposal.bind(this); + this.vote = this.vote.bind(this); + this.exec = this.exec.bind(this); + this.leaveGroup = this.leaveGroup.bind(this); + } + createGroup(request: MsgCreateGroup): Promise { + const data = MsgCreateGroup.encode(request).finish(); + const promise = this.rpc.request("cosmos.group.v1.Msg", "CreateGroup", data); + return promise.then(data => MsgCreateGroupResponse.decode(new BinaryReader(data))); + } + updateGroupMembers(request: MsgUpdateGroupMembers): Promise { + const data = MsgUpdateGroupMembers.encode(request).finish(); + const promise = this.rpc.request("cosmos.group.v1.Msg", "UpdateGroupMembers", data); + return promise.then(data => MsgUpdateGroupMembersResponse.decode(new BinaryReader(data))); + } + updateGroupAdmin(request: MsgUpdateGroupAdmin): Promise { + const data = MsgUpdateGroupAdmin.encode(request).finish(); + const promise = this.rpc.request("cosmos.group.v1.Msg", "UpdateGroupAdmin", data); + return promise.then(data => MsgUpdateGroupAdminResponse.decode(new BinaryReader(data))); + } + updateGroupMetadata(request: MsgUpdateGroupMetadata): Promise { + const data = MsgUpdateGroupMetadata.encode(request).finish(); + const promise = this.rpc.request("cosmos.group.v1.Msg", "UpdateGroupMetadata", data); + return promise.then(data => MsgUpdateGroupMetadataResponse.decode(new BinaryReader(data))); + } + createGroupPolicy(request: MsgCreateGroupPolicy): Promise { + const data = MsgCreateGroupPolicy.encode(request).finish(); + const promise = this.rpc.request("cosmos.group.v1.Msg", "CreateGroupPolicy", data); + return promise.then(data => MsgCreateGroupPolicyResponse.decode(new BinaryReader(data))); + } + createGroupWithPolicy(request: MsgCreateGroupWithPolicy): Promise { + const data = MsgCreateGroupWithPolicy.encode(request).finish(); + const promise = this.rpc.request("cosmos.group.v1.Msg", "CreateGroupWithPolicy", data); + return promise.then(data => MsgCreateGroupWithPolicyResponse.decode(new BinaryReader(data))); + } + updateGroupPolicyAdmin(request: MsgUpdateGroupPolicyAdmin): Promise { + const data = MsgUpdateGroupPolicyAdmin.encode(request).finish(); + const promise = this.rpc.request("cosmos.group.v1.Msg", "UpdateGroupPolicyAdmin", data); + return promise.then(data => MsgUpdateGroupPolicyAdminResponse.decode(new BinaryReader(data))); + } + updateGroupPolicyDecisionPolicy(request: MsgUpdateGroupPolicyDecisionPolicy): Promise { + const data = MsgUpdateGroupPolicyDecisionPolicy.encode(request).finish(); + const promise = this.rpc.request("cosmos.group.v1.Msg", "UpdateGroupPolicyDecisionPolicy", data); + return promise.then(data => MsgUpdateGroupPolicyDecisionPolicyResponse.decode(new BinaryReader(data))); + } + updateGroupPolicyMetadata(request: MsgUpdateGroupPolicyMetadata): Promise { + const data = MsgUpdateGroupPolicyMetadata.encode(request).finish(); + const promise = this.rpc.request("cosmos.group.v1.Msg", "UpdateGroupPolicyMetadata", data); + return promise.then(data => MsgUpdateGroupPolicyMetadataResponse.decode(new BinaryReader(data))); + } + submitProposal(request: MsgSubmitProposal): Promise { + const data = MsgSubmitProposal.encode(request).finish(); + const promise = this.rpc.request("cosmos.group.v1.Msg", "SubmitProposal", data); + return promise.then(data => MsgSubmitProposalResponse.decode(new BinaryReader(data))); + } + withdrawProposal(request: MsgWithdrawProposal): Promise { + const data = MsgWithdrawProposal.encode(request).finish(); + const promise = this.rpc.request("cosmos.group.v1.Msg", "WithdrawProposal", data); + return promise.then(data => MsgWithdrawProposalResponse.decode(new BinaryReader(data))); + } + vote(request: MsgVote): Promise { + const data = MsgVote.encode(request).finish(); + const promise = this.rpc.request("cosmos.group.v1.Msg", "Vote", data); + return promise.then(data => MsgVoteResponse.decode(new BinaryReader(data))); + } + exec(request: MsgExec): Promise { + const data = MsgExec.encode(request).finish(); + const promise = this.rpc.request("cosmos.group.v1.Msg", "Exec", data); + return promise.then(data => MsgExecResponse.decode(new BinaryReader(data))); + } + leaveGroup(request: MsgLeaveGroup): Promise { + const data = MsgLeaveGroup.encode(request).finish(); + const promise = this.rpc.request("cosmos.group.v1.Msg", "LeaveGroup", data); + return promise.then(data => MsgLeaveGroupResponse.decode(new BinaryReader(data))); + } +} +export const createClientImpl = (rpc: Rpc) => { + return new MsgClientImpl(rpc); +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/group/v1/tx.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/group/v1/tx.ts new file mode 100644 index 0000000000..781a3a119b --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/group/v1/tx.ts @@ -0,0 +1,3565 @@ +import { Member, MemberSDKType, VoteOption, VoteOptionSDKType, voteOptionFromJSON, voteOptionToJSON } from "./types.js"; +import { Any, AnySDKType } from "../../../google/protobuf/any.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "cosmos.group.v1"; +/** Exec defines modes of execution of a proposal on creation or on new vote. */ +export enum Exec { + /** + * EXEC_UNSPECIFIED - An empty value means that there should be a separate + * MsgExec request for the proposal to execute. + */ + EXEC_UNSPECIFIED = 0, + /** + * EXEC_TRY - Try to execute the proposal immediately. + * If the proposal is not allowed per the DecisionPolicy, + * the proposal will still be open and could + * be executed at a later point. + */ + EXEC_TRY = 1, + UNRECOGNIZED = -1, +} +export const ExecSDKType = Exec; +export function execFromJSON(object: any): Exec { + switch (object) { + case 0: + case "EXEC_UNSPECIFIED": + return Exec.EXEC_UNSPECIFIED; + case 1: + case "EXEC_TRY": + return Exec.EXEC_TRY; + case -1: + case "UNRECOGNIZED": + default: + return Exec.UNRECOGNIZED; + } +} +export function execToJSON(object: Exec): string { + switch (object) { + case Exec.EXEC_UNSPECIFIED: + return "EXEC_UNSPECIFIED"; + case Exec.EXEC_TRY: + return "EXEC_TRY"; + case Exec.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** MsgCreateGroup is the Msg/CreateGroup request type. */ +export interface MsgCreateGroup { + /** admin is the account address of the group admin. */ + admin: string; + /** members defines the group members. */ + members: Member[]; + /** metadata is any arbitrary metadata to attached to the group. */ + metadata: string; +} +export interface MsgCreateGroupProtoMsg { + typeUrl: "/cosmos.group.v1.MsgCreateGroup"; + value: Uint8Array; +} +/** MsgCreateGroup is the Msg/CreateGroup request type. */ +export interface MsgCreateGroupSDKType { + admin: string; + members: MemberSDKType[]; + metadata: string; +} +/** MsgCreateGroupResponse is the Msg/CreateGroup response type. */ +export interface MsgCreateGroupResponse { + /** group_id is the unique ID of the newly created group. */ + groupId: bigint; +} +export interface MsgCreateGroupResponseProtoMsg { + typeUrl: "/cosmos.group.v1.MsgCreateGroupResponse"; + value: Uint8Array; +} +/** MsgCreateGroupResponse is the Msg/CreateGroup response type. */ +export interface MsgCreateGroupResponseSDKType { + group_id: bigint; +} +/** MsgUpdateGroupMembers is the Msg/UpdateGroupMembers request type. */ +export interface MsgUpdateGroupMembers { + /** admin is the account address of the group admin. */ + admin: string; + /** group_id is the unique ID of the group. */ + groupId: bigint; + /** + * member_updates is the list of members to update, + * set weight to 0 to remove a member. + */ + memberUpdates: Member[]; +} +export interface MsgUpdateGroupMembersProtoMsg { + typeUrl: "/cosmos.group.v1.MsgUpdateGroupMembers"; + value: Uint8Array; +} +/** MsgUpdateGroupMembers is the Msg/UpdateGroupMembers request type. */ +export interface MsgUpdateGroupMembersSDKType { + admin: string; + group_id: bigint; + member_updates: MemberSDKType[]; +} +/** MsgUpdateGroupMembersResponse is the Msg/UpdateGroupMembers response type. */ +export interface MsgUpdateGroupMembersResponse {} +export interface MsgUpdateGroupMembersResponseProtoMsg { + typeUrl: "/cosmos.group.v1.MsgUpdateGroupMembersResponse"; + value: Uint8Array; +} +/** MsgUpdateGroupMembersResponse is the Msg/UpdateGroupMembers response type. */ +export interface MsgUpdateGroupMembersResponseSDKType {} +/** MsgUpdateGroupAdmin is the Msg/UpdateGroupAdmin request type. */ +export interface MsgUpdateGroupAdmin { + /** admin is the current account address of the group admin. */ + admin: string; + /** group_id is the unique ID of the group. */ + groupId: bigint; + /** new_admin is the group new admin account address. */ + newAdmin: string; +} +export interface MsgUpdateGroupAdminProtoMsg { + typeUrl: "/cosmos.group.v1.MsgUpdateGroupAdmin"; + value: Uint8Array; +} +/** MsgUpdateGroupAdmin is the Msg/UpdateGroupAdmin request type. */ +export interface MsgUpdateGroupAdminSDKType { + admin: string; + group_id: bigint; + new_admin: string; +} +/** MsgUpdateGroupAdminResponse is the Msg/UpdateGroupAdmin response type. */ +export interface MsgUpdateGroupAdminResponse {} +export interface MsgUpdateGroupAdminResponseProtoMsg { + typeUrl: "/cosmos.group.v1.MsgUpdateGroupAdminResponse"; + value: Uint8Array; +} +/** MsgUpdateGroupAdminResponse is the Msg/UpdateGroupAdmin response type. */ +export interface MsgUpdateGroupAdminResponseSDKType {} +/** MsgUpdateGroupMetadata is the Msg/UpdateGroupMetadata request type. */ +export interface MsgUpdateGroupMetadata { + /** admin is the account address of the group admin. */ + admin: string; + /** group_id is the unique ID of the group. */ + groupId: bigint; + /** metadata is the updated group's metadata. */ + metadata: string; +} +export interface MsgUpdateGroupMetadataProtoMsg { + typeUrl: "/cosmos.group.v1.MsgUpdateGroupMetadata"; + value: Uint8Array; +} +/** MsgUpdateGroupMetadata is the Msg/UpdateGroupMetadata request type. */ +export interface MsgUpdateGroupMetadataSDKType { + admin: string; + group_id: bigint; + metadata: string; +} +/** MsgUpdateGroupMetadataResponse is the Msg/UpdateGroupMetadata response type. */ +export interface MsgUpdateGroupMetadataResponse {} +export interface MsgUpdateGroupMetadataResponseProtoMsg { + typeUrl: "/cosmos.group.v1.MsgUpdateGroupMetadataResponse"; + value: Uint8Array; +} +/** MsgUpdateGroupMetadataResponse is the Msg/UpdateGroupMetadata response type. */ +export interface MsgUpdateGroupMetadataResponseSDKType {} +/** MsgCreateGroupPolicy is the Msg/CreateGroupPolicy request type. */ +export interface MsgCreateGroupPolicy { + /** admin is the account address of the group admin. */ + admin: string; + /** group_id is the unique ID of the group. */ + groupId: bigint; + /** metadata is any arbitrary metadata attached to the group policy. */ + metadata: string; + /** decision_policy specifies the group policy's decision policy. */ + decisionPolicy?: Any; +} +export interface MsgCreateGroupPolicyProtoMsg { + typeUrl: "/cosmos.group.v1.MsgCreateGroupPolicy"; + value: Uint8Array; +} +/** MsgCreateGroupPolicy is the Msg/CreateGroupPolicy request type. */ +export interface MsgCreateGroupPolicySDKType { + admin: string; + group_id: bigint; + metadata: string; + decision_policy?: AnySDKType; +} +/** MsgCreateGroupPolicyResponse is the Msg/CreateGroupPolicy response type. */ +export interface MsgCreateGroupPolicyResponse { + /** address is the account address of the newly created group policy. */ + address: string; +} +export interface MsgCreateGroupPolicyResponseProtoMsg { + typeUrl: "/cosmos.group.v1.MsgCreateGroupPolicyResponse"; + value: Uint8Array; +} +/** MsgCreateGroupPolicyResponse is the Msg/CreateGroupPolicy response type. */ +export interface MsgCreateGroupPolicyResponseSDKType { + address: string; +} +/** MsgUpdateGroupPolicyAdmin is the Msg/UpdateGroupPolicyAdmin request type. */ +export interface MsgUpdateGroupPolicyAdmin { + /** admin is the account address of the group admin. */ + admin: string; + /** address is the account address of the group policy. */ + address: string; + /** new_admin is the new group policy admin. */ + newAdmin: string; +} +export interface MsgUpdateGroupPolicyAdminProtoMsg { + typeUrl: "/cosmos.group.v1.MsgUpdateGroupPolicyAdmin"; + value: Uint8Array; +} +/** MsgUpdateGroupPolicyAdmin is the Msg/UpdateGroupPolicyAdmin request type. */ +export interface MsgUpdateGroupPolicyAdminSDKType { + admin: string; + address: string; + new_admin: string; +} +/** MsgCreateGroupWithPolicy is the Msg/CreateGroupWithPolicy request type. */ +export interface MsgCreateGroupWithPolicy { + /** admin is the account address of the group and group policy admin. */ + admin: string; + /** members defines the group members. */ + members: Member[]; + /** group_metadata is any arbitrary metadata attached to the group. */ + groupMetadata: string; + /** group_policy_metadata is any arbitrary metadata attached to the group policy. */ + groupPolicyMetadata: string; + /** group_policy_as_admin is a boolean field, if set to true, the group policy account address will be used as group and group policy admin. */ + groupPolicyAsAdmin: boolean; + /** decision_policy specifies the group policy's decision policy. */ + decisionPolicy?: Any; +} +export interface MsgCreateGroupWithPolicyProtoMsg { + typeUrl: "/cosmos.group.v1.MsgCreateGroupWithPolicy"; + value: Uint8Array; +} +/** MsgCreateGroupWithPolicy is the Msg/CreateGroupWithPolicy request type. */ +export interface MsgCreateGroupWithPolicySDKType { + admin: string; + members: MemberSDKType[]; + group_metadata: string; + group_policy_metadata: string; + group_policy_as_admin: boolean; + decision_policy?: AnySDKType; +} +/** MsgCreateGroupWithPolicyResponse is the Msg/CreateGroupWithPolicy response type. */ +export interface MsgCreateGroupWithPolicyResponse { + /** group_id is the unique ID of the newly created group with policy. */ + groupId: bigint; + /** group_policy_address is the account address of the newly created group policy. */ + groupPolicyAddress: string; +} +export interface MsgCreateGroupWithPolicyResponseProtoMsg { + typeUrl: "/cosmos.group.v1.MsgCreateGroupWithPolicyResponse"; + value: Uint8Array; +} +/** MsgCreateGroupWithPolicyResponse is the Msg/CreateGroupWithPolicy response type. */ +export interface MsgCreateGroupWithPolicyResponseSDKType { + group_id: bigint; + group_policy_address: string; +} +/** MsgUpdateGroupPolicyAdminResponse is the Msg/UpdateGroupPolicyAdmin response type. */ +export interface MsgUpdateGroupPolicyAdminResponse {} +export interface MsgUpdateGroupPolicyAdminResponseProtoMsg { + typeUrl: "/cosmos.group.v1.MsgUpdateGroupPolicyAdminResponse"; + value: Uint8Array; +} +/** MsgUpdateGroupPolicyAdminResponse is the Msg/UpdateGroupPolicyAdmin response type. */ +export interface MsgUpdateGroupPolicyAdminResponseSDKType {} +/** MsgUpdateGroupPolicyDecisionPolicy is the Msg/UpdateGroupPolicyDecisionPolicy request type. */ +export interface MsgUpdateGroupPolicyDecisionPolicy { + /** admin is the account address of the group admin. */ + admin: string; + /** address is the account address of group policy. */ + address: string; + /** decision_policy is the updated group policy's decision policy. */ + decisionPolicy?: Any; +} +export interface MsgUpdateGroupPolicyDecisionPolicyProtoMsg { + typeUrl: "/cosmos.group.v1.MsgUpdateGroupPolicyDecisionPolicy"; + value: Uint8Array; +} +/** MsgUpdateGroupPolicyDecisionPolicy is the Msg/UpdateGroupPolicyDecisionPolicy request type. */ +export interface MsgUpdateGroupPolicyDecisionPolicySDKType { + admin: string; + address: string; + decision_policy?: AnySDKType; +} +/** MsgUpdateGroupPolicyDecisionPolicyResponse is the Msg/UpdateGroupPolicyDecisionPolicy response type. */ +export interface MsgUpdateGroupPolicyDecisionPolicyResponse {} +export interface MsgUpdateGroupPolicyDecisionPolicyResponseProtoMsg { + typeUrl: "/cosmos.group.v1.MsgUpdateGroupPolicyDecisionPolicyResponse"; + value: Uint8Array; +} +/** MsgUpdateGroupPolicyDecisionPolicyResponse is the Msg/UpdateGroupPolicyDecisionPolicy response type. */ +export interface MsgUpdateGroupPolicyDecisionPolicyResponseSDKType {} +/** MsgUpdateGroupPolicyMetadata is the Msg/UpdateGroupPolicyMetadata request type. */ +export interface MsgUpdateGroupPolicyMetadata { + /** admin is the account address of the group admin. */ + admin: string; + /** address is the account address of group policy. */ + address: string; + /** metadata is the updated group policy metadata. */ + metadata: string; +} +export interface MsgUpdateGroupPolicyMetadataProtoMsg { + typeUrl: "/cosmos.group.v1.MsgUpdateGroupPolicyMetadata"; + value: Uint8Array; +} +/** MsgUpdateGroupPolicyMetadata is the Msg/UpdateGroupPolicyMetadata request type. */ +export interface MsgUpdateGroupPolicyMetadataSDKType { + admin: string; + address: string; + metadata: string; +} +/** MsgUpdateGroupPolicyMetadataResponse is the Msg/UpdateGroupPolicyMetadata response type. */ +export interface MsgUpdateGroupPolicyMetadataResponse {} +export interface MsgUpdateGroupPolicyMetadataResponseProtoMsg { + typeUrl: "/cosmos.group.v1.MsgUpdateGroupPolicyMetadataResponse"; + value: Uint8Array; +} +/** MsgUpdateGroupPolicyMetadataResponse is the Msg/UpdateGroupPolicyMetadata response type. */ +export interface MsgUpdateGroupPolicyMetadataResponseSDKType {} +/** MsgSubmitProposal is the Msg/SubmitProposal request type. */ +export interface MsgSubmitProposal { + /** address is the account address of group policy. */ + address: string; + /** + * proposers are the account addresses of the proposers. + * Proposers signatures will be counted as yes votes. + */ + proposers: string[]; + /** metadata is any arbitrary metadata to attached to the proposal. */ + metadata: string; + /** messages is a list of `sdk.Msg`s that will be executed if the proposal passes. */ + messages: Any[]; + /** + * exec defines the mode of execution of the proposal, + * whether it should be executed immediately on creation or not. + * If so, proposers signatures are considered as Yes votes. + */ + exec: Exec; +} +export interface MsgSubmitProposalProtoMsg { + typeUrl: "/cosmos.group.v1.MsgSubmitProposal"; + value: Uint8Array; +} +/** MsgSubmitProposal is the Msg/SubmitProposal request type. */ +export interface MsgSubmitProposalSDKType { + address: string; + proposers: string[]; + metadata: string; + messages: AnySDKType[]; + exec: Exec; +} +/** MsgSubmitProposalResponse is the Msg/SubmitProposal response type. */ +export interface MsgSubmitProposalResponse { + /** proposal is the unique ID of the proposal. */ + proposalId: bigint; +} +export interface MsgSubmitProposalResponseProtoMsg { + typeUrl: "/cosmos.group.v1.MsgSubmitProposalResponse"; + value: Uint8Array; +} +/** MsgSubmitProposalResponse is the Msg/SubmitProposal response type. */ +export interface MsgSubmitProposalResponseSDKType { + proposal_id: bigint; +} +/** MsgWithdrawProposal is the Msg/WithdrawProposal request type. */ +export interface MsgWithdrawProposal { + /** proposal is the unique ID of the proposal. */ + proposalId: bigint; + /** address is the admin of the group policy or one of the proposer of the proposal. */ + address: string; +} +export interface MsgWithdrawProposalProtoMsg { + typeUrl: "/cosmos.group.v1.MsgWithdrawProposal"; + value: Uint8Array; +} +/** MsgWithdrawProposal is the Msg/WithdrawProposal request type. */ +export interface MsgWithdrawProposalSDKType { + proposal_id: bigint; + address: string; +} +/** MsgWithdrawProposalResponse is the Msg/WithdrawProposal response type. */ +export interface MsgWithdrawProposalResponse {} +export interface MsgWithdrawProposalResponseProtoMsg { + typeUrl: "/cosmos.group.v1.MsgWithdrawProposalResponse"; + value: Uint8Array; +} +/** MsgWithdrawProposalResponse is the Msg/WithdrawProposal response type. */ +export interface MsgWithdrawProposalResponseSDKType {} +/** MsgVote is the Msg/Vote request type. */ +export interface MsgVote { + /** proposal is the unique ID of the proposal. */ + proposalId: bigint; + /** voter is the voter account address. */ + voter: string; + /** option is the voter's choice on the proposal. */ + option: VoteOption; + /** metadata is any arbitrary metadata to attached to the vote. */ + metadata: string; + /** + * exec defines whether the proposal should be executed + * immediately after voting or not. + */ + exec: Exec; +} +export interface MsgVoteProtoMsg { + typeUrl: "/cosmos.group.v1.MsgVote"; + value: Uint8Array; +} +/** MsgVote is the Msg/Vote request type. */ +export interface MsgVoteSDKType { + proposal_id: bigint; + voter: string; + option: VoteOption; + metadata: string; + exec: Exec; +} +/** MsgVoteResponse is the Msg/Vote response type. */ +export interface MsgVoteResponse {} +export interface MsgVoteResponseProtoMsg { + typeUrl: "/cosmos.group.v1.MsgVoteResponse"; + value: Uint8Array; +} +/** MsgVoteResponse is the Msg/Vote response type. */ +export interface MsgVoteResponseSDKType {} +/** MsgExec is the Msg/Exec request type. */ +export interface MsgExec { + /** proposal is the unique ID of the proposal. */ + proposalId: bigint; + /** signer is the account address used to execute the proposal. */ + signer: string; +} +export interface MsgExecProtoMsg { + typeUrl: "/cosmos.group.v1.MsgExec"; + value: Uint8Array; +} +/** MsgExec is the Msg/Exec request type. */ +export interface MsgExecSDKType { + proposal_id: bigint; + signer: string; +} +/** MsgExecResponse is the Msg/Exec request type. */ +export interface MsgExecResponse {} +export interface MsgExecResponseProtoMsg { + typeUrl: "/cosmos.group.v1.MsgExecResponse"; + value: Uint8Array; +} +/** MsgExecResponse is the Msg/Exec request type. */ +export interface MsgExecResponseSDKType {} +/** MsgLeaveGroup is the Msg/LeaveGroup request type. */ +export interface MsgLeaveGroup { + /** address is the account address of the group member. */ + address: string; + /** group_id is the unique ID of the group. */ + groupId: bigint; +} +export interface MsgLeaveGroupProtoMsg { + typeUrl: "/cosmos.group.v1.MsgLeaveGroup"; + value: Uint8Array; +} +/** MsgLeaveGroup is the Msg/LeaveGroup request type. */ +export interface MsgLeaveGroupSDKType { + address: string; + group_id: bigint; +} +/** MsgLeaveGroupResponse is the Msg/LeaveGroup response type. */ +export interface MsgLeaveGroupResponse {} +export interface MsgLeaveGroupResponseProtoMsg { + typeUrl: "/cosmos.group.v1.MsgLeaveGroupResponse"; + value: Uint8Array; +} +/** MsgLeaveGroupResponse is the Msg/LeaveGroup response type. */ +export interface MsgLeaveGroupResponseSDKType {} +function createBaseMsgCreateGroup(): MsgCreateGroup { + return { + admin: "", + members: [], + metadata: "" + }; +} +export const MsgCreateGroup = { + typeUrl: "/cosmos.group.v1.MsgCreateGroup", + encode(message: MsgCreateGroup, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.admin !== undefined) { + writer.uint32(10).string(message.admin); + } + for (const v of message.members) { + Member.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.metadata !== undefined) { + writer.uint32(26).string(message.metadata); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgCreateGroup { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgCreateGroup(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.admin = reader.string(); + break; + case 2: + message.members.push(Member.decode(reader, reader.uint32())); + break; + case 3: + message.metadata = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgCreateGroup { + const obj = createBaseMsgCreateGroup(); + if (isSet(object.admin)) obj.admin = String(object.admin); + if (Array.isArray(object?.members)) obj.members = object.members.map((e: any) => Member.fromJSON(e)); + if (isSet(object.metadata)) obj.metadata = String(object.metadata); + return obj; + }, + toJSON(message: MsgCreateGroup): JsonSafe { + const obj: any = {}; + message.admin !== undefined && (obj.admin = message.admin); + if (message.members) { + obj.members = message.members.map(e => e ? Member.toJSON(e) : undefined); + } else { + obj.members = []; + } + message.metadata !== undefined && (obj.metadata = message.metadata); + return obj; + }, + fromPartial(object: DeepPartial): MsgCreateGroup { + const message = createBaseMsgCreateGroup(); + message.admin = object.admin ?? ""; + message.members = object.members?.map(e => Member.fromPartial(e)) || []; + message.metadata = object.metadata ?? ""; + return message; + }, + fromSDK(object: MsgCreateGroupSDKType): MsgCreateGroup { + return { + admin: object?.admin, + members: Array.isArray(object?.members) ? object.members.map((e: any) => Member.fromSDK(e)) : [], + metadata: object?.metadata + }; + }, + fromSDKJSON(object: any): MsgCreateGroupSDKType { + return { + admin: isSet(object.admin) ? String(object.admin) : "", + members: Array.isArray(object?.members) ? object.members.map((e: any) => Member.fromSDKJSON(e)) : [], + metadata: isSet(object.metadata) ? String(object.metadata) : "" + }; + }, + toSDK(message: MsgCreateGroup): MsgCreateGroupSDKType { + const obj: any = {}; + obj.admin = message.admin; + if (message.members) { + obj.members = message.members.map(e => e ? Member.toSDK(e) : undefined); + } else { + obj.members = []; + } + obj.metadata = message.metadata; + return obj; + }, + fromAmino(object: MsgCreateGroupAmino): MsgCreateGroup { + const message = createBaseMsgCreateGroup(); + if (object.admin !== undefined && object.admin !== null) { + message.admin = object.admin; + } + message.members = object.members?.map(e => Member.fromAmino(e)) || []; + if (object.metadata !== undefined && object.metadata !== null) { + message.metadata = object.metadata; + } + return message; + }, + toAmino(message: MsgCreateGroup): MsgCreateGroupAmino { + const obj: any = {}; + obj.admin = message.admin === "" ? undefined : message.admin; + if (message.members) { + obj.members = message.members.map(e => e ? Member.toAmino(e) : undefined); + } else { + obj.members = message.members; + } + obj.metadata = message.metadata === "" ? undefined : message.metadata; + return obj; + }, + fromAminoMsg(object: MsgCreateGroupAminoMsg): MsgCreateGroup { + return MsgCreateGroup.fromAmino(object.value); + }, + toAminoMsg(message: MsgCreateGroup): MsgCreateGroupAminoMsg { + return { + type: "cosmos-sdk/MsgCreateGroup", + value: MsgCreateGroup.toAmino(message) + }; + }, + fromProtoMsg(message: MsgCreateGroupProtoMsg): MsgCreateGroup { + return MsgCreateGroup.decode(message.value); + }, + toProto(message: MsgCreateGroup): Uint8Array { + return MsgCreateGroup.encode(message).finish(); + }, + toProtoMsg(message: MsgCreateGroup): MsgCreateGroupProtoMsg { + return { + typeUrl: "/cosmos.group.v1.MsgCreateGroup", + value: MsgCreateGroup.encode(message).finish() + }; + } +}; +function createBaseMsgCreateGroupResponse(): MsgCreateGroupResponse { + return { + groupId: BigInt(0) + }; +} +export const MsgCreateGroupResponse = { + typeUrl: "/cosmos.group.v1.MsgCreateGroupResponse", + encode(message: MsgCreateGroupResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.groupId !== undefined) { + writer.uint32(8).uint64(message.groupId); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgCreateGroupResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgCreateGroupResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.groupId = reader.uint64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgCreateGroupResponse { + const obj = createBaseMsgCreateGroupResponse(); + if (isSet(object.groupId)) obj.groupId = BigInt(object.groupId.toString()); + return obj; + }, + toJSON(message: MsgCreateGroupResponse): JsonSafe { + const obj: any = {}; + message.groupId !== undefined && (obj.groupId = (message.groupId || BigInt(0)).toString()); + return obj; + }, + fromPartial(object: DeepPartial): MsgCreateGroupResponse { + const message = createBaseMsgCreateGroupResponse(); + if (object.groupId !== undefined && object.groupId !== null) { + message.groupId = BigInt(object.groupId.toString()); + } + return message; + }, + fromSDK(object: MsgCreateGroupResponseSDKType): MsgCreateGroupResponse { + return { + groupId: object?.group_id + }; + }, + fromSDKJSON(object: any): MsgCreateGroupResponseSDKType { + return { + group_id: isSet(object.group_id) ? BigInt(object.group_id.toString()) : BigInt(0) + }; + }, + toSDK(message: MsgCreateGroupResponse): MsgCreateGroupResponseSDKType { + const obj: any = {}; + obj.group_id = message.groupId; + return obj; + }, + fromAmino(object: MsgCreateGroupResponseAmino): MsgCreateGroupResponse { + const message = createBaseMsgCreateGroupResponse(); + if (object.group_id !== undefined && object.group_id !== null) { + message.groupId = BigInt(object.group_id); + } + return message; + }, + toAmino(message: MsgCreateGroupResponse): MsgCreateGroupResponseAmino { + const obj: any = {}; + obj.group_id = message.groupId !== BigInt(0) ? message.groupId?.toString() : undefined; + return obj; + }, + fromAminoMsg(object: MsgCreateGroupResponseAminoMsg): MsgCreateGroupResponse { + return MsgCreateGroupResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgCreateGroupResponse): MsgCreateGroupResponseAminoMsg { + return { + type: "cosmos-sdk/MsgCreateGroupResponse", + value: MsgCreateGroupResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgCreateGroupResponseProtoMsg): MsgCreateGroupResponse { + return MsgCreateGroupResponse.decode(message.value); + }, + toProto(message: MsgCreateGroupResponse): Uint8Array { + return MsgCreateGroupResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgCreateGroupResponse): MsgCreateGroupResponseProtoMsg { + return { + typeUrl: "/cosmos.group.v1.MsgCreateGroupResponse", + value: MsgCreateGroupResponse.encode(message).finish() + }; + } +}; +function createBaseMsgUpdateGroupMembers(): MsgUpdateGroupMembers { + return { + admin: "", + groupId: BigInt(0), + memberUpdates: [] + }; +} +export const MsgUpdateGroupMembers = { + typeUrl: "/cosmos.group.v1.MsgUpdateGroupMembers", + encode(message: MsgUpdateGroupMembers, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.admin !== undefined) { + writer.uint32(10).string(message.admin); + } + if (message.groupId !== undefined) { + writer.uint32(16).uint64(message.groupId); + } + for (const v of message.memberUpdates) { + Member.encode(v!, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgUpdateGroupMembers { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgUpdateGroupMembers(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.admin = reader.string(); + break; + case 2: + message.groupId = reader.uint64(); + break; + case 3: + message.memberUpdates.push(Member.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgUpdateGroupMembers { + const obj = createBaseMsgUpdateGroupMembers(); + if (isSet(object.admin)) obj.admin = String(object.admin); + if (isSet(object.groupId)) obj.groupId = BigInt(object.groupId.toString()); + if (Array.isArray(object?.memberUpdates)) obj.memberUpdates = object.memberUpdates.map((e: any) => Member.fromJSON(e)); + return obj; + }, + toJSON(message: MsgUpdateGroupMembers): JsonSafe { + const obj: any = {}; + message.admin !== undefined && (obj.admin = message.admin); + message.groupId !== undefined && (obj.groupId = (message.groupId || BigInt(0)).toString()); + if (message.memberUpdates) { + obj.memberUpdates = message.memberUpdates.map(e => e ? Member.toJSON(e) : undefined); + } else { + obj.memberUpdates = []; + } + return obj; + }, + fromPartial(object: DeepPartial): MsgUpdateGroupMembers { + const message = createBaseMsgUpdateGroupMembers(); + message.admin = object.admin ?? ""; + if (object.groupId !== undefined && object.groupId !== null) { + message.groupId = BigInt(object.groupId.toString()); + } + message.memberUpdates = object.memberUpdates?.map(e => Member.fromPartial(e)) || []; + return message; + }, + fromSDK(object: MsgUpdateGroupMembersSDKType): MsgUpdateGroupMembers { + return { + admin: object?.admin, + groupId: object?.group_id, + memberUpdates: Array.isArray(object?.member_updates) ? object.member_updates.map((e: any) => Member.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): MsgUpdateGroupMembersSDKType { + return { + admin: isSet(object.admin) ? String(object.admin) : "", + group_id: isSet(object.group_id) ? BigInt(object.group_id.toString()) : BigInt(0), + member_updates: Array.isArray(object?.member_updates) ? object.member_updates.map((e: any) => Member.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: MsgUpdateGroupMembers): MsgUpdateGroupMembersSDKType { + const obj: any = {}; + obj.admin = message.admin; + obj.group_id = message.groupId; + if (message.memberUpdates) { + obj.member_updates = message.memberUpdates.map(e => e ? Member.toSDK(e) : undefined); + } else { + obj.member_updates = []; + } + return obj; + }, + fromAmino(object: MsgUpdateGroupMembersAmino): MsgUpdateGroupMembers { + const message = createBaseMsgUpdateGroupMembers(); + if (object.admin !== undefined && object.admin !== null) { + message.admin = object.admin; + } + if (object.group_id !== undefined && object.group_id !== null) { + message.groupId = BigInt(object.group_id); + } + message.memberUpdates = object.member_updates?.map(e => Member.fromAmino(e)) || []; + return message; + }, + toAmino(message: MsgUpdateGroupMembers): MsgUpdateGroupMembersAmino { + const obj: any = {}; + obj.admin = message.admin === "" ? undefined : message.admin; + obj.group_id = message.groupId !== BigInt(0) ? message.groupId?.toString() : undefined; + if (message.memberUpdates) { + obj.member_updates = message.memberUpdates.map(e => e ? Member.toAmino(e) : undefined); + } else { + obj.member_updates = message.memberUpdates; + } + return obj; + }, + fromAminoMsg(object: MsgUpdateGroupMembersAminoMsg): MsgUpdateGroupMembers { + return MsgUpdateGroupMembers.fromAmino(object.value); + }, + toAminoMsg(message: MsgUpdateGroupMembers): MsgUpdateGroupMembersAminoMsg { + return { + type: "cosmos-sdk/MsgUpdateGroupMembers", + value: MsgUpdateGroupMembers.toAmino(message) + }; + }, + fromProtoMsg(message: MsgUpdateGroupMembersProtoMsg): MsgUpdateGroupMembers { + return MsgUpdateGroupMembers.decode(message.value); + }, + toProto(message: MsgUpdateGroupMembers): Uint8Array { + return MsgUpdateGroupMembers.encode(message).finish(); + }, + toProtoMsg(message: MsgUpdateGroupMembers): MsgUpdateGroupMembersProtoMsg { + return { + typeUrl: "/cosmos.group.v1.MsgUpdateGroupMembers", + value: MsgUpdateGroupMembers.encode(message).finish() + }; + } +}; +function createBaseMsgUpdateGroupMembersResponse(): MsgUpdateGroupMembersResponse { + return {}; +} +export const MsgUpdateGroupMembersResponse = { + typeUrl: "/cosmos.group.v1.MsgUpdateGroupMembersResponse", + encode(_: MsgUpdateGroupMembersResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgUpdateGroupMembersResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgUpdateGroupMembersResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgUpdateGroupMembersResponse { + const obj = createBaseMsgUpdateGroupMembersResponse(); + return obj; + }, + toJSON(_: MsgUpdateGroupMembersResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): MsgUpdateGroupMembersResponse { + const message = createBaseMsgUpdateGroupMembersResponse(); + return message; + }, + fromSDK(_: MsgUpdateGroupMembersResponseSDKType): MsgUpdateGroupMembersResponse { + return {}; + }, + fromSDKJSON(_: any): MsgUpdateGroupMembersResponseSDKType { + return {}; + }, + toSDK(_: MsgUpdateGroupMembersResponse): MsgUpdateGroupMembersResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgUpdateGroupMembersResponseAmino): MsgUpdateGroupMembersResponse { + const message = createBaseMsgUpdateGroupMembersResponse(); + return message; + }, + toAmino(_: MsgUpdateGroupMembersResponse): MsgUpdateGroupMembersResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgUpdateGroupMembersResponseAminoMsg): MsgUpdateGroupMembersResponse { + return MsgUpdateGroupMembersResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgUpdateGroupMembersResponse): MsgUpdateGroupMembersResponseAminoMsg { + return { + type: "cosmos-sdk/MsgUpdateGroupMembersResponse", + value: MsgUpdateGroupMembersResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgUpdateGroupMembersResponseProtoMsg): MsgUpdateGroupMembersResponse { + return MsgUpdateGroupMembersResponse.decode(message.value); + }, + toProto(message: MsgUpdateGroupMembersResponse): Uint8Array { + return MsgUpdateGroupMembersResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgUpdateGroupMembersResponse): MsgUpdateGroupMembersResponseProtoMsg { + return { + typeUrl: "/cosmos.group.v1.MsgUpdateGroupMembersResponse", + value: MsgUpdateGroupMembersResponse.encode(message).finish() + }; + } +}; +function createBaseMsgUpdateGroupAdmin(): MsgUpdateGroupAdmin { + return { + admin: "", + groupId: BigInt(0), + newAdmin: "" + }; +} +export const MsgUpdateGroupAdmin = { + typeUrl: "/cosmos.group.v1.MsgUpdateGroupAdmin", + encode(message: MsgUpdateGroupAdmin, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.admin !== undefined) { + writer.uint32(10).string(message.admin); + } + if (message.groupId !== undefined) { + writer.uint32(16).uint64(message.groupId); + } + if (message.newAdmin !== undefined) { + writer.uint32(26).string(message.newAdmin); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgUpdateGroupAdmin { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgUpdateGroupAdmin(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.admin = reader.string(); + break; + case 2: + message.groupId = reader.uint64(); + break; + case 3: + message.newAdmin = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgUpdateGroupAdmin { + const obj = createBaseMsgUpdateGroupAdmin(); + if (isSet(object.admin)) obj.admin = String(object.admin); + if (isSet(object.groupId)) obj.groupId = BigInt(object.groupId.toString()); + if (isSet(object.newAdmin)) obj.newAdmin = String(object.newAdmin); + return obj; + }, + toJSON(message: MsgUpdateGroupAdmin): JsonSafe { + const obj: any = {}; + message.admin !== undefined && (obj.admin = message.admin); + message.groupId !== undefined && (obj.groupId = (message.groupId || BigInt(0)).toString()); + message.newAdmin !== undefined && (obj.newAdmin = message.newAdmin); + return obj; + }, + fromPartial(object: DeepPartial): MsgUpdateGroupAdmin { + const message = createBaseMsgUpdateGroupAdmin(); + message.admin = object.admin ?? ""; + if (object.groupId !== undefined && object.groupId !== null) { + message.groupId = BigInt(object.groupId.toString()); + } + message.newAdmin = object.newAdmin ?? ""; + return message; + }, + fromSDK(object: MsgUpdateGroupAdminSDKType): MsgUpdateGroupAdmin { + return { + admin: object?.admin, + groupId: object?.group_id, + newAdmin: object?.new_admin + }; + }, + fromSDKJSON(object: any): MsgUpdateGroupAdminSDKType { + return { + admin: isSet(object.admin) ? String(object.admin) : "", + group_id: isSet(object.group_id) ? BigInt(object.group_id.toString()) : BigInt(0), + new_admin: isSet(object.new_admin) ? String(object.new_admin) : "" + }; + }, + toSDK(message: MsgUpdateGroupAdmin): MsgUpdateGroupAdminSDKType { + const obj: any = {}; + obj.admin = message.admin; + obj.group_id = message.groupId; + obj.new_admin = message.newAdmin; + return obj; + }, + fromAmino(object: MsgUpdateGroupAdminAmino): MsgUpdateGroupAdmin { + const message = createBaseMsgUpdateGroupAdmin(); + if (object.admin !== undefined && object.admin !== null) { + message.admin = object.admin; + } + if (object.group_id !== undefined && object.group_id !== null) { + message.groupId = BigInt(object.group_id); + } + if (object.new_admin !== undefined && object.new_admin !== null) { + message.newAdmin = object.new_admin; + } + return message; + }, + toAmino(message: MsgUpdateGroupAdmin): MsgUpdateGroupAdminAmino { + const obj: any = {}; + obj.admin = message.admin === "" ? undefined : message.admin; + obj.group_id = message.groupId !== BigInt(0) ? message.groupId?.toString() : undefined; + obj.new_admin = message.newAdmin === "" ? undefined : message.newAdmin; + return obj; + }, + fromAminoMsg(object: MsgUpdateGroupAdminAminoMsg): MsgUpdateGroupAdmin { + return MsgUpdateGroupAdmin.fromAmino(object.value); + }, + toAminoMsg(message: MsgUpdateGroupAdmin): MsgUpdateGroupAdminAminoMsg { + return { + type: "cosmos-sdk/MsgUpdateGroupAdmin", + value: MsgUpdateGroupAdmin.toAmino(message) + }; + }, + fromProtoMsg(message: MsgUpdateGroupAdminProtoMsg): MsgUpdateGroupAdmin { + return MsgUpdateGroupAdmin.decode(message.value); + }, + toProto(message: MsgUpdateGroupAdmin): Uint8Array { + return MsgUpdateGroupAdmin.encode(message).finish(); + }, + toProtoMsg(message: MsgUpdateGroupAdmin): MsgUpdateGroupAdminProtoMsg { + return { + typeUrl: "/cosmos.group.v1.MsgUpdateGroupAdmin", + value: MsgUpdateGroupAdmin.encode(message).finish() + }; + } +}; +function createBaseMsgUpdateGroupAdminResponse(): MsgUpdateGroupAdminResponse { + return {}; +} +export const MsgUpdateGroupAdminResponse = { + typeUrl: "/cosmos.group.v1.MsgUpdateGroupAdminResponse", + encode(_: MsgUpdateGroupAdminResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgUpdateGroupAdminResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgUpdateGroupAdminResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgUpdateGroupAdminResponse { + const obj = createBaseMsgUpdateGroupAdminResponse(); + return obj; + }, + toJSON(_: MsgUpdateGroupAdminResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): MsgUpdateGroupAdminResponse { + const message = createBaseMsgUpdateGroupAdminResponse(); + return message; + }, + fromSDK(_: MsgUpdateGroupAdminResponseSDKType): MsgUpdateGroupAdminResponse { + return {}; + }, + fromSDKJSON(_: any): MsgUpdateGroupAdminResponseSDKType { + return {}; + }, + toSDK(_: MsgUpdateGroupAdminResponse): MsgUpdateGroupAdminResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgUpdateGroupAdminResponseAmino): MsgUpdateGroupAdminResponse { + const message = createBaseMsgUpdateGroupAdminResponse(); + return message; + }, + toAmino(_: MsgUpdateGroupAdminResponse): MsgUpdateGroupAdminResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgUpdateGroupAdminResponseAminoMsg): MsgUpdateGroupAdminResponse { + return MsgUpdateGroupAdminResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgUpdateGroupAdminResponse): MsgUpdateGroupAdminResponseAminoMsg { + return { + type: "cosmos-sdk/MsgUpdateGroupAdminResponse", + value: MsgUpdateGroupAdminResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgUpdateGroupAdminResponseProtoMsg): MsgUpdateGroupAdminResponse { + return MsgUpdateGroupAdminResponse.decode(message.value); + }, + toProto(message: MsgUpdateGroupAdminResponse): Uint8Array { + return MsgUpdateGroupAdminResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgUpdateGroupAdminResponse): MsgUpdateGroupAdminResponseProtoMsg { + return { + typeUrl: "/cosmos.group.v1.MsgUpdateGroupAdminResponse", + value: MsgUpdateGroupAdminResponse.encode(message).finish() + }; + } +}; +function createBaseMsgUpdateGroupMetadata(): MsgUpdateGroupMetadata { + return { + admin: "", + groupId: BigInt(0), + metadata: "" + }; +} +export const MsgUpdateGroupMetadata = { + typeUrl: "/cosmos.group.v1.MsgUpdateGroupMetadata", + encode(message: MsgUpdateGroupMetadata, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.admin !== undefined) { + writer.uint32(10).string(message.admin); + } + if (message.groupId !== undefined) { + writer.uint32(16).uint64(message.groupId); + } + if (message.metadata !== undefined) { + writer.uint32(26).string(message.metadata); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgUpdateGroupMetadata { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgUpdateGroupMetadata(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.admin = reader.string(); + break; + case 2: + message.groupId = reader.uint64(); + break; + case 3: + message.metadata = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgUpdateGroupMetadata { + const obj = createBaseMsgUpdateGroupMetadata(); + if (isSet(object.admin)) obj.admin = String(object.admin); + if (isSet(object.groupId)) obj.groupId = BigInt(object.groupId.toString()); + if (isSet(object.metadata)) obj.metadata = String(object.metadata); + return obj; + }, + toJSON(message: MsgUpdateGroupMetadata): JsonSafe { + const obj: any = {}; + message.admin !== undefined && (obj.admin = message.admin); + message.groupId !== undefined && (obj.groupId = (message.groupId || BigInt(0)).toString()); + message.metadata !== undefined && (obj.metadata = message.metadata); + return obj; + }, + fromPartial(object: DeepPartial): MsgUpdateGroupMetadata { + const message = createBaseMsgUpdateGroupMetadata(); + message.admin = object.admin ?? ""; + if (object.groupId !== undefined && object.groupId !== null) { + message.groupId = BigInt(object.groupId.toString()); + } + message.metadata = object.metadata ?? ""; + return message; + }, + fromSDK(object: MsgUpdateGroupMetadataSDKType): MsgUpdateGroupMetadata { + return { + admin: object?.admin, + groupId: object?.group_id, + metadata: object?.metadata + }; + }, + fromSDKJSON(object: any): MsgUpdateGroupMetadataSDKType { + return { + admin: isSet(object.admin) ? String(object.admin) : "", + group_id: isSet(object.group_id) ? BigInt(object.group_id.toString()) : BigInt(0), + metadata: isSet(object.metadata) ? String(object.metadata) : "" + }; + }, + toSDK(message: MsgUpdateGroupMetadata): MsgUpdateGroupMetadataSDKType { + const obj: any = {}; + obj.admin = message.admin; + obj.group_id = message.groupId; + obj.metadata = message.metadata; + return obj; + }, + fromAmino(object: MsgUpdateGroupMetadataAmino): MsgUpdateGroupMetadata { + const message = createBaseMsgUpdateGroupMetadata(); + if (object.admin !== undefined && object.admin !== null) { + message.admin = object.admin; + } + if (object.group_id !== undefined && object.group_id !== null) { + message.groupId = BigInt(object.group_id); + } + if (object.metadata !== undefined && object.metadata !== null) { + message.metadata = object.metadata; + } + return message; + }, + toAmino(message: MsgUpdateGroupMetadata): MsgUpdateGroupMetadataAmino { + const obj: any = {}; + obj.admin = message.admin === "" ? undefined : message.admin; + obj.group_id = message.groupId !== BigInt(0) ? message.groupId?.toString() : undefined; + obj.metadata = message.metadata === "" ? undefined : message.metadata; + return obj; + }, + fromAminoMsg(object: MsgUpdateGroupMetadataAminoMsg): MsgUpdateGroupMetadata { + return MsgUpdateGroupMetadata.fromAmino(object.value); + }, + toAminoMsg(message: MsgUpdateGroupMetadata): MsgUpdateGroupMetadataAminoMsg { + return { + type: "cosmos-sdk/MsgUpdateGroupMetadata", + value: MsgUpdateGroupMetadata.toAmino(message) + }; + }, + fromProtoMsg(message: MsgUpdateGroupMetadataProtoMsg): MsgUpdateGroupMetadata { + return MsgUpdateGroupMetadata.decode(message.value); + }, + toProto(message: MsgUpdateGroupMetadata): Uint8Array { + return MsgUpdateGroupMetadata.encode(message).finish(); + }, + toProtoMsg(message: MsgUpdateGroupMetadata): MsgUpdateGroupMetadataProtoMsg { + return { + typeUrl: "/cosmos.group.v1.MsgUpdateGroupMetadata", + value: MsgUpdateGroupMetadata.encode(message).finish() + }; + } +}; +function createBaseMsgUpdateGroupMetadataResponse(): MsgUpdateGroupMetadataResponse { + return {}; +} +export const MsgUpdateGroupMetadataResponse = { + typeUrl: "/cosmos.group.v1.MsgUpdateGroupMetadataResponse", + encode(_: MsgUpdateGroupMetadataResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgUpdateGroupMetadataResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgUpdateGroupMetadataResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgUpdateGroupMetadataResponse { + const obj = createBaseMsgUpdateGroupMetadataResponse(); + return obj; + }, + toJSON(_: MsgUpdateGroupMetadataResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): MsgUpdateGroupMetadataResponse { + const message = createBaseMsgUpdateGroupMetadataResponse(); + return message; + }, + fromSDK(_: MsgUpdateGroupMetadataResponseSDKType): MsgUpdateGroupMetadataResponse { + return {}; + }, + fromSDKJSON(_: any): MsgUpdateGroupMetadataResponseSDKType { + return {}; + }, + toSDK(_: MsgUpdateGroupMetadataResponse): MsgUpdateGroupMetadataResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgUpdateGroupMetadataResponseAmino): MsgUpdateGroupMetadataResponse { + const message = createBaseMsgUpdateGroupMetadataResponse(); + return message; + }, + toAmino(_: MsgUpdateGroupMetadataResponse): MsgUpdateGroupMetadataResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgUpdateGroupMetadataResponseAminoMsg): MsgUpdateGroupMetadataResponse { + return MsgUpdateGroupMetadataResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgUpdateGroupMetadataResponse): MsgUpdateGroupMetadataResponseAminoMsg { + return { + type: "cosmos-sdk/MsgUpdateGroupMetadataResponse", + value: MsgUpdateGroupMetadataResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgUpdateGroupMetadataResponseProtoMsg): MsgUpdateGroupMetadataResponse { + return MsgUpdateGroupMetadataResponse.decode(message.value); + }, + toProto(message: MsgUpdateGroupMetadataResponse): Uint8Array { + return MsgUpdateGroupMetadataResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgUpdateGroupMetadataResponse): MsgUpdateGroupMetadataResponseProtoMsg { + return { + typeUrl: "/cosmos.group.v1.MsgUpdateGroupMetadataResponse", + value: MsgUpdateGroupMetadataResponse.encode(message).finish() + }; + } +}; +function createBaseMsgCreateGroupPolicy(): MsgCreateGroupPolicy { + return { + admin: "", + groupId: BigInt(0), + metadata: "", + decisionPolicy: undefined + }; +} +export const MsgCreateGroupPolicy = { + typeUrl: "/cosmos.group.v1.MsgCreateGroupPolicy", + encode(message: MsgCreateGroupPolicy, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.admin !== undefined) { + writer.uint32(10).string(message.admin); + } + if (message.groupId !== undefined) { + writer.uint32(16).uint64(message.groupId); + } + if (message.metadata !== undefined) { + writer.uint32(26).string(message.metadata); + } + if (message.decisionPolicy !== undefined) { + Any.encode(message.decisionPolicy, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgCreateGroupPolicy { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgCreateGroupPolicy(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.admin = reader.string(); + break; + case 2: + message.groupId = reader.uint64(); + break; + case 3: + message.metadata = reader.string(); + break; + case 4: + message.decisionPolicy = Any.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgCreateGroupPolicy { + const obj = createBaseMsgCreateGroupPolicy(); + if (isSet(object.admin)) obj.admin = String(object.admin); + if (isSet(object.groupId)) obj.groupId = BigInt(object.groupId.toString()); + if (isSet(object.metadata)) obj.metadata = String(object.metadata); + if (isSet(object.decisionPolicy)) obj.decisionPolicy = Any.fromJSON(object.decisionPolicy); + return obj; + }, + toJSON(message: MsgCreateGroupPolicy): JsonSafe { + const obj: any = {}; + message.admin !== undefined && (obj.admin = message.admin); + message.groupId !== undefined && (obj.groupId = (message.groupId || BigInt(0)).toString()); + message.metadata !== undefined && (obj.metadata = message.metadata); + message.decisionPolicy !== undefined && (obj.decisionPolicy = message.decisionPolicy ? Any.toJSON(message.decisionPolicy) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): MsgCreateGroupPolicy { + const message = createBaseMsgCreateGroupPolicy(); + message.admin = object.admin ?? ""; + if (object.groupId !== undefined && object.groupId !== null) { + message.groupId = BigInt(object.groupId.toString()); + } + message.metadata = object.metadata ?? ""; + if (object.decisionPolicy !== undefined && object.decisionPolicy !== null) { + message.decisionPolicy = Any.fromPartial(object.decisionPolicy); + } + return message; + }, + fromSDK(object: MsgCreateGroupPolicySDKType): MsgCreateGroupPolicy { + return { + admin: object?.admin, + groupId: object?.group_id, + metadata: object?.metadata, + decisionPolicy: object.decision_policy ? Any.fromSDK(object.decision_policy) : undefined + }; + }, + fromSDKJSON(object: any): MsgCreateGroupPolicySDKType { + return { + admin: isSet(object.admin) ? String(object.admin) : "", + group_id: isSet(object.group_id) ? BigInt(object.group_id.toString()) : BigInt(0), + metadata: isSet(object.metadata) ? String(object.metadata) : "", + decision_policy: isSet(object.decision_policy) ? Any.fromSDKJSON(object.decision_policy) : undefined + }; + }, + toSDK(message: MsgCreateGroupPolicy): MsgCreateGroupPolicySDKType { + const obj: any = {}; + obj.admin = message.admin; + obj.group_id = message.groupId; + obj.metadata = message.metadata; + message.decisionPolicy !== undefined && (obj.decision_policy = message.decisionPolicy ? Any.toSDK(message.decisionPolicy) : undefined); + return obj; + }, + fromAmino(object: MsgCreateGroupPolicyAmino): MsgCreateGroupPolicy { + const message = createBaseMsgCreateGroupPolicy(); + if (object.admin !== undefined && object.admin !== null) { + message.admin = object.admin; + } + if (object.group_id !== undefined && object.group_id !== null) { + message.groupId = BigInt(object.group_id); + } + if (object.metadata !== undefined && object.metadata !== null) { + message.metadata = object.metadata; + } + if (object.decision_policy !== undefined && object.decision_policy !== null) { + message.decisionPolicy = Any.fromAmino(object.decision_policy); + } + return message; + }, + toAmino(message: MsgCreateGroupPolicy): MsgCreateGroupPolicyAmino { + const obj: any = {}; + obj.admin = message.admin === "" ? undefined : message.admin; + obj.group_id = message.groupId !== BigInt(0) ? message.groupId?.toString() : undefined; + obj.metadata = message.metadata === "" ? undefined : message.metadata; + obj.decision_policy = message.decisionPolicy ? Any.toAmino(message.decisionPolicy) : undefined; + return obj; + }, + fromAminoMsg(object: MsgCreateGroupPolicyAminoMsg): MsgCreateGroupPolicy { + return MsgCreateGroupPolicy.fromAmino(object.value); + }, + toAminoMsg(message: MsgCreateGroupPolicy): MsgCreateGroupPolicyAminoMsg { + return { + type: "cosmos-sdk/MsgCreateGroupPolicy", + value: MsgCreateGroupPolicy.toAmino(message) + }; + }, + fromProtoMsg(message: MsgCreateGroupPolicyProtoMsg): MsgCreateGroupPolicy { + return MsgCreateGroupPolicy.decode(message.value); + }, + toProto(message: MsgCreateGroupPolicy): Uint8Array { + return MsgCreateGroupPolicy.encode(message).finish(); + }, + toProtoMsg(message: MsgCreateGroupPolicy): MsgCreateGroupPolicyProtoMsg { + return { + typeUrl: "/cosmos.group.v1.MsgCreateGroupPolicy", + value: MsgCreateGroupPolicy.encode(message).finish() + }; + } +}; +function createBaseMsgCreateGroupPolicyResponse(): MsgCreateGroupPolicyResponse { + return { + address: "" + }; +} +export const MsgCreateGroupPolicyResponse = { + typeUrl: "/cosmos.group.v1.MsgCreateGroupPolicyResponse", + encode(message: MsgCreateGroupPolicyResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.address !== undefined) { + writer.uint32(10).string(message.address); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgCreateGroupPolicyResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgCreateGroupPolicyResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgCreateGroupPolicyResponse { + const obj = createBaseMsgCreateGroupPolicyResponse(); + if (isSet(object.address)) obj.address = String(object.address); + return obj; + }, + toJSON(message: MsgCreateGroupPolicyResponse): JsonSafe { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + return obj; + }, + fromPartial(object: DeepPartial): MsgCreateGroupPolicyResponse { + const message = createBaseMsgCreateGroupPolicyResponse(); + message.address = object.address ?? ""; + return message; + }, + fromSDK(object: MsgCreateGroupPolicyResponseSDKType): MsgCreateGroupPolicyResponse { + return { + address: object?.address + }; + }, + fromSDKJSON(object: any): MsgCreateGroupPolicyResponseSDKType { + return { + address: isSet(object.address) ? String(object.address) : "" + }; + }, + toSDK(message: MsgCreateGroupPolicyResponse): MsgCreateGroupPolicyResponseSDKType { + const obj: any = {}; + obj.address = message.address; + return obj; + }, + fromAmino(object: MsgCreateGroupPolicyResponseAmino): MsgCreateGroupPolicyResponse { + const message = createBaseMsgCreateGroupPolicyResponse(); + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } + return message; + }, + toAmino(message: MsgCreateGroupPolicyResponse): MsgCreateGroupPolicyResponseAmino { + const obj: any = {}; + obj.address = message.address === "" ? undefined : message.address; + return obj; + }, + fromAminoMsg(object: MsgCreateGroupPolicyResponseAminoMsg): MsgCreateGroupPolicyResponse { + return MsgCreateGroupPolicyResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgCreateGroupPolicyResponse): MsgCreateGroupPolicyResponseAminoMsg { + return { + type: "cosmos-sdk/MsgCreateGroupPolicyResponse", + value: MsgCreateGroupPolicyResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgCreateGroupPolicyResponseProtoMsg): MsgCreateGroupPolicyResponse { + return MsgCreateGroupPolicyResponse.decode(message.value); + }, + toProto(message: MsgCreateGroupPolicyResponse): Uint8Array { + return MsgCreateGroupPolicyResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgCreateGroupPolicyResponse): MsgCreateGroupPolicyResponseProtoMsg { + return { + typeUrl: "/cosmos.group.v1.MsgCreateGroupPolicyResponse", + value: MsgCreateGroupPolicyResponse.encode(message).finish() + }; + } +}; +function createBaseMsgUpdateGroupPolicyAdmin(): MsgUpdateGroupPolicyAdmin { + return { + admin: "", + address: "", + newAdmin: "" + }; +} +export const MsgUpdateGroupPolicyAdmin = { + typeUrl: "/cosmos.group.v1.MsgUpdateGroupPolicyAdmin", + encode(message: MsgUpdateGroupPolicyAdmin, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.admin !== undefined) { + writer.uint32(10).string(message.admin); + } + if (message.address !== undefined) { + writer.uint32(18).string(message.address); + } + if (message.newAdmin !== undefined) { + writer.uint32(26).string(message.newAdmin); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgUpdateGroupPolicyAdmin { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgUpdateGroupPolicyAdmin(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.admin = reader.string(); + break; + case 2: + message.address = reader.string(); + break; + case 3: + message.newAdmin = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgUpdateGroupPolicyAdmin { + const obj = createBaseMsgUpdateGroupPolicyAdmin(); + if (isSet(object.admin)) obj.admin = String(object.admin); + if (isSet(object.address)) obj.address = String(object.address); + if (isSet(object.newAdmin)) obj.newAdmin = String(object.newAdmin); + return obj; + }, + toJSON(message: MsgUpdateGroupPolicyAdmin): JsonSafe { + const obj: any = {}; + message.admin !== undefined && (obj.admin = message.admin); + message.address !== undefined && (obj.address = message.address); + message.newAdmin !== undefined && (obj.newAdmin = message.newAdmin); + return obj; + }, + fromPartial(object: DeepPartial): MsgUpdateGroupPolicyAdmin { + const message = createBaseMsgUpdateGroupPolicyAdmin(); + message.admin = object.admin ?? ""; + message.address = object.address ?? ""; + message.newAdmin = object.newAdmin ?? ""; + return message; + }, + fromSDK(object: MsgUpdateGroupPolicyAdminSDKType): MsgUpdateGroupPolicyAdmin { + return { + admin: object?.admin, + address: object?.address, + newAdmin: object?.new_admin + }; + }, + fromSDKJSON(object: any): MsgUpdateGroupPolicyAdminSDKType { + return { + admin: isSet(object.admin) ? String(object.admin) : "", + address: isSet(object.address) ? String(object.address) : "", + new_admin: isSet(object.new_admin) ? String(object.new_admin) : "" + }; + }, + toSDK(message: MsgUpdateGroupPolicyAdmin): MsgUpdateGroupPolicyAdminSDKType { + const obj: any = {}; + obj.admin = message.admin; + obj.address = message.address; + obj.new_admin = message.newAdmin; + return obj; + }, + fromAmino(object: MsgUpdateGroupPolicyAdminAmino): MsgUpdateGroupPolicyAdmin { + const message = createBaseMsgUpdateGroupPolicyAdmin(); + if (object.admin !== undefined && object.admin !== null) { + message.admin = object.admin; + } + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } + if (object.new_admin !== undefined && object.new_admin !== null) { + message.newAdmin = object.new_admin; + } + return message; + }, + toAmino(message: MsgUpdateGroupPolicyAdmin): MsgUpdateGroupPolicyAdminAmino { + const obj: any = {}; + obj.admin = message.admin === "" ? undefined : message.admin; + obj.address = message.address === "" ? undefined : message.address; + obj.new_admin = message.newAdmin === "" ? undefined : message.newAdmin; + return obj; + }, + fromAminoMsg(object: MsgUpdateGroupPolicyAdminAminoMsg): MsgUpdateGroupPolicyAdmin { + return MsgUpdateGroupPolicyAdmin.fromAmino(object.value); + }, + toAminoMsg(message: MsgUpdateGroupPolicyAdmin): MsgUpdateGroupPolicyAdminAminoMsg { + return { + type: "cosmos-sdk/MsgUpdateGroupPolicyAdmin", + value: MsgUpdateGroupPolicyAdmin.toAmino(message) + }; + }, + fromProtoMsg(message: MsgUpdateGroupPolicyAdminProtoMsg): MsgUpdateGroupPolicyAdmin { + return MsgUpdateGroupPolicyAdmin.decode(message.value); + }, + toProto(message: MsgUpdateGroupPolicyAdmin): Uint8Array { + return MsgUpdateGroupPolicyAdmin.encode(message).finish(); + }, + toProtoMsg(message: MsgUpdateGroupPolicyAdmin): MsgUpdateGroupPolicyAdminProtoMsg { + return { + typeUrl: "/cosmos.group.v1.MsgUpdateGroupPolicyAdmin", + value: MsgUpdateGroupPolicyAdmin.encode(message).finish() + }; + } +}; +function createBaseMsgCreateGroupWithPolicy(): MsgCreateGroupWithPolicy { + return { + admin: "", + members: [], + groupMetadata: "", + groupPolicyMetadata: "", + groupPolicyAsAdmin: false, + decisionPolicy: undefined + }; +} +export const MsgCreateGroupWithPolicy = { + typeUrl: "/cosmos.group.v1.MsgCreateGroupWithPolicy", + encode(message: MsgCreateGroupWithPolicy, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.admin !== undefined) { + writer.uint32(10).string(message.admin); + } + for (const v of message.members) { + Member.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.groupMetadata !== undefined) { + writer.uint32(26).string(message.groupMetadata); + } + if (message.groupPolicyMetadata !== undefined) { + writer.uint32(34).string(message.groupPolicyMetadata); + } + if (message.groupPolicyAsAdmin !== undefined) { + writer.uint32(40).bool(message.groupPolicyAsAdmin); + } + if (message.decisionPolicy !== undefined) { + Any.encode(message.decisionPolicy, writer.uint32(50).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgCreateGroupWithPolicy { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgCreateGroupWithPolicy(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.admin = reader.string(); + break; + case 2: + message.members.push(Member.decode(reader, reader.uint32())); + break; + case 3: + message.groupMetadata = reader.string(); + break; + case 4: + message.groupPolicyMetadata = reader.string(); + break; + case 5: + message.groupPolicyAsAdmin = reader.bool(); + break; + case 6: + message.decisionPolicy = Any.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgCreateGroupWithPolicy { + const obj = createBaseMsgCreateGroupWithPolicy(); + if (isSet(object.admin)) obj.admin = String(object.admin); + if (Array.isArray(object?.members)) obj.members = object.members.map((e: any) => Member.fromJSON(e)); + if (isSet(object.groupMetadata)) obj.groupMetadata = String(object.groupMetadata); + if (isSet(object.groupPolicyMetadata)) obj.groupPolicyMetadata = String(object.groupPolicyMetadata); + if (isSet(object.groupPolicyAsAdmin)) obj.groupPolicyAsAdmin = Boolean(object.groupPolicyAsAdmin); + if (isSet(object.decisionPolicy)) obj.decisionPolicy = Any.fromJSON(object.decisionPolicy); + return obj; + }, + toJSON(message: MsgCreateGroupWithPolicy): JsonSafe { + const obj: any = {}; + message.admin !== undefined && (obj.admin = message.admin); + if (message.members) { + obj.members = message.members.map(e => e ? Member.toJSON(e) : undefined); + } else { + obj.members = []; + } + message.groupMetadata !== undefined && (obj.groupMetadata = message.groupMetadata); + message.groupPolicyMetadata !== undefined && (obj.groupPolicyMetadata = message.groupPolicyMetadata); + message.groupPolicyAsAdmin !== undefined && (obj.groupPolicyAsAdmin = message.groupPolicyAsAdmin); + message.decisionPolicy !== undefined && (obj.decisionPolicy = message.decisionPolicy ? Any.toJSON(message.decisionPolicy) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): MsgCreateGroupWithPolicy { + const message = createBaseMsgCreateGroupWithPolicy(); + message.admin = object.admin ?? ""; + message.members = object.members?.map(e => Member.fromPartial(e)) || []; + message.groupMetadata = object.groupMetadata ?? ""; + message.groupPolicyMetadata = object.groupPolicyMetadata ?? ""; + message.groupPolicyAsAdmin = object.groupPolicyAsAdmin ?? false; + if (object.decisionPolicy !== undefined && object.decisionPolicy !== null) { + message.decisionPolicy = Any.fromPartial(object.decisionPolicy); + } + return message; + }, + fromSDK(object: MsgCreateGroupWithPolicySDKType): MsgCreateGroupWithPolicy { + return { + admin: object?.admin, + members: Array.isArray(object?.members) ? object.members.map((e: any) => Member.fromSDK(e)) : [], + groupMetadata: object?.group_metadata, + groupPolicyMetadata: object?.group_policy_metadata, + groupPolicyAsAdmin: object?.group_policy_as_admin, + decisionPolicy: object.decision_policy ? Any.fromSDK(object.decision_policy) : undefined + }; + }, + fromSDKJSON(object: any): MsgCreateGroupWithPolicySDKType { + return { + admin: isSet(object.admin) ? String(object.admin) : "", + members: Array.isArray(object?.members) ? object.members.map((e: any) => Member.fromSDKJSON(e)) : [], + group_metadata: isSet(object.group_metadata) ? String(object.group_metadata) : "", + group_policy_metadata: isSet(object.group_policy_metadata) ? String(object.group_policy_metadata) : "", + group_policy_as_admin: isSet(object.group_policy_as_admin) ? Boolean(object.group_policy_as_admin) : false, + decision_policy: isSet(object.decision_policy) ? Any.fromSDKJSON(object.decision_policy) : undefined + }; + }, + toSDK(message: MsgCreateGroupWithPolicy): MsgCreateGroupWithPolicySDKType { + const obj: any = {}; + obj.admin = message.admin; + if (message.members) { + obj.members = message.members.map(e => e ? Member.toSDK(e) : undefined); + } else { + obj.members = []; + } + obj.group_metadata = message.groupMetadata; + obj.group_policy_metadata = message.groupPolicyMetadata; + obj.group_policy_as_admin = message.groupPolicyAsAdmin; + message.decisionPolicy !== undefined && (obj.decision_policy = message.decisionPolicy ? Any.toSDK(message.decisionPolicy) : undefined); + return obj; + }, + fromAmino(object: MsgCreateGroupWithPolicyAmino): MsgCreateGroupWithPolicy { + const message = createBaseMsgCreateGroupWithPolicy(); + if (object.admin !== undefined && object.admin !== null) { + message.admin = object.admin; + } + message.members = object.members?.map(e => Member.fromAmino(e)) || []; + if (object.group_metadata !== undefined && object.group_metadata !== null) { + message.groupMetadata = object.group_metadata; + } + if (object.group_policy_metadata !== undefined && object.group_policy_metadata !== null) { + message.groupPolicyMetadata = object.group_policy_metadata; + } + if (object.group_policy_as_admin !== undefined && object.group_policy_as_admin !== null) { + message.groupPolicyAsAdmin = object.group_policy_as_admin; + } + if (object.decision_policy !== undefined && object.decision_policy !== null) { + message.decisionPolicy = Any.fromAmino(object.decision_policy); + } + return message; + }, + toAmino(message: MsgCreateGroupWithPolicy): MsgCreateGroupWithPolicyAmino { + const obj: any = {}; + obj.admin = message.admin === "" ? undefined : message.admin; + if (message.members) { + obj.members = message.members.map(e => e ? Member.toAmino(e) : undefined); + } else { + obj.members = message.members; + } + obj.group_metadata = message.groupMetadata === "" ? undefined : message.groupMetadata; + obj.group_policy_metadata = message.groupPolicyMetadata === "" ? undefined : message.groupPolicyMetadata; + obj.group_policy_as_admin = message.groupPolicyAsAdmin === false ? undefined : message.groupPolicyAsAdmin; + obj.decision_policy = message.decisionPolicy ? Any.toAmino(message.decisionPolicy) : undefined; + return obj; + }, + fromAminoMsg(object: MsgCreateGroupWithPolicyAminoMsg): MsgCreateGroupWithPolicy { + return MsgCreateGroupWithPolicy.fromAmino(object.value); + }, + toAminoMsg(message: MsgCreateGroupWithPolicy): MsgCreateGroupWithPolicyAminoMsg { + return { + type: "cosmos-sdk/MsgCreateGroupWithPolicy", + value: MsgCreateGroupWithPolicy.toAmino(message) + }; + }, + fromProtoMsg(message: MsgCreateGroupWithPolicyProtoMsg): MsgCreateGroupWithPolicy { + return MsgCreateGroupWithPolicy.decode(message.value); + }, + toProto(message: MsgCreateGroupWithPolicy): Uint8Array { + return MsgCreateGroupWithPolicy.encode(message).finish(); + }, + toProtoMsg(message: MsgCreateGroupWithPolicy): MsgCreateGroupWithPolicyProtoMsg { + return { + typeUrl: "/cosmos.group.v1.MsgCreateGroupWithPolicy", + value: MsgCreateGroupWithPolicy.encode(message).finish() + }; + } +}; +function createBaseMsgCreateGroupWithPolicyResponse(): MsgCreateGroupWithPolicyResponse { + return { + groupId: BigInt(0), + groupPolicyAddress: "" + }; +} +export const MsgCreateGroupWithPolicyResponse = { + typeUrl: "/cosmos.group.v1.MsgCreateGroupWithPolicyResponse", + encode(message: MsgCreateGroupWithPolicyResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.groupId !== undefined) { + writer.uint32(8).uint64(message.groupId); + } + if (message.groupPolicyAddress !== undefined) { + writer.uint32(18).string(message.groupPolicyAddress); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgCreateGroupWithPolicyResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgCreateGroupWithPolicyResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.groupId = reader.uint64(); + break; + case 2: + message.groupPolicyAddress = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgCreateGroupWithPolicyResponse { + const obj = createBaseMsgCreateGroupWithPolicyResponse(); + if (isSet(object.groupId)) obj.groupId = BigInt(object.groupId.toString()); + if (isSet(object.groupPolicyAddress)) obj.groupPolicyAddress = String(object.groupPolicyAddress); + return obj; + }, + toJSON(message: MsgCreateGroupWithPolicyResponse): JsonSafe { + const obj: any = {}; + message.groupId !== undefined && (obj.groupId = (message.groupId || BigInt(0)).toString()); + message.groupPolicyAddress !== undefined && (obj.groupPolicyAddress = message.groupPolicyAddress); + return obj; + }, + fromPartial(object: DeepPartial): MsgCreateGroupWithPolicyResponse { + const message = createBaseMsgCreateGroupWithPolicyResponse(); + if (object.groupId !== undefined && object.groupId !== null) { + message.groupId = BigInt(object.groupId.toString()); + } + message.groupPolicyAddress = object.groupPolicyAddress ?? ""; + return message; + }, + fromSDK(object: MsgCreateGroupWithPolicyResponseSDKType): MsgCreateGroupWithPolicyResponse { + return { + groupId: object?.group_id, + groupPolicyAddress: object?.group_policy_address + }; + }, + fromSDKJSON(object: any): MsgCreateGroupWithPolicyResponseSDKType { + return { + group_id: isSet(object.group_id) ? BigInt(object.group_id.toString()) : BigInt(0), + group_policy_address: isSet(object.group_policy_address) ? String(object.group_policy_address) : "" + }; + }, + toSDK(message: MsgCreateGroupWithPolicyResponse): MsgCreateGroupWithPolicyResponseSDKType { + const obj: any = {}; + obj.group_id = message.groupId; + obj.group_policy_address = message.groupPolicyAddress; + return obj; + }, + fromAmino(object: MsgCreateGroupWithPolicyResponseAmino): MsgCreateGroupWithPolicyResponse { + const message = createBaseMsgCreateGroupWithPolicyResponse(); + if (object.group_id !== undefined && object.group_id !== null) { + message.groupId = BigInt(object.group_id); + } + if (object.group_policy_address !== undefined && object.group_policy_address !== null) { + message.groupPolicyAddress = object.group_policy_address; + } + return message; + }, + toAmino(message: MsgCreateGroupWithPolicyResponse): MsgCreateGroupWithPolicyResponseAmino { + const obj: any = {}; + obj.group_id = message.groupId !== BigInt(0) ? message.groupId?.toString() : undefined; + obj.group_policy_address = message.groupPolicyAddress === "" ? undefined : message.groupPolicyAddress; + return obj; + }, + fromAminoMsg(object: MsgCreateGroupWithPolicyResponseAminoMsg): MsgCreateGroupWithPolicyResponse { + return MsgCreateGroupWithPolicyResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgCreateGroupWithPolicyResponse): MsgCreateGroupWithPolicyResponseAminoMsg { + return { + type: "cosmos-sdk/MsgCreateGroupWithPolicyResponse", + value: MsgCreateGroupWithPolicyResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgCreateGroupWithPolicyResponseProtoMsg): MsgCreateGroupWithPolicyResponse { + return MsgCreateGroupWithPolicyResponse.decode(message.value); + }, + toProto(message: MsgCreateGroupWithPolicyResponse): Uint8Array { + return MsgCreateGroupWithPolicyResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgCreateGroupWithPolicyResponse): MsgCreateGroupWithPolicyResponseProtoMsg { + return { + typeUrl: "/cosmos.group.v1.MsgCreateGroupWithPolicyResponse", + value: MsgCreateGroupWithPolicyResponse.encode(message).finish() + }; + } +}; +function createBaseMsgUpdateGroupPolicyAdminResponse(): MsgUpdateGroupPolicyAdminResponse { + return {}; +} +export const MsgUpdateGroupPolicyAdminResponse = { + typeUrl: "/cosmos.group.v1.MsgUpdateGroupPolicyAdminResponse", + encode(_: MsgUpdateGroupPolicyAdminResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgUpdateGroupPolicyAdminResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgUpdateGroupPolicyAdminResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgUpdateGroupPolicyAdminResponse { + const obj = createBaseMsgUpdateGroupPolicyAdminResponse(); + return obj; + }, + toJSON(_: MsgUpdateGroupPolicyAdminResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): MsgUpdateGroupPolicyAdminResponse { + const message = createBaseMsgUpdateGroupPolicyAdminResponse(); + return message; + }, + fromSDK(_: MsgUpdateGroupPolicyAdminResponseSDKType): MsgUpdateGroupPolicyAdminResponse { + return {}; + }, + fromSDKJSON(_: any): MsgUpdateGroupPolicyAdminResponseSDKType { + return {}; + }, + toSDK(_: MsgUpdateGroupPolicyAdminResponse): MsgUpdateGroupPolicyAdminResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgUpdateGroupPolicyAdminResponseAmino): MsgUpdateGroupPolicyAdminResponse { + const message = createBaseMsgUpdateGroupPolicyAdminResponse(); + return message; + }, + toAmino(_: MsgUpdateGroupPolicyAdminResponse): MsgUpdateGroupPolicyAdminResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgUpdateGroupPolicyAdminResponseAminoMsg): MsgUpdateGroupPolicyAdminResponse { + return MsgUpdateGroupPolicyAdminResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgUpdateGroupPolicyAdminResponse): MsgUpdateGroupPolicyAdminResponseAminoMsg { + return { + type: "cosmos-sdk/MsgUpdateGroupPolicyAdminResponse", + value: MsgUpdateGroupPolicyAdminResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgUpdateGroupPolicyAdminResponseProtoMsg): MsgUpdateGroupPolicyAdminResponse { + return MsgUpdateGroupPolicyAdminResponse.decode(message.value); + }, + toProto(message: MsgUpdateGroupPolicyAdminResponse): Uint8Array { + return MsgUpdateGroupPolicyAdminResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgUpdateGroupPolicyAdminResponse): MsgUpdateGroupPolicyAdminResponseProtoMsg { + return { + typeUrl: "/cosmos.group.v1.MsgUpdateGroupPolicyAdminResponse", + value: MsgUpdateGroupPolicyAdminResponse.encode(message).finish() + }; + } +}; +function createBaseMsgUpdateGroupPolicyDecisionPolicy(): MsgUpdateGroupPolicyDecisionPolicy { + return { + admin: "", + address: "", + decisionPolicy: undefined + }; +} +export const MsgUpdateGroupPolicyDecisionPolicy = { + typeUrl: "/cosmos.group.v1.MsgUpdateGroupPolicyDecisionPolicy", + encode(message: MsgUpdateGroupPolicyDecisionPolicy, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.admin !== undefined) { + writer.uint32(10).string(message.admin); + } + if (message.address !== undefined) { + writer.uint32(18).string(message.address); + } + if (message.decisionPolicy !== undefined) { + Any.encode(message.decisionPolicy, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgUpdateGroupPolicyDecisionPolicy { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgUpdateGroupPolicyDecisionPolicy(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.admin = reader.string(); + break; + case 2: + message.address = reader.string(); + break; + case 3: + message.decisionPolicy = Any.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgUpdateGroupPolicyDecisionPolicy { + const obj = createBaseMsgUpdateGroupPolicyDecisionPolicy(); + if (isSet(object.admin)) obj.admin = String(object.admin); + if (isSet(object.address)) obj.address = String(object.address); + if (isSet(object.decisionPolicy)) obj.decisionPolicy = Any.fromJSON(object.decisionPolicy); + return obj; + }, + toJSON(message: MsgUpdateGroupPolicyDecisionPolicy): JsonSafe { + const obj: any = {}; + message.admin !== undefined && (obj.admin = message.admin); + message.address !== undefined && (obj.address = message.address); + message.decisionPolicy !== undefined && (obj.decisionPolicy = message.decisionPolicy ? Any.toJSON(message.decisionPolicy) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): MsgUpdateGroupPolicyDecisionPolicy { + const message = createBaseMsgUpdateGroupPolicyDecisionPolicy(); + message.admin = object.admin ?? ""; + message.address = object.address ?? ""; + if (object.decisionPolicy !== undefined && object.decisionPolicy !== null) { + message.decisionPolicy = Any.fromPartial(object.decisionPolicy); + } + return message; + }, + fromSDK(object: MsgUpdateGroupPolicyDecisionPolicySDKType): MsgUpdateGroupPolicyDecisionPolicy { + return { + admin: object?.admin, + address: object?.address, + decisionPolicy: object.decision_policy ? Any.fromSDK(object.decision_policy) : undefined + }; + }, + fromSDKJSON(object: any): MsgUpdateGroupPolicyDecisionPolicySDKType { + return { + admin: isSet(object.admin) ? String(object.admin) : "", + address: isSet(object.address) ? String(object.address) : "", + decision_policy: isSet(object.decision_policy) ? Any.fromSDKJSON(object.decision_policy) : undefined + }; + }, + toSDK(message: MsgUpdateGroupPolicyDecisionPolicy): MsgUpdateGroupPolicyDecisionPolicySDKType { + const obj: any = {}; + obj.admin = message.admin; + obj.address = message.address; + message.decisionPolicy !== undefined && (obj.decision_policy = message.decisionPolicy ? Any.toSDK(message.decisionPolicy) : undefined); + return obj; + }, + fromAmino(object: MsgUpdateGroupPolicyDecisionPolicyAmino): MsgUpdateGroupPolicyDecisionPolicy { + const message = createBaseMsgUpdateGroupPolicyDecisionPolicy(); + if (object.admin !== undefined && object.admin !== null) { + message.admin = object.admin; + } + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } + if (object.decision_policy !== undefined && object.decision_policy !== null) { + message.decisionPolicy = Any.fromAmino(object.decision_policy); + } + return message; + }, + toAmino(message: MsgUpdateGroupPolicyDecisionPolicy): MsgUpdateGroupPolicyDecisionPolicyAmino { + const obj: any = {}; + obj.admin = message.admin === "" ? undefined : message.admin; + obj.address = message.address === "" ? undefined : message.address; + obj.decision_policy = message.decisionPolicy ? Any.toAmino(message.decisionPolicy) : undefined; + return obj; + }, + fromAminoMsg(object: MsgUpdateGroupPolicyDecisionPolicyAminoMsg): MsgUpdateGroupPolicyDecisionPolicy { + return MsgUpdateGroupPolicyDecisionPolicy.fromAmino(object.value); + }, + toAminoMsg(message: MsgUpdateGroupPolicyDecisionPolicy): MsgUpdateGroupPolicyDecisionPolicyAminoMsg { + return { + type: "cosmos-sdk/MsgUpdateGroupPolicyDecisionPolicy", + value: MsgUpdateGroupPolicyDecisionPolicy.toAmino(message) + }; + }, + fromProtoMsg(message: MsgUpdateGroupPolicyDecisionPolicyProtoMsg): MsgUpdateGroupPolicyDecisionPolicy { + return MsgUpdateGroupPolicyDecisionPolicy.decode(message.value); + }, + toProto(message: MsgUpdateGroupPolicyDecisionPolicy): Uint8Array { + return MsgUpdateGroupPolicyDecisionPolicy.encode(message).finish(); + }, + toProtoMsg(message: MsgUpdateGroupPolicyDecisionPolicy): MsgUpdateGroupPolicyDecisionPolicyProtoMsg { + return { + typeUrl: "/cosmos.group.v1.MsgUpdateGroupPolicyDecisionPolicy", + value: MsgUpdateGroupPolicyDecisionPolicy.encode(message).finish() + }; + } +}; +function createBaseMsgUpdateGroupPolicyDecisionPolicyResponse(): MsgUpdateGroupPolicyDecisionPolicyResponse { + return {}; +} +export const MsgUpdateGroupPolicyDecisionPolicyResponse = { + typeUrl: "/cosmos.group.v1.MsgUpdateGroupPolicyDecisionPolicyResponse", + encode(_: MsgUpdateGroupPolicyDecisionPolicyResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgUpdateGroupPolicyDecisionPolicyResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgUpdateGroupPolicyDecisionPolicyResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgUpdateGroupPolicyDecisionPolicyResponse { + const obj = createBaseMsgUpdateGroupPolicyDecisionPolicyResponse(); + return obj; + }, + toJSON(_: MsgUpdateGroupPolicyDecisionPolicyResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): MsgUpdateGroupPolicyDecisionPolicyResponse { + const message = createBaseMsgUpdateGroupPolicyDecisionPolicyResponse(); + return message; + }, + fromSDK(_: MsgUpdateGroupPolicyDecisionPolicyResponseSDKType): MsgUpdateGroupPolicyDecisionPolicyResponse { + return {}; + }, + fromSDKJSON(_: any): MsgUpdateGroupPolicyDecisionPolicyResponseSDKType { + return {}; + }, + toSDK(_: MsgUpdateGroupPolicyDecisionPolicyResponse): MsgUpdateGroupPolicyDecisionPolicyResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgUpdateGroupPolicyDecisionPolicyResponseAmino): MsgUpdateGroupPolicyDecisionPolicyResponse { + const message = createBaseMsgUpdateGroupPolicyDecisionPolicyResponse(); + return message; + }, + toAmino(_: MsgUpdateGroupPolicyDecisionPolicyResponse): MsgUpdateGroupPolicyDecisionPolicyResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgUpdateGroupPolicyDecisionPolicyResponseAminoMsg): MsgUpdateGroupPolicyDecisionPolicyResponse { + return MsgUpdateGroupPolicyDecisionPolicyResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgUpdateGroupPolicyDecisionPolicyResponse): MsgUpdateGroupPolicyDecisionPolicyResponseAminoMsg { + return { + type: "cosmos-sdk/MsgUpdateGroupPolicyDecisionPolicyResponse", + value: MsgUpdateGroupPolicyDecisionPolicyResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgUpdateGroupPolicyDecisionPolicyResponseProtoMsg): MsgUpdateGroupPolicyDecisionPolicyResponse { + return MsgUpdateGroupPolicyDecisionPolicyResponse.decode(message.value); + }, + toProto(message: MsgUpdateGroupPolicyDecisionPolicyResponse): Uint8Array { + return MsgUpdateGroupPolicyDecisionPolicyResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgUpdateGroupPolicyDecisionPolicyResponse): MsgUpdateGroupPolicyDecisionPolicyResponseProtoMsg { + return { + typeUrl: "/cosmos.group.v1.MsgUpdateGroupPolicyDecisionPolicyResponse", + value: MsgUpdateGroupPolicyDecisionPolicyResponse.encode(message).finish() + }; + } +}; +function createBaseMsgUpdateGroupPolicyMetadata(): MsgUpdateGroupPolicyMetadata { + return { + admin: "", + address: "", + metadata: "" + }; +} +export const MsgUpdateGroupPolicyMetadata = { + typeUrl: "/cosmos.group.v1.MsgUpdateGroupPolicyMetadata", + encode(message: MsgUpdateGroupPolicyMetadata, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.admin !== undefined) { + writer.uint32(10).string(message.admin); + } + if (message.address !== undefined) { + writer.uint32(18).string(message.address); + } + if (message.metadata !== undefined) { + writer.uint32(26).string(message.metadata); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgUpdateGroupPolicyMetadata { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgUpdateGroupPolicyMetadata(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.admin = reader.string(); + break; + case 2: + message.address = reader.string(); + break; + case 3: + message.metadata = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgUpdateGroupPolicyMetadata { + const obj = createBaseMsgUpdateGroupPolicyMetadata(); + if (isSet(object.admin)) obj.admin = String(object.admin); + if (isSet(object.address)) obj.address = String(object.address); + if (isSet(object.metadata)) obj.metadata = String(object.metadata); + return obj; + }, + toJSON(message: MsgUpdateGroupPolicyMetadata): JsonSafe { + const obj: any = {}; + message.admin !== undefined && (obj.admin = message.admin); + message.address !== undefined && (obj.address = message.address); + message.metadata !== undefined && (obj.metadata = message.metadata); + return obj; + }, + fromPartial(object: DeepPartial): MsgUpdateGroupPolicyMetadata { + const message = createBaseMsgUpdateGroupPolicyMetadata(); + message.admin = object.admin ?? ""; + message.address = object.address ?? ""; + message.metadata = object.metadata ?? ""; + return message; + }, + fromSDK(object: MsgUpdateGroupPolicyMetadataSDKType): MsgUpdateGroupPolicyMetadata { + return { + admin: object?.admin, + address: object?.address, + metadata: object?.metadata + }; + }, + fromSDKJSON(object: any): MsgUpdateGroupPolicyMetadataSDKType { + return { + admin: isSet(object.admin) ? String(object.admin) : "", + address: isSet(object.address) ? String(object.address) : "", + metadata: isSet(object.metadata) ? String(object.metadata) : "" + }; + }, + toSDK(message: MsgUpdateGroupPolicyMetadata): MsgUpdateGroupPolicyMetadataSDKType { + const obj: any = {}; + obj.admin = message.admin; + obj.address = message.address; + obj.metadata = message.metadata; + return obj; + }, + fromAmino(object: MsgUpdateGroupPolicyMetadataAmino): MsgUpdateGroupPolicyMetadata { + const message = createBaseMsgUpdateGroupPolicyMetadata(); + if (object.admin !== undefined && object.admin !== null) { + message.admin = object.admin; + } + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } + if (object.metadata !== undefined && object.metadata !== null) { + message.metadata = object.metadata; + } + return message; + }, + toAmino(message: MsgUpdateGroupPolicyMetadata): MsgUpdateGroupPolicyMetadataAmino { + const obj: any = {}; + obj.admin = message.admin === "" ? undefined : message.admin; + obj.address = message.address === "" ? undefined : message.address; + obj.metadata = message.metadata === "" ? undefined : message.metadata; + return obj; + }, + fromAminoMsg(object: MsgUpdateGroupPolicyMetadataAminoMsg): MsgUpdateGroupPolicyMetadata { + return MsgUpdateGroupPolicyMetadata.fromAmino(object.value); + }, + toAminoMsg(message: MsgUpdateGroupPolicyMetadata): MsgUpdateGroupPolicyMetadataAminoMsg { + return { + type: "cosmos-sdk/MsgUpdateGroupPolicyMetadata", + value: MsgUpdateGroupPolicyMetadata.toAmino(message) + }; + }, + fromProtoMsg(message: MsgUpdateGroupPolicyMetadataProtoMsg): MsgUpdateGroupPolicyMetadata { + return MsgUpdateGroupPolicyMetadata.decode(message.value); + }, + toProto(message: MsgUpdateGroupPolicyMetadata): Uint8Array { + return MsgUpdateGroupPolicyMetadata.encode(message).finish(); + }, + toProtoMsg(message: MsgUpdateGroupPolicyMetadata): MsgUpdateGroupPolicyMetadataProtoMsg { + return { + typeUrl: "/cosmos.group.v1.MsgUpdateGroupPolicyMetadata", + value: MsgUpdateGroupPolicyMetadata.encode(message).finish() + }; + } +}; +function createBaseMsgUpdateGroupPolicyMetadataResponse(): MsgUpdateGroupPolicyMetadataResponse { + return {}; +} +export const MsgUpdateGroupPolicyMetadataResponse = { + typeUrl: "/cosmos.group.v1.MsgUpdateGroupPolicyMetadataResponse", + encode(_: MsgUpdateGroupPolicyMetadataResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgUpdateGroupPolicyMetadataResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgUpdateGroupPolicyMetadataResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgUpdateGroupPolicyMetadataResponse { + const obj = createBaseMsgUpdateGroupPolicyMetadataResponse(); + return obj; + }, + toJSON(_: MsgUpdateGroupPolicyMetadataResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): MsgUpdateGroupPolicyMetadataResponse { + const message = createBaseMsgUpdateGroupPolicyMetadataResponse(); + return message; + }, + fromSDK(_: MsgUpdateGroupPolicyMetadataResponseSDKType): MsgUpdateGroupPolicyMetadataResponse { + return {}; + }, + fromSDKJSON(_: any): MsgUpdateGroupPolicyMetadataResponseSDKType { + return {}; + }, + toSDK(_: MsgUpdateGroupPolicyMetadataResponse): MsgUpdateGroupPolicyMetadataResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgUpdateGroupPolicyMetadataResponseAmino): MsgUpdateGroupPolicyMetadataResponse { + const message = createBaseMsgUpdateGroupPolicyMetadataResponse(); + return message; + }, + toAmino(_: MsgUpdateGroupPolicyMetadataResponse): MsgUpdateGroupPolicyMetadataResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgUpdateGroupPolicyMetadataResponseAminoMsg): MsgUpdateGroupPolicyMetadataResponse { + return MsgUpdateGroupPolicyMetadataResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgUpdateGroupPolicyMetadataResponse): MsgUpdateGroupPolicyMetadataResponseAminoMsg { + return { + type: "cosmos-sdk/MsgUpdateGroupPolicyMetadataResponse", + value: MsgUpdateGroupPolicyMetadataResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgUpdateGroupPolicyMetadataResponseProtoMsg): MsgUpdateGroupPolicyMetadataResponse { + return MsgUpdateGroupPolicyMetadataResponse.decode(message.value); + }, + toProto(message: MsgUpdateGroupPolicyMetadataResponse): Uint8Array { + return MsgUpdateGroupPolicyMetadataResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgUpdateGroupPolicyMetadataResponse): MsgUpdateGroupPolicyMetadataResponseProtoMsg { + return { + typeUrl: "/cosmos.group.v1.MsgUpdateGroupPolicyMetadataResponse", + value: MsgUpdateGroupPolicyMetadataResponse.encode(message).finish() + }; + } +}; +function createBaseMsgSubmitProposal(): MsgSubmitProposal { + return { + address: "", + proposers: [], + metadata: "", + messages: [], + exec: 0 + }; +} +export const MsgSubmitProposal = { + typeUrl: "/cosmos.group.v1.MsgSubmitProposal", + encode(message: MsgSubmitProposal, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.address !== undefined) { + writer.uint32(10).string(message.address); + } + for (const v of message.proposers) { + writer.uint32(18).string(v!); + } + if (message.metadata !== undefined) { + writer.uint32(26).string(message.metadata); + } + for (const v of message.messages) { + Any.encode(v!, writer.uint32(34).fork()).ldelim(); + } + if (message.exec !== 0) { + writer.uint32(40).int32(message.exec); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgSubmitProposal { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgSubmitProposal(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.string(); + break; + case 2: + message.proposers.push(reader.string()); + break; + case 3: + message.metadata = reader.string(); + break; + case 4: + message.messages.push(Any.decode(reader, reader.uint32())); + break; + case 5: + message.exec = (reader.int32() as any); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgSubmitProposal { + const obj = createBaseMsgSubmitProposal(); + if (isSet(object.address)) obj.address = String(object.address); + if (Array.isArray(object?.proposers)) obj.proposers = object.proposers.map((e: any) => String(e)); + if (isSet(object.metadata)) obj.metadata = String(object.metadata); + if (Array.isArray(object?.messages)) obj.messages = object.messages.map((e: any) => Any.fromJSON(e)); + if (isSet(object.exec)) obj.exec = execFromJSON(object.exec); + return obj; + }, + toJSON(message: MsgSubmitProposal): JsonSafe { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + if (message.proposers) { + obj.proposers = message.proposers.map(e => e); + } else { + obj.proposers = []; + } + message.metadata !== undefined && (obj.metadata = message.metadata); + if (message.messages) { + obj.messages = message.messages.map(e => e ? Any.toJSON(e) : undefined); + } else { + obj.messages = []; + } + message.exec !== undefined && (obj.exec = execToJSON(message.exec)); + return obj; + }, + fromPartial(object: DeepPartial): MsgSubmitProposal { + const message = createBaseMsgSubmitProposal(); + message.address = object.address ?? ""; + message.proposers = object.proposers?.map(e => e) || []; + message.metadata = object.metadata ?? ""; + message.messages = object.messages?.map(e => Any.fromPartial(e)) || []; + message.exec = object.exec ?? 0; + return message; + }, + fromSDK(object: MsgSubmitProposalSDKType): MsgSubmitProposal { + return { + address: object?.address, + proposers: Array.isArray(object?.proposers) ? object.proposers.map((e: any) => e) : [], + metadata: object?.metadata, + messages: Array.isArray(object?.messages) ? object.messages.map((e: any) => Any.fromSDK(e)) : [], + exec: isSet(object.exec) ? execFromJSON(object.exec) : -1 + }; + }, + fromSDKJSON(object: any): MsgSubmitProposalSDKType { + return { + address: isSet(object.address) ? String(object.address) : "", + proposers: Array.isArray(object?.proposers) ? object.proposers.map((e: any) => String(e)) : [], + metadata: isSet(object.metadata) ? String(object.metadata) : "", + messages: Array.isArray(object?.messages) ? object.messages.map((e: any) => Any.fromSDKJSON(e)) : [], + exec: isSet(object.exec) ? execFromJSON(object.exec) : -1 + }; + }, + toSDK(message: MsgSubmitProposal): MsgSubmitProposalSDKType { + const obj: any = {}; + obj.address = message.address; + if (message.proposers) { + obj.proposers = message.proposers.map(e => e); + } else { + obj.proposers = []; + } + obj.metadata = message.metadata; + if (message.messages) { + obj.messages = message.messages.map(e => e ? Any.toSDK(e) : undefined); + } else { + obj.messages = []; + } + message.exec !== undefined && (obj.exec = execToJSON(message.exec)); + return obj; + }, + fromAmino(object: MsgSubmitProposalAmino): MsgSubmitProposal { + const message = createBaseMsgSubmitProposal(); + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } + message.proposers = object.proposers?.map(e => e) || []; + if (object.metadata !== undefined && object.metadata !== null) { + message.metadata = object.metadata; + } + message.messages = object.messages?.map(e => Any.fromAmino(e)) || []; + if (object.exec !== undefined && object.exec !== null) { + message.exec = object.exec; + } + return message; + }, + toAmino(message: MsgSubmitProposal): MsgSubmitProposalAmino { + const obj: any = {}; + obj.address = message.address === "" ? undefined : message.address; + if (message.proposers) { + obj.proposers = message.proposers.map(e => e); + } else { + obj.proposers = message.proposers; + } + obj.metadata = message.metadata === "" ? undefined : message.metadata; + if (message.messages) { + obj.messages = message.messages.map(e => e ? Any.toAmino(e) : undefined); + } else { + obj.messages = message.messages; + } + obj.exec = message.exec === 0 ? undefined : message.exec; + return obj; + }, + fromAminoMsg(object: MsgSubmitProposalAminoMsg): MsgSubmitProposal { + return MsgSubmitProposal.fromAmino(object.value); + }, + toAminoMsg(message: MsgSubmitProposal): MsgSubmitProposalAminoMsg { + return { + type: "cosmos-sdk/group/MsgSubmitProposal", + value: MsgSubmitProposal.toAmino(message) + }; + }, + fromProtoMsg(message: MsgSubmitProposalProtoMsg): MsgSubmitProposal { + return MsgSubmitProposal.decode(message.value); + }, + toProto(message: MsgSubmitProposal): Uint8Array { + return MsgSubmitProposal.encode(message).finish(); + }, + toProtoMsg(message: MsgSubmitProposal): MsgSubmitProposalProtoMsg { + return { + typeUrl: "/cosmos.group.v1.MsgSubmitProposal", + value: MsgSubmitProposal.encode(message).finish() + }; + } +}; +function createBaseMsgSubmitProposalResponse(): MsgSubmitProposalResponse { + return { + proposalId: BigInt(0) + }; +} +export const MsgSubmitProposalResponse = { + typeUrl: "/cosmos.group.v1.MsgSubmitProposalResponse", + encode(message: MsgSubmitProposalResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.proposalId !== undefined) { + writer.uint32(8).uint64(message.proposalId); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgSubmitProposalResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgSubmitProposalResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.proposalId = reader.uint64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgSubmitProposalResponse { + const obj = createBaseMsgSubmitProposalResponse(); + if (isSet(object.proposalId)) obj.proposalId = BigInt(object.proposalId.toString()); + return obj; + }, + toJSON(message: MsgSubmitProposalResponse): JsonSafe { + const obj: any = {}; + message.proposalId !== undefined && (obj.proposalId = (message.proposalId || BigInt(0)).toString()); + return obj; + }, + fromPartial(object: DeepPartial): MsgSubmitProposalResponse { + const message = createBaseMsgSubmitProposalResponse(); + if (object.proposalId !== undefined && object.proposalId !== null) { + message.proposalId = BigInt(object.proposalId.toString()); + } + return message; + }, + fromSDK(object: MsgSubmitProposalResponseSDKType): MsgSubmitProposalResponse { + return { + proposalId: object?.proposal_id + }; + }, + fromSDKJSON(object: any): MsgSubmitProposalResponseSDKType { + return { + proposal_id: isSet(object.proposal_id) ? BigInt(object.proposal_id.toString()) : BigInt(0) + }; + }, + toSDK(message: MsgSubmitProposalResponse): MsgSubmitProposalResponseSDKType { + const obj: any = {}; + obj.proposal_id = message.proposalId; + return obj; + }, + fromAmino(object: MsgSubmitProposalResponseAmino): MsgSubmitProposalResponse { + const message = createBaseMsgSubmitProposalResponse(); + if (object.proposal_id !== undefined && object.proposal_id !== null) { + message.proposalId = BigInt(object.proposal_id); + } + return message; + }, + toAmino(message: MsgSubmitProposalResponse): MsgSubmitProposalResponseAmino { + const obj: any = {}; + obj.proposal_id = message.proposalId !== BigInt(0) ? message.proposalId?.toString() : undefined; + return obj; + }, + fromAminoMsg(object: MsgSubmitProposalResponseAminoMsg): MsgSubmitProposalResponse { + return MsgSubmitProposalResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgSubmitProposalResponse): MsgSubmitProposalResponseAminoMsg { + return { + type: "cosmos-sdk/MsgSubmitProposalResponse", + value: MsgSubmitProposalResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgSubmitProposalResponseProtoMsg): MsgSubmitProposalResponse { + return MsgSubmitProposalResponse.decode(message.value); + }, + toProto(message: MsgSubmitProposalResponse): Uint8Array { + return MsgSubmitProposalResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgSubmitProposalResponse): MsgSubmitProposalResponseProtoMsg { + return { + typeUrl: "/cosmos.group.v1.MsgSubmitProposalResponse", + value: MsgSubmitProposalResponse.encode(message).finish() + }; + } +}; +function createBaseMsgWithdrawProposal(): MsgWithdrawProposal { + return { + proposalId: BigInt(0), + address: "" + }; +} +export const MsgWithdrawProposal = { + typeUrl: "/cosmos.group.v1.MsgWithdrawProposal", + encode(message: MsgWithdrawProposal, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.proposalId !== undefined) { + writer.uint32(8).uint64(message.proposalId); + } + if (message.address !== undefined) { + writer.uint32(18).string(message.address); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgWithdrawProposal { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgWithdrawProposal(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.proposalId = reader.uint64(); + break; + case 2: + message.address = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgWithdrawProposal { + const obj = createBaseMsgWithdrawProposal(); + if (isSet(object.proposalId)) obj.proposalId = BigInt(object.proposalId.toString()); + if (isSet(object.address)) obj.address = String(object.address); + return obj; + }, + toJSON(message: MsgWithdrawProposal): JsonSafe { + const obj: any = {}; + message.proposalId !== undefined && (obj.proposalId = (message.proposalId || BigInt(0)).toString()); + message.address !== undefined && (obj.address = message.address); + return obj; + }, + fromPartial(object: DeepPartial): MsgWithdrawProposal { + const message = createBaseMsgWithdrawProposal(); + if (object.proposalId !== undefined && object.proposalId !== null) { + message.proposalId = BigInt(object.proposalId.toString()); + } + message.address = object.address ?? ""; + return message; + }, + fromSDK(object: MsgWithdrawProposalSDKType): MsgWithdrawProposal { + return { + proposalId: object?.proposal_id, + address: object?.address + }; + }, + fromSDKJSON(object: any): MsgWithdrawProposalSDKType { + return { + proposal_id: isSet(object.proposal_id) ? BigInt(object.proposal_id.toString()) : BigInt(0), + address: isSet(object.address) ? String(object.address) : "" + }; + }, + toSDK(message: MsgWithdrawProposal): MsgWithdrawProposalSDKType { + const obj: any = {}; + obj.proposal_id = message.proposalId; + obj.address = message.address; + return obj; + }, + fromAmino(object: MsgWithdrawProposalAmino): MsgWithdrawProposal { + const message = createBaseMsgWithdrawProposal(); + if (object.proposal_id !== undefined && object.proposal_id !== null) { + message.proposalId = BigInt(object.proposal_id); + } + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } + return message; + }, + toAmino(message: MsgWithdrawProposal): MsgWithdrawProposalAmino { + const obj: any = {}; + obj.proposal_id = message.proposalId !== BigInt(0) ? message.proposalId?.toString() : undefined; + obj.address = message.address === "" ? undefined : message.address; + return obj; + }, + fromAminoMsg(object: MsgWithdrawProposalAminoMsg): MsgWithdrawProposal { + return MsgWithdrawProposal.fromAmino(object.value); + }, + toAminoMsg(message: MsgWithdrawProposal): MsgWithdrawProposalAminoMsg { + return { + type: "cosmos-sdk/group/MsgWithdrawProposal", + value: MsgWithdrawProposal.toAmino(message) + }; + }, + fromProtoMsg(message: MsgWithdrawProposalProtoMsg): MsgWithdrawProposal { + return MsgWithdrawProposal.decode(message.value); + }, + toProto(message: MsgWithdrawProposal): Uint8Array { + return MsgWithdrawProposal.encode(message).finish(); + }, + toProtoMsg(message: MsgWithdrawProposal): MsgWithdrawProposalProtoMsg { + return { + typeUrl: "/cosmos.group.v1.MsgWithdrawProposal", + value: MsgWithdrawProposal.encode(message).finish() + }; + } +}; +function createBaseMsgWithdrawProposalResponse(): MsgWithdrawProposalResponse { + return {}; +} +export const MsgWithdrawProposalResponse = { + typeUrl: "/cosmos.group.v1.MsgWithdrawProposalResponse", + encode(_: MsgWithdrawProposalResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgWithdrawProposalResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgWithdrawProposalResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgWithdrawProposalResponse { + const obj = createBaseMsgWithdrawProposalResponse(); + return obj; + }, + toJSON(_: MsgWithdrawProposalResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): MsgWithdrawProposalResponse { + const message = createBaseMsgWithdrawProposalResponse(); + return message; + }, + fromSDK(_: MsgWithdrawProposalResponseSDKType): MsgWithdrawProposalResponse { + return {}; + }, + fromSDKJSON(_: any): MsgWithdrawProposalResponseSDKType { + return {}; + }, + toSDK(_: MsgWithdrawProposalResponse): MsgWithdrawProposalResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgWithdrawProposalResponseAmino): MsgWithdrawProposalResponse { + const message = createBaseMsgWithdrawProposalResponse(); + return message; + }, + toAmino(_: MsgWithdrawProposalResponse): MsgWithdrawProposalResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgWithdrawProposalResponseAminoMsg): MsgWithdrawProposalResponse { + return MsgWithdrawProposalResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgWithdrawProposalResponse): MsgWithdrawProposalResponseAminoMsg { + return { + type: "cosmos-sdk/MsgWithdrawProposalResponse", + value: MsgWithdrawProposalResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgWithdrawProposalResponseProtoMsg): MsgWithdrawProposalResponse { + return MsgWithdrawProposalResponse.decode(message.value); + }, + toProto(message: MsgWithdrawProposalResponse): Uint8Array { + return MsgWithdrawProposalResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgWithdrawProposalResponse): MsgWithdrawProposalResponseProtoMsg { + return { + typeUrl: "/cosmos.group.v1.MsgWithdrawProposalResponse", + value: MsgWithdrawProposalResponse.encode(message).finish() + }; + } +}; +function createBaseMsgVote(): MsgVote { + return { + proposalId: BigInt(0), + voter: "", + option: 0, + metadata: "", + exec: 0 + }; +} +export const MsgVote = { + typeUrl: "/cosmos.group.v1.MsgVote", + encode(message: MsgVote, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.proposalId !== undefined) { + writer.uint32(8).uint64(message.proposalId); + } + if (message.voter !== undefined) { + writer.uint32(18).string(message.voter); + } + if (message.option !== 0) { + writer.uint32(24).int32(message.option); + } + if (message.metadata !== undefined) { + writer.uint32(34).string(message.metadata); + } + if (message.exec !== 0) { + writer.uint32(40).int32(message.exec); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgVote { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgVote(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.proposalId = reader.uint64(); + break; + case 2: + message.voter = reader.string(); + break; + case 3: + message.option = (reader.int32() as any); + break; + case 4: + message.metadata = reader.string(); + break; + case 5: + message.exec = (reader.int32() as any); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgVote { + const obj = createBaseMsgVote(); + if (isSet(object.proposalId)) obj.proposalId = BigInt(object.proposalId.toString()); + if (isSet(object.voter)) obj.voter = String(object.voter); + if (isSet(object.option)) obj.option = voteOptionFromJSON(object.option); + if (isSet(object.metadata)) obj.metadata = String(object.metadata); + if (isSet(object.exec)) obj.exec = execFromJSON(object.exec); + return obj; + }, + toJSON(message: MsgVote): JsonSafe { + const obj: any = {}; + message.proposalId !== undefined && (obj.proposalId = (message.proposalId || BigInt(0)).toString()); + message.voter !== undefined && (obj.voter = message.voter); + message.option !== undefined && (obj.option = voteOptionToJSON(message.option)); + message.metadata !== undefined && (obj.metadata = message.metadata); + message.exec !== undefined && (obj.exec = execToJSON(message.exec)); + return obj; + }, + fromPartial(object: DeepPartial): MsgVote { + const message = createBaseMsgVote(); + if (object.proposalId !== undefined && object.proposalId !== null) { + message.proposalId = BigInt(object.proposalId.toString()); + } + message.voter = object.voter ?? ""; + message.option = object.option ?? 0; + message.metadata = object.metadata ?? ""; + message.exec = object.exec ?? 0; + return message; + }, + fromSDK(object: MsgVoteSDKType): MsgVote { + return { + proposalId: object?.proposal_id, + voter: object?.voter, + option: isSet(object.option) ? voteOptionFromJSON(object.option) : -1, + metadata: object?.metadata, + exec: isSet(object.exec) ? execFromJSON(object.exec) : -1 + }; + }, + fromSDKJSON(object: any): MsgVoteSDKType { + return { + proposal_id: isSet(object.proposal_id) ? BigInt(object.proposal_id.toString()) : BigInt(0), + voter: isSet(object.voter) ? String(object.voter) : "", + option: isSet(object.option) ? voteOptionFromJSON(object.option) : -1, + metadata: isSet(object.metadata) ? String(object.metadata) : "", + exec: isSet(object.exec) ? execFromJSON(object.exec) : -1 + }; + }, + toSDK(message: MsgVote): MsgVoteSDKType { + const obj: any = {}; + obj.proposal_id = message.proposalId; + obj.voter = message.voter; + message.option !== undefined && (obj.option = voteOptionToJSON(message.option)); + obj.metadata = message.metadata; + message.exec !== undefined && (obj.exec = execToJSON(message.exec)); + return obj; + }, + fromAmino(object: MsgVoteAmino): MsgVote { + const message = createBaseMsgVote(); + if (object.proposal_id !== undefined && object.proposal_id !== null) { + message.proposalId = BigInt(object.proposal_id); + } + if (object.voter !== undefined && object.voter !== null) { + message.voter = object.voter; + } + if (object.option !== undefined && object.option !== null) { + message.option = object.option; + } + if (object.metadata !== undefined && object.metadata !== null) { + message.metadata = object.metadata; + } + if (object.exec !== undefined && object.exec !== null) { + message.exec = object.exec; + } + return message; + }, + toAmino(message: MsgVote): MsgVoteAmino { + const obj: any = {}; + obj.proposal_id = message.proposalId !== BigInt(0) ? message.proposalId?.toString() : undefined; + obj.voter = message.voter === "" ? undefined : message.voter; + obj.option = message.option === 0 ? undefined : message.option; + obj.metadata = message.metadata === "" ? undefined : message.metadata; + obj.exec = message.exec === 0 ? undefined : message.exec; + return obj; + }, + fromAminoMsg(object: MsgVoteAminoMsg): MsgVote { + return MsgVote.fromAmino(object.value); + }, + toAminoMsg(message: MsgVote): MsgVoteAminoMsg { + return { + type: "cosmos-sdk/group/MsgVote", + value: MsgVote.toAmino(message) + }; + }, + fromProtoMsg(message: MsgVoteProtoMsg): MsgVote { + return MsgVote.decode(message.value); + }, + toProto(message: MsgVote): Uint8Array { + return MsgVote.encode(message).finish(); + }, + toProtoMsg(message: MsgVote): MsgVoteProtoMsg { + return { + typeUrl: "/cosmos.group.v1.MsgVote", + value: MsgVote.encode(message).finish() + }; + } +}; +function createBaseMsgVoteResponse(): MsgVoteResponse { + return {}; +} +export const MsgVoteResponse = { + typeUrl: "/cosmos.group.v1.MsgVoteResponse", + encode(_: MsgVoteResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgVoteResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgVoteResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgVoteResponse { + const obj = createBaseMsgVoteResponse(); + return obj; + }, + toJSON(_: MsgVoteResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): MsgVoteResponse { + const message = createBaseMsgVoteResponse(); + return message; + }, + fromSDK(_: MsgVoteResponseSDKType): MsgVoteResponse { + return {}; + }, + fromSDKJSON(_: any): MsgVoteResponseSDKType { + return {}; + }, + toSDK(_: MsgVoteResponse): MsgVoteResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgVoteResponseAmino): MsgVoteResponse { + const message = createBaseMsgVoteResponse(); + return message; + }, + toAmino(_: MsgVoteResponse): MsgVoteResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgVoteResponseAminoMsg): MsgVoteResponse { + return MsgVoteResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgVoteResponse): MsgVoteResponseAminoMsg { + return { + type: "cosmos-sdk/MsgVoteResponse", + value: MsgVoteResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgVoteResponseProtoMsg): MsgVoteResponse { + return MsgVoteResponse.decode(message.value); + }, + toProto(message: MsgVoteResponse): Uint8Array { + return MsgVoteResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgVoteResponse): MsgVoteResponseProtoMsg { + return { + typeUrl: "/cosmos.group.v1.MsgVoteResponse", + value: MsgVoteResponse.encode(message).finish() + }; + } +}; +function createBaseMsgExec(): MsgExec { + return { + proposalId: BigInt(0), + signer: "" + }; +} +export const MsgExec = { + typeUrl: "/cosmos.group.v1.MsgExec", + encode(message: MsgExec, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.proposalId !== undefined) { + writer.uint32(8).uint64(message.proposalId); + } + if (message.signer !== undefined) { + writer.uint32(18).string(message.signer); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgExec { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgExec(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.proposalId = reader.uint64(); + break; + case 2: + message.signer = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgExec { + const obj = createBaseMsgExec(); + if (isSet(object.proposalId)) obj.proposalId = BigInt(object.proposalId.toString()); + if (isSet(object.signer)) obj.signer = String(object.signer); + return obj; + }, + toJSON(message: MsgExec): JsonSafe { + const obj: any = {}; + message.proposalId !== undefined && (obj.proposalId = (message.proposalId || BigInt(0)).toString()); + message.signer !== undefined && (obj.signer = message.signer); + return obj; + }, + fromPartial(object: DeepPartial): MsgExec { + const message = createBaseMsgExec(); + if (object.proposalId !== undefined && object.proposalId !== null) { + message.proposalId = BigInt(object.proposalId.toString()); + } + message.signer = object.signer ?? ""; + return message; + }, + fromSDK(object: MsgExecSDKType): MsgExec { + return { + proposalId: object?.proposal_id, + signer: object?.signer + }; + }, + fromSDKJSON(object: any): MsgExecSDKType { + return { + proposal_id: isSet(object.proposal_id) ? BigInt(object.proposal_id.toString()) : BigInt(0), + signer: isSet(object.signer) ? String(object.signer) : "" + }; + }, + toSDK(message: MsgExec): MsgExecSDKType { + const obj: any = {}; + obj.proposal_id = message.proposalId; + obj.signer = message.signer; + return obj; + }, + fromAmino(object: MsgExecAmino): MsgExec { + const message = createBaseMsgExec(); + if (object.proposal_id !== undefined && object.proposal_id !== null) { + message.proposalId = BigInt(object.proposal_id); + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = object.signer; + } + return message; + }, + toAmino(message: MsgExec): MsgExecAmino { + const obj: any = {}; + obj.proposal_id = message.proposalId !== BigInt(0) ? message.proposalId?.toString() : undefined; + obj.signer = message.signer === "" ? undefined : message.signer; + return obj; + }, + fromAminoMsg(object: MsgExecAminoMsg): MsgExec { + return MsgExec.fromAmino(object.value); + }, + toAminoMsg(message: MsgExec): MsgExecAminoMsg { + return { + type: "cosmos-sdk/group/MsgExec", + value: MsgExec.toAmino(message) + }; + }, + fromProtoMsg(message: MsgExecProtoMsg): MsgExec { + return MsgExec.decode(message.value); + }, + toProto(message: MsgExec): Uint8Array { + return MsgExec.encode(message).finish(); + }, + toProtoMsg(message: MsgExec): MsgExecProtoMsg { + return { + typeUrl: "/cosmos.group.v1.MsgExec", + value: MsgExec.encode(message).finish() + }; + } +}; +function createBaseMsgExecResponse(): MsgExecResponse { + return {}; +} +export const MsgExecResponse = { + typeUrl: "/cosmos.group.v1.MsgExecResponse", + encode(_: MsgExecResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgExecResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgExecResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgExecResponse { + const obj = createBaseMsgExecResponse(); + return obj; + }, + toJSON(_: MsgExecResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): MsgExecResponse { + const message = createBaseMsgExecResponse(); + return message; + }, + fromSDK(_: MsgExecResponseSDKType): MsgExecResponse { + return {}; + }, + fromSDKJSON(_: any): MsgExecResponseSDKType { + return {}; + }, + toSDK(_: MsgExecResponse): MsgExecResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgExecResponseAmino): MsgExecResponse { + const message = createBaseMsgExecResponse(); + return message; + }, + toAmino(_: MsgExecResponse): MsgExecResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgExecResponseAminoMsg): MsgExecResponse { + return MsgExecResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgExecResponse): MsgExecResponseAminoMsg { + return { + type: "cosmos-sdk/MsgExecResponse", + value: MsgExecResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgExecResponseProtoMsg): MsgExecResponse { + return MsgExecResponse.decode(message.value); + }, + toProto(message: MsgExecResponse): Uint8Array { + return MsgExecResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgExecResponse): MsgExecResponseProtoMsg { + return { + typeUrl: "/cosmos.group.v1.MsgExecResponse", + value: MsgExecResponse.encode(message).finish() + }; + } +}; +function createBaseMsgLeaveGroup(): MsgLeaveGroup { + return { + address: "", + groupId: BigInt(0) + }; +} +export const MsgLeaveGroup = { + typeUrl: "/cosmos.group.v1.MsgLeaveGroup", + encode(message: MsgLeaveGroup, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.address !== undefined) { + writer.uint32(10).string(message.address); + } + if (message.groupId !== undefined) { + writer.uint32(16).uint64(message.groupId); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgLeaveGroup { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgLeaveGroup(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.string(); + break; + case 2: + message.groupId = reader.uint64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgLeaveGroup { + const obj = createBaseMsgLeaveGroup(); + if (isSet(object.address)) obj.address = String(object.address); + if (isSet(object.groupId)) obj.groupId = BigInt(object.groupId.toString()); + return obj; + }, + toJSON(message: MsgLeaveGroup): JsonSafe { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + message.groupId !== undefined && (obj.groupId = (message.groupId || BigInt(0)).toString()); + return obj; + }, + fromPartial(object: DeepPartial): MsgLeaveGroup { + const message = createBaseMsgLeaveGroup(); + message.address = object.address ?? ""; + if (object.groupId !== undefined && object.groupId !== null) { + message.groupId = BigInt(object.groupId.toString()); + } + return message; + }, + fromSDK(object: MsgLeaveGroupSDKType): MsgLeaveGroup { + return { + address: object?.address, + groupId: object?.group_id + }; + }, + fromSDKJSON(object: any): MsgLeaveGroupSDKType { + return { + address: isSet(object.address) ? String(object.address) : "", + group_id: isSet(object.group_id) ? BigInt(object.group_id.toString()) : BigInt(0) + }; + }, + toSDK(message: MsgLeaveGroup): MsgLeaveGroupSDKType { + const obj: any = {}; + obj.address = message.address; + obj.group_id = message.groupId; + return obj; + }, + fromAmino(object: MsgLeaveGroupAmino): MsgLeaveGroup { + const message = createBaseMsgLeaveGroup(); + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } + if (object.group_id !== undefined && object.group_id !== null) { + message.groupId = BigInt(object.group_id); + } + return message; + }, + toAmino(message: MsgLeaveGroup): MsgLeaveGroupAmino { + const obj: any = {}; + obj.address = message.address === "" ? undefined : message.address; + obj.group_id = message.groupId !== BigInt(0) ? message.groupId?.toString() : undefined; + return obj; + }, + fromAminoMsg(object: MsgLeaveGroupAminoMsg): MsgLeaveGroup { + return MsgLeaveGroup.fromAmino(object.value); + }, + toAminoMsg(message: MsgLeaveGroup): MsgLeaveGroupAminoMsg { + return { + type: "cosmos-sdk/group/MsgLeaveGroup", + value: MsgLeaveGroup.toAmino(message) + }; + }, + fromProtoMsg(message: MsgLeaveGroupProtoMsg): MsgLeaveGroup { + return MsgLeaveGroup.decode(message.value); + }, + toProto(message: MsgLeaveGroup): Uint8Array { + return MsgLeaveGroup.encode(message).finish(); + }, + toProtoMsg(message: MsgLeaveGroup): MsgLeaveGroupProtoMsg { + return { + typeUrl: "/cosmos.group.v1.MsgLeaveGroup", + value: MsgLeaveGroup.encode(message).finish() + }; + } +}; +function createBaseMsgLeaveGroupResponse(): MsgLeaveGroupResponse { + return {}; +} +export const MsgLeaveGroupResponse = { + typeUrl: "/cosmos.group.v1.MsgLeaveGroupResponse", + encode(_: MsgLeaveGroupResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgLeaveGroupResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgLeaveGroupResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgLeaveGroupResponse { + const obj = createBaseMsgLeaveGroupResponse(); + return obj; + }, + toJSON(_: MsgLeaveGroupResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): MsgLeaveGroupResponse { + const message = createBaseMsgLeaveGroupResponse(); + return message; + }, + fromSDK(_: MsgLeaveGroupResponseSDKType): MsgLeaveGroupResponse { + return {}; + }, + fromSDKJSON(_: any): MsgLeaveGroupResponseSDKType { + return {}; + }, + toSDK(_: MsgLeaveGroupResponse): MsgLeaveGroupResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgLeaveGroupResponseAmino): MsgLeaveGroupResponse { + const message = createBaseMsgLeaveGroupResponse(); + return message; + }, + toAmino(_: MsgLeaveGroupResponse): MsgLeaveGroupResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgLeaveGroupResponseAminoMsg): MsgLeaveGroupResponse { + return MsgLeaveGroupResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgLeaveGroupResponse): MsgLeaveGroupResponseAminoMsg { + return { + type: "cosmos-sdk/MsgLeaveGroupResponse", + value: MsgLeaveGroupResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgLeaveGroupResponseProtoMsg): MsgLeaveGroupResponse { + return MsgLeaveGroupResponse.decode(message.value); + }, + toProto(message: MsgLeaveGroupResponse): Uint8Array { + return MsgLeaveGroupResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgLeaveGroupResponse): MsgLeaveGroupResponseProtoMsg { + return { + typeUrl: "/cosmos.group.v1.MsgLeaveGroupResponse", + value: MsgLeaveGroupResponse.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/group/v1/types.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/group/v1/types.ts new file mode 100644 index 0000000000..c4caae9c4f --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/group/v1/types.ts @@ -0,0 +1,2254 @@ +import { Timestamp, TimestampSDKType } from "../../../google/protobuf/timestamp.js"; +import { Duration, DurationSDKType } from "../../../google/protobuf/duration.js"; +import { Any, AnySDKType } from "../../../google/protobuf/any.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { toTimestamp, fromTimestamp, isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "cosmos.group.v1"; +/** VoteOption enumerates the valid vote options for a given proposal. */ +export enum VoteOption { + /** VOTE_OPTION_UNSPECIFIED - VOTE_OPTION_UNSPECIFIED defines a no-op vote option. */ + VOTE_OPTION_UNSPECIFIED = 0, + /** VOTE_OPTION_YES - VOTE_OPTION_YES defines a yes vote option. */ + VOTE_OPTION_YES = 1, + /** VOTE_OPTION_ABSTAIN - VOTE_OPTION_ABSTAIN defines an abstain vote option. */ + VOTE_OPTION_ABSTAIN = 2, + /** VOTE_OPTION_NO - VOTE_OPTION_NO defines a no vote option. */ + VOTE_OPTION_NO = 3, + /** VOTE_OPTION_NO_WITH_VETO - VOTE_OPTION_NO_WITH_VETO defines a no with veto vote option. */ + VOTE_OPTION_NO_WITH_VETO = 4, + UNRECOGNIZED = -1, +} +export const VoteOptionSDKType = VoteOption; +export function voteOptionFromJSON(object: any): VoteOption { + switch (object) { + case 0: + case "VOTE_OPTION_UNSPECIFIED": + return VoteOption.VOTE_OPTION_UNSPECIFIED; + case 1: + case "VOTE_OPTION_YES": + return VoteOption.VOTE_OPTION_YES; + case 2: + case "VOTE_OPTION_ABSTAIN": + return VoteOption.VOTE_OPTION_ABSTAIN; + case 3: + case "VOTE_OPTION_NO": + return VoteOption.VOTE_OPTION_NO; + case 4: + case "VOTE_OPTION_NO_WITH_VETO": + return VoteOption.VOTE_OPTION_NO_WITH_VETO; + case -1: + case "UNRECOGNIZED": + default: + return VoteOption.UNRECOGNIZED; + } +} +export function voteOptionToJSON(object: VoteOption): string { + switch (object) { + case VoteOption.VOTE_OPTION_UNSPECIFIED: + return "VOTE_OPTION_UNSPECIFIED"; + case VoteOption.VOTE_OPTION_YES: + return "VOTE_OPTION_YES"; + case VoteOption.VOTE_OPTION_ABSTAIN: + return "VOTE_OPTION_ABSTAIN"; + case VoteOption.VOTE_OPTION_NO: + return "VOTE_OPTION_NO"; + case VoteOption.VOTE_OPTION_NO_WITH_VETO: + return "VOTE_OPTION_NO_WITH_VETO"; + case VoteOption.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** ProposalStatus defines proposal statuses. */ +export enum ProposalStatus { + /** PROPOSAL_STATUS_UNSPECIFIED - An empty value is invalid and not allowed. */ + PROPOSAL_STATUS_UNSPECIFIED = 0, + /** PROPOSAL_STATUS_SUBMITTED - Initial status of a proposal when persisted. */ + PROPOSAL_STATUS_SUBMITTED = 1, + /** PROPOSAL_STATUS_CLOSED - Final status of a proposal when the final tally was executed. */ + PROPOSAL_STATUS_CLOSED = 2, + /** PROPOSAL_STATUS_ABORTED - Final status of a proposal when the group was modified before the final tally. */ + PROPOSAL_STATUS_ABORTED = 3, + /** + * PROPOSAL_STATUS_WITHDRAWN - A proposal can be deleted before the voting start time by the owner. When this happens the final status + * is Withdrawn. + */ + PROPOSAL_STATUS_WITHDRAWN = 4, + UNRECOGNIZED = -1, +} +export const ProposalStatusSDKType = ProposalStatus; +export function proposalStatusFromJSON(object: any): ProposalStatus { + switch (object) { + case 0: + case "PROPOSAL_STATUS_UNSPECIFIED": + return ProposalStatus.PROPOSAL_STATUS_UNSPECIFIED; + case 1: + case "PROPOSAL_STATUS_SUBMITTED": + return ProposalStatus.PROPOSAL_STATUS_SUBMITTED; + case 2: + case "PROPOSAL_STATUS_CLOSED": + return ProposalStatus.PROPOSAL_STATUS_CLOSED; + case 3: + case "PROPOSAL_STATUS_ABORTED": + return ProposalStatus.PROPOSAL_STATUS_ABORTED; + case 4: + case "PROPOSAL_STATUS_WITHDRAWN": + return ProposalStatus.PROPOSAL_STATUS_WITHDRAWN; + case -1: + case "UNRECOGNIZED": + default: + return ProposalStatus.UNRECOGNIZED; + } +} +export function proposalStatusToJSON(object: ProposalStatus): string { + switch (object) { + case ProposalStatus.PROPOSAL_STATUS_UNSPECIFIED: + return "PROPOSAL_STATUS_UNSPECIFIED"; + case ProposalStatus.PROPOSAL_STATUS_SUBMITTED: + return "PROPOSAL_STATUS_SUBMITTED"; + case ProposalStatus.PROPOSAL_STATUS_CLOSED: + return "PROPOSAL_STATUS_CLOSED"; + case ProposalStatus.PROPOSAL_STATUS_ABORTED: + return "PROPOSAL_STATUS_ABORTED"; + case ProposalStatus.PROPOSAL_STATUS_WITHDRAWN: + return "PROPOSAL_STATUS_WITHDRAWN"; + case ProposalStatus.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** ProposalResult defines types of proposal results. */ +export enum ProposalResult { + /** PROPOSAL_RESULT_UNSPECIFIED - An empty value is invalid and not allowed */ + PROPOSAL_RESULT_UNSPECIFIED = 0, + /** PROPOSAL_RESULT_UNFINALIZED - Until a final tally has happened the status is unfinalized */ + PROPOSAL_RESULT_UNFINALIZED = 1, + /** PROPOSAL_RESULT_ACCEPTED - Final result of the tally */ + PROPOSAL_RESULT_ACCEPTED = 2, + /** PROPOSAL_RESULT_REJECTED - Final result of the tally */ + PROPOSAL_RESULT_REJECTED = 3, + UNRECOGNIZED = -1, +} +export const ProposalResultSDKType = ProposalResult; +export function proposalResultFromJSON(object: any): ProposalResult { + switch (object) { + case 0: + case "PROPOSAL_RESULT_UNSPECIFIED": + return ProposalResult.PROPOSAL_RESULT_UNSPECIFIED; + case 1: + case "PROPOSAL_RESULT_UNFINALIZED": + return ProposalResult.PROPOSAL_RESULT_UNFINALIZED; + case 2: + case "PROPOSAL_RESULT_ACCEPTED": + return ProposalResult.PROPOSAL_RESULT_ACCEPTED; + case 3: + case "PROPOSAL_RESULT_REJECTED": + return ProposalResult.PROPOSAL_RESULT_REJECTED; + case -1: + case "UNRECOGNIZED": + default: + return ProposalResult.UNRECOGNIZED; + } +} +export function proposalResultToJSON(object: ProposalResult): string { + switch (object) { + case ProposalResult.PROPOSAL_RESULT_UNSPECIFIED: + return "PROPOSAL_RESULT_UNSPECIFIED"; + case ProposalResult.PROPOSAL_RESULT_UNFINALIZED: + return "PROPOSAL_RESULT_UNFINALIZED"; + case ProposalResult.PROPOSAL_RESULT_ACCEPTED: + return "PROPOSAL_RESULT_ACCEPTED"; + case ProposalResult.PROPOSAL_RESULT_REJECTED: + return "PROPOSAL_RESULT_REJECTED"; + case ProposalResult.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** ProposalExecutorResult defines types of proposal executor results. */ +export enum ProposalExecutorResult { + /** PROPOSAL_EXECUTOR_RESULT_UNSPECIFIED - An empty value is not allowed. */ + PROPOSAL_EXECUTOR_RESULT_UNSPECIFIED = 0, + /** PROPOSAL_EXECUTOR_RESULT_NOT_RUN - We have not yet run the executor. */ + PROPOSAL_EXECUTOR_RESULT_NOT_RUN = 1, + /** PROPOSAL_EXECUTOR_RESULT_SUCCESS - The executor was successful and proposed action updated state. */ + PROPOSAL_EXECUTOR_RESULT_SUCCESS = 2, + /** PROPOSAL_EXECUTOR_RESULT_FAILURE - The executor returned an error and proposed action didn't update state. */ + PROPOSAL_EXECUTOR_RESULT_FAILURE = 3, + UNRECOGNIZED = -1, +} +export const ProposalExecutorResultSDKType = ProposalExecutorResult; +export function proposalExecutorResultFromJSON(object: any): ProposalExecutorResult { + switch (object) { + case 0: + case "PROPOSAL_EXECUTOR_RESULT_UNSPECIFIED": + return ProposalExecutorResult.PROPOSAL_EXECUTOR_RESULT_UNSPECIFIED; + case 1: + case "PROPOSAL_EXECUTOR_RESULT_NOT_RUN": + return ProposalExecutorResult.PROPOSAL_EXECUTOR_RESULT_NOT_RUN; + case 2: + case "PROPOSAL_EXECUTOR_RESULT_SUCCESS": + return ProposalExecutorResult.PROPOSAL_EXECUTOR_RESULT_SUCCESS; + case 3: + case "PROPOSAL_EXECUTOR_RESULT_FAILURE": + return ProposalExecutorResult.PROPOSAL_EXECUTOR_RESULT_FAILURE; + case -1: + case "UNRECOGNIZED": + default: + return ProposalExecutorResult.UNRECOGNIZED; + } +} +export function proposalExecutorResultToJSON(object: ProposalExecutorResult): string { + switch (object) { + case ProposalExecutorResult.PROPOSAL_EXECUTOR_RESULT_UNSPECIFIED: + return "PROPOSAL_EXECUTOR_RESULT_UNSPECIFIED"; + case ProposalExecutorResult.PROPOSAL_EXECUTOR_RESULT_NOT_RUN: + return "PROPOSAL_EXECUTOR_RESULT_NOT_RUN"; + case ProposalExecutorResult.PROPOSAL_EXECUTOR_RESULT_SUCCESS: + return "PROPOSAL_EXECUTOR_RESULT_SUCCESS"; + case ProposalExecutorResult.PROPOSAL_EXECUTOR_RESULT_FAILURE: + return "PROPOSAL_EXECUTOR_RESULT_FAILURE"; + case ProposalExecutorResult.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** + * Member represents a group member with an account address, + * non-zero weight and metadata. + */ +export interface Member { + /** address is the member's account address. */ + address: string; + /** weight is the member's voting weight that should be greater than 0. */ + weight: string; + /** metadata is any arbitrary metadata to attached to the member. */ + metadata: string; + /** added_at is a timestamp specifying when a member was added. */ + addedAt: Date; +} +export interface MemberProtoMsg { + typeUrl: "/cosmos.group.v1.Member"; + value: Uint8Array; +} +/** + * Member represents a group member with an account address, + * non-zero weight and metadata. + */ +export interface MemberSDKType { + address: string; + weight: string; + metadata: string; + added_at: Date; +} +/** Members defines a repeated slice of Member objects. */ +export interface Members { + /** members is the list of members. */ + members: Member[]; +} +export interface MembersProtoMsg { + typeUrl: "/cosmos.group.v1.Members"; + value: Uint8Array; +} +/** Members defines a repeated slice of Member objects. */ +export interface MembersSDKType { + members: MemberSDKType[]; +} +/** ThresholdDecisionPolicy implements the DecisionPolicy interface */ +export interface ThresholdDecisionPolicy { + /** threshold is the minimum weighted sum of yes votes that must be met or exceeded for a proposal to succeed. */ + threshold: string; + /** windows defines the different windows for voting and execution. */ + windows?: DecisionPolicyWindows; +} +export interface ThresholdDecisionPolicyProtoMsg { + typeUrl: "/cosmos.group.v1.ThresholdDecisionPolicy"; + value: Uint8Array; +} +/** ThresholdDecisionPolicy implements the DecisionPolicy interface */ +export interface ThresholdDecisionPolicySDKType { + threshold: string; + windows?: DecisionPolicyWindowsSDKType; +} +/** PercentageDecisionPolicy implements the DecisionPolicy interface */ +export interface PercentageDecisionPolicy { + /** percentage is the minimum percentage the weighted sum of yes votes must meet for a proposal to succeed. */ + percentage: string; + /** windows defines the different windows for voting and execution. */ + windows?: DecisionPolicyWindows; +} +export interface PercentageDecisionPolicyProtoMsg { + typeUrl: "/cosmos.group.v1.PercentageDecisionPolicy"; + value: Uint8Array; +} +/** PercentageDecisionPolicy implements the DecisionPolicy interface */ +export interface PercentageDecisionPolicySDKType { + percentage: string; + windows?: DecisionPolicyWindowsSDKType; +} +/** DecisionPolicyWindows defines the different windows for voting and execution. */ +export interface DecisionPolicyWindows { + /** + * voting_period is the duration from submission of a proposal to the end of voting period + * Within this times votes can be submitted with MsgVote. + */ + votingPeriod: Duration; + /** + * min_execution_period is the minimum duration after the proposal submission + * where members can start sending MsgExec. This means that the window for + * sending a MsgExec transaction is: + * `[ submission + min_execution_period ; submission + voting_period + max_execution_period]` + * where max_execution_period is a app-specific config, defined in the keeper. + * If not set, min_execution_period will default to 0. + * + * Please make sure to set a `min_execution_period` that is smaller than + * `voting_period + max_execution_period`, or else the above execution window + * is empty, meaning that all proposals created with this decision policy + * won't be able to be executed. + */ + minExecutionPeriod: Duration; +} +export interface DecisionPolicyWindowsProtoMsg { + typeUrl: "/cosmos.group.v1.DecisionPolicyWindows"; + value: Uint8Array; +} +/** DecisionPolicyWindows defines the different windows for voting and execution. */ +export interface DecisionPolicyWindowsSDKType { + voting_period: DurationSDKType; + min_execution_period: DurationSDKType; +} +/** GroupInfo represents the high-level on-chain information for a group. */ +export interface GroupInfo { + /** id is the unique ID of the group. */ + id: bigint; + /** admin is the account address of the group's admin. */ + admin: string; + /** metadata is any arbitrary metadata to attached to the group. */ + metadata: string; + /** + * version is used to track changes to a group's membership structure that + * would break existing proposals. Whenever any members weight is changed, + * or any member is added or removed this version is incremented and will + * cause proposals based on older versions of this group to fail + */ + version: bigint; + /** total_weight is the sum of the group members' weights. */ + totalWeight: string; + /** created_at is a timestamp specifying when a group was created. */ + createdAt: Date; +} +export interface GroupInfoProtoMsg { + typeUrl: "/cosmos.group.v1.GroupInfo"; + value: Uint8Array; +} +/** GroupInfo represents the high-level on-chain information for a group. */ +export interface GroupInfoSDKType { + id: bigint; + admin: string; + metadata: string; + version: bigint; + total_weight: string; + created_at: Date; +} +/** GroupMember represents the relationship between a group and a member. */ +export interface GroupMember { + /** group_id is the unique ID of the group. */ + groupId: bigint; + /** member is the member data. */ + member?: Member; +} +export interface GroupMemberProtoMsg { + typeUrl: "/cosmos.group.v1.GroupMember"; + value: Uint8Array; +} +/** GroupMember represents the relationship between a group and a member. */ +export interface GroupMemberSDKType { + group_id: bigint; + member?: MemberSDKType; +} +/** GroupPolicyInfo represents the high-level on-chain information for a group policy. */ +export interface GroupPolicyInfo { + /** address is the account address of group policy. */ + address: string; + /** group_id is the unique ID of the group. */ + groupId: bigint; + /** admin is the account address of the group admin. */ + admin: string; + /** metadata is any arbitrary metadata to attached to the group policy. */ + metadata: string; + /** + * version is used to track changes to a group's GroupPolicyInfo structure that + * would create a different result on a running proposal. + */ + version: bigint; + /** decision_policy specifies the group policy's decision policy. */ + decisionPolicy?: Any; + /** created_at is a timestamp specifying when a group policy was created. */ + createdAt: Date; +} +export interface GroupPolicyInfoProtoMsg { + typeUrl: "/cosmos.group.v1.GroupPolicyInfo"; + value: Uint8Array; +} +/** GroupPolicyInfo represents the high-level on-chain information for a group policy. */ +export interface GroupPolicyInfoSDKType { + address: string; + group_id: bigint; + admin: string; + metadata: string; + version: bigint; + decision_policy?: AnySDKType; + created_at: Date; +} +/** + * Proposal defines a group proposal. Any member of a group can submit a proposal + * for a group policy to decide upon. + * A proposal consists of a set of `sdk.Msg`s that will be executed if the proposal + * passes as well as some optional metadata associated with the proposal. + */ +export interface Proposal { + /** id is the unique id of the proposal. */ + id: bigint; + /** address is the account address of group policy. */ + address: string; + /** metadata is any arbitrary metadata to attached to the proposal. */ + metadata: string; + /** proposers are the account addresses of the proposers. */ + proposers: string[]; + /** submit_time is a timestamp specifying when a proposal was submitted. */ + submitTime: Date; + /** + * group_version tracks the version of the group that this proposal corresponds to. + * When group membership is changed, existing proposals from previous group versions will become invalid. + */ + groupVersion: bigint; + /** + * group_policy_version tracks the version of the group policy that this proposal corresponds to. + * When a decision policy is changed, existing proposals from previous policy versions will become invalid. + */ + groupPolicyVersion: bigint; + /** status represents the high level position in the life cycle of the proposal. Initial value is Submitted. */ + status: ProposalStatus; + /** + * result is the final result based on the votes and election rule. Initial value is unfinalized. + * The result is persisted so that clients can always rely on this state and not have to replicate the logic. + */ + result: ProposalResult; + /** + * final_tally_result contains the sums of all weighted votes for this + * proposal for each vote option, after tallying. When querying a proposal + * via gRPC, this field is not populated until the proposal's voting period + * has ended. + */ + finalTallyResult: TallyResult; + /** + * voting_period_end is the timestamp before which voting must be done. + * Unless a successfull MsgExec is called before (to execute a proposal whose + * tally is successful before the voting period ends), tallying will be done + * at this point, and the `final_tally_result`, as well + * as `status` and `result` fields will be accordingly updated. + */ + votingPeriodEnd: Date; + /** executor_result is the final result based on the votes and election rule. Initial value is NotRun. */ + executorResult: ProposalExecutorResult; + /** messages is a list of Msgs that will be executed if the proposal passes. */ + messages: Any[]; +} +export interface ProposalProtoMsg { + typeUrl: "/cosmos.group.v1.Proposal"; + value: Uint8Array; +} +/** + * Proposal defines a group proposal. Any member of a group can submit a proposal + * for a group policy to decide upon. + * A proposal consists of a set of `sdk.Msg`s that will be executed if the proposal + * passes as well as some optional metadata associated with the proposal. + */ +export interface ProposalSDKType { + id: bigint; + address: string; + metadata: string; + proposers: string[]; + submit_time: Date; + group_version: bigint; + group_policy_version: bigint; + status: ProposalStatus; + result: ProposalResult; + final_tally_result: TallyResultSDKType; + voting_period_end: Date; + executor_result: ProposalExecutorResult; + messages: AnySDKType[]; +} +/** TallyResult represents the sum of weighted votes for each vote option. */ +export interface TallyResult { + /** yes_count is the weighted sum of yes votes. */ + yesCount: string; + /** abstain_count is the weighted sum of abstainers. */ + abstainCount: string; + /** no is the weighted sum of no votes. */ + noCount: string; + /** no_with_veto_count is the weighted sum of veto. */ + noWithVetoCount: string; +} +export interface TallyResultProtoMsg { + typeUrl: "/cosmos.group.v1.TallyResult"; + value: Uint8Array; +} +/** TallyResult represents the sum of weighted votes for each vote option. */ +export interface TallyResultSDKType { + yes_count: string; + abstain_count: string; + no_count: string; + no_with_veto_count: string; +} +/** Vote represents a vote for a proposal. */ +export interface Vote { + /** proposal is the unique ID of the proposal. */ + proposalId: bigint; + /** voter is the account address of the voter. */ + voter: string; + /** option is the voter's choice on the proposal. */ + option: VoteOption; + /** metadata is any arbitrary metadata to attached to the vote. */ + metadata: string; + /** submit_time is the timestamp when the vote was submitted. */ + submitTime: Date; +} +export interface VoteProtoMsg { + typeUrl: "/cosmos.group.v1.Vote"; + value: Uint8Array; +} +/** Vote represents a vote for a proposal. */ +export interface VoteSDKType { + proposal_id: bigint; + voter: string; + option: VoteOption; + metadata: string; + submit_time: Date; +} +function createBaseMember(): Member { + return { + address: "", + weight: "", + metadata: "", + addedAt: new Date() + }; +} +export const Member = { + typeUrl: "/cosmos.group.v1.Member", + encode(message: Member, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.address !== undefined) { + writer.uint32(10).string(message.address); + } + if (message.weight !== undefined) { + writer.uint32(18).string(message.weight); + } + if (message.metadata !== undefined) { + writer.uint32(26).string(message.metadata); + } + if (message.addedAt !== undefined) { + Timestamp.encode(toTimestamp(message.addedAt), writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Member { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMember(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.string(); + break; + case 2: + message.weight = reader.string(); + break; + case 3: + message.metadata = reader.string(); + break; + case 4: + message.addedAt = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Member { + const obj = createBaseMember(); + if (isSet(object.address)) obj.address = String(object.address); + if (isSet(object.weight)) obj.weight = String(object.weight); + if (isSet(object.metadata)) obj.metadata = String(object.metadata); + if (isSet(object.addedAt)) obj.addedAt = new Date(object.addedAt); + return obj; + }, + toJSON(message: Member): JsonSafe { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + message.weight !== undefined && (obj.weight = message.weight); + message.metadata !== undefined && (obj.metadata = message.metadata); + message.addedAt !== undefined && (obj.addedAt = message.addedAt.toISOString()); + return obj; + }, + fromPartial(object: DeepPartial): Member { + const message = createBaseMember(); + message.address = object.address ?? ""; + message.weight = object.weight ?? ""; + message.metadata = object.metadata ?? ""; + message.addedAt = object.addedAt ?? undefined; + return message; + }, + fromSDK(object: MemberSDKType): Member { + return { + address: object?.address, + weight: object?.weight, + metadata: object?.metadata, + addedAt: object.added_at ?? undefined + }; + }, + fromSDKJSON(object: any): MemberSDKType { + return { + address: isSet(object.address) ? String(object.address) : "", + weight: isSet(object.weight) ? String(object.weight) : "", + metadata: isSet(object.metadata) ? String(object.metadata) : "", + added_at: isSet(object.added_at) ? new Date(object.added_at) : undefined + }; + }, + toSDK(message: Member): MemberSDKType { + const obj: any = {}; + obj.address = message.address; + obj.weight = message.weight; + obj.metadata = message.metadata; + message.addedAt !== undefined && (obj.added_at = message.addedAt ?? undefined); + return obj; + }, + fromAmino(object: MemberAmino): Member { + const message = createBaseMember(); + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } + if (object.weight !== undefined && object.weight !== null) { + message.weight = object.weight; + } + if (object.metadata !== undefined && object.metadata !== null) { + message.metadata = object.metadata; + } + if (object.added_at !== undefined && object.added_at !== null) { + message.addedAt = fromTimestamp(Timestamp.fromAmino(object.added_at)); + } + return message; + }, + toAmino(message: Member): MemberAmino { + const obj: any = {}; + obj.address = message.address === "" ? undefined : message.address; + obj.weight = message.weight === "" ? undefined : message.weight; + obj.metadata = message.metadata === "" ? undefined : message.metadata; + obj.added_at = message.addedAt ? Timestamp.toAmino(toTimestamp(message.addedAt)) : undefined; + return obj; + }, + fromAminoMsg(object: MemberAminoMsg): Member { + return Member.fromAmino(object.value); + }, + toAminoMsg(message: Member): MemberAminoMsg { + return { + type: "cosmos-sdk/Member", + value: Member.toAmino(message) + }; + }, + fromProtoMsg(message: MemberProtoMsg): Member { + return Member.decode(message.value); + }, + toProto(message: Member): Uint8Array { + return Member.encode(message).finish(); + }, + toProtoMsg(message: Member): MemberProtoMsg { + return { + typeUrl: "/cosmos.group.v1.Member", + value: Member.encode(message).finish() + }; + } +}; +function createBaseMembers(): Members { + return { + members: [] + }; +} +export const Members = { + typeUrl: "/cosmos.group.v1.Members", + encode(message: Members, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.members) { + Member.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Members { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMembers(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.members.push(Member.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Members { + const obj = createBaseMembers(); + if (Array.isArray(object?.members)) obj.members = object.members.map((e: any) => Member.fromJSON(e)); + return obj; + }, + toJSON(message: Members): JsonSafe { + const obj: any = {}; + if (message.members) { + obj.members = message.members.map(e => e ? Member.toJSON(e) : undefined); + } else { + obj.members = []; + } + return obj; + }, + fromPartial(object: DeepPartial): Members { + const message = createBaseMembers(); + message.members = object.members?.map(e => Member.fromPartial(e)) || []; + return message; + }, + fromSDK(object: MembersSDKType): Members { + return { + members: Array.isArray(object?.members) ? object.members.map((e: any) => Member.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): MembersSDKType { + return { + members: Array.isArray(object?.members) ? object.members.map((e: any) => Member.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: Members): MembersSDKType { + const obj: any = {}; + if (message.members) { + obj.members = message.members.map(e => e ? Member.toSDK(e) : undefined); + } else { + obj.members = []; + } + return obj; + }, + fromAmino(object: MembersAmino): Members { + const message = createBaseMembers(); + message.members = object.members?.map(e => Member.fromAmino(e)) || []; + return message; + }, + toAmino(message: Members): MembersAmino { + const obj: any = {}; + if (message.members) { + obj.members = message.members.map(e => e ? Member.toAmino(e) : undefined); + } else { + obj.members = message.members; + } + return obj; + }, + fromAminoMsg(object: MembersAminoMsg): Members { + return Members.fromAmino(object.value); + }, + toAminoMsg(message: Members): MembersAminoMsg { + return { + type: "cosmos-sdk/Members", + value: Members.toAmino(message) + }; + }, + fromProtoMsg(message: MembersProtoMsg): Members { + return Members.decode(message.value); + }, + toProto(message: Members): Uint8Array { + return Members.encode(message).finish(); + }, + toProtoMsg(message: Members): MembersProtoMsg { + return { + typeUrl: "/cosmos.group.v1.Members", + value: Members.encode(message).finish() + }; + } +}; +function createBaseThresholdDecisionPolicy(): ThresholdDecisionPolicy { + return { + threshold: "", + windows: undefined + }; +} +export const ThresholdDecisionPolicy = { + typeUrl: "/cosmos.group.v1.ThresholdDecisionPolicy", + encode(message: ThresholdDecisionPolicy, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.threshold !== undefined) { + writer.uint32(10).string(message.threshold); + } + if (message.windows !== undefined) { + DecisionPolicyWindows.encode(message.windows, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ThresholdDecisionPolicy { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseThresholdDecisionPolicy(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.threshold = reader.string(); + break; + case 2: + message.windows = DecisionPolicyWindows.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ThresholdDecisionPolicy { + const obj = createBaseThresholdDecisionPolicy(); + if (isSet(object.threshold)) obj.threshold = String(object.threshold); + if (isSet(object.windows)) obj.windows = DecisionPolicyWindows.fromJSON(object.windows); + return obj; + }, + toJSON(message: ThresholdDecisionPolicy): JsonSafe { + const obj: any = {}; + message.threshold !== undefined && (obj.threshold = message.threshold); + message.windows !== undefined && (obj.windows = message.windows ? DecisionPolicyWindows.toJSON(message.windows) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): ThresholdDecisionPolicy { + const message = createBaseThresholdDecisionPolicy(); + message.threshold = object.threshold ?? ""; + if (object.windows !== undefined && object.windows !== null) { + message.windows = DecisionPolicyWindows.fromPartial(object.windows); + } + return message; + }, + fromSDK(object: ThresholdDecisionPolicySDKType): ThresholdDecisionPolicy { + return { + threshold: object?.threshold, + windows: object.windows ? DecisionPolicyWindows.fromSDK(object.windows) : undefined + }; + }, + fromSDKJSON(object: any): ThresholdDecisionPolicySDKType { + return { + threshold: isSet(object.threshold) ? String(object.threshold) : "", + windows: isSet(object.windows) ? DecisionPolicyWindows.fromSDKJSON(object.windows) : undefined + }; + }, + toSDK(message: ThresholdDecisionPolicy): ThresholdDecisionPolicySDKType { + const obj: any = {}; + obj.threshold = message.threshold; + message.windows !== undefined && (obj.windows = message.windows ? DecisionPolicyWindows.toSDK(message.windows) : undefined); + return obj; + }, + fromAmino(object: ThresholdDecisionPolicyAmino): ThresholdDecisionPolicy { + const message = createBaseThresholdDecisionPolicy(); + if (object.threshold !== undefined && object.threshold !== null) { + message.threshold = object.threshold; + } + if (object.windows !== undefined && object.windows !== null) { + message.windows = DecisionPolicyWindows.fromAmino(object.windows); + } + return message; + }, + toAmino(message: ThresholdDecisionPolicy): ThresholdDecisionPolicyAmino { + const obj: any = {}; + obj.threshold = message.threshold === "" ? undefined : message.threshold; + obj.windows = message.windows ? DecisionPolicyWindows.toAmino(message.windows) : undefined; + return obj; + }, + fromAminoMsg(object: ThresholdDecisionPolicyAminoMsg): ThresholdDecisionPolicy { + return ThresholdDecisionPolicy.fromAmino(object.value); + }, + toAminoMsg(message: ThresholdDecisionPolicy): ThresholdDecisionPolicyAminoMsg { + return { + type: "cosmos-sdk/ThresholdDecisionPolicy", + value: ThresholdDecisionPolicy.toAmino(message) + }; + }, + fromProtoMsg(message: ThresholdDecisionPolicyProtoMsg): ThresholdDecisionPolicy { + return ThresholdDecisionPolicy.decode(message.value); + }, + toProto(message: ThresholdDecisionPolicy): Uint8Array { + return ThresholdDecisionPolicy.encode(message).finish(); + }, + toProtoMsg(message: ThresholdDecisionPolicy): ThresholdDecisionPolicyProtoMsg { + return { + typeUrl: "/cosmos.group.v1.ThresholdDecisionPolicy", + value: ThresholdDecisionPolicy.encode(message).finish() + }; + } +}; +function createBasePercentageDecisionPolicy(): PercentageDecisionPolicy { + return { + percentage: "", + windows: undefined + }; +} +export const PercentageDecisionPolicy = { + typeUrl: "/cosmos.group.v1.PercentageDecisionPolicy", + encode(message: PercentageDecisionPolicy, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.percentage !== undefined) { + writer.uint32(10).string(message.percentage); + } + if (message.windows !== undefined) { + DecisionPolicyWindows.encode(message.windows, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): PercentageDecisionPolicy { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBasePercentageDecisionPolicy(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.percentage = reader.string(); + break; + case 2: + message.windows = DecisionPolicyWindows.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): PercentageDecisionPolicy { + const obj = createBasePercentageDecisionPolicy(); + if (isSet(object.percentage)) obj.percentage = String(object.percentage); + if (isSet(object.windows)) obj.windows = DecisionPolicyWindows.fromJSON(object.windows); + return obj; + }, + toJSON(message: PercentageDecisionPolicy): JsonSafe { + const obj: any = {}; + message.percentage !== undefined && (obj.percentage = message.percentage); + message.windows !== undefined && (obj.windows = message.windows ? DecisionPolicyWindows.toJSON(message.windows) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): PercentageDecisionPolicy { + const message = createBasePercentageDecisionPolicy(); + message.percentage = object.percentage ?? ""; + if (object.windows !== undefined && object.windows !== null) { + message.windows = DecisionPolicyWindows.fromPartial(object.windows); + } + return message; + }, + fromSDK(object: PercentageDecisionPolicySDKType): PercentageDecisionPolicy { + return { + percentage: object?.percentage, + windows: object.windows ? DecisionPolicyWindows.fromSDK(object.windows) : undefined + }; + }, + fromSDKJSON(object: any): PercentageDecisionPolicySDKType { + return { + percentage: isSet(object.percentage) ? String(object.percentage) : "", + windows: isSet(object.windows) ? DecisionPolicyWindows.fromSDKJSON(object.windows) : undefined + }; + }, + toSDK(message: PercentageDecisionPolicy): PercentageDecisionPolicySDKType { + const obj: any = {}; + obj.percentage = message.percentage; + message.windows !== undefined && (obj.windows = message.windows ? DecisionPolicyWindows.toSDK(message.windows) : undefined); + return obj; + }, + fromAmino(object: PercentageDecisionPolicyAmino): PercentageDecisionPolicy { + const message = createBasePercentageDecisionPolicy(); + if (object.percentage !== undefined && object.percentage !== null) { + message.percentage = object.percentage; + } + if (object.windows !== undefined && object.windows !== null) { + message.windows = DecisionPolicyWindows.fromAmino(object.windows); + } + return message; + }, + toAmino(message: PercentageDecisionPolicy): PercentageDecisionPolicyAmino { + const obj: any = {}; + obj.percentage = message.percentage === "" ? undefined : message.percentage; + obj.windows = message.windows ? DecisionPolicyWindows.toAmino(message.windows) : undefined; + return obj; + }, + fromAminoMsg(object: PercentageDecisionPolicyAminoMsg): PercentageDecisionPolicy { + return PercentageDecisionPolicy.fromAmino(object.value); + }, + toAminoMsg(message: PercentageDecisionPolicy): PercentageDecisionPolicyAminoMsg { + return { + type: "cosmos-sdk/PercentageDecisionPolicy", + value: PercentageDecisionPolicy.toAmino(message) + }; + }, + fromProtoMsg(message: PercentageDecisionPolicyProtoMsg): PercentageDecisionPolicy { + return PercentageDecisionPolicy.decode(message.value); + }, + toProto(message: PercentageDecisionPolicy): Uint8Array { + return PercentageDecisionPolicy.encode(message).finish(); + }, + toProtoMsg(message: PercentageDecisionPolicy): PercentageDecisionPolicyProtoMsg { + return { + typeUrl: "/cosmos.group.v1.PercentageDecisionPolicy", + value: PercentageDecisionPolicy.encode(message).finish() + }; + } +}; +function createBaseDecisionPolicyWindows(): DecisionPolicyWindows { + return { + votingPeriod: Duration.fromPartial({}), + minExecutionPeriod: Duration.fromPartial({}) + }; +} +export const DecisionPolicyWindows = { + typeUrl: "/cosmos.group.v1.DecisionPolicyWindows", + encode(message: DecisionPolicyWindows, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.votingPeriod !== undefined) { + Duration.encode(message.votingPeriod, writer.uint32(10).fork()).ldelim(); + } + if (message.minExecutionPeriod !== undefined) { + Duration.encode(message.minExecutionPeriod, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): DecisionPolicyWindows { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDecisionPolicyWindows(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.votingPeriod = Duration.decode(reader, reader.uint32()); + break; + case 2: + message.minExecutionPeriod = Duration.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): DecisionPolicyWindows { + const obj = createBaseDecisionPolicyWindows(); + if (isSet(object.votingPeriod)) obj.votingPeriod = Duration.fromJSON(object.votingPeriod); + if (isSet(object.minExecutionPeriod)) obj.minExecutionPeriod = Duration.fromJSON(object.minExecutionPeriod); + return obj; + }, + toJSON(message: DecisionPolicyWindows): JsonSafe { + const obj: any = {}; + message.votingPeriod !== undefined && (obj.votingPeriod = message.votingPeriod ? Duration.toJSON(message.votingPeriod) : undefined); + message.minExecutionPeriod !== undefined && (obj.minExecutionPeriod = message.minExecutionPeriod ? Duration.toJSON(message.minExecutionPeriod) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): DecisionPolicyWindows { + const message = createBaseDecisionPolicyWindows(); + if (object.votingPeriod !== undefined && object.votingPeriod !== null) { + message.votingPeriod = Duration.fromPartial(object.votingPeriod); + } + if (object.minExecutionPeriod !== undefined && object.minExecutionPeriod !== null) { + message.minExecutionPeriod = Duration.fromPartial(object.minExecutionPeriod); + } + return message; + }, + fromSDK(object: DecisionPolicyWindowsSDKType): DecisionPolicyWindows { + return { + votingPeriod: object.voting_period ? Duration.fromSDK(object.voting_period) : undefined, + minExecutionPeriod: object.min_execution_period ? Duration.fromSDK(object.min_execution_period) : undefined + }; + }, + fromSDKJSON(object: any): DecisionPolicyWindowsSDKType { + return { + voting_period: isSet(object.voting_period) ? Duration.fromSDKJSON(object.voting_period) : undefined, + min_execution_period: isSet(object.min_execution_period) ? Duration.fromSDKJSON(object.min_execution_period) : undefined + }; + }, + toSDK(message: DecisionPolicyWindows): DecisionPolicyWindowsSDKType { + const obj: any = {}; + message.votingPeriod !== undefined && (obj.voting_period = message.votingPeriod ? Duration.toSDK(message.votingPeriod) : undefined); + message.minExecutionPeriod !== undefined && (obj.min_execution_period = message.minExecutionPeriod ? Duration.toSDK(message.minExecutionPeriod) : undefined); + return obj; + }, + fromAmino(object: DecisionPolicyWindowsAmino): DecisionPolicyWindows { + const message = createBaseDecisionPolicyWindows(); + if (object.voting_period !== undefined && object.voting_period !== null) { + message.votingPeriod = Duration.fromAmino(object.voting_period); + } + if (object.min_execution_period !== undefined && object.min_execution_period !== null) { + message.minExecutionPeriod = Duration.fromAmino(object.min_execution_period); + } + return message; + }, + toAmino(message: DecisionPolicyWindows): DecisionPolicyWindowsAmino { + const obj: any = {}; + obj.voting_period = message.votingPeriod ? Duration.toAmino(message.votingPeriod) : undefined; + obj.min_execution_period = message.minExecutionPeriod ? Duration.toAmino(message.minExecutionPeriod) : undefined; + return obj; + }, + fromAminoMsg(object: DecisionPolicyWindowsAminoMsg): DecisionPolicyWindows { + return DecisionPolicyWindows.fromAmino(object.value); + }, + toAminoMsg(message: DecisionPolicyWindows): DecisionPolicyWindowsAminoMsg { + return { + type: "cosmos-sdk/DecisionPolicyWindows", + value: DecisionPolicyWindows.toAmino(message) + }; + }, + fromProtoMsg(message: DecisionPolicyWindowsProtoMsg): DecisionPolicyWindows { + return DecisionPolicyWindows.decode(message.value); + }, + toProto(message: DecisionPolicyWindows): Uint8Array { + return DecisionPolicyWindows.encode(message).finish(); + }, + toProtoMsg(message: DecisionPolicyWindows): DecisionPolicyWindowsProtoMsg { + return { + typeUrl: "/cosmos.group.v1.DecisionPolicyWindows", + value: DecisionPolicyWindows.encode(message).finish() + }; + } +}; +function createBaseGroupInfo(): GroupInfo { + return { + id: BigInt(0), + admin: "", + metadata: "", + version: BigInt(0), + totalWeight: "", + createdAt: new Date() + }; +} +export const GroupInfo = { + typeUrl: "/cosmos.group.v1.GroupInfo", + encode(message: GroupInfo, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.id !== undefined) { + writer.uint32(8).uint64(message.id); + } + if (message.admin !== undefined) { + writer.uint32(18).string(message.admin); + } + if (message.metadata !== undefined) { + writer.uint32(26).string(message.metadata); + } + if (message.version !== undefined) { + writer.uint32(32).uint64(message.version); + } + if (message.totalWeight !== undefined) { + writer.uint32(42).string(message.totalWeight); + } + if (message.createdAt !== undefined) { + Timestamp.encode(toTimestamp(message.createdAt), writer.uint32(50).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GroupInfo { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGroupInfo(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.id = reader.uint64(); + break; + case 2: + message.admin = reader.string(); + break; + case 3: + message.metadata = reader.string(); + break; + case 4: + message.version = reader.uint64(); + break; + case 5: + message.totalWeight = reader.string(); + break; + case 6: + message.createdAt = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GroupInfo { + const obj = createBaseGroupInfo(); + if (isSet(object.id)) obj.id = BigInt(object.id.toString()); + if (isSet(object.admin)) obj.admin = String(object.admin); + if (isSet(object.metadata)) obj.metadata = String(object.metadata); + if (isSet(object.version)) obj.version = BigInt(object.version.toString()); + if (isSet(object.totalWeight)) obj.totalWeight = String(object.totalWeight); + if (isSet(object.createdAt)) obj.createdAt = new Date(object.createdAt); + return obj; + }, + toJSON(message: GroupInfo): JsonSafe { + const obj: any = {}; + message.id !== undefined && (obj.id = (message.id || BigInt(0)).toString()); + message.admin !== undefined && (obj.admin = message.admin); + message.metadata !== undefined && (obj.metadata = message.metadata); + message.version !== undefined && (obj.version = (message.version || BigInt(0)).toString()); + message.totalWeight !== undefined && (obj.totalWeight = message.totalWeight); + message.createdAt !== undefined && (obj.createdAt = message.createdAt.toISOString()); + return obj; + }, + fromPartial(object: DeepPartial): GroupInfo { + const message = createBaseGroupInfo(); + if (object.id !== undefined && object.id !== null) { + message.id = BigInt(object.id.toString()); + } + message.admin = object.admin ?? ""; + message.metadata = object.metadata ?? ""; + if (object.version !== undefined && object.version !== null) { + message.version = BigInt(object.version.toString()); + } + message.totalWeight = object.totalWeight ?? ""; + message.createdAt = object.createdAt ?? undefined; + return message; + }, + fromSDK(object: GroupInfoSDKType): GroupInfo { + return { + id: object?.id, + admin: object?.admin, + metadata: object?.metadata, + version: object?.version, + totalWeight: object?.total_weight, + createdAt: object.created_at ?? undefined + }; + }, + fromSDKJSON(object: any): GroupInfoSDKType { + return { + id: isSet(object.id) ? BigInt(object.id.toString()) : BigInt(0), + admin: isSet(object.admin) ? String(object.admin) : "", + metadata: isSet(object.metadata) ? String(object.metadata) : "", + version: isSet(object.version) ? BigInt(object.version.toString()) : BigInt(0), + total_weight: isSet(object.total_weight) ? String(object.total_weight) : "", + created_at: isSet(object.created_at) ? new Date(object.created_at) : undefined + }; + }, + toSDK(message: GroupInfo): GroupInfoSDKType { + const obj: any = {}; + obj.id = message.id; + obj.admin = message.admin; + obj.metadata = message.metadata; + obj.version = message.version; + obj.total_weight = message.totalWeight; + message.createdAt !== undefined && (obj.created_at = message.createdAt ?? undefined); + return obj; + }, + fromAmino(object: GroupInfoAmino): GroupInfo { + const message = createBaseGroupInfo(); + if (object.id !== undefined && object.id !== null) { + message.id = BigInt(object.id); + } + if (object.admin !== undefined && object.admin !== null) { + message.admin = object.admin; + } + if (object.metadata !== undefined && object.metadata !== null) { + message.metadata = object.metadata; + } + if (object.version !== undefined && object.version !== null) { + message.version = BigInt(object.version); + } + if (object.total_weight !== undefined && object.total_weight !== null) { + message.totalWeight = object.total_weight; + } + if (object.created_at !== undefined && object.created_at !== null) { + message.createdAt = fromTimestamp(Timestamp.fromAmino(object.created_at)); + } + return message; + }, + toAmino(message: GroupInfo): GroupInfoAmino { + const obj: any = {}; + obj.id = message.id !== BigInt(0) ? message.id?.toString() : undefined; + obj.admin = message.admin === "" ? undefined : message.admin; + obj.metadata = message.metadata === "" ? undefined : message.metadata; + obj.version = message.version !== BigInt(0) ? message.version?.toString() : undefined; + obj.total_weight = message.totalWeight === "" ? undefined : message.totalWeight; + obj.created_at = message.createdAt ? Timestamp.toAmino(toTimestamp(message.createdAt)) : undefined; + return obj; + }, + fromAminoMsg(object: GroupInfoAminoMsg): GroupInfo { + return GroupInfo.fromAmino(object.value); + }, + toAminoMsg(message: GroupInfo): GroupInfoAminoMsg { + return { + type: "cosmos-sdk/GroupInfo", + value: GroupInfo.toAmino(message) + }; + }, + fromProtoMsg(message: GroupInfoProtoMsg): GroupInfo { + return GroupInfo.decode(message.value); + }, + toProto(message: GroupInfo): Uint8Array { + return GroupInfo.encode(message).finish(); + }, + toProtoMsg(message: GroupInfo): GroupInfoProtoMsg { + return { + typeUrl: "/cosmos.group.v1.GroupInfo", + value: GroupInfo.encode(message).finish() + }; + } +}; +function createBaseGroupMember(): GroupMember { + return { + groupId: BigInt(0), + member: undefined + }; +} +export const GroupMember = { + typeUrl: "/cosmos.group.v1.GroupMember", + encode(message: GroupMember, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.groupId !== undefined) { + writer.uint32(8).uint64(message.groupId); + } + if (message.member !== undefined) { + Member.encode(message.member, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GroupMember { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGroupMember(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.groupId = reader.uint64(); + break; + case 2: + message.member = Member.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GroupMember { + const obj = createBaseGroupMember(); + if (isSet(object.groupId)) obj.groupId = BigInt(object.groupId.toString()); + if (isSet(object.member)) obj.member = Member.fromJSON(object.member); + return obj; + }, + toJSON(message: GroupMember): JsonSafe { + const obj: any = {}; + message.groupId !== undefined && (obj.groupId = (message.groupId || BigInt(0)).toString()); + message.member !== undefined && (obj.member = message.member ? Member.toJSON(message.member) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): GroupMember { + const message = createBaseGroupMember(); + if (object.groupId !== undefined && object.groupId !== null) { + message.groupId = BigInt(object.groupId.toString()); + } + if (object.member !== undefined && object.member !== null) { + message.member = Member.fromPartial(object.member); + } + return message; + }, + fromSDK(object: GroupMemberSDKType): GroupMember { + return { + groupId: object?.group_id, + member: object.member ? Member.fromSDK(object.member) : undefined + }; + }, + fromSDKJSON(object: any): GroupMemberSDKType { + return { + group_id: isSet(object.group_id) ? BigInt(object.group_id.toString()) : BigInt(0), + member: isSet(object.member) ? Member.fromSDKJSON(object.member) : undefined + }; + }, + toSDK(message: GroupMember): GroupMemberSDKType { + const obj: any = {}; + obj.group_id = message.groupId; + message.member !== undefined && (obj.member = message.member ? Member.toSDK(message.member) : undefined); + return obj; + }, + fromAmino(object: GroupMemberAmino): GroupMember { + const message = createBaseGroupMember(); + if (object.group_id !== undefined && object.group_id !== null) { + message.groupId = BigInt(object.group_id); + } + if (object.member !== undefined && object.member !== null) { + message.member = Member.fromAmino(object.member); + } + return message; + }, + toAmino(message: GroupMember): GroupMemberAmino { + const obj: any = {}; + obj.group_id = message.groupId !== BigInt(0) ? message.groupId?.toString() : undefined; + obj.member = message.member ? Member.toAmino(message.member) : undefined; + return obj; + }, + fromAminoMsg(object: GroupMemberAminoMsg): GroupMember { + return GroupMember.fromAmino(object.value); + }, + toAminoMsg(message: GroupMember): GroupMemberAminoMsg { + return { + type: "cosmos-sdk/GroupMember", + value: GroupMember.toAmino(message) + }; + }, + fromProtoMsg(message: GroupMemberProtoMsg): GroupMember { + return GroupMember.decode(message.value); + }, + toProto(message: GroupMember): Uint8Array { + return GroupMember.encode(message).finish(); + }, + toProtoMsg(message: GroupMember): GroupMemberProtoMsg { + return { + typeUrl: "/cosmos.group.v1.GroupMember", + value: GroupMember.encode(message).finish() + }; + } +}; +function createBaseGroupPolicyInfo(): GroupPolicyInfo { + return { + address: "", + groupId: BigInt(0), + admin: "", + metadata: "", + version: BigInt(0), + decisionPolicy: undefined, + createdAt: new Date() + }; +} +export const GroupPolicyInfo = { + typeUrl: "/cosmos.group.v1.GroupPolicyInfo", + encode(message: GroupPolicyInfo, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.address !== undefined) { + writer.uint32(10).string(message.address); + } + if (message.groupId !== undefined) { + writer.uint32(16).uint64(message.groupId); + } + if (message.admin !== undefined) { + writer.uint32(26).string(message.admin); + } + if (message.metadata !== undefined) { + writer.uint32(34).string(message.metadata); + } + if (message.version !== undefined) { + writer.uint32(40).uint64(message.version); + } + if (message.decisionPolicy !== undefined) { + Any.encode(message.decisionPolicy, writer.uint32(50).fork()).ldelim(); + } + if (message.createdAt !== undefined) { + Timestamp.encode(toTimestamp(message.createdAt), writer.uint32(58).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GroupPolicyInfo { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGroupPolicyInfo(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.string(); + break; + case 2: + message.groupId = reader.uint64(); + break; + case 3: + message.admin = reader.string(); + break; + case 4: + message.metadata = reader.string(); + break; + case 5: + message.version = reader.uint64(); + break; + case 6: + message.decisionPolicy = Any.decode(reader, reader.uint32()); + break; + case 7: + message.createdAt = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GroupPolicyInfo { + const obj = createBaseGroupPolicyInfo(); + if (isSet(object.address)) obj.address = String(object.address); + if (isSet(object.groupId)) obj.groupId = BigInt(object.groupId.toString()); + if (isSet(object.admin)) obj.admin = String(object.admin); + if (isSet(object.metadata)) obj.metadata = String(object.metadata); + if (isSet(object.version)) obj.version = BigInt(object.version.toString()); + if (isSet(object.decisionPolicy)) obj.decisionPolicy = Any.fromJSON(object.decisionPolicy); + if (isSet(object.createdAt)) obj.createdAt = new Date(object.createdAt); + return obj; + }, + toJSON(message: GroupPolicyInfo): JsonSafe { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + message.groupId !== undefined && (obj.groupId = (message.groupId || BigInt(0)).toString()); + message.admin !== undefined && (obj.admin = message.admin); + message.metadata !== undefined && (obj.metadata = message.metadata); + message.version !== undefined && (obj.version = (message.version || BigInt(0)).toString()); + message.decisionPolicy !== undefined && (obj.decisionPolicy = message.decisionPolicy ? Any.toJSON(message.decisionPolicy) : undefined); + message.createdAt !== undefined && (obj.createdAt = message.createdAt.toISOString()); + return obj; + }, + fromPartial(object: DeepPartial): GroupPolicyInfo { + const message = createBaseGroupPolicyInfo(); + message.address = object.address ?? ""; + if (object.groupId !== undefined && object.groupId !== null) { + message.groupId = BigInt(object.groupId.toString()); + } + message.admin = object.admin ?? ""; + message.metadata = object.metadata ?? ""; + if (object.version !== undefined && object.version !== null) { + message.version = BigInt(object.version.toString()); + } + if (object.decisionPolicy !== undefined && object.decisionPolicy !== null) { + message.decisionPolicy = Any.fromPartial(object.decisionPolicy); + } + message.createdAt = object.createdAt ?? undefined; + return message; + }, + fromSDK(object: GroupPolicyInfoSDKType): GroupPolicyInfo { + return { + address: object?.address, + groupId: object?.group_id, + admin: object?.admin, + metadata: object?.metadata, + version: object?.version, + decisionPolicy: object.decision_policy ? Any.fromSDK(object.decision_policy) : undefined, + createdAt: object.created_at ?? undefined + }; + }, + fromSDKJSON(object: any): GroupPolicyInfoSDKType { + return { + address: isSet(object.address) ? String(object.address) : "", + group_id: isSet(object.group_id) ? BigInt(object.group_id.toString()) : BigInt(0), + admin: isSet(object.admin) ? String(object.admin) : "", + metadata: isSet(object.metadata) ? String(object.metadata) : "", + version: isSet(object.version) ? BigInt(object.version.toString()) : BigInt(0), + decision_policy: isSet(object.decision_policy) ? Any.fromSDKJSON(object.decision_policy) : undefined, + created_at: isSet(object.created_at) ? new Date(object.created_at) : undefined + }; + }, + toSDK(message: GroupPolicyInfo): GroupPolicyInfoSDKType { + const obj: any = {}; + obj.address = message.address; + obj.group_id = message.groupId; + obj.admin = message.admin; + obj.metadata = message.metadata; + obj.version = message.version; + message.decisionPolicy !== undefined && (obj.decision_policy = message.decisionPolicy ? Any.toSDK(message.decisionPolicy) : undefined); + message.createdAt !== undefined && (obj.created_at = message.createdAt ?? undefined); + return obj; + }, + fromAmino(object: GroupPolicyInfoAmino): GroupPolicyInfo { + const message = createBaseGroupPolicyInfo(); + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } + if (object.group_id !== undefined && object.group_id !== null) { + message.groupId = BigInt(object.group_id); + } + if (object.admin !== undefined && object.admin !== null) { + message.admin = object.admin; + } + if (object.metadata !== undefined && object.metadata !== null) { + message.metadata = object.metadata; + } + if (object.version !== undefined && object.version !== null) { + message.version = BigInt(object.version); + } + if (object.decision_policy !== undefined && object.decision_policy !== null) { + message.decisionPolicy = Any.fromAmino(object.decision_policy); + } + if (object.created_at !== undefined && object.created_at !== null) { + message.createdAt = fromTimestamp(Timestamp.fromAmino(object.created_at)); + } + return message; + }, + toAmino(message: GroupPolicyInfo): GroupPolicyInfoAmino { + const obj: any = {}; + obj.address = message.address === "" ? undefined : message.address; + obj.group_id = message.groupId !== BigInt(0) ? message.groupId?.toString() : undefined; + obj.admin = message.admin === "" ? undefined : message.admin; + obj.metadata = message.metadata === "" ? undefined : message.metadata; + obj.version = message.version !== BigInt(0) ? message.version?.toString() : undefined; + obj.decision_policy = message.decisionPolicy ? Any.toAmino(message.decisionPolicy) : undefined; + obj.created_at = message.createdAt ? Timestamp.toAmino(toTimestamp(message.createdAt)) : undefined; + return obj; + }, + fromAminoMsg(object: GroupPolicyInfoAminoMsg): GroupPolicyInfo { + return GroupPolicyInfo.fromAmino(object.value); + }, + toAminoMsg(message: GroupPolicyInfo): GroupPolicyInfoAminoMsg { + return { + type: "cosmos-sdk/GroupPolicyInfo", + value: GroupPolicyInfo.toAmino(message) + }; + }, + fromProtoMsg(message: GroupPolicyInfoProtoMsg): GroupPolicyInfo { + return GroupPolicyInfo.decode(message.value); + }, + toProto(message: GroupPolicyInfo): Uint8Array { + return GroupPolicyInfo.encode(message).finish(); + }, + toProtoMsg(message: GroupPolicyInfo): GroupPolicyInfoProtoMsg { + return { + typeUrl: "/cosmos.group.v1.GroupPolicyInfo", + value: GroupPolicyInfo.encode(message).finish() + }; + } +}; +function createBaseProposal(): Proposal { + return { + id: BigInt(0), + address: "", + metadata: "", + proposers: [], + submitTime: new Date(), + groupVersion: BigInt(0), + groupPolicyVersion: BigInt(0), + status: 0, + result: 0, + finalTallyResult: TallyResult.fromPartial({}), + votingPeriodEnd: new Date(), + executorResult: 0, + messages: [] + }; +} +export const Proposal = { + typeUrl: "/cosmos.group.v1.Proposal", + encode(message: Proposal, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.id !== undefined) { + writer.uint32(8).uint64(message.id); + } + if (message.address !== undefined) { + writer.uint32(18).string(message.address); + } + if (message.metadata !== undefined) { + writer.uint32(26).string(message.metadata); + } + for (const v of message.proposers) { + writer.uint32(34).string(v!); + } + if (message.submitTime !== undefined) { + Timestamp.encode(toTimestamp(message.submitTime), writer.uint32(42).fork()).ldelim(); + } + if (message.groupVersion !== undefined) { + writer.uint32(48).uint64(message.groupVersion); + } + if (message.groupPolicyVersion !== undefined) { + writer.uint32(56).uint64(message.groupPolicyVersion); + } + if (message.status !== 0) { + writer.uint32(64).int32(message.status); + } + if (message.result !== 0) { + writer.uint32(72).int32(message.result); + } + if (message.finalTallyResult !== undefined) { + TallyResult.encode(message.finalTallyResult, writer.uint32(82).fork()).ldelim(); + } + if (message.votingPeriodEnd !== undefined) { + Timestamp.encode(toTimestamp(message.votingPeriodEnd), writer.uint32(90).fork()).ldelim(); + } + if (message.executorResult !== 0) { + writer.uint32(96).int32(message.executorResult); + } + for (const v of message.messages) { + Any.encode(v!, writer.uint32(106).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Proposal { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseProposal(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.id = reader.uint64(); + break; + case 2: + message.address = reader.string(); + break; + case 3: + message.metadata = reader.string(); + break; + case 4: + message.proposers.push(reader.string()); + break; + case 5: + message.submitTime = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + break; + case 6: + message.groupVersion = reader.uint64(); + break; + case 7: + message.groupPolicyVersion = reader.uint64(); + break; + case 8: + message.status = (reader.int32() as any); + break; + case 9: + message.result = (reader.int32() as any); + break; + case 10: + message.finalTallyResult = TallyResult.decode(reader, reader.uint32()); + break; + case 11: + message.votingPeriodEnd = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + break; + case 12: + message.executorResult = (reader.int32() as any); + break; + case 13: + message.messages.push(Any.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Proposal { + const obj = createBaseProposal(); + if (isSet(object.id)) obj.id = BigInt(object.id.toString()); + if (isSet(object.address)) obj.address = String(object.address); + if (isSet(object.metadata)) obj.metadata = String(object.metadata); + if (Array.isArray(object?.proposers)) obj.proposers = object.proposers.map((e: any) => String(e)); + if (isSet(object.submitTime)) obj.submitTime = new Date(object.submitTime); + if (isSet(object.groupVersion)) obj.groupVersion = BigInt(object.groupVersion.toString()); + if (isSet(object.groupPolicyVersion)) obj.groupPolicyVersion = BigInt(object.groupPolicyVersion.toString()); + if (isSet(object.status)) obj.status = proposalStatusFromJSON(object.status); + if (isSet(object.result)) obj.result = proposalResultFromJSON(object.result); + if (isSet(object.finalTallyResult)) obj.finalTallyResult = TallyResult.fromJSON(object.finalTallyResult); + if (isSet(object.votingPeriodEnd)) obj.votingPeriodEnd = new Date(object.votingPeriodEnd); + if (isSet(object.executorResult)) obj.executorResult = proposalExecutorResultFromJSON(object.executorResult); + if (Array.isArray(object?.messages)) obj.messages = object.messages.map((e: any) => Any.fromJSON(e)); + return obj; + }, + toJSON(message: Proposal): JsonSafe { + const obj: any = {}; + message.id !== undefined && (obj.id = (message.id || BigInt(0)).toString()); + message.address !== undefined && (obj.address = message.address); + message.metadata !== undefined && (obj.metadata = message.metadata); + if (message.proposers) { + obj.proposers = message.proposers.map(e => e); + } else { + obj.proposers = []; + } + message.submitTime !== undefined && (obj.submitTime = message.submitTime.toISOString()); + message.groupVersion !== undefined && (obj.groupVersion = (message.groupVersion || BigInt(0)).toString()); + message.groupPolicyVersion !== undefined && (obj.groupPolicyVersion = (message.groupPolicyVersion || BigInt(0)).toString()); + message.status !== undefined && (obj.status = proposalStatusToJSON(message.status)); + message.result !== undefined && (obj.result = proposalResultToJSON(message.result)); + message.finalTallyResult !== undefined && (obj.finalTallyResult = message.finalTallyResult ? TallyResult.toJSON(message.finalTallyResult) : undefined); + message.votingPeriodEnd !== undefined && (obj.votingPeriodEnd = message.votingPeriodEnd.toISOString()); + message.executorResult !== undefined && (obj.executorResult = proposalExecutorResultToJSON(message.executorResult)); + if (message.messages) { + obj.messages = message.messages.map(e => e ? Any.toJSON(e) : undefined); + } else { + obj.messages = []; + } + return obj; + }, + fromPartial(object: DeepPartial): Proposal { + const message = createBaseProposal(); + if (object.id !== undefined && object.id !== null) { + message.id = BigInt(object.id.toString()); + } + message.address = object.address ?? ""; + message.metadata = object.metadata ?? ""; + message.proposers = object.proposers?.map(e => e) || []; + message.submitTime = object.submitTime ?? undefined; + if (object.groupVersion !== undefined && object.groupVersion !== null) { + message.groupVersion = BigInt(object.groupVersion.toString()); + } + if (object.groupPolicyVersion !== undefined && object.groupPolicyVersion !== null) { + message.groupPolicyVersion = BigInt(object.groupPolicyVersion.toString()); + } + message.status = object.status ?? 0; + message.result = object.result ?? 0; + if (object.finalTallyResult !== undefined && object.finalTallyResult !== null) { + message.finalTallyResult = TallyResult.fromPartial(object.finalTallyResult); + } + message.votingPeriodEnd = object.votingPeriodEnd ?? undefined; + message.executorResult = object.executorResult ?? 0; + message.messages = object.messages?.map(e => Any.fromPartial(e)) || []; + return message; + }, + fromSDK(object: ProposalSDKType): Proposal { + return { + id: object?.id, + address: object?.address, + metadata: object?.metadata, + proposers: Array.isArray(object?.proposers) ? object.proposers.map((e: any) => e) : [], + submitTime: object.submit_time ?? undefined, + groupVersion: object?.group_version, + groupPolicyVersion: object?.group_policy_version, + status: isSet(object.status) ? proposalStatusFromJSON(object.status) : -1, + result: isSet(object.result) ? proposalResultFromJSON(object.result) : -1, + finalTallyResult: object.final_tally_result ? TallyResult.fromSDK(object.final_tally_result) : undefined, + votingPeriodEnd: object.voting_period_end ?? undefined, + executorResult: isSet(object.executor_result) ? proposalExecutorResultFromJSON(object.executor_result) : -1, + messages: Array.isArray(object?.messages) ? object.messages.map((e: any) => Any.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): ProposalSDKType { + return { + id: isSet(object.id) ? BigInt(object.id.toString()) : BigInt(0), + address: isSet(object.address) ? String(object.address) : "", + metadata: isSet(object.metadata) ? String(object.metadata) : "", + proposers: Array.isArray(object?.proposers) ? object.proposers.map((e: any) => String(e)) : [], + submit_time: isSet(object.submit_time) ? new Date(object.submit_time) : undefined, + group_version: isSet(object.group_version) ? BigInt(object.group_version.toString()) : BigInt(0), + group_policy_version: isSet(object.group_policy_version) ? BigInt(object.group_policy_version.toString()) : BigInt(0), + status: isSet(object.status) ? proposalStatusFromJSON(object.status) : -1, + result: isSet(object.result) ? proposalResultFromJSON(object.result) : -1, + final_tally_result: isSet(object.final_tally_result) ? TallyResult.fromSDKJSON(object.final_tally_result) : undefined, + voting_period_end: isSet(object.voting_period_end) ? new Date(object.voting_period_end) : undefined, + executor_result: isSet(object.executor_result) ? proposalExecutorResultFromJSON(object.executor_result) : -1, + messages: Array.isArray(object?.messages) ? object.messages.map((e: any) => Any.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: Proposal): ProposalSDKType { + const obj: any = {}; + obj.id = message.id; + obj.address = message.address; + obj.metadata = message.metadata; + if (message.proposers) { + obj.proposers = message.proposers.map(e => e); + } else { + obj.proposers = []; + } + message.submitTime !== undefined && (obj.submit_time = message.submitTime ?? undefined); + obj.group_version = message.groupVersion; + obj.group_policy_version = message.groupPolicyVersion; + message.status !== undefined && (obj.status = proposalStatusToJSON(message.status)); + message.result !== undefined && (obj.result = proposalResultToJSON(message.result)); + message.finalTallyResult !== undefined && (obj.final_tally_result = message.finalTallyResult ? TallyResult.toSDK(message.finalTallyResult) : undefined); + message.votingPeriodEnd !== undefined && (obj.voting_period_end = message.votingPeriodEnd ?? undefined); + message.executorResult !== undefined && (obj.executor_result = proposalExecutorResultToJSON(message.executorResult)); + if (message.messages) { + obj.messages = message.messages.map(e => e ? Any.toSDK(e) : undefined); + } else { + obj.messages = []; + } + return obj; + }, + fromAmino(object: ProposalAmino): Proposal { + const message = createBaseProposal(); + if (object.id !== undefined && object.id !== null) { + message.id = BigInt(object.id); + } + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } + if (object.metadata !== undefined && object.metadata !== null) { + message.metadata = object.metadata; + } + message.proposers = object.proposers?.map(e => e) || []; + if (object.submit_time !== undefined && object.submit_time !== null) { + message.submitTime = fromTimestamp(Timestamp.fromAmino(object.submit_time)); + } + if (object.group_version !== undefined && object.group_version !== null) { + message.groupVersion = BigInt(object.group_version); + } + if (object.group_policy_version !== undefined && object.group_policy_version !== null) { + message.groupPolicyVersion = BigInt(object.group_policy_version); + } + if (object.status !== undefined && object.status !== null) { + message.status = object.status; + } + if (object.result !== undefined && object.result !== null) { + message.result = object.result; + } + if (object.final_tally_result !== undefined && object.final_tally_result !== null) { + message.finalTallyResult = TallyResult.fromAmino(object.final_tally_result); + } + if (object.voting_period_end !== undefined && object.voting_period_end !== null) { + message.votingPeriodEnd = fromTimestamp(Timestamp.fromAmino(object.voting_period_end)); + } + if (object.executor_result !== undefined && object.executor_result !== null) { + message.executorResult = object.executor_result; + } + message.messages = object.messages?.map(e => Any.fromAmino(e)) || []; + return message; + }, + toAmino(message: Proposal): ProposalAmino { + const obj: any = {}; + obj.id = message.id !== BigInt(0) ? message.id?.toString() : undefined; + obj.address = message.address === "" ? undefined : message.address; + obj.metadata = message.metadata === "" ? undefined : message.metadata; + if (message.proposers) { + obj.proposers = message.proposers.map(e => e); + } else { + obj.proposers = message.proposers; + } + obj.submit_time = message.submitTime ? Timestamp.toAmino(toTimestamp(message.submitTime)) : undefined; + obj.group_version = message.groupVersion !== BigInt(0) ? message.groupVersion?.toString() : undefined; + obj.group_policy_version = message.groupPolicyVersion !== BigInt(0) ? message.groupPolicyVersion?.toString() : undefined; + obj.status = message.status === 0 ? undefined : message.status; + obj.result = message.result === 0 ? undefined : message.result; + obj.final_tally_result = message.finalTallyResult ? TallyResult.toAmino(message.finalTallyResult) : undefined; + obj.voting_period_end = message.votingPeriodEnd ? Timestamp.toAmino(toTimestamp(message.votingPeriodEnd)) : undefined; + obj.executor_result = message.executorResult === 0 ? undefined : message.executorResult; + if (message.messages) { + obj.messages = message.messages.map(e => e ? Any.toAmino(e) : undefined); + } else { + obj.messages = message.messages; + } + return obj; + }, + fromAminoMsg(object: ProposalAminoMsg): Proposal { + return Proposal.fromAmino(object.value); + }, + toAminoMsg(message: Proposal): ProposalAminoMsg { + return { + type: "cosmos-sdk/Proposal", + value: Proposal.toAmino(message) + }; + }, + fromProtoMsg(message: ProposalProtoMsg): Proposal { + return Proposal.decode(message.value); + }, + toProto(message: Proposal): Uint8Array { + return Proposal.encode(message).finish(); + }, + toProtoMsg(message: Proposal): ProposalProtoMsg { + return { + typeUrl: "/cosmos.group.v1.Proposal", + value: Proposal.encode(message).finish() + }; + } +}; +function createBaseTallyResult(): TallyResult { + return { + yesCount: "", + abstainCount: "", + noCount: "", + noWithVetoCount: "" + }; +} +export const TallyResult = { + typeUrl: "/cosmos.group.v1.TallyResult", + encode(message: TallyResult, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.yesCount !== undefined) { + writer.uint32(10).string(message.yesCount); + } + if (message.abstainCount !== undefined) { + writer.uint32(18).string(message.abstainCount); + } + if (message.noCount !== undefined) { + writer.uint32(26).string(message.noCount); + } + if (message.noWithVetoCount !== undefined) { + writer.uint32(34).string(message.noWithVetoCount); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): TallyResult { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseTallyResult(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.yesCount = reader.string(); + break; + case 2: + message.abstainCount = reader.string(); + break; + case 3: + message.noCount = reader.string(); + break; + case 4: + message.noWithVetoCount = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): TallyResult { + const obj = createBaseTallyResult(); + if (isSet(object.yesCount)) obj.yesCount = String(object.yesCount); + if (isSet(object.abstainCount)) obj.abstainCount = String(object.abstainCount); + if (isSet(object.noCount)) obj.noCount = String(object.noCount); + if (isSet(object.noWithVetoCount)) obj.noWithVetoCount = String(object.noWithVetoCount); + return obj; + }, + toJSON(message: TallyResult): JsonSafe { + const obj: any = {}; + message.yesCount !== undefined && (obj.yesCount = message.yesCount); + message.abstainCount !== undefined && (obj.abstainCount = message.abstainCount); + message.noCount !== undefined && (obj.noCount = message.noCount); + message.noWithVetoCount !== undefined && (obj.noWithVetoCount = message.noWithVetoCount); + return obj; + }, + fromPartial(object: DeepPartial): TallyResult { + const message = createBaseTallyResult(); + message.yesCount = object.yesCount ?? ""; + message.abstainCount = object.abstainCount ?? ""; + message.noCount = object.noCount ?? ""; + message.noWithVetoCount = object.noWithVetoCount ?? ""; + return message; + }, + fromSDK(object: TallyResultSDKType): TallyResult { + return { + yesCount: object?.yes_count, + abstainCount: object?.abstain_count, + noCount: object?.no_count, + noWithVetoCount: object?.no_with_veto_count + }; + }, + fromSDKJSON(object: any): TallyResultSDKType { + return { + yes_count: isSet(object.yes_count) ? String(object.yes_count) : "", + abstain_count: isSet(object.abstain_count) ? String(object.abstain_count) : "", + no_count: isSet(object.no_count) ? String(object.no_count) : "", + no_with_veto_count: isSet(object.no_with_veto_count) ? String(object.no_with_veto_count) : "" + }; + }, + toSDK(message: TallyResult): TallyResultSDKType { + const obj: any = {}; + obj.yes_count = message.yesCount; + obj.abstain_count = message.abstainCount; + obj.no_count = message.noCount; + obj.no_with_veto_count = message.noWithVetoCount; + return obj; + }, + fromAmino(object: TallyResultAmino): TallyResult { + const message = createBaseTallyResult(); + if (object.yes_count !== undefined && object.yes_count !== null) { + message.yesCount = object.yes_count; + } + if (object.abstain_count !== undefined && object.abstain_count !== null) { + message.abstainCount = object.abstain_count; + } + if (object.no_count !== undefined && object.no_count !== null) { + message.noCount = object.no_count; + } + if (object.no_with_veto_count !== undefined && object.no_with_veto_count !== null) { + message.noWithVetoCount = object.no_with_veto_count; + } + return message; + }, + toAmino(message: TallyResult): TallyResultAmino { + const obj: any = {}; + obj.yes_count = message.yesCount === "" ? undefined : message.yesCount; + obj.abstain_count = message.abstainCount === "" ? undefined : message.abstainCount; + obj.no_count = message.noCount === "" ? undefined : message.noCount; + obj.no_with_veto_count = message.noWithVetoCount === "" ? undefined : message.noWithVetoCount; + return obj; + }, + fromAminoMsg(object: TallyResultAminoMsg): TallyResult { + return TallyResult.fromAmino(object.value); + }, + toAminoMsg(message: TallyResult): TallyResultAminoMsg { + return { + type: "cosmos-sdk/TallyResult", + value: TallyResult.toAmino(message) + }; + }, + fromProtoMsg(message: TallyResultProtoMsg): TallyResult { + return TallyResult.decode(message.value); + }, + toProto(message: TallyResult): Uint8Array { + return TallyResult.encode(message).finish(); + }, + toProtoMsg(message: TallyResult): TallyResultProtoMsg { + return { + typeUrl: "/cosmos.group.v1.TallyResult", + value: TallyResult.encode(message).finish() + }; + } +}; +function createBaseVote(): Vote { + return { + proposalId: BigInt(0), + voter: "", + option: 0, + metadata: "", + submitTime: new Date() + }; +} +export const Vote = { + typeUrl: "/cosmos.group.v1.Vote", + encode(message: Vote, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.proposalId !== undefined) { + writer.uint32(8).uint64(message.proposalId); + } + if (message.voter !== undefined) { + writer.uint32(18).string(message.voter); + } + if (message.option !== 0) { + writer.uint32(24).int32(message.option); + } + if (message.metadata !== undefined) { + writer.uint32(34).string(message.metadata); + } + if (message.submitTime !== undefined) { + Timestamp.encode(toTimestamp(message.submitTime), writer.uint32(42).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Vote { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseVote(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.proposalId = reader.uint64(); + break; + case 2: + message.voter = reader.string(); + break; + case 3: + message.option = (reader.int32() as any); + break; + case 4: + message.metadata = reader.string(); + break; + case 5: + message.submitTime = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Vote { + const obj = createBaseVote(); + if (isSet(object.proposalId)) obj.proposalId = BigInt(object.proposalId.toString()); + if (isSet(object.voter)) obj.voter = String(object.voter); + if (isSet(object.option)) obj.option = voteOptionFromJSON(object.option); + if (isSet(object.metadata)) obj.metadata = String(object.metadata); + if (isSet(object.submitTime)) obj.submitTime = new Date(object.submitTime); + return obj; + }, + toJSON(message: Vote): JsonSafe { + const obj: any = {}; + message.proposalId !== undefined && (obj.proposalId = (message.proposalId || BigInt(0)).toString()); + message.voter !== undefined && (obj.voter = message.voter); + message.option !== undefined && (obj.option = voteOptionToJSON(message.option)); + message.metadata !== undefined && (obj.metadata = message.metadata); + message.submitTime !== undefined && (obj.submitTime = message.submitTime.toISOString()); + return obj; + }, + fromPartial(object: DeepPartial): Vote { + const message = createBaseVote(); + if (object.proposalId !== undefined && object.proposalId !== null) { + message.proposalId = BigInt(object.proposalId.toString()); + } + message.voter = object.voter ?? ""; + message.option = object.option ?? 0; + message.metadata = object.metadata ?? ""; + message.submitTime = object.submitTime ?? undefined; + return message; + }, + fromSDK(object: VoteSDKType): Vote { + return { + proposalId: object?.proposal_id, + voter: object?.voter, + option: isSet(object.option) ? voteOptionFromJSON(object.option) : -1, + metadata: object?.metadata, + submitTime: object.submit_time ?? undefined + }; + }, + fromSDKJSON(object: any): VoteSDKType { + return { + proposal_id: isSet(object.proposal_id) ? BigInt(object.proposal_id.toString()) : BigInt(0), + voter: isSet(object.voter) ? String(object.voter) : "", + option: isSet(object.option) ? voteOptionFromJSON(object.option) : -1, + metadata: isSet(object.metadata) ? String(object.metadata) : "", + submit_time: isSet(object.submit_time) ? new Date(object.submit_time) : undefined + }; + }, + toSDK(message: Vote): VoteSDKType { + const obj: any = {}; + obj.proposal_id = message.proposalId; + obj.voter = message.voter; + message.option !== undefined && (obj.option = voteOptionToJSON(message.option)); + obj.metadata = message.metadata; + message.submitTime !== undefined && (obj.submit_time = message.submitTime ?? undefined); + return obj; + }, + fromAmino(object: VoteAmino): Vote { + const message = createBaseVote(); + if (object.proposal_id !== undefined && object.proposal_id !== null) { + message.proposalId = BigInt(object.proposal_id); + } + if (object.voter !== undefined && object.voter !== null) { + message.voter = object.voter; + } + if (object.option !== undefined && object.option !== null) { + message.option = object.option; + } + if (object.metadata !== undefined && object.metadata !== null) { + message.metadata = object.metadata; + } + if (object.submit_time !== undefined && object.submit_time !== null) { + message.submitTime = fromTimestamp(Timestamp.fromAmino(object.submit_time)); + } + return message; + }, + toAmino(message: Vote): VoteAmino { + const obj: any = {}; + obj.proposal_id = message.proposalId !== BigInt(0) ? message.proposalId?.toString() : undefined; + obj.voter = message.voter === "" ? undefined : message.voter; + obj.option = message.option === 0 ? undefined : message.option; + obj.metadata = message.metadata === "" ? undefined : message.metadata; + obj.submit_time = message.submitTime ? Timestamp.toAmino(toTimestamp(message.submitTime)) : undefined; + return obj; + }, + fromAminoMsg(object: VoteAminoMsg): Vote { + return Vote.fromAmino(object.value); + }, + toAminoMsg(message: Vote): VoteAminoMsg { + return { + type: "cosmos-sdk/Vote", + value: Vote.toAmino(message) + }; + }, + fromProtoMsg(message: VoteProtoMsg): Vote { + return Vote.decode(message.value); + }, + toProto(message: Vote): Uint8Array { + return Vote.encode(message).finish(); + }, + toProtoMsg(message: Vote): VoteProtoMsg { + return { + typeUrl: "/cosmos.group.v1.Vote", + value: Vote.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/lcd.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/lcd.ts new file mode 100644 index 0000000000..8623b1e3f9 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/lcd.ts @@ -0,0 +1,107 @@ +import { LCDClient } from "@cosmology/lcd"; +export const createLCDClient = async ({ + restEndpoint +}: { + restEndpoint: string; +}) => { + const requestClient = new LCDClient({ + restEndpoint + }); + return { + cosmos: { + auth: { + v1beta1: new (await import("./auth/v1beta1/query.lcd")).LCDQueryClient({ + requestClient + }) + }, + authz: { + v1beta1: new (await import("./authz/v1beta1/query.lcd")).LCDQueryClient({ + requestClient + }) + }, + bank: { + v1beta1: new (await import("./bank/v1beta1/query.lcd")).LCDQueryClient({ + requestClient + }) + }, + base: { + reflection: { + v1beta1: new (await import("./base/reflection/v1beta1/reflection.lcd")).LCDQueryClient({ + requestClient + }), + v2alpha1: new (await import("./base/reflection/v2alpha1/reflection.lcd")).LCDQueryClient({ + requestClient + }) + }, + tendermint: { + v1beta1: new (await import("./base/tendermint/v1beta1/query.lcd")).LCDQueryClient({ + requestClient + }) + } + }, + distribution: { + v1beta1: new (await import("./distribution/v1beta1/query.lcd")).LCDQueryClient({ + requestClient + }) + }, + evidence: { + v1beta1: new (await import("./evidence/v1beta1/query.lcd")).LCDQueryClient({ + requestClient + }) + }, + feegrant: { + v1beta1: new (await import("./feegrant/v1beta1/query.lcd")).LCDQueryClient({ + requestClient + }) + }, + gov: { + v1: new (await import("./gov/v1/query.lcd")).LCDQueryClient({ + requestClient + }), + v1beta1: new (await import("./gov/v1beta1/query.lcd")).LCDQueryClient({ + requestClient + }) + }, + group: { + v1: new (await import("./group/v1/query.lcd")).LCDQueryClient({ + requestClient + }) + }, + mint: { + v1beta1: new (await import("./mint/v1beta1/query.lcd")).LCDQueryClient({ + requestClient + }) + }, + nft: { + v1beta1: new (await import("./nft/v1beta1/query.lcd")).LCDQueryClient({ + requestClient + }) + }, + params: { + v1beta1: new (await import("./params/v1beta1/query.lcd")).LCDQueryClient({ + requestClient + }) + }, + slashing: { + v1beta1: new (await import("./slashing/v1beta1/query.lcd")).LCDQueryClient({ + requestClient + }) + }, + staking: { + v1beta1: new (await import("./staking/v1beta1/query.lcd")).LCDQueryClient({ + requestClient + }) + }, + tx: { + v1beta1: new (await import("./tx/v1beta1/service.lcd")).LCDQueryClient({ + requestClient + }) + }, + upgrade: { + v1beta1: new (await import("./upgrade/v1beta1/query.lcd")).LCDQueryClient({ + requestClient + }) + } + } + }; +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/mint/v1beta1/genesis.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/mint/v1beta1/genesis.ts new file mode 100644 index 0000000000..0e2ff61b68 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/mint/v1beta1/genesis.ts @@ -0,0 +1,136 @@ +import { Minter, MinterSDKType, Params, ParamsSDKType } from "./mint.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "cosmos.mint.v1beta1"; +/** GenesisState defines the mint module's genesis state. */ +export interface GenesisState { + /** minter is a space for holding current inflation information. */ + minter: Minter; + /** params defines all the paramaters of the module. */ + params: Params; +} +export interface GenesisStateProtoMsg { + typeUrl: "/cosmos.mint.v1beta1.GenesisState"; + value: Uint8Array; +} +/** GenesisState defines the mint module's genesis state. */ +export interface GenesisStateSDKType { + minter: MinterSDKType; + params: ParamsSDKType; +} +function createBaseGenesisState(): GenesisState { + return { + minter: Minter.fromPartial({}), + params: Params.fromPartial({}) + }; +} +export const GenesisState = { + typeUrl: "/cosmos.mint.v1beta1.GenesisState", + encode(message: GenesisState, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.minter !== undefined) { + Minter.encode(message.minter, writer.uint32(10).fork()).ldelim(); + } + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GenesisState { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGenesisState(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.minter = Minter.decode(reader, reader.uint32()); + break; + case 2: + message.params = Params.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GenesisState { + const obj = createBaseGenesisState(); + if (isSet(object.minter)) obj.minter = Minter.fromJSON(object.minter); + if (isSet(object.params)) obj.params = Params.fromJSON(object.params); + return obj; + }, + toJSON(message: GenesisState): JsonSafe { + const obj: any = {}; + message.minter !== undefined && (obj.minter = message.minter ? Minter.toJSON(message.minter) : undefined); + message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): GenesisState { + const message = createBaseGenesisState(); + if (object.minter !== undefined && object.minter !== null) { + message.minter = Minter.fromPartial(object.minter); + } + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } + return message; + }, + fromSDK(object: GenesisStateSDKType): GenesisState { + return { + minter: object.minter ? Minter.fromSDK(object.minter) : undefined, + params: object.params ? Params.fromSDK(object.params) : undefined + }; + }, + fromSDKJSON(object: any): GenesisStateSDKType { + return { + minter: isSet(object.minter) ? Minter.fromSDKJSON(object.minter) : undefined, + params: isSet(object.params) ? Params.fromSDKJSON(object.params) : undefined + }; + }, + toSDK(message: GenesisState): GenesisStateSDKType { + const obj: any = {}; + message.minter !== undefined && (obj.minter = message.minter ? Minter.toSDK(message.minter) : undefined); + message.params !== undefined && (obj.params = message.params ? Params.toSDK(message.params) : undefined); + return obj; + }, + fromAmino(object: GenesisStateAmino): GenesisState { + const message = createBaseGenesisState(); + if (object.minter !== undefined && object.minter !== null) { + message.minter = Minter.fromAmino(object.minter); + } + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromAmino(object.params); + } + return message; + }, + toAmino(message: GenesisState): GenesisStateAmino { + const obj: any = {}; + obj.minter = message.minter ? Minter.toAmino(message.minter) : undefined; + obj.params = message.params ? Params.toAmino(message.params) : undefined; + return obj; + }, + fromAminoMsg(object: GenesisStateAminoMsg): GenesisState { + return GenesisState.fromAmino(object.value); + }, + toAminoMsg(message: GenesisState): GenesisStateAminoMsg { + return { + type: "cosmos-sdk/GenesisState", + value: GenesisState.toAmino(message) + }; + }, + fromProtoMsg(message: GenesisStateProtoMsg): GenesisState { + return GenesisState.decode(message.value); + }, + toProto(message: GenesisState): Uint8Array { + return GenesisState.encode(message).finish(); + }, + toProtoMsg(message: GenesisState): GenesisStateProtoMsg { + return { + typeUrl: "/cosmos.mint.v1beta1.GenesisState", + value: GenesisState.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/mint/v1beta1/mint.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/mint/v1beta1/mint.ts new file mode 100644 index 0000000000..313d2b1a56 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/mint/v1beta1/mint.ts @@ -0,0 +1,341 @@ +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { Decimal } from "@cosmjs/math"; +import { isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "cosmos.mint.v1beta1"; +/** Minter represents the minting state. */ +export interface Minter { + /** current annual inflation rate */ + inflation: string; + /** current annual expected provisions */ + annualProvisions: string; +} +export interface MinterProtoMsg { + typeUrl: "/cosmos.mint.v1beta1.Minter"; + value: Uint8Array; +} +/** Minter represents the minting state. */ +export interface MinterSDKType { + inflation: string; + annual_provisions: string; +} +/** Params holds parameters for the mint module. */ +export interface Params { + /** type of coin to mint */ + mintDenom: string; + /** maximum annual change in inflation rate */ + inflationRateChange: string; + /** maximum inflation rate */ + inflationMax: string; + /** minimum inflation rate */ + inflationMin: string; + /** goal of percent bonded atoms */ + goalBonded: string; + /** expected blocks per year */ + blocksPerYear: bigint; +} +export interface ParamsProtoMsg { + typeUrl: "/cosmos.mint.v1beta1.Params"; + value: Uint8Array; +} +/** Params holds parameters for the mint module. */ +export interface ParamsSDKType { + mint_denom: string; + inflation_rate_change: string; + inflation_max: string; + inflation_min: string; + goal_bonded: string; + blocks_per_year: bigint; +} +function createBaseMinter(): Minter { + return { + inflation: "", + annualProvisions: "" + }; +} +export const Minter = { + typeUrl: "/cosmos.mint.v1beta1.Minter", + encode(message: Minter, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.inflation !== undefined) { + writer.uint32(10).string(Decimal.fromUserInput(message.inflation, 18).atomics); + } + if (message.annualProvisions !== undefined) { + writer.uint32(18).string(Decimal.fromUserInput(message.annualProvisions, 18).atomics); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Minter { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMinter(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.inflation = Decimal.fromAtomics(reader.string(), 18).toString(); + break; + case 2: + message.annualProvisions = Decimal.fromAtomics(reader.string(), 18).toString(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Minter { + const obj = createBaseMinter(); + if (isSet(object.inflation)) obj.inflation = String(object.inflation); + if (isSet(object.annualProvisions)) obj.annualProvisions = String(object.annualProvisions); + return obj; + }, + toJSON(message: Minter): JsonSafe { + const obj: any = {}; + message.inflation !== undefined && (obj.inflation = message.inflation); + message.annualProvisions !== undefined && (obj.annualProvisions = message.annualProvisions); + return obj; + }, + fromPartial(object: DeepPartial): Minter { + const message = createBaseMinter(); + message.inflation = object.inflation ?? ""; + message.annualProvisions = object.annualProvisions ?? ""; + return message; + }, + fromSDK(object: MinterSDKType): Minter { + return { + inflation: object?.inflation, + annualProvisions: object?.annual_provisions + }; + }, + fromSDKJSON(object: any): MinterSDKType { + return { + inflation: isSet(object.inflation) ? String(object.inflation) : "", + annual_provisions: isSet(object.annual_provisions) ? String(object.annual_provisions) : "" + }; + }, + toSDK(message: Minter): MinterSDKType { + const obj: any = {}; + obj.inflation = message.inflation; + obj.annual_provisions = message.annualProvisions; + return obj; + }, + fromAmino(object: MinterAmino): Minter { + const message = createBaseMinter(); + if (object.inflation !== undefined && object.inflation !== null) { + message.inflation = object.inflation; + } + if (object.annual_provisions !== undefined && object.annual_provisions !== null) { + message.annualProvisions = object.annual_provisions; + } + return message; + }, + toAmino(message: Minter): MinterAmino { + const obj: any = {}; + obj.inflation = message.inflation === "" ? undefined : message.inflation; + obj.annual_provisions = message.annualProvisions === "" ? undefined : message.annualProvisions; + return obj; + }, + fromAminoMsg(object: MinterAminoMsg): Minter { + return Minter.fromAmino(object.value); + }, + toAminoMsg(message: Minter): MinterAminoMsg { + return { + type: "cosmos-sdk/Minter", + value: Minter.toAmino(message) + }; + }, + fromProtoMsg(message: MinterProtoMsg): Minter { + return Minter.decode(message.value); + }, + toProto(message: Minter): Uint8Array { + return Minter.encode(message).finish(); + }, + toProtoMsg(message: Minter): MinterProtoMsg { + return { + typeUrl: "/cosmos.mint.v1beta1.Minter", + value: Minter.encode(message).finish() + }; + } +}; +function createBaseParams(): Params { + return { + mintDenom: "", + inflationRateChange: "", + inflationMax: "", + inflationMin: "", + goalBonded: "", + blocksPerYear: BigInt(0) + }; +} +export const Params = { + typeUrl: "/cosmos.mint.v1beta1.Params", + encode(message: Params, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.mintDenom !== undefined) { + writer.uint32(10).string(message.mintDenom); + } + if (message.inflationRateChange !== undefined) { + writer.uint32(18).string(Decimal.fromUserInput(message.inflationRateChange, 18).atomics); + } + if (message.inflationMax !== undefined) { + writer.uint32(26).string(Decimal.fromUserInput(message.inflationMax, 18).atomics); + } + if (message.inflationMin !== undefined) { + writer.uint32(34).string(Decimal.fromUserInput(message.inflationMin, 18).atomics); + } + if (message.goalBonded !== undefined) { + writer.uint32(42).string(Decimal.fromUserInput(message.goalBonded, 18).atomics); + } + if (message.blocksPerYear !== undefined) { + writer.uint32(48).uint64(message.blocksPerYear); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Params { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseParams(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.mintDenom = reader.string(); + break; + case 2: + message.inflationRateChange = Decimal.fromAtomics(reader.string(), 18).toString(); + break; + case 3: + message.inflationMax = Decimal.fromAtomics(reader.string(), 18).toString(); + break; + case 4: + message.inflationMin = Decimal.fromAtomics(reader.string(), 18).toString(); + break; + case 5: + message.goalBonded = Decimal.fromAtomics(reader.string(), 18).toString(); + break; + case 6: + message.blocksPerYear = reader.uint64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Params { + const obj = createBaseParams(); + if (isSet(object.mintDenom)) obj.mintDenom = String(object.mintDenom); + if (isSet(object.inflationRateChange)) obj.inflationRateChange = String(object.inflationRateChange); + if (isSet(object.inflationMax)) obj.inflationMax = String(object.inflationMax); + if (isSet(object.inflationMin)) obj.inflationMin = String(object.inflationMin); + if (isSet(object.goalBonded)) obj.goalBonded = String(object.goalBonded); + if (isSet(object.blocksPerYear)) obj.blocksPerYear = BigInt(object.blocksPerYear.toString()); + return obj; + }, + toJSON(message: Params): JsonSafe { + const obj: any = {}; + message.mintDenom !== undefined && (obj.mintDenom = message.mintDenom); + message.inflationRateChange !== undefined && (obj.inflationRateChange = message.inflationRateChange); + message.inflationMax !== undefined && (obj.inflationMax = message.inflationMax); + message.inflationMin !== undefined && (obj.inflationMin = message.inflationMin); + message.goalBonded !== undefined && (obj.goalBonded = message.goalBonded); + message.blocksPerYear !== undefined && (obj.blocksPerYear = (message.blocksPerYear || BigInt(0)).toString()); + return obj; + }, + fromPartial(object: DeepPartial): Params { + const message = createBaseParams(); + message.mintDenom = object.mintDenom ?? ""; + message.inflationRateChange = object.inflationRateChange ?? ""; + message.inflationMax = object.inflationMax ?? ""; + message.inflationMin = object.inflationMin ?? ""; + message.goalBonded = object.goalBonded ?? ""; + if (object.blocksPerYear !== undefined && object.blocksPerYear !== null) { + message.blocksPerYear = BigInt(object.blocksPerYear.toString()); + } + return message; + }, + fromSDK(object: ParamsSDKType): Params { + return { + mintDenom: object?.mint_denom, + inflationRateChange: object?.inflation_rate_change, + inflationMax: object?.inflation_max, + inflationMin: object?.inflation_min, + goalBonded: object?.goal_bonded, + blocksPerYear: object?.blocks_per_year + }; + }, + fromSDKJSON(object: any): ParamsSDKType { + return { + mint_denom: isSet(object.mint_denom) ? String(object.mint_denom) : "", + inflation_rate_change: isSet(object.inflation_rate_change) ? String(object.inflation_rate_change) : "", + inflation_max: isSet(object.inflation_max) ? String(object.inflation_max) : "", + inflation_min: isSet(object.inflation_min) ? String(object.inflation_min) : "", + goal_bonded: isSet(object.goal_bonded) ? String(object.goal_bonded) : "", + blocks_per_year: isSet(object.blocks_per_year) ? BigInt(object.blocks_per_year.toString()) : BigInt(0) + }; + }, + toSDK(message: Params): ParamsSDKType { + const obj: any = {}; + obj.mint_denom = message.mintDenom; + obj.inflation_rate_change = message.inflationRateChange; + obj.inflation_max = message.inflationMax; + obj.inflation_min = message.inflationMin; + obj.goal_bonded = message.goalBonded; + obj.blocks_per_year = message.blocksPerYear; + return obj; + }, + fromAmino(object: ParamsAmino): Params { + const message = createBaseParams(); + if (object.mint_denom !== undefined && object.mint_denom !== null) { + message.mintDenom = object.mint_denom; + } + if (object.inflation_rate_change !== undefined && object.inflation_rate_change !== null) { + message.inflationRateChange = object.inflation_rate_change; + } + if (object.inflation_max !== undefined && object.inflation_max !== null) { + message.inflationMax = object.inflation_max; + } + if (object.inflation_min !== undefined && object.inflation_min !== null) { + message.inflationMin = object.inflation_min; + } + if (object.goal_bonded !== undefined && object.goal_bonded !== null) { + message.goalBonded = object.goal_bonded; + } + if (object.blocks_per_year !== undefined && object.blocks_per_year !== null) { + message.blocksPerYear = BigInt(object.blocks_per_year); + } + return message; + }, + toAmino(message: Params): ParamsAmino { + const obj: any = {}; + obj.mint_denom = message.mintDenom === "" ? undefined : message.mintDenom; + obj.inflation_rate_change = message.inflationRateChange === "" ? undefined : message.inflationRateChange; + obj.inflation_max = message.inflationMax === "" ? undefined : message.inflationMax; + obj.inflation_min = message.inflationMin === "" ? undefined : message.inflationMin; + obj.goal_bonded = message.goalBonded === "" ? undefined : message.goalBonded; + obj.blocks_per_year = message.blocksPerYear !== BigInt(0) ? message.blocksPerYear?.toString() : undefined; + return obj; + }, + fromAminoMsg(object: ParamsAminoMsg): Params { + return Params.fromAmino(object.value); + }, + toAminoMsg(message: Params): ParamsAminoMsg { + return { + type: "cosmos-sdk/Params", + value: Params.toAmino(message) + }; + }, + fromProtoMsg(message: ParamsProtoMsg): Params { + return Params.decode(message.value); + }, + toProto(message: Params): Uint8Array { + return Params.encode(message).finish(); + }, + toProtoMsg(message: Params): ParamsProtoMsg { + return { + typeUrl: "/cosmos.mint.v1beta1.Params", + value: Params.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/mint/v1beta1/query.lcd.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/mint/v1beta1/query.lcd.ts new file mode 100644 index 0000000000..7e3077001b --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/mint/v1beta1/query.lcd.ts @@ -0,0 +1,31 @@ +import { Params, ParamsSDKType } from "./mint.js"; +import { LCDClient } from "@cosmology/lcd"; +import { QueryParamsRequest, QueryParamsRequestSDKType, QueryParamsResponse, QueryParamsResponseSDKType, QueryInflationRequest, QueryInflationRequestSDKType, QueryInflationResponse, QueryInflationResponseSDKType, QueryAnnualProvisionsRequest, QueryAnnualProvisionsRequestSDKType, QueryAnnualProvisionsResponse, QueryAnnualProvisionsResponseSDKType } from "./query.js"; +export class LCDQueryClient { + req: LCDClient; + constructor({ + requestClient + }: { + requestClient: LCDClient; + }) { + this.req = requestClient; + this.params = this.params.bind(this); + this.inflation = this.inflation.bind(this); + this.annualProvisions = this.annualProvisions.bind(this); + } + /* Params returns the total set of minting parameters. */ + async params(_params: QueryParamsRequest = {}): Promise { + const endpoint = `cosmos/mint/v1beta1/params`; + return QueryParamsResponse.fromSDKJSON(await this.req.get(endpoint)); + } + /* Inflation returns the current minting inflation value. */ + async inflation(_params: QueryInflationRequest = {}): Promise { + const endpoint = `cosmos/mint/v1beta1/inflation`; + return QueryInflationResponse.fromSDKJSON(await this.req.get(endpoint)); + } + /* AnnualProvisions current minting annual provisions value. */ + async annualProvisions(_params: QueryAnnualProvisionsRequest = {}): Promise { + const endpoint = `cosmos/mint/v1beta1/annual_provisions`; + return QueryAnnualProvisionsResponse.fromSDKJSON(await this.req.get(endpoint)); + } +} \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/mint/v1beta1/query.rpc.Query.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/mint/v1beta1/query.rpc.Query.ts new file mode 100644 index 0000000000..60a24be7ad --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/mint/v1beta1/query.rpc.Query.ts @@ -0,0 +1,53 @@ +import { Params, ParamsSDKType } from "./mint.js"; +import { Rpc } from "../../../helpers.js"; +import { BinaryReader } from "../../../binary.js"; +import { QueryClient, createProtobufRpcClient } from "@cosmjs/stargate"; +import { QueryParamsRequest, QueryParamsRequestSDKType, QueryParamsResponse, QueryParamsResponseSDKType, QueryInflationRequest, QueryInflationRequestSDKType, QueryInflationResponse, QueryInflationResponseSDKType, QueryAnnualProvisionsRequest, QueryAnnualProvisionsRequestSDKType, QueryAnnualProvisionsResponse, QueryAnnualProvisionsResponseSDKType } from "./query.js"; +/** Query provides defines the gRPC querier service. */ +export interface Query { + /** Params returns the total set of minting parameters. */ + params(request?: QueryParamsRequest): Promise; + /** Inflation returns the current minting inflation value. */ + inflation(request?: QueryInflationRequest): Promise; + /** AnnualProvisions current minting annual provisions value. */ + annualProvisions(request?: QueryAnnualProvisionsRequest): Promise; +} +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + this.params = this.params.bind(this); + this.inflation = this.inflation.bind(this); + this.annualProvisions = this.annualProvisions.bind(this); + } + params(request: QueryParamsRequest = {}): Promise { + const data = QueryParamsRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.mint.v1beta1.Query", "Params", data); + return promise.then(data => QueryParamsResponse.decode(new BinaryReader(data))); + } + inflation(request: QueryInflationRequest = {}): Promise { + const data = QueryInflationRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.mint.v1beta1.Query", "Inflation", data); + return promise.then(data => QueryInflationResponse.decode(new BinaryReader(data))); + } + annualProvisions(request: QueryAnnualProvisionsRequest = {}): Promise { + const data = QueryAnnualProvisionsRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.mint.v1beta1.Query", "AnnualProvisions", data); + return promise.then(data => QueryAnnualProvisionsResponse.decode(new BinaryReader(data))); + } +} +export const createRpcQueryExtension = (base: QueryClient) => { + const rpc = createProtobufRpcClient(base); + const queryService = new QueryClientImpl(rpc); + return { + params(request?: QueryParamsRequest): Promise { + return queryService.params(request); + }, + inflation(request?: QueryInflationRequest): Promise { + return queryService.inflation(request); + }, + annualProvisions(request?: QueryAnnualProvisionsRequest): Promise { + return queryService.annualProvisions(request); + } + }; +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/mint/v1beta1/query.rpc.func.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/mint/v1beta1/query.rpc.func.ts new file mode 100644 index 0000000000..90b30fdc19 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/mint/v1beta1/query.rpc.func.ts @@ -0,0 +1,36 @@ +import { RpcResolver, buildQuery } from "../../../helper-func-types"; +import { buildUseQuery } from "../../../react-query"; +import { QueryParamsRequest, QueryParamsResponse, QueryInflationRequest, QueryInflationResponse, QueryAnnualProvisionsRequest, QueryAnnualProvisionsResponse } from "./query"; +export const createGetParams = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryParamsRequest.encode, + decode: QueryParamsResponse.decode, + service: "cosmos.mint.v1beta1.Query", + method: "Params", + getRpcInstance: getRpcInstance +}); +export const useGetParams = buildUseQuery({ + builderQueryFn: createGetParams, + queryKeyPrefix: "ParamsQuery" +}); +export const createGetInflation = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryInflationRequest.encode, + decode: QueryInflationResponse.decode, + service: "cosmos.mint.v1beta1.Query", + method: "Inflation", + getRpcInstance: getRpcInstance +}); +export const useGetInflation = buildUseQuery({ + builderQueryFn: createGetInflation, + queryKeyPrefix: "InflationQuery" +}); +export const createGetAnnualProvisions = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryAnnualProvisionsRequest.encode, + decode: QueryAnnualProvisionsResponse.decode, + service: "cosmos.mint.v1beta1.Query", + method: "AnnualProvisions", + getRpcInstance: getRpcInstance +}); +export const useGetAnnualProvisions = buildUseQuery({ + builderQueryFn: createGetAnnualProvisions, + queryKeyPrefix: "AnnualProvisionsQuery" +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/mint/v1beta1/query.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/mint/v1beta1/query.ts new file mode 100644 index 0000000000..bedcf3f214 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/mint/v1beta1/query.ts @@ -0,0 +1,592 @@ +import { Params, ParamsSDKType } from "./mint.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { JsonSafe } from "../../../json-safe.js"; +import { DeepPartial, isSet, bytesFromBase64, base64FromBytes } from "../../../helpers.js"; +export const protobufPackage = "cosmos.mint.v1beta1"; +/** QueryParamsRequest is the request type for the Query/Params RPC method. */ +export interface QueryParamsRequest {} +export interface QueryParamsRequestProtoMsg { + typeUrl: "/cosmos.mint.v1beta1.QueryParamsRequest"; + value: Uint8Array; +} +/** QueryParamsRequest is the request type for the Query/Params RPC method. */ +export interface QueryParamsRequestSDKType {} +/** QueryParamsResponse is the response type for the Query/Params RPC method. */ +export interface QueryParamsResponse { + /** params defines the parameters of the module. */ + params: Params; +} +export interface QueryParamsResponseProtoMsg { + typeUrl: "/cosmos.mint.v1beta1.QueryParamsResponse"; + value: Uint8Array; +} +/** QueryParamsResponse is the response type for the Query/Params RPC method. */ +export interface QueryParamsResponseSDKType { + params: ParamsSDKType; +} +/** QueryInflationRequest is the request type for the Query/Inflation RPC method. */ +export interface QueryInflationRequest {} +export interface QueryInflationRequestProtoMsg { + typeUrl: "/cosmos.mint.v1beta1.QueryInflationRequest"; + value: Uint8Array; +} +/** QueryInflationRequest is the request type for the Query/Inflation RPC method. */ +export interface QueryInflationRequestSDKType {} +/** + * QueryInflationResponse is the response type for the Query/Inflation RPC + * method. + */ +export interface QueryInflationResponse { + /** inflation is the current minting inflation value. */ + inflation: Uint8Array; +} +export interface QueryInflationResponseProtoMsg { + typeUrl: "/cosmos.mint.v1beta1.QueryInflationResponse"; + value: Uint8Array; +} +/** + * QueryInflationResponse is the response type for the Query/Inflation RPC + * method. + */ +export interface QueryInflationResponseSDKType { + inflation: Uint8Array; +} +/** + * QueryAnnualProvisionsRequest is the request type for the + * Query/AnnualProvisions RPC method. + */ +export interface QueryAnnualProvisionsRequest {} +export interface QueryAnnualProvisionsRequestProtoMsg { + typeUrl: "/cosmos.mint.v1beta1.QueryAnnualProvisionsRequest"; + value: Uint8Array; +} +/** + * QueryAnnualProvisionsRequest is the request type for the + * Query/AnnualProvisions RPC method. + */ +export interface QueryAnnualProvisionsRequestSDKType {} +/** + * QueryAnnualProvisionsResponse is the response type for the + * Query/AnnualProvisions RPC method. + */ +export interface QueryAnnualProvisionsResponse { + /** annual_provisions is the current minting annual provisions value. */ + annualProvisions: Uint8Array; +} +export interface QueryAnnualProvisionsResponseProtoMsg { + typeUrl: "/cosmos.mint.v1beta1.QueryAnnualProvisionsResponse"; + value: Uint8Array; +} +/** + * QueryAnnualProvisionsResponse is the response type for the + * Query/AnnualProvisions RPC method. + */ +export interface QueryAnnualProvisionsResponseSDKType { + annual_provisions: Uint8Array; +} +function createBaseQueryParamsRequest(): QueryParamsRequest { + return {}; +} +export const QueryParamsRequest = { + typeUrl: "/cosmos.mint.v1beta1.QueryParamsRequest", + encode(_: QueryParamsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryParamsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryParamsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): QueryParamsRequest { + const obj = createBaseQueryParamsRequest(); + return obj; + }, + toJSON(_: QueryParamsRequest): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): QueryParamsRequest { + const message = createBaseQueryParamsRequest(); + return message; + }, + fromSDK(_: QueryParamsRequestSDKType): QueryParamsRequest { + return {}; + }, + fromSDKJSON(_: any): QueryParamsRequestSDKType { + return {}; + }, + toSDK(_: QueryParamsRequest): QueryParamsRequestSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: QueryParamsRequestAmino): QueryParamsRequest { + const message = createBaseQueryParamsRequest(); + return message; + }, + toAmino(_: QueryParamsRequest): QueryParamsRequestAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: QueryParamsRequestAminoMsg): QueryParamsRequest { + return QueryParamsRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryParamsRequest): QueryParamsRequestAminoMsg { + return { + type: "cosmos-sdk/QueryParamsRequest", + value: QueryParamsRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryParamsRequestProtoMsg): QueryParamsRequest { + return QueryParamsRequest.decode(message.value); + }, + toProto(message: QueryParamsRequest): Uint8Array { + return QueryParamsRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryParamsRequest): QueryParamsRequestProtoMsg { + return { + typeUrl: "/cosmos.mint.v1beta1.QueryParamsRequest", + value: QueryParamsRequest.encode(message).finish() + }; + } +}; +function createBaseQueryParamsResponse(): QueryParamsResponse { + return { + params: Params.fromPartial({}) + }; +} +export const QueryParamsResponse = { + typeUrl: "/cosmos.mint.v1beta1.QueryParamsResponse", + encode(message: QueryParamsResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryParamsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryParamsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.params = Params.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryParamsResponse { + const obj = createBaseQueryParamsResponse(); + if (isSet(object.params)) obj.params = Params.fromJSON(object.params); + return obj; + }, + toJSON(message: QueryParamsResponse): JsonSafe { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryParamsResponse { + const message = createBaseQueryParamsResponse(); + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } + return message; + }, + fromSDK(object: QueryParamsResponseSDKType): QueryParamsResponse { + return { + params: object.params ? Params.fromSDK(object.params) : undefined + }; + }, + fromSDKJSON(object: any): QueryParamsResponseSDKType { + return { + params: isSet(object.params) ? Params.fromSDKJSON(object.params) : undefined + }; + }, + toSDK(message: QueryParamsResponse): QueryParamsResponseSDKType { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toSDK(message.params) : undefined); + return obj; + }, + fromAmino(object: QueryParamsResponseAmino): QueryParamsResponse { + const message = createBaseQueryParamsResponse(); + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromAmino(object.params); + } + return message; + }, + toAmino(message: QueryParamsResponse): QueryParamsResponseAmino { + const obj: any = {}; + obj.params = message.params ? Params.toAmino(message.params) : undefined; + return obj; + }, + fromAminoMsg(object: QueryParamsResponseAminoMsg): QueryParamsResponse { + return QueryParamsResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryParamsResponse): QueryParamsResponseAminoMsg { + return { + type: "cosmos-sdk/QueryParamsResponse", + value: QueryParamsResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryParamsResponseProtoMsg): QueryParamsResponse { + return QueryParamsResponse.decode(message.value); + }, + toProto(message: QueryParamsResponse): Uint8Array { + return QueryParamsResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryParamsResponse): QueryParamsResponseProtoMsg { + return { + typeUrl: "/cosmos.mint.v1beta1.QueryParamsResponse", + value: QueryParamsResponse.encode(message).finish() + }; + } +}; +function createBaseQueryInflationRequest(): QueryInflationRequest { + return {}; +} +export const QueryInflationRequest = { + typeUrl: "/cosmos.mint.v1beta1.QueryInflationRequest", + encode(_: QueryInflationRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryInflationRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryInflationRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): QueryInflationRequest { + const obj = createBaseQueryInflationRequest(); + return obj; + }, + toJSON(_: QueryInflationRequest): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): QueryInflationRequest { + const message = createBaseQueryInflationRequest(); + return message; + }, + fromSDK(_: QueryInflationRequestSDKType): QueryInflationRequest { + return {}; + }, + fromSDKJSON(_: any): QueryInflationRequestSDKType { + return {}; + }, + toSDK(_: QueryInflationRequest): QueryInflationRequestSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: QueryInflationRequestAmino): QueryInflationRequest { + const message = createBaseQueryInflationRequest(); + return message; + }, + toAmino(_: QueryInflationRequest): QueryInflationRequestAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: QueryInflationRequestAminoMsg): QueryInflationRequest { + return QueryInflationRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryInflationRequest): QueryInflationRequestAminoMsg { + return { + type: "cosmos-sdk/QueryInflationRequest", + value: QueryInflationRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryInflationRequestProtoMsg): QueryInflationRequest { + return QueryInflationRequest.decode(message.value); + }, + toProto(message: QueryInflationRequest): Uint8Array { + return QueryInflationRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryInflationRequest): QueryInflationRequestProtoMsg { + return { + typeUrl: "/cosmos.mint.v1beta1.QueryInflationRequest", + value: QueryInflationRequest.encode(message).finish() + }; + } +}; +function createBaseQueryInflationResponse(): QueryInflationResponse { + return { + inflation: new Uint8Array() + }; +} +export const QueryInflationResponse = { + typeUrl: "/cosmos.mint.v1beta1.QueryInflationResponse", + encode(message: QueryInflationResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.inflation.length !== 0) { + writer.uint32(10).bytes(message.inflation); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryInflationResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryInflationResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.inflation = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryInflationResponse { + const obj = createBaseQueryInflationResponse(); + if (isSet(object.inflation)) obj.inflation = bytesFromBase64(object.inflation); + return obj; + }, + toJSON(message: QueryInflationResponse): JsonSafe { + const obj: any = {}; + message.inflation !== undefined && (obj.inflation = base64FromBytes(message.inflation !== undefined ? message.inflation : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): QueryInflationResponse { + const message = createBaseQueryInflationResponse(); + message.inflation = object.inflation ?? new Uint8Array(); + return message; + }, + fromSDK(object: QueryInflationResponseSDKType): QueryInflationResponse { + return { + inflation: object?.inflation + }; + }, + fromSDKJSON(object: any): QueryInflationResponseSDKType { + return { + inflation: isSet(object.inflation) ? bytesFromBase64(object.inflation) : new Uint8Array() + }; + }, + toSDK(message: QueryInflationResponse): QueryInflationResponseSDKType { + const obj: any = {}; + obj.inflation = message.inflation; + return obj; + }, + fromAmino(object: QueryInflationResponseAmino): QueryInflationResponse { + const message = createBaseQueryInflationResponse(); + if (object.inflation !== undefined && object.inflation !== null) { + message.inflation = bytesFromBase64(object.inflation); + } + return message; + }, + toAmino(message: QueryInflationResponse): QueryInflationResponseAmino { + const obj: any = {}; + obj.inflation = message.inflation ? base64FromBytes(message.inflation) : undefined; + return obj; + }, + fromAminoMsg(object: QueryInflationResponseAminoMsg): QueryInflationResponse { + return QueryInflationResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryInflationResponse): QueryInflationResponseAminoMsg { + return { + type: "cosmos-sdk/QueryInflationResponse", + value: QueryInflationResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryInflationResponseProtoMsg): QueryInflationResponse { + return QueryInflationResponse.decode(message.value); + }, + toProto(message: QueryInflationResponse): Uint8Array { + return QueryInflationResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryInflationResponse): QueryInflationResponseProtoMsg { + return { + typeUrl: "/cosmos.mint.v1beta1.QueryInflationResponse", + value: QueryInflationResponse.encode(message).finish() + }; + } +}; +function createBaseQueryAnnualProvisionsRequest(): QueryAnnualProvisionsRequest { + return {}; +} +export const QueryAnnualProvisionsRequest = { + typeUrl: "/cosmos.mint.v1beta1.QueryAnnualProvisionsRequest", + encode(_: QueryAnnualProvisionsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryAnnualProvisionsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryAnnualProvisionsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): QueryAnnualProvisionsRequest { + const obj = createBaseQueryAnnualProvisionsRequest(); + return obj; + }, + toJSON(_: QueryAnnualProvisionsRequest): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): QueryAnnualProvisionsRequest { + const message = createBaseQueryAnnualProvisionsRequest(); + return message; + }, + fromSDK(_: QueryAnnualProvisionsRequestSDKType): QueryAnnualProvisionsRequest { + return {}; + }, + fromSDKJSON(_: any): QueryAnnualProvisionsRequestSDKType { + return {}; + }, + toSDK(_: QueryAnnualProvisionsRequest): QueryAnnualProvisionsRequestSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: QueryAnnualProvisionsRequestAmino): QueryAnnualProvisionsRequest { + const message = createBaseQueryAnnualProvisionsRequest(); + return message; + }, + toAmino(_: QueryAnnualProvisionsRequest): QueryAnnualProvisionsRequestAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: QueryAnnualProvisionsRequestAminoMsg): QueryAnnualProvisionsRequest { + return QueryAnnualProvisionsRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryAnnualProvisionsRequest): QueryAnnualProvisionsRequestAminoMsg { + return { + type: "cosmos-sdk/QueryAnnualProvisionsRequest", + value: QueryAnnualProvisionsRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryAnnualProvisionsRequestProtoMsg): QueryAnnualProvisionsRequest { + return QueryAnnualProvisionsRequest.decode(message.value); + }, + toProto(message: QueryAnnualProvisionsRequest): Uint8Array { + return QueryAnnualProvisionsRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryAnnualProvisionsRequest): QueryAnnualProvisionsRequestProtoMsg { + return { + typeUrl: "/cosmos.mint.v1beta1.QueryAnnualProvisionsRequest", + value: QueryAnnualProvisionsRequest.encode(message).finish() + }; + } +}; +function createBaseQueryAnnualProvisionsResponse(): QueryAnnualProvisionsResponse { + return { + annualProvisions: new Uint8Array() + }; +} +export const QueryAnnualProvisionsResponse = { + typeUrl: "/cosmos.mint.v1beta1.QueryAnnualProvisionsResponse", + encode(message: QueryAnnualProvisionsResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.annualProvisions.length !== 0) { + writer.uint32(10).bytes(message.annualProvisions); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryAnnualProvisionsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryAnnualProvisionsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.annualProvisions = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryAnnualProvisionsResponse { + const obj = createBaseQueryAnnualProvisionsResponse(); + if (isSet(object.annualProvisions)) obj.annualProvisions = bytesFromBase64(object.annualProvisions); + return obj; + }, + toJSON(message: QueryAnnualProvisionsResponse): JsonSafe { + const obj: any = {}; + message.annualProvisions !== undefined && (obj.annualProvisions = base64FromBytes(message.annualProvisions !== undefined ? message.annualProvisions : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): QueryAnnualProvisionsResponse { + const message = createBaseQueryAnnualProvisionsResponse(); + message.annualProvisions = object.annualProvisions ?? new Uint8Array(); + return message; + }, + fromSDK(object: QueryAnnualProvisionsResponseSDKType): QueryAnnualProvisionsResponse { + return { + annualProvisions: object?.annual_provisions + }; + }, + fromSDKJSON(object: any): QueryAnnualProvisionsResponseSDKType { + return { + annual_provisions: isSet(object.annual_provisions) ? bytesFromBase64(object.annual_provisions) : new Uint8Array() + }; + }, + toSDK(message: QueryAnnualProvisionsResponse): QueryAnnualProvisionsResponseSDKType { + const obj: any = {}; + obj.annual_provisions = message.annualProvisions; + return obj; + }, + fromAmino(object: QueryAnnualProvisionsResponseAmino): QueryAnnualProvisionsResponse { + const message = createBaseQueryAnnualProvisionsResponse(); + if (object.annual_provisions !== undefined && object.annual_provisions !== null) { + message.annualProvisions = bytesFromBase64(object.annual_provisions); + } + return message; + }, + toAmino(message: QueryAnnualProvisionsResponse): QueryAnnualProvisionsResponseAmino { + const obj: any = {}; + obj.annual_provisions = message.annualProvisions ? base64FromBytes(message.annualProvisions) : undefined; + return obj; + }, + fromAminoMsg(object: QueryAnnualProvisionsResponseAminoMsg): QueryAnnualProvisionsResponse { + return QueryAnnualProvisionsResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryAnnualProvisionsResponse): QueryAnnualProvisionsResponseAminoMsg { + return { + type: "cosmos-sdk/QueryAnnualProvisionsResponse", + value: QueryAnnualProvisionsResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryAnnualProvisionsResponseProtoMsg): QueryAnnualProvisionsResponse { + return QueryAnnualProvisionsResponse.decode(message.value); + }, + toProto(message: QueryAnnualProvisionsResponse): Uint8Array { + return QueryAnnualProvisionsResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryAnnualProvisionsResponse): QueryAnnualProvisionsResponseProtoMsg { + return { + typeUrl: "/cosmos.mint.v1beta1.QueryAnnualProvisionsResponse", + value: QueryAnnualProvisionsResponse.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/msg/v1/msg.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/msg/v1/msg.ts new file mode 100644 index 0000000000..693da49fc4 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/msg/v1/msg.ts @@ -0,0 +1 @@ +export {} \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/nft/v1beta1/event.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/nft/v1beta1/event.ts new file mode 100644 index 0000000000..4acae30a1d --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/nft/v1beta1/event.ts @@ -0,0 +1,455 @@ +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "cosmos.nft.v1beta1"; +/** EventSend is emitted on Msg/Send */ +export interface EventSend { + classId: string; + id: string; + sender: string; + receiver: string; +} +export interface EventSendProtoMsg { + typeUrl: "/cosmos.nft.v1beta1.EventSend"; + value: Uint8Array; +} +/** EventSend is emitted on Msg/Send */ +export interface EventSendSDKType { + class_id: string; + id: string; + sender: string; + receiver: string; +} +/** EventMint is emitted on Mint */ +export interface EventMint { + classId: string; + id: string; + owner: string; +} +export interface EventMintProtoMsg { + typeUrl: "/cosmos.nft.v1beta1.EventMint"; + value: Uint8Array; +} +/** EventMint is emitted on Mint */ +export interface EventMintSDKType { + class_id: string; + id: string; + owner: string; +} +/** EventBurn is emitted on Burn */ +export interface EventBurn { + classId: string; + id: string; + owner: string; +} +export interface EventBurnProtoMsg { + typeUrl: "/cosmos.nft.v1beta1.EventBurn"; + value: Uint8Array; +} +/** EventBurn is emitted on Burn */ +export interface EventBurnSDKType { + class_id: string; + id: string; + owner: string; +} +function createBaseEventSend(): EventSend { + return { + classId: "", + id: "", + sender: "", + receiver: "" + }; +} +export const EventSend = { + typeUrl: "/cosmos.nft.v1beta1.EventSend", + encode(message: EventSend, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.classId !== undefined) { + writer.uint32(10).string(message.classId); + } + if (message.id !== undefined) { + writer.uint32(18).string(message.id); + } + if (message.sender !== undefined) { + writer.uint32(26).string(message.sender); + } + if (message.receiver !== undefined) { + writer.uint32(34).string(message.receiver); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): EventSend { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseEventSend(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.classId = reader.string(); + break; + case 2: + message.id = reader.string(); + break; + case 3: + message.sender = reader.string(); + break; + case 4: + message.receiver = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): EventSend { + const obj = createBaseEventSend(); + if (isSet(object.classId)) obj.classId = String(object.classId); + if (isSet(object.id)) obj.id = String(object.id); + if (isSet(object.sender)) obj.sender = String(object.sender); + if (isSet(object.receiver)) obj.receiver = String(object.receiver); + return obj; + }, + toJSON(message: EventSend): JsonSafe { + const obj: any = {}; + message.classId !== undefined && (obj.classId = message.classId); + message.id !== undefined && (obj.id = message.id); + message.sender !== undefined && (obj.sender = message.sender); + message.receiver !== undefined && (obj.receiver = message.receiver); + return obj; + }, + fromPartial(object: DeepPartial): EventSend { + const message = createBaseEventSend(); + message.classId = object.classId ?? ""; + message.id = object.id ?? ""; + message.sender = object.sender ?? ""; + message.receiver = object.receiver ?? ""; + return message; + }, + fromSDK(object: EventSendSDKType): EventSend { + return { + classId: object?.class_id, + id: object?.id, + sender: object?.sender, + receiver: object?.receiver + }; + }, + fromSDKJSON(object: any): EventSendSDKType { + return { + class_id: isSet(object.class_id) ? String(object.class_id) : "", + id: isSet(object.id) ? String(object.id) : "", + sender: isSet(object.sender) ? String(object.sender) : "", + receiver: isSet(object.receiver) ? String(object.receiver) : "" + }; + }, + toSDK(message: EventSend): EventSendSDKType { + const obj: any = {}; + obj.class_id = message.classId; + obj.id = message.id; + obj.sender = message.sender; + obj.receiver = message.receiver; + return obj; + }, + fromAmino(object: EventSendAmino): EventSend { + const message = createBaseEventSend(); + if (object.class_id !== undefined && object.class_id !== null) { + message.classId = object.class_id; + } + if (object.id !== undefined && object.id !== null) { + message.id = object.id; + } + if (object.sender !== undefined && object.sender !== null) { + message.sender = object.sender; + } + if (object.receiver !== undefined && object.receiver !== null) { + message.receiver = object.receiver; + } + return message; + }, + toAmino(message: EventSend): EventSendAmino { + const obj: any = {}; + obj.class_id = message.classId === "" ? undefined : message.classId; + obj.id = message.id === "" ? undefined : message.id; + obj.sender = message.sender === "" ? undefined : message.sender; + obj.receiver = message.receiver === "" ? undefined : message.receiver; + return obj; + }, + fromAminoMsg(object: EventSendAminoMsg): EventSend { + return EventSend.fromAmino(object.value); + }, + toAminoMsg(message: EventSend): EventSendAminoMsg { + return { + type: "cosmos-sdk/EventSend", + value: EventSend.toAmino(message) + }; + }, + fromProtoMsg(message: EventSendProtoMsg): EventSend { + return EventSend.decode(message.value); + }, + toProto(message: EventSend): Uint8Array { + return EventSend.encode(message).finish(); + }, + toProtoMsg(message: EventSend): EventSendProtoMsg { + return { + typeUrl: "/cosmos.nft.v1beta1.EventSend", + value: EventSend.encode(message).finish() + }; + } +}; +function createBaseEventMint(): EventMint { + return { + classId: "", + id: "", + owner: "" + }; +} +export const EventMint = { + typeUrl: "/cosmos.nft.v1beta1.EventMint", + encode(message: EventMint, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.classId !== undefined) { + writer.uint32(10).string(message.classId); + } + if (message.id !== undefined) { + writer.uint32(18).string(message.id); + } + if (message.owner !== undefined) { + writer.uint32(26).string(message.owner); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): EventMint { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseEventMint(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.classId = reader.string(); + break; + case 2: + message.id = reader.string(); + break; + case 3: + message.owner = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): EventMint { + const obj = createBaseEventMint(); + if (isSet(object.classId)) obj.classId = String(object.classId); + if (isSet(object.id)) obj.id = String(object.id); + if (isSet(object.owner)) obj.owner = String(object.owner); + return obj; + }, + toJSON(message: EventMint): JsonSafe { + const obj: any = {}; + message.classId !== undefined && (obj.classId = message.classId); + message.id !== undefined && (obj.id = message.id); + message.owner !== undefined && (obj.owner = message.owner); + return obj; + }, + fromPartial(object: DeepPartial): EventMint { + const message = createBaseEventMint(); + message.classId = object.classId ?? ""; + message.id = object.id ?? ""; + message.owner = object.owner ?? ""; + return message; + }, + fromSDK(object: EventMintSDKType): EventMint { + return { + classId: object?.class_id, + id: object?.id, + owner: object?.owner + }; + }, + fromSDKJSON(object: any): EventMintSDKType { + return { + class_id: isSet(object.class_id) ? String(object.class_id) : "", + id: isSet(object.id) ? String(object.id) : "", + owner: isSet(object.owner) ? String(object.owner) : "" + }; + }, + toSDK(message: EventMint): EventMintSDKType { + const obj: any = {}; + obj.class_id = message.classId; + obj.id = message.id; + obj.owner = message.owner; + return obj; + }, + fromAmino(object: EventMintAmino): EventMint { + const message = createBaseEventMint(); + if (object.class_id !== undefined && object.class_id !== null) { + message.classId = object.class_id; + } + if (object.id !== undefined && object.id !== null) { + message.id = object.id; + } + if (object.owner !== undefined && object.owner !== null) { + message.owner = object.owner; + } + return message; + }, + toAmino(message: EventMint): EventMintAmino { + const obj: any = {}; + obj.class_id = message.classId === "" ? undefined : message.classId; + obj.id = message.id === "" ? undefined : message.id; + obj.owner = message.owner === "" ? undefined : message.owner; + return obj; + }, + fromAminoMsg(object: EventMintAminoMsg): EventMint { + return EventMint.fromAmino(object.value); + }, + toAminoMsg(message: EventMint): EventMintAminoMsg { + return { + type: "cosmos-sdk/EventMint", + value: EventMint.toAmino(message) + }; + }, + fromProtoMsg(message: EventMintProtoMsg): EventMint { + return EventMint.decode(message.value); + }, + toProto(message: EventMint): Uint8Array { + return EventMint.encode(message).finish(); + }, + toProtoMsg(message: EventMint): EventMintProtoMsg { + return { + typeUrl: "/cosmos.nft.v1beta1.EventMint", + value: EventMint.encode(message).finish() + }; + } +}; +function createBaseEventBurn(): EventBurn { + return { + classId: "", + id: "", + owner: "" + }; +} +export const EventBurn = { + typeUrl: "/cosmos.nft.v1beta1.EventBurn", + encode(message: EventBurn, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.classId !== undefined) { + writer.uint32(10).string(message.classId); + } + if (message.id !== undefined) { + writer.uint32(18).string(message.id); + } + if (message.owner !== undefined) { + writer.uint32(26).string(message.owner); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): EventBurn { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseEventBurn(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.classId = reader.string(); + break; + case 2: + message.id = reader.string(); + break; + case 3: + message.owner = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): EventBurn { + const obj = createBaseEventBurn(); + if (isSet(object.classId)) obj.classId = String(object.classId); + if (isSet(object.id)) obj.id = String(object.id); + if (isSet(object.owner)) obj.owner = String(object.owner); + return obj; + }, + toJSON(message: EventBurn): JsonSafe { + const obj: any = {}; + message.classId !== undefined && (obj.classId = message.classId); + message.id !== undefined && (obj.id = message.id); + message.owner !== undefined && (obj.owner = message.owner); + return obj; + }, + fromPartial(object: DeepPartial): EventBurn { + const message = createBaseEventBurn(); + message.classId = object.classId ?? ""; + message.id = object.id ?? ""; + message.owner = object.owner ?? ""; + return message; + }, + fromSDK(object: EventBurnSDKType): EventBurn { + return { + classId: object?.class_id, + id: object?.id, + owner: object?.owner + }; + }, + fromSDKJSON(object: any): EventBurnSDKType { + return { + class_id: isSet(object.class_id) ? String(object.class_id) : "", + id: isSet(object.id) ? String(object.id) : "", + owner: isSet(object.owner) ? String(object.owner) : "" + }; + }, + toSDK(message: EventBurn): EventBurnSDKType { + const obj: any = {}; + obj.class_id = message.classId; + obj.id = message.id; + obj.owner = message.owner; + return obj; + }, + fromAmino(object: EventBurnAmino): EventBurn { + const message = createBaseEventBurn(); + if (object.class_id !== undefined && object.class_id !== null) { + message.classId = object.class_id; + } + if (object.id !== undefined && object.id !== null) { + message.id = object.id; + } + if (object.owner !== undefined && object.owner !== null) { + message.owner = object.owner; + } + return message; + }, + toAmino(message: EventBurn): EventBurnAmino { + const obj: any = {}; + obj.class_id = message.classId === "" ? undefined : message.classId; + obj.id = message.id === "" ? undefined : message.id; + obj.owner = message.owner === "" ? undefined : message.owner; + return obj; + }, + fromAminoMsg(object: EventBurnAminoMsg): EventBurn { + return EventBurn.fromAmino(object.value); + }, + toAminoMsg(message: EventBurn): EventBurnAminoMsg { + return { + type: "cosmos-sdk/EventBurn", + value: EventBurn.toAmino(message) + }; + }, + fromProtoMsg(message: EventBurnProtoMsg): EventBurn { + return EventBurn.decode(message.value); + }, + toProto(message: EventBurn): Uint8Array { + return EventBurn.encode(message).finish(); + }, + toProtoMsg(message: EventBurn): EventBurnProtoMsg { + return { + typeUrl: "/cosmos.nft.v1beta1.EventBurn", + value: EventBurn.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/nft/v1beta1/genesis.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/nft/v1beta1/genesis.ts new file mode 100644 index 0000000000..ee5576545b --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/nft/v1beta1/genesis.ts @@ -0,0 +1,288 @@ +import { Class, ClassSDKType, NFT, NFTSDKType } from "./nft.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { JsonSafe } from "../../../json-safe.js"; +import { DeepPartial, isSet } from "../../../helpers.js"; +export const protobufPackage = "cosmos.nft.v1beta1"; +/** GenesisState defines the nft module's genesis state. */ +export interface GenesisState { + /** class defines the class of the nft type. */ + classes: Class[]; + entries: Entry[]; +} +export interface GenesisStateProtoMsg { + typeUrl: "/cosmos.nft.v1beta1.GenesisState"; + value: Uint8Array; +} +/** GenesisState defines the nft module's genesis state. */ +export interface GenesisStateSDKType { + classes: ClassSDKType[]; + entries: EntrySDKType[]; +} +/** Entry Defines all nft owned by a person */ +export interface Entry { + /** owner is the owner address of the following nft */ + owner: string; + /** nfts is a group of nfts of the same owner */ + nfts: NFT[]; +} +export interface EntryProtoMsg { + typeUrl: "/cosmos.nft.v1beta1.Entry"; + value: Uint8Array; +} +/** Entry Defines all nft owned by a person */ +export interface EntrySDKType { + owner: string; + nfts: NFTSDKType[]; +} +function createBaseGenesisState(): GenesisState { + return { + classes: [], + entries: [] + }; +} +export const GenesisState = { + typeUrl: "/cosmos.nft.v1beta1.GenesisState", + encode(message: GenesisState, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.classes) { + Class.encode(v!, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.entries) { + Entry.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GenesisState { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGenesisState(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.classes.push(Class.decode(reader, reader.uint32())); + break; + case 2: + message.entries.push(Entry.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GenesisState { + const obj = createBaseGenesisState(); + if (Array.isArray(object?.classes)) obj.classes = object.classes.map((e: any) => Class.fromJSON(e)); + if (Array.isArray(object?.entries)) obj.entries = object.entries.map((e: any) => Entry.fromJSON(e)); + return obj; + }, + toJSON(message: GenesisState): JsonSafe { + const obj: any = {}; + if (message.classes) { + obj.classes = message.classes.map(e => e ? Class.toJSON(e) : undefined); + } else { + obj.classes = []; + } + if (message.entries) { + obj.entries = message.entries.map(e => e ? Entry.toJSON(e) : undefined); + } else { + obj.entries = []; + } + return obj; + }, + fromPartial(object: DeepPartial): GenesisState { + const message = createBaseGenesisState(); + message.classes = object.classes?.map(e => Class.fromPartial(e)) || []; + message.entries = object.entries?.map(e => Entry.fromPartial(e)) || []; + return message; + }, + fromSDK(object: GenesisStateSDKType): GenesisState { + return { + classes: Array.isArray(object?.classes) ? object.classes.map((e: any) => Class.fromSDK(e)) : [], + entries: Array.isArray(object?.entries) ? object.entries.map((e: any) => Entry.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): GenesisStateSDKType { + return { + classes: Array.isArray(object?.classes) ? object.classes.map((e: any) => Class.fromSDKJSON(e)) : [], + entries: Array.isArray(object?.entries) ? object.entries.map((e: any) => Entry.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: GenesisState): GenesisStateSDKType { + const obj: any = {}; + if (message.classes) { + obj.classes = message.classes.map(e => e ? Class.toSDK(e) : undefined); + } else { + obj.classes = []; + } + if (message.entries) { + obj.entries = message.entries.map(e => e ? Entry.toSDK(e) : undefined); + } else { + obj.entries = []; + } + return obj; + }, + fromAmino(object: GenesisStateAmino): GenesisState { + const message = createBaseGenesisState(); + message.classes = object.classes?.map(e => Class.fromAmino(e)) || []; + message.entries = object.entries?.map(e => Entry.fromAmino(e)) || []; + return message; + }, + toAmino(message: GenesisState): GenesisStateAmino { + const obj: any = {}; + if (message.classes) { + obj.classes = message.classes.map(e => e ? Class.toAmino(e) : undefined); + } else { + obj.classes = message.classes; + } + if (message.entries) { + obj.entries = message.entries.map(e => e ? Entry.toAmino(e) : undefined); + } else { + obj.entries = message.entries; + } + return obj; + }, + fromAminoMsg(object: GenesisStateAminoMsg): GenesisState { + return GenesisState.fromAmino(object.value); + }, + toAminoMsg(message: GenesisState): GenesisStateAminoMsg { + return { + type: "cosmos-sdk/GenesisState", + value: GenesisState.toAmino(message) + }; + }, + fromProtoMsg(message: GenesisStateProtoMsg): GenesisState { + return GenesisState.decode(message.value); + }, + toProto(message: GenesisState): Uint8Array { + return GenesisState.encode(message).finish(); + }, + toProtoMsg(message: GenesisState): GenesisStateProtoMsg { + return { + typeUrl: "/cosmos.nft.v1beta1.GenesisState", + value: GenesisState.encode(message).finish() + }; + } +}; +function createBaseEntry(): Entry { + return { + owner: "", + nfts: [] + }; +} +export const Entry = { + typeUrl: "/cosmos.nft.v1beta1.Entry", + encode(message: Entry, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.owner !== undefined) { + writer.uint32(10).string(message.owner); + } + for (const v of message.nfts) { + NFT.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Entry { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseEntry(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.owner = reader.string(); + break; + case 2: + message.nfts.push(NFT.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Entry { + const obj = createBaseEntry(); + if (isSet(object.owner)) obj.owner = String(object.owner); + if (Array.isArray(object?.nfts)) obj.nfts = object.nfts.map((e: any) => NFT.fromJSON(e)); + return obj; + }, + toJSON(message: Entry): JsonSafe { + const obj: any = {}; + message.owner !== undefined && (obj.owner = message.owner); + if (message.nfts) { + obj.nfts = message.nfts.map(e => e ? NFT.toJSON(e) : undefined); + } else { + obj.nfts = []; + } + return obj; + }, + fromPartial(object: DeepPartial): Entry { + const message = createBaseEntry(); + message.owner = object.owner ?? ""; + message.nfts = object.nfts?.map(e => NFT.fromPartial(e)) || []; + return message; + }, + fromSDK(object: EntrySDKType): Entry { + return { + owner: object?.owner, + nfts: Array.isArray(object?.nfts) ? object.nfts.map((e: any) => NFT.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): EntrySDKType { + return { + owner: isSet(object.owner) ? String(object.owner) : "", + nfts: Array.isArray(object?.nfts) ? object.nfts.map((e: any) => NFT.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: Entry): EntrySDKType { + const obj: any = {}; + obj.owner = message.owner; + if (message.nfts) { + obj.nfts = message.nfts.map(e => e ? NFT.toSDK(e) : undefined); + } else { + obj.nfts = []; + } + return obj; + }, + fromAmino(object: EntryAmino): Entry { + const message = createBaseEntry(); + if (object.owner !== undefined && object.owner !== null) { + message.owner = object.owner; + } + message.nfts = object.nfts?.map(e => NFT.fromAmino(e)) || []; + return message; + }, + toAmino(message: Entry): EntryAmino { + const obj: any = {}; + obj.owner = message.owner === "" ? undefined : message.owner; + if (message.nfts) { + obj.nfts = message.nfts.map(e => e ? NFT.toAmino(e) : undefined); + } else { + obj.nfts = message.nfts; + } + return obj; + }, + fromAminoMsg(object: EntryAminoMsg): Entry { + return Entry.fromAmino(object.value); + }, + toAminoMsg(message: Entry): EntryAminoMsg { + return { + type: "cosmos-sdk/Entry", + value: Entry.toAmino(message) + }; + }, + fromProtoMsg(message: EntryProtoMsg): Entry { + return Entry.decode(message.value); + }, + toProto(message: Entry): Uint8Array { + return Entry.encode(message).finish(); + }, + toProtoMsg(message: Entry): EntryProtoMsg { + return { + typeUrl: "/cosmos.nft.v1beta1.Entry", + value: Entry.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/nft/v1beta1/nft.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/nft/v1beta1/nft.ts new file mode 100644 index 0000000000..9ae4741ebd --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/nft/v1beta1/nft.ts @@ -0,0 +1,423 @@ +import { Any, AnySDKType } from "../../../google/protobuf/any.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "cosmos.nft.v1beta1"; +/** Class defines the class of the nft type. */ +export interface Class { + /** id defines the unique identifier of the NFT classification, similar to the contract address of ERC721 */ + id: string; + /** name defines the human-readable name of the NFT classification. Optional */ + name: string; + /** symbol is an abbreviated name for nft classification. Optional */ + symbol: string; + /** description is a brief description of nft classification. Optional */ + description: string; + /** uri for the class metadata stored off chain. It can define schema for Class and NFT `Data` attributes. Optional */ + uri: string; + /** uri_hash is a hash of the document pointed by uri. Optional */ + uriHash: string; + /** data is the app specific metadata of the NFT class. Optional */ + data?: Any; +} +export interface ClassProtoMsg { + typeUrl: "/cosmos.nft.v1beta1.Class"; + value: Uint8Array; +} +/** Class defines the class of the nft type. */ +export interface ClassSDKType { + id: string; + name: string; + symbol: string; + description: string; + uri: string; + uri_hash: string; + data?: AnySDKType; +} +/** NFT defines the NFT. */ +export interface NFT { + /** class_id associated with the NFT, similar to the contract address of ERC721 */ + classId: string; + /** id is a unique identifier of the NFT */ + id: string; + /** uri for the NFT metadata stored off chain */ + uri: string; + /** uri_hash is a hash of the document pointed by uri */ + uriHash: string; + /** data is an app specific data of the NFT. Optional */ + data?: Any; +} +export interface NFTProtoMsg { + typeUrl: "/cosmos.nft.v1beta1.NFT"; + value: Uint8Array; +} +/** NFT defines the NFT. */ +export interface NFTSDKType { + class_id: string; + id: string; + uri: string; + uri_hash: string; + data?: AnySDKType; +} +function createBaseClass(): Class { + return { + id: "", + name: "", + symbol: "", + description: "", + uri: "", + uriHash: "", + data: undefined + }; +} +export const Class = { + typeUrl: "/cosmos.nft.v1beta1.Class", + encode(message: Class, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.id !== undefined) { + writer.uint32(10).string(message.id); + } + if (message.name !== undefined) { + writer.uint32(18).string(message.name); + } + if (message.symbol !== undefined) { + writer.uint32(26).string(message.symbol); + } + if (message.description !== undefined) { + writer.uint32(34).string(message.description); + } + if (message.uri !== undefined) { + writer.uint32(42).string(message.uri); + } + if (message.uriHash !== undefined) { + writer.uint32(50).string(message.uriHash); + } + if (message.data !== undefined) { + Any.encode(message.data, writer.uint32(58).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Class { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseClass(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.id = reader.string(); + break; + case 2: + message.name = reader.string(); + break; + case 3: + message.symbol = reader.string(); + break; + case 4: + message.description = reader.string(); + break; + case 5: + message.uri = reader.string(); + break; + case 6: + message.uriHash = reader.string(); + break; + case 7: + message.data = Any.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Class { + const obj = createBaseClass(); + if (isSet(object.id)) obj.id = String(object.id); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.symbol)) obj.symbol = String(object.symbol); + if (isSet(object.description)) obj.description = String(object.description); + if (isSet(object.uri)) obj.uri = String(object.uri); + if (isSet(object.uriHash)) obj.uriHash = String(object.uriHash); + if (isSet(object.data)) obj.data = Any.fromJSON(object.data); + return obj; + }, + toJSON(message: Class): JsonSafe { + const obj: any = {}; + message.id !== undefined && (obj.id = message.id); + message.name !== undefined && (obj.name = message.name); + message.symbol !== undefined && (obj.symbol = message.symbol); + message.description !== undefined && (obj.description = message.description); + message.uri !== undefined && (obj.uri = message.uri); + message.uriHash !== undefined && (obj.uriHash = message.uriHash); + message.data !== undefined && (obj.data = message.data ? Any.toJSON(message.data) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): Class { + const message = createBaseClass(); + message.id = object.id ?? ""; + message.name = object.name ?? ""; + message.symbol = object.symbol ?? ""; + message.description = object.description ?? ""; + message.uri = object.uri ?? ""; + message.uriHash = object.uriHash ?? ""; + if (object.data !== undefined && object.data !== null) { + message.data = Any.fromPartial(object.data); + } + return message; + }, + fromSDK(object: ClassSDKType): Class { + return { + id: object?.id, + name: object?.name, + symbol: object?.symbol, + description: object?.description, + uri: object?.uri, + uriHash: object?.uri_hash, + data: object.data ? Any.fromSDK(object.data) : undefined + }; + }, + fromSDKJSON(object: any): ClassSDKType { + return { + id: isSet(object.id) ? String(object.id) : "", + name: isSet(object.name) ? String(object.name) : "", + symbol: isSet(object.symbol) ? String(object.symbol) : "", + description: isSet(object.description) ? String(object.description) : "", + uri: isSet(object.uri) ? String(object.uri) : "", + uri_hash: isSet(object.uri_hash) ? String(object.uri_hash) : "", + data: isSet(object.data) ? Any.fromSDKJSON(object.data) : undefined + }; + }, + toSDK(message: Class): ClassSDKType { + const obj: any = {}; + obj.id = message.id; + obj.name = message.name; + obj.symbol = message.symbol; + obj.description = message.description; + obj.uri = message.uri; + obj.uri_hash = message.uriHash; + message.data !== undefined && (obj.data = message.data ? Any.toSDK(message.data) : undefined); + return obj; + }, + fromAmino(object: ClassAmino): Class { + const message = createBaseClass(); + if (object.id !== undefined && object.id !== null) { + message.id = object.id; + } + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + if (object.symbol !== undefined && object.symbol !== null) { + message.symbol = object.symbol; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } + if (object.uri !== undefined && object.uri !== null) { + message.uri = object.uri; + } + if (object.uri_hash !== undefined && object.uri_hash !== null) { + message.uriHash = object.uri_hash; + } + if (object.data !== undefined && object.data !== null) { + message.data = Any.fromAmino(object.data); + } + return message; + }, + toAmino(message: Class): ClassAmino { + const obj: any = {}; + obj.id = message.id === "" ? undefined : message.id; + obj.name = message.name === "" ? undefined : message.name; + obj.symbol = message.symbol === "" ? undefined : message.symbol; + obj.description = message.description === "" ? undefined : message.description; + obj.uri = message.uri === "" ? undefined : message.uri; + obj.uri_hash = message.uriHash === "" ? undefined : message.uriHash; + obj.data = message.data ? Any.toAmino(message.data) : undefined; + return obj; + }, + fromAminoMsg(object: ClassAminoMsg): Class { + return Class.fromAmino(object.value); + }, + toAminoMsg(message: Class): ClassAminoMsg { + return { + type: "cosmos-sdk/Class", + value: Class.toAmino(message) + }; + }, + fromProtoMsg(message: ClassProtoMsg): Class { + return Class.decode(message.value); + }, + toProto(message: Class): Uint8Array { + return Class.encode(message).finish(); + }, + toProtoMsg(message: Class): ClassProtoMsg { + return { + typeUrl: "/cosmos.nft.v1beta1.Class", + value: Class.encode(message).finish() + }; + } +}; +function createBaseNFT(): NFT { + return { + classId: "", + id: "", + uri: "", + uriHash: "", + data: undefined + }; +} +export const NFT = { + typeUrl: "/cosmos.nft.v1beta1.NFT", + encode(message: NFT, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.classId !== undefined) { + writer.uint32(10).string(message.classId); + } + if (message.id !== undefined) { + writer.uint32(18).string(message.id); + } + if (message.uri !== undefined) { + writer.uint32(26).string(message.uri); + } + if (message.uriHash !== undefined) { + writer.uint32(34).string(message.uriHash); + } + if (message.data !== undefined) { + Any.encode(message.data, writer.uint32(82).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): NFT { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseNFT(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.classId = reader.string(); + break; + case 2: + message.id = reader.string(); + break; + case 3: + message.uri = reader.string(); + break; + case 4: + message.uriHash = reader.string(); + break; + case 10: + message.data = Any.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): NFT { + const obj = createBaseNFT(); + if (isSet(object.classId)) obj.classId = String(object.classId); + if (isSet(object.id)) obj.id = String(object.id); + if (isSet(object.uri)) obj.uri = String(object.uri); + if (isSet(object.uriHash)) obj.uriHash = String(object.uriHash); + if (isSet(object.data)) obj.data = Any.fromJSON(object.data); + return obj; + }, + toJSON(message: NFT): JsonSafe { + const obj: any = {}; + message.classId !== undefined && (obj.classId = message.classId); + message.id !== undefined && (obj.id = message.id); + message.uri !== undefined && (obj.uri = message.uri); + message.uriHash !== undefined && (obj.uriHash = message.uriHash); + message.data !== undefined && (obj.data = message.data ? Any.toJSON(message.data) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): NFT { + const message = createBaseNFT(); + message.classId = object.classId ?? ""; + message.id = object.id ?? ""; + message.uri = object.uri ?? ""; + message.uriHash = object.uriHash ?? ""; + if (object.data !== undefined && object.data !== null) { + message.data = Any.fromPartial(object.data); + } + return message; + }, + fromSDK(object: NFTSDKType): NFT { + return { + classId: object?.class_id, + id: object?.id, + uri: object?.uri, + uriHash: object?.uri_hash, + data: object.data ? Any.fromSDK(object.data) : undefined + }; + }, + fromSDKJSON(object: any): NFTSDKType { + return { + class_id: isSet(object.class_id) ? String(object.class_id) : "", + id: isSet(object.id) ? String(object.id) : "", + uri: isSet(object.uri) ? String(object.uri) : "", + uri_hash: isSet(object.uri_hash) ? String(object.uri_hash) : "", + data: isSet(object.data) ? Any.fromSDKJSON(object.data) : undefined + }; + }, + toSDK(message: NFT): NFTSDKType { + const obj: any = {}; + obj.class_id = message.classId; + obj.id = message.id; + obj.uri = message.uri; + obj.uri_hash = message.uriHash; + message.data !== undefined && (obj.data = message.data ? Any.toSDK(message.data) : undefined); + return obj; + }, + fromAmino(object: NFTAmino): NFT { + const message = createBaseNFT(); + if (object.class_id !== undefined && object.class_id !== null) { + message.classId = object.class_id; + } + if (object.id !== undefined && object.id !== null) { + message.id = object.id; + } + if (object.uri !== undefined && object.uri !== null) { + message.uri = object.uri; + } + if (object.uri_hash !== undefined && object.uri_hash !== null) { + message.uriHash = object.uri_hash; + } + if (object.data !== undefined && object.data !== null) { + message.data = Any.fromAmino(object.data); + } + return message; + }, + toAmino(message: NFT): NFTAmino { + const obj: any = {}; + obj.class_id = message.classId === "" ? undefined : message.classId; + obj.id = message.id === "" ? undefined : message.id; + obj.uri = message.uri === "" ? undefined : message.uri; + obj.uri_hash = message.uriHash === "" ? undefined : message.uriHash; + obj.data = message.data ? Any.toAmino(message.data) : undefined; + return obj; + }, + fromAminoMsg(object: NFTAminoMsg): NFT { + return NFT.fromAmino(object.value); + }, + toAminoMsg(message: NFT): NFTAminoMsg { + return { + type: "cosmos-sdk/NFT", + value: NFT.toAmino(message) + }; + }, + fromProtoMsg(message: NFTProtoMsg): NFT { + return NFT.decode(message.value); + }, + toProto(message: NFT): Uint8Array { + return NFT.encode(message).finish(); + }, + toProtoMsg(message: NFT): NFTProtoMsg { + return { + typeUrl: "/cosmos.nft.v1beta1.NFT", + value: NFT.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/nft/v1beta1/query.lcd.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/nft/v1beta1/query.lcd.ts new file mode 100644 index 0000000000..046df45272 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/nft/v1beta1/query.lcd.ts @@ -0,0 +1,78 @@ +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../base/query/v1beta1/pagination.js"; +import { NFT, NFTSDKType, Class, ClassSDKType } from "./nft.js"; +import { setPaginationParams } from "../../../helpers.js"; +import { LCDClient } from "@cosmology/lcd"; +import { QueryBalanceRequest, QueryBalanceRequestSDKType, QueryBalanceResponse, QueryBalanceResponseSDKType, QueryOwnerRequest, QueryOwnerRequestSDKType, QueryOwnerResponse, QueryOwnerResponseSDKType, QuerySupplyRequest, QuerySupplyRequestSDKType, QuerySupplyResponse, QuerySupplyResponseSDKType, QueryNFTsRequest, QueryNFTsRequestSDKType, QueryNFTsResponse, QueryNFTsResponseSDKType, QueryNFTRequest, QueryNFTRequestSDKType, QueryNFTResponse, QueryNFTResponseSDKType, QueryClassRequest, QueryClassRequestSDKType, QueryClassResponse, QueryClassResponseSDKType, QueryClassesRequest, QueryClassesRequestSDKType, QueryClassesResponse, QueryClassesResponseSDKType } from "./query.js"; +export class LCDQueryClient { + req: LCDClient; + constructor({ + requestClient + }: { + requestClient: LCDClient; + }) { + this.req = requestClient; + this.balance = this.balance.bind(this); + this.owner = this.owner.bind(this); + this.supply = this.supply.bind(this); + this.nFTs = this.nFTs.bind(this); + this.nFT = this.nFT.bind(this); + this.class = this.class.bind(this); + this.classes = this.classes.bind(this); + } + /* Balance queries the number of NFTs of a given class owned by the owner, same as balanceOf in ERC721 */ + async balance(params: QueryBalanceRequest): Promise { + const endpoint = `cosmos/nft/v1beta1/balance/${params.owner}/${params.classId}`; + return QueryBalanceResponse.fromSDKJSON(await this.req.get(endpoint)); + } + /* Owner queries the owner of the NFT based on its class and id, same as ownerOf in ERC721 */ + async owner(params: QueryOwnerRequest): Promise { + const endpoint = `cosmos/nft/v1beta1/owner/${params.classId}/${params.id}`; + return QueryOwnerResponse.fromSDKJSON(await this.req.get(endpoint)); + } + /* Supply queries the number of NFTs from the given class, same as totalSupply of ERC721. */ + async supply(params: QuerySupplyRequest): Promise { + const endpoint = `cosmos/nft/v1beta1/supply/${params.classId}`; + return QuerySupplyResponse.fromSDKJSON(await this.req.get(endpoint)); + } + /* NFTs queries all NFTs of a given class or owner,choose at least one of the two, similar to tokenByIndex in + ERC721Enumerable */ + async nFTs(params: QueryNFTsRequest): Promise { + const options: any = { + params: {} + }; + if (typeof params?.classId !== "undefined") { + options.params.class_id = params.classId; + } + if (typeof params?.owner !== "undefined") { + options.params.owner = params.owner; + } + if (typeof params?.pagination !== "undefined") { + setPaginationParams(options, params.pagination); + } + const endpoint = `cosmos/nft/v1beta1/nfts`; + return QueryNFTsResponse.fromSDKJSON(await this.req.get(endpoint, options)); + } + /* NFT queries an NFT based on its class and id. */ + async nFT(params: QueryNFTRequest): Promise { + const endpoint = `cosmos/nft/v1beta1/nfts/${params.classId}/${params.id}`; + return QueryNFTResponse.fromSDKJSON(await this.req.get(endpoint)); + } + /* Class queries an NFT class based on its id */ + async class(params: QueryClassRequest): Promise { + const endpoint = `cosmos/nft/v1beta1/classes/${params.classId}`; + return QueryClassResponse.fromSDKJSON(await this.req.get(endpoint)); + } + /* Classes queries all NFT classes */ + async classes(params: QueryClassesRequest = { + pagination: PageRequest.fromPartial({}) + }): Promise { + const options: any = { + params: {} + }; + if (typeof params?.pagination !== "undefined") { + setPaginationParams(options, params.pagination); + } + const endpoint = `cosmos/nft/v1beta1/classes`; + return QueryClassesResponse.fromSDKJSON(await this.req.get(endpoint, options)); + } +} \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/nft/v1beta1/query.rpc.Query.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/nft/v1beta1/query.rpc.Query.ts new file mode 100644 index 0000000000..abe44f5797 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/nft/v1beta1/query.rpc.Query.ts @@ -0,0 +1,215 @@ +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../base/query/v1beta1/pagination.js"; +import { NFT, NFTSDKType, Class, ClassSDKType } from "./nft.js"; +import { Rpc } from "../../../helpers.js"; +import { BinaryReader } from "../../../binary.js"; +import { QueryClient, createProtobufRpcClient, ProtobufRpcClient } from "@cosmjs/stargate"; +import { ReactQueryParams } from "../../../react-query.js"; +import { useQuery } from "@tanstack/react-query"; +import { QueryBalanceRequest, QueryBalanceRequestSDKType, QueryBalanceResponse, QueryBalanceResponseSDKType, QueryOwnerRequest, QueryOwnerRequestSDKType, QueryOwnerResponse, QueryOwnerResponseSDKType, QuerySupplyRequest, QuerySupplyRequestSDKType, QuerySupplyResponse, QuerySupplyResponseSDKType, QueryNFTsRequest, QueryNFTsRequestSDKType, QueryNFTsResponse, QueryNFTsResponseSDKType, QueryNFTRequest, QueryNFTRequestSDKType, QueryNFTResponse, QueryNFTResponseSDKType, QueryClassRequest, QueryClassRequestSDKType, QueryClassResponse, QueryClassResponseSDKType, QueryClassesRequest, QueryClassesRequestSDKType, QueryClassesResponse, QueryClassesResponseSDKType } from "./query.js"; +/** Query defines the gRPC querier service. */ +export interface Query { + /** Balance queries the number of NFTs of a given class owned by the owner, same as balanceOf in ERC721 */ + balance(request: QueryBalanceRequest): Promise; + /** Owner queries the owner of the NFT based on its class and id, same as ownerOf in ERC721 */ + owner(request: QueryOwnerRequest): Promise; + /** Supply queries the number of NFTs from the given class, same as totalSupply of ERC721. */ + supply(request: QuerySupplyRequest): Promise; + /** + * NFTs queries all NFTs of a given class or owner,choose at least one of the two, similar to tokenByIndex in + * ERC721Enumerable + */ + nFTs(request: QueryNFTsRequest): Promise; + /** NFT queries an NFT based on its class and id. */ + nFT(request: QueryNFTRequest): Promise; + /** Class queries an NFT class based on its id */ + class(request: QueryClassRequest): Promise; + /** Classes queries all NFT classes */ + classes(request?: QueryClassesRequest): Promise; +} +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + this.balance = this.balance.bind(this); + this.owner = this.owner.bind(this); + this.supply = this.supply.bind(this); + this.nFTs = this.nFTs.bind(this); + this.nFT = this.nFT.bind(this); + this.class = this.class.bind(this); + this.classes = this.classes.bind(this); + } + balance(request: QueryBalanceRequest): Promise { + const data = QueryBalanceRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.nft.v1beta1.Query", "Balance", data); + return promise.then(data => QueryBalanceResponse.decode(new BinaryReader(data))); + } + owner(request: QueryOwnerRequest): Promise { + const data = QueryOwnerRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.nft.v1beta1.Query", "Owner", data); + return promise.then(data => QueryOwnerResponse.decode(new BinaryReader(data))); + } + supply(request: QuerySupplyRequest): Promise { + const data = QuerySupplyRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.nft.v1beta1.Query", "Supply", data); + return promise.then(data => QuerySupplyResponse.decode(new BinaryReader(data))); + } + nFTs(request: QueryNFTsRequest): Promise { + const data = QueryNFTsRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.nft.v1beta1.Query", "NFTs", data); + return promise.then(data => QueryNFTsResponse.decode(new BinaryReader(data))); + } + nFT(request: QueryNFTRequest): Promise { + const data = QueryNFTRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.nft.v1beta1.Query", "NFT", data); + return promise.then(data => QueryNFTResponse.decode(new BinaryReader(data))); + } + class(request: QueryClassRequest): Promise { + const data = QueryClassRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.nft.v1beta1.Query", "Class", data); + return promise.then(data => QueryClassResponse.decode(new BinaryReader(data))); + } + classes(request: QueryClassesRequest = { + pagination: PageRequest.fromPartial({}) + }): Promise { + const data = QueryClassesRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.nft.v1beta1.Query", "Classes", data); + return promise.then(data => QueryClassesResponse.decode(new BinaryReader(data))); + } +} +export const createRpcQueryExtension = (base: QueryClient) => { + const rpc = createProtobufRpcClient(base); + const queryService = new QueryClientImpl(rpc); + return { + balance(request: QueryBalanceRequest): Promise { + return queryService.balance(request); + }, + owner(request: QueryOwnerRequest): Promise { + return queryService.owner(request); + }, + supply(request: QuerySupplyRequest): Promise { + return queryService.supply(request); + }, + nFTs(request: QueryNFTsRequest): Promise { + return queryService.nFTs(request); + }, + nFT(request: QueryNFTRequest): Promise { + return queryService.nFT(request); + }, + class(request: QueryClassRequest): Promise { + return queryService.class(request); + }, + classes(request?: QueryClassesRequest): Promise { + return queryService.classes(request); + } + }; +}; +export interface UseBalanceQuery extends ReactQueryParams { + request: QueryBalanceRequest; +} +export interface UseOwnerQuery extends ReactQueryParams { + request: QueryOwnerRequest; +} +export interface UseSupplyQuery extends ReactQueryParams { + request: QuerySupplyRequest; +} +export interface UseNFTsQuery extends ReactQueryParams { + request: QueryNFTsRequest; +} +export interface UseNFTQuery extends ReactQueryParams { + request: QueryNFTRequest; +} +export interface UseClassQuery extends ReactQueryParams { + request: QueryClassRequest; +} +export interface UseClassesQuery extends ReactQueryParams { + request?: QueryClassesRequest; +} +const _queryClients: WeakMap = new WeakMap(); +const getQueryService = (rpc: ProtobufRpcClient | undefined): QueryClientImpl | undefined => { + if (!rpc) return; + if (_queryClients.has(rpc)) { + return _queryClients.get(rpc); + } + const queryService = new QueryClientImpl(rpc); + _queryClients.set(rpc, queryService); + return queryService; +}; +export const createRpcQueryHooks = (rpc: ProtobufRpcClient | undefined) => { + const queryService = getQueryService(rpc); + const useBalance = ({ + request, + options + }: UseBalanceQuery) => { + return useQuery(["balanceQuery", request], () => { + if (!queryService) throw new Error("Query Service not initialized"); + return queryService.balance(request); + }, options); + }; + const useOwner = ({ + request, + options + }: UseOwnerQuery) => { + return useQuery(["ownerQuery", request], () => { + if (!queryService) throw new Error("Query Service not initialized"); + return queryService.owner(request); + }, options); + }; + const useSupply = ({ + request, + options + }: UseSupplyQuery) => { + return useQuery(["supplyQuery", request], () => { + if (!queryService) throw new Error("Query Service not initialized"); + return queryService.supply(request); + }, options); + }; + const useNFTs = ({ + request, + options + }: UseNFTsQuery) => { + return useQuery(["nFTsQuery", request], () => { + if (!queryService) throw new Error("Query Service not initialized"); + return queryService.nFTs(request); + }, options); + }; + const useNFT = ({ + request, + options + }: UseNFTQuery) => { + return useQuery(["nFTQuery", request], () => { + if (!queryService) throw new Error("Query Service not initialized"); + return queryService.nFT(request); + }, options); + }; + const useClass = ({ + request, + options + }: UseClassQuery) => { + return useQuery(["classQuery", request], () => { + if (!queryService) throw new Error("Query Service not initialized"); + return queryService.class(request); + }, options); + }; + const useClasses = ({ + request, + options + }: UseClassesQuery) => { + return useQuery(["classesQuery", request], () => { + if (!queryService) throw new Error("Query Service not initialized"); + return queryService.classes(request); + }, options); + }; + return { + /** Balance queries the number of NFTs of a given class owned by the owner, same as balanceOf in ERC721 */useBalance, + /** Owner queries the owner of the NFT based on its class and id, same as ownerOf in ERC721 */useOwner, + /** Supply queries the number of NFTs from the given class, same as totalSupply of ERC721. */useSupply, + /** + * NFTs queries all NFTs of a given class or owner,choose at least one of the two, similar to tokenByIndex in + * ERC721Enumerable + */ + useNFTs, + /** NFT queries an NFT based on its class and id. */useNFT, + /** Class queries an NFT class based on its id */useClass, + /** Classes queries all NFT classes */useClasses + }; +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/nft/v1beta1/query.rpc.func.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/nft/v1beta1/query.rpc.func.ts new file mode 100644 index 0000000000..06f85a2e8e --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/nft/v1beta1/query.rpc.func.ts @@ -0,0 +1,80 @@ +import { RpcResolver, buildQuery } from "../../../helper-func-types"; +import { buildUseQuery } from "../../../react-query"; +import { QueryBalanceRequest, QueryBalanceResponse, QueryOwnerRequest, QueryOwnerResponse, QuerySupplyRequest, QuerySupplyResponse, QueryNFTsRequest, QueryNFTsResponse, QueryNFTRequest, QueryNFTResponse, QueryClassRequest, QueryClassResponse, QueryClassesRequest, QueryClassesResponse } from "./query"; +export const createGetBalance = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryBalanceRequest.encode, + decode: QueryBalanceResponse.decode, + service: "cosmos.nft.v1beta1.Query", + method: "Balance", + getRpcInstance: getRpcInstance +}); +export const useGetBalance = buildUseQuery({ + builderQueryFn: createGetBalance, + queryKeyPrefix: "BalanceQuery" +}); +export const createGetOwner = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryOwnerRequest.encode, + decode: QueryOwnerResponse.decode, + service: "cosmos.nft.v1beta1.Query", + method: "Owner", + getRpcInstance: getRpcInstance +}); +export const useGetOwner = buildUseQuery({ + builderQueryFn: createGetOwner, + queryKeyPrefix: "OwnerQuery" +}); +export const createGetSupply = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QuerySupplyRequest.encode, + decode: QuerySupplyResponse.decode, + service: "cosmos.nft.v1beta1.Query", + method: "Supply", + getRpcInstance: getRpcInstance +}); +export const useGetSupply = buildUseQuery({ + builderQueryFn: createGetSupply, + queryKeyPrefix: "SupplyQuery" +}); +export const createGetNFTs = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryNFTsRequest.encode, + decode: QueryNFTsResponse.decode, + service: "cosmos.nft.v1beta1.Query", + method: "NFTs", + getRpcInstance: getRpcInstance +}); +export const useGetNFTs = buildUseQuery({ + builderQueryFn: createGetNFTs, + queryKeyPrefix: "NFTsQuery" +}); +export const createGetNFT = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryNFTRequest.encode, + decode: QueryNFTResponse.decode, + service: "cosmos.nft.v1beta1.Query", + method: "NFT", + getRpcInstance: getRpcInstance +}); +export const useGetNFT = buildUseQuery({ + builderQueryFn: createGetNFT, + queryKeyPrefix: "NFTQuery" +}); +export const createGetClass = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryClassRequest.encode, + decode: QueryClassResponse.decode, + service: "cosmos.nft.v1beta1.Query", + method: "Class", + getRpcInstance: getRpcInstance +}); +export const useGetClass = buildUseQuery({ + builderQueryFn: createGetClass, + queryKeyPrefix: "ClassQuery" +}); +export const createGetClasses = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryClassesRequest.encode, + decode: QueryClassesResponse.decode, + service: "cosmos.nft.v1beta1.Query", + method: "Classes", + getRpcInstance: getRpcInstance +}); +export const useGetClasses = buildUseQuery({ + builderQueryFn: createGetClasses, + queryKeyPrefix: "ClassesQuery" +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/nft/v1beta1/query.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/nft/v1beta1/query.ts new file mode 100644 index 0000000000..625bac32e8 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/nft/v1beta1/query.ts @@ -0,0 +1,1660 @@ +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../base/query/v1beta1/pagination.js"; +import { NFT, NFTSDKType, Class, ClassSDKType } from "./nft.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "cosmos.nft.v1beta1"; +/** QueryBalanceRequest is the request type for the Query/Balance RPC method */ +export interface QueryBalanceRequest { + classId: string; + owner: string; +} +export interface QueryBalanceRequestProtoMsg { + typeUrl: "/cosmos.nft.v1beta1.QueryBalanceRequest"; + value: Uint8Array; +} +/** QueryBalanceRequest is the request type for the Query/Balance RPC method */ +export interface QueryBalanceRequestSDKType { + class_id: string; + owner: string; +} +/** QueryBalanceResponse is the response type for the Query/Balance RPC method */ +export interface QueryBalanceResponse { + amount: bigint; +} +export interface QueryBalanceResponseProtoMsg { + typeUrl: "/cosmos.nft.v1beta1.QueryBalanceResponse"; + value: Uint8Array; +} +/** QueryBalanceResponse is the response type for the Query/Balance RPC method */ +export interface QueryBalanceResponseSDKType { + amount: bigint; +} +/** QueryOwnerRequest is the request type for the Query/Owner RPC method */ +export interface QueryOwnerRequest { + classId: string; + id: string; +} +export interface QueryOwnerRequestProtoMsg { + typeUrl: "/cosmos.nft.v1beta1.QueryOwnerRequest"; + value: Uint8Array; +} +/** QueryOwnerRequest is the request type for the Query/Owner RPC method */ +export interface QueryOwnerRequestSDKType { + class_id: string; + id: string; +} +/** QueryOwnerResponse is the response type for the Query/Owner RPC method */ +export interface QueryOwnerResponse { + owner: string; +} +export interface QueryOwnerResponseProtoMsg { + typeUrl: "/cosmos.nft.v1beta1.QueryOwnerResponse"; + value: Uint8Array; +} +/** QueryOwnerResponse is the response type for the Query/Owner RPC method */ +export interface QueryOwnerResponseSDKType { + owner: string; +} +/** QuerySupplyRequest is the request type for the Query/Supply RPC method */ +export interface QuerySupplyRequest { + classId: string; +} +export interface QuerySupplyRequestProtoMsg { + typeUrl: "/cosmos.nft.v1beta1.QuerySupplyRequest"; + value: Uint8Array; +} +/** QuerySupplyRequest is the request type for the Query/Supply RPC method */ +export interface QuerySupplyRequestSDKType { + class_id: string; +} +/** QuerySupplyResponse is the response type for the Query/Supply RPC method */ +export interface QuerySupplyResponse { + amount: bigint; +} +export interface QuerySupplyResponseProtoMsg { + typeUrl: "/cosmos.nft.v1beta1.QuerySupplyResponse"; + value: Uint8Array; +} +/** QuerySupplyResponse is the response type for the Query/Supply RPC method */ +export interface QuerySupplyResponseSDKType { + amount: bigint; +} +/** QueryNFTstRequest is the request type for the Query/NFTs RPC method */ +export interface QueryNFTsRequest { + classId: string; + owner: string; + pagination?: PageRequest; +} +export interface QueryNFTsRequestProtoMsg { + typeUrl: "/cosmos.nft.v1beta1.QueryNFTsRequest"; + value: Uint8Array; +} +/** QueryNFTstRequest is the request type for the Query/NFTs RPC method */ +export interface QueryNFTsRequestSDKType { + class_id: string; + owner: string; + pagination?: PageRequestSDKType; +} +/** QueryNFTsResponse is the response type for the Query/NFTs RPC methods */ +export interface QueryNFTsResponse { + nfts: NFT[]; + pagination?: PageResponse; +} +export interface QueryNFTsResponseProtoMsg { + typeUrl: "/cosmos.nft.v1beta1.QueryNFTsResponse"; + value: Uint8Array; +} +/** QueryNFTsResponse is the response type for the Query/NFTs RPC methods */ +export interface QueryNFTsResponseSDKType { + nfts: NFTSDKType[]; + pagination?: PageResponseSDKType; +} +/** QueryNFTRequest is the request type for the Query/NFT RPC method */ +export interface QueryNFTRequest { + classId: string; + id: string; +} +export interface QueryNFTRequestProtoMsg { + typeUrl: "/cosmos.nft.v1beta1.QueryNFTRequest"; + value: Uint8Array; +} +/** QueryNFTRequest is the request type for the Query/NFT RPC method */ +export interface QueryNFTRequestSDKType { + class_id: string; + id: string; +} +/** QueryNFTResponse is the response type for the Query/NFT RPC method */ +export interface QueryNFTResponse { + nft?: NFT; +} +export interface QueryNFTResponseProtoMsg { + typeUrl: "/cosmos.nft.v1beta1.QueryNFTResponse"; + value: Uint8Array; +} +/** QueryNFTResponse is the response type for the Query/NFT RPC method */ +export interface QueryNFTResponseSDKType { + nft?: NFTSDKType; +} +/** QueryClassRequest is the request type for the Query/Class RPC method */ +export interface QueryClassRequest { + classId: string; +} +export interface QueryClassRequestProtoMsg { + typeUrl: "/cosmos.nft.v1beta1.QueryClassRequest"; + value: Uint8Array; +} +/** QueryClassRequest is the request type for the Query/Class RPC method */ +export interface QueryClassRequestSDKType { + class_id: string; +} +/** QueryClassResponse is the response type for the Query/Class RPC method */ +export interface QueryClassResponse { + class?: Class; +} +export interface QueryClassResponseProtoMsg { + typeUrl: "/cosmos.nft.v1beta1.QueryClassResponse"; + value: Uint8Array; +} +/** QueryClassResponse is the response type for the Query/Class RPC method */ +export interface QueryClassResponseSDKType { + class?: ClassSDKType; +} +/** QueryClassesRequest is the request type for the Query/Classes RPC method */ +export interface QueryClassesRequest { + /** pagination defines an optional pagination for the request. */ + pagination?: PageRequest; +} +export interface QueryClassesRequestProtoMsg { + typeUrl: "/cosmos.nft.v1beta1.QueryClassesRequest"; + value: Uint8Array; +} +/** QueryClassesRequest is the request type for the Query/Classes RPC method */ +export interface QueryClassesRequestSDKType { + pagination?: PageRequestSDKType; +} +/** QueryClassesResponse is the response type for the Query/Classes RPC method */ +export interface QueryClassesResponse { + classes: Class[]; + pagination?: PageResponse; +} +export interface QueryClassesResponseProtoMsg { + typeUrl: "/cosmos.nft.v1beta1.QueryClassesResponse"; + value: Uint8Array; +} +/** QueryClassesResponse is the response type for the Query/Classes RPC method */ +export interface QueryClassesResponseSDKType { + classes: ClassSDKType[]; + pagination?: PageResponseSDKType; +} +function createBaseQueryBalanceRequest(): QueryBalanceRequest { + return { + classId: "", + owner: "" + }; +} +export const QueryBalanceRequest = { + typeUrl: "/cosmos.nft.v1beta1.QueryBalanceRequest", + encode(message: QueryBalanceRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.classId !== undefined) { + writer.uint32(10).string(message.classId); + } + if (message.owner !== undefined) { + writer.uint32(18).string(message.owner); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryBalanceRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryBalanceRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.classId = reader.string(); + break; + case 2: + message.owner = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryBalanceRequest { + const obj = createBaseQueryBalanceRequest(); + if (isSet(object.classId)) obj.classId = String(object.classId); + if (isSet(object.owner)) obj.owner = String(object.owner); + return obj; + }, + toJSON(message: QueryBalanceRequest): JsonSafe { + const obj: any = {}; + message.classId !== undefined && (obj.classId = message.classId); + message.owner !== undefined && (obj.owner = message.owner); + return obj; + }, + fromPartial(object: DeepPartial): QueryBalanceRequest { + const message = createBaseQueryBalanceRequest(); + message.classId = object.classId ?? ""; + message.owner = object.owner ?? ""; + return message; + }, + fromSDK(object: QueryBalanceRequestSDKType): QueryBalanceRequest { + return { + classId: object?.class_id, + owner: object?.owner + }; + }, + fromSDKJSON(object: any): QueryBalanceRequestSDKType { + return { + class_id: isSet(object.class_id) ? String(object.class_id) : "", + owner: isSet(object.owner) ? String(object.owner) : "" + }; + }, + toSDK(message: QueryBalanceRequest): QueryBalanceRequestSDKType { + const obj: any = {}; + obj.class_id = message.classId; + obj.owner = message.owner; + return obj; + }, + fromAmino(object: QueryBalanceRequestAmino): QueryBalanceRequest { + const message = createBaseQueryBalanceRequest(); + if (object.class_id !== undefined && object.class_id !== null) { + message.classId = object.class_id; + } + if (object.owner !== undefined && object.owner !== null) { + message.owner = object.owner; + } + return message; + }, + toAmino(message: QueryBalanceRequest): QueryBalanceRequestAmino { + const obj: any = {}; + obj.class_id = message.classId === "" ? undefined : message.classId; + obj.owner = message.owner === "" ? undefined : message.owner; + return obj; + }, + fromAminoMsg(object: QueryBalanceRequestAminoMsg): QueryBalanceRequest { + return QueryBalanceRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryBalanceRequest): QueryBalanceRequestAminoMsg { + return { + type: "cosmos-sdk/QueryBalanceRequest", + value: QueryBalanceRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryBalanceRequestProtoMsg): QueryBalanceRequest { + return QueryBalanceRequest.decode(message.value); + }, + toProto(message: QueryBalanceRequest): Uint8Array { + return QueryBalanceRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryBalanceRequest): QueryBalanceRequestProtoMsg { + return { + typeUrl: "/cosmos.nft.v1beta1.QueryBalanceRequest", + value: QueryBalanceRequest.encode(message).finish() + }; + } +}; +function createBaseQueryBalanceResponse(): QueryBalanceResponse { + return { + amount: BigInt(0) + }; +} +export const QueryBalanceResponse = { + typeUrl: "/cosmos.nft.v1beta1.QueryBalanceResponse", + encode(message: QueryBalanceResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.amount !== undefined) { + writer.uint32(8).uint64(message.amount); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryBalanceResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryBalanceResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.amount = reader.uint64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryBalanceResponse { + const obj = createBaseQueryBalanceResponse(); + if (isSet(object.amount)) obj.amount = BigInt(object.amount.toString()); + return obj; + }, + toJSON(message: QueryBalanceResponse): JsonSafe { + const obj: any = {}; + message.amount !== undefined && (obj.amount = (message.amount || BigInt(0)).toString()); + return obj; + }, + fromPartial(object: DeepPartial): QueryBalanceResponse { + const message = createBaseQueryBalanceResponse(); + if (object.amount !== undefined && object.amount !== null) { + message.amount = BigInt(object.amount.toString()); + } + return message; + }, + fromSDK(object: QueryBalanceResponseSDKType): QueryBalanceResponse { + return { + amount: object?.amount + }; + }, + fromSDKJSON(object: any): QueryBalanceResponseSDKType { + return { + amount: isSet(object.amount) ? BigInt(object.amount.toString()) : BigInt(0) + }; + }, + toSDK(message: QueryBalanceResponse): QueryBalanceResponseSDKType { + const obj: any = {}; + obj.amount = message.amount; + return obj; + }, + fromAmino(object: QueryBalanceResponseAmino): QueryBalanceResponse { + const message = createBaseQueryBalanceResponse(); + if (object.amount !== undefined && object.amount !== null) { + message.amount = BigInt(object.amount); + } + return message; + }, + toAmino(message: QueryBalanceResponse): QueryBalanceResponseAmino { + const obj: any = {}; + obj.amount = message.amount !== BigInt(0) ? message.amount?.toString() : undefined; + return obj; + }, + fromAminoMsg(object: QueryBalanceResponseAminoMsg): QueryBalanceResponse { + return QueryBalanceResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryBalanceResponse): QueryBalanceResponseAminoMsg { + return { + type: "cosmos-sdk/QueryBalanceResponse", + value: QueryBalanceResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryBalanceResponseProtoMsg): QueryBalanceResponse { + return QueryBalanceResponse.decode(message.value); + }, + toProto(message: QueryBalanceResponse): Uint8Array { + return QueryBalanceResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryBalanceResponse): QueryBalanceResponseProtoMsg { + return { + typeUrl: "/cosmos.nft.v1beta1.QueryBalanceResponse", + value: QueryBalanceResponse.encode(message).finish() + }; + } +}; +function createBaseQueryOwnerRequest(): QueryOwnerRequest { + return { + classId: "", + id: "" + }; +} +export const QueryOwnerRequest = { + typeUrl: "/cosmos.nft.v1beta1.QueryOwnerRequest", + encode(message: QueryOwnerRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.classId !== undefined) { + writer.uint32(10).string(message.classId); + } + if (message.id !== undefined) { + writer.uint32(18).string(message.id); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryOwnerRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryOwnerRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.classId = reader.string(); + break; + case 2: + message.id = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryOwnerRequest { + const obj = createBaseQueryOwnerRequest(); + if (isSet(object.classId)) obj.classId = String(object.classId); + if (isSet(object.id)) obj.id = String(object.id); + return obj; + }, + toJSON(message: QueryOwnerRequest): JsonSafe { + const obj: any = {}; + message.classId !== undefined && (obj.classId = message.classId); + message.id !== undefined && (obj.id = message.id); + return obj; + }, + fromPartial(object: DeepPartial): QueryOwnerRequest { + const message = createBaseQueryOwnerRequest(); + message.classId = object.classId ?? ""; + message.id = object.id ?? ""; + return message; + }, + fromSDK(object: QueryOwnerRequestSDKType): QueryOwnerRequest { + return { + classId: object?.class_id, + id: object?.id + }; + }, + fromSDKJSON(object: any): QueryOwnerRequestSDKType { + return { + class_id: isSet(object.class_id) ? String(object.class_id) : "", + id: isSet(object.id) ? String(object.id) : "" + }; + }, + toSDK(message: QueryOwnerRequest): QueryOwnerRequestSDKType { + const obj: any = {}; + obj.class_id = message.classId; + obj.id = message.id; + return obj; + }, + fromAmino(object: QueryOwnerRequestAmino): QueryOwnerRequest { + const message = createBaseQueryOwnerRequest(); + if (object.class_id !== undefined && object.class_id !== null) { + message.classId = object.class_id; + } + if (object.id !== undefined && object.id !== null) { + message.id = object.id; + } + return message; + }, + toAmino(message: QueryOwnerRequest): QueryOwnerRequestAmino { + const obj: any = {}; + obj.class_id = message.classId === "" ? undefined : message.classId; + obj.id = message.id === "" ? undefined : message.id; + return obj; + }, + fromAminoMsg(object: QueryOwnerRequestAminoMsg): QueryOwnerRequest { + return QueryOwnerRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryOwnerRequest): QueryOwnerRequestAminoMsg { + return { + type: "cosmos-sdk/QueryOwnerRequest", + value: QueryOwnerRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryOwnerRequestProtoMsg): QueryOwnerRequest { + return QueryOwnerRequest.decode(message.value); + }, + toProto(message: QueryOwnerRequest): Uint8Array { + return QueryOwnerRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryOwnerRequest): QueryOwnerRequestProtoMsg { + return { + typeUrl: "/cosmos.nft.v1beta1.QueryOwnerRequest", + value: QueryOwnerRequest.encode(message).finish() + }; + } +}; +function createBaseQueryOwnerResponse(): QueryOwnerResponse { + return { + owner: "" + }; +} +export const QueryOwnerResponse = { + typeUrl: "/cosmos.nft.v1beta1.QueryOwnerResponse", + encode(message: QueryOwnerResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.owner !== undefined) { + writer.uint32(10).string(message.owner); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryOwnerResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryOwnerResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.owner = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryOwnerResponse { + const obj = createBaseQueryOwnerResponse(); + if (isSet(object.owner)) obj.owner = String(object.owner); + return obj; + }, + toJSON(message: QueryOwnerResponse): JsonSafe { + const obj: any = {}; + message.owner !== undefined && (obj.owner = message.owner); + return obj; + }, + fromPartial(object: DeepPartial): QueryOwnerResponse { + const message = createBaseQueryOwnerResponse(); + message.owner = object.owner ?? ""; + return message; + }, + fromSDK(object: QueryOwnerResponseSDKType): QueryOwnerResponse { + return { + owner: object?.owner + }; + }, + fromSDKJSON(object: any): QueryOwnerResponseSDKType { + return { + owner: isSet(object.owner) ? String(object.owner) : "" + }; + }, + toSDK(message: QueryOwnerResponse): QueryOwnerResponseSDKType { + const obj: any = {}; + obj.owner = message.owner; + return obj; + }, + fromAmino(object: QueryOwnerResponseAmino): QueryOwnerResponse { + const message = createBaseQueryOwnerResponse(); + if (object.owner !== undefined && object.owner !== null) { + message.owner = object.owner; + } + return message; + }, + toAmino(message: QueryOwnerResponse): QueryOwnerResponseAmino { + const obj: any = {}; + obj.owner = message.owner === "" ? undefined : message.owner; + return obj; + }, + fromAminoMsg(object: QueryOwnerResponseAminoMsg): QueryOwnerResponse { + return QueryOwnerResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryOwnerResponse): QueryOwnerResponseAminoMsg { + return { + type: "cosmos-sdk/QueryOwnerResponse", + value: QueryOwnerResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryOwnerResponseProtoMsg): QueryOwnerResponse { + return QueryOwnerResponse.decode(message.value); + }, + toProto(message: QueryOwnerResponse): Uint8Array { + return QueryOwnerResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryOwnerResponse): QueryOwnerResponseProtoMsg { + return { + typeUrl: "/cosmos.nft.v1beta1.QueryOwnerResponse", + value: QueryOwnerResponse.encode(message).finish() + }; + } +}; +function createBaseQuerySupplyRequest(): QuerySupplyRequest { + return { + classId: "" + }; +} +export const QuerySupplyRequest = { + typeUrl: "/cosmos.nft.v1beta1.QuerySupplyRequest", + encode(message: QuerySupplyRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.classId !== undefined) { + writer.uint32(10).string(message.classId); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QuerySupplyRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQuerySupplyRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.classId = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QuerySupplyRequest { + const obj = createBaseQuerySupplyRequest(); + if (isSet(object.classId)) obj.classId = String(object.classId); + return obj; + }, + toJSON(message: QuerySupplyRequest): JsonSafe { + const obj: any = {}; + message.classId !== undefined && (obj.classId = message.classId); + return obj; + }, + fromPartial(object: DeepPartial): QuerySupplyRequest { + const message = createBaseQuerySupplyRequest(); + message.classId = object.classId ?? ""; + return message; + }, + fromSDK(object: QuerySupplyRequestSDKType): QuerySupplyRequest { + return { + classId: object?.class_id + }; + }, + fromSDKJSON(object: any): QuerySupplyRequestSDKType { + return { + class_id: isSet(object.class_id) ? String(object.class_id) : "" + }; + }, + toSDK(message: QuerySupplyRequest): QuerySupplyRequestSDKType { + const obj: any = {}; + obj.class_id = message.classId; + return obj; + }, + fromAmino(object: QuerySupplyRequestAmino): QuerySupplyRequest { + const message = createBaseQuerySupplyRequest(); + if (object.class_id !== undefined && object.class_id !== null) { + message.classId = object.class_id; + } + return message; + }, + toAmino(message: QuerySupplyRequest): QuerySupplyRequestAmino { + const obj: any = {}; + obj.class_id = message.classId === "" ? undefined : message.classId; + return obj; + }, + fromAminoMsg(object: QuerySupplyRequestAminoMsg): QuerySupplyRequest { + return QuerySupplyRequest.fromAmino(object.value); + }, + toAminoMsg(message: QuerySupplyRequest): QuerySupplyRequestAminoMsg { + return { + type: "cosmos-sdk/QuerySupplyRequest", + value: QuerySupplyRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QuerySupplyRequestProtoMsg): QuerySupplyRequest { + return QuerySupplyRequest.decode(message.value); + }, + toProto(message: QuerySupplyRequest): Uint8Array { + return QuerySupplyRequest.encode(message).finish(); + }, + toProtoMsg(message: QuerySupplyRequest): QuerySupplyRequestProtoMsg { + return { + typeUrl: "/cosmos.nft.v1beta1.QuerySupplyRequest", + value: QuerySupplyRequest.encode(message).finish() + }; + } +}; +function createBaseQuerySupplyResponse(): QuerySupplyResponse { + return { + amount: BigInt(0) + }; +} +export const QuerySupplyResponse = { + typeUrl: "/cosmos.nft.v1beta1.QuerySupplyResponse", + encode(message: QuerySupplyResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.amount !== undefined) { + writer.uint32(8).uint64(message.amount); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QuerySupplyResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQuerySupplyResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.amount = reader.uint64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QuerySupplyResponse { + const obj = createBaseQuerySupplyResponse(); + if (isSet(object.amount)) obj.amount = BigInt(object.amount.toString()); + return obj; + }, + toJSON(message: QuerySupplyResponse): JsonSafe { + const obj: any = {}; + message.amount !== undefined && (obj.amount = (message.amount || BigInt(0)).toString()); + return obj; + }, + fromPartial(object: DeepPartial): QuerySupplyResponse { + const message = createBaseQuerySupplyResponse(); + if (object.amount !== undefined && object.amount !== null) { + message.amount = BigInt(object.amount.toString()); + } + return message; + }, + fromSDK(object: QuerySupplyResponseSDKType): QuerySupplyResponse { + return { + amount: object?.amount + }; + }, + fromSDKJSON(object: any): QuerySupplyResponseSDKType { + return { + amount: isSet(object.amount) ? BigInt(object.amount.toString()) : BigInt(0) + }; + }, + toSDK(message: QuerySupplyResponse): QuerySupplyResponseSDKType { + const obj: any = {}; + obj.amount = message.amount; + return obj; + }, + fromAmino(object: QuerySupplyResponseAmino): QuerySupplyResponse { + const message = createBaseQuerySupplyResponse(); + if (object.amount !== undefined && object.amount !== null) { + message.amount = BigInt(object.amount); + } + return message; + }, + toAmino(message: QuerySupplyResponse): QuerySupplyResponseAmino { + const obj: any = {}; + obj.amount = message.amount !== BigInt(0) ? message.amount?.toString() : undefined; + return obj; + }, + fromAminoMsg(object: QuerySupplyResponseAminoMsg): QuerySupplyResponse { + return QuerySupplyResponse.fromAmino(object.value); + }, + toAminoMsg(message: QuerySupplyResponse): QuerySupplyResponseAminoMsg { + return { + type: "cosmos-sdk/QuerySupplyResponse", + value: QuerySupplyResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QuerySupplyResponseProtoMsg): QuerySupplyResponse { + return QuerySupplyResponse.decode(message.value); + }, + toProto(message: QuerySupplyResponse): Uint8Array { + return QuerySupplyResponse.encode(message).finish(); + }, + toProtoMsg(message: QuerySupplyResponse): QuerySupplyResponseProtoMsg { + return { + typeUrl: "/cosmos.nft.v1beta1.QuerySupplyResponse", + value: QuerySupplyResponse.encode(message).finish() + }; + } +}; +function createBaseQueryNFTsRequest(): QueryNFTsRequest { + return { + classId: "", + owner: "", + pagination: undefined + }; +} +export const QueryNFTsRequest = { + typeUrl: "/cosmos.nft.v1beta1.QueryNFTsRequest", + encode(message: QueryNFTsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.classId !== undefined) { + writer.uint32(10).string(message.classId); + } + if (message.owner !== undefined) { + writer.uint32(18).string(message.owner); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryNFTsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryNFTsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.classId = reader.string(); + break; + case 2: + message.owner = reader.string(); + break; + case 3: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryNFTsRequest { + const obj = createBaseQueryNFTsRequest(); + if (isSet(object.classId)) obj.classId = String(object.classId); + if (isSet(object.owner)) obj.owner = String(object.owner); + if (isSet(object.pagination)) obj.pagination = PageRequest.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryNFTsRequest): JsonSafe { + const obj: any = {}; + message.classId !== undefined && (obj.classId = message.classId); + message.owner !== undefined && (obj.owner = message.owner); + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryNFTsRequest { + const message = createBaseQueryNFTsRequest(); + message.classId = object.classId ?? ""; + message.owner = object.owner ?? ""; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryNFTsRequestSDKType): QueryNFTsRequest { + return { + classId: object?.class_id, + owner: object?.owner, + pagination: object.pagination ? PageRequest.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryNFTsRequestSDKType { + return { + class_id: isSet(object.class_id) ? String(object.class_id) : "", + owner: isSet(object.owner) ? String(object.owner) : "", + pagination: isSet(object.pagination) ? PageRequest.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryNFTsRequest): QueryNFTsRequestSDKType { + const obj: any = {}; + obj.class_id = message.classId; + obj.owner = message.owner; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryNFTsRequestAmino): QueryNFTsRequest { + const message = createBaseQueryNFTsRequest(); + if (object.class_id !== undefined && object.class_id !== null) { + message.classId = object.class_id; + } + if (object.owner !== undefined && object.owner !== null) { + message.owner = object.owner; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryNFTsRequest): QueryNFTsRequestAmino { + const obj: any = {}; + obj.class_id = message.classId === "" ? undefined : message.classId; + obj.owner = message.owner === "" ? undefined : message.owner; + obj.pagination = message.pagination ? PageRequest.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryNFTsRequestAminoMsg): QueryNFTsRequest { + return QueryNFTsRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryNFTsRequest): QueryNFTsRequestAminoMsg { + return { + type: "cosmos-sdk/QueryNFTsRequest", + value: QueryNFTsRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryNFTsRequestProtoMsg): QueryNFTsRequest { + return QueryNFTsRequest.decode(message.value); + }, + toProto(message: QueryNFTsRequest): Uint8Array { + return QueryNFTsRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryNFTsRequest): QueryNFTsRequestProtoMsg { + return { + typeUrl: "/cosmos.nft.v1beta1.QueryNFTsRequest", + value: QueryNFTsRequest.encode(message).finish() + }; + } +}; +function createBaseQueryNFTsResponse(): QueryNFTsResponse { + return { + nfts: [], + pagination: undefined + }; +} +export const QueryNFTsResponse = { + typeUrl: "/cosmos.nft.v1beta1.QueryNFTsResponse", + encode(message: QueryNFTsResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.nfts) { + NFT.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryNFTsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryNFTsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.nfts.push(NFT.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryNFTsResponse { + const obj = createBaseQueryNFTsResponse(); + if (Array.isArray(object?.nfts)) obj.nfts = object.nfts.map((e: any) => NFT.fromJSON(e)); + if (isSet(object.pagination)) obj.pagination = PageResponse.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryNFTsResponse): JsonSafe { + const obj: any = {}; + if (message.nfts) { + obj.nfts = message.nfts.map(e => e ? NFT.toJSON(e) : undefined); + } else { + obj.nfts = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryNFTsResponse { + const message = createBaseQueryNFTsResponse(); + message.nfts = object.nfts?.map(e => NFT.fromPartial(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryNFTsResponseSDKType): QueryNFTsResponse { + return { + nfts: Array.isArray(object?.nfts) ? object.nfts.map((e: any) => NFT.fromSDK(e)) : [], + pagination: object.pagination ? PageResponse.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryNFTsResponseSDKType { + return { + nfts: Array.isArray(object?.nfts) ? object.nfts.map((e: any) => NFT.fromSDKJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryNFTsResponse): QueryNFTsResponseSDKType { + const obj: any = {}; + if (message.nfts) { + obj.nfts = message.nfts.map(e => e ? NFT.toSDK(e) : undefined); + } else { + obj.nfts = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryNFTsResponseAmino): QueryNFTsResponse { + const message = createBaseQueryNFTsResponse(); + message.nfts = object.nfts?.map(e => NFT.fromAmino(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryNFTsResponse): QueryNFTsResponseAmino { + const obj: any = {}; + if (message.nfts) { + obj.nfts = message.nfts.map(e => e ? NFT.toAmino(e) : undefined); + } else { + obj.nfts = message.nfts; + } + obj.pagination = message.pagination ? PageResponse.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryNFTsResponseAminoMsg): QueryNFTsResponse { + return QueryNFTsResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryNFTsResponse): QueryNFTsResponseAminoMsg { + return { + type: "cosmos-sdk/QueryNFTsResponse", + value: QueryNFTsResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryNFTsResponseProtoMsg): QueryNFTsResponse { + return QueryNFTsResponse.decode(message.value); + }, + toProto(message: QueryNFTsResponse): Uint8Array { + return QueryNFTsResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryNFTsResponse): QueryNFTsResponseProtoMsg { + return { + typeUrl: "/cosmos.nft.v1beta1.QueryNFTsResponse", + value: QueryNFTsResponse.encode(message).finish() + }; + } +}; +function createBaseQueryNFTRequest(): QueryNFTRequest { + return { + classId: "", + id: "" + }; +} +export const QueryNFTRequest = { + typeUrl: "/cosmos.nft.v1beta1.QueryNFTRequest", + encode(message: QueryNFTRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.classId !== undefined) { + writer.uint32(10).string(message.classId); + } + if (message.id !== undefined) { + writer.uint32(18).string(message.id); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryNFTRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryNFTRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.classId = reader.string(); + break; + case 2: + message.id = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryNFTRequest { + const obj = createBaseQueryNFTRequest(); + if (isSet(object.classId)) obj.classId = String(object.classId); + if (isSet(object.id)) obj.id = String(object.id); + return obj; + }, + toJSON(message: QueryNFTRequest): JsonSafe { + const obj: any = {}; + message.classId !== undefined && (obj.classId = message.classId); + message.id !== undefined && (obj.id = message.id); + return obj; + }, + fromPartial(object: DeepPartial): QueryNFTRequest { + const message = createBaseQueryNFTRequest(); + message.classId = object.classId ?? ""; + message.id = object.id ?? ""; + return message; + }, + fromSDK(object: QueryNFTRequestSDKType): QueryNFTRequest { + return { + classId: object?.class_id, + id: object?.id + }; + }, + fromSDKJSON(object: any): QueryNFTRequestSDKType { + return { + class_id: isSet(object.class_id) ? String(object.class_id) : "", + id: isSet(object.id) ? String(object.id) : "" + }; + }, + toSDK(message: QueryNFTRequest): QueryNFTRequestSDKType { + const obj: any = {}; + obj.class_id = message.classId; + obj.id = message.id; + return obj; + }, + fromAmino(object: QueryNFTRequestAmino): QueryNFTRequest { + const message = createBaseQueryNFTRequest(); + if (object.class_id !== undefined && object.class_id !== null) { + message.classId = object.class_id; + } + if (object.id !== undefined && object.id !== null) { + message.id = object.id; + } + return message; + }, + toAmino(message: QueryNFTRequest): QueryNFTRequestAmino { + const obj: any = {}; + obj.class_id = message.classId === "" ? undefined : message.classId; + obj.id = message.id === "" ? undefined : message.id; + return obj; + }, + fromAminoMsg(object: QueryNFTRequestAminoMsg): QueryNFTRequest { + return QueryNFTRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryNFTRequest): QueryNFTRequestAminoMsg { + return { + type: "cosmos-sdk/QueryNFTRequest", + value: QueryNFTRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryNFTRequestProtoMsg): QueryNFTRequest { + return QueryNFTRequest.decode(message.value); + }, + toProto(message: QueryNFTRequest): Uint8Array { + return QueryNFTRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryNFTRequest): QueryNFTRequestProtoMsg { + return { + typeUrl: "/cosmos.nft.v1beta1.QueryNFTRequest", + value: QueryNFTRequest.encode(message).finish() + }; + } +}; +function createBaseQueryNFTResponse(): QueryNFTResponse { + return { + nft: undefined + }; +} +export const QueryNFTResponse = { + typeUrl: "/cosmos.nft.v1beta1.QueryNFTResponse", + encode(message: QueryNFTResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.nft !== undefined) { + NFT.encode(message.nft, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryNFTResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryNFTResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.nft = NFT.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryNFTResponse { + const obj = createBaseQueryNFTResponse(); + if (isSet(object.nft)) obj.nft = NFT.fromJSON(object.nft); + return obj; + }, + toJSON(message: QueryNFTResponse): JsonSafe { + const obj: any = {}; + message.nft !== undefined && (obj.nft = message.nft ? NFT.toJSON(message.nft) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryNFTResponse { + const message = createBaseQueryNFTResponse(); + if (object.nft !== undefined && object.nft !== null) { + message.nft = NFT.fromPartial(object.nft); + } + return message; + }, + fromSDK(object: QueryNFTResponseSDKType): QueryNFTResponse { + return { + nft: object.nft ? NFT.fromSDK(object.nft) : undefined + }; + }, + fromSDKJSON(object: any): QueryNFTResponseSDKType { + return { + nft: isSet(object.nft) ? NFT.fromSDKJSON(object.nft) : undefined + }; + }, + toSDK(message: QueryNFTResponse): QueryNFTResponseSDKType { + const obj: any = {}; + message.nft !== undefined && (obj.nft = message.nft ? NFT.toSDK(message.nft) : undefined); + return obj; + }, + fromAmino(object: QueryNFTResponseAmino): QueryNFTResponse { + const message = createBaseQueryNFTResponse(); + if (object.nft !== undefined && object.nft !== null) { + message.nft = NFT.fromAmino(object.nft); + } + return message; + }, + toAmino(message: QueryNFTResponse): QueryNFTResponseAmino { + const obj: any = {}; + obj.nft = message.nft ? NFT.toAmino(message.nft) : undefined; + return obj; + }, + fromAminoMsg(object: QueryNFTResponseAminoMsg): QueryNFTResponse { + return QueryNFTResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryNFTResponse): QueryNFTResponseAminoMsg { + return { + type: "cosmos-sdk/QueryNFTResponse", + value: QueryNFTResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryNFTResponseProtoMsg): QueryNFTResponse { + return QueryNFTResponse.decode(message.value); + }, + toProto(message: QueryNFTResponse): Uint8Array { + return QueryNFTResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryNFTResponse): QueryNFTResponseProtoMsg { + return { + typeUrl: "/cosmos.nft.v1beta1.QueryNFTResponse", + value: QueryNFTResponse.encode(message).finish() + }; + } +}; +function createBaseQueryClassRequest(): QueryClassRequest { + return { + classId: "" + }; +} +export const QueryClassRequest = { + typeUrl: "/cosmos.nft.v1beta1.QueryClassRequest", + encode(message: QueryClassRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.classId !== undefined) { + writer.uint32(10).string(message.classId); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryClassRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryClassRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.classId = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryClassRequest { + const obj = createBaseQueryClassRequest(); + if (isSet(object.classId)) obj.classId = String(object.classId); + return obj; + }, + toJSON(message: QueryClassRequest): JsonSafe { + const obj: any = {}; + message.classId !== undefined && (obj.classId = message.classId); + return obj; + }, + fromPartial(object: DeepPartial): QueryClassRequest { + const message = createBaseQueryClassRequest(); + message.classId = object.classId ?? ""; + return message; + }, + fromSDK(object: QueryClassRequestSDKType): QueryClassRequest { + return { + classId: object?.class_id + }; + }, + fromSDKJSON(object: any): QueryClassRequestSDKType { + return { + class_id: isSet(object.class_id) ? String(object.class_id) : "" + }; + }, + toSDK(message: QueryClassRequest): QueryClassRequestSDKType { + const obj: any = {}; + obj.class_id = message.classId; + return obj; + }, + fromAmino(object: QueryClassRequestAmino): QueryClassRequest { + const message = createBaseQueryClassRequest(); + if (object.class_id !== undefined && object.class_id !== null) { + message.classId = object.class_id; + } + return message; + }, + toAmino(message: QueryClassRequest): QueryClassRequestAmino { + const obj: any = {}; + obj.class_id = message.classId === "" ? undefined : message.classId; + return obj; + }, + fromAminoMsg(object: QueryClassRequestAminoMsg): QueryClassRequest { + return QueryClassRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryClassRequest): QueryClassRequestAminoMsg { + return { + type: "cosmos-sdk/QueryClassRequest", + value: QueryClassRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryClassRequestProtoMsg): QueryClassRequest { + return QueryClassRequest.decode(message.value); + }, + toProto(message: QueryClassRequest): Uint8Array { + return QueryClassRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryClassRequest): QueryClassRequestProtoMsg { + return { + typeUrl: "/cosmos.nft.v1beta1.QueryClassRequest", + value: QueryClassRequest.encode(message).finish() + }; + } +}; +function createBaseQueryClassResponse(): QueryClassResponse { + return { + class: undefined + }; +} +export const QueryClassResponse = { + typeUrl: "/cosmos.nft.v1beta1.QueryClassResponse", + encode(message: QueryClassResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.class !== undefined) { + Class.encode(message.class, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryClassResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryClassResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.class = Class.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryClassResponse { + const obj = createBaseQueryClassResponse(); + if (isSet(object.class)) obj.class = Class.fromJSON(object.class); + return obj; + }, + toJSON(message: QueryClassResponse): JsonSafe { + const obj: any = {}; + message.class !== undefined && (obj.class = message.class ? Class.toJSON(message.class) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryClassResponse { + const message = createBaseQueryClassResponse(); + if (object.class !== undefined && object.class !== null) { + message.class = Class.fromPartial(object.class); + } + return message; + }, + fromSDK(object: QueryClassResponseSDKType): QueryClassResponse { + return { + class: object.class ? Class.fromSDK(object.class) : undefined + }; + }, + fromSDKJSON(object: any): QueryClassResponseSDKType { + return { + class: isSet(object.class) ? Class.fromSDKJSON(object.class) : undefined + }; + }, + toSDK(message: QueryClassResponse): QueryClassResponseSDKType { + const obj: any = {}; + message.class !== undefined && (obj.class = message.class ? Class.toSDK(message.class) : undefined); + return obj; + }, + fromAmino(object: QueryClassResponseAmino): QueryClassResponse { + const message = createBaseQueryClassResponse(); + if (object.class !== undefined && object.class !== null) { + message.class = Class.fromAmino(object.class); + } + return message; + }, + toAmino(message: QueryClassResponse): QueryClassResponseAmino { + const obj: any = {}; + obj.class = message.class ? Class.toAmino(message.class) : undefined; + return obj; + }, + fromAminoMsg(object: QueryClassResponseAminoMsg): QueryClassResponse { + return QueryClassResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryClassResponse): QueryClassResponseAminoMsg { + return { + type: "cosmos-sdk/QueryClassResponse", + value: QueryClassResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryClassResponseProtoMsg): QueryClassResponse { + return QueryClassResponse.decode(message.value); + }, + toProto(message: QueryClassResponse): Uint8Array { + return QueryClassResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryClassResponse): QueryClassResponseProtoMsg { + return { + typeUrl: "/cosmos.nft.v1beta1.QueryClassResponse", + value: QueryClassResponse.encode(message).finish() + }; + } +}; +function createBaseQueryClassesRequest(): QueryClassesRequest { + return { + pagination: undefined + }; +} +export const QueryClassesRequest = { + typeUrl: "/cosmos.nft.v1beta1.QueryClassesRequest", + encode(message: QueryClassesRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryClassesRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryClassesRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryClassesRequest { + const obj = createBaseQueryClassesRequest(); + if (isSet(object.pagination)) obj.pagination = PageRequest.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryClassesRequest): JsonSafe { + const obj: any = {}; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryClassesRequest { + const message = createBaseQueryClassesRequest(); + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryClassesRequestSDKType): QueryClassesRequest { + return { + pagination: object.pagination ? PageRequest.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryClassesRequestSDKType { + return { + pagination: isSet(object.pagination) ? PageRequest.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryClassesRequest): QueryClassesRequestSDKType { + const obj: any = {}; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryClassesRequestAmino): QueryClassesRequest { + const message = createBaseQueryClassesRequest(); + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryClassesRequest): QueryClassesRequestAmino { + const obj: any = {}; + obj.pagination = message.pagination ? PageRequest.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryClassesRequestAminoMsg): QueryClassesRequest { + return QueryClassesRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryClassesRequest): QueryClassesRequestAminoMsg { + return { + type: "cosmos-sdk/QueryClassesRequest", + value: QueryClassesRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryClassesRequestProtoMsg): QueryClassesRequest { + return QueryClassesRequest.decode(message.value); + }, + toProto(message: QueryClassesRequest): Uint8Array { + return QueryClassesRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryClassesRequest): QueryClassesRequestProtoMsg { + return { + typeUrl: "/cosmos.nft.v1beta1.QueryClassesRequest", + value: QueryClassesRequest.encode(message).finish() + }; + } +}; +function createBaseQueryClassesResponse(): QueryClassesResponse { + return { + classes: [], + pagination: undefined + }; +} +export const QueryClassesResponse = { + typeUrl: "/cosmos.nft.v1beta1.QueryClassesResponse", + encode(message: QueryClassesResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.classes) { + Class.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryClassesResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryClassesResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.classes.push(Class.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryClassesResponse { + const obj = createBaseQueryClassesResponse(); + if (Array.isArray(object?.classes)) obj.classes = object.classes.map((e: any) => Class.fromJSON(e)); + if (isSet(object.pagination)) obj.pagination = PageResponse.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryClassesResponse): JsonSafe { + const obj: any = {}; + if (message.classes) { + obj.classes = message.classes.map(e => e ? Class.toJSON(e) : undefined); + } else { + obj.classes = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryClassesResponse { + const message = createBaseQueryClassesResponse(); + message.classes = object.classes?.map(e => Class.fromPartial(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryClassesResponseSDKType): QueryClassesResponse { + return { + classes: Array.isArray(object?.classes) ? object.classes.map((e: any) => Class.fromSDK(e)) : [], + pagination: object.pagination ? PageResponse.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryClassesResponseSDKType { + return { + classes: Array.isArray(object?.classes) ? object.classes.map((e: any) => Class.fromSDKJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryClassesResponse): QueryClassesResponseSDKType { + const obj: any = {}; + if (message.classes) { + obj.classes = message.classes.map(e => e ? Class.toSDK(e) : undefined); + } else { + obj.classes = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryClassesResponseAmino): QueryClassesResponse { + const message = createBaseQueryClassesResponse(); + message.classes = object.classes?.map(e => Class.fromAmino(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryClassesResponse): QueryClassesResponseAmino { + const obj: any = {}; + if (message.classes) { + obj.classes = message.classes.map(e => e ? Class.toAmino(e) : undefined); + } else { + obj.classes = message.classes; + } + obj.pagination = message.pagination ? PageResponse.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryClassesResponseAminoMsg): QueryClassesResponse { + return QueryClassesResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryClassesResponse): QueryClassesResponseAminoMsg { + return { + type: "cosmos-sdk/QueryClassesResponse", + value: QueryClassesResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryClassesResponseProtoMsg): QueryClassesResponse { + return QueryClassesResponse.decode(message.value); + }, + toProto(message: QueryClassesResponse): Uint8Array { + return QueryClassesResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryClassesResponse): QueryClassesResponseProtoMsg { + return { + typeUrl: "/cosmos.nft.v1beta1.QueryClassesResponse", + value: QueryClassesResponse.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/nft/v1beta1/tx.amino.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/nft/v1beta1/tx.amino.ts new file mode 100644 index 0000000000..631675dca7 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/nft/v1beta1/tx.amino.ts @@ -0,0 +1,42 @@ +import { ReadOnlyAminoMsg as AminoMsg } from "@interchainjs/ReadOnlyAminoMsg"; +import { MsgSend, MsgSendSDKType } from "./tx.js"; +export interface MsgSendAminoType extends AminoMsg { + type: "cosmos-sdk/MsgNFTSend"; + value: { + class_id: string; + id: string; + sender: string; + receiver: string; + }; +} +export const AminoConverter = { + "/cosmos.nft.v1beta1.MsgSend": { + aminoType: "cosmos-sdk/MsgNFTSend", + toAmino: ({ + classId, + id, + sender, + receiver + }: MsgSend): MsgSendAminoType["value"] => { + return { + class_id: classId, + id, + sender, + receiver + }; + }, + fromAmino: ({ + class_id, + id, + sender, + receiver + }: MsgSendAminoType["value"]): MsgSend => { + return { + classId: class_id, + id, + sender, + receiver + }; + } + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/nft/v1beta1/tx.registry.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/nft/v1beta1/tx.registry.ts new file mode 100644 index 0000000000..e56ae140f0 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/nft/v1beta1/tx.registry.ts @@ -0,0 +1,50 @@ +import { GeneratedType, Registry } from "@cosmjs/proto-signing"; +import { MsgSend, MsgSendSDKType } from "./tx.js"; +export const registry: ReadonlyArray<[string, GeneratedType]> = [["/cosmos.nft.v1beta1.MsgSend", MsgSend]]; +export const load = (protoRegistry: Registry) => { + registry.forEach(([typeUrl, mod]) => { + protoRegistry.register(typeUrl, mod); + }); +}; +export const MessageComposer = { + encoded: { + send(value: MsgSend) { + return { + typeUrl: "/cosmos.nft.v1beta1.MsgSend", + value: MsgSend.encode(value).finish() + }; + } + }, + withTypeUrl: { + send(value: MsgSend) { + return { + typeUrl: "/cosmos.nft.v1beta1.MsgSend", + value + }; + } + }, + toJSON: { + send(value: MsgSend) { + return { + typeUrl: "/cosmos.nft.v1beta1.MsgSend", + value: MsgSend.toJSON(value) + }; + } + }, + fromJSON: { + send(value: any) { + return { + typeUrl: "/cosmos.nft.v1beta1.MsgSend", + value: MsgSend.fromJSON(value) + }; + } + }, + fromPartial: { + send(value: MsgSend) { + return { + typeUrl: "/cosmos.nft.v1beta1.MsgSend", + value: MsgSend.fromPartial(value) + }; + } + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/nft/v1beta1/tx.rpc.func.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/nft/v1beta1/tx.rpc.func.ts new file mode 100644 index 0000000000..c2551a90e0 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/nft/v1beta1/tx.rpc.func.ts @@ -0,0 +1,13 @@ +import { buildTx, SigningClientResolver } from "../../../helper-func-types"; +import { buildUseMutation } from "../../../react-query"; +import { toEncoders, toConverters } from "@interchainjs/cosmos/utils"; +import { MsgSend } from "./tx"; +export const createSend = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgSend.typeUrl, + encoders: toEncoders(MsgSend), + converters: toConverters(MsgSend) +}); +export const useSend = buildUseMutation({ + builderMutationFn: createSend +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/nft/v1beta1/tx.rpc.msg.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/nft/v1beta1/tx.rpc.msg.ts new file mode 100644 index 0000000000..4b5be7dfb5 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/nft/v1beta1/tx.rpc.msg.ts @@ -0,0 +1,23 @@ +import { Rpc } from "../../../helpers.js"; +import { BinaryReader } from "../../../binary.js"; +import { MsgSend, MsgSendSDKType, MsgSendResponse, MsgSendResponseSDKType } from "./tx.js"; +/** Msg defines the nft Msg service. */ +export interface Msg { + /** Send defines a method to send a nft from one account to another account. */ + send(request: MsgSend): Promise; +} +export class MsgClientImpl implements Msg { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + this.send = this.send.bind(this); + } + send(request: MsgSend): Promise { + const data = MsgSend.encode(request).finish(); + const promise = this.rpc.request("cosmos.nft.v1beta1.Msg", "Send", data); + return promise.then(data => MsgSendResponse.decode(new BinaryReader(data))); + } +} +export const createClientImpl = (rpc: Rpc) => { + return new MsgClientImpl(rpc); +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/nft/v1beta1/tx.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/nft/v1beta1/tx.ts new file mode 100644 index 0000000000..1406834d09 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/nft/v1beta1/tx.ts @@ -0,0 +1,253 @@ +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "cosmos.nft.v1beta1"; +/** MsgSend represents a message to send a nft from one account to another account. */ +export interface MsgSend { + /** class_id defines the unique identifier of the nft classification, similar to the contract address of ERC721 */ + classId: string; + /** id defines the unique identification of nft */ + id: string; + /** sender is the address of the owner of nft */ + sender: string; + /** receiver is the receiver address of nft */ + receiver: string; +} +export interface MsgSendProtoMsg { + typeUrl: "/cosmos.nft.v1beta1.MsgSend"; + value: Uint8Array; +} +/** MsgSend represents a message to send a nft from one account to another account. */ +export interface MsgSendSDKType { + class_id: string; + id: string; + sender: string; + receiver: string; +} +/** MsgSendResponse defines the Msg/Send response type. */ +export interface MsgSendResponse {} +export interface MsgSendResponseProtoMsg { + typeUrl: "/cosmos.nft.v1beta1.MsgSendResponse"; + value: Uint8Array; +} +/** MsgSendResponse defines the Msg/Send response type. */ +export interface MsgSendResponseSDKType {} +function createBaseMsgSend(): MsgSend { + return { + classId: "", + id: "", + sender: "", + receiver: "" + }; +} +export const MsgSend = { + typeUrl: "/cosmos.nft.v1beta1.MsgSend", + encode(message: MsgSend, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.classId !== undefined) { + writer.uint32(10).string(message.classId); + } + if (message.id !== undefined) { + writer.uint32(18).string(message.id); + } + if (message.sender !== undefined) { + writer.uint32(26).string(message.sender); + } + if (message.receiver !== undefined) { + writer.uint32(34).string(message.receiver); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgSend { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgSend(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.classId = reader.string(); + break; + case 2: + message.id = reader.string(); + break; + case 3: + message.sender = reader.string(); + break; + case 4: + message.receiver = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgSend { + const obj = createBaseMsgSend(); + if (isSet(object.classId)) obj.classId = String(object.classId); + if (isSet(object.id)) obj.id = String(object.id); + if (isSet(object.sender)) obj.sender = String(object.sender); + if (isSet(object.receiver)) obj.receiver = String(object.receiver); + return obj; + }, + toJSON(message: MsgSend): JsonSafe { + const obj: any = {}; + message.classId !== undefined && (obj.classId = message.classId); + message.id !== undefined && (obj.id = message.id); + message.sender !== undefined && (obj.sender = message.sender); + message.receiver !== undefined && (obj.receiver = message.receiver); + return obj; + }, + fromPartial(object: DeepPartial): MsgSend { + const message = createBaseMsgSend(); + message.classId = object.classId ?? ""; + message.id = object.id ?? ""; + message.sender = object.sender ?? ""; + message.receiver = object.receiver ?? ""; + return message; + }, + fromSDK(object: MsgSendSDKType): MsgSend { + return { + classId: object?.class_id, + id: object?.id, + sender: object?.sender, + receiver: object?.receiver + }; + }, + fromSDKJSON(object: any): MsgSendSDKType { + return { + class_id: isSet(object.class_id) ? String(object.class_id) : "", + id: isSet(object.id) ? String(object.id) : "", + sender: isSet(object.sender) ? String(object.sender) : "", + receiver: isSet(object.receiver) ? String(object.receiver) : "" + }; + }, + toSDK(message: MsgSend): MsgSendSDKType { + const obj: any = {}; + obj.class_id = message.classId; + obj.id = message.id; + obj.sender = message.sender; + obj.receiver = message.receiver; + return obj; + }, + fromAmino(object: MsgSendAmino): MsgSend { + const message = createBaseMsgSend(); + if (object.class_id !== undefined && object.class_id !== null) { + message.classId = object.class_id; + } + if (object.id !== undefined && object.id !== null) { + message.id = object.id; + } + if (object.sender !== undefined && object.sender !== null) { + message.sender = object.sender; + } + if (object.receiver !== undefined && object.receiver !== null) { + message.receiver = object.receiver; + } + return message; + }, + toAmino(message: MsgSend): MsgSendAmino { + const obj: any = {}; + obj.class_id = message.classId === "" ? undefined : message.classId; + obj.id = message.id === "" ? undefined : message.id; + obj.sender = message.sender === "" ? undefined : message.sender; + obj.receiver = message.receiver === "" ? undefined : message.receiver; + return obj; + }, + fromAminoMsg(object: MsgSendAminoMsg): MsgSend { + return MsgSend.fromAmino(object.value); + }, + toAminoMsg(message: MsgSend): MsgSendAminoMsg { + return { + type: "cosmos-sdk/MsgNFTSend", + value: MsgSend.toAmino(message) + }; + }, + fromProtoMsg(message: MsgSendProtoMsg): MsgSend { + return MsgSend.decode(message.value); + }, + toProto(message: MsgSend): Uint8Array { + return MsgSend.encode(message).finish(); + }, + toProtoMsg(message: MsgSend): MsgSendProtoMsg { + return { + typeUrl: "/cosmos.nft.v1beta1.MsgSend", + value: MsgSend.encode(message).finish() + }; + } +}; +function createBaseMsgSendResponse(): MsgSendResponse { + return {}; +} +export const MsgSendResponse = { + typeUrl: "/cosmos.nft.v1beta1.MsgSendResponse", + encode(_: MsgSendResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgSendResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgSendResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgSendResponse { + const obj = createBaseMsgSendResponse(); + return obj; + }, + toJSON(_: MsgSendResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): MsgSendResponse { + const message = createBaseMsgSendResponse(); + return message; + }, + fromSDK(_: MsgSendResponseSDKType): MsgSendResponse { + return {}; + }, + fromSDKJSON(_: any): MsgSendResponseSDKType { + return {}; + }, + toSDK(_: MsgSendResponse): MsgSendResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgSendResponseAmino): MsgSendResponse { + const message = createBaseMsgSendResponse(); + return message; + }, + toAmino(_: MsgSendResponse): MsgSendResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgSendResponseAminoMsg): MsgSendResponse { + return MsgSendResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgSendResponse): MsgSendResponseAminoMsg { + return { + type: "cosmos-sdk/MsgSendResponse", + value: MsgSendResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgSendResponseProtoMsg): MsgSendResponse { + return MsgSendResponse.decode(message.value); + }, + toProto(message: MsgSendResponse): Uint8Array { + return MsgSendResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgSendResponse): MsgSendResponseProtoMsg { + return { + typeUrl: "/cosmos.nft.v1beta1.MsgSendResponse", + value: MsgSendResponse.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/orm/module/v1alpha1/module.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/orm/module/v1alpha1/module.ts new file mode 100644 index 0000000000..0ddd6499a8 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/orm/module/v1alpha1/module.ts @@ -0,0 +1,94 @@ +import { BinaryReader, BinaryWriter } from "../../../../binary.js"; +import { JsonSafe } from "../../../../json-safe.js"; +import { DeepPartial } from "../../../../helpers.js"; +export const protobufPackage = "cosmos.orm.module.v1alpha1"; +/** + * Module defines the ORM module which adds providers to the app container for + * module-scoped DB's. In the future it may provide gRPC services for interacting + * with ORM data. + */ +export interface Module {} +export interface ModuleProtoMsg { + typeUrl: "/cosmos.orm.module.v1alpha1.Module"; + value: Uint8Array; +} +/** + * Module defines the ORM module which adds providers to the app container for + * module-scoped DB's. In the future it may provide gRPC services for interacting + * with ORM data. + */ +export interface ModuleSDKType {} +function createBaseModule(): Module { + return {}; +} +export const Module = { + typeUrl: "/cosmos.orm.module.v1alpha1.Module", + encode(_: Module, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Module { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseModule(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): Module { + const obj = createBaseModule(); + return obj; + }, + toJSON(_: Module): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): Module { + const message = createBaseModule(); + return message; + }, + fromSDK(_: ModuleSDKType): Module { + return {}; + }, + fromSDKJSON(_: any): ModuleSDKType { + return {}; + }, + toSDK(_: Module): ModuleSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: ModuleAmino): Module { + const message = createBaseModule(); + return message; + }, + toAmino(_: Module): ModuleAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: ModuleAminoMsg): Module { + return Module.fromAmino(object.value); + }, + toAminoMsg(message: Module): ModuleAminoMsg { + return { + type: "cosmos-sdk/Module", + value: Module.toAmino(message) + }; + }, + fromProtoMsg(message: ModuleProtoMsg): Module { + return Module.decode(message.value); + }, + toProto(message: Module): Uint8Array { + return Module.encode(message).finish(); + }, + toProtoMsg(message: Module): ModuleProtoMsg { + return { + typeUrl: "/cosmos.orm.module.v1alpha1.Module", + value: Module.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/orm/v1/orm.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/orm/v1/orm.ts new file mode 100644 index 0000000000..2210cff480 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/orm/v1/orm.ts @@ -0,0 +1,601 @@ +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "cosmos.orm.v1"; +/** TableDescriptor describes an ORM table. */ +export interface TableDescriptor { + /** primary_key defines the primary key for the table. */ + primaryKey?: PrimaryKeyDescriptor; + /** index defines one or more secondary indexes. */ + index: SecondaryIndexDescriptor[]; + /** + * id is a non-zero integer ID that must be unique within the + * tables and singletons in this file. It may be deprecated in the future when this + * can be auto-generated. + */ + id: number; +} +export interface TableDescriptorProtoMsg { + typeUrl: "/cosmos.orm.v1.TableDescriptor"; + value: Uint8Array; +} +/** TableDescriptor describes an ORM table. */ +export interface TableDescriptorSDKType { + primary_key?: PrimaryKeyDescriptorSDKType; + index: SecondaryIndexDescriptorSDKType[]; + id: number; +} +/** PrimaryKeyDescriptor describes a table primary key. */ +export interface PrimaryKeyDescriptor { + /** + * fields is a comma-separated list of fields in the primary key. Spaces are + * not allowed. Supported field types, their encodings, and any applicable constraints + * are described below. + * - uint32 are encoded as 2,3,4 or 5 bytes using a compact encoding that + * is suitable for sorted iteration (not varint encoding). This type is + * well-suited for small integers. + * - uint64 are encoded as 2,4,6 or 9 bytes using a compact encoding that + * is suitable for sorted iteration (not varint encoding). This type is + * well-suited for small integers such as auto-incrementing sequences. + * - fixed32, fixed64 are encoded as big-endian fixed width bytes and support + * sorted iteration. These types are well-suited for encoding fixed with + * decimals as integers. + * - string's are encoded as raw bytes in terminal key segments and null-terminated + * in non-terminal segments. Null characters are thus forbidden in strings. + * string fields support sorted iteration. + * - bytes are encoded as raw bytes in terminal segments and length-prefixed + * with a 32-bit unsigned varint in non-terminal segments. + * - int32, sint32, int64, sint64, sfixed32, sfixed64 are encoded as fixed width bytes with + * an encoding that enables sorted iteration. + * - google.protobuf.Timestamp and google.protobuf.Duration are encoded + * as 12 bytes using an encoding that enables sorted iteration. + * - enum fields are encoded using varint encoding and do not support sorted + * iteration. + * - bool fields are encoded as a single byte 0 or 1. + * + * All other fields types are unsupported in keys including repeated and + * oneof fields. + * + * Primary keys are prefixed by the varint encoded table id and the byte 0x0 + * plus any additional prefix specified by the schema. + */ + fields: string; + /** + * auto_increment specifies that the primary key is generated by an + * auto-incrementing integer. If this is set to true fields must only + * contain one field of that is of type uint64. + */ + autoIncrement: boolean; +} +export interface PrimaryKeyDescriptorProtoMsg { + typeUrl: "/cosmos.orm.v1.PrimaryKeyDescriptor"; + value: Uint8Array; +} +/** PrimaryKeyDescriptor describes a table primary key. */ +export interface PrimaryKeyDescriptorSDKType { + fields: string; + auto_increment: boolean; +} +/** PrimaryKeyDescriptor describes a table secondary index. */ +export interface SecondaryIndexDescriptor { + /** + * fields is a comma-separated list of fields in the index. The supported + * field types are the same as those for PrimaryKeyDescriptor.fields. + * Index keys are prefixed by the varint encoded table id and the varint + * encoded index id plus any additional prefix specified by the schema. + * + * In addition the field segments, non-unique index keys are suffixed with + * any additional primary key fields not present in the index fields so that the + * primary key can be reconstructed. Unique indexes instead of being suffixed + * store the remaining primary key fields in the value.. + */ + fields: string; + /** + * id is a non-zero integer ID that must be unique within the indexes for this + * table and less than 32768. It may be deprecated in the future when this can + * be auto-generated. + */ + id: number; + /** unique specifies that this an unique index. */ + unique: boolean; +} +export interface SecondaryIndexDescriptorProtoMsg { + typeUrl: "/cosmos.orm.v1.SecondaryIndexDescriptor"; + value: Uint8Array; +} +/** PrimaryKeyDescriptor describes a table secondary index. */ +export interface SecondaryIndexDescriptorSDKType { + fields: string; + id: number; + unique: boolean; +} +/** TableDescriptor describes an ORM singleton table which has at most one instance. */ +export interface SingletonDescriptor { + /** + * id is a non-zero integer ID that must be unique within the + * tables and singletons in this file. It may be deprecated in the future when this + * can be auto-generated. + */ + id: number; +} +export interface SingletonDescriptorProtoMsg { + typeUrl: "/cosmos.orm.v1.SingletonDescriptor"; + value: Uint8Array; +} +/** TableDescriptor describes an ORM singleton table which has at most one instance. */ +export interface SingletonDescriptorSDKType { + id: number; +} +function createBaseTableDescriptor(): TableDescriptor { + return { + primaryKey: undefined, + index: [], + id: 0 + }; +} +export const TableDescriptor = { + typeUrl: "/cosmos.orm.v1.TableDescriptor", + encode(message: TableDescriptor, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.primaryKey !== undefined) { + PrimaryKeyDescriptor.encode(message.primaryKey, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.index) { + SecondaryIndexDescriptor.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.id !== undefined) { + writer.uint32(24).uint32(message.id); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): TableDescriptor { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseTableDescriptor(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.primaryKey = PrimaryKeyDescriptor.decode(reader, reader.uint32()); + break; + case 2: + message.index.push(SecondaryIndexDescriptor.decode(reader, reader.uint32())); + break; + case 3: + message.id = reader.uint32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): TableDescriptor { + const obj = createBaseTableDescriptor(); + if (isSet(object.primaryKey)) obj.primaryKey = PrimaryKeyDescriptor.fromJSON(object.primaryKey); + if (Array.isArray(object?.index)) obj.index = object.index.map((e: any) => SecondaryIndexDescriptor.fromJSON(e)); + if (isSet(object.id)) obj.id = Number(object.id); + return obj; + }, + toJSON(message: TableDescriptor): JsonSafe { + const obj: any = {}; + message.primaryKey !== undefined && (obj.primaryKey = message.primaryKey ? PrimaryKeyDescriptor.toJSON(message.primaryKey) : undefined); + if (message.index) { + obj.index = message.index.map(e => e ? SecondaryIndexDescriptor.toJSON(e) : undefined); + } else { + obj.index = []; + } + message.id !== undefined && (obj.id = Math.round(message.id)); + return obj; + }, + fromPartial(object: DeepPartial): TableDescriptor { + const message = createBaseTableDescriptor(); + if (object.primaryKey !== undefined && object.primaryKey !== null) { + message.primaryKey = PrimaryKeyDescriptor.fromPartial(object.primaryKey); + } + message.index = object.index?.map(e => SecondaryIndexDescriptor.fromPartial(e)) || []; + message.id = object.id ?? 0; + return message; + }, + fromSDK(object: TableDescriptorSDKType): TableDescriptor { + return { + primaryKey: object.primary_key ? PrimaryKeyDescriptor.fromSDK(object.primary_key) : undefined, + index: Array.isArray(object?.index) ? object.index.map((e: any) => SecondaryIndexDescriptor.fromSDK(e)) : [], + id: object?.id + }; + }, + fromSDKJSON(object: any): TableDescriptorSDKType { + return { + primary_key: isSet(object.primary_key) ? PrimaryKeyDescriptor.fromSDKJSON(object.primary_key) : undefined, + index: Array.isArray(object?.index) ? object.index.map((e: any) => SecondaryIndexDescriptor.fromSDKJSON(e)) : [], + id: isSet(object.id) ? Number(object.id) : 0 + }; + }, + toSDK(message: TableDescriptor): TableDescriptorSDKType { + const obj: any = {}; + message.primaryKey !== undefined && (obj.primary_key = message.primaryKey ? PrimaryKeyDescriptor.toSDK(message.primaryKey) : undefined); + if (message.index) { + obj.index = message.index.map(e => e ? SecondaryIndexDescriptor.toSDK(e) : undefined); + } else { + obj.index = []; + } + obj.id = message.id; + return obj; + }, + fromAmino(object: TableDescriptorAmino): TableDescriptor { + const message = createBaseTableDescriptor(); + if (object.primary_key !== undefined && object.primary_key !== null) { + message.primaryKey = PrimaryKeyDescriptor.fromAmino(object.primary_key); + } + message.index = object.index?.map(e => SecondaryIndexDescriptor.fromAmino(e)) || []; + if (object.id !== undefined && object.id !== null) { + message.id = object.id; + } + return message; + }, + toAmino(message: TableDescriptor): TableDescriptorAmino { + const obj: any = {}; + obj.primary_key = message.primaryKey ? PrimaryKeyDescriptor.toAmino(message.primaryKey) : undefined; + if (message.index) { + obj.index = message.index.map(e => e ? SecondaryIndexDescriptor.toAmino(e) : undefined); + } else { + obj.index = message.index; + } + obj.id = message.id === 0 ? undefined : message.id; + return obj; + }, + fromAminoMsg(object: TableDescriptorAminoMsg): TableDescriptor { + return TableDescriptor.fromAmino(object.value); + }, + toAminoMsg(message: TableDescriptor): TableDescriptorAminoMsg { + return { + type: "cosmos-sdk/TableDescriptor", + value: TableDescriptor.toAmino(message) + }; + }, + fromProtoMsg(message: TableDescriptorProtoMsg): TableDescriptor { + return TableDescriptor.decode(message.value); + }, + toProto(message: TableDescriptor): Uint8Array { + return TableDescriptor.encode(message).finish(); + }, + toProtoMsg(message: TableDescriptor): TableDescriptorProtoMsg { + return { + typeUrl: "/cosmos.orm.v1.TableDescriptor", + value: TableDescriptor.encode(message).finish() + }; + } +}; +function createBasePrimaryKeyDescriptor(): PrimaryKeyDescriptor { + return { + fields: "", + autoIncrement: false + }; +} +export const PrimaryKeyDescriptor = { + typeUrl: "/cosmos.orm.v1.PrimaryKeyDescriptor", + encode(message: PrimaryKeyDescriptor, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.fields !== undefined) { + writer.uint32(10).string(message.fields); + } + if (message.autoIncrement !== undefined) { + writer.uint32(16).bool(message.autoIncrement); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): PrimaryKeyDescriptor { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBasePrimaryKeyDescriptor(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.fields = reader.string(); + break; + case 2: + message.autoIncrement = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): PrimaryKeyDescriptor { + const obj = createBasePrimaryKeyDescriptor(); + if (isSet(object.fields)) obj.fields = String(object.fields); + if (isSet(object.autoIncrement)) obj.autoIncrement = Boolean(object.autoIncrement); + return obj; + }, + toJSON(message: PrimaryKeyDescriptor): JsonSafe { + const obj: any = {}; + message.fields !== undefined && (obj.fields = message.fields); + message.autoIncrement !== undefined && (obj.autoIncrement = message.autoIncrement); + return obj; + }, + fromPartial(object: DeepPartial): PrimaryKeyDescriptor { + const message = createBasePrimaryKeyDescriptor(); + message.fields = object.fields ?? ""; + message.autoIncrement = object.autoIncrement ?? false; + return message; + }, + fromSDK(object: PrimaryKeyDescriptorSDKType): PrimaryKeyDescriptor { + return { + fields: object?.fields, + autoIncrement: object?.auto_increment + }; + }, + fromSDKJSON(object: any): PrimaryKeyDescriptorSDKType { + return { + fields: isSet(object.fields) ? String(object.fields) : "", + auto_increment: isSet(object.auto_increment) ? Boolean(object.auto_increment) : false + }; + }, + toSDK(message: PrimaryKeyDescriptor): PrimaryKeyDescriptorSDKType { + const obj: any = {}; + obj.fields = message.fields; + obj.auto_increment = message.autoIncrement; + return obj; + }, + fromAmino(object: PrimaryKeyDescriptorAmino): PrimaryKeyDescriptor { + const message = createBasePrimaryKeyDescriptor(); + if (object.fields !== undefined && object.fields !== null) { + message.fields = object.fields; + } + if (object.auto_increment !== undefined && object.auto_increment !== null) { + message.autoIncrement = object.auto_increment; + } + return message; + }, + toAmino(message: PrimaryKeyDescriptor): PrimaryKeyDescriptorAmino { + const obj: any = {}; + obj.fields = message.fields === "" ? undefined : message.fields; + obj.auto_increment = message.autoIncrement === false ? undefined : message.autoIncrement; + return obj; + }, + fromAminoMsg(object: PrimaryKeyDescriptorAminoMsg): PrimaryKeyDescriptor { + return PrimaryKeyDescriptor.fromAmino(object.value); + }, + toAminoMsg(message: PrimaryKeyDescriptor): PrimaryKeyDescriptorAminoMsg { + return { + type: "cosmos-sdk/PrimaryKeyDescriptor", + value: PrimaryKeyDescriptor.toAmino(message) + }; + }, + fromProtoMsg(message: PrimaryKeyDescriptorProtoMsg): PrimaryKeyDescriptor { + return PrimaryKeyDescriptor.decode(message.value); + }, + toProto(message: PrimaryKeyDescriptor): Uint8Array { + return PrimaryKeyDescriptor.encode(message).finish(); + }, + toProtoMsg(message: PrimaryKeyDescriptor): PrimaryKeyDescriptorProtoMsg { + return { + typeUrl: "/cosmos.orm.v1.PrimaryKeyDescriptor", + value: PrimaryKeyDescriptor.encode(message).finish() + }; + } +}; +function createBaseSecondaryIndexDescriptor(): SecondaryIndexDescriptor { + return { + fields: "", + id: 0, + unique: false + }; +} +export const SecondaryIndexDescriptor = { + typeUrl: "/cosmos.orm.v1.SecondaryIndexDescriptor", + encode(message: SecondaryIndexDescriptor, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.fields !== undefined) { + writer.uint32(10).string(message.fields); + } + if (message.id !== undefined) { + writer.uint32(16).uint32(message.id); + } + if (message.unique !== undefined) { + writer.uint32(24).bool(message.unique); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): SecondaryIndexDescriptor { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseSecondaryIndexDescriptor(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.fields = reader.string(); + break; + case 2: + message.id = reader.uint32(); + break; + case 3: + message.unique = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): SecondaryIndexDescriptor { + const obj = createBaseSecondaryIndexDescriptor(); + if (isSet(object.fields)) obj.fields = String(object.fields); + if (isSet(object.id)) obj.id = Number(object.id); + if (isSet(object.unique)) obj.unique = Boolean(object.unique); + return obj; + }, + toJSON(message: SecondaryIndexDescriptor): JsonSafe { + const obj: any = {}; + message.fields !== undefined && (obj.fields = message.fields); + message.id !== undefined && (obj.id = Math.round(message.id)); + message.unique !== undefined && (obj.unique = message.unique); + return obj; + }, + fromPartial(object: DeepPartial): SecondaryIndexDescriptor { + const message = createBaseSecondaryIndexDescriptor(); + message.fields = object.fields ?? ""; + message.id = object.id ?? 0; + message.unique = object.unique ?? false; + return message; + }, + fromSDK(object: SecondaryIndexDescriptorSDKType): SecondaryIndexDescriptor { + return { + fields: object?.fields, + id: object?.id, + unique: object?.unique + }; + }, + fromSDKJSON(object: any): SecondaryIndexDescriptorSDKType { + return { + fields: isSet(object.fields) ? String(object.fields) : "", + id: isSet(object.id) ? Number(object.id) : 0, + unique: isSet(object.unique) ? Boolean(object.unique) : false + }; + }, + toSDK(message: SecondaryIndexDescriptor): SecondaryIndexDescriptorSDKType { + const obj: any = {}; + obj.fields = message.fields; + obj.id = message.id; + obj.unique = message.unique; + return obj; + }, + fromAmino(object: SecondaryIndexDescriptorAmino): SecondaryIndexDescriptor { + const message = createBaseSecondaryIndexDescriptor(); + if (object.fields !== undefined && object.fields !== null) { + message.fields = object.fields; + } + if (object.id !== undefined && object.id !== null) { + message.id = object.id; + } + if (object.unique !== undefined && object.unique !== null) { + message.unique = object.unique; + } + return message; + }, + toAmino(message: SecondaryIndexDescriptor): SecondaryIndexDescriptorAmino { + const obj: any = {}; + obj.fields = message.fields === "" ? undefined : message.fields; + obj.id = message.id === 0 ? undefined : message.id; + obj.unique = message.unique === false ? undefined : message.unique; + return obj; + }, + fromAminoMsg(object: SecondaryIndexDescriptorAminoMsg): SecondaryIndexDescriptor { + return SecondaryIndexDescriptor.fromAmino(object.value); + }, + toAminoMsg(message: SecondaryIndexDescriptor): SecondaryIndexDescriptorAminoMsg { + return { + type: "cosmos-sdk/SecondaryIndexDescriptor", + value: SecondaryIndexDescriptor.toAmino(message) + }; + }, + fromProtoMsg(message: SecondaryIndexDescriptorProtoMsg): SecondaryIndexDescriptor { + return SecondaryIndexDescriptor.decode(message.value); + }, + toProto(message: SecondaryIndexDescriptor): Uint8Array { + return SecondaryIndexDescriptor.encode(message).finish(); + }, + toProtoMsg(message: SecondaryIndexDescriptor): SecondaryIndexDescriptorProtoMsg { + return { + typeUrl: "/cosmos.orm.v1.SecondaryIndexDescriptor", + value: SecondaryIndexDescriptor.encode(message).finish() + }; + } +}; +function createBaseSingletonDescriptor(): SingletonDescriptor { + return { + id: 0 + }; +} +export const SingletonDescriptor = { + typeUrl: "/cosmos.orm.v1.SingletonDescriptor", + encode(message: SingletonDescriptor, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.id !== undefined) { + writer.uint32(8).uint32(message.id); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): SingletonDescriptor { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseSingletonDescriptor(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.id = reader.uint32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): SingletonDescriptor { + const obj = createBaseSingletonDescriptor(); + if (isSet(object.id)) obj.id = Number(object.id); + return obj; + }, + toJSON(message: SingletonDescriptor): JsonSafe { + const obj: any = {}; + message.id !== undefined && (obj.id = Math.round(message.id)); + return obj; + }, + fromPartial(object: DeepPartial): SingletonDescriptor { + const message = createBaseSingletonDescriptor(); + message.id = object.id ?? 0; + return message; + }, + fromSDK(object: SingletonDescriptorSDKType): SingletonDescriptor { + return { + id: object?.id + }; + }, + fromSDKJSON(object: any): SingletonDescriptorSDKType { + return { + id: isSet(object.id) ? Number(object.id) : 0 + }; + }, + toSDK(message: SingletonDescriptor): SingletonDescriptorSDKType { + const obj: any = {}; + obj.id = message.id; + return obj; + }, + fromAmino(object: SingletonDescriptorAmino): SingletonDescriptor { + const message = createBaseSingletonDescriptor(); + if (object.id !== undefined && object.id !== null) { + message.id = object.id; + } + return message; + }, + toAmino(message: SingletonDescriptor): SingletonDescriptorAmino { + const obj: any = {}; + obj.id = message.id === 0 ? undefined : message.id; + return obj; + }, + fromAminoMsg(object: SingletonDescriptorAminoMsg): SingletonDescriptor { + return SingletonDescriptor.fromAmino(object.value); + }, + toAminoMsg(message: SingletonDescriptor): SingletonDescriptorAminoMsg { + return { + type: "cosmos-sdk/SingletonDescriptor", + value: SingletonDescriptor.toAmino(message) + }; + }, + fromProtoMsg(message: SingletonDescriptorProtoMsg): SingletonDescriptor { + return SingletonDescriptor.decode(message.value); + }, + toProto(message: SingletonDescriptor): Uint8Array { + return SingletonDescriptor.encode(message).finish(); + }, + toProtoMsg(message: SingletonDescriptor): SingletonDescriptorProtoMsg { + return { + typeUrl: "/cosmos.orm.v1.SingletonDescriptor", + value: SingletonDescriptor.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/orm/v1alpha1/schema.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/orm/v1alpha1/schema.ts new file mode 100644 index 0000000000..cc5c217cf8 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/orm/v1alpha1/schema.ts @@ -0,0 +1,385 @@ +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, bytesFromBase64, base64FromBytes, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "cosmos.orm.v1alpha1"; +/** StorageType */ +export enum StorageType { + /** + * STORAGE_TYPE_DEFAULT_UNSPECIFIED - STORAGE_TYPE_DEFAULT_UNSPECIFIED indicates the persistent + * KV-storage where primary key entries are stored in merkle-tree + * backed commitment storage and indexes and seqs are stored in + * fast index storage. Note that the Cosmos SDK before store/v2alpha1 + * does not support this. + */ + STORAGE_TYPE_DEFAULT_UNSPECIFIED = 0, + /** + * STORAGE_TYPE_MEMORY - STORAGE_TYPE_MEMORY indicates in-memory storage that will be + * reloaded every time an app restarts. Tables with this type of storage + * will by default be ignored when importing and exporting a module's + * state from JSON. + */ + STORAGE_TYPE_MEMORY = 1, + /** + * STORAGE_TYPE_TRANSIENT - STORAGE_TYPE_TRANSIENT indicates transient storage that is reset + * at the end of every block. Tables with this type of storage + * will by default be ignored when importing and exporting a module's + * state from JSON. + */ + STORAGE_TYPE_TRANSIENT = 2, + /** + * STORAGE_TYPE_INDEX - STORAGE_TYPE_INDEX indicates persistent storage which is not backed + * by a merkle-tree and won't affect the app hash. Note that the Cosmos SDK + * before store/v2alpha1 does not support this. + */ + STORAGE_TYPE_INDEX = 3, + /** + * STORAGE_TYPE_COMMITMENT - STORAGE_TYPE_INDEX indicates persistent storage which is backed by + * a merkle-tree. With this type of storage, both primary and index keys + * will affect the app hash and this is generally less efficient + * than using STORAGE_TYPE_DEFAULT_UNSPECIFIED which separates index + * keys into index storage. Note that modules built with the + * Cosmos SDK before store/v2alpha1 must specify STORAGE_TYPE_COMMITMENT + * instead of STORAGE_TYPE_DEFAULT_UNSPECIFIED or STORAGE_TYPE_INDEX + * because this is the only type of persistent storage available. + */ + STORAGE_TYPE_COMMITMENT = 4, + UNRECOGNIZED = -1, +} +export const StorageTypeSDKType = StorageType; +export function storageTypeFromJSON(object: any): StorageType { + switch (object) { + case 0: + case "STORAGE_TYPE_DEFAULT_UNSPECIFIED": + return StorageType.STORAGE_TYPE_DEFAULT_UNSPECIFIED; + case 1: + case "STORAGE_TYPE_MEMORY": + return StorageType.STORAGE_TYPE_MEMORY; + case 2: + case "STORAGE_TYPE_TRANSIENT": + return StorageType.STORAGE_TYPE_TRANSIENT; + case 3: + case "STORAGE_TYPE_INDEX": + return StorageType.STORAGE_TYPE_INDEX; + case 4: + case "STORAGE_TYPE_COMMITMENT": + return StorageType.STORAGE_TYPE_COMMITMENT; + case -1: + case "UNRECOGNIZED": + default: + return StorageType.UNRECOGNIZED; + } +} +export function storageTypeToJSON(object: StorageType): string { + switch (object) { + case StorageType.STORAGE_TYPE_DEFAULT_UNSPECIFIED: + return "STORAGE_TYPE_DEFAULT_UNSPECIFIED"; + case StorageType.STORAGE_TYPE_MEMORY: + return "STORAGE_TYPE_MEMORY"; + case StorageType.STORAGE_TYPE_TRANSIENT: + return "STORAGE_TYPE_TRANSIENT"; + case StorageType.STORAGE_TYPE_INDEX: + return "STORAGE_TYPE_INDEX"; + case StorageType.STORAGE_TYPE_COMMITMENT: + return "STORAGE_TYPE_COMMITMENT"; + case StorageType.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** ModuleSchemaDescriptor describe's a module's ORM schema. */ +export interface ModuleSchemaDescriptor { + schemaFile: ModuleSchemaDescriptor_FileEntry[]; + /** + * prefix is an optional prefix that precedes all keys in this module's + * store. + */ + prefix: Uint8Array; +} +export interface ModuleSchemaDescriptorProtoMsg { + typeUrl: "/cosmos.orm.v1alpha1.ModuleSchemaDescriptor"; + value: Uint8Array; +} +/** ModuleSchemaDescriptor describe's a module's ORM schema. */ +export interface ModuleSchemaDescriptorSDKType { + schema_file: ModuleSchemaDescriptor_FileEntrySDKType[]; + prefix: Uint8Array; +} +/** FileEntry describes an ORM file used in a module. */ +export interface ModuleSchemaDescriptor_FileEntry { + /** + * id is a prefix that will be varint encoded and prepended to all the + * table keys specified in the file's tables. + */ + id: number; + /** + * proto_file_name is the name of a file .proto in that contains + * table definitions. The .proto file must be in a package that the + * module has referenced using cosmos.app.v1.ModuleDescriptor.use_package. + */ + protoFileName: string; + /** + * storage_type optionally indicates the type of storage this file's + * tables should used. If it is left unspecified, the default KV-storage + * of the app will be used. + */ + storageType: StorageType; +} +export interface ModuleSchemaDescriptor_FileEntryProtoMsg { + typeUrl: "/cosmos.orm.v1alpha1.FileEntry"; + value: Uint8Array; +} +/** FileEntry describes an ORM file used in a module. */ +export interface ModuleSchemaDescriptor_FileEntrySDKType { + id: number; + proto_file_name: string; + storage_type: StorageType; +} +function createBaseModuleSchemaDescriptor(): ModuleSchemaDescriptor { + return { + schemaFile: [], + prefix: new Uint8Array() + }; +} +export const ModuleSchemaDescriptor = { + typeUrl: "/cosmos.orm.v1alpha1.ModuleSchemaDescriptor", + encode(message: ModuleSchemaDescriptor, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.schemaFile) { + ModuleSchemaDescriptor_FileEntry.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.prefix.length !== 0) { + writer.uint32(18).bytes(message.prefix); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ModuleSchemaDescriptor { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseModuleSchemaDescriptor(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.schemaFile.push(ModuleSchemaDescriptor_FileEntry.decode(reader, reader.uint32())); + break; + case 2: + message.prefix = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ModuleSchemaDescriptor { + const obj = createBaseModuleSchemaDescriptor(); + if (Array.isArray(object?.schemaFile)) obj.schemaFile = object.schemaFile.map((e: any) => ModuleSchemaDescriptor_FileEntry.fromJSON(e)); + if (isSet(object.prefix)) obj.prefix = bytesFromBase64(object.prefix); + return obj; + }, + toJSON(message: ModuleSchemaDescriptor): JsonSafe { + const obj: any = {}; + if (message.schemaFile) { + obj.schemaFile = message.schemaFile.map(e => e ? ModuleSchemaDescriptor_FileEntry.toJSON(e) : undefined); + } else { + obj.schemaFile = []; + } + message.prefix !== undefined && (obj.prefix = base64FromBytes(message.prefix !== undefined ? message.prefix : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): ModuleSchemaDescriptor { + const message = createBaseModuleSchemaDescriptor(); + message.schemaFile = object.schemaFile?.map(e => ModuleSchemaDescriptor_FileEntry.fromPartial(e)) || []; + message.prefix = object.prefix ?? new Uint8Array(); + return message; + }, + fromSDK(object: ModuleSchemaDescriptorSDKType): ModuleSchemaDescriptor { + return { + schemaFile: Array.isArray(object?.schema_file) ? object.schema_file.map((e: any) => ModuleSchemaDescriptor_FileEntry.fromSDK(e)) : [], + prefix: object?.prefix + }; + }, + fromSDKJSON(object: any): ModuleSchemaDescriptorSDKType { + return { + schema_file: Array.isArray(object?.schema_file) ? object.schema_file.map((e: any) => ModuleSchemaDescriptor_FileEntry.fromSDKJSON(e)) : [], + prefix: isSet(object.prefix) ? bytesFromBase64(object.prefix) : new Uint8Array() + }; + }, + toSDK(message: ModuleSchemaDescriptor): ModuleSchemaDescriptorSDKType { + const obj: any = {}; + if (message.schemaFile) { + obj.schema_file = message.schemaFile.map(e => e ? ModuleSchemaDescriptor_FileEntry.toSDK(e) : undefined); + } else { + obj.schema_file = []; + } + obj.prefix = message.prefix; + return obj; + }, + fromAmino(object: ModuleSchemaDescriptorAmino): ModuleSchemaDescriptor { + const message = createBaseModuleSchemaDescriptor(); + message.schemaFile = object.schema_file?.map(e => ModuleSchemaDescriptor_FileEntry.fromAmino(e)) || []; + if (object.prefix !== undefined && object.prefix !== null) { + message.prefix = bytesFromBase64(object.prefix); + } + return message; + }, + toAmino(message: ModuleSchemaDescriptor): ModuleSchemaDescriptorAmino { + const obj: any = {}; + if (message.schemaFile) { + obj.schema_file = message.schemaFile.map(e => e ? ModuleSchemaDescriptor_FileEntry.toAmino(e) : undefined); + } else { + obj.schema_file = message.schemaFile; + } + obj.prefix = message.prefix ? base64FromBytes(message.prefix) : undefined; + return obj; + }, + fromAminoMsg(object: ModuleSchemaDescriptorAminoMsg): ModuleSchemaDescriptor { + return ModuleSchemaDescriptor.fromAmino(object.value); + }, + toAminoMsg(message: ModuleSchemaDescriptor): ModuleSchemaDescriptorAminoMsg { + return { + type: "cosmos-sdk/ModuleSchemaDescriptor", + value: ModuleSchemaDescriptor.toAmino(message) + }; + }, + fromProtoMsg(message: ModuleSchemaDescriptorProtoMsg): ModuleSchemaDescriptor { + return ModuleSchemaDescriptor.decode(message.value); + }, + toProto(message: ModuleSchemaDescriptor): Uint8Array { + return ModuleSchemaDescriptor.encode(message).finish(); + }, + toProtoMsg(message: ModuleSchemaDescriptor): ModuleSchemaDescriptorProtoMsg { + return { + typeUrl: "/cosmos.orm.v1alpha1.ModuleSchemaDescriptor", + value: ModuleSchemaDescriptor.encode(message).finish() + }; + } +}; +function createBaseModuleSchemaDescriptor_FileEntry(): ModuleSchemaDescriptor_FileEntry { + return { + id: 0, + protoFileName: "", + storageType: 0 + }; +} +export const ModuleSchemaDescriptor_FileEntry = { + typeUrl: "/cosmos.orm.v1alpha1.FileEntry", + encode(message: ModuleSchemaDescriptor_FileEntry, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.id !== undefined) { + writer.uint32(8).uint32(message.id); + } + if (message.protoFileName !== undefined) { + writer.uint32(18).string(message.protoFileName); + } + if (message.storageType !== 0) { + writer.uint32(24).int32(message.storageType); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ModuleSchemaDescriptor_FileEntry { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseModuleSchemaDescriptor_FileEntry(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.id = reader.uint32(); + break; + case 2: + message.protoFileName = reader.string(); + break; + case 3: + message.storageType = (reader.int32() as any); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ModuleSchemaDescriptor_FileEntry { + const obj = createBaseModuleSchemaDescriptor_FileEntry(); + if (isSet(object.id)) obj.id = Number(object.id); + if (isSet(object.protoFileName)) obj.protoFileName = String(object.protoFileName); + if (isSet(object.storageType)) obj.storageType = storageTypeFromJSON(object.storageType); + return obj; + }, + toJSON(message: ModuleSchemaDescriptor_FileEntry): JsonSafe { + const obj: any = {}; + message.id !== undefined && (obj.id = Math.round(message.id)); + message.protoFileName !== undefined && (obj.protoFileName = message.protoFileName); + message.storageType !== undefined && (obj.storageType = storageTypeToJSON(message.storageType)); + return obj; + }, + fromPartial(object: DeepPartial): ModuleSchemaDescriptor_FileEntry { + const message = createBaseModuleSchemaDescriptor_FileEntry(); + message.id = object.id ?? 0; + message.protoFileName = object.protoFileName ?? ""; + message.storageType = object.storageType ?? 0; + return message; + }, + fromSDK(object: ModuleSchemaDescriptor_FileEntrySDKType): ModuleSchemaDescriptor_FileEntry { + return { + id: object?.id, + protoFileName: object?.proto_file_name, + storageType: isSet(object.storage_type) ? storageTypeFromJSON(object.storage_type) : -1 + }; + }, + fromSDKJSON(object: any): ModuleSchemaDescriptor_FileEntrySDKType { + return { + id: isSet(object.id) ? Number(object.id) : 0, + proto_file_name: isSet(object.proto_file_name) ? String(object.proto_file_name) : "", + storage_type: isSet(object.storage_type) ? storageTypeFromJSON(object.storage_type) : -1 + }; + }, + toSDK(message: ModuleSchemaDescriptor_FileEntry): ModuleSchemaDescriptor_FileEntrySDKType { + const obj: any = {}; + obj.id = message.id; + obj.proto_file_name = message.protoFileName; + message.storageType !== undefined && (obj.storage_type = storageTypeToJSON(message.storageType)); + return obj; + }, + fromAmino(object: ModuleSchemaDescriptor_FileEntryAmino): ModuleSchemaDescriptor_FileEntry { + const message = createBaseModuleSchemaDescriptor_FileEntry(); + if (object.id !== undefined && object.id !== null) { + message.id = object.id; + } + if (object.proto_file_name !== undefined && object.proto_file_name !== null) { + message.protoFileName = object.proto_file_name; + } + if (object.storage_type !== undefined && object.storage_type !== null) { + message.storageType = object.storage_type; + } + return message; + }, + toAmino(message: ModuleSchemaDescriptor_FileEntry): ModuleSchemaDescriptor_FileEntryAmino { + const obj: any = {}; + obj.id = message.id === 0 ? undefined : message.id; + obj.proto_file_name = message.protoFileName === "" ? undefined : message.protoFileName; + obj.storage_type = message.storageType === 0 ? undefined : message.storageType; + return obj; + }, + fromAminoMsg(object: ModuleSchemaDescriptor_FileEntryAminoMsg): ModuleSchemaDescriptor_FileEntry { + return ModuleSchemaDescriptor_FileEntry.fromAmino(object.value); + }, + toAminoMsg(message: ModuleSchemaDescriptor_FileEntry): ModuleSchemaDescriptor_FileEntryAminoMsg { + return { + type: "cosmos-sdk/FileEntry", + value: ModuleSchemaDescriptor_FileEntry.toAmino(message) + }; + }, + fromProtoMsg(message: ModuleSchemaDescriptor_FileEntryProtoMsg): ModuleSchemaDescriptor_FileEntry { + return ModuleSchemaDescriptor_FileEntry.decode(message.value); + }, + toProto(message: ModuleSchemaDescriptor_FileEntry): Uint8Array { + return ModuleSchemaDescriptor_FileEntry.encode(message).finish(); + }, + toProtoMsg(message: ModuleSchemaDescriptor_FileEntry): ModuleSchemaDescriptor_FileEntryProtoMsg { + return { + typeUrl: "/cosmos.orm.v1alpha1.FileEntry", + value: ModuleSchemaDescriptor_FileEntry.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/params/v1beta1/params.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/params/v1beta1/params.ts new file mode 100644 index 0000000000..2253d97aac --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/params/v1beta1/params.ts @@ -0,0 +1,308 @@ +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "cosmos.params.v1beta1"; +/** ParameterChangeProposal defines a proposal to change one or more parameters. */ +export interface ParameterChangeProposal { + title: string; + description: string; + changes: ParamChange[]; +} +export interface ParameterChangeProposalProtoMsg { + typeUrl: "/cosmos.params.v1beta1.ParameterChangeProposal"; + value: Uint8Array; +} +/** ParameterChangeProposal defines a proposal to change one or more parameters. */ +export interface ParameterChangeProposalSDKType { + title: string; + description: string; + changes: ParamChangeSDKType[]; +} +/** + * ParamChange defines an individual parameter change, for use in + * ParameterChangeProposal. + */ +export interface ParamChange { + subspace: string; + key: string; + value: string; +} +export interface ParamChangeProtoMsg { + typeUrl: "/cosmos.params.v1beta1.ParamChange"; + value: Uint8Array; +} +/** + * ParamChange defines an individual parameter change, for use in + * ParameterChangeProposal. + */ +export interface ParamChangeSDKType { + subspace: string; + key: string; + value: string; +} +function createBaseParameterChangeProposal(): ParameterChangeProposal { + return { + title: "", + description: "", + changes: [] + }; +} +export const ParameterChangeProposal = { + typeUrl: "/cosmos.params.v1beta1.ParameterChangeProposal", + encode(message: ParameterChangeProposal, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.title !== undefined) { + writer.uint32(10).string(message.title); + } + if (message.description !== undefined) { + writer.uint32(18).string(message.description); + } + for (const v of message.changes) { + ParamChange.encode(v!, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ParameterChangeProposal { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseParameterChangeProposal(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.title = reader.string(); + break; + case 2: + message.description = reader.string(); + break; + case 3: + message.changes.push(ParamChange.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ParameterChangeProposal { + const obj = createBaseParameterChangeProposal(); + if (isSet(object.title)) obj.title = String(object.title); + if (isSet(object.description)) obj.description = String(object.description); + if (Array.isArray(object?.changes)) obj.changes = object.changes.map((e: any) => ParamChange.fromJSON(e)); + return obj; + }, + toJSON(message: ParameterChangeProposal): JsonSafe { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && (obj.description = message.description); + if (message.changes) { + obj.changes = message.changes.map(e => e ? ParamChange.toJSON(e) : undefined); + } else { + obj.changes = []; + } + return obj; + }, + fromPartial(object: DeepPartial): ParameterChangeProposal { + const message = createBaseParameterChangeProposal(); + message.title = object.title ?? ""; + message.description = object.description ?? ""; + message.changes = object.changes?.map(e => ParamChange.fromPartial(e)) || []; + return message; + }, + fromSDK(object: ParameterChangeProposalSDKType): ParameterChangeProposal { + return { + title: object?.title, + description: object?.description, + changes: Array.isArray(object?.changes) ? object.changes.map((e: any) => ParamChange.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): ParameterChangeProposalSDKType { + return { + title: isSet(object.title) ? String(object.title) : "", + description: isSet(object.description) ? String(object.description) : "", + changes: Array.isArray(object?.changes) ? object.changes.map((e: any) => ParamChange.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: ParameterChangeProposal): ParameterChangeProposalSDKType { + const obj: any = {}; + obj.title = message.title; + obj.description = message.description; + if (message.changes) { + obj.changes = message.changes.map(e => e ? ParamChange.toSDK(e) : undefined); + } else { + obj.changes = []; + } + return obj; + }, + fromAmino(object: ParameterChangeProposalAmino): ParameterChangeProposal { + const message = createBaseParameterChangeProposal(); + if (object.title !== undefined && object.title !== null) { + message.title = object.title; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } + message.changes = object.changes?.map(e => ParamChange.fromAmino(e)) || []; + return message; + }, + toAmino(message: ParameterChangeProposal): ParameterChangeProposalAmino { + const obj: any = {}; + obj.title = message.title === "" ? undefined : message.title; + obj.description = message.description === "" ? undefined : message.description; + if (message.changes) { + obj.changes = message.changes.map(e => e ? ParamChange.toAmino(e) : undefined); + } else { + obj.changes = message.changes; + } + return obj; + }, + fromAminoMsg(object: ParameterChangeProposalAminoMsg): ParameterChangeProposal { + return ParameterChangeProposal.fromAmino(object.value); + }, + toAminoMsg(message: ParameterChangeProposal): ParameterChangeProposalAminoMsg { + return { + type: "cosmos-sdk/ParameterChangeProposal", + value: ParameterChangeProposal.toAmino(message) + }; + }, + fromProtoMsg(message: ParameterChangeProposalProtoMsg): ParameterChangeProposal { + return ParameterChangeProposal.decode(message.value); + }, + toProto(message: ParameterChangeProposal): Uint8Array { + return ParameterChangeProposal.encode(message).finish(); + }, + toProtoMsg(message: ParameterChangeProposal): ParameterChangeProposalProtoMsg { + return { + typeUrl: "/cosmos.params.v1beta1.ParameterChangeProposal", + value: ParameterChangeProposal.encode(message).finish() + }; + } +}; +function createBaseParamChange(): ParamChange { + return { + subspace: "", + key: "", + value: "" + }; +} +export const ParamChange = { + typeUrl: "/cosmos.params.v1beta1.ParamChange", + encode(message: ParamChange, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.subspace !== undefined) { + writer.uint32(10).string(message.subspace); + } + if (message.key !== undefined) { + writer.uint32(18).string(message.key); + } + if (message.value !== undefined) { + writer.uint32(26).string(message.value); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ParamChange { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseParamChange(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.subspace = reader.string(); + break; + case 2: + message.key = reader.string(); + break; + case 3: + message.value = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ParamChange { + const obj = createBaseParamChange(); + if (isSet(object.subspace)) obj.subspace = String(object.subspace); + if (isSet(object.key)) obj.key = String(object.key); + if (isSet(object.value)) obj.value = String(object.value); + return obj; + }, + toJSON(message: ParamChange): JsonSafe { + const obj: any = {}; + message.subspace !== undefined && (obj.subspace = message.subspace); + message.key !== undefined && (obj.key = message.key); + message.value !== undefined && (obj.value = message.value); + return obj; + }, + fromPartial(object: DeepPartial): ParamChange { + const message = createBaseParamChange(); + message.subspace = object.subspace ?? ""; + message.key = object.key ?? ""; + message.value = object.value ?? ""; + return message; + }, + fromSDK(object: ParamChangeSDKType): ParamChange { + return { + subspace: object?.subspace, + key: object?.key, + value: object?.value + }; + }, + fromSDKJSON(object: any): ParamChangeSDKType { + return { + subspace: isSet(object.subspace) ? String(object.subspace) : "", + key: isSet(object.key) ? String(object.key) : "", + value: isSet(object.value) ? String(object.value) : "" + }; + }, + toSDK(message: ParamChange): ParamChangeSDKType { + const obj: any = {}; + obj.subspace = message.subspace; + obj.key = message.key; + obj.value = message.value; + return obj; + }, + fromAmino(object: ParamChangeAmino): ParamChange { + const message = createBaseParamChange(); + if (object.subspace !== undefined && object.subspace !== null) { + message.subspace = object.subspace; + } + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } + if (object.value !== undefined && object.value !== null) { + message.value = object.value; + } + return message; + }, + toAmino(message: ParamChange): ParamChangeAmino { + const obj: any = {}; + obj.subspace = message.subspace === "" ? undefined : message.subspace; + obj.key = message.key === "" ? undefined : message.key; + obj.value = message.value === "" ? undefined : message.value; + return obj; + }, + fromAminoMsg(object: ParamChangeAminoMsg): ParamChange { + return ParamChange.fromAmino(object.value); + }, + toAminoMsg(message: ParamChange): ParamChangeAminoMsg { + return { + type: "cosmos-sdk/ParamChange", + value: ParamChange.toAmino(message) + }; + }, + fromProtoMsg(message: ParamChangeProtoMsg): ParamChange { + return ParamChange.decode(message.value); + }, + toProto(message: ParamChange): Uint8Array { + return ParamChange.encode(message).finish(); + }, + toProtoMsg(message: ParamChange): ParamChangeProtoMsg { + return { + typeUrl: "/cosmos.params.v1beta1.ParamChange", + value: ParamChange.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/params/v1beta1/query.lcd.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/params/v1beta1/query.lcd.ts new file mode 100644 index 0000000000..737ed229cf --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/params/v1beta1/query.lcd.ts @@ -0,0 +1,35 @@ +import { ParamChange, ParamChangeSDKType } from "./params.js"; +import { LCDClient } from "@cosmology/lcd"; +import { QueryParamsRequest, QueryParamsRequestSDKType, QueryParamsResponse, QueryParamsResponseSDKType, QuerySubspacesRequest, QuerySubspacesRequestSDKType, QuerySubspacesResponse, QuerySubspacesResponseSDKType } from "./query.js"; +export class LCDQueryClient { + req: LCDClient; + constructor({ + requestClient + }: { + requestClient: LCDClient; + }) { + this.req = requestClient; + this.params = this.params.bind(this); + this.subspaces = this.subspaces.bind(this); + } + /* Params queries a specific parameter of a module, given its subspace and + key. */ + async params(params: QueryParamsRequest): Promise { + const options: any = { + params: {} + }; + if (typeof params?.subspace !== "undefined") { + options.params.subspace = params.subspace; + } + if (typeof params?.key !== "undefined") { + options.params.key = params.key; + } + const endpoint = `cosmos/params/v1beta1/params`; + return QueryParamsResponse.fromSDKJSON(await this.req.get(endpoint, options)); + } + /* Subspaces queries for all registered subspaces and all keys for a subspace. */ + async subspaces(_params: QuerySubspacesRequest = {}): Promise { + const endpoint = `cosmos/params/v1beta1/subspaces`; + return QuerySubspacesResponse.fromSDKJSON(await this.req.get(endpoint)); + } +} \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/params/v1beta1/query.rpc.Query.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/params/v1beta1/query.rpc.Query.ts new file mode 100644 index 0000000000..79b76656f2 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/params/v1beta1/query.rpc.Query.ts @@ -0,0 +1,45 @@ +import { ParamChange, ParamChangeSDKType } from "./params.js"; +import { Rpc } from "../../../helpers.js"; +import { BinaryReader } from "../../../binary.js"; +import { QueryClient, createProtobufRpcClient } from "@cosmjs/stargate"; +import { QueryParamsRequest, QueryParamsRequestSDKType, QueryParamsResponse, QueryParamsResponseSDKType, QuerySubspacesRequest, QuerySubspacesRequestSDKType, QuerySubspacesResponse, QuerySubspacesResponseSDKType } from "./query.js"; +/** Query defines the gRPC querier service. */ +export interface Query { + /** + * Params queries a specific parameter of a module, given its subspace and + * key. + */ + params(request: QueryParamsRequest): Promise; + /** Subspaces queries for all registered subspaces and all keys for a subspace. */ + subspaces(request?: QuerySubspacesRequest): Promise; +} +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + this.params = this.params.bind(this); + this.subspaces = this.subspaces.bind(this); + } + params(request: QueryParamsRequest): Promise { + const data = QueryParamsRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.params.v1beta1.Query", "Params", data); + return promise.then(data => QueryParamsResponse.decode(new BinaryReader(data))); + } + subspaces(request: QuerySubspacesRequest = {}): Promise { + const data = QuerySubspacesRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.params.v1beta1.Query", "Subspaces", data); + return promise.then(data => QuerySubspacesResponse.decode(new BinaryReader(data))); + } +} +export const createRpcQueryExtension = (base: QueryClient) => { + const rpc = createProtobufRpcClient(base); + const queryService = new QueryClientImpl(rpc); + return { + params(request: QueryParamsRequest): Promise { + return queryService.params(request); + }, + subspaces(request?: QuerySubspacesRequest): Promise { + return queryService.subspaces(request); + } + }; +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/params/v1beta1/query.rpc.func.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/params/v1beta1/query.rpc.func.ts new file mode 100644 index 0000000000..3bf68015a5 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/params/v1beta1/query.rpc.func.ts @@ -0,0 +1,25 @@ +import { RpcResolver, buildQuery } from "../../../helper-func-types"; +import { buildUseQuery } from "../../../react-query"; +import { QueryParamsRequest, QueryParamsResponse, QuerySubspacesRequest, QuerySubspacesResponse } from "./query"; +export const createGetParams = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryParamsRequest.encode, + decode: QueryParamsResponse.decode, + service: "cosmos.params.v1beta1.Query", + method: "Params", + getRpcInstance: getRpcInstance +}); +export const useGetParams = buildUseQuery({ + builderQueryFn: createGetParams, + queryKeyPrefix: "ParamsQuery" +}); +export const createGetSubspaces = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QuerySubspacesRequest.encode, + decode: QuerySubspacesResponse.decode, + service: "cosmos.params.v1beta1.Query", + method: "Subspaces", + getRpcInstance: getRpcInstance +}); +export const useGetSubspaces = buildUseQuery({ + builderQueryFn: createGetSubspaces, + queryKeyPrefix: "SubspacesQuery" +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/params/v1beta1/query.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/params/v1beta1/query.ts new file mode 100644 index 0000000000..206aeb146a --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/params/v1beta1/query.ts @@ -0,0 +1,592 @@ +import { ParamChange, ParamChangeSDKType } from "./params.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "cosmos.params.v1beta1"; +/** QueryParamsRequest is request type for the Query/Params RPC method. */ +export interface QueryParamsRequest { + /** subspace defines the module to query the parameter for. */ + subspace: string; + /** key defines the key of the parameter in the subspace. */ + key: string; +} +export interface QueryParamsRequestProtoMsg { + typeUrl: "/cosmos.params.v1beta1.QueryParamsRequest"; + value: Uint8Array; +} +/** QueryParamsRequest is request type for the Query/Params RPC method. */ +export interface QueryParamsRequestSDKType { + subspace: string; + key: string; +} +/** QueryParamsResponse is response type for the Query/Params RPC method. */ +export interface QueryParamsResponse { + /** param defines the queried parameter. */ + param: ParamChange; +} +export interface QueryParamsResponseProtoMsg { + typeUrl: "/cosmos.params.v1beta1.QueryParamsResponse"; + value: Uint8Array; +} +/** QueryParamsResponse is response type for the Query/Params RPC method. */ +export interface QueryParamsResponseSDKType { + param: ParamChangeSDKType; +} +/** + * QuerySubspacesRequest defines a request type for querying for all registered + * subspaces and all keys for a subspace. + */ +export interface QuerySubspacesRequest {} +export interface QuerySubspacesRequestProtoMsg { + typeUrl: "/cosmos.params.v1beta1.QuerySubspacesRequest"; + value: Uint8Array; +} +/** + * QuerySubspacesRequest defines a request type for querying for all registered + * subspaces and all keys for a subspace. + */ +export interface QuerySubspacesRequestSDKType {} +/** + * QuerySubspacesResponse defines the response types for querying for all + * registered subspaces and all keys for a subspace. + */ +export interface QuerySubspacesResponse { + subspaces: Subspace[]; +} +export interface QuerySubspacesResponseProtoMsg { + typeUrl: "/cosmos.params.v1beta1.QuerySubspacesResponse"; + value: Uint8Array; +} +/** + * QuerySubspacesResponse defines the response types for querying for all + * registered subspaces and all keys for a subspace. + */ +export interface QuerySubspacesResponseSDKType { + subspaces: SubspaceSDKType[]; +} +/** + * Subspace defines a parameter subspace name and all the keys that exist for + * the subspace. + */ +export interface Subspace { + subspace: string; + keys: string[]; +} +export interface SubspaceProtoMsg { + typeUrl: "/cosmos.params.v1beta1.Subspace"; + value: Uint8Array; +} +/** + * Subspace defines a parameter subspace name and all the keys that exist for + * the subspace. + */ +export interface SubspaceSDKType { + subspace: string; + keys: string[]; +} +function createBaseQueryParamsRequest(): QueryParamsRequest { + return { + subspace: "", + key: "" + }; +} +export const QueryParamsRequest = { + typeUrl: "/cosmos.params.v1beta1.QueryParamsRequest", + encode(message: QueryParamsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.subspace !== undefined) { + writer.uint32(10).string(message.subspace); + } + if (message.key !== undefined) { + writer.uint32(18).string(message.key); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryParamsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryParamsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.subspace = reader.string(); + break; + case 2: + message.key = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryParamsRequest { + const obj = createBaseQueryParamsRequest(); + if (isSet(object.subspace)) obj.subspace = String(object.subspace); + if (isSet(object.key)) obj.key = String(object.key); + return obj; + }, + toJSON(message: QueryParamsRequest): JsonSafe { + const obj: any = {}; + message.subspace !== undefined && (obj.subspace = message.subspace); + message.key !== undefined && (obj.key = message.key); + return obj; + }, + fromPartial(object: DeepPartial): QueryParamsRequest { + const message = createBaseQueryParamsRequest(); + message.subspace = object.subspace ?? ""; + message.key = object.key ?? ""; + return message; + }, + fromSDK(object: QueryParamsRequestSDKType): QueryParamsRequest { + return { + subspace: object?.subspace, + key: object?.key + }; + }, + fromSDKJSON(object: any): QueryParamsRequestSDKType { + return { + subspace: isSet(object.subspace) ? String(object.subspace) : "", + key: isSet(object.key) ? String(object.key) : "" + }; + }, + toSDK(message: QueryParamsRequest): QueryParamsRequestSDKType { + const obj: any = {}; + obj.subspace = message.subspace; + obj.key = message.key; + return obj; + }, + fromAmino(object: QueryParamsRequestAmino): QueryParamsRequest { + const message = createBaseQueryParamsRequest(); + if (object.subspace !== undefined && object.subspace !== null) { + message.subspace = object.subspace; + } + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } + return message; + }, + toAmino(message: QueryParamsRequest): QueryParamsRequestAmino { + const obj: any = {}; + obj.subspace = message.subspace === "" ? undefined : message.subspace; + obj.key = message.key === "" ? undefined : message.key; + return obj; + }, + fromAminoMsg(object: QueryParamsRequestAminoMsg): QueryParamsRequest { + return QueryParamsRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryParamsRequest): QueryParamsRequestAminoMsg { + return { + type: "cosmos-sdk/QueryParamsRequest", + value: QueryParamsRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryParamsRequestProtoMsg): QueryParamsRequest { + return QueryParamsRequest.decode(message.value); + }, + toProto(message: QueryParamsRequest): Uint8Array { + return QueryParamsRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryParamsRequest): QueryParamsRequestProtoMsg { + return { + typeUrl: "/cosmos.params.v1beta1.QueryParamsRequest", + value: QueryParamsRequest.encode(message).finish() + }; + } +}; +function createBaseQueryParamsResponse(): QueryParamsResponse { + return { + param: ParamChange.fromPartial({}) + }; +} +export const QueryParamsResponse = { + typeUrl: "/cosmos.params.v1beta1.QueryParamsResponse", + encode(message: QueryParamsResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.param !== undefined) { + ParamChange.encode(message.param, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryParamsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryParamsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.param = ParamChange.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryParamsResponse { + const obj = createBaseQueryParamsResponse(); + if (isSet(object.param)) obj.param = ParamChange.fromJSON(object.param); + return obj; + }, + toJSON(message: QueryParamsResponse): JsonSafe { + const obj: any = {}; + message.param !== undefined && (obj.param = message.param ? ParamChange.toJSON(message.param) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryParamsResponse { + const message = createBaseQueryParamsResponse(); + if (object.param !== undefined && object.param !== null) { + message.param = ParamChange.fromPartial(object.param); + } + return message; + }, + fromSDK(object: QueryParamsResponseSDKType): QueryParamsResponse { + return { + param: object.param ? ParamChange.fromSDK(object.param) : undefined + }; + }, + fromSDKJSON(object: any): QueryParamsResponseSDKType { + return { + param: isSet(object.param) ? ParamChange.fromSDKJSON(object.param) : undefined + }; + }, + toSDK(message: QueryParamsResponse): QueryParamsResponseSDKType { + const obj: any = {}; + message.param !== undefined && (obj.param = message.param ? ParamChange.toSDK(message.param) : undefined); + return obj; + }, + fromAmino(object: QueryParamsResponseAmino): QueryParamsResponse { + const message = createBaseQueryParamsResponse(); + if (object.param !== undefined && object.param !== null) { + message.param = ParamChange.fromAmino(object.param); + } + return message; + }, + toAmino(message: QueryParamsResponse): QueryParamsResponseAmino { + const obj: any = {}; + obj.param = message.param ? ParamChange.toAmino(message.param) : undefined; + return obj; + }, + fromAminoMsg(object: QueryParamsResponseAminoMsg): QueryParamsResponse { + return QueryParamsResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryParamsResponse): QueryParamsResponseAminoMsg { + return { + type: "cosmos-sdk/QueryParamsResponse", + value: QueryParamsResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryParamsResponseProtoMsg): QueryParamsResponse { + return QueryParamsResponse.decode(message.value); + }, + toProto(message: QueryParamsResponse): Uint8Array { + return QueryParamsResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryParamsResponse): QueryParamsResponseProtoMsg { + return { + typeUrl: "/cosmos.params.v1beta1.QueryParamsResponse", + value: QueryParamsResponse.encode(message).finish() + }; + } +}; +function createBaseQuerySubspacesRequest(): QuerySubspacesRequest { + return {}; +} +export const QuerySubspacesRequest = { + typeUrl: "/cosmos.params.v1beta1.QuerySubspacesRequest", + encode(_: QuerySubspacesRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QuerySubspacesRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQuerySubspacesRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): QuerySubspacesRequest { + const obj = createBaseQuerySubspacesRequest(); + return obj; + }, + toJSON(_: QuerySubspacesRequest): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): QuerySubspacesRequest { + const message = createBaseQuerySubspacesRequest(); + return message; + }, + fromSDK(_: QuerySubspacesRequestSDKType): QuerySubspacesRequest { + return {}; + }, + fromSDKJSON(_: any): QuerySubspacesRequestSDKType { + return {}; + }, + toSDK(_: QuerySubspacesRequest): QuerySubspacesRequestSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: QuerySubspacesRequestAmino): QuerySubspacesRequest { + const message = createBaseQuerySubspacesRequest(); + return message; + }, + toAmino(_: QuerySubspacesRequest): QuerySubspacesRequestAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: QuerySubspacesRequestAminoMsg): QuerySubspacesRequest { + return QuerySubspacesRequest.fromAmino(object.value); + }, + toAminoMsg(message: QuerySubspacesRequest): QuerySubspacesRequestAminoMsg { + return { + type: "cosmos-sdk/QuerySubspacesRequest", + value: QuerySubspacesRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QuerySubspacesRequestProtoMsg): QuerySubspacesRequest { + return QuerySubspacesRequest.decode(message.value); + }, + toProto(message: QuerySubspacesRequest): Uint8Array { + return QuerySubspacesRequest.encode(message).finish(); + }, + toProtoMsg(message: QuerySubspacesRequest): QuerySubspacesRequestProtoMsg { + return { + typeUrl: "/cosmos.params.v1beta1.QuerySubspacesRequest", + value: QuerySubspacesRequest.encode(message).finish() + }; + } +}; +function createBaseQuerySubspacesResponse(): QuerySubspacesResponse { + return { + subspaces: [] + }; +} +export const QuerySubspacesResponse = { + typeUrl: "/cosmos.params.v1beta1.QuerySubspacesResponse", + encode(message: QuerySubspacesResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.subspaces) { + Subspace.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QuerySubspacesResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQuerySubspacesResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.subspaces.push(Subspace.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QuerySubspacesResponse { + const obj = createBaseQuerySubspacesResponse(); + if (Array.isArray(object?.subspaces)) obj.subspaces = object.subspaces.map((e: any) => Subspace.fromJSON(e)); + return obj; + }, + toJSON(message: QuerySubspacesResponse): JsonSafe { + const obj: any = {}; + if (message.subspaces) { + obj.subspaces = message.subspaces.map(e => e ? Subspace.toJSON(e) : undefined); + } else { + obj.subspaces = []; + } + return obj; + }, + fromPartial(object: DeepPartial): QuerySubspacesResponse { + const message = createBaseQuerySubspacesResponse(); + message.subspaces = object.subspaces?.map(e => Subspace.fromPartial(e)) || []; + return message; + }, + fromSDK(object: QuerySubspacesResponseSDKType): QuerySubspacesResponse { + return { + subspaces: Array.isArray(object?.subspaces) ? object.subspaces.map((e: any) => Subspace.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): QuerySubspacesResponseSDKType { + return { + subspaces: Array.isArray(object?.subspaces) ? object.subspaces.map((e: any) => Subspace.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: QuerySubspacesResponse): QuerySubspacesResponseSDKType { + const obj: any = {}; + if (message.subspaces) { + obj.subspaces = message.subspaces.map(e => e ? Subspace.toSDK(e) : undefined); + } else { + obj.subspaces = []; + } + return obj; + }, + fromAmino(object: QuerySubspacesResponseAmino): QuerySubspacesResponse { + const message = createBaseQuerySubspacesResponse(); + message.subspaces = object.subspaces?.map(e => Subspace.fromAmino(e)) || []; + return message; + }, + toAmino(message: QuerySubspacesResponse): QuerySubspacesResponseAmino { + const obj: any = {}; + if (message.subspaces) { + obj.subspaces = message.subspaces.map(e => e ? Subspace.toAmino(e) : undefined); + } else { + obj.subspaces = message.subspaces; + } + return obj; + }, + fromAminoMsg(object: QuerySubspacesResponseAminoMsg): QuerySubspacesResponse { + return QuerySubspacesResponse.fromAmino(object.value); + }, + toAminoMsg(message: QuerySubspacesResponse): QuerySubspacesResponseAminoMsg { + return { + type: "cosmos-sdk/QuerySubspacesResponse", + value: QuerySubspacesResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QuerySubspacesResponseProtoMsg): QuerySubspacesResponse { + return QuerySubspacesResponse.decode(message.value); + }, + toProto(message: QuerySubspacesResponse): Uint8Array { + return QuerySubspacesResponse.encode(message).finish(); + }, + toProtoMsg(message: QuerySubspacesResponse): QuerySubspacesResponseProtoMsg { + return { + typeUrl: "/cosmos.params.v1beta1.QuerySubspacesResponse", + value: QuerySubspacesResponse.encode(message).finish() + }; + } +}; +function createBaseSubspace(): Subspace { + return { + subspace: "", + keys: [] + }; +} +export const Subspace = { + typeUrl: "/cosmos.params.v1beta1.Subspace", + encode(message: Subspace, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.subspace !== undefined) { + writer.uint32(10).string(message.subspace); + } + for (const v of message.keys) { + writer.uint32(18).string(v!); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Subspace { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseSubspace(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.subspace = reader.string(); + break; + case 2: + message.keys.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Subspace { + const obj = createBaseSubspace(); + if (isSet(object.subspace)) obj.subspace = String(object.subspace); + if (Array.isArray(object?.keys)) obj.keys = object.keys.map((e: any) => String(e)); + return obj; + }, + toJSON(message: Subspace): JsonSafe { + const obj: any = {}; + message.subspace !== undefined && (obj.subspace = message.subspace); + if (message.keys) { + obj.keys = message.keys.map(e => e); + } else { + obj.keys = []; + } + return obj; + }, + fromPartial(object: DeepPartial): Subspace { + const message = createBaseSubspace(); + message.subspace = object.subspace ?? ""; + message.keys = object.keys?.map(e => e) || []; + return message; + }, + fromSDK(object: SubspaceSDKType): Subspace { + return { + subspace: object?.subspace, + keys: Array.isArray(object?.keys) ? object.keys.map((e: any) => e) : [] + }; + }, + fromSDKJSON(object: any): SubspaceSDKType { + return { + subspace: isSet(object.subspace) ? String(object.subspace) : "", + keys: Array.isArray(object?.keys) ? object.keys.map((e: any) => String(e)) : [] + }; + }, + toSDK(message: Subspace): SubspaceSDKType { + const obj: any = {}; + obj.subspace = message.subspace; + if (message.keys) { + obj.keys = message.keys.map(e => e); + } else { + obj.keys = []; + } + return obj; + }, + fromAmino(object: SubspaceAmino): Subspace { + const message = createBaseSubspace(); + if (object.subspace !== undefined && object.subspace !== null) { + message.subspace = object.subspace; + } + message.keys = object.keys?.map(e => e) || []; + return message; + }, + toAmino(message: Subspace): SubspaceAmino { + const obj: any = {}; + obj.subspace = message.subspace === "" ? undefined : message.subspace; + if (message.keys) { + obj.keys = message.keys.map(e => e); + } else { + obj.keys = message.keys; + } + return obj; + }, + fromAminoMsg(object: SubspaceAminoMsg): Subspace { + return Subspace.fromAmino(object.value); + }, + toAminoMsg(message: Subspace): SubspaceAminoMsg { + return { + type: "cosmos-sdk/Subspace", + value: Subspace.toAmino(message) + }; + }, + fromProtoMsg(message: SubspaceProtoMsg): Subspace { + return Subspace.decode(message.value); + }, + toProto(message: Subspace): Uint8Array { + return Subspace.encode(message).finish(); + }, + toProtoMsg(message: Subspace): SubspaceProtoMsg { + return { + typeUrl: "/cosmos.params.v1beta1.Subspace", + value: Subspace.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/rpc.query.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/rpc.query.ts new file mode 100644 index 0000000000..7a583ff3e2 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/rpc.query.ts @@ -0,0 +1,73 @@ +import { Rpc } from "../helpers.js"; +import { connectComet, HttpEndpoint } from "@cosmjs/tendermint-rpc"; +import { QueryClient } from "@cosmjs/stargate"; +export const createRPCQueryClient = async ({ + rpcEndpoint +}: { + rpcEndpoint: string | HttpEndpoint; +}) => { + const tmClient = await connectComet(rpcEndpoint); + const client = new QueryClient(tmClient); + return { + cosmos: { + app: { + v1alpha1: (await import("./app/v1alpha1/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + auth: { + v1beta1: (await import("./auth/v1beta1/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + authz: { + v1beta1: (await import("./authz/v1beta1/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + bank: { + v1beta1: (await import("./bank/v1beta1/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + base: { + reflection: { + v1beta1: (await import("./base/reflection/v1beta1/reflection.rpc.ReflectionService.js")).createRpcQueryExtension(client), + v2alpha1: (await import("./base/reflection/v2alpha1/reflection.rpc.ReflectionService.js")).createRpcQueryExtension(client) + }, + tendermint: { + v1beta1: (await import("./base/tendermint/v1beta1/query.rpc.Service.js")).createRpcQueryExtension(client) + } + }, + distribution: { + v1beta1: (await import("./distribution/v1beta1/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + evidence: { + v1beta1: (await import("./evidence/v1beta1/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + feegrant: { + v1beta1: (await import("./feegrant/v1beta1/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + gov: { + v1: (await import("./gov/v1/query.rpc.Query.js")).createRpcQueryExtension(client), + v1beta1: (await import("./gov/v1beta1/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + group: { + v1: (await import("./group/v1/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + mint: { + v1beta1: (await import("./mint/v1beta1/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + nft: { + v1beta1: (await import("./nft/v1beta1/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + params: { + v1beta1: (await import("./params/v1beta1/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + slashing: { + v1beta1: (await import("./slashing/v1beta1/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + staking: { + v1beta1: (await import("./staking/v1beta1/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + tx: { + v1beta1: (await import("./tx/v1beta1/service.rpc.Service.js")).createRpcQueryExtension(client) + }, + upgrade: { + v1beta1: (await import("./upgrade/v1beta1/query.rpc.Query.js")).createRpcQueryExtension(client) + } + } + }; +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/rpc.tx.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/rpc.tx.ts new file mode 100644 index 0000000000..ee7fdfff0a --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/rpc.tx.ts @@ -0,0 +1,49 @@ +import { Rpc } from "../helpers.js"; +export const createRPCMsgClient = async ({ + rpc +}: { + rpc: Rpc; +}) => ({ + cosmos: { + authz: { + v1beta1: new (await import("./authz/v1beta1/tx.rpc.msg.js")).MsgClientImpl(rpc) + }, + bank: { + v1beta1: new (await import("./bank/v1beta1/tx.rpc.msg.js")).MsgClientImpl(rpc) + }, + crisis: { + v1beta1: new (await import("./crisis/v1beta1/tx.rpc.msg.js")).MsgClientImpl(rpc) + }, + distribution: { + v1beta1: new (await import("./distribution/v1beta1/tx.rpc.msg.js")).MsgClientImpl(rpc) + }, + evidence: { + v1beta1: new (await import("./evidence/v1beta1/tx.rpc.msg.js")).MsgClientImpl(rpc) + }, + feegrant: { + v1beta1: new (await import("./feegrant/v1beta1/tx.rpc.msg.js")).MsgClientImpl(rpc) + }, + gov: { + v1: new (await import("./gov/v1/tx.rpc.msg.js")).MsgClientImpl(rpc), + v1beta1: new (await import("./gov/v1beta1/tx.rpc.msg.js")).MsgClientImpl(rpc) + }, + group: { + v1: new (await import("./group/v1/tx.rpc.msg.js")).MsgClientImpl(rpc) + }, + nft: { + v1beta1: new (await import("./nft/v1beta1/tx.rpc.msg.js")).MsgClientImpl(rpc) + }, + slashing: { + v1beta1: new (await import("./slashing/v1beta1/tx.rpc.msg.js")).MsgClientImpl(rpc) + }, + staking: { + v1beta1: new (await import("./staking/v1beta1/tx.rpc.msg.js")).MsgClientImpl(rpc) + }, + upgrade: { + v1beta1: new (await import("./upgrade/v1beta1/tx.rpc.msg.js")).MsgClientImpl(rpc) + }, + vesting: { + v1beta1: new (await import("./vesting/v1beta1/tx.rpc.msg.js")).MsgClientImpl(rpc) + } + } +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/slashing/v1beta1/genesis.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/slashing/v1beta1/genesis.ts new file mode 100644 index 0000000000..d99b4d75ce --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/slashing/v1beta1/genesis.ts @@ -0,0 +1,581 @@ +import { Params, ParamsSDKType, ValidatorSigningInfo, ValidatorSigningInfoSDKType } from "./slashing.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "cosmos.slashing.v1beta1"; +/** GenesisState defines the slashing module's genesis state. */ +export interface GenesisState { + /** params defines all the paramaters of related to deposit. */ + params: Params; + /** + * signing_infos represents a map between validator addresses and their + * signing infos. + */ + signingInfos: SigningInfo[]; + /** + * missed_blocks represents a map between validator addresses and their + * missed blocks. + */ + missedBlocks: ValidatorMissedBlocks[]; +} +export interface GenesisStateProtoMsg { + typeUrl: "/cosmos.slashing.v1beta1.GenesisState"; + value: Uint8Array; +} +/** GenesisState defines the slashing module's genesis state. */ +export interface GenesisStateSDKType { + params: ParamsSDKType; + signing_infos: SigningInfoSDKType[]; + missed_blocks: ValidatorMissedBlocksSDKType[]; +} +/** SigningInfo stores validator signing info of corresponding address. */ +export interface SigningInfo { + /** address is the validator address. */ + address: string; + /** validator_signing_info represents the signing info of this validator. */ + validatorSigningInfo: ValidatorSigningInfo; +} +export interface SigningInfoProtoMsg { + typeUrl: "/cosmos.slashing.v1beta1.SigningInfo"; + value: Uint8Array; +} +/** SigningInfo stores validator signing info of corresponding address. */ +export interface SigningInfoSDKType { + address: string; + validator_signing_info: ValidatorSigningInfoSDKType; +} +/** + * ValidatorMissedBlocks contains array of missed blocks of corresponding + * address. + */ +export interface ValidatorMissedBlocks { + /** address is the validator address. */ + address: string; + /** missed_blocks is an array of missed blocks by the validator. */ + missedBlocks: MissedBlock[]; +} +export interface ValidatorMissedBlocksProtoMsg { + typeUrl: "/cosmos.slashing.v1beta1.ValidatorMissedBlocks"; + value: Uint8Array; +} +/** + * ValidatorMissedBlocks contains array of missed blocks of corresponding + * address. + */ +export interface ValidatorMissedBlocksSDKType { + address: string; + missed_blocks: MissedBlockSDKType[]; +} +/** MissedBlock contains height and missed status as boolean. */ +export interface MissedBlock { + /** index is the height at which the block was missed. */ + index: bigint; + /** missed is the missed status. */ + missed: boolean; +} +export interface MissedBlockProtoMsg { + typeUrl: "/cosmos.slashing.v1beta1.MissedBlock"; + value: Uint8Array; +} +/** MissedBlock contains height and missed status as boolean. */ +export interface MissedBlockSDKType { + index: bigint; + missed: boolean; +} +function createBaseGenesisState(): GenesisState { + return { + params: Params.fromPartial({}), + signingInfos: [], + missedBlocks: [] + }; +} +export const GenesisState = { + typeUrl: "/cosmos.slashing.v1beta1.GenesisState", + encode(message: GenesisState, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.signingInfos) { + SigningInfo.encode(v!, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.missedBlocks) { + ValidatorMissedBlocks.encode(v!, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GenesisState { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGenesisState(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.params = Params.decode(reader, reader.uint32()); + break; + case 2: + message.signingInfos.push(SigningInfo.decode(reader, reader.uint32())); + break; + case 3: + message.missedBlocks.push(ValidatorMissedBlocks.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GenesisState { + const obj = createBaseGenesisState(); + if (isSet(object.params)) obj.params = Params.fromJSON(object.params); + if (Array.isArray(object?.signingInfos)) obj.signingInfos = object.signingInfos.map((e: any) => SigningInfo.fromJSON(e)); + if (Array.isArray(object?.missedBlocks)) obj.missedBlocks = object.missedBlocks.map((e: any) => ValidatorMissedBlocks.fromJSON(e)); + return obj; + }, + toJSON(message: GenesisState): JsonSafe { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); + if (message.signingInfos) { + obj.signingInfos = message.signingInfos.map(e => e ? SigningInfo.toJSON(e) : undefined); + } else { + obj.signingInfos = []; + } + if (message.missedBlocks) { + obj.missedBlocks = message.missedBlocks.map(e => e ? ValidatorMissedBlocks.toJSON(e) : undefined); + } else { + obj.missedBlocks = []; + } + return obj; + }, + fromPartial(object: DeepPartial): GenesisState { + const message = createBaseGenesisState(); + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } + message.signingInfos = object.signingInfos?.map(e => SigningInfo.fromPartial(e)) || []; + message.missedBlocks = object.missedBlocks?.map(e => ValidatorMissedBlocks.fromPartial(e)) || []; + return message; + }, + fromSDK(object: GenesisStateSDKType): GenesisState { + return { + params: object.params ? Params.fromSDK(object.params) : undefined, + signingInfos: Array.isArray(object?.signing_infos) ? object.signing_infos.map((e: any) => SigningInfo.fromSDK(e)) : [], + missedBlocks: Array.isArray(object?.missed_blocks) ? object.missed_blocks.map((e: any) => ValidatorMissedBlocks.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): GenesisStateSDKType { + return { + params: isSet(object.params) ? Params.fromSDKJSON(object.params) : undefined, + signing_infos: Array.isArray(object?.signing_infos) ? object.signing_infos.map((e: any) => SigningInfo.fromSDKJSON(e)) : [], + missed_blocks: Array.isArray(object?.missed_blocks) ? object.missed_blocks.map((e: any) => ValidatorMissedBlocks.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: GenesisState): GenesisStateSDKType { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toSDK(message.params) : undefined); + if (message.signingInfos) { + obj.signing_infos = message.signingInfos.map(e => e ? SigningInfo.toSDK(e) : undefined); + } else { + obj.signing_infos = []; + } + if (message.missedBlocks) { + obj.missed_blocks = message.missedBlocks.map(e => e ? ValidatorMissedBlocks.toSDK(e) : undefined); + } else { + obj.missed_blocks = []; + } + return obj; + }, + fromAmino(object: GenesisStateAmino): GenesisState { + const message = createBaseGenesisState(); + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromAmino(object.params); + } + message.signingInfos = object.signing_infos?.map(e => SigningInfo.fromAmino(e)) || []; + message.missedBlocks = object.missed_blocks?.map(e => ValidatorMissedBlocks.fromAmino(e)) || []; + return message; + }, + toAmino(message: GenesisState): GenesisStateAmino { + const obj: any = {}; + obj.params = message.params ? Params.toAmino(message.params) : undefined; + if (message.signingInfos) { + obj.signing_infos = message.signingInfos.map(e => e ? SigningInfo.toAmino(e) : undefined); + } else { + obj.signing_infos = message.signingInfos; + } + if (message.missedBlocks) { + obj.missed_blocks = message.missedBlocks.map(e => e ? ValidatorMissedBlocks.toAmino(e) : undefined); + } else { + obj.missed_blocks = message.missedBlocks; + } + return obj; + }, + fromAminoMsg(object: GenesisStateAminoMsg): GenesisState { + return GenesisState.fromAmino(object.value); + }, + toAminoMsg(message: GenesisState): GenesisStateAminoMsg { + return { + type: "cosmos-sdk/GenesisState", + value: GenesisState.toAmino(message) + }; + }, + fromProtoMsg(message: GenesisStateProtoMsg): GenesisState { + return GenesisState.decode(message.value); + }, + toProto(message: GenesisState): Uint8Array { + return GenesisState.encode(message).finish(); + }, + toProtoMsg(message: GenesisState): GenesisStateProtoMsg { + return { + typeUrl: "/cosmos.slashing.v1beta1.GenesisState", + value: GenesisState.encode(message).finish() + }; + } +}; +function createBaseSigningInfo(): SigningInfo { + return { + address: "", + validatorSigningInfo: ValidatorSigningInfo.fromPartial({}) + }; +} +export const SigningInfo = { + typeUrl: "/cosmos.slashing.v1beta1.SigningInfo", + encode(message: SigningInfo, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.address !== undefined) { + writer.uint32(10).string(message.address); + } + if (message.validatorSigningInfo !== undefined) { + ValidatorSigningInfo.encode(message.validatorSigningInfo, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): SigningInfo { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseSigningInfo(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.string(); + break; + case 2: + message.validatorSigningInfo = ValidatorSigningInfo.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): SigningInfo { + const obj = createBaseSigningInfo(); + if (isSet(object.address)) obj.address = String(object.address); + if (isSet(object.validatorSigningInfo)) obj.validatorSigningInfo = ValidatorSigningInfo.fromJSON(object.validatorSigningInfo); + return obj; + }, + toJSON(message: SigningInfo): JsonSafe { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + message.validatorSigningInfo !== undefined && (obj.validatorSigningInfo = message.validatorSigningInfo ? ValidatorSigningInfo.toJSON(message.validatorSigningInfo) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): SigningInfo { + const message = createBaseSigningInfo(); + message.address = object.address ?? ""; + if (object.validatorSigningInfo !== undefined && object.validatorSigningInfo !== null) { + message.validatorSigningInfo = ValidatorSigningInfo.fromPartial(object.validatorSigningInfo); + } + return message; + }, + fromSDK(object: SigningInfoSDKType): SigningInfo { + return { + address: object?.address, + validatorSigningInfo: object.validator_signing_info ? ValidatorSigningInfo.fromSDK(object.validator_signing_info) : undefined + }; + }, + fromSDKJSON(object: any): SigningInfoSDKType { + return { + address: isSet(object.address) ? String(object.address) : "", + validator_signing_info: isSet(object.validator_signing_info) ? ValidatorSigningInfo.fromSDKJSON(object.validator_signing_info) : undefined + }; + }, + toSDK(message: SigningInfo): SigningInfoSDKType { + const obj: any = {}; + obj.address = message.address; + message.validatorSigningInfo !== undefined && (obj.validator_signing_info = message.validatorSigningInfo ? ValidatorSigningInfo.toSDK(message.validatorSigningInfo) : undefined); + return obj; + }, + fromAmino(object: SigningInfoAmino): SigningInfo { + const message = createBaseSigningInfo(); + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } + if (object.validator_signing_info !== undefined && object.validator_signing_info !== null) { + message.validatorSigningInfo = ValidatorSigningInfo.fromAmino(object.validator_signing_info); + } + return message; + }, + toAmino(message: SigningInfo): SigningInfoAmino { + const obj: any = {}; + obj.address = message.address === "" ? undefined : message.address; + obj.validator_signing_info = message.validatorSigningInfo ? ValidatorSigningInfo.toAmino(message.validatorSigningInfo) : undefined; + return obj; + }, + fromAminoMsg(object: SigningInfoAminoMsg): SigningInfo { + return SigningInfo.fromAmino(object.value); + }, + toAminoMsg(message: SigningInfo): SigningInfoAminoMsg { + return { + type: "cosmos-sdk/SigningInfo", + value: SigningInfo.toAmino(message) + }; + }, + fromProtoMsg(message: SigningInfoProtoMsg): SigningInfo { + return SigningInfo.decode(message.value); + }, + toProto(message: SigningInfo): Uint8Array { + return SigningInfo.encode(message).finish(); + }, + toProtoMsg(message: SigningInfo): SigningInfoProtoMsg { + return { + typeUrl: "/cosmos.slashing.v1beta1.SigningInfo", + value: SigningInfo.encode(message).finish() + }; + } +}; +function createBaseValidatorMissedBlocks(): ValidatorMissedBlocks { + return { + address: "", + missedBlocks: [] + }; +} +export const ValidatorMissedBlocks = { + typeUrl: "/cosmos.slashing.v1beta1.ValidatorMissedBlocks", + encode(message: ValidatorMissedBlocks, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.address !== undefined) { + writer.uint32(10).string(message.address); + } + for (const v of message.missedBlocks) { + MissedBlock.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ValidatorMissedBlocks { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseValidatorMissedBlocks(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.string(); + break; + case 2: + message.missedBlocks.push(MissedBlock.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ValidatorMissedBlocks { + const obj = createBaseValidatorMissedBlocks(); + if (isSet(object.address)) obj.address = String(object.address); + if (Array.isArray(object?.missedBlocks)) obj.missedBlocks = object.missedBlocks.map((e: any) => MissedBlock.fromJSON(e)); + return obj; + }, + toJSON(message: ValidatorMissedBlocks): JsonSafe { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + if (message.missedBlocks) { + obj.missedBlocks = message.missedBlocks.map(e => e ? MissedBlock.toJSON(e) : undefined); + } else { + obj.missedBlocks = []; + } + return obj; + }, + fromPartial(object: DeepPartial): ValidatorMissedBlocks { + const message = createBaseValidatorMissedBlocks(); + message.address = object.address ?? ""; + message.missedBlocks = object.missedBlocks?.map(e => MissedBlock.fromPartial(e)) || []; + return message; + }, + fromSDK(object: ValidatorMissedBlocksSDKType): ValidatorMissedBlocks { + return { + address: object?.address, + missedBlocks: Array.isArray(object?.missed_blocks) ? object.missed_blocks.map((e: any) => MissedBlock.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): ValidatorMissedBlocksSDKType { + return { + address: isSet(object.address) ? String(object.address) : "", + missed_blocks: Array.isArray(object?.missed_blocks) ? object.missed_blocks.map((e: any) => MissedBlock.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: ValidatorMissedBlocks): ValidatorMissedBlocksSDKType { + const obj: any = {}; + obj.address = message.address; + if (message.missedBlocks) { + obj.missed_blocks = message.missedBlocks.map(e => e ? MissedBlock.toSDK(e) : undefined); + } else { + obj.missed_blocks = []; + } + return obj; + }, + fromAmino(object: ValidatorMissedBlocksAmino): ValidatorMissedBlocks { + const message = createBaseValidatorMissedBlocks(); + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } + message.missedBlocks = object.missed_blocks?.map(e => MissedBlock.fromAmino(e)) || []; + return message; + }, + toAmino(message: ValidatorMissedBlocks): ValidatorMissedBlocksAmino { + const obj: any = {}; + obj.address = message.address === "" ? undefined : message.address; + if (message.missedBlocks) { + obj.missed_blocks = message.missedBlocks.map(e => e ? MissedBlock.toAmino(e) : undefined); + } else { + obj.missed_blocks = message.missedBlocks; + } + return obj; + }, + fromAminoMsg(object: ValidatorMissedBlocksAminoMsg): ValidatorMissedBlocks { + return ValidatorMissedBlocks.fromAmino(object.value); + }, + toAminoMsg(message: ValidatorMissedBlocks): ValidatorMissedBlocksAminoMsg { + return { + type: "cosmos-sdk/ValidatorMissedBlocks", + value: ValidatorMissedBlocks.toAmino(message) + }; + }, + fromProtoMsg(message: ValidatorMissedBlocksProtoMsg): ValidatorMissedBlocks { + return ValidatorMissedBlocks.decode(message.value); + }, + toProto(message: ValidatorMissedBlocks): Uint8Array { + return ValidatorMissedBlocks.encode(message).finish(); + }, + toProtoMsg(message: ValidatorMissedBlocks): ValidatorMissedBlocksProtoMsg { + return { + typeUrl: "/cosmos.slashing.v1beta1.ValidatorMissedBlocks", + value: ValidatorMissedBlocks.encode(message).finish() + }; + } +}; +function createBaseMissedBlock(): MissedBlock { + return { + index: BigInt(0), + missed: false + }; +} +export const MissedBlock = { + typeUrl: "/cosmos.slashing.v1beta1.MissedBlock", + encode(message: MissedBlock, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.index !== undefined) { + writer.uint32(8).int64(message.index); + } + if (message.missed !== undefined) { + writer.uint32(16).bool(message.missed); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MissedBlock { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMissedBlock(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.index = reader.int64(); + break; + case 2: + message.missed = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MissedBlock { + const obj = createBaseMissedBlock(); + if (isSet(object.index)) obj.index = BigInt(object.index.toString()); + if (isSet(object.missed)) obj.missed = Boolean(object.missed); + return obj; + }, + toJSON(message: MissedBlock): JsonSafe { + const obj: any = {}; + message.index !== undefined && (obj.index = (message.index || BigInt(0)).toString()); + message.missed !== undefined && (obj.missed = message.missed); + return obj; + }, + fromPartial(object: DeepPartial): MissedBlock { + const message = createBaseMissedBlock(); + if (object.index !== undefined && object.index !== null) { + message.index = BigInt(object.index.toString()); + } + message.missed = object.missed ?? false; + return message; + }, + fromSDK(object: MissedBlockSDKType): MissedBlock { + return { + index: object?.index, + missed: object?.missed + }; + }, + fromSDKJSON(object: any): MissedBlockSDKType { + return { + index: isSet(object.index) ? BigInt(object.index.toString()) : BigInt(0), + missed: isSet(object.missed) ? Boolean(object.missed) : false + }; + }, + toSDK(message: MissedBlock): MissedBlockSDKType { + const obj: any = {}; + obj.index = message.index; + obj.missed = message.missed; + return obj; + }, + fromAmino(object: MissedBlockAmino): MissedBlock { + const message = createBaseMissedBlock(); + if (object.index !== undefined && object.index !== null) { + message.index = BigInt(object.index); + } + if (object.missed !== undefined && object.missed !== null) { + message.missed = object.missed; + } + return message; + }, + toAmino(message: MissedBlock): MissedBlockAmino { + const obj: any = {}; + obj.index = message.index !== BigInt(0) ? message.index?.toString() : undefined; + obj.missed = message.missed === false ? undefined : message.missed; + return obj; + }, + fromAminoMsg(object: MissedBlockAminoMsg): MissedBlock { + return MissedBlock.fromAmino(object.value); + }, + toAminoMsg(message: MissedBlock): MissedBlockAminoMsg { + return { + type: "cosmos-sdk/MissedBlock", + value: MissedBlock.toAmino(message) + }; + }, + fromProtoMsg(message: MissedBlockProtoMsg): MissedBlock { + return MissedBlock.decode(message.value); + }, + toProto(message: MissedBlock): Uint8Array { + return MissedBlock.encode(message).finish(); + }, + toProtoMsg(message: MissedBlock): MissedBlockProtoMsg { + return { + typeUrl: "/cosmos.slashing.v1beta1.MissedBlock", + value: MissedBlock.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/slashing/v1beta1/query.lcd.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/slashing/v1beta1/query.lcd.ts new file mode 100644 index 0000000000..7a1d6bbc68 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/slashing/v1beta1/query.lcd.ts @@ -0,0 +1,41 @@ +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../base/query/v1beta1/pagination.js"; +import { Params, ParamsSDKType, ValidatorSigningInfo, ValidatorSigningInfoSDKType } from "./slashing.js"; +import { setPaginationParams } from "../../../helpers.js"; +import { LCDClient } from "@cosmology/lcd"; +import { QueryParamsRequest, QueryParamsRequestSDKType, QueryParamsResponse, QueryParamsResponseSDKType, QuerySigningInfoRequest, QuerySigningInfoRequestSDKType, QuerySigningInfoResponse, QuerySigningInfoResponseSDKType, QuerySigningInfosRequest, QuerySigningInfosRequestSDKType, QuerySigningInfosResponse, QuerySigningInfosResponseSDKType } from "./query.js"; +export class LCDQueryClient { + req: LCDClient; + constructor({ + requestClient + }: { + requestClient: LCDClient; + }) { + this.req = requestClient; + this.params = this.params.bind(this); + this.signingInfo = this.signingInfo.bind(this); + this.signingInfos = this.signingInfos.bind(this); + } + /* Params queries the parameters of slashing module */ + async params(_params: QueryParamsRequest = {}): Promise { + const endpoint = `cosmos/slashing/v1beta1/params`; + return QueryParamsResponse.fromSDKJSON(await this.req.get(endpoint)); + } + /* SigningInfo queries the signing info of given cons address */ + async signingInfo(params: QuerySigningInfoRequest): Promise { + const endpoint = `cosmos/slashing/v1beta1/signing_infos/${params.consAddress}`; + return QuerySigningInfoResponse.fromSDKJSON(await this.req.get(endpoint)); + } + /* SigningInfos queries signing info of all validators */ + async signingInfos(params: QuerySigningInfosRequest = { + pagination: PageRequest.fromPartial({}) + }): Promise { + const options: any = { + params: {} + }; + if (typeof params?.pagination !== "undefined") { + setPaginationParams(options, params.pagination); + } + const endpoint = `cosmos/slashing/v1beta1/signing_infos`; + return QuerySigningInfosResponse.fromSDKJSON(await this.req.get(endpoint, options)); + } +} \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/slashing/v1beta1/query.rpc.Query.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/slashing/v1beta1/query.rpc.Query.ts new file mode 100644 index 0000000000..0808cf79b5 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/slashing/v1beta1/query.rpc.Query.ts @@ -0,0 +1,56 @@ +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../base/query/v1beta1/pagination.js"; +import { Params, ParamsSDKType, ValidatorSigningInfo, ValidatorSigningInfoSDKType } from "./slashing.js"; +import { Rpc } from "../../../helpers.js"; +import { BinaryReader } from "../../../binary.js"; +import { QueryClient, createProtobufRpcClient } from "@cosmjs/stargate"; +import { QueryParamsRequest, QueryParamsRequestSDKType, QueryParamsResponse, QueryParamsResponseSDKType, QuerySigningInfoRequest, QuerySigningInfoRequestSDKType, QuerySigningInfoResponse, QuerySigningInfoResponseSDKType, QuerySigningInfosRequest, QuerySigningInfosRequestSDKType, QuerySigningInfosResponse, QuerySigningInfosResponseSDKType } from "./query.js"; +/** Query provides defines the gRPC querier service */ +export interface Query { + /** Params queries the parameters of slashing module */ + params(request?: QueryParamsRequest): Promise; + /** SigningInfo queries the signing info of given cons address */ + signingInfo(request: QuerySigningInfoRequest): Promise; + /** SigningInfos queries signing info of all validators */ + signingInfos(request?: QuerySigningInfosRequest): Promise; +} +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + this.params = this.params.bind(this); + this.signingInfo = this.signingInfo.bind(this); + this.signingInfos = this.signingInfos.bind(this); + } + params(request: QueryParamsRequest = {}): Promise { + const data = QueryParamsRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.slashing.v1beta1.Query", "Params", data); + return promise.then(data => QueryParamsResponse.decode(new BinaryReader(data))); + } + signingInfo(request: QuerySigningInfoRequest): Promise { + const data = QuerySigningInfoRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.slashing.v1beta1.Query", "SigningInfo", data); + return promise.then(data => QuerySigningInfoResponse.decode(new BinaryReader(data))); + } + signingInfos(request: QuerySigningInfosRequest = { + pagination: PageRequest.fromPartial({}) + }): Promise { + const data = QuerySigningInfosRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.slashing.v1beta1.Query", "SigningInfos", data); + return promise.then(data => QuerySigningInfosResponse.decode(new BinaryReader(data))); + } +} +export const createRpcQueryExtension = (base: QueryClient) => { + const rpc = createProtobufRpcClient(base); + const queryService = new QueryClientImpl(rpc); + return { + params(request?: QueryParamsRequest): Promise { + return queryService.params(request); + }, + signingInfo(request: QuerySigningInfoRequest): Promise { + return queryService.signingInfo(request); + }, + signingInfos(request?: QuerySigningInfosRequest): Promise { + return queryService.signingInfos(request); + } + }; +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/slashing/v1beta1/query.rpc.func.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/slashing/v1beta1/query.rpc.func.ts new file mode 100644 index 0000000000..f5b43b9bc1 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/slashing/v1beta1/query.rpc.func.ts @@ -0,0 +1,36 @@ +import { RpcResolver, buildQuery } from "../../../helper-func-types"; +import { buildUseQuery } from "../../../react-query"; +import { QueryParamsRequest, QueryParamsResponse, QuerySigningInfoRequest, QuerySigningInfoResponse, QuerySigningInfosRequest, QuerySigningInfosResponse } from "./query"; +export const createGetParams = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryParamsRequest.encode, + decode: QueryParamsResponse.decode, + service: "cosmos.slashing.v1beta1.Query", + method: "Params", + getRpcInstance: getRpcInstance +}); +export const useGetParams = buildUseQuery({ + builderQueryFn: createGetParams, + queryKeyPrefix: "ParamsQuery" +}); +export const createGetSigningInfo = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QuerySigningInfoRequest.encode, + decode: QuerySigningInfoResponse.decode, + service: "cosmos.slashing.v1beta1.Query", + method: "SigningInfo", + getRpcInstance: getRpcInstance +}); +export const useGetSigningInfo = buildUseQuery({ + builderQueryFn: createGetSigningInfo, + queryKeyPrefix: "SigningInfoQuery" +}); +export const createGetSigningInfos = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QuerySigningInfosRequest.encode, + decode: QuerySigningInfosResponse.decode, + service: "cosmos.slashing.v1beta1.Query", + method: "SigningInfos", + getRpcInstance: getRpcInstance +}); +export const useGetSigningInfos = buildUseQuery({ + builderQueryFn: createGetSigningInfos, + queryKeyPrefix: "SigningInfosQuery" +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/slashing/v1beta1/query.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/slashing/v1beta1/query.ts new file mode 100644 index 0000000000..2156c1bcbb --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/slashing/v1beta1/query.ts @@ -0,0 +1,682 @@ +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../base/query/v1beta1/pagination.js"; +import { Params, ParamsSDKType, ValidatorSigningInfo, ValidatorSigningInfoSDKType } from "./slashing.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { JsonSafe } from "../../../json-safe.js"; +import { DeepPartial, isSet } from "../../../helpers.js"; +export const protobufPackage = "cosmos.slashing.v1beta1"; +/** QueryParamsRequest is the request type for the Query/Params RPC method */ +export interface QueryParamsRequest {} +export interface QueryParamsRequestProtoMsg { + typeUrl: "/cosmos.slashing.v1beta1.QueryParamsRequest"; + value: Uint8Array; +} +/** QueryParamsRequest is the request type for the Query/Params RPC method */ +export interface QueryParamsRequestSDKType {} +/** QueryParamsResponse is the response type for the Query/Params RPC method */ +export interface QueryParamsResponse { + params: Params; +} +export interface QueryParamsResponseProtoMsg { + typeUrl: "/cosmos.slashing.v1beta1.QueryParamsResponse"; + value: Uint8Array; +} +/** QueryParamsResponse is the response type for the Query/Params RPC method */ +export interface QueryParamsResponseSDKType { + params: ParamsSDKType; +} +/** + * QuerySigningInfoRequest is the request type for the Query/SigningInfo RPC + * method + */ +export interface QuerySigningInfoRequest { + /** cons_address is the address to query signing info of */ + consAddress: string; +} +export interface QuerySigningInfoRequestProtoMsg { + typeUrl: "/cosmos.slashing.v1beta1.QuerySigningInfoRequest"; + value: Uint8Array; +} +/** + * QuerySigningInfoRequest is the request type for the Query/SigningInfo RPC + * method + */ +export interface QuerySigningInfoRequestSDKType { + cons_address: string; +} +/** + * QuerySigningInfoResponse is the response type for the Query/SigningInfo RPC + * method + */ +export interface QuerySigningInfoResponse { + /** val_signing_info is the signing info of requested val cons address */ + valSigningInfo: ValidatorSigningInfo; +} +export interface QuerySigningInfoResponseProtoMsg { + typeUrl: "/cosmos.slashing.v1beta1.QuerySigningInfoResponse"; + value: Uint8Array; +} +/** + * QuerySigningInfoResponse is the response type for the Query/SigningInfo RPC + * method + */ +export interface QuerySigningInfoResponseSDKType { + val_signing_info: ValidatorSigningInfoSDKType; +} +/** + * QuerySigningInfosRequest is the request type for the Query/SigningInfos RPC + * method + */ +export interface QuerySigningInfosRequest { + pagination?: PageRequest; +} +export interface QuerySigningInfosRequestProtoMsg { + typeUrl: "/cosmos.slashing.v1beta1.QuerySigningInfosRequest"; + value: Uint8Array; +} +/** + * QuerySigningInfosRequest is the request type for the Query/SigningInfos RPC + * method + */ +export interface QuerySigningInfosRequestSDKType { + pagination?: PageRequestSDKType; +} +/** + * QuerySigningInfosResponse is the response type for the Query/SigningInfos RPC + * method + */ +export interface QuerySigningInfosResponse { + /** info is the signing info of all validators */ + info: ValidatorSigningInfo[]; + pagination?: PageResponse; +} +export interface QuerySigningInfosResponseProtoMsg { + typeUrl: "/cosmos.slashing.v1beta1.QuerySigningInfosResponse"; + value: Uint8Array; +} +/** + * QuerySigningInfosResponse is the response type for the Query/SigningInfos RPC + * method + */ +export interface QuerySigningInfosResponseSDKType { + info: ValidatorSigningInfoSDKType[]; + pagination?: PageResponseSDKType; +} +function createBaseQueryParamsRequest(): QueryParamsRequest { + return {}; +} +export const QueryParamsRequest = { + typeUrl: "/cosmos.slashing.v1beta1.QueryParamsRequest", + encode(_: QueryParamsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryParamsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryParamsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): QueryParamsRequest { + const obj = createBaseQueryParamsRequest(); + return obj; + }, + toJSON(_: QueryParamsRequest): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): QueryParamsRequest { + const message = createBaseQueryParamsRequest(); + return message; + }, + fromSDK(_: QueryParamsRequestSDKType): QueryParamsRequest { + return {}; + }, + fromSDKJSON(_: any): QueryParamsRequestSDKType { + return {}; + }, + toSDK(_: QueryParamsRequest): QueryParamsRequestSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: QueryParamsRequestAmino): QueryParamsRequest { + const message = createBaseQueryParamsRequest(); + return message; + }, + toAmino(_: QueryParamsRequest): QueryParamsRequestAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: QueryParamsRequestAminoMsg): QueryParamsRequest { + return QueryParamsRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryParamsRequest): QueryParamsRequestAminoMsg { + return { + type: "cosmos-sdk/QueryParamsRequest", + value: QueryParamsRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryParamsRequestProtoMsg): QueryParamsRequest { + return QueryParamsRequest.decode(message.value); + }, + toProto(message: QueryParamsRequest): Uint8Array { + return QueryParamsRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryParamsRequest): QueryParamsRequestProtoMsg { + return { + typeUrl: "/cosmos.slashing.v1beta1.QueryParamsRequest", + value: QueryParamsRequest.encode(message).finish() + }; + } +}; +function createBaseQueryParamsResponse(): QueryParamsResponse { + return { + params: Params.fromPartial({}) + }; +} +export const QueryParamsResponse = { + typeUrl: "/cosmos.slashing.v1beta1.QueryParamsResponse", + encode(message: QueryParamsResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryParamsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryParamsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.params = Params.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryParamsResponse { + const obj = createBaseQueryParamsResponse(); + if (isSet(object.params)) obj.params = Params.fromJSON(object.params); + return obj; + }, + toJSON(message: QueryParamsResponse): JsonSafe { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryParamsResponse { + const message = createBaseQueryParamsResponse(); + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } + return message; + }, + fromSDK(object: QueryParamsResponseSDKType): QueryParamsResponse { + return { + params: object.params ? Params.fromSDK(object.params) : undefined + }; + }, + fromSDKJSON(object: any): QueryParamsResponseSDKType { + return { + params: isSet(object.params) ? Params.fromSDKJSON(object.params) : undefined + }; + }, + toSDK(message: QueryParamsResponse): QueryParamsResponseSDKType { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toSDK(message.params) : undefined); + return obj; + }, + fromAmino(object: QueryParamsResponseAmino): QueryParamsResponse { + const message = createBaseQueryParamsResponse(); + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromAmino(object.params); + } + return message; + }, + toAmino(message: QueryParamsResponse): QueryParamsResponseAmino { + const obj: any = {}; + obj.params = message.params ? Params.toAmino(message.params) : undefined; + return obj; + }, + fromAminoMsg(object: QueryParamsResponseAminoMsg): QueryParamsResponse { + return QueryParamsResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryParamsResponse): QueryParamsResponseAminoMsg { + return { + type: "cosmos-sdk/QueryParamsResponse", + value: QueryParamsResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryParamsResponseProtoMsg): QueryParamsResponse { + return QueryParamsResponse.decode(message.value); + }, + toProto(message: QueryParamsResponse): Uint8Array { + return QueryParamsResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryParamsResponse): QueryParamsResponseProtoMsg { + return { + typeUrl: "/cosmos.slashing.v1beta1.QueryParamsResponse", + value: QueryParamsResponse.encode(message).finish() + }; + } +}; +function createBaseQuerySigningInfoRequest(): QuerySigningInfoRequest { + return { + consAddress: "" + }; +} +export const QuerySigningInfoRequest = { + typeUrl: "/cosmos.slashing.v1beta1.QuerySigningInfoRequest", + encode(message: QuerySigningInfoRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.consAddress !== undefined) { + writer.uint32(10).string(message.consAddress); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QuerySigningInfoRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQuerySigningInfoRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.consAddress = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QuerySigningInfoRequest { + const obj = createBaseQuerySigningInfoRequest(); + if (isSet(object.consAddress)) obj.consAddress = String(object.consAddress); + return obj; + }, + toJSON(message: QuerySigningInfoRequest): JsonSafe { + const obj: any = {}; + message.consAddress !== undefined && (obj.consAddress = message.consAddress); + return obj; + }, + fromPartial(object: DeepPartial): QuerySigningInfoRequest { + const message = createBaseQuerySigningInfoRequest(); + message.consAddress = object.consAddress ?? ""; + return message; + }, + fromSDK(object: QuerySigningInfoRequestSDKType): QuerySigningInfoRequest { + return { + consAddress: object?.cons_address + }; + }, + fromSDKJSON(object: any): QuerySigningInfoRequestSDKType { + return { + cons_address: isSet(object.cons_address) ? String(object.cons_address) : "" + }; + }, + toSDK(message: QuerySigningInfoRequest): QuerySigningInfoRequestSDKType { + const obj: any = {}; + obj.cons_address = message.consAddress; + return obj; + }, + fromAmino(object: QuerySigningInfoRequestAmino): QuerySigningInfoRequest { + const message = createBaseQuerySigningInfoRequest(); + if (object.cons_address !== undefined && object.cons_address !== null) { + message.consAddress = object.cons_address; + } + return message; + }, + toAmino(message: QuerySigningInfoRequest): QuerySigningInfoRequestAmino { + const obj: any = {}; + obj.cons_address = message.consAddress === "" ? undefined : message.consAddress; + return obj; + }, + fromAminoMsg(object: QuerySigningInfoRequestAminoMsg): QuerySigningInfoRequest { + return QuerySigningInfoRequest.fromAmino(object.value); + }, + toAminoMsg(message: QuerySigningInfoRequest): QuerySigningInfoRequestAminoMsg { + return { + type: "cosmos-sdk/QuerySigningInfoRequest", + value: QuerySigningInfoRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QuerySigningInfoRequestProtoMsg): QuerySigningInfoRequest { + return QuerySigningInfoRequest.decode(message.value); + }, + toProto(message: QuerySigningInfoRequest): Uint8Array { + return QuerySigningInfoRequest.encode(message).finish(); + }, + toProtoMsg(message: QuerySigningInfoRequest): QuerySigningInfoRequestProtoMsg { + return { + typeUrl: "/cosmos.slashing.v1beta1.QuerySigningInfoRequest", + value: QuerySigningInfoRequest.encode(message).finish() + }; + } +}; +function createBaseQuerySigningInfoResponse(): QuerySigningInfoResponse { + return { + valSigningInfo: ValidatorSigningInfo.fromPartial({}) + }; +} +export const QuerySigningInfoResponse = { + typeUrl: "/cosmos.slashing.v1beta1.QuerySigningInfoResponse", + encode(message: QuerySigningInfoResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.valSigningInfo !== undefined) { + ValidatorSigningInfo.encode(message.valSigningInfo, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QuerySigningInfoResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQuerySigningInfoResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.valSigningInfo = ValidatorSigningInfo.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QuerySigningInfoResponse { + const obj = createBaseQuerySigningInfoResponse(); + if (isSet(object.valSigningInfo)) obj.valSigningInfo = ValidatorSigningInfo.fromJSON(object.valSigningInfo); + return obj; + }, + toJSON(message: QuerySigningInfoResponse): JsonSafe { + const obj: any = {}; + message.valSigningInfo !== undefined && (obj.valSigningInfo = message.valSigningInfo ? ValidatorSigningInfo.toJSON(message.valSigningInfo) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QuerySigningInfoResponse { + const message = createBaseQuerySigningInfoResponse(); + if (object.valSigningInfo !== undefined && object.valSigningInfo !== null) { + message.valSigningInfo = ValidatorSigningInfo.fromPartial(object.valSigningInfo); + } + return message; + }, + fromSDK(object: QuerySigningInfoResponseSDKType): QuerySigningInfoResponse { + return { + valSigningInfo: object.val_signing_info ? ValidatorSigningInfo.fromSDK(object.val_signing_info) : undefined + }; + }, + fromSDKJSON(object: any): QuerySigningInfoResponseSDKType { + return { + val_signing_info: isSet(object.val_signing_info) ? ValidatorSigningInfo.fromSDKJSON(object.val_signing_info) : undefined + }; + }, + toSDK(message: QuerySigningInfoResponse): QuerySigningInfoResponseSDKType { + const obj: any = {}; + message.valSigningInfo !== undefined && (obj.val_signing_info = message.valSigningInfo ? ValidatorSigningInfo.toSDK(message.valSigningInfo) : undefined); + return obj; + }, + fromAmino(object: QuerySigningInfoResponseAmino): QuerySigningInfoResponse { + const message = createBaseQuerySigningInfoResponse(); + if (object.val_signing_info !== undefined && object.val_signing_info !== null) { + message.valSigningInfo = ValidatorSigningInfo.fromAmino(object.val_signing_info); + } + return message; + }, + toAmino(message: QuerySigningInfoResponse): QuerySigningInfoResponseAmino { + const obj: any = {}; + obj.val_signing_info = message.valSigningInfo ? ValidatorSigningInfo.toAmino(message.valSigningInfo) : undefined; + return obj; + }, + fromAminoMsg(object: QuerySigningInfoResponseAminoMsg): QuerySigningInfoResponse { + return QuerySigningInfoResponse.fromAmino(object.value); + }, + toAminoMsg(message: QuerySigningInfoResponse): QuerySigningInfoResponseAminoMsg { + return { + type: "cosmos-sdk/QuerySigningInfoResponse", + value: QuerySigningInfoResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QuerySigningInfoResponseProtoMsg): QuerySigningInfoResponse { + return QuerySigningInfoResponse.decode(message.value); + }, + toProto(message: QuerySigningInfoResponse): Uint8Array { + return QuerySigningInfoResponse.encode(message).finish(); + }, + toProtoMsg(message: QuerySigningInfoResponse): QuerySigningInfoResponseProtoMsg { + return { + typeUrl: "/cosmos.slashing.v1beta1.QuerySigningInfoResponse", + value: QuerySigningInfoResponse.encode(message).finish() + }; + } +}; +function createBaseQuerySigningInfosRequest(): QuerySigningInfosRequest { + return { + pagination: undefined + }; +} +export const QuerySigningInfosRequest = { + typeUrl: "/cosmos.slashing.v1beta1.QuerySigningInfosRequest", + encode(message: QuerySigningInfosRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QuerySigningInfosRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQuerySigningInfosRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QuerySigningInfosRequest { + const obj = createBaseQuerySigningInfosRequest(); + if (isSet(object.pagination)) obj.pagination = PageRequest.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QuerySigningInfosRequest): JsonSafe { + const obj: any = {}; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QuerySigningInfosRequest { + const message = createBaseQuerySigningInfosRequest(); + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QuerySigningInfosRequestSDKType): QuerySigningInfosRequest { + return { + pagination: object.pagination ? PageRequest.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QuerySigningInfosRequestSDKType { + return { + pagination: isSet(object.pagination) ? PageRequest.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QuerySigningInfosRequest): QuerySigningInfosRequestSDKType { + const obj: any = {}; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QuerySigningInfosRequestAmino): QuerySigningInfosRequest { + const message = createBaseQuerySigningInfosRequest(); + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QuerySigningInfosRequest): QuerySigningInfosRequestAmino { + const obj: any = {}; + obj.pagination = message.pagination ? PageRequest.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QuerySigningInfosRequestAminoMsg): QuerySigningInfosRequest { + return QuerySigningInfosRequest.fromAmino(object.value); + }, + toAminoMsg(message: QuerySigningInfosRequest): QuerySigningInfosRequestAminoMsg { + return { + type: "cosmos-sdk/QuerySigningInfosRequest", + value: QuerySigningInfosRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QuerySigningInfosRequestProtoMsg): QuerySigningInfosRequest { + return QuerySigningInfosRequest.decode(message.value); + }, + toProto(message: QuerySigningInfosRequest): Uint8Array { + return QuerySigningInfosRequest.encode(message).finish(); + }, + toProtoMsg(message: QuerySigningInfosRequest): QuerySigningInfosRequestProtoMsg { + return { + typeUrl: "/cosmos.slashing.v1beta1.QuerySigningInfosRequest", + value: QuerySigningInfosRequest.encode(message).finish() + }; + } +}; +function createBaseQuerySigningInfosResponse(): QuerySigningInfosResponse { + return { + info: [], + pagination: undefined + }; +} +export const QuerySigningInfosResponse = { + typeUrl: "/cosmos.slashing.v1beta1.QuerySigningInfosResponse", + encode(message: QuerySigningInfosResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.info) { + ValidatorSigningInfo.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QuerySigningInfosResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQuerySigningInfosResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.info.push(ValidatorSigningInfo.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QuerySigningInfosResponse { + const obj = createBaseQuerySigningInfosResponse(); + if (Array.isArray(object?.info)) obj.info = object.info.map((e: any) => ValidatorSigningInfo.fromJSON(e)); + if (isSet(object.pagination)) obj.pagination = PageResponse.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QuerySigningInfosResponse): JsonSafe { + const obj: any = {}; + if (message.info) { + obj.info = message.info.map(e => e ? ValidatorSigningInfo.toJSON(e) : undefined); + } else { + obj.info = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QuerySigningInfosResponse { + const message = createBaseQuerySigningInfosResponse(); + message.info = object.info?.map(e => ValidatorSigningInfo.fromPartial(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QuerySigningInfosResponseSDKType): QuerySigningInfosResponse { + return { + info: Array.isArray(object?.info) ? object.info.map((e: any) => ValidatorSigningInfo.fromSDK(e)) : [], + pagination: object.pagination ? PageResponse.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QuerySigningInfosResponseSDKType { + return { + info: Array.isArray(object?.info) ? object.info.map((e: any) => ValidatorSigningInfo.fromSDKJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QuerySigningInfosResponse): QuerySigningInfosResponseSDKType { + const obj: any = {}; + if (message.info) { + obj.info = message.info.map(e => e ? ValidatorSigningInfo.toSDK(e) : undefined); + } else { + obj.info = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QuerySigningInfosResponseAmino): QuerySigningInfosResponse { + const message = createBaseQuerySigningInfosResponse(); + message.info = object.info?.map(e => ValidatorSigningInfo.fromAmino(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QuerySigningInfosResponse): QuerySigningInfosResponseAmino { + const obj: any = {}; + if (message.info) { + obj.info = message.info.map(e => e ? ValidatorSigningInfo.toAmino(e) : undefined); + } else { + obj.info = message.info; + } + obj.pagination = message.pagination ? PageResponse.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QuerySigningInfosResponseAminoMsg): QuerySigningInfosResponse { + return QuerySigningInfosResponse.fromAmino(object.value); + }, + toAminoMsg(message: QuerySigningInfosResponse): QuerySigningInfosResponseAminoMsg { + return { + type: "cosmos-sdk/QuerySigningInfosResponse", + value: QuerySigningInfosResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QuerySigningInfosResponseProtoMsg): QuerySigningInfosResponse { + return QuerySigningInfosResponse.decode(message.value); + }, + toProto(message: QuerySigningInfosResponse): Uint8Array { + return QuerySigningInfosResponse.encode(message).finish(); + }, + toProtoMsg(message: QuerySigningInfosResponse): QuerySigningInfosResponseProtoMsg { + return { + typeUrl: "/cosmos.slashing.v1beta1.QuerySigningInfosResponse", + value: QuerySigningInfosResponse.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/slashing/v1beta1/slashing.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/slashing/v1beta1/slashing.ts new file mode 100644 index 0000000000..288dc3e078 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/slashing/v1beta1/slashing.ts @@ -0,0 +1,420 @@ +import { Timestamp, TimestampSDKType } from "../../../google/protobuf/timestamp.js"; +import { Duration, DurationSDKType } from "../../../google/protobuf/duration.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { toTimestamp, fromTimestamp, isSet, DeepPartial, bytesFromBase64, base64FromBytes } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "cosmos.slashing.v1beta1"; +/** + * ValidatorSigningInfo defines a validator's signing info for monitoring their + * liveness activity. + */ +export interface ValidatorSigningInfo { + address: string; + /** Height at which validator was first a candidate OR was unjailed */ + startHeight: bigint; + /** + * Index which is incremented each time the validator was a bonded + * in a block and may have signed a precommit or not. This in conjunction with the + * `SignedBlocksWindow` param determines the index in the `MissedBlocksBitArray`. + */ + indexOffset: bigint; + /** Timestamp until which the validator is jailed due to liveness downtime. */ + jailedUntil: Date; + /** + * Whether or not a validator has been tombstoned (killed out of validator set). It is set + * once the validator commits an equivocation or for any other configured misbehiavor. + */ + tombstoned: boolean; + /** + * A counter kept to avoid unnecessary array reads. + * Note that `Sum(MissedBlocksBitArray)` always equals `MissedBlocksCounter`. + */ + missedBlocksCounter: bigint; +} +export interface ValidatorSigningInfoProtoMsg { + typeUrl: "/cosmos.slashing.v1beta1.ValidatorSigningInfo"; + value: Uint8Array; +} +/** + * ValidatorSigningInfo defines a validator's signing info for monitoring their + * liveness activity. + */ +export interface ValidatorSigningInfoSDKType { + address: string; + start_height: bigint; + index_offset: bigint; + jailed_until: Date; + tombstoned: boolean; + missed_blocks_counter: bigint; +} +/** Params represents the parameters used for by the slashing module. */ +export interface Params { + signedBlocksWindow: bigint; + minSignedPerWindow: Uint8Array; + downtimeJailDuration: Duration; + slashFractionDoubleSign: Uint8Array; + slashFractionDowntime: Uint8Array; +} +export interface ParamsProtoMsg { + typeUrl: "/cosmos.slashing.v1beta1.Params"; + value: Uint8Array; +} +/** Params represents the parameters used for by the slashing module. */ +export interface ParamsSDKType { + signed_blocks_window: bigint; + min_signed_per_window: Uint8Array; + downtime_jail_duration: DurationSDKType; + slash_fraction_double_sign: Uint8Array; + slash_fraction_downtime: Uint8Array; +} +function createBaseValidatorSigningInfo(): ValidatorSigningInfo { + return { + address: "", + startHeight: BigInt(0), + indexOffset: BigInt(0), + jailedUntil: new Date(), + tombstoned: false, + missedBlocksCounter: BigInt(0) + }; +} +export const ValidatorSigningInfo = { + typeUrl: "/cosmos.slashing.v1beta1.ValidatorSigningInfo", + encode(message: ValidatorSigningInfo, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.address !== undefined) { + writer.uint32(10).string(message.address); + } + if (message.startHeight !== undefined) { + writer.uint32(16).int64(message.startHeight); + } + if (message.indexOffset !== undefined) { + writer.uint32(24).int64(message.indexOffset); + } + if (message.jailedUntil !== undefined) { + Timestamp.encode(toTimestamp(message.jailedUntil), writer.uint32(34).fork()).ldelim(); + } + if (message.tombstoned !== undefined) { + writer.uint32(40).bool(message.tombstoned); + } + if (message.missedBlocksCounter !== undefined) { + writer.uint32(48).int64(message.missedBlocksCounter); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ValidatorSigningInfo { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseValidatorSigningInfo(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.string(); + break; + case 2: + message.startHeight = reader.int64(); + break; + case 3: + message.indexOffset = reader.int64(); + break; + case 4: + message.jailedUntil = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + break; + case 5: + message.tombstoned = reader.bool(); + break; + case 6: + message.missedBlocksCounter = reader.int64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ValidatorSigningInfo { + const obj = createBaseValidatorSigningInfo(); + if (isSet(object.address)) obj.address = String(object.address); + if (isSet(object.startHeight)) obj.startHeight = BigInt(object.startHeight.toString()); + if (isSet(object.indexOffset)) obj.indexOffset = BigInt(object.indexOffset.toString()); + if (isSet(object.jailedUntil)) obj.jailedUntil = new Date(object.jailedUntil); + if (isSet(object.tombstoned)) obj.tombstoned = Boolean(object.tombstoned); + if (isSet(object.missedBlocksCounter)) obj.missedBlocksCounter = BigInt(object.missedBlocksCounter.toString()); + return obj; + }, + toJSON(message: ValidatorSigningInfo): JsonSafe { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + message.startHeight !== undefined && (obj.startHeight = (message.startHeight || BigInt(0)).toString()); + message.indexOffset !== undefined && (obj.indexOffset = (message.indexOffset || BigInt(0)).toString()); + message.jailedUntil !== undefined && (obj.jailedUntil = message.jailedUntil.toISOString()); + message.tombstoned !== undefined && (obj.tombstoned = message.tombstoned); + message.missedBlocksCounter !== undefined && (obj.missedBlocksCounter = (message.missedBlocksCounter || BigInt(0)).toString()); + return obj; + }, + fromPartial(object: DeepPartial): ValidatorSigningInfo { + const message = createBaseValidatorSigningInfo(); + message.address = object.address ?? ""; + if (object.startHeight !== undefined && object.startHeight !== null) { + message.startHeight = BigInt(object.startHeight.toString()); + } + if (object.indexOffset !== undefined && object.indexOffset !== null) { + message.indexOffset = BigInt(object.indexOffset.toString()); + } + message.jailedUntil = object.jailedUntil ?? undefined; + message.tombstoned = object.tombstoned ?? false; + if (object.missedBlocksCounter !== undefined && object.missedBlocksCounter !== null) { + message.missedBlocksCounter = BigInt(object.missedBlocksCounter.toString()); + } + return message; + }, + fromSDK(object: ValidatorSigningInfoSDKType): ValidatorSigningInfo { + return { + address: object?.address, + startHeight: object?.start_height, + indexOffset: object?.index_offset, + jailedUntil: object.jailed_until ?? undefined, + tombstoned: object?.tombstoned, + missedBlocksCounter: object?.missed_blocks_counter + }; + }, + fromSDKJSON(object: any): ValidatorSigningInfoSDKType { + return { + address: isSet(object.address) ? String(object.address) : "", + start_height: isSet(object.start_height) ? BigInt(object.start_height.toString()) : BigInt(0), + index_offset: isSet(object.index_offset) ? BigInt(object.index_offset.toString()) : BigInt(0), + jailed_until: isSet(object.jailed_until) ? new Date(object.jailed_until) : undefined, + tombstoned: isSet(object.tombstoned) ? Boolean(object.tombstoned) : false, + missed_blocks_counter: isSet(object.missed_blocks_counter) ? BigInt(object.missed_blocks_counter.toString()) : BigInt(0) + }; + }, + toSDK(message: ValidatorSigningInfo): ValidatorSigningInfoSDKType { + const obj: any = {}; + obj.address = message.address; + obj.start_height = message.startHeight; + obj.index_offset = message.indexOffset; + message.jailedUntil !== undefined && (obj.jailed_until = message.jailedUntil ?? undefined); + obj.tombstoned = message.tombstoned; + obj.missed_blocks_counter = message.missedBlocksCounter; + return obj; + }, + fromAmino(object: ValidatorSigningInfoAmino): ValidatorSigningInfo { + const message = createBaseValidatorSigningInfo(); + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } + if (object.start_height !== undefined && object.start_height !== null) { + message.startHeight = BigInt(object.start_height); + } + if (object.index_offset !== undefined && object.index_offset !== null) { + message.indexOffset = BigInt(object.index_offset); + } + if (object.jailed_until !== undefined && object.jailed_until !== null) { + message.jailedUntil = fromTimestamp(Timestamp.fromAmino(object.jailed_until)); + } + if (object.tombstoned !== undefined && object.tombstoned !== null) { + message.tombstoned = object.tombstoned; + } + if (object.missed_blocks_counter !== undefined && object.missed_blocks_counter !== null) { + message.missedBlocksCounter = BigInt(object.missed_blocks_counter); + } + return message; + }, + toAmino(message: ValidatorSigningInfo): ValidatorSigningInfoAmino { + const obj: any = {}; + obj.address = message.address === "" ? undefined : message.address; + obj.start_height = message.startHeight !== BigInt(0) ? message.startHeight?.toString() : undefined; + obj.index_offset = message.indexOffset !== BigInt(0) ? message.indexOffset?.toString() : undefined; + obj.jailed_until = message.jailedUntil ? Timestamp.toAmino(toTimestamp(message.jailedUntil)) : undefined; + obj.tombstoned = message.tombstoned === false ? undefined : message.tombstoned; + obj.missed_blocks_counter = message.missedBlocksCounter !== BigInt(0) ? message.missedBlocksCounter?.toString() : undefined; + return obj; + }, + fromAminoMsg(object: ValidatorSigningInfoAminoMsg): ValidatorSigningInfo { + return ValidatorSigningInfo.fromAmino(object.value); + }, + toAminoMsg(message: ValidatorSigningInfo): ValidatorSigningInfoAminoMsg { + return { + type: "cosmos-sdk/ValidatorSigningInfo", + value: ValidatorSigningInfo.toAmino(message) + }; + }, + fromProtoMsg(message: ValidatorSigningInfoProtoMsg): ValidatorSigningInfo { + return ValidatorSigningInfo.decode(message.value); + }, + toProto(message: ValidatorSigningInfo): Uint8Array { + return ValidatorSigningInfo.encode(message).finish(); + }, + toProtoMsg(message: ValidatorSigningInfo): ValidatorSigningInfoProtoMsg { + return { + typeUrl: "/cosmos.slashing.v1beta1.ValidatorSigningInfo", + value: ValidatorSigningInfo.encode(message).finish() + }; + } +}; +function createBaseParams(): Params { + return { + signedBlocksWindow: BigInt(0), + minSignedPerWindow: new Uint8Array(), + downtimeJailDuration: Duration.fromPartial({}), + slashFractionDoubleSign: new Uint8Array(), + slashFractionDowntime: new Uint8Array() + }; +} +export const Params = { + typeUrl: "/cosmos.slashing.v1beta1.Params", + encode(message: Params, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.signedBlocksWindow !== undefined) { + writer.uint32(8).int64(message.signedBlocksWindow); + } + if (message.minSignedPerWindow.length !== 0) { + writer.uint32(18).bytes(message.minSignedPerWindow); + } + if (message.downtimeJailDuration !== undefined) { + Duration.encode(message.downtimeJailDuration, writer.uint32(26).fork()).ldelim(); + } + if (message.slashFractionDoubleSign.length !== 0) { + writer.uint32(34).bytes(message.slashFractionDoubleSign); + } + if (message.slashFractionDowntime.length !== 0) { + writer.uint32(42).bytes(message.slashFractionDowntime); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Params { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseParams(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.signedBlocksWindow = reader.int64(); + break; + case 2: + message.minSignedPerWindow = reader.bytes(); + break; + case 3: + message.downtimeJailDuration = Duration.decode(reader, reader.uint32()); + break; + case 4: + message.slashFractionDoubleSign = reader.bytes(); + break; + case 5: + message.slashFractionDowntime = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Params { + const obj = createBaseParams(); + if (isSet(object.signedBlocksWindow)) obj.signedBlocksWindow = BigInt(object.signedBlocksWindow.toString()); + if (isSet(object.minSignedPerWindow)) obj.minSignedPerWindow = bytesFromBase64(object.minSignedPerWindow); + if (isSet(object.downtimeJailDuration)) obj.downtimeJailDuration = Duration.fromJSON(object.downtimeJailDuration); + if (isSet(object.slashFractionDoubleSign)) obj.slashFractionDoubleSign = bytesFromBase64(object.slashFractionDoubleSign); + if (isSet(object.slashFractionDowntime)) obj.slashFractionDowntime = bytesFromBase64(object.slashFractionDowntime); + return obj; + }, + toJSON(message: Params): JsonSafe { + const obj: any = {}; + message.signedBlocksWindow !== undefined && (obj.signedBlocksWindow = (message.signedBlocksWindow || BigInt(0)).toString()); + message.minSignedPerWindow !== undefined && (obj.minSignedPerWindow = base64FromBytes(message.minSignedPerWindow !== undefined ? message.minSignedPerWindow : new Uint8Array())); + message.downtimeJailDuration !== undefined && (obj.downtimeJailDuration = message.downtimeJailDuration ? Duration.toJSON(message.downtimeJailDuration) : undefined); + message.slashFractionDoubleSign !== undefined && (obj.slashFractionDoubleSign = base64FromBytes(message.slashFractionDoubleSign !== undefined ? message.slashFractionDoubleSign : new Uint8Array())); + message.slashFractionDowntime !== undefined && (obj.slashFractionDowntime = base64FromBytes(message.slashFractionDowntime !== undefined ? message.slashFractionDowntime : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): Params { + const message = createBaseParams(); + if (object.signedBlocksWindow !== undefined && object.signedBlocksWindow !== null) { + message.signedBlocksWindow = BigInt(object.signedBlocksWindow.toString()); + } + message.minSignedPerWindow = object.minSignedPerWindow ?? new Uint8Array(); + if (object.downtimeJailDuration !== undefined && object.downtimeJailDuration !== null) { + message.downtimeJailDuration = Duration.fromPartial(object.downtimeJailDuration); + } + message.slashFractionDoubleSign = object.slashFractionDoubleSign ?? new Uint8Array(); + message.slashFractionDowntime = object.slashFractionDowntime ?? new Uint8Array(); + return message; + }, + fromSDK(object: ParamsSDKType): Params { + return { + signedBlocksWindow: object?.signed_blocks_window, + minSignedPerWindow: object?.min_signed_per_window, + downtimeJailDuration: object.downtime_jail_duration ? Duration.fromSDK(object.downtime_jail_duration) : undefined, + slashFractionDoubleSign: object?.slash_fraction_double_sign, + slashFractionDowntime: object?.slash_fraction_downtime + }; + }, + fromSDKJSON(object: any): ParamsSDKType { + return { + signed_blocks_window: isSet(object.signed_blocks_window) ? BigInt(object.signed_blocks_window.toString()) : BigInt(0), + min_signed_per_window: isSet(object.min_signed_per_window) ? bytesFromBase64(object.min_signed_per_window) : new Uint8Array(), + downtime_jail_duration: isSet(object.downtime_jail_duration) ? Duration.fromSDKJSON(object.downtime_jail_duration) : undefined, + slash_fraction_double_sign: isSet(object.slash_fraction_double_sign) ? bytesFromBase64(object.slash_fraction_double_sign) : new Uint8Array(), + slash_fraction_downtime: isSet(object.slash_fraction_downtime) ? bytesFromBase64(object.slash_fraction_downtime) : new Uint8Array() + }; + }, + toSDK(message: Params): ParamsSDKType { + const obj: any = {}; + obj.signed_blocks_window = message.signedBlocksWindow; + obj.min_signed_per_window = message.minSignedPerWindow; + message.downtimeJailDuration !== undefined && (obj.downtime_jail_duration = message.downtimeJailDuration ? Duration.toSDK(message.downtimeJailDuration) : undefined); + obj.slash_fraction_double_sign = message.slashFractionDoubleSign; + obj.slash_fraction_downtime = message.slashFractionDowntime; + return obj; + }, + fromAmino(object: ParamsAmino): Params { + const message = createBaseParams(); + if (object.signed_blocks_window !== undefined && object.signed_blocks_window !== null) { + message.signedBlocksWindow = BigInt(object.signed_blocks_window); + } + if (object.min_signed_per_window !== undefined && object.min_signed_per_window !== null) { + message.minSignedPerWindow = bytesFromBase64(object.min_signed_per_window); + } + if (object.downtime_jail_duration !== undefined && object.downtime_jail_duration !== null) { + message.downtimeJailDuration = Duration.fromAmino(object.downtime_jail_duration); + } + if (object.slash_fraction_double_sign !== undefined && object.slash_fraction_double_sign !== null) { + message.slashFractionDoubleSign = bytesFromBase64(object.slash_fraction_double_sign); + } + if (object.slash_fraction_downtime !== undefined && object.slash_fraction_downtime !== null) { + message.slashFractionDowntime = bytesFromBase64(object.slash_fraction_downtime); + } + return message; + }, + toAmino(message: Params): ParamsAmino { + const obj: any = {}; + obj.signed_blocks_window = message.signedBlocksWindow !== BigInt(0) ? message.signedBlocksWindow?.toString() : undefined; + obj.min_signed_per_window = message.minSignedPerWindow ? base64FromBytes(message.minSignedPerWindow) : undefined; + obj.downtime_jail_duration = message.downtimeJailDuration ? Duration.toAmino(message.downtimeJailDuration) : undefined; + obj.slash_fraction_double_sign = message.slashFractionDoubleSign ? base64FromBytes(message.slashFractionDoubleSign) : undefined; + obj.slash_fraction_downtime = message.slashFractionDowntime ? base64FromBytes(message.slashFractionDowntime) : undefined; + return obj; + }, + fromAminoMsg(object: ParamsAminoMsg): Params { + return Params.fromAmino(object.value); + }, + toAminoMsg(message: Params): ParamsAminoMsg { + return { + type: "cosmos-sdk/Params", + value: Params.toAmino(message) + }; + }, + fromProtoMsg(message: ParamsProtoMsg): Params { + return Params.decode(message.value); + }, + toProto(message: Params): Uint8Array { + return Params.encode(message).finish(); + }, + toProtoMsg(message: Params): ParamsProtoMsg { + return { + typeUrl: "/cosmos.slashing.v1beta1.Params", + value: Params.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/slashing/v1beta1/tx.amino.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/slashing/v1beta1/tx.amino.ts new file mode 100644 index 0000000000..a16eb107ff --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/slashing/v1beta1/tx.amino.ts @@ -0,0 +1,27 @@ +import { ReadOnlyAminoMsg as AminoMsg } from "@interchainjs/ReadOnlyAminoMsg"; +import { MsgUnjail, MsgUnjailSDKType } from "./tx.js"; +export interface MsgUnjailAminoType extends AminoMsg { + type: "cosmos-sdk/MsgUnjail"; + value: { + validator_addr: string; + }; +} +export const AminoConverter = { + "/cosmos.slashing.v1beta1.MsgUnjail": { + aminoType: "cosmos-sdk/MsgUnjail", + toAmino: ({ + validatorAddr + }: MsgUnjail): MsgUnjailAminoType["value"] => { + return { + validator_addr: validatorAddr + }; + }, + fromAmino: ({ + validator_addr + }: MsgUnjailAminoType["value"]): MsgUnjail => { + return { + validatorAddr: validator_addr + }; + } + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/slashing/v1beta1/tx.registry.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/slashing/v1beta1/tx.registry.ts new file mode 100644 index 0000000000..c7c212537b --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/slashing/v1beta1/tx.registry.ts @@ -0,0 +1,50 @@ +import { GeneratedType, Registry } from "@cosmjs/proto-signing"; +import { MsgUnjail, MsgUnjailSDKType } from "./tx.js"; +export const registry: ReadonlyArray<[string, GeneratedType]> = [["/cosmos.slashing.v1beta1.MsgUnjail", MsgUnjail]]; +export const load = (protoRegistry: Registry) => { + registry.forEach(([typeUrl, mod]) => { + protoRegistry.register(typeUrl, mod); + }); +}; +export const MessageComposer = { + encoded: { + unjail(value: MsgUnjail) { + return { + typeUrl: "/cosmos.slashing.v1beta1.MsgUnjail", + value: MsgUnjail.encode(value).finish() + }; + } + }, + withTypeUrl: { + unjail(value: MsgUnjail) { + return { + typeUrl: "/cosmos.slashing.v1beta1.MsgUnjail", + value + }; + } + }, + toJSON: { + unjail(value: MsgUnjail) { + return { + typeUrl: "/cosmos.slashing.v1beta1.MsgUnjail", + value: MsgUnjail.toJSON(value) + }; + } + }, + fromJSON: { + unjail(value: any) { + return { + typeUrl: "/cosmos.slashing.v1beta1.MsgUnjail", + value: MsgUnjail.fromJSON(value) + }; + } + }, + fromPartial: { + unjail(value: MsgUnjail) { + return { + typeUrl: "/cosmos.slashing.v1beta1.MsgUnjail", + value: MsgUnjail.fromPartial(value) + }; + } + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/slashing/v1beta1/tx.rpc.func.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/slashing/v1beta1/tx.rpc.func.ts new file mode 100644 index 0000000000..340afd3bd7 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/slashing/v1beta1/tx.rpc.func.ts @@ -0,0 +1,13 @@ +import { buildTx, SigningClientResolver } from "../../../helper-func-types"; +import { buildUseMutation } from "../../../react-query"; +import { toEncoders, toConverters } from "@interchainjs/cosmos/utils"; +import { MsgUnjail } from "./tx"; +export const createUnjail = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgUnjail.typeUrl, + encoders: toEncoders(MsgUnjail), + converters: toConverters(MsgUnjail) +}); +export const useUnjail = buildUseMutation({ + builderMutationFn: createUnjail +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/slashing/v1beta1/tx.rpc.msg.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/slashing/v1beta1/tx.rpc.msg.ts new file mode 100644 index 0000000000..81e397e161 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/slashing/v1beta1/tx.rpc.msg.ts @@ -0,0 +1,27 @@ +import { Rpc } from "../../../helpers.js"; +import { BinaryReader } from "../../../binary.js"; +import { MsgUnjail, MsgUnjailSDKType, MsgUnjailResponse, MsgUnjailResponseSDKType } from "./tx.js"; +/** Msg defines the slashing Msg service. */ +export interface Msg { + /** + * Unjail defines a method for unjailing a jailed validator, thus returning + * them into the bonded validator set, so they can begin receiving provisions + * and rewards again. + */ + unjail(request: MsgUnjail): Promise; +} +export class MsgClientImpl implements Msg { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + this.unjail = this.unjail.bind(this); + } + unjail(request: MsgUnjail): Promise { + const data = MsgUnjail.encode(request).finish(); + const promise = this.rpc.request("cosmos.slashing.v1beta1.Msg", "Unjail", data); + return promise.then(data => MsgUnjailResponse.decode(new BinaryReader(data))); + } +} +export const createClientImpl = (rpc: Rpc) => { + return new MsgClientImpl(rpc); +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/slashing/v1beta1/tx.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/slashing/v1beta1/tx.ts new file mode 100644 index 0000000000..e46a2ba6f1 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/slashing/v1beta1/tx.ts @@ -0,0 +1,192 @@ +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "cosmos.slashing.v1beta1"; +/** MsgUnjail defines the Msg/Unjail request type */ +export interface MsgUnjail { + validatorAddr: string; +} +export interface MsgUnjailProtoMsg { + typeUrl: "/cosmos.slashing.v1beta1.MsgUnjail"; + value: Uint8Array; +} +/** MsgUnjail defines the Msg/Unjail request type */ +export interface MsgUnjailSDKType { + validator_addr: string; +} +/** MsgUnjailResponse defines the Msg/Unjail response type */ +export interface MsgUnjailResponse {} +export interface MsgUnjailResponseProtoMsg { + typeUrl: "/cosmos.slashing.v1beta1.MsgUnjailResponse"; + value: Uint8Array; +} +/** MsgUnjailResponse defines the Msg/Unjail response type */ +export interface MsgUnjailResponseSDKType {} +function createBaseMsgUnjail(): MsgUnjail { + return { + validatorAddr: "" + }; +} +export const MsgUnjail = { + typeUrl: "/cosmos.slashing.v1beta1.MsgUnjail", + encode(message: MsgUnjail, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.validatorAddr !== undefined) { + writer.uint32(10).string(message.validatorAddr); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgUnjail { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgUnjail(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.validatorAddr = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgUnjail { + const obj = createBaseMsgUnjail(); + if (isSet(object.validatorAddr)) obj.validatorAddr = String(object.validatorAddr); + return obj; + }, + toJSON(message: MsgUnjail): JsonSafe { + const obj: any = {}; + message.validatorAddr !== undefined && (obj.validatorAddr = message.validatorAddr); + return obj; + }, + fromPartial(object: DeepPartial): MsgUnjail { + const message = createBaseMsgUnjail(); + message.validatorAddr = object.validatorAddr ?? ""; + return message; + }, + fromSDK(object: MsgUnjailSDKType): MsgUnjail { + return { + validatorAddr: object?.validator_addr + }; + }, + fromSDKJSON(object: any): MsgUnjailSDKType { + return { + validator_addr: isSet(object.validator_addr) ? String(object.validator_addr) : "" + }; + }, + toSDK(message: MsgUnjail): MsgUnjailSDKType { + const obj: any = {}; + obj.validator_addr = message.validatorAddr; + return obj; + }, + fromAmino(object: MsgUnjailAmino): MsgUnjail { + const message = createBaseMsgUnjail(); + if (object.validator_addr !== undefined && object.validator_addr !== null) { + message.validatorAddr = object.validator_addr; + } + return message; + }, + toAmino(message: MsgUnjail): MsgUnjailAmino { + const obj: any = {}; + obj.validator_addr = message.validatorAddr ?? ""; + return obj; + }, + fromAminoMsg(object: MsgUnjailAminoMsg): MsgUnjail { + return MsgUnjail.fromAmino(object.value); + }, + toAminoMsg(message: MsgUnjail): MsgUnjailAminoMsg { + return { + type: "cosmos-sdk/MsgUnjail", + value: MsgUnjail.toAmino(message) + }; + }, + fromProtoMsg(message: MsgUnjailProtoMsg): MsgUnjail { + return MsgUnjail.decode(message.value); + }, + toProto(message: MsgUnjail): Uint8Array { + return MsgUnjail.encode(message).finish(); + }, + toProtoMsg(message: MsgUnjail): MsgUnjailProtoMsg { + return { + typeUrl: "/cosmos.slashing.v1beta1.MsgUnjail", + value: MsgUnjail.encode(message).finish() + }; + } +}; +function createBaseMsgUnjailResponse(): MsgUnjailResponse { + return {}; +} +export const MsgUnjailResponse = { + typeUrl: "/cosmos.slashing.v1beta1.MsgUnjailResponse", + encode(_: MsgUnjailResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgUnjailResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgUnjailResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgUnjailResponse { + const obj = createBaseMsgUnjailResponse(); + return obj; + }, + toJSON(_: MsgUnjailResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): MsgUnjailResponse { + const message = createBaseMsgUnjailResponse(); + return message; + }, + fromSDK(_: MsgUnjailResponseSDKType): MsgUnjailResponse { + return {}; + }, + fromSDKJSON(_: any): MsgUnjailResponseSDKType { + return {}; + }, + toSDK(_: MsgUnjailResponse): MsgUnjailResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgUnjailResponseAmino): MsgUnjailResponse { + const message = createBaseMsgUnjailResponse(); + return message; + }, + toAmino(_: MsgUnjailResponse): MsgUnjailResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgUnjailResponseAminoMsg): MsgUnjailResponse { + return MsgUnjailResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgUnjailResponse): MsgUnjailResponseAminoMsg { + return { + type: "cosmos-sdk/MsgUnjailResponse", + value: MsgUnjailResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgUnjailResponseProtoMsg): MsgUnjailResponse { + return MsgUnjailResponse.decode(message.value); + }, + toProto(message: MsgUnjailResponse): Uint8Array { + return MsgUnjailResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgUnjailResponse): MsgUnjailResponseProtoMsg { + return { + typeUrl: "/cosmos.slashing.v1beta1.MsgUnjailResponse", + value: MsgUnjailResponse.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/staking/v1beta1/authz.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/staking/v1beta1/authz.ts new file mode 100644 index 0000000000..eb1307bbe3 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/staking/v1beta1/authz.ts @@ -0,0 +1,360 @@ +import { Coin, CoinSDKType } from "../../base/v1beta1/coin.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "cosmos.staking.v1beta1"; +/** + * AuthorizationType defines the type of staking module authorization type + * + * Since: cosmos-sdk 0.43 + */ +export enum AuthorizationType { + /** AUTHORIZATION_TYPE_UNSPECIFIED - AUTHORIZATION_TYPE_UNSPECIFIED specifies an unknown authorization type */ + AUTHORIZATION_TYPE_UNSPECIFIED = 0, + /** AUTHORIZATION_TYPE_DELEGATE - AUTHORIZATION_TYPE_DELEGATE defines an authorization type for Msg/Delegate */ + AUTHORIZATION_TYPE_DELEGATE = 1, + /** AUTHORIZATION_TYPE_UNDELEGATE - AUTHORIZATION_TYPE_UNDELEGATE defines an authorization type for Msg/Undelegate */ + AUTHORIZATION_TYPE_UNDELEGATE = 2, + /** AUTHORIZATION_TYPE_REDELEGATE - AUTHORIZATION_TYPE_REDELEGATE defines an authorization type for Msg/BeginRedelegate */ + AUTHORIZATION_TYPE_REDELEGATE = 3, + UNRECOGNIZED = -1, +} +export const AuthorizationTypeSDKType = AuthorizationType; +export function authorizationTypeFromJSON(object: any): AuthorizationType { + switch (object) { + case 0: + case "AUTHORIZATION_TYPE_UNSPECIFIED": + return AuthorizationType.AUTHORIZATION_TYPE_UNSPECIFIED; + case 1: + case "AUTHORIZATION_TYPE_DELEGATE": + return AuthorizationType.AUTHORIZATION_TYPE_DELEGATE; + case 2: + case "AUTHORIZATION_TYPE_UNDELEGATE": + return AuthorizationType.AUTHORIZATION_TYPE_UNDELEGATE; + case 3: + case "AUTHORIZATION_TYPE_REDELEGATE": + return AuthorizationType.AUTHORIZATION_TYPE_REDELEGATE; + case -1: + case "UNRECOGNIZED": + default: + return AuthorizationType.UNRECOGNIZED; + } +} +export function authorizationTypeToJSON(object: AuthorizationType): string { + switch (object) { + case AuthorizationType.AUTHORIZATION_TYPE_UNSPECIFIED: + return "AUTHORIZATION_TYPE_UNSPECIFIED"; + case AuthorizationType.AUTHORIZATION_TYPE_DELEGATE: + return "AUTHORIZATION_TYPE_DELEGATE"; + case AuthorizationType.AUTHORIZATION_TYPE_UNDELEGATE: + return "AUTHORIZATION_TYPE_UNDELEGATE"; + case AuthorizationType.AUTHORIZATION_TYPE_REDELEGATE: + return "AUTHORIZATION_TYPE_REDELEGATE"; + case AuthorizationType.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** + * StakeAuthorization defines authorization for delegate/undelegate/redelegate. + * + * Since: cosmos-sdk 0.43 + */ +export interface StakeAuthorization { + /** + * max_tokens specifies the maximum amount of tokens can be delegate to a validator. If it is + * empty, there is no spend limit and any amount of coins can be delegated. + */ + maxTokens?: Coin; + /** + * allow_list specifies list of validator addresses to whom grantee can delegate tokens on behalf of granter's + * account. + */ + allowList?: StakeAuthorization_Validators; + /** deny_list specifies list of validator addresses to whom grantee can not delegate tokens. */ + denyList?: StakeAuthorization_Validators; + /** authorization_type defines one of AuthorizationType. */ + authorizationType: AuthorizationType; +} +export interface StakeAuthorizationProtoMsg { + typeUrl: "/cosmos.staking.v1beta1.StakeAuthorization"; + value: Uint8Array; +} +/** + * StakeAuthorization defines authorization for delegate/undelegate/redelegate. + * + * Since: cosmos-sdk 0.43 + */ +export interface StakeAuthorizationSDKType { + max_tokens?: CoinSDKType; + allow_list?: StakeAuthorization_ValidatorsSDKType; + deny_list?: StakeAuthorization_ValidatorsSDKType; + authorization_type: AuthorizationType; +} +/** Validators defines list of validator addresses. */ +export interface StakeAuthorization_Validators { + address: string[]; +} +export interface StakeAuthorization_ValidatorsProtoMsg { + typeUrl: "/cosmos.staking.v1beta1.Validators"; + value: Uint8Array; +} +/** Validators defines list of validator addresses. */ +export interface StakeAuthorization_ValidatorsSDKType { + address: string[]; +} +function createBaseStakeAuthorization(): StakeAuthorization { + return { + maxTokens: undefined, + allowList: undefined, + denyList: undefined, + authorizationType: 0 + }; +} +export const StakeAuthorization = { + typeUrl: "/cosmos.staking.v1beta1.StakeAuthorization", + encode(message: StakeAuthorization, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.maxTokens !== undefined) { + Coin.encode(message.maxTokens, writer.uint32(10).fork()).ldelim(); + } + if (message.allowList !== undefined) { + StakeAuthorization_Validators.encode(message.allowList, writer.uint32(18).fork()).ldelim(); + } + if (message.denyList !== undefined) { + StakeAuthorization_Validators.encode(message.denyList, writer.uint32(26).fork()).ldelim(); + } + if (message.authorizationType !== 0) { + writer.uint32(32).int32(message.authorizationType); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): StakeAuthorization { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseStakeAuthorization(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.maxTokens = Coin.decode(reader, reader.uint32()); + break; + case 2: + message.allowList = StakeAuthorization_Validators.decode(reader, reader.uint32()); + break; + case 3: + message.denyList = StakeAuthorization_Validators.decode(reader, reader.uint32()); + break; + case 4: + message.authorizationType = (reader.int32() as any); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): StakeAuthorization { + const obj = createBaseStakeAuthorization(); + if (isSet(object.maxTokens)) obj.maxTokens = Coin.fromJSON(object.maxTokens); + if (isSet(object.allowList)) obj.allowList = StakeAuthorization_Validators.fromJSON(object.allowList); + if (isSet(object.denyList)) obj.denyList = StakeAuthorization_Validators.fromJSON(object.denyList); + if (isSet(object.authorizationType)) obj.authorizationType = authorizationTypeFromJSON(object.authorizationType); + return obj; + }, + toJSON(message: StakeAuthorization): JsonSafe { + const obj: any = {}; + message.maxTokens !== undefined && (obj.maxTokens = message.maxTokens ? Coin.toJSON(message.maxTokens) : undefined); + message.allowList !== undefined && (obj.allowList = message.allowList ? StakeAuthorization_Validators.toJSON(message.allowList) : undefined); + message.denyList !== undefined && (obj.denyList = message.denyList ? StakeAuthorization_Validators.toJSON(message.denyList) : undefined); + message.authorizationType !== undefined && (obj.authorizationType = authorizationTypeToJSON(message.authorizationType)); + return obj; + }, + fromPartial(object: DeepPartial): StakeAuthorization { + const message = createBaseStakeAuthorization(); + if (object.maxTokens !== undefined && object.maxTokens !== null) { + message.maxTokens = Coin.fromPartial(object.maxTokens); + } + if (object.allowList !== undefined && object.allowList !== null) { + message.allowList = StakeAuthorization_Validators.fromPartial(object.allowList); + } + if (object.denyList !== undefined && object.denyList !== null) { + message.denyList = StakeAuthorization_Validators.fromPartial(object.denyList); + } + message.authorizationType = object.authorizationType ?? 0; + return message; + }, + fromSDK(object: StakeAuthorizationSDKType): StakeAuthorization { + return { + maxTokens: object.max_tokens ? Coin.fromSDK(object.max_tokens) : undefined, + allowList: object.allow_list ? StakeAuthorization_Validators.fromSDK(object.allow_list) : undefined, + denyList: object.deny_list ? StakeAuthorization_Validators.fromSDK(object.deny_list) : undefined, + authorizationType: isSet(object.authorization_type) ? authorizationTypeFromJSON(object.authorization_type) : -1 + }; + }, + fromSDKJSON(object: any): StakeAuthorizationSDKType { + return { + max_tokens: isSet(object.max_tokens) ? Coin.fromSDKJSON(object.max_tokens) : undefined, + allow_list: isSet(object.allow_list) ? StakeAuthorization_Validators.fromSDKJSON(object.allow_list) : undefined, + deny_list: isSet(object.deny_list) ? StakeAuthorization_Validators.fromSDKJSON(object.deny_list) : undefined, + authorization_type: isSet(object.authorization_type) ? authorizationTypeFromJSON(object.authorization_type) : -1 + }; + }, + toSDK(message: StakeAuthorization): StakeAuthorizationSDKType { + const obj: any = {}; + message.maxTokens !== undefined && (obj.max_tokens = message.maxTokens ? Coin.toSDK(message.maxTokens) : undefined); + message.allowList !== undefined && (obj.allow_list = message.allowList ? StakeAuthorization_Validators.toSDK(message.allowList) : undefined); + message.denyList !== undefined && (obj.deny_list = message.denyList ? StakeAuthorization_Validators.toSDK(message.denyList) : undefined); + message.authorizationType !== undefined && (obj.authorization_type = authorizationTypeToJSON(message.authorizationType)); + return obj; + }, + fromAmino(object: StakeAuthorizationAmino): StakeAuthorization { + const message = createBaseStakeAuthorization(); + if (object.max_tokens !== undefined && object.max_tokens !== null) { + message.maxTokens = Coin.fromAmino(object.max_tokens); + } + if (object.allow_list !== undefined && object.allow_list !== null) { + message.allowList = StakeAuthorization_Validators.fromAmino(object.allow_list); + } + if (object.deny_list !== undefined && object.deny_list !== null) { + message.denyList = StakeAuthorization_Validators.fromAmino(object.deny_list); + } + if (object.authorization_type !== undefined && object.authorization_type !== null) { + message.authorizationType = object.authorization_type; + } + return message; + }, + toAmino(message: StakeAuthorization): StakeAuthorizationAmino { + const obj: any = {}; + obj.max_tokens = message.maxTokens ? Coin.toAmino(message.maxTokens) : undefined; + obj.allow_list = message.allowList ? StakeAuthorization_Validators.toAmino(message.allowList) : undefined; + obj.deny_list = message.denyList ? StakeAuthorization_Validators.toAmino(message.denyList) : undefined; + obj.authorization_type = message.authorizationType === 0 ? undefined : message.authorizationType; + return obj; + }, + fromAminoMsg(object: StakeAuthorizationAminoMsg): StakeAuthorization { + return StakeAuthorization.fromAmino(object.value); + }, + toAminoMsg(message: StakeAuthorization): StakeAuthorizationAminoMsg { + return { + type: "cosmos-sdk/StakeAuthorization", + value: StakeAuthorization.toAmino(message) + }; + }, + fromProtoMsg(message: StakeAuthorizationProtoMsg): StakeAuthorization { + return StakeAuthorization.decode(message.value); + }, + toProto(message: StakeAuthorization): Uint8Array { + return StakeAuthorization.encode(message).finish(); + }, + toProtoMsg(message: StakeAuthorization): StakeAuthorizationProtoMsg { + return { + typeUrl: "/cosmos.staking.v1beta1.StakeAuthorization", + value: StakeAuthorization.encode(message).finish() + }; + } +}; +function createBaseStakeAuthorization_Validators(): StakeAuthorization_Validators { + return { + address: [] + }; +} +export const StakeAuthorization_Validators = { + typeUrl: "/cosmos.staking.v1beta1.Validators", + encode(message: StakeAuthorization_Validators, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.address) { + writer.uint32(10).string(v!); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): StakeAuthorization_Validators { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseStakeAuthorization_Validators(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): StakeAuthorization_Validators { + const obj = createBaseStakeAuthorization_Validators(); + if (Array.isArray(object?.address)) obj.address = object.address.map((e: any) => String(e)); + return obj; + }, + toJSON(message: StakeAuthorization_Validators): JsonSafe { + const obj: any = {}; + if (message.address) { + obj.address = message.address.map(e => e); + } else { + obj.address = []; + } + return obj; + }, + fromPartial(object: DeepPartial): StakeAuthorization_Validators { + const message = createBaseStakeAuthorization_Validators(); + message.address = object.address?.map(e => e) || []; + return message; + }, + fromSDK(object: StakeAuthorization_ValidatorsSDKType): StakeAuthorization_Validators { + return { + address: Array.isArray(object?.address) ? object.address.map((e: any) => e) : [] + }; + }, + fromSDKJSON(object: any): StakeAuthorization_ValidatorsSDKType { + return { + address: Array.isArray(object?.address) ? object.address.map((e: any) => String(e)) : [] + }; + }, + toSDK(message: StakeAuthorization_Validators): StakeAuthorization_ValidatorsSDKType { + const obj: any = {}; + if (message.address) { + obj.address = message.address.map(e => e); + } else { + obj.address = []; + } + return obj; + }, + fromAmino(object: StakeAuthorization_ValidatorsAmino): StakeAuthorization_Validators { + const message = createBaseStakeAuthorization_Validators(); + message.address = object.address?.map(e => e) || []; + return message; + }, + toAmino(message: StakeAuthorization_Validators): StakeAuthorization_ValidatorsAmino { + const obj: any = {}; + if (message.address) { + obj.address = message.address.map(e => e); + } else { + obj.address = message.address; + } + return obj; + }, + fromAminoMsg(object: StakeAuthorization_ValidatorsAminoMsg): StakeAuthorization_Validators { + return StakeAuthorization_Validators.fromAmino(object.value); + }, + toAminoMsg(message: StakeAuthorization_Validators): StakeAuthorization_ValidatorsAminoMsg { + return { + type: "cosmos-sdk/Validators", + value: StakeAuthorization_Validators.toAmino(message) + }; + }, + fromProtoMsg(message: StakeAuthorization_ValidatorsProtoMsg): StakeAuthorization_Validators { + return StakeAuthorization_Validators.decode(message.value); + }, + toProto(message: StakeAuthorization_Validators): Uint8Array { + return StakeAuthorization_Validators.encode(message).finish(); + }, + toProtoMsg(message: StakeAuthorization_Validators): StakeAuthorization_ValidatorsProtoMsg { + return { + typeUrl: "/cosmos.staking.v1beta1.Validators", + value: StakeAuthorization_Validators.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/staking/v1beta1/genesis.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/staking/v1beta1/genesis.ts new file mode 100644 index 0000000000..17b0b3094d --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/staking/v1beta1/genesis.ts @@ -0,0 +1,438 @@ +import { Params, ParamsSDKType, Validator, ValidatorSDKType, Delegation, DelegationSDKType, UnbondingDelegation, UnbondingDelegationSDKType, Redelegation, RedelegationSDKType } from "./staking.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, bytesFromBase64, base64FromBytes, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "cosmos.staking.v1beta1"; +/** GenesisState defines the staking module's genesis state. */ +export interface GenesisState { + /** params defines all the paramaters of related to deposit. */ + params: Params; + /** + * last_total_power tracks the total amounts of bonded tokens recorded during + * the previous end block. + */ + lastTotalPower: Uint8Array; + /** + * last_validator_powers is a special index that provides a historical list + * of the last-block's bonded validators. + */ + lastValidatorPowers: LastValidatorPower[]; + /** delegations defines the validator set at genesis. */ + validators: Validator[]; + /** delegations defines the delegations active at genesis. */ + delegations: Delegation[]; + /** unbonding_delegations defines the unbonding delegations active at genesis. */ + unbondingDelegations: UnbondingDelegation[]; + /** redelegations defines the redelegations active at genesis. */ + redelegations: Redelegation[]; + exported: boolean; +} +export interface GenesisStateProtoMsg { + typeUrl: "/cosmos.staking.v1beta1.GenesisState"; + value: Uint8Array; +} +/** GenesisState defines the staking module's genesis state. */ +export interface GenesisStateSDKType { + params: ParamsSDKType; + last_total_power: Uint8Array; + last_validator_powers: LastValidatorPowerSDKType[]; + validators: ValidatorSDKType[]; + delegations: DelegationSDKType[]; + unbonding_delegations: UnbondingDelegationSDKType[]; + redelegations: RedelegationSDKType[]; + exported: boolean; +} +/** LastValidatorPower required for validator set update logic. */ +export interface LastValidatorPower { + /** address is the address of the validator. */ + address: string; + /** power defines the power of the validator. */ + power: bigint; +} +export interface LastValidatorPowerProtoMsg { + typeUrl: "/cosmos.staking.v1beta1.LastValidatorPower"; + value: Uint8Array; +} +/** LastValidatorPower required for validator set update logic. */ +export interface LastValidatorPowerSDKType { + address: string; + power: bigint; +} +function createBaseGenesisState(): GenesisState { + return { + params: Params.fromPartial({}), + lastTotalPower: new Uint8Array(), + lastValidatorPowers: [], + validators: [], + delegations: [], + unbondingDelegations: [], + redelegations: [], + exported: false + }; +} +export const GenesisState = { + typeUrl: "/cosmos.staking.v1beta1.GenesisState", + encode(message: GenesisState, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(10).fork()).ldelim(); + } + if (message.lastTotalPower.length !== 0) { + writer.uint32(18).bytes(message.lastTotalPower); + } + for (const v of message.lastValidatorPowers) { + LastValidatorPower.encode(v!, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.validators) { + Validator.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.delegations) { + Delegation.encode(v!, writer.uint32(42).fork()).ldelim(); + } + for (const v of message.unbondingDelegations) { + UnbondingDelegation.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.redelegations) { + Redelegation.encode(v!, writer.uint32(58).fork()).ldelim(); + } + if (message.exported !== undefined) { + writer.uint32(64).bool(message.exported); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GenesisState { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGenesisState(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.params = Params.decode(reader, reader.uint32()); + break; + case 2: + message.lastTotalPower = reader.bytes(); + break; + case 3: + message.lastValidatorPowers.push(LastValidatorPower.decode(reader, reader.uint32())); + break; + case 4: + message.validators.push(Validator.decode(reader, reader.uint32())); + break; + case 5: + message.delegations.push(Delegation.decode(reader, reader.uint32())); + break; + case 6: + message.unbondingDelegations.push(UnbondingDelegation.decode(reader, reader.uint32())); + break; + case 7: + message.redelegations.push(Redelegation.decode(reader, reader.uint32())); + break; + case 8: + message.exported = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GenesisState { + const obj = createBaseGenesisState(); + if (isSet(object.params)) obj.params = Params.fromJSON(object.params); + if (isSet(object.lastTotalPower)) obj.lastTotalPower = bytesFromBase64(object.lastTotalPower); + if (Array.isArray(object?.lastValidatorPowers)) obj.lastValidatorPowers = object.lastValidatorPowers.map((e: any) => LastValidatorPower.fromJSON(e)); + if (Array.isArray(object?.validators)) obj.validators = object.validators.map((e: any) => Validator.fromJSON(e)); + if (Array.isArray(object?.delegations)) obj.delegations = object.delegations.map((e: any) => Delegation.fromJSON(e)); + if (Array.isArray(object?.unbondingDelegations)) obj.unbondingDelegations = object.unbondingDelegations.map((e: any) => UnbondingDelegation.fromJSON(e)); + if (Array.isArray(object?.redelegations)) obj.redelegations = object.redelegations.map((e: any) => Redelegation.fromJSON(e)); + if (isSet(object.exported)) obj.exported = Boolean(object.exported); + return obj; + }, + toJSON(message: GenesisState): JsonSafe { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); + message.lastTotalPower !== undefined && (obj.lastTotalPower = base64FromBytes(message.lastTotalPower !== undefined ? message.lastTotalPower : new Uint8Array())); + if (message.lastValidatorPowers) { + obj.lastValidatorPowers = message.lastValidatorPowers.map(e => e ? LastValidatorPower.toJSON(e) : undefined); + } else { + obj.lastValidatorPowers = []; + } + if (message.validators) { + obj.validators = message.validators.map(e => e ? Validator.toJSON(e) : undefined); + } else { + obj.validators = []; + } + if (message.delegations) { + obj.delegations = message.delegations.map(e => e ? Delegation.toJSON(e) : undefined); + } else { + obj.delegations = []; + } + if (message.unbondingDelegations) { + obj.unbondingDelegations = message.unbondingDelegations.map(e => e ? UnbondingDelegation.toJSON(e) : undefined); + } else { + obj.unbondingDelegations = []; + } + if (message.redelegations) { + obj.redelegations = message.redelegations.map(e => e ? Redelegation.toJSON(e) : undefined); + } else { + obj.redelegations = []; + } + message.exported !== undefined && (obj.exported = message.exported); + return obj; + }, + fromPartial(object: DeepPartial): GenesisState { + const message = createBaseGenesisState(); + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } + message.lastTotalPower = object.lastTotalPower ?? new Uint8Array(); + message.lastValidatorPowers = object.lastValidatorPowers?.map(e => LastValidatorPower.fromPartial(e)) || []; + message.validators = object.validators?.map(e => Validator.fromPartial(e)) || []; + message.delegations = object.delegations?.map(e => Delegation.fromPartial(e)) || []; + message.unbondingDelegations = object.unbondingDelegations?.map(e => UnbondingDelegation.fromPartial(e)) || []; + message.redelegations = object.redelegations?.map(e => Redelegation.fromPartial(e)) || []; + message.exported = object.exported ?? false; + return message; + }, + fromSDK(object: GenesisStateSDKType): GenesisState { + return { + params: object.params ? Params.fromSDK(object.params) : undefined, + lastTotalPower: object?.last_total_power, + lastValidatorPowers: Array.isArray(object?.last_validator_powers) ? object.last_validator_powers.map((e: any) => LastValidatorPower.fromSDK(e)) : [], + validators: Array.isArray(object?.validators) ? object.validators.map((e: any) => Validator.fromSDK(e)) : [], + delegations: Array.isArray(object?.delegations) ? object.delegations.map((e: any) => Delegation.fromSDK(e)) : [], + unbondingDelegations: Array.isArray(object?.unbonding_delegations) ? object.unbonding_delegations.map((e: any) => UnbondingDelegation.fromSDK(e)) : [], + redelegations: Array.isArray(object?.redelegations) ? object.redelegations.map((e: any) => Redelegation.fromSDK(e)) : [], + exported: object?.exported + }; + }, + fromSDKJSON(object: any): GenesisStateSDKType { + return { + params: isSet(object.params) ? Params.fromSDKJSON(object.params) : undefined, + last_total_power: isSet(object.last_total_power) ? bytesFromBase64(object.last_total_power) : new Uint8Array(), + last_validator_powers: Array.isArray(object?.last_validator_powers) ? object.last_validator_powers.map((e: any) => LastValidatorPower.fromSDKJSON(e)) : [], + validators: Array.isArray(object?.validators) ? object.validators.map((e: any) => Validator.fromSDKJSON(e)) : [], + delegations: Array.isArray(object?.delegations) ? object.delegations.map((e: any) => Delegation.fromSDKJSON(e)) : [], + unbonding_delegations: Array.isArray(object?.unbonding_delegations) ? object.unbonding_delegations.map((e: any) => UnbondingDelegation.fromSDKJSON(e)) : [], + redelegations: Array.isArray(object?.redelegations) ? object.redelegations.map((e: any) => Redelegation.fromSDKJSON(e)) : [], + exported: isSet(object.exported) ? Boolean(object.exported) : false + }; + }, + toSDK(message: GenesisState): GenesisStateSDKType { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toSDK(message.params) : undefined); + obj.last_total_power = message.lastTotalPower; + if (message.lastValidatorPowers) { + obj.last_validator_powers = message.lastValidatorPowers.map(e => e ? LastValidatorPower.toSDK(e) : undefined); + } else { + obj.last_validator_powers = []; + } + if (message.validators) { + obj.validators = message.validators.map(e => e ? Validator.toSDK(e) : undefined); + } else { + obj.validators = []; + } + if (message.delegations) { + obj.delegations = message.delegations.map(e => e ? Delegation.toSDK(e) : undefined); + } else { + obj.delegations = []; + } + if (message.unbondingDelegations) { + obj.unbonding_delegations = message.unbondingDelegations.map(e => e ? UnbondingDelegation.toSDK(e) : undefined); + } else { + obj.unbonding_delegations = []; + } + if (message.redelegations) { + obj.redelegations = message.redelegations.map(e => e ? Redelegation.toSDK(e) : undefined); + } else { + obj.redelegations = []; + } + obj.exported = message.exported; + return obj; + }, + fromAmino(object: GenesisStateAmino): GenesisState { + const message = createBaseGenesisState(); + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromAmino(object.params); + } + if (object.last_total_power !== undefined && object.last_total_power !== null) { + message.lastTotalPower = bytesFromBase64(object.last_total_power); + } + message.lastValidatorPowers = object.last_validator_powers?.map(e => LastValidatorPower.fromAmino(e)) || []; + message.validators = object.validators?.map(e => Validator.fromAmino(e)) || []; + message.delegations = object.delegations?.map(e => Delegation.fromAmino(e)) || []; + message.unbondingDelegations = object.unbonding_delegations?.map(e => UnbondingDelegation.fromAmino(e)) || []; + message.redelegations = object.redelegations?.map(e => Redelegation.fromAmino(e)) || []; + if (object.exported !== undefined && object.exported !== null) { + message.exported = object.exported; + } + return message; + }, + toAmino(message: GenesisState): GenesisStateAmino { + const obj: any = {}; + obj.params = message.params ? Params.toAmino(message.params) : undefined; + obj.last_total_power = message.lastTotalPower ? base64FromBytes(message.lastTotalPower) : undefined; + if (message.lastValidatorPowers) { + obj.last_validator_powers = message.lastValidatorPowers.map(e => e ? LastValidatorPower.toAmino(e) : undefined); + } else { + obj.last_validator_powers = message.lastValidatorPowers; + } + if (message.validators) { + obj.validators = message.validators.map(e => e ? Validator.toAmino(e) : undefined); + } else { + obj.validators = message.validators; + } + if (message.delegations) { + obj.delegations = message.delegations.map(e => e ? Delegation.toAmino(e) : undefined); + } else { + obj.delegations = message.delegations; + } + if (message.unbondingDelegations) { + obj.unbonding_delegations = message.unbondingDelegations.map(e => e ? UnbondingDelegation.toAmino(e) : undefined); + } else { + obj.unbonding_delegations = message.unbondingDelegations; + } + if (message.redelegations) { + obj.redelegations = message.redelegations.map(e => e ? Redelegation.toAmino(e) : undefined); + } else { + obj.redelegations = message.redelegations; + } + obj.exported = message.exported === false ? undefined : message.exported; + return obj; + }, + fromAminoMsg(object: GenesisStateAminoMsg): GenesisState { + return GenesisState.fromAmino(object.value); + }, + toAminoMsg(message: GenesisState): GenesisStateAminoMsg { + return { + type: "cosmos-sdk/GenesisState", + value: GenesisState.toAmino(message) + }; + }, + fromProtoMsg(message: GenesisStateProtoMsg): GenesisState { + return GenesisState.decode(message.value); + }, + toProto(message: GenesisState): Uint8Array { + return GenesisState.encode(message).finish(); + }, + toProtoMsg(message: GenesisState): GenesisStateProtoMsg { + return { + typeUrl: "/cosmos.staking.v1beta1.GenesisState", + value: GenesisState.encode(message).finish() + }; + } +}; +function createBaseLastValidatorPower(): LastValidatorPower { + return { + address: "", + power: BigInt(0) + }; +} +export const LastValidatorPower = { + typeUrl: "/cosmos.staking.v1beta1.LastValidatorPower", + encode(message: LastValidatorPower, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.address !== undefined) { + writer.uint32(10).string(message.address); + } + if (message.power !== undefined) { + writer.uint32(16).int64(message.power); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): LastValidatorPower { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseLastValidatorPower(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.string(); + break; + case 2: + message.power = reader.int64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): LastValidatorPower { + const obj = createBaseLastValidatorPower(); + if (isSet(object.address)) obj.address = String(object.address); + if (isSet(object.power)) obj.power = BigInt(object.power.toString()); + return obj; + }, + toJSON(message: LastValidatorPower): JsonSafe { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + message.power !== undefined && (obj.power = (message.power || BigInt(0)).toString()); + return obj; + }, + fromPartial(object: DeepPartial): LastValidatorPower { + const message = createBaseLastValidatorPower(); + message.address = object.address ?? ""; + if (object.power !== undefined && object.power !== null) { + message.power = BigInt(object.power.toString()); + } + return message; + }, + fromSDK(object: LastValidatorPowerSDKType): LastValidatorPower { + return { + address: object?.address, + power: object?.power + }; + }, + fromSDKJSON(object: any): LastValidatorPowerSDKType { + return { + address: isSet(object.address) ? String(object.address) : "", + power: isSet(object.power) ? BigInt(object.power.toString()) : BigInt(0) + }; + }, + toSDK(message: LastValidatorPower): LastValidatorPowerSDKType { + const obj: any = {}; + obj.address = message.address; + obj.power = message.power; + return obj; + }, + fromAmino(object: LastValidatorPowerAmino): LastValidatorPower { + const message = createBaseLastValidatorPower(); + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } + if (object.power !== undefined && object.power !== null) { + message.power = BigInt(object.power); + } + return message; + }, + toAmino(message: LastValidatorPower): LastValidatorPowerAmino { + const obj: any = {}; + obj.address = message.address === "" ? undefined : message.address; + obj.power = message.power !== BigInt(0) ? message.power?.toString() : undefined; + return obj; + }, + fromAminoMsg(object: LastValidatorPowerAminoMsg): LastValidatorPower { + return LastValidatorPower.fromAmino(object.value); + }, + toAminoMsg(message: LastValidatorPower): LastValidatorPowerAminoMsg { + return { + type: "cosmos-sdk/LastValidatorPower", + value: LastValidatorPower.toAmino(message) + }; + }, + fromProtoMsg(message: LastValidatorPowerProtoMsg): LastValidatorPower { + return LastValidatorPower.decode(message.value); + }, + toProto(message: LastValidatorPower): Uint8Array { + return LastValidatorPower.encode(message).finish(); + }, + toProtoMsg(message: LastValidatorPower): LastValidatorPowerProtoMsg { + return { + typeUrl: "/cosmos.staking.v1beta1.LastValidatorPower", + value: LastValidatorPower.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/staking/v1beta1/query.lcd.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/staking/v1beta1/query.lcd.ts new file mode 100644 index 0000000000..385240543e --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/staking/v1beta1/query.lcd.ts @@ -0,0 +1,154 @@ +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../base/query/v1beta1/pagination.js"; +import { Validator, ValidatorSDKType, DelegationResponse, DelegationResponseSDKType, UnbondingDelegation, UnbondingDelegationSDKType, RedelegationResponse, RedelegationResponseSDKType, HistoricalInfo, HistoricalInfoSDKType, Pool, PoolSDKType, Params, ParamsSDKType } from "./staking.js"; +import { setPaginationParams } from "../../../helpers.js"; +import { LCDClient } from "@cosmology/lcd"; +import { QueryValidatorsRequest, QueryValidatorsRequestSDKType, QueryValidatorsResponse, QueryValidatorsResponseSDKType, QueryValidatorRequest, QueryValidatorRequestSDKType, QueryValidatorResponse, QueryValidatorResponseSDKType, QueryValidatorDelegationsRequest, QueryValidatorDelegationsRequestSDKType, QueryValidatorDelegationsResponse, QueryValidatorDelegationsResponseSDKType, QueryValidatorUnbondingDelegationsRequest, QueryValidatorUnbondingDelegationsRequestSDKType, QueryValidatorUnbondingDelegationsResponse, QueryValidatorUnbondingDelegationsResponseSDKType, QueryDelegationRequest, QueryDelegationRequestSDKType, QueryDelegationResponse, QueryDelegationResponseSDKType, QueryUnbondingDelegationRequest, QueryUnbondingDelegationRequestSDKType, QueryUnbondingDelegationResponse, QueryUnbondingDelegationResponseSDKType, QueryDelegatorDelegationsRequest, QueryDelegatorDelegationsRequestSDKType, QueryDelegatorDelegationsResponse, QueryDelegatorDelegationsResponseSDKType, QueryDelegatorUnbondingDelegationsRequest, QueryDelegatorUnbondingDelegationsRequestSDKType, QueryDelegatorUnbondingDelegationsResponse, QueryDelegatorUnbondingDelegationsResponseSDKType, QueryRedelegationsRequest, QueryRedelegationsRequestSDKType, QueryRedelegationsResponse, QueryRedelegationsResponseSDKType, QueryDelegatorValidatorsRequest, QueryDelegatorValidatorsRequestSDKType, QueryDelegatorValidatorsResponse, QueryDelegatorValidatorsResponseSDKType, QueryDelegatorValidatorRequest, QueryDelegatorValidatorRequestSDKType, QueryDelegatorValidatorResponse, QueryDelegatorValidatorResponseSDKType, QueryHistoricalInfoRequest, QueryHistoricalInfoRequestSDKType, QueryHistoricalInfoResponse, QueryHistoricalInfoResponseSDKType, QueryPoolRequest, QueryPoolRequestSDKType, QueryPoolResponse, QueryPoolResponseSDKType, QueryParamsRequest, QueryParamsRequestSDKType, QueryParamsResponse, QueryParamsResponseSDKType } from "./query.js"; +export class LCDQueryClient { + req: LCDClient; + constructor({ + requestClient + }: { + requestClient: LCDClient; + }) { + this.req = requestClient; + this.validators = this.validators.bind(this); + this.validator = this.validator.bind(this); + this.validatorDelegations = this.validatorDelegations.bind(this); + this.validatorUnbondingDelegations = this.validatorUnbondingDelegations.bind(this); + this.delegation = this.delegation.bind(this); + this.unbondingDelegation = this.unbondingDelegation.bind(this); + this.delegatorDelegations = this.delegatorDelegations.bind(this); + this.delegatorUnbondingDelegations = this.delegatorUnbondingDelegations.bind(this); + this.redelegations = this.redelegations.bind(this); + this.delegatorValidators = this.delegatorValidators.bind(this); + this.delegatorValidator = this.delegatorValidator.bind(this); + this.historicalInfo = this.historicalInfo.bind(this); + this.pool = this.pool.bind(this); + this.params = this.params.bind(this); + } + /* Validators queries all validators that match the given status. */ + async validators(params: QueryValidatorsRequest): Promise { + const options: any = { + params: {} + }; + if (typeof params?.status !== "undefined") { + options.params.status = params.status; + } + if (typeof params?.pagination !== "undefined") { + setPaginationParams(options, params.pagination); + } + const endpoint = `cosmos/staking/v1beta1/validators`; + return QueryValidatorsResponse.fromSDKJSON(await this.req.get(endpoint, options)); + } + /* Validator queries validator info for given validator address. */ + async validator(params: QueryValidatorRequest): Promise { + const endpoint = `cosmos/staking/v1beta1/validators/${params.validatorAddr}`; + return QueryValidatorResponse.fromSDKJSON(await this.req.get(endpoint)); + } + /* ValidatorDelegations queries delegate info for given validator. */ + async validatorDelegations(params: QueryValidatorDelegationsRequest): Promise { + const options: any = { + params: {} + }; + if (typeof params?.pagination !== "undefined") { + setPaginationParams(options, params.pagination); + } + const endpoint = `cosmos/staking/v1beta1/validators/${params.validatorAddr}/delegations`; + return QueryValidatorDelegationsResponse.fromSDKJSON(await this.req.get(endpoint, options)); + } + /* ValidatorUnbondingDelegations queries unbonding delegations of a validator. */ + async validatorUnbondingDelegations(params: QueryValidatorUnbondingDelegationsRequest): Promise { + const options: any = { + params: {} + }; + if (typeof params?.pagination !== "undefined") { + setPaginationParams(options, params.pagination); + } + const endpoint = `cosmos/staking/v1beta1/validators/${params.validatorAddr}/unbonding_delegations`; + return QueryValidatorUnbondingDelegationsResponse.fromSDKJSON(await this.req.get(endpoint, options)); + } + /* Delegation queries delegate info for given validator delegator pair. */ + async delegation(params: QueryDelegationRequest): Promise { + const endpoint = `cosmos/staking/v1beta1/validators/${params.validatorAddr}/delegations/${params.delegatorAddr}`; + return QueryDelegationResponse.fromSDKJSON(await this.req.get(endpoint)); + } + /* UnbondingDelegation queries unbonding info for given validator delegator + pair. */ + async unbondingDelegation(params: QueryUnbondingDelegationRequest): Promise { + const endpoint = `cosmos/staking/v1beta1/validators/${params.validatorAddr}/delegations/${params.delegatorAddr}/unbonding_delegation`; + return QueryUnbondingDelegationResponse.fromSDKJSON(await this.req.get(endpoint)); + } + /* DelegatorDelegations queries all delegations of a given delegator address. */ + async delegatorDelegations(params: QueryDelegatorDelegationsRequest): Promise { + const options: any = { + params: {} + }; + if (typeof params?.pagination !== "undefined") { + setPaginationParams(options, params.pagination); + } + const endpoint = `cosmos/staking/v1beta1/delegations/${params.delegatorAddr}`; + return QueryDelegatorDelegationsResponse.fromSDKJSON(await this.req.get(endpoint, options)); + } + /* DelegatorUnbondingDelegations queries all unbonding delegations of a given + delegator address. */ + async delegatorUnbondingDelegations(params: QueryDelegatorUnbondingDelegationsRequest): Promise { + const options: any = { + params: {} + }; + if (typeof params?.pagination !== "undefined") { + setPaginationParams(options, params.pagination); + } + const endpoint = `cosmos/staking/v1beta1/delegators/${params.delegatorAddr}/unbonding_delegations`; + return QueryDelegatorUnbondingDelegationsResponse.fromSDKJSON(await this.req.get(endpoint, options)); + } + /* Redelegations queries redelegations of given address. */ + async redelegations(params: QueryRedelegationsRequest): Promise { + const options: any = { + params: {} + }; + if (typeof params?.srcValidatorAddr !== "undefined") { + options.params.src_validator_addr = params.srcValidatorAddr; + } + if (typeof params?.dstValidatorAddr !== "undefined") { + options.params.dst_validator_addr = params.dstValidatorAddr; + } + if (typeof params?.pagination !== "undefined") { + setPaginationParams(options, params.pagination); + } + const endpoint = `cosmos/staking/v1beta1/delegators/${params.delegatorAddr}/redelegations`; + return QueryRedelegationsResponse.fromSDKJSON(await this.req.get(endpoint, options)); + } + /* DelegatorValidators queries all validators info for given delegator + address. */ + async delegatorValidators(params: QueryDelegatorValidatorsRequest): Promise { + const options: any = { + params: {} + }; + if (typeof params?.pagination !== "undefined") { + setPaginationParams(options, params.pagination); + } + const endpoint = `cosmos/staking/v1beta1/delegators/${params.delegatorAddr}/validators`; + return QueryDelegatorValidatorsResponse.fromSDKJSON(await this.req.get(endpoint, options)); + } + /* DelegatorValidator queries validator info for given delegator validator + pair. */ + async delegatorValidator(params: QueryDelegatorValidatorRequest): Promise { + const endpoint = `cosmos/staking/v1beta1/delegators/${params.delegatorAddr}/validators/${params.validatorAddr}`; + return QueryDelegatorValidatorResponse.fromSDKJSON(await this.req.get(endpoint)); + } + /* HistoricalInfo queries the historical info for given height. */ + async historicalInfo(params: QueryHistoricalInfoRequest): Promise { + const endpoint = `cosmos/staking/v1beta1/historical_info/${params.height}`; + return QueryHistoricalInfoResponse.fromSDKJSON(await this.req.get(endpoint)); + } + /* Pool queries the pool info. */ + async pool(_params: QueryPoolRequest = {}): Promise { + const endpoint = `cosmos/staking/v1beta1/pool`; + return QueryPoolResponse.fromSDKJSON(await this.req.get(endpoint)); + } + /* Parameters queries the staking parameters. */ + async params(_params: QueryParamsRequest = {}): Promise { + const endpoint = `cosmos/staking/v1beta1/params`; + return QueryParamsResponse.fromSDKJSON(await this.req.get(endpoint)); + } +} \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/staking/v1beta1/query.rpc.Query.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/staking/v1beta1/query.rpc.Query.ts new file mode 100644 index 0000000000..6cb4037052 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/staking/v1beta1/query.rpc.Query.ts @@ -0,0 +1,187 @@ +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../base/query/v1beta1/pagination.js"; +import { Validator, ValidatorSDKType, DelegationResponse, DelegationResponseSDKType, UnbondingDelegation, UnbondingDelegationSDKType, RedelegationResponse, RedelegationResponseSDKType, HistoricalInfo, HistoricalInfoSDKType, Pool, PoolSDKType, Params, ParamsSDKType } from "./staking.js"; +import { Rpc } from "../../../helpers.js"; +import { BinaryReader } from "../../../binary.js"; +import { QueryClient, createProtobufRpcClient } from "@cosmjs/stargate"; +import { QueryValidatorsRequest, QueryValidatorsRequestSDKType, QueryValidatorsResponse, QueryValidatorsResponseSDKType, QueryValidatorRequest, QueryValidatorRequestSDKType, QueryValidatorResponse, QueryValidatorResponseSDKType, QueryValidatorDelegationsRequest, QueryValidatorDelegationsRequestSDKType, QueryValidatorDelegationsResponse, QueryValidatorDelegationsResponseSDKType, QueryValidatorUnbondingDelegationsRequest, QueryValidatorUnbondingDelegationsRequestSDKType, QueryValidatorUnbondingDelegationsResponse, QueryValidatorUnbondingDelegationsResponseSDKType, QueryDelegationRequest, QueryDelegationRequestSDKType, QueryDelegationResponse, QueryDelegationResponseSDKType, QueryUnbondingDelegationRequest, QueryUnbondingDelegationRequestSDKType, QueryUnbondingDelegationResponse, QueryUnbondingDelegationResponseSDKType, QueryDelegatorDelegationsRequest, QueryDelegatorDelegationsRequestSDKType, QueryDelegatorDelegationsResponse, QueryDelegatorDelegationsResponseSDKType, QueryDelegatorUnbondingDelegationsRequest, QueryDelegatorUnbondingDelegationsRequestSDKType, QueryDelegatorUnbondingDelegationsResponse, QueryDelegatorUnbondingDelegationsResponseSDKType, QueryRedelegationsRequest, QueryRedelegationsRequestSDKType, QueryRedelegationsResponse, QueryRedelegationsResponseSDKType, QueryDelegatorValidatorsRequest, QueryDelegatorValidatorsRequestSDKType, QueryDelegatorValidatorsResponse, QueryDelegatorValidatorsResponseSDKType, QueryDelegatorValidatorRequest, QueryDelegatorValidatorRequestSDKType, QueryDelegatorValidatorResponse, QueryDelegatorValidatorResponseSDKType, QueryHistoricalInfoRequest, QueryHistoricalInfoRequestSDKType, QueryHistoricalInfoResponse, QueryHistoricalInfoResponseSDKType, QueryPoolRequest, QueryPoolRequestSDKType, QueryPoolResponse, QueryPoolResponseSDKType, QueryParamsRequest, QueryParamsRequestSDKType, QueryParamsResponse, QueryParamsResponseSDKType } from "./query.js"; +/** Query defines the gRPC querier service. */ +export interface Query { + /** Validators queries all validators that match the given status. */ + validators(request: QueryValidatorsRequest): Promise; + /** Validator queries validator info for given validator address. */ + validator(request: QueryValidatorRequest): Promise; + /** ValidatorDelegations queries delegate info for given validator. */ + validatorDelegations(request: QueryValidatorDelegationsRequest): Promise; + /** ValidatorUnbondingDelegations queries unbonding delegations of a validator. */ + validatorUnbondingDelegations(request: QueryValidatorUnbondingDelegationsRequest): Promise; + /** Delegation queries delegate info for given validator delegator pair. */ + delegation(request: QueryDelegationRequest): Promise; + /** + * UnbondingDelegation queries unbonding info for given validator delegator + * pair. + */ + unbondingDelegation(request: QueryUnbondingDelegationRequest): Promise; + /** DelegatorDelegations queries all delegations of a given delegator address. */ + delegatorDelegations(request: QueryDelegatorDelegationsRequest): Promise; + /** + * DelegatorUnbondingDelegations queries all unbonding delegations of a given + * delegator address. + */ + delegatorUnbondingDelegations(request: QueryDelegatorUnbondingDelegationsRequest): Promise; + /** Redelegations queries redelegations of given address. */ + redelegations(request: QueryRedelegationsRequest): Promise; + /** + * DelegatorValidators queries all validators info for given delegator + * address. + */ + delegatorValidators(request: QueryDelegatorValidatorsRequest): Promise; + /** + * DelegatorValidator queries validator info for given delegator validator + * pair. + */ + delegatorValidator(request: QueryDelegatorValidatorRequest): Promise; + /** HistoricalInfo queries the historical info for given height. */ + historicalInfo(request: QueryHistoricalInfoRequest): Promise; + /** Pool queries the pool info. */ + pool(request?: QueryPoolRequest): Promise; + /** Parameters queries the staking parameters. */ + params(request?: QueryParamsRequest): Promise; +} +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + this.validators = this.validators.bind(this); + this.validator = this.validator.bind(this); + this.validatorDelegations = this.validatorDelegations.bind(this); + this.validatorUnbondingDelegations = this.validatorUnbondingDelegations.bind(this); + this.delegation = this.delegation.bind(this); + this.unbondingDelegation = this.unbondingDelegation.bind(this); + this.delegatorDelegations = this.delegatorDelegations.bind(this); + this.delegatorUnbondingDelegations = this.delegatorUnbondingDelegations.bind(this); + this.redelegations = this.redelegations.bind(this); + this.delegatorValidators = this.delegatorValidators.bind(this); + this.delegatorValidator = this.delegatorValidator.bind(this); + this.historicalInfo = this.historicalInfo.bind(this); + this.pool = this.pool.bind(this); + this.params = this.params.bind(this); + } + validators(request: QueryValidatorsRequest): Promise { + const data = QueryValidatorsRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.staking.v1beta1.Query", "Validators", data); + return promise.then(data => QueryValidatorsResponse.decode(new BinaryReader(data))); + } + validator(request: QueryValidatorRequest): Promise { + const data = QueryValidatorRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.staking.v1beta1.Query", "Validator", data); + return promise.then(data => QueryValidatorResponse.decode(new BinaryReader(data))); + } + validatorDelegations(request: QueryValidatorDelegationsRequest): Promise { + const data = QueryValidatorDelegationsRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.staking.v1beta1.Query", "ValidatorDelegations", data); + return promise.then(data => QueryValidatorDelegationsResponse.decode(new BinaryReader(data))); + } + validatorUnbondingDelegations(request: QueryValidatorUnbondingDelegationsRequest): Promise { + const data = QueryValidatorUnbondingDelegationsRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.staking.v1beta1.Query", "ValidatorUnbondingDelegations", data); + return promise.then(data => QueryValidatorUnbondingDelegationsResponse.decode(new BinaryReader(data))); + } + delegation(request: QueryDelegationRequest): Promise { + const data = QueryDelegationRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.staking.v1beta1.Query", "Delegation", data); + return promise.then(data => QueryDelegationResponse.decode(new BinaryReader(data))); + } + unbondingDelegation(request: QueryUnbondingDelegationRequest): Promise { + const data = QueryUnbondingDelegationRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.staking.v1beta1.Query", "UnbondingDelegation", data); + return promise.then(data => QueryUnbondingDelegationResponse.decode(new BinaryReader(data))); + } + delegatorDelegations(request: QueryDelegatorDelegationsRequest): Promise { + const data = QueryDelegatorDelegationsRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.staking.v1beta1.Query", "DelegatorDelegations", data); + return promise.then(data => QueryDelegatorDelegationsResponse.decode(new BinaryReader(data))); + } + delegatorUnbondingDelegations(request: QueryDelegatorUnbondingDelegationsRequest): Promise { + const data = QueryDelegatorUnbondingDelegationsRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.staking.v1beta1.Query", "DelegatorUnbondingDelegations", data); + return promise.then(data => QueryDelegatorUnbondingDelegationsResponse.decode(new BinaryReader(data))); + } + redelegations(request: QueryRedelegationsRequest): Promise { + const data = QueryRedelegationsRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.staking.v1beta1.Query", "Redelegations", data); + return promise.then(data => QueryRedelegationsResponse.decode(new BinaryReader(data))); + } + delegatorValidators(request: QueryDelegatorValidatorsRequest): Promise { + const data = QueryDelegatorValidatorsRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.staking.v1beta1.Query", "DelegatorValidators", data); + return promise.then(data => QueryDelegatorValidatorsResponse.decode(new BinaryReader(data))); + } + delegatorValidator(request: QueryDelegatorValidatorRequest): Promise { + const data = QueryDelegatorValidatorRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.staking.v1beta1.Query", "DelegatorValidator", data); + return promise.then(data => QueryDelegatorValidatorResponse.decode(new BinaryReader(data))); + } + historicalInfo(request: QueryHistoricalInfoRequest): Promise { + const data = QueryHistoricalInfoRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.staking.v1beta1.Query", "HistoricalInfo", data); + return promise.then(data => QueryHistoricalInfoResponse.decode(new BinaryReader(data))); + } + pool(request: QueryPoolRequest = {}): Promise { + const data = QueryPoolRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.staking.v1beta1.Query", "Pool", data); + return promise.then(data => QueryPoolResponse.decode(new BinaryReader(data))); + } + params(request: QueryParamsRequest = {}): Promise { + const data = QueryParamsRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.staking.v1beta1.Query", "Params", data); + return promise.then(data => QueryParamsResponse.decode(new BinaryReader(data))); + } +} +export const createRpcQueryExtension = (base: QueryClient) => { + const rpc = createProtobufRpcClient(base); + const queryService = new QueryClientImpl(rpc); + return { + validators(request: QueryValidatorsRequest): Promise { + return queryService.validators(request); + }, + validator(request: QueryValidatorRequest): Promise { + return queryService.validator(request); + }, + validatorDelegations(request: QueryValidatorDelegationsRequest): Promise { + return queryService.validatorDelegations(request); + }, + validatorUnbondingDelegations(request: QueryValidatorUnbondingDelegationsRequest): Promise { + return queryService.validatorUnbondingDelegations(request); + }, + delegation(request: QueryDelegationRequest): Promise { + return queryService.delegation(request); + }, + unbondingDelegation(request: QueryUnbondingDelegationRequest): Promise { + return queryService.unbondingDelegation(request); + }, + delegatorDelegations(request: QueryDelegatorDelegationsRequest): Promise { + return queryService.delegatorDelegations(request); + }, + delegatorUnbondingDelegations(request: QueryDelegatorUnbondingDelegationsRequest): Promise { + return queryService.delegatorUnbondingDelegations(request); + }, + redelegations(request: QueryRedelegationsRequest): Promise { + return queryService.redelegations(request); + }, + delegatorValidators(request: QueryDelegatorValidatorsRequest): Promise { + return queryService.delegatorValidators(request); + }, + delegatorValidator(request: QueryDelegatorValidatorRequest): Promise { + return queryService.delegatorValidator(request); + }, + historicalInfo(request: QueryHistoricalInfoRequest): Promise { + return queryService.historicalInfo(request); + }, + pool(request?: QueryPoolRequest): Promise { + return queryService.pool(request); + }, + params(request?: QueryParamsRequest): Promise { + return queryService.params(request); + } + }; +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/staking/v1beta1/query.rpc.func.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/staking/v1beta1/query.rpc.func.ts new file mode 100644 index 0000000000..c85d8e3996 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/staking/v1beta1/query.rpc.func.ts @@ -0,0 +1,157 @@ +import { RpcResolver, buildQuery } from "../../../helper-func-types"; +import { buildUseQuery } from "../../../react-query"; +import { QueryValidatorsRequest, QueryValidatorsResponse, QueryValidatorRequest, QueryValidatorResponse, QueryValidatorDelegationsRequest, QueryValidatorDelegationsResponse, QueryValidatorUnbondingDelegationsRequest, QueryValidatorUnbondingDelegationsResponse, QueryDelegationRequest, QueryDelegationResponse, QueryUnbondingDelegationRequest, QueryUnbondingDelegationResponse, QueryDelegatorDelegationsRequest, QueryDelegatorDelegationsResponse, QueryDelegatorUnbondingDelegationsRequest, QueryDelegatorUnbondingDelegationsResponse, QueryRedelegationsRequest, QueryRedelegationsResponse, QueryDelegatorValidatorsRequest, QueryDelegatorValidatorsResponse, QueryDelegatorValidatorRequest, QueryDelegatorValidatorResponse, QueryHistoricalInfoRequest, QueryHistoricalInfoResponse, QueryPoolRequest, QueryPoolResponse, QueryParamsRequest, QueryParamsResponse } from "./query"; +export const createGetValidators = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryValidatorsRequest.encode, + decode: QueryValidatorsResponse.decode, + service: "cosmos.staking.v1beta1.Query", + method: "Validators", + getRpcInstance: getRpcInstance +}); +export const useGetValidators = buildUseQuery({ + builderQueryFn: createGetValidators, + queryKeyPrefix: "ValidatorsQuery" +}); +export const createGetValidator = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryValidatorRequest.encode, + decode: QueryValidatorResponse.decode, + service: "cosmos.staking.v1beta1.Query", + method: "Validator", + getRpcInstance: getRpcInstance +}); +export const useGetValidator = buildUseQuery({ + builderQueryFn: createGetValidator, + queryKeyPrefix: "ValidatorQuery" +}); +export const createGetValidatorDelegations = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryValidatorDelegationsRequest.encode, + decode: QueryValidatorDelegationsResponse.decode, + service: "cosmos.staking.v1beta1.Query", + method: "ValidatorDelegations", + getRpcInstance: getRpcInstance +}); +export const useGetValidatorDelegations = buildUseQuery({ + builderQueryFn: createGetValidatorDelegations, + queryKeyPrefix: "ValidatorDelegationsQuery" +}); +export const createGetValidatorUnbondingDelegations = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryValidatorUnbondingDelegationsRequest.encode, + decode: QueryValidatorUnbondingDelegationsResponse.decode, + service: "cosmos.staking.v1beta1.Query", + method: "ValidatorUnbondingDelegations", + getRpcInstance: getRpcInstance +}); +export const useGetValidatorUnbondingDelegations = buildUseQuery({ + builderQueryFn: createGetValidatorUnbondingDelegations, + queryKeyPrefix: "ValidatorUnbondingDelegationsQuery" +}); +export const createGetDelegation = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryDelegationRequest.encode, + decode: QueryDelegationResponse.decode, + service: "cosmos.staking.v1beta1.Query", + method: "Delegation", + getRpcInstance: getRpcInstance +}); +export const useGetDelegation = buildUseQuery({ + builderQueryFn: createGetDelegation, + queryKeyPrefix: "DelegationQuery" +}); +export const createGetUnbondingDelegation = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryUnbondingDelegationRequest.encode, + decode: QueryUnbondingDelegationResponse.decode, + service: "cosmos.staking.v1beta1.Query", + method: "UnbondingDelegation", + getRpcInstance: getRpcInstance +}); +export const useGetUnbondingDelegation = buildUseQuery({ + builderQueryFn: createGetUnbondingDelegation, + queryKeyPrefix: "UnbondingDelegationQuery" +}); +export const createGetDelegatorDelegations = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryDelegatorDelegationsRequest.encode, + decode: QueryDelegatorDelegationsResponse.decode, + service: "cosmos.staking.v1beta1.Query", + method: "DelegatorDelegations", + getRpcInstance: getRpcInstance +}); +export const useGetDelegatorDelegations = buildUseQuery({ + builderQueryFn: createGetDelegatorDelegations, + queryKeyPrefix: "DelegatorDelegationsQuery" +}); +export const createGetDelegatorUnbondingDelegations = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryDelegatorUnbondingDelegationsRequest.encode, + decode: QueryDelegatorUnbondingDelegationsResponse.decode, + service: "cosmos.staking.v1beta1.Query", + method: "DelegatorUnbondingDelegations", + getRpcInstance: getRpcInstance +}); +export const useGetDelegatorUnbondingDelegations = buildUseQuery({ + builderQueryFn: createGetDelegatorUnbondingDelegations, + queryKeyPrefix: "DelegatorUnbondingDelegationsQuery" +}); +export const createGetRedelegations = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryRedelegationsRequest.encode, + decode: QueryRedelegationsResponse.decode, + service: "cosmos.staking.v1beta1.Query", + method: "Redelegations", + getRpcInstance: getRpcInstance +}); +export const useGetRedelegations = buildUseQuery({ + builderQueryFn: createGetRedelegations, + queryKeyPrefix: "RedelegationsQuery" +}); +export const createGetDelegatorValidators = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryDelegatorValidatorsRequest.encode, + decode: QueryDelegatorValidatorsResponse.decode, + service: "cosmos.staking.v1beta1.Query", + method: "DelegatorValidators", + getRpcInstance: getRpcInstance +}); +export const useGetDelegatorValidators = buildUseQuery({ + builderQueryFn: createGetDelegatorValidators, + queryKeyPrefix: "DelegatorValidatorsQuery" +}); +export const createGetDelegatorValidator = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryDelegatorValidatorRequest.encode, + decode: QueryDelegatorValidatorResponse.decode, + service: "cosmos.staking.v1beta1.Query", + method: "DelegatorValidator", + getRpcInstance: getRpcInstance +}); +export const useGetDelegatorValidator = buildUseQuery({ + builderQueryFn: createGetDelegatorValidator, + queryKeyPrefix: "DelegatorValidatorQuery" +}); +export const createGetHistoricalInfo = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryHistoricalInfoRequest.encode, + decode: QueryHistoricalInfoResponse.decode, + service: "cosmos.staking.v1beta1.Query", + method: "HistoricalInfo", + getRpcInstance: getRpcInstance +}); +export const useGetHistoricalInfo = buildUseQuery({ + builderQueryFn: createGetHistoricalInfo, + queryKeyPrefix: "HistoricalInfoQuery" +}); +export const createGetPool = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryPoolRequest.encode, + decode: QueryPoolResponse.decode, + service: "cosmos.staking.v1beta1.Query", + method: "Pool", + getRpcInstance: getRpcInstance +}); +export const useGetPool = buildUseQuery({ + builderQueryFn: createGetPool, + queryKeyPrefix: "PoolQuery" +}); +export const createGetParams = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryParamsRequest.encode, + decode: QueryParamsResponse.decode, + service: "cosmos.staking.v1beta1.Query", + method: "Params", + getRpcInstance: getRpcInstance +}); +export const useGetParams = buildUseQuery({ + builderQueryFn: createGetParams, + queryKeyPrefix: "ParamsQuery" +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/staking/v1beta1/query.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/staking/v1beta1/query.ts new file mode 100644 index 0000000000..a89bebd5d4 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/staking/v1beta1/query.ts @@ -0,0 +1,3550 @@ +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../base/query/v1beta1/pagination.js"; +import { Validator, ValidatorSDKType, DelegationResponse, DelegationResponseSDKType, UnbondingDelegation, UnbondingDelegationSDKType, RedelegationResponse, RedelegationResponseSDKType, HistoricalInfo, HistoricalInfoSDKType, Pool, PoolSDKType, Params, ParamsSDKType } from "./staking.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "cosmos.staking.v1beta1"; +/** QueryValidatorsRequest is request type for Query/Validators RPC method. */ +export interface QueryValidatorsRequest { + /** status enables to query for validators matching a given status. */ + status: string; + /** pagination defines an optional pagination for the request. */ + pagination?: PageRequest; +} +export interface QueryValidatorsRequestProtoMsg { + typeUrl: "/cosmos.staking.v1beta1.QueryValidatorsRequest"; + value: Uint8Array; +} +/** QueryValidatorsRequest is request type for Query/Validators RPC method. */ +export interface QueryValidatorsRequestSDKType { + status: string; + pagination?: PageRequestSDKType; +} +/** QueryValidatorsResponse is response type for the Query/Validators RPC method */ +export interface QueryValidatorsResponse { + /** validators contains all the queried validators. */ + validators: Validator[]; + /** pagination defines the pagination in the response. */ + pagination?: PageResponse; +} +export interface QueryValidatorsResponseProtoMsg { + typeUrl: "/cosmos.staking.v1beta1.QueryValidatorsResponse"; + value: Uint8Array; +} +/** QueryValidatorsResponse is response type for the Query/Validators RPC method */ +export interface QueryValidatorsResponseSDKType { + validators: ValidatorSDKType[]; + pagination?: PageResponseSDKType; +} +/** QueryValidatorRequest is response type for the Query/Validator RPC method */ +export interface QueryValidatorRequest { + /** validator_addr defines the validator address to query for. */ + validatorAddr: string; +} +export interface QueryValidatorRequestProtoMsg { + typeUrl: "/cosmos.staking.v1beta1.QueryValidatorRequest"; + value: Uint8Array; +} +/** QueryValidatorRequest is response type for the Query/Validator RPC method */ +export interface QueryValidatorRequestSDKType { + validator_addr: string; +} +/** QueryValidatorResponse is response type for the Query/Validator RPC method */ +export interface QueryValidatorResponse { + /** validator defines the the validator info. */ + validator: Validator; +} +export interface QueryValidatorResponseProtoMsg { + typeUrl: "/cosmos.staking.v1beta1.QueryValidatorResponse"; + value: Uint8Array; +} +/** QueryValidatorResponse is response type for the Query/Validator RPC method */ +export interface QueryValidatorResponseSDKType { + validator: ValidatorSDKType; +} +/** + * QueryValidatorDelegationsRequest is request type for the + * Query/ValidatorDelegations RPC method + */ +export interface QueryValidatorDelegationsRequest { + /** validator_addr defines the validator address to query for. */ + validatorAddr: string; + /** pagination defines an optional pagination for the request. */ + pagination?: PageRequest; +} +export interface QueryValidatorDelegationsRequestProtoMsg { + typeUrl: "/cosmos.staking.v1beta1.QueryValidatorDelegationsRequest"; + value: Uint8Array; +} +/** + * QueryValidatorDelegationsRequest is request type for the + * Query/ValidatorDelegations RPC method + */ +export interface QueryValidatorDelegationsRequestSDKType { + validator_addr: string; + pagination?: PageRequestSDKType; +} +/** + * QueryValidatorDelegationsResponse is response type for the + * Query/ValidatorDelegations RPC method + */ +export interface QueryValidatorDelegationsResponse { + delegationResponses: DelegationResponse[]; + /** pagination defines the pagination in the response. */ + pagination?: PageResponse; +} +export interface QueryValidatorDelegationsResponseProtoMsg { + typeUrl: "/cosmos.staking.v1beta1.QueryValidatorDelegationsResponse"; + value: Uint8Array; +} +/** + * QueryValidatorDelegationsResponse is response type for the + * Query/ValidatorDelegations RPC method + */ +export interface QueryValidatorDelegationsResponseSDKType { + delegation_responses: DelegationResponseSDKType[]; + pagination?: PageResponseSDKType; +} +/** + * QueryValidatorUnbondingDelegationsRequest is required type for the + * Query/ValidatorUnbondingDelegations RPC method + */ +export interface QueryValidatorUnbondingDelegationsRequest { + /** validator_addr defines the validator address to query for. */ + validatorAddr: string; + /** pagination defines an optional pagination for the request. */ + pagination?: PageRequest; +} +export interface QueryValidatorUnbondingDelegationsRequestProtoMsg { + typeUrl: "/cosmos.staking.v1beta1.QueryValidatorUnbondingDelegationsRequest"; + value: Uint8Array; +} +/** + * QueryValidatorUnbondingDelegationsRequest is required type for the + * Query/ValidatorUnbondingDelegations RPC method + */ +export interface QueryValidatorUnbondingDelegationsRequestSDKType { + validator_addr: string; + pagination?: PageRequestSDKType; +} +/** + * QueryValidatorUnbondingDelegationsResponse is response type for the + * Query/ValidatorUnbondingDelegations RPC method. + */ +export interface QueryValidatorUnbondingDelegationsResponse { + unbondingResponses: UnbondingDelegation[]; + /** pagination defines the pagination in the response. */ + pagination?: PageResponse; +} +export interface QueryValidatorUnbondingDelegationsResponseProtoMsg { + typeUrl: "/cosmos.staking.v1beta1.QueryValidatorUnbondingDelegationsResponse"; + value: Uint8Array; +} +/** + * QueryValidatorUnbondingDelegationsResponse is response type for the + * Query/ValidatorUnbondingDelegations RPC method. + */ +export interface QueryValidatorUnbondingDelegationsResponseSDKType { + unbonding_responses: UnbondingDelegationSDKType[]; + pagination?: PageResponseSDKType; +} +/** QueryDelegationRequest is request type for the Query/Delegation RPC method. */ +export interface QueryDelegationRequest { + /** delegator_addr defines the delegator address to query for. */ + delegatorAddr: string; + /** validator_addr defines the validator address to query for. */ + validatorAddr: string; +} +export interface QueryDelegationRequestProtoMsg { + typeUrl: "/cosmos.staking.v1beta1.QueryDelegationRequest"; + value: Uint8Array; +} +/** QueryDelegationRequest is request type for the Query/Delegation RPC method. */ +export interface QueryDelegationRequestSDKType { + delegator_addr: string; + validator_addr: string; +} +/** QueryDelegationResponse is response type for the Query/Delegation RPC method. */ +export interface QueryDelegationResponse { + /** delegation_responses defines the delegation info of a delegation. */ + delegationResponse?: DelegationResponse; +} +export interface QueryDelegationResponseProtoMsg { + typeUrl: "/cosmos.staking.v1beta1.QueryDelegationResponse"; + value: Uint8Array; +} +/** QueryDelegationResponse is response type for the Query/Delegation RPC method. */ +export interface QueryDelegationResponseSDKType { + delegation_response?: DelegationResponseSDKType; +} +/** + * QueryUnbondingDelegationRequest is request type for the + * Query/UnbondingDelegation RPC method. + */ +export interface QueryUnbondingDelegationRequest { + /** delegator_addr defines the delegator address to query for. */ + delegatorAddr: string; + /** validator_addr defines the validator address to query for. */ + validatorAddr: string; +} +export interface QueryUnbondingDelegationRequestProtoMsg { + typeUrl: "/cosmos.staking.v1beta1.QueryUnbondingDelegationRequest"; + value: Uint8Array; +} +/** + * QueryUnbondingDelegationRequest is request type for the + * Query/UnbondingDelegation RPC method. + */ +export interface QueryUnbondingDelegationRequestSDKType { + delegator_addr: string; + validator_addr: string; +} +/** + * QueryDelegationResponse is response type for the Query/UnbondingDelegation + * RPC method. + */ +export interface QueryUnbondingDelegationResponse { + /** unbond defines the unbonding information of a delegation. */ + unbond: UnbondingDelegation; +} +export interface QueryUnbondingDelegationResponseProtoMsg { + typeUrl: "/cosmos.staking.v1beta1.QueryUnbondingDelegationResponse"; + value: Uint8Array; +} +/** + * QueryDelegationResponse is response type for the Query/UnbondingDelegation + * RPC method. + */ +export interface QueryUnbondingDelegationResponseSDKType { + unbond: UnbondingDelegationSDKType; +} +/** + * QueryDelegatorDelegationsRequest is request type for the + * Query/DelegatorDelegations RPC method. + */ +export interface QueryDelegatorDelegationsRequest { + /** delegator_addr defines the delegator address to query for. */ + delegatorAddr: string; + /** pagination defines an optional pagination for the request. */ + pagination?: PageRequest; +} +export interface QueryDelegatorDelegationsRequestProtoMsg { + typeUrl: "/cosmos.staking.v1beta1.QueryDelegatorDelegationsRequest"; + value: Uint8Array; +} +/** + * QueryDelegatorDelegationsRequest is request type for the + * Query/DelegatorDelegations RPC method. + */ +export interface QueryDelegatorDelegationsRequestSDKType { + delegator_addr: string; + pagination?: PageRequestSDKType; +} +/** + * QueryDelegatorDelegationsResponse is response type for the + * Query/DelegatorDelegations RPC method. + */ +export interface QueryDelegatorDelegationsResponse { + /** delegation_responses defines all the delegations' info of a delegator. */ + delegationResponses: DelegationResponse[]; + /** pagination defines the pagination in the response. */ + pagination?: PageResponse; +} +export interface QueryDelegatorDelegationsResponseProtoMsg { + typeUrl: "/cosmos.staking.v1beta1.QueryDelegatorDelegationsResponse"; + value: Uint8Array; +} +/** + * QueryDelegatorDelegationsResponse is response type for the + * Query/DelegatorDelegations RPC method. + */ +export interface QueryDelegatorDelegationsResponseSDKType { + delegation_responses: DelegationResponseSDKType[]; + pagination?: PageResponseSDKType; +} +/** + * QueryDelegatorUnbondingDelegationsRequest is request type for the + * Query/DelegatorUnbondingDelegations RPC method. + */ +export interface QueryDelegatorUnbondingDelegationsRequest { + /** delegator_addr defines the delegator address to query for. */ + delegatorAddr: string; + /** pagination defines an optional pagination for the request. */ + pagination?: PageRequest; +} +export interface QueryDelegatorUnbondingDelegationsRequestProtoMsg { + typeUrl: "/cosmos.staking.v1beta1.QueryDelegatorUnbondingDelegationsRequest"; + value: Uint8Array; +} +/** + * QueryDelegatorUnbondingDelegationsRequest is request type for the + * Query/DelegatorUnbondingDelegations RPC method. + */ +export interface QueryDelegatorUnbondingDelegationsRequestSDKType { + delegator_addr: string; + pagination?: PageRequestSDKType; +} +/** + * QueryUnbondingDelegatorDelegationsResponse is response type for the + * Query/UnbondingDelegatorDelegations RPC method. + */ +export interface QueryDelegatorUnbondingDelegationsResponse { + unbondingResponses: UnbondingDelegation[]; + /** pagination defines the pagination in the response. */ + pagination?: PageResponse; +} +export interface QueryDelegatorUnbondingDelegationsResponseProtoMsg { + typeUrl: "/cosmos.staking.v1beta1.QueryDelegatorUnbondingDelegationsResponse"; + value: Uint8Array; +} +/** + * QueryUnbondingDelegatorDelegationsResponse is response type for the + * Query/UnbondingDelegatorDelegations RPC method. + */ +export interface QueryDelegatorUnbondingDelegationsResponseSDKType { + unbonding_responses: UnbondingDelegationSDKType[]; + pagination?: PageResponseSDKType; +} +/** + * QueryRedelegationsRequest is request type for the Query/Redelegations RPC + * method. + */ +export interface QueryRedelegationsRequest { + /** delegator_addr defines the delegator address to query for. */ + delegatorAddr: string; + /** src_validator_addr defines the validator address to redelegate from. */ + srcValidatorAddr: string; + /** dst_validator_addr defines the validator address to redelegate to. */ + dstValidatorAddr: string; + /** pagination defines an optional pagination for the request. */ + pagination?: PageRequest; +} +export interface QueryRedelegationsRequestProtoMsg { + typeUrl: "/cosmos.staking.v1beta1.QueryRedelegationsRequest"; + value: Uint8Array; +} +/** + * QueryRedelegationsRequest is request type for the Query/Redelegations RPC + * method. + */ +export interface QueryRedelegationsRequestSDKType { + delegator_addr: string; + src_validator_addr: string; + dst_validator_addr: string; + pagination?: PageRequestSDKType; +} +/** + * QueryRedelegationsResponse is response type for the Query/Redelegations RPC + * method. + */ +export interface QueryRedelegationsResponse { + redelegationResponses: RedelegationResponse[]; + /** pagination defines the pagination in the response. */ + pagination?: PageResponse; +} +export interface QueryRedelegationsResponseProtoMsg { + typeUrl: "/cosmos.staking.v1beta1.QueryRedelegationsResponse"; + value: Uint8Array; +} +/** + * QueryRedelegationsResponse is response type for the Query/Redelegations RPC + * method. + */ +export interface QueryRedelegationsResponseSDKType { + redelegation_responses: RedelegationResponseSDKType[]; + pagination?: PageResponseSDKType; +} +/** + * QueryDelegatorValidatorsRequest is request type for the + * Query/DelegatorValidators RPC method. + */ +export interface QueryDelegatorValidatorsRequest { + /** delegator_addr defines the delegator address to query for. */ + delegatorAddr: string; + /** pagination defines an optional pagination for the request. */ + pagination?: PageRequest; +} +export interface QueryDelegatorValidatorsRequestProtoMsg { + typeUrl: "/cosmos.staking.v1beta1.QueryDelegatorValidatorsRequest"; + value: Uint8Array; +} +/** + * QueryDelegatorValidatorsRequest is request type for the + * Query/DelegatorValidators RPC method. + */ +export interface QueryDelegatorValidatorsRequestSDKType { + delegator_addr: string; + pagination?: PageRequestSDKType; +} +/** + * QueryDelegatorValidatorsResponse is response type for the + * Query/DelegatorValidators RPC method. + */ +export interface QueryDelegatorValidatorsResponse { + /** validators defines the the validators' info of a delegator. */ + validators: Validator[]; + /** pagination defines the pagination in the response. */ + pagination?: PageResponse; +} +export interface QueryDelegatorValidatorsResponseProtoMsg { + typeUrl: "/cosmos.staking.v1beta1.QueryDelegatorValidatorsResponse"; + value: Uint8Array; +} +/** + * QueryDelegatorValidatorsResponse is response type for the + * Query/DelegatorValidators RPC method. + */ +export interface QueryDelegatorValidatorsResponseSDKType { + validators: ValidatorSDKType[]; + pagination?: PageResponseSDKType; +} +/** + * QueryDelegatorValidatorRequest is request type for the + * Query/DelegatorValidator RPC method. + */ +export interface QueryDelegatorValidatorRequest { + /** delegator_addr defines the delegator address to query for. */ + delegatorAddr: string; + /** validator_addr defines the validator address to query for. */ + validatorAddr: string; +} +export interface QueryDelegatorValidatorRequestProtoMsg { + typeUrl: "/cosmos.staking.v1beta1.QueryDelegatorValidatorRequest"; + value: Uint8Array; +} +/** + * QueryDelegatorValidatorRequest is request type for the + * Query/DelegatorValidator RPC method. + */ +export interface QueryDelegatorValidatorRequestSDKType { + delegator_addr: string; + validator_addr: string; +} +/** + * QueryDelegatorValidatorResponse response type for the + * Query/DelegatorValidator RPC method. + */ +export interface QueryDelegatorValidatorResponse { + /** validator defines the the validator info. */ + validator: Validator; +} +export interface QueryDelegatorValidatorResponseProtoMsg { + typeUrl: "/cosmos.staking.v1beta1.QueryDelegatorValidatorResponse"; + value: Uint8Array; +} +/** + * QueryDelegatorValidatorResponse response type for the + * Query/DelegatorValidator RPC method. + */ +export interface QueryDelegatorValidatorResponseSDKType { + validator: ValidatorSDKType; +} +/** + * QueryHistoricalInfoRequest is request type for the Query/HistoricalInfo RPC + * method. + */ +export interface QueryHistoricalInfoRequest { + /** height defines at which height to query the historical info. */ + height: bigint; +} +export interface QueryHistoricalInfoRequestProtoMsg { + typeUrl: "/cosmos.staking.v1beta1.QueryHistoricalInfoRequest"; + value: Uint8Array; +} +/** + * QueryHistoricalInfoRequest is request type for the Query/HistoricalInfo RPC + * method. + */ +export interface QueryHistoricalInfoRequestSDKType { + height: bigint; +} +/** + * QueryHistoricalInfoResponse is response type for the Query/HistoricalInfo RPC + * method. + */ +export interface QueryHistoricalInfoResponse { + /** hist defines the historical info at the given height. */ + hist?: HistoricalInfo; +} +export interface QueryHistoricalInfoResponseProtoMsg { + typeUrl: "/cosmos.staking.v1beta1.QueryHistoricalInfoResponse"; + value: Uint8Array; +} +/** + * QueryHistoricalInfoResponse is response type for the Query/HistoricalInfo RPC + * method. + */ +export interface QueryHistoricalInfoResponseSDKType { + hist?: HistoricalInfoSDKType; +} +/** QueryPoolRequest is request type for the Query/Pool RPC method. */ +export interface QueryPoolRequest {} +export interface QueryPoolRequestProtoMsg { + typeUrl: "/cosmos.staking.v1beta1.QueryPoolRequest"; + value: Uint8Array; +} +/** QueryPoolRequest is request type for the Query/Pool RPC method. */ +export interface QueryPoolRequestSDKType {} +/** QueryPoolResponse is response type for the Query/Pool RPC method. */ +export interface QueryPoolResponse { + /** pool defines the pool info. */ + pool: Pool; +} +export interface QueryPoolResponseProtoMsg { + typeUrl: "/cosmos.staking.v1beta1.QueryPoolResponse"; + value: Uint8Array; +} +/** QueryPoolResponse is response type for the Query/Pool RPC method. */ +export interface QueryPoolResponseSDKType { + pool: PoolSDKType; +} +/** QueryParamsRequest is request type for the Query/Params RPC method. */ +export interface QueryParamsRequest {} +export interface QueryParamsRequestProtoMsg { + typeUrl: "/cosmos.staking.v1beta1.QueryParamsRequest"; + value: Uint8Array; +} +/** QueryParamsRequest is request type for the Query/Params RPC method. */ +export interface QueryParamsRequestSDKType {} +/** QueryParamsResponse is response type for the Query/Params RPC method. */ +export interface QueryParamsResponse { + /** params holds all the parameters of this module. */ + params: Params; +} +export interface QueryParamsResponseProtoMsg { + typeUrl: "/cosmos.staking.v1beta1.QueryParamsResponse"; + value: Uint8Array; +} +/** QueryParamsResponse is response type for the Query/Params RPC method. */ +export interface QueryParamsResponseSDKType { + params: ParamsSDKType; +} +function createBaseQueryValidatorsRequest(): QueryValidatorsRequest { + return { + status: "", + pagination: undefined + }; +} +export const QueryValidatorsRequest = { + typeUrl: "/cosmos.staking.v1beta1.QueryValidatorsRequest", + encode(message: QueryValidatorsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.status !== undefined) { + writer.uint32(10).string(message.status); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryValidatorsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryValidatorsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.status = reader.string(); + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryValidatorsRequest { + const obj = createBaseQueryValidatorsRequest(); + if (isSet(object.status)) obj.status = String(object.status); + if (isSet(object.pagination)) obj.pagination = PageRequest.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryValidatorsRequest): JsonSafe { + const obj: any = {}; + message.status !== undefined && (obj.status = message.status); + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryValidatorsRequest { + const message = createBaseQueryValidatorsRequest(); + message.status = object.status ?? ""; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryValidatorsRequestSDKType): QueryValidatorsRequest { + return { + status: object?.status, + pagination: object.pagination ? PageRequest.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryValidatorsRequestSDKType { + return { + status: isSet(object.status) ? String(object.status) : "", + pagination: isSet(object.pagination) ? PageRequest.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryValidatorsRequest): QueryValidatorsRequestSDKType { + const obj: any = {}; + obj.status = message.status; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryValidatorsRequestAmino): QueryValidatorsRequest { + const message = createBaseQueryValidatorsRequest(); + if (object.status !== undefined && object.status !== null) { + message.status = object.status; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryValidatorsRequest): QueryValidatorsRequestAmino { + const obj: any = {}; + obj.status = message.status === "" ? undefined : message.status; + obj.pagination = message.pagination ? PageRequest.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryValidatorsRequestAminoMsg): QueryValidatorsRequest { + return QueryValidatorsRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryValidatorsRequest): QueryValidatorsRequestAminoMsg { + return { + type: "cosmos-sdk/QueryValidatorsRequest", + value: QueryValidatorsRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryValidatorsRequestProtoMsg): QueryValidatorsRequest { + return QueryValidatorsRequest.decode(message.value); + }, + toProto(message: QueryValidatorsRequest): Uint8Array { + return QueryValidatorsRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryValidatorsRequest): QueryValidatorsRequestProtoMsg { + return { + typeUrl: "/cosmos.staking.v1beta1.QueryValidatorsRequest", + value: QueryValidatorsRequest.encode(message).finish() + }; + } +}; +function createBaseQueryValidatorsResponse(): QueryValidatorsResponse { + return { + validators: [], + pagination: undefined + }; +} +export const QueryValidatorsResponse = { + typeUrl: "/cosmos.staking.v1beta1.QueryValidatorsResponse", + encode(message: QueryValidatorsResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.validators) { + Validator.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryValidatorsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryValidatorsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.validators.push(Validator.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryValidatorsResponse { + const obj = createBaseQueryValidatorsResponse(); + if (Array.isArray(object?.validators)) obj.validators = object.validators.map((e: any) => Validator.fromJSON(e)); + if (isSet(object.pagination)) obj.pagination = PageResponse.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryValidatorsResponse): JsonSafe { + const obj: any = {}; + if (message.validators) { + obj.validators = message.validators.map(e => e ? Validator.toJSON(e) : undefined); + } else { + obj.validators = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryValidatorsResponse { + const message = createBaseQueryValidatorsResponse(); + message.validators = object.validators?.map(e => Validator.fromPartial(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryValidatorsResponseSDKType): QueryValidatorsResponse { + return { + validators: Array.isArray(object?.validators) ? object.validators.map((e: any) => Validator.fromSDK(e)) : [], + pagination: object.pagination ? PageResponse.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryValidatorsResponseSDKType { + return { + validators: Array.isArray(object?.validators) ? object.validators.map((e: any) => Validator.fromSDKJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryValidatorsResponse): QueryValidatorsResponseSDKType { + const obj: any = {}; + if (message.validators) { + obj.validators = message.validators.map(e => e ? Validator.toSDK(e) : undefined); + } else { + obj.validators = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryValidatorsResponseAmino): QueryValidatorsResponse { + const message = createBaseQueryValidatorsResponse(); + message.validators = object.validators?.map(e => Validator.fromAmino(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryValidatorsResponse): QueryValidatorsResponseAmino { + const obj: any = {}; + if (message.validators) { + obj.validators = message.validators.map(e => e ? Validator.toAmino(e) : undefined); + } else { + obj.validators = message.validators; + } + obj.pagination = message.pagination ? PageResponse.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryValidatorsResponseAminoMsg): QueryValidatorsResponse { + return QueryValidatorsResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryValidatorsResponse): QueryValidatorsResponseAminoMsg { + return { + type: "cosmos-sdk/QueryValidatorsResponse", + value: QueryValidatorsResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryValidatorsResponseProtoMsg): QueryValidatorsResponse { + return QueryValidatorsResponse.decode(message.value); + }, + toProto(message: QueryValidatorsResponse): Uint8Array { + return QueryValidatorsResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryValidatorsResponse): QueryValidatorsResponseProtoMsg { + return { + typeUrl: "/cosmos.staking.v1beta1.QueryValidatorsResponse", + value: QueryValidatorsResponse.encode(message).finish() + }; + } +}; +function createBaseQueryValidatorRequest(): QueryValidatorRequest { + return { + validatorAddr: "" + }; +} +export const QueryValidatorRequest = { + typeUrl: "/cosmos.staking.v1beta1.QueryValidatorRequest", + encode(message: QueryValidatorRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.validatorAddr !== undefined) { + writer.uint32(10).string(message.validatorAddr); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryValidatorRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryValidatorRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.validatorAddr = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryValidatorRequest { + const obj = createBaseQueryValidatorRequest(); + if (isSet(object.validatorAddr)) obj.validatorAddr = String(object.validatorAddr); + return obj; + }, + toJSON(message: QueryValidatorRequest): JsonSafe { + const obj: any = {}; + message.validatorAddr !== undefined && (obj.validatorAddr = message.validatorAddr); + return obj; + }, + fromPartial(object: DeepPartial): QueryValidatorRequest { + const message = createBaseQueryValidatorRequest(); + message.validatorAddr = object.validatorAddr ?? ""; + return message; + }, + fromSDK(object: QueryValidatorRequestSDKType): QueryValidatorRequest { + return { + validatorAddr: object?.validator_addr + }; + }, + fromSDKJSON(object: any): QueryValidatorRequestSDKType { + return { + validator_addr: isSet(object.validator_addr) ? String(object.validator_addr) : "" + }; + }, + toSDK(message: QueryValidatorRequest): QueryValidatorRequestSDKType { + const obj: any = {}; + obj.validator_addr = message.validatorAddr; + return obj; + }, + fromAmino(object: QueryValidatorRequestAmino): QueryValidatorRequest { + const message = createBaseQueryValidatorRequest(); + if (object.validator_addr !== undefined && object.validator_addr !== null) { + message.validatorAddr = object.validator_addr; + } + return message; + }, + toAmino(message: QueryValidatorRequest): QueryValidatorRequestAmino { + const obj: any = {}; + obj.validator_addr = message.validatorAddr === "" ? undefined : message.validatorAddr; + return obj; + }, + fromAminoMsg(object: QueryValidatorRequestAminoMsg): QueryValidatorRequest { + return QueryValidatorRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryValidatorRequest): QueryValidatorRequestAminoMsg { + return { + type: "cosmos-sdk/QueryValidatorRequest", + value: QueryValidatorRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryValidatorRequestProtoMsg): QueryValidatorRequest { + return QueryValidatorRequest.decode(message.value); + }, + toProto(message: QueryValidatorRequest): Uint8Array { + return QueryValidatorRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryValidatorRequest): QueryValidatorRequestProtoMsg { + return { + typeUrl: "/cosmos.staking.v1beta1.QueryValidatorRequest", + value: QueryValidatorRequest.encode(message).finish() + }; + } +}; +function createBaseQueryValidatorResponse(): QueryValidatorResponse { + return { + validator: Validator.fromPartial({}) + }; +} +export const QueryValidatorResponse = { + typeUrl: "/cosmos.staking.v1beta1.QueryValidatorResponse", + encode(message: QueryValidatorResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.validator !== undefined) { + Validator.encode(message.validator, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryValidatorResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryValidatorResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.validator = Validator.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryValidatorResponse { + const obj = createBaseQueryValidatorResponse(); + if (isSet(object.validator)) obj.validator = Validator.fromJSON(object.validator); + return obj; + }, + toJSON(message: QueryValidatorResponse): JsonSafe { + const obj: any = {}; + message.validator !== undefined && (obj.validator = message.validator ? Validator.toJSON(message.validator) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryValidatorResponse { + const message = createBaseQueryValidatorResponse(); + if (object.validator !== undefined && object.validator !== null) { + message.validator = Validator.fromPartial(object.validator); + } + return message; + }, + fromSDK(object: QueryValidatorResponseSDKType): QueryValidatorResponse { + return { + validator: object.validator ? Validator.fromSDK(object.validator) : undefined + }; + }, + fromSDKJSON(object: any): QueryValidatorResponseSDKType { + return { + validator: isSet(object.validator) ? Validator.fromSDKJSON(object.validator) : undefined + }; + }, + toSDK(message: QueryValidatorResponse): QueryValidatorResponseSDKType { + const obj: any = {}; + message.validator !== undefined && (obj.validator = message.validator ? Validator.toSDK(message.validator) : undefined); + return obj; + }, + fromAmino(object: QueryValidatorResponseAmino): QueryValidatorResponse { + const message = createBaseQueryValidatorResponse(); + if (object.validator !== undefined && object.validator !== null) { + message.validator = Validator.fromAmino(object.validator); + } + return message; + }, + toAmino(message: QueryValidatorResponse): QueryValidatorResponseAmino { + const obj: any = {}; + obj.validator = message.validator ? Validator.toAmino(message.validator) : undefined; + return obj; + }, + fromAminoMsg(object: QueryValidatorResponseAminoMsg): QueryValidatorResponse { + return QueryValidatorResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryValidatorResponse): QueryValidatorResponseAminoMsg { + return { + type: "cosmos-sdk/QueryValidatorResponse", + value: QueryValidatorResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryValidatorResponseProtoMsg): QueryValidatorResponse { + return QueryValidatorResponse.decode(message.value); + }, + toProto(message: QueryValidatorResponse): Uint8Array { + return QueryValidatorResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryValidatorResponse): QueryValidatorResponseProtoMsg { + return { + typeUrl: "/cosmos.staking.v1beta1.QueryValidatorResponse", + value: QueryValidatorResponse.encode(message).finish() + }; + } +}; +function createBaseQueryValidatorDelegationsRequest(): QueryValidatorDelegationsRequest { + return { + validatorAddr: "", + pagination: undefined + }; +} +export const QueryValidatorDelegationsRequest = { + typeUrl: "/cosmos.staking.v1beta1.QueryValidatorDelegationsRequest", + encode(message: QueryValidatorDelegationsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.validatorAddr !== undefined) { + writer.uint32(10).string(message.validatorAddr); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryValidatorDelegationsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryValidatorDelegationsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.validatorAddr = reader.string(); + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryValidatorDelegationsRequest { + const obj = createBaseQueryValidatorDelegationsRequest(); + if (isSet(object.validatorAddr)) obj.validatorAddr = String(object.validatorAddr); + if (isSet(object.pagination)) obj.pagination = PageRequest.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryValidatorDelegationsRequest): JsonSafe { + const obj: any = {}; + message.validatorAddr !== undefined && (obj.validatorAddr = message.validatorAddr); + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryValidatorDelegationsRequest { + const message = createBaseQueryValidatorDelegationsRequest(); + message.validatorAddr = object.validatorAddr ?? ""; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryValidatorDelegationsRequestSDKType): QueryValidatorDelegationsRequest { + return { + validatorAddr: object?.validator_addr, + pagination: object.pagination ? PageRequest.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryValidatorDelegationsRequestSDKType { + return { + validator_addr: isSet(object.validator_addr) ? String(object.validator_addr) : "", + pagination: isSet(object.pagination) ? PageRequest.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryValidatorDelegationsRequest): QueryValidatorDelegationsRequestSDKType { + const obj: any = {}; + obj.validator_addr = message.validatorAddr; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryValidatorDelegationsRequestAmino): QueryValidatorDelegationsRequest { + const message = createBaseQueryValidatorDelegationsRequest(); + if (object.validator_addr !== undefined && object.validator_addr !== null) { + message.validatorAddr = object.validator_addr; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryValidatorDelegationsRequest): QueryValidatorDelegationsRequestAmino { + const obj: any = {}; + obj.validator_addr = message.validatorAddr === "" ? undefined : message.validatorAddr; + obj.pagination = message.pagination ? PageRequest.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryValidatorDelegationsRequestAminoMsg): QueryValidatorDelegationsRequest { + return QueryValidatorDelegationsRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryValidatorDelegationsRequest): QueryValidatorDelegationsRequestAminoMsg { + return { + type: "cosmos-sdk/QueryValidatorDelegationsRequest", + value: QueryValidatorDelegationsRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryValidatorDelegationsRequestProtoMsg): QueryValidatorDelegationsRequest { + return QueryValidatorDelegationsRequest.decode(message.value); + }, + toProto(message: QueryValidatorDelegationsRequest): Uint8Array { + return QueryValidatorDelegationsRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryValidatorDelegationsRequest): QueryValidatorDelegationsRequestProtoMsg { + return { + typeUrl: "/cosmos.staking.v1beta1.QueryValidatorDelegationsRequest", + value: QueryValidatorDelegationsRequest.encode(message).finish() + }; + } +}; +function createBaseQueryValidatorDelegationsResponse(): QueryValidatorDelegationsResponse { + return { + delegationResponses: [], + pagination: undefined + }; +} +export const QueryValidatorDelegationsResponse = { + typeUrl: "/cosmos.staking.v1beta1.QueryValidatorDelegationsResponse", + encode(message: QueryValidatorDelegationsResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.delegationResponses) { + DelegationResponse.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryValidatorDelegationsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryValidatorDelegationsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.delegationResponses.push(DelegationResponse.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryValidatorDelegationsResponse { + const obj = createBaseQueryValidatorDelegationsResponse(); + if (Array.isArray(object?.delegationResponses)) obj.delegationResponses = object.delegationResponses.map((e: any) => DelegationResponse.fromJSON(e)); + if (isSet(object.pagination)) obj.pagination = PageResponse.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryValidatorDelegationsResponse): JsonSafe { + const obj: any = {}; + if (message.delegationResponses) { + obj.delegationResponses = message.delegationResponses.map(e => e ? DelegationResponse.toJSON(e) : undefined); + } else { + obj.delegationResponses = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryValidatorDelegationsResponse { + const message = createBaseQueryValidatorDelegationsResponse(); + message.delegationResponses = object.delegationResponses?.map(e => DelegationResponse.fromPartial(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryValidatorDelegationsResponseSDKType): QueryValidatorDelegationsResponse { + return { + delegationResponses: Array.isArray(object?.delegation_responses) ? object.delegation_responses.map((e: any) => DelegationResponse.fromSDK(e)) : [], + pagination: object.pagination ? PageResponse.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryValidatorDelegationsResponseSDKType { + return { + delegation_responses: Array.isArray(object?.delegation_responses) ? object.delegation_responses.map((e: any) => DelegationResponse.fromSDKJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryValidatorDelegationsResponse): QueryValidatorDelegationsResponseSDKType { + const obj: any = {}; + if (message.delegationResponses) { + obj.delegation_responses = message.delegationResponses.map(e => e ? DelegationResponse.toSDK(e) : undefined); + } else { + obj.delegation_responses = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryValidatorDelegationsResponseAmino): QueryValidatorDelegationsResponse { + const message = createBaseQueryValidatorDelegationsResponse(); + message.delegationResponses = object.delegation_responses?.map(e => DelegationResponse.fromAmino(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryValidatorDelegationsResponse): QueryValidatorDelegationsResponseAmino { + const obj: any = {}; + if (message.delegationResponses) { + obj.delegation_responses = message.delegationResponses.map(e => e ? DelegationResponse.toAmino(e) : undefined); + } else { + obj.delegation_responses = message.delegationResponses; + } + obj.pagination = message.pagination ? PageResponse.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryValidatorDelegationsResponseAminoMsg): QueryValidatorDelegationsResponse { + return QueryValidatorDelegationsResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryValidatorDelegationsResponse): QueryValidatorDelegationsResponseAminoMsg { + return { + type: "cosmos-sdk/QueryValidatorDelegationsResponse", + value: QueryValidatorDelegationsResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryValidatorDelegationsResponseProtoMsg): QueryValidatorDelegationsResponse { + return QueryValidatorDelegationsResponse.decode(message.value); + }, + toProto(message: QueryValidatorDelegationsResponse): Uint8Array { + return QueryValidatorDelegationsResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryValidatorDelegationsResponse): QueryValidatorDelegationsResponseProtoMsg { + return { + typeUrl: "/cosmos.staking.v1beta1.QueryValidatorDelegationsResponse", + value: QueryValidatorDelegationsResponse.encode(message).finish() + }; + } +}; +function createBaseQueryValidatorUnbondingDelegationsRequest(): QueryValidatorUnbondingDelegationsRequest { + return { + validatorAddr: "", + pagination: undefined + }; +} +export const QueryValidatorUnbondingDelegationsRequest = { + typeUrl: "/cosmos.staking.v1beta1.QueryValidatorUnbondingDelegationsRequest", + encode(message: QueryValidatorUnbondingDelegationsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.validatorAddr !== undefined) { + writer.uint32(10).string(message.validatorAddr); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryValidatorUnbondingDelegationsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryValidatorUnbondingDelegationsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.validatorAddr = reader.string(); + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryValidatorUnbondingDelegationsRequest { + const obj = createBaseQueryValidatorUnbondingDelegationsRequest(); + if (isSet(object.validatorAddr)) obj.validatorAddr = String(object.validatorAddr); + if (isSet(object.pagination)) obj.pagination = PageRequest.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryValidatorUnbondingDelegationsRequest): JsonSafe { + const obj: any = {}; + message.validatorAddr !== undefined && (obj.validatorAddr = message.validatorAddr); + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryValidatorUnbondingDelegationsRequest { + const message = createBaseQueryValidatorUnbondingDelegationsRequest(); + message.validatorAddr = object.validatorAddr ?? ""; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryValidatorUnbondingDelegationsRequestSDKType): QueryValidatorUnbondingDelegationsRequest { + return { + validatorAddr: object?.validator_addr, + pagination: object.pagination ? PageRequest.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryValidatorUnbondingDelegationsRequestSDKType { + return { + validator_addr: isSet(object.validator_addr) ? String(object.validator_addr) : "", + pagination: isSet(object.pagination) ? PageRequest.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryValidatorUnbondingDelegationsRequest): QueryValidatorUnbondingDelegationsRequestSDKType { + const obj: any = {}; + obj.validator_addr = message.validatorAddr; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryValidatorUnbondingDelegationsRequestAmino): QueryValidatorUnbondingDelegationsRequest { + const message = createBaseQueryValidatorUnbondingDelegationsRequest(); + if (object.validator_addr !== undefined && object.validator_addr !== null) { + message.validatorAddr = object.validator_addr; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryValidatorUnbondingDelegationsRequest): QueryValidatorUnbondingDelegationsRequestAmino { + const obj: any = {}; + obj.validator_addr = message.validatorAddr === "" ? undefined : message.validatorAddr; + obj.pagination = message.pagination ? PageRequest.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryValidatorUnbondingDelegationsRequestAminoMsg): QueryValidatorUnbondingDelegationsRequest { + return QueryValidatorUnbondingDelegationsRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryValidatorUnbondingDelegationsRequest): QueryValidatorUnbondingDelegationsRequestAminoMsg { + return { + type: "cosmos-sdk/QueryValidatorUnbondingDelegationsRequest", + value: QueryValidatorUnbondingDelegationsRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryValidatorUnbondingDelegationsRequestProtoMsg): QueryValidatorUnbondingDelegationsRequest { + return QueryValidatorUnbondingDelegationsRequest.decode(message.value); + }, + toProto(message: QueryValidatorUnbondingDelegationsRequest): Uint8Array { + return QueryValidatorUnbondingDelegationsRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryValidatorUnbondingDelegationsRequest): QueryValidatorUnbondingDelegationsRequestProtoMsg { + return { + typeUrl: "/cosmos.staking.v1beta1.QueryValidatorUnbondingDelegationsRequest", + value: QueryValidatorUnbondingDelegationsRequest.encode(message).finish() + }; + } +}; +function createBaseQueryValidatorUnbondingDelegationsResponse(): QueryValidatorUnbondingDelegationsResponse { + return { + unbondingResponses: [], + pagination: undefined + }; +} +export const QueryValidatorUnbondingDelegationsResponse = { + typeUrl: "/cosmos.staking.v1beta1.QueryValidatorUnbondingDelegationsResponse", + encode(message: QueryValidatorUnbondingDelegationsResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.unbondingResponses) { + UnbondingDelegation.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryValidatorUnbondingDelegationsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryValidatorUnbondingDelegationsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.unbondingResponses.push(UnbondingDelegation.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryValidatorUnbondingDelegationsResponse { + const obj = createBaseQueryValidatorUnbondingDelegationsResponse(); + if (Array.isArray(object?.unbondingResponses)) obj.unbondingResponses = object.unbondingResponses.map((e: any) => UnbondingDelegation.fromJSON(e)); + if (isSet(object.pagination)) obj.pagination = PageResponse.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryValidatorUnbondingDelegationsResponse): JsonSafe { + const obj: any = {}; + if (message.unbondingResponses) { + obj.unbondingResponses = message.unbondingResponses.map(e => e ? UnbondingDelegation.toJSON(e) : undefined); + } else { + obj.unbondingResponses = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryValidatorUnbondingDelegationsResponse { + const message = createBaseQueryValidatorUnbondingDelegationsResponse(); + message.unbondingResponses = object.unbondingResponses?.map(e => UnbondingDelegation.fromPartial(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryValidatorUnbondingDelegationsResponseSDKType): QueryValidatorUnbondingDelegationsResponse { + return { + unbondingResponses: Array.isArray(object?.unbonding_responses) ? object.unbonding_responses.map((e: any) => UnbondingDelegation.fromSDK(e)) : [], + pagination: object.pagination ? PageResponse.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryValidatorUnbondingDelegationsResponseSDKType { + return { + unbonding_responses: Array.isArray(object?.unbonding_responses) ? object.unbonding_responses.map((e: any) => UnbondingDelegation.fromSDKJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryValidatorUnbondingDelegationsResponse): QueryValidatorUnbondingDelegationsResponseSDKType { + const obj: any = {}; + if (message.unbondingResponses) { + obj.unbonding_responses = message.unbondingResponses.map(e => e ? UnbondingDelegation.toSDK(e) : undefined); + } else { + obj.unbonding_responses = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryValidatorUnbondingDelegationsResponseAmino): QueryValidatorUnbondingDelegationsResponse { + const message = createBaseQueryValidatorUnbondingDelegationsResponse(); + message.unbondingResponses = object.unbonding_responses?.map(e => UnbondingDelegation.fromAmino(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryValidatorUnbondingDelegationsResponse): QueryValidatorUnbondingDelegationsResponseAmino { + const obj: any = {}; + if (message.unbondingResponses) { + obj.unbonding_responses = message.unbondingResponses.map(e => e ? UnbondingDelegation.toAmino(e) : undefined); + } else { + obj.unbonding_responses = message.unbondingResponses; + } + obj.pagination = message.pagination ? PageResponse.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryValidatorUnbondingDelegationsResponseAminoMsg): QueryValidatorUnbondingDelegationsResponse { + return QueryValidatorUnbondingDelegationsResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryValidatorUnbondingDelegationsResponse): QueryValidatorUnbondingDelegationsResponseAminoMsg { + return { + type: "cosmos-sdk/QueryValidatorUnbondingDelegationsResponse", + value: QueryValidatorUnbondingDelegationsResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryValidatorUnbondingDelegationsResponseProtoMsg): QueryValidatorUnbondingDelegationsResponse { + return QueryValidatorUnbondingDelegationsResponse.decode(message.value); + }, + toProto(message: QueryValidatorUnbondingDelegationsResponse): Uint8Array { + return QueryValidatorUnbondingDelegationsResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryValidatorUnbondingDelegationsResponse): QueryValidatorUnbondingDelegationsResponseProtoMsg { + return { + typeUrl: "/cosmos.staking.v1beta1.QueryValidatorUnbondingDelegationsResponse", + value: QueryValidatorUnbondingDelegationsResponse.encode(message).finish() + }; + } +}; +function createBaseQueryDelegationRequest(): QueryDelegationRequest { + return { + delegatorAddr: "", + validatorAddr: "" + }; +} +export const QueryDelegationRequest = { + typeUrl: "/cosmos.staking.v1beta1.QueryDelegationRequest", + encode(message: QueryDelegationRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.delegatorAddr !== undefined) { + writer.uint32(10).string(message.delegatorAddr); + } + if (message.validatorAddr !== undefined) { + writer.uint32(18).string(message.validatorAddr); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryDelegationRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryDelegationRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.delegatorAddr = reader.string(); + break; + case 2: + message.validatorAddr = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryDelegationRequest { + const obj = createBaseQueryDelegationRequest(); + if (isSet(object.delegatorAddr)) obj.delegatorAddr = String(object.delegatorAddr); + if (isSet(object.validatorAddr)) obj.validatorAddr = String(object.validatorAddr); + return obj; + }, + toJSON(message: QueryDelegationRequest): JsonSafe { + const obj: any = {}; + message.delegatorAddr !== undefined && (obj.delegatorAddr = message.delegatorAddr); + message.validatorAddr !== undefined && (obj.validatorAddr = message.validatorAddr); + return obj; + }, + fromPartial(object: DeepPartial): QueryDelegationRequest { + const message = createBaseQueryDelegationRequest(); + message.delegatorAddr = object.delegatorAddr ?? ""; + message.validatorAddr = object.validatorAddr ?? ""; + return message; + }, + fromSDK(object: QueryDelegationRequestSDKType): QueryDelegationRequest { + return { + delegatorAddr: object?.delegator_addr, + validatorAddr: object?.validator_addr + }; + }, + fromSDKJSON(object: any): QueryDelegationRequestSDKType { + return { + delegator_addr: isSet(object.delegator_addr) ? String(object.delegator_addr) : "", + validator_addr: isSet(object.validator_addr) ? String(object.validator_addr) : "" + }; + }, + toSDK(message: QueryDelegationRequest): QueryDelegationRequestSDKType { + const obj: any = {}; + obj.delegator_addr = message.delegatorAddr; + obj.validator_addr = message.validatorAddr; + return obj; + }, + fromAmino(object: QueryDelegationRequestAmino): QueryDelegationRequest { + const message = createBaseQueryDelegationRequest(); + if (object.delegator_addr !== undefined && object.delegator_addr !== null) { + message.delegatorAddr = object.delegator_addr; + } + if (object.validator_addr !== undefined && object.validator_addr !== null) { + message.validatorAddr = object.validator_addr; + } + return message; + }, + toAmino(message: QueryDelegationRequest): QueryDelegationRequestAmino { + const obj: any = {}; + obj.delegator_addr = message.delegatorAddr === "" ? undefined : message.delegatorAddr; + obj.validator_addr = message.validatorAddr === "" ? undefined : message.validatorAddr; + return obj; + }, + fromAminoMsg(object: QueryDelegationRequestAminoMsg): QueryDelegationRequest { + return QueryDelegationRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryDelegationRequest): QueryDelegationRequestAminoMsg { + return { + type: "cosmos-sdk/QueryDelegationRequest", + value: QueryDelegationRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryDelegationRequestProtoMsg): QueryDelegationRequest { + return QueryDelegationRequest.decode(message.value); + }, + toProto(message: QueryDelegationRequest): Uint8Array { + return QueryDelegationRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryDelegationRequest): QueryDelegationRequestProtoMsg { + return { + typeUrl: "/cosmos.staking.v1beta1.QueryDelegationRequest", + value: QueryDelegationRequest.encode(message).finish() + }; + } +}; +function createBaseQueryDelegationResponse(): QueryDelegationResponse { + return { + delegationResponse: undefined + }; +} +export const QueryDelegationResponse = { + typeUrl: "/cosmos.staking.v1beta1.QueryDelegationResponse", + encode(message: QueryDelegationResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.delegationResponse !== undefined) { + DelegationResponse.encode(message.delegationResponse, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryDelegationResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryDelegationResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.delegationResponse = DelegationResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryDelegationResponse { + const obj = createBaseQueryDelegationResponse(); + if (isSet(object.delegationResponse)) obj.delegationResponse = DelegationResponse.fromJSON(object.delegationResponse); + return obj; + }, + toJSON(message: QueryDelegationResponse): JsonSafe { + const obj: any = {}; + message.delegationResponse !== undefined && (obj.delegationResponse = message.delegationResponse ? DelegationResponse.toJSON(message.delegationResponse) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryDelegationResponse { + const message = createBaseQueryDelegationResponse(); + if (object.delegationResponse !== undefined && object.delegationResponse !== null) { + message.delegationResponse = DelegationResponse.fromPartial(object.delegationResponse); + } + return message; + }, + fromSDK(object: QueryDelegationResponseSDKType): QueryDelegationResponse { + return { + delegationResponse: object.delegation_response ? DelegationResponse.fromSDK(object.delegation_response) : undefined + }; + }, + fromSDKJSON(object: any): QueryDelegationResponseSDKType { + return { + delegation_response: isSet(object.delegation_response) ? DelegationResponse.fromSDKJSON(object.delegation_response) : undefined + }; + }, + toSDK(message: QueryDelegationResponse): QueryDelegationResponseSDKType { + const obj: any = {}; + message.delegationResponse !== undefined && (obj.delegation_response = message.delegationResponse ? DelegationResponse.toSDK(message.delegationResponse) : undefined); + return obj; + }, + fromAmino(object: QueryDelegationResponseAmino): QueryDelegationResponse { + const message = createBaseQueryDelegationResponse(); + if (object.delegation_response !== undefined && object.delegation_response !== null) { + message.delegationResponse = DelegationResponse.fromAmino(object.delegation_response); + } + return message; + }, + toAmino(message: QueryDelegationResponse): QueryDelegationResponseAmino { + const obj: any = {}; + obj.delegation_response = message.delegationResponse ? DelegationResponse.toAmino(message.delegationResponse) : undefined; + return obj; + }, + fromAminoMsg(object: QueryDelegationResponseAminoMsg): QueryDelegationResponse { + return QueryDelegationResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryDelegationResponse): QueryDelegationResponseAminoMsg { + return { + type: "cosmos-sdk/QueryDelegationResponse", + value: QueryDelegationResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryDelegationResponseProtoMsg): QueryDelegationResponse { + return QueryDelegationResponse.decode(message.value); + }, + toProto(message: QueryDelegationResponse): Uint8Array { + return QueryDelegationResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryDelegationResponse): QueryDelegationResponseProtoMsg { + return { + typeUrl: "/cosmos.staking.v1beta1.QueryDelegationResponse", + value: QueryDelegationResponse.encode(message).finish() + }; + } +}; +function createBaseQueryUnbondingDelegationRequest(): QueryUnbondingDelegationRequest { + return { + delegatorAddr: "", + validatorAddr: "" + }; +} +export const QueryUnbondingDelegationRequest = { + typeUrl: "/cosmos.staking.v1beta1.QueryUnbondingDelegationRequest", + encode(message: QueryUnbondingDelegationRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.delegatorAddr !== undefined) { + writer.uint32(10).string(message.delegatorAddr); + } + if (message.validatorAddr !== undefined) { + writer.uint32(18).string(message.validatorAddr); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryUnbondingDelegationRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryUnbondingDelegationRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.delegatorAddr = reader.string(); + break; + case 2: + message.validatorAddr = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryUnbondingDelegationRequest { + const obj = createBaseQueryUnbondingDelegationRequest(); + if (isSet(object.delegatorAddr)) obj.delegatorAddr = String(object.delegatorAddr); + if (isSet(object.validatorAddr)) obj.validatorAddr = String(object.validatorAddr); + return obj; + }, + toJSON(message: QueryUnbondingDelegationRequest): JsonSafe { + const obj: any = {}; + message.delegatorAddr !== undefined && (obj.delegatorAddr = message.delegatorAddr); + message.validatorAddr !== undefined && (obj.validatorAddr = message.validatorAddr); + return obj; + }, + fromPartial(object: DeepPartial): QueryUnbondingDelegationRequest { + const message = createBaseQueryUnbondingDelegationRequest(); + message.delegatorAddr = object.delegatorAddr ?? ""; + message.validatorAddr = object.validatorAddr ?? ""; + return message; + }, + fromSDK(object: QueryUnbondingDelegationRequestSDKType): QueryUnbondingDelegationRequest { + return { + delegatorAddr: object?.delegator_addr, + validatorAddr: object?.validator_addr + }; + }, + fromSDKJSON(object: any): QueryUnbondingDelegationRequestSDKType { + return { + delegator_addr: isSet(object.delegator_addr) ? String(object.delegator_addr) : "", + validator_addr: isSet(object.validator_addr) ? String(object.validator_addr) : "" + }; + }, + toSDK(message: QueryUnbondingDelegationRequest): QueryUnbondingDelegationRequestSDKType { + const obj: any = {}; + obj.delegator_addr = message.delegatorAddr; + obj.validator_addr = message.validatorAddr; + return obj; + }, + fromAmino(object: QueryUnbondingDelegationRequestAmino): QueryUnbondingDelegationRequest { + const message = createBaseQueryUnbondingDelegationRequest(); + if (object.delegator_addr !== undefined && object.delegator_addr !== null) { + message.delegatorAddr = object.delegator_addr; + } + if (object.validator_addr !== undefined && object.validator_addr !== null) { + message.validatorAddr = object.validator_addr; + } + return message; + }, + toAmino(message: QueryUnbondingDelegationRequest): QueryUnbondingDelegationRequestAmino { + const obj: any = {}; + obj.delegator_addr = message.delegatorAddr === "" ? undefined : message.delegatorAddr; + obj.validator_addr = message.validatorAddr === "" ? undefined : message.validatorAddr; + return obj; + }, + fromAminoMsg(object: QueryUnbondingDelegationRequestAminoMsg): QueryUnbondingDelegationRequest { + return QueryUnbondingDelegationRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryUnbondingDelegationRequest): QueryUnbondingDelegationRequestAminoMsg { + return { + type: "cosmos-sdk/QueryUnbondingDelegationRequest", + value: QueryUnbondingDelegationRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryUnbondingDelegationRequestProtoMsg): QueryUnbondingDelegationRequest { + return QueryUnbondingDelegationRequest.decode(message.value); + }, + toProto(message: QueryUnbondingDelegationRequest): Uint8Array { + return QueryUnbondingDelegationRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryUnbondingDelegationRequest): QueryUnbondingDelegationRequestProtoMsg { + return { + typeUrl: "/cosmos.staking.v1beta1.QueryUnbondingDelegationRequest", + value: QueryUnbondingDelegationRequest.encode(message).finish() + }; + } +}; +function createBaseQueryUnbondingDelegationResponse(): QueryUnbondingDelegationResponse { + return { + unbond: UnbondingDelegation.fromPartial({}) + }; +} +export const QueryUnbondingDelegationResponse = { + typeUrl: "/cosmos.staking.v1beta1.QueryUnbondingDelegationResponse", + encode(message: QueryUnbondingDelegationResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.unbond !== undefined) { + UnbondingDelegation.encode(message.unbond, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryUnbondingDelegationResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryUnbondingDelegationResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.unbond = UnbondingDelegation.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryUnbondingDelegationResponse { + const obj = createBaseQueryUnbondingDelegationResponse(); + if (isSet(object.unbond)) obj.unbond = UnbondingDelegation.fromJSON(object.unbond); + return obj; + }, + toJSON(message: QueryUnbondingDelegationResponse): JsonSafe { + const obj: any = {}; + message.unbond !== undefined && (obj.unbond = message.unbond ? UnbondingDelegation.toJSON(message.unbond) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryUnbondingDelegationResponse { + const message = createBaseQueryUnbondingDelegationResponse(); + if (object.unbond !== undefined && object.unbond !== null) { + message.unbond = UnbondingDelegation.fromPartial(object.unbond); + } + return message; + }, + fromSDK(object: QueryUnbondingDelegationResponseSDKType): QueryUnbondingDelegationResponse { + return { + unbond: object.unbond ? UnbondingDelegation.fromSDK(object.unbond) : undefined + }; + }, + fromSDKJSON(object: any): QueryUnbondingDelegationResponseSDKType { + return { + unbond: isSet(object.unbond) ? UnbondingDelegation.fromSDKJSON(object.unbond) : undefined + }; + }, + toSDK(message: QueryUnbondingDelegationResponse): QueryUnbondingDelegationResponseSDKType { + const obj: any = {}; + message.unbond !== undefined && (obj.unbond = message.unbond ? UnbondingDelegation.toSDK(message.unbond) : undefined); + return obj; + }, + fromAmino(object: QueryUnbondingDelegationResponseAmino): QueryUnbondingDelegationResponse { + const message = createBaseQueryUnbondingDelegationResponse(); + if (object.unbond !== undefined && object.unbond !== null) { + message.unbond = UnbondingDelegation.fromAmino(object.unbond); + } + return message; + }, + toAmino(message: QueryUnbondingDelegationResponse): QueryUnbondingDelegationResponseAmino { + const obj: any = {}; + obj.unbond = message.unbond ? UnbondingDelegation.toAmino(message.unbond) : undefined; + return obj; + }, + fromAminoMsg(object: QueryUnbondingDelegationResponseAminoMsg): QueryUnbondingDelegationResponse { + return QueryUnbondingDelegationResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryUnbondingDelegationResponse): QueryUnbondingDelegationResponseAminoMsg { + return { + type: "cosmos-sdk/QueryUnbondingDelegationResponse", + value: QueryUnbondingDelegationResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryUnbondingDelegationResponseProtoMsg): QueryUnbondingDelegationResponse { + return QueryUnbondingDelegationResponse.decode(message.value); + }, + toProto(message: QueryUnbondingDelegationResponse): Uint8Array { + return QueryUnbondingDelegationResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryUnbondingDelegationResponse): QueryUnbondingDelegationResponseProtoMsg { + return { + typeUrl: "/cosmos.staking.v1beta1.QueryUnbondingDelegationResponse", + value: QueryUnbondingDelegationResponse.encode(message).finish() + }; + } +}; +function createBaseQueryDelegatorDelegationsRequest(): QueryDelegatorDelegationsRequest { + return { + delegatorAddr: "", + pagination: undefined + }; +} +export const QueryDelegatorDelegationsRequest = { + typeUrl: "/cosmos.staking.v1beta1.QueryDelegatorDelegationsRequest", + encode(message: QueryDelegatorDelegationsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.delegatorAddr !== undefined) { + writer.uint32(10).string(message.delegatorAddr); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryDelegatorDelegationsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryDelegatorDelegationsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.delegatorAddr = reader.string(); + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryDelegatorDelegationsRequest { + const obj = createBaseQueryDelegatorDelegationsRequest(); + if (isSet(object.delegatorAddr)) obj.delegatorAddr = String(object.delegatorAddr); + if (isSet(object.pagination)) obj.pagination = PageRequest.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryDelegatorDelegationsRequest): JsonSafe { + const obj: any = {}; + message.delegatorAddr !== undefined && (obj.delegatorAddr = message.delegatorAddr); + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryDelegatorDelegationsRequest { + const message = createBaseQueryDelegatorDelegationsRequest(); + message.delegatorAddr = object.delegatorAddr ?? ""; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryDelegatorDelegationsRequestSDKType): QueryDelegatorDelegationsRequest { + return { + delegatorAddr: object?.delegator_addr, + pagination: object.pagination ? PageRequest.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryDelegatorDelegationsRequestSDKType { + return { + delegator_addr: isSet(object.delegator_addr) ? String(object.delegator_addr) : "", + pagination: isSet(object.pagination) ? PageRequest.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryDelegatorDelegationsRequest): QueryDelegatorDelegationsRequestSDKType { + const obj: any = {}; + obj.delegator_addr = message.delegatorAddr; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryDelegatorDelegationsRequestAmino): QueryDelegatorDelegationsRequest { + const message = createBaseQueryDelegatorDelegationsRequest(); + if (object.delegator_addr !== undefined && object.delegator_addr !== null) { + message.delegatorAddr = object.delegator_addr; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryDelegatorDelegationsRequest): QueryDelegatorDelegationsRequestAmino { + const obj: any = {}; + obj.delegator_addr = message.delegatorAddr === "" ? undefined : message.delegatorAddr; + obj.pagination = message.pagination ? PageRequest.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryDelegatorDelegationsRequestAminoMsg): QueryDelegatorDelegationsRequest { + return QueryDelegatorDelegationsRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryDelegatorDelegationsRequest): QueryDelegatorDelegationsRequestAminoMsg { + return { + type: "cosmos-sdk/QueryDelegatorDelegationsRequest", + value: QueryDelegatorDelegationsRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryDelegatorDelegationsRequestProtoMsg): QueryDelegatorDelegationsRequest { + return QueryDelegatorDelegationsRequest.decode(message.value); + }, + toProto(message: QueryDelegatorDelegationsRequest): Uint8Array { + return QueryDelegatorDelegationsRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryDelegatorDelegationsRequest): QueryDelegatorDelegationsRequestProtoMsg { + return { + typeUrl: "/cosmos.staking.v1beta1.QueryDelegatorDelegationsRequest", + value: QueryDelegatorDelegationsRequest.encode(message).finish() + }; + } +}; +function createBaseQueryDelegatorDelegationsResponse(): QueryDelegatorDelegationsResponse { + return { + delegationResponses: [], + pagination: undefined + }; +} +export const QueryDelegatorDelegationsResponse = { + typeUrl: "/cosmos.staking.v1beta1.QueryDelegatorDelegationsResponse", + encode(message: QueryDelegatorDelegationsResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.delegationResponses) { + DelegationResponse.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryDelegatorDelegationsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryDelegatorDelegationsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.delegationResponses.push(DelegationResponse.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryDelegatorDelegationsResponse { + const obj = createBaseQueryDelegatorDelegationsResponse(); + if (Array.isArray(object?.delegationResponses)) obj.delegationResponses = object.delegationResponses.map((e: any) => DelegationResponse.fromJSON(e)); + if (isSet(object.pagination)) obj.pagination = PageResponse.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryDelegatorDelegationsResponse): JsonSafe { + const obj: any = {}; + if (message.delegationResponses) { + obj.delegationResponses = message.delegationResponses.map(e => e ? DelegationResponse.toJSON(e) : undefined); + } else { + obj.delegationResponses = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryDelegatorDelegationsResponse { + const message = createBaseQueryDelegatorDelegationsResponse(); + message.delegationResponses = object.delegationResponses?.map(e => DelegationResponse.fromPartial(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryDelegatorDelegationsResponseSDKType): QueryDelegatorDelegationsResponse { + return { + delegationResponses: Array.isArray(object?.delegation_responses) ? object.delegation_responses.map((e: any) => DelegationResponse.fromSDK(e)) : [], + pagination: object.pagination ? PageResponse.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryDelegatorDelegationsResponseSDKType { + return { + delegation_responses: Array.isArray(object?.delegation_responses) ? object.delegation_responses.map((e: any) => DelegationResponse.fromSDKJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryDelegatorDelegationsResponse): QueryDelegatorDelegationsResponseSDKType { + const obj: any = {}; + if (message.delegationResponses) { + obj.delegation_responses = message.delegationResponses.map(e => e ? DelegationResponse.toSDK(e) : undefined); + } else { + obj.delegation_responses = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryDelegatorDelegationsResponseAmino): QueryDelegatorDelegationsResponse { + const message = createBaseQueryDelegatorDelegationsResponse(); + message.delegationResponses = object.delegation_responses?.map(e => DelegationResponse.fromAmino(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryDelegatorDelegationsResponse): QueryDelegatorDelegationsResponseAmino { + const obj: any = {}; + if (message.delegationResponses) { + obj.delegation_responses = message.delegationResponses.map(e => e ? DelegationResponse.toAmino(e) : undefined); + } else { + obj.delegation_responses = message.delegationResponses; + } + obj.pagination = message.pagination ? PageResponse.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryDelegatorDelegationsResponseAminoMsg): QueryDelegatorDelegationsResponse { + return QueryDelegatorDelegationsResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryDelegatorDelegationsResponse): QueryDelegatorDelegationsResponseAminoMsg { + return { + type: "cosmos-sdk/QueryDelegatorDelegationsResponse", + value: QueryDelegatorDelegationsResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryDelegatorDelegationsResponseProtoMsg): QueryDelegatorDelegationsResponse { + return QueryDelegatorDelegationsResponse.decode(message.value); + }, + toProto(message: QueryDelegatorDelegationsResponse): Uint8Array { + return QueryDelegatorDelegationsResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryDelegatorDelegationsResponse): QueryDelegatorDelegationsResponseProtoMsg { + return { + typeUrl: "/cosmos.staking.v1beta1.QueryDelegatorDelegationsResponse", + value: QueryDelegatorDelegationsResponse.encode(message).finish() + }; + } +}; +function createBaseQueryDelegatorUnbondingDelegationsRequest(): QueryDelegatorUnbondingDelegationsRequest { + return { + delegatorAddr: "", + pagination: undefined + }; +} +export const QueryDelegatorUnbondingDelegationsRequest = { + typeUrl: "/cosmos.staking.v1beta1.QueryDelegatorUnbondingDelegationsRequest", + encode(message: QueryDelegatorUnbondingDelegationsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.delegatorAddr !== undefined) { + writer.uint32(10).string(message.delegatorAddr); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryDelegatorUnbondingDelegationsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryDelegatorUnbondingDelegationsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.delegatorAddr = reader.string(); + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryDelegatorUnbondingDelegationsRequest { + const obj = createBaseQueryDelegatorUnbondingDelegationsRequest(); + if (isSet(object.delegatorAddr)) obj.delegatorAddr = String(object.delegatorAddr); + if (isSet(object.pagination)) obj.pagination = PageRequest.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryDelegatorUnbondingDelegationsRequest): JsonSafe { + const obj: any = {}; + message.delegatorAddr !== undefined && (obj.delegatorAddr = message.delegatorAddr); + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryDelegatorUnbondingDelegationsRequest { + const message = createBaseQueryDelegatorUnbondingDelegationsRequest(); + message.delegatorAddr = object.delegatorAddr ?? ""; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryDelegatorUnbondingDelegationsRequestSDKType): QueryDelegatorUnbondingDelegationsRequest { + return { + delegatorAddr: object?.delegator_addr, + pagination: object.pagination ? PageRequest.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryDelegatorUnbondingDelegationsRequestSDKType { + return { + delegator_addr: isSet(object.delegator_addr) ? String(object.delegator_addr) : "", + pagination: isSet(object.pagination) ? PageRequest.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryDelegatorUnbondingDelegationsRequest): QueryDelegatorUnbondingDelegationsRequestSDKType { + const obj: any = {}; + obj.delegator_addr = message.delegatorAddr; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryDelegatorUnbondingDelegationsRequestAmino): QueryDelegatorUnbondingDelegationsRequest { + const message = createBaseQueryDelegatorUnbondingDelegationsRequest(); + if (object.delegator_addr !== undefined && object.delegator_addr !== null) { + message.delegatorAddr = object.delegator_addr; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryDelegatorUnbondingDelegationsRequest): QueryDelegatorUnbondingDelegationsRequestAmino { + const obj: any = {}; + obj.delegator_addr = message.delegatorAddr === "" ? undefined : message.delegatorAddr; + obj.pagination = message.pagination ? PageRequest.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryDelegatorUnbondingDelegationsRequestAminoMsg): QueryDelegatorUnbondingDelegationsRequest { + return QueryDelegatorUnbondingDelegationsRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryDelegatorUnbondingDelegationsRequest): QueryDelegatorUnbondingDelegationsRequestAminoMsg { + return { + type: "cosmos-sdk/QueryDelegatorUnbondingDelegationsRequest", + value: QueryDelegatorUnbondingDelegationsRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryDelegatorUnbondingDelegationsRequestProtoMsg): QueryDelegatorUnbondingDelegationsRequest { + return QueryDelegatorUnbondingDelegationsRequest.decode(message.value); + }, + toProto(message: QueryDelegatorUnbondingDelegationsRequest): Uint8Array { + return QueryDelegatorUnbondingDelegationsRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryDelegatorUnbondingDelegationsRequest): QueryDelegatorUnbondingDelegationsRequestProtoMsg { + return { + typeUrl: "/cosmos.staking.v1beta1.QueryDelegatorUnbondingDelegationsRequest", + value: QueryDelegatorUnbondingDelegationsRequest.encode(message).finish() + }; + } +}; +function createBaseQueryDelegatorUnbondingDelegationsResponse(): QueryDelegatorUnbondingDelegationsResponse { + return { + unbondingResponses: [], + pagination: undefined + }; +} +export const QueryDelegatorUnbondingDelegationsResponse = { + typeUrl: "/cosmos.staking.v1beta1.QueryDelegatorUnbondingDelegationsResponse", + encode(message: QueryDelegatorUnbondingDelegationsResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.unbondingResponses) { + UnbondingDelegation.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryDelegatorUnbondingDelegationsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryDelegatorUnbondingDelegationsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.unbondingResponses.push(UnbondingDelegation.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryDelegatorUnbondingDelegationsResponse { + const obj = createBaseQueryDelegatorUnbondingDelegationsResponse(); + if (Array.isArray(object?.unbondingResponses)) obj.unbondingResponses = object.unbondingResponses.map((e: any) => UnbondingDelegation.fromJSON(e)); + if (isSet(object.pagination)) obj.pagination = PageResponse.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryDelegatorUnbondingDelegationsResponse): JsonSafe { + const obj: any = {}; + if (message.unbondingResponses) { + obj.unbondingResponses = message.unbondingResponses.map(e => e ? UnbondingDelegation.toJSON(e) : undefined); + } else { + obj.unbondingResponses = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryDelegatorUnbondingDelegationsResponse { + const message = createBaseQueryDelegatorUnbondingDelegationsResponse(); + message.unbondingResponses = object.unbondingResponses?.map(e => UnbondingDelegation.fromPartial(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryDelegatorUnbondingDelegationsResponseSDKType): QueryDelegatorUnbondingDelegationsResponse { + return { + unbondingResponses: Array.isArray(object?.unbonding_responses) ? object.unbonding_responses.map((e: any) => UnbondingDelegation.fromSDK(e)) : [], + pagination: object.pagination ? PageResponse.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryDelegatorUnbondingDelegationsResponseSDKType { + return { + unbonding_responses: Array.isArray(object?.unbonding_responses) ? object.unbonding_responses.map((e: any) => UnbondingDelegation.fromSDKJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryDelegatorUnbondingDelegationsResponse): QueryDelegatorUnbondingDelegationsResponseSDKType { + const obj: any = {}; + if (message.unbondingResponses) { + obj.unbonding_responses = message.unbondingResponses.map(e => e ? UnbondingDelegation.toSDK(e) : undefined); + } else { + obj.unbonding_responses = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryDelegatorUnbondingDelegationsResponseAmino): QueryDelegatorUnbondingDelegationsResponse { + const message = createBaseQueryDelegatorUnbondingDelegationsResponse(); + message.unbondingResponses = object.unbonding_responses?.map(e => UnbondingDelegation.fromAmino(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryDelegatorUnbondingDelegationsResponse): QueryDelegatorUnbondingDelegationsResponseAmino { + const obj: any = {}; + if (message.unbondingResponses) { + obj.unbonding_responses = message.unbondingResponses.map(e => e ? UnbondingDelegation.toAmino(e) : undefined); + } else { + obj.unbonding_responses = message.unbondingResponses; + } + obj.pagination = message.pagination ? PageResponse.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryDelegatorUnbondingDelegationsResponseAminoMsg): QueryDelegatorUnbondingDelegationsResponse { + return QueryDelegatorUnbondingDelegationsResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryDelegatorUnbondingDelegationsResponse): QueryDelegatorUnbondingDelegationsResponseAminoMsg { + return { + type: "cosmos-sdk/QueryDelegatorUnbondingDelegationsResponse", + value: QueryDelegatorUnbondingDelegationsResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryDelegatorUnbondingDelegationsResponseProtoMsg): QueryDelegatorUnbondingDelegationsResponse { + return QueryDelegatorUnbondingDelegationsResponse.decode(message.value); + }, + toProto(message: QueryDelegatorUnbondingDelegationsResponse): Uint8Array { + return QueryDelegatorUnbondingDelegationsResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryDelegatorUnbondingDelegationsResponse): QueryDelegatorUnbondingDelegationsResponseProtoMsg { + return { + typeUrl: "/cosmos.staking.v1beta1.QueryDelegatorUnbondingDelegationsResponse", + value: QueryDelegatorUnbondingDelegationsResponse.encode(message).finish() + }; + } +}; +function createBaseQueryRedelegationsRequest(): QueryRedelegationsRequest { + return { + delegatorAddr: "", + srcValidatorAddr: "", + dstValidatorAddr: "", + pagination: undefined + }; +} +export const QueryRedelegationsRequest = { + typeUrl: "/cosmos.staking.v1beta1.QueryRedelegationsRequest", + encode(message: QueryRedelegationsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.delegatorAddr !== undefined) { + writer.uint32(10).string(message.delegatorAddr); + } + if (message.srcValidatorAddr !== undefined) { + writer.uint32(18).string(message.srcValidatorAddr); + } + if (message.dstValidatorAddr !== undefined) { + writer.uint32(26).string(message.dstValidatorAddr); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryRedelegationsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryRedelegationsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.delegatorAddr = reader.string(); + break; + case 2: + message.srcValidatorAddr = reader.string(); + break; + case 3: + message.dstValidatorAddr = reader.string(); + break; + case 4: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryRedelegationsRequest { + const obj = createBaseQueryRedelegationsRequest(); + if (isSet(object.delegatorAddr)) obj.delegatorAddr = String(object.delegatorAddr); + if (isSet(object.srcValidatorAddr)) obj.srcValidatorAddr = String(object.srcValidatorAddr); + if (isSet(object.dstValidatorAddr)) obj.dstValidatorAddr = String(object.dstValidatorAddr); + if (isSet(object.pagination)) obj.pagination = PageRequest.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryRedelegationsRequest): JsonSafe { + const obj: any = {}; + message.delegatorAddr !== undefined && (obj.delegatorAddr = message.delegatorAddr); + message.srcValidatorAddr !== undefined && (obj.srcValidatorAddr = message.srcValidatorAddr); + message.dstValidatorAddr !== undefined && (obj.dstValidatorAddr = message.dstValidatorAddr); + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryRedelegationsRequest { + const message = createBaseQueryRedelegationsRequest(); + message.delegatorAddr = object.delegatorAddr ?? ""; + message.srcValidatorAddr = object.srcValidatorAddr ?? ""; + message.dstValidatorAddr = object.dstValidatorAddr ?? ""; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryRedelegationsRequestSDKType): QueryRedelegationsRequest { + return { + delegatorAddr: object?.delegator_addr, + srcValidatorAddr: object?.src_validator_addr, + dstValidatorAddr: object?.dst_validator_addr, + pagination: object.pagination ? PageRequest.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryRedelegationsRequestSDKType { + return { + delegator_addr: isSet(object.delegator_addr) ? String(object.delegator_addr) : "", + src_validator_addr: isSet(object.src_validator_addr) ? String(object.src_validator_addr) : "", + dst_validator_addr: isSet(object.dst_validator_addr) ? String(object.dst_validator_addr) : "", + pagination: isSet(object.pagination) ? PageRequest.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryRedelegationsRequest): QueryRedelegationsRequestSDKType { + const obj: any = {}; + obj.delegator_addr = message.delegatorAddr; + obj.src_validator_addr = message.srcValidatorAddr; + obj.dst_validator_addr = message.dstValidatorAddr; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryRedelegationsRequestAmino): QueryRedelegationsRequest { + const message = createBaseQueryRedelegationsRequest(); + if (object.delegator_addr !== undefined && object.delegator_addr !== null) { + message.delegatorAddr = object.delegator_addr; + } + if (object.src_validator_addr !== undefined && object.src_validator_addr !== null) { + message.srcValidatorAddr = object.src_validator_addr; + } + if (object.dst_validator_addr !== undefined && object.dst_validator_addr !== null) { + message.dstValidatorAddr = object.dst_validator_addr; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryRedelegationsRequest): QueryRedelegationsRequestAmino { + const obj: any = {}; + obj.delegator_addr = message.delegatorAddr === "" ? undefined : message.delegatorAddr; + obj.src_validator_addr = message.srcValidatorAddr === "" ? undefined : message.srcValidatorAddr; + obj.dst_validator_addr = message.dstValidatorAddr === "" ? undefined : message.dstValidatorAddr; + obj.pagination = message.pagination ? PageRequest.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryRedelegationsRequestAminoMsg): QueryRedelegationsRequest { + return QueryRedelegationsRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryRedelegationsRequest): QueryRedelegationsRequestAminoMsg { + return { + type: "cosmos-sdk/QueryRedelegationsRequest", + value: QueryRedelegationsRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryRedelegationsRequestProtoMsg): QueryRedelegationsRequest { + return QueryRedelegationsRequest.decode(message.value); + }, + toProto(message: QueryRedelegationsRequest): Uint8Array { + return QueryRedelegationsRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryRedelegationsRequest): QueryRedelegationsRequestProtoMsg { + return { + typeUrl: "/cosmos.staking.v1beta1.QueryRedelegationsRequest", + value: QueryRedelegationsRequest.encode(message).finish() + }; + } +}; +function createBaseQueryRedelegationsResponse(): QueryRedelegationsResponse { + return { + redelegationResponses: [], + pagination: undefined + }; +} +export const QueryRedelegationsResponse = { + typeUrl: "/cosmos.staking.v1beta1.QueryRedelegationsResponse", + encode(message: QueryRedelegationsResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.redelegationResponses) { + RedelegationResponse.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryRedelegationsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryRedelegationsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.redelegationResponses.push(RedelegationResponse.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryRedelegationsResponse { + const obj = createBaseQueryRedelegationsResponse(); + if (Array.isArray(object?.redelegationResponses)) obj.redelegationResponses = object.redelegationResponses.map((e: any) => RedelegationResponse.fromJSON(e)); + if (isSet(object.pagination)) obj.pagination = PageResponse.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryRedelegationsResponse): JsonSafe { + const obj: any = {}; + if (message.redelegationResponses) { + obj.redelegationResponses = message.redelegationResponses.map(e => e ? RedelegationResponse.toJSON(e) : undefined); + } else { + obj.redelegationResponses = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryRedelegationsResponse { + const message = createBaseQueryRedelegationsResponse(); + message.redelegationResponses = object.redelegationResponses?.map(e => RedelegationResponse.fromPartial(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryRedelegationsResponseSDKType): QueryRedelegationsResponse { + return { + redelegationResponses: Array.isArray(object?.redelegation_responses) ? object.redelegation_responses.map((e: any) => RedelegationResponse.fromSDK(e)) : [], + pagination: object.pagination ? PageResponse.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryRedelegationsResponseSDKType { + return { + redelegation_responses: Array.isArray(object?.redelegation_responses) ? object.redelegation_responses.map((e: any) => RedelegationResponse.fromSDKJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryRedelegationsResponse): QueryRedelegationsResponseSDKType { + const obj: any = {}; + if (message.redelegationResponses) { + obj.redelegation_responses = message.redelegationResponses.map(e => e ? RedelegationResponse.toSDK(e) : undefined); + } else { + obj.redelegation_responses = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryRedelegationsResponseAmino): QueryRedelegationsResponse { + const message = createBaseQueryRedelegationsResponse(); + message.redelegationResponses = object.redelegation_responses?.map(e => RedelegationResponse.fromAmino(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryRedelegationsResponse): QueryRedelegationsResponseAmino { + const obj: any = {}; + if (message.redelegationResponses) { + obj.redelegation_responses = message.redelegationResponses.map(e => e ? RedelegationResponse.toAmino(e) : undefined); + } else { + obj.redelegation_responses = message.redelegationResponses; + } + obj.pagination = message.pagination ? PageResponse.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryRedelegationsResponseAminoMsg): QueryRedelegationsResponse { + return QueryRedelegationsResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryRedelegationsResponse): QueryRedelegationsResponseAminoMsg { + return { + type: "cosmos-sdk/QueryRedelegationsResponse", + value: QueryRedelegationsResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryRedelegationsResponseProtoMsg): QueryRedelegationsResponse { + return QueryRedelegationsResponse.decode(message.value); + }, + toProto(message: QueryRedelegationsResponse): Uint8Array { + return QueryRedelegationsResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryRedelegationsResponse): QueryRedelegationsResponseProtoMsg { + return { + typeUrl: "/cosmos.staking.v1beta1.QueryRedelegationsResponse", + value: QueryRedelegationsResponse.encode(message).finish() + }; + } +}; +function createBaseQueryDelegatorValidatorsRequest(): QueryDelegatorValidatorsRequest { + return { + delegatorAddr: "", + pagination: undefined + }; +} +export const QueryDelegatorValidatorsRequest = { + typeUrl: "/cosmos.staking.v1beta1.QueryDelegatorValidatorsRequest", + encode(message: QueryDelegatorValidatorsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.delegatorAddr !== undefined) { + writer.uint32(10).string(message.delegatorAddr); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryDelegatorValidatorsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryDelegatorValidatorsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.delegatorAddr = reader.string(); + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryDelegatorValidatorsRequest { + const obj = createBaseQueryDelegatorValidatorsRequest(); + if (isSet(object.delegatorAddr)) obj.delegatorAddr = String(object.delegatorAddr); + if (isSet(object.pagination)) obj.pagination = PageRequest.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryDelegatorValidatorsRequest): JsonSafe { + const obj: any = {}; + message.delegatorAddr !== undefined && (obj.delegatorAddr = message.delegatorAddr); + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryDelegatorValidatorsRequest { + const message = createBaseQueryDelegatorValidatorsRequest(); + message.delegatorAddr = object.delegatorAddr ?? ""; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryDelegatorValidatorsRequestSDKType): QueryDelegatorValidatorsRequest { + return { + delegatorAddr: object?.delegator_addr, + pagination: object.pagination ? PageRequest.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryDelegatorValidatorsRequestSDKType { + return { + delegator_addr: isSet(object.delegator_addr) ? String(object.delegator_addr) : "", + pagination: isSet(object.pagination) ? PageRequest.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryDelegatorValidatorsRequest): QueryDelegatorValidatorsRequestSDKType { + const obj: any = {}; + obj.delegator_addr = message.delegatorAddr; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryDelegatorValidatorsRequestAmino): QueryDelegatorValidatorsRequest { + const message = createBaseQueryDelegatorValidatorsRequest(); + if (object.delegator_addr !== undefined && object.delegator_addr !== null) { + message.delegatorAddr = object.delegator_addr; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryDelegatorValidatorsRequest): QueryDelegatorValidatorsRequestAmino { + const obj: any = {}; + obj.delegator_addr = message.delegatorAddr === "" ? undefined : message.delegatorAddr; + obj.pagination = message.pagination ? PageRequest.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryDelegatorValidatorsRequestAminoMsg): QueryDelegatorValidatorsRequest { + return QueryDelegatorValidatorsRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryDelegatorValidatorsRequest): QueryDelegatorValidatorsRequestAminoMsg { + return { + type: "cosmos-sdk/QueryDelegatorValidatorsRequest", + value: QueryDelegatorValidatorsRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryDelegatorValidatorsRequestProtoMsg): QueryDelegatorValidatorsRequest { + return QueryDelegatorValidatorsRequest.decode(message.value); + }, + toProto(message: QueryDelegatorValidatorsRequest): Uint8Array { + return QueryDelegatorValidatorsRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryDelegatorValidatorsRequest): QueryDelegatorValidatorsRequestProtoMsg { + return { + typeUrl: "/cosmos.staking.v1beta1.QueryDelegatorValidatorsRequest", + value: QueryDelegatorValidatorsRequest.encode(message).finish() + }; + } +}; +function createBaseQueryDelegatorValidatorsResponse(): QueryDelegatorValidatorsResponse { + return { + validators: [], + pagination: undefined + }; +} +export const QueryDelegatorValidatorsResponse = { + typeUrl: "/cosmos.staking.v1beta1.QueryDelegatorValidatorsResponse", + encode(message: QueryDelegatorValidatorsResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.validators) { + Validator.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryDelegatorValidatorsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryDelegatorValidatorsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.validators.push(Validator.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryDelegatorValidatorsResponse { + const obj = createBaseQueryDelegatorValidatorsResponse(); + if (Array.isArray(object?.validators)) obj.validators = object.validators.map((e: any) => Validator.fromJSON(e)); + if (isSet(object.pagination)) obj.pagination = PageResponse.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryDelegatorValidatorsResponse): JsonSafe { + const obj: any = {}; + if (message.validators) { + obj.validators = message.validators.map(e => e ? Validator.toJSON(e) : undefined); + } else { + obj.validators = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryDelegatorValidatorsResponse { + const message = createBaseQueryDelegatorValidatorsResponse(); + message.validators = object.validators?.map(e => Validator.fromPartial(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryDelegatorValidatorsResponseSDKType): QueryDelegatorValidatorsResponse { + return { + validators: Array.isArray(object?.validators) ? object.validators.map((e: any) => Validator.fromSDK(e)) : [], + pagination: object.pagination ? PageResponse.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryDelegatorValidatorsResponseSDKType { + return { + validators: Array.isArray(object?.validators) ? object.validators.map((e: any) => Validator.fromSDKJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryDelegatorValidatorsResponse): QueryDelegatorValidatorsResponseSDKType { + const obj: any = {}; + if (message.validators) { + obj.validators = message.validators.map(e => e ? Validator.toSDK(e) : undefined); + } else { + obj.validators = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryDelegatorValidatorsResponseAmino): QueryDelegatorValidatorsResponse { + const message = createBaseQueryDelegatorValidatorsResponse(); + message.validators = object.validators?.map(e => Validator.fromAmino(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryDelegatorValidatorsResponse): QueryDelegatorValidatorsResponseAmino { + const obj: any = {}; + if (message.validators) { + obj.validators = message.validators.map(e => e ? Validator.toAmino(e) : undefined); + } else { + obj.validators = message.validators; + } + obj.pagination = message.pagination ? PageResponse.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryDelegatorValidatorsResponseAminoMsg): QueryDelegatorValidatorsResponse { + return QueryDelegatorValidatorsResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryDelegatorValidatorsResponse): QueryDelegatorValidatorsResponseAminoMsg { + return { + type: "cosmos-sdk/QueryDelegatorValidatorsResponse", + value: QueryDelegatorValidatorsResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryDelegatorValidatorsResponseProtoMsg): QueryDelegatorValidatorsResponse { + return QueryDelegatorValidatorsResponse.decode(message.value); + }, + toProto(message: QueryDelegatorValidatorsResponse): Uint8Array { + return QueryDelegatorValidatorsResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryDelegatorValidatorsResponse): QueryDelegatorValidatorsResponseProtoMsg { + return { + typeUrl: "/cosmos.staking.v1beta1.QueryDelegatorValidatorsResponse", + value: QueryDelegatorValidatorsResponse.encode(message).finish() + }; + } +}; +function createBaseQueryDelegatorValidatorRequest(): QueryDelegatorValidatorRequest { + return { + delegatorAddr: "", + validatorAddr: "" + }; +} +export const QueryDelegatorValidatorRequest = { + typeUrl: "/cosmos.staking.v1beta1.QueryDelegatorValidatorRequest", + encode(message: QueryDelegatorValidatorRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.delegatorAddr !== undefined) { + writer.uint32(10).string(message.delegatorAddr); + } + if (message.validatorAddr !== undefined) { + writer.uint32(18).string(message.validatorAddr); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryDelegatorValidatorRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryDelegatorValidatorRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.delegatorAddr = reader.string(); + break; + case 2: + message.validatorAddr = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryDelegatorValidatorRequest { + const obj = createBaseQueryDelegatorValidatorRequest(); + if (isSet(object.delegatorAddr)) obj.delegatorAddr = String(object.delegatorAddr); + if (isSet(object.validatorAddr)) obj.validatorAddr = String(object.validatorAddr); + return obj; + }, + toJSON(message: QueryDelegatorValidatorRequest): JsonSafe { + const obj: any = {}; + message.delegatorAddr !== undefined && (obj.delegatorAddr = message.delegatorAddr); + message.validatorAddr !== undefined && (obj.validatorAddr = message.validatorAddr); + return obj; + }, + fromPartial(object: DeepPartial): QueryDelegatorValidatorRequest { + const message = createBaseQueryDelegatorValidatorRequest(); + message.delegatorAddr = object.delegatorAddr ?? ""; + message.validatorAddr = object.validatorAddr ?? ""; + return message; + }, + fromSDK(object: QueryDelegatorValidatorRequestSDKType): QueryDelegatorValidatorRequest { + return { + delegatorAddr: object?.delegator_addr, + validatorAddr: object?.validator_addr + }; + }, + fromSDKJSON(object: any): QueryDelegatorValidatorRequestSDKType { + return { + delegator_addr: isSet(object.delegator_addr) ? String(object.delegator_addr) : "", + validator_addr: isSet(object.validator_addr) ? String(object.validator_addr) : "" + }; + }, + toSDK(message: QueryDelegatorValidatorRequest): QueryDelegatorValidatorRequestSDKType { + const obj: any = {}; + obj.delegator_addr = message.delegatorAddr; + obj.validator_addr = message.validatorAddr; + return obj; + }, + fromAmino(object: QueryDelegatorValidatorRequestAmino): QueryDelegatorValidatorRequest { + const message = createBaseQueryDelegatorValidatorRequest(); + if (object.delegator_addr !== undefined && object.delegator_addr !== null) { + message.delegatorAddr = object.delegator_addr; + } + if (object.validator_addr !== undefined && object.validator_addr !== null) { + message.validatorAddr = object.validator_addr; + } + return message; + }, + toAmino(message: QueryDelegatorValidatorRequest): QueryDelegatorValidatorRequestAmino { + const obj: any = {}; + obj.delegator_addr = message.delegatorAddr === "" ? undefined : message.delegatorAddr; + obj.validator_addr = message.validatorAddr === "" ? undefined : message.validatorAddr; + return obj; + }, + fromAminoMsg(object: QueryDelegatorValidatorRequestAminoMsg): QueryDelegatorValidatorRequest { + return QueryDelegatorValidatorRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryDelegatorValidatorRequest): QueryDelegatorValidatorRequestAminoMsg { + return { + type: "cosmos-sdk/QueryDelegatorValidatorRequest", + value: QueryDelegatorValidatorRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryDelegatorValidatorRequestProtoMsg): QueryDelegatorValidatorRequest { + return QueryDelegatorValidatorRequest.decode(message.value); + }, + toProto(message: QueryDelegatorValidatorRequest): Uint8Array { + return QueryDelegatorValidatorRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryDelegatorValidatorRequest): QueryDelegatorValidatorRequestProtoMsg { + return { + typeUrl: "/cosmos.staking.v1beta1.QueryDelegatorValidatorRequest", + value: QueryDelegatorValidatorRequest.encode(message).finish() + }; + } +}; +function createBaseQueryDelegatorValidatorResponse(): QueryDelegatorValidatorResponse { + return { + validator: Validator.fromPartial({}) + }; +} +export const QueryDelegatorValidatorResponse = { + typeUrl: "/cosmos.staking.v1beta1.QueryDelegatorValidatorResponse", + encode(message: QueryDelegatorValidatorResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.validator !== undefined) { + Validator.encode(message.validator, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryDelegatorValidatorResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryDelegatorValidatorResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.validator = Validator.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryDelegatorValidatorResponse { + const obj = createBaseQueryDelegatorValidatorResponse(); + if (isSet(object.validator)) obj.validator = Validator.fromJSON(object.validator); + return obj; + }, + toJSON(message: QueryDelegatorValidatorResponse): JsonSafe { + const obj: any = {}; + message.validator !== undefined && (obj.validator = message.validator ? Validator.toJSON(message.validator) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryDelegatorValidatorResponse { + const message = createBaseQueryDelegatorValidatorResponse(); + if (object.validator !== undefined && object.validator !== null) { + message.validator = Validator.fromPartial(object.validator); + } + return message; + }, + fromSDK(object: QueryDelegatorValidatorResponseSDKType): QueryDelegatorValidatorResponse { + return { + validator: object.validator ? Validator.fromSDK(object.validator) : undefined + }; + }, + fromSDKJSON(object: any): QueryDelegatorValidatorResponseSDKType { + return { + validator: isSet(object.validator) ? Validator.fromSDKJSON(object.validator) : undefined + }; + }, + toSDK(message: QueryDelegatorValidatorResponse): QueryDelegatorValidatorResponseSDKType { + const obj: any = {}; + message.validator !== undefined && (obj.validator = message.validator ? Validator.toSDK(message.validator) : undefined); + return obj; + }, + fromAmino(object: QueryDelegatorValidatorResponseAmino): QueryDelegatorValidatorResponse { + const message = createBaseQueryDelegatorValidatorResponse(); + if (object.validator !== undefined && object.validator !== null) { + message.validator = Validator.fromAmino(object.validator); + } + return message; + }, + toAmino(message: QueryDelegatorValidatorResponse): QueryDelegatorValidatorResponseAmino { + const obj: any = {}; + obj.validator = message.validator ? Validator.toAmino(message.validator) : undefined; + return obj; + }, + fromAminoMsg(object: QueryDelegatorValidatorResponseAminoMsg): QueryDelegatorValidatorResponse { + return QueryDelegatorValidatorResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryDelegatorValidatorResponse): QueryDelegatorValidatorResponseAminoMsg { + return { + type: "cosmos-sdk/QueryDelegatorValidatorResponse", + value: QueryDelegatorValidatorResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryDelegatorValidatorResponseProtoMsg): QueryDelegatorValidatorResponse { + return QueryDelegatorValidatorResponse.decode(message.value); + }, + toProto(message: QueryDelegatorValidatorResponse): Uint8Array { + return QueryDelegatorValidatorResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryDelegatorValidatorResponse): QueryDelegatorValidatorResponseProtoMsg { + return { + typeUrl: "/cosmos.staking.v1beta1.QueryDelegatorValidatorResponse", + value: QueryDelegatorValidatorResponse.encode(message).finish() + }; + } +}; +function createBaseQueryHistoricalInfoRequest(): QueryHistoricalInfoRequest { + return { + height: BigInt(0) + }; +} +export const QueryHistoricalInfoRequest = { + typeUrl: "/cosmos.staking.v1beta1.QueryHistoricalInfoRequest", + encode(message: QueryHistoricalInfoRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.height !== undefined) { + writer.uint32(8).int64(message.height); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryHistoricalInfoRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryHistoricalInfoRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.height = reader.int64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryHistoricalInfoRequest { + const obj = createBaseQueryHistoricalInfoRequest(); + if (isSet(object.height)) obj.height = BigInt(object.height.toString()); + return obj; + }, + toJSON(message: QueryHistoricalInfoRequest): JsonSafe { + const obj: any = {}; + message.height !== undefined && (obj.height = (message.height || BigInt(0)).toString()); + return obj; + }, + fromPartial(object: DeepPartial): QueryHistoricalInfoRequest { + const message = createBaseQueryHistoricalInfoRequest(); + if (object.height !== undefined && object.height !== null) { + message.height = BigInt(object.height.toString()); + } + return message; + }, + fromSDK(object: QueryHistoricalInfoRequestSDKType): QueryHistoricalInfoRequest { + return { + height: object?.height + }; + }, + fromSDKJSON(object: any): QueryHistoricalInfoRequestSDKType { + return { + height: isSet(object.height) ? BigInt(object.height.toString()) : BigInt(0) + }; + }, + toSDK(message: QueryHistoricalInfoRequest): QueryHistoricalInfoRequestSDKType { + const obj: any = {}; + obj.height = message.height; + return obj; + }, + fromAmino(object: QueryHistoricalInfoRequestAmino): QueryHistoricalInfoRequest { + const message = createBaseQueryHistoricalInfoRequest(); + if (object.height !== undefined && object.height !== null) { + message.height = BigInt(object.height); + } + return message; + }, + toAmino(message: QueryHistoricalInfoRequest): QueryHistoricalInfoRequestAmino { + const obj: any = {}; + obj.height = message.height !== BigInt(0) ? message.height?.toString() : undefined; + return obj; + }, + fromAminoMsg(object: QueryHistoricalInfoRequestAminoMsg): QueryHistoricalInfoRequest { + return QueryHistoricalInfoRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryHistoricalInfoRequest): QueryHistoricalInfoRequestAminoMsg { + return { + type: "cosmos-sdk/QueryHistoricalInfoRequest", + value: QueryHistoricalInfoRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryHistoricalInfoRequestProtoMsg): QueryHistoricalInfoRequest { + return QueryHistoricalInfoRequest.decode(message.value); + }, + toProto(message: QueryHistoricalInfoRequest): Uint8Array { + return QueryHistoricalInfoRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryHistoricalInfoRequest): QueryHistoricalInfoRequestProtoMsg { + return { + typeUrl: "/cosmos.staking.v1beta1.QueryHistoricalInfoRequest", + value: QueryHistoricalInfoRequest.encode(message).finish() + }; + } +}; +function createBaseQueryHistoricalInfoResponse(): QueryHistoricalInfoResponse { + return { + hist: undefined + }; +} +export const QueryHistoricalInfoResponse = { + typeUrl: "/cosmos.staking.v1beta1.QueryHistoricalInfoResponse", + encode(message: QueryHistoricalInfoResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.hist !== undefined) { + HistoricalInfo.encode(message.hist, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryHistoricalInfoResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryHistoricalInfoResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.hist = HistoricalInfo.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryHistoricalInfoResponse { + const obj = createBaseQueryHistoricalInfoResponse(); + if (isSet(object.hist)) obj.hist = HistoricalInfo.fromJSON(object.hist); + return obj; + }, + toJSON(message: QueryHistoricalInfoResponse): JsonSafe { + const obj: any = {}; + message.hist !== undefined && (obj.hist = message.hist ? HistoricalInfo.toJSON(message.hist) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryHistoricalInfoResponse { + const message = createBaseQueryHistoricalInfoResponse(); + if (object.hist !== undefined && object.hist !== null) { + message.hist = HistoricalInfo.fromPartial(object.hist); + } + return message; + }, + fromSDK(object: QueryHistoricalInfoResponseSDKType): QueryHistoricalInfoResponse { + return { + hist: object.hist ? HistoricalInfo.fromSDK(object.hist) : undefined + }; + }, + fromSDKJSON(object: any): QueryHistoricalInfoResponseSDKType { + return { + hist: isSet(object.hist) ? HistoricalInfo.fromSDKJSON(object.hist) : undefined + }; + }, + toSDK(message: QueryHistoricalInfoResponse): QueryHistoricalInfoResponseSDKType { + const obj: any = {}; + message.hist !== undefined && (obj.hist = message.hist ? HistoricalInfo.toSDK(message.hist) : undefined); + return obj; + }, + fromAmino(object: QueryHistoricalInfoResponseAmino): QueryHistoricalInfoResponse { + const message = createBaseQueryHistoricalInfoResponse(); + if (object.hist !== undefined && object.hist !== null) { + message.hist = HistoricalInfo.fromAmino(object.hist); + } + return message; + }, + toAmino(message: QueryHistoricalInfoResponse): QueryHistoricalInfoResponseAmino { + const obj: any = {}; + obj.hist = message.hist ? HistoricalInfo.toAmino(message.hist) : undefined; + return obj; + }, + fromAminoMsg(object: QueryHistoricalInfoResponseAminoMsg): QueryHistoricalInfoResponse { + return QueryHistoricalInfoResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryHistoricalInfoResponse): QueryHistoricalInfoResponseAminoMsg { + return { + type: "cosmos-sdk/QueryHistoricalInfoResponse", + value: QueryHistoricalInfoResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryHistoricalInfoResponseProtoMsg): QueryHistoricalInfoResponse { + return QueryHistoricalInfoResponse.decode(message.value); + }, + toProto(message: QueryHistoricalInfoResponse): Uint8Array { + return QueryHistoricalInfoResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryHistoricalInfoResponse): QueryHistoricalInfoResponseProtoMsg { + return { + typeUrl: "/cosmos.staking.v1beta1.QueryHistoricalInfoResponse", + value: QueryHistoricalInfoResponse.encode(message).finish() + }; + } +}; +function createBaseQueryPoolRequest(): QueryPoolRequest { + return {}; +} +export const QueryPoolRequest = { + typeUrl: "/cosmos.staking.v1beta1.QueryPoolRequest", + encode(_: QueryPoolRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryPoolRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryPoolRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): QueryPoolRequest { + const obj = createBaseQueryPoolRequest(); + return obj; + }, + toJSON(_: QueryPoolRequest): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): QueryPoolRequest { + const message = createBaseQueryPoolRequest(); + return message; + }, + fromSDK(_: QueryPoolRequestSDKType): QueryPoolRequest { + return {}; + }, + fromSDKJSON(_: any): QueryPoolRequestSDKType { + return {}; + }, + toSDK(_: QueryPoolRequest): QueryPoolRequestSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: QueryPoolRequestAmino): QueryPoolRequest { + const message = createBaseQueryPoolRequest(); + return message; + }, + toAmino(_: QueryPoolRequest): QueryPoolRequestAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: QueryPoolRequestAminoMsg): QueryPoolRequest { + return QueryPoolRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryPoolRequest): QueryPoolRequestAminoMsg { + return { + type: "cosmos-sdk/QueryPoolRequest", + value: QueryPoolRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryPoolRequestProtoMsg): QueryPoolRequest { + return QueryPoolRequest.decode(message.value); + }, + toProto(message: QueryPoolRequest): Uint8Array { + return QueryPoolRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryPoolRequest): QueryPoolRequestProtoMsg { + return { + typeUrl: "/cosmos.staking.v1beta1.QueryPoolRequest", + value: QueryPoolRequest.encode(message).finish() + }; + } +}; +function createBaseQueryPoolResponse(): QueryPoolResponse { + return { + pool: Pool.fromPartial({}) + }; +} +export const QueryPoolResponse = { + typeUrl: "/cosmos.staking.v1beta1.QueryPoolResponse", + encode(message: QueryPoolResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.pool !== undefined) { + Pool.encode(message.pool, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryPoolResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryPoolResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.pool = Pool.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryPoolResponse { + const obj = createBaseQueryPoolResponse(); + if (isSet(object.pool)) obj.pool = Pool.fromJSON(object.pool); + return obj; + }, + toJSON(message: QueryPoolResponse): JsonSafe { + const obj: any = {}; + message.pool !== undefined && (obj.pool = message.pool ? Pool.toJSON(message.pool) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryPoolResponse { + const message = createBaseQueryPoolResponse(); + if (object.pool !== undefined && object.pool !== null) { + message.pool = Pool.fromPartial(object.pool); + } + return message; + }, + fromSDK(object: QueryPoolResponseSDKType): QueryPoolResponse { + return { + pool: object.pool ? Pool.fromSDK(object.pool) : undefined + }; + }, + fromSDKJSON(object: any): QueryPoolResponseSDKType { + return { + pool: isSet(object.pool) ? Pool.fromSDKJSON(object.pool) : undefined + }; + }, + toSDK(message: QueryPoolResponse): QueryPoolResponseSDKType { + const obj: any = {}; + message.pool !== undefined && (obj.pool = message.pool ? Pool.toSDK(message.pool) : undefined); + return obj; + }, + fromAmino(object: QueryPoolResponseAmino): QueryPoolResponse { + const message = createBaseQueryPoolResponse(); + if (object.pool !== undefined && object.pool !== null) { + message.pool = Pool.fromAmino(object.pool); + } + return message; + }, + toAmino(message: QueryPoolResponse): QueryPoolResponseAmino { + const obj: any = {}; + obj.pool = message.pool ? Pool.toAmino(message.pool) : undefined; + return obj; + }, + fromAminoMsg(object: QueryPoolResponseAminoMsg): QueryPoolResponse { + return QueryPoolResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryPoolResponse): QueryPoolResponseAminoMsg { + return { + type: "cosmos-sdk/QueryPoolResponse", + value: QueryPoolResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryPoolResponseProtoMsg): QueryPoolResponse { + return QueryPoolResponse.decode(message.value); + }, + toProto(message: QueryPoolResponse): Uint8Array { + return QueryPoolResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryPoolResponse): QueryPoolResponseProtoMsg { + return { + typeUrl: "/cosmos.staking.v1beta1.QueryPoolResponse", + value: QueryPoolResponse.encode(message).finish() + }; + } +}; +function createBaseQueryParamsRequest(): QueryParamsRequest { + return {}; +} +export const QueryParamsRequest = { + typeUrl: "/cosmos.staking.v1beta1.QueryParamsRequest", + encode(_: QueryParamsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryParamsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryParamsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): QueryParamsRequest { + const obj = createBaseQueryParamsRequest(); + return obj; + }, + toJSON(_: QueryParamsRequest): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): QueryParamsRequest { + const message = createBaseQueryParamsRequest(); + return message; + }, + fromSDK(_: QueryParamsRequestSDKType): QueryParamsRequest { + return {}; + }, + fromSDKJSON(_: any): QueryParamsRequestSDKType { + return {}; + }, + toSDK(_: QueryParamsRequest): QueryParamsRequestSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: QueryParamsRequestAmino): QueryParamsRequest { + const message = createBaseQueryParamsRequest(); + return message; + }, + toAmino(_: QueryParamsRequest): QueryParamsRequestAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: QueryParamsRequestAminoMsg): QueryParamsRequest { + return QueryParamsRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryParamsRequest): QueryParamsRequestAminoMsg { + return { + type: "cosmos-sdk/QueryParamsRequest", + value: QueryParamsRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryParamsRequestProtoMsg): QueryParamsRequest { + return QueryParamsRequest.decode(message.value); + }, + toProto(message: QueryParamsRequest): Uint8Array { + return QueryParamsRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryParamsRequest): QueryParamsRequestProtoMsg { + return { + typeUrl: "/cosmos.staking.v1beta1.QueryParamsRequest", + value: QueryParamsRequest.encode(message).finish() + }; + } +}; +function createBaseQueryParamsResponse(): QueryParamsResponse { + return { + params: Params.fromPartial({}) + }; +} +export const QueryParamsResponse = { + typeUrl: "/cosmos.staking.v1beta1.QueryParamsResponse", + encode(message: QueryParamsResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryParamsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryParamsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.params = Params.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryParamsResponse { + const obj = createBaseQueryParamsResponse(); + if (isSet(object.params)) obj.params = Params.fromJSON(object.params); + return obj; + }, + toJSON(message: QueryParamsResponse): JsonSafe { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryParamsResponse { + const message = createBaseQueryParamsResponse(); + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } + return message; + }, + fromSDK(object: QueryParamsResponseSDKType): QueryParamsResponse { + return { + params: object.params ? Params.fromSDK(object.params) : undefined + }; + }, + fromSDKJSON(object: any): QueryParamsResponseSDKType { + return { + params: isSet(object.params) ? Params.fromSDKJSON(object.params) : undefined + }; + }, + toSDK(message: QueryParamsResponse): QueryParamsResponseSDKType { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toSDK(message.params) : undefined); + return obj; + }, + fromAmino(object: QueryParamsResponseAmino): QueryParamsResponse { + const message = createBaseQueryParamsResponse(); + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromAmino(object.params); + } + return message; + }, + toAmino(message: QueryParamsResponse): QueryParamsResponseAmino { + const obj: any = {}; + obj.params = message.params ? Params.toAmino(message.params) : undefined; + return obj; + }, + fromAminoMsg(object: QueryParamsResponseAminoMsg): QueryParamsResponse { + return QueryParamsResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryParamsResponse): QueryParamsResponseAminoMsg { + return { + type: "cosmos-sdk/QueryParamsResponse", + value: QueryParamsResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryParamsResponseProtoMsg): QueryParamsResponse { + return QueryParamsResponse.decode(message.value); + }, + toProto(message: QueryParamsResponse): Uint8Array { + return QueryParamsResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryParamsResponse): QueryParamsResponseProtoMsg { + return { + typeUrl: "/cosmos.staking.v1beta1.QueryParamsResponse", + value: QueryParamsResponse.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/staking/v1beta1/staking.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/staking/v1beta1/staking.ts new file mode 100644 index 0000000000..2ed6ddbcbd --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/staking/v1beta1/staking.ts @@ -0,0 +1,3237 @@ +import { Header, HeaderSDKType } from "../../../tendermint/types/types.js"; +import { Timestamp, TimestampSDKType } from "../../../google/protobuf/timestamp.js"; +import { Any, AnySDKType } from "../../../google/protobuf/any.js"; +import { Duration, DurationSDKType } from "../../../google/protobuf/duration.js"; +import { Coin, CoinSDKType } from "../../base/v1beta1/coin.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial, toTimestamp, fromTimestamp } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +import { Decimal } from "@cosmjs/math"; +import { encodePubkey, decodePubkey } from "@cosmjs/proto-signing"; +export const protobufPackage = "cosmos.staking.v1beta1"; +/** BondStatus is the status of a validator. */ +export enum BondStatus { + /** BOND_STATUS_UNSPECIFIED - UNSPECIFIED defines an invalid validator status. */ + BOND_STATUS_UNSPECIFIED = 0, + /** BOND_STATUS_UNBONDED - UNBONDED defines a validator that is not bonded. */ + BOND_STATUS_UNBONDED = 1, + /** BOND_STATUS_UNBONDING - UNBONDING defines a validator that is unbonding. */ + BOND_STATUS_UNBONDING = 2, + /** BOND_STATUS_BONDED - BONDED defines a validator that is bonded. */ + BOND_STATUS_BONDED = 3, + UNRECOGNIZED = -1, +} +export const BondStatusSDKType = BondStatus; +export function bondStatusFromJSON(object: any): BondStatus { + switch (object) { + case 0: + case "BOND_STATUS_UNSPECIFIED": + return BondStatus.BOND_STATUS_UNSPECIFIED; + case 1: + case "BOND_STATUS_UNBONDED": + return BondStatus.BOND_STATUS_UNBONDED; + case 2: + case "BOND_STATUS_UNBONDING": + return BondStatus.BOND_STATUS_UNBONDING; + case 3: + case "BOND_STATUS_BONDED": + return BondStatus.BOND_STATUS_BONDED; + case -1: + case "UNRECOGNIZED": + default: + return BondStatus.UNRECOGNIZED; + } +} +export function bondStatusToJSON(object: BondStatus): string { + switch (object) { + case BondStatus.BOND_STATUS_UNSPECIFIED: + return "BOND_STATUS_UNSPECIFIED"; + case BondStatus.BOND_STATUS_UNBONDED: + return "BOND_STATUS_UNBONDED"; + case BondStatus.BOND_STATUS_UNBONDING: + return "BOND_STATUS_UNBONDING"; + case BondStatus.BOND_STATUS_BONDED: + return "BOND_STATUS_BONDED"; + case BondStatus.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** + * HistoricalInfo contains header and validator information for a given block. + * It is stored as part of staking module's state, which persists the `n` most + * recent HistoricalInfo + * (`n` is set by the staking module's `historical_entries` parameter). + */ +export interface HistoricalInfo { + header: Header; + valset: Validator[]; +} +export interface HistoricalInfoProtoMsg { + typeUrl: "/cosmos.staking.v1beta1.HistoricalInfo"; + value: Uint8Array; +} +/** + * HistoricalInfo contains header and validator information for a given block. + * It is stored as part of staking module's state, which persists the `n` most + * recent HistoricalInfo + * (`n` is set by the staking module's `historical_entries` parameter). + */ +export interface HistoricalInfoSDKType { + header: HeaderSDKType; + valset: ValidatorSDKType[]; +} +/** + * CommissionRates defines the initial commission rates to be used for creating + * a validator. + */ +export interface CommissionRates { + /** rate is the commission rate charged to delegators, as a fraction. */ + rate: string; + /** max_rate defines the maximum commission rate which validator can ever charge, as a fraction. */ + maxRate: string; + /** max_change_rate defines the maximum daily increase of the validator commission, as a fraction. */ + maxChangeRate: string; +} +export interface CommissionRatesProtoMsg { + typeUrl: "/cosmos.staking.v1beta1.CommissionRates"; + value: Uint8Array; +} +/** + * CommissionRates defines the initial commission rates to be used for creating + * a validator. + */ +export interface CommissionRatesSDKType { + rate: string; + max_rate: string; + max_change_rate: string; +} +/** Commission defines commission parameters for a given validator. */ +export interface Commission { + /** commission_rates defines the initial commission rates to be used for creating a validator. */ + commissionRates: CommissionRates; + /** update_time is the last time the commission rate was changed. */ + updateTime: Date; +} +export interface CommissionProtoMsg { + typeUrl: "/cosmos.staking.v1beta1.Commission"; + value: Uint8Array; +} +/** Commission defines commission parameters for a given validator. */ +export interface CommissionSDKType { + commission_rates: CommissionRatesSDKType; + update_time: Date; +} +/** Description defines a validator description. */ +export interface Description { + /** moniker defines a human-readable name for the validator. */ + moniker: string; + /** identity defines an optional identity signature (ex. UPort or Keybase). */ + identity: string; + /** website defines an optional website link. */ + website: string; + /** security_contact defines an optional email for security contact. */ + securityContact: string; + /** details define other optional details. */ + details: string; +} +export interface DescriptionProtoMsg { + typeUrl: "/cosmos.staking.v1beta1.Description"; + value: Uint8Array; +} +/** Description defines a validator description. */ +export interface DescriptionSDKType { + moniker: string; + identity: string; + website: string; + security_contact: string; + details: string; +} +/** + * Validator defines a validator, together with the total amount of the + * Validator's bond shares and their exchange rate to coins. Slashing results in + * a decrease in the exchange rate, allowing correct calculation of future + * undelegations without iterating over delegators. When coins are delegated to + * this validator, the validator is credited with a delegation whose number of + * bond shares is based on the amount of coins delegated divided by the current + * exchange rate. Voting power can be calculated as total bonded shares + * multiplied by exchange rate. + */ +export interface Validator { + /** operator_address defines the address of the validator's operator; bech encoded in JSON. */ + operatorAddress: string; + /** consensus_pubkey is the consensus public key of the validator, as a Protobuf Any. */ + consensusPubkey?: Any; + /** jailed defined whether the validator has been jailed from bonded status or not. */ + jailed: boolean; + /** status is the validator status (bonded/unbonding/unbonded). */ + status: BondStatus; + /** tokens define the delegated tokens (incl. self-delegation). */ + tokens: string; + /** delegator_shares defines total shares issued to a validator's delegators. */ + delegatorShares: string; + /** description defines the description terms for the validator. */ + description: Description; + /** unbonding_height defines, if unbonding, the height at which this validator has begun unbonding. */ + unbondingHeight: bigint; + /** unbonding_time defines, if unbonding, the min time for the validator to complete unbonding. */ + unbondingTime: Date; + /** commission defines the commission parameters. */ + commission: Commission; + /** min_self_delegation is the validator's self declared minimum self delegation. */ + minSelfDelegation: string; +} +export interface ValidatorProtoMsg { + typeUrl: "/cosmos.staking.v1beta1.Validator"; + value: Uint8Array; +} +/** + * Validator defines a validator, together with the total amount of the + * Validator's bond shares and their exchange rate to coins. Slashing results in + * a decrease in the exchange rate, allowing correct calculation of future + * undelegations without iterating over delegators. When coins are delegated to + * this validator, the validator is credited with a delegation whose number of + * bond shares is based on the amount of coins delegated divided by the current + * exchange rate. Voting power can be calculated as total bonded shares + * multiplied by exchange rate. + */ +export interface ValidatorSDKType { + operator_address: string; + consensus_pubkey?: AnySDKType; + jailed: boolean; + status: BondStatus; + tokens: string; + delegator_shares: string; + description: DescriptionSDKType; + unbonding_height: bigint; + unbonding_time: Date; + commission: CommissionSDKType; + min_self_delegation: string; +} +/** ValAddresses defines a repeated set of validator addresses. */ +export interface ValAddresses { + addresses: string[]; +} +export interface ValAddressesProtoMsg { + typeUrl: "/cosmos.staking.v1beta1.ValAddresses"; + value: Uint8Array; +} +/** ValAddresses defines a repeated set of validator addresses. */ +export interface ValAddressesSDKType { + addresses: string[]; +} +/** + * DVPair is struct that just has a delegator-validator pair with no other data. + * It is intended to be used as a marshalable pointer. For example, a DVPair can + * be used to construct the key to getting an UnbondingDelegation from state. + */ +export interface DVPair { + delegatorAddress: string; + validatorAddress: string; +} +export interface DVPairProtoMsg { + typeUrl: "/cosmos.staking.v1beta1.DVPair"; + value: Uint8Array; +} +/** + * DVPair is struct that just has a delegator-validator pair with no other data. + * It is intended to be used as a marshalable pointer. For example, a DVPair can + * be used to construct the key to getting an UnbondingDelegation from state. + */ +export interface DVPairSDKType { + delegator_address: string; + validator_address: string; +} +/** DVPairs defines an array of DVPair objects. */ +export interface DVPairs { + pairs: DVPair[]; +} +export interface DVPairsProtoMsg { + typeUrl: "/cosmos.staking.v1beta1.DVPairs"; + value: Uint8Array; +} +/** DVPairs defines an array of DVPair objects. */ +export interface DVPairsSDKType { + pairs: DVPairSDKType[]; +} +/** + * DVVTriplet is struct that just has a delegator-validator-validator triplet + * with no other data. It is intended to be used as a marshalable pointer. For + * example, a DVVTriplet can be used to construct the key to getting a + * Redelegation from state. + */ +export interface DVVTriplet { + delegatorAddress: string; + validatorSrcAddress: string; + validatorDstAddress: string; +} +export interface DVVTripletProtoMsg { + typeUrl: "/cosmos.staking.v1beta1.DVVTriplet"; + value: Uint8Array; +} +/** + * DVVTriplet is struct that just has a delegator-validator-validator triplet + * with no other data. It is intended to be used as a marshalable pointer. For + * example, a DVVTriplet can be used to construct the key to getting a + * Redelegation from state. + */ +export interface DVVTripletSDKType { + delegator_address: string; + validator_src_address: string; + validator_dst_address: string; +} +/** DVVTriplets defines an array of DVVTriplet objects. */ +export interface DVVTriplets { + triplets: DVVTriplet[]; +} +export interface DVVTripletsProtoMsg { + typeUrl: "/cosmos.staking.v1beta1.DVVTriplets"; + value: Uint8Array; +} +/** DVVTriplets defines an array of DVVTriplet objects. */ +export interface DVVTripletsSDKType { + triplets: DVVTripletSDKType[]; +} +/** + * Delegation represents the bond with tokens held by an account. It is + * owned by one delegator, and is associated with the voting power of one + * validator. + */ +export interface Delegation { + /** delegator_address is the bech32-encoded address of the delegator. */ + delegatorAddress: string; + /** validator_address is the bech32-encoded address of the validator. */ + validatorAddress: string; + /** shares define the delegation shares received. */ + shares: string; +} +export interface DelegationProtoMsg { + typeUrl: "/cosmos.staking.v1beta1.Delegation"; + value: Uint8Array; +} +/** + * Delegation represents the bond with tokens held by an account. It is + * owned by one delegator, and is associated with the voting power of one + * validator. + */ +export interface DelegationSDKType { + delegator_address: string; + validator_address: string; + shares: string; +} +/** + * UnbondingDelegation stores all of a single delegator's unbonding bonds + * for a single validator in an time-ordered list. + */ +export interface UnbondingDelegation { + /** delegator_address is the bech32-encoded address of the delegator. */ + delegatorAddress: string; + /** validator_address is the bech32-encoded address of the validator. */ + validatorAddress: string; + /** entries are the unbonding delegation entries. */ + entries: UnbondingDelegationEntry[]; +} +export interface UnbondingDelegationProtoMsg { + typeUrl: "/cosmos.staking.v1beta1.UnbondingDelegation"; + value: Uint8Array; +} +/** + * UnbondingDelegation stores all of a single delegator's unbonding bonds + * for a single validator in an time-ordered list. + */ +export interface UnbondingDelegationSDKType { + delegator_address: string; + validator_address: string; + entries: UnbondingDelegationEntrySDKType[]; +} +/** UnbondingDelegationEntry defines an unbonding object with relevant metadata. */ +export interface UnbondingDelegationEntry { + /** creation_height is the height which the unbonding took place. */ + creationHeight: bigint; + /** completion_time is the unix time for unbonding completion. */ + completionTime: Date; + /** initial_balance defines the tokens initially scheduled to receive at completion. */ + initialBalance: string; + /** balance defines the tokens to receive at completion. */ + balance: string; +} +export interface UnbondingDelegationEntryProtoMsg { + typeUrl: "/cosmos.staking.v1beta1.UnbondingDelegationEntry"; + value: Uint8Array; +} +/** UnbondingDelegationEntry defines an unbonding object with relevant metadata. */ +export interface UnbondingDelegationEntrySDKType { + creation_height: bigint; + completion_time: Date; + initial_balance: string; + balance: string; +} +/** RedelegationEntry defines a redelegation object with relevant metadata. */ +export interface RedelegationEntry { + /** creation_height defines the height which the redelegation took place. */ + creationHeight: bigint; + /** completion_time defines the unix time for redelegation completion. */ + completionTime: Date; + /** initial_balance defines the initial balance when redelegation started. */ + initialBalance: string; + /** shares_dst is the amount of destination-validator shares created by redelegation. */ + sharesDst: string; +} +export interface RedelegationEntryProtoMsg { + typeUrl: "/cosmos.staking.v1beta1.RedelegationEntry"; + value: Uint8Array; +} +/** RedelegationEntry defines a redelegation object with relevant metadata. */ +export interface RedelegationEntrySDKType { + creation_height: bigint; + completion_time: Date; + initial_balance: string; + shares_dst: string; +} +/** + * Redelegation contains the list of a particular delegator's redelegating bonds + * from a particular source validator to a particular destination validator. + */ +export interface Redelegation { + /** delegator_address is the bech32-encoded address of the delegator. */ + delegatorAddress: string; + /** validator_src_address is the validator redelegation source operator address. */ + validatorSrcAddress: string; + /** validator_dst_address is the validator redelegation destination operator address. */ + validatorDstAddress: string; + /** entries are the redelegation entries. */ + entries: RedelegationEntry[]; +} +export interface RedelegationProtoMsg { + typeUrl: "/cosmos.staking.v1beta1.Redelegation"; + value: Uint8Array; +} +/** + * Redelegation contains the list of a particular delegator's redelegating bonds + * from a particular source validator to a particular destination validator. + */ +export interface RedelegationSDKType { + delegator_address: string; + validator_src_address: string; + validator_dst_address: string; + entries: RedelegationEntrySDKType[]; +} +/** Params defines the parameters for the staking module. */ +export interface Params { + /** unbonding_time is the time duration of unbonding. */ + unbondingTime: Duration; + /** max_validators is the maximum number of validators. */ + maxValidators: number; + /** max_entries is the max entries for either unbonding delegation or redelegation (per pair/trio). */ + maxEntries: number; + /** historical_entries is the number of historical entries to persist. */ + historicalEntries: number; + /** bond_denom defines the bondable coin denomination. */ + bondDenom: string; + /** min_commission_rate is the chain-wide minimum commission rate that a validator can charge their delegators */ + minCommissionRate: string; +} +export interface ParamsProtoMsg { + typeUrl: "/cosmos.staking.v1beta1.Params"; + value: Uint8Array; +} +/** Params defines the parameters for the staking module. */ +export interface ParamsSDKType { + unbonding_time: DurationSDKType; + max_validators: number; + max_entries: number; + historical_entries: number; + bond_denom: string; + min_commission_rate: string; +} +/** + * DelegationResponse is equivalent to Delegation except that it contains a + * balance in addition to shares which is more suitable for client responses. + */ +export interface DelegationResponse { + delegation: Delegation; + balance: Coin; +} +export interface DelegationResponseProtoMsg { + typeUrl: "/cosmos.staking.v1beta1.DelegationResponse"; + value: Uint8Array; +} +/** + * DelegationResponse is equivalent to Delegation except that it contains a + * balance in addition to shares which is more suitable for client responses. + */ +export interface DelegationResponseSDKType { + delegation: DelegationSDKType; + balance: CoinSDKType; +} +/** + * RedelegationEntryResponse is equivalent to a RedelegationEntry except that it + * contains a balance in addition to shares which is more suitable for client + * responses. + */ +export interface RedelegationEntryResponse { + redelegationEntry: RedelegationEntry; + balance: string; +} +export interface RedelegationEntryResponseProtoMsg { + typeUrl: "/cosmos.staking.v1beta1.RedelegationEntryResponse"; + value: Uint8Array; +} +/** + * RedelegationEntryResponse is equivalent to a RedelegationEntry except that it + * contains a balance in addition to shares which is more suitable for client + * responses. + */ +export interface RedelegationEntryResponseSDKType { + redelegation_entry: RedelegationEntrySDKType; + balance: string; +} +/** + * RedelegationResponse is equivalent to a Redelegation except that its entries + * contain a balance in addition to shares which is more suitable for client + * responses. + */ +export interface RedelegationResponse { + redelegation: Redelegation; + entries: RedelegationEntryResponse[]; +} +export interface RedelegationResponseProtoMsg { + typeUrl: "/cosmos.staking.v1beta1.RedelegationResponse"; + value: Uint8Array; +} +/** + * RedelegationResponse is equivalent to a Redelegation except that its entries + * contain a balance in addition to shares which is more suitable for client + * responses. + */ +export interface RedelegationResponseSDKType { + redelegation: RedelegationSDKType; + entries: RedelegationEntryResponseSDKType[]; +} +/** + * Pool is used for tracking bonded and not-bonded token supply of the bond + * denomination. + */ +export interface Pool { + notBondedTokens: string; + bondedTokens: string; +} +export interface PoolProtoMsg { + typeUrl: "/cosmos.staking.v1beta1.Pool"; + value: Uint8Array; +} +/** + * Pool is used for tracking bonded and not-bonded token supply of the bond + * denomination. + */ +export interface PoolSDKType { + not_bonded_tokens: string; + bonded_tokens: string; +} +function createBaseHistoricalInfo(): HistoricalInfo { + return { + header: Header.fromPartial({}), + valset: [] + }; +} +export const HistoricalInfo = { + typeUrl: "/cosmos.staking.v1beta1.HistoricalInfo", + encode(message: HistoricalInfo, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.header !== undefined) { + Header.encode(message.header, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.valset) { + Validator.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): HistoricalInfo { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseHistoricalInfo(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.header = Header.decode(reader, reader.uint32()); + break; + case 2: + message.valset.push(Validator.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): HistoricalInfo { + const obj = createBaseHistoricalInfo(); + if (isSet(object.header)) obj.header = Header.fromJSON(object.header); + if (Array.isArray(object?.valset)) obj.valset = object.valset.map((e: any) => Validator.fromJSON(e)); + return obj; + }, + toJSON(message: HistoricalInfo): JsonSafe { + const obj: any = {}; + message.header !== undefined && (obj.header = message.header ? Header.toJSON(message.header) : undefined); + if (message.valset) { + obj.valset = message.valset.map(e => e ? Validator.toJSON(e) : undefined); + } else { + obj.valset = []; + } + return obj; + }, + fromPartial(object: DeepPartial): HistoricalInfo { + const message = createBaseHistoricalInfo(); + if (object.header !== undefined && object.header !== null) { + message.header = Header.fromPartial(object.header); + } + message.valset = object.valset?.map(e => Validator.fromPartial(e)) || []; + return message; + }, + fromSDK(object: HistoricalInfoSDKType): HistoricalInfo { + return { + header: object.header ? Header.fromSDK(object.header) : undefined, + valset: Array.isArray(object?.valset) ? object.valset.map((e: any) => Validator.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): HistoricalInfoSDKType { + return { + header: isSet(object.header) ? Header.fromSDKJSON(object.header) : undefined, + valset: Array.isArray(object?.valset) ? object.valset.map((e: any) => Validator.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: HistoricalInfo): HistoricalInfoSDKType { + const obj: any = {}; + message.header !== undefined && (obj.header = message.header ? Header.toSDK(message.header) : undefined); + if (message.valset) { + obj.valset = message.valset.map(e => e ? Validator.toSDK(e) : undefined); + } else { + obj.valset = []; + } + return obj; + }, + fromAmino(object: HistoricalInfoAmino): HistoricalInfo { + const message = createBaseHistoricalInfo(); + if (object.header !== undefined && object.header !== null) { + message.header = Header.fromAmino(object.header); + } + message.valset = object.valset?.map(e => Validator.fromAmino(e)) || []; + return message; + }, + toAmino(message: HistoricalInfo): HistoricalInfoAmino { + const obj: any = {}; + obj.header = message.header ? Header.toAmino(message.header) : undefined; + if (message.valset) { + obj.valset = message.valset.map(e => e ? Validator.toAmino(e) : undefined); + } else { + obj.valset = message.valset; + } + return obj; + }, + fromAminoMsg(object: HistoricalInfoAminoMsg): HistoricalInfo { + return HistoricalInfo.fromAmino(object.value); + }, + toAminoMsg(message: HistoricalInfo): HistoricalInfoAminoMsg { + return { + type: "cosmos-sdk/HistoricalInfo", + value: HistoricalInfo.toAmino(message) + }; + }, + fromProtoMsg(message: HistoricalInfoProtoMsg): HistoricalInfo { + return HistoricalInfo.decode(message.value); + }, + toProto(message: HistoricalInfo): Uint8Array { + return HistoricalInfo.encode(message).finish(); + }, + toProtoMsg(message: HistoricalInfo): HistoricalInfoProtoMsg { + return { + typeUrl: "/cosmos.staking.v1beta1.HistoricalInfo", + value: HistoricalInfo.encode(message).finish() + }; + } +}; +function createBaseCommissionRates(): CommissionRates { + return { + rate: "", + maxRate: "", + maxChangeRate: "" + }; +} +export const CommissionRates = { + typeUrl: "/cosmos.staking.v1beta1.CommissionRates", + encode(message: CommissionRates, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.rate !== undefined) { + writer.uint32(10).string(Decimal.fromUserInput(message.rate, 18).atomics); + } + if (message.maxRate !== undefined) { + writer.uint32(18).string(Decimal.fromUserInput(message.maxRate, 18).atomics); + } + if (message.maxChangeRate !== undefined) { + writer.uint32(26).string(Decimal.fromUserInput(message.maxChangeRate, 18).atomics); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): CommissionRates { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCommissionRates(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.rate = Decimal.fromAtomics(reader.string(), 18).toString(); + break; + case 2: + message.maxRate = Decimal.fromAtomics(reader.string(), 18).toString(); + break; + case 3: + message.maxChangeRate = Decimal.fromAtomics(reader.string(), 18).toString(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): CommissionRates { + const obj = createBaseCommissionRates(); + if (isSet(object.rate)) obj.rate = String(object.rate); + if (isSet(object.maxRate)) obj.maxRate = String(object.maxRate); + if (isSet(object.maxChangeRate)) obj.maxChangeRate = String(object.maxChangeRate); + return obj; + }, + toJSON(message: CommissionRates): JsonSafe { + const obj: any = {}; + message.rate !== undefined && (obj.rate = message.rate); + message.maxRate !== undefined && (obj.maxRate = message.maxRate); + message.maxChangeRate !== undefined && (obj.maxChangeRate = message.maxChangeRate); + return obj; + }, + fromPartial(object: DeepPartial): CommissionRates { + const message = createBaseCommissionRates(); + message.rate = object.rate ?? ""; + message.maxRate = object.maxRate ?? ""; + message.maxChangeRate = object.maxChangeRate ?? ""; + return message; + }, + fromSDK(object: CommissionRatesSDKType): CommissionRates { + return { + rate: object?.rate, + maxRate: object?.max_rate, + maxChangeRate: object?.max_change_rate + }; + }, + fromSDKJSON(object: any): CommissionRatesSDKType { + return { + rate: isSet(object.rate) ? String(object.rate) : "", + max_rate: isSet(object.max_rate) ? String(object.max_rate) : "", + max_change_rate: isSet(object.max_change_rate) ? String(object.max_change_rate) : "" + }; + }, + toSDK(message: CommissionRates): CommissionRatesSDKType { + const obj: any = {}; + obj.rate = message.rate; + obj.max_rate = message.maxRate; + obj.max_change_rate = message.maxChangeRate; + return obj; + }, + fromAmino(object: CommissionRatesAmino): CommissionRates { + const message = createBaseCommissionRates(); + if (object.rate !== undefined && object.rate !== null) { + message.rate = object.rate; + } + if (object.max_rate !== undefined && object.max_rate !== null) { + message.maxRate = object.max_rate; + } + if (object.max_change_rate !== undefined && object.max_change_rate !== null) { + message.maxChangeRate = object.max_change_rate; + } + return message; + }, + toAmino(message: CommissionRates): CommissionRatesAmino { + const obj: any = {}; + obj.rate = message.rate === "" ? undefined : message.rate; + obj.max_rate = message.maxRate === "" ? undefined : message.maxRate; + obj.max_change_rate = message.maxChangeRate === "" ? undefined : message.maxChangeRate; + return obj; + }, + fromAminoMsg(object: CommissionRatesAminoMsg): CommissionRates { + return CommissionRates.fromAmino(object.value); + }, + toAminoMsg(message: CommissionRates): CommissionRatesAminoMsg { + return { + type: "cosmos-sdk/CommissionRates", + value: CommissionRates.toAmino(message) + }; + }, + fromProtoMsg(message: CommissionRatesProtoMsg): CommissionRates { + return CommissionRates.decode(message.value); + }, + toProto(message: CommissionRates): Uint8Array { + return CommissionRates.encode(message).finish(); + }, + toProtoMsg(message: CommissionRates): CommissionRatesProtoMsg { + return { + typeUrl: "/cosmos.staking.v1beta1.CommissionRates", + value: CommissionRates.encode(message).finish() + }; + } +}; +function createBaseCommission(): Commission { + return { + commissionRates: CommissionRates.fromPartial({}), + updateTime: new Date() + }; +} +export const Commission = { + typeUrl: "/cosmos.staking.v1beta1.Commission", + encode(message: Commission, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.commissionRates !== undefined) { + CommissionRates.encode(message.commissionRates, writer.uint32(10).fork()).ldelim(); + } + if (message.updateTime !== undefined) { + Timestamp.encode(toTimestamp(message.updateTime), writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Commission { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCommission(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.commissionRates = CommissionRates.decode(reader, reader.uint32()); + break; + case 2: + message.updateTime = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Commission { + const obj = createBaseCommission(); + if (isSet(object.commissionRates)) obj.commissionRates = CommissionRates.fromJSON(object.commissionRates); + if (isSet(object.updateTime)) obj.updateTime = new Date(object.updateTime); + return obj; + }, + toJSON(message: Commission): JsonSafe { + const obj: any = {}; + message.commissionRates !== undefined && (obj.commissionRates = message.commissionRates ? CommissionRates.toJSON(message.commissionRates) : undefined); + message.updateTime !== undefined && (obj.updateTime = message.updateTime.toISOString()); + return obj; + }, + fromPartial(object: DeepPartial): Commission { + const message = createBaseCommission(); + if (object.commissionRates !== undefined && object.commissionRates !== null) { + message.commissionRates = CommissionRates.fromPartial(object.commissionRates); + } + message.updateTime = object.updateTime ?? undefined; + return message; + }, + fromSDK(object: CommissionSDKType): Commission { + return { + commissionRates: object.commission_rates ? CommissionRates.fromSDK(object.commission_rates) : undefined, + updateTime: object.update_time ?? undefined + }; + }, + fromSDKJSON(object: any): CommissionSDKType { + return { + commission_rates: isSet(object.commission_rates) ? CommissionRates.fromSDKJSON(object.commission_rates) : undefined, + update_time: isSet(object.update_time) ? new Date(object.update_time) : undefined + }; + }, + toSDK(message: Commission): CommissionSDKType { + const obj: any = {}; + message.commissionRates !== undefined && (obj.commission_rates = message.commissionRates ? CommissionRates.toSDK(message.commissionRates) : undefined); + message.updateTime !== undefined && (obj.update_time = message.updateTime ?? undefined); + return obj; + }, + fromAmino(object: CommissionAmino): Commission { + const message = createBaseCommission(); + if (object.commission_rates !== undefined && object.commission_rates !== null) { + message.commissionRates = CommissionRates.fromAmino(object.commission_rates); + } + if (object.update_time !== undefined && object.update_time !== null) { + message.updateTime = fromTimestamp(Timestamp.fromAmino(object.update_time)); + } + return message; + }, + toAmino(message: Commission): CommissionAmino { + const obj: any = {}; + obj.commission_rates = message.commissionRates ? CommissionRates.toAmino(message.commissionRates) : undefined; + obj.update_time = message.updateTime ? Timestamp.toAmino(toTimestamp(message.updateTime)) : undefined; + return obj; + }, + fromAminoMsg(object: CommissionAminoMsg): Commission { + return Commission.fromAmino(object.value); + }, + toAminoMsg(message: Commission): CommissionAminoMsg { + return { + type: "cosmos-sdk/Commission", + value: Commission.toAmino(message) + }; + }, + fromProtoMsg(message: CommissionProtoMsg): Commission { + return Commission.decode(message.value); + }, + toProto(message: Commission): Uint8Array { + return Commission.encode(message).finish(); + }, + toProtoMsg(message: Commission): CommissionProtoMsg { + return { + typeUrl: "/cosmos.staking.v1beta1.Commission", + value: Commission.encode(message).finish() + }; + } +}; +function createBaseDescription(): Description { + return { + moniker: "", + identity: "", + website: "", + securityContact: "", + details: "" + }; +} +export const Description = { + typeUrl: "/cosmos.staking.v1beta1.Description", + encode(message: Description, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.moniker !== undefined) { + writer.uint32(10).string(message.moniker); + } + if (message.identity !== undefined) { + writer.uint32(18).string(message.identity); + } + if (message.website !== undefined) { + writer.uint32(26).string(message.website); + } + if (message.securityContact !== undefined) { + writer.uint32(34).string(message.securityContact); + } + if (message.details !== undefined) { + writer.uint32(42).string(message.details); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Description { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDescription(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.moniker = reader.string(); + break; + case 2: + message.identity = reader.string(); + break; + case 3: + message.website = reader.string(); + break; + case 4: + message.securityContact = reader.string(); + break; + case 5: + message.details = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Description { + const obj = createBaseDescription(); + if (isSet(object.moniker)) obj.moniker = String(object.moniker); + if (isSet(object.identity)) obj.identity = String(object.identity); + if (isSet(object.website)) obj.website = String(object.website); + if (isSet(object.securityContact)) obj.securityContact = String(object.securityContact); + if (isSet(object.details)) obj.details = String(object.details); + return obj; + }, + toJSON(message: Description): JsonSafe { + const obj: any = {}; + message.moniker !== undefined && (obj.moniker = message.moniker); + message.identity !== undefined && (obj.identity = message.identity); + message.website !== undefined && (obj.website = message.website); + message.securityContact !== undefined && (obj.securityContact = message.securityContact); + message.details !== undefined && (obj.details = message.details); + return obj; + }, + fromPartial(object: DeepPartial): Description { + const message = createBaseDescription(); + message.moniker = object.moniker ?? ""; + message.identity = object.identity ?? ""; + message.website = object.website ?? ""; + message.securityContact = object.securityContact ?? ""; + message.details = object.details ?? ""; + return message; + }, + fromSDK(object: DescriptionSDKType): Description { + return { + moniker: object?.moniker, + identity: object?.identity, + website: object?.website, + securityContact: object?.security_contact, + details: object?.details + }; + }, + fromSDKJSON(object: any): DescriptionSDKType { + return { + moniker: isSet(object.moniker) ? String(object.moniker) : "", + identity: isSet(object.identity) ? String(object.identity) : "", + website: isSet(object.website) ? String(object.website) : "", + security_contact: isSet(object.security_contact) ? String(object.security_contact) : "", + details: isSet(object.details) ? String(object.details) : "" + }; + }, + toSDK(message: Description): DescriptionSDKType { + const obj: any = {}; + obj.moniker = message.moniker; + obj.identity = message.identity; + obj.website = message.website; + obj.security_contact = message.securityContact; + obj.details = message.details; + return obj; + }, + fromAmino(object: DescriptionAmino): Description { + const message = createBaseDescription(); + if (object.moniker !== undefined && object.moniker !== null) { + message.moniker = object.moniker; + } + if (object.identity !== undefined && object.identity !== null) { + message.identity = object.identity; + } + if (object.website !== undefined && object.website !== null) { + message.website = object.website; + } + if (object.security_contact !== undefined && object.security_contact !== null) { + message.securityContact = object.security_contact; + } + if (object.details !== undefined && object.details !== null) { + message.details = object.details; + } + return message; + }, + toAmino(message: Description): DescriptionAmino { + const obj: any = {}; + obj.moniker = message.moniker === "" ? undefined : message.moniker; + obj.identity = message.identity === "" ? undefined : message.identity; + obj.website = message.website === "" ? undefined : message.website; + obj.security_contact = message.securityContact === "" ? undefined : message.securityContact; + obj.details = message.details === "" ? undefined : message.details; + return obj; + }, + fromAminoMsg(object: DescriptionAminoMsg): Description { + return Description.fromAmino(object.value); + }, + toAminoMsg(message: Description): DescriptionAminoMsg { + return { + type: "cosmos-sdk/Description", + value: Description.toAmino(message) + }; + }, + fromProtoMsg(message: DescriptionProtoMsg): Description { + return Description.decode(message.value); + }, + toProto(message: Description): Uint8Array { + return Description.encode(message).finish(); + }, + toProtoMsg(message: Description): DescriptionProtoMsg { + return { + typeUrl: "/cosmos.staking.v1beta1.Description", + value: Description.encode(message).finish() + }; + } +}; +function createBaseValidator(): Validator { + return { + operatorAddress: "", + consensusPubkey: undefined, + jailed: false, + status: 0, + tokens: "", + delegatorShares: "", + description: Description.fromPartial({}), + unbondingHeight: BigInt(0), + unbondingTime: new Date(), + commission: Commission.fromPartial({}), + minSelfDelegation: "" + }; +} +export const Validator = { + typeUrl: "/cosmos.staking.v1beta1.Validator", + encode(message: Validator, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.operatorAddress !== undefined) { + writer.uint32(10).string(message.operatorAddress); + } + if (message.consensusPubkey !== undefined) { + Any.encode(message.consensusPubkey, writer.uint32(18).fork()).ldelim(); + } + if (message.jailed !== undefined) { + writer.uint32(24).bool(message.jailed); + } + if (message.status !== 0) { + writer.uint32(32).int32(message.status); + } + if (message.tokens !== undefined) { + writer.uint32(42).string(message.tokens); + } + if (message.delegatorShares !== undefined) { + writer.uint32(50).string(Decimal.fromUserInput(message.delegatorShares, 18).atomics); + } + if (message.description !== undefined) { + Description.encode(message.description, writer.uint32(58).fork()).ldelim(); + } + if (message.unbondingHeight !== undefined) { + writer.uint32(64).int64(message.unbondingHeight); + } + if (message.unbondingTime !== undefined) { + Timestamp.encode(toTimestamp(message.unbondingTime), writer.uint32(74).fork()).ldelim(); + } + if (message.commission !== undefined) { + Commission.encode(message.commission, writer.uint32(82).fork()).ldelim(); + } + if (message.minSelfDelegation !== undefined) { + writer.uint32(90).string(message.minSelfDelegation); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Validator { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseValidator(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.operatorAddress = reader.string(); + break; + case 2: + message.consensusPubkey = Any.decode(reader, reader.uint32()); + break; + case 3: + message.jailed = reader.bool(); + break; + case 4: + message.status = (reader.int32() as any); + break; + case 5: + message.tokens = reader.string(); + break; + case 6: + message.delegatorShares = Decimal.fromAtomics(reader.string(), 18).toString(); + break; + case 7: + message.description = Description.decode(reader, reader.uint32()); + break; + case 8: + message.unbondingHeight = reader.int64(); + break; + case 9: + message.unbondingTime = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + break; + case 10: + message.commission = Commission.decode(reader, reader.uint32()); + break; + case 11: + message.minSelfDelegation = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Validator { + const obj = createBaseValidator(); + if (isSet(object.operatorAddress)) obj.operatorAddress = String(object.operatorAddress); + if (isSet(object.consensusPubkey)) obj.consensusPubkey = Any.fromJSON(object.consensusPubkey); + if (isSet(object.jailed)) obj.jailed = Boolean(object.jailed); + if (isSet(object.status)) obj.status = bondStatusFromJSON(object.status); + if (isSet(object.tokens)) obj.tokens = String(object.tokens); + if (isSet(object.delegatorShares)) obj.delegatorShares = String(object.delegatorShares); + if (isSet(object.description)) obj.description = Description.fromJSON(object.description); + if (isSet(object.unbondingHeight)) obj.unbondingHeight = BigInt(object.unbondingHeight.toString()); + if (isSet(object.unbondingTime)) obj.unbondingTime = new Date(object.unbondingTime); + if (isSet(object.commission)) obj.commission = Commission.fromJSON(object.commission); + if (isSet(object.minSelfDelegation)) obj.minSelfDelegation = String(object.minSelfDelegation); + return obj; + }, + toJSON(message: Validator): JsonSafe { + const obj: any = {}; + message.operatorAddress !== undefined && (obj.operatorAddress = message.operatorAddress); + message.consensusPubkey !== undefined && (obj.consensusPubkey = message.consensusPubkey ? Any.toJSON(message.consensusPubkey) : undefined); + message.jailed !== undefined && (obj.jailed = message.jailed); + message.status !== undefined && (obj.status = bondStatusToJSON(message.status)); + message.tokens !== undefined && (obj.tokens = message.tokens); + message.delegatorShares !== undefined && (obj.delegatorShares = message.delegatorShares); + message.description !== undefined && (obj.description = message.description ? Description.toJSON(message.description) : undefined); + message.unbondingHeight !== undefined && (obj.unbondingHeight = (message.unbondingHeight || BigInt(0)).toString()); + message.unbondingTime !== undefined && (obj.unbondingTime = message.unbondingTime.toISOString()); + message.commission !== undefined && (obj.commission = message.commission ? Commission.toJSON(message.commission) : undefined); + message.minSelfDelegation !== undefined && (obj.minSelfDelegation = message.minSelfDelegation); + return obj; + }, + fromPartial(object: DeepPartial): Validator { + const message = createBaseValidator(); + message.operatorAddress = object.operatorAddress ?? ""; + if (object.consensusPubkey !== undefined && object.consensusPubkey !== null) { + message.consensusPubkey = Any.fromPartial(object.consensusPubkey); + } + message.jailed = object.jailed ?? false; + message.status = object.status ?? 0; + message.tokens = object.tokens ?? ""; + message.delegatorShares = object.delegatorShares ?? ""; + if (object.description !== undefined && object.description !== null) { + message.description = Description.fromPartial(object.description); + } + if (object.unbondingHeight !== undefined && object.unbondingHeight !== null) { + message.unbondingHeight = BigInt(object.unbondingHeight.toString()); + } + message.unbondingTime = object.unbondingTime ?? undefined; + if (object.commission !== undefined && object.commission !== null) { + message.commission = Commission.fromPartial(object.commission); + } + message.minSelfDelegation = object.minSelfDelegation ?? ""; + return message; + }, + fromSDK(object: ValidatorSDKType): Validator { + return { + operatorAddress: object?.operator_address, + consensusPubkey: object.consensus_pubkey ? Any.fromSDK(object.consensus_pubkey) : undefined, + jailed: object?.jailed, + status: isSet(object.status) ? bondStatusFromJSON(object.status) : -1, + tokens: object?.tokens, + delegatorShares: object?.delegator_shares, + description: object.description ? Description.fromSDK(object.description) : undefined, + unbondingHeight: object?.unbonding_height, + unbondingTime: object.unbonding_time ?? undefined, + commission: object.commission ? Commission.fromSDK(object.commission) : undefined, + minSelfDelegation: object?.min_self_delegation + }; + }, + fromSDKJSON(object: any): ValidatorSDKType { + return { + operator_address: isSet(object.operator_address) ? String(object.operator_address) : "", + consensus_pubkey: isSet(object.consensus_pubkey) ? Any.fromSDKJSON(object.consensus_pubkey) : undefined, + jailed: isSet(object.jailed) ? Boolean(object.jailed) : false, + status: isSet(object.status) ? bondStatusFromJSON(object.status) : -1, + tokens: isSet(object.tokens) ? String(object.tokens) : "", + delegator_shares: isSet(object.delegator_shares) ? String(object.delegator_shares) : "", + description: isSet(object.description) ? Description.fromSDKJSON(object.description) : undefined, + unbonding_height: isSet(object.unbonding_height) ? BigInt(object.unbonding_height.toString()) : BigInt(0), + unbonding_time: isSet(object.unbonding_time) ? new Date(object.unbonding_time) : undefined, + commission: isSet(object.commission) ? Commission.fromSDKJSON(object.commission) : undefined, + min_self_delegation: isSet(object.min_self_delegation) ? String(object.min_self_delegation) : "" + }; + }, + toSDK(message: Validator): ValidatorSDKType { + const obj: any = {}; + obj.operator_address = message.operatorAddress; + message.consensusPubkey !== undefined && (obj.consensus_pubkey = message.consensusPubkey ? Any.toSDK(message.consensusPubkey) : undefined); + obj.jailed = message.jailed; + message.status !== undefined && (obj.status = bondStatusToJSON(message.status)); + obj.tokens = message.tokens; + obj.delegator_shares = message.delegatorShares; + message.description !== undefined && (obj.description = message.description ? Description.toSDK(message.description) : undefined); + obj.unbonding_height = message.unbondingHeight; + message.unbondingTime !== undefined && (obj.unbonding_time = message.unbondingTime ?? undefined); + message.commission !== undefined && (obj.commission = message.commission ? Commission.toSDK(message.commission) : undefined); + obj.min_self_delegation = message.minSelfDelegation; + return obj; + }, + fromAmino(object: ValidatorAmino): Validator { + const message = createBaseValidator(); + if (object.operator_address !== undefined && object.operator_address !== null) { + message.operatorAddress = object.operator_address; + } + if (object.consensus_pubkey !== undefined && object.consensus_pubkey !== null) { + message.consensusPubkey = encodePubkey(object.consensus_pubkey); + } + if (object.jailed !== undefined && object.jailed !== null) { + message.jailed = object.jailed; + } + if (object.status !== undefined && object.status !== null) { + message.status = object.status; + } + if (object.tokens !== undefined && object.tokens !== null) { + message.tokens = object.tokens; + } + if (object.delegator_shares !== undefined && object.delegator_shares !== null) { + message.delegatorShares = object.delegator_shares; + } + if (object.description !== undefined && object.description !== null) { + message.description = Description.fromAmino(object.description); + } + if (object.unbonding_height !== undefined && object.unbonding_height !== null) { + message.unbondingHeight = BigInt(object.unbonding_height); + } + if (object.unbonding_time !== undefined && object.unbonding_time !== null) { + message.unbondingTime = fromTimestamp(Timestamp.fromAmino(object.unbonding_time)); + } + if (object.commission !== undefined && object.commission !== null) { + message.commission = Commission.fromAmino(object.commission); + } + if (object.min_self_delegation !== undefined && object.min_self_delegation !== null) { + message.minSelfDelegation = object.min_self_delegation; + } + return message; + }, + toAmino(message: Validator): ValidatorAmino { + const obj: any = {}; + obj.operator_address = message.operatorAddress === "" ? undefined : message.operatorAddress; + obj.consensus_pubkey = message.consensusPubkey ? decodePubkey(message.consensusPubkey) : undefined; + obj.jailed = message.jailed === false ? undefined : message.jailed; + obj.status = message.status === 0 ? undefined : message.status; + obj.tokens = message.tokens === "" ? undefined : message.tokens; + obj.delegator_shares = message.delegatorShares === "" ? undefined : message.delegatorShares; + obj.description = message.description ? Description.toAmino(message.description) : undefined; + obj.unbonding_height = message.unbondingHeight !== BigInt(0) ? message.unbondingHeight?.toString() : undefined; + obj.unbonding_time = message.unbondingTime ? Timestamp.toAmino(toTimestamp(message.unbondingTime)) : undefined; + obj.commission = message.commission ? Commission.toAmino(message.commission) : undefined; + obj.min_self_delegation = message.minSelfDelegation === "" ? undefined : message.minSelfDelegation; + return obj; + }, + fromAminoMsg(object: ValidatorAminoMsg): Validator { + return Validator.fromAmino(object.value); + }, + toAminoMsg(message: Validator): ValidatorAminoMsg { + return { + type: "cosmos-sdk/Validator", + value: Validator.toAmino(message) + }; + }, + fromProtoMsg(message: ValidatorProtoMsg): Validator { + return Validator.decode(message.value); + }, + toProto(message: Validator): Uint8Array { + return Validator.encode(message).finish(); + }, + toProtoMsg(message: Validator): ValidatorProtoMsg { + return { + typeUrl: "/cosmos.staking.v1beta1.Validator", + value: Validator.encode(message).finish() + }; + } +}; +function createBaseValAddresses(): ValAddresses { + return { + addresses: [] + }; +} +export const ValAddresses = { + typeUrl: "/cosmos.staking.v1beta1.ValAddresses", + encode(message: ValAddresses, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.addresses) { + writer.uint32(10).string(v!); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ValAddresses { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseValAddresses(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.addresses.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ValAddresses { + const obj = createBaseValAddresses(); + if (Array.isArray(object?.addresses)) obj.addresses = object.addresses.map((e: any) => String(e)); + return obj; + }, + toJSON(message: ValAddresses): JsonSafe { + const obj: any = {}; + if (message.addresses) { + obj.addresses = message.addresses.map(e => e); + } else { + obj.addresses = []; + } + return obj; + }, + fromPartial(object: DeepPartial): ValAddresses { + const message = createBaseValAddresses(); + message.addresses = object.addresses?.map(e => e) || []; + return message; + }, + fromSDK(object: ValAddressesSDKType): ValAddresses { + return { + addresses: Array.isArray(object?.addresses) ? object.addresses.map((e: any) => e) : [] + }; + }, + fromSDKJSON(object: any): ValAddressesSDKType { + return { + addresses: Array.isArray(object?.addresses) ? object.addresses.map((e: any) => String(e)) : [] + }; + }, + toSDK(message: ValAddresses): ValAddressesSDKType { + const obj: any = {}; + if (message.addresses) { + obj.addresses = message.addresses.map(e => e); + } else { + obj.addresses = []; + } + return obj; + }, + fromAmino(object: ValAddressesAmino): ValAddresses { + const message = createBaseValAddresses(); + message.addresses = object.addresses?.map(e => e) || []; + return message; + }, + toAmino(message: ValAddresses): ValAddressesAmino { + const obj: any = {}; + if (message.addresses) { + obj.addresses = message.addresses.map(e => e); + } else { + obj.addresses = message.addresses; + } + return obj; + }, + fromAminoMsg(object: ValAddressesAminoMsg): ValAddresses { + return ValAddresses.fromAmino(object.value); + }, + toAminoMsg(message: ValAddresses): ValAddressesAminoMsg { + return { + type: "cosmos-sdk/ValAddresses", + value: ValAddresses.toAmino(message) + }; + }, + fromProtoMsg(message: ValAddressesProtoMsg): ValAddresses { + return ValAddresses.decode(message.value); + }, + toProto(message: ValAddresses): Uint8Array { + return ValAddresses.encode(message).finish(); + }, + toProtoMsg(message: ValAddresses): ValAddressesProtoMsg { + return { + typeUrl: "/cosmos.staking.v1beta1.ValAddresses", + value: ValAddresses.encode(message).finish() + }; + } +}; +function createBaseDVPair(): DVPair { + return { + delegatorAddress: "", + validatorAddress: "" + }; +} +export const DVPair = { + typeUrl: "/cosmos.staking.v1beta1.DVPair", + encode(message: DVPair, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.delegatorAddress !== undefined) { + writer.uint32(10).string(message.delegatorAddress); + } + if (message.validatorAddress !== undefined) { + writer.uint32(18).string(message.validatorAddress); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): DVPair { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDVPair(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.delegatorAddress = reader.string(); + break; + case 2: + message.validatorAddress = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): DVPair { + const obj = createBaseDVPair(); + if (isSet(object.delegatorAddress)) obj.delegatorAddress = String(object.delegatorAddress); + if (isSet(object.validatorAddress)) obj.validatorAddress = String(object.validatorAddress); + return obj; + }, + toJSON(message: DVPair): JsonSafe { + const obj: any = {}; + message.delegatorAddress !== undefined && (obj.delegatorAddress = message.delegatorAddress); + message.validatorAddress !== undefined && (obj.validatorAddress = message.validatorAddress); + return obj; + }, + fromPartial(object: DeepPartial): DVPair { + const message = createBaseDVPair(); + message.delegatorAddress = object.delegatorAddress ?? ""; + message.validatorAddress = object.validatorAddress ?? ""; + return message; + }, + fromSDK(object: DVPairSDKType): DVPair { + return { + delegatorAddress: object?.delegator_address, + validatorAddress: object?.validator_address + }; + }, + fromSDKJSON(object: any): DVPairSDKType { + return { + delegator_address: isSet(object.delegator_address) ? String(object.delegator_address) : "", + validator_address: isSet(object.validator_address) ? String(object.validator_address) : "" + }; + }, + toSDK(message: DVPair): DVPairSDKType { + const obj: any = {}; + obj.delegator_address = message.delegatorAddress; + obj.validator_address = message.validatorAddress; + return obj; + }, + fromAmino(object: DVPairAmino): DVPair { + const message = createBaseDVPair(); + if (object.delegator_address !== undefined && object.delegator_address !== null) { + message.delegatorAddress = object.delegator_address; + } + if (object.validator_address !== undefined && object.validator_address !== null) { + message.validatorAddress = object.validator_address; + } + return message; + }, + toAmino(message: DVPair): DVPairAmino { + const obj: any = {}; + obj.delegator_address = message.delegatorAddress === "" ? undefined : message.delegatorAddress; + obj.validator_address = message.validatorAddress === "" ? undefined : message.validatorAddress; + return obj; + }, + fromAminoMsg(object: DVPairAminoMsg): DVPair { + return DVPair.fromAmino(object.value); + }, + toAminoMsg(message: DVPair): DVPairAminoMsg { + return { + type: "cosmos-sdk/DVPair", + value: DVPair.toAmino(message) + }; + }, + fromProtoMsg(message: DVPairProtoMsg): DVPair { + return DVPair.decode(message.value); + }, + toProto(message: DVPair): Uint8Array { + return DVPair.encode(message).finish(); + }, + toProtoMsg(message: DVPair): DVPairProtoMsg { + return { + typeUrl: "/cosmos.staking.v1beta1.DVPair", + value: DVPair.encode(message).finish() + }; + } +}; +function createBaseDVPairs(): DVPairs { + return { + pairs: [] + }; +} +export const DVPairs = { + typeUrl: "/cosmos.staking.v1beta1.DVPairs", + encode(message: DVPairs, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.pairs) { + DVPair.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): DVPairs { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDVPairs(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.pairs.push(DVPair.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): DVPairs { + const obj = createBaseDVPairs(); + if (Array.isArray(object?.pairs)) obj.pairs = object.pairs.map((e: any) => DVPair.fromJSON(e)); + return obj; + }, + toJSON(message: DVPairs): JsonSafe { + const obj: any = {}; + if (message.pairs) { + obj.pairs = message.pairs.map(e => e ? DVPair.toJSON(e) : undefined); + } else { + obj.pairs = []; + } + return obj; + }, + fromPartial(object: DeepPartial): DVPairs { + const message = createBaseDVPairs(); + message.pairs = object.pairs?.map(e => DVPair.fromPartial(e)) || []; + return message; + }, + fromSDK(object: DVPairsSDKType): DVPairs { + return { + pairs: Array.isArray(object?.pairs) ? object.pairs.map((e: any) => DVPair.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): DVPairsSDKType { + return { + pairs: Array.isArray(object?.pairs) ? object.pairs.map((e: any) => DVPair.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: DVPairs): DVPairsSDKType { + const obj: any = {}; + if (message.pairs) { + obj.pairs = message.pairs.map(e => e ? DVPair.toSDK(e) : undefined); + } else { + obj.pairs = []; + } + return obj; + }, + fromAmino(object: DVPairsAmino): DVPairs { + const message = createBaseDVPairs(); + message.pairs = object.pairs?.map(e => DVPair.fromAmino(e)) || []; + return message; + }, + toAmino(message: DVPairs): DVPairsAmino { + const obj: any = {}; + if (message.pairs) { + obj.pairs = message.pairs.map(e => e ? DVPair.toAmino(e) : undefined); + } else { + obj.pairs = message.pairs; + } + return obj; + }, + fromAminoMsg(object: DVPairsAminoMsg): DVPairs { + return DVPairs.fromAmino(object.value); + }, + toAminoMsg(message: DVPairs): DVPairsAminoMsg { + return { + type: "cosmos-sdk/DVPairs", + value: DVPairs.toAmino(message) + }; + }, + fromProtoMsg(message: DVPairsProtoMsg): DVPairs { + return DVPairs.decode(message.value); + }, + toProto(message: DVPairs): Uint8Array { + return DVPairs.encode(message).finish(); + }, + toProtoMsg(message: DVPairs): DVPairsProtoMsg { + return { + typeUrl: "/cosmos.staking.v1beta1.DVPairs", + value: DVPairs.encode(message).finish() + }; + } +}; +function createBaseDVVTriplet(): DVVTriplet { + return { + delegatorAddress: "", + validatorSrcAddress: "", + validatorDstAddress: "" + }; +} +export const DVVTriplet = { + typeUrl: "/cosmos.staking.v1beta1.DVVTriplet", + encode(message: DVVTriplet, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.delegatorAddress !== undefined) { + writer.uint32(10).string(message.delegatorAddress); + } + if (message.validatorSrcAddress !== undefined) { + writer.uint32(18).string(message.validatorSrcAddress); + } + if (message.validatorDstAddress !== undefined) { + writer.uint32(26).string(message.validatorDstAddress); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): DVVTriplet { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDVVTriplet(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.delegatorAddress = reader.string(); + break; + case 2: + message.validatorSrcAddress = reader.string(); + break; + case 3: + message.validatorDstAddress = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): DVVTriplet { + const obj = createBaseDVVTriplet(); + if (isSet(object.delegatorAddress)) obj.delegatorAddress = String(object.delegatorAddress); + if (isSet(object.validatorSrcAddress)) obj.validatorSrcAddress = String(object.validatorSrcAddress); + if (isSet(object.validatorDstAddress)) obj.validatorDstAddress = String(object.validatorDstAddress); + return obj; + }, + toJSON(message: DVVTriplet): JsonSafe { + const obj: any = {}; + message.delegatorAddress !== undefined && (obj.delegatorAddress = message.delegatorAddress); + message.validatorSrcAddress !== undefined && (obj.validatorSrcAddress = message.validatorSrcAddress); + message.validatorDstAddress !== undefined && (obj.validatorDstAddress = message.validatorDstAddress); + return obj; + }, + fromPartial(object: DeepPartial): DVVTriplet { + const message = createBaseDVVTriplet(); + message.delegatorAddress = object.delegatorAddress ?? ""; + message.validatorSrcAddress = object.validatorSrcAddress ?? ""; + message.validatorDstAddress = object.validatorDstAddress ?? ""; + return message; + }, + fromSDK(object: DVVTripletSDKType): DVVTriplet { + return { + delegatorAddress: object?.delegator_address, + validatorSrcAddress: object?.validator_src_address, + validatorDstAddress: object?.validator_dst_address + }; + }, + fromSDKJSON(object: any): DVVTripletSDKType { + return { + delegator_address: isSet(object.delegator_address) ? String(object.delegator_address) : "", + validator_src_address: isSet(object.validator_src_address) ? String(object.validator_src_address) : "", + validator_dst_address: isSet(object.validator_dst_address) ? String(object.validator_dst_address) : "" + }; + }, + toSDK(message: DVVTriplet): DVVTripletSDKType { + const obj: any = {}; + obj.delegator_address = message.delegatorAddress; + obj.validator_src_address = message.validatorSrcAddress; + obj.validator_dst_address = message.validatorDstAddress; + return obj; + }, + fromAmino(object: DVVTripletAmino): DVVTriplet { + const message = createBaseDVVTriplet(); + if (object.delegator_address !== undefined && object.delegator_address !== null) { + message.delegatorAddress = object.delegator_address; + } + if (object.validator_src_address !== undefined && object.validator_src_address !== null) { + message.validatorSrcAddress = object.validator_src_address; + } + if (object.validator_dst_address !== undefined && object.validator_dst_address !== null) { + message.validatorDstAddress = object.validator_dst_address; + } + return message; + }, + toAmino(message: DVVTriplet): DVVTripletAmino { + const obj: any = {}; + obj.delegator_address = message.delegatorAddress === "" ? undefined : message.delegatorAddress; + obj.validator_src_address = message.validatorSrcAddress === "" ? undefined : message.validatorSrcAddress; + obj.validator_dst_address = message.validatorDstAddress === "" ? undefined : message.validatorDstAddress; + return obj; + }, + fromAminoMsg(object: DVVTripletAminoMsg): DVVTriplet { + return DVVTriplet.fromAmino(object.value); + }, + toAminoMsg(message: DVVTriplet): DVVTripletAminoMsg { + return { + type: "cosmos-sdk/DVVTriplet", + value: DVVTriplet.toAmino(message) + }; + }, + fromProtoMsg(message: DVVTripletProtoMsg): DVVTriplet { + return DVVTriplet.decode(message.value); + }, + toProto(message: DVVTriplet): Uint8Array { + return DVVTriplet.encode(message).finish(); + }, + toProtoMsg(message: DVVTriplet): DVVTripletProtoMsg { + return { + typeUrl: "/cosmos.staking.v1beta1.DVVTriplet", + value: DVVTriplet.encode(message).finish() + }; + } +}; +function createBaseDVVTriplets(): DVVTriplets { + return { + triplets: [] + }; +} +export const DVVTriplets = { + typeUrl: "/cosmos.staking.v1beta1.DVVTriplets", + encode(message: DVVTriplets, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.triplets) { + DVVTriplet.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): DVVTriplets { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDVVTriplets(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.triplets.push(DVVTriplet.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): DVVTriplets { + const obj = createBaseDVVTriplets(); + if (Array.isArray(object?.triplets)) obj.triplets = object.triplets.map((e: any) => DVVTriplet.fromJSON(e)); + return obj; + }, + toJSON(message: DVVTriplets): JsonSafe { + const obj: any = {}; + if (message.triplets) { + obj.triplets = message.triplets.map(e => e ? DVVTriplet.toJSON(e) : undefined); + } else { + obj.triplets = []; + } + return obj; + }, + fromPartial(object: DeepPartial): DVVTriplets { + const message = createBaseDVVTriplets(); + message.triplets = object.triplets?.map(e => DVVTriplet.fromPartial(e)) || []; + return message; + }, + fromSDK(object: DVVTripletsSDKType): DVVTriplets { + return { + triplets: Array.isArray(object?.triplets) ? object.triplets.map((e: any) => DVVTriplet.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): DVVTripletsSDKType { + return { + triplets: Array.isArray(object?.triplets) ? object.triplets.map((e: any) => DVVTriplet.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: DVVTriplets): DVVTripletsSDKType { + const obj: any = {}; + if (message.triplets) { + obj.triplets = message.triplets.map(e => e ? DVVTriplet.toSDK(e) : undefined); + } else { + obj.triplets = []; + } + return obj; + }, + fromAmino(object: DVVTripletsAmino): DVVTriplets { + const message = createBaseDVVTriplets(); + message.triplets = object.triplets?.map(e => DVVTriplet.fromAmino(e)) || []; + return message; + }, + toAmino(message: DVVTriplets): DVVTripletsAmino { + const obj: any = {}; + if (message.triplets) { + obj.triplets = message.triplets.map(e => e ? DVVTriplet.toAmino(e) : undefined); + } else { + obj.triplets = message.triplets; + } + return obj; + }, + fromAminoMsg(object: DVVTripletsAminoMsg): DVVTriplets { + return DVVTriplets.fromAmino(object.value); + }, + toAminoMsg(message: DVVTriplets): DVVTripletsAminoMsg { + return { + type: "cosmos-sdk/DVVTriplets", + value: DVVTriplets.toAmino(message) + }; + }, + fromProtoMsg(message: DVVTripletsProtoMsg): DVVTriplets { + return DVVTriplets.decode(message.value); + }, + toProto(message: DVVTriplets): Uint8Array { + return DVVTriplets.encode(message).finish(); + }, + toProtoMsg(message: DVVTriplets): DVVTripletsProtoMsg { + return { + typeUrl: "/cosmos.staking.v1beta1.DVVTriplets", + value: DVVTriplets.encode(message).finish() + }; + } +}; +function createBaseDelegation(): Delegation { + return { + delegatorAddress: "", + validatorAddress: "", + shares: "" + }; +} +export const Delegation = { + typeUrl: "/cosmos.staking.v1beta1.Delegation", + encode(message: Delegation, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.delegatorAddress !== undefined) { + writer.uint32(10).string(message.delegatorAddress); + } + if (message.validatorAddress !== undefined) { + writer.uint32(18).string(message.validatorAddress); + } + if (message.shares !== undefined) { + writer.uint32(26).string(Decimal.fromUserInput(message.shares, 18).atomics); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Delegation { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDelegation(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.delegatorAddress = reader.string(); + break; + case 2: + message.validatorAddress = reader.string(); + break; + case 3: + message.shares = Decimal.fromAtomics(reader.string(), 18).toString(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Delegation { + const obj = createBaseDelegation(); + if (isSet(object.delegatorAddress)) obj.delegatorAddress = String(object.delegatorAddress); + if (isSet(object.validatorAddress)) obj.validatorAddress = String(object.validatorAddress); + if (isSet(object.shares)) obj.shares = String(object.shares); + return obj; + }, + toJSON(message: Delegation): JsonSafe { + const obj: any = {}; + message.delegatorAddress !== undefined && (obj.delegatorAddress = message.delegatorAddress); + message.validatorAddress !== undefined && (obj.validatorAddress = message.validatorAddress); + message.shares !== undefined && (obj.shares = message.shares); + return obj; + }, + fromPartial(object: DeepPartial): Delegation { + const message = createBaseDelegation(); + message.delegatorAddress = object.delegatorAddress ?? ""; + message.validatorAddress = object.validatorAddress ?? ""; + message.shares = object.shares ?? ""; + return message; + }, + fromSDK(object: DelegationSDKType): Delegation { + return { + delegatorAddress: object?.delegator_address, + validatorAddress: object?.validator_address, + shares: object?.shares + }; + }, + fromSDKJSON(object: any): DelegationSDKType { + return { + delegator_address: isSet(object.delegator_address) ? String(object.delegator_address) : "", + validator_address: isSet(object.validator_address) ? String(object.validator_address) : "", + shares: isSet(object.shares) ? String(object.shares) : "" + }; + }, + toSDK(message: Delegation): DelegationSDKType { + const obj: any = {}; + obj.delegator_address = message.delegatorAddress; + obj.validator_address = message.validatorAddress; + obj.shares = message.shares; + return obj; + }, + fromAmino(object: DelegationAmino): Delegation { + const message = createBaseDelegation(); + if (object.delegator_address !== undefined && object.delegator_address !== null) { + message.delegatorAddress = object.delegator_address; + } + if (object.validator_address !== undefined && object.validator_address !== null) { + message.validatorAddress = object.validator_address; + } + if (object.shares !== undefined && object.shares !== null) { + message.shares = object.shares; + } + return message; + }, + toAmino(message: Delegation): DelegationAmino { + const obj: any = {}; + obj.delegator_address = message.delegatorAddress === "" ? undefined : message.delegatorAddress; + obj.validator_address = message.validatorAddress === "" ? undefined : message.validatorAddress; + obj.shares = message.shares === "" ? undefined : message.shares; + return obj; + }, + fromAminoMsg(object: DelegationAminoMsg): Delegation { + return Delegation.fromAmino(object.value); + }, + toAminoMsg(message: Delegation): DelegationAminoMsg { + return { + type: "cosmos-sdk/Delegation", + value: Delegation.toAmino(message) + }; + }, + fromProtoMsg(message: DelegationProtoMsg): Delegation { + return Delegation.decode(message.value); + }, + toProto(message: Delegation): Uint8Array { + return Delegation.encode(message).finish(); + }, + toProtoMsg(message: Delegation): DelegationProtoMsg { + return { + typeUrl: "/cosmos.staking.v1beta1.Delegation", + value: Delegation.encode(message).finish() + }; + } +}; +function createBaseUnbondingDelegation(): UnbondingDelegation { + return { + delegatorAddress: "", + validatorAddress: "", + entries: [] + }; +} +export const UnbondingDelegation = { + typeUrl: "/cosmos.staking.v1beta1.UnbondingDelegation", + encode(message: UnbondingDelegation, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.delegatorAddress !== undefined) { + writer.uint32(10).string(message.delegatorAddress); + } + if (message.validatorAddress !== undefined) { + writer.uint32(18).string(message.validatorAddress); + } + for (const v of message.entries) { + UnbondingDelegationEntry.encode(v!, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): UnbondingDelegation { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseUnbondingDelegation(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.delegatorAddress = reader.string(); + break; + case 2: + message.validatorAddress = reader.string(); + break; + case 3: + message.entries.push(UnbondingDelegationEntry.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): UnbondingDelegation { + const obj = createBaseUnbondingDelegation(); + if (isSet(object.delegatorAddress)) obj.delegatorAddress = String(object.delegatorAddress); + if (isSet(object.validatorAddress)) obj.validatorAddress = String(object.validatorAddress); + if (Array.isArray(object?.entries)) obj.entries = object.entries.map((e: any) => UnbondingDelegationEntry.fromJSON(e)); + return obj; + }, + toJSON(message: UnbondingDelegation): JsonSafe { + const obj: any = {}; + message.delegatorAddress !== undefined && (obj.delegatorAddress = message.delegatorAddress); + message.validatorAddress !== undefined && (obj.validatorAddress = message.validatorAddress); + if (message.entries) { + obj.entries = message.entries.map(e => e ? UnbondingDelegationEntry.toJSON(e) : undefined); + } else { + obj.entries = []; + } + return obj; + }, + fromPartial(object: DeepPartial): UnbondingDelegation { + const message = createBaseUnbondingDelegation(); + message.delegatorAddress = object.delegatorAddress ?? ""; + message.validatorAddress = object.validatorAddress ?? ""; + message.entries = object.entries?.map(e => UnbondingDelegationEntry.fromPartial(e)) || []; + return message; + }, + fromSDK(object: UnbondingDelegationSDKType): UnbondingDelegation { + return { + delegatorAddress: object?.delegator_address, + validatorAddress: object?.validator_address, + entries: Array.isArray(object?.entries) ? object.entries.map((e: any) => UnbondingDelegationEntry.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): UnbondingDelegationSDKType { + return { + delegator_address: isSet(object.delegator_address) ? String(object.delegator_address) : "", + validator_address: isSet(object.validator_address) ? String(object.validator_address) : "", + entries: Array.isArray(object?.entries) ? object.entries.map((e: any) => UnbondingDelegationEntry.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: UnbondingDelegation): UnbondingDelegationSDKType { + const obj: any = {}; + obj.delegator_address = message.delegatorAddress; + obj.validator_address = message.validatorAddress; + if (message.entries) { + obj.entries = message.entries.map(e => e ? UnbondingDelegationEntry.toSDK(e) : undefined); + } else { + obj.entries = []; + } + return obj; + }, + fromAmino(object: UnbondingDelegationAmino): UnbondingDelegation { + const message = createBaseUnbondingDelegation(); + if (object.delegator_address !== undefined && object.delegator_address !== null) { + message.delegatorAddress = object.delegator_address; + } + if (object.validator_address !== undefined && object.validator_address !== null) { + message.validatorAddress = object.validator_address; + } + message.entries = object.entries?.map(e => UnbondingDelegationEntry.fromAmino(e)) || []; + return message; + }, + toAmino(message: UnbondingDelegation): UnbondingDelegationAmino { + const obj: any = {}; + obj.delegator_address = message.delegatorAddress === "" ? undefined : message.delegatorAddress; + obj.validator_address = message.validatorAddress === "" ? undefined : message.validatorAddress; + if (message.entries) { + obj.entries = message.entries.map(e => e ? UnbondingDelegationEntry.toAmino(e) : undefined); + } else { + obj.entries = message.entries; + } + return obj; + }, + fromAminoMsg(object: UnbondingDelegationAminoMsg): UnbondingDelegation { + return UnbondingDelegation.fromAmino(object.value); + }, + toAminoMsg(message: UnbondingDelegation): UnbondingDelegationAminoMsg { + return { + type: "cosmos-sdk/UnbondingDelegation", + value: UnbondingDelegation.toAmino(message) + }; + }, + fromProtoMsg(message: UnbondingDelegationProtoMsg): UnbondingDelegation { + return UnbondingDelegation.decode(message.value); + }, + toProto(message: UnbondingDelegation): Uint8Array { + return UnbondingDelegation.encode(message).finish(); + }, + toProtoMsg(message: UnbondingDelegation): UnbondingDelegationProtoMsg { + return { + typeUrl: "/cosmos.staking.v1beta1.UnbondingDelegation", + value: UnbondingDelegation.encode(message).finish() + }; + } +}; +function createBaseUnbondingDelegationEntry(): UnbondingDelegationEntry { + return { + creationHeight: BigInt(0), + completionTime: new Date(), + initialBalance: "", + balance: "" + }; +} +export const UnbondingDelegationEntry = { + typeUrl: "/cosmos.staking.v1beta1.UnbondingDelegationEntry", + encode(message: UnbondingDelegationEntry, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.creationHeight !== undefined) { + writer.uint32(8).int64(message.creationHeight); + } + if (message.completionTime !== undefined) { + Timestamp.encode(toTimestamp(message.completionTime), writer.uint32(18).fork()).ldelim(); + } + if (message.initialBalance !== undefined) { + writer.uint32(26).string(message.initialBalance); + } + if (message.balance !== undefined) { + writer.uint32(34).string(message.balance); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): UnbondingDelegationEntry { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseUnbondingDelegationEntry(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.creationHeight = reader.int64(); + break; + case 2: + message.completionTime = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + break; + case 3: + message.initialBalance = reader.string(); + break; + case 4: + message.balance = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): UnbondingDelegationEntry { + const obj = createBaseUnbondingDelegationEntry(); + if (isSet(object.creationHeight)) obj.creationHeight = BigInt(object.creationHeight.toString()); + if (isSet(object.completionTime)) obj.completionTime = new Date(object.completionTime); + if (isSet(object.initialBalance)) obj.initialBalance = String(object.initialBalance); + if (isSet(object.balance)) obj.balance = String(object.balance); + return obj; + }, + toJSON(message: UnbondingDelegationEntry): JsonSafe { + const obj: any = {}; + message.creationHeight !== undefined && (obj.creationHeight = (message.creationHeight || BigInt(0)).toString()); + message.completionTime !== undefined && (obj.completionTime = message.completionTime.toISOString()); + message.initialBalance !== undefined && (obj.initialBalance = message.initialBalance); + message.balance !== undefined && (obj.balance = message.balance); + return obj; + }, + fromPartial(object: DeepPartial): UnbondingDelegationEntry { + const message = createBaseUnbondingDelegationEntry(); + if (object.creationHeight !== undefined && object.creationHeight !== null) { + message.creationHeight = BigInt(object.creationHeight.toString()); + } + message.completionTime = object.completionTime ?? undefined; + message.initialBalance = object.initialBalance ?? ""; + message.balance = object.balance ?? ""; + return message; + }, + fromSDK(object: UnbondingDelegationEntrySDKType): UnbondingDelegationEntry { + return { + creationHeight: object?.creation_height, + completionTime: object.completion_time ?? undefined, + initialBalance: object?.initial_balance, + balance: object?.balance + }; + }, + fromSDKJSON(object: any): UnbondingDelegationEntrySDKType { + return { + creation_height: isSet(object.creation_height) ? BigInt(object.creation_height.toString()) : BigInt(0), + completion_time: isSet(object.completion_time) ? new Date(object.completion_time) : undefined, + initial_balance: isSet(object.initial_balance) ? String(object.initial_balance) : "", + balance: isSet(object.balance) ? String(object.balance) : "" + }; + }, + toSDK(message: UnbondingDelegationEntry): UnbondingDelegationEntrySDKType { + const obj: any = {}; + obj.creation_height = message.creationHeight; + message.completionTime !== undefined && (obj.completion_time = message.completionTime ?? undefined); + obj.initial_balance = message.initialBalance; + obj.balance = message.balance; + return obj; + }, + fromAmino(object: UnbondingDelegationEntryAmino): UnbondingDelegationEntry { + const message = createBaseUnbondingDelegationEntry(); + if (object.creation_height !== undefined && object.creation_height !== null) { + message.creationHeight = BigInt(object.creation_height); + } + if (object.completion_time !== undefined && object.completion_time !== null) { + message.completionTime = fromTimestamp(Timestamp.fromAmino(object.completion_time)); + } + if (object.initial_balance !== undefined && object.initial_balance !== null) { + message.initialBalance = object.initial_balance; + } + if (object.balance !== undefined && object.balance !== null) { + message.balance = object.balance; + } + return message; + }, + toAmino(message: UnbondingDelegationEntry): UnbondingDelegationEntryAmino { + const obj: any = {}; + obj.creation_height = message.creationHeight !== BigInt(0) ? message.creationHeight?.toString() : undefined; + obj.completion_time = message.completionTime ? Timestamp.toAmino(toTimestamp(message.completionTime)) : undefined; + obj.initial_balance = message.initialBalance === "" ? undefined : message.initialBalance; + obj.balance = message.balance === "" ? undefined : message.balance; + return obj; + }, + fromAminoMsg(object: UnbondingDelegationEntryAminoMsg): UnbondingDelegationEntry { + return UnbondingDelegationEntry.fromAmino(object.value); + }, + toAminoMsg(message: UnbondingDelegationEntry): UnbondingDelegationEntryAminoMsg { + return { + type: "cosmos-sdk/UnbondingDelegationEntry", + value: UnbondingDelegationEntry.toAmino(message) + }; + }, + fromProtoMsg(message: UnbondingDelegationEntryProtoMsg): UnbondingDelegationEntry { + return UnbondingDelegationEntry.decode(message.value); + }, + toProto(message: UnbondingDelegationEntry): Uint8Array { + return UnbondingDelegationEntry.encode(message).finish(); + }, + toProtoMsg(message: UnbondingDelegationEntry): UnbondingDelegationEntryProtoMsg { + return { + typeUrl: "/cosmos.staking.v1beta1.UnbondingDelegationEntry", + value: UnbondingDelegationEntry.encode(message).finish() + }; + } +}; +function createBaseRedelegationEntry(): RedelegationEntry { + return { + creationHeight: BigInt(0), + completionTime: new Date(), + initialBalance: "", + sharesDst: "" + }; +} +export const RedelegationEntry = { + typeUrl: "/cosmos.staking.v1beta1.RedelegationEntry", + encode(message: RedelegationEntry, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.creationHeight !== undefined) { + writer.uint32(8).int64(message.creationHeight); + } + if (message.completionTime !== undefined) { + Timestamp.encode(toTimestamp(message.completionTime), writer.uint32(18).fork()).ldelim(); + } + if (message.initialBalance !== undefined) { + writer.uint32(26).string(message.initialBalance); + } + if (message.sharesDst !== undefined) { + writer.uint32(34).string(Decimal.fromUserInput(message.sharesDst, 18).atomics); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): RedelegationEntry { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseRedelegationEntry(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.creationHeight = reader.int64(); + break; + case 2: + message.completionTime = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + break; + case 3: + message.initialBalance = reader.string(); + break; + case 4: + message.sharesDst = Decimal.fromAtomics(reader.string(), 18).toString(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): RedelegationEntry { + const obj = createBaseRedelegationEntry(); + if (isSet(object.creationHeight)) obj.creationHeight = BigInt(object.creationHeight.toString()); + if (isSet(object.completionTime)) obj.completionTime = new Date(object.completionTime); + if (isSet(object.initialBalance)) obj.initialBalance = String(object.initialBalance); + if (isSet(object.sharesDst)) obj.sharesDst = String(object.sharesDst); + return obj; + }, + toJSON(message: RedelegationEntry): JsonSafe { + const obj: any = {}; + message.creationHeight !== undefined && (obj.creationHeight = (message.creationHeight || BigInt(0)).toString()); + message.completionTime !== undefined && (obj.completionTime = message.completionTime.toISOString()); + message.initialBalance !== undefined && (obj.initialBalance = message.initialBalance); + message.sharesDst !== undefined && (obj.sharesDst = message.sharesDst); + return obj; + }, + fromPartial(object: DeepPartial): RedelegationEntry { + const message = createBaseRedelegationEntry(); + if (object.creationHeight !== undefined && object.creationHeight !== null) { + message.creationHeight = BigInt(object.creationHeight.toString()); + } + message.completionTime = object.completionTime ?? undefined; + message.initialBalance = object.initialBalance ?? ""; + message.sharesDst = object.sharesDst ?? ""; + return message; + }, + fromSDK(object: RedelegationEntrySDKType): RedelegationEntry { + return { + creationHeight: object?.creation_height, + completionTime: object.completion_time ?? undefined, + initialBalance: object?.initial_balance, + sharesDst: object?.shares_dst + }; + }, + fromSDKJSON(object: any): RedelegationEntrySDKType { + return { + creation_height: isSet(object.creation_height) ? BigInt(object.creation_height.toString()) : BigInt(0), + completion_time: isSet(object.completion_time) ? new Date(object.completion_time) : undefined, + initial_balance: isSet(object.initial_balance) ? String(object.initial_balance) : "", + shares_dst: isSet(object.shares_dst) ? String(object.shares_dst) : "" + }; + }, + toSDK(message: RedelegationEntry): RedelegationEntrySDKType { + const obj: any = {}; + obj.creation_height = message.creationHeight; + message.completionTime !== undefined && (obj.completion_time = message.completionTime ?? undefined); + obj.initial_balance = message.initialBalance; + obj.shares_dst = message.sharesDst; + return obj; + }, + fromAmino(object: RedelegationEntryAmino): RedelegationEntry { + const message = createBaseRedelegationEntry(); + if (object.creation_height !== undefined && object.creation_height !== null) { + message.creationHeight = BigInt(object.creation_height); + } + if (object.completion_time !== undefined && object.completion_time !== null) { + message.completionTime = fromTimestamp(Timestamp.fromAmino(object.completion_time)); + } + if (object.initial_balance !== undefined && object.initial_balance !== null) { + message.initialBalance = object.initial_balance; + } + if (object.shares_dst !== undefined && object.shares_dst !== null) { + message.sharesDst = object.shares_dst; + } + return message; + }, + toAmino(message: RedelegationEntry): RedelegationEntryAmino { + const obj: any = {}; + obj.creation_height = message.creationHeight !== BigInt(0) ? message.creationHeight?.toString() : undefined; + obj.completion_time = message.completionTime ? Timestamp.toAmino(toTimestamp(message.completionTime)) : undefined; + obj.initial_balance = message.initialBalance === "" ? undefined : message.initialBalance; + obj.shares_dst = message.sharesDst === "" ? undefined : message.sharesDst; + return obj; + }, + fromAminoMsg(object: RedelegationEntryAminoMsg): RedelegationEntry { + return RedelegationEntry.fromAmino(object.value); + }, + toAminoMsg(message: RedelegationEntry): RedelegationEntryAminoMsg { + return { + type: "cosmos-sdk/RedelegationEntry", + value: RedelegationEntry.toAmino(message) + }; + }, + fromProtoMsg(message: RedelegationEntryProtoMsg): RedelegationEntry { + return RedelegationEntry.decode(message.value); + }, + toProto(message: RedelegationEntry): Uint8Array { + return RedelegationEntry.encode(message).finish(); + }, + toProtoMsg(message: RedelegationEntry): RedelegationEntryProtoMsg { + return { + typeUrl: "/cosmos.staking.v1beta1.RedelegationEntry", + value: RedelegationEntry.encode(message).finish() + }; + } +}; +function createBaseRedelegation(): Redelegation { + return { + delegatorAddress: "", + validatorSrcAddress: "", + validatorDstAddress: "", + entries: [] + }; +} +export const Redelegation = { + typeUrl: "/cosmos.staking.v1beta1.Redelegation", + encode(message: Redelegation, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.delegatorAddress !== undefined) { + writer.uint32(10).string(message.delegatorAddress); + } + if (message.validatorSrcAddress !== undefined) { + writer.uint32(18).string(message.validatorSrcAddress); + } + if (message.validatorDstAddress !== undefined) { + writer.uint32(26).string(message.validatorDstAddress); + } + for (const v of message.entries) { + RedelegationEntry.encode(v!, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Redelegation { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseRedelegation(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.delegatorAddress = reader.string(); + break; + case 2: + message.validatorSrcAddress = reader.string(); + break; + case 3: + message.validatorDstAddress = reader.string(); + break; + case 4: + message.entries.push(RedelegationEntry.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Redelegation { + const obj = createBaseRedelegation(); + if (isSet(object.delegatorAddress)) obj.delegatorAddress = String(object.delegatorAddress); + if (isSet(object.validatorSrcAddress)) obj.validatorSrcAddress = String(object.validatorSrcAddress); + if (isSet(object.validatorDstAddress)) obj.validatorDstAddress = String(object.validatorDstAddress); + if (Array.isArray(object?.entries)) obj.entries = object.entries.map((e: any) => RedelegationEntry.fromJSON(e)); + return obj; + }, + toJSON(message: Redelegation): JsonSafe { + const obj: any = {}; + message.delegatorAddress !== undefined && (obj.delegatorAddress = message.delegatorAddress); + message.validatorSrcAddress !== undefined && (obj.validatorSrcAddress = message.validatorSrcAddress); + message.validatorDstAddress !== undefined && (obj.validatorDstAddress = message.validatorDstAddress); + if (message.entries) { + obj.entries = message.entries.map(e => e ? RedelegationEntry.toJSON(e) : undefined); + } else { + obj.entries = []; + } + return obj; + }, + fromPartial(object: DeepPartial): Redelegation { + const message = createBaseRedelegation(); + message.delegatorAddress = object.delegatorAddress ?? ""; + message.validatorSrcAddress = object.validatorSrcAddress ?? ""; + message.validatorDstAddress = object.validatorDstAddress ?? ""; + message.entries = object.entries?.map(e => RedelegationEntry.fromPartial(e)) || []; + return message; + }, + fromSDK(object: RedelegationSDKType): Redelegation { + return { + delegatorAddress: object?.delegator_address, + validatorSrcAddress: object?.validator_src_address, + validatorDstAddress: object?.validator_dst_address, + entries: Array.isArray(object?.entries) ? object.entries.map((e: any) => RedelegationEntry.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): RedelegationSDKType { + return { + delegator_address: isSet(object.delegator_address) ? String(object.delegator_address) : "", + validator_src_address: isSet(object.validator_src_address) ? String(object.validator_src_address) : "", + validator_dst_address: isSet(object.validator_dst_address) ? String(object.validator_dst_address) : "", + entries: Array.isArray(object?.entries) ? object.entries.map((e: any) => RedelegationEntry.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: Redelegation): RedelegationSDKType { + const obj: any = {}; + obj.delegator_address = message.delegatorAddress; + obj.validator_src_address = message.validatorSrcAddress; + obj.validator_dst_address = message.validatorDstAddress; + if (message.entries) { + obj.entries = message.entries.map(e => e ? RedelegationEntry.toSDK(e) : undefined); + } else { + obj.entries = []; + } + return obj; + }, + fromAmino(object: RedelegationAmino): Redelegation { + const message = createBaseRedelegation(); + if (object.delegator_address !== undefined && object.delegator_address !== null) { + message.delegatorAddress = object.delegator_address; + } + if (object.validator_src_address !== undefined && object.validator_src_address !== null) { + message.validatorSrcAddress = object.validator_src_address; + } + if (object.validator_dst_address !== undefined && object.validator_dst_address !== null) { + message.validatorDstAddress = object.validator_dst_address; + } + message.entries = object.entries?.map(e => RedelegationEntry.fromAmino(e)) || []; + return message; + }, + toAmino(message: Redelegation): RedelegationAmino { + const obj: any = {}; + obj.delegator_address = message.delegatorAddress === "" ? undefined : message.delegatorAddress; + obj.validator_src_address = message.validatorSrcAddress === "" ? undefined : message.validatorSrcAddress; + obj.validator_dst_address = message.validatorDstAddress === "" ? undefined : message.validatorDstAddress; + if (message.entries) { + obj.entries = message.entries.map(e => e ? RedelegationEntry.toAmino(e) : undefined); + } else { + obj.entries = message.entries; + } + return obj; + }, + fromAminoMsg(object: RedelegationAminoMsg): Redelegation { + return Redelegation.fromAmino(object.value); + }, + toAminoMsg(message: Redelegation): RedelegationAminoMsg { + return { + type: "cosmos-sdk/Redelegation", + value: Redelegation.toAmino(message) + }; + }, + fromProtoMsg(message: RedelegationProtoMsg): Redelegation { + return Redelegation.decode(message.value); + }, + toProto(message: Redelegation): Uint8Array { + return Redelegation.encode(message).finish(); + }, + toProtoMsg(message: Redelegation): RedelegationProtoMsg { + return { + typeUrl: "/cosmos.staking.v1beta1.Redelegation", + value: Redelegation.encode(message).finish() + }; + } +}; +function createBaseParams(): Params { + return { + unbondingTime: Duration.fromPartial({}), + maxValidators: 0, + maxEntries: 0, + historicalEntries: 0, + bondDenom: "", + minCommissionRate: "" + }; +} +export const Params = { + typeUrl: "/cosmos.staking.v1beta1.Params", + encode(message: Params, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.unbondingTime !== undefined) { + Duration.encode(message.unbondingTime, writer.uint32(10).fork()).ldelim(); + } + if (message.maxValidators !== undefined) { + writer.uint32(16).uint32(message.maxValidators); + } + if (message.maxEntries !== undefined) { + writer.uint32(24).uint32(message.maxEntries); + } + if (message.historicalEntries !== undefined) { + writer.uint32(32).uint32(message.historicalEntries); + } + if (message.bondDenom !== undefined) { + writer.uint32(42).string(message.bondDenom); + } + if (message.minCommissionRate !== undefined) { + writer.uint32(50).string(Decimal.fromUserInput(message.minCommissionRate, 18).atomics); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Params { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseParams(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.unbondingTime = Duration.decode(reader, reader.uint32()); + break; + case 2: + message.maxValidators = reader.uint32(); + break; + case 3: + message.maxEntries = reader.uint32(); + break; + case 4: + message.historicalEntries = reader.uint32(); + break; + case 5: + message.bondDenom = reader.string(); + break; + case 6: + message.minCommissionRate = Decimal.fromAtomics(reader.string(), 18).toString(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Params { + const obj = createBaseParams(); + if (isSet(object.unbondingTime)) obj.unbondingTime = Duration.fromJSON(object.unbondingTime); + if (isSet(object.maxValidators)) obj.maxValidators = Number(object.maxValidators); + if (isSet(object.maxEntries)) obj.maxEntries = Number(object.maxEntries); + if (isSet(object.historicalEntries)) obj.historicalEntries = Number(object.historicalEntries); + if (isSet(object.bondDenom)) obj.bondDenom = String(object.bondDenom); + if (isSet(object.minCommissionRate)) obj.minCommissionRate = String(object.minCommissionRate); + return obj; + }, + toJSON(message: Params): JsonSafe { + const obj: any = {}; + message.unbondingTime !== undefined && (obj.unbondingTime = message.unbondingTime ? Duration.toJSON(message.unbondingTime) : undefined); + message.maxValidators !== undefined && (obj.maxValidators = Math.round(message.maxValidators)); + message.maxEntries !== undefined && (obj.maxEntries = Math.round(message.maxEntries)); + message.historicalEntries !== undefined && (obj.historicalEntries = Math.round(message.historicalEntries)); + message.bondDenom !== undefined && (obj.bondDenom = message.bondDenom); + message.minCommissionRate !== undefined && (obj.minCommissionRate = message.minCommissionRate); + return obj; + }, + fromPartial(object: DeepPartial): Params { + const message = createBaseParams(); + if (object.unbondingTime !== undefined && object.unbondingTime !== null) { + message.unbondingTime = Duration.fromPartial(object.unbondingTime); + } + message.maxValidators = object.maxValidators ?? 0; + message.maxEntries = object.maxEntries ?? 0; + message.historicalEntries = object.historicalEntries ?? 0; + message.bondDenom = object.bondDenom ?? ""; + message.minCommissionRate = object.minCommissionRate ?? ""; + return message; + }, + fromSDK(object: ParamsSDKType): Params { + return { + unbondingTime: object.unbonding_time ? Duration.fromSDK(object.unbonding_time) : undefined, + maxValidators: object?.max_validators, + maxEntries: object?.max_entries, + historicalEntries: object?.historical_entries, + bondDenom: object?.bond_denom, + minCommissionRate: object?.min_commission_rate + }; + }, + fromSDKJSON(object: any): ParamsSDKType { + return { + unbonding_time: isSet(object.unbonding_time) ? Duration.fromSDKJSON(object.unbonding_time) : undefined, + max_validators: isSet(object.max_validators) ? Number(object.max_validators) : 0, + max_entries: isSet(object.max_entries) ? Number(object.max_entries) : 0, + historical_entries: isSet(object.historical_entries) ? Number(object.historical_entries) : 0, + bond_denom: isSet(object.bond_denom) ? String(object.bond_denom) : "", + min_commission_rate: isSet(object.min_commission_rate) ? String(object.min_commission_rate) : "" + }; + }, + toSDK(message: Params): ParamsSDKType { + const obj: any = {}; + message.unbondingTime !== undefined && (obj.unbonding_time = message.unbondingTime ? Duration.toSDK(message.unbondingTime) : undefined); + obj.max_validators = message.maxValidators; + obj.max_entries = message.maxEntries; + obj.historical_entries = message.historicalEntries; + obj.bond_denom = message.bondDenom; + obj.min_commission_rate = message.minCommissionRate; + return obj; + }, + fromAmino(object: ParamsAmino): Params { + const message = createBaseParams(); + if (object.unbonding_time !== undefined && object.unbonding_time !== null) { + message.unbondingTime = Duration.fromAmino(object.unbonding_time); + } + if (object.max_validators !== undefined && object.max_validators !== null) { + message.maxValidators = object.max_validators; + } + if (object.max_entries !== undefined && object.max_entries !== null) { + message.maxEntries = object.max_entries; + } + if (object.historical_entries !== undefined && object.historical_entries !== null) { + message.historicalEntries = object.historical_entries; + } + if (object.bond_denom !== undefined && object.bond_denom !== null) { + message.bondDenom = object.bond_denom; + } + if (object.min_commission_rate !== undefined && object.min_commission_rate !== null) { + message.minCommissionRate = object.min_commission_rate; + } + return message; + }, + toAmino(message: Params): ParamsAmino { + const obj: any = {}; + obj.unbonding_time = message.unbondingTime ? Duration.toAmino(message.unbondingTime) : undefined; + obj.max_validators = message.maxValidators === 0 ? undefined : message.maxValidators; + obj.max_entries = message.maxEntries === 0 ? undefined : message.maxEntries; + obj.historical_entries = message.historicalEntries === 0 ? undefined : message.historicalEntries; + obj.bond_denom = message.bondDenom === "" ? undefined : message.bondDenom; + obj.min_commission_rate = message.minCommissionRate === "" ? undefined : message.minCommissionRate; + return obj; + }, + fromAminoMsg(object: ParamsAminoMsg): Params { + return Params.fromAmino(object.value); + }, + toAminoMsg(message: Params): ParamsAminoMsg { + return { + type: "cosmos-sdk/Params", + value: Params.toAmino(message) + }; + }, + fromProtoMsg(message: ParamsProtoMsg): Params { + return Params.decode(message.value); + }, + toProto(message: Params): Uint8Array { + return Params.encode(message).finish(); + }, + toProtoMsg(message: Params): ParamsProtoMsg { + return { + typeUrl: "/cosmos.staking.v1beta1.Params", + value: Params.encode(message).finish() + }; + } +}; +function createBaseDelegationResponse(): DelegationResponse { + return { + delegation: Delegation.fromPartial({}), + balance: Coin.fromPartial({}) + }; +} +export const DelegationResponse = { + typeUrl: "/cosmos.staking.v1beta1.DelegationResponse", + encode(message: DelegationResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.delegation !== undefined) { + Delegation.encode(message.delegation, writer.uint32(10).fork()).ldelim(); + } + if (message.balance !== undefined) { + Coin.encode(message.balance, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): DelegationResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDelegationResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.delegation = Delegation.decode(reader, reader.uint32()); + break; + case 2: + message.balance = Coin.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): DelegationResponse { + const obj = createBaseDelegationResponse(); + if (isSet(object.delegation)) obj.delegation = Delegation.fromJSON(object.delegation); + if (isSet(object.balance)) obj.balance = Coin.fromJSON(object.balance); + return obj; + }, + toJSON(message: DelegationResponse): JsonSafe { + const obj: any = {}; + message.delegation !== undefined && (obj.delegation = message.delegation ? Delegation.toJSON(message.delegation) : undefined); + message.balance !== undefined && (obj.balance = message.balance ? Coin.toJSON(message.balance) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): DelegationResponse { + const message = createBaseDelegationResponse(); + if (object.delegation !== undefined && object.delegation !== null) { + message.delegation = Delegation.fromPartial(object.delegation); + } + if (object.balance !== undefined && object.balance !== null) { + message.balance = Coin.fromPartial(object.balance); + } + return message; + }, + fromSDK(object: DelegationResponseSDKType): DelegationResponse { + return { + delegation: object.delegation ? Delegation.fromSDK(object.delegation) : undefined, + balance: object.balance ? Coin.fromSDK(object.balance) : undefined + }; + }, + fromSDKJSON(object: any): DelegationResponseSDKType { + return { + delegation: isSet(object.delegation) ? Delegation.fromSDKJSON(object.delegation) : undefined, + balance: isSet(object.balance) ? Coin.fromSDKJSON(object.balance) : undefined + }; + }, + toSDK(message: DelegationResponse): DelegationResponseSDKType { + const obj: any = {}; + message.delegation !== undefined && (obj.delegation = message.delegation ? Delegation.toSDK(message.delegation) : undefined); + message.balance !== undefined && (obj.balance = message.balance ? Coin.toSDK(message.balance) : undefined); + return obj; + }, + fromAmino(object: DelegationResponseAmino): DelegationResponse { + const message = createBaseDelegationResponse(); + if (object.delegation !== undefined && object.delegation !== null) { + message.delegation = Delegation.fromAmino(object.delegation); + } + if (object.balance !== undefined && object.balance !== null) { + message.balance = Coin.fromAmino(object.balance); + } + return message; + }, + toAmino(message: DelegationResponse): DelegationResponseAmino { + const obj: any = {}; + obj.delegation = message.delegation ? Delegation.toAmino(message.delegation) : undefined; + obj.balance = message.balance ? Coin.toAmino(message.balance) : undefined; + return obj; + }, + fromAminoMsg(object: DelegationResponseAminoMsg): DelegationResponse { + return DelegationResponse.fromAmino(object.value); + }, + toAminoMsg(message: DelegationResponse): DelegationResponseAminoMsg { + return { + type: "cosmos-sdk/DelegationResponse", + value: DelegationResponse.toAmino(message) + }; + }, + fromProtoMsg(message: DelegationResponseProtoMsg): DelegationResponse { + return DelegationResponse.decode(message.value); + }, + toProto(message: DelegationResponse): Uint8Array { + return DelegationResponse.encode(message).finish(); + }, + toProtoMsg(message: DelegationResponse): DelegationResponseProtoMsg { + return { + typeUrl: "/cosmos.staking.v1beta1.DelegationResponse", + value: DelegationResponse.encode(message).finish() + }; + } +}; +function createBaseRedelegationEntryResponse(): RedelegationEntryResponse { + return { + redelegationEntry: RedelegationEntry.fromPartial({}), + balance: "" + }; +} +export const RedelegationEntryResponse = { + typeUrl: "/cosmos.staking.v1beta1.RedelegationEntryResponse", + encode(message: RedelegationEntryResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.redelegationEntry !== undefined) { + RedelegationEntry.encode(message.redelegationEntry, writer.uint32(10).fork()).ldelim(); + } + if (message.balance !== undefined) { + writer.uint32(34).string(message.balance); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): RedelegationEntryResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseRedelegationEntryResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.redelegationEntry = RedelegationEntry.decode(reader, reader.uint32()); + break; + case 4: + message.balance = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): RedelegationEntryResponse { + const obj = createBaseRedelegationEntryResponse(); + if (isSet(object.redelegationEntry)) obj.redelegationEntry = RedelegationEntry.fromJSON(object.redelegationEntry); + if (isSet(object.balance)) obj.balance = String(object.balance); + return obj; + }, + toJSON(message: RedelegationEntryResponse): JsonSafe { + const obj: any = {}; + message.redelegationEntry !== undefined && (obj.redelegationEntry = message.redelegationEntry ? RedelegationEntry.toJSON(message.redelegationEntry) : undefined); + message.balance !== undefined && (obj.balance = message.balance); + return obj; + }, + fromPartial(object: DeepPartial): RedelegationEntryResponse { + const message = createBaseRedelegationEntryResponse(); + if (object.redelegationEntry !== undefined && object.redelegationEntry !== null) { + message.redelegationEntry = RedelegationEntry.fromPartial(object.redelegationEntry); + } + message.balance = object.balance ?? ""; + return message; + }, + fromSDK(object: RedelegationEntryResponseSDKType): RedelegationEntryResponse { + return { + redelegationEntry: object.redelegation_entry ? RedelegationEntry.fromSDK(object.redelegation_entry) : undefined, + balance: object?.balance + }; + }, + fromSDKJSON(object: any): RedelegationEntryResponseSDKType { + return { + redelegation_entry: isSet(object.redelegation_entry) ? RedelegationEntry.fromSDKJSON(object.redelegation_entry) : undefined, + balance: isSet(object.balance) ? String(object.balance) : "" + }; + }, + toSDK(message: RedelegationEntryResponse): RedelegationEntryResponseSDKType { + const obj: any = {}; + message.redelegationEntry !== undefined && (obj.redelegation_entry = message.redelegationEntry ? RedelegationEntry.toSDK(message.redelegationEntry) : undefined); + obj.balance = message.balance; + return obj; + }, + fromAmino(object: RedelegationEntryResponseAmino): RedelegationEntryResponse { + const message = createBaseRedelegationEntryResponse(); + if (object.redelegation_entry !== undefined && object.redelegation_entry !== null) { + message.redelegationEntry = RedelegationEntry.fromAmino(object.redelegation_entry); + } + if (object.balance !== undefined && object.balance !== null) { + message.balance = object.balance; + } + return message; + }, + toAmino(message: RedelegationEntryResponse): RedelegationEntryResponseAmino { + const obj: any = {}; + obj.redelegation_entry = message.redelegationEntry ? RedelegationEntry.toAmino(message.redelegationEntry) : undefined; + obj.balance = message.balance === "" ? undefined : message.balance; + return obj; + }, + fromAminoMsg(object: RedelegationEntryResponseAminoMsg): RedelegationEntryResponse { + return RedelegationEntryResponse.fromAmino(object.value); + }, + toAminoMsg(message: RedelegationEntryResponse): RedelegationEntryResponseAminoMsg { + return { + type: "cosmos-sdk/RedelegationEntryResponse", + value: RedelegationEntryResponse.toAmino(message) + }; + }, + fromProtoMsg(message: RedelegationEntryResponseProtoMsg): RedelegationEntryResponse { + return RedelegationEntryResponse.decode(message.value); + }, + toProto(message: RedelegationEntryResponse): Uint8Array { + return RedelegationEntryResponse.encode(message).finish(); + }, + toProtoMsg(message: RedelegationEntryResponse): RedelegationEntryResponseProtoMsg { + return { + typeUrl: "/cosmos.staking.v1beta1.RedelegationEntryResponse", + value: RedelegationEntryResponse.encode(message).finish() + }; + } +}; +function createBaseRedelegationResponse(): RedelegationResponse { + return { + redelegation: Redelegation.fromPartial({}), + entries: [] + }; +} +export const RedelegationResponse = { + typeUrl: "/cosmos.staking.v1beta1.RedelegationResponse", + encode(message: RedelegationResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.redelegation !== undefined) { + Redelegation.encode(message.redelegation, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.entries) { + RedelegationEntryResponse.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): RedelegationResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseRedelegationResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.redelegation = Redelegation.decode(reader, reader.uint32()); + break; + case 2: + message.entries.push(RedelegationEntryResponse.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): RedelegationResponse { + const obj = createBaseRedelegationResponse(); + if (isSet(object.redelegation)) obj.redelegation = Redelegation.fromJSON(object.redelegation); + if (Array.isArray(object?.entries)) obj.entries = object.entries.map((e: any) => RedelegationEntryResponse.fromJSON(e)); + return obj; + }, + toJSON(message: RedelegationResponse): JsonSafe { + const obj: any = {}; + message.redelegation !== undefined && (obj.redelegation = message.redelegation ? Redelegation.toJSON(message.redelegation) : undefined); + if (message.entries) { + obj.entries = message.entries.map(e => e ? RedelegationEntryResponse.toJSON(e) : undefined); + } else { + obj.entries = []; + } + return obj; + }, + fromPartial(object: DeepPartial): RedelegationResponse { + const message = createBaseRedelegationResponse(); + if (object.redelegation !== undefined && object.redelegation !== null) { + message.redelegation = Redelegation.fromPartial(object.redelegation); + } + message.entries = object.entries?.map(e => RedelegationEntryResponse.fromPartial(e)) || []; + return message; + }, + fromSDK(object: RedelegationResponseSDKType): RedelegationResponse { + return { + redelegation: object.redelegation ? Redelegation.fromSDK(object.redelegation) : undefined, + entries: Array.isArray(object?.entries) ? object.entries.map((e: any) => RedelegationEntryResponse.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): RedelegationResponseSDKType { + return { + redelegation: isSet(object.redelegation) ? Redelegation.fromSDKJSON(object.redelegation) : undefined, + entries: Array.isArray(object?.entries) ? object.entries.map((e: any) => RedelegationEntryResponse.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: RedelegationResponse): RedelegationResponseSDKType { + const obj: any = {}; + message.redelegation !== undefined && (obj.redelegation = message.redelegation ? Redelegation.toSDK(message.redelegation) : undefined); + if (message.entries) { + obj.entries = message.entries.map(e => e ? RedelegationEntryResponse.toSDK(e) : undefined); + } else { + obj.entries = []; + } + return obj; + }, + fromAmino(object: RedelegationResponseAmino): RedelegationResponse { + const message = createBaseRedelegationResponse(); + if (object.redelegation !== undefined && object.redelegation !== null) { + message.redelegation = Redelegation.fromAmino(object.redelegation); + } + message.entries = object.entries?.map(e => RedelegationEntryResponse.fromAmino(e)) || []; + return message; + }, + toAmino(message: RedelegationResponse): RedelegationResponseAmino { + const obj: any = {}; + obj.redelegation = message.redelegation ? Redelegation.toAmino(message.redelegation) : undefined; + if (message.entries) { + obj.entries = message.entries.map(e => e ? RedelegationEntryResponse.toAmino(e) : undefined); + } else { + obj.entries = message.entries; + } + return obj; + }, + fromAminoMsg(object: RedelegationResponseAminoMsg): RedelegationResponse { + return RedelegationResponse.fromAmino(object.value); + }, + toAminoMsg(message: RedelegationResponse): RedelegationResponseAminoMsg { + return { + type: "cosmos-sdk/RedelegationResponse", + value: RedelegationResponse.toAmino(message) + }; + }, + fromProtoMsg(message: RedelegationResponseProtoMsg): RedelegationResponse { + return RedelegationResponse.decode(message.value); + }, + toProto(message: RedelegationResponse): Uint8Array { + return RedelegationResponse.encode(message).finish(); + }, + toProtoMsg(message: RedelegationResponse): RedelegationResponseProtoMsg { + return { + typeUrl: "/cosmos.staking.v1beta1.RedelegationResponse", + value: RedelegationResponse.encode(message).finish() + }; + } +}; +function createBasePool(): Pool { + return { + notBondedTokens: "", + bondedTokens: "" + }; +} +export const Pool = { + typeUrl: "/cosmos.staking.v1beta1.Pool", + encode(message: Pool, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.notBondedTokens !== undefined) { + writer.uint32(10).string(message.notBondedTokens); + } + if (message.bondedTokens !== undefined) { + writer.uint32(18).string(message.bondedTokens); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Pool { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBasePool(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.notBondedTokens = reader.string(); + break; + case 2: + message.bondedTokens = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Pool { + const obj = createBasePool(); + if (isSet(object.notBondedTokens)) obj.notBondedTokens = String(object.notBondedTokens); + if (isSet(object.bondedTokens)) obj.bondedTokens = String(object.bondedTokens); + return obj; + }, + toJSON(message: Pool): JsonSafe { + const obj: any = {}; + message.notBondedTokens !== undefined && (obj.notBondedTokens = message.notBondedTokens); + message.bondedTokens !== undefined && (obj.bondedTokens = message.bondedTokens); + return obj; + }, + fromPartial(object: DeepPartial): Pool { + const message = createBasePool(); + message.notBondedTokens = object.notBondedTokens ?? ""; + message.bondedTokens = object.bondedTokens ?? ""; + return message; + }, + fromSDK(object: PoolSDKType): Pool { + return { + notBondedTokens: object?.not_bonded_tokens, + bondedTokens: object?.bonded_tokens + }; + }, + fromSDKJSON(object: any): PoolSDKType { + return { + not_bonded_tokens: isSet(object.not_bonded_tokens) ? String(object.not_bonded_tokens) : "", + bonded_tokens: isSet(object.bonded_tokens) ? String(object.bonded_tokens) : "" + }; + }, + toSDK(message: Pool): PoolSDKType { + const obj: any = {}; + obj.not_bonded_tokens = message.notBondedTokens; + obj.bonded_tokens = message.bondedTokens; + return obj; + }, + fromAmino(object: PoolAmino): Pool { + const message = createBasePool(); + if (object.not_bonded_tokens !== undefined && object.not_bonded_tokens !== null) { + message.notBondedTokens = object.not_bonded_tokens; + } + if (object.bonded_tokens !== undefined && object.bonded_tokens !== null) { + message.bondedTokens = object.bonded_tokens; + } + return message; + }, + toAmino(message: Pool): PoolAmino { + const obj: any = {}; + obj.not_bonded_tokens = message.notBondedTokens ?? ""; + obj.bonded_tokens = message.bondedTokens ?? ""; + return obj; + }, + fromAminoMsg(object: PoolAminoMsg): Pool { + return Pool.fromAmino(object.value); + }, + toAminoMsg(message: Pool): PoolAminoMsg { + return { + type: "cosmos-sdk/Pool", + value: Pool.toAmino(message) + }; + }, + fromProtoMsg(message: PoolProtoMsg): Pool { + return Pool.decode(message.value); + }, + toProto(message: Pool): Uint8Array { + return Pool.encode(message).finish(); + }, + toProtoMsg(message: Pool): PoolProtoMsg { + return { + typeUrl: "/cosmos.staking.v1beta1.Pool", + value: Pool.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/staking/v1beta1/tx.amino.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/staking/v1beta1/tx.amino.ts new file mode 100644 index 0000000000..7038771304 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/staking/v1beta1/tx.amino.ts @@ -0,0 +1,289 @@ +import { Description, DescriptionSDKType, CommissionRates, CommissionRatesSDKType } from "./staking.js"; +import { Any, AnySDKType } from "../../../google/protobuf/any.js"; +import { Coin, CoinSDKType } from "../../base/v1beta1/coin.js"; +import { Timestamp, TimestampSDKType } from "../../../google/protobuf/timestamp.js"; +import { ReadOnlyAminoMsg as AminoMsg } from "@interchainjs/ReadOnlyAminoMsg"; +import { Pubkey } from "@interchainjs/Pubkey"; +import { decodePubkey, encodePubkey } from "@cosmjs/proto-signing"; +import { MsgCreateValidator, MsgCreateValidatorSDKType, MsgEditValidator, MsgEditValidatorSDKType, MsgDelegate, MsgDelegateSDKType, MsgBeginRedelegate, MsgBeginRedelegateSDKType, MsgUndelegate, MsgUndelegateSDKType } from "./tx.js"; +export interface MsgCreateValidatorAminoType extends AminoMsg { + type: "cosmos-sdk/MsgCreateValidator"; + value: { + description: { + moniker: string; + identity: string; + website: string; + security_contact: string; + details: string; + }; + commission: { + rate: string; + max_rate: string; + max_change_rate: string; + }; + min_self_delegation: string; + delegator_address: string; + validator_address: string; + pubkey: Pubkey; + value: { + denom: string; + amount: string; + }; + }; +} +export interface MsgEditValidatorAminoType extends AminoMsg { + type: "cosmos-sdk/MsgEditValidator"; + value: { + description: { + moniker: string; + identity: string; + website: string; + security_contact: string; + details: string; + }; + validator_address: string; + commission_rate: string; + min_self_delegation: string; + }; +} +export interface MsgDelegateAminoType extends AminoMsg { + type: "cosmos-sdk/MsgDelegate"; + value: { + delegator_address: string; + validator_address: string; + amount: { + denom: string; + amount: string; + }; + }; +} +export interface MsgBeginRedelegateAminoType extends AminoMsg { + type: "cosmos-sdk/MsgBeginRedelegate"; + value: { + delegator_address: string; + validator_src_address: string; + validator_dst_address: string; + amount: { + denom: string; + amount: string; + }; + }; +} +export interface MsgUndelegateAminoType extends AminoMsg { + type: "cosmos-sdk/MsgUndelegate"; + value: { + delegator_address: string; + validator_address: string; + amount: { + denom: string; + amount: string; + }; + }; +} +export const AminoConverter = { + "/cosmos.staking.v1beta1.MsgCreateValidator": { + aminoType: "cosmos-sdk/MsgCreateValidator", + toAmino: ({ + description, + commission, + minSelfDelegation, + delegatorAddress, + validatorAddress, + pubkey, + value + }: MsgCreateValidator): MsgCreateValidatorAminoType["value"] => { + return { + description: { + moniker: description.moniker, + identity: description.identity, + website: description.website, + security_contact: description.securityContact, + details: description.details + }, + commission: { + rate: commission.rate, + max_rate: commission.maxRate, + max_change_rate: commission.maxChangeRate + }, + min_self_delegation: minSelfDelegation, + delegator_address: delegatorAddress, + validator_address: validatorAddress, + pubkey: decodePubkey(pubkey)!, + value: { + denom: value.denom, + amount: value.amount + } + }; + }, + fromAmino: ({ + description, + commission, + min_self_delegation, + delegator_address, + validator_address, + pubkey, + value + }: MsgCreateValidatorAminoType["value"]): MsgCreateValidator => { + return { + description: { + moniker: description.moniker, + identity: description.identity, + website: description.website, + securityContact: description.security_contact, + details: description.details + }, + commission: { + rate: commission.rate, + maxRate: commission.max_rate, + maxChangeRate: commission.max_change_rate + }, + minSelfDelegation: min_self_delegation, + delegatorAddress: delegator_address, + validatorAddress: validator_address, + pubkey: encodePubkey(pubkey), + value: { + denom: value.denom, + amount: value.amount + } + }; + } + }, + "/cosmos.staking.v1beta1.MsgEditValidator": { + aminoType: "cosmos-sdk/MsgEditValidator", + toAmino: ({ + description, + validatorAddress, + commissionRate, + minSelfDelegation + }: MsgEditValidator): MsgEditValidatorAminoType["value"] => { + return { + description: { + moniker: description.moniker, + identity: description.identity, + website: description.website, + security_contact: description.securityContact, + details: description.details + }, + validator_address: validatorAddress, + commission_rate: commissionRate, + min_self_delegation: minSelfDelegation + }; + }, + fromAmino: ({ + description, + validator_address, + commission_rate, + min_self_delegation + }: MsgEditValidatorAminoType["value"]): MsgEditValidator => { + return { + description: { + moniker: description.moniker, + identity: description.identity, + website: description.website, + securityContact: description.security_contact, + details: description.details + }, + validatorAddress: validator_address, + commissionRate: commission_rate, + minSelfDelegation: min_self_delegation + }; + } + }, + "/cosmos.staking.v1beta1.MsgDelegate": { + aminoType: "cosmos-sdk/MsgDelegate", + toAmino: ({ + delegatorAddress, + validatorAddress, + amount + }: MsgDelegate): MsgDelegateAminoType["value"] => { + return { + delegator_address: delegatorAddress, + validator_address: validatorAddress, + amount: { + denom: amount.denom, + amount: amount.amount + } + }; + }, + fromAmino: ({ + delegator_address, + validator_address, + amount + }: MsgDelegateAminoType["value"]): MsgDelegate => { + return { + delegatorAddress: delegator_address, + validatorAddress: validator_address, + amount: { + denom: amount.denom, + amount: amount.amount + } + }; + } + }, + "/cosmos.staking.v1beta1.MsgBeginRedelegate": { + aminoType: "cosmos-sdk/MsgBeginRedelegate", + toAmino: ({ + delegatorAddress, + validatorSrcAddress, + validatorDstAddress, + amount + }: MsgBeginRedelegate): MsgBeginRedelegateAminoType["value"] => { + return { + delegator_address: delegatorAddress, + validator_src_address: validatorSrcAddress, + validator_dst_address: validatorDstAddress, + amount: { + denom: amount.denom, + amount: amount.amount + } + }; + }, + fromAmino: ({ + delegator_address, + validator_src_address, + validator_dst_address, + amount + }: MsgBeginRedelegateAminoType["value"]): MsgBeginRedelegate => { + return { + delegatorAddress: delegator_address, + validatorSrcAddress: validator_src_address, + validatorDstAddress: validator_dst_address, + amount: { + denom: amount.denom, + amount: amount.amount + } + }; + } + }, + "/cosmos.staking.v1beta1.MsgUndelegate": { + aminoType: "cosmos-sdk/MsgUndelegate", + toAmino: ({ + delegatorAddress, + validatorAddress, + amount + }: MsgUndelegate): MsgUndelegateAminoType["value"] => { + return { + delegator_address: delegatorAddress, + validator_address: validatorAddress, + amount: { + denom: amount.denom, + amount: amount.amount + } + }; + }, + fromAmino: ({ + delegator_address, + validator_address, + amount + }: MsgUndelegateAminoType["value"]): MsgUndelegate => { + return { + delegatorAddress: delegator_address, + validatorAddress: validator_address, + amount: { + denom: amount.denom, + amount: amount.amount + } + }; + } + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/staking/v1beta1/tx.registry.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/staking/v1beta1/tx.registry.ts new file mode 100644 index 0000000000..bf55cd2deb --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/staking/v1beta1/tx.registry.ts @@ -0,0 +1,174 @@ +import { Description, DescriptionSDKType, CommissionRates, CommissionRatesSDKType } from "./staking.js"; +import { Any, AnySDKType } from "../../../google/protobuf/any.js"; +import { Coin, CoinSDKType } from "../../base/v1beta1/coin.js"; +import { Timestamp, TimestampSDKType } from "../../../google/protobuf/timestamp.js"; +import { GeneratedType, Registry } from "@cosmjs/proto-signing"; +import { MsgCreateValidator, MsgCreateValidatorSDKType, MsgEditValidator, MsgEditValidatorSDKType, MsgDelegate, MsgDelegateSDKType, MsgBeginRedelegate, MsgBeginRedelegateSDKType, MsgUndelegate, MsgUndelegateSDKType } from "./tx.js"; +export const registry: ReadonlyArray<[string, GeneratedType]> = [["/cosmos.staking.v1beta1.MsgCreateValidator", MsgCreateValidator], ["/cosmos.staking.v1beta1.MsgEditValidator", MsgEditValidator], ["/cosmos.staking.v1beta1.MsgDelegate", MsgDelegate], ["/cosmos.staking.v1beta1.MsgBeginRedelegate", MsgBeginRedelegate], ["/cosmos.staking.v1beta1.MsgUndelegate", MsgUndelegate]]; +export const load = (protoRegistry: Registry) => { + registry.forEach(([typeUrl, mod]) => { + protoRegistry.register(typeUrl, mod); + }); +}; +export const MessageComposer = { + encoded: { + createValidator(value: MsgCreateValidator) { + return { + typeUrl: "/cosmos.staking.v1beta1.MsgCreateValidator", + value: MsgCreateValidator.encode(value).finish() + }; + }, + editValidator(value: MsgEditValidator) { + return { + typeUrl: "/cosmos.staking.v1beta1.MsgEditValidator", + value: MsgEditValidator.encode(value).finish() + }; + }, + delegate(value: MsgDelegate) { + return { + typeUrl: "/cosmos.staking.v1beta1.MsgDelegate", + value: MsgDelegate.encode(value).finish() + }; + }, + beginRedelegate(value: MsgBeginRedelegate) { + return { + typeUrl: "/cosmos.staking.v1beta1.MsgBeginRedelegate", + value: MsgBeginRedelegate.encode(value).finish() + }; + }, + undelegate(value: MsgUndelegate) { + return { + typeUrl: "/cosmos.staking.v1beta1.MsgUndelegate", + value: MsgUndelegate.encode(value).finish() + }; + } + }, + withTypeUrl: { + createValidator(value: MsgCreateValidator) { + return { + typeUrl: "/cosmos.staking.v1beta1.MsgCreateValidator", + value + }; + }, + editValidator(value: MsgEditValidator) { + return { + typeUrl: "/cosmos.staking.v1beta1.MsgEditValidator", + value + }; + }, + delegate(value: MsgDelegate) { + return { + typeUrl: "/cosmos.staking.v1beta1.MsgDelegate", + value + }; + }, + beginRedelegate(value: MsgBeginRedelegate) { + return { + typeUrl: "/cosmos.staking.v1beta1.MsgBeginRedelegate", + value + }; + }, + undelegate(value: MsgUndelegate) { + return { + typeUrl: "/cosmos.staking.v1beta1.MsgUndelegate", + value + }; + } + }, + toJSON: { + createValidator(value: MsgCreateValidator) { + return { + typeUrl: "/cosmos.staking.v1beta1.MsgCreateValidator", + value: MsgCreateValidator.toJSON(value) + }; + }, + editValidator(value: MsgEditValidator) { + return { + typeUrl: "/cosmos.staking.v1beta1.MsgEditValidator", + value: MsgEditValidator.toJSON(value) + }; + }, + delegate(value: MsgDelegate) { + return { + typeUrl: "/cosmos.staking.v1beta1.MsgDelegate", + value: MsgDelegate.toJSON(value) + }; + }, + beginRedelegate(value: MsgBeginRedelegate) { + return { + typeUrl: "/cosmos.staking.v1beta1.MsgBeginRedelegate", + value: MsgBeginRedelegate.toJSON(value) + }; + }, + undelegate(value: MsgUndelegate) { + return { + typeUrl: "/cosmos.staking.v1beta1.MsgUndelegate", + value: MsgUndelegate.toJSON(value) + }; + } + }, + fromJSON: { + createValidator(value: any) { + return { + typeUrl: "/cosmos.staking.v1beta1.MsgCreateValidator", + value: MsgCreateValidator.fromJSON(value) + }; + }, + editValidator(value: any) { + return { + typeUrl: "/cosmos.staking.v1beta1.MsgEditValidator", + value: MsgEditValidator.fromJSON(value) + }; + }, + delegate(value: any) { + return { + typeUrl: "/cosmos.staking.v1beta1.MsgDelegate", + value: MsgDelegate.fromJSON(value) + }; + }, + beginRedelegate(value: any) { + return { + typeUrl: "/cosmos.staking.v1beta1.MsgBeginRedelegate", + value: MsgBeginRedelegate.fromJSON(value) + }; + }, + undelegate(value: any) { + return { + typeUrl: "/cosmos.staking.v1beta1.MsgUndelegate", + value: MsgUndelegate.fromJSON(value) + }; + } + }, + fromPartial: { + createValidator(value: MsgCreateValidator) { + return { + typeUrl: "/cosmos.staking.v1beta1.MsgCreateValidator", + value: MsgCreateValidator.fromPartial(value) + }; + }, + editValidator(value: MsgEditValidator) { + return { + typeUrl: "/cosmos.staking.v1beta1.MsgEditValidator", + value: MsgEditValidator.fromPartial(value) + }; + }, + delegate(value: MsgDelegate) { + return { + typeUrl: "/cosmos.staking.v1beta1.MsgDelegate", + value: MsgDelegate.fromPartial(value) + }; + }, + beginRedelegate(value: MsgBeginRedelegate) { + return { + typeUrl: "/cosmos.staking.v1beta1.MsgBeginRedelegate", + value: MsgBeginRedelegate.fromPartial(value) + }; + }, + undelegate(value: MsgUndelegate) { + return { + typeUrl: "/cosmos.staking.v1beta1.MsgUndelegate", + value: MsgUndelegate.fromPartial(value) + }; + } + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/staking/v1beta1/tx.rpc.func.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/staking/v1beta1/tx.rpc.func.ts new file mode 100644 index 0000000000..6e98980156 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/staking/v1beta1/tx.rpc.func.ts @@ -0,0 +1,49 @@ +import { buildTx, SigningClientResolver } from "../../../helper-func-types"; +import { buildUseMutation } from "../../../react-query"; +import { toEncoders, toConverters } from "@interchainjs/cosmos/utils"; +import { MsgCreateValidator, MsgEditValidator, MsgDelegate, MsgBeginRedelegate, MsgUndelegate } from "./tx"; +export const createCreateValidator = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgCreateValidator.typeUrl, + encoders: toEncoders(MsgCreateValidator), + converters: toConverters(MsgCreateValidator) +}); +export const useCreateValidator = buildUseMutation({ + builderMutationFn: createCreateValidator +}); +export const createEditValidator = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgEditValidator.typeUrl, + encoders: toEncoders(MsgEditValidator), + converters: toConverters(MsgEditValidator) +}); +export const useEditValidator = buildUseMutation({ + builderMutationFn: createEditValidator +}); +export const createDelegate = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgDelegate.typeUrl, + encoders: toEncoders(MsgDelegate), + converters: toConverters(MsgDelegate) +}); +export const useDelegate = buildUseMutation({ + builderMutationFn: createDelegate +}); +export const createBeginRedelegate = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgBeginRedelegate.typeUrl, + encoders: toEncoders(MsgBeginRedelegate), + converters: toConverters(MsgBeginRedelegate) +}); +export const useBeginRedelegate = buildUseMutation({ + builderMutationFn: createBeginRedelegate +}); +export const createUndelegate = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgUndelegate.typeUrl, + encoders: toEncoders(MsgUndelegate), + converters: toConverters(MsgUndelegate) +}); +export const useUndelegate = buildUseMutation({ + builderMutationFn: createUndelegate +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/staking/v1beta1/tx.rpc.msg.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/staking/v1beta1/tx.rpc.msg.ts new file mode 100644 index 0000000000..f807da072f --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/staking/v1beta1/tx.rpc.msg.ts @@ -0,0 +1,68 @@ +import { Description, DescriptionSDKType, CommissionRates, CommissionRatesSDKType } from "./staking.js"; +import { Any, AnySDKType } from "../../../google/protobuf/any.js"; +import { Coin, CoinSDKType } from "../../base/v1beta1/coin.js"; +import { Timestamp, TimestampSDKType } from "../../../google/protobuf/timestamp.js"; +import { Rpc } from "../../../helpers.js"; +import { BinaryReader } from "../../../binary.js"; +import { MsgCreateValidator, MsgCreateValidatorSDKType, MsgCreateValidatorResponse, MsgCreateValidatorResponseSDKType, MsgEditValidator, MsgEditValidatorSDKType, MsgEditValidatorResponse, MsgEditValidatorResponseSDKType, MsgDelegate, MsgDelegateSDKType, MsgDelegateResponse, MsgDelegateResponseSDKType, MsgBeginRedelegate, MsgBeginRedelegateSDKType, MsgBeginRedelegateResponse, MsgBeginRedelegateResponseSDKType, MsgUndelegate, MsgUndelegateSDKType, MsgUndelegateResponse, MsgUndelegateResponseSDKType } from "./tx.js"; +/** Msg defines the staking Msg service. */ +export interface Msg { + /** CreateValidator defines a method for creating a new validator. */ + createValidator(request: MsgCreateValidator): Promise; + /** EditValidator defines a method for editing an existing validator. */ + editValidator(request: MsgEditValidator): Promise; + /** + * Delegate defines a method for performing a delegation of coins + * from a delegator to a validator. + */ + delegate(request: MsgDelegate): Promise; + /** + * BeginRedelegate defines a method for performing a redelegation + * of coins from a delegator and source validator to a destination validator. + */ + beginRedelegate(request: MsgBeginRedelegate): Promise; + /** + * Undelegate defines a method for performing an undelegation from a + * delegate and a validator. + */ + undelegate(request: MsgUndelegate): Promise; +} +export class MsgClientImpl implements Msg { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + this.createValidator = this.createValidator.bind(this); + this.editValidator = this.editValidator.bind(this); + this.delegate = this.delegate.bind(this); + this.beginRedelegate = this.beginRedelegate.bind(this); + this.undelegate = this.undelegate.bind(this); + } + createValidator(request: MsgCreateValidator): Promise { + const data = MsgCreateValidator.encode(request).finish(); + const promise = this.rpc.request("cosmos.staking.v1beta1.Msg", "CreateValidator", data); + return promise.then(data => MsgCreateValidatorResponse.decode(new BinaryReader(data))); + } + editValidator(request: MsgEditValidator): Promise { + const data = MsgEditValidator.encode(request).finish(); + const promise = this.rpc.request("cosmos.staking.v1beta1.Msg", "EditValidator", data); + return promise.then(data => MsgEditValidatorResponse.decode(new BinaryReader(data))); + } + delegate(request: MsgDelegate): Promise { + const data = MsgDelegate.encode(request).finish(); + const promise = this.rpc.request("cosmos.staking.v1beta1.Msg", "Delegate", data); + return promise.then(data => MsgDelegateResponse.decode(new BinaryReader(data))); + } + beginRedelegate(request: MsgBeginRedelegate): Promise { + const data = MsgBeginRedelegate.encode(request).finish(); + const promise = this.rpc.request("cosmos.staking.v1beta1.Msg", "BeginRedelegate", data); + return promise.then(data => MsgBeginRedelegateResponse.decode(new BinaryReader(data))); + } + undelegate(request: MsgUndelegate): Promise { + const data = MsgUndelegate.encode(request).finish(); + const promise = this.rpc.request("cosmos.staking.v1beta1.Msg", "Undelegate", data); + return promise.then(data => MsgUndelegateResponse.decode(new BinaryReader(data))); + } +} +export const createClientImpl = (rpc: Rpc) => { + return new MsgClientImpl(rpc); +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/staking/v1beta1/tx.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/staking/v1beta1/tx.ts new file mode 100644 index 0000000000..2fc07ea2b2 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/staking/v1beta1/tx.ts @@ -0,0 +1,1342 @@ +import { Description, DescriptionSDKType, CommissionRates, CommissionRatesSDKType } from "./staking.js"; +import { Any, AnySDKType } from "../../../google/protobuf/any.js"; +import { Coin, CoinSDKType } from "../../base/v1beta1/coin.js"; +import { Timestamp, TimestampSDKType } from "../../../google/protobuf/timestamp.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial, toTimestamp, fromTimestamp } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +import { encodePubkey, decodePubkey } from "@cosmjs/proto-signing"; +import { Decimal } from "@cosmjs/math"; +export const protobufPackage = "cosmos.staking.v1beta1"; +/** MsgCreateValidator defines a SDK message for creating a new validator. */ +export interface MsgCreateValidator { + description: Description; + commission: CommissionRates; + minSelfDelegation: string; + delegatorAddress: string; + validatorAddress: string; + pubkey?: Any; + value: Coin; +} +export interface MsgCreateValidatorProtoMsg { + typeUrl: "/cosmos.staking.v1beta1.MsgCreateValidator"; + value: Uint8Array; +} +/** MsgCreateValidator defines a SDK message for creating a new validator. */ +export interface MsgCreateValidatorSDKType { + description: DescriptionSDKType; + commission: CommissionRatesSDKType; + min_self_delegation: string; + delegator_address: string; + validator_address: string; + pubkey?: AnySDKType; + value: CoinSDKType; +} +/** MsgCreateValidatorResponse defines the Msg/CreateValidator response type. */ +export interface MsgCreateValidatorResponse {} +export interface MsgCreateValidatorResponseProtoMsg { + typeUrl: "/cosmos.staking.v1beta1.MsgCreateValidatorResponse"; + value: Uint8Array; +} +/** MsgCreateValidatorResponse defines the Msg/CreateValidator response type. */ +export interface MsgCreateValidatorResponseSDKType {} +/** MsgEditValidator defines a SDK message for editing an existing validator. */ +export interface MsgEditValidator { + description: Description; + validatorAddress: string; + /** + * We pass a reference to the new commission rate and min self delegation as + * it's not mandatory to update. If not updated, the deserialized rate will be + * zero with no way to distinguish if an update was intended. + * REF: #2373 + */ + commissionRate: string; + minSelfDelegation: string; +} +export interface MsgEditValidatorProtoMsg { + typeUrl: "/cosmos.staking.v1beta1.MsgEditValidator"; + value: Uint8Array; +} +/** MsgEditValidator defines a SDK message for editing an existing validator. */ +export interface MsgEditValidatorSDKType { + description: DescriptionSDKType; + validator_address: string; + commission_rate: string; + min_self_delegation: string; +} +/** MsgEditValidatorResponse defines the Msg/EditValidator response type. */ +export interface MsgEditValidatorResponse {} +export interface MsgEditValidatorResponseProtoMsg { + typeUrl: "/cosmos.staking.v1beta1.MsgEditValidatorResponse"; + value: Uint8Array; +} +/** MsgEditValidatorResponse defines the Msg/EditValidator response type. */ +export interface MsgEditValidatorResponseSDKType {} +/** + * MsgDelegate defines a SDK message for performing a delegation of coins + * from a delegator to a validator. + */ +export interface MsgDelegate { + delegatorAddress: string; + validatorAddress: string; + amount: Coin; +} +export interface MsgDelegateProtoMsg { + typeUrl: "/cosmos.staking.v1beta1.MsgDelegate"; + value: Uint8Array; +} +/** + * MsgDelegate defines a SDK message for performing a delegation of coins + * from a delegator to a validator. + */ +export interface MsgDelegateSDKType { + delegator_address: string; + validator_address: string; + amount: CoinSDKType; +} +/** MsgDelegateResponse defines the Msg/Delegate response type. */ +export interface MsgDelegateResponse {} +export interface MsgDelegateResponseProtoMsg { + typeUrl: "/cosmos.staking.v1beta1.MsgDelegateResponse"; + value: Uint8Array; +} +/** MsgDelegateResponse defines the Msg/Delegate response type. */ +export interface MsgDelegateResponseSDKType {} +/** + * MsgBeginRedelegate defines a SDK message for performing a redelegation + * of coins from a delegator and source validator to a destination validator. + */ +export interface MsgBeginRedelegate { + delegatorAddress: string; + validatorSrcAddress: string; + validatorDstAddress: string; + amount: Coin; +} +export interface MsgBeginRedelegateProtoMsg { + typeUrl: "/cosmos.staking.v1beta1.MsgBeginRedelegate"; + value: Uint8Array; +} +/** + * MsgBeginRedelegate defines a SDK message for performing a redelegation + * of coins from a delegator and source validator to a destination validator. + */ +export interface MsgBeginRedelegateSDKType { + delegator_address: string; + validator_src_address: string; + validator_dst_address: string; + amount: CoinSDKType; +} +/** MsgBeginRedelegateResponse defines the Msg/BeginRedelegate response type. */ +export interface MsgBeginRedelegateResponse { + completionTime: Date; +} +export interface MsgBeginRedelegateResponseProtoMsg { + typeUrl: "/cosmos.staking.v1beta1.MsgBeginRedelegateResponse"; + value: Uint8Array; +} +/** MsgBeginRedelegateResponse defines the Msg/BeginRedelegate response type. */ +export interface MsgBeginRedelegateResponseSDKType { + completion_time: Date; +} +/** + * MsgUndelegate defines a SDK message for performing an undelegation from a + * delegate and a validator. + */ +export interface MsgUndelegate { + delegatorAddress: string; + validatorAddress: string; + amount: Coin; +} +export interface MsgUndelegateProtoMsg { + typeUrl: "/cosmos.staking.v1beta1.MsgUndelegate"; + value: Uint8Array; +} +/** + * MsgUndelegate defines a SDK message for performing an undelegation from a + * delegate and a validator. + */ +export interface MsgUndelegateSDKType { + delegator_address: string; + validator_address: string; + amount: CoinSDKType; +} +/** MsgUndelegateResponse defines the Msg/Undelegate response type. */ +export interface MsgUndelegateResponse { + completionTime: Date; +} +export interface MsgUndelegateResponseProtoMsg { + typeUrl: "/cosmos.staking.v1beta1.MsgUndelegateResponse"; + value: Uint8Array; +} +/** MsgUndelegateResponse defines the Msg/Undelegate response type. */ +export interface MsgUndelegateResponseSDKType { + completion_time: Date; +} +function createBaseMsgCreateValidator(): MsgCreateValidator { + return { + description: Description.fromPartial({}), + commission: CommissionRates.fromPartial({}), + minSelfDelegation: "", + delegatorAddress: "", + validatorAddress: "", + pubkey: undefined, + value: Coin.fromPartial({}) + }; +} +export const MsgCreateValidator = { + typeUrl: "/cosmos.staking.v1beta1.MsgCreateValidator", + encode(message: MsgCreateValidator, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.description !== undefined) { + Description.encode(message.description, writer.uint32(10).fork()).ldelim(); + } + if (message.commission !== undefined) { + CommissionRates.encode(message.commission, writer.uint32(18).fork()).ldelim(); + } + if (message.minSelfDelegation !== undefined) { + writer.uint32(26).string(message.minSelfDelegation); + } + if (message.delegatorAddress !== undefined) { + writer.uint32(34).string(message.delegatorAddress); + } + if (message.validatorAddress !== undefined) { + writer.uint32(42).string(message.validatorAddress); + } + if (message.pubkey !== undefined) { + Any.encode(message.pubkey, writer.uint32(50).fork()).ldelim(); + } + if (message.value !== undefined) { + Coin.encode(message.value, writer.uint32(58).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgCreateValidator { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgCreateValidator(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.description = Description.decode(reader, reader.uint32()); + break; + case 2: + message.commission = CommissionRates.decode(reader, reader.uint32()); + break; + case 3: + message.minSelfDelegation = reader.string(); + break; + case 4: + message.delegatorAddress = reader.string(); + break; + case 5: + message.validatorAddress = reader.string(); + break; + case 6: + message.pubkey = Any.decode(reader, reader.uint32()); + break; + case 7: + message.value = Coin.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgCreateValidator { + const obj = createBaseMsgCreateValidator(); + if (isSet(object.description)) obj.description = Description.fromJSON(object.description); + if (isSet(object.commission)) obj.commission = CommissionRates.fromJSON(object.commission); + if (isSet(object.minSelfDelegation)) obj.minSelfDelegation = String(object.minSelfDelegation); + if (isSet(object.delegatorAddress)) obj.delegatorAddress = String(object.delegatorAddress); + if (isSet(object.validatorAddress)) obj.validatorAddress = String(object.validatorAddress); + if (isSet(object.pubkey)) obj.pubkey = Any.fromJSON(object.pubkey); + if (isSet(object.value)) obj.value = Coin.fromJSON(object.value); + return obj; + }, + toJSON(message: MsgCreateValidator): JsonSafe { + const obj: any = {}; + message.description !== undefined && (obj.description = message.description ? Description.toJSON(message.description) : undefined); + message.commission !== undefined && (obj.commission = message.commission ? CommissionRates.toJSON(message.commission) : undefined); + message.minSelfDelegation !== undefined && (obj.minSelfDelegation = message.minSelfDelegation); + message.delegatorAddress !== undefined && (obj.delegatorAddress = message.delegatorAddress); + message.validatorAddress !== undefined && (obj.validatorAddress = message.validatorAddress); + message.pubkey !== undefined && (obj.pubkey = message.pubkey ? Any.toJSON(message.pubkey) : undefined); + message.value !== undefined && (obj.value = message.value ? Coin.toJSON(message.value) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): MsgCreateValidator { + const message = createBaseMsgCreateValidator(); + if (object.description !== undefined && object.description !== null) { + message.description = Description.fromPartial(object.description); + } + if (object.commission !== undefined && object.commission !== null) { + message.commission = CommissionRates.fromPartial(object.commission); + } + message.minSelfDelegation = object.minSelfDelegation ?? ""; + message.delegatorAddress = object.delegatorAddress ?? ""; + message.validatorAddress = object.validatorAddress ?? ""; + if (object.pubkey !== undefined && object.pubkey !== null) { + message.pubkey = Any.fromPartial(object.pubkey); + } + if (object.value !== undefined && object.value !== null) { + message.value = Coin.fromPartial(object.value); + } + return message; + }, + fromSDK(object: MsgCreateValidatorSDKType): MsgCreateValidator { + return { + description: object.description ? Description.fromSDK(object.description) : undefined, + commission: object.commission ? CommissionRates.fromSDK(object.commission) : undefined, + minSelfDelegation: object?.min_self_delegation, + delegatorAddress: object?.delegator_address, + validatorAddress: object?.validator_address, + pubkey: object.pubkey ? Any.fromSDK(object.pubkey) : undefined, + value: object.value ? Coin.fromSDK(object.value) : undefined + }; + }, + fromSDKJSON(object: any): MsgCreateValidatorSDKType { + return { + description: isSet(object.description) ? Description.fromSDKJSON(object.description) : undefined, + commission: isSet(object.commission) ? CommissionRates.fromSDKJSON(object.commission) : undefined, + min_self_delegation: isSet(object.min_self_delegation) ? String(object.min_self_delegation) : "", + delegator_address: isSet(object.delegator_address) ? String(object.delegator_address) : "", + validator_address: isSet(object.validator_address) ? String(object.validator_address) : "", + pubkey: isSet(object.pubkey) ? Any.fromSDKJSON(object.pubkey) : undefined, + value: isSet(object.value) ? Coin.fromSDKJSON(object.value) : undefined + }; + }, + toSDK(message: MsgCreateValidator): MsgCreateValidatorSDKType { + const obj: any = {}; + message.description !== undefined && (obj.description = message.description ? Description.toSDK(message.description) : undefined); + message.commission !== undefined && (obj.commission = message.commission ? CommissionRates.toSDK(message.commission) : undefined); + obj.min_self_delegation = message.minSelfDelegation; + obj.delegator_address = message.delegatorAddress; + obj.validator_address = message.validatorAddress; + message.pubkey !== undefined && (obj.pubkey = message.pubkey ? Any.toSDK(message.pubkey) : undefined); + message.value !== undefined && (obj.value = message.value ? Coin.toSDK(message.value) : undefined); + return obj; + }, + fromAmino(object: MsgCreateValidatorAmino): MsgCreateValidator { + const message = createBaseMsgCreateValidator(); + if (object.description !== undefined && object.description !== null) { + message.description = Description.fromAmino(object.description); + } + if (object.commission !== undefined && object.commission !== null) { + message.commission = CommissionRates.fromAmino(object.commission); + } + if (object.min_self_delegation !== undefined && object.min_self_delegation !== null) { + message.minSelfDelegation = object.min_self_delegation; + } + if (object.delegator_address !== undefined && object.delegator_address !== null) { + message.delegatorAddress = object.delegator_address; + } + if (object.validator_address !== undefined && object.validator_address !== null) { + message.validatorAddress = object.validator_address; + } + if (object.pubkey !== undefined && object.pubkey !== null) { + message.pubkey = encodePubkey(object.pubkey); + } + if (object.value !== undefined && object.value !== null) { + message.value = Coin.fromAmino(object.value); + } + return message; + }, + toAmino(message: MsgCreateValidator): MsgCreateValidatorAmino { + const obj: any = {}; + obj.description = message.description ? Description.toAmino(message.description) : undefined; + obj.commission = message.commission ? CommissionRates.toAmino(message.commission) : undefined; + obj.min_self_delegation = message.minSelfDelegation === "" ? undefined : message.minSelfDelegation; + obj.delegator_address = message.delegatorAddress === "" ? undefined : message.delegatorAddress; + obj.validator_address = message.validatorAddress === "" ? undefined : message.validatorAddress; + obj.pubkey = message.pubkey ? decodePubkey(message.pubkey) : undefined; + obj.value = message.value ? Coin.toAmino(message.value) : undefined; + return obj; + }, + fromAminoMsg(object: MsgCreateValidatorAminoMsg): MsgCreateValidator { + return MsgCreateValidator.fromAmino(object.value); + }, + toAminoMsg(message: MsgCreateValidator): MsgCreateValidatorAminoMsg { + return { + type: "cosmos-sdk/MsgCreateValidator", + value: MsgCreateValidator.toAmino(message) + }; + }, + fromProtoMsg(message: MsgCreateValidatorProtoMsg): MsgCreateValidator { + return MsgCreateValidator.decode(message.value); + }, + toProto(message: MsgCreateValidator): Uint8Array { + return MsgCreateValidator.encode(message).finish(); + }, + toProtoMsg(message: MsgCreateValidator): MsgCreateValidatorProtoMsg { + return { + typeUrl: "/cosmos.staking.v1beta1.MsgCreateValidator", + value: MsgCreateValidator.encode(message).finish() + }; + } +}; +function createBaseMsgCreateValidatorResponse(): MsgCreateValidatorResponse { + return {}; +} +export const MsgCreateValidatorResponse = { + typeUrl: "/cosmos.staking.v1beta1.MsgCreateValidatorResponse", + encode(_: MsgCreateValidatorResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgCreateValidatorResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgCreateValidatorResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgCreateValidatorResponse { + const obj = createBaseMsgCreateValidatorResponse(); + return obj; + }, + toJSON(_: MsgCreateValidatorResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): MsgCreateValidatorResponse { + const message = createBaseMsgCreateValidatorResponse(); + return message; + }, + fromSDK(_: MsgCreateValidatorResponseSDKType): MsgCreateValidatorResponse { + return {}; + }, + fromSDKJSON(_: any): MsgCreateValidatorResponseSDKType { + return {}; + }, + toSDK(_: MsgCreateValidatorResponse): MsgCreateValidatorResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgCreateValidatorResponseAmino): MsgCreateValidatorResponse { + const message = createBaseMsgCreateValidatorResponse(); + return message; + }, + toAmino(_: MsgCreateValidatorResponse): MsgCreateValidatorResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgCreateValidatorResponseAminoMsg): MsgCreateValidatorResponse { + return MsgCreateValidatorResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgCreateValidatorResponse): MsgCreateValidatorResponseAminoMsg { + return { + type: "cosmos-sdk/MsgCreateValidatorResponse", + value: MsgCreateValidatorResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgCreateValidatorResponseProtoMsg): MsgCreateValidatorResponse { + return MsgCreateValidatorResponse.decode(message.value); + }, + toProto(message: MsgCreateValidatorResponse): Uint8Array { + return MsgCreateValidatorResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgCreateValidatorResponse): MsgCreateValidatorResponseProtoMsg { + return { + typeUrl: "/cosmos.staking.v1beta1.MsgCreateValidatorResponse", + value: MsgCreateValidatorResponse.encode(message).finish() + }; + } +}; +function createBaseMsgEditValidator(): MsgEditValidator { + return { + description: Description.fromPartial({}), + validatorAddress: "", + commissionRate: "", + minSelfDelegation: "" + }; +} +export const MsgEditValidator = { + typeUrl: "/cosmos.staking.v1beta1.MsgEditValidator", + encode(message: MsgEditValidator, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.description !== undefined) { + Description.encode(message.description, writer.uint32(10).fork()).ldelim(); + } + if (message.validatorAddress !== undefined) { + writer.uint32(18).string(message.validatorAddress); + } + if (message.commissionRate !== undefined) { + writer.uint32(26).string(Decimal.fromUserInput(message.commissionRate, 18).atomics); + } + if (message.minSelfDelegation !== undefined) { + writer.uint32(34).string(message.minSelfDelegation); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgEditValidator { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgEditValidator(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.description = Description.decode(reader, reader.uint32()); + break; + case 2: + message.validatorAddress = reader.string(); + break; + case 3: + message.commissionRate = Decimal.fromAtomics(reader.string(), 18).toString(); + break; + case 4: + message.minSelfDelegation = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgEditValidator { + const obj = createBaseMsgEditValidator(); + if (isSet(object.description)) obj.description = Description.fromJSON(object.description); + if (isSet(object.validatorAddress)) obj.validatorAddress = String(object.validatorAddress); + if (isSet(object.commissionRate)) obj.commissionRate = String(object.commissionRate); + if (isSet(object.minSelfDelegation)) obj.minSelfDelegation = String(object.minSelfDelegation); + return obj; + }, + toJSON(message: MsgEditValidator): JsonSafe { + const obj: any = {}; + message.description !== undefined && (obj.description = message.description ? Description.toJSON(message.description) : undefined); + message.validatorAddress !== undefined && (obj.validatorAddress = message.validatorAddress); + message.commissionRate !== undefined && (obj.commissionRate = message.commissionRate); + message.minSelfDelegation !== undefined && (obj.minSelfDelegation = message.minSelfDelegation); + return obj; + }, + fromPartial(object: DeepPartial): MsgEditValidator { + const message = createBaseMsgEditValidator(); + if (object.description !== undefined && object.description !== null) { + message.description = Description.fromPartial(object.description); + } + message.validatorAddress = object.validatorAddress ?? ""; + message.commissionRate = object.commissionRate ?? ""; + message.minSelfDelegation = object.minSelfDelegation ?? ""; + return message; + }, + fromSDK(object: MsgEditValidatorSDKType): MsgEditValidator { + return { + description: object.description ? Description.fromSDK(object.description) : undefined, + validatorAddress: object?.validator_address, + commissionRate: object?.commission_rate, + minSelfDelegation: object?.min_self_delegation + }; + }, + fromSDKJSON(object: any): MsgEditValidatorSDKType { + return { + description: isSet(object.description) ? Description.fromSDKJSON(object.description) : undefined, + validator_address: isSet(object.validator_address) ? String(object.validator_address) : "", + commission_rate: isSet(object.commission_rate) ? String(object.commission_rate) : "", + min_self_delegation: isSet(object.min_self_delegation) ? String(object.min_self_delegation) : "" + }; + }, + toSDK(message: MsgEditValidator): MsgEditValidatorSDKType { + const obj: any = {}; + message.description !== undefined && (obj.description = message.description ? Description.toSDK(message.description) : undefined); + obj.validator_address = message.validatorAddress; + obj.commission_rate = message.commissionRate; + obj.min_self_delegation = message.minSelfDelegation; + return obj; + }, + fromAmino(object: MsgEditValidatorAmino): MsgEditValidator { + const message = createBaseMsgEditValidator(); + if (object.description !== undefined && object.description !== null) { + message.description = Description.fromAmino(object.description); + } + if (object.validator_address !== undefined && object.validator_address !== null) { + message.validatorAddress = object.validator_address; + } + if (object.commission_rate !== undefined && object.commission_rate !== null) { + message.commissionRate = object.commission_rate; + } + if (object.min_self_delegation !== undefined && object.min_self_delegation !== null) { + message.minSelfDelegation = object.min_self_delegation; + } + return message; + }, + toAmino(message: MsgEditValidator): MsgEditValidatorAmino { + const obj: any = {}; + obj.description = message.description ? Description.toAmino(message.description) : undefined; + obj.validator_address = message.validatorAddress === "" ? undefined : message.validatorAddress; + obj.commission_rate = message.commissionRate === "" ? undefined : message.commissionRate; + obj.min_self_delegation = message.minSelfDelegation === "" ? undefined : message.minSelfDelegation; + return obj; + }, + fromAminoMsg(object: MsgEditValidatorAminoMsg): MsgEditValidator { + return MsgEditValidator.fromAmino(object.value); + }, + toAminoMsg(message: MsgEditValidator): MsgEditValidatorAminoMsg { + return { + type: "cosmos-sdk/MsgEditValidator", + value: MsgEditValidator.toAmino(message) + }; + }, + fromProtoMsg(message: MsgEditValidatorProtoMsg): MsgEditValidator { + return MsgEditValidator.decode(message.value); + }, + toProto(message: MsgEditValidator): Uint8Array { + return MsgEditValidator.encode(message).finish(); + }, + toProtoMsg(message: MsgEditValidator): MsgEditValidatorProtoMsg { + return { + typeUrl: "/cosmos.staking.v1beta1.MsgEditValidator", + value: MsgEditValidator.encode(message).finish() + }; + } +}; +function createBaseMsgEditValidatorResponse(): MsgEditValidatorResponse { + return {}; +} +export const MsgEditValidatorResponse = { + typeUrl: "/cosmos.staking.v1beta1.MsgEditValidatorResponse", + encode(_: MsgEditValidatorResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgEditValidatorResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgEditValidatorResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgEditValidatorResponse { + const obj = createBaseMsgEditValidatorResponse(); + return obj; + }, + toJSON(_: MsgEditValidatorResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): MsgEditValidatorResponse { + const message = createBaseMsgEditValidatorResponse(); + return message; + }, + fromSDK(_: MsgEditValidatorResponseSDKType): MsgEditValidatorResponse { + return {}; + }, + fromSDKJSON(_: any): MsgEditValidatorResponseSDKType { + return {}; + }, + toSDK(_: MsgEditValidatorResponse): MsgEditValidatorResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgEditValidatorResponseAmino): MsgEditValidatorResponse { + const message = createBaseMsgEditValidatorResponse(); + return message; + }, + toAmino(_: MsgEditValidatorResponse): MsgEditValidatorResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgEditValidatorResponseAminoMsg): MsgEditValidatorResponse { + return MsgEditValidatorResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgEditValidatorResponse): MsgEditValidatorResponseAminoMsg { + return { + type: "cosmos-sdk/MsgEditValidatorResponse", + value: MsgEditValidatorResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgEditValidatorResponseProtoMsg): MsgEditValidatorResponse { + return MsgEditValidatorResponse.decode(message.value); + }, + toProto(message: MsgEditValidatorResponse): Uint8Array { + return MsgEditValidatorResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgEditValidatorResponse): MsgEditValidatorResponseProtoMsg { + return { + typeUrl: "/cosmos.staking.v1beta1.MsgEditValidatorResponse", + value: MsgEditValidatorResponse.encode(message).finish() + }; + } +}; +function createBaseMsgDelegate(): MsgDelegate { + return { + delegatorAddress: "", + validatorAddress: "", + amount: Coin.fromPartial({}) + }; +} +export const MsgDelegate = { + typeUrl: "/cosmos.staking.v1beta1.MsgDelegate", + encode(message: MsgDelegate, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.delegatorAddress !== undefined) { + writer.uint32(10).string(message.delegatorAddress); + } + if (message.validatorAddress !== undefined) { + writer.uint32(18).string(message.validatorAddress); + } + if (message.amount !== undefined) { + Coin.encode(message.amount, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgDelegate { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgDelegate(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.delegatorAddress = reader.string(); + break; + case 2: + message.validatorAddress = reader.string(); + break; + case 3: + message.amount = Coin.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgDelegate { + const obj = createBaseMsgDelegate(); + if (isSet(object.delegatorAddress)) obj.delegatorAddress = String(object.delegatorAddress); + if (isSet(object.validatorAddress)) obj.validatorAddress = String(object.validatorAddress); + if (isSet(object.amount)) obj.amount = Coin.fromJSON(object.amount); + return obj; + }, + toJSON(message: MsgDelegate): JsonSafe { + const obj: any = {}; + message.delegatorAddress !== undefined && (obj.delegatorAddress = message.delegatorAddress); + message.validatorAddress !== undefined && (obj.validatorAddress = message.validatorAddress); + message.amount !== undefined && (obj.amount = message.amount ? Coin.toJSON(message.amount) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): MsgDelegate { + const message = createBaseMsgDelegate(); + message.delegatorAddress = object.delegatorAddress ?? ""; + message.validatorAddress = object.validatorAddress ?? ""; + if (object.amount !== undefined && object.amount !== null) { + message.amount = Coin.fromPartial(object.amount); + } + return message; + }, + fromSDK(object: MsgDelegateSDKType): MsgDelegate { + return { + delegatorAddress: object?.delegator_address, + validatorAddress: object?.validator_address, + amount: object.amount ? Coin.fromSDK(object.amount) : undefined + }; + }, + fromSDKJSON(object: any): MsgDelegateSDKType { + return { + delegator_address: isSet(object.delegator_address) ? String(object.delegator_address) : "", + validator_address: isSet(object.validator_address) ? String(object.validator_address) : "", + amount: isSet(object.amount) ? Coin.fromSDKJSON(object.amount) : undefined + }; + }, + toSDK(message: MsgDelegate): MsgDelegateSDKType { + const obj: any = {}; + obj.delegator_address = message.delegatorAddress; + obj.validator_address = message.validatorAddress; + message.amount !== undefined && (obj.amount = message.amount ? Coin.toSDK(message.amount) : undefined); + return obj; + }, + fromAmino(object: MsgDelegateAmino): MsgDelegate { + const message = createBaseMsgDelegate(); + if (object.delegator_address !== undefined && object.delegator_address !== null) { + message.delegatorAddress = object.delegator_address; + } + if (object.validator_address !== undefined && object.validator_address !== null) { + message.validatorAddress = object.validator_address; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = Coin.fromAmino(object.amount); + } + return message; + }, + toAmino(message: MsgDelegate): MsgDelegateAmino { + const obj: any = {}; + obj.delegator_address = message.delegatorAddress === "" ? undefined : message.delegatorAddress; + obj.validator_address = message.validatorAddress === "" ? undefined : message.validatorAddress; + obj.amount = message.amount ? Coin.toAmino(message.amount) : undefined; + return obj; + }, + fromAminoMsg(object: MsgDelegateAminoMsg): MsgDelegate { + return MsgDelegate.fromAmino(object.value); + }, + toAminoMsg(message: MsgDelegate): MsgDelegateAminoMsg { + return { + type: "cosmos-sdk/MsgDelegate", + value: MsgDelegate.toAmino(message) + }; + }, + fromProtoMsg(message: MsgDelegateProtoMsg): MsgDelegate { + return MsgDelegate.decode(message.value); + }, + toProto(message: MsgDelegate): Uint8Array { + return MsgDelegate.encode(message).finish(); + }, + toProtoMsg(message: MsgDelegate): MsgDelegateProtoMsg { + return { + typeUrl: "/cosmos.staking.v1beta1.MsgDelegate", + value: MsgDelegate.encode(message).finish() + }; + } +}; +function createBaseMsgDelegateResponse(): MsgDelegateResponse { + return {}; +} +export const MsgDelegateResponse = { + typeUrl: "/cosmos.staking.v1beta1.MsgDelegateResponse", + encode(_: MsgDelegateResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgDelegateResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgDelegateResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgDelegateResponse { + const obj = createBaseMsgDelegateResponse(); + return obj; + }, + toJSON(_: MsgDelegateResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): MsgDelegateResponse { + const message = createBaseMsgDelegateResponse(); + return message; + }, + fromSDK(_: MsgDelegateResponseSDKType): MsgDelegateResponse { + return {}; + }, + fromSDKJSON(_: any): MsgDelegateResponseSDKType { + return {}; + }, + toSDK(_: MsgDelegateResponse): MsgDelegateResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgDelegateResponseAmino): MsgDelegateResponse { + const message = createBaseMsgDelegateResponse(); + return message; + }, + toAmino(_: MsgDelegateResponse): MsgDelegateResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgDelegateResponseAminoMsg): MsgDelegateResponse { + return MsgDelegateResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgDelegateResponse): MsgDelegateResponseAminoMsg { + return { + type: "cosmos-sdk/MsgDelegateResponse", + value: MsgDelegateResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgDelegateResponseProtoMsg): MsgDelegateResponse { + return MsgDelegateResponse.decode(message.value); + }, + toProto(message: MsgDelegateResponse): Uint8Array { + return MsgDelegateResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgDelegateResponse): MsgDelegateResponseProtoMsg { + return { + typeUrl: "/cosmos.staking.v1beta1.MsgDelegateResponse", + value: MsgDelegateResponse.encode(message).finish() + }; + } +}; +function createBaseMsgBeginRedelegate(): MsgBeginRedelegate { + return { + delegatorAddress: "", + validatorSrcAddress: "", + validatorDstAddress: "", + amount: Coin.fromPartial({}) + }; +} +export const MsgBeginRedelegate = { + typeUrl: "/cosmos.staking.v1beta1.MsgBeginRedelegate", + encode(message: MsgBeginRedelegate, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.delegatorAddress !== undefined) { + writer.uint32(10).string(message.delegatorAddress); + } + if (message.validatorSrcAddress !== undefined) { + writer.uint32(18).string(message.validatorSrcAddress); + } + if (message.validatorDstAddress !== undefined) { + writer.uint32(26).string(message.validatorDstAddress); + } + if (message.amount !== undefined) { + Coin.encode(message.amount, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgBeginRedelegate { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgBeginRedelegate(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.delegatorAddress = reader.string(); + break; + case 2: + message.validatorSrcAddress = reader.string(); + break; + case 3: + message.validatorDstAddress = reader.string(); + break; + case 4: + message.amount = Coin.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgBeginRedelegate { + const obj = createBaseMsgBeginRedelegate(); + if (isSet(object.delegatorAddress)) obj.delegatorAddress = String(object.delegatorAddress); + if (isSet(object.validatorSrcAddress)) obj.validatorSrcAddress = String(object.validatorSrcAddress); + if (isSet(object.validatorDstAddress)) obj.validatorDstAddress = String(object.validatorDstAddress); + if (isSet(object.amount)) obj.amount = Coin.fromJSON(object.amount); + return obj; + }, + toJSON(message: MsgBeginRedelegate): JsonSafe { + const obj: any = {}; + message.delegatorAddress !== undefined && (obj.delegatorAddress = message.delegatorAddress); + message.validatorSrcAddress !== undefined && (obj.validatorSrcAddress = message.validatorSrcAddress); + message.validatorDstAddress !== undefined && (obj.validatorDstAddress = message.validatorDstAddress); + message.amount !== undefined && (obj.amount = message.amount ? Coin.toJSON(message.amount) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): MsgBeginRedelegate { + const message = createBaseMsgBeginRedelegate(); + message.delegatorAddress = object.delegatorAddress ?? ""; + message.validatorSrcAddress = object.validatorSrcAddress ?? ""; + message.validatorDstAddress = object.validatorDstAddress ?? ""; + if (object.amount !== undefined && object.amount !== null) { + message.amount = Coin.fromPartial(object.amount); + } + return message; + }, + fromSDK(object: MsgBeginRedelegateSDKType): MsgBeginRedelegate { + return { + delegatorAddress: object?.delegator_address, + validatorSrcAddress: object?.validator_src_address, + validatorDstAddress: object?.validator_dst_address, + amount: object.amount ? Coin.fromSDK(object.amount) : undefined + }; + }, + fromSDKJSON(object: any): MsgBeginRedelegateSDKType { + return { + delegator_address: isSet(object.delegator_address) ? String(object.delegator_address) : "", + validator_src_address: isSet(object.validator_src_address) ? String(object.validator_src_address) : "", + validator_dst_address: isSet(object.validator_dst_address) ? String(object.validator_dst_address) : "", + amount: isSet(object.amount) ? Coin.fromSDKJSON(object.amount) : undefined + }; + }, + toSDK(message: MsgBeginRedelegate): MsgBeginRedelegateSDKType { + const obj: any = {}; + obj.delegator_address = message.delegatorAddress; + obj.validator_src_address = message.validatorSrcAddress; + obj.validator_dst_address = message.validatorDstAddress; + message.amount !== undefined && (obj.amount = message.amount ? Coin.toSDK(message.amount) : undefined); + return obj; + }, + fromAmino(object: MsgBeginRedelegateAmino): MsgBeginRedelegate { + const message = createBaseMsgBeginRedelegate(); + if (object.delegator_address !== undefined && object.delegator_address !== null) { + message.delegatorAddress = object.delegator_address; + } + if (object.validator_src_address !== undefined && object.validator_src_address !== null) { + message.validatorSrcAddress = object.validator_src_address; + } + if (object.validator_dst_address !== undefined && object.validator_dst_address !== null) { + message.validatorDstAddress = object.validator_dst_address; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = Coin.fromAmino(object.amount); + } + return message; + }, + toAmino(message: MsgBeginRedelegate): MsgBeginRedelegateAmino { + const obj: any = {}; + obj.delegator_address = message.delegatorAddress === "" ? undefined : message.delegatorAddress; + obj.validator_src_address = message.validatorSrcAddress === "" ? undefined : message.validatorSrcAddress; + obj.validator_dst_address = message.validatorDstAddress === "" ? undefined : message.validatorDstAddress; + obj.amount = message.amount ? Coin.toAmino(message.amount) : undefined; + return obj; + }, + fromAminoMsg(object: MsgBeginRedelegateAminoMsg): MsgBeginRedelegate { + return MsgBeginRedelegate.fromAmino(object.value); + }, + toAminoMsg(message: MsgBeginRedelegate): MsgBeginRedelegateAminoMsg { + return { + type: "cosmos-sdk/MsgBeginRedelegate", + value: MsgBeginRedelegate.toAmino(message) + }; + }, + fromProtoMsg(message: MsgBeginRedelegateProtoMsg): MsgBeginRedelegate { + return MsgBeginRedelegate.decode(message.value); + }, + toProto(message: MsgBeginRedelegate): Uint8Array { + return MsgBeginRedelegate.encode(message).finish(); + }, + toProtoMsg(message: MsgBeginRedelegate): MsgBeginRedelegateProtoMsg { + return { + typeUrl: "/cosmos.staking.v1beta1.MsgBeginRedelegate", + value: MsgBeginRedelegate.encode(message).finish() + }; + } +}; +function createBaseMsgBeginRedelegateResponse(): MsgBeginRedelegateResponse { + return { + completionTime: new Date() + }; +} +export const MsgBeginRedelegateResponse = { + typeUrl: "/cosmos.staking.v1beta1.MsgBeginRedelegateResponse", + encode(message: MsgBeginRedelegateResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.completionTime !== undefined) { + Timestamp.encode(toTimestamp(message.completionTime), writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgBeginRedelegateResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgBeginRedelegateResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.completionTime = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgBeginRedelegateResponse { + const obj = createBaseMsgBeginRedelegateResponse(); + if (isSet(object.completionTime)) obj.completionTime = new Date(object.completionTime); + return obj; + }, + toJSON(message: MsgBeginRedelegateResponse): JsonSafe { + const obj: any = {}; + message.completionTime !== undefined && (obj.completionTime = message.completionTime.toISOString()); + return obj; + }, + fromPartial(object: DeepPartial): MsgBeginRedelegateResponse { + const message = createBaseMsgBeginRedelegateResponse(); + message.completionTime = object.completionTime ?? undefined; + return message; + }, + fromSDK(object: MsgBeginRedelegateResponseSDKType): MsgBeginRedelegateResponse { + return { + completionTime: object.completion_time ?? undefined + }; + }, + fromSDKJSON(object: any): MsgBeginRedelegateResponseSDKType { + return { + completion_time: isSet(object.completion_time) ? new Date(object.completion_time) : undefined + }; + }, + toSDK(message: MsgBeginRedelegateResponse): MsgBeginRedelegateResponseSDKType { + const obj: any = {}; + message.completionTime !== undefined && (obj.completion_time = message.completionTime ?? undefined); + return obj; + }, + fromAmino(object: MsgBeginRedelegateResponseAmino): MsgBeginRedelegateResponse { + const message = createBaseMsgBeginRedelegateResponse(); + if (object.completion_time !== undefined && object.completion_time !== null) { + message.completionTime = fromTimestamp(Timestamp.fromAmino(object.completion_time)); + } + return message; + }, + toAmino(message: MsgBeginRedelegateResponse): MsgBeginRedelegateResponseAmino { + const obj: any = {}; + obj.completion_time = message.completionTime ? Timestamp.toAmino(toTimestamp(message.completionTime)) : undefined; + return obj; + }, + fromAminoMsg(object: MsgBeginRedelegateResponseAminoMsg): MsgBeginRedelegateResponse { + return MsgBeginRedelegateResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgBeginRedelegateResponse): MsgBeginRedelegateResponseAminoMsg { + return { + type: "cosmos-sdk/MsgBeginRedelegateResponse", + value: MsgBeginRedelegateResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgBeginRedelegateResponseProtoMsg): MsgBeginRedelegateResponse { + return MsgBeginRedelegateResponse.decode(message.value); + }, + toProto(message: MsgBeginRedelegateResponse): Uint8Array { + return MsgBeginRedelegateResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgBeginRedelegateResponse): MsgBeginRedelegateResponseProtoMsg { + return { + typeUrl: "/cosmos.staking.v1beta1.MsgBeginRedelegateResponse", + value: MsgBeginRedelegateResponse.encode(message).finish() + }; + } +}; +function createBaseMsgUndelegate(): MsgUndelegate { + return { + delegatorAddress: "", + validatorAddress: "", + amount: Coin.fromPartial({}) + }; +} +export const MsgUndelegate = { + typeUrl: "/cosmos.staking.v1beta1.MsgUndelegate", + encode(message: MsgUndelegate, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.delegatorAddress !== undefined) { + writer.uint32(10).string(message.delegatorAddress); + } + if (message.validatorAddress !== undefined) { + writer.uint32(18).string(message.validatorAddress); + } + if (message.amount !== undefined) { + Coin.encode(message.amount, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgUndelegate { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgUndelegate(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.delegatorAddress = reader.string(); + break; + case 2: + message.validatorAddress = reader.string(); + break; + case 3: + message.amount = Coin.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgUndelegate { + const obj = createBaseMsgUndelegate(); + if (isSet(object.delegatorAddress)) obj.delegatorAddress = String(object.delegatorAddress); + if (isSet(object.validatorAddress)) obj.validatorAddress = String(object.validatorAddress); + if (isSet(object.amount)) obj.amount = Coin.fromJSON(object.amount); + return obj; + }, + toJSON(message: MsgUndelegate): JsonSafe { + const obj: any = {}; + message.delegatorAddress !== undefined && (obj.delegatorAddress = message.delegatorAddress); + message.validatorAddress !== undefined && (obj.validatorAddress = message.validatorAddress); + message.amount !== undefined && (obj.amount = message.amount ? Coin.toJSON(message.amount) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): MsgUndelegate { + const message = createBaseMsgUndelegate(); + message.delegatorAddress = object.delegatorAddress ?? ""; + message.validatorAddress = object.validatorAddress ?? ""; + if (object.amount !== undefined && object.amount !== null) { + message.amount = Coin.fromPartial(object.amount); + } + return message; + }, + fromSDK(object: MsgUndelegateSDKType): MsgUndelegate { + return { + delegatorAddress: object?.delegator_address, + validatorAddress: object?.validator_address, + amount: object.amount ? Coin.fromSDK(object.amount) : undefined + }; + }, + fromSDKJSON(object: any): MsgUndelegateSDKType { + return { + delegator_address: isSet(object.delegator_address) ? String(object.delegator_address) : "", + validator_address: isSet(object.validator_address) ? String(object.validator_address) : "", + amount: isSet(object.amount) ? Coin.fromSDKJSON(object.amount) : undefined + }; + }, + toSDK(message: MsgUndelegate): MsgUndelegateSDKType { + const obj: any = {}; + obj.delegator_address = message.delegatorAddress; + obj.validator_address = message.validatorAddress; + message.amount !== undefined && (obj.amount = message.amount ? Coin.toSDK(message.amount) : undefined); + return obj; + }, + fromAmino(object: MsgUndelegateAmino): MsgUndelegate { + const message = createBaseMsgUndelegate(); + if (object.delegator_address !== undefined && object.delegator_address !== null) { + message.delegatorAddress = object.delegator_address; + } + if (object.validator_address !== undefined && object.validator_address !== null) { + message.validatorAddress = object.validator_address; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = Coin.fromAmino(object.amount); + } + return message; + }, + toAmino(message: MsgUndelegate): MsgUndelegateAmino { + const obj: any = {}; + obj.delegator_address = message.delegatorAddress === "" ? undefined : message.delegatorAddress; + obj.validator_address = message.validatorAddress === "" ? undefined : message.validatorAddress; + obj.amount = message.amount ? Coin.toAmino(message.amount) : undefined; + return obj; + }, + fromAminoMsg(object: MsgUndelegateAminoMsg): MsgUndelegate { + return MsgUndelegate.fromAmino(object.value); + }, + toAminoMsg(message: MsgUndelegate): MsgUndelegateAminoMsg { + return { + type: "cosmos-sdk/MsgUndelegate", + value: MsgUndelegate.toAmino(message) + }; + }, + fromProtoMsg(message: MsgUndelegateProtoMsg): MsgUndelegate { + return MsgUndelegate.decode(message.value); + }, + toProto(message: MsgUndelegate): Uint8Array { + return MsgUndelegate.encode(message).finish(); + }, + toProtoMsg(message: MsgUndelegate): MsgUndelegateProtoMsg { + return { + typeUrl: "/cosmos.staking.v1beta1.MsgUndelegate", + value: MsgUndelegate.encode(message).finish() + }; + } +}; +function createBaseMsgUndelegateResponse(): MsgUndelegateResponse { + return { + completionTime: new Date() + }; +} +export const MsgUndelegateResponse = { + typeUrl: "/cosmos.staking.v1beta1.MsgUndelegateResponse", + encode(message: MsgUndelegateResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.completionTime !== undefined) { + Timestamp.encode(toTimestamp(message.completionTime), writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgUndelegateResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgUndelegateResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.completionTime = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgUndelegateResponse { + const obj = createBaseMsgUndelegateResponse(); + if (isSet(object.completionTime)) obj.completionTime = new Date(object.completionTime); + return obj; + }, + toJSON(message: MsgUndelegateResponse): JsonSafe { + const obj: any = {}; + message.completionTime !== undefined && (obj.completionTime = message.completionTime.toISOString()); + return obj; + }, + fromPartial(object: DeepPartial): MsgUndelegateResponse { + const message = createBaseMsgUndelegateResponse(); + message.completionTime = object.completionTime ?? undefined; + return message; + }, + fromSDK(object: MsgUndelegateResponseSDKType): MsgUndelegateResponse { + return { + completionTime: object.completion_time ?? undefined + }; + }, + fromSDKJSON(object: any): MsgUndelegateResponseSDKType { + return { + completion_time: isSet(object.completion_time) ? new Date(object.completion_time) : undefined + }; + }, + toSDK(message: MsgUndelegateResponse): MsgUndelegateResponseSDKType { + const obj: any = {}; + message.completionTime !== undefined && (obj.completion_time = message.completionTime ?? undefined); + return obj; + }, + fromAmino(object: MsgUndelegateResponseAmino): MsgUndelegateResponse { + const message = createBaseMsgUndelegateResponse(); + if (object.completion_time !== undefined && object.completion_time !== null) { + message.completionTime = fromTimestamp(Timestamp.fromAmino(object.completion_time)); + } + return message; + }, + toAmino(message: MsgUndelegateResponse): MsgUndelegateResponseAmino { + const obj: any = {}; + obj.completion_time = message.completionTime ? Timestamp.toAmino(toTimestamp(message.completionTime)) : undefined; + return obj; + }, + fromAminoMsg(object: MsgUndelegateResponseAminoMsg): MsgUndelegateResponse { + return MsgUndelegateResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgUndelegateResponse): MsgUndelegateResponseAminoMsg { + return { + type: "cosmos-sdk/MsgUndelegateResponse", + value: MsgUndelegateResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgUndelegateResponseProtoMsg): MsgUndelegateResponse { + return MsgUndelegateResponse.decode(message.value); + }, + toProto(message: MsgUndelegateResponse): Uint8Array { + return MsgUndelegateResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgUndelegateResponse): MsgUndelegateResponseProtoMsg { + return { + typeUrl: "/cosmos.staking.v1beta1.MsgUndelegateResponse", + value: MsgUndelegateResponse.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/tx/signing/v1beta1/signing.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/tx/signing/v1beta1/signing.ts new file mode 100644 index 0000000000..5e627b7fc1 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/tx/signing/v1beta1/signing.ts @@ -0,0 +1,770 @@ +import { CompactBitArray, CompactBitArraySDKType } from "../../../crypto/multisig/v1beta1/multisig.js"; +import { Any, AnySDKType } from "../../../../google/protobuf/any.js"; +import { BinaryReader, BinaryWriter } from "../../../../binary.js"; +import { JsonSafe } from "../../../../json-safe.js"; +import { DeepPartial, isSet, bytesFromBase64, base64FromBytes } from "../../../../helpers.js"; +export const protobufPackage = "cosmos.tx.signing.v1beta1"; +/** + * SignMode represents a signing mode with its own security guarantees. + * + * This enum should be considered a registry of all known sign modes + * in the Cosmos ecosystem. Apps are not expected to support all known + * sign modes. Apps that would like to support custom sign modes are + * encouraged to open a small PR against this file to add a new case + * to this SignMode enum describing their sign mode so that different + * apps have a consistent version of this enum. + */ +export enum SignMode { + /** + * SIGN_MODE_UNSPECIFIED - SIGN_MODE_UNSPECIFIED specifies an unknown signing mode and will be + * rejected. + */ + SIGN_MODE_UNSPECIFIED = 0, + /** + * SIGN_MODE_DIRECT - SIGN_MODE_DIRECT specifies a signing mode which uses SignDoc and is + * verified with raw bytes from Tx. + */ + SIGN_MODE_DIRECT = 1, + /** + * SIGN_MODE_TEXTUAL - SIGN_MODE_TEXTUAL is a future signing mode that will verify some + * human-readable textual representation on top of the binary representation + * from SIGN_MODE_DIRECT. It is currently not supported. + */ + SIGN_MODE_TEXTUAL = 2, + /** + * SIGN_MODE_DIRECT_AUX - SIGN_MODE_DIRECT_AUX specifies a signing mode which uses + * SignDocDirectAux. As opposed to SIGN_MODE_DIRECT, this sign mode does not + * require signers signing over other signers' `signer_info`. It also allows + * for adding Tips in transactions. + * + * Since: cosmos-sdk 0.46 + */ + SIGN_MODE_DIRECT_AUX = 3, + /** + * SIGN_MODE_LEGACY_AMINO_JSON - SIGN_MODE_LEGACY_AMINO_JSON is a backwards compatibility mode which uses + * Amino JSON and will be removed in the future. + */ + SIGN_MODE_LEGACY_AMINO_JSON = 127, + UNRECOGNIZED = -1, +} +export const SignModeSDKType = SignMode; +export function signModeFromJSON(object: any): SignMode { + switch (object) { + case 0: + case "SIGN_MODE_UNSPECIFIED": + return SignMode.SIGN_MODE_UNSPECIFIED; + case 1: + case "SIGN_MODE_DIRECT": + return SignMode.SIGN_MODE_DIRECT; + case 2: + case "SIGN_MODE_TEXTUAL": + return SignMode.SIGN_MODE_TEXTUAL; + case 3: + case "SIGN_MODE_DIRECT_AUX": + return SignMode.SIGN_MODE_DIRECT_AUX; + case 127: + case "SIGN_MODE_LEGACY_AMINO_JSON": + return SignMode.SIGN_MODE_LEGACY_AMINO_JSON; + case -1: + case "UNRECOGNIZED": + default: + return SignMode.UNRECOGNIZED; + } +} +export function signModeToJSON(object: SignMode): string { + switch (object) { + case SignMode.SIGN_MODE_UNSPECIFIED: + return "SIGN_MODE_UNSPECIFIED"; + case SignMode.SIGN_MODE_DIRECT: + return "SIGN_MODE_DIRECT"; + case SignMode.SIGN_MODE_TEXTUAL: + return "SIGN_MODE_TEXTUAL"; + case SignMode.SIGN_MODE_DIRECT_AUX: + return "SIGN_MODE_DIRECT_AUX"; + case SignMode.SIGN_MODE_LEGACY_AMINO_JSON: + return "SIGN_MODE_LEGACY_AMINO_JSON"; + case SignMode.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** SignatureDescriptors wraps multiple SignatureDescriptor's. */ +export interface SignatureDescriptors { + /** signatures are the signature descriptors */ + signatures: SignatureDescriptor[]; +} +export interface SignatureDescriptorsProtoMsg { + typeUrl: "/cosmos.tx.signing.v1beta1.SignatureDescriptors"; + value: Uint8Array; +} +/** SignatureDescriptors wraps multiple SignatureDescriptor's. */ +export interface SignatureDescriptorsSDKType { + signatures: SignatureDescriptorSDKType[]; +} +/** + * SignatureDescriptor is a convenience type which represents the full data for + * a signature including the public key of the signer, signing modes and the + * signature itself. It is primarily used for coordinating signatures between + * clients. + */ +export interface SignatureDescriptor { + /** public_key is the public key of the signer */ + publicKey?: Any; + data?: SignatureDescriptor_Data; + /** + * sequence is the sequence of the account, which describes the + * number of committed transactions signed by a given address. It is used to prevent + * replay attacks. + */ + sequence: bigint; +} +export interface SignatureDescriptorProtoMsg { + typeUrl: "/cosmos.tx.signing.v1beta1.SignatureDescriptor"; + value: Uint8Array; +} +/** + * SignatureDescriptor is a convenience type which represents the full data for + * a signature including the public key of the signer, signing modes and the + * signature itself. It is primarily used for coordinating signatures between + * clients. + */ +export interface SignatureDescriptorSDKType { + public_key?: AnySDKType; + data?: SignatureDescriptor_DataSDKType; + sequence: bigint; +} +/** Data represents signature data */ +export interface SignatureDescriptor_Data { + /** single represents a single signer */ + single?: SignatureDescriptor_Data_Single; + /** multi represents a multisig signer */ + multi?: SignatureDescriptor_Data_Multi; +} +export interface SignatureDescriptor_DataProtoMsg { + typeUrl: "/cosmos.tx.signing.v1beta1.Data"; + value: Uint8Array; +} +/** Data represents signature data */ +export interface SignatureDescriptor_DataSDKType { + single?: SignatureDescriptor_Data_SingleSDKType; + multi?: SignatureDescriptor_Data_MultiSDKType; +} +/** Single is the signature data for a single signer */ +export interface SignatureDescriptor_Data_Single { + /** mode is the signing mode of the single signer */ + mode: SignMode; + /** signature is the raw signature bytes */ + signature: Uint8Array; +} +export interface SignatureDescriptor_Data_SingleProtoMsg { + typeUrl: "/cosmos.tx.signing.v1beta1.Single"; + value: Uint8Array; +} +/** Single is the signature data for a single signer */ +export interface SignatureDescriptor_Data_SingleSDKType { + mode: SignMode; + signature: Uint8Array; +} +/** Multi is the signature data for a multisig public key */ +export interface SignatureDescriptor_Data_Multi { + /** bitarray specifies which keys within the multisig are signing */ + bitarray?: CompactBitArray; + /** signatures is the signatures of the multi-signature */ + signatures: SignatureDescriptor_Data[]; +} +export interface SignatureDescriptor_Data_MultiProtoMsg { + typeUrl: "/cosmos.tx.signing.v1beta1.Multi"; + value: Uint8Array; +} +/** Multi is the signature data for a multisig public key */ +export interface SignatureDescriptor_Data_MultiSDKType { + bitarray?: CompactBitArraySDKType; + signatures: SignatureDescriptor_DataSDKType[]; +} +function createBaseSignatureDescriptors(): SignatureDescriptors { + return { + signatures: [] + }; +} +export const SignatureDescriptors = { + typeUrl: "/cosmos.tx.signing.v1beta1.SignatureDescriptors", + encode(message: SignatureDescriptors, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.signatures) { + SignatureDescriptor.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): SignatureDescriptors { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseSignatureDescriptors(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.signatures.push(SignatureDescriptor.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): SignatureDescriptors { + const obj = createBaseSignatureDescriptors(); + if (Array.isArray(object?.signatures)) obj.signatures = object.signatures.map((e: any) => SignatureDescriptor.fromJSON(e)); + return obj; + }, + toJSON(message: SignatureDescriptors): JsonSafe { + const obj: any = {}; + if (message.signatures) { + obj.signatures = message.signatures.map(e => e ? SignatureDescriptor.toJSON(e) : undefined); + } else { + obj.signatures = []; + } + return obj; + }, + fromPartial(object: DeepPartial): SignatureDescriptors { + const message = createBaseSignatureDescriptors(); + message.signatures = object.signatures?.map(e => SignatureDescriptor.fromPartial(e)) || []; + return message; + }, + fromSDK(object: SignatureDescriptorsSDKType): SignatureDescriptors { + return { + signatures: Array.isArray(object?.signatures) ? object.signatures.map((e: any) => SignatureDescriptor.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): SignatureDescriptorsSDKType { + return { + signatures: Array.isArray(object?.signatures) ? object.signatures.map((e: any) => SignatureDescriptor.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: SignatureDescriptors): SignatureDescriptorsSDKType { + const obj: any = {}; + if (message.signatures) { + obj.signatures = message.signatures.map(e => e ? SignatureDescriptor.toSDK(e) : undefined); + } else { + obj.signatures = []; + } + return obj; + }, + fromAmino(object: SignatureDescriptorsAmino): SignatureDescriptors { + const message = createBaseSignatureDescriptors(); + message.signatures = object.signatures?.map(e => SignatureDescriptor.fromAmino(e)) || []; + return message; + }, + toAmino(message: SignatureDescriptors): SignatureDescriptorsAmino { + const obj: any = {}; + if (message.signatures) { + obj.signatures = message.signatures.map(e => e ? SignatureDescriptor.toAmino(e) : undefined); + } else { + obj.signatures = message.signatures; + } + return obj; + }, + fromAminoMsg(object: SignatureDescriptorsAminoMsg): SignatureDescriptors { + return SignatureDescriptors.fromAmino(object.value); + }, + toAminoMsg(message: SignatureDescriptors): SignatureDescriptorsAminoMsg { + return { + type: "cosmos-sdk/SignatureDescriptors", + value: SignatureDescriptors.toAmino(message) + }; + }, + fromProtoMsg(message: SignatureDescriptorsProtoMsg): SignatureDescriptors { + return SignatureDescriptors.decode(message.value); + }, + toProto(message: SignatureDescriptors): Uint8Array { + return SignatureDescriptors.encode(message).finish(); + }, + toProtoMsg(message: SignatureDescriptors): SignatureDescriptorsProtoMsg { + return { + typeUrl: "/cosmos.tx.signing.v1beta1.SignatureDescriptors", + value: SignatureDescriptors.encode(message).finish() + }; + } +}; +function createBaseSignatureDescriptor(): SignatureDescriptor { + return { + publicKey: undefined, + data: undefined, + sequence: BigInt(0) + }; +} +export const SignatureDescriptor = { + typeUrl: "/cosmos.tx.signing.v1beta1.SignatureDescriptor", + encode(message: SignatureDescriptor, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.publicKey !== undefined) { + Any.encode(message.publicKey, writer.uint32(10).fork()).ldelim(); + } + if (message.data !== undefined) { + SignatureDescriptor_Data.encode(message.data, writer.uint32(18).fork()).ldelim(); + } + if (message.sequence !== undefined) { + writer.uint32(24).uint64(message.sequence); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): SignatureDescriptor { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseSignatureDescriptor(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.publicKey = Any.decode(reader, reader.uint32()); + break; + case 2: + message.data = SignatureDescriptor_Data.decode(reader, reader.uint32()); + break; + case 3: + message.sequence = reader.uint64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): SignatureDescriptor { + const obj = createBaseSignatureDescriptor(); + if (isSet(object.publicKey)) obj.publicKey = Any.fromJSON(object.publicKey); + if (isSet(object.data)) obj.data = SignatureDescriptor_Data.fromJSON(object.data); + if (isSet(object.sequence)) obj.sequence = BigInt(object.sequence.toString()); + return obj; + }, + toJSON(message: SignatureDescriptor): JsonSafe { + const obj: any = {}; + message.publicKey !== undefined && (obj.publicKey = message.publicKey ? Any.toJSON(message.publicKey) : undefined); + message.data !== undefined && (obj.data = message.data ? SignatureDescriptor_Data.toJSON(message.data) : undefined); + message.sequence !== undefined && (obj.sequence = (message.sequence || BigInt(0)).toString()); + return obj; + }, + fromPartial(object: DeepPartial): SignatureDescriptor { + const message = createBaseSignatureDescriptor(); + if (object.publicKey !== undefined && object.publicKey !== null) { + message.publicKey = Any.fromPartial(object.publicKey); + } + if (object.data !== undefined && object.data !== null) { + message.data = SignatureDescriptor_Data.fromPartial(object.data); + } + if (object.sequence !== undefined && object.sequence !== null) { + message.sequence = BigInt(object.sequence.toString()); + } + return message; + }, + fromSDK(object: SignatureDescriptorSDKType): SignatureDescriptor { + return { + publicKey: object.public_key ? Any.fromSDK(object.public_key) : undefined, + data: object.data ? SignatureDescriptor_Data.fromSDK(object.data) : undefined, + sequence: object?.sequence + }; + }, + fromSDKJSON(object: any): SignatureDescriptorSDKType { + return { + public_key: isSet(object.public_key) ? Any.fromSDKJSON(object.public_key) : undefined, + data: isSet(object.data) ? SignatureDescriptor_Data.fromSDKJSON(object.data) : undefined, + sequence: isSet(object.sequence) ? BigInt(object.sequence.toString()) : BigInt(0) + }; + }, + toSDK(message: SignatureDescriptor): SignatureDescriptorSDKType { + const obj: any = {}; + message.publicKey !== undefined && (obj.public_key = message.publicKey ? Any.toSDK(message.publicKey) : undefined); + message.data !== undefined && (obj.data = message.data ? SignatureDescriptor_Data.toSDK(message.data) : undefined); + obj.sequence = message.sequence; + return obj; + }, + fromAmino(object: SignatureDescriptorAmino): SignatureDescriptor { + const message = createBaseSignatureDescriptor(); + if (object.public_key !== undefined && object.public_key !== null) { + message.publicKey = Any.fromAmino(object.public_key); + } + if (object.data !== undefined && object.data !== null) { + message.data = SignatureDescriptor_Data.fromAmino(object.data); + } + if (object.sequence !== undefined && object.sequence !== null) { + message.sequence = BigInt(object.sequence); + } + return message; + }, + toAmino(message: SignatureDescriptor): SignatureDescriptorAmino { + const obj: any = {}; + obj.public_key = message.publicKey ? Any.toAmino(message.publicKey) : undefined; + obj.data = message.data ? SignatureDescriptor_Data.toAmino(message.data) : undefined; + obj.sequence = message.sequence !== BigInt(0) ? message.sequence?.toString() : undefined; + return obj; + }, + fromAminoMsg(object: SignatureDescriptorAminoMsg): SignatureDescriptor { + return SignatureDescriptor.fromAmino(object.value); + }, + toAminoMsg(message: SignatureDescriptor): SignatureDescriptorAminoMsg { + return { + type: "cosmos-sdk/SignatureDescriptor", + value: SignatureDescriptor.toAmino(message) + }; + }, + fromProtoMsg(message: SignatureDescriptorProtoMsg): SignatureDescriptor { + return SignatureDescriptor.decode(message.value); + }, + toProto(message: SignatureDescriptor): Uint8Array { + return SignatureDescriptor.encode(message).finish(); + }, + toProtoMsg(message: SignatureDescriptor): SignatureDescriptorProtoMsg { + return { + typeUrl: "/cosmos.tx.signing.v1beta1.SignatureDescriptor", + value: SignatureDescriptor.encode(message).finish() + }; + } +}; +function createBaseSignatureDescriptor_Data(): SignatureDescriptor_Data { + return { + single: undefined, + multi: undefined + }; +} +export const SignatureDescriptor_Data = { + typeUrl: "/cosmos.tx.signing.v1beta1.Data", + encode(message: SignatureDescriptor_Data, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.single !== undefined) { + SignatureDescriptor_Data_Single.encode(message.single, writer.uint32(10).fork()).ldelim(); + } + if (message.multi !== undefined) { + SignatureDescriptor_Data_Multi.encode(message.multi, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): SignatureDescriptor_Data { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseSignatureDescriptor_Data(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.single = SignatureDescriptor_Data_Single.decode(reader, reader.uint32()); + break; + case 2: + message.multi = SignatureDescriptor_Data_Multi.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): SignatureDescriptor_Data { + const obj = createBaseSignatureDescriptor_Data(); + if (isSet(object.single)) obj.single = SignatureDescriptor_Data_Single.fromJSON(object.single); + if (isSet(object.multi)) obj.multi = SignatureDescriptor_Data_Multi.fromJSON(object.multi); + return obj; + }, + toJSON(message: SignatureDescriptor_Data): JsonSafe { + const obj: any = {}; + message.single !== undefined && (obj.single = message.single ? SignatureDescriptor_Data_Single.toJSON(message.single) : undefined); + message.multi !== undefined && (obj.multi = message.multi ? SignatureDescriptor_Data_Multi.toJSON(message.multi) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): SignatureDescriptor_Data { + const message = createBaseSignatureDescriptor_Data(); + if (object.single !== undefined && object.single !== null) { + message.single = SignatureDescriptor_Data_Single.fromPartial(object.single); + } + if (object.multi !== undefined && object.multi !== null) { + message.multi = SignatureDescriptor_Data_Multi.fromPartial(object.multi); + } + return message; + }, + fromSDK(object: SignatureDescriptor_DataSDKType): SignatureDescriptor_Data { + return { + single: object.single ? SignatureDescriptor_Data_Single.fromSDK(object.single) : undefined, + multi: object.multi ? SignatureDescriptor_Data_Multi.fromSDK(object.multi) : undefined + }; + }, + fromSDKJSON(object: any): SignatureDescriptor_DataSDKType { + return { + single: isSet(object.single) ? SignatureDescriptor_Data_Single.fromSDKJSON(object.single) : undefined, + multi: isSet(object.multi) ? SignatureDescriptor_Data_Multi.fromSDKJSON(object.multi) : undefined + }; + }, + toSDK(message: SignatureDescriptor_Data): SignatureDescriptor_DataSDKType { + const obj: any = {}; + message.single !== undefined && (obj.single = message.single ? SignatureDescriptor_Data_Single.toSDK(message.single) : undefined); + message.multi !== undefined && (obj.multi = message.multi ? SignatureDescriptor_Data_Multi.toSDK(message.multi) : undefined); + return obj; + }, + fromAmino(object: SignatureDescriptor_DataAmino): SignatureDescriptor_Data { + const message = createBaseSignatureDescriptor_Data(); + if (object.single !== undefined && object.single !== null) { + message.single = SignatureDescriptor_Data_Single.fromAmino(object.single); + } + if (object.multi !== undefined && object.multi !== null) { + message.multi = SignatureDescriptor_Data_Multi.fromAmino(object.multi); + } + return message; + }, + toAmino(message: SignatureDescriptor_Data): SignatureDescriptor_DataAmino { + const obj: any = {}; + obj.single = message.single ? SignatureDescriptor_Data_Single.toAmino(message.single) : undefined; + obj.multi = message.multi ? SignatureDescriptor_Data_Multi.toAmino(message.multi) : undefined; + return obj; + }, + fromAminoMsg(object: SignatureDescriptor_DataAminoMsg): SignatureDescriptor_Data { + return SignatureDescriptor_Data.fromAmino(object.value); + }, + toAminoMsg(message: SignatureDescriptor_Data): SignatureDescriptor_DataAminoMsg { + return { + type: "cosmos-sdk/Data", + value: SignatureDescriptor_Data.toAmino(message) + }; + }, + fromProtoMsg(message: SignatureDescriptor_DataProtoMsg): SignatureDescriptor_Data { + return SignatureDescriptor_Data.decode(message.value); + }, + toProto(message: SignatureDescriptor_Data): Uint8Array { + return SignatureDescriptor_Data.encode(message).finish(); + }, + toProtoMsg(message: SignatureDescriptor_Data): SignatureDescriptor_DataProtoMsg { + return { + typeUrl: "/cosmos.tx.signing.v1beta1.Data", + value: SignatureDescriptor_Data.encode(message).finish() + }; + } +}; +function createBaseSignatureDescriptor_Data_Single(): SignatureDescriptor_Data_Single { + return { + mode: 0, + signature: new Uint8Array() + }; +} +export const SignatureDescriptor_Data_Single = { + typeUrl: "/cosmos.tx.signing.v1beta1.Single", + encode(message: SignatureDescriptor_Data_Single, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.mode !== 0) { + writer.uint32(8).int32(message.mode); + } + if (message.signature.length !== 0) { + writer.uint32(18).bytes(message.signature); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): SignatureDescriptor_Data_Single { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseSignatureDescriptor_Data_Single(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.mode = (reader.int32() as any); + break; + case 2: + message.signature = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): SignatureDescriptor_Data_Single { + const obj = createBaseSignatureDescriptor_Data_Single(); + if (isSet(object.mode)) obj.mode = signModeFromJSON(object.mode); + if (isSet(object.signature)) obj.signature = bytesFromBase64(object.signature); + return obj; + }, + toJSON(message: SignatureDescriptor_Data_Single): JsonSafe { + const obj: any = {}; + message.mode !== undefined && (obj.mode = signModeToJSON(message.mode)); + message.signature !== undefined && (obj.signature = base64FromBytes(message.signature !== undefined ? message.signature : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): SignatureDescriptor_Data_Single { + const message = createBaseSignatureDescriptor_Data_Single(); + message.mode = object.mode ?? 0; + message.signature = object.signature ?? new Uint8Array(); + return message; + }, + fromSDK(object: SignatureDescriptor_Data_SingleSDKType): SignatureDescriptor_Data_Single { + return { + mode: isSet(object.mode) ? signModeFromJSON(object.mode) : -1, + signature: object?.signature + }; + }, + fromSDKJSON(object: any): SignatureDescriptor_Data_SingleSDKType { + return { + mode: isSet(object.mode) ? signModeFromJSON(object.mode) : -1, + signature: isSet(object.signature) ? bytesFromBase64(object.signature) : new Uint8Array() + }; + }, + toSDK(message: SignatureDescriptor_Data_Single): SignatureDescriptor_Data_SingleSDKType { + const obj: any = {}; + message.mode !== undefined && (obj.mode = signModeToJSON(message.mode)); + obj.signature = message.signature; + return obj; + }, + fromAmino(object: SignatureDescriptor_Data_SingleAmino): SignatureDescriptor_Data_Single { + const message = createBaseSignatureDescriptor_Data_Single(); + if (object.mode !== undefined && object.mode !== null) { + message.mode = object.mode; + } + if (object.signature !== undefined && object.signature !== null) { + message.signature = bytesFromBase64(object.signature); + } + return message; + }, + toAmino(message: SignatureDescriptor_Data_Single): SignatureDescriptor_Data_SingleAmino { + const obj: any = {}; + obj.mode = message.mode === 0 ? undefined : message.mode; + obj.signature = message.signature ? base64FromBytes(message.signature) : undefined; + return obj; + }, + fromAminoMsg(object: SignatureDescriptor_Data_SingleAminoMsg): SignatureDescriptor_Data_Single { + return SignatureDescriptor_Data_Single.fromAmino(object.value); + }, + toAminoMsg(message: SignatureDescriptor_Data_Single): SignatureDescriptor_Data_SingleAminoMsg { + return { + type: "cosmos-sdk/Single", + value: SignatureDescriptor_Data_Single.toAmino(message) + }; + }, + fromProtoMsg(message: SignatureDescriptor_Data_SingleProtoMsg): SignatureDescriptor_Data_Single { + return SignatureDescriptor_Data_Single.decode(message.value); + }, + toProto(message: SignatureDescriptor_Data_Single): Uint8Array { + return SignatureDescriptor_Data_Single.encode(message).finish(); + }, + toProtoMsg(message: SignatureDescriptor_Data_Single): SignatureDescriptor_Data_SingleProtoMsg { + return { + typeUrl: "/cosmos.tx.signing.v1beta1.Single", + value: SignatureDescriptor_Data_Single.encode(message).finish() + }; + } +}; +function createBaseSignatureDescriptor_Data_Multi(): SignatureDescriptor_Data_Multi { + return { + bitarray: undefined, + signatures: [] + }; +} +export const SignatureDescriptor_Data_Multi = { + typeUrl: "/cosmos.tx.signing.v1beta1.Multi", + encode(message: SignatureDescriptor_Data_Multi, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.bitarray !== undefined) { + CompactBitArray.encode(message.bitarray, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.signatures) { + SignatureDescriptor_Data.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): SignatureDescriptor_Data_Multi { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseSignatureDescriptor_Data_Multi(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.bitarray = CompactBitArray.decode(reader, reader.uint32()); + break; + case 2: + message.signatures.push(SignatureDescriptor_Data.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): SignatureDescriptor_Data_Multi { + const obj = createBaseSignatureDescriptor_Data_Multi(); + if (isSet(object.bitarray)) obj.bitarray = CompactBitArray.fromJSON(object.bitarray); + if (Array.isArray(object?.signatures)) obj.signatures = object.signatures.map((e: any) => SignatureDescriptor_Data.fromJSON(e)); + return obj; + }, + toJSON(message: SignatureDescriptor_Data_Multi): JsonSafe { + const obj: any = {}; + message.bitarray !== undefined && (obj.bitarray = message.bitarray ? CompactBitArray.toJSON(message.bitarray) : undefined); + if (message.signatures) { + obj.signatures = message.signatures.map(e => e ? SignatureDescriptor_Data.toJSON(e) : undefined); + } else { + obj.signatures = []; + } + return obj; + }, + fromPartial(object: DeepPartial): SignatureDescriptor_Data_Multi { + const message = createBaseSignatureDescriptor_Data_Multi(); + if (object.bitarray !== undefined && object.bitarray !== null) { + message.bitarray = CompactBitArray.fromPartial(object.bitarray); + } + message.signatures = object.signatures?.map(e => SignatureDescriptor_Data.fromPartial(e)) || []; + return message; + }, + fromSDK(object: SignatureDescriptor_Data_MultiSDKType): SignatureDescriptor_Data_Multi { + return { + bitarray: object.bitarray ? CompactBitArray.fromSDK(object.bitarray) : undefined, + signatures: Array.isArray(object?.signatures) ? object.signatures.map((e: any) => SignatureDescriptor_Data.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): SignatureDescriptor_Data_MultiSDKType { + return { + bitarray: isSet(object.bitarray) ? CompactBitArray.fromSDKJSON(object.bitarray) : undefined, + signatures: Array.isArray(object?.signatures) ? object.signatures.map((e: any) => SignatureDescriptor_Data.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: SignatureDescriptor_Data_Multi): SignatureDescriptor_Data_MultiSDKType { + const obj: any = {}; + message.bitarray !== undefined && (obj.bitarray = message.bitarray ? CompactBitArray.toSDK(message.bitarray) : undefined); + if (message.signatures) { + obj.signatures = message.signatures.map(e => e ? SignatureDescriptor_Data.toSDK(e) : undefined); + } else { + obj.signatures = []; + } + return obj; + }, + fromAmino(object: SignatureDescriptor_Data_MultiAmino): SignatureDescriptor_Data_Multi { + const message = createBaseSignatureDescriptor_Data_Multi(); + if (object.bitarray !== undefined && object.bitarray !== null) { + message.bitarray = CompactBitArray.fromAmino(object.bitarray); + } + message.signatures = object.signatures?.map(e => SignatureDescriptor_Data.fromAmino(e)) || []; + return message; + }, + toAmino(message: SignatureDescriptor_Data_Multi): SignatureDescriptor_Data_MultiAmino { + const obj: any = {}; + obj.bitarray = message.bitarray ? CompactBitArray.toAmino(message.bitarray) : undefined; + if (message.signatures) { + obj.signatures = message.signatures.map(e => e ? SignatureDescriptor_Data.toAmino(e) : undefined); + } else { + obj.signatures = message.signatures; + } + return obj; + }, + fromAminoMsg(object: SignatureDescriptor_Data_MultiAminoMsg): SignatureDescriptor_Data_Multi { + return SignatureDescriptor_Data_Multi.fromAmino(object.value); + }, + toAminoMsg(message: SignatureDescriptor_Data_Multi): SignatureDescriptor_Data_MultiAminoMsg { + return { + type: "cosmos-sdk/Multi", + value: SignatureDescriptor_Data_Multi.toAmino(message) + }; + }, + fromProtoMsg(message: SignatureDescriptor_Data_MultiProtoMsg): SignatureDescriptor_Data_Multi { + return SignatureDescriptor_Data_Multi.decode(message.value); + }, + toProto(message: SignatureDescriptor_Data_Multi): Uint8Array { + return SignatureDescriptor_Data_Multi.encode(message).finish(); + }, + toProtoMsg(message: SignatureDescriptor_Data_Multi): SignatureDescriptor_Data_MultiProtoMsg { + return { + typeUrl: "/cosmos.tx.signing.v1beta1.Multi", + value: SignatureDescriptor_Data_Multi.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/tx/v1beta1/service.lcd.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/tx/v1beta1/service.lcd.ts new file mode 100644 index 0000000000..d2d8f63cd5 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/tx/v1beta1/service.lcd.ts @@ -0,0 +1,56 @@ +import { Tx, TxSDKType } from "./tx.js"; +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../base/query/v1beta1/pagination.js"; +import { TxResponse, TxResponseSDKType, GasInfo, GasInfoSDKType, Result, ResultSDKType } from "../../base/abci/v1beta1/abci.js"; +import { BlockID, BlockIDSDKType } from "../../../tendermint/types/types.js"; +import { Block, BlockSDKType } from "../../../tendermint/types/block.js"; +import { setPaginationParams } from "../../../helpers.js"; +import { LCDClient } from "@cosmology/lcd"; +import { SimulateRequest, SimulateRequestSDKType, SimulateResponse, SimulateResponseSDKType, GetTxRequest, GetTxRequestSDKType, GetTxResponse, GetTxResponseSDKType, BroadcastTxRequest, BroadcastTxRequestSDKType, BroadcastTxResponse, BroadcastTxResponseSDKType, GetTxsEventRequest, GetTxsEventRequestSDKType, GetTxsEventResponse, GetTxsEventResponseSDKType, GetBlockWithTxsRequest, GetBlockWithTxsRequestSDKType, GetBlockWithTxsResponse, GetBlockWithTxsResponseSDKType } from "./service.js"; +export class LCDQueryClient { + req: LCDClient; + constructor({ + requestClient + }: { + requestClient: LCDClient; + }) { + this.req = requestClient; + this.getTx = this.getTx.bind(this); + this.getTxsEvent = this.getTxsEvent.bind(this); + this.getBlockWithTxs = this.getBlockWithTxs.bind(this); + } + /* GetTx fetches a tx by hash. */ + async getTx(params: GetTxRequest): Promise { + const endpoint = `cosmos/tx/v1beta1/txs/${params.hash}`; + return GetTxResponse.fromSDKJSON(await this.req.get(endpoint)); + } + /* GetTxsEvent fetches txs by event. */ + async getTxsEvent(params: GetTxsEventRequest): Promise { + const options: any = { + params: {} + }; + if (typeof params?.events !== "undefined") { + options.params.events = params.events; + } + if (typeof params?.pagination !== "undefined") { + setPaginationParams(options, params.pagination); + } + if (typeof params?.orderBy !== "undefined") { + options.params.order_by = params.orderBy; + } + const endpoint = `cosmos/tx/v1beta1/txs`; + return GetTxsEventResponse.fromSDKJSON(await this.req.get(endpoint, options)); + } + /* GetBlockWithTxs fetches a block with decoded txs. + + Since: cosmos-sdk 0.45.2 */ + async getBlockWithTxs(params: GetBlockWithTxsRequest): Promise { + const options: any = { + params: {} + }; + if (typeof params?.pagination !== "undefined") { + setPaginationParams(options, params.pagination); + } + const endpoint = `cosmos/tx/v1beta1/txs/block/${params.height}`; + return GetBlockWithTxsResponse.fromSDKJSON(await this.req.get(endpoint, options)); + } +} \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/tx/v1beta1/service.rpc.Service.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/tx/v1beta1/service.rpc.Service.ts new file mode 100644 index 0000000000..4dd76261b6 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/tx/v1beta1/service.rpc.Service.ts @@ -0,0 +1,83 @@ +import { Tx, TxSDKType } from "./tx.js"; +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../base/query/v1beta1/pagination.js"; +import { TxResponse, TxResponseSDKType, GasInfo, GasInfoSDKType, Result, ResultSDKType } from "../../base/abci/v1beta1/abci.js"; +import { BlockID, BlockIDSDKType } from "../../../tendermint/types/types.js"; +import { Block, BlockSDKType } from "../../../tendermint/types/block.js"; +import { Rpc } from "../../../helpers.js"; +import { BinaryReader } from "../../../binary.js"; +import { QueryClient, createProtobufRpcClient } from "@cosmjs/stargate"; +import { SimulateRequest, SimulateRequestSDKType, SimulateResponse, SimulateResponseSDKType, GetTxRequest, GetTxRequestSDKType, GetTxResponse, GetTxResponseSDKType, BroadcastTxRequest, BroadcastTxRequestSDKType, BroadcastTxResponse, BroadcastTxResponseSDKType, GetTxsEventRequest, GetTxsEventRequestSDKType, GetTxsEventResponse, GetTxsEventResponseSDKType, GetBlockWithTxsRequest, GetBlockWithTxsRequestSDKType, GetBlockWithTxsResponse, GetBlockWithTxsResponseSDKType } from "./service.js"; +/** Service defines a gRPC service for interacting with transactions. */ +export interface Service { + /** Simulate simulates executing a transaction for estimating gas usage. */ + simulate(request: SimulateRequest): Promise; + /** GetTx fetches a tx by hash. */ + getTx(request: GetTxRequest): Promise; + /** BroadcastTx broadcast transaction. */ + broadcastTx(request: BroadcastTxRequest): Promise; + /** GetTxsEvent fetches txs by event. */ + getTxsEvent(request: GetTxsEventRequest): Promise; + /** + * GetBlockWithTxs fetches a block with decoded txs. + * + * Since: cosmos-sdk 0.45.2 + */ + getBlockWithTxs(request: GetBlockWithTxsRequest): Promise; +} +export class ServiceClientImpl implements Service { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + this.simulate = this.simulate.bind(this); + this.getTx = this.getTx.bind(this); + this.broadcastTx = this.broadcastTx.bind(this); + this.getTxsEvent = this.getTxsEvent.bind(this); + this.getBlockWithTxs = this.getBlockWithTxs.bind(this); + } + simulate(request: SimulateRequest): Promise { + const data = SimulateRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.tx.v1beta1.Service", "Simulate", data); + return promise.then(data => SimulateResponse.decode(new BinaryReader(data))); + } + getTx(request: GetTxRequest): Promise { + const data = GetTxRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.tx.v1beta1.Service", "GetTx", data); + return promise.then(data => GetTxResponse.decode(new BinaryReader(data))); + } + broadcastTx(request: BroadcastTxRequest): Promise { + const data = BroadcastTxRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.tx.v1beta1.Service", "BroadcastTx", data); + return promise.then(data => BroadcastTxResponse.decode(new BinaryReader(data))); + } + getTxsEvent(request: GetTxsEventRequest): Promise { + const data = GetTxsEventRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.tx.v1beta1.Service", "GetTxsEvent", data); + return promise.then(data => GetTxsEventResponse.decode(new BinaryReader(data))); + } + getBlockWithTxs(request: GetBlockWithTxsRequest): Promise { + const data = GetBlockWithTxsRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.tx.v1beta1.Service", "GetBlockWithTxs", data); + return promise.then(data => GetBlockWithTxsResponse.decode(new BinaryReader(data))); + } +} +export const createRpcQueryExtension = (base: QueryClient) => { + const rpc = createProtobufRpcClient(base); + const queryService = new ServiceClientImpl(rpc); + return { + simulate(request: SimulateRequest): Promise { + return queryService.simulate(request); + }, + getTx(request: GetTxRequest): Promise { + return queryService.getTx(request); + }, + broadcastTx(request: BroadcastTxRequest): Promise { + return queryService.broadcastTx(request); + }, + getTxsEvent(request: GetTxsEventRequest): Promise { + return queryService.getTxsEvent(request); + }, + getBlockWithTxs(request: GetBlockWithTxsRequest): Promise { + return queryService.getBlockWithTxs(request); + } + }; +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/tx/v1beta1/service.rpc.func.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/tx/v1beta1/service.rpc.func.ts new file mode 100644 index 0000000000..b3c15a7ede --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/tx/v1beta1/service.rpc.func.ts @@ -0,0 +1,58 @@ +import { RpcResolver, buildQuery } from "../../../helper-func-types"; +import { buildUseQuery } from "../../../react-query"; +import { SimulateRequest, SimulateResponse, GetTxRequest, GetTxResponse, BroadcastTxRequest, BroadcastTxResponse, GetTxsEventRequest, GetTxsEventResponse, GetBlockWithTxsRequest, GetBlockWithTxsResponse } from "./service"; +export const createGetSimulate = (getRpcInstance: RpcResolver) => buildQuery({ + encode: SimulateRequest.encode, + decode: SimulateResponse.decode, + service: "cosmos.tx.v1beta1.Service", + method: "Simulate", + getRpcInstance: getRpcInstance +}); +export const useGetSimulate = buildUseQuery({ + builderQueryFn: createGetSimulate, + queryKeyPrefix: "SimulateQuery" +}); +export const createGetGetTx = (getRpcInstance: RpcResolver) => buildQuery({ + encode: GetTxRequest.encode, + decode: GetTxResponse.decode, + service: "cosmos.tx.v1beta1.Service", + method: "GetTx", + getRpcInstance: getRpcInstance +}); +export const useGetGetTx = buildUseQuery({ + builderQueryFn: createGetGetTx, + queryKeyPrefix: "GetTxQuery" +}); +export const createGetBroadcastTx = (getRpcInstance: RpcResolver) => buildQuery({ + encode: BroadcastTxRequest.encode, + decode: BroadcastTxResponse.decode, + service: "cosmos.tx.v1beta1.Service", + method: "BroadcastTx", + getRpcInstance: getRpcInstance +}); +export const useGetBroadcastTx = buildUseQuery({ + builderQueryFn: createGetBroadcastTx, + queryKeyPrefix: "BroadcastTxQuery" +}); +export const createGetGetTxsEvent = (getRpcInstance: RpcResolver) => buildQuery({ + encode: GetTxsEventRequest.encode, + decode: GetTxsEventResponse.decode, + service: "cosmos.tx.v1beta1.Service", + method: "GetTxsEvent", + getRpcInstance: getRpcInstance +}); +export const useGetGetTxsEvent = buildUseQuery({ + builderQueryFn: createGetGetTxsEvent, + queryKeyPrefix: "GetTxsEventQuery" +}); +export const createGetGetBlockWithTxs = (getRpcInstance: RpcResolver) => buildQuery({ + encode: GetBlockWithTxsRequest.encode, + decode: GetBlockWithTxsResponse.decode, + service: "cosmos.tx.v1beta1.Service", + method: "GetBlockWithTxs", + getRpcInstance: getRpcInstance +}); +export const useGetGetBlockWithTxs = buildUseQuery({ + builderQueryFn: createGetGetBlockWithTxs, + queryKeyPrefix: "GetBlockWithTxsQuery" +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/tx/v1beta1/service.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/tx/v1beta1/service.ts new file mode 100644 index 0000000000..b0919e5265 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/tx/v1beta1/service.ts @@ -0,0 +1,1548 @@ +import { Tx, TxSDKType } from "./tx.js"; +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../base/query/v1beta1/pagination.js"; +import { TxResponse, TxResponseSDKType, GasInfo, GasInfoSDKType, Result, ResultSDKType } from "../../base/abci/v1beta1/abci.js"; +import { BlockID, BlockIDSDKType } from "../../../tendermint/types/types.js"; +import { Block, BlockSDKType } from "../../../tendermint/types/block.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial, bytesFromBase64, base64FromBytes } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "cosmos.tx.v1beta1"; +/** OrderBy defines the sorting order */ +export enum OrderBy { + /** ORDER_BY_UNSPECIFIED - ORDER_BY_UNSPECIFIED specifies an unknown sorting order. OrderBy defaults to ASC in this case. */ + ORDER_BY_UNSPECIFIED = 0, + /** ORDER_BY_ASC - ORDER_BY_ASC defines ascending order */ + ORDER_BY_ASC = 1, + /** ORDER_BY_DESC - ORDER_BY_DESC defines descending order */ + ORDER_BY_DESC = 2, + UNRECOGNIZED = -1, +} +export const OrderBySDKType = OrderBy; +export function orderByFromJSON(object: any): OrderBy { + switch (object) { + case 0: + case "ORDER_BY_UNSPECIFIED": + return OrderBy.ORDER_BY_UNSPECIFIED; + case 1: + case "ORDER_BY_ASC": + return OrderBy.ORDER_BY_ASC; + case 2: + case "ORDER_BY_DESC": + return OrderBy.ORDER_BY_DESC; + case -1: + case "UNRECOGNIZED": + default: + return OrderBy.UNRECOGNIZED; + } +} +export function orderByToJSON(object: OrderBy): string { + switch (object) { + case OrderBy.ORDER_BY_UNSPECIFIED: + return "ORDER_BY_UNSPECIFIED"; + case OrderBy.ORDER_BY_ASC: + return "ORDER_BY_ASC"; + case OrderBy.ORDER_BY_DESC: + return "ORDER_BY_DESC"; + case OrderBy.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** BroadcastMode specifies the broadcast mode for the TxService.Broadcast RPC method. */ +export enum BroadcastMode { + /** BROADCAST_MODE_UNSPECIFIED - zero-value for mode ordering */ + BROADCAST_MODE_UNSPECIFIED = 0, + /** + * BROADCAST_MODE_BLOCK - BROADCAST_MODE_BLOCK defines a tx broadcasting mode where the client waits for + * the tx to be committed in a block. + */ + BROADCAST_MODE_BLOCK = 1, + /** + * BROADCAST_MODE_SYNC - BROADCAST_MODE_SYNC defines a tx broadcasting mode where the client waits for + * a CheckTx execution response only. + */ + BROADCAST_MODE_SYNC = 2, + /** + * BROADCAST_MODE_ASYNC - BROADCAST_MODE_ASYNC defines a tx broadcasting mode where the client returns + * immediately. + */ + BROADCAST_MODE_ASYNC = 3, + UNRECOGNIZED = -1, +} +export const BroadcastModeSDKType = BroadcastMode; +export function broadcastModeFromJSON(object: any): BroadcastMode { + switch (object) { + case 0: + case "BROADCAST_MODE_UNSPECIFIED": + return BroadcastMode.BROADCAST_MODE_UNSPECIFIED; + case 1: + case "BROADCAST_MODE_BLOCK": + return BroadcastMode.BROADCAST_MODE_BLOCK; + case 2: + case "BROADCAST_MODE_SYNC": + return BroadcastMode.BROADCAST_MODE_SYNC; + case 3: + case "BROADCAST_MODE_ASYNC": + return BroadcastMode.BROADCAST_MODE_ASYNC; + case -1: + case "UNRECOGNIZED": + default: + return BroadcastMode.UNRECOGNIZED; + } +} +export function broadcastModeToJSON(object: BroadcastMode): string { + switch (object) { + case BroadcastMode.BROADCAST_MODE_UNSPECIFIED: + return "BROADCAST_MODE_UNSPECIFIED"; + case BroadcastMode.BROADCAST_MODE_BLOCK: + return "BROADCAST_MODE_BLOCK"; + case BroadcastMode.BROADCAST_MODE_SYNC: + return "BROADCAST_MODE_SYNC"; + case BroadcastMode.BROADCAST_MODE_ASYNC: + return "BROADCAST_MODE_ASYNC"; + case BroadcastMode.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** + * GetTxsEventRequest is the request type for the Service.TxsByEvents + * RPC method. + */ +export interface GetTxsEventRequest { + /** events is the list of transaction event type. */ + events: string[]; + /** pagination defines a pagination for the request. */ + pagination?: PageRequest; + orderBy: OrderBy; +} +export interface GetTxsEventRequestProtoMsg { + typeUrl: "/cosmos.tx.v1beta1.GetTxsEventRequest"; + value: Uint8Array; +} +/** + * GetTxsEventRequest is the request type for the Service.TxsByEvents + * RPC method. + */ +export interface GetTxsEventRequestSDKType { + events: string[]; + pagination?: PageRequestSDKType; + order_by: OrderBy; +} +/** + * GetTxsEventResponse is the response type for the Service.TxsByEvents + * RPC method. + */ +export interface GetTxsEventResponse { + /** txs is the list of queried transactions. */ + txs: Tx[]; + /** tx_responses is the list of queried TxResponses. */ + txResponses: TxResponse[]; + /** pagination defines a pagination for the response. */ + pagination?: PageResponse; +} +export interface GetTxsEventResponseProtoMsg { + typeUrl: "/cosmos.tx.v1beta1.GetTxsEventResponse"; + value: Uint8Array; +} +/** + * GetTxsEventResponse is the response type for the Service.TxsByEvents + * RPC method. + */ +export interface GetTxsEventResponseSDKType { + txs: TxSDKType[]; + tx_responses: TxResponseSDKType[]; + pagination?: PageResponseSDKType; +} +/** + * BroadcastTxRequest is the request type for the Service.BroadcastTxRequest + * RPC method. + */ +export interface BroadcastTxRequest { + /** tx_bytes is the raw transaction. */ + txBytes: Uint8Array; + mode: BroadcastMode; +} +export interface BroadcastTxRequestProtoMsg { + typeUrl: "/cosmos.tx.v1beta1.BroadcastTxRequest"; + value: Uint8Array; +} +/** + * BroadcastTxRequest is the request type for the Service.BroadcastTxRequest + * RPC method. + */ +export interface BroadcastTxRequestSDKType { + tx_bytes: Uint8Array; + mode: BroadcastMode; +} +/** + * BroadcastTxResponse is the response type for the + * Service.BroadcastTx method. + */ +export interface BroadcastTxResponse { + /** tx_response is the queried TxResponses. */ + txResponse?: TxResponse; +} +export interface BroadcastTxResponseProtoMsg { + typeUrl: "/cosmos.tx.v1beta1.BroadcastTxResponse"; + value: Uint8Array; +} +/** + * BroadcastTxResponse is the response type for the + * Service.BroadcastTx method. + */ +export interface BroadcastTxResponseSDKType { + tx_response?: TxResponseSDKType; +} +/** + * SimulateRequest is the request type for the Service.Simulate + * RPC method. + */ +export interface SimulateRequest { + /** + * tx is the transaction to simulate. + * Deprecated. Send raw tx bytes instead. + */ + /** @deprecated */ + tx?: Tx; + /** + * tx_bytes is the raw transaction. + * + * Since: cosmos-sdk 0.43 + */ + txBytes: Uint8Array; +} +export interface SimulateRequestProtoMsg { + typeUrl: "/cosmos.tx.v1beta1.SimulateRequest"; + value: Uint8Array; +} +/** + * SimulateRequest is the request type for the Service.Simulate + * RPC method. + */ +export interface SimulateRequestSDKType { + /** @deprecated */ + tx?: TxSDKType; + tx_bytes: Uint8Array; +} +/** + * SimulateResponse is the response type for the + * Service.SimulateRPC method. + */ +export interface SimulateResponse { + /** gas_info is the information about gas used in the simulation. */ + gasInfo?: GasInfo; + /** result is the result of the simulation. */ + result?: Result; +} +export interface SimulateResponseProtoMsg { + typeUrl: "/cosmos.tx.v1beta1.SimulateResponse"; + value: Uint8Array; +} +/** + * SimulateResponse is the response type for the + * Service.SimulateRPC method. + */ +export interface SimulateResponseSDKType { + gas_info?: GasInfoSDKType; + result?: ResultSDKType; +} +/** + * GetTxRequest is the request type for the Service.GetTx + * RPC method. + */ +export interface GetTxRequest { + /** hash is the tx hash to query, encoded as a hex string. */ + hash: string; +} +export interface GetTxRequestProtoMsg { + typeUrl: "/cosmos.tx.v1beta1.GetTxRequest"; + value: Uint8Array; +} +/** + * GetTxRequest is the request type for the Service.GetTx + * RPC method. + */ +export interface GetTxRequestSDKType { + hash: string; +} +/** GetTxResponse is the response type for the Service.GetTx method. */ +export interface GetTxResponse { + /** tx is the queried transaction. */ + tx?: Tx; + /** tx_response is the queried TxResponses. */ + txResponse?: TxResponse; +} +export interface GetTxResponseProtoMsg { + typeUrl: "/cosmos.tx.v1beta1.GetTxResponse"; + value: Uint8Array; +} +/** GetTxResponse is the response type for the Service.GetTx method. */ +export interface GetTxResponseSDKType { + tx?: TxSDKType; + tx_response?: TxResponseSDKType; +} +/** + * GetBlockWithTxsRequest is the request type for the Service.GetBlockWithTxs + * RPC method. + * + * Since: cosmos-sdk 0.45.2 + */ +export interface GetBlockWithTxsRequest { + /** height is the height of the block to query. */ + height: bigint; + /** pagination defines a pagination for the request. */ + pagination?: PageRequest; +} +export interface GetBlockWithTxsRequestProtoMsg { + typeUrl: "/cosmos.tx.v1beta1.GetBlockWithTxsRequest"; + value: Uint8Array; +} +/** + * GetBlockWithTxsRequest is the request type for the Service.GetBlockWithTxs + * RPC method. + * + * Since: cosmos-sdk 0.45.2 + */ +export interface GetBlockWithTxsRequestSDKType { + height: bigint; + pagination?: PageRequestSDKType; +} +/** + * GetBlockWithTxsResponse is the response type for the Service.GetBlockWithTxs method. + * + * Since: cosmos-sdk 0.45.2 + */ +export interface GetBlockWithTxsResponse { + /** txs are the transactions in the block. */ + txs: Tx[]; + blockId?: BlockID; + block?: Block; + /** pagination defines a pagination for the response. */ + pagination?: PageResponse; +} +export interface GetBlockWithTxsResponseProtoMsg { + typeUrl: "/cosmos.tx.v1beta1.GetBlockWithTxsResponse"; + value: Uint8Array; +} +/** + * GetBlockWithTxsResponse is the response type for the Service.GetBlockWithTxs method. + * + * Since: cosmos-sdk 0.45.2 + */ +export interface GetBlockWithTxsResponseSDKType { + txs: TxSDKType[]; + block_id?: BlockIDSDKType; + block?: BlockSDKType; + pagination?: PageResponseSDKType; +} +function createBaseGetTxsEventRequest(): GetTxsEventRequest { + return { + events: [], + pagination: undefined, + orderBy: 0 + }; +} +export const GetTxsEventRequest = { + typeUrl: "/cosmos.tx.v1beta1.GetTxsEventRequest", + encode(message: GetTxsEventRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.events) { + writer.uint32(10).string(v!); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + if (message.orderBy !== 0) { + writer.uint32(24).int32(message.orderBy); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GetTxsEventRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGetTxsEventRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.events.push(reader.string()); + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + case 3: + message.orderBy = (reader.int32() as any); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GetTxsEventRequest { + const obj = createBaseGetTxsEventRequest(); + if (Array.isArray(object?.events)) obj.events = object.events.map((e: any) => String(e)); + if (isSet(object.pagination)) obj.pagination = PageRequest.fromJSON(object.pagination); + if (isSet(object.orderBy)) obj.orderBy = orderByFromJSON(object.orderBy); + return obj; + }, + toJSON(message: GetTxsEventRequest): JsonSafe { + const obj: any = {}; + if (message.events) { + obj.events = message.events.map(e => e); + } else { + obj.events = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + message.orderBy !== undefined && (obj.orderBy = orderByToJSON(message.orderBy)); + return obj; + }, + fromPartial(object: DeepPartial): GetTxsEventRequest { + const message = createBaseGetTxsEventRequest(); + message.events = object.events?.map(e => e) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } + message.orderBy = object.orderBy ?? 0; + return message; + }, + fromSDK(object: GetTxsEventRequestSDKType): GetTxsEventRequest { + return { + events: Array.isArray(object?.events) ? object.events.map((e: any) => e) : [], + pagination: object.pagination ? PageRequest.fromSDK(object.pagination) : undefined, + orderBy: isSet(object.order_by) ? orderByFromJSON(object.order_by) : -1 + }; + }, + fromSDKJSON(object: any): GetTxsEventRequestSDKType { + return { + events: Array.isArray(object?.events) ? object.events.map((e: any) => String(e)) : [], + pagination: isSet(object.pagination) ? PageRequest.fromSDKJSON(object.pagination) : undefined, + order_by: isSet(object.order_by) ? orderByFromJSON(object.order_by) : -1 + }; + }, + toSDK(message: GetTxsEventRequest): GetTxsEventRequestSDKType { + const obj: any = {}; + if (message.events) { + obj.events = message.events.map(e => e); + } else { + obj.events = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toSDK(message.pagination) : undefined); + message.orderBy !== undefined && (obj.order_by = orderByToJSON(message.orderBy)); + return obj; + }, + fromAmino(object: GetTxsEventRequestAmino): GetTxsEventRequest { + const message = createBaseGetTxsEventRequest(); + message.events = object.events?.map(e => e) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromAmino(object.pagination); + } + if (object.order_by !== undefined && object.order_by !== null) { + message.orderBy = object.order_by; + } + return message; + }, + toAmino(message: GetTxsEventRequest): GetTxsEventRequestAmino { + const obj: any = {}; + if (message.events) { + obj.events = message.events.map(e => e); + } else { + obj.events = message.events; + } + obj.pagination = message.pagination ? PageRequest.toAmino(message.pagination) : undefined; + obj.order_by = message.orderBy === 0 ? undefined : message.orderBy; + return obj; + }, + fromAminoMsg(object: GetTxsEventRequestAminoMsg): GetTxsEventRequest { + return GetTxsEventRequest.fromAmino(object.value); + }, + toAminoMsg(message: GetTxsEventRequest): GetTxsEventRequestAminoMsg { + return { + type: "cosmos-sdk/GetTxsEventRequest", + value: GetTxsEventRequest.toAmino(message) + }; + }, + fromProtoMsg(message: GetTxsEventRequestProtoMsg): GetTxsEventRequest { + return GetTxsEventRequest.decode(message.value); + }, + toProto(message: GetTxsEventRequest): Uint8Array { + return GetTxsEventRequest.encode(message).finish(); + }, + toProtoMsg(message: GetTxsEventRequest): GetTxsEventRequestProtoMsg { + return { + typeUrl: "/cosmos.tx.v1beta1.GetTxsEventRequest", + value: GetTxsEventRequest.encode(message).finish() + }; + } +}; +function createBaseGetTxsEventResponse(): GetTxsEventResponse { + return { + txs: [], + txResponses: [], + pagination: undefined + }; +} +export const GetTxsEventResponse = { + typeUrl: "/cosmos.tx.v1beta1.GetTxsEventResponse", + encode(message: GetTxsEventResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.txs) { + Tx.encode(v!, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.txResponses) { + TxResponse.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GetTxsEventResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGetTxsEventResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.txs.push(Tx.decode(reader, reader.uint32())); + break; + case 2: + message.txResponses.push(TxResponse.decode(reader, reader.uint32())); + break; + case 3: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GetTxsEventResponse { + const obj = createBaseGetTxsEventResponse(); + if (Array.isArray(object?.txs)) obj.txs = object.txs.map((e: any) => Tx.fromJSON(e)); + if (Array.isArray(object?.txResponses)) obj.txResponses = object.txResponses.map((e: any) => TxResponse.fromJSON(e)); + if (isSet(object.pagination)) obj.pagination = PageResponse.fromJSON(object.pagination); + return obj; + }, + toJSON(message: GetTxsEventResponse): JsonSafe { + const obj: any = {}; + if (message.txs) { + obj.txs = message.txs.map(e => e ? Tx.toJSON(e) : undefined); + } else { + obj.txs = []; + } + if (message.txResponses) { + obj.txResponses = message.txResponses.map(e => e ? TxResponse.toJSON(e) : undefined); + } else { + obj.txResponses = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): GetTxsEventResponse { + const message = createBaseGetTxsEventResponse(); + message.txs = object.txs?.map(e => Tx.fromPartial(e)) || []; + message.txResponses = object.txResponses?.map(e => TxResponse.fromPartial(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: GetTxsEventResponseSDKType): GetTxsEventResponse { + return { + txs: Array.isArray(object?.txs) ? object.txs.map((e: any) => Tx.fromSDK(e)) : [], + txResponses: Array.isArray(object?.tx_responses) ? object.tx_responses.map((e: any) => TxResponse.fromSDK(e)) : [], + pagination: object.pagination ? PageResponse.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): GetTxsEventResponseSDKType { + return { + txs: Array.isArray(object?.txs) ? object.txs.map((e: any) => Tx.fromSDKJSON(e)) : [], + tx_responses: Array.isArray(object?.tx_responses) ? object.tx_responses.map((e: any) => TxResponse.fromSDKJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: GetTxsEventResponse): GetTxsEventResponseSDKType { + const obj: any = {}; + if (message.txs) { + obj.txs = message.txs.map(e => e ? Tx.toSDK(e) : undefined); + } else { + obj.txs = []; + } + if (message.txResponses) { + obj.tx_responses = message.txResponses.map(e => e ? TxResponse.toSDK(e) : undefined); + } else { + obj.tx_responses = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: GetTxsEventResponseAmino): GetTxsEventResponse { + const message = createBaseGetTxsEventResponse(); + message.txs = object.txs?.map(e => Tx.fromAmino(e)) || []; + message.txResponses = object.tx_responses?.map(e => TxResponse.fromAmino(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: GetTxsEventResponse): GetTxsEventResponseAmino { + const obj: any = {}; + if (message.txs) { + obj.txs = message.txs.map(e => e ? Tx.toAmino(e) : undefined); + } else { + obj.txs = message.txs; + } + if (message.txResponses) { + obj.tx_responses = message.txResponses.map(e => e ? TxResponse.toAmino(e) : undefined); + } else { + obj.tx_responses = message.txResponses; + } + obj.pagination = message.pagination ? PageResponse.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: GetTxsEventResponseAminoMsg): GetTxsEventResponse { + return GetTxsEventResponse.fromAmino(object.value); + }, + toAminoMsg(message: GetTxsEventResponse): GetTxsEventResponseAminoMsg { + return { + type: "cosmos-sdk/GetTxsEventResponse", + value: GetTxsEventResponse.toAmino(message) + }; + }, + fromProtoMsg(message: GetTxsEventResponseProtoMsg): GetTxsEventResponse { + return GetTxsEventResponse.decode(message.value); + }, + toProto(message: GetTxsEventResponse): Uint8Array { + return GetTxsEventResponse.encode(message).finish(); + }, + toProtoMsg(message: GetTxsEventResponse): GetTxsEventResponseProtoMsg { + return { + typeUrl: "/cosmos.tx.v1beta1.GetTxsEventResponse", + value: GetTxsEventResponse.encode(message).finish() + }; + } +}; +function createBaseBroadcastTxRequest(): BroadcastTxRequest { + return { + txBytes: new Uint8Array(), + mode: 0 + }; +} +export const BroadcastTxRequest = { + typeUrl: "/cosmos.tx.v1beta1.BroadcastTxRequest", + encode(message: BroadcastTxRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.txBytes.length !== 0) { + writer.uint32(10).bytes(message.txBytes); + } + if (message.mode !== 0) { + writer.uint32(16).int32(message.mode); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): BroadcastTxRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseBroadcastTxRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.txBytes = reader.bytes(); + break; + case 2: + message.mode = (reader.int32() as any); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): BroadcastTxRequest { + const obj = createBaseBroadcastTxRequest(); + if (isSet(object.txBytes)) obj.txBytes = bytesFromBase64(object.txBytes); + if (isSet(object.mode)) obj.mode = broadcastModeFromJSON(object.mode); + return obj; + }, + toJSON(message: BroadcastTxRequest): JsonSafe { + const obj: any = {}; + message.txBytes !== undefined && (obj.txBytes = base64FromBytes(message.txBytes !== undefined ? message.txBytes : new Uint8Array())); + message.mode !== undefined && (obj.mode = broadcastModeToJSON(message.mode)); + return obj; + }, + fromPartial(object: DeepPartial): BroadcastTxRequest { + const message = createBaseBroadcastTxRequest(); + message.txBytes = object.txBytes ?? new Uint8Array(); + message.mode = object.mode ?? 0; + return message; + }, + fromSDK(object: BroadcastTxRequestSDKType): BroadcastTxRequest { + return { + txBytes: object?.tx_bytes, + mode: isSet(object.mode) ? broadcastModeFromJSON(object.mode) : -1 + }; + }, + fromSDKJSON(object: any): BroadcastTxRequestSDKType { + return { + tx_bytes: isSet(object.tx_bytes) ? bytesFromBase64(object.tx_bytes) : new Uint8Array(), + mode: isSet(object.mode) ? broadcastModeFromJSON(object.mode) : -1 + }; + }, + toSDK(message: BroadcastTxRequest): BroadcastTxRequestSDKType { + const obj: any = {}; + obj.tx_bytes = message.txBytes; + message.mode !== undefined && (obj.mode = broadcastModeToJSON(message.mode)); + return obj; + }, + fromAmino(object: BroadcastTxRequestAmino): BroadcastTxRequest { + const message = createBaseBroadcastTxRequest(); + if (object.tx_bytes !== undefined && object.tx_bytes !== null) { + message.txBytes = bytesFromBase64(object.tx_bytes); + } + if (object.mode !== undefined && object.mode !== null) { + message.mode = object.mode; + } + return message; + }, + toAmino(message: BroadcastTxRequest): BroadcastTxRequestAmino { + const obj: any = {}; + obj.tx_bytes = message.txBytes ? base64FromBytes(message.txBytes) : undefined; + obj.mode = message.mode === 0 ? undefined : message.mode; + return obj; + }, + fromAminoMsg(object: BroadcastTxRequestAminoMsg): BroadcastTxRequest { + return BroadcastTxRequest.fromAmino(object.value); + }, + toAminoMsg(message: BroadcastTxRequest): BroadcastTxRequestAminoMsg { + return { + type: "cosmos-sdk/BroadcastTxRequest", + value: BroadcastTxRequest.toAmino(message) + }; + }, + fromProtoMsg(message: BroadcastTxRequestProtoMsg): BroadcastTxRequest { + return BroadcastTxRequest.decode(message.value); + }, + toProto(message: BroadcastTxRequest): Uint8Array { + return BroadcastTxRequest.encode(message).finish(); + }, + toProtoMsg(message: BroadcastTxRequest): BroadcastTxRequestProtoMsg { + return { + typeUrl: "/cosmos.tx.v1beta1.BroadcastTxRequest", + value: BroadcastTxRequest.encode(message).finish() + }; + } +}; +function createBaseBroadcastTxResponse(): BroadcastTxResponse { + return { + txResponse: undefined + }; +} +export const BroadcastTxResponse = { + typeUrl: "/cosmos.tx.v1beta1.BroadcastTxResponse", + encode(message: BroadcastTxResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.txResponse !== undefined) { + TxResponse.encode(message.txResponse, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): BroadcastTxResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseBroadcastTxResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.txResponse = TxResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): BroadcastTxResponse { + const obj = createBaseBroadcastTxResponse(); + if (isSet(object.txResponse)) obj.txResponse = TxResponse.fromJSON(object.txResponse); + return obj; + }, + toJSON(message: BroadcastTxResponse): JsonSafe { + const obj: any = {}; + message.txResponse !== undefined && (obj.txResponse = message.txResponse ? TxResponse.toJSON(message.txResponse) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): BroadcastTxResponse { + const message = createBaseBroadcastTxResponse(); + if (object.txResponse !== undefined && object.txResponse !== null) { + message.txResponse = TxResponse.fromPartial(object.txResponse); + } + return message; + }, + fromSDK(object: BroadcastTxResponseSDKType): BroadcastTxResponse { + return { + txResponse: object.tx_response ? TxResponse.fromSDK(object.tx_response) : undefined + }; + }, + fromSDKJSON(object: any): BroadcastTxResponseSDKType { + return { + tx_response: isSet(object.tx_response) ? TxResponse.fromSDKJSON(object.tx_response) : undefined + }; + }, + toSDK(message: BroadcastTxResponse): BroadcastTxResponseSDKType { + const obj: any = {}; + message.txResponse !== undefined && (obj.tx_response = message.txResponse ? TxResponse.toSDK(message.txResponse) : undefined); + return obj; + }, + fromAmino(object: BroadcastTxResponseAmino): BroadcastTxResponse { + const message = createBaseBroadcastTxResponse(); + if (object.tx_response !== undefined && object.tx_response !== null) { + message.txResponse = TxResponse.fromAmino(object.tx_response); + } + return message; + }, + toAmino(message: BroadcastTxResponse): BroadcastTxResponseAmino { + const obj: any = {}; + obj.tx_response = message.txResponse ? TxResponse.toAmino(message.txResponse) : undefined; + return obj; + }, + fromAminoMsg(object: BroadcastTxResponseAminoMsg): BroadcastTxResponse { + return BroadcastTxResponse.fromAmino(object.value); + }, + toAminoMsg(message: BroadcastTxResponse): BroadcastTxResponseAminoMsg { + return { + type: "cosmos-sdk/BroadcastTxResponse", + value: BroadcastTxResponse.toAmino(message) + }; + }, + fromProtoMsg(message: BroadcastTxResponseProtoMsg): BroadcastTxResponse { + return BroadcastTxResponse.decode(message.value); + }, + toProto(message: BroadcastTxResponse): Uint8Array { + return BroadcastTxResponse.encode(message).finish(); + }, + toProtoMsg(message: BroadcastTxResponse): BroadcastTxResponseProtoMsg { + return { + typeUrl: "/cosmos.tx.v1beta1.BroadcastTxResponse", + value: BroadcastTxResponse.encode(message).finish() + }; + } +}; +function createBaseSimulateRequest(): SimulateRequest { + return { + tx: undefined, + txBytes: new Uint8Array() + }; +} +export const SimulateRequest = { + typeUrl: "/cosmos.tx.v1beta1.SimulateRequest", + encode(message: SimulateRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.tx !== undefined) { + Tx.encode(message.tx, writer.uint32(10).fork()).ldelim(); + } + if (message.txBytes.length !== 0) { + writer.uint32(18).bytes(message.txBytes); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): SimulateRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseSimulateRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.tx = Tx.decode(reader, reader.uint32()); + break; + case 2: + message.txBytes = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): SimulateRequest { + const obj = createBaseSimulateRequest(); + if (isSet(object.tx)) obj.tx = Tx.fromJSON(object.tx); + if (isSet(object.txBytes)) obj.txBytes = bytesFromBase64(object.txBytes); + return obj; + }, + toJSON(message: SimulateRequest): JsonSafe { + const obj: any = {}; + message.tx !== undefined && (obj.tx = message.tx ? Tx.toJSON(message.tx) : undefined); + message.txBytes !== undefined && (obj.txBytes = base64FromBytes(message.txBytes !== undefined ? message.txBytes : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): SimulateRequest { + const message = createBaseSimulateRequest(); + if (object.tx !== undefined && object.tx !== null) { + message.tx = Tx.fromPartial(object.tx); + } + message.txBytes = object.txBytes ?? new Uint8Array(); + return message; + }, + fromSDK(object: SimulateRequestSDKType): SimulateRequest { + return { + tx: object.tx ? Tx.fromSDK(object.tx) : undefined, + txBytes: object?.tx_bytes + }; + }, + fromSDKJSON(object: any): SimulateRequestSDKType { + return { + tx: isSet(object.tx) ? Tx.fromSDKJSON(object.tx) : undefined, + tx_bytes: isSet(object.tx_bytes) ? bytesFromBase64(object.tx_bytes) : new Uint8Array() + }; + }, + toSDK(message: SimulateRequest): SimulateRequestSDKType { + const obj: any = {}; + message.tx !== undefined && (obj.tx = message.tx ? Tx.toSDK(message.tx) : undefined); + obj.tx_bytes = message.txBytes; + return obj; + }, + fromAmino(object: SimulateRequestAmino): SimulateRequest { + const message = createBaseSimulateRequest(); + if (object.tx !== undefined && object.tx !== null) { + message.tx = Tx.fromAmino(object.tx); + } + if (object.tx_bytes !== undefined && object.tx_bytes !== null) { + message.txBytes = bytesFromBase64(object.tx_bytes); + } + return message; + }, + toAmino(message: SimulateRequest): SimulateRequestAmino { + const obj: any = {}; + obj.tx = message.tx ? Tx.toAmino(message.tx) : undefined; + obj.tx_bytes = message.txBytes ? base64FromBytes(message.txBytes) : undefined; + return obj; + }, + fromAminoMsg(object: SimulateRequestAminoMsg): SimulateRequest { + return SimulateRequest.fromAmino(object.value); + }, + toAminoMsg(message: SimulateRequest): SimulateRequestAminoMsg { + return { + type: "cosmos-sdk/SimulateRequest", + value: SimulateRequest.toAmino(message) + }; + }, + fromProtoMsg(message: SimulateRequestProtoMsg): SimulateRequest { + return SimulateRequest.decode(message.value); + }, + toProto(message: SimulateRequest): Uint8Array { + return SimulateRequest.encode(message).finish(); + }, + toProtoMsg(message: SimulateRequest): SimulateRequestProtoMsg { + return { + typeUrl: "/cosmos.tx.v1beta1.SimulateRequest", + value: SimulateRequest.encode(message).finish() + }; + } +}; +function createBaseSimulateResponse(): SimulateResponse { + return { + gasInfo: undefined, + result: undefined + }; +} +export const SimulateResponse = { + typeUrl: "/cosmos.tx.v1beta1.SimulateResponse", + encode(message: SimulateResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.gasInfo !== undefined) { + GasInfo.encode(message.gasInfo, writer.uint32(10).fork()).ldelim(); + } + if (message.result !== undefined) { + Result.encode(message.result, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): SimulateResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseSimulateResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.gasInfo = GasInfo.decode(reader, reader.uint32()); + break; + case 2: + message.result = Result.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): SimulateResponse { + const obj = createBaseSimulateResponse(); + if (isSet(object.gasInfo)) obj.gasInfo = GasInfo.fromJSON(object.gasInfo); + if (isSet(object.result)) obj.result = Result.fromJSON(object.result); + return obj; + }, + toJSON(message: SimulateResponse): JsonSafe { + const obj: any = {}; + message.gasInfo !== undefined && (obj.gasInfo = message.gasInfo ? GasInfo.toJSON(message.gasInfo) : undefined); + message.result !== undefined && (obj.result = message.result ? Result.toJSON(message.result) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): SimulateResponse { + const message = createBaseSimulateResponse(); + if (object.gasInfo !== undefined && object.gasInfo !== null) { + message.gasInfo = GasInfo.fromPartial(object.gasInfo); + } + if (object.result !== undefined && object.result !== null) { + message.result = Result.fromPartial(object.result); + } + return message; + }, + fromSDK(object: SimulateResponseSDKType): SimulateResponse { + return { + gasInfo: object.gas_info ? GasInfo.fromSDK(object.gas_info) : undefined, + result: object.result ? Result.fromSDK(object.result) : undefined + }; + }, + fromSDKJSON(object: any): SimulateResponseSDKType { + return { + gas_info: isSet(object.gas_info) ? GasInfo.fromSDKJSON(object.gas_info) : undefined, + result: isSet(object.result) ? Result.fromSDKJSON(object.result) : undefined + }; + }, + toSDK(message: SimulateResponse): SimulateResponseSDKType { + const obj: any = {}; + message.gasInfo !== undefined && (obj.gas_info = message.gasInfo ? GasInfo.toSDK(message.gasInfo) : undefined); + message.result !== undefined && (obj.result = message.result ? Result.toSDK(message.result) : undefined); + return obj; + }, + fromAmino(object: SimulateResponseAmino): SimulateResponse { + const message = createBaseSimulateResponse(); + if (object.gas_info !== undefined && object.gas_info !== null) { + message.gasInfo = GasInfo.fromAmino(object.gas_info); + } + if (object.result !== undefined && object.result !== null) { + message.result = Result.fromAmino(object.result); + } + return message; + }, + toAmino(message: SimulateResponse): SimulateResponseAmino { + const obj: any = {}; + obj.gas_info = message.gasInfo ? GasInfo.toAmino(message.gasInfo) : undefined; + obj.result = message.result ? Result.toAmino(message.result) : undefined; + return obj; + }, + fromAminoMsg(object: SimulateResponseAminoMsg): SimulateResponse { + return SimulateResponse.fromAmino(object.value); + }, + toAminoMsg(message: SimulateResponse): SimulateResponseAminoMsg { + return { + type: "cosmos-sdk/SimulateResponse", + value: SimulateResponse.toAmino(message) + }; + }, + fromProtoMsg(message: SimulateResponseProtoMsg): SimulateResponse { + return SimulateResponse.decode(message.value); + }, + toProto(message: SimulateResponse): Uint8Array { + return SimulateResponse.encode(message).finish(); + }, + toProtoMsg(message: SimulateResponse): SimulateResponseProtoMsg { + return { + typeUrl: "/cosmos.tx.v1beta1.SimulateResponse", + value: SimulateResponse.encode(message).finish() + }; + } +}; +function createBaseGetTxRequest(): GetTxRequest { + return { + hash: "" + }; +} +export const GetTxRequest = { + typeUrl: "/cosmos.tx.v1beta1.GetTxRequest", + encode(message: GetTxRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.hash !== undefined) { + writer.uint32(10).string(message.hash); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GetTxRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGetTxRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.hash = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GetTxRequest { + const obj = createBaseGetTxRequest(); + if (isSet(object.hash)) obj.hash = String(object.hash); + return obj; + }, + toJSON(message: GetTxRequest): JsonSafe { + const obj: any = {}; + message.hash !== undefined && (obj.hash = message.hash); + return obj; + }, + fromPartial(object: DeepPartial): GetTxRequest { + const message = createBaseGetTxRequest(); + message.hash = object.hash ?? ""; + return message; + }, + fromSDK(object: GetTxRequestSDKType): GetTxRequest { + return { + hash: object?.hash + }; + }, + fromSDKJSON(object: any): GetTxRequestSDKType { + return { + hash: isSet(object.hash) ? String(object.hash) : "" + }; + }, + toSDK(message: GetTxRequest): GetTxRequestSDKType { + const obj: any = {}; + obj.hash = message.hash; + return obj; + }, + fromAmino(object: GetTxRequestAmino): GetTxRequest { + const message = createBaseGetTxRequest(); + if (object.hash !== undefined && object.hash !== null) { + message.hash = object.hash; + } + return message; + }, + toAmino(message: GetTxRequest): GetTxRequestAmino { + const obj: any = {}; + obj.hash = message.hash === "" ? undefined : message.hash; + return obj; + }, + fromAminoMsg(object: GetTxRequestAminoMsg): GetTxRequest { + return GetTxRequest.fromAmino(object.value); + }, + toAminoMsg(message: GetTxRequest): GetTxRequestAminoMsg { + return { + type: "cosmos-sdk/GetTxRequest", + value: GetTxRequest.toAmino(message) + }; + }, + fromProtoMsg(message: GetTxRequestProtoMsg): GetTxRequest { + return GetTxRequest.decode(message.value); + }, + toProto(message: GetTxRequest): Uint8Array { + return GetTxRequest.encode(message).finish(); + }, + toProtoMsg(message: GetTxRequest): GetTxRequestProtoMsg { + return { + typeUrl: "/cosmos.tx.v1beta1.GetTxRequest", + value: GetTxRequest.encode(message).finish() + }; + } +}; +function createBaseGetTxResponse(): GetTxResponse { + return { + tx: undefined, + txResponse: undefined + }; +} +export const GetTxResponse = { + typeUrl: "/cosmos.tx.v1beta1.GetTxResponse", + encode(message: GetTxResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.tx !== undefined) { + Tx.encode(message.tx, writer.uint32(10).fork()).ldelim(); + } + if (message.txResponse !== undefined) { + TxResponse.encode(message.txResponse, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GetTxResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGetTxResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.tx = Tx.decode(reader, reader.uint32()); + break; + case 2: + message.txResponse = TxResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GetTxResponse { + const obj = createBaseGetTxResponse(); + if (isSet(object.tx)) obj.tx = Tx.fromJSON(object.tx); + if (isSet(object.txResponse)) obj.txResponse = TxResponse.fromJSON(object.txResponse); + return obj; + }, + toJSON(message: GetTxResponse): JsonSafe { + const obj: any = {}; + message.tx !== undefined && (obj.tx = message.tx ? Tx.toJSON(message.tx) : undefined); + message.txResponse !== undefined && (obj.txResponse = message.txResponse ? TxResponse.toJSON(message.txResponse) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): GetTxResponse { + const message = createBaseGetTxResponse(); + if (object.tx !== undefined && object.tx !== null) { + message.tx = Tx.fromPartial(object.tx); + } + if (object.txResponse !== undefined && object.txResponse !== null) { + message.txResponse = TxResponse.fromPartial(object.txResponse); + } + return message; + }, + fromSDK(object: GetTxResponseSDKType): GetTxResponse { + return { + tx: object.tx ? Tx.fromSDK(object.tx) : undefined, + txResponse: object.tx_response ? TxResponse.fromSDK(object.tx_response) : undefined + }; + }, + fromSDKJSON(object: any): GetTxResponseSDKType { + return { + tx: isSet(object.tx) ? Tx.fromSDKJSON(object.tx) : undefined, + tx_response: isSet(object.tx_response) ? TxResponse.fromSDKJSON(object.tx_response) : undefined + }; + }, + toSDK(message: GetTxResponse): GetTxResponseSDKType { + const obj: any = {}; + message.tx !== undefined && (obj.tx = message.tx ? Tx.toSDK(message.tx) : undefined); + message.txResponse !== undefined && (obj.tx_response = message.txResponse ? TxResponse.toSDK(message.txResponse) : undefined); + return obj; + }, + fromAmino(object: GetTxResponseAmino): GetTxResponse { + const message = createBaseGetTxResponse(); + if (object.tx !== undefined && object.tx !== null) { + message.tx = Tx.fromAmino(object.tx); + } + if (object.tx_response !== undefined && object.tx_response !== null) { + message.txResponse = TxResponse.fromAmino(object.tx_response); + } + return message; + }, + toAmino(message: GetTxResponse): GetTxResponseAmino { + const obj: any = {}; + obj.tx = message.tx ? Tx.toAmino(message.tx) : undefined; + obj.tx_response = message.txResponse ? TxResponse.toAmino(message.txResponse) : undefined; + return obj; + }, + fromAminoMsg(object: GetTxResponseAminoMsg): GetTxResponse { + return GetTxResponse.fromAmino(object.value); + }, + toAminoMsg(message: GetTxResponse): GetTxResponseAminoMsg { + return { + type: "cosmos-sdk/GetTxResponse", + value: GetTxResponse.toAmino(message) + }; + }, + fromProtoMsg(message: GetTxResponseProtoMsg): GetTxResponse { + return GetTxResponse.decode(message.value); + }, + toProto(message: GetTxResponse): Uint8Array { + return GetTxResponse.encode(message).finish(); + }, + toProtoMsg(message: GetTxResponse): GetTxResponseProtoMsg { + return { + typeUrl: "/cosmos.tx.v1beta1.GetTxResponse", + value: GetTxResponse.encode(message).finish() + }; + } +}; +function createBaseGetBlockWithTxsRequest(): GetBlockWithTxsRequest { + return { + height: BigInt(0), + pagination: undefined + }; +} +export const GetBlockWithTxsRequest = { + typeUrl: "/cosmos.tx.v1beta1.GetBlockWithTxsRequest", + encode(message: GetBlockWithTxsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.height !== undefined) { + writer.uint32(8).int64(message.height); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GetBlockWithTxsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGetBlockWithTxsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.height = reader.int64(); + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GetBlockWithTxsRequest { + const obj = createBaseGetBlockWithTxsRequest(); + if (isSet(object.height)) obj.height = BigInt(object.height.toString()); + if (isSet(object.pagination)) obj.pagination = PageRequest.fromJSON(object.pagination); + return obj; + }, + toJSON(message: GetBlockWithTxsRequest): JsonSafe { + const obj: any = {}; + message.height !== undefined && (obj.height = (message.height || BigInt(0)).toString()); + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): GetBlockWithTxsRequest { + const message = createBaseGetBlockWithTxsRequest(); + if (object.height !== undefined && object.height !== null) { + message.height = BigInt(object.height.toString()); + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: GetBlockWithTxsRequestSDKType): GetBlockWithTxsRequest { + return { + height: object?.height, + pagination: object.pagination ? PageRequest.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): GetBlockWithTxsRequestSDKType { + return { + height: isSet(object.height) ? BigInt(object.height.toString()) : BigInt(0), + pagination: isSet(object.pagination) ? PageRequest.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: GetBlockWithTxsRequest): GetBlockWithTxsRequestSDKType { + const obj: any = {}; + obj.height = message.height; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: GetBlockWithTxsRequestAmino): GetBlockWithTxsRequest { + const message = createBaseGetBlockWithTxsRequest(); + if (object.height !== undefined && object.height !== null) { + message.height = BigInt(object.height); + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: GetBlockWithTxsRequest): GetBlockWithTxsRequestAmino { + const obj: any = {}; + obj.height = message.height !== BigInt(0) ? message.height?.toString() : undefined; + obj.pagination = message.pagination ? PageRequest.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: GetBlockWithTxsRequestAminoMsg): GetBlockWithTxsRequest { + return GetBlockWithTxsRequest.fromAmino(object.value); + }, + toAminoMsg(message: GetBlockWithTxsRequest): GetBlockWithTxsRequestAminoMsg { + return { + type: "cosmos-sdk/GetBlockWithTxsRequest", + value: GetBlockWithTxsRequest.toAmino(message) + }; + }, + fromProtoMsg(message: GetBlockWithTxsRequestProtoMsg): GetBlockWithTxsRequest { + return GetBlockWithTxsRequest.decode(message.value); + }, + toProto(message: GetBlockWithTxsRequest): Uint8Array { + return GetBlockWithTxsRequest.encode(message).finish(); + }, + toProtoMsg(message: GetBlockWithTxsRequest): GetBlockWithTxsRequestProtoMsg { + return { + typeUrl: "/cosmos.tx.v1beta1.GetBlockWithTxsRequest", + value: GetBlockWithTxsRequest.encode(message).finish() + }; + } +}; +function createBaseGetBlockWithTxsResponse(): GetBlockWithTxsResponse { + return { + txs: [], + blockId: undefined, + block: undefined, + pagination: undefined + }; +} +export const GetBlockWithTxsResponse = { + typeUrl: "/cosmos.tx.v1beta1.GetBlockWithTxsResponse", + encode(message: GetBlockWithTxsResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.txs) { + Tx.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.blockId !== undefined) { + BlockID.encode(message.blockId, writer.uint32(18).fork()).ldelim(); + } + if (message.block !== undefined) { + Block.encode(message.block, writer.uint32(26).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GetBlockWithTxsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGetBlockWithTxsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.txs.push(Tx.decode(reader, reader.uint32())); + break; + case 2: + message.blockId = BlockID.decode(reader, reader.uint32()); + break; + case 3: + message.block = Block.decode(reader, reader.uint32()); + break; + case 4: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GetBlockWithTxsResponse { + const obj = createBaseGetBlockWithTxsResponse(); + if (Array.isArray(object?.txs)) obj.txs = object.txs.map((e: any) => Tx.fromJSON(e)); + if (isSet(object.blockId)) obj.blockId = BlockID.fromJSON(object.blockId); + if (isSet(object.block)) obj.block = Block.fromJSON(object.block); + if (isSet(object.pagination)) obj.pagination = PageResponse.fromJSON(object.pagination); + return obj; + }, + toJSON(message: GetBlockWithTxsResponse): JsonSafe { + const obj: any = {}; + if (message.txs) { + obj.txs = message.txs.map(e => e ? Tx.toJSON(e) : undefined); + } else { + obj.txs = []; + } + message.blockId !== undefined && (obj.blockId = message.blockId ? BlockID.toJSON(message.blockId) : undefined); + message.block !== undefined && (obj.block = message.block ? Block.toJSON(message.block) : undefined); + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): GetBlockWithTxsResponse { + const message = createBaseGetBlockWithTxsResponse(); + message.txs = object.txs?.map(e => Tx.fromPartial(e)) || []; + if (object.blockId !== undefined && object.blockId !== null) { + message.blockId = BlockID.fromPartial(object.blockId); + } + if (object.block !== undefined && object.block !== null) { + message.block = Block.fromPartial(object.block); + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: GetBlockWithTxsResponseSDKType): GetBlockWithTxsResponse { + return { + txs: Array.isArray(object?.txs) ? object.txs.map((e: any) => Tx.fromSDK(e)) : [], + blockId: object.block_id ? BlockID.fromSDK(object.block_id) : undefined, + block: object.block ? Block.fromSDK(object.block) : undefined, + pagination: object.pagination ? PageResponse.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): GetBlockWithTxsResponseSDKType { + return { + txs: Array.isArray(object?.txs) ? object.txs.map((e: any) => Tx.fromSDKJSON(e)) : [], + block_id: isSet(object.block_id) ? BlockID.fromSDKJSON(object.block_id) : undefined, + block: isSet(object.block) ? Block.fromSDKJSON(object.block) : undefined, + pagination: isSet(object.pagination) ? PageResponse.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: GetBlockWithTxsResponse): GetBlockWithTxsResponseSDKType { + const obj: any = {}; + if (message.txs) { + obj.txs = message.txs.map(e => e ? Tx.toSDK(e) : undefined); + } else { + obj.txs = []; + } + message.blockId !== undefined && (obj.block_id = message.blockId ? BlockID.toSDK(message.blockId) : undefined); + message.block !== undefined && (obj.block = message.block ? Block.toSDK(message.block) : undefined); + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: GetBlockWithTxsResponseAmino): GetBlockWithTxsResponse { + const message = createBaseGetBlockWithTxsResponse(); + message.txs = object.txs?.map(e => Tx.fromAmino(e)) || []; + if (object.block_id !== undefined && object.block_id !== null) { + message.blockId = BlockID.fromAmino(object.block_id); + } + if (object.block !== undefined && object.block !== null) { + message.block = Block.fromAmino(object.block); + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: GetBlockWithTxsResponse): GetBlockWithTxsResponseAmino { + const obj: any = {}; + if (message.txs) { + obj.txs = message.txs.map(e => e ? Tx.toAmino(e) : undefined); + } else { + obj.txs = message.txs; + } + obj.block_id = message.blockId ? BlockID.toAmino(message.blockId) : undefined; + obj.block = message.block ? Block.toAmino(message.block) : undefined; + obj.pagination = message.pagination ? PageResponse.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: GetBlockWithTxsResponseAminoMsg): GetBlockWithTxsResponse { + return GetBlockWithTxsResponse.fromAmino(object.value); + }, + toAminoMsg(message: GetBlockWithTxsResponse): GetBlockWithTxsResponseAminoMsg { + return { + type: "cosmos-sdk/GetBlockWithTxsResponse", + value: GetBlockWithTxsResponse.toAmino(message) + }; + }, + fromProtoMsg(message: GetBlockWithTxsResponseProtoMsg): GetBlockWithTxsResponse { + return GetBlockWithTxsResponse.decode(message.value); + }, + toProto(message: GetBlockWithTxsResponse): Uint8Array { + return GetBlockWithTxsResponse.encode(message).finish(); + }, + toProtoMsg(message: GetBlockWithTxsResponse): GetBlockWithTxsResponseProtoMsg { + return { + typeUrl: "/cosmos.tx.v1beta1.GetBlockWithTxsResponse", + value: GetBlockWithTxsResponse.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/tx/v1beta1/tx.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/tx/v1beta1/tx.ts new file mode 100644 index 0000000000..13eadffee6 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/tx/v1beta1/tx.ts @@ -0,0 +1,2284 @@ +import { Any, AnySDKType } from "../../../google/protobuf/any.js"; +import { SignMode, SignModeSDKType, signModeFromJSON, signModeToJSON } from "../signing/v1beta1/signing.js"; +import { CompactBitArray, CompactBitArraySDKType } from "../../crypto/multisig/v1beta1/multisig.js"; +import { Coin, CoinSDKType } from "../../base/v1beta1/coin.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, bytesFromBase64, base64FromBytes, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "cosmos.tx.v1beta1"; +/** Tx is the standard type used for broadcasting transactions. */ +export interface Tx { + /** body is the processable content of the transaction */ + body?: TxBody; + /** + * auth_info is the authorization related content of the transaction, + * specifically signers, signer modes and fee + */ + authInfo?: AuthInfo; + /** + * signatures is a list of signatures that matches the length and order of + * AuthInfo's signer_infos to allow connecting signature meta information like + * public key and signing mode by position. + */ + signatures: Uint8Array[]; +} +export interface TxProtoMsg { + typeUrl: "/cosmos.tx.v1beta1.Tx"; + value: Uint8Array; +} +/** Tx is the standard type used for broadcasting transactions. */ +export interface TxSDKType { + body?: TxBodySDKType; + auth_info?: AuthInfoSDKType; + signatures: Uint8Array[]; +} +/** + * TxRaw is a variant of Tx that pins the signer's exact binary representation + * of body and auth_info. This is used for signing, broadcasting and + * verification. The binary `serialize(tx: TxRaw)` is stored in Tendermint and + * the hash `sha256(serialize(tx: TxRaw))` becomes the "txhash", commonly used + * as the transaction ID. + */ +export interface TxRaw { + /** + * body_bytes is a protobuf serialization of a TxBody that matches the + * representation in SignDoc. + */ + bodyBytes: Uint8Array; + /** + * auth_info_bytes is a protobuf serialization of an AuthInfo that matches the + * representation in SignDoc. + */ + authInfoBytes: Uint8Array; + /** + * signatures is a list of signatures that matches the length and order of + * AuthInfo's signer_infos to allow connecting signature meta information like + * public key and signing mode by position. + */ + signatures: Uint8Array[]; +} +export interface TxRawProtoMsg { + typeUrl: "/cosmos.tx.v1beta1.TxRaw"; + value: Uint8Array; +} +/** + * TxRaw is a variant of Tx that pins the signer's exact binary representation + * of body and auth_info. This is used for signing, broadcasting and + * verification. The binary `serialize(tx: TxRaw)` is stored in Tendermint and + * the hash `sha256(serialize(tx: TxRaw))` becomes the "txhash", commonly used + * as the transaction ID. + */ +export interface TxRawSDKType { + body_bytes: Uint8Array; + auth_info_bytes: Uint8Array; + signatures: Uint8Array[]; +} +/** SignDoc is the type used for generating sign bytes for SIGN_MODE_DIRECT. */ +export interface SignDoc { + /** + * body_bytes is protobuf serialization of a TxBody that matches the + * representation in TxRaw. + */ + bodyBytes: Uint8Array; + /** + * auth_info_bytes is a protobuf serialization of an AuthInfo that matches the + * representation in TxRaw. + */ + authInfoBytes: Uint8Array; + /** + * chain_id is the unique identifier of the chain this transaction targets. + * It prevents signed transactions from being used on another chain by an + * attacker + */ + chainId: string; + /** account_number is the account number of the account in state */ + accountNumber: bigint; +} +export interface SignDocProtoMsg { + typeUrl: "/cosmos.tx.v1beta1.SignDoc"; + value: Uint8Array; +} +/** SignDoc is the type used for generating sign bytes for SIGN_MODE_DIRECT. */ +export interface SignDocSDKType { + body_bytes: Uint8Array; + auth_info_bytes: Uint8Array; + chain_id: string; + account_number: bigint; +} +/** + * SignDocDirectAux is the type used for generating sign bytes for + * SIGN_MODE_DIRECT_AUX. + * + * Since: cosmos-sdk 0.46 + */ +export interface SignDocDirectAux { + /** + * body_bytes is protobuf serialization of a TxBody that matches the + * representation in TxRaw. + */ + bodyBytes: Uint8Array; + /** public_key is the public key of the signing account. */ + publicKey?: Any; + /** + * chain_id is the identifier of the chain this transaction targets. + * It prevents signed transactions from being used on another chain by an + * attacker. + */ + chainId: string; + /** account_number is the account number of the account in state. */ + accountNumber: bigint; + /** sequence is the sequence number of the signing account. */ + sequence: bigint; + /** + * Tip is the optional tip used for meta-transactions. It should be left + * empty if the signer is not the tipper for this transaction. + */ + tip?: Tip; +} +export interface SignDocDirectAuxProtoMsg { + typeUrl: "/cosmos.tx.v1beta1.SignDocDirectAux"; + value: Uint8Array; +} +/** + * SignDocDirectAux is the type used for generating sign bytes for + * SIGN_MODE_DIRECT_AUX. + * + * Since: cosmos-sdk 0.46 + */ +export interface SignDocDirectAuxSDKType { + body_bytes: Uint8Array; + public_key?: AnySDKType; + chain_id: string; + account_number: bigint; + sequence: bigint; + tip?: TipSDKType; +} +/** TxBody is the body of a transaction that all signers sign over. */ +export interface TxBody { + /** + * messages is a list of messages to be executed. The required signers of + * those messages define the number and order of elements in AuthInfo's + * signer_infos and Tx's signatures. Each required signer address is added to + * the list only the first time it occurs. + * By convention, the first required signer (usually from the first message) + * is referred to as the primary signer and pays the fee for the whole + * transaction. + */ + messages: Any[]; + /** + * memo is any arbitrary note/comment to be added to the transaction. + * WARNING: in clients, any publicly exposed text should not be called memo, + * but should be called `note` instead (see https://github.com/cosmos/cosmos-sdk/issues/9122). + */ + memo: string; + /** + * timeout is the block height after which this transaction will not + * be processed by the chain + */ + timeoutHeight: bigint; + /** + * extension_options are arbitrary options that can be added by chains + * when the default options are not sufficient. If any of these are present + * and can't be handled, the transaction will be rejected + */ + extensionOptions: Any[]; + /** + * extension_options are arbitrary options that can be added by chains + * when the default options are not sufficient. If any of these are present + * and can't be handled, they will be ignored + */ + nonCriticalExtensionOptions: Any[]; +} +export interface TxBodyProtoMsg { + typeUrl: "/cosmos.tx.v1beta1.TxBody"; + value: Uint8Array; +} +/** TxBody is the body of a transaction that all signers sign over. */ +export interface TxBodySDKType { + messages: AnySDKType[]; + memo: string; + timeout_height: bigint; + extension_options: AnySDKType[]; + non_critical_extension_options: AnySDKType[]; +} +/** + * AuthInfo describes the fee and signer modes that are used to sign a + * transaction. + */ +export interface AuthInfo { + /** + * signer_infos defines the signing modes for the required signers. The number + * and order of elements must match the required signers from TxBody's + * messages. The first element is the primary signer and the one which pays + * the fee. + */ + signerInfos: SignerInfo[]; + /** + * Fee is the fee and gas limit for the transaction. The first signer is the + * primary signer and the one which pays the fee. The fee can be calculated + * based on the cost of evaluating the body and doing signature verification + * of the signers. This can be estimated via simulation. + */ + fee?: Fee; + /** + * Tip is the optional tip used for meta-transactions. + * + * Since: cosmos-sdk 0.46 + */ + tip?: Tip; +} +export interface AuthInfoProtoMsg { + typeUrl: "/cosmos.tx.v1beta1.AuthInfo"; + value: Uint8Array; +} +/** + * AuthInfo describes the fee and signer modes that are used to sign a + * transaction. + */ +export interface AuthInfoSDKType { + signer_infos: SignerInfoSDKType[]; + fee?: FeeSDKType; + tip?: TipSDKType; +} +/** + * SignerInfo describes the public key and signing mode of a single top-level + * signer. + */ +export interface SignerInfo { + /** + * public_key is the public key of the signer. It is optional for accounts + * that already exist in state. If unset, the verifier can use the required \ + * signer address for this position and lookup the public key. + */ + publicKey?: Any; + /** + * mode_info describes the signing mode of the signer and is a nested + * structure to support nested multisig pubkey's + */ + modeInfo?: ModeInfo; + /** + * sequence is the sequence of the account, which describes the + * number of committed transactions signed by a given address. It is used to + * prevent replay attacks. + */ + sequence: bigint; +} +export interface SignerInfoProtoMsg { + typeUrl: "/cosmos.tx.v1beta1.SignerInfo"; + value: Uint8Array; +} +/** + * SignerInfo describes the public key and signing mode of a single top-level + * signer. + */ +export interface SignerInfoSDKType { + public_key?: AnySDKType; + mode_info?: ModeInfoSDKType; + sequence: bigint; +} +/** ModeInfo describes the signing mode of a single or nested multisig signer. */ +export interface ModeInfo { + /** single represents a single signer */ + single?: ModeInfo_Single; + /** multi represents a nested multisig signer */ + multi?: ModeInfo_Multi; +} +export interface ModeInfoProtoMsg { + typeUrl: "/cosmos.tx.v1beta1.ModeInfo"; + value: Uint8Array; +} +/** ModeInfo describes the signing mode of a single or nested multisig signer. */ +export interface ModeInfoSDKType { + single?: ModeInfo_SingleSDKType; + multi?: ModeInfo_MultiSDKType; +} +/** + * Single is the mode info for a single signer. It is structured as a message + * to allow for additional fields such as locale for SIGN_MODE_TEXTUAL in the + * future + */ +export interface ModeInfo_Single { + /** mode is the signing mode of the single signer */ + mode: SignMode; +} +export interface ModeInfo_SingleProtoMsg { + typeUrl: "/cosmos.tx.v1beta1.Single"; + value: Uint8Array; +} +/** + * Single is the mode info for a single signer. It is structured as a message + * to allow for additional fields such as locale for SIGN_MODE_TEXTUAL in the + * future + */ +export interface ModeInfo_SingleSDKType { + mode: SignMode; +} +/** Multi is the mode info for a multisig public key */ +export interface ModeInfo_Multi { + /** bitarray specifies which keys within the multisig are signing */ + bitarray?: CompactBitArray; + /** + * mode_infos is the corresponding modes of the signers of the multisig + * which could include nested multisig public keys + */ + modeInfos: ModeInfo[]; +} +export interface ModeInfo_MultiProtoMsg { + typeUrl: "/cosmos.tx.v1beta1.Multi"; + value: Uint8Array; +} +/** Multi is the mode info for a multisig public key */ +export interface ModeInfo_MultiSDKType { + bitarray?: CompactBitArraySDKType; + mode_infos: ModeInfoSDKType[]; +} +/** + * Fee includes the amount of coins paid in fees and the maximum + * gas to be used by the transaction. The ratio yields an effective "gasprice", + * which must be above some miminum to be accepted into the mempool. + */ +export interface Fee { + /** amount is the amount of coins to be paid as a fee */ + amount: Coin[]; + /** + * gas_limit is the maximum gas that can be used in transaction processing + * before an out of gas error occurs + */ + gasLimit: bigint; + /** + * if unset, the first signer is responsible for paying the fees. If set, the specified account must pay the fees. + * the payer must be a tx signer (and thus have signed this field in AuthInfo). + * setting this field does *not* change the ordering of required signers for the transaction. + */ + payer: string; + /** + * if set, the fee payer (either the first signer or the value of the payer field) requests that a fee grant be used + * to pay fees instead of the fee payer's own balance. If an appropriate fee grant does not exist or the chain does + * not support fee grants, this will fail + */ + granter: string; +} +export interface FeeProtoMsg { + typeUrl: "/cosmos.tx.v1beta1.Fee"; + value: Uint8Array; +} +/** + * Fee includes the amount of coins paid in fees and the maximum + * gas to be used by the transaction. The ratio yields an effective "gasprice", + * which must be above some miminum to be accepted into the mempool. + */ +export interface FeeSDKType { + amount: CoinSDKType[]; + gas_limit: bigint; + payer: string; + granter: string; +} +/** + * Tip is the tip used for meta-transactions. + * + * Since: cosmos-sdk 0.46 + */ +export interface Tip { + /** amount is the amount of the tip */ + amount: Coin[]; + /** tipper is the address of the account paying for the tip */ + tipper: string; +} +export interface TipProtoMsg { + typeUrl: "/cosmos.tx.v1beta1.Tip"; + value: Uint8Array; +} +/** + * Tip is the tip used for meta-transactions. + * + * Since: cosmos-sdk 0.46 + */ +export interface TipSDKType { + amount: CoinSDKType[]; + tipper: string; +} +/** + * AuxSignerData is the intermediary format that an auxiliary signer (e.g. a + * tipper) builds and sends to the fee payer (who will build and broadcast the + * actual tx). AuxSignerData is not a valid tx in itself, and will be rejected + * by the node if sent directly as-is. + * + * Since: cosmos-sdk 0.46 + */ +export interface AuxSignerData { + /** + * address is the bech32-encoded address of the auxiliary signer. If using + * AuxSignerData across different chains, the bech32 prefix of the target + * chain (where the final transaction is broadcasted) should be used. + */ + address: string; + /** + * sign_doc is the SIGN_MOD_DIRECT_AUX sign doc that the auxiliary signer + * signs. Note: we use the same sign doc even if we're signing with + * LEGACY_AMINO_JSON. + */ + signDoc?: SignDocDirectAux; + /** mode is the signing mode of the single signer */ + mode: SignMode; + /** sig is the signature of the sign doc. */ + sig: Uint8Array; +} +export interface AuxSignerDataProtoMsg { + typeUrl: "/cosmos.tx.v1beta1.AuxSignerData"; + value: Uint8Array; +} +/** + * AuxSignerData is the intermediary format that an auxiliary signer (e.g. a + * tipper) builds and sends to the fee payer (who will build and broadcast the + * actual tx). AuxSignerData is not a valid tx in itself, and will be rejected + * by the node if sent directly as-is. + * + * Since: cosmos-sdk 0.46 + */ +export interface AuxSignerDataSDKType { + address: string; + sign_doc?: SignDocDirectAuxSDKType; + mode: SignMode; + sig: Uint8Array; +} +function createBaseTx(): Tx { + return { + body: undefined, + authInfo: undefined, + signatures: [] + }; +} +export const Tx = { + typeUrl: "/cosmos.tx.v1beta1.Tx", + encode(message: Tx, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.body !== undefined) { + TxBody.encode(message.body, writer.uint32(10).fork()).ldelim(); + } + if (message.authInfo !== undefined) { + AuthInfo.encode(message.authInfo, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.signatures) { + writer.uint32(26).bytes(v!); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Tx { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseTx(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.body = TxBody.decode(reader, reader.uint32()); + break; + case 2: + message.authInfo = AuthInfo.decode(reader, reader.uint32()); + break; + case 3: + message.signatures.push(reader.bytes()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Tx { + const obj = createBaseTx(); + if (isSet(object.body)) obj.body = TxBody.fromJSON(object.body); + if (isSet(object.authInfo)) obj.authInfo = AuthInfo.fromJSON(object.authInfo); + if (Array.isArray(object?.signatures)) obj.signatures = object.signatures.map((e: any) => bytesFromBase64(e)); + return obj; + }, + toJSON(message: Tx): JsonSafe { + const obj: any = {}; + message.body !== undefined && (obj.body = message.body ? TxBody.toJSON(message.body) : undefined); + message.authInfo !== undefined && (obj.authInfo = message.authInfo ? AuthInfo.toJSON(message.authInfo) : undefined); + if (message.signatures) { + obj.signatures = message.signatures.map(e => base64FromBytes(e !== undefined ? e : new Uint8Array())); + } else { + obj.signatures = []; + } + return obj; + }, + fromPartial(object: DeepPartial): Tx { + const message = createBaseTx(); + if (object.body !== undefined && object.body !== null) { + message.body = TxBody.fromPartial(object.body); + } + if (object.authInfo !== undefined && object.authInfo !== null) { + message.authInfo = AuthInfo.fromPartial(object.authInfo); + } + message.signatures = object.signatures?.map(e => e) || []; + return message; + }, + fromSDK(object: TxSDKType): Tx { + return { + body: object.body ? TxBody.fromSDK(object.body) : undefined, + authInfo: object.auth_info ? AuthInfo.fromSDK(object.auth_info) : undefined, + signatures: Array.isArray(object?.signatures) ? object.signatures.map((e: any) => e) : [] + }; + }, + fromSDKJSON(object: any): TxSDKType { + return { + body: isSet(object.body) ? TxBody.fromSDKJSON(object.body) : undefined, + auth_info: isSet(object.auth_info) ? AuthInfo.fromSDKJSON(object.auth_info) : undefined, + signatures: Array.isArray(object?.signatures) ? object.signatures.map((e: any) => bytesFromBase64(e)) : [] + }; + }, + toSDK(message: Tx): TxSDKType { + const obj: any = {}; + message.body !== undefined && (obj.body = message.body ? TxBody.toSDK(message.body) : undefined); + message.authInfo !== undefined && (obj.auth_info = message.authInfo ? AuthInfo.toSDK(message.authInfo) : undefined); + if (message.signatures) { + obj.signatures = message.signatures.map(e => e); + } else { + obj.signatures = []; + } + return obj; + }, + fromAmino(object: TxAmino): Tx { + const message = createBaseTx(); + if (object.body !== undefined && object.body !== null) { + message.body = TxBody.fromAmino(object.body); + } + if (object.auth_info !== undefined && object.auth_info !== null) { + message.authInfo = AuthInfo.fromAmino(object.auth_info); + } + message.signatures = object.signatures?.map(e => bytesFromBase64(e)) || []; + return message; + }, + toAmino(message: Tx): TxAmino { + const obj: any = {}; + obj.body = message.body ? TxBody.toAmino(message.body) : undefined; + obj.auth_info = message.authInfo ? AuthInfo.toAmino(message.authInfo) : undefined; + if (message.signatures) { + obj.signatures = message.signatures.map(e => base64FromBytes(e)); + } else { + obj.signatures = message.signatures; + } + return obj; + }, + fromAminoMsg(object: TxAminoMsg): Tx { + return Tx.fromAmino(object.value); + }, + toAminoMsg(message: Tx): TxAminoMsg { + return { + type: "cosmos-sdk/Tx", + value: Tx.toAmino(message) + }; + }, + fromProtoMsg(message: TxProtoMsg): Tx { + return Tx.decode(message.value); + }, + toProto(message: Tx): Uint8Array { + return Tx.encode(message).finish(); + }, + toProtoMsg(message: Tx): TxProtoMsg { + return { + typeUrl: "/cosmos.tx.v1beta1.Tx", + value: Tx.encode(message).finish() + }; + } +}; +function createBaseTxRaw(): TxRaw { + return { + bodyBytes: new Uint8Array(), + authInfoBytes: new Uint8Array(), + signatures: [] + }; +} +export const TxRaw = { + typeUrl: "/cosmos.tx.v1beta1.TxRaw", + encode(message: TxRaw, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.bodyBytes.length !== 0) { + writer.uint32(10).bytes(message.bodyBytes); + } + if (message.authInfoBytes.length !== 0) { + writer.uint32(18).bytes(message.authInfoBytes); + } + for (const v of message.signatures) { + writer.uint32(26).bytes(v!); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): TxRaw { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseTxRaw(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.bodyBytes = reader.bytes(); + break; + case 2: + message.authInfoBytes = reader.bytes(); + break; + case 3: + message.signatures.push(reader.bytes()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): TxRaw { + const obj = createBaseTxRaw(); + if (isSet(object.bodyBytes)) obj.bodyBytes = bytesFromBase64(object.bodyBytes); + if (isSet(object.authInfoBytes)) obj.authInfoBytes = bytesFromBase64(object.authInfoBytes); + if (Array.isArray(object?.signatures)) obj.signatures = object.signatures.map((e: any) => bytesFromBase64(e)); + return obj; + }, + toJSON(message: TxRaw): JsonSafe { + const obj: any = {}; + message.bodyBytes !== undefined && (obj.bodyBytes = base64FromBytes(message.bodyBytes !== undefined ? message.bodyBytes : new Uint8Array())); + message.authInfoBytes !== undefined && (obj.authInfoBytes = base64FromBytes(message.authInfoBytes !== undefined ? message.authInfoBytes : new Uint8Array())); + if (message.signatures) { + obj.signatures = message.signatures.map(e => base64FromBytes(e !== undefined ? e : new Uint8Array())); + } else { + obj.signatures = []; + } + return obj; + }, + fromPartial(object: DeepPartial): TxRaw { + const message = createBaseTxRaw(); + message.bodyBytes = object.bodyBytes ?? new Uint8Array(); + message.authInfoBytes = object.authInfoBytes ?? new Uint8Array(); + message.signatures = object.signatures?.map(e => e) || []; + return message; + }, + fromSDK(object: TxRawSDKType): TxRaw { + return { + bodyBytes: object?.body_bytes, + authInfoBytes: object?.auth_info_bytes, + signatures: Array.isArray(object?.signatures) ? object.signatures.map((e: any) => e) : [] + }; + }, + fromSDKJSON(object: any): TxRawSDKType { + return { + body_bytes: isSet(object.body_bytes) ? bytesFromBase64(object.body_bytes) : new Uint8Array(), + auth_info_bytes: isSet(object.auth_info_bytes) ? bytesFromBase64(object.auth_info_bytes) : new Uint8Array(), + signatures: Array.isArray(object?.signatures) ? object.signatures.map((e: any) => bytesFromBase64(e)) : [] + }; + }, + toSDK(message: TxRaw): TxRawSDKType { + const obj: any = {}; + obj.body_bytes = message.bodyBytes; + obj.auth_info_bytes = message.authInfoBytes; + if (message.signatures) { + obj.signatures = message.signatures.map(e => e); + } else { + obj.signatures = []; + } + return obj; + }, + fromAmino(object: TxRawAmino): TxRaw { + const message = createBaseTxRaw(); + if (object.body_bytes !== undefined && object.body_bytes !== null) { + message.bodyBytes = bytesFromBase64(object.body_bytes); + } + if (object.auth_info_bytes !== undefined && object.auth_info_bytes !== null) { + message.authInfoBytes = bytesFromBase64(object.auth_info_bytes); + } + message.signatures = object.signatures?.map(e => bytesFromBase64(e)) || []; + return message; + }, + toAmino(message: TxRaw): TxRawAmino { + const obj: any = {}; + obj.body_bytes = message.bodyBytes ? base64FromBytes(message.bodyBytes) : undefined; + obj.auth_info_bytes = message.authInfoBytes ? base64FromBytes(message.authInfoBytes) : undefined; + if (message.signatures) { + obj.signatures = message.signatures.map(e => base64FromBytes(e)); + } else { + obj.signatures = message.signatures; + } + return obj; + }, + fromAminoMsg(object: TxRawAminoMsg): TxRaw { + return TxRaw.fromAmino(object.value); + }, + toAminoMsg(message: TxRaw): TxRawAminoMsg { + return { + type: "cosmos-sdk/TxRaw", + value: TxRaw.toAmino(message) + }; + }, + fromProtoMsg(message: TxRawProtoMsg): TxRaw { + return TxRaw.decode(message.value); + }, + toProto(message: TxRaw): Uint8Array { + return TxRaw.encode(message).finish(); + }, + toProtoMsg(message: TxRaw): TxRawProtoMsg { + return { + typeUrl: "/cosmos.tx.v1beta1.TxRaw", + value: TxRaw.encode(message).finish() + }; + } +}; +function createBaseSignDoc(): SignDoc { + return { + bodyBytes: new Uint8Array(), + authInfoBytes: new Uint8Array(), + chainId: "", + accountNumber: BigInt(0) + }; +} +export const SignDoc = { + typeUrl: "/cosmos.tx.v1beta1.SignDoc", + encode(message: SignDoc, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.bodyBytes.length !== 0) { + writer.uint32(10).bytes(message.bodyBytes); + } + if (message.authInfoBytes.length !== 0) { + writer.uint32(18).bytes(message.authInfoBytes); + } + if (message.chainId !== undefined) { + writer.uint32(26).string(message.chainId); + } + if (message.accountNumber !== undefined) { + writer.uint32(32).uint64(message.accountNumber); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): SignDoc { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseSignDoc(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.bodyBytes = reader.bytes(); + break; + case 2: + message.authInfoBytes = reader.bytes(); + break; + case 3: + message.chainId = reader.string(); + break; + case 4: + message.accountNumber = reader.uint64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): SignDoc { + const obj = createBaseSignDoc(); + if (isSet(object.bodyBytes)) obj.bodyBytes = bytesFromBase64(object.bodyBytes); + if (isSet(object.authInfoBytes)) obj.authInfoBytes = bytesFromBase64(object.authInfoBytes); + if (isSet(object.chainId)) obj.chainId = String(object.chainId); + if (isSet(object.accountNumber)) obj.accountNumber = BigInt(object.accountNumber.toString()); + return obj; + }, + toJSON(message: SignDoc): JsonSafe { + const obj: any = {}; + message.bodyBytes !== undefined && (obj.bodyBytes = base64FromBytes(message.bodyBytes !== undefined ? message.bodyBytes : new Uint8Array())); + message.authInfoBytes !== undefined && (obj.authInfoBytes = base64FromBytes(message.authInfoBytes !== undefined ? message.authInfoBytes : new Uint8Array())); + message.chainId !== undefined && (obj.chainId = message.chainId); + message.accountNumber !== undefined && (obj.accountNumber = (message.accountNumber || BigInt(0)).toString()); + return obj; + }, + fromPartial(object: DeepPartial): SignDoc { + const message = createBaseSignDoc(); + message.bodyBytes = object.bodyBytes ?? new Uint8Array(); + message.authInfoBytes = object.authInfoBytes ?? new Uint8Array(); + message.chainId = object.chainId ?? ""; + if (object.accountNumber !== undefined && object.accountNumber !== null) { + message.accountNumber = BigInt(object.accountNumber.toString()); + } + return message; + }, + fromSDK(object: SignDocSDKType): SignDoc { + return { + bodyBytes: object?.body_bytes, + authInfoBytes: object?.auth_info_bytes, + chainId: object?.chain_id, + accountNumber: object?.account_number + }; + }, + fromSDKJSON(object: any): SignDocSDKType { + return { + body_bytes: isSet(object.body_bytes) ? bytesFromBase64(object.body_bytes) : new Uint8Array(), + auth_info_bytes: isSet(object.auth_info_bytes) ? bytesFromBase64(object.auth_info_bytes) : new Uint8Array(), + chain_id: isSet(object.chain_id) ? String(object.chain_id) : "", + account_number: isSet(object.account_number) ? BigInt(object.account_number.toString()) : BigInt(0) + }; + }, + toSDK(message: SignDoc): SignDocSDKType { + const obj: any = {}; + obj.body_bytes = message.bodyBytes; + obj.auth_info_bytes = message.authInfoBytes; + obj.chain_id = message.chainId; + obj.account_number = message.accountNumber; + return obj; + }, + fromAmino(object: SignDocAmino): SignDoc { + const message = createBaseSignDoc(); + if (object.body_bytes !== undefined && object.body_bytes !== null) { + message.bodyBytes = bytesFromBase64(object.body_bytes); + } + if (object.auth_info_bytes !== undefined && object.auth_info_bytes !== null) { + message.authInfoBytes = bytesFromBase64(object.auth_info_bytes); + } + if (object.chain_id !== undefined && object.chain_id !== null) { + message.chainId = object.chain_id; + } + if (object.account_number !== undefined && object.account_number !== null) { + message.accountNumber = BigInt(object.account_number); + } + return message; + }, + toAmino(message: SignDoc): SignDocAmino { + const obj: any = {}; + obj.body_bytes = message.bodyBytes ? base64FromBytes(message.bodyBytes) : undefined; + obj.auth_info_bytes = message.authInfoBytes ? base64FromBytes(message.authInfoBytes) : undefined; + obj.chain_id = message.chainId === "" ? undefined : message.chainId; + obj.account_number = message.accountNumber !== BigInt(0) ? message.accountNumber?.toString() : undefined; + return obj; + }, + fromAminoMsg(object: SignDocAminoMsg): SignDoc { + return SignDoc.fromAmino(object.value); + }, + toAminoMsg(message: SignDoc): SignDocAminoMsg { + return { + type: "cosmos-sdk/SignDoc", + value: SignDoc.toAmino(message) + }; + }, + fromProtoMsg(message: SignDocProtoMsg): SignDoc { + return SignDoc.decode(message.value); + }, + toProto(message: SignDoc): Uint8Array { + return SignDoc.encode(message).finish(); + }, + toProtoMsg(message: SignDoc): SignDocProtoMsg { + return { + typeUrl: "/cosmos.tx.v1beta1.SignDoc", + value: SignDoc.encode(message).finish() + }; + } +}; +function createBaseSignDocDirectAux(): SignDocDirectAux { + return { + bodyBytes: new Uint8Array(), + publicKey: undefined, + chainId: "", + accountNumber: BigInt(0), + sequence: BigInt(0), + tip: undefined + }; +} +export const SignDocDirectAux = { + typeUrl: "/cosmos.tx.v1beta1.SignDocDirectAux", + encode(message: SignDocDirectAux, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.bodyBytes.length !== 0) { + writer.uint32(10).bytes(message.bodyBytes); + } + if (message.publicKey !== undefined) { + Any.encode(message.publicKey, writer.uint32(18).fork()).ldelim(); + } + if (message.chainId !== undefined) { + writer.uint32(26).string(message.chainId); + } + if (message.accountNumber !== undefined) { + writer.uint32(32).uint64(message.accountNumber); + } + if (message.sequence !== undefined) { + writer.uint32(40).uint64(message.sequence); + } + if (message.tip !== undefined) { + Tip.encode(message.tip, writer.uint32(50).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): SignDocDirectAux { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseSignDocDirectAux(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.bodyBytes = reader.bytes(); + break; + case 2: + message.publicKey = Any.decode(reader, reader.uint32()); + break; + case 3: + message.chainId = reader.string(); + break; + case 4: + message.accountNumber = reader.uint64(); + break; + case 5: + message.sequence = reader.uint64(); + break; + case 6: + message.tip = Tip.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): SignDocDirectAux { + const obj = createBaseSignDocDirectAux(); + if (isSet(object.bodyBytes)) obj.bodyBytes = bytesFromBase64(object.bodyBytes); + if (isSet(object.publicKey)) obj.publicKey = Any.fromJSON(object.publicKey); + if (isSet(object.chainId)) obj.chainId = String(object.chainId); + if (isSet(object.accountNumber)) obj.accountNumber = BigInt(object.accountNumber.toString()); + if (isSet(object.sequence)) obj.sequence = BigInt(object.sequence.toString()); + if (isSet(object.tip)) obj.tip = Tip.fromJSON(object.tip); + return obj; + }, + toJSON(message: SignDocDirectAux): JsonSafe { + const obj: any = {}; + message.bodyBytes !== undefined && (obj.bodyBytes = base64FromBytes(message.bodyBytes !== undefined ? message.bodyBytes : new Uint8Array())); + message.publicKey !== undefined && (obj.publicKey = message.publicKey ? Any.toJSON(message.publicKey) : undefined); + message.chainId !== undefined && (obj.chainId = message.chainId); + message.accountNumber !== undefined && (obj.accountNumber = (message.accountNumber || BigInt(0)).toString()); + message.sequence !== undefined && (obj.sequence = (message.sequence || BigInt(0)).toString()); + message.tip !== undefined && (obj.tip = message.tip ? Tip.toJSON(message.tip) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): SignDocDirectAux { + const message = createBaseSignDocDirectAux(); + message.bodyBytes = object.bodyBytes ?? new Uint8Array(); + if (object.publicKey !== undefined && object.publicKey !== null) { + message.publicKey = Any.fromPartial(object.publicKey); + } + message.chainId = object.chainId ?? ""; + if (object.accountNumber !== undefined && object.accountNumber !== null) { + message.accountNumber = BigInt(object.accountNumber.toString()); + } + if (object.sequence !== undefined && object.sequence !== null) { + message.sequence = BigInt(object.sequence.toString()); + } + if (object.tip !== undefined && object.tip !== null) { + message.tip = Tip.fromPartial(object.tip); + } + return message; + }, + fromSDK(object: SignDocDirectAuxSDKType): SignDocDirectAux { + return { + bodyBytes: object?.body_bytes, + publicKey: object.public_key ? Any.fromSDK(object.public_key) : undefined, + chainId: object?.chain_id, + accountNumber: object?.account_number, + sequence: object?.sequence, + tip: object.tip ? Tip.fromSDK(object.tip) : undefined + }; + }, + fromSDKJSON(object: any): SignDocDirectAuxSDKType { + return { + body_bytes: isSet(object.body_bytes) ? bytesFromBase64(object.body_bytes) : new Uint8Array(), + public_key: isSet(object.public_key) ? Any.fromSDKJSON(object.public_key) : undefined, + chain_id: isSet(object.chain_id) ? String(object.chain_id) : "", + account_number: isSet(object.account_number) ? BigInt(object.account_number.toString()) : BigInt(0), + sequence: isSet(object.sequence) ? BigInt(object.sequence.toString()) : BigInt(0), + tip: isSet(object.tip) ? Tip.fromSDKJSON(object.tip) : undefined + }; + }, + toSDK(message: SignDocDirectAux): SignDocDirectAuxSDKType { + const obj: any = {}; + obj.body_bytes = message.bodyBytes; + message.publicKey !== undefined && (obj.public_key = message.publicKey ? Any.toSDK(message.publicKey) : undefined); + obj.chain_id = message.chainId; + obj.account_number = message.accountNumber; + obj.sequence = message.sequence; + message.tip !== undefined && (obj.tip = message.tip ? Tip.toSDK(message.tip) : undefined); + return obj; + }, + fromAmino(object: SignDocDirectAuxAmino): SignDocDirectAux { + const message = createBaseSignDocDirectAux(); + if (object.body_bytes !== undefined && object.body_bytes !== null) { + message.bodyBytes = bytesFromBase64(object.body_bytes); + } + if (object.public_key !== undefined && object.public_key !== null) { + message.publicKey = Any.fromAmino(object.public_key); + } + if (object.chain_id !== undefined && object.chain_id !== null) { + message.chainId = object.chain_id; + } + if (object.account_number !== undefined && object.account_number !== null) { + message.accountNumber = BigInt(object.account_number); + } + if (object.sequence !== undefined && object.sequence !== null) { + message.sequence = BigInt(object.sequence); + } + if (object.tip !== undefined && object.tip !== null) { + message.tip = Tip.fromAmino(object.tip); + } + return message; + }, + toAmino(message: SignDocDirectAux): SignDocDirectAuxAmino { + const obj: any = {}; + obj.body_bytes = message.bodyBytes ? base64FromBytes(message.bodyBytes) : undefined; + obj.public_key = message.publicKey ? Any.toAmino(message.publicKey) : undefined; + obj.chain_id = message.chainId === "" ? undefined : message.chainId; + obj.account_number = message.accountNumber !== BigInt(0) ? message.accountNumber?.toString() : undefined; + obj.sequence = message.sequence !== BigInt(0) ? message.sequence?.toString() : undefined; + obj.tip = message.tip ? Tip.toAmino(message.tip) : undefined; + return obj; + }, + fromAminoMsg(object: SignDocDirectAuxAminoMsg): SignDocDirectAux { + return SignDocDirectAux.fromAmino(object.value); + }, + toAminoMsg(message: SignDocDirectAux): SignDocDirectAuxAminoMsg { + return { + type: "cosmos-sdk/SignDocDirectAux", + value: SignDocDirectAux.toAmino(message) + }; + }, + fromProtoMsg(message: SignDocDirectAuxProtoMsg): SignDocDirectAux { + return SignDocDirectAux.decode(message.value); + }, + toProto(message: SignDocDirectAux): Uint8Array { + return SignDocDirectAux.encode(message).finish(); + }, + toProtoMsg(message: SignDocDirectAux): SignDocDirectAuxProtoMsg { + return { + typeUrl: "/cosmos.tx.v1beta1.SignDocDirectAux", + value: SignDocDirectAux.encode(message).finish() + }; + } +}; +function createBaseTxBody(): TxBody { + return { + messages: [], + memo: "", + timeoutHeight: BigInt(0), + extensionOptions: [], + nonCriticalExtensionOptions: [] + }; +} +export const TxBody = { + typeUrl: "/cosmos.tx.v1beta1.TxBody", + encode(message: TxBody, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.messages) { + Any.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.memo !== undefined) { + writer.uint32(18).string(message.memo); + } + if (message.timeoutHeight !== undefined) { + writer.uint32(24).uint64(message.timeoutHeight); + } + for (const v of message.extensionOptions) { + Any.encode(v!, writer.uint32(8186).fork()).ldelim(); + } + for (const v of message.nonCriticalExtensionOptions) { + Any.encode(v!, writer.uint32(16378).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): TxBody { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseTxBody(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.messages.push(Any.decode(reader, reader.uint32())); + break; + case 2: + message.memo = reader.string(); + break; + case 3: + message.timeoutHeight = reader.uint64(); + break; + case 1023: + message.extensionOptions.push(Any.decode(reader, reader.uint32())); + break; + case 2047: + message.nonCriticalExtensionOptions.push(Any.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): TxBody { + const obj = createBaseTxBody(); + if (Array.isArray(object?.messages)) obj.messages = object.messages.map((e: any) => Any.fromJSON(e)); + if (isSet(object.memo)) obj.memo = String(object.memo); + if (isSet(object.timeoutHeight)) obj.timeoutHeight = BigInt(object.timeoutHeight.toString()); + if (Array.isArray(object?.extensionOptions)) obj.extensionOptions = object.extensionOptions.map((e: any) => Any.fromJSON(e)); + if (Array.isArray(object?.nonCriticalExtensionOptions)) obj.nonCriticalExtensionOptions = object.nonCriticalExtensionOptions.map((e: any) => Any.fromJSON(e)); + return obj; + }, + toJSON(message: TxBody): JsonSafe { + const obj: any = {}; + if (message.messages) { + obj.messages = message.messages.map(e => e ? Any.toJSON(e) : undefined); + } else { + obj.messages = []; + } + message.memo !== undefined && (obj.memo = message.memo); + message.timeoutHeight !== undefined && (obj.timeoutHeight = (message.timeoutHeight || BigInt(0)).toString()); + if (message.extensionOptions) { + obj.extensionOptions = message.extensionOptions.map(e => e ? Any.toJSON(e) : undefined); + } else { + obj.extensionOptions = []; + } + if (message.nonCriticalExtensionOptions) { + obj.nonCriticalExtensionOptions = message.nonCriticalExtensionOptions.map(e => e ? Any.toJSON(e) : undefined); + } else { + obj.nonCriticalExtensionOptions = []; + } + return obj; + }, + fromPartial(object: DeepPartial): TxBody { + const message = createBaseTxBody(); + message.messages = object.messages?.map(e => Any.fromPartial(e)) || []; + message.memo = object.memo ?? ""; + if (object.timeoutHeight !== undefined && object.timeoutHeight !== null) { + message.timeoutHeight = BigInt(object.timeoutHeight.toString()); + } + message.extensionOptions = object.extensionOptions?.map(e => Any.fromPartial(e)) || []; + message.nonCriticalExtensionOptions = object.nonCriticalExtensionOptions?.map(e => Any.fromPartial(e)) || []; + return message; + }, + fromSDK(object: TxBodySDKType): TxBody { + return { + messages: Array.isArray(object?.messages) ? object.messages.map((e: any) => Any.fromSDK(e)) : [], + memo: object?.memo, + timeoutHeight: object?.timeout_height, + extensionOptions: Array.isArray(object?.extension_options) ? object.extension_options.map((e: any) => Any.fromSDK(e)) : [], + nonCriticalExtensionOptions: Array.isArray(object?.non_critical_extension_options) ? object.non_critical_extension_options.map((e: any) => Any.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): TxBodySDKType { + return { + messages: Array.isArray(object?.messages) ? object.messages.map((e: any) => Any.fromSDKJSON(e)) : [], + memo: isSet(object.memo) ? String(object.memo) : "", + timeout_height: isSet(object.timeout_height) ? BigInt(object.timeout_height.toString()) : BigInt(0), + extension_options: Array.isArray(object?.extension_options) ? object.extension_options.map((e: any) => Any.fromSDKJSON(e)) : [], + non_critical_extension_options: Array.isArray(object?.non_critical_extension_options) ? object.non_critical_extension_options.map((e: any) => Any.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: TxBody): TxBodySDKType { + const obj: any = {}; + if (message.messages) { + obj.messages = message.messages.map(e => e ? Any.toSDK(e) : undefined); + } else { + obj.messages = []; + } + obj.memo = message.memo; + obj.timeout_height = message.timeoutHeight; + if (message.extensionOptions) { + obj.extension_options = message.extensionOptions.map(e => e ? Any.toSDK(e) : undefined); + } else { + obj.extension_options = []; + } + if (message.nonCriticalExtensionOptions) { + obj.non_critical_extension_options = message.nonCriticalExtensionOptions.map(e => e ? Any.toSDK(e) : undefined); + } else { + obj.non_critical_extension_options = []; + } + return obj; + }, + fromAmino(object: TxBodyAmino): TxBody { + const message = createBaseTxBody(); + message.messages = object.messages?.map(e => Any.fromAmino(e)) || []; + if (object.memo !== undefined && object.memo !== null) { + message.memo = object.memo; + } + if (object.timeout_height !== undefined && object.timeout_height !== null) { + message.timeoutHeight = BigInt(object.timeout_height); + } + message.extensionOptions = object.extension_options?.map(e => Any.fromAmino(e)) || []; + message.nonCriticalExtensionOptions = object.non_critical_extension_options?.map(e => Any.fromAmino(e)) || []; + return message; + }, + toAmino(message: TxBody): TxBodyAmino { + const obj: any = {}; + if (message.messages) { + obj.messages = message.messages.map(e => e ? Any.toAmino(e) : undefined); + } else { + obj.messages = message.messages; + } + obj.memo = message.memo === "" ? undefined : message.memo; + obj.timeout_height = message.timeoutHeight !== BigInt(0) ? message.timeoutHeight?.toString() : undefined; + if (message.extensionOptions) { + obj.extension_options = message.extensionOptions.map(e => e ? Any.toAmino(e) : undefined); + } else { + obj.extension_options = message.extensionOptions; + } + if (message.nonCriticalExtensionOptions) { + obj.non_critical_extension_options = message.nonCriticalExtensionOptions.map(e => e ? Any.toAmino(e) : undefined); + } else { + obj.non_critical_extension_options = message.nonCriticalExtensionOptions; + } + return obj; + }, + fromAminoMsg(object: TxBodyAminoMsg): TxBody { + return TxBody.fromAmino(object.value); + }, + toAminoMsg(message: TxBody): TxBodyAminoMsg { + return { + type: "cosmos-sdk/TxBody", + value: TxBody.toAmino(message) + }; + }, + fromProtoMsg(message: TxBodyProtoMsg): TxBody { + return TxBody.decode(message.value); + }, + toProto(message: TxBody): Uint8Array { + return TxBody.encode(message).finish(); + }, + toProtoMsg(message: TxBody): TxBodyProtoMsg { + return { + typeUrl: "/cosmos.tx.v1beta1.TxBody", + value: TxBody.encode(message).finish() + }; + } +}; +function createBaseAuthInfo(): AuthInfo { + return { + signerInfos: [], + fee: undefined, + tip: undefined + }; +} +export const AuthInfo = { + typeUrl: "/cosmos.tx.v1beta1.AuthInfo", + encode(message: AuthInfo, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.signerInfos) { + SignerInfo.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.fee !== undefined) { + Fee.encode(message.fee, writer.uint32(18).fork()).ldelim(); + } + if (message.tip !== undefined) { + Tip.encode(message.tip, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): AuthInfo { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseAuthInfo(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.signerInfos.push(SignerInfo.decode(reader, reader.uint32())); + break; + case 2: + message.fee = Fee.decode(reader, reader.uint32()); + break; + case 3: + message.tip = Tip.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): AuthInfo { + const obj = createBaseAuthInfo(); + if (Array.isArray(object?.signerInfos)) obj.signerInfos = object.signerInfos.map((e: any) => SignerInfo.fromJSON(e)); + if (isSet(object.fee)) obj.fee = Fee.fromJSON(object.fee); + if (isSet(object.tip)) obj.tip = Tip.fromJSON(object.tip); + return obj; + }, + toJSON(message: AuthInfo): JsonSafe { + const obj: any = {}; + if (message.signerInfos) { + obj.signerInfos = message.signerInfos.map(e => e ? SignerInfo.toJSON(e) : undefined); + } else { + obj.signerInfos = []; + } + message.fee !== undefined && (obj.fee = message.fee ? Fee.toJSON(message.fee) : undefined); + message.tip !== undefined && (obj.tip = message.tip ? Tip.toJSON(message.tip) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): AuthInfo { + const message = createBaseAuthInfo(); + message.signerInfos = object.signerInfos?.map(e => SignerInfo.fromPartial(e)) || []; + if (object.fee !== undefined && object.fee !== null) { + message.fee = Fee.fromPartial(object.fee); + } + if (object.tip !== undefined && object.tip !== null) { + message.tip = Tip.fromPartial(object.tip); + } + return message; + }, + fromSDK(object: AuthInfoSDKType): AuthInfo { + return { + signerInfos: Array.isArray(object?.signer_infos) ? object.signer_infos.map((e: any) => SignerInfo.fromSDK(e)) : [], + fee: object.fee ? Fee.fromSDK(object.fee) : undefined, + tip: object.tip ? Tip.fromSDK(object.tip) : undefined + }; + }, + fromSDKJSON(object: any): AuthInfoSDKType { + return { + signer_infos: Array.isArray(object?.signer_infos) ? object.signer_infos.map((e: any) => SignerInfo.fromSDKJSON(e)) : [], + fee: isSet(object.fee) ? Fee.fromSDKJSON(object.fee) : undefined, + tip: isSet(object.tip) ? Tip.fromSDKJSON(object.tip) : undefined + }; + }, + toSDK(message: AuthInfo): AuthInfoSDKType { + const obj: any = {}; + if (message.signerInfos) { + obj.signer_infos = message.signerInfos.map(e => e ? SignerInfo.toSDK(e) : undefined); + } else { + obj.signer_infos = []; + } + message.fee !== undefined && (obj.fee = message.fee ? Fee.toSDK(message.fee) : undefined); + message.tip !== undefined && (obj.tip = message.tip ? Tip.toSDK(message.tip) : undefined); + return obj; + }, + fromAmino(object: AuthInfoAmino): AuthInfo { + const message = createBaseAuthInfo(); + message.signerInfos = object.signer_infos?.map(e => SignerInfo.fromAmino(e)) || []; + if (object.fee !== undefined && object.fee !== null) { + message.fee = Fee.fromAmino(object.fee); + } + if (object.tip !== undefined && object.tip !== null) { + message.tip = Tip.fromAmino(object.tip); + } + return message; + }, + toAmino(message: AuthInfo): AuthInfoAmino { + const obj: any = {}; + if (message.signerInfos) { + obj.signer_infos = message.signerInfos.map(e => e ? SignerInfo.toAmino(e) : undefined); + } else { + obj.signer_infos = message.signerInfos; + } + obj.fee = message.fee ? Fee.toAmino(message.fee) : undefined; + obj.tip = message.tip ? Tip.toAmino(message.tip) : undefined; + return obj; + }, + fromAminoMsg(object: AuthInfoAminoMsg): AuthInfo { + return AuthInfo.fromAmino(object.value); + }, + toAminoMsg(message: AuthInfo): AuthInfoAminoMsg { + return { + type: "cosmos-sdk/AuthInfo", + value: AuthInfo.toAmino(message) + }; + }, + fromProtoMsg(message: AuthInfoProtoMsg): AuthInfo { + return AuthInfo.decode(message.value); + }, + toProto(message: AuthInfo): Uint8Array { + return AuthInfo.encode(message).finish(); + }, + toProtoMsg(message: AuthInfo): AuthInfoProtoMsg { + return { + typeUrl: "/cosmos.tx.v1beta1.AuthInfo", + value: AuthInfo.encode(message).finish() + }; + } +}; +function createBaseSignerInfo(): SignerInfo { + return { + publicKey: undefined, + modeInfo: undefined, + sequence: BigInt(0) + }; +} +export const SignerInfo = { + typeUrl: "/cosmos.tx.v1beta1.SignerInfo", + encode(message: SignerInfo, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.publicKey !== undefined) { + Any.encode(message.publicKey, writer.uint32(10).fork()).ldelim(); + } + if (message.modeInfo !== undefined) { + ModeInfo.encode(message.modeInfo, writer.uint32(18).fork()).ldelim(); + } + if (message.sequence !== undefined) { + writer.uint32(24).uint64(message.sequence); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): SignerInfo { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseSignerInfo(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.publicKey = Any.decode(reader, reader.uint32()); + break; + case 2: + message.modeInfo = ModeInfo.decode(reader, reader.uint32()); + break; + case 3: + message.sequence = reader.uint64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): SignerInfo { + const obj = createBaseSignerInfo(); + if (isSet(object.publicKey)) obj.publicKey = Any.fromJSON(object.publicKey); + if (isSet(object.modeInfo)) obj.modeInfo = ModeInfo.fromJSON(object.modeInfo); + if (isSet(object.sequence)) obj.sequence = BigInt(object.sequence.toString()); + return obj; + }, + toJSON(message: SignerInfo): JsonSafe { + const obj: any = {}; + message.publicKey !== undefined && (obj.publicKey = message.publicKey ? Any.toJSON(message.publicKey) : undefined); + message.modeInfo !== undefined && (obj.modeInfo = message.modeInfo ? ModeInfo.toJSON(message.modeInfo) : undefined); + message.sequence !== undefined && (obj.sequence = (message.sequence || BigInt(0)).toString()); + return obj; + }, + fromPartial(object: DeepPartial): SignerInfo { + const message = createBaseSignerInfo(); + if (object.publicKey !== undefined && object.publicKey !== null) { + message.publicKey = Any.fromPartial(object.publicKey); + } + if (object.modeInfo !== undefined && object.modeInfo !== null) { + message.modeInfo = ModeInfo.fromPartial(object.modeInfo); + } + if (object.sequence !== undefined && object.sequence !== null) { + message.sequence = BigInt(object.sequence.toString()); + } + return message; + }, + fromSDK(object: SignerInfoSDKType): SignerInfo { + return { + publicKey: object.public_key ? Any.fromSDK(object.public_key) : undefined, + modeInfo: object.mode_info ? ModeInfo.fromSDK(object.mode_info) : undefined, + sequence: object?.sequence + }; + }, + fromSDKJSON(object: any): SignerInfoSDKType { + return { + public_key: isSet(object.public_key) ? Any.fromSDKJSON(object.public_key) : undefined, + mode_info: isSet(object.mode_info) ? ModeInfo.fromSDKJSON(object.mode_info) : undefined, + sequence: isSet(object.sequence) ? BigInt(object.sequence.toString()) : BigInt(0) + }; + }, + toSDK(message: SignerInfo): SignerInfoSDKType { + const obj: any = {}; + message.publicKey !== undefined && (obj.public_key = message.publicKey ? Any.toSDK(message.publicKey) : undefined); + message.modeInfo !== undefined && (obj.mode_info = message.modeInfo ? ModeInfo.toSDK(message.modeInfo) : undefined); + obj.sequence = message.sequence; + return obj; + }, + fromAmino(object: SignerInfoAmino): SignerInfo { + const message = createBaseSignerInfo(); + if (object.public_key !== undefined && object.public_key !== null) { + message.publicKey = Any.fromAmino(object.public_key); + } + if (object.mode_info !== undefined && object.mode_info !== null) { + message.modeInfo = ModeInfo.fromAmino(object.mode_info); + } + if (object.sequence !== undefined && object.sequence !== null) { + message.sequence = BigInt(object.sequence); + } + return message; + }, + toAmino(message: SignerInfo): SignerInfoAmino { + const obj: any = {}; + obj.public_key = message.publicKey ? Any.toAmino(message.publicKey) : undefined; + obj.mode_info = message.modeInfo ? ModeInfo.toAmino(message.modeInfo) : undefined; + obj.sequence = message.sequence !== BigInt(0) ? message.sequence?.toString() : undefined; + return obj; + }, + fromAminoMsg(object: SignerInfoAminoMsg): SignerInfo { + return SignerInfo.fromAmino(object.value); + }, + toAminoMsg(message: SignerInfo): SignerInfoAminoMsg { + return { + type: "cosmos-sdk/SignerInfo", + value: SignerInfo.toAmino(message) + }; + }, + fromProtoMsg(message: SignerInfoProtoMsg): SignerInfo { + return SignerInfo.decode(message.value); + }, + toProto(message: SignerInfo): Uint8Array { + return SignerInfo.encode(message).finish(); + }, + toProtoMsg(message: SignerInfo): SignerInfoProtoMsg { + return { + typeUrl: "/cosmos.tx.v1beta1.SignerInfo", + value: SignerInfo.encode(message).finish() + }; + } +}; +function createBaseModeInfo(): ModeInfo { + return { + single: undefined, + multi: undefined + }; +} +export const ModeInfo = { + typeUrl: "/cosmos.tx.v1beta1.ModeInfo", + encode(message: ModeInfo, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.single !== undefined) { + ModeInfo_Single.encode(message.single, writer.uint32(10).fork()).ldelim(); + } + if (message.multi !== undefined) { + ModeInfo_Multi.encode(message.multi, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ModeInfo { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseModeInfo(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.single = ModeInfo_Single.decode(reader, reader.uint32()); + break; + case 2: + message.multi = ModeInfo_Multi.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ModeInfo { + const obj = createBaseModeInfo(); + if (isSet(object.single)) obj.single = ModeInfo_Single.fromJSON(object.single); + if (isSet(object.multi)) obj.multi = ModeInfo_Multi.fromJSON(object.multi); + return obj; + }, + toJSON(message: ModeInfo): JsonSafe { + const obj: any = {}; + message.single !== undefined && (obj.single = message.single ? ModeInfo_Single.toJSON(message.single) : undefined); + message.multi !== undefined && (obj.multi = message.multi ? ModeInfo_Multi.toJSON(message.multi) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): ModeInfo { + const message = createBaseModeInfo(); + if (object.single !== undefined && object.single !== null) { + message.single = ModeInfo_Single.fromPartial(object.single); + } + if (object.multi !== undefined && object.multi !== null) { + message.multi = ModeInfo_Multi.fromPartial(object.multi); + } + return message; + }, + fromSDK(object: ModeInfoSDKType): ModeInfo { + return { + single: object.single ? ModeInfo_Single.fromSDK(object.single) : undefined, + multi: object.multi ? ModeInfo_Multi.fromSDK(object.multi) : undefined + }; + }, + fromSDKJSON(object: any): ModeInfoSDKType { + return { + single: isSet(object.single) ? ModeInfo_Single.fromSDKJSON(object.single) : undefined, + multi: isSet(object.multi) ? ModeInfo_Multi.fromSDKJSON(object.multi) : undefined + }; + }, + toSDK(message: ModeInfo): ModeInfoSDKType { + const obj: any = {}; + message.single !== undefined && (obj.single = message.single ? ModeInfo_Single.toSDK(message.single) : undefined); + message.multi !== undefined && (obj.multi = message.multi ? ModeInfo_Multi.toSDK(message.multi) : undefined); + return obj; + }, + fromAmino(object: ModeInfoAmino): ModeInfo { + const message = createBaseModeInfo(); + if (object.single !== undefined && object.single !== null) { + message.single = ModeInfo_Single.fromAmino(object.single); + } + if (object.multi !== undefined && object.multi !== null) { + message.multi = ModeInfo_Multi.fromAmino(object.multi); + } + return message; + }, + toAmino(message: ModeInfo): ModeInfoAmino { + const obj: any = {}; + obj.single = message.single ? ModeInfo_Single.toAmino(message.single) : undefined; + obj.multi = message.multi ? ModeInfo_Multi.toAmino(message.multi) : undefined; + return obj; + }, + fromAminoMsg(object: ModeInfoAminoMsg): ModeInfo { + return ModeInfo.fromAmino(object.value); + }, + toAminoMsg(message: ModeInfo): ModeInfoAminoMsg { + return { + type: "cosmos-sdk/ModeInfo", + value: ModeInfo.toAmino(message) + }; + }, + fromProtoMsg(message: ModeInfoProtoMsg): ModeInfo { + return ModeInfo.decode(message.value); + }, + toProto(message: ModeInfo): Uint8Array { + return ModeInfo.encode(message).finish(); + }, + toProtoMsg(message: ModeInfo): ModeInfoProtoMsg { + return { + typeUrl: "/cosmos.tx.v1beta1.ModeInfo", + value: ModeInfo.encode(message).finish() + }; + } +}; +function createBaseModeInfo_Single(): ModeInfo_Single { + return { + mode: 0 + }; +} +export const ModeInfo_Single = { + typeUrl: "/cosmos.tx.v1beta1.Single", + encode(message: ModeInfo_Single, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.mode !== 0) { + writer.uint32(8).int32(message.mode); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ModeInfo_Single { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseModeInfo_Single(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.mode = (reader.int32() as any); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ModeInfo_Single { + const obj = createBaseModeInfo_Single(); + if (isSet(object.mode)) obj.mode = signModeFromJSON(object.mode); + return obj; + }, + toJSON(message: ModeInfo_Single): JsonSafe { + const obj: any = {}; + message.mode !== undefined && (obj.mode = signModeToJSON(message.mode)); + return obj; + }, + fromPartial(object: DeepPartial): ModeInfo_Single { + const message = createBaseModeInfo_Single(); + message.mode = object.mode ?? 0; + return message; + }, + fromSDK(object: ModeInfo_SingleSDKType): ModeInfo_Single { + return { + mode: isSet(object.mode) ? signModeFromJSON(object.mode) : -1 + }; + }, + fromSDKJSON(object: any): ModeInfo_SingleSDKType { + return { + mode: isSet(object.mode) ? signModeFromJSON(object.mode) : -1 + }; + }, + toSDK(message: ModeInfo_Single): ModeInfo_SingleSDKType { + const obj: any = {}; + message.mode !== undefined && (obj.mode = signModeToJSON(message.mode)); + return obj; + }, + fromAmino(object: ModeInfo_SingleAmino): ModeInfo_Single { + const message = createBaseModeInfo_Single(); + if (object.mode !== undefined && object.mode !== null) { + message.mode = object.mode; + } + return message; + }, + toAmino(message: ModeInfo_Single): ModeInfo_SingleAmino { + const obj: any = {}; + obj.mode = message.mode === 0 ? undefined : message.mode; + return obj; + }, + fromAminoMsg(object: ModeInfo_SingleAminoMsg): ModeInfo_Single { + return ModeInfo_Single.fromAmino(object.value); + }, + toAminoMsg(message: ModeInfo_Single): ModeInfo_SingleAminoMsg { + return { + type: "cosmos-sdk/Single", + value: ModeInfo_Single.toAmino(message) + }; + }, + fromProtoMsg(message: ModeInfo_SingleProtoMsg): ModeInfo_Single { + return ModeInfo_Single.decode(message.value); + }, + toProto(message: ModeInfo_Single): Uint8Array { + return ModeInfo_Single.encode(message).finish(); + }, + toProtoMsg(message: ModeInfo_Single): ModeInfo_SingleProtoMsg { + return { + typeUrl: "/cosmos.tx.v1beta1.Single", + value: ModeInfo_Single.encode(message).finish() + }; + } +}; +function createBaseModeInfo_Multi(): ModeInfo_Multi { + return { + bitarray: undefined, + modeInfos: [] + }; +} +export const ModeInfo_Multi = { + typeUrl: "/cosmos.tx.v1beta1.Multi", + encode(message: ModeInfo_Multi, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.bitarray !== undefined) { + CompactBitArray.encode(message.bitarray, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.modeInfos) { + ModeInfo.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ModeInfo_Multi { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseModeInfo_Multi(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.bitarray = CompactBitArray.decode(reader, reader.uint32()); + break; + case 2: + message.modeInfos.push(ModeInfo.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ModeInfo_Multi { + const obj = createBaseModeInfo_Multi(); + if (isSet(object.bitarray)) obj.bitarray = CompactBitArray.fromJSON(object.bitarray); + if (Array.isArray(object?.modeInfos)) obj.modeInfos = object.modeInfos.map((e: any) => ModeInfo.fromJSON(e)); + return obj; + }, + toJSON(message: ModeInfo_Multi): JsonSafe { + const obj: any = {}; + message.bitarray !== undefined && (obj.bitarray = message.bitarray ? CompactBitArray.toJSON(message.bitarray) : undefined); + if (message.modeInfos) { + obj.modeInfos = message.modeInfos.map(e => e ? ModeInfo.toJSON(e) : undefined); + } else { + obj.modeInfos = []; + } + return obj; + }, + fromPartial(object: DeepPartial): ModeInfo_Multi { + const message = createBaseModeInfo_Multi(); + if (object.bitarray !== undefined && object.bitarray !== null) { + message.bitarray = CompactBitArray.fromPartial(object.bitarray); + } + message.modeInfos = object.modeInfos?.map(e => ModeInfo.fromPartial(e)) || []; + return message; + }, + fromSDK(object: ModeInfo_MultiSDKType): ModeInfo_Multi { + return { + bitarray: object.bitarray ? CompactBitArray.fromSDK(object.bitarray) : undefined, + modeInfos: Array.isArray(object?.mode_infos) ? object.mode_infos.map((e: any) => ModeInfo.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): ModeInfo_MultiSDKType { + return { + bitarray: isSet(object.bitarray) ? CompactBitArray.fromSDKJSON(object.bitarray) : undefined, + mode_infos: Array.isArray(object?.mode_infos) ? object.mode_infos.map((e: any) => ModeInfo.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: ModeInfo_Multi): ModeInfo_MultiSDKType { + const obj: any = {}; + message.bitarray !== undefined && (obj.bitarray = message.bitarray ? CompactBitArray.toSDK(message.bitarray) : undefined); + if (message.modeInfos) { + obj.mode_infos = message.modeInfos.map(e => e ? ModeInfo.toSDK(e) : undefined); + } else { + obj.mode_infos = []; + } + return obj; + }, + fromAmino(object: ModeInfo_MultiAmino): ModeInfo_Multi { + const message = createBaseModeInfo_Multi(); + if (object.bitarray !== undefined && object.bitarray !== null) { + message.bitarray = CompactBitArray.fromAmino(object.bitarray); + } + message.modeInfos = object.mode_infos?.map(e => ModeInfo.fromAmino(e)) || []; + return message; + }, + toAmino(message: ModeInfo_Multi): ModeInfo_MultiAmino { + const obj: any = {}; + obj.bitarray = message.bitarray ? CompactBitArray.toAmino(message.bitarray) : undefined; + if (message.modeInfos) { + obj.mode_infos = message.modeInfos.map(e => e ? ModeInfo.toAmino(e) : undefined); + } else { + obj.mode_infos = message.modeInfos; + } + return obj; + }, + fromAminoMsg(object: ModeInfo_MultiAminoMsg): ModeInfo_Multi { + return ModeInfo_Multi.fromAmino(object.value); + }, + toAminoMsg(message: ModeInfo_Multi): ModeInfo_MultiAminoMsg { + return { + type: "cosmos-sdk/Multi", + value: ModeInfo_Multi.toAmino(message) + }; + }, + fromProtoMsg(message: ModeInfo_MultiProtoMsg): ModeInfo_Multi { + return ModeInfo_Multi.decode(message.value); + }, + toProto(message: ModeInfo_Multi): Uint8Array { + return ModeInfo_Multi.encode(message).finish(); + }, + toProtoMsg(message: ModeInfo_Multi): ModeInfo_MultiProtoMsg { + return { + typeUrl: "/cosmos.tx.v1beta1.Multi", + value: ModeInfo_Multi.encode(message).finish() + }; + } +}; +function createBaseFee(): Fee { + return { + amount: [], + gasLimit: BigInt(0), + payer: "", + granter: "" + }; +} +export const Fee = { + typeUrl: "/cosmos.tx.v1beta1.Fee", + encode(message: Fee, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.amount) { + Coin.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.gasLimit !== undefined) { + writer.uint32(16).uint64(message.gasLimit); + } + if (message.payer !== undefined) { + writer.uint32(26).string(message.payer); + } + if (message.granter !== undefined) { + writer.uint32(34).string(message.granter); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Fee { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseFee(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.amount.push(Coin.decode(reader, reader.uint32())); + break; + case 2: + message.gasLimit = reader.uint64(); + break; + case 3: + message.payer = reader.string(); + break; + case 4: + message.granter = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Fee { + const obj = createBaseFee(); + if (Array.isArray(object?.amount)) obj.amount = object.amount.map((e: any) => Coin.fromJSON(e)); + if (isSet(object.gasLimit)) obj.gasLimit = BigInt(object.gasLimit.toString()); + if (isSet(object.payer)) obj.payer = String(object.payer); + if (isSet(object.granter)) obj.granter = String(object.granter); + return obj; + }, + toJSON(message: Fee): JsonSafe { + const obj: any = {}; + if (message.amount) { + obj.amount = message.amount.map(e => e ? Coin.toJSON(e) : undefined); + } else { + obj.amount = []; + } + message.gasLimit !== undefined && (obj.gasLimit = (message.gasLimit || BigInt(0)).toString()); + message.payer !== undefined && (obj.payer = message.payer); + message.granter !== undefined && (obj.granter = message.granter); + return obj; + }, + fromPartial(object: DeepPartial): Fee { + const message = createBaseFee(); + message.amount = object.amount?.map(e => Coin.fromPartial(e)) || []; + if (object.gasLimit !== undefined && object.gasLimit !== null) { + message.gasLimit = BigInt(object.gasLimit.toString()); + } + message.payer = object.payer ?? ""; + message.granter = object.granter ?? ""; + return message; + }, + fromSDK(object: FeeSDKType): Fee { + return { + amount: Array.isArray(object?.amount) ? object.amount.map((e: any) => Coin.fromSDK(e)) : [], + gasLimit: object?.gas_limit, + payer: object?.payer, + granter: object?.granter + }; + }, + fromSDKJSON(object: any): FeeSDKType { + return { + amount: Array.isArray(object?.amount) ? object.amount.map((e: any) => Coin.fromSDKJSON(e)) : [], + gas_limit: isSet(object.gas_limit) ? BigInt(object.gas_limit.toString()) : BigInt(0), + payer: isSet(object.payer) ? String(object.payer) : "", + granter: isSet(object.granter) ? String(object.granter) : "" + }; + }, + toSDK(message: Fee): FeeSDKType { + const obj: any = {}; + if (message.amount) { + obj.amount = message.amount.map(e => e ? Coin.toSDK(e) : undefined); + } else { + obj.amount = []; + } + obj.gas_limit = message.gasLimit; + obj.payer = message.payer; + obj.granter = message.granter; + return obj; + }, + fromAmino(object: FeeAmino): Fee { + const message = createBaseFee(); + message.amount = object.amount?.map(e => Coin.fromAmino(e)) || []; + if (object.gas_limit !== undefined && object.gas_limit !== null) { + message.gasLimit = BigInt(object.gas_limit); + } + if (object.payer !== undefined && object.payer !== null) { + message.payer = object.payer; + } + if (object.granter !== undefined && object.granter !== null) { + message.granter = object.granter; + } + return message; + }, + toAmino(message: Fee): FeeAmino { + const obj: any = {}; + if (message.amount) { + obj.amount = message.amount.map(e => e ? Coin.toAmino(e) : undefined); + } else { + obj.amount = message.amount; + } + obj.gas_limit = message.gasLimit !== BigInt(0) ? message.gasLimit?.toString() : undefined; + obj.payer = message.payer === "" ? undefined : message.payer; + obj.granter = message.granter === "" ? undefined : message.granter; + return obj; + }, + fromAminoMsg(object: FeeAminoMsg): Fee { + return Fee.fromAmino(object.value); + }, + toAminoMsg(message: Fee): FeeAminoMsg { + return { + type: "cosmos-sdk/Fee", + value: Fee.toAmino(message) + }; + }, + fromProtoMsg(message: FeeProtoMsg): Fee { + return Fee.decode(message.value); + }, + toProto(message: Fee): Uint8Array { + return Fee.encode(message).finish(); + }, + toProtoMsg(message: Fee): FeeProtoMsg { + return { + typeUrl: "/cosmos.tx.v1beta1.Fee", + value: Fee.encode(message).finish() + }; + } +}; +function createBaseTip(): Tip { + return { + amount: [], + tipper: "" + }; +} +export const Tip = { + typeUrl: "/cosmos.tx.v1beta1.Tip", + encode(message: Tip, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.amount) { + Coin.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.tipper !== undefined) { + writer.uint32(18).string(message.tipper); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Tip { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseTip(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.amount.push(Coin.decode(reader, reader.uint32())); + break; + case 2: + message.tipper = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Tip { + const obj = createBaseTip(); + if (Array.isArray(object?.amount)) obj.amount = object.amount.map((e: any) => Coin.fromJSON(e)); + if (isSet(object.tipper)) obj.tipper = String(object.tipper); + return obj; + }, + toJSON(message: Tip): JsonSafe { + const obj: any = {}; + if (message.amount) { + obj.amount = message.amount.map(e => e ? Coin.toJSON(e) : undefined); + } else { + obj.amount = []; + } + message.tipper !== undefined && (obj.tipper = message.tipper); + return obj; + }, + fromPartial(object: DeepPartial): Tip { + const message = createBaseTip(); + message.amount = object.amount?.map(e => Coin.fromPartial(e)) || []; + message.tipper = object.tipper ?? ""; + return message; + }, + fromSDK(object: TipSDKType): Tip { + return { + amount: Array.isArray(object?.amount) ? object.amount.map((e: any) => Coin.fromSDK(e)) : [], + tipper: object?.tipper + }; + }, + fromSDKJSON(object: any): TipSDKType { + return { + amount: Array.isArray(object?.amount) ? object.amount.map((e: any) => Coin.fromSDKJSON(e)) : [], + tipper: isSet(object.tipper) ? String(object.tipper) : "" + }; + }, + toSDK(message: Tip): TipSDKType { + const obj: any = {}; + if (message.amount) { + obj.amount = message.amount.map(e => e ? Coin.toSDK(e) : undefined); + } else { + obj.amount = []; + } + obj.tipper = message.tipper; + return obj; + }, + fromAmino(object: TipAmino): Tip { + const message = createBaseTip(); + message.amount = object.amount?.map(e => Coin.fromAmino(e)) || []; + if (object.tipper !== undefined && object.tipper !== null) { + message.tipper = object.tipper; + } + return message; + }, + toAmino(message: Tip): TipAmino { + const obj: any = {}; + if (message.amount) { + obj.amount = message.amount.map(e => e ? Coin.toAmino(e) : undefined); + } else { + obj.amount = message.amount; + } + obj.tipper = message.tipper === "" ? undefined : message.tipper; + return obj; + }, + fromAminoMsg(object: TipAminoMsg): Tip { + return Tip.fromAmino(object.value); + }, + toAminoMsg(message: Tip): TipAminoMsg { + return { + type: "cosmos-sdk/Tip", + value: Tip.toAmino(message) + }; + }, + fromProtoMsg(message: TipProtoMsg): Tip { + return Tip.decode(message.value); + }, + toProto(message: Tip): Uint8Array { + return Tip.encode(message).finish(); + }, + toProtoMsg(message: Tip): TipProtoMsg { + return { + typeUrl: "/cosmos.tx.v1beta1.Tip", + value: Tip.encode(message).finish() + }; + } +}; +function createBaseAuxSignerData(): AuxSignerData { + return { + address: "", + signDoc: undefined, + mode: 0, + sig: new Uint8Array() + }; +} +export const AuxSignerData = { + typeUrl: "/cosmos.tx.v1beta1.AuxSignerData", + encode(message: AuxSignerData, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.address !== undefined) { + writer.uint32(10).string(message.address); + } + if (message.signDoc !== undefined) { + SignDocDirectAux.encode(message.signDoc, writer.uint32(18).fork()).ldelim(); + } + if (message.mode !== 0) { + writer.uint32(24).int32(message.mode); + } + if (message.sig.length !== 0) { + writer.uint32(34).bytes(message.sig); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): AuxSignerData { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseAuxSignerData(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.string(); + break; + case 2: + message.signDoc = SignDocDirectAux.decode(reader, reader.uint32()); + break; + case 3: + message.mode = (reader.int32() as any); + break; + case 4: + message.sig = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): AuxSignerData { + const obj = createBaseAuxSignerData(); + if (isSet(object.address)) obj.address = String(object.address); + if (isSet(object.signDoc)) obj.signDoc = SignDocDirectAux.fromJSON(object.signDoc); + if (isSet(object.mode)) obj.mode = signModeFromJSON(object.mode); + if (isSet(object.sig)) obj.sig = bytesFromBase64(object.sig); + return obj; + }, + toJSON(message: AuxSignerData): JsonSafe { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + message.signDoc !== undefined && (obj.signDoc = message.signDoc ? SignDocDirectAux.toJSON(message.signDoc) : undefined); + message.mode !== undefined && (obj.mode = signModeToJSON(message.mode)); + message.sig !== undefined && (obj.sig = base64FromBytes(message.sig !== undefined ? message.sig : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): AuxSignerData { + const message = createBaseAuxSignerData(); + message.address = object.address ?? ""; + if (object.signDoc !== undefined && object.signDoc !== null) { + message.signDoc = SignDocDirectAux.fromPartial(object.signDoc); + } + message.mode = object.mode ?? 0; + message.sig = object.sig ?? new Uint8Array(); + return message; + }, + fromSDK(object: AuxSignerDataSDKType): AuxSignerData { + return { + address: object?.address, + signDoc: object.sign_doc ? SignDocDirectAux.fromSDK(object.sign_doc) : undefined, + mode: isSet(object.mode) ? signModeFromJSON(object.mode) : -1, + sig: object?.sig + }; + }, + fromSDKJSON(object: any): AuxSignerDataSDKType { + return { + address: isSet(object.address) ? String(object.address) : "", + sign_doc: isSet(object.sign_doc) ? SignDocDirectAux.fromSDKJSON(object.sign_doc) : undefined, + mode: isSet(object.mode) ? signModeFromJSON(object.mode) : -1, + sig: isSet(object.sig) ? bytesFromBase64(object.sig) : new Uint8Array() + }; + }, + toSDK(message: AuxSignerData): AuxSignerDataSDKType { + const obj: any = {}; + obj.address = message.address; + message.signDoc !== undefined && (obj.sign_doc = message.signDoc ? SignDocDirectAux.toSDK(message.signDoc) : undefined); + message.mode !== undefined && (obj.mode = signModeToJSON(message.mode)); + obj.sig = message.sig; + return obj; + }, + fromAmino(object: AuxSignerDataAmino): AuxSignerData { + const message = createBaseAuxSignerData(); + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } + if (object.sign_doc !== undefined && object.sign_doc !== null) { + message.signDoc = SignDocDirectAux.fromAmino(object.sign_doc); + } + if (object.mode !== undefined && object.mode !== null) { + message.mode = object.mode; + } + if (object.sig !== undefined && object.sig !== null) { + message.sig = bytesFromBase64(object.sig); + } + return message; + }, + toAmino(message: AuxSignerData): AuxSignerDataAmino { + const obj: any = {}; + obj.address = message.address === "" ? undefined : message.address; + obj.sign_doc = message.signDoc ? SignDocDirectAux.toAmino(message.signDoc) : undefined; + obj.mode = message.mode === 0 ? undefined : message.mode; + obj.sig = message.sig ? base64FromBytes(message.sig) : undefined; + return obj; + }, + fromAminoMsg(object: AuxSignerDataAminoMsg): AuxSignerData { + return AuxSignerData.fromAmino(object.value); + }, + toAminoMsg(message: AuxSignerData): AuxSignerDataAminoMsg { + return { + type: "cosmos-sdk/AuxSignerData", + value: AuxSignerData.toAmino(message) + }; + }, + fromProtoMsg(message: AuxSignerDataProtoMsg): AuxSignerData { + return AuxSignerData.decode(message.value); + }, + toProto(message: AuxSignerData): Uint8Array { + return AuxSignerData.encode(message).finish(); + }, + toProtoMsg(message: AuxSignerData): AuxSignerDataProtoMsg { + return { + typeUrl: "/cosmos.tx.v1beta1.AuxSignerData", + value: AuxSignerData.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/upgrade/v1beta1/query.lcd.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/upgrade/v1beta1/query.lcd.ts new file mode 100644 index 0000000000..e2a48e1e67 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/upgrade/v1beta1/query.lcd.ts @@ -0,0 +1,56 @@ +import { Plan, PlanSDKType, ModuleVersion, ModuleVersionSDKType } from "./upgrade.js"; +import { LCDClient } from "@cosmology/lcd"; +import { QueryCurrentPlanRequest, QueryCurrentPlanRequestSDKType, QueryCurrentPlanResponse, QueryCurrentPlanResponseSDKType, QueryAppliedPlanRequest, QueryAppliedPlanRequestSDKType, QueryAppliedPlanResponse, QueryAppliedPlanResponseSDKType, QueryUpgradedConsensusStateRequest, QueryUpgradedConsensusStateRequestSDKType, QueryUpgradedConsensusStateResponse, QueryUpgradedConsensusStateResponseSDKType, QueryModuleVersionsRequest, QueryModuleVersionsRequestSDKType, QueryModuleVersionsResponse, QueryModuleVersionsResponseSDKType, QueryAuthorityRequest, QueryAuthorityRequestSDKType, QueryAuthorityResponse, QueryAuthorityResponseSDKType } from "./query.js"; +export class LCDQueryClient { + req: LCDClient; + constructor({ + requestClient + }: { + requestClient: LCDClient; + }) { + this.req = requestClient; + this.currentPlan = this.currentPlan.bind(this); + this.appliedPlan = this.appliedPlan.bind(this); + this.upgradedConsensusState = this.upgradedConsensusState.bind(this); + this.moduleVersions = this.moduleVersions.bind(this); + this.authority = this.authority.bind(this); + } + /* CurrentPlan queries the current upgrade plan. */ + async currentPlan(_params: QueryCurrentPlanRequest = {}): Promise { + const endpoint = `cosmos/upgrade/v1beta1/current_plan`; + return QueryCurrentPlanResponse.fromSDKJSON(await this.req.get(endpoint)); + } + /* AppliedPlan queries a previously applied upgrade plan by its name. */ + async appliedPlan(params: QueryAppliedPlanRequest): Promise { + const endpoint = `cosmos/upgrade/v1beta1/applied_plan/${params.name}`; + return QueryAppliedPlanResponse.fromSDKJSON(await this.req.get(endpoint)); + } + /* UpgradedConsensusState queries the consensus state that will serve + as a trusted kernel for the next version of this chain. It will only be + stored at the last height of this chain. + UpgradedConsensusState RPC not supported with legacy querier + This rpc is deprecated now that IBC has its own replacement + (https://github.com/cosmos/ibc-go/blob/2c880a22e9f9cc75f62b527ca94aa75ce1106001/proto/ibc/core/client/v1/query.proto#L54) */ + async upgradedConsensusState(params: QueryUpgradedConsensusStateRequest): Promise { + const endpoint = `cosmos/upgrade/v1beta1/upgraded_consensus_state/${params.lastHeight}`; + return QueryUpgradedConsensusStateResponse.fromSDKJSON(await this.req.get(endpoint)); + } + /* ModuleVersions queries the list of module versions from state. + + Since: cosmos-sdk 0.43 */ + async moduleVersions(params: QueryModuleVersionsRequest): Promise { + const options: any = { + params: {} + }; + if (typeof params?.moduleName !== "undefined") { + options.params.module_name = params.moduleName; + } + const endpoint = `cosmos/upgrade/v1beta1/module_versions`; + return QueryModuleVersionsResponse.fromSDKJSON(await this.req.get(endpoint, options)); + } + /* Returns the account with authority to conduct upgrades */ + async authority(_params: QueryAuthorityRequest = {}): Promise { + const endpoint = `cosmos/upgrade/v1beta1/authority`; + return QueryAuthorityResponse.fromSDKJSON(await this.req.get(endpoint)); + } +} \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/upgrade/v1beta1/query.rpc.Query.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/upgrade/v1beta1/query.rpc.Query.ts new file mode 100644 index 0000000000..80d127d58d --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/upgrade/v1beta1/query.rpc.Query.ts @@ -0,0 +1,86 @@ +import { Plan, PlanSDKType, ModuleVersion, ModuleVersionSDKType } from "./upgrade.js"; +import { Rpc } from "../../../helpers.js"; +import { BinaryReader } from "../../../binary.js"; +import { QueryClient, createProtobufRpcClient } from "@cosmjs/stargate"; +import { QueryCurrentPlanRequest, QueryCurrentPlanRequestSDKType, QueryCurrentPlanResponse, QueryCurrentPlanResponseSDKType, QueryAppliedPlanRequest, QueryAppliedPlanRequestSDKType, QueryAppliedPlanResponse, QueryAppliedPlanResponseSDKType, QueryUpgradedConsensusStateRequest, QueryUpgradedConsensusStateRequestSDKType, QueryUpgradedConsensusStateResponse, QueryUpgradedConsensusStateResponseSDKType, QueryModuleVersionsRequest, QueryModuleVersionsRequestSDKType, QueryModuleVersionsResponse, QueryModuleVersionsResponseSDKType, QueryAuthorityRequest, QueryAuthorityRequestSDKType, QueryAuthorityResponse, QueryAuthorityResponseSDKType } from "./query.js"; +/** Query defines the gRPC upgrade querier service. */ +export interface Query { + /** CurrentPlan queries the current upgrade plan. */ + currentPlan(request?: QueryCurrentPlanRequest): Promise; + /** AppliedPlan queries a previously applied upgrade plan by its name. */ + appliedPlan(request: QueryAppliedPlanRequest): Promise; + /** + * UpgradedConsensusState queries the consensus state that will serve + * as a trusted kernel for the next version of this chain. It will only be + * stored at the last height of this chain. + * UpgradedConsensusState RPC not supported with legacy querier + * This rpc is deprecated now that IBC has its own replacement + * (https://github.com/cosmos/ibc-go/blob/2c880a22e9f9cc75f62b527ca94aa75ce1106001/proto/ibc/core/client/v1/query.proto#L54) + */ + upgradedConsensusState(request: QueryUpgradedConsensusStateRequest): Promise; + /** + * ModuleVersions queries the list of module versions from state. + * + * Since: cosmos-sdk 0.43 + */ + moduleVersions(request: QueryModuleVersionsRequest): Promise; + /** Returns the account with authority to conduct upgrades */ + authority(request?: QueryAuthorityRequest): Promise; +} +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + this.currentPlan = this.currentPlan.bind(this); + this.appliedPlan = this.appliedPlan.bind(this); + this.upgradedConsensusState = this.upgradedConsensusState.bind(this); + this.moduleVersions = this.moduleVersions.bind(this); + this.authority = this.authority.bind(this); + } + currentPlan(request: QueryCurrentPlanRequest = {}): Promise { + const data = QueryCurrentPlanRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.upgrade.v1beta1.Query", "CurrentPlan", data); + return promise.then(data => QueryCurrentPlanResponse.decode(new BinaryReader(data))); + } + appliedPlan(request: QueryAppliedPlanRequest): Promise { + const data = QueryAppliedPlanRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.upgrade.v1beta1.Query", "AppliedPlan", data); + return promise.then(data => QueryAppliedPlanResponse.decode(new BinaryReader(data))); + } + upgradedConsensusState(request: QueryUpgradedConsensusStateRequest): Promise { + const data = QueryUpgradedConsensusStateRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.upgrade.v1beta1.Query", "UpgradedConsensusState", data); + return promise.then(data => QueryUpgradedConsensusStateResponse.decode(new BinaryReader(data))); + } + moduleVersions(request: QueryModuleVersionsRequest): Promise { + const data = QueryModuleVersionsRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.upgrade.v1beta1.Query", "ModuleVersions", data); + return promise.then(data => QueryModuleVersionsResponse.decode(new BinaryReader(data))); + } + authority(request: QueryAuthorityRequest = {}): Promise { + const data = QueryAuthorityRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.upgrade.v1beta1.Query", "Authority", data); + return promise.then(data => QueryAuthorityResponse.decode(new BinaryReader(data))); + } +} +export const createRpcQueryExtension = (base: QueryClient) => { + const rpc = createProtobufRpcClient(base); + const queryService = new QueryClientImpl(rpc); + return { + currentPlan(request?: QueryCurrentPlanRequest): Promise { + return queryService.currentPlan(request); + }, + appliedPlan(request: QueryAppliedPlanRequest): Promise { + return queryService.appliedPlan(request); + }, + upgradedConsensusState(request: QueryUpgradedConsensusStateRequest): Promise { + return queryService.upgradedConsensusState(request); + }, + moduleVersions(request: QueryModuleVersionsRequest): Promise { + return queryService.moduleVersions(request); + }, + authority(request?: QueryAuthorityRequest): Promise { + return queryService.authority(request); + } + }; +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/upgrade/v1beta1/query.rpc.func.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/upgrade/v1beta1/query.rpc.func.ts new file mode 100644 index 0000000000..a774cb5c79 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/upgrade/v1beta1/query.rpc.func.ts @@ -0,0 +1,58 @@ +import { RpcResolver, buildQuery } from "../../../helper-func-types"; +import { buildUseQuery } from "../../../react-query"; +import { QueryCurrentPlanRequest, QueryCurrentPlanResponse, QueryAppliedPlanRequest, QueryAppliedPlanResponse, QueryUpgradedConsensusStateRequest, QueryUpgradedConsensusStateResponse, QueryModuleVersionsRequest, QueryModuleVersionsResponse, QueryAuthorityRequest, QueryAuthorityResponse } from "./query"; +export const createGetCurrentPlan = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryCurrentPlanRequest.encode, + decode: QueryCurrentPlanResponse.decode, + service: "cosmos.upgrade.v1beta1.Query", + method: "CurrentPlan", + getRpcInstance: getRpcInstance +}); +export const useGetCurrentPlan = buildUseQuery({ + builderQueryFn: createGetCurrentPlan, + queryKeyPrefix: "CurrentPlanQuery" +}); +export const createGetAppliedPlan = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryAppliedPlanRequest.encode, + decode: QueryAppliedPlanResponse.decode, + service: "cosmos.upgrade.v1beta1.Query", + method: "AppliedPlan", + getRpcInstance: getRpcInstance +}); +export const useGetAppliedPlan = buildUseQuery({ + builderQueryFn: createGetAppliedPlan, + queryKeyPrefix: "AppliedPlanQuery" +}); +export const createGetUpgradedConsensusState = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryUpgradedConsensusStateRequest.encode, + decode: QueryUpgradedConsensusStateResponse.decode, + service: "cosmos.upgrade.v1beta1.Query", + method: "UpgradedConsensusState", + getRpcInstance: getRpcInstance +}); +export const useGetUpgradedConsensusState = buildUseQuery({ + builderQueryFn: createGetUpgradedConsensusState, + queryKeyPrefix: "UpgradedConsensusStateQuery" +}); +export const createGetModuleVersions = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryModuleVersionsRequest.encode, + decode: QueryModuleVersionsResponse.decode, + service: "cosmos.upgrade.v1beta1.Query", + method: "ModuleVersions", + getRpcInstance: getRpcInstance +}); +export const useGetModuleVersions = buildUseQuery({ + builderQueryFn: createGetModuleVersions, + queryKeyPrefix: "ModuleVersionsQuery" +}); +export const createGetAuthority = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryAuthorityRequest.encode, + decode: QueryAuthorityResponse.decode, + service: "cosmos.upgrade.v1beta1.Query", + method: "Authority", + getRpcInstance: getRpcInstance +}); +export const useGetAuthority = buildUseQuery({ + builderQueryFn: createGetAuthority, + queryKeyPrefix: "AuthorityQuery" +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/upgrade/v1beta1/query.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/upgrade/v1beta1/query.ts new file mode 100644 index 0000000000..65e3031521 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/upgrade/v1beta1/query.ts @@ -0,0 +1,1123 @@ +import { Plan, PlanSDKType, ModuleVersion, ModuleVersionSDKType } from "./upgrade.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { JsonSafe } from "../../../json-safe.js"; +import { DeepPartial, isSet, bytesFromBase64, base64FromBytes } from "../../../helpers.js"; +export const protobufPackage = "cosmos.upgrade.v1beta1"; +/** + * QueryCurrentPlanRequest is the request type for the Query/CurrentPlan RPC + * method. + */ +export interface QueryCurrentPlanRequest {} +export interface QueryCurrentPlanRequestProtoMsg { + typeUrl: "/cosmos.upgrade.v1beta1.QueryCurrentPlanRequest"; + value: Uint8Array; +} +/** + * QueryCurrentPlanRequest is the request type for the Query/CurrentPlan RPC + * method. + */ +export interface QueryCurrentPlanRequestSDKType {} +/** + * QueryCurrentPlanResponse is the response type for the Query/CurrentPlan RPC + * method. + */ +export interface QueryCurrentPlanResponse { + /** plan is the current upgrade plan. */ + plan?: Plan; +} +export interface QueryCurrentPlanResponseProtoMsg { + typeUrl: "/cosmos.upgrade.v1beta1.QueryCurrentPlanResponse"; + value: Uint8Array; +} +/** + * QueryCurrentPlanResponse is the response type for the Query/CurrentPlan RPC + * method. + */ +export interface QueryCurrentPlanResponseSDKType { + plan?: PlanSDKType; +} +/** + * QueryCurrentPlanRequest is the request type for the Query/AppliedPlan RPC + * method. + */ +export interface QueryAppliedPlanRequest { + /** name is the name of the applied plan to query for. */ + name: string; +} +export interface QueryAppliedPlanRequestProtoMsg { + typeUrl: "/cosmos.upgrade.v1beta1.QueryAppliedPlanRequest"; + value: Uint8Array; +} +/** + * QueryCurrentPlanRequest is the request type for the Query/AppliedPlan RPC + * method. + */ +export interface QueryAppliedPlanRequestSDKType { + name: string; +} +/** + * QueryAppliedPlanResponse is the response type for the Query/AppliedPlan RPC + * method. + */ +export interface QueryAppliedPlanResponse { + /** height is the block height at which the plan was applied. */ + height: bigint; +} +export interface QueryAppliedPlanResponseProtoMsg { + typeUrl: "/cosmos.upgrade.v1beta1.QueryAppliedPlanResponse"; + value: Uint8Array; +} +/** + * QueryAppliedPlanResponse is the response type for the Query/AppliedPlan RPC + * method. + */ +export interface QueryAppliedPlanResponseSDKType { + height: bigint; +} +/** + * QueryUpgradedConsensusStateRequest is the request type for the Query/UpgradedConsensusState + * RPC method. + */ +/** @deprecated */ +export interface QueryUpgradedConsensusStateRequest { + /** + * last height of the current chain must be sent in request + * as this is the height under which next consensus state is stored + */ + lastHeight: bigint; +} +export interface QueryUpgradedConsensusStateRequestProtoMsg { + typeUrl: "/cosmos.upgrade.v1beta1.QueryUpgradedConsensusStateRequest"; + value: Uint8Array; +} +/** + * QueryUpgradedConsensusStateRequest is the request type for the Query/UpgradedConsensusState + * RPC method. + */ +/** @deprecated */ +export interface QueryUpgradedConsensusStateRequestSDKType { + last_height: bigint; +} +/** + * QueryUpgradedConsensusStateResponse is the response type for the Query/UpgradedConsensusState + * RPC method. + */ +/** @deprecated */ +export interface QueryUpgradedConsensusStateResponse { + /** Since: cosmos-sdk 0.43 */ + upgradedConsensusState: Uint8Array; +} +export interface QueryUpgradedConsensusStateResponseProtoMsg { + typeUrl: "/cosmos.upgrade.v1beta1.QueryUpgradedConsensusStateResponse"; + value: Uint8Array; +} +/** + * QueryUpgradedConsensusStateResponse is the response type for the Query/UpgradedConsensusState + * RPC method. + */ +/** @deprecated */ +export interface QueryUpgradedConsensusStateResponseSDKType { + upgraded_consensus_state: Uint8Array; +} +/** + * QueryModuleVersionsRequest is the request type for the Query/ModuleVersions + * RPC method. + * + * Since: cosmos-sdk 0.43 + */ +export interface QueryModuleVersionsRequest { + /** + * module_name is a field to query a specific module + * consensus version from state. Leaving this empty will + * fetch the full list of module versions from state + */ + moduleName: string; +} +export interface QueryModuleVersionsRequestProtoMsg { + typeUrl: "/cosmos.upgrade.v1beta1.QueryModuleVersionsRequest"; + value: Uint8Array; +} +/** + * QueryModuleVersionsRequest is the request type for the Query/ModuleVersions + * RPC method. + * + * Since: cosmos-sdk 0.43 + */ +export interface QueryModuleVersionsRequestSDKType { + module_name: string; +} +/** + * QueryModuleVersionsResponse is the response type for the Query/ModuleVersions + * RPC method. + * + * Since: cosmos-sdk 0.43 + */ +export interface QueryModuleVersionsResponse { + /** module_versions is a list of module names with their consensus versions. */ + moduleVersions: ModuleVersion[]; +} +export interface QueryModuleVersionsResponseProtoMsg { + typeUrl: "/cosmos.upgrade.v1beta1.QueryModuleVersionsResponse"; + value: Uint8Array; +} +/** + * QueryModuleVersionsResponse is the response type for the Query/ModuleVersions + * RPC method. + * + * Since: cosmos-sdk 0.43 + */ +export interface QueryModuleVersionsResponseSDKType { + module_versions: ModuleVersionSDKType[]; +} +/** + * QueryAuthorityRequest is the request type for Query/Authority + * + * Since: cosmos-sdk 0.46 + */ +export interface QueryAuthorityRequest {} +export interface QueryAuthorityRequestProtoMsg { + typeUrl: "/cosmos.upgrade.v1beta1.QueryAuthorityRequest"; + value: Uint8Array; +} +/** + * QueryAuthorityRequest is the request type for Query/Authority + * + * Since: cosmos-sdk 0.46 + */ +export interface QueryAuthorityRequestSDKType {} +/** + * QueryAuthorityResponse is the response type for Query/Authority + * + * Since: cosmos-sdk 0.46 + */ +export interface QueryAuthorityResponse { + address: string; +} +export interface QueryAuthorityResponseProtoMsg { + typeUrl: "/cosmos.upgrade.v1beta1.QueryAuthorityResponse"; + value: Uint8Array; +} +/** + * QueryAuthorityResponse is the response type for Query/Authority + * + * Since: cosmos-sdk 0.46 + */ +export interface QueryAuthorityResponseSDKType { + address: string; +} +function createBaseQueryCurrentPlanRequest(): QueryCurrentPlanRequest { + return {}; +} +export const QueryCurrentPlanRequest = { + typeUrl: "/cosmos.upgrade.v1beta1.QueryCurrentPlanRequest", + encode(_: QueryCurrentPlanRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryCurrentPlanRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryCurrentPlanRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): QueryCurrentPlanRequest { + const obj = createBaseQueryCurrentPlanRequest(); + return obj; + }, + toJSON(_: QueryCurrentPlanRequest): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): QueryCurrentPlanRequest { + const message = createBaseQueryCurrentPlanRequest(); + return message; + }, + fromSDK(_: QueryCurrentPlanRequestSDKType): QueryCurrentPlanRequest { + return {}; + }, + fromSDKJSON(_: any): QueryCurrentPlanRequestSDKType { + return {}; + }, + toSDK(_: QueryCurrentPlanRequest): QueryCurrentPlanRequestSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: QueryCurrentPlanRequestAmino): QueryCurrentPlanRequest { + const message = createBaseQueryCurrentPlanRequest(); + return message; + }, + toAmino(_: QueryCurrentPlanRequest): QueryCurrentPlanRequestAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: QueryCurrentPlanRequestAminoMsg): QueryCurrentPlanRequest { + return QueryCurrentPlanRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryCurrentPlanRequest): QueryCurrentPlanRequestAminoMsg { + return { + type: "cosmos-sdk/QueryCurrentPlanRequest", + value: QueryCurrentPlanRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryCurrentPlanRequestProtoMsg): QueryCurrentPlanRequest { + return QueryCurrentPlanRequest.decode(message.value); + }, + toProto(message: QueryCurrentPlanRequest): Uint8Array { + return QueryCurrentPlanRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryCurrentPlanRequest): QueryCurrentPlanRequestProtoMsg { + return { + typeUrl: "/cosmos.upgrade.v1beta1.QueryCurrentPlanRequest", + value: QueryCurrentPlanRequest.encode(message).finish() + }; + } +}; +function createBaseQueryCurrentPlanResponse(): QueryCurrentPlanResponse { + return { + plan: undefined + }; +} +export const QueryCurrentPlanResponse = { + typeUrl: "/cosmos.upgrade.v1beta1.QueryCurrentPlanResponse", + encode(message: QueryCurrentPlanResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.plan !== undefined) { + Plan.encode(message.plan, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryCurrentPlanResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryCurrentPlanResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.plan = Plan.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryCurrentPlanResponse { + const obj = createBaseQueryCurrentPlanResponse(); + if (isSet(object.plan)) obj.plan = Plan.fromJSON(object.plan); + return obj; + }, + toJSON(message: QueryCurrentPlanResponse): JsonSafe { + const obj: any = {}; + message.plan !== undefined && (obj.plan = message.plan ? Plan.toJSON(message.plan) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryCurrentPlanResponse { + const message = createBaseQueryCurrentPlanResponse(); + if (object.plan !== undefined && object.plan !== null) { + message.plan = Plan.fromPartial(object.plan); + } + return message; + }, + fromSDK(object: QueryCurrentPlanResponseSDKType): QueryCurrentPlanResponse { + return { + plan: object.plan ? Plan.fromSDK(object.plan) : undefined + }; + }, + fromSDKJSON(object: any): QueryCurrentPlanResponseSDKType { + return { + plan: isSet(object.plan) ? Plan.fromSDKJSON(object.plan) : undefined + }; + }, + toSDK(message: QueryCurrentPlanResponse): QueryCurrentPlanResponseSDKType { + const obj: any = {}; + message.plan !== undefined && (obj.plan = message.plan ? Plan.toSDK(message.plan) : undefined); + return obj; + }, + fromAmino(object: QueryCurrentPlanResponseAmino): QueryCurrentPlanResponse { + const message = createBaseQueryCurrentPlanResponse(); + if (object.plan !== undefined && object.plan !== null) { + message.plan = Plan.fromAmino(object.plan); + } + return message; + }, + toAmino(message: QueryCurrentPlanResponse): QueryCurrentPlanResponseAmino { + const obj: any = {}; + obj.plan = message.plan ? Plan.toAmino(message.plan) : undefined; + return obj; + }, + fromAminoMsg(object: QueryCurrentPlanResponseAminoMsg): QueryCurrentPlanResponse { + return QueryCurrentPlanResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryCurrentPlanResponse): QueryCurrentPlanResponseAminoMsg { + return { + type: "cosmos-sdk/QueryCurrentPlanResponse", + value: QueryCurrentPlanResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryCurrentPlanResponseProtoMsg): QueryCurrentPlanResponse { + return QueryCurrentPlanResponse.decode(message.value); + }, + toProto(message: QueryCurrentPlanResponse): Uint8Array { + return QueryCurrentPlanResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryCurrentPlanResponse): QueryCurrentPlanResponseProtoMsg { + return { + typeUrl: "/cosmos.upgrade.v1beta1.QueryCurrentPlanResponse", + value: QueryCurrentPlanResponse.encode(message).finish() + }; + } +}; +function createBaseQueryAppliedPlanRequest(): QueryAppliedPlanRequest { + return { + name: "" + }; +} +export const QueryAppliedPlanRequest = { + typeUrl: "/cosmos.upgrade.v1beta1.QueryAppliedPlanRequest", + encode(message: QueryAppliedPlanRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryAppliedPlanRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryAppliedPlanRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryAppliedPlanRequest { + const obj = createBaseQueryAppliedPlanRequest(); + if (isSet(object.name)) obj.name = String(object.name); + return obj; + }, + toJSON(message: QueryAppliedPlanRequest): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + return obj; + }, + fromPartial(object: DeepPartial): QueryAppliedPlanRequest { + const message = createBaseQueryAppliedPlanRequest(); + message.name = object.name ?? ""; + return message; + }, + fromSDK(object: QueryAppliedPlanRequestSDKType): QueryAppliedPlanRequest { + return { + name: object?.name + }; + }, + fromSDKJSON(object: any): QueryAppliedPlanRequestSDKType { + return { + name: isSet(object.name) ? String(object.name) : "" + }; + }, + toSDK(message: QueryAppliedPlanRequest): QueryAppliedPlanRequestSDKType { + const obj: any = {}; + obj.name = message.name; + return obj; + }, + fromAmino(object: QueryAppliedPlanRequestAmino): QueryAppliedPlanRequest { + const message = createBaseQueryAppliedPlanRequest(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + return message; + }, + toAmino(message: QueryAppliedPlanRequest): QueryAppliedPlanRequestAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + return obj; + }, + fromAminoMsg(object: QueryAppliedPlanRequestAminoMsg): QueryAppliedPlanRequest { + return QueryAppliedPlanRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryAppliedPlanRequest): QueryAppliedPlanRequestAminoMsg { + return { + type: "cosmos-sdk/QueryAppliedPlanRequest", + value: QueryAppliedPlanRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryAppliedPlanRequestProtoMsg): QueryAppliedPlanRequest { + return QueryAppliedPlanRequest.decode(message.value); + }, + toProto(message: QueryAppliedPlanRequest): Uint8Array { + return QueryAppliedPlanRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryAppliedPlanRequest): QueryAppliedPlanRequestProtoMsg { + return { + typeUrl: "/cosmos.upgrade.v1beta1.QueryAppliedPlanRequest", + value: QueryAppliedPlanRequest.encode(message).finish() + }; + } +}; +function createBaseQueryAppliedPlanResponse(): QueryAppliedPlanResponse { + return { + height: BigInt(0) + }; +} +export const QueryAppliedPlanResponse = { + typeUrl: "/cosmos.upgrade.v1beta1.QueryAppliedPlanResponse", + encode(message: QueryAppliedPlanResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.height !== undefined) { + writer.uint32(8).int64(message.height); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryAppliedPlanResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryAppliedPlanResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.height = reader.int64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryAppliedPlanResponse { + const obj = createBaseQueryAppliedPlanResponse(); + if (isSet(object.height)) obj.height = BigInt(object.height.toString()); + return obj; + }, + toJSON(message: QueryAppliedPlanResponse): JsonSafe { + const obj: any = {}; + message.height !== undefined && (obj.height = (message.height || BigInt(0)).toString()); + return obj; + }, + fromPartial(object: DeepPartial): QueryAppliedPlanResponse { + const message = createBaseQueryAppliedPlanResponse(); + if (object.height !== undefined && object.height !== null) { + message.height = BigInt(object.height.toString()); + } + return message; + }, + fromSDK(object: QueryAppliedPlanResponseSDKType): QueryAppliedPlanResponse { + return { + height: object?.height + }; + }, + fromSDKJSON(object: any): QueryAppliedPlanResponseSDKType { + return { + height: isSet(object.height) ? BigInt(object.height.toString()) : BigInt(0) + }; + }, + toSDK(message: QueryAppliedPlanResponse): QueryAppliedPlanResponseSDKType { + const obj: any = {}; + obj.height = message.height; + return obj; + }, + fromAmino(object: QueryAppliedPlanResponseAmino): QueryAppliedPlanResponse { + const message = createBaseQueryAppliedPlanResponse(); + if (object.height !== undefined && object.height !== null) { + message.height = BigInt(object.height); + } + return message; + }, + toAmino(message: QueryAppliedPlanResponse): QueryAppliedPlanResponseAmino { + const obj: any = {}; + obj.height = message.height !== BigInt(0) ? message.height?.toString() : undefined; + return obj; + }, + fromAminoMsg(object: QueryAppliedPlanResponseAminoMsg): QueryAppliedPlanResponse { + return QueryAppliedPlanResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryAppliedPlanResponse): QueryAppliedPlanResponseAminoMsg { + return { + type: "cosmos-sdk/QueryAppliedPlanResponse", + value: QueryAppliedPlanResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryAppliedPlanResponseProtoMsg): QueryAppliedPlanResponse { + return QueryAppliedPlanResponse.decode(message.value); + }, + toProto(message: QueryAppliedPlanResponse): Uint8Array { + return QueryAppliedPlanResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryAppliedPlanResponse): QueryAppliedPlanResponseProtoMsg { + return { + typeUrl: "/cosmos.upgrade.v1beta1.QueryAppliedPlanResponse", + value: QueryAppliedPlanResponse.encode(message).finish() + }; + } +}; +function createBaseQueryUpgradedConsensusStateRequest(): QueryUpgradedConsensusStateRequest { + return { + lastHeight: BigInt(0) + }; +} +export const QueryUpgradedConsensusStateRequest = { + typeUrl: "/cosmos.upgrade.v1beta1.QueryUpgradedConsensusStateRequest", + encode(message: QueryUpgradedConsensusStateRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.lastHeight !== undefined) { + writer.uint32(8).int64(message.lastHeight); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryUpgradedConsensusStateRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryUpgradedConsensusStateRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.lastHeight = reader.int64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryUpgradedConsensusStateRequest { + const obj = createBaseQueryUpgradedConsensusStateRequest(); + if (isSet(object.lastHeight)) obj.lastHeight = BigInt(object.lastHeight.toString()); + return obj; + }, + toJSON(message: QueryUpgradedConsensusStateRequest): JsonSafe { + const obj: any = {}; + message.lastHeight !== undefined && (obj.lastHeight = (message.lastHeight || BigInt(0)).toString()); + return obj; + }, + fromPartial(object: DeepPartial): QueryUpgradedConsensusStateRequest { + const message = createBaseQueryUpgradedConsensusStateRequest(); + if (object.lastHeight !== undefined && object.lastHeight !== null) { + message.lastHeight = BigInt(object.lastHeight.toString()); + } + return message; + }, + fromSDK(object: QueryUpgradedConsensusStateRequestSDKType): QueryUpgradedConsensusStateRequest { + return { + lastHeight: object?.last_height + }; + }, + fromSDKJSON(object: any): QueryUpgradedConsensusStateRequestSDKType { + return { + last_height: isSet(object.last_height) ? BigInt(object.last_height.toString()) : BigInt(0) + }; + }, + toSDK(message: QueryUpgradedConsensusStateRequest): QueryUpgradedConsensusStateRequestSDKType { + const obj: any = {}; + obj.last_height = message.lastHeight; + return obj; + }, + fromAmino(object: QueryUpgradedConsensusStateRequestAmino): QueryUpgradedConsensusStateRequest { + const message = createBaseQueryUpgradedConsensusStateRequest(); + if (object.last_height !== undefined && object.last_height !== null) { + message.lastHeight = BigInt(object.last_height); + } + return message; + }, + toAmino(message: QueryUpgradedConsensusStateRequest): QueryUpgradedConsensusStateRequestAmino { + const obj: any = {}; + obj.last_height = message.lastHeight !== BigInt(0) ? message.lastHeight?.toString() : undefined; + return obj; + }, + fromAminoMsg(object: QueryUpgradedConsensusStateRequestAminoMsg): QueryUpgradedConsensusStateRequest { + return QueryUpgradedConsensusStateRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryUpgradedConsensusStateRequest): QueryUpgradedConsensusStateRequestAminoMsg { + return { + type: "cosmos-sdk/QueryUpgradedConsensusStateRequest", + value: QueryUpgradedConsensusStateRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryUpgradedConsensusStateRequestProtoMsg): QueryUpgradedConsensusStateRequest { + return QueryUpgradedConsensusStateRequest.decode(message.value); + }, + toProto(message: QueryUpgradedConsensusStateRequest): Uint8Array { + return QueryUpgradedConsensusStateRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryUpgradedConsensusStateRequest): QueryUpgradedConsensusStateRequestProtoMsg { + return { + typeUrl: "/cosmos.upgrade.v1beta1.QueryUpgradedConsensusStateRequest", + value: QueryUpgradedConsensusStateRequest.encode(message).finish() + }; + } +}; +function createBaseQueryUpgradedConsensusStateResponse(): QueryUpgradedConsensusStateResponse { + return { + upgradedConsensusState: new Uint8Array() + }; +} +export const QueryUpgradedConsensusStateResponse = { + typeUrl: "/cosmos.upgrade.v1beta1.QueryUpgradedConsensusStateResponse", + encode(message: QueryUpgradedConsensusStateResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.upgradedConsensusState.length !== 0) { + writer.uint32(18).bytes(message.upgradedConsensusState); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryUpgradedConsensusStateResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryUpgradedConsensusStateResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.upgradedConsensusState = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryUpgradedConsensusStateResponse { + const obj = createBaseQueryUpgradedConsensusStateResponse(); + if (isSet(object.upgradedConsensusState)) obj.upgradedConsensusState = bytesFromBase64(object.upgradedConsensusState); + return obj; + }, + toJSON(message: QueryUpgradedConsensusStateResponse): JsonSafe { + const obj: any = {}; + message.upgradedConsensusState !== undefined && (obj.upgradedConsensusState = base64FromBytes(message.upgradedConsensusState !== undefined ? message.upgradedConsensusState : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): QueryUpgradedConsensusStateResponse { + const message = createBaseQueryUpgradedConsensusStateResponse(); + message.upgradedConsensusState = object.upgradedConsensusState ?? new Uint8Array(); + return message; + }, + fromSDK(object: QueryUpgradedConsensusStateResponseSDKType): QueryUpgradedConsensusStateResponse { + return { + upgradedConsensusState: object?.upgraded_consensus_state + }; + }, + fromSDKJSON(object: any): QueryUpgradedConsensusStateResponseSDKType { + return { + upgraded_consensus_state: isSet(object.upgraded_consensus_state) ? bytesFromBase64(object.upgraded_consensus_state) : new Uint8Array() + }; + }, + toSDK(message: QueryUpgradedConsensusStateResponse): QueryUpgradedConsensusStateResponseSDKType { + const obj: any = {}; + obj.upgraded_consensus_state = message.upgradedConsensusState; + return obj; + }, + fromAmino(object: QueryUpgradedConsensusStateResponseAmino): QueryUpgradedConsensusStateResponse { + const message = createBaseQueryUpgradedConsensusStateResponse(); + if (object.upgraded_consensus_state !== undefined && object.upgraded_consensus_state !== null) { + message.upgradedConsensusState = bytesFromBase64(object.upgraded_consensus_state); + } + return message; + }, + toAmino(message: QueryUpgradedConsensusStateResponse): QueryUpgradedConsensusStateResponseAmino { + const obj: any = {}; + obj.upgraded_consensus_state = message.upgradedConsensusState ? base64FromBytes(message.upgradedConsensusState) : undefined; + return obj; + }, + fromAminoMsg(object: QueryUpgradedConsensusStateResponseAminoMsg): QueryUpgradedConsensusStateResponse { + return QueryUpgradedConsensusStateResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryUpgradedConsensusStateResponse): QueryUpgradedConsensusStateResponseAminoMsg { + return { + type: "cosmos-sdk/QueryUpgradedConsensusStateResponse", + value: QueryUpgradedConsensusStateResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryUpgradedConsensusStateResponseProtoMsg): QueryUpgradedConsensusStateResponse { + return QueryUpgradedConsensusStateResponse.decode(message.value); + }, + toProto(message: QueryUpgradedConsensusStateResponse): Uint8Array { + return QueryUpgradedConsensusStateResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryUpgradedConsensusStateResponse): QueryUpgradedConsensusStateResponseProtoMsg { + return { + typeUrl: "/cosmos.upgrade.v1beta1.QueryUpgradedConsensusStateResponse", + value: QueryUpgradedConsensusStateResponse.encode(message).finish() + }; + } +}; +function createBaseQueryModuleVersionsRequest(): QueryModuleVersionsRequest { + return { + moduleName: "" + }; +} +export const QueryModuleVersionsRequest = { + typeUrl: "/cosmos.upgrade.v1beta1.QueryModuleVersionsRequest", + encode(message: QueryModuleVersionsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.moduleName !== undefined) { + writer.uint32(10).string(message.moduleName); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryModuleVersionsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryModuleVersionsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.moduleName = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryModuleVersionsRequest { + const obj = createBaseQueryModuleVersionsRequest(); + if (isSet(object.moduleName)) obj.moduleName = String(object.moduleName); + return obj; + }, + toJSON(message: QueryModuleVersionsRequest): JsonSafe { + const obj: any = {}; + message.moduleName !== undefined && (obj.moduleName = message.moduleName); + return obj; + }, + fromPartial(object: DeepPartial): QueryModuleVersionsRequest { + const message = createBaseQueryModuleVersionsRequest(); + message.moduleName = object.moduleName ?? ""; + return message; + }, + fromSDK(object: QueryModuleVersionsRequestSDKType): QueryModuleVersionsRequest { + return { + moduleName: object?.module_name + }; + }, + fromSDKJSON(object: any): QueryModuleVersionsRequestSDKType { + return { + module_name: isSet(object.module_name) ? String(object.module_name) : "" + }; + }, + toSDK(message: QueryModuleVersionsRequest): QueryModuleVersionsRequestSDKType { + const obj: any = {}; + obj.module_name = message.moduleName; + return obj; + }, + fromAmino(object: QueryModuleVersionsRequestAmino): QueryModuleVersionsRequest { + const message = createBaseQueryModuleVersionsRequest(); + if (object.module_name !== undefined && object.module_name !== null) { + message.moduleName = object.module_name; + } + return message; + }, + toAmino(message: QueryModuleVersionsRequest): QueryModuleVersionsRequestAmino { + const obj: any = {}; + obj.module_name = message.moduleName === "" ? undefined : message.moduleName; + return obj; + }, + fromAminoMsg(object: QueryModuleVersionsRequestAminoMsg): QueryModuleVersionsRequest { + return QueryModuleVersionsRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryModuleVersionsRequest): QueryModuleVersionsRequestAminoMsg { + return { + type: "cosmos-sdk/QueryModuleVersionsRequest", + value: QueryModuleVersionsRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryModuleVersionsRequestProtoMsg): QueryModuleVersionsRequest { + return QueryModuleVersionsRequest.decode(message.value); + }, + toProto(message: QueryModuleVersionsRequest): Uint8Array { + return QueryModuleVersionsRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryModuleVersionsRequest): QueryModuleVersionsRequestProtoMsg { + return { + typeUrl: "/cosmos.upgrade.v1beta1.QueryModuleVersionsRequest", + value: QueryModuleVersionsRequest.encode(message).finish() + }; + } +}; +function createBaseQueryModuleVersionsResponse(): QueryModuleVersionsResponse { + return { + moduleVersions: [] + }; +} +export const QueryModuleVersionsResponse = { + typeUrl: "/cosmos.upgrade.v1beta1.QueryModuleVersionsResponse", + encode(message: QueryModuleVersionsResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.moduleVersions) { + ModuleVersion.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryModuleVersionsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryModuleVersionsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.moduleVersions.push(ModuleVersion.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryModuleVersionsResponse { + const obj = createBaseQueryModuleVersionsResponse(); + if (Array.isArray(object?.moduleVersions)) obj.moduleVersions = object.moduleVersions.map((e: any) => ModuleVersion.fromJSON(e)); + return obj; + }, + toJSON(message: QueryModuleVersionsResponse): JsonSafe { + const obj: any = {}; + if (message.moduleVersions) { + obj.moduleVersions = message.moduleVersions.map(e => e ? ModuleVersion.toJSON(e) : undefined); + } else { + obj.moduleVersions = []; + } + return obj; + }, + fromPartial(object: DeepPartial): QueryModuleVersionsResponse { + const message = createBaseQueryModuleVersionsResponse(); + message.moduleVersions = object.moduleVersions?.map(e => ModuleVersion.fromPartial(e)) || []; + return message; + }, + fromSDK(object: QueryModuleVersionsResponseSDKType): QueryModuleVersionsResponse { + return { + moduleVersions: Array.isArray(object?.module_versions) ? object.module_versions.map((e: any) => ModuleVersion.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): QueryModuleVersionsResponseSDKType { + return { + module_versions: Array.isArray(object?.module_versions) ? object.module_versions.map((e: any) => ModuleVersion.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: QueryModuleVersionsResponse): QueryModuleVersionsResponseSDKType { + const obj: any = {}; + if (message.moduleVersions) { + obj.module_versions = message.moduleVersions.map(e => e ? ModuleVersion.toSDK(e) : undefined); + } else { + obj.module_versions = []; + } + return obj; + }, + fromAmino(object: QueryModuleVersionsResponseAmino): QueryModuleVersionsResponse { + const message = createBaseQueryModuleVersionsResponse(); + message.moduleVersions = object.module_versions?.map(e => ModuleVersion.fromAmino(e)) || []; + return message; + }, + toAmino(message: QueryModuleVersionsResponse): QueryModuleVersionsResponseAmino { + const obj: any = {}; + if (message.moduleVersions) { + obj.module_versions = message.moduleVersions.map(e => e ? ModuleVersion.toAmino(e) : undefined); + } else { + obj.module_versions = message.moduleVersions; + } + return obj; + }, + fromAminoMsg(object: QueryModuleVersionsResponseAminoMsg): QueryModuleVersionsResponse { + return QueryModuleVersionsResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryModuleVersionsResponse): QueryModuleVersionsResponseAminoMsg { + return { + type: "cosmos-sdk/QueryModuleVersionsResponse", + value: QueryModuleVersionsResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryModuleVersionsResponseProtoMsg): QueryModuleVersionsResponse { + return QueryModuleVersionsResponse.decode(message.value); + }, + toProto(message: QueryModuleVersionsResponse): Uint8Array { + return QueryModuleVersionsResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryModuleVersionsResponse): QueryModuleVersionsResponseProtoMsg { + return { + typeUrl: "/cosmos.upgrade.v1beta1.QueryModuleVersionsResponse", + value: QueryModuleVersionsResponse.encode(message).finish() + }; + } +}; +function createBaseQueryAuthorityRequest(): QueryAuthorityRequest { + return {}; +} +export const QueryAuthorityRequest = { + typeUrl: "/cosmos.upgrade.v1beta1.QueryAuthorityRequest", + encode(_: QueryAuthorityRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryAuthorityRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryAuthorityRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): QueryAuthorityRequest { + const obj = createBaseQueryAuthorityRequest(); + return obj; + }, + toJSON(_: QueryAuthorityRequest): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): QueryAuthorityRequest { + const message = createBaseQueryAuthorityRequest(); + return message; + }, + fromSDK(_: QueryAuthorityRequestSDKType): QueryAuthorityRequest { + return {}; + }, + fromSDKJSON(_: any): QueryAuthorityRequestSDKType { + return {}; + }, + toSDK(_: QueryAuthorityRequest): QueryAuthorityRequestSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: QueryAuthorityRequestAmino): QueryAuthorityRequest { + const message = createBaseQueryAuthorityRequest(); + return message; + }, + toAmino(_: QueryAuthorityRequest): QueryAuthorityRequestAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: QueryAuthorityRequestAminoMsg): QueryAuthorityRequest { + return QueryAuthorityRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryAuthorityRequest): QueryAuthorityRequestAminoMsg { + return { + type: "cosmos-sdk/QueryAuthorityRequest", + value: QueryAuthorityRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryAuthorityRequestProtoMsg): QueryAuthorityRequest { + return QueryAuthorityRequest.decode(message.value); + }, + toProto(message: QueryAuthorityRequest): Uint8Array { + return QueryAuthorityRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryAuthorityRequest): QueryAuthorityRequestProtoMsg { + return { + typeUrl: "/cosmos.upgrade.v1beta1.QueryAuthorityRequest", + value: QueryAuthorityRequest.encode(message).finish() + }; + } +}; +function createBaseQueryAuthorityResponse(): QueryAuthorityResponse { + return { + address: "" + }; +} +export const QueryAuthorityResponse = { + typeUrl: "/cosmos.upgrade.v1beta1.QueryAuthorityResponse", + encode(message: QueryAuthorityResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.address !== undefined) { + writer.uint32(10).string(message.address); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryAuthorityResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryAuthorityResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryAuthorityResponse { + const obj = createBaseQueryAuthorityResponse(); + if (isSet(object.address)) obj.address = String(object.address); + return obj; + }, + toJSON(message: QueryAuthorityResponse): JsonSafe { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + return obj; + }, + fromPartial(object: DeepPartial): QueryAuthorityResponse { + const message = createBaseQueryAuthorityResponse(); + message.address = object.address ?? ""; + return message; + }, + fromSDK(object: QueryAuthorityResponseSDKType): QueryAuthorityResponse { + return { + address: object?.address + }; + }, + fromSDKJSON(object: any): QueryAuthorityResponseSDKType { + return { + address: isSet(object.address) ? String(object.address) : "" + }; + }, + toSDK(message: QueryAuthorityResponse): QueryAuthorityResponseSDKType { + const obj: any = {}; + obj.address = message.address; + return obj; + }, + fromAmino(object: QueryAuthorityResponseAmino): QueryAuthorityResponse { + const message = createBaseQueryAuthorityResponse(); + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } + return message; + }, + toAmino(message: QueryAuthorityResponse): QueryAuthorityResponseAmino { + const obj: any = {}; + obj.address = message.address === "" ? undefined : message.address; + return obj; + }, + fromAminoMsg(object: QueryAuthorityResponseAminoMsg): QueryAuthorityResponse { + return QueryAuthorityResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryAuthorityResponse): QueryAuthorityResponseAminoMsg { + return { + type: "cosmos-sdk/QueryAuthorityResponse", + value: QueryAuthorityResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryAuthorityResponseProtoMsg): QueryAuthorityResponse { + return QueryAuthorityResponse.decode(message.value); + }, + toProto(message: QueryAuthorityResponse): Uint8Array { + return QueryAuthorityResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryAuthorityResponse): QueryAuthorityResponseProtoMsg { + return { + typeUrl: "/cosmos.upgrade.v1beta1.QueryAuthorityResponse", + value: QueryAuthorityResponse.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/upgrade/v1beta1/tx.amino.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/upgrade/v1beta1/tx.amino.ts new file mode 100644 index 0000000000..3150ec6bda --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/upgrade/v1beta1/tx.amino.ts @@ -0,0 +1,84 @@ +import { Plan, PlanSDKType } from "./upgrade.js"; +import { ReadOnlyAminoMsg as AminoMsg } from "@interchainjs/ReadOnlyAminoMsg"; +import { Any, AnySDKType } from "../../../google/protobuf/any.js"; +import { MsgSoftwareUpgrade, MsgSoftwareUpgradeSDKType, MsgCancelUpgrade, MsgCancelUpgradeSDKType } from "./tx.js"; +export interface MsgSoftwareUpgradeAminoType extends AminoMsg { + type: "cosmos-sdk/MsgSoftwareUpgrade"; + value: { + authority: string; + plan: { + name: string; + time: string; + height: string; + info: string; + upgraded_client_state: { + type_url: string; + value: Uint8Array; + }; + }; + }; +} +export interface MsgCancelUpgradeAminoType extends AminoMsg { + type: "cosmos-sdk/MsgCancelUpgrade"; + value: { + authority: string; + }; +} +export const AminoConverter = { + "/cosmos.upgrade.v1beta1.MsgSoftwareUpgrade": { + aminoType: "cosmos-sdk/MsgSoftwareUpgrade", + toAmino: ({ + authority, + plan + }: MsgSoftwareUpgrade): MsgSoftwareUpgradeAminoType["value"] => { + return { + authority, + plan: { + name: plan.name, + time: plan.time, + height: plan.height.toString(), + info: plan.info, + upgraded_client_state: { + type_url: plan.upgradedClientState.typeUrl, + value: plan.upgradedClientState.value + } + } + }; + }, + fromAmino: ({ + authority, + plan + }: MsgSoftwareUpgradeAminoType["value"]): MsgSoftwareUpgrade => { + return { + authority, + plan: { + name: plan.name, + time: plan.time, + height: BigInt(plan.height), + info: plan.info, + upgradedClientState: { + typeUrl: plan.upgraded_client_state.type_url, + value: plan.upgraded_client_state.value + } + } + }; + } + }, + "/cosmos.upgrade.v1beta1.MsgCancelUpgrade": { + aminoType: "cosmos-sdk/MsgCancelUpgrade", + toAmino: ({ + authority + }: MsgCancelUpgrade): MsgCancelUpgradeAminoType["value"] => { + return { + authority + }; + }, + fromAmino: ({ + authority + }: MsgCancelUpgradeAminoType["value"]): MsgCancelUpgrade => { + return { + authority + }; + } + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/upgrade/v1beta1/tx.registry.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/upgrade/v1beta1/tx.registry.ts new file mode 100644 index 0000000000..e3fae09441 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/upgrade/v1beta1/tx.registry.ts @@ -0,0 +1,81 @@ +import { Plan, PlanSDKType } from "./upgrade.js"; +import { GeneratedType, Registry } from "@cosmjs/proto-signing"; +import { MsgSoftwareUpgrade, MsgSoftwareUpgradeSDKType, MsgCancelUpgrade, MsgCancelUpgradeSDKType } from "./tx.js"; +export const registry: ReadonlyArray<[string, GeneratedType]> = [["/cosmos.upgrade.v1beta1.MsgSoftwareUpgrade", MsgSoftwareUpgrade], ["/cosmos.upgrade.v1beta1.MsgCancelUpgrade", MsgCancelUpgrade]]; +export const load = (protoRegistry: Registry) => { + registry.forEach(([typeUrl, mod]) => { + protoRegistry.register(typeUrl, mod); + }); +}; +export const MessageComposer = { + encoded: { + softwareUpgrade(value: MsgSoftwareUpgrade) { + return { + typeUrl: "/cosmos.upgrade.v1beta1.MsgSoftwareUpgrade", + value: MsgSoftwareUpgrade.encode(value).finish() + }; + }, + cancelUpgrade(value: MsgCancelUpgrade) { + return { + typeUrl: "/cosmos.upgrade.v1beta1.MsgCancelUpgrade", + value: MsgCancelUpgrade.encode(value).finish() + }; + } + }, + withTypeUrl: { + softwareUpgrade(value: MsgSoftwareUpgrade) { + return { + typeUrl: "/cosmos.upgrade.v1beta1.MsgSoftwareUpgrade", + value + }; + }, + cancelUpgrade(value: MsgCancelUpgrade) { + return { + typeUrl: "/cosmos.upgrade.v1beta1.MsgCancelUpgrade", + value + }; + } + }, + toJSON: { + softwareUpgrade(value: MsgSoftwareUpgrade) { + return { + typeUrl: "/cosmos.upgrade.v1beta1.MsgSoftwareUpgrade", + value: MsgSoftwareUpgrade.toJSON(value) + }; + }, + cancelUpgrade(value: MsgCancelUpgrade) { + return { + typeUrl: "/cosmos.upgrade.v1beta1.MsgCancelUpgrade", + value: MsgCancelUpgrade.toJSON(value) + }; + } + }, + fromJSON: { + softwareUpgrade(value: any) { + return { + typeUrl: "/cosmos.upgrade.v1beta1.MsgSoftwareUpgrade", + value: MsgSoftwareUpgrade.fromJSON(value) + }; + }, + cancelUpgrade(value: any) { + return { + typeUrl: "/cosmos.upgrade.v1beta1.MsgCancelUpgrade", + value: MsgCancelUpgrade.fromJSON(value) + }; + } + }, + fromPartial: { + softwareUpgrade(value: MsgSoftwareUpgrade) { + return { + typeUrl: "/cosmos.upgrade.v1beta1.MsgSoftwareUpgrade", + value: MsgSoftwareUpgrade.fromPartial(value) + }; + }, + cancelUpgrade(value: MsgCancelUpgrade) { + return { + typeUrl: "/cosmos.upgrade.v1beta1.MsgCancelUpgrade", + value: MsgCancelUpgrade.fromPartial(value) + }; + } + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/upgrade/v1beta1/tx.rpc.func.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/upgrade/v1beta1/tx.rpc.func.ts new file mode 100644 index 0000000000..1361e7514b --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/upgrade/v1beta1/tx.rpc.func.ts @@ -0,0 +1,22 @@ +import { buildTx, SigningClientResolver } from "../../../helper-func-types"; +import { buildUseMutation } from "../../../react-query"; +import { toEncoders, toConverters } from "@interchainjs/cosmos/utils"; +import { MsgSoftwareUpgrade, MsgCancelUpgrade } from "./tx"; +export const createSoftwareUpgrade = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgSoftwareUpgrade.typeUrl, + encoders: toEncoders(MsgSoftwareUpgrade), + converters: toConverters(MsgSoftwareUpgrade) +}); +export const useSoftwareUpgrade = buildUseMutation({ + builderMutationFn: createSoftwareUpgrade +}); +export const createCancelUpgrade = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgCancelUpgrade.typeUrl, + encoders: toEncoders(MsgCancelUpgrade), + converters: toConverters(MsgCancelUpgrade) +}); +export const useCancelUpgrade = buildUseMutation({ + builderMutationFn: createCancelUpgrade +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/upgrade/v1beta1/tx.rpc.msg.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/upgrade/v1beta1/tx.rpc.msg.ts new file mode 100644 index 0000000000..adeae6342a --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/upgrade/v1beta1/tx.rpc.msg.ts @@ -0,0 +1,41 @@ +import { Plan, PlanSDKType } from "./upgrade.js"; +import { Rpc } from "../../../helpers.js"; +import { BinaryReader } from "../../../binary.js"; +import { MsgSoftwareUpgrade, MsgSoftwareUpgradeSDKType, MsgSoftwareUpgradeResponse, MsgSoftwareUpgradeResponseSDKType, MsgCancelUpgrade, MsgCancelUpgradeSDKType, MsgCancelUpgradeResponse, MsgCancelUpgradeResponseSDKType } from "./tx.js"; +/** Msg defines the upgrade Msg service. */ +export interface Msg { + /** + * SoftwareUpgrade is a governance operation for initiating a software upgrade. + * + * Since: cosmos-sdk 0.46 + */ + softwareUpgrade(request: MsgSoftwareUpgrade): Promise; + /** + * CancelUpgrade is a governance operation for cancelling a previously + * approvid software upgrade. + * + * Since: cosmos-sdk 0.46 + */ + cancelUpgrade(request: MsgCancelUpgrade): Promise; +} +export class MsgClientImpl implements Msg { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + this.softwareUpgrade = this.softwareUpgrade.bind(this); + this.cancelUpgrade = this.cancelUpgrade.bind(this); + } + softwareUpgrade(request: MsgSoftwareUpgrade): Promise { + const data = MsgSoftwareUpgrade.encode(request).finish(); + const promise = this.rpc.request("cosmos.upgrade.v1beta1.Msg", "SoftwareUpgrade", data); + return promise.then(data => MsgSoftwareUpgradeResponse.decode(new BinaryReader(data))); + } + cancelUpgrade(request: MsgCancelUpgrade): Promise { + const data = MsgCancelUpgrade.encode(request).finish(); + const promise = this.rpc.request("cosmos.upgrade.v1beta1.Msg", "CancelUpgrade", data); + return promise.then(data => MsgCancelUpgradeResponse.decode(new BinaryReader(data))); + } +} +export const createClientImpl = (rpc: Rpc) => { + return new MsgClientImpl(rpc); +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/upgrade/v1beta1/tx.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/upgrade/v1beta1/tx.ts new file mode 100644 index 0000000000..e1e807d4af --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/upgrade/v1beta1/tx.ts @@ -0,0 +1,437 @@ +import { Plan, PlanSDKType } from "./upgrade.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "cosmos.upgrade.v1beta1"; +/** + * MsgSoftwareUpgrade is the Msg/SoftwareUpgrade request type. + * + * Since: cosmos-sdk 0.46 + */ +export interface MsgSoftwareUpgrade { + /** authority is the address of the governance account. */ + authority: string; + /** plan is the upgrade plan. */ + plan: Plan; +} +export interface MsgSoftwareUpgradeProtoMsg { + typeUrl: "/cosmos.upgrade.v1beta1.MsgSoftwareUpgrade"; + value: Uint8Array; +} +/** + * MsgSoftwareUpgrade is the Msg/SoftwareUpgrade request type. + * + * Since: cosmos-sdk 0.46 + */ +export interface MsgSoftwareUpgradeSDKType { + authority: string; + plan: PlanSDKType; +} +/** + * MsgSoftwareUpgradeResponse is the Msg/SoftwareUpgrade response type. + * + * Since: cosmos-sdk 0.46 + */ +export interface MsgSoftwareUpgradeResponse {} +export interface MsgSoftwareUpgradeResponseProtoMsg { + typeUrl: "/cosmos.upgrade.v1beta1.MsgSoftwareUpgradeResponse"; + value: Uint8Array; +} +/** + * MsgSoftwareUpgradeResponse is the Msg/SoftwareUpgrade response type. + * + * Since: cosmos-sdk 0.46 + */ +export interface MsgSoftwareUpgradeResponseSDKType {} +/** + * MsgCancelUpgrade is the Msg/CancelUpgrade request type. + * + * Since: cosmos-sdk 0.46 + */ +export interface MsgCancelUpgrade { + /** authority is the address of the governance account. */ + authority: string; +} +export interface MsgCancelUpgradeProtoMsg { + typeUrl: "/cosmos.upgrade.v1beta1.MsgCancelUpgrade"; + value: Uint8Array; +} +/** + * MsgCancelUpgrade is the Msg/CancelUpgrade request type. + * + * Since: cosmos-sdk 0.46 + */ +export interface MsgCancelUpgradeSDKType { + authority: string; +} +/** + * MsgCancelUpgradeResponse is the Msg/CancelUpgrade response type. + * + * Since: cosmos-sdk 0.46 + */ +export interface MsgCancelUpgradeResponse {} +export interface MsgCancelUpgradeResponseProtoMsg { + typeUrl: "/cosmos.upgrade.v1beta1.MsgCancelUpgradeResponse"; + value: Uint8Array; +} +/** + * MsgCancelUpgradeResponse is the Msg/CancelUpgrade response type. + * + * Since: cosmos-sdk 0.46 + */ +export interface MsgCancelUpgradeResponseSDKType {} +function createBaseMsgSoftwareUpgrade(): MsgSoftwareUpgrade { + return { + authority: "", + plan: Plan.fromPartial({}) + }; +} +export const MsgSoftwareUpgrade = { + typeUrl: "/cosmos.upgrade.v1beta1.MsgSoftwareUpgrade", + encode(message: MsgSoftwareUpgrade, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.authority !== undefined) { + writer.uint32(10).string(message.authority); + } + if (message.plan !== undefined) { + Plan.encode(message.plan, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgSoftwareUpgrade { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgSoftwareUpgrade(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.authority = reader.string(); + break; + case 2: + message.plan = Plan.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgSoftwareUpgrade { + const obj = createBaseMsgSoftwareUpgrade(); + if (isSet(object.authority)) obj.authority = String(object.authority); + if (isSet(object.plan)) obj.plan = Plan.fromJSON(object.plan); + return obj; + }, + toJSON(message: MsgSoftwareUpgrade): JsonSafe { + const obj: any = {}; + message.authority !== undefined && (obj.authority = message.authority); + message.plan !== undefined && (obj.plan = message.plan ? Plan.toJSON(message.plan) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): MsgSoftwareUpgrade { + const message = createBaseMsgSoftwareUpgrade(); + message.authority = object.authority ?? ""; + if (object.plan !== undefined && object.plan !== null) { + message.plan = Plan.fromPartial(object.plan); + } + return message; + }, + fromSDK(object: MsgSoftwareUpgradeSDKType): MsgSoftwareUpgrade { + return { + authority: object?.authority, + plan: object.plan ? Plan.fromSDK(object.plan) : undefined + }; + }, + fromSDKJSON(object: any): MsgSoftwareUpgradeSDKType { + return { + authority: isSet(object.authority) ? String(object.authority) : "", + plan: isSet(object.plan) ? Plan.fromSDKJSON(object.plan) : undefined + }; + }, + toSDK(message: MsgSoftwareUpgrade): MsgSoftwareUpgradeSDKType { + const obj: any = {}; + obj.authority = message.authority; + message.plan !== undefined && (obj.plan = message.plan ? Plan.toSDK(message.plan) : undefined); + return obj; + }, + fromAmino(object: MsgSoftwareUpgradeAmino): MsgSoftwareUpgrade { + const message = createBaseMsgSoftwareUpgrade(); + if (object.authority !== undefined && object.authority !== null) { + message.authority = object.authority; + } + if (object.plan !== undefined && object.plan !== null) { + message.plan = Plan.fromAmino(object.plan); + } + return message; + }, + toAmino(message: MsgSoftwareUpgrade): MsgSoftwareUpgradeAmino { + const obj: any = {}; + obj.authority = message.authority === "" ? undefined : message.authority; + obj.plan = message.plan ? Plan.toAmino(message.plan) : undefined; + return obj; + }, + fromAminoMsg(object: MsgSoftwareUpgradeAminoMsg): MsgSoftwareUpgrade { + return MsgSoftwareUpgrade.fromAmino(object.value); + }, + toAminoMsg(message: MsgSoftwareUpgrade): MsgSoftwareUpgradeAminoMsg { + return { + type: "cosmos-sdk/MsgSoftwareUpgrade", + value: MsgSoftwareUpgrade.toAmino(message) + }; + }, + fromProtoMsg(message: MsgSoftwareUpgradeProtoMsg): MsgSoftwareUpgrade { + return MsgSoftwareUpgrade.decode(message.value); + }, + toProto(message: MsgSoftwareUpgrade): Uint8Array { + return MsgSoftwareUpgrade.encode(message).finish(); + }, + toProtoMsg(message: MsgSoftwareUpgrade): MsgSoftwareUpgradeProtoMsg { + return { + typeUrl: "/cosmos.upgrade.v1beta1.MsgSoftwareUpgrade", + value: MsgSoftwareUpgrade.encode(message).finish() + }; + } +}; +function createBaseMsgSoftwareUpgradeResponse(): MsgSoftwareUpgradeResponse { + return {}; +} +export const MsgSoftwareUpgradeResponse = { + typeUrl: "/cosmos.upgrade.v1beta1.MsgSoftwareUpgradeResponse", + encode(_: MsgSoftwareUpgradeResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgSoftwareUpgradeResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgSoftwareUpgradeResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgSoftwareUpgradeResponse { + const obj = createBaseMsgSoftwareUpgradeResponse(); + return obj; + }, + toJSON(_: MsgSoftwareUpgradeResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): MsgSoftwareUpgradeResponse { + const message = createBaseMsgSoftwareUpgradeResponse(); + return message; + }, + fromSDK(_: MsgSoftwareUpgradeResponseSDKType): MsgSoftwareUpgradeResponse { + return {}; + }, + fromSDKJSON(_: any): MsgSoftwareUpgradeResponseSDKType { + return {}; + }, + toSDK(_: MsgSoftwareUpgradeResponse): MsgSoftwareUpgradeResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgSoftwareUpgradeResponseAmino): MsgSoftwareUpgradeResponse { + const message = createBaseMsgSoftwareUpgradeResponse(); + return message; + }, + toAmino(_: MsgSoftwareUpgradeResponse): MsgSoftwareUpgradeResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgSoftwareUpgradeResponseAminoMsg): MsgSoftwareUpgradeResponse { + return MsgSoftwareUpgradeResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgSoftwareUpgradeResponse): MsgSoftwareUpgradeResponseAminoMsg { + return { + type: "cosmos-sdk/MsgSoftwareUpgradeResponse", + value: MsgSoftwareUpgradeResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgSoftwareUpgradeResponseProtoMsg): MsgSoftwareUpgradeResponse { + return MsgSoftwareUpgradeResponse.decode(message.value); + }, + toProto(message: MsgSoftwareUpgradeResponse): Uint8Array { + return MsgSoftwareUpgradeResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgSoftwareUpgradeResponse): MsgSoftwareUpgradeResponseProtoMsg { + return { + typeUrl: "/cosmos.upgrade.v1beta1.MsgSoftwareUpgradeResponse", + value: MsgSoftwareUpgradeResponse.encode(message).finish() + }; + } +}; +function createBaseMsgCancelUpgrade(): MsgCancelUpgrade { + return { + authority: "" + }; +} +export const MsgCancelUpgrade = { + typeUrl: "/cosmos.upgrade.v1beta1.MsgCancelUpgrade", + encode(message: MsgCancelUpgrade, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.authority !== undefined) { + writer.uint32(10).string(message.authority); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgCancelUpgrade { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgCancelUpgrade(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.authority = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgCancelUpgrade { + const obj = createBaseMsgCancelUpgrade(); + if (isSet(object.authority)) obj.authority = String(object.authority); + return obj; + }, + toJSON(message: MsgCancelUpgrade): JsonSafe { + const obj: any = {}; + message.authority !== undefined && (obj.authority = message.authority); + return obj; + }, + fromPartial(object: DeepPartial): MsgCancelUpgrade { + const message = createBaseMsgCancelUpgrade(); + message.authority = object.authority ?? ""; + return message; + }, + fromSDK(object: MsgCancelUpgradeSDKType): MsgCancelUpgrade { + return { + authority: object?.authority + }; + }, + fromSDKJSON(object: any): MsgCancelUpgradeSDKType { + return { + authority: isSet(object.authority) ? String(object.authority) : "" + }; + }, + toSDK(message: MsgCancelUpgrade): MsgCancelUpgradeSDKType { + const obj: any = {}; + obj.authority = message.authority; + return obj; + }, + fromAmino(object: MsgCancelUpgradeAmino): MsgCancelUpgrade { + const message = createBaseMsgCancelUpgrade(); + if (object.authority !== undefined && object.authority !== null) { + message.authority = object.authority; + } + return message; + }, + toAmino(message: MsgCancelUpgrade): MsgCancelUpgradeAmino { + const obj: any = {}; + obj.authority = message.authority === "" ? undefined : message.authority; + return obj; + }, + fromAminoMsg(object: MsgCancelUpgradeAminoMsg): MsgCancelUpgrade { + return MsgCancelUpgrade.fromAmino(object.value); + }, + toAminoMsg(message: MsgCancelUpgrade): MsgCancelUpgradeAminoMsg { + return { + type: "cosmos-sdk/MsgCancelUpgrade", + value: MsgCancelUpgrade.toAmino(message) + }; + }, + fromProtoMsg(message: MsgCancelUpgradeProtoMsg): MsgCancelUpgrade { + return MsgCancelUpgrade.decode(message.value); + }, + toProto(message: MsgCancelUpgrade): Uint8Array { + return MsgCancelUpgrade.encode(message).finish(); + }, + toProtoMsg(message: MsgCancelUpgrade): MsgCancelUpgradeProtoMsg { + return { + typeUrl: "/cosmos.upgrade.v1beta1.MsgCancelUpgrade", + value: MsgCancelUpgrade.encode(message).finish() + }; + } +}; +function createBaseMsgCancelUpgradeResponse(): MsgCancelUpgradeResponse { + return {}; +} +export const MsgCancelUpgradeResponse = { + typeUrl: "/cosmos.upgrade.v1beta1.MsgCancelUpgradeResponse", + encode(_: MsgCancelUpgradeResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgCancelUpgradeResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgCancelUpgradeResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgCancelUpgradeResponse { + const obj = createBaseMsgCancelUpgradeResponse(); + return obj; + }, + toJSON(_: MsgCancelUpgradeResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): MsgCancelUpgradeResponse { + const message = createBaseMsgCancelUpgradeResponse(); + return message; + }, + fromSDK(_: MsgCancelUpgradeResponseSDKType): MsgCancelUpgradeResponse { + return {}; + }, + fromSDKJSON(_: any): MsgCancelUpgradeResponseSDKType { + return {}; + }, + toSDK(_: MsgCancelUpgradeResponse): MsgCancelUpgradeResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgCancelUpgradeResponseAmino): MsgCancelUpgradeResponse { + const message = createBaseMsgCancelUpgradeResponse(); + return message; + }, + toAmino(_: MsgCancelUpgradeResponse): MsgCancelUpgradeResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgCancelUpgradeResponseAminoMsg): MsgCancelUpgradeResponse { + return MsgCancelUpgradeResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgCancelUpgradeResponse): MsgCancelUpgradeResponseAminoMsg { + return { + type: "cosmos-sdk/MsgCancelUpgradeResponse", + value: MsgCancelUpgradeResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgCancelUpgradeResponseProtoMsg): MsgCancelUpgradeResponse { + return MsgCancelUpgradeResponse.decode(message.value); + }, + toProto(message: MsgCancelUpgradeResponse): Uint8Array { + return MsgCancelUpgradeResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgCancelUpgradeResponse): MsgCancelUpgradeResponseProtoMsg { + return { + typeUrl: "/cosmos.upgrade.v1beta1.MsgCancelUpgradeResponse", + value: MsgCancelUpgradeResponse.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/upgrade/v1beta1/upgrade.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/upgrade/v1beta1/upgrade.ts new file mode 100644 index 0000000000..0c594529ac --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/upgrade/v1beta1/upgrade.ts @@ -0,0 +1,655 @@ +import { Timestamp, TimestampSDKType } from "../../../google/protobuf/timestamp.js"; +import { Any, AnySDKType } from "../../../google/protobuf/any.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { toTimestamp, fromTimestamp, isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "cosmos.upgrade.v1beta1"; +/** Plan specifies information about a planned upgrade and when it should occur. */ +export interface Plan { + /** + * Sets the name for the upgrade. This name will be used by the upgraded + * version of the software to apply any special "on-upgrade" commands during + * the first BeginBlock method after the upgrade is applied. It is also used + * to detect whether a software version can handle a given upgrade. If no + * upgrade handler with this name has been set in the software, it will be + * assumed that the software is out-of-date when the upgrade Time or Height is + * reached and the software will exit. + */ + name: string; + /** + * Deprecated: Time based upgrades have been deprecated. Time based upgrade logic + * has been removed from the SDK. + * If this field is not empty, an error will be thrown. + */ + /** @deprecated */ + time: Date; + /** + * The height at which the upgrade must be performed. + * Only used if Time is not set. + */ + height: bigint; + /** + * Any application specific upgrade info to be included on-chain + * such as a git commit that validators could automatically upgrade to + */ + info: string; + /** + * Deprecated: UpgradedClientState field has been deprecated. IBC upgrade logic has been + * moved to the IBC module in the sub module 02-client. + * If this field is not empty, an error will be thrown. + */ + /** @deprecated */ + upgradedClientState?: Any; +} +export interface PlanProtoMsg { + typeUrl: "/cosmos.upgrade.v1beta1.Plan"; + value: Uint8Array; +} +/** Plan specifies information about a planned upgrade and when it should occur. */ +export interface PlanSDKType { + name: string; + /** @deprecated */ + time: Date; + height: bigint; + info: string; + /** @deprecated */ + upgraded_client_state?: AnySDKType; +} +/** + * SoftwareUpgradeProposal is a gov Content type for initiating a software + * upgrade. + * Deprecated: This legacy proposal is deprecated in favor of Msg-based gov + * proposals, see MsgSoftwareUpgrade. + */ +/** @deprecated */ +export interface SoftwareUpgradeProposal { + title: string; + description: string; + plan: Plan; +} +export interface SoftwareUpgradeProposalProtoMsg { + typeUrl: "/cosmos.upgrade.v1beta1.SoftwareUpgradeProposal"; + value: Uint8Array; +} +/** + * SoftwareUpgradeProposal is a gov Content type for initiating a software + * upgrade. + * Deprecated: This legacy proposal is deprecated in favor of Msg-based gov + * proposals, see MsgSoftwareUpgrade. + */ +/** @deprecated */ +export interface SoftwareUpgradeProposalSDKType { + title: string; + description: string; + plan: PlanSDKType; +} +/** + * CancelSoftwareUpgradeProposal is a gov Content type for cancelling a software + * upgrade. + * Deprecated: This legacy proposal is deprecated in favor of Msg-based gov + * proposals, see MsgCancelUpgrade. + */ +/** @deprecated */ +export interface CancelSoftwareUpgradeProposal { + title: string; + description: string; +} +export interface CancelSoftwareUpgradeProposalProtoMsg { + typeUrl: "/cosmos.upgrade.v1beta1.CancelSoftwareUpgradeProposal"; + value: Uint8Array; +} +/** + * CancelSoftwareUpgradeProposal is a gov Content type for cancelling a software + * upgrade. + * Deprecated: This legacy proposal is deprecated in favor of Msg-based gov + * proposals, see MsgCancelUpgrade. + */ +/** @deprecated */ +export interface CancelSoftwareUpgradeProposalSDKType { + title: string; + description: string; +} +/** + * ModuleVersion specifies a module and its consensus version. + * + * Since: cosmos-sdk 0.43 + */ +export interface ModuleVersion { + /** name of the app module */ + name: string; + /** consensus version of the app module */ + version: bigint; +} +export interface ModuleVersionProtoMsg { + typeUrl: "/cosmos.upgrade.v1beta1.ModuleVersion"; + value: Uint8Array; +} +/** + * ModuleVersion specifies a module and its consensus version. + * + * Since: cosmos-sdk 0.43 + */ +export interface ModuleVersionSDKType { + name: string; + version: bigint; +} +function createBasePlan(): Plan { + return { + name: "", + time: new Date(), + height: BigInt(0), + info: "", + upgradedClientState: undefined + }; +} +export const Plan = { + typeUrl: "/cosmos.upgrade.v1beta1.Plan", + encode(message: Plan, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + if (message.time !== undefined) { + Timestamp.encode(toTimestamp(message.time), writer.uint32(18).fork()).ldelim(); + } + if (message.height !== undefined) { + writer.uint32(24).int64(message.height); + } + if (message.info !== undefined) { + writer.uint32(34).string(message.info); + } + if (message.upgradedClientState !== undefined) { + Any.encode(message.upgradedClientState, writer.uint32(42).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Plan { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBasePlan(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.time = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + break; + case 3: + message.height = reader.int64(); + break; + case 4: + message.info = reader.string(); + break; + case 5: + message.upgradedClientState = Any.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Plan { + const obj = createBasePlan(); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.time)) obj.time = new Date(object.time); + if (isSet(object.height)) obj.height = BigInt(object.height.toString()); + if (isSet(object.info)) obj.info = String(object.info); + if (isSet(object.upgradedClientState)) obj.upgradedClientState = Any.fromJSON(object.upgradedClientState); + return obj; + }, + toJSON(message: Plan): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.time !== undefined && (obj.time = message.time.toISOString()); + message.height !== undefined && (obj.height = (message.height || BigInt(0)).toString()); + message.info !== undefined && (obj.info = message.info); + message.upgradedClientState !== undefined && (obj.upgradedClientState = message.upgradedClientState ? Any.toJSON(message.upgradedClientState) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): Plan { + const message = createBasePlan(); + message.name = object.name ?? ""; + message.time = object.time ?? undefined; + if (object.height !== undefined && object.height !== null) { + message.height = BigInt(object.height.toString()); + } + message.info = object.info ?? ""; + if (object.upgradedClientState !== undefined && object.upgradedClientState !== null) { + message.upgradedClientState = Any.fromPartial(object.upgradedClientState); + } + return message; + }, + fromSDK(object: PlanSDKType): Plan { + return { + name: object?.name, + time: object.time ?? undefined, + height: object?.height, + info: object?.info, + upgradedClientState: object.upgraded_client_state ? Any.fromSDK(object.upgraded_client_state) : undefined + }; + }, + fromSDKJSON(object: any): PlanSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + time: isSet(object.time) ? new Date(object.time) : undefined, + height: isSet(object.height) ? BigInt(object.height.toString()) : BigInt(0), + info: isSet(object.info) ? String(object.info) : "", + upgraded_client_state: isSet(object.upgraded_client_state) ? Any.fromSDKJSON(object.upgraded_client_state) : undefined + }; + }, + toSDK(message: Plan): PlanSDKType { + const obj: any = {}; + obj.name = message.name; + message.time !== undefined && (obj.time = message.time ?? undefined); + obj.height = message.height; + obj.info = message.info; + message.upgradedClientState !== undefined && (obj.upgraded_client_state = message.upgradedClientState ? Any.toSDK(message.upgradedClientState) : undefined); + return obj; + }, + fromAmino(object: PlanAmino): Plan { + const message = createBasePlan(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + if (object.time !== undefined && object.time !== null) { + message.time = fromTimestamp(Timestamp.fromAmino(object.time)); + } + if (object.height !== undefined && object.height !== null) { + message.height = BigInt(object.height); + } + if (object.info !== undefined && object.info !== null) { + message.info = object.info; + } + if (object.upgraded_client_state !== undefined && object.upgraded_client_state !== null) { + message.upgradedClientState = Any.fromAmino(object.upgraded_client_state); + } + return message; + }, + toAmino(message: Plan): PlanAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + obj.time = message.time ? Timestamp.toAmino(toTimestamp(message.time)) : undefined; + obj.height = message.height !== BigInt(0) ? message.height?.toString() : undefined; + obj.info = message.info === "" ? undefined : message.info; + obj.upgraded_client_state = message.upgradedClientState ? Any.toAmino(message.upgradedClientState) : undefined; + return obj; + }, + fromAminoMsg(object: PlanAminoMsg): Plan { + return Plan.fromAmino(object.value); + }, + toAminoMsg(message: Plan): PlanAminoMsg { + return { + type: "cosmos-sdk/Plan", + value: Plan.toAmino(message) + }; + }, + fromProtoMsg(message: PlanProtoMsg): Plan { + return Plan.decode(message.value); + }, + toProto(message: Plan): Uint8Array { + return Plan.encode(message).finish(); + }, + toProtoMsg(message: Plan): PlanProtoMsg { + return { + typeUrl: "/cosmos.upgrade.v1beta1.Plan", + value: Plan.encode(message).finish() + }; + } +}; +function createBaseSoftwareUpgradeProposal(): SoftwareUpgradeProposal { + return { + title: "", + description: "", + plan: Plan.fromPartial({}) + }; +} +export const SoftwareUpgradeProposal = { + typeUrl: "/cosmos.upgrade.v1beta1.SoftwareUpgradeProposal", + encode(message: SoftwareUpgradeProposal, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.title !== undefined) { + writer.uint32(10).string(message.title); + } + if (message.description !== undefined) { + writer.uint32(18).string(message.description); + } + if (message.plan !== undefined) { + Plan.encode(message.plan, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): SoftwareUpgradeProposal { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseSoftwareUpgradeProposal(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.title = reader.string(); + break; + case 2: + message.description = reader.string(); + break; + case 3: + message.plan = Plan.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): SoftwareUpgradeProposal { + const obj = createBaseSoftwareUpgradeProposal(); + if (isSet(object.title)) obj.title = String(object.title); + if (isSet(object.description)) obj.description = String(object.description); + if (isSet(object.plan)) obj.plan = Plan.fromJSON(object.plan); + return obj; + }, + toJSON(message: SoftwareUpgradeProposal): JsonSafe { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && (obj.description = message.description); + message.plan !== undefined && (obj.plan = message.plan ? Plan.toJSON(message.plan) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): SoftwareUpgradeProposal { + const message = createBaseSoftwareUpgradeProposal(); + message.title = object.title ?? ""; + message.description = object.description ?? ""; + if (object.plan !== undefined && object.plan !== null) { + message.plan = Plan.fromPartial(object.plan); + } + return message; + }, + fromSDK(object: SoftwareUpgradeProposalSDKType): SoftwareUpgradeProposal { + return { + title: object?.title, + description: object?.description, + plan: object.plan ? Plan.fromSDK(object.plan) : undefined + }; + }, + fromSDKJSON(object: any): SoftwareUpgradeProposalSDKType { + return { + title: isSet(object.title) ? String(object.title) : "", + description: isSet(object.description) ? String(object.description) : "", + plan: isSet(object.plan) ? Plan.fromSDKJSON(object.plan) : undefined + }; + }, + toSDK(message: SoftwareUpgradeProposal): SoftwareUpgradeProposalSDKType { + const obj: any = {}; + obj.title = message.title; + obj.description = message.description; + message.plan !== undefined && (obj.plan = message.plan ? Plan.toSDK(message.plan) : undefined); + return obj; + }, + fromAmino(object: SoftwareUpgradeProposalAmino): SoftwareUpgradeProposal { + const message = createBaseSoftwareUpgradeProposal(); + if (object.title !== undefined && object.title !== null) { + message.title = object.title; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } + if (object.plan !== undefined && object.plan !== null) { + message.plan = Plan.fromAmino(object.plan); + } + return message; + }, + toAmino(message: SoftwareUpgradeProposal): SoftwareUpgradeProposalAmino { + const obj: any = {}; + obj.title = message.title === "" ? undefined : message.title; + obj.description = message.description === "" ? undefined : message.description; + obj.plan = message.plan ? Plan.toAmino(message.plan) : undefined; + return obj; + }, + fromAminoMsg(object: SoftwareUpgradeProposalAminoMsg): SoftwareUpgradeProposal { + return SoftwareUpgradeProposal.fromAmino(object.value); + }, + toAminoMsg(message: SoftwareUpgradeProposal): SoftwareUpgradeProposalAminoMsg { + return { + type: "cosmos-sdk/SoftwareUpgradeProposal", + value: SoftwareUpgradeProposal.toAmino(message) + }; + }, + fromProtoMsg(message: SoftwareUpgradeProposalProtoMsg): SoftwareUpgradeProposal { + return SoftwareUpgradeProposal.decode(message.value); + }, + toProto(message: SoftwareUpgradeProposal): Uint8Array { + return SoftwareUpgradeProposal.encode(message).finish(); + }, + toProtoMsg(message: SoftwareUpgradeProposal): SoftwareUpgradeProposalProtoMsg { + return { + typeUrl: "/cosmos.upgrade.v1beta1.SoftwareUpgradeProposal", + value: SoftwareUpgradeProposal.encode(message).finish() + }; + } +}; +function createBaseCancelSoftwareUpgradeProposal(): CancelSoftwareUpgradeProposal { + return { + title: "", + description: "" + }; +} +export const CancelSoftwareUpgradeProposal = { + typeUrl: "/cosmos.upgrade.v1beta1.CancelSoftwareUpgradeProposal", + encode(message: CancelSoftwareUpgradeProposal, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.title !== undefined) { + writer.uint32(10).string(message.title); + } + if (message.description !== undefined) { + writer.uint32(18).string(message.description); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): CancelSoftwareUpgradeProposal { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCancelSoftwareUpgradeProposal(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.title = reader.string(); + break; + case 2: + message.description = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): CancelSoftwareUpgradeProposal { + const obj = createBaseCancelSoftwareUpgradeProposal(); + if (isSet(object.title)) obj.title = String(object.title); + if (isSet(object.description)) obj.description = String(object.description); + return obj; + }, + toJSON(message: CancelSoftwareUpgradeProposal): JsonSafe { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && (obj.description = message.description); + return obj; + }, + fromPartial(object: DeepPartial): CancelSoftwareUpgradeProposal { + const message = createBaseCancelSoftwareUpgradeProposal(); + message.title = object.title ?? ""; + message.description = object.description ?? ""; + return message; + }, + fromSDK(object: CancelSoftwareUpgradeProposalSDKType): CancelSoftwareUpgradeProposal { + return { + title: object?.title, + description: object?.description + }; + }, + fromSDKJSON(object: any): CancelSoftwareUpgradeProposalSDKType { + return { + title: isSet(object.title) ? String(object.title) : "", + description: isSet(object.description) ? String(object.description) : "" + }; + }, + toSDK(message: CancelSoftwareUpgradeProposal): CancelSoftwareUpgradeProposalSDKType { + const obj: any = {}; + obj.title = message.title; + obj.description = message.description; + return obj; + }, + fromAmino(object: CancelSoftwareUpgradeProposalAmino): CancelSoftwareUpgradeProposal { + const message = createBaseCancelSoftwareUpgradeProposal(); + if (object.title !== undefined && object.title !== null) { + message.title = object.title; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } + return message; + }, + toAmino(message: CancelSoftwareUpgradeProposal): CancelSoftwareUpgradeProposalAmino { + const obj: any = {}; + obj.title = message.title === "" ? undefined : message.title; + obj.description = message.description === "" ? undefined : message.description; + return obj; + }, + fromAminoMsg(object: CancelSoftwareUpgradeProposalAminoMsg): CancelSoftwareUpgradeProposal { + return CancelSoftwareUpgradeProposal.fromAmino(object.value); + }, + toAminoMsg(message: CancelSoftwareUpgradeProposal): CancelSoftwareUpgradeProposalAminoMsg { + return { + type: "cosmos-sdk/CancelSoftwareUpgradeProposal", + value: CancelSoftwareUpgradeProposal.toAmino(message) + }; + }, + fromProtoMsg(message: CancelSoftwareUpgradeProposalProtoMsg): CancelSoftwareUpgradeProposal { + return CancelSoftwareUpgradeProposal.decode(message.value); + }, + toProto(message: CancelSoftwareUpgradeProposal): Uint8Array { + return CancelSoftwareUpgradeProposal.encode(message).finish(); + }, + toProtoMsg(message: CancelSoftwareUpgradeProposal): CancelSoftwareUpgradeProposalProtoMsg { + return { + typeUrl: "/cosmos.upgrade.v1beta1.CancelSoftwareUpgradeProposal", + value: CancelSoftwareUpgradeProposal.encode(message).finish() + }; + } +}; +function createBaseModuleVersion(): ModuleVersion { + return { + name: "", + version: BigInt(0) + }; +} +export const ModuleVersion = { + typeUrl: "/cosmos.upgrade.v1beta1.ModuleVersion", + encode(message: ModuleVersion, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + if (message.version !== undefined) { + writer.uint32(16).uint64(message.version); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ModuleVersion { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseModuleVersion(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.version = reader.uint64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ModuleVersion { + const obj = createBaseModuleVersion(); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.version)) obj.version = BigInt(object.version.toString()); + return obj; + }, + toJSON(message: ModuleVersion): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.version !== undefined && (obj.version = (message.version || BigInt(0)).toString()); + return obj; + }, + fromPartial(object: DeepPartial): ModuleVersion { + const message = createBaseModuleVersion(); + message.name = object.name ?? ""; + if (object.version !== undefined && object.version !== null) { + message.version = BigInt(object.version.toString()); + } + return message; + }, + fromSDK(object: ModuleVersionSDKType): ModuleVersion { + return { + name: object?.name, + version: object?.version + }; + }, + fromSDKJSON(object: any): ModuleVersionSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + version: isSet(object.version) ? BigInt(object.version.toString()) : BigInt(0) + }; + }, + toSDK(message: ModuleVersion): ModuleVersionSDKType { + const obj: any = {}; + obj.name = message.name; + obj.version = message.version; + return obj; + }, + fromAmino(object: ModuleVersionAmino): ModuleVersion { + const message = createBaseModuleVersion(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + if (object.version !== undefined && object.version !== null) { + message.version = BigInt(object.version); + } + return message; + }, + toAmino(message: ModuleVersion): ModuleVersionAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + obj.version = message.version !== BigInt(0) ? message.version?.toString() : undefined; + return obj; + }, + fromAminoMsg(object: ModuleVersionAminoMsg): ModuleVersion { + return ModuleVersion.fromAmino(object.value); + }, + toAminoMsg(message: ModuleVersion): ModuleVersionAminoMsg { + return { + type: "cosmos-sdk/ModuleVersion", + value: ModuleVersion.toAmino(message) + }; + }, + fromProtoMsg(message: ModuleVersionProtoMsg): ModuleVersion { + return ModuleVersion.decode(message.value); + }, + toProto(message: ModuleVersion): Uint8Array { + return ModuleVersion.encode(message).finish(); + }, + toProtoMsg(message: ModuleVersion): ModuleVersionProtoMsg { + return { + typeUrl: "/cosmos.upgrade.v1beta1.ModuleVersion", + value: ModuleVersion.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/vesting/v1beta1/tx.amino.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/vesting/v1beta1/tx.amino.ts new file mode 100644 index 0000000000..9ca0a496f2 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/vesting/v1beta1/tx.amino.ts @@ -0,0 +1,156 @@ +import { Coin, CoinSDKType } from "../../base/v1beta1/coin.js"; +import { Period, PeriodSDKType } from "./vesting.js"; +import { ReadOnlyAminoMsg as AminoMsg } from "@interchainjs/ReadOnlyAminoMsg"; +import { MsgCreateVestingAccount, MsgCreateVestingAccountSDKType, MsgCreatePermanentLockedAccount, MsgCreatePermanentLockedAccountSDKType, MsgCreatePeriodicVestingAccount, MsgCreatePeriodicVestingAccountSDKType } from "./tx.js"; +export interface MsgCreateVestingAccountAminoType extends AminoMsg { + type: "cosmos-sdk/MsgCreateVestingAccount"; + value: { + from_address: string; + to_address: string; + amount: { + denom: string; + amount: string; + }[]; + end_time: string; + delayed: boolean; + }; +} +export interface MsgCreatePermanentLockedAccountAminoType extends AminoMsg { + type: "cosmos-sdk/MsgCreatePermanentLockedAccount"; + value: { + from_address: string; + to_address: string; + amount: { + denom: string; + amount: string; + }[]; + }; +} +export interface MsgCreatePeriodicVestingAccountAminoType extends AminoMsg { + type: "cosmos-sdk/MsgCreatePeriodicVestingAccount"; + value: { + from_address: string; + to_address: string; + start_time: string; + vesting_periods: { + length: string; + amount: { + denom: string; + amount: string; + }[]; + }[]; + }; +} +export const AminoConverter = { + "/cosmos.vesting.v1beta1.MsgCreateVestingAccount": { + aminoType: "cosmos-sdk/MsgCreateVestingAccount", + toAmino: ({ + fromAddress, + toAddress, + amount, + endTime, + delayed + }: MsgCreateVestingAccount): MsgCreateVestingAccountAminoType["value"] => { + return { + from_address: fromAddress, + to_address: toAddress, + amount: amount.map(el0 => ({ + denom: el0.denom, + amount: el0.amount + })), + end_time: endTime.toString(), + delayed + }; + }, + fromAmino: ({ + from_address, + to_address, + amount, + end_time, + delayed + }: MsgCreateVestingAccountAminoType["value"]): MsgCreateVestingAccount => { + return { + fromAddress: from_address, + toAddress: to_address, + amount: amount.map(el0 => ({ + denom: el0.denom, + amount: el0.amount + })), + endTime: BigInt(end_time), + delayed + }; + } + }, + "/cosmos.vesting.v1beta1.MsgCreatePermanentLockedAccount": { + aminoType: "cosmos-sdk/MsgCreatePermanentLockedAccount", + toAmino: ({ + fromAddress, + toAddress, + amount + }: MsgCreatePermanentLockedAccount): MsgCreatePermanentLockedAccountAminoType["value"] => { + return { + from_address: fromAddress, + to_address: toAddress, + amount: amount.map(el0 => ({ + denom: el0.denom, + amount: el0.amount + })) + }; + }, + fromAmino: ({ + from_address, + to_address, + amount + }: MsgCreatePermanentLockedAccountAminoType["value"]): MsgCreatePermanentLockedAccount => { + return { + fromAddress: from_address, + toAddress: to_address, + amount: amount.map(el0 => ({ + denom: el0.denom, + amount: el0.amount + })) + }; + } + }, + "/cosmos.vesting.v1beta1.MsgCreatePeriodicVestingAccount": { + aminoType: "cosmos-sdk/MsgCreatePeriodicVestingAccount", + toAmino: ({ + fromAddress, + toAddress, + startTime, + vestingPeriods + }: MsgCreatePeriodicVestingAccount): MsgCreatePeriodicVestingAccountAminoType["value"] => { + return { + from_address: fromAddress, + to_address: toAddress, + start_time: startTime.toString(), + vesting_periods: vestingPeriods.map(el0 => ({ + length: el0.length.toString(), + amount: el0.amount.map(el1 => ({ + denom: el1.denom, + amount: el1.amount + })) + })) + }; + }, + fromAmino: ({ + from_address, + to_address, + start_time, + vesting_periods + }: MsgCreatePeriodicVestingAccountAminoType["value"]): MsgCreatePeriodicVestingAccount => { + return { + fromAddress: from_address, + toAddress: to_address, + startTime: BigInt(start_time), + vestingPeriods: vesting_periods.map(el0 => ({ + length: BigInt(el0.length), + amount: el0.amount.map(el1 => ({ + denom: el1.denom, + amount: el1.amount + })) + })) + }; + } + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/vesting/v1beta1/tx.registry.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/vesting/v1beta1/tx.registry.ts new file mode 100644 index 0000000000..6351c655d7 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/vesting/v1beta1/tx.registry.ts @@ -0,0 +1,112 @@ +import { Coin, CoinSDKType } from "../../base/v1beta1/coin.js"; +import { Period, PeriodSDKType } from "./vesting.js"; +import { GeneratedType, Registry } from "@cosmjs/proto-signing"; +import { MsgCreateVestingAccount, MsgCreateVestingAccountSDKType, MsgCreatePermanentLockedAccount, MsgCreatePermanentLockedAccountSDKType, MsgCreatePeriodicVestingAccount, MsgCreatePeriodicVestingAccountSDKType } from "./tx.js"; +export const registry: ReadonlyArray<[string, GeneratedType]> = [["/cosmos.vesting.v1beta1.MsgCreateVestingAccount", MsgCreateVestingAccount], ["/cosmos.vesting.v1beta1.MsgCreatePermanentLockedAccount", MsgCreatePermanentLockedAccount], ["/cosmos.vesting.v1beta1.MsgCreatePeriodicVestingAccount", MsgCreatePeriodicVestingAccount]]; +export const load = (protoRegistry: Registry) => { + registry.forEach(([typeUrl, mod]) => { + protoRegistry.register(typeUrl, mod); + }); +}; +export const MessageComposer = { + encoded: { + createVestingAccount(value: MsgCreateVestingAccount) { + return { + typeUrl: "/cosmos.vesting.v1beta1.MsgCreateVestingAccount", + value: MsgCreateVestingAccount.encode(value).finish() + }; + }, + createPermanentLockedAccount(value: MsgCreatePermanentLockedAccount) { + return { + typeUrl: "/cosmos.vesting.v1beta1.MsgCreatePermanentLockedAccount", + value: MsgCreatePermanentLockedAccount.encode(value).finish() + }; + }, + createPeriodicVestingAccount(value: MsgCreatePeriodicVestingAccount) { + return { + typeUrl: "/cosmos.vesting.v1beta1.MsgCreatePeriodicVestingAccount", + value: MsgCreatePeriodicVestingAccount.encode(value).finish() + }; + } + }, + withTypeUrl: { + createVestingAccount(value: MsgCreateVestingAccount) { + return { + typeUrl: "/cosmos.vesting.v1beta1.MsgCreateVestingAccount", + value + }; + }, + createPermanentLockedAccount(value: MsgCreatePermanentLockedAccount) { + return { + typeUrl: "/cosmos.vesting.v1beta1.MsgCreatePermanentLockedAccount", + value + }; + }, + createPeriodicVestingAccount(value: MsgCreatePeriodicVestingAccount) { + return { + typeUrl: "/cosmos.vesting.v1beta1.MsgCreatePeriodicVestingAccount", + value + }; + } + }, + toJSON: { + createVestingAccount(value: MsgCreateVestingAccount) { + return { + typeUrl: "/cosmos.vesting.v1beta1.MsgCreateVestingAccount", + value: MsgCreateVestingAccount.toJSON(value) + }; + }, + createPermanentLockedAccount(value: MsgCreatePermanentLockedAccount) { + return { + typeUrl: "/cosmos.vesting.v1beta1.MsgCreatePermanentLockedAccount", + value: MsgCreatePermanentLockedAccount.toJSON(value) + }; + }, + createPeriodicVestingAccount(value: MsgCreatePeriodicVestingAccount) { + return { + typeUrl: "/cosmos.vesting.v1beta1.MsgCreatePeriodicVestingAccount", + value: MsgCreatePeriodicVestingAccount.toJSON(value) + }; + } + }, + fromJSON: { + createVestingAccount(value: any) { + return { + typeUrl: "/cosmos.vesting.v1beta1.MsgCreateVestingAccount", + value: MsgCreateVestingAccount.fromJSON(value) + }; + }, + createPermanentLockedAccount(value: any) { + return { + typeUrl: "/cosmos.vesting.v1beta1.MsgCreatePermanentLockedAccount", + value: MsgCreatePermanentLockedAccount.fromJSON(value) + }; + }, + createPeriodicVestingAccount(value: any) { + return { + typeUrl: "/cosmos.vesting.v1beta1.MsgCreatePeriodicVestingAccount", + value: MsgCreatePeriodicVestingAccount.fromJSON(value) + }; + } + }, + fromPartial: { + createVestingAccount(value: MsgCreateVestingAccount) { + return { + typeUrl: "/cosmos.vesting.v1beta1.MsgCreateVestingAccount", + value: MsgCreateVestingAccount.fromPartial(value) + }; + }, + createPermanentLockedAccount(value: MsgCreatePermanentLockedAccount) { + return { + typeUrl: "/cosmos.vesting.v1beta1.MsgCreatePermanentLockedAccount", + value: MsgCreatePermanentLockedAccount.fromPartial(value) + }; + }, + createPeriodicVestingAccount(value: MsgCreatePeriodicVestingAccount) { + return { + typeUrl: "/cosmos.vesting.v1beta1.MsgCreatePeriodicVestingAccount", + value: MsgCreatePeriodicVestingAccount.fromPartial(value) + }; + } + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/vesting/v1beta1/tx.rpc.func.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/vesting/v1beta1/tx.rpc.func.ts new file mode 100644 index 0000000000..6168e11e32 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/vesting/v1beta1/tx.rpc.func.ts @@ -0,0 +1,31 @@ +import { buildTx, SigningClientResolver } from "../../../helper-func-types"; +import { buildUseMutation } from "../../../react-query"; +import { toEncoders, toConverters } from "@interchainjs/cosmos/utils"; +import { MsgCreateVestingAccount, MsgCreatePermanentLockedAccount, MsgCreatePeriodicVestingAccount } from "./tx"; +export const createCreateVestingAccount = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgCreateVestingAccount.typeUrl, + encoders: toEncoders(MsgCreateVestingAccount), + converters: toConverters(MsgCreateVestingAccount) +}); +export const useCreateVestingAccount = buildUseMutation({ + builderMutationFn: createCreateVestingAccount +}); +export const createCreatePermanentLockedAccount = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgCreatePermanentLockedAccount.typeUrl, + encoders: toEncoders(MsgCreatePermanentLockedAccount), + converters: toConverters(MsgCreatePermanentLockedAccount) +}); +export const useCreatePermanentLockedAccount = buildUseMutation({ + builderMutationFn: createCreatePermanentLockedAccount +}); +export const createCreatePeriodicVestingAccount = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgCreatePeriodicVestingAccount.typeUrl, + encoders: toEncoders(MsgCreatePeriodicVestingAccount), + converters: toConverters(MsgCreatePeriodicVestingAccount) +}); +export const useCreatePeriodicVestingAccount = buildUseMutation({ + builderMutationFn: createCreatePeriodicVestingAccount +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/vesting/v1beta1/tx.rpc.msg.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/vesting/v1beta1/tx.rpc.msg.ts new file mode 100644 index 0000000000..50da665cce --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/vesting/v1beta1/tx.rpc.msg.ts @@ -0,0 +1,50 @@ +import { Coin, CoinSDKType } from "../../base/v1beta1/coin.js"; +import { Period, PeriodSDKType } from "./vesting.js"; +import { Rpc } from "../../../helpers.js"; +import { BinaryReader } from "../../../binary.js"; +import { MsgCreateVestingAccount, MsgCreateVestingAccountSDKType, MsgCreateVestingAccountResponse, MsgCreateVestingAccountResponseSDKType, MsgCreatePermanentLockedAccount, MsgCreatePermanentLockedAccountSDKType, MsgCreatePermanentLockedAccountResponse, MsgCreatePermanentLockedAccountResponseSDKType, MsgCreatePeriodicVestingAccount, MsgCreatePeriodicVestingAccountSDKType, MsgCreatePeriodicVestingAccountResponse, MsgCreatePeriodicVestingAccountResponseSDKType } from "./tx.js"; +/** Msg defines the bank Msg service. */ +export interface Msg { + /** + * CreateVestingAccount defines a method that enables creating a vesting + * account. + */ + createVestingAccount(request: MsgCreateVestingAccount): Promise; + /** + * CreatePermanentLockedAccount defines a method that enables creating a permanent + * locked account. + */ + createPermanentLockedAccount(request: MsgCreatePermanentLockedAccount): Promise; + /** + * CreatePeriodicVestingAccount defines a method that enables creating a + * periodic vesting account. + */ + createPeriodicVestingAccount(request: MsgCreatePeriodicVestingAccount): Promise; +} +export class MsgClientImpl implements Msg { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + this.createVestingAccount = this.createVestingAccount.bind(this); + this.createPermanentLockedAccount = this.createPermanentLockedAccount.bind(this); + this.createPeriodicVestingAccount = this.createPeriodicVestingAccount.bind(this); + } + createVestingAccount(request: MsgCreateVestingAccount): Promise { + const data = MsgCreateVestingAccount.encode(request).finish(); + const promise = this.rpc.request("cosmos.vesting.v1beta1.Msg", "CreateVestingAccount", data); + return promise.then(data => MsgCreateVestingAccountResponse.decode(new BinaryReader(data))); + } + createPermanentLockedAccount(request: MsgCreatePermanentLockedAccount): Promise { + const data = MsgCreatePermanentLockedAccount.encode(request).finish(); + const promise = this.rpc.request("cosmos.vesting.v1beta1.Msg", "CreatePermanentLockedAccount", data); + return promise.then(data => MsgCreatePermanentLockedAccountResponse.decode(new BinaryReader(data))); + } + createPeriodicVestingAccount(request: MsgCreatePeriodicVestingAccount): Promise { + const data = MsgCreatePeriodicVestingAccount.encode(request).finish(); + const promise = this.rpc.request("cosmos.vesting.v1beta1.Msg", "CreatePeriodicVestingAccount", data); + return promise.then(data => MsgCreatePeriodicVestingAccountResponse.decode(new BinaryReader(data))); + } +} +export const createClientImpl = (rpc: Rpc) => { + return new MsgClientImpl(rpc); +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/vesting/v1beta1/tx.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/vesting/v1beta1/tx.ts new file mode 100644 index 0000000000..89f9703250 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/vesting/v1beta1/tx.ts @@ -0,0 +1,799 @@ +import { Coin, CoinSDKType } from "../../base/v1beta1/coin.js"; +import { Period, PeriodSDKType } from "./vesting.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "cosmos.vesting.v1beta1"; +/** + * MsgCreateVestingAccount defines a message that enables creating a vesting + * account. + */ +export interface MsgCreateVestingAccount { + fromAddress: string; + toAddress: string; + amount: Coin[]; + endTime: bigint; + delayed: boolean; +} +export interface MsgCreateVestingAccountProtoMsg { + typeUrl: "/cosmos.vesting.v1beta1.MsgCreateVestingAccount"; + value: Uint8Array; +} +/** + * MsgCreateVestingAccount defines a message that enables creating a vesting + * account. + */ +export interface MsgCreateVestingAccountSDKType { + from_address: string; + to_address: string; + amount: CoinSDKType[]; + end_time: bigint; + delayed: boolean; +} +/** MsgCreateVestingAccountResponse defines the Msg/CreateVestingAccount response type. */ +export interface MsgCreateVestingAccountResponse {} +export interface MsgCreateVestingAccountResponseProtoMsg { + typeUrl: "/cosmos.vesting.v1beta1.MsgCreateVestingAccountResponse"; + value: Uint8Array; +} +/** MsgCreateVestingAccountResponse defines the Msg/CreateVestingAccount response type. */ +export interface MsgCreateVestingAccountResponseSDKType {} +/** + * MsgCreatePermanentLockedAccount defines a message that enables creating a permanent + * locked account. + */ +export interface MsgCreatePermanentLockedAccount { + fromAddress: string; + toAddress: string; + amount: Coin[]; +} +export interface MsgCreatePermanentLockedAccountProtoMsg { + typeUrl: "/cosmos.vesting.v1beta1.MsgCreatePermanentLockedAccount"; + value: Uint8Array; +} +/** + * MsgCreatePermanentLockedAccount defines a message that enables creating a permanent + * locked account. + */ +export interface MsgCreatePermanentLockedAccountSDKType { + from_address: string; + to_address: string; + amount: CoinSDKType[]; +} +/** MsgCreatePermanentLockedAccountResponse defines the Msg/CreatePermanentLockedAccount response type. */ +export interface MsgCreatePermanentLockedAccountResponse {} +export interface MsgCreatePermanentLockedAccountResponseProtoMsg { + typeUrl: "/cosmos.vesting.v1beta1.MsgCreatePermanentLockedAccountResponse"; + value: Uint8Array; +} +/** MsgCreatePermanentLockedAccountResponse defines the Msg/CreatePermanentLockedAccount response type. */ +export interface MsgCreatePermanentLockedAccountResponseSDKType {} +/** + * MsgCreateVestingAccount defines a message that enables creating a vesting + * account. + */ +export interface MsgCreatePeriodicVestingAccount { + fromAddress: string; + toAddress: string; + startTime: bigint; + vestingPeriods: Period[]; +} +export interface MsgCreatePeriodicVestingAccountProtoMsg { + typeUrl: "/cosmos.vesting.v1beta1.MsgCreatePeriodicVestingAccount"; + value: Uint8Array; +} +/** + * MsgCreateVestingAccount defines a message that enables creating a vesting + * account. + */ +export interface MsgCreatePeriodicVestingAccountSDKType { + from_address: string; + to_address: string; + start_time: bigint; + vesting_periods: PeriodSDKType[]; +} +/** + * MsgCreateVestingAccountResponse defines the Msg/CreatePeriodicVestingAccount + * response type. + */ +export interface MsgCreatePeriodicVestingAccountResponse {} +export interface MsgCreatePeriodicVestingAccountResponseProtoMsg { + typeUrl: "/cosmos.vesting.v1beta1.MsgCreatePeriodicVestingAccountResponse"; + value: Uint8Array; +} +/** + * MsgCreateVestingAccountResponse defines the Msg/CreatePeriodicVestingAccount + * response type. + */ +export interface MsgCreatePeriodicVestingAccountResponseSDKType {} +function createBaseMsgCreateVestingAccount(): MsgCreateVestingAccount { + return { + fromAddress: "", + toAddress: "", + amount: [], + endTime: BigInt(0), + delayed: false + }; +} +export const MsgCreateVestingAccount = { + typeUrl: "/cosmos.vesting.v1beta1.MsgCreateVestingAccount", + encode(message: MsgCreateVestingAccount, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.fromAddress !== undefined) { + writer.uint32(10).string(message.fromAddress); + } + if (message.toAddress !== undefined) { + writer.uint32(18).string(message.toAddress); + } + for (const v of message.amount) { + Coin.encode(v!, writer.uint32(26).fork()).ldelim(); + } + if (message.endTime !== undefined) { + writer.uint32(32).int64(message.endTime); + } + if (message.delayed !== undefined) { + writer.uint32(40).bool(message.delayed); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgCreateVestingAccount { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgCreateVestingAccount(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.fromAddress = reader.string(); + break; + case 2: + message.toAddress = reader.string(); + break; + case 3: + message.amount.push(Coin.decode(reader, reader.uint32())); + break; + case 4: + message.endTime = reader.int64(); + break; + case 5: + message.delayed = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgCreateVestingAccount { + const obj = createBaseMsgCreateVestingAccount(); + if (isSet(object.fromAddress)) obj.fromAddress = String(object.fromAddress); + if (isSet(object.toAddress)) obj.toAddress = String(object.toAddress); + if (Array.isArray(object?.amount)) obj.amount = object.amount.map((e: any) => Coin.fromJSON(e)); + if (isSet(object.endTime)) obj.endTime = BigInt(object.endTime.toString()); + if (isSet(object.delayed)) obj.delayed = Boolean(object.delayed); + return obj; + }, + toJSON(message: MsgCreateVestingAccount): JsonSafe { + const obj: any = {}; + message.fromAddress !== undefined && (obj.fromAddress = message.fromAddress); + message.toAddress !== undefined && (obj.toAddress = message.toAddress); + if (message.amount) { + obj.amount = message.amount.map(e => e ? Coin.toJSON(e) : undefined); + } else { + obj.amount = []; + } + message.endTime !== undefined && (obj.endTime = (message.endTime || BigInt(0)).toString()); + message.delayed !== undefined && (obj.delayed = message.delayed); + return obj; + }, + fromPartial(object: DeepPartial): MsgCreateVestingAccount { + const message = createBaseMsgCreateVestingAccount(); + message.fromAddress = object.fromAddress ?? ""; + message.toAddress = object.toAddress ?? ""; + message.amount = object.amount?.map(e => Coin.fromPartial(e)) || []; + if (object.endTime !== undefined && object.endTime !== null) { + message.endTime = BigInt(object.endTime.toString()); + } + message.delayed = object.delayed ?? false; + return message; + }, + fromSDK(object: MsgCreateVestingAccountSDKType): MsgCreateVestingAccount { + return { + fromAddress: object?.from_address, + toAddress: object?.to_address, + amount: Array.isArray(object?.amount) ? object.amount.map((e: any) => Coin.fromSDK(e)) : [], + endTime: object?.end_time, + delayed: object?.delayed + }; + }, + fromSDKJSON(object: any): MsgCreateVestingAccountSDKType { + return { + from_address: isSet(object.from_address) ? String(object.from_address) : "", + to_address: isSet(object.to_address) ? String(object.to_address) : "", + amount: Array.isArray(object?.amount) ? object.amount.map((e: any) => Coin.fromSDKJSON(e)) : [], + end_time: isSet(object.end_time) ? BigInt(object.end_time.toString()) : BigInt(0), + delayed: isSet(object.delayed) ? Boolean(object.delayed) : false + }; + }, + toSDK(message: MsgCreateVestingAccount): MsgCreateVestingAccountSDKType { + const obj: any = {}; + obj.from_address = message.fromAddress; + obj.to_address = message.toAddress; + if (message.amount) { + obj.amount = message.amount.map(e => e ? Coin.toSDK(e) : undefined); + } else { + obj.amount = []; + } + obj.end_time = message.endTime; + obj.delayed = message.delayed; + return obj; + }, + fromAmino(object: MsgCreateVestingAccountAmino): MsgCreateVestingAccount { + const message = createBaseMsgCreateVestingAccount(); + if (object.from_address !== undefined && object.from_address !== null) { + message.fromAddress = object.from_address; + } + if (object.to_address !== undefined && object.to_address !== null) { + message.toAddress = object.to_address; + } + message.amount = object.amount?.map(e => Coin.fromAmino(e)) || []; + if (object.end_time !== undefined && object.end_time !== null) { + message.endTime = BigInt(object.end_time); + } + if (object.delayed !== undefined && object.delayed !== null) { + message.delayed = object.delayed; + } + return message; + }, + toAmino(message: MsgCreateVestingAccount): MsgCreateVestingAccountAmino { + const obj: any = {}; + obj.from_address = message.fromAddress === "" ? undefined : message.fromAddress; + obj.to_address = message.toAddress === "" ? undefined : message.toAddress; + if (message.amount) { + obj.amount = message.amount.map(e => e ? Coin.toAmino(e) : undefined); + } else { + obj.amount = message.amount; + } + obj.end_time = message.endTime !== BigInt(0) ? message.endTime?.toString() : undefined; + obj.delayed = message.delayed === false ? undefined : message.delayed; + return obj; + }, + fromAminoMsg(object: MsgCreateVestingAccountAminoMsg): MsgCreateVestingAccount { + return MsgCreateVestingAccount.fromAmino(object.value); + }, + toAminoMsg(message: MsgCreateVestingAccount): MsgCreateVestingAccountAminoMsg { + return { + type: "cosmos-sdk/MsgCreateVestingAccount", + value: MsgCreateVestingAccount.toAmino(message) + }; + }, + fromProtoMsg(message: MsgCreateVestingAccountProtoMsg): MsgCreateVestingAccount { + return MsgCreateVestingAccount.decode(message.value); + }, + toProto(message: MsgCreateVestingAccount): Uint8Array { + return MsgCreateVestingAccount.encode(message).finish(); + }, + toProtoMsg(message: MsgCreateVestingAccount): MsgCreateVestingAccountProtoMsg { + return { + typeUrl: "/cosmos.vesting.v1beta1.MsgCreateVestingAccount", + value: MsgCreateVestingAccount.encode(message).finish() + }; + } +}; +function createBaseMsgCreateVestingAccountResponse(): MsgCreateVestingAccountResponse { + return {}; +} +export const MsgCreateVestingAccountResponse = { + typeUrl: "/cosmos.vesting.v1beta1.MsgCreateVestingAccountResponse", + encode(_: MsgCreateVestingAccountResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgCreateVestingAccountResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgCreateVestingAccountResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgCreateVestingAccountResponse { + const obj = createBaseMsgCreateVestingAccountResponse(); + return obj; + }, + toJSON(_: MsgCreateVestingAccountResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): MsgCreateVestingAccountResponse { + const message = createBaseMsgCreateVestingAccountResponse(); + return message; + }, + fromSDK(_: MsgCreateVestingAccountResponseSDKType): MsgCreateVestingAccountResponse { + return {}; + }, + fromSDKJSON(_: any): MsgCreateVestingAccountResponseSDKType { + return {}; + }, + toSDK(_: MsgCreateVestingAccountResponse): MsgCreateVestingAccountResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgCreateVestingAccountResponseAmino): MsgCreateVestingAccountResponse { + const message = createBaseMsgCreateVestingAccountResponse(); + return message; + }, + toAmino(_: MsgCreateVestingAccountResponse): MsgCreateVestingAccountResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgCreateVestingAccountResponseAminoMsg): MsgCreateVestingAccountResponse { + return MsgCreateVestingAccountResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgCreateVestingAccountResponse): MsgCreateVestingAccountResponseAminoMsg { + return { + type: "cosmos-sdk/MsgCreateVestingAccountResponse", + value: MsgCreateVestingAccountResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgCreateVestingAccountResponseProtoMsg): MsgCreateVestingAccountResponse { + return MsgCreateVestingAccountResponse.decode(message.value); + }, + toProto(message: MsgCreateVestingAccountResponse): Uint8Array { + return MsgCreateVestingAccountResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgCreateVestingAccountResponse): MsgCreateVestingAccountResponseProtoMsg { + return { + typeUrl: "/cosmos.vesting.v1beta1.MsgCreateVestingAccountResponse", + value: MsgCreateVestingAccountResponse.encode(message).finish() + }; + } +}; +function createBaseMsgCreatePermanentLockedAccount(): MsgCreatePermanentLockedAccount { + return { + fromAddress: "", + toAddress: "", + amount: [] + }; +} +export const MsgCreatePermanentLockedAccount = { + typeUrl: "/cosmos.vesting.v1beta1.MsgCreatePermanentLockedAccount", + encode(message: MsgCreatePermanentLockedAccount, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.fromAddress !== undefined) { + writer.uint32(10).string(message.fromAddress); + } + if (message.toAddress !== undefined) { + writer.uint32(18).string(message.toAddress); + } + for (const v of message.amount) { + Coin.encode(v!, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgCreatePermanentLockedAccount { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgCreatePermanentLockedAccount(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.fromAddress = reader.string(); + break; + case 2: + message.toAddress = reader.string(); + break; + case 3: + message.amount.push(Coin.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgCreatePermanentLockedAccount { + const obj = createBaseMsgCreatePermanentLockedAccount(); + if (isSet(object.fromAddress)) obj.fromAddress = String(object.fromAddress); + if (isSet(object.toAddress)) obj.toAddress = String(object.toAddress); + if (Array.isArray(object?.amount)) obj.amount = object.amount.map((e: any) => Coin.fromJSON(e)); + return obj; + }, + toJSON(message: MsgCreatePermanentLockedAccount): JsonSafe { + const obj: any = {}; + message.fromAddress !== undefined && (obj.fromAddress = message.fromAddress); + message.toAddress !== undefined && (obj.toAddress = message.toAddress); + if (message.amount) { + obj.amount = message.amount.map(e => e ? Coin.toJSON(e) : undefined); + } else { + obj.amount = []; + } + return obj; + }, + fromPartial(object: DeepPartial): MsgCreatePermanentLockedAccount { + const message = createBaseMsgCreatePermanentLockedAccount(); + message.fromAddress = object.fromAddress ?? ""; + message.toAddress = object.toAddress ?? ""; + message.amount = object.amount?.map(e => Coin.fromPartial(e)) || []; + return message; + }, + fromSDK(object: MsgCreatePermanentLockedAccountSDKType): MsgCreatePermanentLockedAccount { + return { + fromAddress: object?.from_address, + toAddress: object?.to_address, + amount: Array.isArray(object?.amount) ? object.amount.map((e: any) => Coin.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): MsgCreatePermanentLockedAccountSDKType { + return { + from_address: isSet(object.from_address) ? String(object.from_address) : "", + to_address: isSet(object.to_address) ? String(object.to_address) : "", + amount: Array.isArray(object?.amount) ? object.amount.map((e: any) => Coin.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: MsgCreatePermanentLockedAccount): MsgCreatePermanentLockedAccountSDKType { + const obj: any = {}; + obj.from_address = message.fromAddress; + obj.to_address = message.toAddress; + if (message.amount) { + obj.amount = message.amount.map(e => e ? Coin.toSDK(e) : undefined); + } else { + obj.amount = []; + } + return obj; + }, + fromAmino(object: MsgCreatePermanentLockedAccountAmino): MsgCreatePermanentLockedAccount { + const message = createBaseMsgCreatePermanentLockedAccount(); + if (object.from_address !== undefined && object.from_address !== null) { + message.fromAddress = object.from_address; + } + if (object.to_address !== undefined && object.to_address !== null) { + message.toAddress = object.to_address; + } + message.amount = object.amount?.map(e => Coin.fromAmino(e)) || []; + return message; + }, + toAmino(message: MsgCreatePermanentLockedAccount): MsgCreatePermanentLockedAccountAmino { + const obj: any = {}; + obj.from_address = message.fromAddress === "" ? undefined : message.fromAddress; + obj.to_address = message.toAddress === "" ? undefined : message.toAddress; + if (message.amount) { + obj.amount = message.amount.map(e => e ? Coin.toAmino(e) : undefined); + } else { + obj.amount = message.amount; + } + return obj; + }, + fromAminoMsg(object: MsgCreatePermanentLockedAccountAminoMsg): MsgCreatePermanentLockedAccount { + return MsgCreatePermanentLockedAccount.fromAmino(object.value); + }, + toAminoMsg(message: MsgCreatePermanentLockedAccount): MsgCreatePermanentLockedAccountAminoMsg { + return { + type: "cosmos-sdk/MsgCreatePermanentLockedAccount", + value: MsgCreatePermanentLockedAccount.toAmino(message) + }; + }, + fromProtoMsg(message: MsgCreatePermanentLockedAccountProtoMsg): MsgCreatePermanentLockedAccount { + return MsgCreatePermanentLockedAccount.decode(message.value); + }, + toProto(message: MsgCreatePermanentLockedAccount): Uint8Array { + return MsgCreatePermanentLockedAccount.encode(message).finish(); + }, + toProtoMsg(message: MsgCreatePermanentLockedAccount): MsgCreatePermanentLockedAccountProtoMsg { + return { + typeUrl: "/cosmos.vesting.v1beta1.MsgCreatePermanentLockedAccount", + value: MsgCreatePermanentLockedAccount.encode(message).finish() + }; + } +}; +function createBaseMsgCreatePermanentLockedAccountResponse(): MsgCreatePermanentLockedAccountResponse { + return {}; +} +export const MsgCreatePermanentLockedAccountResponse = { + typeUrl: "/cosmos.vesting.v1beta1.MsgCreatePermanentLockedAccountResponse", + encode(_: MsgCreatePermanentLockedAccountResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgCreatePermanentLockedAccountResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgCreatePermanentLockedAccountResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgCreatePermanentLockedAccountResponse { + const obj = createBaseMsgCreatePermanentLockedAccountResponse(); + return obj; + }, + toJSON(_: MsgCreatePermanentLockedAccountResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): MsgCreatePermanentLockedAccountResponse { + const message = createBaseMsgCreatePermanentLockedAccountResponse(); + return message; + }, + fromSDK(_: MsgCreatePermanentLockedAccountResponseSDKType): MsgCreatePermanentLockedAccountResponse { + return {}; + }, + fromSDKJSON(_: any): MsgCreatePermanentLockedAccountResponseSDKType { + return {}; + }, + toSDK(_: MsgCreatePermanentLockedAccountResponse): MsgCreatePermanentLockedAccountResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgCreatePermanentLockedAccountResponseAmino): MsgCreatePermanentLockedAccountResponse { + const message = createBaseMsgCreatePermanentLockedAccountResponse(); + return message; + }, + toAmino(_: MsgCreatePermanentLockedAccountResponse): MsgCreatePermanentLockedAccountResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgCreatePermanentLockedAccountResponseAminoMsg): MsgCreatePermanentLockedAccountResponse { + return MsgCreatePermanentLockedAccountResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgCreatePermanentLockedAccountResponse): MsgCreatePermanentLockedAccountResponseAminoMsg { + return { + type: "cosmos-sdk/MsgCreatePermanentLockedAccountResponse", + value: MsgCreatePermanentLockedAccountResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgCreatePermanentLockedAccountResponseProtoMsg): MsgCreatePermanentLockedAccountResponse { + return MsgCreatePermanentLockedAccountResponse.decode(message.value); + }, + toProto(message: MsgCreatePermanentLockedAccountResponse): Uint8Array { + return MsgCreatePermanentLockedAccountResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgCreatePermanentLockedAccountResponse): MsgCreatePermanentLockedAccountResponseProtoMsg { + return { + typeUrl: "/cosmos.vesting.v1beta1.MsgCreatePermanentLockedAccountResponse", + value: MsgCreatePermanentLockedAccountResponse.encode(message).finish() + }; + } +}; +function createBaseMsgCreatePeriodicVestingAccount(): MsgCreatePeriodicVestingAccount { + return { + fromAddress: "", + toAddress: "", + startTime: BigInt(0), + vestingPeriods: [] + }; +} +export const MsgCreatePeriodicVestingAccount = { + typeUrl: "/cosmos.vesting.v1beta1.MsgCreatePeriodicVestingAccount", + encode(message: MsgCreatePeriodicVestingAccount, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.fromAddress !== undefined) { + writer.uint32(10).string(message.fromAddress); + } + if (message.toAddress !== undefined) { + writer.uint32(18).string(message.toAddress); + } + if (message.startTime !== undefined) { + writer.uint32(24).int64(message.startTime); + } + for (const v of message.vestingPeriods) { + Period.encode(v!, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgCreatePeriodicVestingAccount { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgCreatePeriodicVestingAccount(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.fromAddress = reader.string(); + break; + case 2: + message.toAddress = reader.string(); + break; + case 3: + message.startTime = reader.int64(); + break; + case 4: + message.vestingPeriods.push(Period.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgCreatePeriodicVestingAccount { + const obj = createBaseMsgCreatePeriodicVestingAccount(); + if (isSet(object.fromAddress)) obj.fromAddress = String(object.fromAddress); + if (isSet(object.toAddress)) obj.toAddress = String(object.toAddress); + if (isSet(object.startTime)) obj.startTime = BigInt(object.startTime.toString()); + if (Array.isArray(object?.vestingPeriods)) obj.vestingPeriods = object.vestingPeriods.map((e: any) => Period.fromJSON(e)); + return obj; + }, + toJSON(message: MsgCreatePeriodicVestingAccount): JsonSafe { + const obj: any = {}; + message.fromAddress !== undefined && (obj.fromAddress = message.fromAddress); + message.toAddress !== undefined && (obj.toAddress = message.toAddress); + message.startTime !== undefined && (obj.startTime = (message.startTime || BigInt(0)).toString()); + if (message.vestingPeriods) { + obj.vestingPeriods = message.vestingPeriods.map(e => e ? Period.toJSON(e) : undefined); + } else { + obj.vestingPeriods = []; + } + return obj; + }, + fromPartial(object: DeepPartial): MsgCreatePeriodicVestingAccount { + const message = createBaseMsgCreatePeriodicVestingAccount(); + message.fromAddress = object.fromAddress ?? ""; + message.toAddress = object.toAddress ?? ""; + if (object.startTime !== undefined && object.startTime !== null) { + message.startTime = BigInt(object.startTime.toString()); + } + message.vestingPeriods = object.vestingPeriods?.map(e => Period.fromPartial(e)) || []; + return message; + }, + fromSDK(object: MsgCreatePeriodicVestingAccountSDKType): MsgCreatePeriodicVestingAccount { + return { + fromAddress: object?.from_address, + toAddress: object?.to_address, + startTime: object?.start_time, + vestingPeriods: Array.isArray(object?.vesting_periods) ? object.vesting_periods.map((e: any) => Period.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): MsgCreatePeriodicVestingAccountSDKType { + return { + from_address: isSet(object.from_address) ? String(object.from_address) : "", + to_address: isSet(object.to_address) ? String(object.to_address) : "", + start_time: isSet(object.start_time) ? BigInt(object.start_time.toString()) : BigInt(0), + vesting_periods: Array.isArray(object?.vesting_periods) ? object.vesting_periods.map((e: any) => Period.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: MsgCreatePeriodicVestingAccount): MsgCreatePeriodicVestingAccountSDKType { + const obj: any = {}; + obj.from_address = message.fromAddress; + obj.to_address = message.toAddress; + obj.start_time = message.startTime; + if (message.vestingPeriods) { + obj.vesting_periods = message.vestingPeriods.map(e => e ? Period.toSDK(e) : undefined); + } else { + obj.vesting_periods = []; + } + return obj; + }, + fromAmino(object: MsgCreatePeriodicVestingAccountAmino): MsgCreatePeriodicVestingAccount { + const message = createBaseMsgCreatePeriodicVestingAccount(); + if (object.from_address !== undefined && object.from_address !== null) { + message.fromAddress = object.from_address; + } + if (object.to_address !== undefined && object.to_address !== null) { + message.toAddress = object.to_address; + } + if (object.start_time !== undefined && object.start_time !== null) { + message.startTime = BigInt(object.start_time); + } + message.vestingPeriods = object.vesting_periods?.map(e => Period.fromAmino(e)) || []; + return message; + }, + toAmino(message: MsgCreatePeriodicVestingAccount): MsgCreatePeriodicVestingAccountAmino { + const obj: any = {}; + obj.from_address = message.fromAddress === "" ? undefined : message.fromAddress; + obj.to_address = message.toAddress === "" ? undefined : message.toAddress; + obj.start_time = message.startTime !== BigInt(0) ? message.startTime?.toString() : undefined; + if (message.vestingPeriods) { + obj.vesting_periods = message.vestingPeriods.map(e => e ? Period.toAmino(e) : undefined); + } else { + obj.vesting_periods = message.vestingPeriods; + } + return obj; + }, + fromAminoMsg(object: MsgCreatePeriodicVestingAccountAminoMsg): MsgCreatePeriodicVestingAccount { + return MsgCreatePeriodicVestingAccount.fromAmino(object.value); + }, + toAminoMsg(message: MsgCreatePeriodicVestingAccount): MsgCreatePeriodicVestingAccountAminoMsg { + return { + type: "cosmos-sdk/MsgCreatePeriodicVestingAccount", + value: MsgCreatePeriodicVestingAccount.toAmino(message) + }; + }, + fromProtoMsg(message: MsgCreatePeriodicVestingAccountProtoMsg): MsgCreatePeriodicVestingAccount { + return MsgCreatePeriodicVestingAccount.decode(message.value); + }, + toProto(message: MsgCreatePeriodicVestingAccount): Uint8Array { + return MsgCreatePeriodicVestingAccount.encode(message).finish(); + }, + toProtoMsg(message: MsgCreatePeriodicVestingAccount): MsgCreatePeriodicVestingAccountProtoMsg { + return { + typeUrl: "/cosmos.vesting.v1beta1.MsgCreatePeriodicVestingAccount", + value: MsgCreatePeriodicVestingAccount.encode(message).finish() + }; + } +}; +function createBaseMsgCreatePeriodicVestingAccountResponse(): MsgCreatePeriodicVestingAccountResponse { + return {}; +} +export const MsgCreatePeriodicVestingAccountResponse = { + typeUrl: "/cosmos.vesting.v1beta1.MsgCreatePeriodicVestingAccountResponse", + encode(_: MsgCreatePeriodicVestingAccountResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgCreatePeriodicVestingAccountResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgCreatePeriodicVestingAccountResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgCreatePeriodicVestingAccountResponse { + const obj = createBaseMsgCreatePeriodicVestingAccountResponse(); + return obj; + }, + toJSON(_: MsgCreatePeriodicVestingAccountResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): MsgCreatePeriodicVestingAccountResponse { + const message = createBaseMsgCreatePeriodicVestingAccountResponse(); + return message; + }, + fromSDK(_: MsgCreatePeriodicVestingAccountResponseSDKType): MsgCreatePeriodicVestingAccountResponse { + return {}; + }, + fromSDKJSON(_: any): MsgCreatePeriodicVestingAccountResponseSDKType { + return {}; + }, + toSDK(_: MsgCreatePeriodicVestingAccountResponse): MsgCreatePeriodicVestingAccountResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgCreatePeriodicVestingAccountResponseAmino): MsgCreatePeriodicVestingAccountResponse { + const message = createBaseMsgCreatePeriodicVestingAccountResponse(); + return message; + }, + toAmino(_: MsgCreatePeriodicVestingAccountResponse): MsgCreatePeriodicVestingAccountResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgCreatePeriodicVestingAccountResponseAminoMsg): MsgCreatePeriodicVestingAccountResponse { + return MsgCreatePeriodicVestingAccountResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgCreatePeriodicVestingAccountResponse): MsgCreatePeriodicVestingAccountResponseAminoMsg { + return { + type: "cosmos-sdk/MsgCreatePeriodicVestingAccountResponse", + value: MsgCreatePeriodicVestingAccountResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgCreatePeriodicVestingAccountResponseProtoMsg): MsgCreatePeriodicVestingAccountResponse { + return MsgCreatePeriodicVestingAccountResponse.decode(message.value); + }, + toProto(message: MsgCreatePeriodicVestingAccountResponse): Uint8Array { + return MsgCreatePeriodicVestingAccountResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgCreatePeriodicVestingAccountResponse): MsgCreatePeriodicVestingAccountResponseProtoMsg { + return { + typeUrl: "/cosmos.vesting.v1beta1.MsgCreatePeriodicVestingAccountResponse", + value: MsgCreatePeriodicVestingAccountResponse.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos/vesting/v1beta1/vesting.ts b/__fixtures__/v-next/outputicjsdeps/cosmos/vesting/v1beta1/vesting.ts new file mode 100644 index 0000000000..cc55ab14df --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos/vesting/v1beta1/vesting.ts @@ -0,0 +1,900 @@ +import { BaseAccount, BaseAccountSDKType } from "../../auth/v1beta1/auth.js"; +import { Coin, CoinSDKType } from "../../base/v1beta1/coin.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "cosmos.vesting.v1beta1"; +/** + * BaseVestingAccount implements the VestingAccount interface. It contains all + * the necessary fields needed for any vesting account implementation. + */ +export interface BaseVestingAccount { + baseAccount?: BaseAccount; + originalVesting: Coin[]; + delegatedFree: Coin[]; + delegatedVesting: Coin[]; + endTime: bigint; +} +export interface BaseVestingAccountProtoMsg { + typeUrl: "/cosmos.vesting.v1beta1.BaseVestingAccount"; + value: Uint8Array; +} +/** + * BaseVestingAccount implements the VestingAccount interface. It contains all + * the necessary fields needed for any vesting account implementation. + */ +export interface BaseVestingAccountSDKType { + base_account?: BaseAccountSDKType; + original_vesting: CoinSDKType[]; + delegated_free: CoinSDKType[]; + delegated_vesting: CoinSDKType[]; + end_time: bigint; +} +/** + * ContinuousVestingAccount implements the VestingAccount interface. It + * continuously vests by unlocking coins linearly with respect to time. + */ +export interface ContinuousVestingAccount { + baseVestingAccount?: BaseVestingAccount; + startTime: bigint; +} +export interface ContinuousVestingAccountProtoMsg { + typeUrl: "/cosmos.vesting.v1beta1.ContinuousVestingAccount"; + value: Uint8Array; +} +/** + * ContinuousVestingAccount implements the VestingAccount interface. It + * continuously vests by unlocking coins linearly with respect to time. + */ +export interface ContinuousVestingAccountSDKType { + base_vesting_account?: BaseVestingAccountSDKType; + start_time: bigint; +} +/** + * DelayedVestingAccount implements the VestingAccount interface. It vests all + * coins after a specific time, but non prior. In other words, it keeps them + * locked until a specified time. + */ +export interface DelayedVestingAccount { + baseVestingAccount?: BaseVestingAccount; +} +export interface DelayedVestingAccountProtoMsg { + typeUrl: "/cosmos.vesting.v1beta1.DelayedVestingAccount"; + value: Uint8Array; +} +/** + * DelayedVestingAccount implements the VestingAccount interface. It vests all + * coins after a specific time, but non prior. In other words, it keeps them + * locked until a specified time. + */ +export interface DelayedVestingAccountSDKType { + base_vesting_account?: BaseVestingAccountSDKType; +} +/** Period defines a length of time and amount of coins that will vest. */ +export interface Period { + length: bigint; + amount: Coin[]; +} +export interface PeriodProtoMsg { + typeUrl: "/cosmos.vesting.v1beta1.Period"; + value: Uint8Array; +} +/** Period defines a length of time and amount of coins that will vest. */ +export interface PeriodSDKType { + length: bigint; + amount: CoinSDKType[]; +} +/** + * PeriodicVestingAccount implements the VestingAccount interface. It + * periodically vests by unlocking coins during each specified period. + */ +export interface PeriodicVestingAccount { + baseVestingAccount?: BaseVestingAccount; + startTime: bigint; + vestingPeriods: Period[]; +} +export interface PeriodicVestingAccountProtoMsg { + typeUrl: "/cosmos.vesting.v1beta1.PeriodicVestingAccount"; + value: Uint8Array; +} +/** + * PeriodicVestingAccount implements the VestingAccount interface. It + * periodically vests by unlocking coins during each specified period. + */ +export interface PeriodicVestingAccountSDKType { + base_vesting_account?: BaseVestingAccountSDKType; + start_time: bigint; + vesting_periods: PeriodSDKType[]; +} +/** + * PermanentLockedAccount implements the VestingAccount interface. It does + * not ever release coins, locking them indefinitely. Coins in this account can + * still be used for delegating and for governance votes even while locked. + * + * Since: cosmos-sdk 0.43 + */ +export interface PermanentLockedAccount { + baseVestingAccount?: BaseVestingAccount; +} +export interface PermanentLockedAccountProtoMsg { + typeUrl: "/cosmos.vesting.v1beta1.PermanentLockedAccount"; + value: Uint8Array; +} +/** + * PermanentLockedAccount implements the VestingAccount interface. It does + * not ever release coins, locking them indefinitely. Coins in this account can + * still be used for delegating and for governance votes even while locked. + * + * Since: cosmos-sdk 0.43 + */ +export interface PermanentLockedAccountSDKType { + base_vesting_account?: BaseVestingAccountSDKType; +} +function createBaseBaseVestingAccount(): BaseVestingAccount { + return { + baseAccount: undefined, + originalVesting: [], + delegatedFree: [], + delegatedVesting: [], + endTime: BigInt(0) + }; +} +export const BaseVestingAccount = { + typeUrl: "/cosmos.vesting.v1beta1.BaseVestingAccount", + encode(message: BaseVestingAccount, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.baseAccount !== undefined) { + BaseAccount.encode(message.baseAccount, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.originalVesting) { + Coin.encode(v!, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.delegatedFree) { + Coin.encode(v!, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.delegatedVesting) { + Coin.encode(v!, writer.uint32(34).fork()).ldelim(); + } + if (message.endTime !== undefined) { + writer.uint32(40).int64(message.endTime); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): BaseVestingAccount { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseBaseVestingAccount(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.baseAccount = BaseAccount.decode(reader, reader.uint32()); + break; + case 2: + message.originalVesting.push(Coin.decode(reader, reader.uint32())); + break; + case 3: + message.delegatedFree.push(Coin.decode(reader, reader.uint32())); + break; + case 4: + message.delegatedVesting.push(Coin.decode(reader, reader.uint32())); + break; + case 5: + message.endTime = reader.int64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): BaseVestingAccount { + const obj = createBaseBaseVestingAccount(); + if (isSet(object.baseAccount)) obj.baseAccount = BaseAccount.fromJSON(object.baseAccount); + if (Array.isArray(object?.originalVesting)) obj.originalVesting = object.originalVesting.map((e: any) => Coin.fromJSON(e)); + if (Array.isArray(object?.delegatedFree)) obj.delegatedFree = object.delegatedFree.map((e: any) => Coin.fromJSON(e)); + if (Array.isArray(object?.delegatedVesting)) obj.delegatedVesting = object.delegatedVesting.map((e: any) => Coin.fromJSON(e)); + if (isSet(object.endTime)) obj.endTime = BigInt(object.endTime.toString()); + return obj; + }, + toJSON(message: BaseVestingAccount): JsonSafe { + const obj: any = {}; + message.baseAccount !== undefined && (obj.baseAccount = message.baseAccount ? BaseAccount.toJSON(message.baseAccount) : undefined); + if (message.originalVesting) { + obj.originalVesting = message.originalVesting.map(e => e ? Coin.toJSON(e) : undefined); + } else { + obj.originalVesting = []; + } + if (message.delegatedFree) { + obj.delegatedFree = message.delegatedFree.map(e => e ? Coin.toJSON(e) : undefined); + } else { + obj.delegatedFree = []; + } + if (message.delegatedVesting) { + obj.delegatedVesting = message.delegatedVesting.map(e => e ? Coin.toJSON(e) : undefined); + } else { + obj.delegatedVesting = []; + } + message.endTime !== undefined && (obj.endTime = (message.endTime || BigInt(0)).toString()); + return obj; + }, + fromPartial(object: DeepPartial): BaseVestingAccount { + const message = createBaseBaseVestingAccount(); + if (object.baseAccount !== undefined && object.baseAccount !== null) { + message.baseAccount = BaseAccount.fromPartial(object.baseAccount); + } + message.originalVesting = object.originalVesting?.map(e => Coin.fromPartial(e)) || []; + message.delegatedFree = object.delegatedFree?.map(e => Coin.fromPartial(e)) || []; + message.delegatedVesting = object.delegatedVesting?.map(e => Coin.fromPartial(e)) || []; + if (object.endTime !== undefined && object.endTime !== null) { + message.endTime = BigInt(object.endTime.toString()); + } + return message; + }, + fromSDK(object: BaseVestingAccountSDKType): BaseVestingAccount { + return { + baseAccount: object.base_account ? BaseAccount.fromSDK(object.base_account) : undefined, + originalVesting: Array.isArray(object?.original_vesting) ? object.original_vesting.map((e: any) => Coin.fromSDK(e)) : [], + delegatedFree: Array.isArray(object?.delegated_free) ? object.delegated_free.map((e: any) => Coin.fromSDK(e)) : [], + delegatedVesting: Array.isArray(object?.delegated_vesting) ? object.delegated_vesting.map((e: any) => Coin.fromSDK(e)) : [], + endTime: object?.end_time + }; + }, + fromSDKJSON(object: any): BaseVestingAccountSDKType { + return { + base_account: isSet(object.base_account) ? BaseAccount.fromSDKJSON(object.base_account) : undefined, + original_vesting: Array.isArray(object?.original_vesting) ? object.original_vesting.map((e: any) => Coin.fromSDKJSON(e)) : [], + delegated_free: Array.isArray(object?.delegated_free) ? object.delegated_free.map((e: any) => Coin.fromSDKJSON(e)) : [], + delegated_vesting: Array.isArray(object?.delegated_vesting) ? object.delegated_vesting.map((e: any) => Coin.fromSDKJSON(e)) : [], + end_time: isSet(object.end_time) ? BigInt(object.end_time.toString()) : BigInt(0) + }; + }, + toSDK(message: BaseVestingAccount): BaseVestingAccountSDKType { + const obj: any = {}; + message.baseAccount !== undefined && (obj.base_account = message.baseAccount ? BaseAccount.toSDK(message.baseAccount) : undefined); + if (message.originalVesting) { + obj.original_vesting = message.originalVesting.map(e => e ? Coin.toSDK(e) : undefined); + } else { + obj.original_vesting = []; + } + if (message.delegatedFree) { + obj.delegated_free = message.delegatedFree.map(e => e ? Coin.toSDK(e) : undefined); + } else { + obj.delegated_free = []; + } + if (message.delegatedVesting) { + obj.delegated_vesting = message.delegatedVesting.map(e => e ? Coin.toSDK(e) : undefined); + } else { + obj.delegated_vesting = []; + } + obj.end_time = message.endTime; + return obj; + }, + fromAmino(object: BaseVestingAccountAmino): BaseVestingAccount { + const message = createBaseBaseVestingAccount(); + if (object.base_account !== undefined && object.base_account !== null) { + message.baseAccount = BaseAccount.fromAmino(object.base_account); + } + message.originalVesting = object.original_vesting?.map(e => Coin.fromAmino(e)) || []; + message.delegatedFree = object.delegated_free?.map(e => Coin.fromAmino(e)) || []; + message.delegatedVesting = object.delegated_vesting?.map(e => Coin.fromAmino(e)) || []; + if (object.end_time !== undefined && object.end_time !== null) { + message.endTime = BigInt(object.end_time); + } + return message; + }, + toAmino(message: BaseVestingAccount): BaseVestingAccountAmino { + const obj: any = {}; + obj.base_account = message.baseAccount ? BaseAccount.toAmino(message.baseAccount) : undefined; + if (message.originalVesting) { + obj.original_vesting = message.originalVesting.map(e => e ? Coin.toAmino(e) : undefined); + } else { + obj.original_vesting = message.originalVesting; + } + if (message.delegatedFree) { + obj.delegated_free = message.delegatedFree.map(e => e ? Coin.toAmino(e) : undefined); + } else { + obj.delegated_free = message.delegatedFree; + } + if (message.delegatedVesting) { + obj.delegated_vesting = message.delegatedVesting.map(e => e ? Coin.toAmino(e) : undefined); + } else { + obj.delegated_vesting = message.delegatedVesting; + } + obj.end_time = message.endTime !== BigInt(0) ? message.endTime?.toString() : undefined; + return obj; + }, + fromAminoMsg(object: BaseVestingAccountAminoMsg): BaseVestingAccount { + return BaseVestingAccount.fromAmino(object.value); + }, + toAminoMsg(message: BaseVestingAccount): BaseVestingAccountAminoMsg { + return { + type: "cosmos-sdk/BaseVestingAccount", + value: BaseVestingAccount.toAmino(message) + }; + }, + fromProtoMsg(message: BaseVestingAccountProtoMsg): BaseVestingAccount { + return BaseVestingAccount.decode(message.value); + }, + toProto(message: BaseVestingAccount): Uint8Array { + return BaseVestingAccount.encode(message).finish(); + }, + toProtoMsg(message: BaseVestingAccount): BaseVestingAccountProtoMsg { + return { + typeUrl: "/cosmos.vesting.v1beta1.BaseVestingAccount", + value: BaseVestingAccount.encode(message).finish() + }; + } +}; +function createBaseContinuousVestingAccount(): ContinuousVestingAccount { + return { + baseVestingAccount: undefined, + startTime: BigInt(0) + }; +} +export const ContinuousVestingAccount = { + typeUrl: "/cosmos.vesting.v1beta1.ContinuousVestingAccount", + encode(message: ContinuousVestingAccount, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.baseVestingAccount !== undefined) { + BaseVestingAccount.encode(message.baseVestingAccount, writer.uint32(10).fork()).ldelim(); + } + if (message.startTime !== undefined) { + writer.uint32(16).int64(message.startTime); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ContinuousVestingAccount { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseContinuousVestingAccount(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.baseVestingAccount = BaseVestingAccount.decode(reader, reader.uint32()); + break; + case 2: + message.startTime = reader.int64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ContinuousVestingAccount { + const obj = createBaseContinuousVestingAccount(); + if (isSet(object.baseVestingAccount)) obj.baseVestingAccount = BaseVestingAccount.fromJSON(object.baseVestingAccount); + if (isSet(object.startTime)) obj.startTime = BigInt(object.startTime.toString()); + return obj; + }, + toJSON(message: ContinuousVestingAccount): JsonSafe { + const obj: any = {}; + message.baseVestingAccount !== undefined && (obj.baseVestingAccount = message.baseVestingAccount ? BaseVestingAccount.toJSON(message.baseVestingAccount) : undefined); + message.startTime !== undefined && (obj.startTime = (message.startTime || BigInt(0)).toString()); + return obj; + }, + fromPartial(object: DeepPartial): ContinuousVestingAccount { + const message = createBaseContinuousVestingAccount(); + if (object.baseVestingAccount !== undefined && object.baseVestingAccount !== null) { + message.baseVestingAccount = BaseVestingAccount.fromPartial(object.baseVestingAccount); + } + if (object.startTime !== undefined && object.startTime !== null) { + message.startTime = BigInt(object.startTime.toString()); + } + return message; + }, + fromSDK(object: ContinuousVestingAccountSDKType): ContinuousVestingAccount { + return { + baseVestingAccount: object.base_vesting_account ? BaseVestingAccount.fromSDK(object.base_vesting_account) : undefined, + startTime: object?.start_time + }; + }, + fromSDKJSON(object: any): ContinuousVestingAccountSDKType { + return { + base_vesting_account: isSet(object.base_vesting_account) ? BaseVestingAccount.fromSDKJSON(object.base_vesting_account) : undefined, + start_time: isSet(object.start_time) ? BigInt(object.start_time.toString()) : BigInt(0) + }; + }, + toSDK(message: ContinuousVestingAccount): ContinuousVestingAccountSDKType { + const obj: any = {}; + message.baseVestingAccount !== undefined && (obj.base_vesting_account = message.baseVestingAccount ? BaseVestingAccount.toSDK(message.baseVestingAccount) : undefined); + obj.start_time = message.startTime; + return obj; + }, + fromAmino(object: ContinuousVestingAccountAmino): ContinuousVestingAccount { + const message = createBaseContinuousVestingAccount(); + if (object.base_vesting_account !== undefined && object.base_vesting_account !== null) { + message.baseVestingAccount = BaseVestingAccount.fromAmino(object.base_vesting_account); + } + if (object.start_time !== undefined && object.start_time !== null) { + message.startTime = BigInt(object.start_time); + } + return message; + }, + toAmino(message: ContinuousVestingAccount): ContinuousVestingAccountAmino { + const obj: any = {}; + obj.base_vesting_account = message.baseVestingAccount ? BaseVestingAccount.toAmino(message.baseVestingAccount) : undefined; + obj.start_time = message.startTime !== BigInt(0) ? message.startTime?.toString() : undefined; + return obj; + }, + fromAminoMsg(object: ContinuousVestingAccountAminoMsg): ContinuousVestingAccount { + return ContinuousVestingAccount.fromAmino(object.value); + }, + toAminoMsg(message: ContinuousVestingAccount): ContinuousVestingAccountAminoMsg { + return { + type: "cosmos-sdk/ContinuousVestingAccount", + value: ContinuousVestingAccount.toAmino(message) + }; + }, + fromProtoMsg(message: ContinuousVestingAccountProtoMsg): ContinuousVestingAccount { + return ContinuousVestingAccount.decode(message.value); + }, + toProto(message: ContinuousVestingAccount): Uint8Array { + return ContinuousVestingAccount.encode(message).finish(); + }, + toProtoMsg(message: ContinuousVestingAccount): ContinuousVestingAccountProtoMsg { + return { + typeUrl: "/cosmos.vesting.v1beta1.ContinuousVestingAccount", + value: ContinuousVestingAccount.encode(message).finish() + }; + } +}; +function createBaseDelayedVestingAccount(): DelayedVestingAccount { + return { + baseVestingAccount: undefined + }; +} +export const DelayedVestingAccount = { + typeUrl: "/cosmos.vesting.v1beta1.DelayedVestingAccount", + encode(message: DelayedVestingAccount, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.baseVestingAccount !== undefined) { + BaseVestingAccount.encode(message.baseVestingAccount, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): DelayedVestingAccount { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDelayedVestingAccount(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.baseVestingAccount = BaseVestingAccount.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): DelayedVestingAccount { + const obj = createBaseDelayedVestingAccount(); + if (isSet(object.baseVestingAccount)) obj.baseVestingAccount = BaseVestingAccount.fromJSON(object.baseVestingAccount); + return obj; + }, + toJSON(message: DelayedVestingAccount): JsonSafe { + const obj: any = {}; + message.baseVestingAccount !== undefined && (obj.baseVestingAccount = message.baseVestingAccount ? BaseVestingAccount.toJSON(message.baseVestingAccount) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): DelayedVestingAccount { + const message = createBaseDelayedVestingAccount(); + if (object.baseVestingAccount !== undefined && object.baseVestingAccount !== null) { + message.baseVestingAccount = BaseVestingAccount.fromPartial(object.baseVestingAccount); + } + return message; + }, + fromSDK(object: DelayedVestingAccountSDKType): DelayedVestingAccount { + return { + baseVestingAccount: object.base_vesting_account ? BaseVestingAccount.fromSDK(object.base_vesting_account) : undefined + }; + }, + fromSDKJSON(object: any): DelayedVestingAccountSDKType { + return { + base_vesting_account: isSet(object.base_vesting_account) ? BaseVestingAccount.fromSDKJSON(object.base_vesting_account) : undefined + }; + }, + toSDK(message: DelayedVestingAccount): DelayedVestingAccountSDKType { + const obj: any = {}; + message.baseVestingAccount !== undefined && (obj.base_vesting_account = message.baseVestingAccount ? BaseVestingAccount.toSDK(message.baseVestingAccount) : undefined); + return obj; + }, + fromAmino(object: DelayedVestingAccountAmino): DelayedVestingAccount { + const message = createBaseDelayedVestingAccount(); + if (object.base_vesting_account !== undefined && object.base_vesting_account !== null) { + message.baseVestingAccount = BaseVestingAccount.fromAmino(object.base_vesting_account); + } + return message; + }, + toAmino(message: DelayedVestingAccount): DelayedVestingAccountAmino { + const obj: any = {}; + obj.base_vesting_account = message.baseVestingAccount ? BaseVestingAccount.toAmino(message.baseVestingAccount) : undefined; + return obj; + }, + fromAminoMsg(object: DelayedVestingAccountAminoMsg): DelayedVestingAccount { + return DelayedVestingAccount.fromAmino(object.value); + }, + toAminoMsg(message: DelayedVestingAccount): DelayedVestingAccountAminoMsg { + return { + type: "cosmos-sdk/DelayedVestingAccount", + value: DelayedVestingAccount.toAmino(message) + }; + }, + fromProtoMsg(message: DelayedVestingAccountProtoMsg): DelayedVestingAccount { + return DelayedVestingAccount.decode(message.value); + }, + toProto(message: DelayedVestingAccount): Uint8Array { + return DelayedVestingAccount.encode(message).finish(); + }, + toProtoMsg(message: DelayedVestingAccount): DelayedVestingAccountProtoMsg { + return { + typeUrl: "/cosmos.vesting.v1beta1.DelayedVestingAccount", + value: DelayedVestingAccount.encode(message).finish() + }; + } +}; +function createBasePeriod(): Period { + return { + length: BigInt(0), + amount: [] + }; +} +export const Period = { + typeUrl: "/cosmos.vesting.v1beta1.Period", + encode(message: Period, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.length !== undefined) { + writer.uint32(8).int64(message.length); + } + for (const v of message.amount) { + Coin.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Period { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBasePeriod(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.length = reader.int64(); + break; + case 2: + message.amount.push(Coin.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Period { + const obj = createBasePeriod(); + if (isSet(object.length)) obj.length = BigInt(object.length.toString()); + if (Array.isArray(object?.amount)) obj.amount = object.amount.map((e: any) => Coin.fromJSON(e)); + return obj; + }, + toJSON(message: Period): JsonSafe { + const obj: any = {}; + message.length !== undefined && (obj.length = (message.length || BigInt(0)).toString()); + if (message.amount) { + obj.amount = message.amount.map(e => e ? Coin.toJSON(e) : undefined); + } else { + obj.amount = []; + } + return obj; + }, + fromPartial(object: DeepPartial): Period { + const message = createBasePeriod(); + if (object.length !== undefined && object.length !== null) { + message.length = BigInt(object.length.toString()); + } + message.amount = object.amount?.map(e => Coin.fromPartial(e)) || []; + return message; + }, + fromSDK(object: PeriodSDKType): Period { + return { + length: object?.length, + amount: Array.isArray(object?.amount) ? object.amount.map((e: any) => Coin.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): PeriodSDKType { + return { + length: isSet(object.length) ? BigInt(object.length.toString()) : BigInt(0), + amount: Array.isArray(object?.amount) ? object.amount.map((e: any) => Coin.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: Period): PeriodSDKType { + const obj: any = {}; + obj.length = message.length; + if (message.amount) { + obj.amount = message.amount.map(e => e ? Coin.toSDK(e) : undefined); + } else { + obj.amount = []; + } + return obj; + }, + fromAmino(object: PeriodAmino): Period { + const message = createBasePeriod(); + if (object.length !== undefined && object.length !== null) { + message.length = BigInt(object.length); + } + message.amount = object.amount?.map(e => Coin.fromAmino(e)) || []; + return message; + }, + toAmino(message: Period): PeriodAmino { + const obj: any = {}; + obj.length = message.length !== BigInt(0) ? message.length?.toString() : undefined; + if (message.amount) { + obj.amount = message.amount.map(e => e ? Coin.toAmino(e) : undefined); + } else { + obj.amount = message.amount; + } + return obj; + }, + fromAminoMsg(object: PeriodAminoMsg): Period { + return Period.fromAmino(object.value); + }, + toAminoMsg(message: Period): PeriodAminoMsg { + return { + type: "cosmos-sdk/Period", + value: Period.toAmino(message) + }; + }, + fromProtoMsg(message: PeriodProtoMsg): Period { + return Period.decode(message.value); + }, + toProto(message: Period): Uint8Array { + return Period.encode(message).finish(); + }, + toProtoMsg(message: Period): PeriodProtoMsg { + return { + typeUrl: "/cosmos.vesting.v1beta1.Period", + value: Period.encode(message).finish() + }; + } +}; +function createBasePeriodicVestingAccount(): PeriodicVestingAccount { + return { + baseVestingAccount: undefined, + startTime: BigInt(0), + vestingPeriods: [] + }; +} +export const PeriodicVestingAccount = { + typeUrl: "/cosmos.vesting.v1beta1.PeriodicVestingAccount", + encode(message: PeriodicVestingAccount, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.baseVestingAccount !== undefined) { + BaseVestingAccount.encode(message.baseVestingAccount, writer.uint32(10).fork()).ldelim(); + } + if (message.startTime !== undefined) { + writer.uint32(16).int64(message.startTime); + } + for (const v of message.vestingPeriods) { + Period.encode(v!, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): PeriodicVestingAccount { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBasePeriodicVestingAccount(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.baseVestingAccount = BaseVestingAccount.decode(reader, reader.uint32()); + break; + case 2: + message.startTime = reader.int64(); + break; + case 3: + message.vestingPeriods.push(Period.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): PeriodicVestingAccount { + const obj = createBasePeriodicVestingAccount(); + if (isSet(object.baseVestingAccount)) obj.baseVestingAccount = BaseVestingAccount.fromJSON(object.baseVestingAccount); + if (isSet(object.startTime)) obj.startTime = BigInt(object.startTime.toString()); + if (Array.isArray(object?.vestingPeriods)) obj.vestingPeriods = object.vestingPeriods.map((e: any) => Period.fromJSON(e)); + return obj; + }, + toJSON(message: PeriodicVestingAccount): JsonSafe { + const obj: any = {}; + message.baseVestingAccount !== undefined && (obj.baseVestingAccount = message.baseVestingAccount ? BaseVestingAccount.toJSON(message.baseVestingAccount) : undefined); + message.startTime !== undefined && (obj.startTime = (message.startTime || BigInt(0)).toString()); + if (message.vestingPeriods) { + obj.vestingPeriods = message.vestingPeriods.map(e => e ? Period.toJSON(e) : undefined); + } else { + obj.vestingPeriods = []; + } + return obj; + }, + fromPartial(object: DeepPartial): PeriodicVestingAccount { + const message = createBasePeriodicVestingAccount(); + if (object.baseVestingAccount !== undefined && object.baseVestingAccount !== null) { + message.baseVestingAccount = BaseVestingAccount.fromPartial(object.baseVestingAccount); + } + if (object.startTime !== undefined && object.startTime !== null) { + message.startTime = BigInt(object.startTime.toString()); + } + message.vestingPeriods = object.vestingPeriods?.map(e => Period.fromPartial(e)) || []; + return message; + }, + fromSDK(object: PeriodicVestingAccountSDKType): PeriodicVestingAccount { + return { + baseVestingAccount: object.base_vesting_account ? BaseVestingAccount.fromSDK(object.base_vesting_account) : undefined, + startTime: object?.start_time, + vestingPeriods: Array.isArray(object?.vesting_periods) ? object.vesting_periods.map((e: any) => Period.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): PeriodicVestingAccountSDKType { + return { + base_vesting_account: isSet(object.base_vesting_account) ? BaseVestingAccount.fromSDKJSON(object.base_vesting_account) : undefined, + start_time: isSet(object.start_time) ? BigInt(object.start_time.toString()) : BigInt(0), + vesting_periods: Array.isArray(object?.vesting_periods) ? object.vesting_periods.map((e: any) => Period.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: PeriodicVestingAccount): PeriodicVestingAccountSDKType { + const obj: any = {}; + message.baseVestingAccount !== undefined && (obj.base_vesting_account = message.baseVestingAccount ? BaseVestingAccount.toSDK(message.baseVestingAccount) : undefined); + obj.start_time = message.startTime; + if (message.vestingPeriods) { + obj.vesting_periods = message.vestingPeriods.map(e => e ? Period.toSDK(e) : undefined); + } else { + obj.vesting_periods = []; + } + return obj; + }, + fromAmino(object: PeriodicVestingAccountAmino): PeriodicVestingAccount { + const message = createBasePeriodicVestingAccount(); + if (object.base_vesting_account !== undefined && object.base_vesting_account !== null) { + message.baseVestingAccount = BaseVestingAccount.fromAmino(object.base_vesting_account); + } + if (object.start_time !== undefined && object.start_time !== null) { + message.startTime = BigInt(object.start_time); + } + message.vestingPeriods = object.vesting_periods?.map(e => Period.fromAmino(e)) || []; + return message; + }, + toAmino(message: PeriodicVestingAccount): PeriodicVestingAccountAmino { + const obj: any = {}; + obj.base_vesting_account = message.baseVestingAccount ? BaseVestingAccount.toAmino(message.baseVestingAccount) : undefined; + obj.start_time = message.startTime !== BigInt(0) ? message.startTime?.toString() : undefined; + if (message.vestingPeriods) { + obj.vesting_periods = message.vestingPeriods.map(e => e ? Period.toAmino(e) : undefined); + } else { + obj.vesting_periods = message.vestingPeriods; + } + return obj; + }, + fromAminoMsg(object: PeriodicVestingAccountAminoMsg): PeriodicVestingAccount { + return PeriodicVestingAccount.fromAmino(object.value); + }, + toAminoMsg(message: PeriodicVestingAccount): PeriodicVestingAccountAminoMsg { + return { + type: "cosmos-sdk/PeriodicVestingAccount", + value: PeriodicVestingAccount.toAmino(message) + }; + }, + fromProtoMsg(message: PeriodicVestingAccountProtoMsg): PeriodicVestingAccount { + return PeriodicVestingAccount.decode(message.value); + }, + toProto(message: PeriodicVestingAccount): Uint8Array { + return PeriodicVestingAccount.encode(message).finish(); + }, + toProtoMsg(message: PeriodicVestingAccount): PeriodicVestingAccountProtoMsg { + return { + typeUrl: "/cosmos.vesting.v1beta1.PeriodicVestingAccount", + value: PeriodicVestingAccount.encode(message).finish() + }; + } +}; +function createBasePermanentLockedAccount(): PermanentLockedAccount { + return { + baseVestingAccount: undefined + }; +} +export const PermanentLockedAccount = { + typeUrl: "/cosmos.vesting.v1beta1.PermanentLockedAccount", + encode(message: PermanentLockedAccount, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.baseVestingAccount !== undefined) { + BaseVestingAccount.encode(message.baseVestingAccount, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): PermanentLockedAccount { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBasePermanentLockedAccount(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.baseVestingAccount = BaseVestingAccount.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): PermanentLockedAccount { + const obj = createBasePermanentLockedAccount(); + if (isSet(object.baseVestingAccount)) obj.baseVestingAccount = BaseVestingAccount.fromJSON(object.baseVestingAccount); + return obj; + }, + toJSON(message: PermanentLockedAccount): JsonSafe { + const obj: any = {}; + message.baseVestingAccount !== undefined && (obj.baseVestingAccount = message.baseVestingAccount ? BaseVestingAccount.toJSON(message.baseVestingAccount) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): PermanentLockedAccount { + const message = createBasePermanentLockedAccount(); + if (object.baseVestingAccount !== undefined && object.baseVestingAccount !== null) { + message.baseVestingAccount = BaseVestingAccount.fromPartial(object.baseVestingAccount); + } + return message; + }, + fromSDK(object: PermanentLockedAccountSDKType): PermanentLockedAccount { + return { + baseVestingAccount: object.base_vesting_account ? BaseVestingAccount.fromSDK(object.base_vesting_account) : undefined + }; + }, + fromSDKJSON(object: any): PermanentLockedAccountSDKType { + return { + base_vesting_account: isSet(object.base_vesting_account) ? BaseVestingAccount.fromSDKJSON(object.base_vesting_account) : undefined + }; + }, + toSDK(message: PermanentLockedAccount): PermanentLockedAccountSDKType { + const obj: any = {}; + message.baseVestingAccount !== undefined && (obj.base_vesting_account = message.baseVestingAccount ? BaseVestingAccount.toSDK(message.baseVestingAccount) : undefined); + return obj; + }, + fromAmino(object: PermanentLockedAccountAmino): PermanentLockedAccount { + const message = createBasePermanentLockedAccount(); + if (object.base_vesting_account !== undefined && object.base_vesting_account !== null) { + message.baseVestingAccount = BaseVestingAccount.fromAmino(object.base_vesting_account); + } + return message; + }, + toAmino(message: PermanentLockedAccount): PermanentLockedAccountAmino { + const obj: any = {}; + obj.base_vesting_account = message.baseVestingAccount ? BaseVestingAccount.toAmino(message.baseVestingAccount) : undefined; + return obj; + }, + fromAminoMsg(object: PermanentLockedAccountAminoMsg): PermanentLockedAccount { + return PermanentLockedAccount.fromAmino(object.value); + }, + toAminoMsg(message: PermanentLockedAccount): PermanentLockedAccountAminoMsg { + return { + type: "cosmos-sdk/PermanentLockedAccount", + value: PermanentLockedAccount.toAmino(message) + }; + }, + fromProtoMsg(message: PermanentLockedAccountProtoMsg): PermanentLockedAccount { + return PermanentLockedAccount.decode(message.value); + }, + toProto(message: PermanentLockedAccount): Uint8Array { + return PermanentLockedAccount.encode(message).finish(); + }, + toProtoMsg(message: PermanentLockedAccount): PermanentLockedAccountProtoMsg { + return { + typeUrl: "/cosmos.vesting.v1beta1.PermanentLockedAccount", + value: PermanentLockedAccount.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos_proto/bundle.ts b/__fixtures__/v-next/outputicjsdeps/cosmos_proto/bundle.ts new file mode 100644 index 0000000000..6b937aef3a --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos_proto/bundle.ts @@ -0,0 +1,4 @@ +import * as _54 from "./cosmos.js"; +export const cosmos_proto = { + ..._54 +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmos_proto/cosmos.ts b/__fixtures__/v-next/outputicjsdeps/cosmos_proto/cosmos.ts new file mode 100644 index 0000000000..c0ca244aba --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmos_proto/cosmos.ts @@ -0,0 +1,366 @@ +import { BinaryReader, BinaryWriter } from "../binary.js"; +import { isSet, DeepPartial } from "../helpers.js"; +import { JsonSafe } from "../json-safe.js"; +export const protobufPackage = "cosmos_proto"; +export enum ScalarType { + SCALAR_TYPE_UNSPECIFIED = 0, + SCALAR_TYPE_STRING = 1, + SCALAR_TYPE_BYTES = 2, + UNRECOGNIZED = -1, +} +export const ScalarTypeSDKType = ScalarType; +export function scalarTypeFromJSON(object: any): ScalarType { + switch (object) { + case 0: + case "SCALAR_TYPE_UNSPECIFIED": + return ScalarType.SCALAR_TYPE_UNSPECIFIED; + case 1: + case "SCALAR_TYPE_STRING": + return ScalarType.SCALAR_TYPE_STRING; + case 2: + case "SCALAR_TYPE_BYTES": + return ScalarType.SCALAR_TYPE_BYTES; + case -1: + case "UNRECOGNIZED": + default: + return ScalarType.UNRECOGNIZED; + } +} +export function scalarTypeToJSON(object: ScalarType): string { + switch (object) { + case ScalarType.SCALAR_TYPE_UNSPECIFIED: + return "SCALAR_TYPE_UNSPECIFIED"; + case ScalarType.SCALAR_TYPE_STRING: + return "SCALAR_TYPE_STRING"; + case ScalarType.SCALAR_TYPE_BYTES: + return "SCALAR_TYPE_BYTES"; + case ScalarType.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** + * InterfaceDescriptor describes an interface type to be used with + * accepts_interface and implements_interface and declared by declare_interface. + */ +export interface InterfaceDescriptor { + /** + * name is the name of the interface. It should be a short-name (without + * a period) such that the fully qualified name of the interface will be + * package.name, ex. for the package a.b and interface named C, the + * fully-qualified name will be a.b.C. + */ + name: string; + /** + * description is a human-readable description of the interface and its + * purpose. + */ + description: string; +} +export interface InterfaceDescriptorProtoMsg { + typeUrl: "/cosmos_proto.InterfaceDescriptor"; + value: Uint8Array; +} +/** + * InterfaceDescriptor describes an interface type to be used with + * accepts_interface and implements_interface and declared by declare_interface. + */ +export interface InterfaceDescriptorSDKType { + name: string; + description: string; +} +/** + * ScalarDescriptor describes an scalar type to be used with + * the scalar field option and declared by declare_scalar. + * Scalars extend simple protobuf built-in types with additional + * syntax and semantics, for instance to represent big integers. + * Scalars should ideally define an encoding such that there is only one + * valid syntactical representation for a given semantic meaning, + * i.e. the encoding should be deterministic. + */ +export interface ScalarDescriptor { + /** + * name is the name of the scalar. It should be a short-name (without + * a period) such that the fully qualified name of the scalar will be + * package.name, ex. for the package a.b and scalar named C, the + * fully-qualified name will be a.b.C. + */ + name: string; + /** + * description is a human-readable description of the scalar and its + * encoding format. For instance a big integer or decimal scalar should + * specify precisely the expected encoding format. + */ + description: string; + /** + * field_type is the type of field with which this scalar can be used. + * Scalars can be used with one and only one type of field so that + * encoding standards and simple and clear. Currently only string and + * bytes fields are supported for scalars. + */ + fieldType: ScalarType[]; +} +export interface ScalarDescriptorProtoMsg { + typeUrl: "/cosmos_proto.ScalarDescriptor"; + value: Uint8Array; +} +/** + * ScalarDescriptor describes an scalar type to be used with + * the scalar field option and declared by declare_scalar. + * Scalars extend simple protobuf built-in types with additional + * syntax and semantics, for instance to represent big integers. + * Scalars should ideally define an encoding such that there is only one + * valid syntactical representation for a given semantic meaning, + * i.e. the encoding should be deterministic. + */ +export interface ScalarDescriptorSDKType { + name: string; + description: string; + field_type: ScalarType[]; +} +function createBaseInterfaceDescriptor(): InterfaceDescriptor { + return { + name: "", + description: "" + }; +} +export const InterfaceDescriptor = { + typeUrl: "/cosmos_proto.InterfaceDescriptor", + encode(message: InterfaceDescriptor, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + if (message.description !== undefined) { + writer.uint32(18).string(message.description); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): InterfaceDescriptor { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseInterfaceDescriptor(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.description = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): InterfaceDescriptor { + const obj = createBaseInterfaceDescriptor(); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.description)) obj.description = String(object.description); + return obj; + }, + toJSON(message: InterfaceDescriptor): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.description !== undefined && (obj.description = message.description); + return obj; + }, + fromPartial(object: DeepPartial): InterfaceDescriptor { + const message = createBaseInterfaceDescriptor(); + message.name = object.name ?? ""; + message.description = object.description ?? ""; + return message; + }, + fromSDK(object: InterfaceDescriptorSDKType): InterfaceDescriptor { + return { + name: object?.name, + description: object?.description + }; + }, + fromSDKJSON(object: any): InterfaceDescriptorSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + description: isSet(object.description) ? String(object.description) : "" + }; + }, + toSDK(message: InterfaceDescriptor): InterfaceDescriptorSDKType { + const obj: any = {}; + obj.name = message.name; + obj.description = message.description; + return obj; + }, + fromAmino(object: InterfaceDescriptorAmino): InterfaceDescriptor { + const message = createBaseInterfaceDescriptor(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } + return message; + }, + toAmino(message: InterfaceDescriptor): InterfaceDescriptorAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + obj.description = message.description === "" ? undefined : message.description; + return obj; + }, + fromAminoMsg(object: InterfaceDescriptorAminoMsg): InterfaceDescriptor { + return InterfaceDescriptor.fromAmino(object.value); + }, + fromProtoMsg(message: InterfaceDescriptorProtoMsg): InterfaceDescriptor { + return InterfaceDescriptor.decode(message.value); + }, + toProto(message: InterfaceDescriptor): Uint8Array { + return InterfaceDescriptor.encode(message).finish(); + }, + toProtoMsg(message: InterfaceDescriptor): InterfaceDescriptorProtoMsg { + return { + typeUrl: "/cosmos_proto.InterfaceDescriptor", + value: InterfaceDescriptor.encode(message).finish() + }; + } +}; +function createBaseScalarDescriptor(): ScalarDescriptor { + return { + name: "", + description: "", + fieldType: [] + }; +} +export const ScalarDescriptor = { + typeUrl: "/cosmos_proto.ScalarDescriptor", + encode(message: ScalarDescriptor, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + if (message.description !== undefined) { + writer.uint32(18).string(message.description); + } + writer.uint32(26).fork(); + for (const v of message.fieldType) { + writer.int32(v); + } + writer.ldelim(); + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ScalarDescriptor { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseScalarDescriptor(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.description = reader.string(); + break; + case 3: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.fieldType.push((reader.int32() as any)); + } + } else { + message.fieldType.push((reader.int32() as any)); + } + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ScalarDescriptor { + const obj = createBaseScalarDescriptor(); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.description)) obj.description = String(object.description); + if (Array.isArray(object?.fieldType)) obj.fieldType = object.fieldType.map((e: any) => scalarTypeFromJSON(e)); + return obj; + }, + toJSON(message: ScalarDescriptor): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.description !== undefined && (obj.description = message.description); + if (message.fieldType) { + obj.fieldType = message.fieldType.map(e => scalarTypeToJSON(e)); + } else { + obj.fieldType = []; + } + return obj; + }, + fromPartial(object: DeepPartial): ScalarDescriptor { + const message = createBaseScalarDescriptor(); + message.name = object.name ?? ""; + message.description = object.description ?? ""; + message.fieldType = object.fieldType?.map(e => e) || []; + return message; + }, + fromSDK(object: ScalarDescriptorSDKType): ScalarDescriptor { + return { + name: object?.name, + description: object?.description, + fieldType: Array.isArray(object?.field_type) ? object.field_type.map((e: any) => scalarTypeFromJSON(e)) : [] + }; + }, + fromSDKJSON(object: any): ScalarDescriptorSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + description: isSet(object.description) ? String(object.description) : "", + field_type: Array.isArray(object?.field_type) ? object.field_type.map((e: any) => scalarTypeFromJSON(e)) : [] + }; + }, + toSDK(message: ScalarDescriptor): ScalarDescriptorSDKType { + const obj: any = {}; + obj.name = message.name; + obj.description = message.description; + if (message.fieldType) { + obj.field_type = message.fieldType.map(e => scalarTypeToJSON(e)); + } else { + obj.field_type = []; + } + return obj; + }, + fromAmino(object: ScalarDescriptorAmino): ScalarDescriptor { + const message = createBaseScalarDescriptor(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } + message.fieldType = object.field_type?.map(e => e) || []; + return message; + }, + toAmino(message: ScalarDescriptor): ScalarDescriptorAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + obj.description = message.description === "" ? undefined : message.description; + if (message.fieldType) { + obj.field_type = message.fieldType.map(e => e); + } else { + obj.field_type = message.fieldType; + } + return obj; + }, + fromAminoMsg(object: ScalarDescriptorAminoMsg): ScalarDescriptor { + return ScalarDescriptor.fromAmino(object.value); + }, + fromProtoMsg(message: ScalarDescriptorProtoMsg): ScalarDescriptor { + return ScalarDescriptor.decode(message.value); + }, + toProto(message: ScalarDescriptor): Uint8Array { + return ScalarDescriptor.encode(message).finish(); + }, + toProtoMsg(message: ScalarDescriptor): ScalarDescriptorProtoMsg { + return { + typeUrl: "/cosmos_proto.ScalarDescriptor", + value: ScalarDescriptor.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmwasm/bundle.ts b/__fixtures__/v-next/outputicjsdeps/cosmwasm/bundle.ts new file mode 100644 index 0000000000..7509d6daa8 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmwasm/bundle.ts @@ -0,0 +1,36 @@ +import * as _147 from "./wasm/v1/genesis.js"; +import * as _148 from "./wasm/v1/ibc.js"; +import * as _149 from "./wasm/v1/proposal.js"; +import * as _150 from "./wasm/v1/query.js"; +import * as _151 from "./wasm/v1/tx.js"; +import * as _152 from "./wasm/v1/types.js"; +import * as _434 from "./wasm/v1/tx.amino.js"; +import * as _435 from "./wasm/v1/tx.registry.js"; +import * as _436 from "./wasm/v1/query.lcd.js"; +import * as _437 from "./wasm/v1/query.rpc.Query.js"; +import * as _438 from "./wasm/v1/tx.rpc.msg.js"; +import * as _544 from "./lcd.js"; +import * as _545 from "./rpc.query.js"; +import * as _546 from "./rpc.tx.js"; +export namespace cosmwasm { + export namespace wasm { + export const v1 = { + ..._147, + ..._148, + ..._149, + ..._150, + ..._151, + ..._152, + ..._434, + ..._435, + ..._436, + ..._437, + ..._438 + }; + } + export const ClientFactory = { + ..._544, + ..._545, + ..._546 + }; +} \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmwasm/client.ts b/__fixtures__/v-next/outputicjsdeps/cosmwasm/client.ts new file mode 100644 index 0000000000..c9f2fa6696 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmwasm/client.ts @@ -0,0 +1,47 @@ +import { GeneratedType, Registry, OfflineSigner } from "@cosmjs/proto-signing"; +import { defaultRegistryTypes, AminoTypes, SigningStargateClient } from "@cosmjs/stargate"; +import { HttpEndpoint } from "@cosmjs/tendermint-rpc"; +import * as cosmwasmWasmV1TxRegistry from "./wasm/v1/tx.registry.js"; +import * as cosmwasmWasmV1TxAmino from "./wasm/v1/tx.amino.js"; +export const cosmwasmAminoConverters = { + ...cosmwasmWasmV1TxAmino.AminoConverter +}; +export const cosmwasmProtoRegistry: ReadonlyArray<[string, GeneratedType]> = [...cosmwasmWasmV1TxRegistry.registry]; +export const getSigningCosmwasmClientOptions = ({ + defaultTypes = defaultRegistryTypes +}: { + defaultTypes?: ReadonlyArray<[string, GeneratedType]>; +} = {}): { + registry: Registry; + aminoTypes: AminoTypes; +} => { + const registry = new Registry([...defaultTypes, ...cosmwasmProtoRegistry]); + const aminoTypes = new AminoTypes({ + ...cosmwasmAminoConverters + }); + return { + registry, + aminoTypes + }; +}; +export const getSigningCosmwasmClient = async ({ + rpcEndpoint, + signer, + defaultTypes = defaultRegistryTypes +}: { + rpcEndpoint: string | HttpEndpoint; + signer: OfflineSigner; + defaultTypes?: ReadonlyArray<[string, GeneratedType]>; +}) => { + const { + registry, + aminoTypes + } = getSigningCosmwasmClientOptions({ + defaultTypes + }); + const client = await SigningStargateClient.connectWithSigner(rpcEndpoint, signer, { + registry: (registry as any), + aminoTypes + }); + return client; +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmwasm/lcd.ts b/__fixtures__/v-next/outputicjsdeps/cosmwasm/lcd.ts new file mode 100644 index 0000000000..311dbf0829 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmwasm/lcd.ts @@ -0,0 +1,114 @@ +import { LCDClient } from "@cosmology/lcd"; +export const createLCDClient = async ({ + restEndpoint +}: { + restEndpoint: string; +}) => { + const requestClient = new LCDClient({ + restEndpoint + }); + return { + cosmos: { + auth: { + v1beta1: new (await import("../cosmos/auth/v1beta1/query.lcd")).LCDQueryClient({ + requestClient + }) + }, + authz: { + v1beta1: new (await import("../cosmos/authz/v1beta1/query.lcd")).LCDQueryClient({ + requestClient + }) + }, + bank: { + v1beta1: new (await import("../cosmos/bank/v1beta1/query.lcd")).LCDQueryClient({ + requestClient + }) + }, + base: { + reflection: { + v1beta1: new (await import("../cosmos/base/reflection/v1beta1/reflection.lcd")).LCDQueryClient({ + requestClient + }), + v2alpha1: new (await import("../cosmos/base/reflection/v2alpha1/reflection.lcd")).LCDQueryClient({ + requestClient + }) + }, + tendermint: { + v1beta1: new (await import("../cosmos/base/tendermint/v1beta1/query.lcd")).LCDQueryClient({ + requestClient + }) + } + }, + distribution: { + v1beta1: new (await import("../cosmos/distribution/v1beta1/query.lcd")).LCDQueryClient({ + requestClient + }) + }, + evidence: { + v1beta1: new (await import("../cosmos/evidence/v1beta1/query.lcd")).LCDQueryClient({ + requestClient + }) + }, + feegrant: { + v1beta1: new (await import("../cosmos/feegrant/v1beta1/query.lcd")).LCDQueryClient({ + requestClient + }) + }, + gov: { + v1: new (await import("../cosmos/gov/v1/query.lcd")).LCDQueryClient({ + requestClient + }), + v1beta1: new (await import("../cosmos/gov/v1beta1/query.lcd")).LCDQueryClient({ + requestClient + }) + }, + group: { + v1: new (await import("../cosmos/group/v1/query.lcd")).LCDQueryClient({ + requestClient + }) + }, + mint: { + v1beta1: new (await import("../cosmos/mint/v1beta1/query.lcd")).LCDQueryClient({ + requestClient + }) + }, + nft: { + v1beta1: new (await import("../cosmos/nft/v1beta1/query.lcd")).LCDQueryClient({ + requestClient + }) + }, + params: { + v1beta1: new (await import("../cosmos/params/v1beta1/query.lcd")).LCDQueryClient({ + requestClient + }) + }, + slashing: { + v1beta1: new (await import("../cosmos/slashing/v1beta1/query.lcd")).LCDQueryClient({ + requestClient + }) + }, + staking: { + v1beta1: new (await import("../cosmos/staking/v1beta1/query.lcd")).LCDQueryClient({ + requestClient + }) + }, + tx: { + v1beta1: new (await import("../cosmos/tx/v1beta1/service.lcd")).LCDQueryClient({ + requestClient + }) + }, + upgrade: { + v1beta1: new (await import("../cosmos/upgrade/v1beta1/query.lcd")).LCDQueryClient({ + requestClient + }) + } + }, + cosmwasm: { + wasm: { + v1: new (await import("./wasm/v1/query.lcd")).LCDQueryClient({ + requestClient + }) + } + } + }; +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmwasm/rpc.query.ts b/__fixtures__/v-next/outputicjsdeps/cosmwasm/rpc.query.ts new file mode 100644 index 0000000000..f1213e3fa7 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmwasm/rpc.query.ts @@ -0,0 +1,78 @@ +import { Rpc } from "../helpers.js"; +import { connectComet, HttpEndpoint } from "@cosmjs/tendermint-rpc"; +import { QueryClient } from "@cosmjs/stargate"; +export const createRPCQueryClient = async ({ + rpcEndpoint +}: { + rpcEndpoint: string | HttpEndpoint; +}) => { + const tmClient = await connectComet(rpcEndpoint); + const client = new QueryClient(tmClient); + return { + cosmos: { + app: { + v1alpha1: (await import("../cosmos/app/v1alpha1/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + auth: { + v1beta1: (await import("../cosmos/auth/v1beta1/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + authz: { + v1beta1: (await import("../cosmos/authz/v1beta1/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + bank: { + v1beta1: (await import("../cosmos/bank/v1beta1/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + base: { + reflection: { + v1beta1: (await import("../cosmos/base/reflection/v1beta1/reflection.rpc.ReflectionService.js")).createRpcQueryExtension(client), + v2alpha1: (await import("../cosmos/base/reflection/v2alpha1/reflection.rpc.ReflectionService.js")).createRpcQueryExtension(client) + }, + tendermint: { + v1beta1: (await import("../cosmos/base/tendermint/v1beta1/query.rpc.Service.js")).createRpcQueryExtension(client) + } + }, + distribution: { + v1beta1: (await import("../cosmos/distribution/v1beta1/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + evidence: { + v1beta1: (await import("../cosmos/evidence/v1beta1/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + feegrant: { + v1beta1: (await import("../cosmos/feegrant/v1beta1/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + gov: { + v1: (await import("../cosmos/gov/v1/query.rpc.Query.js")).createRpcQueryExtension(client), + v1beta1: (await import("../cosmos/gov/v1beta1/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + group: { + v1: (await import("../cosmos/group/v1/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + mint: { + v1beta1: (await import("../cosmos/mint/v1beta1/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + nft: { + v1beta1: (await import("../cosmos/nft/v1beta1/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + params: { + v1beta1: (await import("../cosmos/params/v1beta1/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + slashing: { + v1beta1: (await import("../cosmos/slashing/v1beta1/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + staking: { + v1beta1: (await import("../cosmos/staking/v1beta1/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + tx: { + v1beta1: (await import("../cosmos/tx/v1beta1/service.rpc.Service.js")).createRpcQueryExtension(client) + }, + upgrade: { + v1beta1: (await import("../cosmos/upgrade/v1beta1/query.rpc.Query.js")).createRpcQueryExtension(client) + } + }, + cosmwasm: { + wasm: { + v1: (await import("./wasm/v1/query.rpc.Query.js")).createRpcQueryExtension(client) + } + } + }; +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmwasm/rpc.tx.ts b/__fixtures__/v-next/outputicjsdeps/cosmwasm/rpc.tx.ts new file mode 100644 index 0000000000..51d72af436 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmwasm/rpc.tx.ts @@ -0,0 +1,54 @@ +import { Rpc } from "../helpers.js"; +export const createRPCMsgClient = async ({ + rpc +}: { + rpc: Rpc; +}) => ({ + cosmos: { + authz: { + v1beta1: new (await import("../cosmos/authz/v1beta1/tx.rpc.msg.js")).MsgClientImpl(rpc) + }, + bank: { + v1beta1: new (await import("../cosmos/bank/v1beta1/tx.rpc.msg.js")).MsgClientImpl(rpc) + }, + crisis: { + v1beta1: new (await import("../cosmos/crisis/v1beta1/tx.rpc.msg.js")).MsgClientImpl(rpc) + }, + distribution: { + v1beta1: new (await import("../cosmos/distribution/v1beta1/tx.rpc.msg.js")).MsgClientImpl(rpc) + }, + evidence: { + v1beta1: new (await import("../cosmos/evidence/v1beta1/tx.rpc.msg.js")).MsgClientImpl(rpc) + }, + feegrant: { + v1beta1: new (await import("../cosmos/feegrant/v1beta1/tx.rpc.msg.js")).MsgClientImpl(rpc) + }, + gov: { + v1: new (await import("../cosmos/gov/v1/tx.rpc.msg.js")).MsgClientImpl(rpc), + v1beta1: new (await import("../cosmos/gov/v1beta1/tx.rpc.msg.js")).MsgClientImpl(rpc) + }, + group: { + v1: new (await import("../cosmos/group/v1/tx.rpc.msg.js")).MsgClientImpl(rpc) + }, + nft: { + v1beta1: new (await import("../cosmos/nft/v1beta1/tx.rpc.msg.js")).MsgClientImpl(rpc) + }, + slashing: { + v1beta1: new (await import("../cosmos/slashing/v1beta1/tx.rpc.msg.js")).MsgClientImpl(rpc) + }, + staking: { + v1beta1: new (await import("../cosmos/staking/v1beta1/tx.rpc.msg.js")).MsgClientImpl(rpc) + }, + upgrade: { + v1beta1: new (await import("../cosmos/upgrade/v1beta1/tx.rpc.msg.js")).MsgClientImpl(rpc) + }, + vesting: { + v1beta1: new (await import("../cosmos/vesting/v1beta1/tx.rpc.msg.js")).MsgClientImpl(rpc) + } + }, + cosmwasm: { + wasm: { + v1: new (await import("./wasm/v1/tx.rpc.msg.js")).MsgClientImpl(rpc) + } + } +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmwasm/wasm/v1/genesis.ts b/__fixtures__/v-next/outputicjsdeps/cosmwasm/wasm/v1/genesis.ts new file mode 100644 index 0000000000..2add1007dc --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmwasm/wasm/v1/genesis.ts @@ -0,0 +1,837 @@ +import { MsgStoreCode, MsgStoreCodeSDKType, MsgInstantiateContract, MsgInstantiateContractSDKType, MsgExecuteContract, MsgExecuteContractSDKType } from "./tx.js"; +import { Params, ParamsSDKType, CodeInfo, CodeInfoSDKType, ContractInfo, ContractInfoSDKType, Model, ModelSDKType } from "./types.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial, bytesFromBase64, base64FromBytes } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "cosmwasm.wasm.v1"; +/** GenesisState - genesis state of x/wasm */ +export interface GenesisState { + params: Params; + codes: Code[]; + contracts: Contract[]; + sequences: Sequence[]; + genMsgs: GenesisState_GenMsgs[]; +} +export interface GenesisStateProtoMsg { + typeUrl: "/cosmwasm.wasm.v1.GenesisState"; + value: Uint8Array; +} +/** GenesisState - genesis state of x/wasm */ +export interface GenesisStateSDKType { + params: ParamsSDKType; + codes: CodeSDKType[]; + contracts: ContractSDKType[]; + sequences: SequenceSDKType[]; + gen_msgs: GenesisState_GenMsgsSDKType[]; +} +/** + * GenMsgs define the messages that can be executed during genesis phase in + * order. The intention is to have more human readable data that is auditable. + */ +export interface GenesisState_GenMsgs { + storeCode?: MsgStoreCode; + instantiateContract?: MsgInstantiateContract; + executeContract?: MsgExecuteContract; +} +export interface GenesisState_GenMsgsProtoMsg { + typeUrl: "/cosmwasm.wasm.v1.GenMsgs"; + value: Uint8Array; +} +/** + * GenMsgs define the messages that can be executed during genesis phase in + * order. The intention is to have more human readable data that is auditable. + */ +export interface GenesisState_GenMsgsSDKType { + store_code?: MsgStoreCodeSDKType; + instantiate_contract?: MsgInstantiateContractSDKType; + execute_contract?: MsgExecuteContractSDKType; +} +/** Code struct encompasses CodeInfo and CodeBytes */ +export interface Code { + codeId: bigint; + codeInfo: CodeInfo; + codeBytes: Uint8Array; + /** Pinned to wasmvm cache */ + pinned: boolean; +} +export interface CodeProtoMsg { + typeUrl: "/cosmwasm.wasm.v1.Code"; + value: Uint8Array; +} +/** Code struct encompasses CodeInfo and CodeBytes */ +export interface CodeSDKType { + code_id: bigint; + code_info: CodeInfoSDKType; + code_bytes: Uint8Array; + pinned: boolean; +} +/** Contract struct encompasses ContractAddress, ContractInfo, and ContractState */ +export interface Contract { + contractAddress: string; + contractInfo: ContractInfo; + contractState: Model[]; +} +export interface ContractProtoMsg { + typeUrl: "/cosmwasm.wasm.v1.Contract"; + value: Uint8Array; +} +/** Contract struct encompasses ContractAddress, ContractInfo, and ContractState */ +export interface ContractSDKType { + contract_address: string; + contract_info: ContractInfoSDKType; + contract_state: ModelSDKType[]; +} +/** Sequence key and value of an id generation counter */ +export interface Sequence { + idKey: Uint8Array; + value: bigint; +} +export interface SequenceProtoMsg { + typeUrl: "/cosmwasm.wasm.v1.Sequence"; + value: Uint8Array; +} +/** Sequence key and value of an id generation counter */ +export interface SequenceSDKType { + id_key: Uint8Array; + value: bigint; +} +function createBaseGenesisState(): GenesisState { + return { + params: Params.fromPartial({}), + codes: [], + contracts: [], + sequences: [], + genMsgs: [] + }; +} +export const GenesisState = { + typeUrl: "/cosmwasm.wasm.v1.GenesisState", + encode(message: GenesisState, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.codes) { + Code.encode(v!, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.contracts) { + Contract.encode(v!, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.sequences) { + Sequence.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.genMsgs) { + GenesisState_GenMsgs.encode(v!, writer.uint32(42).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GenesisState { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGenesisState(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.params = Params.decode(reader, reader.uint32()); + break; + case 2: + message.codes.push(Code.decode(reader, reader.uint32())); + break; + case 3: + message.contracts.push(Contract.decode(reader, reader.uint32())); + break; + case 4: + message.sequences.push(Sequence.decode(reader, reader.uint32())); + break; + case 5: + message.genMsgs.push(GenesisState_GenMsgs.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GenesisState { + const obj = createBaseGenesisState(); + if (isSet(object.params)) obj.params = Params.fromJSON(object.params); + if (Array.isArray(object?.codes)) obj.codes = object.codes.map((e: any) => Code.fromJSON(e)); + if (Array.isArray(object?.contracts)) obj.contracts = object.contracts.map((e: any) => Contract.fromJSON(e)); + if (Array.isArray(object?.sequences)) obj.sequences = object.sequences.map((e: any) => Sequence.fromJSON(e)); + if (Array.isArray(object?.genMsgs)) obj.genMsgs = object.genMsgs.map((e: any) => GenesisState_GenMsgs.fromJSON(e)); + return obj; + }, + toJSON(message: GenesisState): JsonSafe { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); + if (message.codes) { + obj.codes = message.codes.map(e => e ? Code.toJSON(e) : undefined); + } else { + obj.codes = []; + } + if (message.contracts) { + obj.contracts = message.contracts.map(e => e ? Contract.toJSON(e) : undefined); + } else { + obj.contracts = []; + } + if (message.sequences) { + obj.sequences = message.sequences.map(e => e ? Sequence.toJSON(e) : undefined); + } else { + obj.sequences = []; + } + if (message.genMsgs) { + obj.genMsgs = message.genMsgs.map(e => e ? GenesisState_GenMsgs.toJSON(e) : undefined); + } else { + obj.genMsgs = []; + } + return obj; + }, + fromPartial(object: DeepPartial): GenesisState { + const message = createBaseGenesisState(); + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } + message.codes = object.codes?.map(e => Code.fromPartial(e)) || []; + message.contracts = object.contracts?.map(e => Contract.fromPartial(e)) || []; + message.sequences = object.sequences?.map(e => Sequence.fromPartial(e)) || []; + message.genMsgs = object.genMsgs?.map(e => GenesisState_GenMsgs.fromPartial(e)) || []; + return message; + }, + fromSDK(object: GenesisStateSDKType): GenesisState { + return { + params: object.params ? Params.fromSDK(object.params) : undefined, + codes: Array.isArray(object?.codes) ? object.codes.map((e: any) => Code.fromSDK(e)) : [], + contracts: Array.isArray(object?.contracts) ? object.contracts.map((e: any) => Contract.fromSDK(e)) : [], + sequences: Array.isArray(object?.sequences) ? object.sequences.map((e: any) => Sequence.fromSDK(e)) : [], + genMsgs: Array.isArray(object?.gen_msgs) ? object.gen_msgs.map((e: any) => GenesisState_GenMsgs.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): GenesisStateSDKType { + return { + params: isSet(object.params) ? Params.fromSDKJSON(object.params) : undefined, + codes: Array.isArray(object?.codes) ? object.codes.map((e: any) => Code.fromSDKJSON(e)) : [], + contracts: Array.isArray(object?.contracts) ? object.contracts.map((e: any) => Contract.fromSDKJSON(e)) : [], + sequences: Array.isArray(object?.sequences) ? object.sequences.map((e: any) => Sequence.fromSDKJSON(e)) : [], + gen_msgs: Array.isArray(object?.gen_msgs) ? object.gen_msgs.map((e: any) => GenesisState_GenMsgs.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: GenesisState): GenesisStateSDKType { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toSDK(message.params) : undefined); + if (message.codes) { + obj.codes = message.codes.map(e => e ? Code.toSDK(e) : undefined); + } else { + obj.codes = []; + } + if (message.contracts) { + obj.contracts = message.contracts.map(e => e ? Contract.toSDK(e) : undefined); + } else { + obj.contracts = []; + } + if (message.sequences) { + obj.sequences = message.sequences.map(e => e ? Sequence.toSDK(e) : undefined); + } else { + obj.sequences = []; + } + if (message.genMsgs) { + obj.gen_msgs = message.genMsgs.map(e => e ? GenesisState_GenMsgs.toSDK(e) : undefined); + } else { + obj.gen_msgs = []; + } + return obj; + }, + fromAmino(object: GenesisStateAmino): GenesisState { + const message = createBaseGenesisState(); + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromAmino(object.params); + } + message.codes = object.codes?.map(e => Code.fromAmino(e)) || []; + message.contracts = object.contracts?.map(e => Contract.fromAmino(e)) || []; + message.sequences = object.sequences?.map(e => Sequence.fromAmino(e)) || []; + message.genMsgs = object.gen_msgs?.map(e => GenesisState_GenMsgs.fromAmino(e)) || []; + return message; + }, + toAmino(message: GenesisState): GenesisStateAmino { + const obj: any = {}; + obj.params = message.params ? Params.toAmino(message.params) : undefined; + if (message.codes) { + obj.codes = message.codes.map(e => e ? Code.toAmino(e) : undefined); + } else { + obj.codes = message.codes; + } + if (message.contracts) { + obj.contracts = message.contracts.map(e => e ? Contract.toAmino(e) : undefined); + } else { + obj.contracts = message.contracts; + } + if (message.sequences) { + obj.sequences = message.sequences.map(e => e ? Sequence.toAmino(e) : undefined); + } else { + obj.sequences = message.sequences; + } + if (message.genMsgs) { + obj.gen_msgs = message.genMsgs.map(e => e ? GenesisState_GenMsgs.toAmino(e) : undefined); + } else { + obj.gen_msgs = message.genMsgs; + } + return obj; + }, + fromAminoMsg(object: GenesisStateAminoMsg): GenesisState { + return GenesisState.fromAmino(object.value); + }, + toAminoMsg(message: GenesisState): GenesisStateAminoMsg { + return { + type: "wasm/GenesisState", + value: GenesisState.toAmino(message) + }; + }, + fromProtoMsg(message: GenesisStateProtoMsg): GenesisState { + return GenesisState.decode(message.value); + }, + toProto(message: GenesisState): Uint8Array { + return GenesisState.encode(message).finish(); + }, + toProtoMsg(message: GenesisState): GenesisStateProtoMsg { + return { + typeUrl: "/cosmwasm.wasm.v1.GenesisState", + value: GenesisState.encode(message).finish() + }; + } +}; +function createBaseGenesisState_GenMsgs(): GenesisState_GenMsgs { + return { + storeCode: undefined, + instantiateContract: undefined, + executeContract: undefined + }; +} +export const GenesisState_GenMsgs = { + typeUrl: "/cosmwasm.wasm.v1.GenMsgs", + encode(message: GenesisState_GenMsgs, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.storeCode !== undefined) { + MsgStoreCode.encode(message.storeCode, writer.uint32(10).fork()).ldelim(); + } + if (message.instantiateContract !== undefined) { + MsgInstantiateContract.encode(message.instantiateContract, writer.uint32(18).fork()).ldelim(); + } + if (message.executeContract !== undefined) { + MsgExecuteContract.encode(message.executeContract, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GenesisState_GenMsgs { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGenesisState_GenMsgs(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.storeCode = MsgStoreCode.decode(reader, reader.uint32()); + break; + case 2: + message.instantiateContract = MsgInstantiateContract.decode(reader, reader.uint32()); + break; + case 3: + message.executeContract = MsgExecuteContract.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GenesisState_GenMsgs { + const obj = createBaseGenesisState_GenMsgs(); + if (isSet(object.storeCode)) obj.storeCode = MsgStoreCode.fromJSON(object.storeCode); + if (isSet(object.instantiateContract)) obj.instantiateContract = MsgInstantiateContract.fromJSON(object.instantiateContract); + if (isSet(object.executeContract)) obj.executeContract = MsgExecuteContract.fromJSON(object.executeContract); + return obj; + }, + toJSON(message: GenesisState_GenMsgs): JsonSafe { + const obj: any = {}; + message.storeCode !== undefined && (obj.storeCode = message.storeCode ? MsgStoreCode.toJSON(message.storeCode) : undefined); + message.instantiateContract !== undefined && (obj.instantiateContract = message.instantiateContract ? MsgInstantiateContract.toJSON(message.instantiateContract) : undefined); + message.executeContract !== undefined && (obj.executeContract = message.executeContract ? MsgExecuteContract.toJSON(message.executeContract) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): GenesisState_GenMsgs { + const message = createBaseGenesisState_GenMsgs(); + if (object.storeCode !== undefined && object.storeCode !== null) { + message.storeCode = MsgStoreCode.fromPartial(object.storeCode); + } + if (object.instantiateContract !== undefined && object.instantiateContract !== null) { + message.instantiateContract = MsgInstantiateContract.fromPartial(object.instantiateContract); + } + if (object.executeContract !== undefined && object.executeContract !== null) { + message.executeContract = MsgExecuteContract.fromPartial(object.executeContract); + } + return message; + }, + fromSDK(object: GenesisState_GenMsgsSDKType): GenesisState_GenMsgs { + return { + storeCode: object.store_code ? MsgStoreCode.fromSDK(object.store_code) : undefined, + instantiateContract: object.instantiate_contract ? MsgInstantiateContract.fromSDK(object.instantiate_contract) : undefined, + executeContract: object.execute_contract ? MsgExecuteContract.fromSDK(object.execute_contract) : undefined + }; + }, + fromSDKJSON(object: any): GenesisState_GenMsgsSDKType { + return { + store_code: isSet(object.store_code) ? MsgStoreCode.fromSDKJSON(object.store_code) : undefined, + instantiate_contract: isSet(object.instantiate_contract) ? MsgInstantiateContract.fromSDKJSON(object.instantiate_contract) : undefined, + execute_contract: isSet(object.execute_contract) ? MsgExecuteContract.fromSDKJSON(object.execute_contract) : undefined + }; + }, + toSDK(message: GenesisState_GenMsgs): GenesisState_GenMsgsSDKType { + const obj: any = {}; + message.storeCode !== undefined && (obj.store_code = message.storeCode ? MsgStoreCode.toSDK(message.storeCode) : undefined); + message.instantiateContract !== undefined && (obj.instantiate_contract = message.instantiateContract ? MsgInstantiateContract.toSDK(message.instantiateContract) : undefined); + message.executeContract !== undefined && (obj.execute_contract = message.executeContract ? MsgExecuteContract.toSDK(message.executeContract) : undefined); + return obj; + }, + fromAmino(object: GenesisState_GenMsgsAmino): GenesisState_GenMsgs { + const message = createBaseGenesisState_GenMsgs(); + if (object.store_code !== undefined && object.store_code !== null) { + message.storeCode = MsgStoreCode.fromAmino(object.store_code); + } + if (object.instantiate_contract !== undefined && object.instantiate_contract !== null) { + message.instantiateContract = MsgInstantiateContract.fromAmino(object.instantiate_contract); + } + if (object.execute_contract !== undefined && object.execute_contract !== null) { + message.executeContract = MsgExecuteContract.fromAmino(object.execute_contract); + } + return message; + }, + toAmino(message: GenesisState_GenMsgs): GenesisState_GenMsgsAmino { + const obj: any = {}; + obj.store_code = message.storeCode ? MsgStoreCode.toAmino(message.storeCode) : undefined; + obj.instantiate_contract = message.instantiateContract ? MsgInstantiateContract.toAmino(message.instantiateContract) : undefined; + obj.execute_contract = message.executeContract ? MsgExecuteContract.toAmino(message.executeContract) : undefined; + return obj; + }, + fromAminoMsg(object: GenesisState_GenMsgsAminoMsg): GenesisState_GenMsgs { + return GenesisState_GenMsgs.fromAmino(object.value); + }, + toAminoMsg(message: GenesisState_GenMsgs): GenesisState_GenMsgsAminoMsg { + return { + type: "wasm/GenMsgs", + value: GenesisState_GenMsgs.toAmino(message) + }; + }, + fromProtoMsg(message: GenesisState_GenMsgsProtoMsg): GenesisState_GenMsgs { + return GenesisState_GenMsgs.decode(message.value); + }, + toProto(message: GenesisState_GenMsgs): Uint8Array { + return GenesisState_GenMsgs.encode(message).finish(); + }, + toProtoMsg(message: GenesisState_GenMsgs): GenesisState_GenMsgsProtoMsg { + return { + typeUrl: "/cosmwasm.wasm.v1.GenMsgs", + value: GenesisState_GenMsgs.encode(message).finish() + }; + } +}; +function createBaseCode(): Code { + return { + codeId: BigInt(0), + codeInfo: CodeInfo.fromPartial({}), + codeBytes: new Uint8Array(), + pinned: false + }; +} +export const Code = { + typeUrl: "/cosmwasm.wasm.v1.Code", + encode(message: Code, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.codeId !== undefined) { + writer.uint32(8).uint64(message.codeId); + } + if (message.codeInfo !== undefined) { + CodeInfo.encode(message.codeInfo, writer.uint32(18).fork()).ldelim(); + } + if (message.codeBytes.length !== 0) { + writer.uint32(26).bytes(message.codeBytes); + } + if (message.pinned !== undefined) { + writer.uint32(32).bool(message.pinned); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Code { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCode(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.codeId = reader.uint64(); + break; + case 2: + message.codeInfo = CodeInfo.decode(reader, reader.uint32()); + break; + case 3: + message.codeBytes = reader.bytes(); + break; + case 4: + message.pinned = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Code { + const obj = createBaseCode(); + if (isSet(object.codeId)) obj.codeId = BigInt(object.codeId.toString()); + if (isSet(object.codeInfo)) obj.codeInfo = CodeInfo.fromJSON(object.codeInfo); + if (isSet(object.codeBytes)) obj.codeBytes = bytesFromBase64(object.codeBytes); + if (isSet(object.pinned)) obj.pinned = Boolean(object.pinned); + return obj; + }, + toJSON(message: Code): JsonSafe { + const obj: any = {}; + message.codeId !== undefined && (obj.codeId = (message.codeId || BigInt(0)).toString()); + message.codeInfo !== undefined && (obj.codeInfo = message.codeInfo ? CodeInfo.toJSON(message.codeInfo) : undefined); + message.codeBytes !== undefined && (obj.codeBytes = base64FromBytes(message.codeBytes !== undefined ? message.codeBytes : new Uint8Array())); + message.pinned !== undefined && (obj.pinned = message.pinned); + return obj; + }, + fromPartial(object: DeepPartial): Code { + const message = createBaseCode(); + if (object.codeId !== undefined && object.codeId !== null) { + message.codeId = BigInt(object.codeId.toString()); + } + if (object.codeInfo !== undefined && object.codeInfo !== null) { + message.codeInfo = CodeInfo.fromPartial(object.codeInfo); + } + message.codeBytes = object.codeBytes ?? new Uint8Array(); + message.pinned = object.pinned ?? false; + return message; + }, + fromSDK(object: CodeSDKType): Code { + return { + codeId: object?.code_id, + codeInfo: object.code_info ? CodeInfo.fromSDK(object.code_info) : undefined, + codeBytes: object?.code_bytes, + pinned: object?.pinned + }; + }, + fromSDKJSON(object: any): CodeSDKType { + return { + code_id: isSet(object.code_id) ? BigInt(object.code_id.toString()) : BigInt(0), + code_info: isSet(object.code_info) ? CodeInfo.fromSDKJSON(object.code_info) : undefined, + code_bytes: isSet(object.code_bytes) ? bytesFromBase64(object.code_bytes) : new Uint8Array(), + pinned: isSet(object.pinned) ? Boolean(object.pinned) : false + }; + }, + toSDK(message: Code): CodeSDKType { + const obj: any = {}; + obj.code_id = message.codeId; + message.codeInfo !== undefined && (obj.code_info = message.codeInfo ? CodeInfo.toSDK(message.codeInfo) : undefined); + obj.code_bytes = message.codeBytes; + obj.pinned = message.pinned; + return obj; + }, + fromAmino(object: CodeAmino): Code { + const message = createBaseCode(); + if (object.code_id !== undefined && object.code_id !== null) { + message.codeId = BigInt(object.code_id); + } + if (object.code_info !== undefined && object.code_info !== null) { + message.codeInfo = CodeInfo.fromAmino(object.code_info); + } + if (object.code_bytes !== undefined && object.code_bytes !== null) { + message.codeBytes = bytesFromBase64(object.code_bytes); + } + if (object.pinned !== undefined && object.pinned !== null) { + message.pinned = object.pinned; + } + return message; + }, + toAmino(message: Code): CodeAmino { + const obj: any = {}; + obj.code_id = message.codeId !== BigInt(0) ? message.codeId?.toString() : undefined; + obj.code_info = message.codeInfo ? CodeInfo.toAmino(message.codeInfo) : undefined; + obj.code_bytes = message.codeBytes ? base64FromBytes(message.codeBytes) : undefined; + obj.pinned = message.pinned === false ? undefined : message.pinned; + return obj; + }, + fromAminoMsg(object: CodeAminoMsg): Code { + return Code.fromAmino(object.value); + }, + toAminoMsg(message: Code): CodeAminoMsg { + return { + type: "wasm/Code", + value: Code.toAmino(message) + }; + }, + fromProtoMsg(message: CodeProtoMsg): Code { + return Code.decode(message.value); + }, + toProto(message: Code): Uint8Array { + return Code.encode(message).finish(); + }, + toProtoMsg(message: Code): CodeProtoMsg { + return { + typeUrl: "/cosmwasm.wasm.v1.Code", + value: Code.encode(message).finish() + }; + } +}; +function createBaseContract(): Contract { + return { + contractAddress: "", + contractInfo: ContractInfo.fromPartial({}), + contractState: [] + }; +} +export const Contract = { + typeUrl: "/cosmwasm.wasm.v1.Contract", + encode(message: Contract, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.contractAddress !== undefined) { + writer.uint32(10).string(message.contractAddress); + } + if (message.contractInfo !== undefined) { + ContractInfo.encode(message.contractInfo, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.contractState) { + Model.encode(v!, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Contract { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseContract(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.contractAddress = reader.string(); + break; + case 2: + message.contractInfo = ContractInfo.decode(reader, reader.uint32()); + break; + case 3: + message.contractState.push(Model.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Contract { + const obj = createBaseContract(); + if (isSet(object.contractAddress)) obj.contractAddress = String(object.contractAddress); + if (isSet(object.contractInfo)) obj.contractInfo = ContractInfo.fromJSON(object.contractInfo); + if (Array.isArray(object?.contractState)) obj.contractState = object.contractState.map((e: any) => Model.fromJSON(e)); + return obj; + }, + toJSON(message: Contract): JsonSafe { + const obj: any = {}; + message.contractAddress !== undefined && (obj.contractAddress = message.contractAddress); + message.contractInfo !== undefined && (obj.contractInfo = message.contractInfo ? ContractInfo.toJSON(message.contractInfo) : undefined); + if (message.contractState) { + obj.contractState = message.contractState.map(e => e ? Model.toJSON(e) : undefined); + } else { + obj.contractState = []; + } + return obj; + }, + fromPartial(object: DeepPartial): Contract { + const message = createBaseContract(); + message.contractAddress = object.contractAddress ?? ""; + if (object.contractInfo !== undefined && object.contractInfo !== null) { + message.contractInfo = ContractInfo.fromPartial(object.contractInfo); + } + message.contractState = object.contractState?.map(e => Model.fromPartial(e)) || []; + return message; + }, + fromSDK(object: ContractSDKType): Contract { + return { + contractAddress: object?.contract_address, + contractInfo: object.contract_info ? ContractInfo.fromSDK(object.contract_info) : undefined, + contractState: Array.isArray(object?.contract_state) ? object.contract_state.map((e: any) => Model.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): ContractSDKType { + return { + contract_address: isSet(object.contract_address) ? String(object.contract_address) : "", + contract_info: isSet(object.contract_info) ? ContractInfo.fromSDKJSON(object.contract_info) : undefined, + contract_state: Array.isArray(object?.contract_state) ? object.contract_state.map((e: any) => Model.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: Contract): ContractSDKType { + const obj: any = {}; + obj.contract_address = message.contractAddress; + message.contractInfo !== undefined && (obj.contract_info = message.contractInfo ? ContractInfo.toSDK(message.contractInfo) : undefined); + if (message.contractState) { + obj.contract_state = message.contractState.map(e => e ? Model.toSDK(e) : undefined); + } else { + obj.contract_state = []; + } + return obj; + }, + fromAmino(object: ContractAmino): Contract { + const message = createBaseContract(); + if (object.contract_address !== undefined && object.contract_address !== null) { + message.contractAddress = object.contract_address; + } + if (object.contract_info !== undefined && object.contract_info !== null) { + message.contractInfo = ContractInfo.fromAmino(object.contract_info); + } + message.contractState = object.contract_state?.map(e => Model.fromAmino(e)) || []; + return message; + }, + toAmino(message: Contract): ContractAmino { + const obj: any = {}; + obj.contract_address = message.contractAddress === "" ? undefined : message.contractAddress; + obj.contract_info = message.contractInfo ? ContractInfo.toAmino(message.contractInfo) : undefined; + if (message.contractState) { + obj.contract_state = message.contractState.map(e => e ? Model.toAmino(e) : undefined); + } else { + obj.contract_state = message.contractState; + } + return obj; + }, + fromAminoMsg(object: ContractAminoMsg): Contract { + return Contract.fromAmino(object.value); + }, + toAminoMsg(message: Contract): ContractAminoMsg { + return { + type: "wasm/Contract", + value: Contract.toAmino(message) + }; + }, + fromProtoMsg(message: ContractProtoMsg): Contract { + return Contract.decode(message.value); + }, + toProto(message: Contract): Uint8Array { + return Contract.encode(message).finish(); + }, + toProtoMsg(message: Contract): ContractProtoMsg { + return { + typeUrl: "/cosmwasm.wasm.v1.Contract", + value: Contract.encode(message).finish() + }; + } +}; +function createBaseSequence(): Sequence { + return { + idKey: new Uint8Array(), + value: BigInt(0) + }; +} +export const Sequence = { + typeUrl: "/cosmwasm.wasm.v1.Sequence", + encode(message: Sequence, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.idKey.length !== 0) { + writer.uint32(10).bytes(message.idKey); + } + if (message.value !== undefined) { + writer.uint32(16).uint64(message.value); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Sequence { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseSequence(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.idKey = reader.bytes(); + break; + case 2: + message.value = reader.uint64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Sequence { + const obj = createBaseSequence(); + if (isSet(object.idKey)) obj.idKey = bytesFromBase64(object.idKey); + if (isSet(object.value)) obj.value = BigInt(object.value.toString()); + return obj; + }, + toJSON(message: Sequence): JsonSafe { + const obj: any = {}; + message.idKey !== undefined && (obj.idKey = base64FromBytes(message.idKey !== undefined ? message.idKey : new Uint8Array())); + message.value !== undefined && (obj.value = (message.value || BigInt(0)).toString()); + return obj; + }, + fromPartial(object: DeepPartial): Sequence { + const message = createBaseSequence(); + message.idKey = object.idKey ?? new Uint8Array(); + if (object.value !== undefined && object.value !== null) { + message.value = BigInt(object.value.toString()); + } + return message; + }, + fromSDK(object: SequenceSDKType): Sequence { + return { + idKey: object?.id_key, + value: object?.value + }; + }, + fromSDKJSON(object: any): SequenceSDKType { + return { + id_key: isSet(object.id_key) ? bytesFromBase64(object.id_key) : new Uint8Array(), + value: isSet(object.value) ? BigInt(object.value.toString()) : BigInt(0) + }; + }, + toSDK(message: Sequence): SequenceSDKType { + const obj: any = {}; + obj.id_key = message.idKey; + obj.value = message.value; + return obj; + }, + fromAmino(object: SequenceAmino): Sequence { + const message = createBaseSequence(); + if (object.id_key !== undefined && object.id_key !== null) { + message.idKey = bytesFromBase64(object.id_key); + } + if (object.value !== undefined && object.value !== null) { + message.value = BigInt(object.value); + } + return message; + }, + toAmino(message: Sequence): SequenceAmino { + const obj: any = {}; + obj.id_key = message.idKey ? base64FromBytes(message.idKey) : undefined; + obj.value = message.value !== BigInt(0) ? message.value?.toString() : undefined; + return obj; + }, + fromAminoMsg(object: SequenceAminoMsg): Sequence { + return Sequence.fromAmino(object.value); + }, + toAminoMsg(message: Sequence): SequenceAminoMsg { + return { + type: "wasm/Sequence", + value: Sequence.toAmino(message) + }; + }, + fromProtoMsg(message: SequenceProtoMsg): Sequence { + return Sequence.decode(message.value); + }, + toProto(message: Sequence): Uint8Array { + return Sequence.encode(message).finish(); + }, + toProtoMsg(message: Sequence): SequenceProtoMsg { + return { + typeUrl: "/cosmwasm.wasm.v1.Sequence", + value: Sequence.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmwasm/wasm/v1/ibc.ts b/__fixtures__/v-next/outputicjsdeps/cosmwasm/wasm/v1/ibc.ts new file mode 100644 index 0000000000..246a4c7a40 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmwasm/wasm/v1/ibc.ts @@ -0,0 +1,290 @@ +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, bytesFromBase64, base64FromBytes, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "cosmwasm.wasm.v1"; +/** MsgIBCSend */ +export interface MsgIBCSend { + /** the channel by which the packet will be sent */ + channel: string; + /** + * Timeout height relative to the current block height. + * The timeout is disabled when set to 0. + */ + timeoutHeight: bigint; + /** + * Timeout timestamp (in nanoseconds) relative to the current block timestamp. + * The timeout is disabled when set to 0. + */ + timeoutTimestamp: bigint; + /** + * Data is the payload to transfer. We must not make assumption what format or + * content is in here. + */ + data: Uint8Array; +} +export interface MsgIBCSendProtoMsg { + typeUrl: "/cosmwasm.wasm.v1.MsgIBCSend"; + value: Uint8Array; +} +/** MsgIBCSend */ +export interface MsgIBCSendSDKType { + channel: string; + timeout_height: bigint; + timeout_timestamp: bigint; + data: Uint8Array; +} +/** MsgIBCCloseChannel port and channel need to be owned by the contract */ +export interface MsgIBCCloseChannel { + channel: string; +} +export interface MsgIBCCloseChannelProtoMsg { + typeUrl: "/cosmwasm.wasm.v1.MsgIBCCloseChannel"; + value: Uint8Array; +} +/** MsgIBCCloseChannel port and channel need to be owned by the contract */ +export interface MsgIBCCloseChannelSDKType { + channel: string; +} +function createBaseMsgIBCSend(): MsgIBCSend { + return { + channel: "", + timeoutHeight: BigInt(0), + timeoutTimestamp: BigInt(0), + data: new Uint8Array() + }; +} +export const MsgIBCSend = { + typeUrl: "/cosmwasm.wasm.v1.MsgIBCSend", + encode(message: MsgIBCSend, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.channel !== undefined) { + writer.uint32(18).string(message.channel); + } + if (message.timeoutHeight !== undefined) { + writer.uint32(32).uint64(message.timeoutHeight); + } + if (message.timeoutTimestamp !== undefined) { + writer.uint32(40).uint64(message.timeoutTimestamp); + } + if (message.data.length !== 0) { + writer.uint32(50).bytes(message.data); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgIBCSend { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgIBCSend(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.channel = reader.string(); + break; + case 4: + message.timeoutHeight = reader.uint64(); + break; + case 5: + message.timeoutTimestamp = reader.uint64(); + break; + case 6: + message.data = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgIBCSend { + const obj = createBaseMsgIBCSend(); + if (isSet(object.channel)) obj.channel = String(object.channel); + if (isSet(object.timeoutHeight)) obj.timeoutHeight = BigInt(object.timeoutHeight.toString()); + if (isSet(object.timeoutTimestamp)) obj.timeoutTimestamp = BigInt(object.timeoutTimestamp.toString()); + if (isSet(object.data)) obj.data = bytesFromBase64(object.data); + return obj; + }, + toJSON(message: MsgIBCSend): JsonSafe { + const obj: any = {}; + message.channel !== undefined && (obj.channel = message.channel); + message.timeoutHeight !== undefined && (obj.timeoutHeight = (message.timeoutHeight || BigInt(0)).toString()); + message.timeoutTimestamp !== undefined && (obj.timeoutTimestamp = (message.timeoutTimestamp || BigInt(0)).toString()); + message.data !== undefined && (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): MsgIBCSend { + const message = createBaseMsgIBCSend(); + message.channel = object.channel ?? ""; + if (object.timeoutHeight !== undefined && object.timeoutHeight !== null) { + message.timeoutHeight = BigInt(object.timeoutHeight.toString()); + } + if (object.timeoutTimestamp !== undefined && object.timeoutTimestamp !== null) { + message.timeoutTimestamp = BigInt(object.timeoutTimestamp.toString()); + } + message.data = object.data ?? new Uint8Array(); + return message; + }, + fromSDK(object: MsgIBCSendSDKType): MsgIBCSend { + return { + channel: object?.channel, + timeoutHeight: object?.timeout_height, + timeoutTimestamp: object?.timeout_timestamp, + data: object?.data + }; + }, + fromSDKJSON(object: any): MsgIBCSendSDKType { + return { + channel: isSet(object.channel) ? String(object.channel) : "", + timeout_height: isSet(object.timeout_height) ? BigInt(object.timeout_height.toString()) : BigInt(0), + timeout_timestamp: isSet(object.timeout_timestamp) ? BigInt(object.timeout_timestamp.toString()) : BigInt(0), + data: isSet(object.data) ? bytesFromBase64(object.data) : new Uint8Array() + }; + }, + toSDK(message: MsgIBCSend): MsgIBCSendSDKType { + const obj: any = {}; + obj.channel = message.channel; + obj.timeout_height = message.timeoutHeight; + obj.timeout_timestamp = message.timeoutTimestamp; + obj.data = message.data; + return obj; + }, + fromAmino(object: MsgIBCSendAmino): MsgIBCSend { + const message = createBaseMsgIBCSend(); + if (object.channel !== undefined && object.channel !== null) { + message.channel = object.channel; + } + if (object.timeout_height !== undefined && object.timeout_height !== null) { + message.timeoutHeight = BigInt(object.timeout_height); + } + if (object.timeout_timestamp !== undefined && object.timeout_timestamp !== null) { + message.timeoutTimestamp = BigInt(object.timeout_timestamp); + } + if (object.data !== undefined && object.data !== null) { + message.data = bytesFromBase64(object.data); + } + return message; + }, + toAmino(message: MsgIBCSend): MsgIBCSendAmino { + const obj: any = {}; + obj.channel = message.channel === "" ? undefined : message.channel; + obj.timeout_height = message.timeoutHeight !== BigInt(0) ? message.timeoutHeight?.toString() : undefined; + obj.timeout_timestamp = message.timeoutTimestamp !== BigInt(0) ? message.timeoutTimestamp?.toString() : undefined; + obj.data = message.data ? base64FromBytes(message.data) : undefined; + return obj; + }, + fromAminoMsg(object: MsgIBCSendAminoMsg): MsgIBCSend { + return MsgIBCSend.fromAmino(object.value); + }, + toAminoMsg(message: MsgIBCSend): MsgIBCSendAminoMsg { + return { + type: "wasm/MsgIBCSend", + value: MsgIBCSend.toAmino(message) + }; + }, + fromProtoMsg(message: MsgIBCSendProtoMsg): MsgIBCSend { + return MsgIBCSend.decode(message.value); + }, + toProto(message: MsgIBCSend): Uint8Array { + return MsgIBCSend.encode(message).finish(); + }, + toProtoMsg(message: MsgIBCSend): MsgIBCSendProtoMsg { + return { + typeUrl: "/cosmwasm.wasm.v1.MsgIBCSend", + value: MsgIBCSend.encode(message).finish() + }; + } +}; +function createBaseMsgIBCCloseChannel(): MsgIBCCloseChannel { + return { + channel: "" + }; +} +export const MsgIBCCloseChannel = { + typeUrl: "/cosmwasm.wasm.v1.MsgIBCCloseChannel", + encode(message: MsgIBCCloseChannel, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.channel !== undefined) { + writer.uint32(18).string(message.channel); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgIBCCloseChannel { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgIBCCloseChannel(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.channel = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgIBCCloseChannel { + const obj = createBaseMsgIBCCloseChannel(); + if (isSet(object.channel)) obj.channel = String(object.channel); + return obj; + }, + toJSON(message: MsgIBCCloseChannel): JsonSafe { + const obj: any = {}; + message.channel !== undefined && (obj.channel = message.channel); + return obj; + }, + fromPartial(object: DeepPartial): MsgIBCCloseChannel { + const message = createBaseMsgIBCCloseChannel(); + message.channel = object.channel ?? ""; + return message; + }, + fromSDK(object: MsgIBCCloseChannelSDKType): MsgIBCCloseChannel { + return { + channel: object?.channel + }; + }, + fromSDKJSON(object: any): MsgIBCCloseChannelSDKType { + return { + channel: isSet(object.channel) ? String(object.channel) : "" + }; + }, + toSDK(message: MsgIBCCloseChannel): MsgIBCCloseChannelSDKType { + const obj: any = {}; + obj.channel = message.channel; + return obj; + }, + fromAmino(object: MsgIBCCloseChannelAmino): MsgIBCCloseChannel { + const message = createBaseMsgIBCCloseChannel(); + if (object.channel !== undefined && object.channel !== null) { + message.channel = object.channel; + } + return message; + }, + toAmino(message: MsgIBCCloseChannel): MsgIBCCloseChannelAmino { + const obj: any = {}; + obj.channel = message.channel === "" ? undefined : message.channel; + return obj; + }, + fromAminoMsg(object: MsgIBCCloseChannelAminoMsg): MsgIBCCloseChannel { + return MsgIBCCloseChannel.fromAmino(object.value); + }, + toAminoMsg(message: MsgIBCCloseChannel): MsgIBCCloseChannelAminoMsg { + return { + type: "wasm/MsgIBCCloseChannel", + value: MsgIBCCloseChannel.toAmino(message) + }; + }, + fromProtoMsg(message: MsgIBCCloseChannelProtoMsg): MsgIBCCloseChannel { + return MsgIBCCloseChannel.decode(message.value); + }, + toProto(message: MsgIBCCloseChannel): Uint8Array { + return MsgIBCCloseChannel.encode(message).finish(); + }, + toProtoMsg(message: MsgIBCCloseChannel): MsgIBCCloseChannelProtoMsg { + return { + typeUrl: "/cosmwasm.wasm.v1.MsgIBCCloseChannel", + value: MsgIBCCloseChannel.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmwasm/wasm/v1/proposal.ts b/__fixtures__/v-next/outputicjsdeps/cosmwasm/wasm/v1/proposal.ts new file mode 100644 index 0000000000..dd73766a61 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmwasm/wasm/v1/proposal.ts @@ -0,0 +1,1704 @@ +import { AccessConfig, AccessConfigSDKType } from "./types.js"; +import { Coin, CoinSDKType } from "../../../cosmos/base/v1beta1/coin.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, bytesFromBase64, base64FromBytes, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +import { fromBase64, toBase64, toUtf8, fromUtf8 } from "@cosmjs/encoding"; +export const protobufPackage = "cosmwasm.wasm.v1"; +/** StoreCodeProposal gov proposal content type to submit WASM code to the system */ +export interface StoreCodeProposal { + /** Title is a short summary */ + title: string; + /** Description is a human readable text */ + description: string; + /** RunAs is the address that is passed to the contract's environment as sender */ + runAs: string; + /** WASMByteCode can be raw or gzip compressed */ + wasmByteCode: Uint8Array; + /** InstantiatePermission to apply on contract creation, optional */ + instantiatePermission?: AccessConfig; +} +export interface StoreCodeProposalProtoMsg { + typeUrl: "/cosmwasm.wasm.v1.StoreCodeProposal"; + value: Uint8Array; +} +/** StoreCodeProposal gov proposal content type to submit WASM code to the system */ +export interface StoreCodeProposalSDKType { + title: string; + description: string; + run_as: string; + wasm_byte_code: Uint8Array; + instantiate_permission?: AccessConfigSDKType; +} +/** + * InstantiateContractProposal gov proposal content type to instantiate a + * contract. + */ +export interface InstantiateContractProposal { + /** Title is a short summary */ + title: string; + /** Description is a human readable text */ + description: string; + /** RunAs is the address that is passed to the contract's environment as sender */ + runAs: string; + /** Admin is an optional address that can execute migrations */ + admin: string; + /** CodeID is the reference to the stored WASM code */ + codeId: bigint; + /** Label is optional metadata to be stored with a constract instance. */ + label: string; + /** Msg json encoded message to be passed to the contract on instantiation */ + msg: Uint8Array; + /** Funds coins that are transferred to the contract on instantiation */ + funds: Coin[]; +} +export interface InstantiateContractProposalProtoMsg { + typeUrl: "/cosmwasm.wasm.v1.InstantiateContractProposal"; + value: Uint8Array; +} +/** + * InstantiateContractProposal gov proposal content type to instantiate a + * contract. + */ +export interface InstantiateContractProposalSDKType { + title: string; + description: string; + run_as: string; + admin: string; + code_id: bigint; + label: string; + msg: Uint8Array; + funds: CoinSDKType[]; +} +/** MigrateContractProposal gov proposal content type to migrate a contract. */ +export interface MigrateContractProposal { + /** Title is a short summary */ + title: string; + /** Description is a human readable text */ + description: string; + /** Contract is the address of the smart contract */ + contract: string; + /** CodeID references the new WASM codesudo */ + codeId: bigint; + /** Msg json encoded message to be passed to the contract on migration */ + msg: Uint8Array; +} +export interface MigrateContractProposalProtoMsg { + typeUrl: "/cosmwasm.wasm.v1.MigrateContractProposal"; + value: Uint8Array; +} +/** MigrateContractProposal gov proposal content type to migrate a contract. */ +export interface MigrateContractProposalSDKType { + title: string; + description: string; + contract: string; + code_id: bigint; + msg: Uint8Array; +} +/** SudoContractProposal gov proposal content type to call sudo on a contract. */ +export interface SudoContractProposal { + /** Title is a short summary */ + title: string; + /** Description is a human readable text */ + description: string; + /** Contract is the address of the smart contract */ + contract: string; + /** Msg json encoded message to be passed to the contract as sudo */ + msg: Uint8Array; +} +export interface SudoContractProposalProtoMsg { + typeUrl: "/cosmwasm.wasm.v1.SudoContractProposal"; + value: Uint8Array; +} +/** SudoContractProposal gov proposal content type to call sudo on a contract. */ +export interface SudoContractProposalSDKType { + title: string; + description: string; + contract: string; + msg: Uint8Array; +} +/** + * ExecuteContractProposal gov proposal content type to call execute on a + * contract. + */ +export interface ExecuteContractProposal { + /** Title is a short summary */ + title: string; + /** Description is a human readable text */ + description: string; + /** RunAs is the address that is passed to the contract's environment as sender */ + runAs: string; + /** Contract is the address of the smart contract */ + contract: string; + /** Msg json encoded message to be passed to the contract as execute */ + msg: Uint8Array; + /** Funds coins that are transferred to the contract on instantiation */ + funds: Coin[]; +} +export interface ExecuteContractProposalProtoMsg { + typeUrl: "/cosmwasm.wasm.v1.ExecuteContractProposal"; + value: Uint8Array; +} +/** + * ExecuteContractProposal gov proposal content type to call execute on a + * contract. + */ +export interface ExecuteContractProposalSDKType { + title: string; + description: string; + run_as: string; + contract: string; + msg: Uint8Array; + funds: CoinSDKType[]; +} +/** UpdateAdminProposal gov proposal content type to set an admin for a contract. */ +export interface UpdateAdminProposal { + /** Title is a short summary */ + title: string; + /** Description is a human readable text */ + description: string; + /** NewAdmin address to be set */ + newAdmin: string; + /** Contract is the address of the smart contract */ + contract: string; +} +export interface UpdateAdminProposalProtoMsg { + typeUrl: "/cosmwasm.wasm.v1.UpdateAdminProposal"; + value: Uint8Array; +} +/** UpdateAdminProposal gov proposal content type to set an admin for a contract. */ +export interface UpdateAdminProposalSDKType { + title: string; + description: string; + new_admin: string; + contract: string; +} +/** + * ClearAdminProposal gov proposal content type to clear the admin of a + * contract. + */ +export interface ClearAdminProposal { + /** Title is a short summary */ + title: string; + /** Description is a human readable text */ + description: string; + /** Contract is the address of the smart contract */ + contract: string; +} +export interface ClearAdminProposalProtoMsg { + typeUrl: "/cosmwasm.wasm.v1.ClearAdminProposal"; + value: Uint8Array; +} +/** + * ClearAdminProposal gov proposal content type to clear the admin of a + * contract. + */ +export interface ClearAdminProposalSDKType { + title: string; + description: string; + contract: string; +} +/** + * PinCodesProposal gov proposal content type to pin a set of code ids in the + * wasmvm cache. + */ +export interface PinCodesProposal { + /** Title is a short summary */ + title: string; + /** Description is a human readable text */ + description: string; + /** CodeIDs references the new WASM codes */ + codeIds: bigint[]; +} +export interface PinCodesProposalProtoMsg { + typeUrl: "/cosmwasm.wasm.v1.PinCodesProposal"; + value: Uint8Array; +} +/** + * PinCodesProposal gov proposal content type to pin a set of code ids in the + * wasmvm cache. + */ +export interface PinCodesProposalSDKType { + title: string; + description: string; + code_ids: bigint[]; +} +/** + * UnpinCodesProposal gov proposal content type to unpin a set of code ids in + * the wasmvm cache. + */ +export interface UnpinCodesProposal { + /** Title is a short summary */ + title: string; + /** Description is a human readable text */ + description: string; + /** CodeIDs references the WASM codes */ + codeIds: bigint[]; +} +export interface UnpinCodesProposalProtoMsg { + typeUrl: "/cosmwasm.wasm.v1.UnpinCodesProposal"; + value: Uint8Array; +} +/** + * UnpinCodesProposal gov proposal content type to unpin a set of code ids in + * the wasmvm cache. + */ +export interface UnpinCodesProposalSDKType { + title: string; + description: string; + code_ids: bigint[]; +} +function createBaseStoreCodeProposal(): StoreCodeProposal { + return { + title: "", + description: "", + runAs: "", + wasmByteCode: new Uint8Array(), + instantiatePermission: undefined + }; +} +export const StoreCodeProposal = { + typeUrl: "/cosmwasm.wasm.v1.StoreCodeProposal", + encode(message: StoreCodeProposal, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.title !== undefined) { + writer.uint32(10).string(message.title); + } + if (message.description !== undefined) { + writer.uint32(18).string(message.description); + } + if (message.runAs !== undefined) { + writer.uint32(26).string(message.runAs); + } + if (message.wasmByteCode.length !== 0) { + writer.uint32(34).bytes(message.wasmByteCode); + } + if (message.instantiatePermission !== undefined) { + AccessConfig.encode(message.instantiatePermission, writer.uint32(58).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): StoreCodeProposal { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseStoreCodeProposal(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.title = reader.string(); + break; + case 2: + message.description = reader.string(); + break; + case 3: + message.runAs = reader.string(); + break; + case 4: + message.wasmByteCode = reader.bytes(); + break; + case 7: + message.instantiatePermission = AccessConfig.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): StoreCodeProposal { + const obj = createBaseStoreCodeProposal(); + if (isSet(object.title)) obj.title = String(object.title); + if (isSet(object.description)) obj.description = String(object.description); + if (isSet(object.runAs)) obj.runAs = String(object.runAs); + if (isSet(object.wasmByteCode)) obj.wasmByteCode = bytesFromBase64(object.wasmByteCode); + if (isSet(object.instantiatePermission)) obj.instantiatePermission = AccessConfig.fromJSON(object.instantiatePermission); + return obj; + }, + toJSON(message: StoreCodeProposal): JsonSafe { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && (obj.description = message.description); + message.runAs !== undefined && (obj.runAs = message.runAs); + message.wasmByteCode !== undefined && (obj.wasmByteCode = base64FromBytes(message.wasmByteCode !== undefined ? message.wasmByteCode : new Uint8Array())); + message.instantiatePermission !== undefined && (obj.instantiatePermission = message.instantiatePermission ? AccessConfig.toJSON(message.instantiatePermission) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): StoreCodeProposal { + const message = createBaseStoreCodeProposal(); + message.title = object.title ?? ""; + message.description = object.description ?? ""; + message.runAs = object.runAs ?? ""; + message.wasmByteCode = object.wasmByteCode ?? new Uint8Array(); + if (object.instantiatePermission !== undefined && object.instantiatePermission !== null) { + message.instantiatePermission = AccessConfig.fromPartial(object.instantiatePermission); + } + return message; + }, + fromSDK(object: StoreCodeProposalSDKType): StoreCodeProposal { + return { + title: object?.title, + description: object?.description, + runAs: object?.run_as, + wasmByteCode: object?.wasm_byte_code, + instantiatePermission: object.instantiate_permission ? AccessConfig.fromSDK(object.instantiate_permission) : undefined + }; + }, + fromSDKJSON(object: any): StoreCodeProposalSDKType { + return { + title: isSet(object.title) ? String(object.title) : "", + description: isSet(object.description) ? String(object.description) : "", + run_as: isSet(object.run_as) ? String(object.run_as) : "", + wasm_byte_code: isSet(object.wasm_byte_code) ? bytesFromBase64(object.wasm_byte_code) : new Uint8Array(), + instantiate_permission: isSet(object.instantiate_permission) ? AccessConfig.fromSDKJSON(object.instantiate_permission) : undefined + }; + }, + toSDK(message: StoreCodeProposal): StoreCodeProposalSDKType { + const obj: any = {}; + obj.title = message.title; + obj.description = message.description; + obj.run_as = message.runAs; + obj.wasm_byte_code = message.wasmByteCode; + message.instantiatePermission !== undefined && (obj.instantiate_permission = message.instantiatePermission ? AccessConfig.toSDK(message.instantiatePermission) : undefined); + return obj; + }, + fromAmino(object: StoreCodeProposalAmino): StoreCodeProposal { + const message = createBaseStoreCodeProposal(); + if (object.title !== undefined && object.title !== null) { + message.title = object.title; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } + if (object.run_as !== undefined && object.run_as !== null) { + message.runAs = object.run_as; + } + if (object.wasm_byte_code !== undefined && object.wasm_byte_code !== null) { + message.wasmByteCode = fromBase64(object.wasm_byte_code); + } + if (object.instantiate_permission !== undefined && object.instantiate_permission !== null) { + message.instantiatePermission = AccessConfig.fromAmino(object.instantiate_permission); + } + return message; + }, + toAmino(message: StoreCodeProposal): StoreCodeProposalAmino { + const obj: any = {}; + obj.title = message.title === "" ? undefined : message.title; + obj.description = message.description === "" ? undefined : message.description; + obj.run_as = message.runAs === "" ? undefined : message.runAs; + obj.wasm_byte_code = message.wasmByteCode ? toBase64(message.wasmByteCode) : undefined; + obj.instantiate_permission = message.instantiatePermission ? AccessConfig.toAmino(message.instantiatePermission) : undefined; + return obj; + }, + fromAminoMsg(object: StoreCodeProposalAminoMsg): StoreCodeProposal { + return StoreCodeProposal.fromAmino(object.value); + }, + toAminoMsg(message: StoreCodeProposal): StoreCodeProposalAminoMsg { + return { + type: "wasm/StoreCodeProposal", + value: StoreCodeProposal.toAmino(message) + }; + }, + fromProtoMsg(message: StoreCodeProposalProtoMsg): StoreCodeProposal { + return StoreCodeProposal.decode(message.value); + }, + toProto(message: StoreCodeProposal): Uint8Array { + return StoreCodeProposal.encode(message).finish(); + }, + toProtoMsg(message: StoreCodeProposal): StoreCodeProposalProtoMsg { + return { + typeUrl: "/cosmwasm.wasm.v1.StoreCodeProposal", + value: StoreCodeProposal.encode(message).finish() + }; + } +}; +function createBaseInstantiateContractProposal(): InstantiateContractProposal { + return { + title: "", + description: "", + runAs: "", + admin: "", + codeId: BigInt(0), + label: "", + msg: new Uint8Array(), + funds: [] + }; +} +export const InstantiateContractProposal = { + typeUrl: "/cosmwasm.wasm.v1.InstantiateContractProposal", + encode(message: InstantiateContractProposal, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.title !== undefined) { + writer.uint32(10).string(message.title); + } + if (message.description !== undefined) { + writer.uint32(18).string(message.description); + } + if (message.runAs !== undefined) { + writer.uint32(26).string(message.runAs); + } + if (message.admin !== undefined) { + writer.uint32(34).string(message.admin); + } + if (message.codeId !== undefined) { + writer.uint32(40).uint64(message.codeId); + } + if (message.label !== undefined) { + writer.uint32(50).string(message.label); + } + if (message.msg.length !== 0) { + writer.uint32(58).bytes(message.msg); + } + for (const v of message.funds) { + Coin.encode(v!, writer.uint32(66).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): InstantiateContractProposal { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseInstantiateContractProposal(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.title = reader.string(); + break; + case 2: + message.description = reader.string(); + break; + case 3: + message.runAs = reader.string(); + break; + case 4: + message.admin = reader.string(); + break; + case 5: + message.codeId = reader.uint64(); + break; + case 6: + message.label = reader.string(); + break; + case 7: + message.msg = reader.bytes(); + break; + case 8: + message.funds.push(Coin.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): InstantiateContractProposal { + const obj = createBaseInstantiateContractProposal(); + if (isSet(object.title)) obj.title = String(object.title); + if (isSet(object.description)) obj.description = String(object.description); + if (isSet(object.runAs)) obj.runAs = String(object.runAs); + if (isSet(object.admin)) obj.admin = String(object.admin); + if (isSet(object.codeId)) obj.codeId = BigInt(object.codeId.toString()); + if (isSet(object.label)) obj.label = String(object.label); + if (isSet(object.msg)) obj.msg = bytesFromBase64(object.msg); + if (Array.isArray(object?.funds)) obj.funds = object.funds.map((e: any) => Coin.fromJSON(e)); + return obj; + }, + toJSON(message: InstantiateContractProposal): JsonSafe { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && (obj.description = message.description); + message.runAs !== undefined && (obj.runAs = message.runAs); + message.admin !== undefined && (obj.admin = message.admin); + message.codeId !== undefined && (obj.codeId = (message.codeId || BigInt(0)).toString()); + message.label !== undefined && (obj.label = message.label); + message.msg !== undefined && (obj.msg = base64FromBytes(message.msg !== undefined ? message.msg : new Uint8Array())); + if (message.funds) { + obj.funds = message.funds.map(e => e ? Coin.toJSON(e) : undefined); + } else { + obj.funds = []; + } + return obj; + }, + fromPartial(object: DeepPartial): InstantiateContractProposal { + const message = createBaseInstantiateContractProposal(); + message.title = object.title ?? ""; + message.description = object.description ?? ""; + message.runAs = object.runAs ?? ""; + message.admin = object.admin ?? ""; + if (object.codeId !== undefined && object.codeId !== null) { + message.codeId = BigInt(object.codeId.toString()); + } + message.label = object.label ?? ""; + message.msg = object.msg ?? new Uint8Array(); + message.funds = object.funds?.map(e => Coin.fromPartial(e)) || []; + return message; + }, + fromSDK(object: InstantiateContractProposalSDKType): InstantiateContractProposal { + return { + title: object?.title, + description: object?.description, + runAs: object?.run_as, + admin: object?.admin, + codeId: object?.code_id, + label: object?.label, + msg: object?.msg, + funds: Array.isArray(object?.funds) ? object.funds.map((e: any) => Coin.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): InstantiateContractProposalSDKType { + return { + title: isSet(object.title) ? String(object.title) : "", + description: isSet(object.description) ? String(object.description) : "", + run_as: isSet(object.run_as) ? String(object.run_as) : "", + admin: isSet(object.admin) ? String(object.admin) : "", + code_id: isSet(object.code_id) ? BigInt(object.code_id.toString()) : BigInt(0), + label: isSet(object.label) ? String(object.label) : "", + msg: isSet(object.msg) ? bytesFromBase64(object.msg) : new Uint8Array(), + funds: Array.isArray(object?.funds) ? object.funds.map((e: any) => Coin.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: InstantiateContractProposal): InstantiateContractProposalSDKType { + const obj: any = {}; + obj.title = message.title; + obj.description = message.description; + obj.run_as = message.runAs; + obj.admin = message.admin; + obj.code_id = message.codeId; + obj.label = message.label; + obj.msg = message.msg; + if (message.funds) { + obj.funds = message.funds.map(e => e ? Coin.toSDK(e) : undefined); + } else { + obj.funds = []; + } + return obj; + }, + fromAmino(object: InstantiateContractProposalAmino): InstantiateContractProposal { + const message = createBaseInstantiateContractProposal(); + if (object.title !== undefined && object.title !== null) { + message.title = object.title; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } + if (object.run_as !== undefined && object.run_as !== null) { + message.runAs = object.run_as; + } + if (object.admin !== undefined && object.admin !== null) { + message.admin = object.admin; + } + if (object.code_id !== undefined && object.code_id !== null) { + message.codeId = BigInt(object.code_id); + } + if (object.label !== undefined && object.label !== null) { + message.label = object.label; + } + if (object.msg !== undefined && object.msg !== null) { + message.msg = toUtf8(JSON.stringify(object.msg)); + } + message.funds = object.funds?.map(e => Coin.fromAmino(e)) || []; + return message; + }, + toAmino(message: InstantiateContractProposal): InstantiateContractProposalAmino { + const obj: any = {}; + obj.title = message.title === "" ? undefined : message.title; + obj.description = message.description === "" ? undefined : message.description; + obj.run_as = message.runAs === "" ? undefined : message.runAs; + obj.admin = message.admin === "" ? undefined : message.admin; + obj.code_id = message.codeId !== BigInt(0) ? message.codeId?.toString() : undefined; + obj.label = message.label === "" ? undefined : message.label; + obj.msg = message.msg ? JSON.parse(fromUtf8(message.msg)) : undefined; + if (message.funds) { + obj.funds = message.funds.map(e => e ? Coin.toAmino(e) : undefined); + } else { + obj.funds = message.funds; + } + return obj; + }, + fromAminoMsg(object: InstantiateContractProposalAminoMsg): InstantiateContractProposal { + return InstantiateContractProposal.fromAmino(object.value); + }, + toAminoMsg(message: InstantiateContractProposal): InstantiateContractProposalAminoMsg { + return { + type: "wasm/InstantiateContractProposal", + value: InstantiateContractProposal.toAmino(message) + }; + }, + fromProtoMsg(message: InstantiateContractProposalProtoMsg): InstantiateContractProposal { + return InstantiateContractProposal.decode(message.value); + }, + toProto(message: InstantiateContractProposal): Uint8Array { + return InstantiateContractProposal.encode(message).finish(); + }, + toProtoMsg(message: InstantiateContractProposal): InstantiateContractProposalProtoMsg { + return { + typeUrl: "/cosmwasm.wasm.v1.InstantiateContractProposal", + value: InstantiateContractProposal.encode(message).finish() + }; + } +}; +function createBaseMigrateContractProposal(): MigrateContractProposal { + return { + title: "", + description: "", + contract: "", + codeId: BigInt(0), + msg: new Uint8Array() + }; +} +export const MigrateContractProposal = { + typeUrl: "/cosmwasm.wasm.v1.MigrateContractProposal", + encode(message: MigrateContractProposal, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.title !== undefined) { + writer.uint32(10).string(message.title); + } + if (message.description !== undefined) { + writer.uint32(18).string(message.description); + } + if (message.contract !== undefined) { + writer.uint32(34).string(message.contract); + } + if (message.codeId !== undefined) { + writer.uint32(40).uint64(message.codeId); + } + if (message.msg.length !== 0) { + writer.uint32(50).bytes(message.msg); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MigrateContractProposal { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMigrateContractProposal(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.title = reader.string(); + break; + case 2: + message.description = reader.string(); + break; + case 4: + message.contract = reader.string(); + break; + case 5: + message.codeId = reader.uint64(); + break; + case 6: + message.msg = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MigrateContractProposal { + const obj = createBaseMigrateContractProposal(); + if (isSet(object.title)) obj.title = String(object.title); + if (isSet(object.description)) obj.description = String(object.description); + if (isSet(object.contract)) obj.contract = String(object.contract); + if (isSet(object.codeId)) obj.codeId = BigInt(object.codeId.toString()); + if (isSet(object.msg)) obj.msg = bytesFromBase64(object.msg); + return obj; + }, + toJSON(message: MigrateContractProposal): JsonSafe { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && (obj.description = message.description); + message.contract !== undefined && (obj.contract = message.contract); + message.codeId !== undefined && (obj.codeId = (message.codeId || BigInt(0)).toString()); + message.msg !== undefined && (obj.msg = base64FromBytes(message.msg !== undefined ? message.msg : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): MigrateContractProposal { + const message = createBaseMigrateContractProposal(); + message.title = object.title ?? ""; + message.description = object.description ?? ""; + message.contract = object.contract ?? ""; + if (object.codeId !== undefined && object.codeId !== null) { + message.codeId = BigInt(object.codeId.toString()); + } + message.msg = object.msg ?? new Uint8Array(); + return message; + }, + fromSDK(object: MigrateContractProposalSDKType): MigrateContractProposal { + return { + title: object?.title, + description: object?.description, + contract: object?.contract, + codeId: object?.code_id, + msg: object?.msg + }; + }, + fromSDKJSON(object: any): MigrateContractProposalSDKType { + return { + title: isSet(object.title) ? String(object.title) : "", + description: isSet(object.description) ? String(object.description) : "", + contract: isSet(object.contract) ? String(object.contract) : "", + code_id: isSet(object.code_id) ? BigInt(object.code_id.toString()) : BigInt(0), + msg: isSet(object.msg) ? bytesFromBase64(object.msg) : new Uint8Array() + }; + }, + toSDK(message: MigrateContractProposal): MigrateContractProposalSDKType { + const obj: any = {}; + obj.title = message.title; + obj.description = message.description; + obj.contract = message.contract; + obj.code_id = message.codeId; + obj.msg = message.msg; + return obj; + }, + fromAmino(object: MigrateContractProposalAmino): MigrateContractProposal { + const message = createBaseMigrateContractProposal(); + if (object.title !== undefined && object.title !== null) { + message.title = object.title; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } + if (object.contract !== undefined && object.contract !== null) { + message.contract = object.contract; + } + if (object.code_id !== undefined && object.code_id !== null) { + message.codeId = BigInt(object.code_id); + } + if (object.msg !== undefined && object.msg !== null) { + message.msg = toUtf8(JSON.stringify(object.msg)); + } + return message; + }, + toAmino(message: MigrateContractProposal): MigrateContractProposalAmino { + const obj: any = {}; + obj.title = message.title === "" ? undefined : message.title; + obj.description = message.description === "" ? undefined : message.description; + obj.contract = message.contract === "" ? undefined : message.contract; + obj.code_id = message.codeId !== BigInt(0) ? message.codeId?.toString() : undefined; + obj.msg = message.msg ? JSON.parse(fromUtf8(message.msg)) : undefined; + return obj; + }, + fromAminoMsg(object: MigrateContractProposalAminoMsg): MigrateContractProposal { + return MigrateContractProposal.fromAmino(object.value); + }, + toAminoMsg(message: MigrateContractProposal): MigrateContractProposalAminoMsg { + return { + type: "wasm/MigrateContractProposal", + value: MigrateContractProposal.toAmino(message) + }; + }, + fromProtoMsg(message: MigrateContractProposalProtoMsg): MigrateContractProposal { + return MigrateContractProposal.decode(message.value); + }, + toProto(message: MigrateContractProposal): Uint8Array { + return MigrateContractProposal.encode(message).finish(); + }, + toProtoMsg(message: MigrateContractProposal): MigrateContractProposalProtoMsg { + return { + typeUrl: "/cosmwasm.wasm.v1.MigrateContractProposal", + value: MigrateContractProposal.encode(message).finish() + }; + } +}; +function createBaseSudoContractProposal(): SudoContractProposal { + return { + title: "", + description: "", + contract: "", + msg: new Uint8Array() + }; +} +export const SudoContractProposal = { + typeUrl: "/cosmwasm.wasm.v1.SudoContractProposal", + encode(message: SudoContractProposal, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.title !== undefined) { + writer.uint32(10).string(message.title); + } + if (message.description !== undefined) { + writer.uint32(18).string(message.description); + } + if (message.contract !== undefined) { + writer.uint32(26).string(message.contract); + } + if (message.msg.length !== 0) { + writer.uint32(34).bytes(message.msg); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): SudoContractProposal { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseSudoContractProposal(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.title = reader.string(); + break; + case 2: + message.description = reader.string(); + break; + case 3: + message.contract = reader.string(); + break; + case 4: + message.msg = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): SudoContractProposal { + const obj = createBaseSudoContractProposal(); + if (isSet(object.title)) obj.title = String(object.title); + if (isSet(object.description)) obj.description = String(object.description); + if (isSet(object.contract)) obj.contract = String(object.contract); + if (isSet(object.msg)) obj.msg = bytesFromBase64(object.msg); + return obj; + }, + toJSON(message: SudoContractProposal): JsonSafe { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && (obj.description = message.description); + message.contract !== undefined && (obj.contract = message.contract); + message.msg !== undefined && (obj.msg = base64FromBytes(message.msg !== undefined ? message.msg : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): SudoContractProposal { + const message = createBaseSudoContractProposal(); + message.title = object.title ?? ""; + message.description = object.description ?? ""; + message.contract = object.contract ?? ""; + message.msg = object.msg ?? new Uint8Array(); + return message; + }, + fromSDK(object: SudoContractProposalSDKType): SudoContractProposal { + return { + title: object?.title, + description: object?.description, + contract: object?.contract, + msg: object?.msg + }; + }, + fromSDKJSON(object: any): SudoContractProposalSDKType { + return { + title: isSet(object.title) ? String(object.title) : "", + description: isSet(object.description) ? String(object.description) : "", + contract: isSet(object.contract) ? String(object.contract) : "", + msg: isSet(object.msg) ? bytesFromBase64(object.msg) : new Uint8Array() + }; + }, + toSDK(message: SudoContractProposal): SudoContractProposalSDKType { + const obj: any = {}; + obj.title = message.title; + obj.description = message.description; + obj.contract = message.contract; + obj.msg = message.msg; + return obj; + }, + fromAmino(object: SudoContractProposalAmino): SudoContractProposal { + const message = createBaseSudoContractProposal(); + if (object.title !== undefined && object.title !== null) { + message.title = object.title; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } + if (object.contract !== undefined && object.contract !== null) { + message.contract = object.contract; + } + if (object.msg !== undefined && object.msg !== null) { + message.msg = toUtf8(JSON.stringify(object.msg)); + } + return message; + }, + toAmino(message: SudoContractProposal): SudoContractProposalAmino { + const obj: any = {}; + obj.title = message.title === "" ? undefined : message.title; + obj.description = message.description === "" ? undefined : message.description; + obj.contract = message.contract === "" ? undefined : message.contract; + obj.msg = message.msg ? JSON.parse(fromUtf8(message.msg)) : undefined; + return obj; + }, + fromAminoMsg(object: SudoContractProposalAminoMsg): SudoContractProposal { + return SudoContractProposal.fromAmino(object.value); + }, + toAminoMsg(message: SudoContractProposal): SudoContractProposalAminoMsg { + return { + type: "wasm/SudoContractProposal", + value: SudoContractProposal.toAmino(message) + }; + }, + fromProtoMsg(message: SudoContractProposalProtoMsg): SudoContractProposal { + return SudoContractProposal.decode(message.value); + }, + toProto(message: SudoContractProposal): Uint8Array { + return SudoContractProposal.encode(message).finish(); + }, + toProtoMsg(message: SudoContractProposal): SudoContractProposalProtoMsg { + return { + typeUrl: "/cosmwasm.wasm.v1.SudoContractProposal", + value: SudoContractProposal.encode(message).finish() + }; + } +}; +function createBaseExecuteContractProposal(): ExecuteContractProposal { + return { + title: "", + description: "", + runAs: "", + contract: "", + msg: new Uint8Array(), + funds: [] + }; +} +export const ExecuteContractProposal = { + typeUrl: "/cosmwasm.wasm.v1.ExecuteContractProposal", + encode(message: ExecuteContractProposal, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.title !== undefined) { + writer.uint32(10).string(message.title); + } + if (message.description !== undefined) { + writer.uint32(18).string(message.description); + } + if (message.runAs !== undefined) { + writer.uint32(26).string(message.runAs); + } + if (message.contract !== undefined) { + writer.uint32(34).string(message.contract); + } + if (message.msg.length !== 0) { + writer.uint32(42).bytes(message.msg); + } + for (const v of message.funds) { + Coin.encode(v!, writer.uint32(50).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ExecuteContractProposal { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseExecuteContractProposal(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.title = reader.string(); + break; + case 2: + message.description = reader.string(); + break; + case 3: + message.runAs = reader.string(); + break; + case 4: + message.contract = reader.string(); + break; + case 5: + message.msg = reader.bytes(); + break; + case 6: + message.funds.push(Coin.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ExecuteContractProposal { + const obj = createBaseExecuteContractProposal(); + if (isSet(object.title)) obj.title = String(object.title); + if (isSet(object.description)) obj.description = String(object.description); + if (isSet(object.runAs)) obj.runAs = String(object.runAs); + if (isSet(object.contract)) obj.contract = String(object.contract); + if (isSet(object.msg)) obj.msg = bytesFromBase64(object.msg); + if (Array.isArray(object?.funds)) obj.funds = object.funds.map((e: any) => Coin.fromJSON(e)); + return obj; + }, + toJSON(message: ExecuteContractProposal): JsonSafe { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && (obj.description = message.description); + message.runAs !== undefined && (obj.runAs = message.runAs); + message.contract !== undefined && (obj.contract = message.contract); + message.msg !== undefined && (obj.msg = base64FromBytes(message.msg !== undefined ? message.msg : new Uint8Array())); + if (message.funds) { + obj.funds = message.funds.map(e => e ? Coin.toJSON(e) : undefined); + } else { + obj.funds = []; + } + return obj; + }, + fromPartial(object: DeepPartial): ExecuteContractProposal { + const message = createBaseExecuteContractProposal(); + message.title = object.title ?? ""; + message.description = object.description ?? ""; + message.runAs = object.runAs ?? ""; + message.contract = object.contract ?? ""; + message.msg = object.msg ?? new Uint8Array(); + message.funds = object.funds?.map(e => Coin.fromPartial(e)) || []; + return message; + }, + fromSDK(object: ExecuteContractProposalSDKType): ExecuteContractProposal { + return { + title: object?.title, + description: object?.description, + runAs: object?.run_as, + contract: object?.contract, + msg: object?.msg, + funds: Array.isArray(object?.funds) ? object.funds.map((e: any) => Coin.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): ExecuteContractProposalSDKType { + return { + title: isSet(object.title) ? String(object.title) : "", + description: isSet(object.description) ? String(object.description) : "", + run_as: isSet(object.run_as) ? String(object.run_as) : "", + contract: isSet(object.contract) ? String(object.contract) : "", + msg: isSet(object.msg) ? bytesFromBase64(object.msg) : new Uint8Array(), + funds: Array.isArray(object?.funds) ? object.funds.map((e: any) => Coin.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: ExecuteContractProposal): ExecuteContractProposalSDKType { + const obj: any = {}; + obj.title = message.title; + obj.description = message.description; + obj.run_as = message.runAs; + obj.contract = message.contract; + obj.msg = message.msg; + if (message.funds) { + obj.funds = message.funds.map(e => e ? Coin.toSDK(e) : undefined); + } else { + obj.funds = []; + } + return obj; + }, + fromAmino(object: ExecuteContractProposalAmino): ExecuteContractProposal { + const message = createBaseExecuteContractProposal(); + if (object.title !== undefined && object.title !== null) { + message.title = object.title; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } + if (object.run_as !== undefined && object.run_as !== null) { + message.runAs = object.run_as; + } + if (object.contract !== undefined && object.contract !== null) { + message.contract = object.contract; + } + if (object.msg !== undefined && object.msg !== null) { + message.msg = toUtf8(JSON.stringify(object.msg)); + } + message.funds = object.funds?.map(e => Coin.fromAmino(e)) || []; + return message; + }, + toAmino(message: ExecuteContractProposal): ExecuteContractProposalAmino { + const obj: any = {}; + obj.title = message.title === "" ? undefined : message.title; + obj.description = message.description === "" ? undefined : message.description; + obj.run_as = message.runAs === "" ? undefined : message.runAs; + obj.contract = message.contract === "" ? undefined : message.contract; + obj.msg = message.msg ? JSON.parse(fromUtf8(message.msg)) : undefined; + if (message.funds) { + obj.funds = message.funds.map(e => e ? Coin.toAmino(e) : undefined); + } else { + obj.funds = message.funds; + } + return obj; + }, + fromAminoMsg(object: ExecuteContractProposalAminoMsg): ExecuteContractProposal { + return ExecuteContractProposal.fromAmino(object.value); + }, + toAminoMsg(message: ExecuteContractProposal): ExecuteContractProposalAminoMsg { + return { + type: "wasm/ExecuteContractProposal", + value: ExecuteContractProposal.toAmino(message) + }; + }, + fromProtoMsg(message: ExecuteContractProposalProtoMsg): ExecuteContractProposal { + return ExecuteContractProposal.decode(message.value); + }, + toProto(message: ExecuteContractProposal): Uint8Array { + return ExecuteContractProposal.encode(message).finish(); + }, + toProtoMsg(message: ExecuteContractProposal): ExecuteContractProposalProtoMsg { + return { + typeUrl: "/cosmwasm.wasm.v1.ExecuteContractProposal", + value: ExecuteContractProposal.encode(message).finish() + }; + } +}; +function createBaseUpdateAdminProposal(): UpdateAdminProposal { + return { + title: "", + description: "", + newAdmin: "", + contract: "" + }; +} +export const UpdateAdminProposal = { + typeUrl: "/cosmwasm.wasm.v1.UpdateAdminProposal", + encode(message: UpdateAdminProposal, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.title !== undefined) { + writer.uint32(10).string(message.title); + } + if (message.description !== undefined) { + writer.uint32(18).string(message.description); + } + if (message.newAdmin !== undefined) { + writer.uint32(26).string(message.newAdmin); + } + if (message.contract !== undefined) { + writer.uint32(34).string(message.contract); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): UpdateAdminProposal { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseUpdateAdminProposal(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.title = reader.string(); + break; + case 2: + message.description = reader.string(); + break; + case 3: + message.newAdmin = reader.string(); + break; + case 4: + message.contract = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): UpdateAdminProposal { + const obj = createBaseUpdateAdminProposal(); + if (isSet(object.title)) obj.title = String(object.title); + if (isSet(object.description)) obj.description = String(object.description); + if (isSet(object.newAdmin)) obj.newAdmin = String(object.newAdmin); + if (isSet(object.contract)) obj.contract = String(object.contract); + return obj; + }, + toJSON(message: UpdateAdminProposal): JsonSafe { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && (obj.description = message.description); + message.newAdmin !== undefined && (obj.newAdmin = message.newAdmin); + message.contract !== undefined && (obj.contract = message.contract); + return obj; + }, + fromPartial(object: DeepPartial): UpdateAdminProposal { + const message = createBaseUpdateAdminProposal(); + message.title = object.title ?? ""; + message.description = object.description ?? ""; + message.newAdmin = object.newAdmin ?? ""; + message.contract = object.contract ?? ""; + return message; + }, + fromSDK(object: UpdateAdminProposalSDKType): UpdateAdminProposal { + return { + title: object?.title, + description: object?.description, + newAdmin: object?.new_admin, + contract: object?.contract + }; + }, + fromSDKJSON(object: any): UpdateAdminProposalSDKType { + return { + title: isSet(object.title) ? String(object.title) : "", + description: isSet(object.description) ? String(object.description) : "", + new_admin: isSet(object.new_admin) ? String(object.new_admin) : "", + contract: isSet(object.contract) ? String(object.contract) : "" + }; + }, + toSDK(message: UpdateAdminProposal): UpdateAdminProposalSDKType { + const obj: any = {}; + obj.title = message.title; + obj.description = message.description; + obj.new_admin = message.newAdmin; + obj.contract = message.contract; + return obj; + }, + fromAmino(object: UpdateAdminProposalAmino): UpdateAdminProposal { + const message = createBaseUpdateAdminProposal(); + if (object.title !== undefined && object.title !== null) { + message.title = object.title; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } + if (object.new_admin !== undefined && object.new_admin !== null) { + message.newAdmin = object.new_admin; + } + if (object.contract !== undefined && object.contract !== null) { + message.contract = object.contract; + } + return message; + }, + toAmino(message: UpdateAdminProposal): UpdateAdminProposalAmino { + const obj: any = {}; + obj.title = message.title === "" ? undefined : message.title; + obj.description = message.description === "" ? undefined : message.description; + obj.new_admin = message.newAdmin === "" ? undefined : message.newAdmin; + obj.contract = message.contract === "" ? undefined : message.contract; + return obj; + }, + fromAminoMsg(object: UpdateAdminProposalAminoMsg): UpdateAdminProposal { + return UpdateAdminProposal.fromAmino(object.value); + }, + toAminoMsg(message: UpdateAdminProposal): UpdateAdminProposalAminoMsg { + return { + type: "wasm/UpdateAdminProposal", + value: UpdateAdminProposal.toAmino(message) + }; + }, + fromProtoMsg(message: UpdateAdminProposalProtoMsg): UpdateAdminProposal { + return UpdateAdminProposal.decode(message.value); + }, + toProto(message: UpdateAdminProposal): Uint8Array { + return UpdateAdminProposal.encode(message).finish(); + }, + toProtoMsg(message: UpdateAdminProposal): UpdateAdminProposalProtoMsg { + return { + typeUrl: "/cosmwasm.wasm.v1.UpdateAdminProposal", + value: UpdateAdminProposal.encode(message).finish() + }; + } +}; +function createBaseClearAdminProposal(): ClearAdminProposal { + return { + title: "", + description: "", + contract: "" + }; +} +export const ClearAdminProposal = { + typeUrl: "/cosmwasm.wasm.v1.ClearAdminProposal", + encode(message: ClearAdminProposal, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.title !== undefined) { + writer.uint32(10).string(message.title); + } + if (message.description !== undefined) { + writer.uint32(18).string(message.description); + } + if (message.contract !== undefined) { + writer.uint32(26).string(message.contract); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ClearAdminProposal { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseClearAdminProposal(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.title = reader.string(); + break; + case 2: + message.description = reader.string(); + break; + case 3: + message.contract = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ClearAdminProposal { + const obj = createBaseClearAdminProposal(); + if (isSet(object.title)) obj.title = String(object.title); + if (isSet(object.description)) obj.description = String(object.description); + if (isSet(object.contract)) obj.contract = String(object.contract); + return obj; + }, + toJSON(message: ClearAdminProposal): JsonSafe { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && (obj.description = message.description); + message.contract !== undefined && (obj.contract = message.contract); + return obj; + }, + fromPartial(object: DeepPartial): ClearAdminProposal { + const message = createBaseClearAdminProposal(); + message.title = object.title ?? ""; + message.description = object.description ?? ""; + message.contract = object.contract ?? ""; + return message; + }, + fromSDK(object: ClearAdminProposalSDKType): ClearAdminProposal { + return { + title: object?.title, + description: object?.description, + contract: object?.contract + }; + }, + fromSDKJSON(object: any): ClearAdminProposalSDKType { + return { + title: isSet(object.title) ? String(object.title) : "", + description: isSet(object.description) ? String(object.description) : "", + contract: isSet(object.contract) ? String(object.contract) : "" + }; + }, + toSDK(message: ClearAdminProposal): ClearAdminProposalSDKType { + const obj: any = {}; + obj.title = message.title; + obj.description = message.description; + obj.contract = message.contract; + return obj; + }, + fromAmino(object: ClearAdminProposalAmino): ClearAdminProposal { + const message = createBaseClearAdminProposal(); + if (object.title !== undefined && object.title !== null) { + message.title = object.title; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } + if (object.contract !== undefined && object.contract !== null) { + message.contract = object.contract; + } + return message; + }, + toAmino(message: ClearAdminProposal): ClearAdminProposalAmino { + const obj: any = {}; + obj.title = message.title === "" ? undefined : message.title; + obj.description = message.description === "" ? undefined : message.description; + obj.contract = message.contract === "" ? undefined : message.contract; + return obj; + }, + fromAminoMsg(object: ClearAdminProposalAminoMsg): ClearAdminProposal { + return ClearAdminProposal.fromAmino(object.value); + }, + toAminoMsg(message: ClearAdminProposal): ClearAdminProposalAminoMsg { + return { + type: "wasm/ClearAdminProposal", + value: ClearAdminProposal.toAmino(message) + }; + }, + fromProtoMsg(message: ClearAdminProposalProtoMsg): ClearAdminProposal { + return ClearAdminProposal.decode(message.value); + }, + toProto(message: ClearAdminProposal): Uint8Array { + return ClearAdminProposal.encode(message).finish(); + }, + toProtoMsg(message: ClearAdminProposal): ClearAdminProposalProtoMsg { + return { + typeUrl: "/cosmwasm.wasm.v1.ClearAdminProposal", + value: ClearAdminProposal.encode(message).finish() + }; + } +}; +function createBasePinCodesProposal(): PinCodesProposal { + return { + title: "", + description: "", + codeIds: [] + }; +} +export const PinCodesProposal = { + typeUrl: "/cosmwasm.wasm.v1.PinCodesProposal", + encode(message: PinCodesProposal, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.title !== undefined) { + writer.uint32(10).string(message.title); + } + if (message.description !== undefined) { + writer.uint32(18).string(message.description); + } + writer.uint32(26).fork(); + for (const v of message.codeIds) { + writer.uint64(v); + } + writer.ldelim(); + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): PinCodesProposal { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBasePinCodesProposal(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.title = reader.string(); + break; + case 2: + message.description = reader.string(); + break; + case 3: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.codeIds.push(reader.uint64()); + } + } else { + message.codeIds.push(reader.uint64()); + } + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): PinCodesProposal { + const obj = createBasePinCodesProposal(); + if (isSet(object.title)) obj.title = String(object.title); + if (isSet(object.description)) obj.description = String(object.description); + if (Array.isArray(object?.codeIds)) obj.codeIds = object.codeIds.map((e: any) => BigInt(e.toString())); + return obj; + }, + toJSON(message: PinCodesProposal): JsonSafe { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && (obj.description = message.description); + if (message.codeIds) { + obj.codeIds = message.codeIds.map(e => (e || BigInt(0)).toString()); + } else { + obj.codeIds = []; + } + return obj; + }, + fromPartial(object: DeepPartial): PinCodesProposal { + const message = createBasePinCodesProposal(); + message.title = object.title ?? ""; + message.description = object.description ?? ""; + message.codeIds = object.codeIds?.map(e => BigInt(e.toString())) || []; + return message; + }, + fromSDK(object: PinCodesProposalSDKType): PinCodesProposal { + return { + title: object?.title, + description: object?.description, + codeIds: Array.isArray(object?.code_ids) ? object.code_ids.map((e: any) => e) : [] + }; + }, + fromSDKJSON(object: any): PinCodesProposalSDKType { + return { + title: isSet(object.title) ? String(object.title) : "", + description: isSet(object.description) ? String(object.description) : "", + code_ids: Array.isArray(object?.code_ids) ? object.code_ids.map((e: any) => BigInt(e.toString())) : [] + }; + }, + toSDK(message: PinCodesProposal): PinCodesProposalSDKType { + const obj: any = {}; + obj.title = message.title; + obj.description = message.description; + if (message.codeIds) { + obj.code_ids = message.codeIds.map(e => e); + } else { + obj.code_ids = []; + } + return obj; + }, + fromAmino(object: PinCodesProposalAmino): PinCodesProposal { + const message = createBasePinCodesProposal(); + if (object.title !== undefined && object.title !== null) { + message.title = object.title; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } + message.codeIds = object.code_ids?.map(e => BigInt(e)) || []; + return message; + }, + toAmino(message: PinCodesProposal): PinCodesProposalAmino { + const obj: any = {}; + obj.title = message.title === "" ? undefined : message.title; + obj.description = message.description === "" ? undefined : message.description; + if (message.codeIds) { + obj.code_ids = message.codeIds.map(e => e.toString()); + } else { + obj.code_ids = message.codeIds; + } + return obj; + }, + fromAminoMsg(object: PinCodesProposalAminoMsg): PinCodesProposal { + return PinCodesProposal.fromAmino(object.value); + }, + toAminoMsg(message: PinCodesProposal): PinCodesProposalAminoMsg { + return { + type: "wasm/PinCodesProposal", + value: PinCodesProposal.toAmino(message) + }; + }, + fromProtoMsg(message: PinCodesProposalProtoMsg): PinCodesProposal { + return PinCodesProposal.decode(message.value); + }, + toProto(message: PinCodesProposal): Uint8Array { + return PinCodesProposal.encode(message).finish(); + }, + toProtoMsg(message: PinCodesProposal): PinCodesProposalProtoMsg { + return { + typeUrl: "/cosmwasm.wasm.v1.PinCodesProposal", + value: PinCodesProposal.encode(message).finish() + }; + } +}; +function createBaseUnpinCodesProposal(): UnpinCodesProposal { + return { + title: "", + description: "", + codeIds: [] + }; +} +export const UnpinCodesProposal = { + typeUrl: "/cosmwasm.wasm.v1.UnpinCodesProposal", + encode(message: UnpinCodesProposal, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.title !== undefined) { + writer.uint32(10).string(message.title); + } + if (message.description !== undefined) { + writer.uint32(18).string(message.description); + } + writer.uint32(26).fork(); + for (const v of message.codeIds) { + writer.uint64(v); + } + writer.ldelim(); + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): UnpinCodesProposal { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseUnpinCodesProposal(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.title = reader.string(); + break; + case 2: + message.description = reader.string(); + break; + case 3: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.codeIds.push(reader.uint64()); + } + } else { + message.codeIds.push(reader.uint64()); + } + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): UnpinCodesProposal { + const obj = createBaseUnpinCodesProposal(); + if (isSet(object.title)) obj.title = String(object.title); + if (isSet(object.description)) obj.description = String(object.description); + if (Array.isArray(object?.codeIds)) obj.codeIds = object.codeIds.map((e: any) => BigInt(e.toString())); + return obj; + }, + toJSON(message: UnpinCodesProposal): JsonSafe { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && (obj.description = message.description); + if (message.codeIds) { + obj.codeIds = message.codeIds.map(e => (e || BigInt(0)).toString()); + } else { + obj.codeIds = []; + } + return obj; + }, + fromPartial(object: DeepPartial): UnpinCodesProposal { + const message = createBaseUnpinCodesProposal(); + message.title = object.title ?? ""; + message.description = object.description ?? ""; + message.codeIds = object.codeIds?.map(e => BigInt(e.toString())) || []; + return message; + }, + fromSDK(object: UnpinCodesProposalSDKType): UnpinCodesProposal { + return { + title: object?.title, + description: object?.description, + codeIds: Array.isArray(object?.code_ids) ? object.code_ids.map((e: any) => e) : [] + }; + }, + fromSDKJSON(object: any): UnpinCodesProposalSDKType { + return { + title: isSet(object.title) ? String(object.title) : "", + description: isSet(object.description) ? String(object.description) : "", + code_ids: Array.isArray(object?.code_ids) ? object.code_ids.map((e: any) => BigInt(e.toString())) : [] + }; + }, + toSDK(message: UnpinCodesProposal): UnpinCodesProposalSDKType { + const obj: any = {}; + obj.title = message.title; + obj.description = message.description; + if (message.codeIds) { + obj.code_ids = message.codeIds.map(e => e); + } else { + obj.code_ids = []; + } + return obj; + }, + fromAmino(object: UnpinCodesProposalAmino): UnpinCodesProposal { + const message = createBaseUnpinCodesProposal(); + if (object.title !== undefined && object.title !== null) { + message.title = object.title; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } + message.codeIds = object.code_ids?.map(e => BigInt(e)) || []; + return message; + }, + toAmino(message: UnpinCodesProposal): UnpinCodesProposalAmino { + const obj: any = {}; + obj.title = message.title === "" ? undefined : message.title; + obj.description = message.description === "" ? undefined : message.description; + if (message.codeIds) { + obj.code_ids = message.codeIds.map(e => e.toString()); + } else { + obj.code_ids = message.codeIds; + } + return obj; + }, + fromAminoMsg(object: UnpinCodesProposalAminoMsg): UnpinCodesProposal { + return UnpinCodesProposal.fromAmino(object.value); + }, + toAminoMsg(message: UnpinCodesProposal): UnpinCodesProposalAminoMsg { + return { + type: "wasm/UnpinCodesProposal", + value: UnpinCodesProposal.toAmino(message) + }; + }, + fromProtoMsg(message: UnpinCodesProposalProtoMsg): UnpinCodesProposal { + return UnpinCodesProposal.decode(message.value); + }, + toProto(message: UnpinCodesProposal): Uint8Array { + return UnpinCodesProposal.encode(message).finish(); + }, + toProtoMsg(message: UnpinCodesProposal): UnpinCodesProposalProtoMsg { + return { + typeUrl: "/cosmwasm.wasm.v1.UnpinCodesProposal", + value: UnpinCodesProposal.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmwasm/wasm/v1/query.lcd.ts b/__fixtures__/v-next/outputicjsdeps/cosmwasm/wasm/v1/query.lcd.ts new file mode 100644 index 0000000000..1e785ed3fa --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmwasm/wasm/v1/query.lcd.ts @@ -0,0 +1,103 @@ +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../../cosmos/base/query/v1beta1/pagination.js"; +import { ContractInfo, ContractInfoSDKType, ContractCodeHistoryEntry, ContractCodeHistoryEntrySDKType, Model, ModelSDKType } from "./types.js"; +import { setPaginationParams } from "../../../helpers.js"; +import { LCDClient } from "@cosmology/lcd"; +import { QueryContractInfoRequest, QueryContractInfoRequestSDKType, QueryContractInfoResponse, QueryContractInfoResponseSDKType, QueryContractHistoryRequest, QueryContractHistoryRequestSDKType, QueryContractHistoryResponse, QueryContractHistoryResponseSDKType, QueryContractsByCodeRequest, QueryContractsByCodeRequestSDKType, QueryContractsByCodeResponse, QueryContractsByCodeResponseSDKType, QueryAllContractStateRequest, QueryAllContractStateRequestSDKType, QueryAllContractStateResponse, QueryAllContractStateResponseSDKType, QueryRawContractStateRequest, QueryRawContractStateRequestSDKType, QueryRawContractStateResponse, QueryRawContractStateResponseSDKType, QuerySmartContractStateRequest, QuerySmartContractStateRequestSDKType, QuerySmartContractStateResponse, QuerySmartContractStateResponseSDKType, QueryCodeRequest, QueryCodeRequestSDKType, QueryCodeResponse, QueryCodeResponseSDKType, QueryCodesRequest, QueryCodesRequestSDKType, QueryCodesResponse, QueryCodesResponseSDKType, QueryPinnedCodesRequest, QueryPinnedCodesRequestSDKType, QueryPinnedCodesResponse, QueryPinnedCodesResponseSDKType } from "./query.js"; +export class LCDQueryClient { + req: LCDClient; + constructor({ + requestClient + }: { + requestClient: LCDClient; + }) { + this.req = requestClient; + this.contractInfo = this.contractInfo.bind(this); + this.contractHistory = this.contractHistory.bind(this); + this.contractsByCode = this.contractsByCode.bind(this); + this.allContractState = this.allContractState.bind(this); + this.rawContractState = this.rawContractState.bind(this); + this.smartContractState = this.smartContractState.bind(this); + this.code = this.code.bind(this); + this.codes = this.codes.bind(this); + this.pinnedCodes = this.pinnedCodes.bind(this); + } + /* ContractInfo gets the contract meta data */ + async contractInfo(params: QueryContractInfoRequest): Promise { + const endpoint = `cosmwasm/wasm/v1/contract/${params.address}`; + return QueryContractInfoResponse.fromSDKJSON(await this.req.get(endpoint)); + } + /* ContractHistory gets the contract code history */ + async contractHistory(params: QueryContractHistoryRequest): Promise { + const options: any = { + params: {} + }; + if (typeof params?.pagination !== "undefined") { + setPaginationParams(options, params.pagination); + } + const endpoint = `cosmwasm/wasm/v1/contract/${params.address}/history`; + return QueryContractHistoryResponse.fromSDKJSON(await this.req.get(endpoint, options)); + } + /* ContractsByCode lists all smart contracts for a code id */ + async contractsByCode(params: QueryContractsByCodeRequest): Promise { + const options: any = { + params: {} + }; + if (typeof params?.pagination !== "undefined") { + setPaginationParams(options, params.pagination); + } + const endpoint = `cosmwasm/wasm/v1/code/${params.codeId}/contracts`; + return QueryContractsByCodeResponse.fromSDKJSON(await this.req.get(endpoint, options)); + } + /* AllContractState gets all raw store data for a single contract */ + async allContractState(params: QueryAllContractStateRequest): Promise { + const options: any = { + params: {} + }; + if (typeof params?.pagination !== "undefined") { + setPaginationParams(options, params.pagination); + } + const endpoint = `cosmwasm/wasm/v1/contract/${params.address}/state`; + return QueryAllContractStateResponse.fromSDKJSON(await this.req.get(endpoint, options)); + } + /* RawContractState gets single key from the raw store data of a contract */ + async rawContractState(params: QueryRawContractStateRequest): Promise { + const endpoint = `wasm/v1/contract/${params.address}/raw/${params.queryData}`; + return QueryRawContractStateResponse.fromSDKJSON(await this.req.get(endpoint)); + } + /* SmartContractState get smart query result from the contract */ + async smartContractState(params: QuerySmartContractStateRequest): Promise { + const endpoint = `wasm/v1/contract/${params.address}/smart/${params.queryData}`; + return QuerySmartContractStateResponse.fromSDKJSON(await this.req.get(endpoint)); + } + /* Code gets the binary code and metadata for a singe wasm code */ + async code(params: QueryCodeRequest): Promise { + const endpoint = `cosmwasm/wasm/v1/code/${params.codeId}`; + return QueryCodeResponse.fromSDKJSON(await this.req.get(endpoint)); + } + /* Codes gets the metadata for all stored wasm codes */ + async codes(params: QueryCodesRequest = { + pagination: PageRequest.fromPartial({}) + }): Promise { + const options: any = { + params: {} + }; + if (typeof params?.pagination !== "undefined") { + setPaginationParams(options, params.pagination); + } + const endpoint = `cosmwasm/wasm/v1/code`; + return QueryCodesResponse.fromSDKJSON(await this.req.get(endpoint, options)); + } + /* PinnedCodes gets the pinned code ids */ + async pinnedCodes(params: QueryPinnedCodesRequest = { + pagination: PageRequest.fromPartial({}) + }): Promise { + const options: any = { + params: {} + }; + if (typeof params?.pagination !== "undefined") { + setPaginationParams(options, params.pagination); + } + const endpoint = `cosmwasm/wasm/v1/codes/pinned`; + return QueryPinnedCodesResponse.fromSDKJSON(await this.req.get(endpoint, options)); + } +} \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmwasm/wasm/v1/query.rpc.Query.ts b/__fixtures__/v-next/outputicjsdeps/cosmwasm/wasm/v1/query.rpc.Query.ts new file mode 100644 index 0000000000..69dbaff5bd --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmwasm/wasm/v1/query.rpc.Query.ts @@ -0,0 +1,124 @@ +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../../cosmos/base/query/v1beta1/pagination.js"; +import { ContractInfo, ContractInfoSDKType, ContractCodeHistoryEntry, ContractCodeHistoryEntrySDKType, Model, ModelSDKType } from "./types.js"; +import { Rpc } from "../../../helpers.js"; +import { BinaryReader } from "../../../binary.js"; +import { QueryClient, createProtobufRpcClient } from "@cosmjs/stargate"; +import { QueryContractInfoRequest, QueryContractInfoRequestSDKType, QueryContractInfoResponse, QueryContractInfoResponseSDKType, QueryContractHistoryRequest, QueryContractHistoryRequestSDKType, QueryContractHistoryResponse, QueryContractHistoryResponseSDKType, QueryContractsByCodeRequest, QueryContractsByCodeRequestSDKType, QueryContractsByCodeResponse, QueryContractsByCodeResponseSDKType, QueryAllContractStateRequest, QueryAllContractStateRequestSDKType, QueryAllContractStateResponse, QueryAllContractStateResponseSDKType, QueryRawContractStateRequest, QueryRawContractStateRequestSDKType, QueryRawContractStateResponse, QueryRawContractStateResponseSDKType, QuerySmartContractStateRequest, QuerySmartContractStateRequestSDKType, QuerySmartContractStateResponse, QuerySmartContractStateResponseSDKType, QueryCodeRequest, QueryCodeRequestSDKType, QueryCodeResponse, QueryCodeResponseSDKType, QueryCodesRequest, QueryCodesRequestSDKType, QueryCodesResponse, QueryCodesResponseSDKType, QueryPinnedCodesRequest, QueryPinnedCodesRequestSDKType, QueryPinnedCodesResponse, QueryPinnedCodesResponseSDKType } from "./query.js"; +/** Query provides defines the gRPC querier service */ +export interface Query { + /** ContractInfo gets the contract meta data */ + contractInfo(request: QueryContractInfoRequest): Promise; + /** ContractHistory gets the contract code history */ + contractHistory(request: QueryContractHistoryRequest): Promise; + /** ContractsByCode lists all smart contracts for a code id */ + contractsByCode(request: QueryContractsByCodeRequest): Promise; + /** AllContractState gets all raw store data for a single contract */ + allContractState(request: QueryAllContractStateRequest): Promise; + /** RawContractState gets single key from the raw store data of a contract */ + rawContractState(request: QueryRawContractStateRequest): Promise; + /** SmartContractState get smart query result from the contract */ + smartContractState(request: QuerySmartContractStateRequest): Promise; + /** Code gets the binary code and metadata for a singe wasm code */ + code(request: QueryCodeRequest): Promise; + /** Codes gets the metadata for all stored wasm codes */ + codes(request?: QueryCodesRequest): Promise; + /** PinnedCodes gets the pinned code ids */ + pinnedCodes(request?: QueryPinnedCodesRequest): Promise; +} +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + this.contractInfo = this.contractInfo.bind(this); + this.contractHistory = this.contractHistory.bind(this); + this.contractsByCode = this.contractsByCode.bind(this); + this.allContractState = this.allContractState.bind(this); + this.rawContractState = this.rawContractState.bind(this); + this.smartContractState = this.smartContractState.bind(this); + this.code = this.code.bind(this); + this.codes = this.codes.bind(this); + this.pinnedCodes = this.pinnedCodes.bind(this); + } + contractInfo(request: QueryContractInfoRequest): Promise { + const data = QueryContractInfoRequest.encode(request).finish(); + const promise = this.rpc.request("cosmwasm.wasm.v1.Query", "ContractInfo", data); + return promise.then(data => QueryContractInfoResponse.decode(new BinaryReader(data))); + } + contractHistory(request: QueryContractHistoryRequest): Promise { + const data = QueryContractHistoryRequest.encode(request).finish(); + const promise = this.rpc.request("cosmwasm.wasm.v1.Query", "ContractHistory", data); + return promise.then(data => QueryContractHistoryResponse.decode(new BinaryReader(data))); + } + contractsByCode(request: QueryContractsByCodeRequest): Promise { + const data = QueryContractsByCodeRequest.encode(request).finish(); + const promise = this.rpc.request("cosmwasm.wasm.v1.Query", "ContractsByCode", data); + return promise.then(data => QueryContractsByCodeResponse.decode(new BinaryReader(data))); + } + allContractState(request: QueryAllContractStateRequest): Promise { + const data = QueryAllContractStateRequest.encode(request).finish(); + const promise = this.rpc.request("cosmwasm.wasm.v1.Query", "AllContractState", data); + return promise.then(data => QueryAllContractStateResponse.decode(new BinaryReader(data))); + } + rawContractState(request: QueryRawContractStateRequest): Promise { + const data = QueryRawContractStateRequest.encode(request).finish(); + const promise = this.rpc.request("cosmwasm.wasm.v1.Query", "RawContractState", data); + return promise.then(data => QueryRawContractStateResponse.decode(new BinaryReader(data))); + } + smartContractState(request: QuerySmartContractStateRequest): Promise { + const data = QuerySmartContractStateRequest.encode(request).finish(); + const promise = this.rpc.request("cosmwasm.wasm.v1.Query", "SmartContractState", data); + return promise.then(data => QuerySmartContractStateResponse.decode(new BinaryReader(data))); + } + code(request: QueryCodeRequest): Promise { + const data = QueryCodeRequest.encode(request).finish(); + const promise = this.rpc.request("cosmwasm.wasm.v1.Query", "Code", data); + return promise.then(data => QueryCodeResponse.decode(new BinaryReader(data))); + } + codes(request: QueryCodesRequest = { + pagination: PageRequest.fromPartial({}) + }): Promise { + const data = QueryCodesRequest.encode(request).finish(); + const promise = this.rpc.request("cosmwasm.wasm.v1.Query", "Codes", data); + return promise.then(data => QueryCodesResponse.decode(new BinaryReader(data))); + } + pinnedCodes(request: QueryPinnedCodesRequest = { + pagination: PageRequest.fromPartial({}) + }): Promise { + const data = QueryPinnedCodesRequest.encode(request).finish(); + const promise = this.rpc.request("cosmwasm.wasm.v1.Query", "PinnedCodes", data); + return promise.then(data => QueryPinnedCodesResponse.decode(new BinaryReader(data))); + } +} +export const createRpcQueryExtension = (base: QueryClient) => { + const rpc = createProtobufRpcClient(base); + const queryService = new QueryClientImpl(rpc); + return { + contractInfo(request: QueryContractInfoRequest): Promise { + return queryService.contractInfo(request); + }, + contractHistory(request: QueryContractHistoryRequest): Promise { + return queryService.contractHistory(request); + }, + contractsByCode(request: QueryContractsByCodeRequest): Promise { + return queryService.contractsByCode(request); + }, + allContractState(request: QueryAllContractStateRequest): Promise { + return queryService.allContractState(request); + }, + rawContractState(request: QueryRawContractStateRequest): Promise { + return queryService.rawContractState(request); + }, + smartContractState(request: QuerySmartContractStateRequest): Promise { + return queryService.smartContractState(request); + }, + code(request: QueryCodeRequest): Promise { + return queryService.code(request); + }, + codes(request?: QueryCodesRequest): Promise { + return queryService.codes(request); + }, + pinnedCodes(request?: QueryPinnedCodesRequest): Promise { + return queryService.pinnedCodes(request); + } + }; +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmwasm/wasm/v1/query.rpc.func.ts b/__fixtures__/v-next/outputicjsdeps/cosmwasm/wasm/v1/query.rpc.func.ts new file mode 100644 index 0000000000..ba78999154 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmwasm/wasm/v1/query.rpc.func.ts @@ -0,0 +1,102 @@ +import { RpcResolver, buildQuery } from "../../../helper-func-types"; +import { buildUseQuery } from "../../../react-query"; +import { QueryContractInfoRequest, QueryContractInfoResponse, QueryContractHistoryRequest, QueryContractHistoryResponse, QueryContractsByCodeRequest, QueryContractsByCodeResponse, QueryAllContractStateRequest, QueryAllContractStateResponse, QueryRawContractStateRequest, QueryRawContractStateResponse, QuerySmartContractStateRequest, QuerySmartContractStateResponse, QueryCodeRequest, QueryCodeResponse, QueryCodesRequest, QueryCodesResponse, QueryPinnedCodesRequest, QueryPinnedCodesResponse } from "./query"; +export const createGetContractInfo = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryContractInfoRequest.encode, + decode: QueryContractInfoResponse.decode, + service: "cosmwasm.wasm.v1.Query", + method: "ContractInfo", + getRpcInstance: getRpcInstance +}); +export const useGetContractInfo = buildUseQuery({ + builderQueryFn: createGetContractInfo, + queryKeyPrefix: "ContractInfoQuery" +}); +export const createGetContractHistory = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryContractHistoryRequest.encode, + decode: QueryContractHistoryResponse.decode, + service: "cosmwasm.wasm.v1.Query", + method: "ContractHistory", + getRpcInstance: getRpcInstance +}); +export const useGetContractHistory = buildUseQuery({ + builderQueryFn: createGetContractHistory, + queryKeyPrefix: "ContractHistoryQuery" +}); +export const createGetContractsByCode = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryContractsByCodeRequest.encode, + decode: QueryContractsByCodeResponse.decode, + service: "cosmwasm.wasm.v1.Query", + method: "ContractsByCode", + getRpcInstance: getRpcInstance +}); +export const useGetContractsByCode = buildUseQuery({ + builderQueryFn: createGetContractsByCode, + queryKeyPrefix: "ContractsByCodeQuery" +}); +export const createGetAllContractState = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryAllContractStateRequest.encode, + decode: QueryAllContractStateResponse.decode, + service: "cosmwasm.wasm.v1.Query", + method: "AllContractState", + getRpcInstance: getRpcInstance +}); +export const useGetAllContractState = buildUseQuery({ + builderQueryFn: createGetAllContractState, + queryKeyPrefix: "AllContractStateQuery" +}); +export const createGetRawContractState = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryRawContractStateRequest.encode, + decode: QueryRawContractStateResponse.decode, + service: "cosmwasm.wasm.v1.Query", + method: "RawContractState", + getRpcInstance: getRpcInstance +}); +export const useGetRawContractState = buildUseQuery({ + builderQueryFn: createGetRawContractState, + queryKeyPrefix: "RawContractStateQuery" +}); +export const createGetSmartContractState = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QuerySmartContractStateRequest.encode, + decode: QuerySmartContractStateResponse.decode, + service: "cosmwasm.wasm.v1.Query", + method: "SmartContractState", + getRpcInstance: getRpcInstance +}); +export const useGetSmartContractState = buildUseQuery({ + builderQueryFn: createGetSmartContractState, + queryKeyPrefix: "SmartContractStateQuery" +}); +export const createGetCode = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryCodeRequest.encode, + decode: QueryCodeResponse.decode, + service: "cosmwasm.wasm.v1.Query", + method: "Code", + getRpcInstance: getRpcInstance +}); +export const useGetCode = buildUseQuery({ + builderQueryFn: createGetCode, + queryKeyPrefix: "CodeQuery" +}); +export const createGetCodes = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryCodesRequest.encode, + decode: QueryCodesResponse.decode, + service: "cosmwasm.wasm.v1.Query", + method: "Codes", + getRpcInstance: getRpcInstance +}); +export const useGetCodes = buildUseQuery({ + builderQueryFn: createGetCodes, + queryKeyPrefix: "CodesQuery" +}); +export const createGetPinnedCodes = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryPinnedCodesRequest.encode, + decode: QueryPinnedCodesResponse.decode, + service: "cosmwasm.wasm.v1.Query", + method: "PinnedCodes", + getRpcInstance: getRpcInstance +}); +export const useGetPinnedCodes = buildUseQuery({ + builderQueryFn: createGetPinnedCodes, + queryKeyPrefix: "PinnedCodesQuery" +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmwasm/wasm/v1/query.ts b/__fixtures__/v-next/outputicjsdeps/cosmwasm/wasm/v1/query.ts new file mode 100644 index 0000000000..262e35e445 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmwasm/wasm/v1/query.ts @@ -0,0 +1,2482 @@ +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../../cosmos/base/query/v1beta1/pagination.js"; +import { ContractInfo, ContractInfoSDKType, ContractCodeHistoryEntry, ContractCodeHistoryEntrySDKType, Model, ModelSDKType } from "./types.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial, bytesFromBase64, base64FromBytes } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +import { toUtf8, fromUtf8 } from "@cosmjs/encoding"; +export const protobufPackage = "cosmwasm.wasm.v1"; +/** + * QueryContractInfoRequest is the request type for the Query/ContractInfo RPC + * method + */ +export interface QueryContractInfoRequest { + /** address is the address of the contract to query */ + address: string; +} +export interface QueryContractInfoRequestProtoMsg { + typeUrl: "/cosmwasm.wasm.v1.QueryContractInfoRequest"; + value: Uint8Array; +} +/** + * QueryContractInfoRequest is the request type for the Query/ContractInfo RPC + * method + */ +export interface QueryContractInfoRequestSDKType { + address: string; +} +/** + * QueryContractInfoResponse is the response type for the Query/ContractInfo RPC + * method + */ +export interface QueryContractInfoResponse { + /** address is the address of the contract */ + address: string; + contractInfo: ContractInfo; +} +export interface QueryContractInfoResponseProtoMsg { + typeUrl: "/cosmwasm.wasm.v1.QueryContractInfoResponse"; + value: Uint8Array; +} +/** + * QueryContractInfoResponse is the response type for the Query/ContractInfo RPC + * method + */ +export interface QueryContractInfoResponseSDKType { + address: string; + contract_info: ContractInfoSDKType; +} +/** + * QueryContractHistoryRequest is the request type for the Query/ContractHistory + * RPC method + */ +export interface QueryContractHistoryRequest { + /** address is the address of the contract to query */ + address: string; + /** pagination defines an optional pagination for the request. */ + pagination?: PageRequest; +} +export interface QueryContractHistoryRequestProtoMsg { + typeUrl: "/cosmwasm.wasm.v1.QueryContractHistoryRequest"; + value: Uint8Array; +} +/** + * QueryContractHistoryRequest is the request type for the Query/ContractHistory + * RPC method + */ +export interface QueryContractHistoryRequestSDKType { + address: string; + pagination?: PageRequestSDKType; +} +/** + * QueryContractHistoryResponse is the response type for the + * Query/ContractHistory RPC method + */ +export interface QueryContractHistoryResponse { + entries: ContractCodeHistoryEntry[]; + /** pagination defines the pagination in the response. */ + pagination?: PageResponse; +} +export interface QueryContractHistoryResponseProtoMsg { + typeUrl: "/cosmwasm.wasm.v1.QueryContractHistoryResponse"; + value: Uint8Array; +} +/** + * QueryContractHistoryResponse is the response type for the + * Query/ContractHistory RPC method + */ +export interface QueryContractHistoryResponseSDKType { + entries: ContractCodeHistoryEntrySDKType[]; + pagination?: PageResponseSDKType; +} +/** + * QueryContractsByCodeRequest is the request type for the Query/ContractsByCode + * RPC method + */ +export interface QueryContractsByCodeRequest { + /** grpc-gateway_out does not support Go style CodID */ + codeId: bigint; + /** pagination defines an optional pagination for the request. */ + pagination?: PageRequest; +} +export interface QueryContractsByCodeRequestProtoMsg { + typeUrl: "/cosmwasm.wasm.v1.QueryContractsByCodeRequest"; + value: Uint8Array; +} +/** + * QueryContractsByCodeRequest is the request type for the Query/ContractsByCode + * RPC method + */ +export interface QueryContractsByCodeRequestSDKType { + code_id: bigint; + pagination?: PageRequestSDKType; +} +/** + * QueryContractsByCodeResponse is the response type for the + * Query/ContractsByCode RPC method + */ +export interface QueryContractsByCodeResponse { + /** contracts are a set of contract addresses */ + contracts: string[]; + /** pagination defines the pagination in the response. */ + pagination?: PageResponse; +} +export interface QueryContractsByCodeResponseProtoMsg { + typeUrl: "/cosmwasm.wasm.v1.QueryContractsByCodeResponse"; + value: Uint8Array; +} +/** + * QueryContractsByCodeResponse is the response type for the + * Query/ContractsByCode RPC method + */ +export interface QueryContractsByCodeResponseSDKType { + contracts: string[]; + pagination?: PageResponseSDKType; +} +/** + * QueryAllContractStateRequest is the request type for the + * Query/AllContractState RPC method + */ +export interface QueryAllContractStateRequest { + /** address is the address of the contract */ + address: string; + /** pagination defines an optional pagination for the request. */ + pagination?: PageRequest; +} +export interface QueryAllContractStateRequestProtoMsg { + typeUrl: "/cosmwasm.wasm.v1.QueryAllContractStateRequest"; + value: Uint8Array; +} +/** + * QueryAllContractStateRequest is the request type for the + * Query/AllContractState RPC method + */ +export interface QueryAllContractStateRequestSDKType { + address: string; + pagination?: PageRequestSDKType; +} +/** + * QueryAllContractStateResponse is the response type for the + * Query/AllContractState RPC method + */ +export interface QueryAllContractStateResponse { + models: Model[]; + /** pagination defines the pagination in the response. */ + pagination?: PageResponse; +} +export interface QueryAllContractStateResponseProtoMsg { + typeUrl: "/cosmwasm.wasm.v1.QueryAllContractStateResponse"; + value: Uint8Array; +} +/** + * QueryAllContractStateResponse is the response type for the + * Query/AllContractState RPC method + */ +export interface QueryAllContractStateResponseSDKType { + models: ModelSDKType[]; + pagination?: PageResponseSDKType; +} +/** + * QueryRawContractStateRequest is the request type for the + * Query/RawContractState RPC method + */ +export interface QueryRawContractStateRequest { + /** address is the address of the contract */ + address: string; + queryData: Uint8Array; +} +export interface QueryRawContractStateRequestProtoMsg { + typeUrl: "/cosmwasm.wasm.v1.QueryRawContractStateRequest"; + value: Uint8Array; +} +/** + * QueryRawContractStateRequest is the request type for the + * Query/RawContractState RPC method + */ +export interface QueryRawContractStateRequestSDKType { + address: string; + query_data: Uint8Array; +} +/** + * QueryRawContractStateResponse is the response type for the + * Query/RawContractState RPC method + */ +export interface QueryRawContractStateResponse { + /** Data contains the raw store data */ + data: Uint8Array; +} +export interface QueryRawContractStateResponseProtoMsg { + typeUrl: "/cosmwasm.wasm.v1.QueryRawContractStateResponse"; + value: Uint8Array; +} +/** + * QueryRawContractStateResponse is the response type for the + * Query/RawContractState RPC method + */ +export interface QueryRawContractStateResponseSDKType { + data: Uint8Array; +} +/** + * QuerySmartContractStateRequest is the request type for the + * Query/SmartContractState RPC method + */ +export interface QuerySmartContractStateRequest { + /** address is the address of the contract */ + address: string; + /** QueryData contains the query data passed to the contract */ + queryData: Uint8Array; +} +export interface QuerySmartContractStateRequestProtoMsg { + typeUrl: "/cosmwasm.wasm.v1.QuerySmartContractStateRequest"; + value: Uint8Array; +} +/** + * QuerySmartContractStateRequest is the request type for the + * Query/SmartContractState RPC method + */ +export interface QuerySmartContractStateRequestSDKType { + address: string; + query_data: Uint8Array; +} +/** + * QuerySmartContractStateResponse is the response type for the + * Query/SmartContractState RPC method + */ +export interface QuerySmartContractStateResponse { + /** Data contains the json data returned from the smart contract */ + data: Uint8Array; +} +export interface QuerySmartContractStateResponseProtoMsg { + typeUrl: "/cosmwasm.wasm.v1.QuerySmartContractStateResponse"; + value: Uint8Array; +} +/** + * QuerySmartContractStateResponse is the response type for the + * Query/SmartContractState RPC method + */ +export interface QuerySmartContractStateResponseSDKType { + data: Uint8Array; +} +/** QueryCodeRequest is the request type for the Query/Code RPC method */ +export interface QueryCodeRequest { + /** grpc-gateway_out does not support Go style CodID */ + codeId: bigint; +} +export interface QueryCodeRequestProtoMsg { + typeUrl: "/cosmwasm.wasm.v1.QueryCodeRequest"; + value: Uint8Array; +} +/** QueryCodeRequest is the request type for the Query/Code RPC method */ +export interface QueryCodeRequestSDKType { + code_id: bigint; +} +/** CodeInfoResponse contains code meta data from CodeInfo */ +export interface CodeInfoResponse { + codeId: bigint; + creator: string; + dataHash: Uint8Array; +} +export interface CodeInfoResponseProtoMsg { + typeUrl: "/cosmwasm.wasm.v1.CodeInfoResponse"; + value: Uint8Array; +} +/** CodeInfoResponse contains code meta data from CodeInfo */ +export interface CodeInfoResponseSDKType { + code_id: bigint; + creator: string; + data_hash: Uint8Array; +} +/** QueryCodeResponse is the response type for the Query/Code RPC method */ +export interface QueryCodeResponse { + codeInfo?: CodeInfoResponse; + data: Uint8Array; +} +export interface QueryCodeResponseProtoMsg { + typeUrl: "/cosmwasm.wasm.v1.QueryCodeResponse"; + value: Uint8Array; +} +/** QueryCodeResponse is the response type for the Query/Code RPC method */ +export interface QueryCodeResponseSDKType { + code_info?: CodeInfoResponseSDKType; + data: Uint8Array; +} +/** QueryCodesRequest is the request type for the Query/Codes RPC method */ +export interface QueryCodesRequest { + /** pagination defines an optional pagination for the request. */ + pagination?: PageRequest; +} +export interface QueryCodesRequestProtoMsg { + typeUrl: "/cosmwasm.wasm.v1.QueryCodesRequest"; + value: Uint8Array; +} +/** QueryCodesRequest is the request type for the Query/Codes RPC method */ +export interface QueryCodesRequestSDKType { + pagination?: PageRequestSDKType; +} +/** QueryCodesResponse is the response type for the Query/Codes RPC method */ +export interface QueryCodesResponse { + codeInfos: CodeInfoResponse[]; + /** pagination defines the pagination in the response. */ + pagination?: PageResponse; +} +export interface QueryCodesResponseProtoMsg { + typeUrl: "/cosmwasm.wasm.v1.QueryCodesResponse"; + value: Uint8Array; +} +/** QueryCodesResponse is the response type for the Query/Codes RPC method */ +export interface QueryCodesResponseSDKType { + code_infos: CodeInfoResponseSDKType[]; + pagination?: PageResponseSDKType; +} +/** + * QueryPinnedCodesRequest is the request type for the Query/PinnedCodes + * RPC method + */ +export interface QueryPinnedCodesRequest { + /** pagination defines an optional pagination for the request. */ + pagination?: PageRequest; +} +export interface QueryPinnedCodesRequestProtoMsg { + typeUrl: "/cosmwasm.wasm.v1.QueryPinnedCodesRequest"; + value: Uint8Array; +} +/** + * QueryPinnedCodesRequest is the request type for the Query/PinnedCodes + * RPC method + */ +export interface QueryPinnedCodesRequestSDKType { + pagination?: PageRequestSDKType; +} +/** + * QueryPinnedCodesResponse is the response type for the + * Query/PinnedCodes RPC method + */ +export interface QueryPinnedCodesResponse { + codeIds: bigint[]; + /** pagination defines the pagination in the response. */ + pagination?: PageResponse; +} +export interface QueryPinnedCodesResponseProtoMsg { + typeUrl: "/cosmwasm.wasm.v1.QueryPinnedCodesResponse"; + value: Uint8Array; +} +/** + * QueryPinnedCodesResponse is the response type for the + * Query/PinnedCodes RPC method + */ +export interface QueryPinnedCodesResponseSDKType { + code_ids: bigint[]; + pagination?: PageResponseSDKType; +} +function createBaseQueryContractInfoRequest(): QueryContractInfoRequest { + return { + address: "" + }; +} +export const QueryContractInfoRequest = { + typeUrl: "/cosmwasm.wasm.v1.QueryContractInfoRequest", + encode(message: QueryContractInfoRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.address !== undefined) { + writer.uint32(10).string(message.address); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryContractInfoRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryContractInfoRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryContractInfoRequest { + const obj = createBaseQueryContractInfoRequest(); + if (isSet(object.address)) obj.address = String(object.address); + return obj; + }, + toJSON(message: QueryContractInfoRequest): JsonSafe { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + return obj; + }, + fromPartial(object: DeepPartial): QueryContractInfoRequest { + const message = createBaseQueryContractInfoRequest(); + message.address = object.address ?? ""; + return message; + }, + fromSDK(object: QueryContractInfoRequestSDKType): QueryContractInfoRequest { + return { + address: object?.address + }; + }, + fromSDKJSON(object: any): QueryContractInfoRequestSDKType { + return { + address: isSet(object.address) ? String(object.address) : "" + }; + }, + toSDK(message: QueryContractInfoRequest): QueryContractInfoRequestSDKType { + const obj: any = {}; + obj.address = message.address; + return obj; + }, + fromAmino(object: QueryContractInfoRequestAmino): QueryContractInfoRequest { + const message = createBaseQueryContractInfoRequest(); + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } + return message; + }, + toAmino(message: QueryContractInfoRequest): QueryContractInfoRequestAmino { + const obj: any = {}; + obj.address = message.address === "" ? undefined : message.address; + return obj; + }, + fromAminoMsg(object: QueryContractInfoRequestAminoMsg): QueryContractInfoRequest { + return QueryContractInfoRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryContractInfoRequest): QueryContractInfoRequestAminoMsg { + return { + type: "wasm/QueryContractInfoRequest", + value: QueryContractInfoRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryContractInfoRequestProtoMsg): QueryContractInfoRequest { + return QueryContractInfoRequest.decode(message.value); + }, + toProto(message: QueryContractInfoRequest): Uint8Array { + return QueryContractInfoRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryContractInfoRequest): QueryContractInfoRequestProtoMsg { + return { + typeUrl: "/cosmwasm.wasm.v1.QueryContractInfoRequest", + value: QueryContractInfoRequest.encode(message).finish() + }; + } +}; +function createBaseQueryContractInfoResponse(): QueryContractInfoResponse { + return { + address: "", + contractInfo: ContractInfo.fromPartial({}) + }; +} +export const QueryContractInfoResponse = { + typeUrl: "/cosmwasm.wasm.v1.QueryContractInfoResponse", + encode(message: QueryContractInfoResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.address !== undefined) { + writer.uint32(10).string(message.address); + } + if (message.contractInfo !== undefined) { + ContractInfo.encode(message.contractInfo, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryContractInfoResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryContractInfoResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.string(); + break; + case 2: + message.contractInfo = ContractInfo.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryContractInfoResponse { + const obj = createBaseQueryContractInfoResponse(); + if (isSet(object.address)) obj.address = String(object.address); + if (isSet(object.contractInfo)) obj.contractInfo = ContractInfo.fromJSON(object.contractInfo); + return obj; + }, + toJSON(message: QueryContractInfoResponse): JsonSafe { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + message.contractInfo !== undefined && (obj.contractInfo = message.contractInfo ? ContractInfo.toJSON(message.contractInfo) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryContractInfoResponse { + const message = createBaseQueryContractInfoResponse(); + message.address = object.address ?? ""; + if (object.contractInfo !== undefined && object.contractInfo !== null) { + message.contractInfo = ContractInfo.fromPartial(object.contractInfo); + } + return message; + }, + fromSDK(object: QueryContractInfoResponseSDKType): QueryContractInfoResponse { + return { + address: object?.address, + contractInfo: object.contract_info ? ContractInfo.fromSDK(object.contract_info) : undefined + }; + }, + fromSDKJSON(object: any): QueryContractInfoResponseSDKType { + return { + address: isSet(object.address) ? String(object.address) : "", + contract_info: isSet(object.contract_info) ? ContractInfo.fromSDKJSON(object.contract_info) : undefined + }; + }, + toSDK(message: QueryContractInfoResponse): QueryContractInfoResponseSDKType { + const obj: any = {}; + obj.address = message.address; + message.contractInfo !== undefined && (obj.contract_info = message.contractInfo ? ContractInfo.toSDK(message.contractInfo) : undefined); + return obj; + }, + fromAmino(object: QueryContractInfoResponseAmino): QueryContractInfoResponse { + const message = createBaseQueryContractInfoResponse(); + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } + if (object.contract_info !== undefined && object.contract_info !== null) { + message.contractInfo = ContractInfo.fromAmino(object.contract_info); + } + return message; + }, + toAmino(message: QueryContractInfoResponse): QueryContractInfoResponseAmino { + const obj: any = {}; + obj.address = message.address === "" ? undefined : message.address; + obj.contract_info = message.contractInfo ? ContractInfo.toAmino(message.contractInfo) : undefined; + return obj; + }, + fromAminoMsg(object: QueryContractInfoResponseAminoMsg): QueryContractInfoResponse { + return QueryContractInfoResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryContractInfoResponse): QueryContractInfoResponseAminoMsg { + return { + type: "wasm/QueryContractInfoResponse", + value: QueryContractInfoResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryContractInfoResponseProtoMsg): QueryContractInfoResponse { + return QueryContractInfoResponse.decode(message.value); + }, + toProto(message: QueryContractInfoResponse): Uint8Array { + return QueryContractInfoResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryContractInfoResponse): QueryContractInfoResponseProtoMsg { + return { + typeUrl: "/cosmwasm.wasm.v1.QueryContractInfoResponse", + value: QueryContractInfoResponse.encode(message).finish() + }; + } +}; +function createBaseQueryContractHistoryRequest(): QueryContractHistoryRequest { + return { + address: "", + pagination: undefined + }; +} +export const QueryContractHistoryRequest = { + typeUrl: "/cosmwasm.wasm.v1.QueryContractHistoryRequest", + encode(message: QueryContractHistoryRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.address !== undefined) { + writer.uint32(10).string(message.address); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryContractHistoryRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryContractHistoryRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.string(); + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryContractHistoryRequest { + const obj = createBaseQueryContractHistoryRequest(); + if (isSet(object.address)) obj.address = String(object.address); + if (isSet(object.pagination)) obj.pagination = PageRequest.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryContractHistoryRequest): JsonSafe { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryContractHistoryRequest { + const message = createBaseQueryContractHistoryRequest(); + message.address = object.address ?? ""; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryContractHistoryRequestSDKType): QueryContractHistoryRequest { + return { + address: object?.address, + pagination: object.pagination ? PageRequest.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryContractHistoryRequestSDKType { + return { + address: isSet(object.address) ? String(object.address) : "", + pagination: isSet(object.pagination) ? PageRequest.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryContractHistoryRequest): QueryContractHistoryRequestSDKType { + const obj: any = {}; + obj.address = message.address; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryContractHistoryRequestAmino): QueryContractHistoryRequest { + const message = createBaseQueryContractHistoryRequest(); + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryContractHistoryRequest): QueryContractHistoryRequestAmino { + const obj: any = {}; + obj.address = message.address === "" ? undefined : message.address; + obj.pagination = message.pagination ? PageRequest.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryContractHistoryRequestAminoMsg): QueryContractHistoryRequest { + return QueryContractHistoryRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryContractHistoryRequest): QueryContractHistoryRequestAminoMsg { + return { + type: "wasm/QueryContractHistoryRequest", + value: QueryContractHistoryRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryContractHistoryRequestProtoMsg): QueryContractHistoryRequest { + return QueryContractHistoryRequest.decode(message.value); + }, + toProto(message: QueryContractHistoryRequest): Uint8Array { + return QueryContractHistoryRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryContractHistoryRequest): QueryContractHistoryRequestProtoMsg { + return { + typeUrl: "/cosmwasm.wasm.v1.QueryContractHistoryRequest", + value: QueryContractHistoryRequest.encode(message).finish() + }; + } +}; +function createBaseQueryContractHistoryResponse(): QueryContractHistoryResponse { + return { + entries: [], + pagination: undefined + }; +} +export const QueryContractHistoryResponse = { + typeUrl: "/cosmwasm.wasm.v1.QueryContractHistoryResponse", + encode(message: QueryContractHistoryResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.entries) { + ContractCodeHistoryEntry.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryContractHistoryResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryContractHistoryResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.entries.push(ContractCodeHistoryEntry.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryContractHistoryResponse { + const obj = createBaseQueryContractHistoryResponse(); + if (Array.isArray(object?.entries)) obj.entries = object.entries.map((e: any) => ContractCodeHistoryEntry.fromJSON(e)); + if (isSet(object.pagination)) obj.pagination = PageResponse.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryContractHistoryResponse): JsonSafe { + const obj: any = {}; + if (message.entries) { + obj.entries = message.entries.map(e => e ? ContractCodeHistoryEntry.toJSON(e) : undefined); + } else { + obj.entries = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryContractHistoryResponse { + const message = createBaseQueryContractHistoryResponse(); + message.entries = object.entries?.map(e => ContractCodeHistoryEntry.fromPartial(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryContractHistoryResponseSDKType): QueryContractHistoryResponse { + return { + entries: Array.isArray(object?.entries) ? object.entries.map((e: any) => ContractCodeHistoryEntry.fromSDK(e)) : [], + pagination: object.pagination ? PageResponse.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryContractHistoryResponseSDKType { + return { + entries: Array.isArray(object?.entries) ? object.entries.map((e: any) => ContractCodeHistoryEntry.fromSDKJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryContractHistoryResponse): QueryContractHistoryResponseSDKType { + const obj: any = {}; + if (message.entries) { + obj.entries = message.entries.map(e => e ? ContractCodeHistoryEntry.toSDK(e) : undefined); + } else { + obj.entries = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryContractHistoryResponseAmino): QueryContractHistoryResponse { + const message = createBaseQueryContractHistoryResponse(); + message.entries = object.entries?.map(e => ContractCodeHistoryEntry.fromAmino(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryContractHistoryResponse): QueryContractHistoryResponseAmino { + const obj: any = {}; + if (message.entries) { + obj.entries = message.entries.map(e => e ? ContractCodeHistoryEntry.toAmino(e) : undefined); + } else { + obj.entries = message.entries; + } + obj.pagination = message.pagination ? PageResponse.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryContractHistoryResponseAminoMsg): QueryContractHistoryResponse { + return QueryContractHistoryResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryContractHistoryResponse): QueryContractHistoryResponseAminoMsg { + return { + type: "wasm/QueryContractHistoryResponse", + value: QueryContractHistoryResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryContractHistoryResponseProtoMsg): QueryContractHistoryResponse { + return QueryContractHistoryResponse.decode(message.value); + }, + toProto(message: QueryContractHistoryResponse): Uint8Array { + return QueryContractHistoryResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryContractHistoryResponse): QueryContractHistoryResponseProtoMsg { + return { + typeUrl: "/cosmwasm.wasm.v1.QueryContractHistoryResponse", + value: QueryContractHistoryResponse.encode(message).finish() + }; + } +}; +function createBaseQueryContractsByCodeRequest(): QueryContractsByCodeRequest { + return { + codeId: BigInt(0), + pagination: undefined + }; +} +export const QueryContractsByCodeRequest = { + typeUrl: "/cosmwasm.wasm.v1.QueryContractsByCodeRequest", + encode(message: QueryContractsByCodeRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.codeId !== undefined) { + writer.uint32(8).uint64(message.codeId); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryContractsByCodeRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryContractsByCodeRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.codeId = reader.uint64(); + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryContractsByCodeRequest { + const obj = createBaseQueryContractsByCodeRequest(); + if (isSet(object.codeId)) obj.codeId = BigInt(object.codeId.toString()); + if (isSet(object.pagination)) obj.pagination = PageRequest.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryContractsByCodeRequest): JsonSafe { + const obj: any = {}; + message.codeId !== undefined && (obj.codeId = (message.codeId || BigInt(0)).toString()); + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryContractsByCodeRequest { + const message = createBaseQueryContractsByCodeRequest(); + if (object.codeId !== undefined && object.codeId !== null) { + message.codeId = BigInt(object.codeId.toString()); + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryContractsByCodeRequestSDKType): QueryContractsByCodeRequest { + return { + codeId: object?.code_id, + pagination: object.pagination ? PageRequest.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryContractsByCodeRequestSDKType { + return { + code_id: isSet(object.code_id) ? BigInt(object.code_id.toString()) : BigInt(0), + pagination: isSet(object.pagination) ? PageRequest.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryContractsByCodeRequest): QueryContractsByCodeRequestSDKType { + const obj: any = {}; + obj.code_id = message.codeId; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryContractsByCodeRequestAmino): QueryContractsByCodeRequest { + const message = createBaseQueryContractsByCodeRequest(); + if (object.code_id !== undefined && object.code_id !== null) { + message.codeId = BigInt(object.code_id); + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryContractsByCodeRequest): QueryContractsByCodeRequestAmino { + const obj: any = {}; + obj.code_id = message.codeId !== BigInt(0) ? message.codeId?.toString() : undefined; + obj.pagination = message.pagination ? PageRequest.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryContractsByCodeRequestAminoMsg): QueryContractsByCodeRequest { + return QueryContractsByCodeRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryContractsByCodeRequest): QueryContractsByCodeRequestAminoMsg { + return { + type: "wasm/QueryContractsByCodeRequest", + value: QueryContractsByCodeRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryContractsByCodeRequestProtoMsg): QueryContractsByCodeRequest { + return QueryContractsByCodeRequest.decode(message.value); + }, + toProto(message: QueryContractsByCodeRequest): Uint8Array { + return QueryContractsByCodeRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryContractsByCodeRequest): QueryContractsByCodeRequestProtoMsg { + return { + typeUrl: "/cosmwasm.wasm.v1.QueryContractsByCodeRequest", + value: QueryContractsByCodeRequest.encode(message).finish() + }; + } +}; +function createBaseQueryContractsByCodeResponse(): QueryContractsByCodeResponse { + return { + contracts: [], + pagination: undefined + }; +} +export const QueryContractsByCodeResponse = { + typeUrl: "/cosmwasm.wasm.v1.QueryContractsByCodeResponse", + encode(message: QueryContractsByCodeResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.contracts) { + writer.uint32(10).string(v!); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryContractsByCodeResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryContractsByCodeResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.contracts.push(reader.string()); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryContractsByCodeResponse { + const obj = createBaseQueryContractsByCodeResponse(); + if (Array.isArray(object?.contracts)) obj.contracts = object.contracts.map((e: any) => String(e)); + if (isSet(object.pagination)) obj.pagination = PageResponse.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryContractsByCodeResponse): JsonSafe { + const obj: any = {}; + if (message.contracts) { + obj.contracts = message.contracts.map(e => e); + } else { + obj.contracts = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryContractsByCodeResponse { + const message = createBaseQueryContractsByCodeResponse(); + message.contracts = object.contracts?.map(e => e) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryContractsByCodeResponseSDKType): QueryContractsByCodeResponse { + return { + contracts: Array.isArray(object?.contracts) ? object.contracts.map((e: any) => e) : [], + pagination: object.pagination ? PageResponse.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryContractsByCodeResponseSDKType { + return { + contracts: Array.isArray(object?.contracts) ? object.contracts.map((e: any) => String(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryContractsByCodeResponse): QueryContractsByCodeResponseSDKType { + const obj: any = {}; + if (message.contracts) { + obj.contracts = message.contracts.map(e => e); + } else { + obj.contracts = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryContractsByCodeResponseAmino): QueryContractsByCodeResponse { + const message = createBaseQueryContractsByCodeResponse(); + message.contracts = object.contracts?.map(e => e) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryContractsByCodeResponse): QueryContractsByCodeResponseAmino { + const obj: any = {}; + if (message.contracts) { + obj.contracts = message.contracts.map(e => e); + } else { + obj.contracts = message.contracts; + } + obj.pagination = message.pagination ? PageResponse.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryContractsByCodeResponseAminoMsg): QueryContractsByCodeResponse { + return QueryContractsByCodeResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryContractsByCodeResponse): QueryContractsByCodeResponseAminoMsg { + return { + type: "wasm/QueryContractsByCodeResponse", + value: QueryContractsByCodeResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryContractsByCodeResponseProtoMsg): QueryContractsByCodeResponse { + return QueryContractsByCodeResponse.decode(message.value); + }, + toProto(message: QueryContractsByCodeResponse): Uint8Array { + return QueryContractsByCodeResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryContractsByCodeResponse): QueryContractsByCodeResponseProtoMsg { + return { + typeUrl: "/cosmwasm.wasm.v1.QueryContractsByCodeResponse", + value: QueryContractsByCodeResponse.encode(message).finish() + }; + } +}; +function createBaseQueryAllContractStateRequest(): QueryAllContractStateRequest { + return { + address: "", + pagination: undefined + }; +} +export const QueryAllContractStateRequest = { + typeUrl: "/cosmwasm.wasm.v1.QueryAllContractStateRequest", + encode(message: QueryAllContractStateRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.address !== undefined) { + writer.uint32(10).string(message.address); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryAllContractStateRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryAllContractStateRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.string(); + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryAllContractStateRequest { + const obj = createBaseQueryAllContractStateRequest(); + if (isSet(object.address)) obj.address = String(object.address); + if (isSet(object.pagination)) obj.pagination = PageRequest.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryAllContractStateRequest): JsonSafe { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryAllContractStateRequest { + const message = createBaseQueryAllContractStateRequest(); + message.address = object.address ?? ""; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryAllContractStateRequestSDKType): QueryAllContractStateRequest { + return { + address: object?.address, + pagination: object.pagination ? PageRequest.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryAllContractStateRequestSDKType { + return { + address: isSet(object.address) ? String(object.address) : "", + pagination: isSet(object.pagination) ? PageRequest.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryAllContractStateRequest): QueryAllContractStateRequestSDKType { + const obj: any = {}; + obj.address = message.address; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryAllContractStateRequestAmino): QueryAllContractStateRequest { + const message = createBaseQueryAllContractStateRequest(); + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryAllContractStateRequest): QueryAllContractStateRequestAmino { + const obj: any = {}; + obj.address = message.address === "" ? undefined : message.address; + obj.pagination = message.pagination ? PageRequest.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryAllContractStateRequestAminoMsg): QueryAllContractStateRequest { + return QueryAllContractStateRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryAllContractStateRequest): QueryAllContractStateRequestAminoMsg { + return { + type: "wasm/QueryAllContractStateRequest", + value: QueryAllContractStateRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryAllContractStateRequestProtoMsg): QueryAllContractStateRequest { + return QueryAllContractStateRequest.decode(message.value); + }, + toProto(message: QueryAllContractStateRequest): Uint8Array { + return QueryAllContractStateRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryAllContractStateRequest): QueryAllContractStateRequestProtoMsg { + return { + typeUrl: "/cosmwasm.wasm.v1.QueryAllContractStateRequest", + value: QueryAllContractStateRequest.encode(message).finish() + }; + } +}; +function createBaseQueryAllContractStateResponse(): QueryAllContractStateResponse { + return { + models: [], + pagination: undefined + }; +} +export const QueryAllContractStateResponse = { + typeUrl: "/cosmwasm.wasm.v1.QueryAllContractStateResponse", + encode(message: QueryAllContractStateResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.models) { + Model.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryAllContractStateResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryAllContractStateResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.models.push(Model.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryAllContractStateResponse { + const obj = createBaseQueryAllContractStateResponse(); + if (Array.isArray(object?.models)) obj.models = object.models.map((e: any) => Model.fromJSON(e)); + if (isSet(object.pagination)) obj.pagination = PageResponse.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryAllContractStateResponse): JsonSafe { + const obj: any = {}; + if (message.models) { + obj.models = message.models.map(e => e ? Model.toJSON(e) : undefined); + } else { + obj.models = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryAllContractStateResponse { + const message = createBaseQueryAllContractStateResponse(); + message.models = object.models?.map(e => Model.fromPartial(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryAllContractStateResponseSDKType): QueryAllContractStateResponse { + return { + models: Array.isArray(object?.models) ? object.models.map((e: any) => Model.fromSDK(e)) : [], + pagination: object.pagination ? PageResponse.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryAllContractStateResponseSDKType { + return { + models: Array.isArray(object?.models) ? object.models.map((e: any) => Model.fromSDKJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryAllContractStateResponse): QueryAllContractStateResponseSDKType { + const obj: any = {}; + if (message.models) { + obj.models = message.models.map(e => e ? Model.toSDK(e) : undefined); + } else { + obj.models = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryAllContractStateResponseAmino): QueryAllContractStateResponse { + const message = createBaseQueryAllContractStateResponse(); + message.models = object.models?.map(e => Model.fromAmino(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryAllContractStateResponse): QueryAllContractStateResponseAmino { + const obj: any = {}; + if (message.models) { + obj.models = message.models.map(e => e ? Model.toAmino(e) : undefined); + } else { + obj.models = message.models; + } + obj.pagination = message.pagination ? PageResponse.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryAllContractStateResponseAminoMsg): QueryAllContractStateResponse { + return QueryAllContractStateResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryAllContractStateResponse): QueryAllContractStateResponseAminoMsg { + return { + type: "wasm/QueryAllContractStateResponse", + value: QueryAllContractStateResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryAllContractStateResponseProtoMsg): QueryAllContractStateResponse { + return QueryAllContractStateResponse.decode(message.value); + }, + toProto(message: QueryAllContractStateResponse): Uint8Array { + return QueryAllContractStateResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryAllContractStateResponse): QueryAllContractStateResponseProtoMsg { + return { + typeUrl: "/cosmwasm.wasm.v1.QueryAllContractStateResponse", + value: QueryAllContractStateResponse.encode(message).finish() + }; + } +}; +function createBaseQueryRawContractStateRequest(): QueryRawContractStateRequest { + return { + address: "", + queryData: new Uint8Array() + }; +} +export const QueryRawContractStateRequest = { + typeUrl: "/cosmwasm.wasm.v1.QueryRawContractStateRequest", + encode(message: QueryRawContractStateRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.address !== undefined) { + writer.uint32(10).string(message.address); + } + if (message.queryData.length !== 0) { + writer.uint32(18).bytes(message.queryData); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryRawContractStateRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryRawContractStateRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.string(); + break; + case 2: + message.queryData = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryRawContractStateRequest { + const obj = createBaseQueryRawContractStateRequest(); + if (isSet(object.address)) obj.address = String(object.address); + if (isSet(object.queryData)) obj.queryData = bytesFromBase64(object.queryData); + return obj; + }, + toJSON(message: QueryRawContractStateRequest): JsonSafe { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + message.queryData !== undefined && (obj.queryData = base64FromBytes(message.queryData !== undefined ? message.queryData : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): QueryRawContractStateRequest { + const message = createBaseQueryRawContractStateRequest(); + message.address = object.address ?? ""; + message.queryData = object.queryData ?? new Uint8Array(); + return message; + }, + fromSDK(object: QueryRawContractStateRequestSDKType): QueryRawContractStateRequest { + return { + address: object?.address, + queryData: object?.query_data + }; + }, + fromSDKJSON(object: any): QueryRawContractStateRequestSDKType { + return { + address: isSet(object.address) ? String(object.address) : "", + query_data: isSet(object.query_data) ? bytesFromBase64(object.query_data) : new Uint8Array() + }; + }, + toSDK(message: QueryRawContractStateRequest): QueryRawContractStateRequestSDKType { + const obj: any = {}; + obj.address = message.address; + obj.query_data = message.queryData; + return obj; + }, + fromAmino(object: QueryRawContractStateRequestAmino): QueryRawContractStateRequest { + const message = createBaseQueryRawContractStateRequest(); + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } + if (object.query_data !== undefined && object.query_data !== null) { + message.queryData = bytesFromBase64(object.query_data); + } + return message; + }, + toAmino(message: QueryRawContractStateRequest): QueryRawContractStateRequestAmino { + const obj: any = {}; + obj.address = message.address === "" ? undefined : message.address; + obj.query_data = message.queryData ? base64FromBytes(message.queryData) : undefined; + return obj; + }, + fromAminoMsg(object: QueryRawContractStateRequestAminoMsg): QueryRawContractStateRequest { + return QueryRawContractStateRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryRawContractStateRequest): QueryRawContractStateRequestAminoMsg { + return { + type: "wasm/QueryRawContractStateRequest", + value: QueryRawContractStateRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryRawContractStateRequestProtoMsg): QueryRawContractStateRequest { + return QueryRawContractStateRequest.decode(message.value); + }, + toProto(message: QueryRawContractStateRequest): Uint8Array { + return QueryRawContractStateRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryRawContractStateRequest): QueryRawContractStateRequestProtoMsg { + return { + typeUrl: "/cosmwasm.wasm.v1.QueryRawContractStateRequest", + value: QueryRawContractStateRequest.encode(message).finish() + }; + } +}; +function createBaseQueryRawContractStateResponse(): QueryRawContractStateResponse { + return { + data: new Uint8Array() + }; +} +export const QueryRawContractStateResponse = { + typeUrl: "/cosmwasm.wasm.v1.QueryRawContractStateResponse", + encode(message: QueryRawContractStateResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.data.length !== 0) { + writer.uint32(10).bytes(message.data); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryRawContractStateResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryRawContractStateResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.data = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryRawContractStateResponse { + const obj = createBaseQueryRawContractStateResponse(); + if (isSet(object.data)) obj.data = bytesFromBase64(object.data); + return obj; + }, + toJSON(message: QueryRawContractStateResponse): JsonSafe { + const obj: any = {}; + message.data !== undefined && (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): QueryRawContractStateResponse { + const message = createBaseQueryRawContractStateResponse(); + message.data = object.data ?? new Uint8Array(); + return message; + }, + fromSDK(object: QueryRawContractStateResponseSDKType): QueryRawContractStateResponse { + return { + data: object?.data + }; + }, + fromSDKJSON(object: any): QueryRawContractStateResponseSDKType { + return { + data: isSet(object.data) ? bytesFromBase64(object.data) : new Uint8Array() + }; + }, + toSDK(message: QueryRawContractStateResponse): QueryRawContractStateResponseSDKType { + const obj: any = {}; + obj.data = message.data; + return obj; + }, + fromAmino(object: QueryRawContractStateResponseAmino): QueryRawContractStateResponse { + const message = createBaseQueryRawContractStateResponse(); + if (object.data !== undefined && object.data !== null) { + message.data = bytesFromBase64(object.data); + } + return message; + }, + toAmino(message: QueryRawContractStateResponse): QueryRawContractStateResponseAmino { + const obj: any = {}; + obj.data = message.data ? base64FromBytes(message.data) : undefined; + return obj; + }, + fromAminoMsg(object: QueryRawContractStateResponseAminoMsg): QueryRawContractStateResponse { + return QueryRawContractStateResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryRawContractStateResponse): QueryRawContractStateResponseAminoMsg { + return { + type: "wasm/QueryRawContractStateResponse", + value: QueryRawContractStateResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryRawContractStateResponseProtoMsg): QueryRawContractStateResponse { + return QueryRawContractStateResponse.decode(message.value); + }, + toProto(message: QueryRawContractStateResponse): Uint8Array { + return QueryRawContractStateResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryRawContractStateResponse): QueryRawContractStateResponseProtoMsg { + return { + typeUrl: "/cosmwasm.wasm.v1.QueryRawContractStateResponse", + value: QueryRawContractStateResponse.encode(message).finish() + }; + } +}; +function createBaseQuerySmartContractStateRequest(): QuerySmartContractStateRequest { + return { + address: "", + queryData: new Uint8Array() + }; +} +export const QuerySmartContractStateRequest = { + typeUrl: "/cosmwasm.wasm.v1.QuerySmartContractStateRequest", + encode(message: QuerySmartContractStateRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.address !== undefined) { + writer.uint32(10).string(message.address); + } + if (message.queryData.length !== 0) { + writer.uint32(18).bytes(message.queryData); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QuerySmartContractStateRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQuerySmartContractStateRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.string(); + break; + case 2: + message.queryData = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QuerySmartContractStateRequest { + const obj = createBaseQuerySmartContractStateRequest(); + if (isSet(object.address)) obj.address = String(object.address); + if (isSet(object.queryData)) obj.queryData = bytesFromBase64(object.queryData); + return obj; + }, + toJSON(message: QuerySmartContractStateRequest): JsonSafe { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + message.queryData !== undefined && (obj.queryData = base64FromBytes(message.queryData !== undefined ? message.queryData : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): QuerySmartContractStateRequest { + const message = createBaseQuerySmartContractStateRequest(); + message.address = object.address ?? ""; + message.queryData = object.queryData ?? new Uint8Array(); + return message; + }, + fromSDK(object: QuerySmartContractStateRequestSDKType): QuerySmartContractStateRequest { + return { + address: object?.address, + queryData: object?.query_data + }; + }, + fromSDKJSON(object: any): QuerySmartContractStateRequestSDKType { + return { + address: isSet(object.address) ? String(object.address) : "", + query_data: isSet(object.query_data) ? bytesFromBase64(object.query_data) : new Uint8Array() + }; + }, + toSDK(message: QuerySmartContractStateRequest): QuerySmartContractStateRequestSDKType { + const obj: any = {}; + obj.address = message.address; + obj.query_data = message.queryData; + return obj; + }, + fromAmino(object: QuerySmartContractStateRequestAmino): QuerySmartContractStateRequest { + const message = createBaseQuerySmartContractStateRequest(); + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } + if (object.query_data !== undefined && object.query_data !== null) { + message.queryData = toUtf8(JSON.stringify(object.query_data)); + } + return message; + }, + toAmino(message: QuerySmartContractStateRequest): QuerySmartContractStateRequestAmino { + const obj: any = {}; + obj.address = message.address === "" ? undefined : message.address; + obj.query_data = message.queryData ? JSON.parse(fromUtf8(message.queryData)) : undefined; + return obj; + }, + fromAminoMsg(object: QuerySmartContractStateRequestAminoMsg): QuerySmartContractStateRequest { + return QuerySmartContractStateRequest.fromAmino(object.value); + }, + toAminoMsg(message: QuerySmartContractStateRequest): QuerySmartContractStateRequestAminoMsg { + return { + type: "wasm/QuerySmartContractStateRequest", + value: QuerySmartContractStateRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QuerySmartContractStateRequestProtoMsg): QuerySmartContractStateRequest { + return QuerySmartContractStateRequest.decode(message.value); + }, + toProto(message: QuerySmartContractStateRequest): Uint8Array { + return QuerySmartContractStateRequest.encode(message).finish(); + }, + toProtoMsg(message: QuerySmartContractStateRequest): QuerySmartContractStateRequestProtoMsg { + return { + typeUrl: "/cosmwasm.wasm.v1.QuerySmartContractStateRequest", + value: QuerySmartContractStateRequest.encode(message).finish() + }; + } +}; +function createBaseQuerySmartContractStateResponse(): QuerySmartContractStateResponse { + return { + data: new Uint8Array() + }; +} +export const QuerySmartContractStateResponse = { + typeUrl: "/cosmwasm.wasm.v1.QuerySmartContractStateResponse", + encode(message: QuerySmartContractStateResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.data.length !== 0) { + writer.uint32(10).bytes(message.data); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QuerySmartContractStateResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQuerySmartContractStateResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.data = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QuerySmartContractStateResponse { + const obj = createBaseQuerySmartContractStateResponse(); + if (isSet(object.data)) obj.data = bytesFromBase64(object.data); + return obj; + }, + toJSON(message: QuerySmartContractStateResponse): JsonSafe { + const obj: any = {}; + message.data !== undefined && (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): QuerySmartContractStateResponse { + const message = createBaseQuerySmartContractStateResponse(); + message.data = object.data ?? new Uint8Array(); + return message; + }, + fromSDK(object: QuerySmartContractStateResponseSDKType): QuerySmartContractStateResponse { + return { + data: object?.data + }; + }, + fromSDKJSON(object: any): QuerySmartContractStateResponseSDKType { + return { + data: isSet(object.data) ? bytesFromBase64(object.data) : new Uint8Array() + }; + }, + toSDK(message: QuerySmartContractStateResponse): QuerySmartContractStateResponseSDKType { + const obj: any = {}; + obj.data = message.data; + return obj; + }, + fromAmino(object: QuerySmartContractStateResponseAmino): QuerySmartContractStateResponse { + const message = createBaseQuerySmartContractStateResponse(); + if (object.data !== undefined && object.data !== null) { + message.data = toUtf8(JSON.stringify(object.data)); + } + return message; + }, + toAmino(message: QuerySmartContractStateResponse): QuerySmartContractStateResponseAmino { + const obj: any = {}; + obj.data = message.data ? JSON.parse(fromUtf8(message.data)) : undefined; + return obj; + }, + fromAminoMsg(object: QuerySmartContractStateResponseAminoMsg): QuerySmartContractStateResponse { + return QuerySmartContractStateResponse.fromAmino(object.value); + }, + toAminoMsg(message: QuerySmartContractStateResponse): QuerySmartContractStateResponseAminoMsg { + return { + type: "wasm/QuerySmartContractStateResponse", + value: QuerySmartContractStateResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QuerySmartContractStateResponseProtoMsg): QuerySmartContractStateResponse { + return QuerySmartContractStateResponse.decode(message.value); + }, + toProto(message: QuerySmartContractStateResponse): Uint8Array { + return QuerySmartContractStateResponse.encode(message).finish(); + }, + toProtoMsg(message: QuerySmartContractStateResponse): QuerySmartContractStateResponseProtoMsg { + return { + typeUrl: "/cosmwasm.wasm.v1.QuerySmartContractStateResponse", + value: QuerySmartContractStateResponse.encode(message).finish() + }; + } +}; +function createBaseQueryCodeRequest(): QueryCodeRequest { + return { + codeId: BigInt(0) + }; +} +export const QueryCodeRequest = { + typeUrl: "/cosmwasm.wasm.v1.QueryCodeRequest", + encode(message: QueryCodeRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.codeId !== undefined) { + writer.uint32(8).uint64(message.codeId); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryCodeRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryCodeRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.codeId = reader.uint64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryCodeRequest { + const obj = createBaseQueryCodeRequest(); + if (isSet(object.codeId)) obj.codeId = BigInt(object.codeId.toString()); + return obj; + }, + toJSON(message: QueryCodeRequest): JsonSafe { + const obj: any = {}; + message.codeId !== undefined && (obj.codeId = (message.codeId || BigInt(0)).toString()); + return obj; + }, + fromPartial(object: DeepPartial): QueryCodeRequest { + const message = createBaseQueryCodeRequest(); + if (object.codeId !== undefined && object.codeId !== null) { + message.codeId = BigInt(object.codeId.toString()); + } + return message; + }, + fromSDK(object: QueryCodeRequestSDKType): QueryCodeRequest { + return { + codeId: object?.code_id + }; + }, + fromSDKJSON(object: any): QueryCodeRequestSDKType { + return { + code_id: isSet(object.code_id) ? BigInt(object.code_id.toString()) : BigInt(0) + }; + }, + toSDK(message: QueryCodeRequest): QueryCodeRequestSDKType { + const obj: any = {}; + obj.code_id = message.codeId; + return obj; + }, + fromAmino(object: QueryCodeRequestAmino): QueryCodeRequest { + const message = createBaseQueryCodeRequest(); + if (object.code_id !== undefined && object.code_id !== null) { + message.codeId = BigInt(object.code_id); + } + return message; + }, + toAmino(message: QueryCodeRequest): QueryCodeRequestAmino { + const obj: any = {}; + obj.code_id = message.codeId !== BigInt(0) ? message.codeId?.toString() : undefined; + return obj; + }, + fromAminoMsg(object: QueryCodeRequestAminoMsg): QueryCodeRequest { + return QueryCodeRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryCodeRequest): QueryCodeRequestAminoMsg { + return { + type: "wasm/QueryCodeRequest", + value: QueryCodeRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryCodeRequestProtoMsg): QueryCodeRequest { + return QueryCodeRequest.decode(message.value); + }, + toProto(message: QueryCodeRequest): Uint8Array { + return QueryCodeRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryCodeRequest): QueryCodeRequestProtoMsg { + return { + typeUrl: "/cosmwasm.wasm.v1.QueryCodeRequest", + value: QueryCodeRequest.encode(message).finish() + }; + } +}; +function createBaseCodeInfoResponse(): CodeInfoResponse { + return { + codeId: BigInt(0), + creator: "", + dataHash: new Uint8Array() + }; +} +export const CodeInfoResponse = { + typeUrl: "/cosmwasm.wasm.v1.CodeInfoResponse", + encode(message: CodeInfoResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.codeId !== undefined) { + writer.uint32(8).uint64(message.codeId); + } + if (message.creator !== undefined) { + writer.uint32(18).string(message.creator); + } + if (message.dataHash.length !== 0) { + writer.uint32(26).bytes(message.dataHash); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): CodeInfoResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCodeInfoResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.codeId = reader.uint64(); + break; + case 2: + message.creator = reader.string(); + break; + case 3: + message.dataHash = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): CodeInfoResponse { + const obj = createBaseCodeInfoResponse(); + if (isSet(object.codeId)) obj.codeId = BigInt(object.codeId.toString()); + if (isSet(object.creator)) obj.creator = String(object.creator); + if (isSet(object.dataHash)) obj.dataHash = bytesFromBase64(object.dataHash); + return obj; + }, + toJSON(message: CodeInfoResponse): JsonSafe { + const obj: any = {}; + message.codeId !== undefined && (obj.codeId = (message.codeId || BigInt(0)).toString()); + message.creator !== undefined && (obj.creator = message.creator); + message.dataHash !== undefined && (obj.dataHash = base64FromBytes(message.dataHash !== undefined ? message.dataHash : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): CodeInfoResponse { + const message = createBaseCodeInfoResponse(); + if (object.codeId !== undefined && object.codeId !== null) { + message.codeId = BigInt(object.codeId.toString()); + } + message.creator = object.creator ?? ""; + message.dataHash = object.dataHash ?? new Uint8Array(); + return message; + }, + fromSDK(object: CodeInfoResponseSDKType): CodeInfoResponse { + return { + codeId: object?.code_id, + creator: object?.creator, + dataHash: object?.data_hash + }; + }, + fromSDKJSON(object: any): CodeInfoResponseSDKType { + return { + code_id: isSet(object.code_id) ? BigInt(object.code_id.toString()) : BigInt(0), + creator: isSet(object.creator) ? String(object.creator) : "", + data_hash: isSet(object.data_hash) ? bytesFromBase64(object.data_hash) : new Uint8Array() + }; + }, + toSDK(message: CodeInfoResponse): CodeInfoResponseSDKType { + const obj: any = {}; + obj.code_id = message.codeId; + obj.creator = message.creator; + obj.data_hash = message.dataHash; + return obj; + }, + fromAmino(object: CodeInfoResponseAmino): CodeInfoResponse { + const message = createBaseCodeInfoResponse(); + if (object.code_id !== undefined && object.code_id !== null) { + message.codeId = BigInt(object.code_id); + } + if (object.creator !== undefined && object.creator !== null) { + message.creator = object.creator; + } + if (object.data_hash !== undefined && object.data_hash !== null) { + message.dataHash = bytesFromBase64(object.data_hash); + } + return message; + }, + toAmino(message: CodeInfoResponse): CodeInfoResponseAmino { + const obj: any = {}; + obj.code_id = message.codeId ? message.codeId?.toString() : "0"; + obj.creator = message.creator === "" ? undefined : message.creator; + obj.data_hash = message.dataHash ? base64FromBytes(message.dataHash) : undefined; + return obj; + }, + fromAminoMsg(object: CodeInfoResponseAminoMsg): CodeInfoResponse { + return CodeInfoResponse.fromAmino(object.value); + }, + toAminoMsg(message: CodeInfoResponse): CodeInfoResponseAminoMsg { + return { + type: "wasm/CodeInfoResponse", + value: CodeInfoResponse.toAmino(message) + }; + }, + fromProtoMsg(message: CodeInfoResponseProtoMsg): CodeInfoResponse { + return CodeInfoResponse.decode(message.value); + }, + toProto(message: CodeInfoResponse): Uint8Array { + return CodeInfoResponse.encode(message).finish(); + }, + toProtoMsg(message: CodeInfoResponse): CodeInfoResponseProtoMsg { + return { + typeUrl: "/cosmwasm.wasm.v1.CodeInfoResponse", + value: CodeInfoResponse.encode(message).finish() + }; + } +}; +function createBaseQueryCodeResponse(): QueryCodeResponse { + return { + codeInfo: undefined, + data: new Uint8Array() + }; +} +export const QueryCodeResponse = { + typeUrl: "/cosmwasm.wasm.v1.QueryCodeResponse", + encode(message: QueryCodeResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.codeInfo !== undefined) { + CodeInfoResponse.encode(message.codeInfo, writer.uint32(10).fork()).ldelim(); + } + if (message.data.length !== 0) { + writer.uint32(18).bytes(message.data); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryCodeResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryCodeResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.codeInfo = CodeInfoResponse.decode(reader, reader.uint32()); + break; + case 2: + message.data = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryCodeResponse { + const obj = createBaseQueryCodeResponse(); + if (isSet(object.codeInfo)) obj.codeInfo = CodeInfoResponse.fromJSON(object.codeInfo); + if (isSet(object.data)) obj.data = bytesFromBase64(object.data); + return obj; + }, + toJSON(message: QueryCodeResponse): JsonSafe { + const obj: any = {}; + message.codeInfo !== undefined && (obj.codeInfo = message.codeInfo ? CodeInfoResponse.toJSON(message.codeInfo) : undefined); + message.data !== undefined && (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): QueryCodeResponse { + const message = createBaseQueryCodeResponse(); + if (object.codeInfo !== undefined && object.codeInfo !== null) { + message.codeInfo = CodeInfoResponse.fromPartial(object.codeInfo); + } + message.data = object.data ?? new Uint8Array(); + return message; + }, + fromSDK(object: QueryCodeResponseSDKType): QueryCodeResponse { + return { + codeInfo: object.code_info ? CodeInfoResponse.fromSDK(object.code_info) : undefined, + data: object?.data + }; + }, + fromSDKJSON(object: any): QueryCodeResponseSDKType { + return { + code_info: isSet(object.code_info) ? CodeInfoResponse.fromSDKJSON(object.code_info) : undefined, + data: isSet(object.data) ? bytesFromBase64(object.data) : new Uint8Array() + }; + }, + toSDK(message: QueryCodeResponse): QueryCodeResponseSDKType { + const obj: any = {}; + message.codeInfo !== undefined && (obj.code_info = message.codeInfo ? CodeInfoResponse.toSDK(message.codeInfo) : undefined); + obj.data = message.data; + return obj; + }, + fromAmino(object: QueryCodeResponseAmino): QueryCodeResponse { + const message = createBaseQueryCodeResponse(); + if (object.code_info !== undefined && object.code_info !== null) { + message.codeInfo = CodeInfoResponse.fromAmino(object.code_info); + } + if (object.data !== undefined && object.data !== null) { + message.data = bytesFromBase64(object.data); + } + return message; + }, + toAmino(message: QueryCodeResponse): QueryCodeResponseAmino { + const obj: any = {}; + obj.code_info = message.codeInfo ? CodeInfoResponse.toAmino(message.codeInfo) : undefined; + obj.data = message.data ? base64FromBytes(message.data) : ""; + return obj; + }, + fromAminoMsg(object: QueryCodeResponseAminoMsg): QueryCodeResponse { + return QueryCodeResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryCodeResponse): QueryCodeResponseAminoMsg { + return { + type: "wasm/QueryCodeResponse", + value: QueryCodeResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryCodeResponseProtoMsg): QueryCodeResponse { + return QueryCodeResponse.decode(message.value); + }, + toProto(message: QueryCodeResponse): Uint8Array { + return QueryCodeResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryCodeResponse): QueryCodeResponseProtoMsg { + return { + typeUrl: "/cosmwasm.wasm.v1.QueryCodeResponse", + value: QueryCodeResponse.encode(message).finish() + }; + } +}; +function createBaseQueryCodesRequest(): QueryCodesRequest { + return { + pagination: undefined + }; +} +export const QueryCodesRequest = { + typeUrl: "/cosmwasm.wasm.v1.QueryCodesRequest", + encode(message: QueryCodesRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryCodesRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryCodesRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryCodesRequest { + const obj = createBaseQueryCodesRequest(); + if (isSet(object.pagination)) obj.pagination = PageRequest.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryCodesRequest): JsonSafe { + const obj: any = {}; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryCodesRequest { + const message = createBaseQueryCodesRequest(); + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryCodesRequestSDKType): QueryCodesRequest { + return { + pagination: object.pagination ? PageRequest.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryCodesRequestSDKType { + return { + pagination: isSet(object.pagination) ? PageRequest.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryCodesRequest): QueryCodesRequestSDKType { + const obj: any = {}; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryCodesRequestAmino): QueryCodesRequest { + const message = createBaseQueryCodesRequest(); + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryCodesRequest): QueryCodesRequestAmino { + const obj: any = {}; + obj.pagination = message.pagination ? PageRequest.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryCodesRequestAminoMsg): QueryCodesRequest { + return QueryCodesRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryCodesRequest): QueryCodesRequestAminoMsg { + return { + type: "wasm/QueryCodesRequest", + value: QueryCodesRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryCodesRequestProtoMsg): QueryCodesRequest { + return QueryCodesRequest.decode(message.value); + }, + toProto(message: QueryCodesRequest): Uint8Array { + return QueryCodesRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryCodesRequest): QueryCodesRequestProtoMsg { + return { + typeUrl: "/cosmwasm.wasm.v1.QueryCodesRequest", + value: QueryCodesRequest.encode(message).finish() + }; + } +}; +function createBaseQueryCodesResponse(): QueryCodesResponse { + return { + codeInfos: [], + pagination: undefined + }; +} +export const QueryCodesResponse = { + typeUrl: "/cosmwasm.wasm.v1.QueryCodesResponse", + encode(message: QueryCodesResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.codeInfos) { + CodeInfoResponse.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryCodesResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryCodesResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.codeInfos.push(CodeInfoResponse.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryCodesResponse { + const obj = createBaseQueryCodesResponse(); + if (Array.isArray(object?.codeInfos)) obj.codeInfos = object.codeInfos.map((e: any) => CodeInfoResponse.fromJSON(e)); + if (isSet(object.pagination)) obj.pagination = PageResponse.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryCodesResponse): JsonSafe { + const obj: any = {}; + if (message.codeInfos) { + obj.codeInfos = message.codeInfos.map(e => e ? CodeInfoResponse.toJSON(e) : undefined); + } else { + obj.codeInfos = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryCodesResponse { + const message = createBaseQueryCodesResponse(); + message.codeInfos = object.codeInfos?.map(e => CodeInfoResponse.fromPartial(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryCodesResponseSDKType): QueryCodesResponse { + return { + codeInfos: Array.isArray(object?.code_infos) ? object.code_infos.map((e: any) => CodeInfoResponse.fromSDK(e)) : [], + pagination: object.pagination ? PageResponse.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryCodesResponseSDKType { + return { + code_infos: Array.isArray(object?.code_infos) ? object.code_infos.map((e: any) => CodeInfoResponse.fromSDKJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryCodesResponse): QueryCodesResponseSDKType { + const obj: any = {}; + if (message.codeInfos) { + obj.code_infos = message.codeInfos.map(e => e ? CodeInfoResponse.toSDK(e) : undefined); + } else { + obj.code_infos = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryCodesResponseAmino): QueryCodesResponse { + const message = createBaseQueryCodesResponse(); + message.codeInfos = object.code_infos?.map(e => CodeInfoResponse.fromAmino(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryCodesResponse): QueryCodesResponseAmino { + const obj: any = {}; + if (message.codeInfos) { + obj.code_infos = message.codeInfos.map(e => e ? CodeInfoResponse.toAmino(e) : undefined); + } else { + obj.code_infos = message.codeInfos; + } + obj.pagination = message.pagination ? PageResponse.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryCodesResponseAminoMsg): QueryCodesResponse { + return QueryCodesResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryCodesResponse): QueryCodesResponseAminoMsg { + return { + type: "wasm/QueryCodesResponse", + value: QueryCodesResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryCodesResponseProtoMsg): QueryCodesResponse { + return QueryCodesResponse.decode(message.value); + }, + toProto(message: QueryCodesResponse): Uint8Array { + return QueryCodesResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryCodesResponse): QueryCodesResponseProtoMsg { + return { + typeUrl: "/cosmwasm.wasm.v1.QueryCodesResponse", + value: QueryCodesResponse.encode(message).finish() + }; + } +}; +function createBaseQueryPinnedCodesRequest(): QueryPinnedCodesRequest { + return { + pagination: undefined + }; +} +export const QueryPinnedCodesRequest = { + typeUrl: "/cosmwasm.wasm.v1.QueryPinnedCodesRequest", + encode(message: QueryPinnedCodesRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryPinnedCodesRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryPinnedCodesRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryPinnedCodesRequest { + const obj = createBaseQueryPinnedCodesRequest(); + if (isSet(object.pagination)) obj.pagination = PageRequest.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryPinnedCodesRequest): JsonSafe { + const obj: any = {}; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryPinnedCodesRequest { + const message = createBaseQueryPinnedCodesRequest(); + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryPinnedCodesRequestSDKType): QueryPinnedCodesRequest { + return { + pagination: object.pagination ? PageRequest.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryPinnedCodesRequestSDKType { + return { + pagination: isSet(object.pagination) ? PageRequest.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryPinnedCodesRequest): QueryPinnedCodesRequestSDKType { + const obj: any = {}; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryPinnedCodesRequestAmino): QueryPinnedCodesRequest { + const message = createBaseQueryPinnedCodesRequest(); + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryPinnedCodesRequest): QueryPinnedCodesRequestAmino { + const obj: any = {}; + obj.pagination = message.pagination ? PageRequest.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryPinnedCodesRequestAminoMsg): QueryPinnedCodesRequest { + return QueryPinnedCodesRequest.fromAmino(object.value); + }, + toAminoMsg(message: QueryPinnedCodesRequest): QueryPinnedCodesRequestAminoMsg { + return { + type: "wasm/QueryPinnedCodesRequest", + value: QueryPinnedCodesRequest.toAmino(message) + }; + }, + fromProtoMsg(message: QueryPinnedCodesRequestProtoMsg): QueryPinnedCodesRequest { + return QueryPinnedCodesRequest.decode(message.value); + }, + toProto(message: QueryPinnedCodesRequest): Uint8Array { + return QueryPinnedCodesRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryPinnedCodesRequest): QueryPinnedCodesRequestProtoMsg { + return { + typeUrl: "/cosmwasm.wasm.v1.QueryPinnedCodesRequest", + value: QueryPinnedCodesRequest.encode(message).finish() + }; + } +}; +function createBaseQueryPinnedCodesResponse(): QueryPinnedCodesResponse { + return { + codeIds: [], + pagination: undefined + }; +} +export const QueryPinnedCodesResponse = { + typeUrl: "/cosmwasm.wasm.v1.QueryPinnedCodesResponse", + encode(message: QueryPinnedCodesResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + writer.uint32(10).fork(); + for (const v of message.codeIds) { + writer.uint64(v); + } + writer.ldelim(); + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryPinnedCodesResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryPinnedCodesResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.codeIds.push(reader.uint64()); + } + } else { + message.codeIds.push(reader.uint64()); + } + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryPinnedCodesResponse { + const obj = createBaseQueryPinnedCodesResponse(); + if (Array.isArray(object?.codeIds)) obj.codeIds = object.codeIds.map((e: any) => BigInt(e.toString())); + if (isSet(object.pagination)) obj.pagination = PageResponse.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryPinnedCodesResponse): JsonSafe { + const obj: any = {}; + if (message.codeIds) { + obj.codeIds = message.codeIds.map(e => (e || BigInt(0)).toString()); + } else { + obj.codeIds = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryPinnedCodesResponse { + const message = createBaseQueryPinnedCodesResponse(); + message.codeIds = object.codeIds?.map(e => BigInt(e.toString())) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryPinnedCodesResponseSDKType): QueryPinnedCodesResponse { + return { + codeIds: Array.isArray(object?.code_ids) ? object.code_ids.map((e: any) => e) : [], + pagination: object.pagination ? PageResponse.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryPinnedCodesResponseSDKType { + return { + code_ids: Array.isArray(object?.code_ids) ? object.code_ids.map((e: any) => BigInt(e.toString())) : [], + pagination: isSet(object.pagination) ? PageResponse.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryPinnedCodesResponse): QueryPinnedCodesResponseSDKType { + const obj: any = {}; + if (message.codeIds) { + obj.code_ids = message.codeIds.map(e => e); + } else { + obj.code_ids = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryPinnedCodesResponseAmino): QueryPinnedCodesResponse { + const message = createBaseQueryPinnedCodesResponse(); + message.codeIds = object.code_ids?.map(e => BigInt(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryPinnedCodesResponse): QueryPinnedCodesResponseAmino { + const obj: any = {}; + if (message.codeIds) { + obj.code_ids = message.codeIds.map(e => e.toString()); + } else { + obj.code_ids = message.codeIds; + } + obj.pagination = message.pagination ? PageResponse.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryPinnedCodesResponseAminoMsg): QueryPinnedCodesResponse { + return QueryPinnedCodesResponse.fromAmino(object.value); + }, + toAminoMsg(message: QueryPinnedCodesResponse): QueryPinnedCodesResponseAminoMsg { + return { + type: "wasm/QueryPinnedCodesResponse", + value: QueryPinnedCodesResponse.toAmino(message) + }; + }, + fromProtoMsg(message: QueryPinnedCodesResponseProtoMsg): QueryPinnedCodesResponse { + return QueryPinnedCodesResponse.decode(message.value); + }, + toProto(message: QueryPinnedCodesResponse): Uint8Array { + return QueryPinnedCodesResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryPinnedCodesResponse): QueryPinnedCodesResponseProtoMsg { + return { + typeUrl: "/cosmwasm.wasm.v1.QueryPinnedCodesResponse", + value: QueryPinnedCodesResponse.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmwasm/wasm/v1/tx.amino.ts b/__fixtures__/v-next/outputicjsdeps/cosmwasm/wasm/v1/tx.amino.ts new file mode 100644 index 0000000000..075070f038 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmwasm/wasm/v1/tx.amino.ts @@ -0,0 +1,252 @@ +import { AccessConfig, AccessConfigSDKType, accessTypeFromJSON } from "./types.js"; +import { Coin, CoinSDKType } from "../../../cosmos/base/v1beta1/coin.js"; +import { ReadOnlyAminoMsg as AminoMsg } from "@interchainjs/ReadOnlyAminoMsg"; +import { toBase64, fromBase64, fromUtf8, toUtf8 } from "@cosmjs/encoding"; +import { MsgStoreCode, MsgStoreCodeSDKType, MsgInstantiateContract, MsgInstantiateContractSDKType, MsgExecuteContract, MsgExecuteContractSDKType, MsgMigrateContract, MsgMigrateContractSDKType, MsgUpdateAdmin, MsgUpdateAdminSDKType, MsgClearAdmin, MsgClearAdminSDKType } from "./tx.js"; +export interface MsgStoreCodeAminoType extends AminoMsg { + type: "wasm/MsgStoreCode"; + value: { + sender: string; + wasm_byte_code: string; + instantiate_permission: { + permission: number; + address: string; + }; + }; +} +export interface MsgInstantiateContractAminoType extends AminoMsg { + type: "wasm/MsgInstantiateContract"; + value: { + sender: string; + admin: string; + code_id: string; + label: string; + msg: Uint8Array; + funds: { + denom: string; + amount: string; + }[]; + }; +} +export interface MsgExecuteContractAminoType extends AminoMsg { + type: "wasm/MsgExecuteContract"; + value: { + sender: string; + contract: string; + msg: Uint8Array; + funds: { + denom: string; + amount: string; + }[]; + }; +} +export interface MsgMigrateContractAminoType extends AminoMsg { + type: "wasm/MsgMigrateContract"; + value: { + sender: string; + contract: string; + code_id: string; + msg: Uint8Array; + }; +} +export interface MsgUpdateAdminAminoType extends AminoMsg { + type: "wasm/MsgUpdateAdmin"; + value: { + sender: string; + new_admin: string; + contract: string; + }; +} +export interface MsgClearAdminAminoType extends AminoMsg { + type: "wasm/MsgClearAdmin"; + value: { + sender: string; + contract: string; + }; +} +export const AminoConverter = { + "/cosmwasm.wasm.v1.MsgStoreCode": { + aminoType: "wasm/MsgStoreCode", + toAmino: ({ + sender, + wasmByteCode, + instantiatePermission + }: MsgStoreCode): MsgStoreCodeAminoType["value"] => { + return { + sender, + wasm_byte_code: toBase64(wasmByteCode), + instantiate_permission: { + permission: instantiatePermission.permission, + address: instantiatePermission.address + } + }; + }, + fromAmino: ({ + sender, + wasm_byte_code, + instantiate_permission + }: MsgStoreCodeAminoType["value"]): MsgStoreCode => { + return { + sender, + wasmByteCode: fromBase64(wasm_byte_code), + instantiatePermission: { + permission: accessTypeFromJSON(instantiate_permission.permission), + address: instantiate_permission.address + } + }; + } + }, + "/cosmwasm.wasm.v1.MsgInstantiateContract": { + aminoType: "wasm/MsgInstantiateContract", + toAmino: ({ + sender, + admin, + codeId, + label, + msg, + funds + }: MsgInstantiateContract): MsgInstantiateContractAminoType["value"] => { + return { + sender, + admin, + code_id: codeId.toString(), + label, + msg: JSON.parse(fromUtf8(msg)), + funds: funds.map(el0 => ({ + denom: el0.denom, + amount: el0.amount + })) + }; + }, + fromAmino: ({ + sender, + admin, + code_id, + label, + msg, + funds + }: MsgInstantiateContractAminoType["value"]): MsgInstantiateContract => { + return { + sender, + admin, + codeId: BigInt(code_id), + label, + msg: toUtf8(JSON.stringify(msg)), + funds: funds.map(el0 => ({ + denom: el0.denom, + amount: el0.amount + })) + }; + } + }, + "/cosmwasm.wasm.v1.MsgExecuteContract": { + aminoType: "wasm/MsgExecuteContract", + toAmino: ({ + sender, + contract, + msg, + funds + }: MsgExecuteContract): MsgExecuteContractAminoType["value"] => { + return { + sender, + contract, + msg: JSON.parse(fromUtf8(msg)), + funds: funds.map(el0 => ({ + denom: el0.denom, + amount: el0.amount + })) + }; + }, + fromAmino: ({ + sender, + contract, + msg, + funds + }: MsgExecuteContractAminoType["value"]): MsgExecuteContract => { + return { + sender, + contract, + msg: toUtf8(JSON.stringify(msg)), + funds: funds.map(el0 => ({ + denom: el0.denom, + amount: el0.amount + })) + }; + } + }, + "/cosmwasm.wasm.v1.MsgMigrateContract": { + aminoType: "wasm/MsgMigrateContract", + toAmino: ({ + sender, + contract, + codeId, + msg + }: MsgMigrateContract): MsgMigrateContractAminoType["value"] => { + return { + sender, + contract, + code_id: codeId.toString(), + msg: JSON.parse(fromUtf8(msg)) + }; + }, + fromAmino: ({ + sender, + contract, + code_id, + msg + }: MsgMigrateContractAminoType["value"]): MsgMigrateContract => { + return { + sender, + contract, + codeId: BigInt(code_id), + msg: toUtf8(JSON.stringify(msg)) + }; + } + }, + "/cosmwasm.wasm.v1.MsgUpdateAdmin": { + aminoType: "wasm/MsgUpdateAdmin", + toAmino: ({ + sender, + newAdmin, + contract + }: MsgUpdateAdmin): MsgUpdateAdminAminoType["value"] => { + return { + sender, + new_admin: newAdmin, + contract + }; + }, + fromAmino: ({ + sender, + new_admin, + contract + }: MsgUpdateAdminAminoType["value"]): MsgUpdateAdmin => { + return { + sender, + newAdmin: new_admin, + contract + }; + } + }, + "/cosmwasm.wasm.v1.MsgClearAdmin": { + aminoType: "wasm/MsgClearAdmin", + toAmino: ({ + sender, + contract + }: MsgClearAdmin): MsgClearAdminAminoType["value"] => { + return { + sender, + contract + }; + }, + fromAmino: ({ + sender, + contract + }: MsgClearAdminAminoType["value"]): MsgClearAdmin => { + return { + sender, + contract + }; + } + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmwasm/wasm/v1/tx.registry.ts b/__fixtures__/v-next/outputicjsdeps/cosmwasm/wasm/v1/tx.registry.ts new file mode 100644 index 0000000000..894e6816c5 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmwasm/wasm/v1/tx.registry.ts @@ -0,0 +1,202 @@ +import { AccessConfig, AccessConfigSDKType } from "./types.js"; +import { Coin, CoinSDKType } from "../../../cosmos/base/v1beta1/coin.js"; +import { GeneratedType, Registry } from "@cosmjs/proto-signing"; +import { MsgStoreCode, MsgStoreCodeSDKType, MsgInstantiateContract, MsgInstantiateContractSDKType, MsgExecuteContract, MsgExecuteContractSDKType, MsgMigrateContract, MsgMigrateContractSDKType, MsgUpdateAdmin, MsgUpdateAdminSDKType, MsgClearAdmin, MsgClearAdminSDKType } from "./tx.js"; +export const registry: ReadonlyArray<[string, GeneratedType]> = [["/cosmwasm.wasm.v1.MsgStoreCode", MsgStoreCode], ["/cosmwasm.wasm.v1.MsgInstantiateContract", MsgInstantiateContract], ["/cosmwasm.wasm.v1.MsgExecuteContract", MsgExecuteContract], ["/cosmwasm.wasm.v1.MsgMigrateContract", MsgMigrateContract], ["/cosmwasm.wasm.v1.MsgUpdateAdmin", MsgUpdateAdmin], ["/cosmwasm.wasm.v1.MsgClearAdmin", MsgClearAdmin]]; +export const load = (protoRegistry: Registry) => { + registry.forEach(([typeUrl, mod]) => { + protoRegistry.register(typeUrl, mod); + }); +}; +export const MessageComposer = { + encoded: { + storeCode(value: MsgStoreCode) { + return { + typeUrl: "/cosmwasm.wasm.v1.MsgStoreCode", + value: MsgStoreCode.encode(value).finish() + }; + }, + instantiateContract(value: MsgInstantiateContract) { + return { + typeUrl: "/cosmwasm.wasm.v1.MsgInstantiateContract", + value: MsgInstantiateContract.encode(value).finish() + }; + }, + executeContract(value: MsgExecuteContract) { + return { + typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract", + value: MsgExecuteContract.encode(value).finish() + }; + }, + migrateContract(value: MsgMigrateContract) { + return { + typeUrl: "/cosmwasm.wasm.v1.MsgMigrateContract", + value: MsgMigrateContract.encode(value).finish() + }; + }, + updateAdmin(value: MsgUpdateAdmin) { + return { + typeUrl: "/cosmwasm.wasm.v1.MsgUpdateAdmin", + value: MsgUpdateAdmin.encode(value).finish() + }; + }, + clearAdmin(value: MsgClearAdmin) { + return { + typeUrl: "/cosmwasm.wasm.v1.MsgClearAdmin", + value: MsgClearAdmin.encode(value).finish() + }; + } + }, + withTypeUrl: { + storeCode(value: MsgStoreCode) { + return { + typeUrl: "/cosmwasm.wasm.v1.MsgStoreCode", + value + }; + }, + instantiateContract(value: MsgInstantiateContract) { + return { + typeUrl: "/cosmwasm.wasm.v1.MsgInstantiateContract", + value + }; + }, + executeContract(value: MsgExecuteContract) { + return { + typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract", + value + }; + }, + migrateContract(value: MsgMigrateContract) { + return { + typeUrl: "/cosmwasm.wasm.v1.MsgMigrateContract", + value + }; + }, + updateAdmin(value: MsgUpdateAdmin) { + return { + typeUrl: "/cosmwasm.wasm.v1.MsgUpdateAdmin", + value + }; + }, + clearAdmin(value: MsgClearAdmin) { + return { + typeUrl: "/cosmwasm.wasm.v1.MsgClearAdmin", + value + }; + } + }, + toJSON: { + storeCode(value: MsgStoreCode) { + return { + typeUrl: "/cosmwasm.wasm.v1.MsgStoreCode", + value: MsgStoreCode.toJSON(value) + }; + }, + instantiateContract(value: MsgInstantiateContract) { + return { + typeUrl: "/cosmwasm.wasm.v1.MsgInstantiateContract", + value: MsgInstantiateContract.toJSON(value) + }; + }, + executeContract(value: MsgExecuteContract) { + return { + typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract", + value: MsgExecuteContract.toJSON(value) + }; + }, + migrateContract(value: MsgMigrateContract) { + return { + typeUrl: "/cosmwasm.wasm.v1.MsgMigrateContract", + value: MsgMigrateContract.toJSON(value) + }; + }, + updateAdmin(value: MsgUpdateAdmin) { + return { + typeUrl: "/cosmwasm.wasm.v1.MsgUpdateAdmin", + value: MsgUpdateAdmin.toJSON(value) + }; + }, + clearAdmin(value: MsgClearAdmin) { + return { + typeUrl: "/cosmwasm.wasm.v1.MsgClearAdmin", + value: MsgClearAdmin.toJSON(value) + }; + } + }, + fromJSON: { + storeCode(value: any) { + return { + typeUrl: "/cosmwasm.wasm.v1.MsgStoreCode", + value: MsgStoreCode.fromJSON(value) + }; + }, + instantiateContract(value: any) { + return { + typeUrl: "/cosmwasm.wasm.v1.MsgInstantiateContract", + value: MsgInstantiateContract.fromJSON(value) + }; + }, + executeContract(value: any) { + return { + typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract", + value: MsgExecuteContract.fromJSON(value) + }; + }, + migrateContract(value: any) { + return { + typeUrl: "/cosmwasm.wasm.v1.MsgMigrateContract", + value: MsgMigrateContract.fromJSON(value) + }; + }, + updateAdmin(value: any) { + return { + typeUrl: "/cosmwasm.wasm.v1.MsgUpdateAdmin", + value: MsgUpdateAdmin.fromJSON(value) + }; + }, + clearAdmin(value: any) { + return { + typeUrl: "/cosmwasm.wasm.v1.MsgClearAdmin", + value: MsgClearAdmin.fromJSON(value) + }; + } + }, + fromPartial: { + storeCode(value: MsgStoreCode) { + return { + typeUrl: "/cosmwasm.wasm.v1.MsgStoreCode", + value: MsgStoreCode.fromPartial(value) + }; + }, + instantiateContract(value: MsgInstantiateContract) { + return { + typeUrl: "/cosmwasm.wasm.v1.MsgInstantiateContract", + value: MsgInstantiateContract.fromPartial(value) + }; + }, + executeContract(value: MsgExecuteContract) { + return { + typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract", + value: MsgExecuteContract.fromPartial(value) + }; + }, + migrateContract(value: MsgMigrateContract) { + return { + typeUrl: "/cosmwasm.wasm.v1.MsgMigrateContract", + value: MsgMigrateContract.fromPartial(value) + }; + }, + updateAdmin(value: MsgUpdateAdmin) { + return { + typeUrl: "/cosmwasm.wasm.v1.MsgUpdateAdmin", + value: MsgUpdateAdmin.fromPartial(value) + }; + }, + clearAdmin(value: MsgClearAdmin) { + return { + typeUrl: "/cosmwasm.wasm.v1.MsgClearAdmin", + value: MsgClearAdmin.fromPartial(value) + }; + } + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmwasm/wasm/v1/tx.rpc.func.ts b/__fixtures__/v-next/outputicjsdeps/cosmwasm/wasm/v1/tx.rpc.func.ts new file mode 100644 index 0000000000..caf34c57db --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmwasm/wasm/v1/tx.rpc.func.ts @@ -0,0 +1,58 @@ +import { buildTx, SigningClientResolver } from "../../../helper-func-types"; +import { buildUseMutation } from "../../../react-query"; +import { toEncoders, toConverters } from "@interchainjs/cosmos/utils"; +import { MsgStoreCode, MsgInstantiateContract, MsgExecuteContract, MsgMigrateContract, MsgUpdateAdmin, MsgClearAdmin } from "./tx"; +export const createStoreCode = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgStoreCode.typeUrl, + encoders: toEncoders(MsgStoreCode), + converters: toConverters(MsgStoreCode) +}); +export const useStoreCode = buildUseMutation({ + builderMutationFn: createStoreCode +}); +export const createInstantiateContract = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgInstantiateContract.typeUrl, + encoders: toEncoders(MsgInstantiateContract), + converters: toConverters(MsgInstantiateContract) +}); +export const useInstantiateContract = buildUseMutation({ + builderMutationFn: createInstantiateContract +}); +export const createExecuteContract = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgExecuteContract.typeUrl, + encoders: toEncoders(MsgExecuteContract), + converters: toConverters(MsgExecuteContract) +}); +export const useExecuteContract = buildUseMutation({ + builderMutationFn: createExecuteContract +}); +export const createMigrateContract = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgMigrateContract.typeUrl, + encoders: toEncoders(MsgMigrateContract), + converters: toConverters(MsgMigrateContract) +}); +export const useMigrateContract = buildUseMutation({ + builderMutationFn: createMigrateContract +}); +export const createUpdateAdmin = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgUpdateAdmin.typeUrl, + encoders: toEncoders(MsgUpdateAdmin), + converters: toConverters(MsgUpdateAdmin) +}); +export const useUpdateAdmin = buildUseMutation({ + builderMutationFn: createUpdateAdmin +}); +export const createClearAdmin = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgClearAdmin.typeUrl, + encoders: toEncoders(MsgClearAdmin), + converters: toConverters(MsgClearAdmin) +}); +export const useClearAdmin = buildUseMutation({ + builderMutationFn: createClearAdmin +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmwasm/wasm/v1/tx.rpc.msg.ts b/__fixtures__/v-next/outputicjsdeps/cosmwasm/wasm/v1/tx.rpc.msg.ts new file mode 100644 index 0000000000..e38afee945 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmwasm/wasm/v1/tx.rpc.msg.ts @@ -0,0 +1,65 @@ +import { AccessConfig, AccessConfigSDKType } from "./types.js"; +import { Coin, CoinSDKType } from "../../../cosmos/base/v1beta1/coin.js"; +import { Rpc } from "../../../helpers.js"; +import { BinaryReader } from "../../../binary.js"; +import { MsgStoreCode, MsgStoreCodeSDKType, MsgStoreCodeResponse, MsgStoreCodeResponseSDKType, MsgInstantiateContract, MsgInstantiateContractSDKType, MsgInstantiateContractResponse, MsgInstantiateContractResponseSDKType, MsgExecuteContract, MsgExecuteContractSDKType, MsgExecuteContractResponse, MsgExecuteContractResponseSDKType, MsgMigrateContract, MsgMigrateContractSDKType, MsgMigrateContractResponse, MsgMigrateContractResponseSDKType, MsgUpdateAdmin, MsgUpdateAdminSDKType, MsgUpdateAdminResponse, MsgUpdateAdminResponseSDKType, MsgClearAdmin, MsgClearAdminSDKType, MsgClearAdminResponse, MsgClearAdminResponseSDKType } from "./tx.js"; +/** Msg defines the wasm Msg service. */ +export interface Msg { + /** StoreCode to submit Wasm code to the system */ + storeCode(request: MsgStoreCode): Promise; + /** Instantiate creates a new smart contract instance for the given code id. */ + instantiateContract(request: MsgInstantiateContract): Promise; + /** Execute submits the given message data to a smart contract */ + executeContract(request: MsgExecuteContract): Promise; + /** Migrate runs a code upgrade/ downgrade for a smart contract */ + migrateContract(request: MsgMigrateContract): Promise; + /** UpdateAdmin sets a new admin for a smart contract */ + updateAdmin(request: MsgUpdateAdmin): Promise; + /** ClearAdmin removes any admin stored for a smart contract */ + clearAdmin(request: MsgClearAdmin): Promise; +} +export class MsgClientImpl implements Msg { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + this.storeCode = this.storeCode.bind(this); + this.instantiateContract = this.instantiateContract.bind(this); + this.executeContract = this.executeContract.bind(this); + this.migrateContract = this.migrateContract.bind(this); + this.updateAdmin = this.updateAdmin.bind(this); + this.clearAdmin = this.clearAdmin.bind(this); + } + storeCode(request: MsgStoreCode): Promise { + const data = MsgStoreCode.encode(request).finish(); + const promise = this.rpc.request("cosmwasm.wasm.v1.Msg", "StoreCode", data); + return promise.then(data => MsgStoreCodeResponse.decode(new BinaryReader(data))); + } + instantiateContract(request: MsgInstantiateContract): Promise { + const data = MsgInstantiateContract.encode(request).finish(); + const promise = this.rpc.request("cosmwasm.wasm.v1.Msg", "InstantiateContract", data); + return promise.then(data => MsgInstantiateContractResponse.decode(new BinaryReader(data))); + } + executeContract(request: MsgExecuteContract): Promise { + const data = MsgExecuteContract.encode(request).finish(); + const promise = this.rpc.request("cosmwasm.wasm.v1.Msg", "ExecuteContract", data); + return promise.then(data => MsgExecuteContractResponse.decode(new BinaryReader(data))); + } + migrateContract(request: MsgMigrateContract): Promise { + const data = MsgMigrateContract.encode(request).finish(); + const promise = this.rpc.request("cosmwasm.wasm.v1.Msg", "MigrateContract", data); + return promise.then(data => MsgMigrateContractResponse.decode(new BinaryReader(data))); + } + updateAdmin(request: MsgUpdateAdmin): Promise { + const data = MsgUpdateAdmin.encode(request).finish(); + const promise = this.rpc.request("cosmwasm.wasm.v1.Msg", "UpdateAdmin", data); + return promise.then(data => MsgUpdateAdminResponse.decode(new BinaryReader(data))); + } + clearAdmin(request: MsgClearAdmin): Promise { + const data = MsgClearAdmin.encode(request).finish(); + const promise = this.rpc.request("cosmwasm.wasm.v1.Msg", "ClearAdmin", data); + return promise.then(data => MsgClearAdminResponse.decode(new BinaryReader(data))); + } +} +export const createClientImpl = (rpc: Rpc) => { + return new MsgClientImpl(rpc); +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmwasm/wasm/v1/tx.ts b/__fixtures__/v-next/outputicjsdeps/cosmwasm/wasm/v1/tx.ts new file mode 100644 index 0000000000..6561ef6f9f --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmwasm/wasm/v1/tx.ts @@ -0,0 +1,1621 @@ +import { AccessConfig, AccessConfigSDKType } from "./types.js"; +import { Coin, CoinSDKType } from "../../../cosmos/base/v1beta1/coin.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, bytesFromBase64, base64FromBytes, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +import { fromBase64, toBase64, toUtf8, fromUtf8 } from "@cosmjs/encoding"; +export const protobufPackage = "cosmwasm.wasm.v1"; +/** MsgStoreCode submit Wasm code to the system */ +export interface MsgStoreCode { + /** Sender is the that actor that signed the messages */ + sender: string; + /** WASMByteCode can be raw or gzip compressed */ + wasmByteCode: Uint8Array; + /** + * InstantiatePermission access control to apply on contract creation, + * optional + */ + instantiatePermission?: AccessConfig; +} +export interface MsgStoreCodeProtoMsg { + typeUrl: "/cosmwasm.wasm.v1.MsgStoreCode"; + value: Uint8Array; +} +/** MsgStoreCode submit Wasm code to the system */ +export interface MsgStoreCodeSDKType { + sender: string; + wasm_byte_code: Uint8Array; + instantiate_permission?: AccessConfigSDKType; +} +/** MsgStoreCodeResponse returns store result data. */ +export interface MsgStoreCodeResponse { + /** CodeID is the reference to the stored WASM code */ + codeId: bigint; +} +export interface MsgStoreCodeResponseProtoMsg { + typeUrl: "/cosmwasm.wasm.v1.MsgStoreCodeResponse"; + value: Uint8Array; +} +/** MsgStoreCodeResponse returns store result data. */ +export interface MsgStoreCodeResponseSDKType { + code_id: bigint; +} +/** + * MsgInstantiateContract create a new smart contract instance for the given + * code id. + */ +export interface MsgInstantiateContract { + /** Sender is the that actor that signed the messages */ + sender: string; + /** Admin is an optional address that can execute migrations */ + admin: string; + /** CodeID is the reference to the stored WASM code */ + codeId: bigint; + /** Label is optional metadata to be stored with a contract instance. */ + label: string; + /** Msg json encoded message to be passed to the contract on instantiation */ + msg: Uint8Array; + /** Funds coins that are transferred to the contract on instantiation */ + funds: Coin[]; +} +export interface MsgInstantiateContractProtoMsg { + typeUrl: "/cosmwasm.wasm.v1.MsgInstantiateContract"; + value: Uint8Array; +} +/** + * MsgInstantiateContract create a new smart contract instance for the given + * code id. + */ +export interface MsgInstantiateContractSDKType { + sender: string; + admin: string; + code_id: bigint; + label: string; + msg: Uint8Array; + funds: CoinSDKType[]; +} +/** MsgInstantiateContractResponse return instantiation result data */ +export interface MsgInstantiateContractResponse { + /** Address is the bech32 address of the new contract instance. */ + address: string; + /** Data contains base64-encoded bytes to returned from the contract */ + data: Uint8Array; +} +export interface MsgInstantiateContractResponseProtoMsg { + typeUrl: "/cosmwasm.wasm.v1.MsgInstantiateContractResponse"; + value: Uint8Array; +} +/** MsgInstantiateContractResponse return instantiation result data */ +export interface MsgInstantiateContractResponseSDKType { + address: string; + data: Uint8Array; +} +/** MsgExecuteContract submits the given message data to a smart contract */ +export interface MsgExecuteContract { + /** Sender is the that actor that signed the messages */ + sender: string; + /** Contract is the address of the smart contract */ + contract: string; + /** Msg json encoded message to be passed to the contract */ + msg: Uint8Array; + /** Funds coins that are transferred to the contract on execution */ + funds: Coin[]; +} +export interface MsgExecuteContractProtoMsg { + typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract"; + value: Uint8Array; +} +/** MsgExecuteContract submits the given message data to a smart contract */ +export interface MsgExecuteContractSDKType { + sender: string; + contract: string; + msg: Uint8Array; + funds: CoinSDKType[]; +} +/** MsgExecuteContractResponse returns execution result data. */ +export interface MsgExecuteContractResponse { + /** Data contains base64-encoded bytes to returned from the contract */ + data: Uint8Array; +} +export interface MsgExecuteContractResponseProtoMsg { + typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContractResponse"; + value: Uint8Array; +} +/** MsgExecuteContractResponse returns execution result data. */ +export interface MsgExecuteContractResponseSDKType { + data: Uint8Array; +} +/** MsgMigrateContract runs a code upgrade/ downgrade for a smart contract */ +export interface MsgMigrateContract { + /** Sender is the that actor that signed the messages */ + sender: string; + /** Contract is the address of the smart contract */ + contract: string; + /** CodeID references the new WASM code */ + codeId: bigint; + /** Msg json encoded message to be passed to the contract on migration */ + msg: Uint8Array; +} +export interface MsgMigrateContractProtoMsg { + typeUrl: "/cosmwasm.wasm.v1.MsgMigrateContract"; + value: Uint8Array; +} +/** MsgMigrateContract runs a code upgrade/ downgrade for a smart contract */ +export interface MsgMigrateContractSDKType { + sender: string; + contract: string; + code_id: bigint; + msg: Uint8Array; +} +/** MsgMigrateContractResponse returns contract migration result data. */ +export interface MsgMigrateContractResponse { + /** + * Data contains same raw bytes returned as data from the wasm contract. + * (May be empty) + */ + data: Uint8Array; +} +export interface MsgMigrateContractResponseProtoMsg { + typeUrl: "/cosmwasm.wasm.v1.MsgMigrateContractResponse"; + value: Uint8Array; +} +/** MsgMigrateContractResponse returns contract migration result data. */ +export interface MsgMigrateContractResponseSDKType { + data: Uint8Array; +} +/** MsgUpdateAdmin sets a new admin for a smart contract */ +export interface MsgUpdateAdmin { + /** Sender is the that actor that signed the messages */ + sender: string; + /** NewAdmin address to be set */ + newAdmin: string; + /** Contract is the address of the smart contract */ + contract: string; +} +export interface MsgUpdateAdminProtoMsg { + typeUrl: "/cosmwasm.wasm.v1.MsgUpdateAdmin"; + value: Uint8Array; +} +/** MsgUpdateAdmin sets a new admin for a smart contract */ +export interface MsgUpdateAdminSDKType { + sender: string; + new_admin: string; + contract: string; +} +/** MsgUpdateAdminResponse returns empty data */ +export interface MsgUpdateAdminResponse {} +export interface MsgUpdateAdminResponseProtoMsg { + typeUrl: "/cosmwasm.wasm.v1.MsgUpdateAdminResponse"; + value: Uint8Array; +} +/** MsgUpdateAdminResponse returns empty data */ +export interface MsgUpdateAdminResponseSDKType {} +/** MsgClearAdmin removes any admin stored for a smart contract */ +export interface MsgClearAdmin { + /** Sender is the that actor that signed the messages */ + sender: string; + /** Contract is the address of the smart contract */ + contract: string; +} +export interface MsgClearAdminProtoMsg { + typeUrl: "/cosmwasm.wasm.v1.MsgClearAdmin"; + value: Uint8Array; +} +/** MsgClearAdmin removes any admin stored for a smart contract */ +export interface MsgClearAdminSDKType { + sender: string; + contract: string; +} +/** MsgClearAdminResponse returns empty data */ +export interface MsgClearAdminResponse {} +export interface MsgClearAdminResponseProtoMsg { + typeUrl: "/cosmwasm.wasm.v1.MsgClearAdminResponse"; + value: Uint8Array; +} +/** MsgClearAdminResponse returns empty data */ +export interface MsgClearAdminResponseSDKType {} +function createBaseMsgStoreCode(): MsgStoreCode { + return { + sender: "", + wasmByteCode: new Uint8Array(), + instantiatePermission: undefined + }; +} +export const MsgStoreCode = { + typeUrl: "/cosmwasm.wasm.v1.MsgStoreCode", + encode(message: MsgStoreCode, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.sender !== undefined) { + writer.uint32(10).string(message.sender); + } + if (message.wasmByteCode.length !== 0) { + writer.uint32(18).bytes(message.wasmByteCode); + } + if (message.instantiatePermission !== undefined) { + AccessConfig.encode(message.instantiatePermission, writer.uint32(42).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgStoreCode { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgStoreCode(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.sender = reader.string(); + break; + case 2: + message.wasmByteCode = reader.bytes(); + break; + case 5: + message.instantiatePermission = AccessConfig.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgStoreCode { + const obj = createBaseMsgStoreCode(); + if (isSet(object.sender)) obj.sender = String(object.sender); + if (isSet(object.wasmByteCode)) obj.wasmByteCode = bytesFromBase64(object.wasmByteCode); + if (isSet(object.instantiatePermission)) obj.instantiatePermission = AccessConfig.fromJSON(object.instantiatePermission); + return obj; + }, + toJSON(message: MsgStoreCode): JsonSafe { + const obj: any = {}; + message.sender !== undefined && (obj.sender = message.sender); + message.wasmByteCode !== undefined && (obj.wasmByteCode = base64FromBytes(message.wasmByteCode !== undefined ? message.wasmByteCode : new Uint8Array())); + message.instantiatePermission !== undefined && (obj.instantiatePermission = message.instantiatePermission ? AccessConfig.toJSON(message.instantiatePermission) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): MsgStoreCode { + const message = createBaseMsgStoreCode(); + message.sender = object.sender ?? ""; + message.wasmByteCode = object.wasmByteCode ?? new Uint8Array(); + if (object.instantiatePermission !== undefined && object.instantiatePermission !== null) { + message.instantiatePermission = AccessConfig.fromPartial(object.instantiatePermission); + } + return message; + }, + fromSDK(object: MsgStoreCodeSDKType): MsgStoreCode { + return { + sender: object?.sender, + wasmByteCode: object?.wasm_byte_code, + instantiatePermission: object.instantiate_permission ? AccessConfig.fromSDK(object.instantiate_permission) : undefined + }; + }, + fromSDKJSON(object: any): MsgStoreCodeSDKType { + return { + sender: isSet(object.sender) ? String(object.sender) : "", + wasm_byte_code: isSet(object.wasm_byte_code) ? bytesFromBase64(object.wasm_byte_code) : new Uint8Array(), + instantiate_permission: isSet(object.instantiate_permission) ? AccessConfig.fromSDKJSON(object.instantiate_permission) : undefined + }; + }, + toSDK(message: MsgStoreCode): MsgStoreCodeSDKType { + const obj: any = {}; + obj.sender = message.sender; + obj.wasm_byte_code = message.wasmByteCode; + message.instantiatePermission !== undefined && (obj.instantiate_permission = message.instantiatePermission ? AccessConfig.toSDK(message.instantiatePermission) : undefined); + return obj; + }, + fromAmino(object: MsgStoreCodeAmino): MsgStoreCode { + const message = createBaseMsgStoreCode(); + if (object.sender !== undefined && object.sender !== null) { + message.sender = object.sender; + } + if (object.wasm_byte_code !== undefined && object.wasm_byte_code !== null) { + message.wasmByteCode = fromBase64(object.wasm_byte_code); + } + if (object.instantiate_permission !== undefined && object.instantiate_permission !== null) { + message.instantiatePermission = AccessConfig.fromAmino(object.instantiate_permission); + } + return message; + }, + toAmino(message: MsgStoreCode): MsgStoreCodeAmino { + const obj: any = {}; + obj.sender = message.sender === "" ? undefined : message.sender; + obj.wasm_byte_code = message.wasmByteCode ? toBase64(message.wasmByteCode) : undefined; + obj.instantiate_permission = message.instantiatePermission ? AccessConfig.toAmino(message.instantiatePermission) : undefined; + return obj; + }, + fromAminoMsg(object: MsgStoreCodeAminoMsg): MsgStoreCode { + return MsgStoreCode.fromAmino(object.value); + }, + toAminoMsg(message: MsgStoreCode): MsgStoreCodeAminoMsg { + return { + type: "wasm/MsgStoreCode", + value: MsgStoreCode.toAmino(message) + }; + }, + fromProtoMsg(message: MsgStoreCodeProtoMsg): MsgStoreCode { + return MsgStoreCode.decode(message.value); + }, + toProto(message: MsgStoreCode): Uint8Array { + return MsgStoreCode.encode(message).finish(); + }, + toProtoMsg(message: MsgStoreCode): MsgStoreCodeProtoMsg { + return { + typeUrl: "/cosmwasm.wasm.v1.MsgStoreCode", + value: MsgStoreCode.encode(message).finish() + }; + } +}; +function createBaseMsgStoreCodeResponse(): MsgStoreCodeResponse { + return { + codeId: BigInt(0) + }; +} +export const MsgStoreCodeResponse = { + typeUrl: "/cosmwasm.wasm.v1.MsgStoreCodeResponse", + encode(message: MsgStoreCodeResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.codeId !== undefined) { + writer.uint32(8).uint64(message.codeId); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgStoreCodeResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgStoreCodeResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.codeId = reader.uint64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgStoreCodeResponse { + const obj = createBaseMsgStoreCodeResponse(); + if (isSet(object.codeId)) obj.codeId = BigInt(object.codeId.toString()); + return obj; + }, + toJSON(message: MsgStoreCodeResponse): JsonSafe { + const obj: any = {}; + message.codeId !== undefined && (obj.codeId = (message.codeId || BigInt(0)).toString()); + return obj; + }, + fromPartial(object: DeepPartial): MsgStoreCodeResponse { + const message = createBaseMsgStoreCodeResponse(); + if (object.codeId !== undefined && object.codeId !== null) { + message.codeId = BigInt(object.codeId.toString()); + } + return message; + }, + fromSDK(object: MsgStoreCodeResponseSDKType): MsgStoreCodeResponse { + return { + codeId: object?.code_id + }; + }, + fromSDKJSON(object: any): MsgStoreCodeResponseSDKType { + return { + code_id: isSet(object.code_id) ? BigInt(object.code_id.toString()) : BigInt(0) + }; + }, + toSDK(message: MsgStoreCodeResponse): MsgStoreCodeResponseSDKType { + const obj: any = {}; + obj.code_id = message.codeId; + return obj; + }, + fromAmino(object: MsgStoreCodeResponseAmino): MsgStoreCodeResponse { + const message = createBaseMsgStoreCodeResponse(); + if (object.code_id !== undefined && object.code_id !== null) { + message.codeId = BigInt(object.code_id); + } + return message; + }, + toAmino(message: MsgStoreCodeResponse): MsgStoreCodeResponseAmino { + const obj: any = {}; + obj.code_id = message.codeId !== BigInt(0) ? message.codeId?.toString() : undefined; + return obj; + }, + fromAminoMsg(object: MsgStoreCodeResponseAminoMsg): MsgStoreCodeResponse { + return MsgStoreCodeResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgStoreCodeResponse): MsgStoreCodeResponseAminoMsg { + return { + type: "wasm/MsgStoreCodeResponse", + value: MsgStoreCodeResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgStoreCodeResponseProtoMsg): MsgStoreCodeResponse { + return MsgStoreCodeResponse.decode(message.value); + }, + toProto(message: MsgStoreCodeResponse): Uint8Array { + return MsgStoreCodeResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgStoreCodeResponse): MsgStoreCodeResponseProtoMsg { + return { + typeUrl: "/cosmwasm.wasm.v1.MsgStoreCodeResponse", + value: MsgStoreCodeResponse.encode(message).finish() + }; + } +}; +function createBaseMsgInstantiateContract(): MsgInstantiateContract { + return { + sender: "", + admin: "", + codeId: BigInt(0), + label: "", + msg: new Uint8Array(), + funds: [] + }; +} +export const MsgInstantiateContract = { + typeUrl: "/cosmwasm.wasm.v1.MsgInstantiateContract", + encode(message: MsgInstantiateContract, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.sender !== undefined) { + writer.uint32(10).string(message.sender); + } + if (message.admin !== undefined) { + writer.uint32(18).string(message.admin); + } + if (message.codeId !== undefined) { + writer.uint32(24).uint64(message.codeId); + } + if (message.label !== undefined) { + writer.uint32(34).string(message.label); + } + if (message.msg.length !== 0) { + writer.uint32(42).bytes(message.msg); + } + for (const v of message.funds) { + Coin.encode(v!, writer.uint32(50).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgInstantiateContract { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgInstantiateContract(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.sender = reader.string(); + break; + case 2: + message.admin = reader.string(); + break; + case 3: + message.codeId = reader.uint64(); + break; + case 4: + message.label = reader.string(); + break; + case 5: + message.msg = reader.bytes(); + break; + case 6: + message.funds.push(Coin.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgInstantiateContract { + const obj = createBaseMsgInstantiateContract(); + if (isSet(object.sender)) obj.sender = String(object.sender); + if (isSet(object.admin)) obj.admin = String(object.admin); + if (isSet(object.codeId)) obj.codeId = BigInt(object.codeId.toString()); + if (isSet(object.label)) obj.label = String(object.label); + if (isSet(object.msg)) obj.msg = bytesFromBase64(object.msg); + if (Array.isArray(object?.funds)) obj.funds = object.funds.map((e: any) => Coin.fromJSON(e)); + return obj; + }, + toJSON(message: MsgInstantiateContract): JsonSafe { + const obj: any = {}; + message.sender !== undefined && (obj.sender = message.sender); + message.admin !== undefined && (obj.admin = message.admin); + message.codeId !== undefined && (obj.codeId = (message.codeId || BigInt(0)).toString()); + message.label !== undefined && (obj.label = message.label); + message.msg !== undefined && (obj.msg = base64FromBytes(message.msg !== undefined ? message.msg : new Uint8Array())); + if (message.funds) { + obj.funds = message.funds.map(e => e ? Coin.toJSON(e) : undefined); + } else { + obj.funds = []; + } + return obj; + }, + fromPartial(object: DeepPartial): MsgInstantiateContract { + const message = createBaseMsgInstantiateContract(); + message.sender = object.sender ?? ""; + message.admin = object.admin ?? ""; + if (object.codeId !== undefined && object.codeId !== null) { + message.codeId = BigInt(object.codeId.toString()); + } + message.label = object.label ?? ""; + message.msg = object.msg ?? new Uint8Array(); + message.funds = object.funds?.map(e => Coin.fromPartial(e)) || []; + return message; + }, + fromSDK(object: MsgInstantiateContractSDKType): MsgInstantiateContract { + return { + sender: object?.sender, + admin: object?.admin, + codeId: object?.code_id, + label: object?.label, + msg: object?.msg, + funds: Array.isArray(object?.funds) ? object.funds.map((e: any) => Coin.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): MsgInstantiateContractSDKType { + return { + sender: isSet(object.sender) ? String(object.sender) : "", + admin: isSet(object.admin) ? String(object.admin) : "", + code_id: isSet(object.code_id) ? BigInt(object.code_id.toString()) : BigInt(0), + label: isSet(object.label) ? String(object.label) : "", + msg: isSet(object.msg) ? bytesFromBase64(object.msg) : new Uint8Array(), + funds: Array.isArray(object?.funds) ? object.funds.map((e: any) => Coin.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: MsgInstantiateContract): MsgInstantiateContractSDKType { + const obj: any = {}; + obj.sender = message.sender; + obj.admin = message.admin; + obj.code_id = message.codeId; + obj.label = message.label; + obj.msg = message.msg; + if (message.funds) { + obj.funds = message.funds.map(e => e ? Coin.toSDK(e) : undefined); + } else { + obj.funds = []; + } + return obj; + }, + fromAmino(object: MsgInstantiateContractAmino): MsgInstantiateContract { + const message = createBaseMsgInstantiateContract(); + if (object.sender !== undefined && object.sender !== null) { + message.sender = object.sender; + } + if (object.admin !== undefined && object.admin !== null) { + message.admin = object.admin; + } + if (object.code_id !== undefined && object.code_id !== null) { + message.codeId = BigInt(object.code_id); + } + if (object.label !== undefined && object.label !== null) { + message.label = object.label; + } + if (object.msg !== undefined && object.msg !== null) { + message.msg = toUtf8(JSON.stringify(object.msg)); + } + message.funds = object.funds?.map(e => Coin.fromAmino(e)) || []; + return message; + }, + toAmino(message: MsgInstantiateContract): MsgInstantiateContractAmino { + const obj: any = {}; + obj.sender = message.sender === "" ? undefined : message.sender; + obj.admin = message.admin === "" ? undefined : message.admin; + obj.code_id = message.codeId !== BigInt(0) ? message.codeId?.toString() : undefined; + obj.label = message.label === "" ? undefined : message.label; + obj.msg = message.msg ? JSON.parse(fromUtf8(message.msg)) : undefined; + if (message.funds) { + obj.funds = message.funds.map(e => e ? Coin.toAmino(e) : undefined); + } else { + obj.funds = message.funds; + } + return obj; + }, + fromAminoMsg(object: MsgInstantiateContractAminoMsg): MsgInstantiateContract { + return MsgInstantiateContract.fromAmino(object.value); + }, + toAminoMsg(message: MsgInstantiateContract): MsgInstantiateContractAminoMsg { + return { + type: "wasm/MsgInstantiateContract", + value: MsgInstantiateContract.toAmino(message) + }; + }, + fromProtoMsg(message: MsgInstantiateContractProtoMsg): MsgInstantiateContract { + return MsgInstantiateContract.decode(message.value); + }, + toProto(message: MsgInstantiateContract): Uint8Array { + return MsgInstantiateContract.encode(message).finish(); + }, + toProtoMsg(message: MsgInstantiateContract): MsgInstantiateContractProtoMsg { + return { + typeUrl: "/cosmwasm.wasm.v1.MsgInstantiateContract", + value: MsgInstantiateContract.encode(message).finish() + }; + } +}; +function createBaseMsgInstantiateContractResponse(): MsgInstantiateContractResponse { + return { + address: "", + data: new Uint8Array() + }; +} +export const MsgInstantiateContractResponse = { + typeUrl: "/cosmwasm.wasm.v1.MsgInstantiateContractResponse", + encode(message: MsgInstantiateContractResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.address !== undefined) { + writer.uint32(10).string(message.address); + } + if (message.data.length !== 0) { + writer.uint32(18).bytes(message.data); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgInstantiateContractResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgInstantiateContractResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.string(); + break; + case 2: + message.data = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgInstantiateContractResponse { + const obj = createBaseMsgInstantiateContractResponse(); + if (isSet(object.address)) obj.address = String(object.address); + if (isSet(object.data)) obj.data = bytesFromBase64(object.data); + return obj; + }, + toJSON(message: MsgInstantiateContractResponse): JsonSafe { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + message.data !== undefined && (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): MsgInstantiateContractResponse { + const message = createBaseMsgInstantiateContractResponse(); + message.address = object.address ?? ""; + message.data = object.data ?? new Uint8Array(); + return message; + }, + fromSDK(object: MsgInstantiateContractResponseSDKType): MsgInstantiateContractResponse { + return { + address: object?.address, + data: object?.data + }; + }, + fromSDKJSON(object: any): MsgInstantiateContractResponseSDKType { + return { + address: isSet(object.address) ? String(object.address) : "", + data: isSet(object.data) ? bytesFromBase64(object.data) : new Uint8Array() + }; + }, + toSDK(message: MsgInstantiateContractResponse): MsgInstantiateContractResponseSDKType { + const obj: any = {}; + obj.address = message.address; + obj.data = message.data; + return obj; + }, + fromAmino(object: MsgInstantiateContractResponseAmino): MsgInstantiateContractResponse { + const message = createBaseMsgInstantiateContractResponse(); + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } + if (object.data !== undefined && object.data !== null) { + message.data = bytesFromBase64(object.data); + } + return message; + }, + toAmino(message: MsgInstantiateContractResponse): MsgInstantiateContractResponseAmino { + const obj: any = {}; + obj.address = message.address === "" ? undefined : message.address; + obj.data = message.data ? base64FromBytes(message.data) : undefined; + return obj; + }, + fromAminoMsg(object: MsgInstantiateContractResponseAminoMsg): MsgInstantiateContractResponse { + return MsgInstantiateContractResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgInstantiateContractResponse): MsgInstantiateContractResponseAminoMsg { + return { + type: "wasm/MsgInstantiateContractResponse", + value: MsgInstantiateContractResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgInstantiateContractResponseProtoMsg): MsgInstantiateContractResponse { + return MsgInstantiateContractResponse.decode(message.value); + }, + toProto(message: MsgInstantiateContractResponse): Uint8Array { + return MsgInstantiateContractResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgInstantiateContractResponse): MsgInstantiateContractResponseProtoMsg { + return { + typeUrl: "/cosmwasm.wasm.v1.MsgInstantiateContractResponse", + value: MsgInstantiateContractResponse.encode(message).finish() + }; + } +}; +function createBaseMsgExecuteContract(): MsgExecuteContract { + return { + sender: "", + contract: "", + msg: new Uint8Array(), + funds: [] + }; +} +export const MsgExecuteContract = { + typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract", + encode(message: MsgExecuteContract, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.sender !== undefined) { + writer.uint32(10).string(message.sender); + } + if (message.contract !== undefined) { + writer.uint32(18).string(message.contract); + } + if (message.msg.length !== 0) { + writer.uint32(26).bytes(message.msg); + } + for (const v of message.funds) { + Coin.encode(v!, writer.uint32(42).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgExecuteContract { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgExecuteContract(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.sender = reader.string(); + break; + case 2: + message.contract = reader.string(); + break; + case 3: + message.msg = reader.bytes(); + break; + case 5: + message.funds.push(Coin.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgExecuteContract { + const obj = createBaseMsgExecuteContract(); + if (isSet(object.sender)) obj.sender = String(object.sender); + if (isSet(object.contract)) obj.contract = String(object.contract); + if (isSet(object.msg)) obj.msg = bytesFromBase64(object.msg); + if (Array.isArray(object?.funds)) obj.funds = object.funds.map((e: any) => Coin.fromJSON(e)); + return obj; + }, + toJSON(message: MsgExecuteContract): JsonSafe { + const obj: any = {}; + message.sender !== undefined && (obj.sender = message.sender); + message.contract !== undefined && (obj.contract = message.contract); + message.msg !== undefined && (obj.msg = base64FromBytes(message.msg !== undefined ? message.msg : new Uint8Array())); + if (message.funds) { + obj.funds = message.funds.map(e => e ? Coin.toJSON(e) : undefined); + } else { + obj.funds = []; + } + return obj; + }, + fromPartial(object: DeepPartial): MsgExecuteContract { + const message = createBaseMsgExecuteContract(); + message.sender = object.sender ?? ""; + message.contract = object.contract ?? ""; + message.msg = object.msg ?? new Uint8Array(); + message.funds = object.funds?.map(e => Coin.fromPartial(e)) || []; + return message; + }, + fromSDK(object: MsgExecuteContractSDKType): MsgExecuteContract { + return { + sender: object?.sender, + contract: object?.contract, + msg: object?.msg, + funds: Array.isArray(object?.funds) ? object.funds.map((e: any) => Coin.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): MsgExecuteContractSDKType { + return { + sender: isSet(object.sender) ? String(object.sender) : "", + contract: isSet(object.contract) ? String(object.contract) : "", + msg: isSet(object.msg) ? bytesFromBase64(object.msg) : new Uint8Array(), + funds: Array.isArray(object?.funds) ? object.funds.map((e: any) => Coin.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: MsgExecuteContract): MsgExecuteContractSDKType { + const obj: any = {}; + obj.sender = message.sender; + obj.contract = message.contract; + obj.msg = message.msg; + if (message.funds) { + obj.funds = message.funds.map(e => e ? Coin.toSDK(e) : undefined); + } else { + obj.funds = []; + } + return obj; + }, + fromAmino(object: MsgExecuteContractAmino): MsgExecuteContract { + const message = createBaseMsgExecuteContract(); + if (object.sender !== undefined && object.sender !== null) { + message.sender = object.sender; + } + if (object.contract !== undefined && object.contract !== null) { + message.contract = object.contract; + } + if (object.msg !== undefined && object.msg !== null) { + message.msg = toUtf8(JSON.stringify(object.msg)); + } + message.funds = object.funds?.map(e => Coin.fromAmino(e)) || []; + return message; + }, + toAmino(message: MsgExecuteContract): MsgExecuteContractAmino { + const obj: any = {}; + obj.sender = message.sender === "" ? undefined : message.sender; + obj.contract = message.contract === "" ? undefined : message.contract; + obj.msg = message.msg ? JSON.parse(fromUtf8(message.msg)) : undefined; + if (message.funds) { + obj.funds = message.funds.map(e => e ? Coin.toAmino(e) : undefined); + } else { + obj.funds = message.funds; + } + return obj; + }, + fromAminoMsg(object: MsgExecuteContractAminoMsg): MsgExecuteContract { + return MsgExecuteContract.fromAmino(object.value); + }, + toAminoMsg(message: MsgExecuteContract): MsgExecuteContractAminoMsg { + return { + type: "wasm/MsgExecuteContract", + value: MsgExecuteContract.toAmino(message) + }; + }, + fromProtoMsg(message: MsgExecuteContractProtoMsg): MsgExecuteContract { + return MsgExecuteContract.decode(message.value); + }, + toProto(message: MsgExecuteContract): Uint8Array { + return MsgExecuteContract.encode(message).finish(); + }, + toProtoMsg(message: MsgExecuteContract): MsgExecuteContractProtoMsg { + return { + typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract", + value: MsgExecuteContract.encode(message).finish() + }; + } +}; +function createBaseMsgExecuteContractResponse(): MsgExecuteContractResponse { + return { + data: new Uint8Array() + }; +} +export const MsgExecuteContractResponse = { + typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContractResponse", + encode(message: MsgExecuteContractResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.data.length !== 0) { + writer.uint32(10).bytes(message.data); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgExecuteContractResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgExecuteContractResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.data = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgExecuteContractResponse { + const obj = createBaseMsgExecuteContractResponse(); + if (isSet(object.data)) obj.data = bytesFromBase64(object.data); + return obj; + }, + toJSON(message: MsgExecuteContractResponse): JsonSafe { + const obj: any = {}; + message.data !== undefined && (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): MsgExecuteContractResponse { + const message = createBaseMsgExecuteContractResponse(); + message.data = object.data ?? new Uint8Array(); + return message; + }, + fromSDK(object: MsgExecuteContractResponseSDKType): MsgExecuteContractResponse { + return { + data: object?.data + }; + }, + fromSDKJSON(object: any): MsgExecuteContractResponseSDKType { + return { + data: isSet(object.data) ? bytesFromBase64(object.data) : new Uint8Array() + }; + }, + toSDK(message: MsgExecuteContractResponse): MsgExecuteContractResponseSDKType { + const obj: any = {}; + obj.data = message.data; + return obj; + }, + fromAmino(object: MsgExecuteContractResponseAmino): MsgExecuteContractResponse { + const message = createBaseMsgExecuteContractResponse(); + if (object.data !== undefined && object.data !== null) { + message.data = bytesFromBase64(object.data); + } + return message; + }, + toAmino(message: MsgExecuteContractResponse): MsgExecuteContractResponseAmino { + const obj: any = {}; + obj.data = message.data ? base64FromBytes(message.data) : undefined; + return obj; + }, + fromAminoMsg(object: MsgExecuteContractResponseAminoMsg): MsgExecuteContractResponse { + return MsgExecuteContractResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgExecuteContractResponse): MsgExecuteContractResponseAminoMsg { + return { + type: "wasm/MsgExecuteContractResponse", + value: MsgExecuteContractResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgExecuteContractResponseProtoMsg): MsgExecuteContractResponse { + return MsgExecuteContractResponse.decode(message.value); + }, + toProto(message: MsgExecuteContractResponse): Uint8Array { + return MsgExecuteContractResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgExecuteContractResponse): MsgExecuteContractResponseProtoMsg { + return { + typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContractResponse", + value: MsgExecuteContractResponse.encode(message).finish() + }; + } +}; +function createBaseMsgMigrateContract(): MsgMigrateContract { + return { + sender: "", + contract: "", + codeId: BigInt(0), + msg: new Uint8Array() + }; +} +export const MsgMigrateContract = { + typeUrl: "/cosmwasm.wasm.v1.MsgMigrateContract", + encode(message: MsgMigrateContract, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.sender !== undefined) { + writer.uint32(10).string(message.sender); + } + if (message.contract !== undefined) { + writer.uint32(18).string(message.contract); + } + if (message.codeId !== undefined) { + writer.uint32(24).uint64(message.codeId); + } + if (message.msg.length !== 0) { + writer.uint32(34).bytes(message.msg); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgMigrateContract { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgMigrateContract(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.sender = reader.string(); + break; + case 2: + message.contract = reader.string(); + break; + case 3: + message.codeId = reader.uint64(); + break; + case 4: + message.msg = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgMigrateContract { + const obj = createBaseMsgMigrateContract(); + if (isSet(object.sender)) obj.sender = String(object.sender); + if (isSet(object.contract)) obj.contract = String(object.contract); + if (isSet(object.codeId)) obj.codeId = BigInt(object.codeId.toString()); + if (isSet(object.msg)) obj.msg = bytesFromBase64(object.msg); + return obj; + }, + toJSON(message: MsgMigrateContract): JsonSafe { + const obj: any = {}; + message.sender !== undefined && (obj.sender = message.sender); + message.contract !== undefined && (obj.contract = message.contract); + message.codeId !== undefined && (obj.codeId = (message.codeId || BigInt(0)).toString()); + message.msg !== undefined && (obj.msg = base64FromBytes(message.msg !== undefined ? message.msg : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): MsgMigrateContract { + const message = createBaseMsgMigrateContract(); + message.sender = object.sender ?? ""; + message.contract = object.contract ?? ""; + if (object.codeId !== undefined && object.codeId !== null) { + message.codeId = BigInt(object.codeId.toString()); + } + message.msg = object.msg ?? new Uint8Array(); + return message; + }, + fromSDK(object: MsgMigrateContractSDKType): MsgMigrateContract { + return { + sender: object?.sender, + contract: object?.contract, + codeId: object?.code_id, + msg: object?.msg + }; + }, + fromSDKJSON(object: any): MsgMigrateContractSDKType { + return { + sender: isSet(object.sender) ? String(object.sender) : "", + contract: isSet(object.contract) ? String(object.contract) : "", + code_id: isSet(object.code_id) ? BigInt(object.code_id.toString()) : BigInt(0), + msg: isSet(object.msg) ? bytesFromBase64(object.msg) : new Uint8Array() + }; + }, + toSDK(message: MsgMigrateContract): MsgMigrateContractSDKType { + const obj: any = {}; + obj.sender = message.sender; + obj.contract = message.contract; + obj.code_id = message.codeId; + obj.msg = message.msg; + return obj; + }, + fromAmino(object: MsgMigrateContractAmino): MsgMigrateContract { + const message = createBaseMsgMigrateContract(); + if (object.sender !== undefined && object.sender !== null) { + message.sender = object.sender; + } + if (object.contract !== undefined && object.contract !== null) { + message.contract = object.contract; + } + if (object.code_id !== undefined && object.code_id !== null) { + message.codeId = BigInt(object.code_id); + } + if (object.msg !== undefined && object.msg !== null) { + message.msg = toUtf8(JSON.stringify(object.msg)); + } + return message; + }, + toAmino(message: MsgMigrateContract): MsgMigrateContractAmino { + const obj: any = {}; + obj.sender = message.sender === "" ? undefined : message.sender; + obj.contract = message.contract === "" ? undefined : message.contract; + obj.code_id = message.codeId !== BigInt(0) ? message.codeId?.toString() : undefined; + obj.msg = message.msg ? JSON.parse(fromUtf8(message.msg)) : undefined; + return obj; + }, + fromAminoMsg(object: MsgMigrateContractAminoMsg): MsgMigrateContract { + return MsgMigrateContract.fromAmino(object.value); + }, + toAminoMsg(message: MsgMigrateContract): MsgMigrateContractAminoMsg { + return { + type: "wasm/MsgMigrateContract", + value: MsgMigrateContract.toAmino(message) + }; + }, + fromProtoMsg(message: MsgMigrateContractProtoMsg): MsgMigrateContract { + return MsgMigrateContract.decode(message.value); + }, + toProto(message: MsgMigrateContract): Uint8Array { + return MsgMigrateContract.encode(message).finish(); + }, + toProtoMsg(message: MsgMigrateContract): MsgMigrateContractProtoMsg { + return { + typeUrl: "/cosmwasm.wasm.v1.MsgMigrateContract", + value: MsgMigrateContract.encode(message).finish() + }; + } +}; +function createBaseMsgMigrateContractResponse(): MsgMigrateContractResponse { + return { + data: new Uint8Array() + }; +} +export const MsgMigrateContractResponse = { + typeUrl: "/cosmwasm.wasm.v1.MsgMigrateContractResponse", + encode(message: MsgMigrateContractResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.data.length !== 0) { + writer.uint32(10).bytes(message.data); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgMigrateContractResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgMigrateContractResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.data = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgMigrateContractResponse { + const obj = createBaseMsgMigrateContractResponse(); + if (isSet(object.data)) obj.data = bytesFromBase64(object.data); + return obj; + }, + toJSON(message: MsgMigrateContractResponse): JsonSafe { + const obj: any = {}; + message.data !== undefined && (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): MsgMigrateContractResponse { + const message = createBaseMsgMigrateContractResponse(); + message.data = object.data ?? new Uint8Array(); + return message; + }, + fromSDK(object: MsgMigrateContractResponseSDKType): MsgMigrateContractResponse { + return { + data: object?.data + }; + }, + fromSDKJSON(object: any): MsgMigrateContractResponseSDKType { + return { + data: isSet(object.data) ? bytesFromBase64(object.data) : new Uint8Array() + }; + }, + toSDK(message: MsgMigrateContractResponse): MsgMigrateContractResponseSDKType { + const obj: any = {}; + obj.data = message.data; + return obj; + }, + fromAmino(object: MsgMigrateContractResponseAmino): MsgMigrateContractResponse { + const message = createBaseMsgMigrateContractResponse(); + if (object.data !== undefined && object.data !== null) { + message.data = bytesFromBase64(object.data); + } + return message; + }, + toAmino(message: MsgMigrateContractResponse): MsgMigrateContractResponseAmino { + const obj: any = {}; + obj.data = message.data ? base64FromBytes(message.data) : undefined; + return obj; + }, + fromAminoMsg(object: MsgMigrateContractResponseAminoMsg): MsgMigrateContractResponse { + return MsgMigrateContractResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgMigrateContractResponse): MsgMigrateContractResponseAminoMsg { + return { + type: "wasm/MsgMigrateContractResponse", + value: MsgMigrateContractResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgMigrateContractResponseProtoMsg): MsgMigrateContractResponse { + return MsgMigrateContractResponse.decode(message.value); + }, + toProto(message: MsgMigrateContractResponse): Uint8Array { + return MsgMigrateContractResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgMigrateContractResponse): MsgMigrateContractResponseProtoMsg { + return { + typeUrl: "/cosmwasm.wasm.v1.MsgMigrateContractResponse", + value: MsgMigrateContractResponse.encode(message).finish() + }; + } +}; +function createBaseMsgUpdateAdmin(): MsgUpdateAdmin { + return { + sender: "", + newAdmin: "", + contract: "" + }; +} +export const MsgUpdateAdmin = { + typeUrl: "/cosmwasm.wasm.v1.MsgUpdateAdmin", + encode(message: MsgUpdateAdmin, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.sender !== undefined) { + writer.uint32(10).string(message.sender); + } + if (message.newAdmin !== undefined) { + writer.uint32(18).string(message.newAdmin); + } + if (message.contract !== undefined) { + writer.uint32(26).string(message.contract); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgUpdateAdmin { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgUpdateAdmin(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.sender = reader.string(); + break; + case 2: + message.newAdmin = reader.string(); + break; + case 3: + message.contract = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgUpdateAdmin { + const obj = createBaseMsgUpdateAdmin(); + if (isSet(object.sender)) obj.sender = String(object.sender); + if (isSet(object.newAdmin)) obj.newAdmin = String(object.newAdmin); + if (isSet(object.contract)) obj.contract = String(object.contract); + return obj; + }, + toJSON(message: MsgUpdateAdmin): JsonSafe { + const obj: any = {}; + message.sender !== undefined && (obj.sender = message.sender); + message.newAdmin !== undefined && (obj.newAdmin = message.newAdmin); + message.contract !== undefined && (obj.contract = message.contract); + return obj; + }, + fromPartial(object: DeepPartial): MsgUpdateAdmin { + const message = createBaseMsgUpdateAdmin(); + message.sender = object.sender ?? ""; + message.newAdmin = object.newAdmin ?? ""; + message.contract = object.contract ?? ""; + return message; + }, + fromSDK(object: MsgUpdateAdminSDKType): MsgUpdateAdmin { + return { + sender: object?.sender, + newAdmin: object?.new_admin, + contract: object?.contract + }; + }, + fromSDKJSON(object: any): MsgUpdateAdminSDKType { + return { + sender: isSet(object.sender) ? String(object.sender) : "", + new_admin: isSet(object.new_admin) ? String(object.new_admin) : "", + contract: isSet(object.contract) ? String(object.contract) : "" + }; + }, + toSDK(message: MsgUpdateAdmin): MsgUpdateAdminSDKType { + const obj: any = {}; + obj.sender = message.sender; + obj.new_admin = message.newAdmin; + obj.contract = message.contract; + return obj; + }, + fromAmino(object: MsgUpdateAdminAmino): MsgUpdateAdmin { + const message = createBaseMsgUpdateAdmin(); + if (object.sender !== undefined && object.sender !== null) { + message.sender = object.sender; + } + if (object.new_admin !== undefined && object.new_admin !== null) { + message.newAdmin = object.new_admin; + } + if (object.contract !== undefined && object.contract !== null) { + message.contract = object.contract; + } + return message; + }, + toAmino(message: MsgUpdateAdmin): MsgUpdateAdminAmino { + const obj: any = {}; + obj.sender = message.sender === "" ? undefined : message.sender; + obj.new_admin = message.newAdmin === "" ? undefined : message.newAdmin; + obj.contract = message.contract === "" ? undefined : message.contract; + return obj; + }, + fromAminoMsg(object: MsgUpdateAdminAminoMsg): MsgUpdateAdmin { + return MsgUpdateAdmin.fromAmino(object.value); + }, + toAminoMsg(message: MsgUpdateAdmin): MsgUpdateAdminAminoMsg { + return { + type: "wasm/MsgUpdateAdmin", + value: MsgUpdateAdmin.toAmino(message) + }; + }, + fromProtoMsg(message: MsgUpdateAdminProtoMsg): MsgUpdateAdmin { + return MsgUpdateAdmin.decode(message.value); + }, + toProto(message: MsgUpdateAdmin): Uint8Array { + return MsgUpdateAdmin.encode(message).finish(); + }, + toProtoMsg(message: MsgUpdateAdmin): MsgUpdateAdminProtoMsg { + return { + typeUrl: "/cosmwasm.wasm.v1.MsgUpdateAdmin", + value: MsgUpdateAdmin.encode(message).finish() + }; + } +}; +function createBaseMsgUpdateAdminResponse(): MsgUpdateAdminResponse { + return {}; +} +export const MsgUpdateAdminResponse = { + typeUrl: "/cosmwasm.wasm.v1.MsgUpdateAdminResponse", + encode(_: MsgUpdateAdminResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgUpdateAdminResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgUpdateAdminResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgUpdateAdminResponse { + const obj = createBaseMsgUpdateAdminResponse(); + return obj; + }, + toJSON(_: MsgUpdateAdminResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): MsgUpdateAdminResponse { + const message = createBaseMsgUpdateAdminResponse(); + return message; + }, + fromSDK(_: MsgUpdateAdminResponseSDKType): MsgUpdateAdminResponse { + return {}; + }, + fromSDKJSON(_: any): MsgUpdateAdminResponseSDKType { + return {}; + }, + toSDK(_: MsgUpdateAdminResponse): MsgUpdateAdminResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgUpdateAdminResponseAmino): MsgUpdateAdminResponse { + const message = createBaseMsgUpdateAdminResponse(); + return message; + }, + toAmino(_: MsgUpdateAdminResponse): MsgUpdateAdminResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgUpdateAdminResponseAminoMsg): MsgUpdateAdminResponse { + return MsgUpdateAdminResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgUpdateAdminResponse): MsgUpdateAdminResponseAminoMsg { + return { + type: "wasm/MsgUpdateAdminResponse", + value: MsgUpdateAdminResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgUpdateAdminResponseProtoMsg): MsgUpdateAdminResponse { + return MsgUpdateAdminResponse.decode(message.value); + }, + toProto(message: MsgUpdateAdminResponse): Uint8Array { + return MsgUpdateAdminResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgUpdateAdminResponse): MsgUpdateAdminResponseProtoMsg { + return { + typeUrl: "/cosmwasm.wasm.v1.MsgUpdateAdminResponse", + value: MsgUpdateAdminResponse.encode(message).finish() + }; + } +}; +function createBaseMsgClearAdmin(): MsgClearAdmin { + return { + sender: "", + contract: "" + }; +} +export const MsgClearAdmin = { + typeUrl: "/cosmwasm.wasm.v1.MsgClearAdmin", + encode(message: MsgClearAdmin, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.sender !== undefined) { + writer.uint32(10).string(message.sender); + } + if (message.contract !== undefined) { + writer.uint32(26).string(message.contract); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgClearAdmin { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgClearAdmin(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.sender = reader.string(); + break; + case 3: + message.contract = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgClearAdmin { + const obj = createBaseMsgClearAdmin(); + if (isSet(object.sender)) obj.sender = String(object.sender); + if (isSet(object.contract)) obj.contract = String(object.contract); + return obj; + }, + toJSON(message: MsgClearAdmin): JsonSafe { + const obj: any = {}; + message.sender !== undefined && (obj.sender = message.sender); + message.contract !== undefined && (obj.contract = message.contract); + return obj; + }, + fromPartial(object: DeepPartial): MsgClearAdmin { + const message = createBaseMsgClearAdmin(); + message.sender = object.sender ?? ""; + message.contract = object.contract ?? ""; + return message; + }, + fromSDK(object: MsgClearAdminSDKType): MsgClearAdmin { + return { + sender: object?.sender, + contract: object?.contract + }; + }, + fromSDKJSON(object: any): MsgClearAdminSDKType { + return { + sender: isSet(object.sender) ? String(object.sender) : "", + contract: isSet(object.contract) ? String(object.contract) : "" + }; + }, + toSDK(message: MsgClearAdmin): MsgClearAdminSDKType { + const obj: any = {}; + obj.sender = message.sender; + obj.contract = message.contract; + return obj; + }, + fromAmino(object: MsgClearAdminAmino): MsgClearAdmin { + const message = createBaseMsgClearAdmin(); + if (object.sender !== undefined && object.sender !== null) { + message.sender = object.sender; + } + if (object.contract !== undefined && object.contract !== null) { + message.contract = object.contract; + } + return message; + }, + toAmino(message: MsgClearAdmin): MsgClearAdminAmino { + const obj: any = {}; + obj.sender = message.sender === "" ? undefined : message.sender; + obj.contract = message.contract === "" ? undefined : message.contract; + return obj; + }, + fromAminoMsg(object: MsgClearAdminAminoMsg): MsgClearAdmin { + return MsgClearAdmin.fromAmino(object.value); + }, + toAminoMsg(message: MsgClearAdmin): MsgClearAdminAminoMsg { + return { + type: "wasm/MsgClearAdmin", + value: MsgClearAdmin.toAmino(message) + }; + }, + fromProtoMsg(message: MsgClearAdminProtoMsg): MsgClearAdmin { + return MsgClearAdmin.decode(message.value); + }, + toProto(message: MsgClearAdmin): Uint8Array { + return MsgClearAdmin.encode(message).finish(); + }, + toProtoMsg(message: MsgClearAdmin): MsgClearAdminProtoMsg { + return { + typeUrl: "/cosmwasm.wasm.v1.MsgClearAdmin", + value: MsgClearAdmin.encode(message).finish() + }; + } +}; +function createBaseMsgClearAdminResponse(): MsgClearAdminResponse { + return {}; +} +export const MsgClearAdminResponse = { + typeUrl: "/cosmwasm.wasm.v1.MsgClearAdminResponse", + encode(_: MsgClearAdminResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgClearAdminResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgClearAdminResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgClearAdminResponse { + const obj = createBaseMsgClearAdminResponse(); + return obj; + }, + toJSON(_: MsgClearAdminResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): MsgClearAdminResponse { + const message = createBaseMsgClearAdminResponse(); + return message; + }, + fromSDK(_: MsgClearAdminResponseSDKType): MsgClearAdminResponse { + return {}; + }, + fromSDKJSON(_: any): MsgClearAdminResponseSDKType { + return {}; + }, + toSDK(_: MsgClearAdminResponse): MsgClearAdminResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgClearAdminResponseAmino): MsgClearAdminResponse { + const message = createBaseMsgClearAdminResponse(); + return message; + }, + toAmino(_: MsgClearAdminResponse): MsgClearAdminResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgClearAdminResponseAminoMsg): MsgClearAdminResponse { + return MsgClearAdminResponse.fromAmino(object.value); + }, + toAminoMsg(message: MsgClearAdminResponse): MsgClearAdminResponseAminoMsg { + return { + type: "wasm/MsgClearAdminResponse", + value: MsgClearAdminResponse.toAmino(message) + }; + }, + fromProtoMsg(message: MsgClearAdminResponseProtoMsg): MsgClearAdminResponse { + return MsgClearAdminResponse.decode(message.value); + }, + toProto(message: MsgClearAdminResponse): Uint8Array { + return MsgClearAdminResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgClearAdminResponse): MsgClearAdminResponseProtoMsg { + return { + typeUrl: "/cosmwasm.wasm.v1.MsgClearAdminResponse", + value: MsgClearAdminResponse.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/cosmwasm/wasm/v1/types.ts b/__fixtures__/v-next/outputicjsdeps/cosmwasm/wasm/v1/types.ts new file mode 100644 index 0000000000..2bc908fd64 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/cosmwasm/wasm/v1/types.ts @@ -0,0 +1,1305 @@ +import { Any, AnySDKType } from "../../../google/protobuf/any.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial, bytesFromBase64, base64FromBytes } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +import { toUtf8, fromUtf8 } from "@cosmjs/encoding"; +export const protobufPackage = "cosmwasm.wasm.v1"; +/** AccessType permission types */ +export enum AccessType { + /** ACCESS_TYPE_UNSPECIFIED - AccessTypeUnspecified placeholder for empty value */ + ACCESS_TYPE_UNSPECIFIED = 0, + /** ACCESS_TYPE_NOBODY - AccessTypeNobody forbidden */ + ACCESS_TYPE_NOBODY = 1, + /** ACCESS_TYPE_ONLY_ADDRESS - AccessTypeOnlyAddress restricted to an address */ + ACCESS_TYPE_ONLY_ADDRESS = 2, + /** ACCESS_TYPE_EVERYBODY - AccessTypeEverybody unrestricted */ + ACCESS_TYPE_EVERYBODY = 3, + UNRECOGNIZED = -1, +} +export const AccessTypeSDKType = AccessType; +export function accessTypeFromJSON(object: any): AccessType { + switch (object) { + case 0: + case "ACCESS_TYPE_UNSPECIFIED": + return AccessType.ACCESS_TYPE_UNSPECIFIED; + case 1: + case "ACCESS_TYPE_NOBODY": + return AccessType.ACCESS_TYPE_NOBODY; + case 2: + case "ACCESS_TYPE_ONLY_ADDRESS": + return AccessType.ACCESS_TYPE_ONLY_ADDRESS; + case 3: + case "ACCESS_TYPE_EVERYBODY": + return AccessType.ACCESS_TYPE_EVERYBODY; + case -1: + case "UNRECOGNIZED": + default: + return AccessType.UNRECOGNIZED; + } +} +export function accessTypeToJSON(object: AccessType): string { + switch (object) { + case AccessType.ACCESS_TYPE_UNSPECIFIED: + return "ACCESS_TYPE_UNSPECIFIED"; + case AccessType.ACCESS_TYPE_NOBODY: + return "ACCESS_TYPE_NOBODY"; + case AccessType.ACCESS_TYPE_ONLY_ADDRESS: + return "ACCESS_TYPE_ONLY_ADDRESS"; + case AccessType.ACCESS_TYPE_EVERYBODY: + return "ACCESS_TYPE_EVERYBODY"; + case AccessType.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** ContractCodeHistoryOperationType actions that caused a code change */ +export enum ContractCodeHistoryOperationType { + /** CONTRACT_CODE_HISTORY_OPERATION_TYPE_UNSPECIFIED - ContractCodeHistoryOperationTypeUnspecified placeholder for empty value */ + CONTRACT_CODE_HISTORY_OPERATION_TYPE_UNSPECIFIED = 0, + /** CONTRACT_CODE_HISTORY_OPERATION_TYPE_INIT - ContractCodeHistoryOperationTypeInit on chain contract instantiation */ + CONTRACT_CODE_HISTORY_OPERATION_TYPE_INIT = 1, + /** CONTRACT_CODE_HISTORY_OPERATION_TYPE_MIGRATE - ContractCodeHistoryOperationTypeMigrate code migration */ + CONTRACT_CODE_HISTORY_OPERATION_TYPE_MIGRATE = 2, + /** CONTRACT_CODE_HISTORY_OPERATION_TYPE_GENESIS - ContractCodeHistoryOperationTypeGenesis based on genesis data */ + CONTRACT_CODE_HISTORY_OPERATION_TYPE_GENESIS = 3, + UNRECOGNIZED = -1, +} +export const ContractCodeHistoryOperationTypeSDKType = ContractCodeHistoryOperationType; +export function contractCodeHistoryOperationTypeFromJSON(object: any): ContractCodeHistoryOperationType { + switch (object) { + case 0: + case "CONTRACT_CODE_HISTORY_OPERATION_TYPE_UNSPECIFIED": + return ContractCodeHistoryOperationType.CONTRACT_CODE_HISTORY_OPERATION_TYPE_UNSPECIFIED; + case 1: + case "CONTRACT_CODE_HISTORY_OPERATION_TYPE_INIT": + return ContractCodeHistoryOperationType.CONTRACT_CODE_HISTORY_OPERATION_TYPE_INIT; + case 2: + case "CONTRACT_CODE_HISTORY_OPERATION_TYPE_MIGRATE": + return ContractCodeHistoryOperationType.CONTRACT_CODE_HISTORY_OPERATION_TYPE_MIGRATE; + case 3: + case "CONTRACT_CODE_HISTORY_OPERATION_TYPE_GENESIS": + return ContractCodeHistoryOperationType.CONTRACT_CODE_HISTORY_OPERATION_TYPE_GENESIS; + case -1: + case "UNRECOGNIZED": + default: + return ContractCodeHistoryOperationType.UNRECOGNIZED; + } +} +export function contractCodeHistoryOperationTypeToJSON(object: ContractCodeHistoryOperationType): string { + switch (object) { + case ContractCodeHistoryOperationType.CONTRACT_CODE_HISTORY_OPERATION_TYPE_UNSPECIFIED: + return "CONTRACT_CODE_HISTORY_OPERATION_TYPE_UNSPECIFIED"; + case ContractCodeHistoryOperationType.CONTRACT_CODE_HISTORY_OPERATION_TYPE_INIT: + return "CONTRACT_CODE_HISTORY_OPERATION_TYPE_INIT"; + case ContractCodeHistoryOperationType.CONTRACT_CODE_HISTORY_OPERATION_TYPE_MIGRATE: + return "CONTRACT_CODE_HISTORY_OPERATION_TYPE_MIGRATE"; + case ContractCodeHistoryOperationType.CONTRACT_CODE_HISTORY_OPERATION_TYPE_GENESIS: + return "CONTRACT_CODE_HISTORY_OPERATION_TYPE_GENESIS"; + case ContractCodeHistoryOperationType.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** AccessTypeParam */ +export interface AccessTypeParam { + value: AccessType; +} +export interface AccessTypeParamProtoMsg { + typeUrl: "/cosmwasm.wasm.v1.AccessTypeParam"; + value: Uint8Array; +} +/** AccessTypeParam */ +export interface AccessTypeParamSDKType { + value: AccessType; +} +/** AccessConfig access control type. */ +export interface AccessConfig { + permission: AccessType; + address: string; +} +export interface AccessConfigProtoMsg { + typeUrl: "/cosmwasm.wasm.v1.AccessConfig"; + value: Uint8Array; +} +/** AccessConfig access control type. */ +export interface AccessConfigSDKType { + permission: AccessType; + address: string; +} +/** Params defines the set of wasm parameters. */ +export interface Params { + codeUploadAccess: AccessConfig; + instantiateDefaultPermission: AccessType; + maxWasmCodeSize: bigint; +} +export interface ParamsProtoMsg { + typeUrl: "/cosmwasm.wasm.v1.Params"; + value: Uint8Array; +} +/** Params defines the set of wasm parameters. */ +export interface ParamsSDKType { + code_upload_access: AccessConfigSDKType; + instantiate_default_permission: AccessType; + max_wasm_code_size: bigint; +} +/** CodeInfo is data for the uploaded contract WASM code */ +export interface CodeInfo { + /** CodeHash is the unique identifier created by wasmvm */ + codeHash: Uint8Array; + /** Creator address who initially stored the code */ + creator: string; + /** InstantiateConfig access control to apply on contract creation, optional */ + instantiateConfig: AccessConfig; +} +export interface CodeInfoProtoMsg { + typeUrl: "/cosmwasm.wasm.v1.CodeInfo"; + value: Uint8Array; +} +/** CodeInfo is data for the uploaded contract WASM code */ +export interface CodeInfoSDKType { + code_hash: Uint8Array; + creator: string; + instantiate_config: AccessConfigSDKType; +} +/** ContractInfo stores a WASM contract instance */ +export interface ContractInfo { + /** CodeID is the reference to the stored Wasm code */ + codeId: bigint; + /** Creator address who initially instantiated the contract */ + creator: string; + /** Admin is an optional address that can execute migrations */ + admin: string; + /** Label is optional metadata to be stored with a contract instance. */ + label: string; + /** + * Created Tx position when the contract was instantiated. + * This data should kept internal and not be exposed via query results. Just + * use for sorting + */ + created?: AbsoluteTxPosition; + ibcPortId: string; + /** + * Extension is an extension point to store custom metadata within the + * persistence model. + */ + extension?: Any; +} +export interface ContractInfoProtoMsg { + typeUrl: "/cosmwasm.wasm.v1.ContractInfo"; + value: Uint8Array; +} +/** ContractInfo stores a WASM contract instance */ +export interface ContractInfoSDKType { + code_id: bigint; + creator: string; + admin: string; + label: string; + created?: AbsoluteTxPositionSDKType; + ibc_port_id: string; + extension?: AnySDKType; +} +/** ContractCodeHistoryEntry metadata to a contract. */ +export interface ContractCodeHistoryEntry { + operation: ContractCodeHistoryOperationType; + /** CodeID is the reference to the stored WASM code */ + codeId: bigint; + /** Updated Tx position when the operation was executed. */ + updated?: AbsoluteTxPosition; + msg: Uint8Array; +} +export interface ContractCodeHistoryEntryProtoMsg { + typeUrl: "/cosmwasm.wasm.v1.ContractCodeHistoryEntry"; + value: Uint8Array; +} +/** ContractCodeHistoryEntry metadata to a contract. */ +export interface ContractCodeHistoryEntrySDKType { + operation: ContractCodeHistoryOperationType; + code_id: bigint; + updated?: AbsoluteTxPositionSDKType; + msg: Uint8Array; +} +/** + * AbsoluteTxPosition is a unique transaction position that allows for global + * ordering of transactions. + */ +export interface AbsoluteTxPosition { + /** BlockHeight is the block the contract was created at */ + blockHeight: bigint; + /** + * TxIndex is a monotonic counter within the block (actual transaction index, + * or gas consumed) + */ + txIndex: bigint; +} +export interface AbsoluteTxPositionProtoMsg { + typeUrl: "/cosmwasm.wasm.v1.AbsoluteTxPosition"; + value: Uint8Array; +} +/** + * AbsoluteTxPosition is a unique transaction position that allows for global + * ordering of transactions. + */ +export interface AbsoluteTxPositionSDKType { + block_height: bigint; + tx_index: bigint; +} +/** Model is a struct that holds a KV pair */ +export interface Model { + /** hex-encode key to read it better (this is often ascii) */ + key: Uint8Array; + /** base64-encode raw value */ + value: Uint8Array; +} +export interface ModelProtoMsg { + typeUrl: "/cosmwasm.wasm.v1.Model"; + value: Uint8Array; +} +/** Model is a struct that holds a KV pair */ +export interface ModelSDKType { + key: Uint8Array; + value: Uint8Array; +} +function createBaseAccessTypeParam(): AccessTypeParam { + return { + value: 0 + }; +} +export const AccessTypeParam = { + typeUrl: "/cosmwasm.wasm.v1.AccessTypeParam", + encode(message: AccessTypeParam, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.value !== 0) { + writer.uint32(8).int32(message.value); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): AccessTypeParam { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseAccessTypeParam(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.value = (reader.int32() as any); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): AccessTypeParam { + const obj = createBaseAccessTypeParam(); + if (isSet(object.value)) obj.value = accessTypeFromJSON(object.value); + return obj; + }, + toJSON(message: AccessTypeParam): JsonSafe { + const obj: any = {}; + message.value !== undefined && (obj.value = accessTypeToJSON(message.value)); + return obj; + }, + fromPartial(object: DeepPartial): AccessTypeParam { + const message = createBaseAccessTypeParam(); + message.value = object.value ?? 0; + return message; + }, + fromSDK(object: AccessTypeParamSDKType): AccessTypeParam { + return { + value: isSet(object.value) ? accessTypeFromJSON(object.value) : -1 + }; + }, + fromSDKJSON(object: any): AccessTypeParamSDKType { + return { + value: isSet(object.value) ? accessTypeFromJSON(object.value) : -1 + }; + }, + toSDK(message: AccessTypeParam): AccessTypeParamSDKType { + const obj: any = {}; + message.value !== undefined && (obj.value = accessTypeToJSON(message.value)); + return obj; + }, + fromAmino(object: AccessTypeParamAmino): AccessTypeParam { + const message = createBaseAccessTypeParam(); + if (object.value !== undefined && object.value !== null) { + message.value = object.value; + } + return message; + }, + toAmino(message: AccessTypeParam): AccessTypeParamAmino { + const obj: any = {}; + obj.value = message.value === 0 ? undefined : message.value; + return obj; + }, + fromAminoMsg(object: AccessTypeParamAminoMsg): AccessTypeParam { + return AccessTypeParam.fromAmino(object.value); + }, + toAminoMsg(message: AccessTypeParam): AccessTypeParamAminoMsg { + return { + type: "wasm/AccessTypeParam", + value: AccessTypeParam.toAmino(message) + }; + }, + fromProtoMsg(message: AccessTypeParamProtoMsg): AccessTypeParam { + return AccessTypeParam.decode(message.value); + }, + toProto(message: AccessTypeParam): Uint8Array { + return AccessTypeParam.encode(message).finish(); + }, + toProtoMsg(message: AccessTypeParam): AccessTypeParamProtoMsg { + return { + typeUrl: "/cosmwasm.wasm.v1.AccessTypeParam", + value: AccessTypeParam.encode(message).finish() + }; + } +}; +function createBaseAccessConfig(): AccessConfig { + return { + permission: 0, + address: "" + }; +} +export const AccessConfig = { + typeUrl: "/cosmwasm.wasm.v1.AccessConfig", + encode(message: AccessConfig, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.permission !== 0) { + writer.uint32(8).int32(message.permission); + } + if (message.address !== undefined) { + writer.uint32(18).string(message.address); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): AccessConfig { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseAccessConfig(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.permission = (reader.int32() as any); + break; + case 2: + message.address = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): AccessConfig { + const obj = createBaseAccessConfig(); + if (isSet(object.permission)) obj.permission = accessTypeFromJSON(object.permission); + if (isSet(object.address)) obj.address = String(object.address); + return obj; + }, + toJSON(message: AccessConfig): JsonSafe { + const obj: any = {}; + message.permission !== undefined && (obj.permission = accessTypeToJSON(message.permission)); + message.address !== undefined && (obj.address = message.address); + return obj; + }, + fromPartial(object: DeepPartial): AccessConfig { + const message = createBaseAccessConfig(); + message.permission = object.permission ?? 0; + message.address = object.address ?? ""; + return message; + }, + fromSDK(object: AccessConfigSDKType): AccessConfig { + return { + permission: isSet(object.permission) ? accessTypeFromJSON(object.permission) : -1, + address: object?.address + }; + }, + fromSDKJSON(object: any): AccessConfigSDKType { + return { + permission: isSet(object.permission) ? accessTypeFromJSON(object.permission) : -1, + address: isSet(object.address) ? String(object.address) : "" + }; + }, + toSDK(message: AccessConfig): AccessConfigSDKType { + const obj: any = {}; + message.permission !== undefined && (obj.permission = accessTypeToJSON(message.permission)); + obj.address = message.address; + return obj; + }, + fromAmino(object: AccessConfigAmino): AccessConfig { + const message = createBaseAccessConfig(); + if (object.permission !== undefined && object.permission !== null) { + message.permission = object.permission; + } + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } + return message; + }, + toAmino(message: AccessConfig): AccessConfigAmino { + const obj: any = {}; + obj.permission = message.permission === 0 ? undefined : message.permission; + obj.address = message.address === "" ? undefined : message.address; + return obj; + }, + fromAminoMsg(object: AccessConfigAminoMsg): AccessConfig { + return AccessConfig.fromAmino(object.value); + }, + toAminoMsg(message: AccessConfig): AccessConfigAminoMsg { + return { + type: "wasm/AccessConfig", + value: AccessConfig.toAmino(message) + }; + }, + fromProtoMsg(message: AccessConfigProtoMsg): AccessConfig { + return AccessConfig.decode(message.value); + }, + toProto(message: AccessConfig): Uint8Array { + return AccessConfig.encode(message).finish(); + }, + toProtoMsg(message: AccessConfig): AccessConfigProtoMsg { + return { + typeUrl: "/cosmwasm.wasm.v1.AccessConfig", + value: AccessConfig.encode(message).finish() + }; + } +}; +function createBaseParams(): Params { + return { + codeUploadAccess: AccessConfig.fromPartial({}), + instantiateDefaultPermission: 0, + maxWasmCodeSize: BigInt(0) + }; +} +export const Params = { + typeUrl: "/cosmwasm.wasm.v1.Params", + encode(message: Params, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.codeUploadAccess !== undefined) { + AccessConfig.encode(message.codeUploadAccess, writer.uint32(10).fork()).ldelim(); + } + if (message.instantiateDefaultPermission !== 0) { + writer.uint32(16).int32(message.instantiateDefaultPermission); + } + if (message.maxWasmCodeSize !== undefined) { + writer.uint32(24).uint64(message.maxWasmCodeSize); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Params { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseParams(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.codeUploadAccess = AccessConfig.decode(reader, reader.uint32()); + break; + case 2: + message.instantiateDefaultPermission = (reader.int32() as any); + break; + case 3: + message.maxWasmCodeSize = reader.uint64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Params { + const obj = createBaseParams(); + if (isSet(object.codeUploadAccess)) obj.codeUploadAccess = AccessConfig.fromJSON(object.codeUploadAccess); + if (isSet(object.instantiateDefaultPermission)) obj.instantiateDefaultPermission = accessTypeFromJSON(object.instantiateDefaultPermission); + if (isSet(object.maxWasmCodeSize)) obj.maxWasmCodeSize = BigInt(object.maxWasmCodeSize.toString()); + return obj; + }, + toJSON(message: Params): JsonSafe { + const obj: any = {}; + message.codeUploadAccess !== undefined && (obj.codeUploadAccess = message.codeUploadAccess ? AccessConfig.toJSON(message.codeUploadAccess) : undefined); + message.instantiateDefaultPermission !== undefined && (obj.instantiateDefaultPermission = accessTypeToJSON(message.instantiateDefaultPermission)); + message.maxWasmCodeSize !== undefined && (obj.maxWasmCodeSize = (message.maxWasmCodeSize || BigInt(0)).toString()); + return obj; + }, + fromPartial(object: DeepPartial): Params { + const message = createBaseParams(); + if (object.codeUploadAccess !== undefined && object.codeUploadAccess !== null) { + message.codeUploadAccess = AccessConfig.fromPartial(object.codeUploadAccess); + } + message.instantiateDefaultPermission = object.instantiateDefaultPermission ?? 0; + if (object.maxWasmCodeSize !== undefined && object.maxWasmCodeSize !== null) { + message.maxWasmCodeSize = BigInt(object.maxWasmCodeSize.toString()); + } + return message; + }, + fromSDK(object: ParamsSDKType): Params { + return { + codeUploadAccess: object.code_upload_access ? AccessConfig.fromSDK(object.code_upload_access) : undefined, + instantiateDefaultPermission: isSet(object.instantiate_default_permission) ? accessTypeFromJSON(object.instantiate_default_permission) : -1, + maxWasmCodeSize: object?.max_wasm_code_size + }; + }, + fromSDKJSON(object: any): ParamsSDKType { + return { + code_upload_access: isSet(object.code_upload_access) ? AccessConfig.fromSDKJSON(object.code_upload_access) : undefined, + instantiate_default_permission: isSet(object.instantiate_default_permission) ? accessTypeFromJSON(object.instantiate_default_permission) : -1, + max_wasm_code_size: isSet(object.max_wasm_code_size) ? BigInt(object.max_wasm_code_size.toString()) : BigInt(0) + }; + }, + toSDK(message: Params): ParamsSDKType { + const obj: any = {}; + message.codeUploadAccess !== undefined && (obj.code_upload_access = message.codeUploadAccess ? AccessConfig.toSDK(message.codeUploadAccess) : undefined); + message.instantiateDefaultPermission !== undefined && (obj.instantiate_default_permission = accessTypeToJSON(message.instantiateDefaultPermission)); + obj.max_wasm_code_size = message.maxWasmCodeSize; + return obj; + }, + fromAmino(object: ParamsAmino): Params { + const message = createBaseParams(); + if (object.code_upload_access !== undefined && object.code_upload_access !== null) { + message.codeUploadAccess = AccessConfig.fromAmino(object.code_upload_access); + } + if (object.instantiate_default_permission !== undefined && object.instantiate_default_permission !== null) { + message.instantiateDefaultPermission = object.instantiate_default_permission; + } + if (object.max_wasm_code_size !== undefined && object.max_wasm_code_size !== null) { + message.maxWasmCodeSize = BigInt(object.max_wasm_code_size); + } + return message; + }, + toAmino(message: Params): ParamsAmino { + const obj: any = {}; + obj.code_upload_access = message.codeUploadAccess ? AccessConfig.toAmino(message.codeUploadAccess) : undefined; + obj.instantiate_default_permission = message.instantiateDefaultPermission === 0 ? undefined : message.instantiateDefaultPermission; + obj.max_wasm_code_size = message.maxWasmCodeSize !== BigInt(0) ? message.maxWasmCodeSize?.toString() : undefined; + return obj; + }, + fromAminoMsg(object: ParamsAminoMsg): Params { + return Params.fromAmino(object.value); + }, + toAminoMsg(message: Params): ParamsAminoMsg { + return { + type: "wasm/Params", + value: Params.toAmino(message) + }; + }, + fromProtoMsg(message: ParamsProtoMsg): Params { + return Params.decode(message.value); + }, + toProto(message: Params): Uint8Array { + return Params.encode(message).finish(); + }, + toProtoMsg(message: Params): ParamsProtoMsg { + return { + typeUrl: "/cosmwasm.wasm.v1.Params", + value: Params.encode(message).finish() + }; + } +}; +function createBaseCodeInfo(): CodeInfo { + return { + codeHash: new Uint8Array(), + creator: "", + instantiateConfig: AccessConfig.fromPartial({}) + }; +} +export const CodeInfo = { + typeUrl: "/cosmwasm.wasm.v1.CodeInfo", + encode(message: CodeInfo, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.codeHash.length !== 0) { + writer.uint32(10).bytes(message.codeHash); + } + if (message.creator !== undefined) { + writer.uint32(18).string(message.creator); + } + if (message.instantiateConfig !== undefined) { + AccessConfig.encode(message.instantiateConfig, writer.uint32(42).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): CodeInfo { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCodeInfo(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.codeHash = reader.bytes(); + break; + case 2: + message.creator = reader.string(); + break; + case 5: + message.instantiateConfig = AccessConfig.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): CodeInfo { + const obj = createBaseCodeInfo(); + if (isSet(object.codeHash)) obj.codeHash = bytesFromBase64(object.codeHash); + if (isSet(object.creator)) obj.creator = String(object.creator); + if (isSet(object.instantiateConfig)) obj.instantiateConfig = AccessConfig.fromJSON(object.instantiateConfig); + return obj; + }, + toJSON(message: CodeInfo): JsonSafe { + const obj: any = {}; + message.codeHash !== undefined && (obj.codeHash = base64FromBytes(message.codeHash !== undefined ? message.codeHash : new Uint8Array())); + message.creator !== undefined && (obj.creator = message.creator); + message.instantiateConfig !== undefined && (obj.instantiateConfig = message.instantiateConfig ? AccessConfig.toJSON(message.instantiateConfig) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): CodeInfo { + const message = createBaseCodeInfo(); + message.codeHash = object.codeHash ?? new Uint8Array(); + message.creator = object.creator ?? ""; + if (object.instantiateConfig !== undefined && object.instantiateConfig !== null) { + message.instantiateConfig = AccessConfig.fromPartial(object.instantiateConfig); + } + return message; + }, + fromSDK(object: CodeInfoSDKType): CodeInfo { + return { + codeHash: object?.code_hash, + creator: object?.creator, + instantiateConfig: object.instantiate_config ? AccessConfig.fromSDK(object.instantiate_config) : undefined + }; + }, + fromSDKJSON(object: any): CodeInfoSDKType { + return { + code_hash: isSet(object.code_hash) ? bytesFromBase64(object.code_hash) : new Uint8Array(), + creator: isSet(object.creator) ? String(object.creator) : "", + instantiate_config: isSet(object.instantiate_config) ? AccessConfig.fromSDKJSON(object.instantiate_config) : undefined + }; + }, + toSDK(message: CodeInfo): CodeInfoSDKType { + const obj: any = {}; + obj.code_hash = message.codeHash; + obj.creator = message.creator; + message.instantiateConfig !== undefined && (obj.instantiate_config = message.instantiateConfig ? AccessConfig.toSDK(message.instantiateConfig) : undefined); + return obj; + }, + fromAmino(object: CodeInfoAmino): CodeInfo { + const message = createBaseCodeInfo(); + if (object.code_hash !== undefined && object.code_hash !== null) { + message.codeHash = bytesFromBase64(object.code_hash); + } + if (object.creator !== undefined && object.creator !== null) { + message.creator = object.creator; + } + if (object.instantiate_config !== undefined && object.instantiate_config !== null) { + message.instantiateConfig = AccessConfig.fromAmino(object.instantiate_config); + } + return message; + }, + toAmino(message: CodeInfo): CodeInfoAmino { + const obj: any = {}; + obj.code_hash = message.codeHash ? base64FromBytes(message.codeHash) : undefined; + obj.creator = message.creator === "" ? undefined : message.creator; + obj.instantiate_config = message.instantiateConfig ? AccessConfig.toAmino(message.instantiateConfig) : undefined; + return obj; + }, + fromAminoMsg(object: CodeInfoAminoMsg): CodeInfo { + return CodeInfo.fromAmino(object.value); + }, + toAminoMsg(message: CodeInfo): CodeInfoAminoMsg { + return { + type: "wasm/CodeInfo", + value: CodeInfo.toAmino(message) + }; + }, + fromProtoMsg(message: CodeInfoProtoMsg): CodeInfo { + return CodeInfo.decode(message.value); + }, + toProto(message: CodeInfo): Uint8Array { + return CodeInfo.encode(message).finish(); + }, + toProtoMsg(message: CodeInfo): CodeInfoProtoMsg { + return { + typeUrl: "/cosmwasm.wasm.v1.CodeInfo", + value: CodeInfo.encode(message).finish() + }; + } +}; +function createBaseContractInfo(): ContractInfo { + return { + codeId: BigInt(0), + creator: "", + admin: "", + label: "", + created: undefined, + ibcPortId: "", + extension: undefined + }; +} +export const ContractInfo = { + typeUrl: "/cosmwasm.wasm.v1.ContractInfo", + encode(message: ContractInfo, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.codeId !== undefined) { + writer.uint32(8).uint64(message.codeId); + } + if (message.creator !== undefined) { + writer.uint32(18).string(message.creator); + } + if (message.admin !== undefined) { + writer.uint32(26).string(message.admin); + } + if (message.label !== undefined) { + writer.uint32(34).string(message.label); + } + if (message.created !== undefined) { + AbsoluteTxPosition.encode(message.created, writer.uint32(42).fork()).ldelim(); + } + if (message.ibcPortId !== undefined) { + writer.uint32(50).string(message.ibcPortId); + } + if (message.extension !== undefined) { + Any.encode(message.extension, writer.uint32(58).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ContractInfo { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseContractInfo(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.codeId = reader.uint64(); + break; + case 2: + message.creator = reader.string(); + break; + case 3: + message.admin = reader.string(); + break; + case 4: + message.label = reader.string(); + break; + case 5: + message.created = AbsoluteTxPosition.decode(reader, reader.uint32()); + break; + case 6: + message.ibcPortId = reader.string(); + break; + case 7: + message.extension = Any.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ContractInfo { + const obj = createBaseContractInfo(); + if (isSet(object.codeId)) obj.codeId = BigInt(object.codeId.toString()); + if (isSet(object.creator)) obj.creator = String(object.creator); + if (isSet(object.admin)) obj.admin = String(object.admin); + if (isSet(object.label)) obj.label = String(object.label); + if (isSet(object.created)) obj.created = AbsoluteTxPosition.fromJSON(object.created); + if (isSet(object.ibcPortId)) obj.ibcPortId = String(object.ibcPortId); + if (isSet(object.extension)) obj.extension = Any.fromJSON(object.extension); + return obj; + }, + toJSON(message: ContractInfo): JsonSafe { + const obj: any = {}; + message.codeId !== undefined && (obj.codeId = (message.codeId || BigInt(0)).toString()); + message.creator !== undefined && (obj.creator = message.creator); + message.admin !== undefined && (obj.admin = message.admin); + message.label !== undefined && (obj.label = message.label); + message.created !== undefined && (obj.created = message.created ? AbsoluteTxPosition.toJSON(message.created) : undefined); + message.ibcPortId !== undefined && (obj.ibcPortId = message.ibcPortId); + message.extension !== undefined && (obj.extension = message.extension ? Any.toJSON(message.extension) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): ContractInfo { + const message = createBaseContractInfo(); + if (object.codeId !== undefined && object.codeId !== null) { + message.codeId = BigInt(object.codeId.toString()); + } + message.creator = object.creator ?? ""; + message.admin = object.admin ?? ""; + message.label = object.label ?? ""; + if (object.created !== undefined && object.created !== null) { + message.created = AbsoluteTxPosition.fromPartial(object.created); + } + message.ibcPortId = object.ibcPortId ?? ""; + if (object.extension !== undefined && object.extension !== null) { + message.extension = Any.fromPartial(object.extension); + } + return message; + }, + fromSDK(object: ContractInfoSDKType): ContractInfo { + return { + codeId: object?.code_id, + creator: object?.creator, + admin: object?.admin, + label: object?.label, + created: object.created ? AbsoluteTxPosition.fromSDK(object.created) : undefined, + ibcPortId: object?.ibc_port_id, + extension: object.extension ? Any.fromSDK(object.extension) : undefined + }; + }, + fromSDKJSON(object: any): ContractInfoSDKType { + return { + code_id: isSet(object.code_id) ? BigInt(object.code_id.toString()) : BigInt(0), + creator: isSet(object.creator) ? String(object.creator) : "", + admin: isSet(object.admin) ? String(object.admin) : "", + label: isSet(object.label) ? String(object.label) : "", + created: isSet(object.created) ? AbsoluteTxPosition.fromSDKJSON(object.created) : undefined, + ibc_port_id: isSet(object.ibc_port_id) ? String(object.ibc_port_id) : "", + extension: isSet(object.extension) ? Any.fromSDKJSON(object.extension) : undefined + }; + }, + toSDK(message: ContractInfo): ContractInfoSDKType { + const obj: any = {}; + obj.code_id = message.codeId; + obj.creator = message.creator; + obj.admin = message.admin; + obj.label = message.label; + message.created !== undefined && (obj.created = message.created ? AbsoluteTxPosition.toSDK(message.created) : undefined); + obj.ibc_port_id = message.ibcPortId; + message.extension !== undefined && (obj.extension = message.extension ? Any.toSDK(message.extension) : undefined); + return obj; + }, + fromAmino(object: ContractInfoAmino): ContractInfo { + const message = createBaseContractInfo(); + if (object.code_id !== undefined && object.code_id !== null) { + message.codeId = BigInt(object.code_id); + } + if (object.creator !== undefined && object.creator !== null) { + message.creator = object.creator; + } + if (object.admin !== undefined && object.admin !== null) { + message.admin = object.admin; + } + if (object.label !== undefined && object.label !== null) { + message.label = object.label; + } + if (object.created !== undefined && object.created !== null) { + message.created = AbsoluteTxPosition.fromAmino(object.created); + } + if (object.ibc_port_id !== undefined && object.ibc_port_id !== null) { + message.ibcPortId = object.ibc_port_id; + } + if (object.extension !== undefined && object.extension !== null) { + message.extension = Any.fromAmino(object.extension); + } + return message; + }, + toAmino(message: ContractInfo): ContractInfoAmino { + const obj: any = {}; + obj.code_id = message.codeId !== BigInt(0) ? message.codeId?.toString() : undefined; + obj.creator = message.creator === "" ? undefined : message.creator; + obj.admin = message.admin === "" ? undefined : message.admin; + obj.label = message.label === "" ? undefined : message.label; + obj.created = message.created ? AbsoluteTxPosition.toAmino(message.created) : undefined; + obj.ibc_port_id = message.ibcPortId === "" ? undefined : message.ibcPortId; + obj.extension = message.extension ? Any.toAmino(message.extension) : undefined; + return obj; + }, + fromAminoMsg(object: ContractInfoAminoMsg): ContractInfo { + return ContractInfo.fromAmino(object.value); + }, + toAminoMsg(message: ContractInfo): ContractInfoAminoMsg { + return { + type: "wasm/ContractInfo", + value: ContractInfo.toAmino(message) + }; + }, + fromProtoMsg(message: ContractInfoProtoMsg): ContractInfo { + return ContractInfo.decode(message.value); + }, + toProto(message: ContractInfo): Uint8Array { + return ContractInfo.encode(message).finish(); + }, + toProtoMsg(message: ContractInfo): ContractInfoProtoMsg { + return { + typeUrl: "/cosmwasm.wasm.v1.ContractInfo", + value: ContractInfo.encode(message).finish() + }; + } +}; +function createBaseContractCodeHistoryEntry(): ContractCodeHistoryEntry { + return { + operation: 0, + codeId: BigInt(0), + updated: undefined, + msg: new Uint8Array() + }; +} +export const ContractCodeHistoryEntry = { + typeUrl: "/cosmwasm.wasm.v1.ContractCodeHistoryEntry", + encode(message: ContractCodeHistoryEntry, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.operation !== 0) { + writer.uint32(8).int32(message.operation); + } + if (message.codeId !== undefined) { + writer.uint32(16).uint64(message.codeId); + } + if (message.updated !== undefined) { + AbsoluteTxPosition.encode(message.updated, writer.uint32(26).fork()).ldelim(); + } + if (message.msg.length !== 0) { + writer.uint32(34).bytes(message.msg); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ContractCodeHistoryEntry { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseContractCodeHistoryEntry(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.operation = (reader.int32() as any); + break; + case 2: + message.codeId = reader.uint64(); + break; + case 3: + message.updated = AbsoluteTxPosition.decode(reader, reader.uint32()); + break; + case 4: + message.msg = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ContractCodeHistoryEntry { + const obj = createBaseContractCodeHistoryEntry(); + if (isSet(object.operation)) obj.operation = contractCodeHistoryOperationTypeFromJSON(object.operation); + if (isSet(object.codeId)) obj.codeId = BigInt(object.codeId.toString()); + if (isSet(object.updated)) obj.updated = AbsoluteTxPosition.fromJSON(object.updated); + if (isSet(object.msg)) obj.msg = bytesFromBase64(object.msg); + return obj; + }, + toJSON(message: ContractCodeHistoryEntry): JsonSafe { + const obj: any = {}; + message.operation !== undefined && (obj.operation = contractCodeHistoryOperationTypeToJSON(message.operation)); + message.codeId !== undefined && (obj.codeId = (message.codeId || BigInt(0)).toString()); + message.updated !== undefined && (obj.updated = message.updated ? AbsoluteTxPosition.toJSON(message.updated) : undefined); + message.msg !== undefined && (obj.msg = base64FromBytes(message.msg !== undefined ? message.msg : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): ContractCodeHistoryEntry { + const message = createBaseContractCodeHistoryEntry(); + message.operation = object.operation ?? 0; + if (object.codeId !== undefined && object.codeId !== null) { + message.codeId = BigInt(object.codeId.toString()); + } + if (object.updated !== undefined && object.updated !== null) { + message.updated = AbsoluteTxPosition.fromPartial(object.updated); + } + message.msg = object.msg ?? new Uint8Array(); + return message; + }, + fromSDK(object: ContractCodeHistoryEntrySDKType): ContractCodeHistoryEntry { + return { + operation: isSet(object.operation) ? contractCodeHistoryOperationTypeFromJSON(object.operation) : -1, + codeId: object?.code_id, + updated: object.updated ? AbsoluteTxPosition.fromSDK(object.updated) : undefined, + msg: object?.msg + }; + }, + fromSDKJSON(object: any): ContractCodeHistoryEntrySDKType { + return { + operation: isSet(object.operation) ? contractCodeHistoryOperationTypeFromJSON(object.operation) : -1, + code_id: isSet(object.code_id) ? BigInt(object.code_id.toString()) : BigInt(0), + updated: isSet(object.updated) ? AbsoluteTxPosition.fromSDKJSON(object.updated) : undefined, + msg: isSet(object.msg) ? bytesFromBase64(object.msg) : new Uint8Array() + }; + }, + toSDK(message: ContractCodeHistoryEntry): ContractCodeHistoryEntrySDKType { + const obj: any = {}; + message.operation !== undefined && (obj.operation = contractCodeHistoryOperationTypeToJSON(message.operation)); + obj.code_id = message.codeId; + message.updated !== undefined && (obj.updated = message.updated ? AbsoluteTxPosition.toSDK(message.updated) : undefined); + obj.msg = message.msg; + return obj; + }, + fromAmino(object: ContractCodeHistoryEntryAmino): ContractCodeHistoryEntry { + const message = createBaseContractCodeHistoryEntry(); + if (object.operation !== undefined && object.operation !== null) { + message.operation = object.operation; + } + if (object.code_id !== undefined && object.code_id !== null) { + message.codeId = BigInt(object.code_id); + } + if (object.updated !== undefined && object.updated !== null) { + message.updated = AbsoluteTxPosition.fromAmino(object.updated); + } + if (object.msg !== undefined && object.msg !== null) { + message.msg = toUtf8(JSON.stringify(object.msg)); + } + return message; + }, + toAmino(message: ContractCodeHistoryEntry): ContractCodeHistoryEntryAmino { + const obj: any = {}; + obj.operation = message.operation === 0 ? undefined : message.operation; + obj.code_id = message.codeId !== BigInt(0) ? message.codeId?.toString() : undefined; + obj.updated = message.updated ? AbsoluteTxPosition.toAmino(message.updated) : undefined; + obj.msg = message.msg ? JSON.parse(fromUtf8(message.msg)) : undefined; + return obj; + }, + fromAminoMsg(object: ContractCodeHistoryEntryAminoMsg): ContractCodeHistoryEntry { + return ContractCodeHistoryEntry.fromAmino(object.value); + }, + toAminoMsg(message: ContractCodeHistoryEntry): ContractCodeHistoryEntryAminoMsg { + return { + type: "wasm/ContractCodeHistoryEntry", + value: ContractCodeHistoryEntry.toAmino(message) + }; + }, + fromProtoMsg(message: ContractCodeHistoryEntryProtoMsg): ContractCodeHistoryEntry { + return ContractCodeHistoryEntry.decode(message.value); + }, + toProto(message: ContractCodeHistoryEntry): Uint8Array { + return ContractCodeHistoryEntry.encode(message).finish(); + }, + toProtoMsg(message: ContractCodeHistoryEntry): ContractCodeHistoryEntryProtoMsg { + return { + typeUrl: "/cosmwasm.wasm.v1.ContractCodeHistoryEntry", + value: ContractCodeHistoryEntry.encode(message).finish() + }; + } +}; +function createBaseAbsoluteTxPosition(): AbsoluteTxPosition { + return { + blockHeight: BigInt(0), + txIndex: BigInt(0) + }; +} +export const AbsoluteTxPosition = { + typeUrl: "/cosmwasm.wasm.v1.AbsoluteTxPosition", + encode(message: AbsoluteTxPosition, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.blockHeight !== undefined) { + writer.uint32(8).uint64(message.blockHeight); + } + if (message.txIndex !== undefined) { + writer.uint32(16).uint64(message.txIndex); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): AbsoluteTxPosition { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseAbsoluteTxPosition(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.blockHeight = reader.uint64(); + break; + case 2: + message.txIndex = reader.uint64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): AbsoluteTxPosition { + const obj = createBaseAbsoluteTxPosition(); + if (isSet(object.blockHeight)) obj.blockHeight = BigInt(object.blockHeight.toString()); + if (isSet(object.txIndex)) obj.txIndex = BigInt(object.txIndex.toString()); + return obj; + }, + toJSON(message: AbsoluteTxPosition): JsonSafe { + const obj: any = {}; + message.blockHeight !== undefined && (obj.blockHeight = (message.blockHeight || BigInt(0)).toString()); + message.txIndex !== undefined && (obj.txIndex = (message.txIndex || BigInt(0)).toString()); + return obj; + }, + fromPartial(object: DeepPartial): AbsoluteTxPosition { + const message = createBaseAbsoluteTxPosition(); + if (object.blockHeight !== undefined && object.blockHeight !== null) { + message.blockHeight = BigInt(object.blockHeight.toString()); + } + if (object.txIndex !== undefined && object.txIndex !== null) { + message.txIndex = BigInt(object.txIndex.toString()); + } + return message; + }, + fromSDK(object: AbsoluteTxPositionSDKType): AbsoluteTxPosition { + return { + blockHeight: object?.block_height, + txIndex: object?.tx_index + }; + }, + fromSDKJSON(object: any): AbsoluteTxPositionSDKType { + return { + block_height: isSet(object.block_height) ? BigInt(object.block_height.toString()) : BigInt(0), + tx_index: isSet(object.tx_index) ? BigInt(object.tx_index.toString()) : BigInt(0) + }; + }, + toSDK(message: AbsoluteTxPosition): AbsoluteTxPositionSDKType { + const obj: any = {}; + obj.block_height = message.blockHeight; + obj.tx_index = message.txIndex; + return obj; + }, + fromAmino(object: AbsoluteTxPositionAmino): AbsoluteTxPosition { + const message = createBaseAbsoluteTxPosition(); + if (object.block_height !== undefined && object.block_height !== null) { + message.blockHeight = BigInt(object.block_height); + } + if (object.tx_index !== undefined && object.tx_index !== null) { + message.txIndex = BigInt(object.tx_index); + } + return message; + }, + toAmino(message: AbsoluteTxPosition): AbsoluteTxPositionAmino { + const obj: any = {}; + obj.block_height = message.blockHeight !== BigInt(0) ? message.blockHeight?.toString() : undefined; + obj.tx_index = message.txIndex !== BigInt(0) ? message.txIndex?.toString() : undefined; + return obj; + }, + fromAminoMsg(object: AbsoluteTxPositionAminoMsg): AbsoluteTxPosition { + return AbsoluteTxPosition.fromAmino(object.value); + }, + toAminoMsg(message: AbsoluteTxPosition): AbsoluteTxPositionAminoMsg { + return { + type: "wasm/AbsoluteTxPosition", + value: AbsoluteTxPosition.toAmino(message) + }; + }, + fromProtoMsg(message: AbsoluteTxPositionProtoMsg): AbsoluteTxPosition { + return AbsoluteTxPosition.decode(message.value); + }, + toProto(message: AbsoluteTxPosition): Uint8Array { + return AbsoluteTxPosition.encode(message).finish(); + }, + toProtoMsg(message: AbsoluteTxPosition): AbsoluteTxPositionProtoMsg { + return { + typeUrl: "/cosmwasm.wasm.v1.AbsoluteTxPosition", + value: AbsoluteTxPosition.encode(message).finish() + }; + } +}; +function createBaseModel(): Model { + return { + key: new Uint8Array(), + value: new Uint8Array() + }; +} +export const Model = { + typeUrl: "/cosmwasm.wasm.v1.Model", + encode(message: Model, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.key.length !== 0) { + writer.uint32(10).bytes(message.key); + } + if (message.value.length !== 0) { + writer.uint32(18).bytes(message.value); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Model { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseModel(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.bytes(); + break; + case 2: + message.value = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Model { + const obj = createBaseModel(); + if (isSet(object.key)) obj.key = bytesFromBase64(object.key); + if (isSet(object.value)) obj.value = bytesFromBase64(object.value); + return obj; + }, + toJSON(message: Model): JsonSafe { + const obj: any = {}; + message.key !== undefined && (obj.key = base64FromBytes(message.key !== undefined ? message.key : new Uint8Array())); + message.value !== undefined && (obj.value = base64FromBytes(message.value !== undefined ? message.value : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): Model { + const message = createBaseModel(); + message.key = object.key ?? new Uint8Array(); + message.value = object.value ?? new Uint8Array(); + return message; + }, + fromSDK(object: ModelSDKType): Model { + return { + key: object?.key, + value: object?.value + }; + }, + fromSDKJSON(object: any): ModelSDKType { + return { + key: isSet(object.key) ? bytesFromBase64(object.key) : new Uint8Array(), + value: isSet(object.value) ? bytesFromBase64(object.value) : new Uint8Array() + }; + }, + toSDK(message: Model): ModelSDKType { + const obj: any = {}; + obj.key = message.key; + obj.value = message.value; + return obj; + }, + fromAmino(object: ModelAmino): Model { + const message = createBaseModel(); + if (object.key !== undefined && object.key !== null) { + message.key = bytesFromBase64(object.key); + } + if (object.value !== undefined && object.value !== null) { + message.value = bytesFromBase64(object.value); + } + return message; + }, + toAmino(message: Model): ModelAmino { + const obj: any = {}; + obj.key = message.key ? base64FromBytes(message.key) : undefined; + obj.value = message.value ? base64FromBytes(message.value) : undefined; + return obj; + }, + fromAminoMsg(object: ModelAminoMsg): Model { + return Model.fromAmino(object.value); + }, + toAminoMsg(message: Model): ModelAminoMsg { + return { + type: "wasm/Model", + value: Model.toAmino(message) + }; + }, + fromProtoMsg(message: ModelProtoMsg): Model { + return Model.decode(message.value); + }, + toProto(message: Model): Uint8Array { + return Model.encode(message).finish(); + }, + toProtoMsg(message: Model): ModelProtoMsg { + return { + typeUrl: "/cosmwasm.wasm.v1.Model", + value: Model.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/evmos/bundle.ts b/__fixtures__/v-next/outputicjsdeps/evmos/bundle.ts new file mode 100644 index 0000000000..a56ca08f5e --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/evmos/bundle.ts @@ -0,0 +1,148 @@ +import * as _153 from "./claims/v1/claims.js"; +import * as _154 from "./claims/v1/genesis.js"; +import * as _155 from "./claims/v1/query.js"; +import * as _156 from "./epochs/v1/genesis.js"; +import * as _157 from "./epochs/v1/query.js"; +import * as _158 from "./erc20/v1/erc20.js"; +import * as _159 from "./erc20/v1/genesis.js"; +import * as _160 from "./erc20/v1/query.js"; +import * as _161 from "./erc20/v1/tx.js"; +import * as _162 from "./fees/v1/fees.js"; +import * as _163 from "./fees/v1/genesis.js"; +import * as _164 from "./fees/v1/query.js"; +import * as _165 from "./fees/v1/tx.js"; +import * as _166 from "./incentives/v1/genesis.js"; +import * as _167 from "./incentives/v1/incentives.js"; +import * as _168 from "./incentives/v1/query.js"; +import * as _169 from "./inflation/v1/genesis.js"; +import * as _170 from "./inflation/v1/inflation.js"; +import * as _171 from "./inflation/v1/query.js"; +import * as _172 from "./recovery/v1/genesis.js"; +import * as _173 from "./recovery/v1/query.js"; +import * as _174 from "./vesting/v1/query.js"; +import * as _175 from "./vesting/v1/tx.js"; +import * as _176 from "./vesting/v1/vesting.js"; +import * as _439 from "./erc20/v1/tx.amino.js"; +import * as _440 from "./fees/v1/tx.amino.js"; +import * as _441 from "./vesting/v1/tx.amino.js"; +import * as _442 from "./erc20/v1/tx.registry.js"; +import * as _443 from "./fees/v1/tx.registry.js"; +import * as _444 from "./vesting/v1/tx.registry.js"; +import * as _445 from "./claims/v1/query.lcd.js"; +import * as _446 from "./epochs/v1/query.lcd.js"; +import * as _447 from "./erc20/v1/query.lcd.js"; +import * as _448 from "./fees/v1/query.lcd.js"; +import * as _449 from "./incentives/v1/query.lcd.js"; +import * as _450 from "./inflation/v1/query.lcd.js"; +import * as _451 from "./recovery/v1/query.lcd.js"; +import * as _452 from "./vesting/v1/query.lcd.js"; +import * as _453 from "./claims/v1/query.rpc.Query.js"; +import * as _454 from "./epochs/v1/query.rpc.Query.js"; +import * as _455 from "./erc20/v1/query.rpc.Query.js"; +import * as _456 from "./fees/v1/query.rpc.Query.js"; +import * as _457 from "./incentives/v1/query.rpc.Query.js"; +import * as _458 from "./inflation/v1/query.rpc.Query.js"; +import * as _459 from "./recovery/v1/query.rpc.Query.js"; +import * as _460 from "./vesting/v1/query.rpc.Query.js"; +import * as _461 from "./erc20/v1/tx.rpc.msg.js"; +import * as _462 from "./fees/v1/tx.rpc.msg.js"; +import * as _463 from "./vesting/v1/tx.rpc.msg.js"; +import * as _464 from "./erc20/v1/query.pinia.store.js"; +import * as _547 from "./lcd.js"; +import * as _548 from "./custom-lcd-client.js"; +import * as _549 from "./rpc.query.js"; +import * as _550 from "./evmos-rpc-client.query.js"; +import * as _551 from "./rpc.tx.js"; +import * as _552 from "./evmos-rpc-client.tx.js"; +export namespace evmos { + export namespace claims { + export const v1 = { + ..._153, + ..._154, + ..._155, + ..._445, + ..._453 + }; + } + export namespace epochs { + export const v1 = { + ..._156, + ..._157, + ..._446, + ..._454 + }; + } + export namespace erc20 { + export const v1 = { + ..._158, + ..._159, + ..._160, + ..._161, + ..._439, + ..._442, + ..._447, + ..._455, + ..._461, + ..._464 + }; + } + export namespace fees { + export const v1 = { + ..._162, + ..._163, + ..._164, + ..._165, + ..._440, + ..._443, + ..._448, + ..._456, + ..._462 + }; + } + export namespace incentives { + export const v1 = { + ..._166, + ..._167, + ..._168, + ..._449, + ..._457 + }; + } + export namespace inflation { + export const v1 = { + ..._169, + ..._170, + ..._171, + ..._450, + ..._458 + }; + } + export namespace recovery { + export const v1 = { + ..._172, + ..._173, + ..._451, + ..._459 + }; + } + export namespace vesting { + export const v1 = { + ..._174, + ..._175, + ..._176, + ..._441, + ..._444, + ..._452, + ..._460, + ..._463 + }; + } + export const ClientFactory = { + ..._547, + ..._548, + ..._549, + ..._550, + ..._551, + ..._552 + }; +} \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/evmos/claims/v1/claims.ts b/__fixtures__/v-next/outputicjsdeps/evmos/claims/v1/claims.ts new file mode 100644 index 0000000000..4bc258e731 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/evmos/claims/v1/claims.ts @@ -0,0 +1,512 @@ +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "evmos.claims.v1"; +/** Action defines the list of available actions to claim the airdrop tokens. */ +export enum Action { + /** ACTION_UNSPECIFIED - UNSPECIFIED defines an invalid action. */ + ACTION_UNSPECIFIED = 0, + /** ACTION_VOTE - VOTE defines a proposal vote. */ + ACTION_VOTE = 1, + /** ACTION_DELEGATE - DELEGATE defines an staking delegation. */ + ACTION_DELEGATE = 2, + /** ACTION_EVM - EVM defines an EVM transaction. */ + ACTION_EVM = 3, + /** ACTION_IBC_TRANSFER - IBC Transfer defines a fungible token transfer transaction via IBC. */ + ACTION_IBC_TRANSFER = 4, + UNRECOGNIZED = -1, +} +export const ActionSDKType = Action; +export function actionFromJSON(object: any): Action { + switch (object) { + case 0: + case "ACTION_UNSPECIFIED": + return Action.ACTION_UNSPECIFIED; + case 1: + case "ACTION_VOTE": + return Action.ACTION_VOTE; + case 2: + case "ACTION_DELEGATE": + return Action.ACTION_DELEGATE; + case 3: + case "ACTION_EVM": + return Action.ACTION_EVM; + case 4: + case "ACTION_IBC_TRANSFER": + return Action.ACTION_IBC_TRANSFER; + case -1: + case "UNRECOGNIZED": + default: + return Action.UNRECOGNIZED; + } +} +export function actionToJSON(object: Action): string { + switch (object) { + case Action.ACTION_UNSPECIFIED: + return "ACTION_UNSPECIFIED"; + case Action.ACTION_VOTE: + return "ACTION_VOTE"; + case Action.ACTION_DELEGATE: + return "ACTION_DELEGATE"; + case Action.ACTION_EVM: + return "ACTION_EVM"; + case Action.ACTION_IBC_TRANSFER: + return "ACTION_IBC_TRANSFER"; + case Action.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** + * Claim defines the action, completed flag and the remaining claimable amount + * for a given user. This is only used during client queries. + */ +export interface Claim { + /** action enum */ + action: Action; + /** true if the action has been completed */ + completed: boolean; + /** claimable token amount for the action. Zero if completed */ + claimableAmount: string; +} +export interface ClaimProtoMsg { + typeUrl: "/evmos.claims.v1.Claim"; + value: Uint8Array; +} +/** + * Claim defines the action, completed flag and the remaining claimable amount + * for a given user. This is only used during client queries. + */ +export interface ClaimSDKType { + action: Action; + completed: boolean; + claimable_amount: string; +} +/** ClaimsRecordAddress is the claims metadata per address that is used at Genesis. */ +export interface ClaimsRecordAddress { + /** bech32 or hex address of claim user */ + address: string; + /** total initial claimable amount for the user */ + initialClaimableAmount: string; + /** slice of the available actions completed */ + actionsCompleted: boolean[]; +} +export interface ClaimsRecordAddressProtoMsg { + typeUrl: "/evmos.claims.v1.ClaimsRecordAddress"; + value: Uint8Array; +} +/** ClaimsRecordAddress is the claims metadata per address that is used at Genesis. */ +export interface ClaimsRecordAddressSDKType { + address: string; + initial_claimable_amount: string; + actions_completed: boolean[]; +} +/** + * ClaimsRecord defines the initial claimable airdrop amount and the list of + * completed actions to claim the tokens. + */ +export interface ClaimsRecord { + /** total initial claimable amount for the user */ + initialClaimableAmount: string; + /** slice of the available actions completed */ + actionsCompleted: boolean[]; +} +export interface ClaimsRecordProtoMsg { + typeUrl: "/evmos.claims.v1.ClaimsRecord"; + value: Uint8Array; +} +/** + * ClaimsRecord defines the initial claimable airdrop amount and the list of + * completed actions to claim the tokens. + */ +export interface ClaimsRecordSDKType { + initial_claimable_amount: string; + actions_completed: boolean[]; +} +function createBaseClaim(): Claim { + return { + action: 0, + completed: false, + claimableAmount: "" + }; +} +export const Claim = { + typeUrl: "/evmos.claims.v1.Claim", + encode(message: Claim, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.action !== 0) { + writer.uint32(8).int32(message.action); + } + if (message.completed !== undefined) { + writer.uint32(16).bool(message.completed); + } + if (message.claimableAmount !== undefined) { + writer.uint32(26).string(message.claimableAmount); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Claim { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseClaim(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.action = (reader.int32() as any); + break; + case 2: + message.completed = reader.bool(); + break; + case 3: + message.claimableAmount = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Claim { + const obj = createBaseClaim(); + if (isSet(object.action)) obj.action = actionFromJSON(object.action); + if (isSet(object.completed)) obj.completed = Boolean(object.completed); + if (isSet(object.claimableAmount)) obj.claimableAmount = String(object.claimableAmount); + return obj; + }, + toJSON(message: Claim): JsonSafe { + const obj: any = {}; + message.action !== undefined && (obj.action = actionToJSON(message.action)); + message.completed !== undefined && (obj.completed = message.completed); + message.claimableAmount !== undefined && (obj.claimableAmount = message.claimableAmount); + return obj; + }, + fromPartial(object: DeepPartial): Claim { + const message = createBaseClaim(); + message.action = object.action ?? 0; + message.completed = object.completed ?? false; + message.claimableAmount = object.claimableAmount ?? ""; + return message; + }, + fromSDK(object: ClaimSDKType): Claim { + return { + action: isSet(object.action) ? actionFromJSON(object.action) : -1, + completed: object?.completed, + claimableAmount: object?.claimable_amount + }; + }, + fromSDKJSON(object: any): ClaimSDKType { + return { + action: isSet(object.action) ? actionFromJSON(object.action) : -1, + completed: isSet(object.completed) ? Boolean(object.completed) : false, + claimable_amount: isSet(object.claimable_amount) ? String(object.claimable_amount) : "" + }; + }, + toSDK(message: Claim): ClaimSDKType { + const obj: any = {}; + message.action !== undefined && (obj.action = actionToJSON(message.action)); + obj.completed = message.completed; + obj.claimable_amount = message.claimableAmount; + return obj; + }, + fromAmino(object: ClaimAmino): Claim { + const message = createBaseClaim(); + if (object.action !== undefined && object.action !== null) { + message.action = object.action; + } + if (object.completed !== undefined && object.completed !== null) { + message.completed = object.completed; + } + if (object.claimable_amount !== undefined && object.claimable_amount !== null) { + message.claimableAmount = object.claimable_amount; + } + return message; + }, + toAmino(message: Claim): ClaimAmino { + const obj: any = {}; + obj.action = message.action === 0 ? undefined : message.action; + obj.completed = message.completed === false ? undefined : message.completed; + obj.claimable_amount = message.claimableAmount === "" ? undefined : message.claimableAmount; + return obj; + }, + fromAminoMsg(object: ClaimAminoMsg): Claim { + return Claim.fromAmino(object.value); + }, + fromProtoMsg(message: ClaimProtoMsg): Claim { + return Claim.decode(message.value); + }, + toProto(message: Claim): Uint8Array { + return Claim.encode(message).finish(); + }, + toProtoMsg(message: Claim): ClaimProtoMsg { + return { + typeUrl: "/evmos.claims.v1.Claim", + value: Claim.encode(message).finish() + }; + } +}; +function createBaseClaimsRecordAddress(): ClaimsRecordAddress { + return { + address: "", + initialClaimableAmount: "", + actionsCompleted: [] + }; +} +export const ClaimsRecordAddress = { + typeUrl: "/evmos.claims.v1.ClaimsRecordAddress", + encode(message: ClaimsRecordAddress, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.address !== undefined) { + writer.uint32(10).string(message.address); + } + if (message.initialClaimableAmount !== undefined) { + writer.uint32(18).string(message.initialClaimableAmount); + } + writer.uint32(26).fork(); + for (const v of message.actionsCompleted) { + writer.bool(v); + } + writer.ldelim(); + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ClaimsRecordAddress { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseClaimsRecordAddress(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.string(); + break; + case 2: + message.initialClaimableAmount = reader.string(); + break; + case 3: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.actionsCompleted.push(reader.bool()); + } + } else { + message.actionsCompleted.push(reader.bool()); + } + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ClaimsRecordAddress { + const obj = createBaseClaimsRecordAddress(); + if (isSet(object.address)) obj.address = String(object.address); + if (isSet(object.initialClaimableAmount)) obj.initialClaimableAmount = String(object.initialClaimableAmount); + if (Array.isArray(object?.actionsCompleted)) obj.actionsCompleted = object.actionsCompleted.map((e: any) => Boolean(e)); + return obj; + }, + toJSON(message: ClaimsRecordAddress): JsonSafe { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + message.initialClaimableAmount !== undefined && (obj.initialClaimableAmount = message.initialClaimableAmount); + if (message.actionsCompleted) { + obj.actionsCompleted = message.actionsCompleted.map(e => e); + } else { + obj.actionsCompleted = []; + } + return obj; + }, + fromPartial(object: DeepPartial): ClaimsRecordAddress { + const message = createBaseClaimsRecordAddress(); + message.address = object.address ?? ""; + message.initialClaimableAmount = object.initialClaimableAmount ?? ""; + message.actionsCompleted = object.actionsCompleted?.map(e => e) || []; + return message; + }, + fromSDK(object: ClaimsRecordAddressSDKType): ClaimsRecordAddress { + return { + address: object?.address, + initialClaimableAmount: object?.initial_claimable_amount, + actionsCompleted: Array.isArray(object?.actions_completed) ? object.actions_completed.map((e: any) => e) : [] + }; + }, + fromSDKJSON(object: any): ClaimsRecordAddressSDKType { + return { + address: isSet(object.address) ? String(object.address) : "", + initial_claimable_amount: isSet(object.initial_claimable_amount) ? String(object.initial_claimable_amount) : "", + actions_completed: Array.isArray(object?.actions_completed) ? object.actions_completed.map((e: any) => Boolean(e)) : [] + }; + }, + toSDK(message: ClaimsRecordAddress): ClaimsRecordAddressSDKType { + const obj: any = {}; + obj.address = message.address; + obj.initial_claimable_amount = message.initialClaimableAmount; + if (message.actionsCompleted) { + obj.actions_completed = message.actionsCompleted.map(e => e); + } else { + obj.actions_completed = []; + } + return obj; + }, + fromAmino(object: ClaimsRecordAddressAmino): ClaimsRecordAddress { + const message = createBaseClaimsRecordAddress(); + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } + if (object.initial_claimable_amount !== undefined && object.initial_claimable_amount !== null) { + message.initialClaimableAmount = object.initial_claimable_amount; + } + message.actionsCompleted = object.actions_completed?.map(e => e) || []; + return message; + }, + toAmino(message: ClaimsRecordAddress): ClaimsRecordAddressAmino { + const obj: any = {}; + obj.address = message.address === "" ? undefined : message.address; + obj.initial_claimable_amount = message.initialClaimableAmount === "" ? undefined : message.initialClaimableAmount; + if (message.actionsCompleted) { + obj.actions_completed = message.actionsCompleted.map(e => e); + } else { + obj.actions_completed = message.actionsCompleted; + } + return obj; + }, + fromAminoMsg(object: ClaimsRecordAddressAminoMsg): ClaimsRecordAddress { + return ClaimsRecordAddress.fromAmino(object.value); + }, + fromProtoMsg(message: ClaimsRecordAddressProtoMsg): ClaimsRecordAddress { + return ClaimsRecordAddress.decode(message.value); + }, + toProto(message: ClaimsRecordAddress): Uint8Array { + return ClaimsRecordAddress.encode(message).finish(); + }, + toProtoMsg(message: ClaimsRecordAddress): ClaimsRecordAddressProtoMsg { + return { + typeUrl: "/evmos.claims.v1.ClaimsRecordAddress", + value: ClaimsRecordAddress.encode(message).finish() + }; + } +}; +function createBaseClaimsRecord(): ClaimsRecord { + return { + initialClaimableAmount: "", + actionsCompleted: [] + }; +} +export const ClaimsRecord = { + typeUrl: "/evmos.claims.v1.ClaimsRecord", + encode(message: ClaimsRecord, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.initialClaimableAmount !== undefined) { + writer.uint32(10).string(message.initialClaimableAmount); + } + writer.uint32(18).fork(); + for (const v of message.actionsCompleted) { + writer.bool(v); + } + writer.ldelim(); + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ClaimsRecord { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseClaimsRecord(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.initialClaimableAmount = reader.string(); + break; + case 2: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.actionsCompleted.push(reader.bool()); + } + } else { + message.actionsCompleted.push(reader.bool()); + } + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ClaimsRecord { + const obj = createBaseClaimsRecord(); + if (isSet(object.initialClaimableAmount)) obj.initialClaimableAmount = String(object.initialClaimableAmount); + if (Array.isArray(object?.actionsCompleted)) obj.actionsCompleted = object.actionsCompleted.map((e: any) => Boolean(e)); + return obj; + }, + toJSON(message: ClaimsRecord): JsonSafe { + const obj: any = {}; + message.initialClaimableAmount !== undefined && (obj.initialClaimableAmount = message.initialClaimableAmount); + if (message.actionsCompleted) { + obj.actionsCompleted = message.actionsCompleted.map(e => e); + } else { + obj.actionsCompleted = []; + } + return obj; + }, + fromPartial(object: DeepPartial): ClaimsRecord { + const message = createBaseClaimsRecord(); + message.initialClaimableAmount = object.initialClaimableAmount ?? ""; + message.actionsCompleted = object.actionsCompleted?.map(e => e) || []; + return message; + }, + fromSDK(object: ClaimsRecordSDKType): ClaimsRecord { + return { + initialClaimableAmount: object?.initial_claimable_amount, + actionsCompleted: Array.isArray(object?.actions_completed) ? object.actions_completed.map((e: any) => e) : [] + }; + }, + fromSDKJSON(object: any): ClaimsRecordSDKType { + return { + initial_claimable_amount: isSet(object.initial_claimable_amount) ? String(object.initial_claimable_amount) : "", + actions_completed: Array.isArray(object?.actions_completed) ? object.actions_completed.map((e: any) => Boolean(e)) : [] + }; + }, + toSDK(message: ClaimsRecord): ClaimsRecordSDKType { + const obj: any = {}; + obj.initial_claimable_amount = message.initialClaimableAmount; + if (message.actionsCompleted) { + obj.actions_completed = message.actionsCompleted.map(e => e); + } else { + obj.actions_completed = []; + } + return obj; + }, + fromAmino(object: ClaimsRecordAmino): ClaimsRecord { + const message = createBaseClaimsRecord(); + if (object.initial_claimable_amount !== undefined && object.initial_claimable_amount !== null) { + message.initialClaimableAmount = object.initial_claimable_amount; + } + message.actionsCompleted = object.actions_completed?.map(e => e) || []; + return message; + }, + toAmino(message: ClaimsRecord): ClaimsRecordAmino { + const obj: any = {}; + obj.initial_claimable_amount = message.initialClaimableAmount === "" ? undefined : message.initialClaimableAmount; + if (message.actionsCompleted) { + obj.actions_completed = message.actionsCompleted.map(e => e); + } else { + obj.actions_completed = message.actionsCompleted; + } + return obj; + }, + fromAminoMsg(object: ClaimsRecordAminoMsg): ClaimsRecord { + return ClaimsRecord.fromAmino(object.value); + }, + fromProtoMsg(message: ClaimsRecordProtoMsg): ClaimsRecord { + return ClaimsRecord.decode(message.value); + }, + toProto(message: ClaimsRecord): Uint8Array { + return ClaimsRecord.encode(message).finish(); + }, + toProtoMsg(message: ClaimsRecord): ClaimsRecordProtoMsg { + return { + typeUrl: "/evmos.claims.v1.ClaimsRecord", + value: ClaimsRecord.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/evmos/claims/v1/genesis.ts b/__fixtures__/v-next/outputicjsdeps/evmos/claims/v1/genesis.ts new file mode 100644 index 0000000000..df1fc00863 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/evmos/claims/v1/genesis.ts @@ -0,0 +1,388 @@ +import { ClaimsRecordAddress, ClaimsRecordAddressSDKType } from "./claims.js"; +import { Timestamp, TimestampSDKType } from "../../../google/protobuf/timestamp.js"; +import { Duration, DurationSDKType } from "../../../google/protobuf/duration.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial, toTimestamp, fromTimestamp } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "evmos.claims.v1"; +/** GenesisState define the claims module's genesis state. */ +export interface GenesisState { + /** params defines all the parameters of the module. */ + params: Params; + /** list of claim records with the corresponding airdrop recipient */ + claimsRecords: ClaimsRecordAddress[]; +} +export interface GenesisStateProtoMsg { + typeUrl: "/evmos.claims.v1.GenesisState"; + value: Uint8Array; +} +/** GenesisState define the claims module's genesis state. */ +export interface GenesisStateSDKType { + params: ParamsSDKType; + claims_records: ClaimsRecordAddressSDKType[]; +} +/** Params defines the claims module's parameters. */ +export interface Params { + /** enable claiming process */ + enableClaims: boolean; + /** timestamp of the airdrop start */ + airdropStartTime: Date; + /** duration until decay of claimable tokens begin */ + durationUntilDecay: Duration; + /** duration of the token claim decay period */ + durationOfDecay: Duration; + /** denom of claimable coin */ + claimsDenom: string; + /** + * list of authorized channel identifiers that can perform address + * attestations via IBC. + */ + authorizedChannels: string[]; + /** list of channel identifiers from EVM compatible chains */ + evmChannels: string[]; +} +export interface ParamsProtoMsg { + typeUrl: "/evmos.claims.v1.Params"; + value: Uint8Array; +} +/** Params defines the claims module's parameters. */ +export interface ParamsSDKType { + enable_claims: boolean; + airdrop_start_time: Date; + duration_until_decay: DurationSDKType; + duration_of_decay: DurationSDKType; + claims_denom: string; + authorized_channels: string[]; + evm_channels: string[]; +} +function createBaseGenesisState(): GenesisState { + return { + params: Params.fromPartial({}), + claimsRecords: [] + }; +} +export const GenesisState = { + typeUrl: "/evmos.claims.v1.GenesisState", + encode(message: GenesisState, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.claimsRecords) { + ClaimsRecordAddress.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GenesisState { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGenesisState(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.params = Params.decode(reader, reader.uint32()); + break; + case 2: + message.claimsRecords.push(ClaimsRecordAddress.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GenesisState { + const obj = createBaseGenesisState(); + if (isSet(object.params)) obj.params = Params.fromJSON(object.params); + if (Array.isArray(object?.claimsRecords)) obj.claimsRecords = object.claimsRecords.map((e: any) => ClaimsRecordAddress.fromJSON(e)); + return obj; + }, + toJSON(message: GenesisState): JsonSafe { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); + if (message.claimsRecords) { + obj.claimsRecords = message.claimsRecords.map(e => e ? ClaimsRecordAddress.toJSON(e) : undefined); + } else { + obj.claimsRecords = []; + } + return obj; + }, + fromPartial(object: DeepPartial): GenesisState { + const message = createBaseGenesisState(); + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } + message.claimsRecords = object.claimsRecords?.map(e => ClaimsRecordAddress.fromPartial(e)) || []; + return message; + }, + fromSDK(object: GenesisStateSDKType): GenesisState { + return { + params: object.params ? Params.fromSDK(object.params) : undefined, + claimsRecords: Array.isArray(object?.claims_records) ? object.claims_records.map((e: any) => ClaimsRecordAddress.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): GenesisStateSDKType { + return { + params: isSet(object.params) ? Params.fromSDKJSON(object.params) : undefined, + claims_records: Array.isArray(object?.claims_records) ? object.claims_records.map((e: any) => ClaimsRecordAddress.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: GenesisState): GenesisStateSDKType { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toSDK(message.params) : undefined); + if (message.claimsRecords) { + obj.claims_records = message.claimsRecords.map(e => e ? ClaimsRecordAddress.toSDK(e) : undefined); + } else { + obj.claims_records = []; + } + return obj; + }, + fromAmino(object: GenesisStateAmino): GenesisState { + const message = createBaseGenesisState(); + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromAmino(object.params); + } + message.claimsRecords = object.claims_records?.map(e => ClaimsRecordAddress.fromAmino(e)) || []; + return message; + }, + toAmino(message: GenesisState): GenesisStateAmino { + const obj: any = {}; + obj.params = message.params ? Params.toAmino(message.params) : undefined; + if (message.claimsRecords) { + obj.claims_records = message.claimsRecords.map(e => e ? ClaimsRecordAddress.toAmino(e) : undefined); + } else { + obj.claims_records = message.claimsRecords; + } + return obj; + }, + fromAminoMsg(object: GenesisStateAminoMsg): GenesisState { + return GenesisState.fromAmino(object.value); + }, + fromProtoMsg(message: GenesisStateProtoMsg): GenesisState { + return GenesisState.decode(message.value); + }, + toProto(message: GenesisState): Uint8Array { + return GenesisState.encode(message).finish(); + }, + toProtoMsg(message: GenesisState): GenesisStateProtoMsg { + return { + typeUrl: "/evmos.claims.v1.GenesisState", + value: GenesisState.encode(message).finish() + }; + } +}; +function createBaseParams(): Params { + return { + enableClaims: false, + airdropStartTime: new Date(), + durationUntilDecay: Duration.fromPartial({}), + durationOfDecay: Duration.fromPartial({}), + claimsDenom: "", + authorizedChannels: [], + evmChannels: [] + }; +} +export const Params = { + typeUrl: "/evmos.claims.v1.Params", + encode(message: Params, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.enableClaims !== undefined) { + writer.uint32(8).bool(message.enableClaims); + } + if (message.airdropStartTime !== undefined) { + Timestamp.encode(toTimestamp(message.airdropStartTime), writer.uint32(18).fork()).ldelim(); + } + if (message.durationUntilDecay !== undefined) { + Duration.encode(message.durationUntilDecay, writer.uint32(26).fork()).ldelim(); + } + if (message.durationOfDecay !== undefined) { + Duration.encode(message.durationOfDecay, writer.uint32(34).fork()).ldelim(); + } + if (message.claimsDenom !== undefined) { + writer.uint32(42).string(message.claimsDenom); + } + for (const v of message.authorizedChannels) { + writer.uint32(50).string(v!); + } + for (const v of message.evmChannels) { + writer.uint32(58).string(v!); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Params { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseParams(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.enableClaims = reader.bool(); + break; + case 2: + message.airdropStartTime = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + break; + case 3: + message.durationUntilDecay = Duration.decode(reader, reader.uint32()); + break; + case 4: + message.durationOfDecay = Duration.decode(reader, reader.uint32()); + break; + case 5: + message.claimsDenom = reader.string(); + break; + case 6: + message.authorizedChannels.push(reader.string()); + break; + case 7: + message.evmChannels.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Params { + const obj = createBaseParams(); + if (isSet(object.enableClaims)) obj.enableClaims = Boolean(object.enableClaims); + if (isSet(object.airdropStartTime)) obj.airdropStartTime = new Date(object.airdropStartTime); + if (isSet(object.durationUntilDecay)) obj.durationUntilDecay = Duration.fromJSON(object.durationUntilDecay); + if (isSet(object.durationOfDecay)) obj.durationOfDecay = Duration.fromJSON(object.durationOfDecay); + if (isSet(object.claimsDenom)) obj.claimsDenom = String(object.claimsDenom); + if (Array.isArray(object?.authorizedChannels)) obj.authorizedChannels = object.authorizedChannels.map((e: any) => String(e)); + if (Array.isArray(object?.evmChannels)) obj.evmChannels = object.evmChannels.map((e: any) => String(e)); + return obj; + }, + toJSON(message: Params): JsonSafe { + const obj: any = {}; + message.enableClaims !== undefined && (obj.enableClaims = message.enableClaims); + message.airdropStartTime !== undefined && (obj.airdropStartTime = message.airdropStartTime.toISOString()); + message.durationUntilDecay !== undefined && (obj.durationUntilDecay = message.durationUntilDecay ? Duration.toJSON(message.durationUntilDecay) : undefined); + message.durationOfDecay !== undefined && (obj.durationOfDecay = message.durationOfDecay ? Duration.toJSON(message.durationOfDecay) : undefined); + message.claimsDenom !== undefined && (obj.claimsDenom = message.claimsDenom); + if (message.authorizedChannels) { + obj.authorizedChannels = message.authorizedChannels.map(e => e); + } else { + obj.authorizedChannels = []; + } + if (message.evmChannels) { + obj.evmChannels = message.evmChannels.map(e => e); + } else { + obj.evmChannels = []; + } + return obj; + }, + fromPartial(object: DeepPartial): Params { + const message = createBaseParams(); + message.enableClaims = object.enableClaims ?? false; + message.airdropStartTime = object.airdropStartTime ?? undefined; + if (object.durationUntilDecay !== undefined && object.durationUntilDecay !== null) { + message.durationUntilDecay = Duration.fromPartial(object.durationUntilDecay); + } + if (object.durationOfDecay !== undefined && object.durationOfDecay !== null) { + message.durationOfDecay = Duration.fromPartial(object.durationOfDecay); + } + message.claimsDenom = object.claimsDenom ?? ""; + message.authorizedChannels = object.authorizedChannels?.map(e => e) || []; + message.evmChannels = object.evmChannels?.map(e => e) || []; + return message; + }, + fromSDK(object: ParamsSDKType): Params { + return { + enableClaims: object?.enable_claims, + airdropStartTime: object.airdrop_start_time ?? undefined, + durationUntilDecay: object.duration_until_decay ? Duration.fromSDK(object.duration_until_decay) : undefined, + durationOfDecay: object.duration_of_decay ? Duration.fromSDK(object.duration_of_decay) : undefined, + claimsDenom: object?.claims_denom, + authorizedChannels: Array.isArray(object?.authorized_channels) ? object.authorized_channels.map((e: any) => e) : [], + evmChannels: Array.isArray(object?.evm_channels) ? object.evm_channels.map((e: any) => e) : [] + }; + }, + fromSDKJSON(object: any): ParamsSDKType { + return { + enable_claims: isSet(object.enable_claims) ? Boolean(object.enable_claims) : false, + airdrop_start_time: isSet(object.airdrop_start_time) ? new Date(object.airdrop_start_time) : undefined, + duration_until_decay: isSet(object.duration_until_decay) ? Duration.fromSDKJSON(object.duration_until_decay) : undefined, + duration_of_decay: isSet(object.duration_of_decay) ? Duration.fromSDKJSON(object.duration_of_decay) : undefined, + claims_denom: isSet(object.claims_denom) ? String(object.claims_denom) : "", + authorized_channels: Array.isArray(object?.authorized_channels) ? object.authorized_channels.map((e: any) => String(e)) : [], + evm_channels: Array.isArray(object?.evm_channels) ? object.evm_channels.map((e: any) => String(e)) : [] + }; + }, + toSDK(message: Params): ParamsSDKType { + const obj: any = {}; + obj.enable_claims = message.enableClaims; + message.airdropStartTime !== undefined && (obj.airdrop_start_time = message.airdropStartTime ?? undefined); + message.durationUntilDecay !== undefined && (obj.duration_until_decay = message.durationUntilDecay ? Duration.toSDK(message.durationUntilDecay) : undefined); + message.durationOfDecay !== undefined && (obj.duration_of_decay = message.durationOfDecay ? Duration.toSDK(message.durationOfDecay) : undefined); + obj.claims_denom = message.claimsDenom; + if (message.authorizedChannels) { + obj.authorized_channels = message.authorizedChannels.map(e => e); + } else { + obj.authorized_channels = []; + } + if (message.evmChannels) { + obj.evm_channels = message.evmChannels.map(e => e); + } else { + obj.evm_channels = []; + } + return obj; + }, + fromAmino(object: ParamsAmino): Params { + const message = createBaseParams(); + if (object.enable_claims !== undefined && object.enable_claims !== null) { + message.enableClaims = object.enable_claims; + } + if (object.airdrop_start_time !== undefined && object.airdrop_start_time !== null) { + message.airdropStartTime = fromTimestamp(Timestamp.fromAmino(object.airdrop_start_time)); + } + if (object.duration_until_decay !== undefined && object.duration_until_decay !== null) { + message.durationUntilDecay = Duration.fromAmino(object.duration_until_decay); + } + if (object.duration_of_decay !== undefined && object.duration_of_decay !== null) { + message.durationOfDecay = Duration.fromAmino(object.duration_of_decay); + } + if (object.claims_denom !== undefined && object.claims_denom !== null) { + message.claimsDenom = object.claims_denom; + } + message.authorizedChannels = object.authorized_channels?.map(e => e) || []; + message.evmChannels = object.evm_channels?.map(e => e) || []; + return message; + }, + toAmino(message: Params): ParamsAmino { + const obj: any = {}; + obj.enable_claims = message.enableClaims === false ? undefined : message.enableClaims; + obj.airdrop_start_time = message.airdropStartTime ? Timestamp.toAmino(toTimestamp(message.airdropStartTime)) : undefined; + obj.duration_until_decay = message.durationUntilDecay ? Duration.toAmino(message.durationUntilDecay) : undefined; + obj.duration_of_decay = message.durationOfDecay ? Duration.toAmino(message.durationOfDecay) : undefined; + obj.claims_denom = message.claimsDenom === "" ? undefined : message.claimsDenom; + if (message.authorizedChannels) { + obj.authorized_channels = message.authorizedChannels.map(e => e); + } else { + obj.authorized_channels = message.authorizedChannels; + } + if (message.evmChannels) { + obj.evm_channels = message.evmChannels.map(e => e); + } else { + obj.evm_channels = message.evmChannels; + } + return obj; + }, + fromAminoMsg(object: ParamsAminoMsg): Params { + return Params.fromAmino(object.value); + }, + fromProtoMsg(message: ParamsProtoMsg): Params { + return Params.decode(message.value); + }, + toProto(message: Params): Uint8Array { + return Params.encode(message).finish(); + }, + toProtoMsg(message: Params): ParamsProtoMsg { + return { + typeUrl: "/evmos.claims.v1.Params", + value: Params.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/evmos/claims/v1/query.lcd.ts b/__fixtures__/v-next/outputicjsdeps/evmos/claims/v1/query.lcd.ts new file mode 100644 index 0000000000..5fe187bd48 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/evmos/claims/v1/query.lcd.ts @@ -0,0 +1,49 @@ +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../../cosmos/base/query/v1beta1/pagination.js"; +import { Coin, CoinSDKType } from "../../../cosmos/base/v1beta1/coin.js"; +import { Params, ParamsSDKType } from "./genesis.js"; +import { ClaimsRecordAddress, ClaimsRecordAddressSDKType, Claim, ClaimSDKType } from "./claims.js"; +import { setPaginationParams } from "../../../helpers.js"; +import { LCDClient } from "@cosmology/lcd"; +import { QueryTotalUnclaimedRequest, QueryTotalUnclaimedRequestSDKType, QueryTotalUnclaimedResponse, QueryTotalUnclaimedResponseSDKType, QueryParamsRequest, QueryParamsRequestSDKType, QueryParamsResponse, QueryParamsResponseSDKType, QueryClaimsRecordsRequest, QueryClaimsRecordsRequestSDKType, QueryClaimsRecordsResponse, QueryClaimsRecordsResponseSDKType, QueryClaimsRecordRequest, QueryClaimsRecordRequestSDKType, QueryClaimsRecordResponse, QueryClaimsRecordResponseSDKType } from "./query.js"; +export class LCDQueryClient { + req: LCDClient; + constructor({ + requestClient + }: { + requestClient: LCDClient; + }) { + this.req = requestClient; + this.totalUnclaimed = this.totalUnclaimed.bind(this); + this.params = this.params.bind(this); + this.claimsRecords = this.claimsRecords.bind(this); + this.claimsRecord = this.claimsRecord.bind(this); + } + /* TotalUnclaimed queries the total unclaimed tokens from the airdrop */ + async totalUnclaimed(_params: QueryTotalUnclaimedRequest = {}): Promise { + const endpoint = `evmos/claims/v1/total_unclaimed`; + return QueryTotalUnclaimedResponse.fromSDKJSON(await this.req.get(endpoint)); + } + /* Params returns the claims module parameters */ + async params(_params: QueryParamsRequest = {}): Promise { + const endpoint = `evmos/claims/v1/params`; + return QueryParamsResponse.fromSDKJSON(await this.req.get(endpoint)); + } + /* ClaimsRecords returns all claims records */ + async claimsRecords(params: QueryClaimsRecordsRequest = { + pagination: PageRequest.fromPartial({}) + }): Promise { + const options: any = { + params: {} + }; + if (typeof params?.pagination !== "undefined") { + setPaginationParams(options, params.pagination); + } + const endpoint = `evmos/claims/v1/claims_records`; + return QueryClaimsRecordsResponse.fromSDKJSON(await this.req.get(endpoint, options)); + } + /* ClaimsRecord returns the claims record for a given address */ + async claimsRecord(params: QueryClaimsRecordRequest): Promise { + const endpoint = `evmos/claims/v1/claims_records/${params.address}`; + return QueryClaimsRecordResponse.fromSDKJSON(await this.req.get(endpoint)); + } +} \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/evmos/claims/v1/query.rpc.Query.ts b/__fixtures__/v-next/outputicjsdeps/evmos/claims/v1/query.rpc.Query.ts new file mode 100644 index 0000000000..d477a713d7 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/evmos/claims/v1/query.rpc.Query.ts @@ -0,0 +1,69 @@ +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../../cosmos/base/query/v1beta1/pagination.js"; +import { Coin, CoinSDKType } from "../../../cosmos/base/v1beta1/coin.js"; +import { Params, ParamsSDKType } from "./genesis.js"; +import { ClaimsRecordAddress, ClaimsRecordAddressSDKType, Claim, ClaimSDKType } from "./claims.js"; +import { Rpc } from "../../../helpers.js"; +import { BinaryReader } from "../../../binary.js"; +import { QueryClient, createProtobufRpcClient } from "@cosmjs/stargate"; +import { QueryTotalUnclaimedRequest, QueryTotalUnclaimedRequestSDKType, QueryTotalUnclaimedResponse, QueryTotalUnclaimedResponseSDKType, QueryParamsRequest, QueryParamsRequestSDKType, QueryParamsResponse, QueryParamsResponseSDKType, QueryClaimsRecordsRequest, QueryClaimsRecordsRequestSDKType, QueryClaimsRecordsResponse, QueryClaimsRecordsResponseSDKType, QueryClaimsRecordRequest, QueryClaimsRecordRequestSDKType, QueryClaimsRecordResponse, QueryClaimsRecordResponseSDKType } from "./query.js"; +/** Query defines the gRPC querier service. */ +export interface Query { + /** TotalUnclaimed queries the total unclaimed tokens from the airdrop */ + totalUnclaimed(request?: QueryTotalUnclaimedRequest): Promise; + /** Params returns the claims module parameters */ + params(request?: QueryParamsRequest): Promise; + /** ClaimsRecords returns all claims records */ + claimsRecords(request?: QueryClaimsRecordsRequest): Promise; + /** ClaimsRecord returns the claims record for a given address */ + claimsRecord(request: QueryClaimsRecordRequest): Promise; +} +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + this.totalUnclaimed = this.totalUnclaimed.bind(this); + this.params = this.params.bind(this); + this.claimsRecords = this.claimsRecords.bind(this); + this.claimsRecord = this.claimsRecord.bind(this); + } + totalUnclaimed(request: QueryTotalUnclaimedRequest = {}): Promise { + const data = QueryTotalUnclaimedRequest.encode(request).finish(); + const promise = this.rpc.request("evmos.claims.v1.Query", "TotalUnclaimed", data); + return promise.then(data => QueryTotalUnclaimedResponse.decode(new BinaryReader(data))); + } + params(request: QueryParamsRequest = {}): Promise { + const data = QueryParamsRequest.encode(request).finish(); + const promise = this.rpc.request("evmos.claims.v1.Query", "Params", data); + return promise.then(data => QueryParamsResponse.decode(new BinaryReader(data))); + } + claimsRecords(request: QueryClaimsRecordsRequest = { + pagination: PageRequest.fromPartial({}) + }): Promise { + const data = QueryClaimsRecordsRequest.encode(request).finish(); + const promise = this.rpc.request("evmos.claims.v1.Query", "ClaimsRecords", data); + return promise.then(data => QueryClaimsRecordsResponse.decode(new BinaryReader(data))); + } + claimsRecord(request: QueryClaimsRecordRequest): Promise { + const data = QueryClaimsRecordRequest.encode(request).finish(); + const promise = this.rpc.request("evmos.claims.v1.Query", "ClaimsRecord", data); + return promise.then(data => QueryClaimsRecordResponse.decode(new BinaryReader(data))); + } +} +export const createRpcQueryExtension = (base: QueryClient) => { + const rpc = createProtobufRpcClient(base); + const queryService = new QueryClientImpl(rpc); + return { + totalUnclaimed(request?: QueryTotalUnclaimedRequest): Promise { + return queryService.totalUnclaimed(request); + }, + params(request?: QueryParamsRequest): Promise { + return queryService.params(request); + }, + claimsRecords(request?: QueryClaimsRecordsRequest): Promise { + return queryService.claimsRecords(request); + }, + claimsRecord(request: QueryClaimsRecordRequest): Promise { + return queryService.claimsRecord(request); + } + }; +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/evmos/claims/v1/query.rpc.func.ts b/__fixtures__/v-next/outputicjsdeps/evmos/claims/v1/query.rpc.func.ts new file mode 100644 index 0000000000..d7e1975e3b --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/evmos/claims/v1/query.rpc.func.ts @@ -0,0 +1,47 @@ +import { RpcResolver, buildQuery } from "../../../helper-func-types"; +import { buildUseQuery } from "../../../react-query"; +import { QueryTotalUnclaimedRequest, QueryTotalUnclaimedResponse, QueryParamsRequest, QueryParamsResponse, QueryClaimsRecordsRequest, QueryClaimsRecordsResponse, QueryClaimsRecordRequest, QueryClaimsRecordResponse } from "./query"; +export const createGetTotalUnclaimed = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryTotalUnclaimedRequest.encode, + decode: QueryTotalUnclaimedResponse.decode, + service: "evmos.claims.v1.Query", + method: "TotalUnclaimed", + getRpcInstance: getRpcInstance +}); +export const useGetTotalUnclaimed = buildUseQuery({ + builderQueryFn: createGetTotalUnclaimed, + queryKeyPrefix: "TotalUnclaimedQuery" +}); +export const createGetParams = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryParamsRequest.encode, + decode: QueryParamsResponse.decode, + service: "evmos.claims.v1.Query", + method: "Params", + getRpcInstance: getRpcInstance +}); +export const useGetParams = buildUseQuery({ + builderQueryFn: createGetParams, + queryKeyPrefix: "ParamsQuery" +}); +export const createGetClaimsRecords = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryClaimsRecordsRequest.encode, + decode: QueryClaimsRecordsResponse.decode, + service: "evmos.claims.v1.Query", + method: "ClaimsRecords", + getRpcInstance: getRpcInstance +}); +export const useGetClaimsRecords = buildUseQuery({ + builderQueryFn: createGetClaimsRecords, + queryKeyPrefix: "ClaimsRecordsQuery" +}); +export const createGetClaimsRecord = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryClaimsRecordRequest.encode, + decode: QueryClaimsRecordResponse.decode, + service: "evmos.claims.v1.Query", + method: "ClaimsRecord", + getRpcInstance: getRpcInstance +}); +export const useGetClaimsRecord = buildUseQuery({ + builderQueryFn: createGetClaimsRecord, + queryKeyPrefix: "ClaimsRecordQuery" +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/evmos/claims/v1/query.ts b/__fixtures__/v-next/outputicjsdeps/evmos/claims/v1/query.ts new file mode 100644 index 0000000000..c79acec275 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/evmos/claims/v1/query.ts @@ -0,0 +1,878 @@ +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../../cosmos/base/query/v1beta1/pagination.js"; +import { Coin, CoinSDKType } from "../../../cosmos/base/v1beta1/coin.js"; +import { Params, ParamsSDKType } from "./genesis.js"; +import { ClaimsRecordAddress, ClaimsRecordAddressSDKType, Claim, ClaimSDKType } from "./claims.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { JsonSafe } from "../../../json-safe.js"; +import { DeepPartial, isSet } from "../../../helpers.js"; +export const protobufPackage = "evmos.claims.v1"; +/** + * QueryTotalUnclaimedRequest is the request type for the Query/TotalUnclaimed + * RPC method. + */ +export interface QueryTotalUnclaimedRequest {} +export interface QueryTotalUnclaimedRequestProtoMsg { + typeUrl: "/evmos.claims.v1.QueryTotalUnclaimedRequest"; + value: Uint8Array; +} +/** + * QueryTotalUnclaimedRequest is the request type for the Query/TotalUnclaimed + * RPC method. + */ +export interface QueryTotalUnclaimedRequestSDKType {} +/** + * QueryTotalUnclaimedResponse is the response type for the Query/TotalUnclaimed + * RPC method. + */ +export interface QueryTotalUnclaimedResponse { + /** coins defines the unclaimed coins */ + coins: Coin[]; +} +export interface QueryTotalUnclaimedResponseProtoMsg { + typeUrl: "/evmos.claims.v1.QueryTotalUnclaimedResponse"; + value: Uint8Array; +} +/** + * QueryTotalUnclaimedResponse is the response type for the Query/TotalUnclaimed + * RPC method. + */ +export interface QueryTotalUnclaimedResponseSDKType { + coins: CoinSDKType[]; +} +/** QueryParamsRequest is the request type for the Query/Params RPC method. */ +export interface QueryParamsRequest {} +export interface QueryParamsRequestProtoMsg { + typeUrl: "/evmos.claims.v1.QueryParamsRequest"; + value: Uint8Array; +} +/** QueryParamsRequest is the request type for the Query/Params RPC method. */ +export interface QueryParamsRequestSDKType {} +/** QueryParamsResponse is the response type for the Query/Params RPC method. */ +export interface QueryParamsResponse { + /** params defines the parameters of the module. */ + params: Params; +} +export interface QueryParamsResponseProtoMsg { + typeUrl: "/evmos.claims.v1.QueryParamsResponse"; + value: Uint8Array; +} +/** QueryParamsResponse is the response type for the Query/Params RPC method. */ +export interface QueryParamsResponseSDKType { + params: ParamsSDKType; +} +/** + * QueryClaimsRecordsRequest is the request type for the Query/ClaimsRecords RPC + * method. + */ +export interface QueryClaimsRecordsRequest { + /** pagination defines an optional pagination for the request. */ + pagination?: PageRequest; +} +export interface QueryClaimsRecordsRequestProtoMsg { + typeUrl: "/evmos.claims.v1.QueryClaimsRecordsRequest"; + value: Uint8Array; +} +/** + * QueryClaimsRecordsRequest is the request type for the Query/ClaimsRecords RPC + * method. + */ +export interface QueryClaimsRecordsRequestSDKType { + pagination?: PageRequestSDKType; +} +/** + * QueryClaimsRecordsResponse is the response type for the Query/ClaimsRecords + * RPC method. + */ +export interface QueryClaimsRecordsResponse { + /** claims defines all claims records */ + claims: ClaimsRecordAddress[]; + /** pagination defines the pagination in the response. */ + pagination?: PageResponse; +} +export interface QueryClaimsRecordsResponseProtoMsg { + typeUrl: "/evmos.claims.v1.QueryClaimsRecordsResponse"; + value: Uint8Array; +} +/** + * QueryClaimsRecordsResponse is the response type for the Query/ClaimsRecords + * RPC method. + */ +export interface QueryClaimsRecordsResponseSDKType { + claims: ClaimsRecordAddressSDKType[]; + pagination?: PageResponseSDKType; +} +/** + * QueryClaimsRecordRequest is the request type for the Query/ClaimsRecord RPC + * method. + */ +export interface QueryClaimsRecordRequest { + /** address defines the user to query claims record for */ + address: string; +} +export interface QueryClaimsRecordRequestProtoMsg { + typeUrl: "/evmos.claims.v1.QueryClaimsRecordRequest"; + value: Uint8Array; +} +/** + * QueryClaimsRecordRequest is the request type for the Query/ClaimsRecord RPC + * method. + */ +export interface QueryClaimsRecordRequestSDKType { + address: string; +} +/** + * QueryClaimsRecordResponse is the response type for the Query/ClaimsRecord RPC + * method. + */ +export interface QueryClaimsRecordResponse { + /** total initial claimable amount for the user */ + initialClaimableAmount: string; + /** the claims of the user */ + claims: Claim[]; +} +export interface QueryClaimsRecordResponseProtoMsg { + typeUrl: "/evmos.claims.v1.QueryClaimsRecordResponse"; + value: Uint8Array; +} +/** + * QueryClaimsRecordResponse is the response type for the Query/ClaimsRecord RPC + * method. + */ +export interface QueryClaimsRecordResponseSDKType { + initial_claimable_amount: string; + claims: ClaimSDKType[]; +} +function createBaseQueryTotalUnclaimedRequest(): QueryTotalUnclaimedRequest { + return {}; +} +export const QueryTotalUnclaimedRequest = { + typeUrl: "/evmos.claims.v1.QueryTotalUnclaimedRequest", + encode(_: QueryTotalUnclaimedRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryTotalUnclaimedRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryTotalUnclaimedRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): QueryTotalUnclaimedRequest { + const obj = createBaseQueryTotalUnclaimedRequest(); + return obj; + }, + toJSON(_: QueryTotalUnclaimedRequest): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): QueryTotalUnclaimedRequest { + const message = createBaseQueryTotalUnclaimedRequest(); + return message; + }, + fromSDK(_: QueryTotalUnclaimedRequestSDKType): QueryTotalUnclaimedRequest { + return {}; + }, + fromSDKJSON(_: any): QueryTotalUnclaimedRequestSDKType { + return {}; + }, + toSDK(_: QueryTotalUnclaimedRequest): QueryTotalUnclaimedRequestSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: QueryTotalUnclaimedRequestAmino): QueryTotalUnclaimedRequest { + const message = createBaseQueryTotalUnclaimedRequest(); + return message; + }, + toAmino(_: QueryTotalUnclaimedRequest): QueryTotalUnclaimedRequestAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: QueryTotalUnclaimedRequestAminoMsg): QueryTotalUnclaimedRequest { + return QueryTotalUnclaimedRequest.fromAmino(object.value); + }, + fromProtoMsg(message: QueryTotalUnclaimedRequestProtoMsg): QueryTotalUnclaimedRequest { + return QueryTotalUnclaimedRequest.decode(message.value); + }, + toProto(message: QueryTotalUnclaimedRequest): Uint8Array { + return QueryTotalUnclaimedRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryTotalUnclaimedRequest): QueryTotalUnclaimedRequestProtoMsg { + return { + typeUrl: "/evmos.claims.v1.QueryTotalUnclaimedRequest", + value: QueryTotalUnclaimedRequest.encode(message).finish() + }; + } +}; +function createBaseQueryTotalUnclaimedResponse(): QueryTotalUnclaimedResponse { + return { + coins: [] + }; +} +export const QueryTotalUnclaimedResponse = { + typeUrl: "/evmos.claims.v1.QueryTotalUnclaimedResponse", + encode(message: QueryTotalUnclaimedResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.coins) { + Coin.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryTotalUnclaimedResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryTotalUnclaimedResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.coins.push(Coin.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryTotalUnclaimedResponse { + const obj = createBaseQueryTotalUnclaimedResponse(); + if (Array.isArray(object?.coins)) obj.coins = object.coins.map((e: any) => Coin.fromJSON(e)); + return obj; + }, + toJSON(message: QueryTotalUnclaimedResponse): JsonSafe { + const obj: any = {}; + if (message.coins) { + obj.coins = message.coins.map(e => e ? Coin.toJSON(e) : undefined); + } else { + obj.coins = []; + } + return obj; + }, + fromPartial(object: DeepPartial): QueryTotalUnclaimedResponse { + const message = createBaseQueryTotalUnclaimedResponse(); + message.coins = object.coins?.map(e => Coin.fromPartial(e)) || []; + return message; + }, + fromSDK(object: QueryTotalUnclaimedResponseSDKType): QueryTotalUnclaimedResponse { + return { + coins: Array.isArray(object?.coins) ? object.coins.map((e: any) => Coin.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): QueryTotalUnclaimedResponseSDKType { + return { + coins: Array.isArray(object?.coins) ? object.coins.map((e: any) => Coin.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: QueryTotalUnclaimedResponse): QueryTotalUnclaimedResponseSDKType { + const obj: any = {}; + if (message.coins) { + obj.coins = message.coins.map(e => e ? Coin.toSDK(e) : undefined); + } else { + obj.coins = []; + } + return obj; + }, + fromAmino(object: QueryTotalUnclaimedResponseAmino): QueryTotalUnclaimedResponse { + const message = createBaseQueryTotalUnclaimedResponse(); + message.coins = object.coins?.map(e => Coin.fromAmino(e)) || []; + return message; + }, + toAmino(message: QueryTotalUnclaimedResponse): QueryTotalUnclaimedResponseAmino { + const obj: any = {}; + if (message.coins) { + obj.coins = message.coins.map(e => e ? Coin.toAmino(e) : undefined); + } else { + obj.coins = message.coins; + } + return obj; + }, + fromAminoMsg(object: QueryTotalUnclaimedResponseAminoMsg): QueryTotalUnclaimedResponse { + return QueryTotalUnclaimedResponse.fromAmino(object.value); + }, + fromProtoMsg(message: QueryTotalUnclaimedResponseProtoMsg): QueryTotalUnclaimedResponse { + return QueryTotalUnclaimedResponse.decode(message.value); + }, + toProto(message: QueryTotalUnclaimedResponse): Uint8Array { + return QueryTotalUnclaimedResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryTotalUnclaimedResponse): QueryTotalUnclaimedResponseProtoMsg { + return { + typeUrl: "/evmos.claims.v1.QueryTotalUnclaimedResponse", + value: QueryTotalUnclaimedResponse.encode(message).finish() + }; + } +}; +function createBaseQueryParamsRequest(): QueryParamsRequest { + return {}; +} +export const QueryParamsRequest = { + typeUrl: "/evmos.claims.v1.QueryParamsRequest", + encode(_: QueryParamsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryParamsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryParamsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): QueryParamsRequest { + const obj = createBaseQueryParamsRequest(); + return obj; + }, + toJSON(_: QueryParamsRequest): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): QueryParamsRequest { + const message = createBaseQueryParamsRequest(); + return message; + }, + fromSDK(_: QueryParamsRequestSDKType): QueryParamsRequest { + return {}; + }, + fromSDKJSON(_: any): QueryParamsRequestSDKType { + return {}; + }, + toSDK(_: QueryParamsRequest): QueryParamsRequestSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: QueryParamsRequestAmino): QueryParamsRequest { + const message = createBaseQueryParamsRequest(); + return message; + }, + toAmino(_: QueryParamsRequest): QueryParamsRequestAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: QueryParamsRequestAminoMsg): QueryParamsRequest { + return QueryParamsRequest.fromAmino(object.value); + }, + fromProtoMsg(message: QueryParamsRequestProtoMsg): QueryParamsRequest { + return QueryParamsRequest.decode(message.value); + }, + toProto(message: QueryParamsRequest): Uint8Array { + return QueryParamsRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryParamsRequest): QueryParamsRequestProtoMsg { + return { + typeUrl: "/evmos.claims.v1.QueryParamsRequest", + value: QueryParamsRequest.encode(message).finish() + }; + } +}; +function createBaseQueryParamsResponse(): QueryParamsResponse { + return { + params: Params.fromPartial({}) + }; +} +export const QueryParamsResponse = { + typeUrl: "/evmos.claims.v1.QueryParamsResponse", + encode(message: QueryParamsResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryParamsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryParamsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.params = Params.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryParamsResponse { + const obj = createBaseQueryParamsResponse(); + if (isSet(object.params)) obj.params = Params.fromJSON(object.params); + return obj; + }, + toJSON(message: QueryParamsResponse): JsonSafe { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryParamsResponse { + const message = createBaseQueryParamsResponse(); + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } + return message; + }, + fromSDK(object: QueryParamsResponseSDKType): QueryParamsResponse { + return { + params: object.params ? Params.fromSDK(object.params) : undefined + }; + }, + fromSDKJSON(object: any): QueryParamsResponseSDKType { + return { + params: isSet(object.params) ? Params.fromSDKJSON(object.params) : undefined + }; + }, + toSDK(message: QueryParamsResponse): QueryParamsResponseSDKType { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toSDK(message.params) : undefined); + return obj; + }, + fromAmino(object: QueryParamsResponseAmino): QueryParamsResponse { + const message = createBaseQueryParamsResponse(); + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromAmino(object.params); + } + return message; + }, + toAmino(message: QueryParamsResponse): QueryParamsResponseAmino { + const obj: any = {}; + obj.params = message.params ? Params.toAmino(message.params) : undefined; + return obj; + }, + fromAminoMsg(object: QueryParamsResponseAminoMsg): QueryParamsResponse { + return QueryParamsResponse.fromAmino(object.value); + }, + fromProtoMsg(message: QueryParamsResponseProtoMsg): QueryParamsResponse { + return QueryParamsResponse.decode(message.value); + }, + toProto(message: QueryParamsResponse): Uint8Array { + return QueryParamsResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryParamsResponse): QueryParamsResponseProtoMsg { + return { + typeUrl: "/evmos.claims.v1.QueryParamsResponse", + value: QueryParamsResponse.encode(message).finish() + }; + } +}; +function createBaseQueryClaimsRecordsRequest(): QueryClaimsRecordsRequest { + return { + pagination: undefined + }; +} +export const QueryClaimsRecordsRequest = { + typeUrl: "/evmos.claims.v1.QueryClaimsRecordsRequest", + encode(message: QueryClaimsRecordsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryClaimsRecordsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryClaimsRecordsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryClaimsRecordsRequest { + const obj = createBaseQueryClaimsRecordsRequest(); + if (isSet(object.pagination)) obj.pagination = PageRequest.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryClaimsRecordsRequest): JsonSafe { + const obj: any = {}; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryClaimsRecordsRequest { + const message = createBaseQueryClaimsRecordsRequest(); + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryClaimsRecordsRequestSDKType): QueryClaimsRecordsRequest { + return { + pagination: object.pagination ? PageRequest.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryClaimsRecordsRequestSDKType { + return { + pagination: isSet(object.pagination) ? PageRequest.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryClaimsRecordsRequest): QueryClaimsRecordsRequestSDKType { + const obj: any = {}; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryClaimsRecordsRequestAmino): QueryClaimsRecordsRequest { + const message = createBaseQueryClaimsRecordsRequest(); + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryClaimsRecordsRequest): QueryClaimsRecordsRequestAmino { + const obj: any = {}; + obj.pagination = message.pagination ? PageRequest.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryClaimsRecordsRequestAminoMsg): QueryClaimsRecordsRequest { + return QueryClaimsRecordsRequest.fromAmino(object.value); + }, + fromProtoMsg(message: QueryClaimsRecordsRequestProtoMsg): QueryClaimsRecordsRequest { + return QueryClaimsRecordsRequest.decode(message.value); + }, + toProto(message: QueryClaimsRecordsRequest): Uint8Array { + return QueryClaimsRecordsRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryClaimsRecordsRequest): QueryClaimsRecordsRequestProtoMsg { + return { + typeUrl: "/evmos.claims.v1.QueryClaimsRecordsRequest", + value: QueryClaimsRecordsRequest.encode(message).finish() + }; + } +}; +function createBaseQueryClaimsRecordsResponse(): QueryClaimsRecordsResponse { + return { + claims: [], + pagination: undefined + }; +} +export const QueryClaimsRecordsResponse = { + typeUrl: "/evmos.claims.v1.QueryClaimsRecordsResponse", + encode(message: QueryClaimsRecordsResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.claims) { + ClaimsRecordAddress.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryClaimsRecordsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryClaimsRecordsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.claims.push(ClaimsRecordAddress.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryClaimsRecordsResponse { + const obj = createBaseQueryClaimsRecordsResponse(); + if (Array.isArray(object?.claims)) obj.claims = object.claims.map((e: any) => ClaimsRecordAddress.fromJSON(e)); + if (isSet(object.pagination)) obj.pagination = PageResponse.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryClaimsRecordsResponse): JsonSafe { + const obj: any = {}; + if (message.claims) { + obj.claims = message.claims.map(e => e ? ClaimsRecordAddress.toJSON(e) : undefined); + } else { + obj.claims = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryClaimsRecordsResponse { + const message = createBaseQueryClaimsRecordsResponse(); + message.claims = object.claims?.map(e => ClaimsRecordAddress.fromPartial(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryClaimsRecordsResponseSDKType): QueryClaimsRecordsResponse { + return { + claims: Array.isArray(object?.claims) ? object.claims.map((e: any) => ClaimsRecordAddress.fromSDK(e)) : [], + pagination: object.pagination ? PageResponse.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryClaimsRecordsResponseSDKType { + return { + claims: Array.isArray(object?.claims) ? object.claims.map((e: any) => ClaimsRecordAddress.fromSDKJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryClaimsRecordsResponse): QueryClaimsRecordsResponseSDKType { + const obj: any = {}; + if (message.claims) { + obj.claims = message.claims.map(e => e ? ClaimsRecordAddress.toSDK(e) : undefined); + } else { + obj.claims = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryClaimsRecordsResponseAmino): QueryClaimsRecordsResponse { + const message = createBaseQueryClaimsRecordsResponse(); + message.claims = object.claims?.map(e => ClaimsRecordAddress.fromAmino(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryClaimsRecordsResponse): QueryClaimsRecordsResponseAmino { + const obj: any = {}; + if (message.claims) { + obj.claims = message.claims.map(e => e ? ClaimsRecordAddress.toAmino(e) : undefined); + } else { + obj.claims = message.claims; + } + obj.pagination = message.pagination ? PageResponse.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryClaimsRecordsResponseAminoMsg): QueryClaimsRecordsResponse { + return QueryClaimsRecordsResponse.fromAmino(object.value); + }, + fromProtoMsg(message: QueryClaimsRecordsResponseProtoMsg): QueryClaimsRecordsResponse { + return QueryClaimsRecordsResponse.decode(message.value); + }, + toProto(message: QueryClaimsRecordsResponse): Uint8Array { + return QueryClaimsRecordsResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryClaimsRecordsResponse): QueryClaimsRecordsResponseProtoMsg { + return { + typeUrl: "/evmos.claims.v1.QueryClaimsRecordsResponse", + value: QueryClaimsRecordsResponse.encode(message).finish() + }; + } +}; +function createBaseQueryClaimsRecordRequest(): QueryClaimsRecordRequest { + return { + address: "" + }; +} +export const QueryClaimsRecordRequest = { + typeUrl: "/evmos.claims.v1.QueryClaimsRecordRequest", + encode(message: QueryClaimsRecordRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.address !== undefined) { + writer.uint32(10).string(message.address); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryClaimsRecordRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryClaimsRecordRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryClaimsRecordRequest { + const obj = createBaseQueryClaimsRecordRequest(); + if (isSet(object.address)) obj.address = String(object.address); + return obj; + }, + toJSON(message: QueryClaimsRecordRequest): JsonSafe { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + return obj; + }, + fromPartial(object: DeepPartial): QueryClaimsRecordRequest { + const message = createBaseQueryClaimsRecordRequest(); + message.address = object.address ?? ""; + return message; + }, + fromSDK(object: QueryClaimsRecordRequestSDKType): QueryClaimsRecordRequest { + return { + address: object?.address + }; + }, + fromSDKJSON(object: any): QueryClaimsRecordRequestSDKType { + return { + address: isSet(object.address) ? String(object.address) : "" + }; + }, + toSDK(message: QueryClaimsRecordRequest): QueryClaimsRecordRequestSDKType { + const obj: any = {}; + obj.address = message.address; + return obj; + }, + fromAmino(object: QueryClaimsRecordRequestAmino): QueryClaimsRecordRequest { + const message = createBaseQueryClaimsRecordRequest(); + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } + return message; + }, + toAmino(message: QueryClaimsRecordRequest): QueryClaimsRecordRequestAmino { + const obj: any = {}; + obj.address = message.address === "" ? undefined : message.address; + return obj; + }, + fromAminoMsg(object: QueryClaimsRecordRequestAminoMsg): QueryClaimsRecordRequest { + return QueryClaimsRecordRequest.fromAmino(object.value); + }, + fromProtoMsg(message: QueryClaimsRecordRequestProtoMsg): QueryClaimsRecordRequest { + return QueryClaimsRecordRequest.decode(message.value); + }, + toProto(message: QueryClaimsRecordRequest): Uint8Array { + return QueryClaimsRecordRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryClaimsRecordRequest): QueryClaimsRecordRequestProtoMsg { + return { + typeUrl: "/evmos.claims.v1.QueryClaimsRecordRequest", + value: QueryClaimsRecordRequest.encode(message).finish() + }; + } +}; +function createBaseQueryClaimsRecordResponse(): QueryClaimsRecordResponse { + return { + initialClaimableAmount: "", + claims: [] + }; +} +export const QueryClaimsRecordResponse = { + typeUrl: "/evmos.claims.v1.QueryClaimsRecordResponse", + encode(message: QueryClaimsRecordResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.initialClaimableAmount !== undefined) { + writer.uint32(10).string(message.initialClaimableAmount); + } + for (const v of message.claims) { + Claim.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryClaimsRecordResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryClaimsRecordResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.initialClaimableAmount = reader.string(); + break; + case 2: + message.claims.push(Claim.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryClaimsRecordResponse { + const obj = createBaseQueryClaimsRecordResponse(); + if (isSet(object.initialClaimableAmount)) obj.initialClaimableAmount = String(object.initialClaimableAmount); + if (Array.isArray(object?.claims)) obj.claims = object.claims.map((e: any) => Claim.fromJSON(e)); + return obj; + }, + toJSON(message: QueryClaimsRecordResponse): JsonSafe { + const obj: any = {}; + message.initialClaimableAmount !== undefined && (obj.initialClaimableAmount = message.initialClaimableAmount); + if (message.claims) { + obj.claims = message.claims.map(e => e ? Claim.toJSON(e) : undefined); + } else { + obj.claims = []; + } + return obj; + }, + fromPartial(object: DeepPartial): QueryClaimsRecordResponse { + const message = createBaseQueryClaimsRecordResponse(); + message.initialClaimableAmount = object.initialClaimableAmount ?? ""; + message.claims = object.claims?.map(e => Claim.fromPartial(e)) || []; + return message; + }, + fromSDK(object: QueryClaimsRecordResponseSDKType): QueryClaimsRecordResponse { + return { + initialClaimableAmount: object?.initial_claimable_amount, + claims: Array.isArray(object?.claims) ? object.claims.map((e: any) => Claim.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): QueryClaimsRecordResponseSDKType { + return { + initial_claimable_amount: isSet(object.initial_claimable_amount) ? String(object.initial_claimable_amount) : "", + claims: Array.isArray(object?.claims) ? object.claims.map((e: any) => Claim.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: QueryClaimsRecordResponse): QueryClaimsRecordResponseSDKType { + const obj: any = {}; + obj.initial_claimable_amount = message.initialClaimableAmount; + if (message.claims) { + obj.claims = message.claims.map(e => e ? Claim.toSDK(e) : undefined); + } else { + obj.claims = []; + } + return obj; + }, + fromAmino(object: QueryClaimsRecordResponseAmino): QueryClaimsRecordResponse { + const message = createBaseQueryClaimsRecordResponse(); + if (object.initial_claimable_amount !== undefined && object.initial_claimable_amount !== null) { + message.initialClaimableAmount = object.initial_claimable_amount; + } + message.claims = object.claims?.map(e => Claim.fromAmino(e)) || []; + return message; + }, + toAmino(message: QueryClaimsRecordResponse): QueryClaimsRecordResponseAmino { + const obj: any = {}; + obj.initial_claimable_amount = message.initialClaimableAmount === "" ? undefined : message.initialClaimableAmount; + if (message.claims) { + obj.claims = message.claims.map(e => e ? Claim.toAmino(e) : undefined); + } else { + obj.claims = message.claims; + } + return obj; + }, + fromAminoMsg(object: QueryClaimsRecordResponseAminoMsg): QueryClaimsRecordResponse { + return QueryClaimsRecordResponse.fromAmino(object.value); + }, + fromProtoMsg(message: QueryClaimsRecordResponseProtoMsg): QueryClaimsRecordResponse { + return QueryClaimsRecordResponse.decode(message.value); + }, + toProto(message: QueryClaimsRecordResponse): Uint8Array { + return QueryClaimsRecordResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryClaimsRecordResponse): QueryClaimsRecordResponseProtoMsg { + return { + typeUrl: "/evmos.claims.v1.QueryClaimsRecordResponse", + value: QueryClaimsRecordResponse.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/evmos/client.ts b/__fixtures__/v-next/outputicjsdeps/evmos/client.ts new file mode 100644 index 0000000000..f1a4c88c94 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/evmos/client.ts @@ -0,0 +1,53 @@ +import { GeneratedType, Registry, OfflineSigner } from "@cosmjs/proto-signing"; +import { defaultRegistryTypes, AminoTypes, SigningStargateClient } from "@cosmjs/stargate"; +import { HttpEndpoint } from "@cosmjs/tendermint-rpc"; +import * as evmosErc20V1TxRegistry from "./erc20/v1/tx.registry.js"; +import * as evmosFeesV1TxRegistry from "./fees/v1/tx.registry.js"; +import * as evmosVestingV1TxRegistry from "./vesting/v1/tx.registry.js"; +import * as evmosErc20V1TxAmino from "./erc20/v1/tx.amino.js"; +import * as evmosFeesV1TxAmino from "./fees/v1/tx.amino.js"; +import * as evmosVestingV1TxAmino from "./vesting/v1/tx.amino.js"; +export const evmosAminoConverters = { + ...evmosErc20V1TxAmino.AminoConverter, + ...evmosFeesV1TxAmino.AminoConverter, + ...evmosVestingV1TxAmino.AminoConverter +}; +export const evmosProtoRegistry: ReadonlyArray<[string, GeneratedType]> = [...evmosErc20V1TxRegistry.registry, ...evmosFeesV1TxRegistry.registry, ...evmosVestingV1TxRegistry.registry]; +export const getSigningEvmosClientOptions = ({ + defaultTypes = defaultRegistryTypes +}: { + defaultTypes?: ReadonlyArray<[string, GeneratedType]>; +} = {}): { + registry: Registry; + aminoTypes: AminoTypes; +} => { + const registry = new Registry([...defaultTypes, ...evmosProtoRegistry]); + const aminoTypes = new AminoTypes({ + ...evmosAminoConverters + }); + return { + registry, + aminoTypes + }; +}; +export const getSigningEvmosClient = async ({ + rpcEndpoint, + signer, + defaultTypes = defaultRegistryTypes +}: { + rpcEndpoint: string | HttpEndpoint; + signer: OfflineSigner; + defaultTypes?: ReadonlyArray<[string, GeneratedType]>; +}) => { + const { + registry, + aminoTypes + } = getSigningEvmosClientOptions({ + defaultTypes + }); + const client = await SigningStargateClient.connectWithSigner(rpcEndpoint, signer, { + registry: (registry as any), + aminoTypes + }); + return client; +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/evmos/custom-lcd-client.ts b/__fixtures__/v-next/outputicjsdeps/evmos/custom-lcd-client.ts new file mode 100644 index 0000000000..b21f7d9554 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/evmos/custom-lcd-client.ts @@ -0,0 +1,31 @@ +import { LCDClient } from "@cosmology/lcd"; +export const createEvmosLCDClient = async ({ + restEndpoint +}: { + restEndpoint: string; +}) => { + const requestClient = new LCDClient({ + restEndpoint + }); + return { + cosmos: { + bank: { + v1beta1: new (await import("../cosmos/bank/v1beta1/query.lcd")).LCDQueryClient({ + requestClient + }) + }, + gov: { + v1beta1: new (await import("../cosmos/gov/v1beta1/query.lcd")).LCDQueryClient({ + requestClient + }) + } + }, + evmos: { + erc20: { + v1: new (await import("./erc20/v1/query.lcd")).LCDQueryClient({ + requestClient + }) + } + } + }; +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/evmos/epochs/v1/genesis.ts b/__fixtures__/v-next/outputicjsdeps/evmos/epochs/v1/genesis.ts new file mode 100644 index 0000000000..7bb574f8bd --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/evmos/epochs/v1/genesis.ts @@ -0,0 +1,334 @@ +import { Timestamp, TimestampSDKType } from "../../../google/protobuf/timestamp.js"; +import { Duration, DurationSDKType } from "../../../google/protobuf/duration.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { toTimestamp, fromTimestamp, isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "evmos.epochs.v1"; +export interface EpochInfo { + identifier: string; + startTime: Date; + duration: Duration; + currentEpoch: bigint; + currentEpochStartTime: Date; + epochCountingStarted: boolean; + currentEpochStartHeight: bigint; +} +export interface EpochInfoProtoMsg { + typeUrl: "/evmos.epochs.v1.EpochInfo"; + value: Uint8Array; +} +export interface EpochInfoSDKType { + identifier: string; + start_time: Date; + duration: DurationSDKType; + current_epoch: bigint; + current_epoch_start_time: Date; + epoch_counting_started: boolean; + current_epoch_start_height: bigint; +} +/** GenesisState defines the epochs module's genesis state. */ +export interface GenesisState { + epochs: EpochInfo[]; +} +export interface GenesisStateProtoMsg { + typeUrl: "/evmos.epochs.v1.GenesisState"; + value: Uint8Array; +} +/** GenesisState defines the epochs module's genesis state. */ +export interface GenesisStateSDKType { + epochs: EpochInfoSDKType[]; +} +function createBaseEpochInfo(): EpochInfo { + return { + identifier: "", + startTime: new Date(), + duration: Duration.fromPartial({}), + currentEpoch: BigInt(0), + currentEpochStartTime: new Date(), + epochCountingStarted: false, + currentEpochStartHeight: BigInt(0) + }; +} +export const EpochInfo = { + typeUrl: "/evmos.epochs.v1.EpochInfo", + encode(message: EpochInfo, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.identifier !== undefined) { + writer.uint32(10).string(message.identifier); + } + if (message.startTime !== undefined) { + Timestamp.encode(toTimestamp(message.startTime), writer.uint32(18).fork()).ldelim(); + } + if (message.duration !== undefined) { + Duration.encode(message.duration, writer.uint32(26).fork()).ldelim(); + } + if (message.currentEpoch !== undefined) { + writer.uint32(32).int64(message.currentEpoch); + } + if (message.currentEpochStartTime !== undefined) { + Timestamp.encode(toTimestamp(message.currentEpochStartTime), writer.uint32(42).fork()).ldelim(); + } + if (message.epochCountingStarted !== undefined) { + writer.uint32(48).bool(message.epochCountingStarted); + } + if (message.currentEpochStartHeight !== undefined) { + writer.uint32(56).int64(message.currentEpochStartHeight); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): EpochInfo { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseEpochInfo(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.identifier = reader.string(); + break; + case 2: + message.startTime = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + break; + case 3: + message.duration = Duration.decode(reader, reader.uint32()); + break; + case 4: + message.currentEpoch = reader.int64(); + break; + case 5: + message.currentEpochStartTime = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + break; + case 6: + message.epochCountingStarted = reader.bool(); + break; + case 7: + message.currentEpochStartHeight = reader.int64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): EpochInfo { + const obj = createBaseEpochInfo(); + if (isSet(object.identifier)) obj.identifier = String(object.identifier); + if (isSet(object.startTime)) obj.startTime = new Date(object.startTime); + if (isSet(object.duration)) obj.duration = Duration.fromJSON(object.duration); + if (isSet(object.currentEpoch)) obj.currentEpoch = BigInt(object.currentEpoch.toString()); + if (isSet(object.currentEpochStartTime)) obj.currentEpochStartTime = new Date(object.currentEpochStartTime); + if (isSet(object.epochCountingStarted)) obj.epochCountingStarted = Boolean(object.epochCountingStarted); + if (isSet(object.currentEpochStartHeight)) obj.currentEpochStartHeight = BigInt(object.currentEpochStartHeight.toString()); + return obj; + }, + toJSON(message: EpochInfo): JsonSafe { + const obj: any = {}; + message.identifier !== undefined && (obj.identifier = message.identifier); + message.startTime !== undefined && (obj.startTime = message.startTime.toISOString()); + message.duration !== undefined && (obj.duration = message.duration ? Duration.toJSON(message.duration) : undefined); + message.currentEpoch !== undefined && (obj.currentEpoch = (message.currentEpoch || BigInt(0)).toString()); + message.currentEpochStartTime !== undefined && (obj.currentEpochStartTime = message.currentEpochStartTime.toISOString()); + message.epochCountingStarted !== undefined && (obj.epochCountingStarted = message.epochCountingStarted); + message.currentEpochStartHeight !== undefined && (obj.currentEpochStartHeight = (message.currentEpochStartHeight || BigInt(0)).toString()); + return obj; + }, + fromPartial(object: DeepPartial): EpochInfo { + const message = createBaseEpochInfo(); + message.identifier = object.identifier ?? ""; + message.startTime = object.startTime ?? undefined; + if (object.duration !== undefined && object.duration !== null) { + message.duration = Duration.fromPartial(object.duration); + } + if (object.currentEpoch !== undefined && object.currentEpoch !== null) { + message.currentEpoch = BigInt(object.currentEpoch.toString()); + } + message.currentEpochStartTime = object.currentEpochStartTime ?? undefined; + message.epochCountingStarted = object.epochCountingStarted ?? false; + if (object.currentEpochStartHeight !== undefined && object.currentEpochStartHeight !== null) { + message.currentEpochStartHeight = BigInt(object.currentEpochStartHeight.toString()); + } + return message; + }, + fromSDK(object: EpochInfoSDKType): EpochInfo { + return { + identifier: object?.identifier, + startTime: object.start_time ?? undefined, + duration: object.duration ? Duration.fromSDK(object.duration) : undefined, + currentEpoch: object?.current_epoch, + currentEpochStartTime: object.current_epoch_start_time ?? undefined, + epochCountingStarted: object?.epoch_counting_started, + currentEpochStartHeight: object?.current_epoch_start_height + }; + }, + fromSDKJSON(object: any): EpochInfoSDKType { + return { + identifier: isSet(object.identifier) ? String(object.identifier) : "", + start_time: isSet(object.start_time) ? new Date(object.start_time) : undefined, + duration: isSet(object.duration) ? Duration.fromSDKJSON(object.duration) : undefined, + current_epoch: isSet(object.current_epoch) ? BigInt(object.current_epoch.toString()) : BigInt(0), + current_epoch_start_time: isSet(object.current_epoch_start_time) ? new Date(object.current_epoch_start_time) : undefined, + epoch_counting_started: isSet(object.epoch_counting_started) ? Boolean(object.epoch_counting_started) : false, + current_epoch_start_height: isSet(object.current_epoch_start_height) ? BigInt(object.current_epoch_start_height.toString()) : BigInt(0) + }; + }, + toSDK(message: EpochInfo): EpochInfoSDKType { + const obj: any = {}; + obj.identifier = message.identifier; + message.startTime !== undefined && (obj.start_time = message.startTime ?? undefined); + message.duration !== undefined && (obj.duration = message.duration ? Duration.toSDK(message.duration) : undefined); + obj.current_epoch = message.currentEpoch; + message.currentEpochStartTime !== undefined && (obj.current_epoch_start_time = message.currentEpochStartTime ?? undefined); + obj.epoch_counting_started = message.epochCountingStarted; + obj.current_epoch_start_height = message.currentEpochStartHeight; + return obj; + }, + fromAmino(object: EpochInfoAmino): EpochInfo { + const message = createBaseEpochInfo(); + if (object.identifier !== undefined && object.identifier !== null) { + message.identifier = object.identifier; + } + if (object.start_time !== undefined && object.start_time !== null) { + message.startTime = fromTimestamp(Timestamp.fromAmino(object.start_time)); + } + if (object.duration !== undefined && object.duration !== null) { + message.duration = Duration.fromAmino(object.duration); + } + if (object.current_epoch !== undefined && object.current_epoch !== null) { + message.currentEpoch = BigInt(object.current_epoch); + } + if (object.current_epoch_start_time !== undefined && object.current_epoch_start_time !== null) { + message.currentEpochStartTime = fromTimestamp(Timestamp.fromAmino(object.current_epoch_start_time)); + } + if (object.epoch_counting_started !== undefined && object.epoch_counting_started !== null) { + message.epochCountingStarted = object.epoch_counting_started; + } + if (object.current_epoch_start_height !== undefined && object.current_epoch_start_height !== null) { + message.currentEpochStartHeight = BigInt(object.current_epoch_start_height); + } + return message; + }, + toAmino(message: EpochInfo): EpochInfoAmino { + const obj: any = {}; + obj.identifier = message.identifier === "" ? undefined : message.identifier; + obj.start_time = message.startTime ? Timestamp.toAmino(toTimestamp(message.startTime)) : undefined; + obj.duration = message.duration ? Duration.toAmino(message.duration) : undefined; + obj.current_epoch = message.currentEpoch !== BigInt(0) ? message.currentEpoch?.toString() : undefined; + obj.current_epoch_start_time = message.currentEpochStartTime ? Timestamp.toAmino(toTimestamp(message.currentEpochStartTime)) : undefined; + obj.epoch_counting_started = message.epochCountingStarted === false ? undefined : message.epochCountingStarted; + obj.current_epoch_start_height = message.currentEpochStartHeight !== BigInt(0) ? message.currentEpochStartHeight?.toString() : undefined; + return obj; + }, + fromAminoMsg(object: EpochInfoAminoMsg): EpochInfo { + return EpochInfo.fromAmino(object.value); + }, + fromProtoMsg(message: EpochInfoProtoMsg): EpochInfo { + return EpochInfo.decode(message.value); + }, + toProto(message: EpochInfo): Uint8Array { + return EpochInfo.encode(message).finish(); + }, + toProtoMsg(message: EpochInfo): EpochInfoProtoMsg { + return { + typeUrl: "/evmos.epochs.v1.EpochInfo", + value: EpochInfo.encode(message).finish() + }; + } +}; +function createBaseGenesisState(): GenesisState { + return { + epochs: [] + }; +} +export const GenesisState = { + typeUrl: "/evmos.epochs.v1.GenesisState", + encode(message: GenesisState, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.epochs) { + EpochInfo.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GenesisState { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGenesisState(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.epochs.push(EpochInfo.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GenesisState { + const obj = createBaseGenesisState(); + if (Array.isArray(object?.epochs)) obj.epochs = object.epochs.map((e: any) => EpochInfo.fromJSON(e)); + return obj; + }, + toJSON(message: GenesisState): JsonSafe { + const obj: any = {}; + if (message.epochs) { + obj.epochs = message.epochs.map(e => e ? EpochInfo.toJSON(e) : undefined); + } else { + obj.epochs = []; + } + return obj; + }, + fromPartial(object: DeepPartial): GenesisState { + const message = createBaseGenesisState(); + message.epochs = object.epochs?.map(e => EpochInfo.fromPartial(e)) || []; + return message; + }, + fromSDK(object: GenesisStateSDKType): GenesisState { + return { + epochs: Array.isArray(object?.epochs) ? object.epochs.map((e: any) => EpochInfo.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): GenesisStateSDKType { + return { + epochs: Array.isArray(object?.epochs) ? object.epochs.map((e: any) => EpochInfo.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: GenesisState): GenesisStateSDKType { + const obj: any = {}; + if (message.epochs) { + obj.epochs = message.epochs.map(e => e ? EpochInfo.toSDK(e) : undefined); + } else { + obj.epochs = []; + } + return obj; + }, + fromAmino(object: GenesisStateAmino): GenesisState { + const message = createBaseGenesisState(); + message.epochs = object.epochs?.map(e => EpochInfo.fromAmino(e)) || []; + return message; + }, + toAmino(message: GenesisState): GenesisStateAmino { + const obj: any = {}; + if (message.epochs) { + obj.epochs = message.epochs.map(e => e ? EpochInfo.toAmino(e) : undefined); + } else { + obj.epochs = message.epochs; + } + return obj; + }, + fromAminoMsg(object: GenesisStateAminoMsg): GenesisState { + return GenesisState.fromAmino(object.value); + }, + fromProtoMsg(message: GenesisStateProtoMsg): GenesisState { + return GenesisState.decode(message.value); + }, + toProto(message: GenesisState): Uint8Array { + return GenesisState.encode(message).finish(); + }, + toProtoMsg(message: GenesisState): GenesisStateProtoMsg { + return { + typeUrl: "/evmos.epochs.v1.GenesisState", + value: GenesisState.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/evmos/epochs/v1/query.lcd.ts b/__fixtures__/v-next/outputicjsdeps/evmos/epochs/v1/query.lcd.ts new file mode 100644 index 0000000000..adae7a040b --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/evmos/epochs/v1/query.lcd.ts @@ -0,0 +1,41 @@ +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../../cosmos/base/query/v1beta1/pagination.js"; +import { EpochInfo, EpochInfoSDKType } from "./genesis.js"; +import { setPaginationParams } from "../../../helpers.js"; +import { LCDClient } from "@cosmology/lcd"; +import { QueryEpochsInfoRequest, QueryEpochsInfoRequestSDKType, QueryEpochsInfoResponse, QueryEpochsInfoResponseSDKType, QueryCurrentEpochRequest, QueryCurrentEpochRequestSDKType, QueryCurrentEpochResponse, QueryCurrentEpochResponseSDKType } from "./query.js"; +export class LCDQueryClient { + req: LCDClient; + constructor({ + requestClient + }: { + requestClient: LCDClient; + }) { + this.req = requestClient; + this.epochInfos = this.epochInfos.bind(this); + this.currentEpoch = this.currentEpoch.bind(this); + } + /* EpochInfos provide running epochInfos */ + async epochInfos(params: QueryEpochsInfoRequest = { + pagination: PageRequest.fromPartial({}) + }): Promise { + const options: any = { + params: {} + }; + if (typeof params?.pagination !== "undefined") { + setPaginationParams(options, params.pagination); + } + const endpoint = `evmos/epochs/v1/epochs`; + return QueryEpochsInfoResponse.fromSDKJSON(await this.req.get(endpoint, options)); + } + /* CurrentEpoch provide current epoch of specified identifier */ + async currentEpoch(params: QueryCurrentEpochRequest): Promise { + const options: any = { + params: {} + }; + if (typeof params?.identifier !== "undefined") { + options.params.identifier = params.identifier; + } + const endpoint = `evmos/epochs/v1/current_epoch`; + return QueryCurrentEpochResponse.fromSDKJSON(await this.req.get(endpoint, options)); + } +} \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/evmos/epochs/v1/query.rpc.Query.ts b/__fixtures__/v-next/outputicjsdeps/evmos/epochs/v1/query.rpc.Query.ts new file mode 100644 index 0000000000..fce4616b32 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/evmos/epochs/v1/query.rpc.Query.ts @@ -0,0 +1,45 @@ +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../../cosmos/base/query/v1beta1/pagination.js"; +import { EpochInfo, EpochInfoSDKType } from "./genesis.js"; +import { Rpc } from "../../../helpers.js"; +import { BinaryReader } from "../../../binary.js"; +import { QueryClient, createProtobufRpcClient } from "@cosmjs/stargate"; +import { QueryEpochsInfoRequest, QueryEpochsInfoRequestSDKType, QueryEpochsInfoResponse, QueryEpochsInfoResponseSDKType, QueryCurrentEpochRequest, QueryCurrentEpochRequestSDKType, QueryCurrentEpochResponse, QueryCurrentEpochResponseSDKType } from "./query.js"; +/** Query defines the gRPC querier service. */ +export interface Query { + /** EpochInfos provide running epochInfos */ + epochInfos(request?: QueryEpochsInfoRequest): Promise; + /** CurrentEpoch provide current epoch of specified identifier */ + currentEpoch(request: QueryCurrentEpochRequest): Promise; +} +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + this.epochInfos = this.epochInfos.bind(this); + this.currentEpoch = this.currentEpoch.bind(this); + } + epochInfos(request: QueryEpochsInfoRequest = { + pagination: PageRequest.fromPartial({}) + }): Promise { + const data = QueryEpochsInfoRequest.encode(request).finish(); + const promise = this.rpc.request("evmos.epochs.v1.Query", "EpochInfos", data); + return promise.then(data => QueryEpochsInfoResponse.decode(new BinaryReader(data))); + } + currentEpoch(request: QueryCurrentEpochRequest): Promise { + const data = QueryCurrentEpochRequest.encode(request).finish(); + const promise = this.rpc.request("evmos.epochs.v1.Query", "CurrentEpoch", data); + return promise.then(data => QueryCurrentEpochResponse.decode(new BinaryReader(data))); + } +} +export const createRpcQueryExtension = (base: QueryClient) => { + const rpc = createProtobufRpcClient(base); + const queryService = new QueryClientImpl(rpc); + return { + epochInfos(request?: QueryEpochsInfoRequest): Promise { + return queryService.epochInfos(request); + }, + currentEpoch(request: QueryCurrentEpochRequest): Promise { + return queryService.currentEpoch(request); + } + }; +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/evmos/epochs/v1/query.rpc.func.ts b/__fixtures__/v-next/outputicjsdeps/evmos/epochs/v1/query.rpc.func.ts new file mode 100644 index 0000000000..ad4e9d19b5 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/evmos/epochs/v1/query.rpc.func.ts @@ -0,0 +1,25 @@ +import { RpcResolver, buildQuery } from "../../../helper-func-types"; +import { buildUseQuery } from "../../../react-query"; +import { QueryEpochsInfoRequest, QueryEpochsInfoResponse, QueryCurrentEpochRequest, QueryCurrentEpochResponse } from "./query"; +export const createGetEpochInfos = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryEpochsInfoRequest.encode, + decode: QueryEpochsInfoResponse.decode, + service: "evmos.epochs.v1.Query", + method: "EpochInfos", + getRpcInstance: getRpcInstance +}); +export const useGetEpochInfos = buildUseQuery({ + builderQueryFn: createGetEpochInfos, + queryKeyPrefix: "EpochInfosQuery" +}); +export const createGetCurrentEpoch = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryCurrentEpochRequest.encode, + decode: QueryCurrentEpochResponse.decode, + service: "evmos.epochs.v1.Query", + method: "CurrentEpoch", + getRpcInstance: getRpcInstance +}); +export const useGetCurrentEpoch = buildUseQuery({ + builderQueryFn: createGetCurrentEpoch, + queryKeyPrefix: "CurrentEpochQuery" +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/evmos/epochs/v1/query.ts b/__fixtures__/v-next/outputicjsdeps/evmos/epochs/v1/query.ts new file mode 100644 index 0000000000..1c985d7ede --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/evmos/epochs/v1/query.ts @@ -0,0 +1,433 @@ +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../../cosmos/base/query/v1beta1/pagination.js"; +import { EpochInfo, EpochInfoSDKType } from "./genesis.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "evmos.epochs.v1"; +export interface QueryEpochsInfoRequest { + pagination?: PageRequest; +} +export interface QueryEpochsInfoRequestProtoMsg { + typeUrl: "/evmos.epochs.v1.QueryEpochsInfoRequest"; + value: Uint8Array; +} +export interface QueryEpochsInfoRequestSDKType { + pagination?: PageRequestSDKType; +} +export interface QueryEpochsInfoResponse { + epochs: EpochInfo[]; + pagination?: PageResponse; +} +export interface QueryEpochsInfoResponseProtoMsg { + typeUrl: "/evmos.epochs.v1.QueryEpochsInfoResponse"; + value: Uint8Array; +} +export interface QueryEpochsInfoResponseSDKType { + epochs: EpochInfoSDKType[]; + pagination?: PageResponseSDKType; +} +export interface QueryCurrentEpochRequest { + identifier: string; +} +export interface QueryCurrentEpochRequestProtoMsg { + typeUrl: "/evmos.epochs.v1.QueryCurrentEpochRequest"; + value: Uint8Array; +} +export interface QueryCurrentEpochRequestSDKType { + identifier: string; +} +export interface QueryCurrentEpochResponse { + currentEpoch: bigint; +} +export interface QueryCurrentEpochResponseProtoMsg { + typeUrl: "/evmos.epochs.v1.QueryCurrentEpochResponse"; + value: Uint8Array; +} +export interface QueryCurrentEpochResponseSDKType { + current_epoch: bigint; +} +function createBaseQueryEpochsInfoRequest(): QueryEpochsInfoRequest { + return { + pagination: undefined + }; +} +export const QueryEpochsInfoRequest = { + typeUrl: "/evmos.epochs.v1.QueryEpochsInfoRequest", + encode(message: QueryEpochsInfoRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryEpochsInfoRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryEpochsInfoRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryEpochsInfoRequest { + const obj = createBaseQueryEpochsInfoRequest(); + if (isSet(object.pagination)) obj.pagination = PageRequest.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryEpochsInfoRequest): JsonSafe { + const obj: any = {}; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryEpochsInfoRequest { + const message = createBaseQueryEpochsInfoRequest(); + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryEpochsInfoRequestSDKType): QueryEpochsInfoRequest { + return { + pagination: object.pagination ? PageRequest.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryEpochsInfoRequestSDKType { + return { + pagination: isSet(object.pagination) ? PageRequest.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryEpochsInfoRequest): QueryEpochsInfoRequestSDKType { + const obj: any = {}; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryEpochsInfoRequestAmino): QueryEpochsInfoRequest { + const message = createBaseQueryEpochsInfoRequest(); + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryEpochsInfoRequest): QueryEpochsInfoRequestAmino { + const obj: any = {}; + obj.pagination = message.pagination ? PageRequest.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryEpochsInfoRequestAminoMsg): QueryEpochsInfoRequest { + return QueryEpochsInfoRequest.fromAmino(object.value); + }, + fromProtoMsg(message: QueryEpochsInfoRequestProtoMsg): QueryEpochsInfoRequest { + return QueryEpochsInfoRequest.decode(message.value); + }, + toProto(message: QueryEpochsInfoRequest): Uint8Array { + return QueryEpochsInfoRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryEpochsInfoRequest): QueryEpochsInfoRequestProtoMsg { + return { + typeUrl: "/evmos.epochs.v1.QueryEpochsInfoRequest", + value: QueryEpochsInfoRequest.encode(message).finish() + }; + } +}; +function createBaseQueryEpochsInfoResponse(): QueryEpochsInfoResponse { + return { + epochs: [], + pagination: undefined + }; +} +export const QueryEpochsInfoResponse = { + typeUrl: "/evmos.epochs.v1.QueryEpochsInfoResponse", + encode(message: QueryEpochsInfoResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.epochs) { + EpochInfo.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryEpochsInfoResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryEpochsInfoResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.epochs.push(EpochInfo.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryEpochsInfoResponse { + const obj = createBaseQueryEpochsInfoResponse(); + if (Array.isArray(object?.epochs)) obj.epochs = object.epochs.map((e: any) => EpochInfo.fromJSON(e)); + if (isSet(object.pagination)) obj.pagination = PageResponse.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryEpochsInfoResponse): JsonSafe { + const obj: any = {}; + if (message.epochs) { + obj.epochs = message.epochs.map(e => e ? EpochInfo.toJSON(e) : undefined); + } else { + obj.epochs = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryEpochsInfoResponse { + const message = createBaseQueryEpochsInfoResponse(); + message.epochs = object.epochs?.map(e => EpochInfo.fromPartial(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryEpochsInfoResponseSDKType): QueryEpochsInfoResponse { + return { + epochs: Array.isArray(object?.epochs) ? object.epochs.map((e: any) => EpochInfo.fromSDK(e)) : [], + pagination: object.pagination ? PageResponse.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryEpochsInfoResponseSDKType { + return { + epochs: Array.isArray(object?.epochs) ? object.epochs.map((e: any) => EpochInfo.fromSDKJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryEpochsInfoResponse): QueryEpochsInfoResponseSDKType { + const obj: any = {}; + if (message.epochs) { + obj.epochs = message.epochs.map(e => e ? EpochInfo.toSDK(e) : undefined); + } else { + obj.epochs = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryEpochsInfoResponseAmino): QueryEpochsInfoResponse { + const message = createBaseQueryEpochsInfoResponse(); + message.epochs = object.epochs?.map(e => EpochInfo.fromAmino(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryEpochsInfoResponse): QueryEpochsInfoResponseAmino { + const obj: any = {}; + if (message.epochs) { + obj.epochs = message.epochs.map(e => e ? EpochInfo.toAmino(e) : undefined); + } else { + obj.epochs = message.epochs; + } + obj.pagination = message.pagination ? PageResponse.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryEpochsInfoResponseAminoMsg): QueryEpochsInfoResponse { + return QueryEpochsInfoResponse.fromAmino(object.value); + }, + fromProtoMsg(message: QueryEpochsInfoResponseProtoMsg): QueryEpochsInfoResponse { + return QueryEpochsInfoResponse.decode(message.value); + }, + toProto(message: QueryEpochsInfoResponse): Uint8Array { + return QueryEpochsInfoResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryEpochsInfoResponse): QueryEpochsInfoResponseProtoMsg { + return { + typeUrl: "/evmos.epochs.v1.QueryEpochsInfoResponse", + value: QueryEpochsInfoResponse.encode(message).finish() + }; + } +}; +function createBaseQueryCurrentEpochRequest(): QueryCurrentEpochRequest { + return { + identifier: "" + }; +} +export const QueryCurrentEpochRequest = { + typeUrl: "/evmos.epochs.v1.QueryCurrentEpochRequest", + encode(message: QueryCurrentEpochRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.identifier !== undefined) { + writer.uint32(10).string(message.identifier); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryCurrentEpochRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryCurrentEpochRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.identifier = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryCurrentEpochRequest { + const obj = createBaseQueryCurrentEpochRequest(); + if (isSet(object.identifier)) obj.identifier = String(object.identifier); + return obj; + }, + toJSON(message: QueryCurrentEpochRequest): JsonSafe { + const obj: any = {}; + message.identifier !== undefined && (obj.identifier = message.identifier); + return obj; + }, + fromPartial(object: DeepPartial): QueryCurrentEpochRequest { + const message = createBaseQueryCurrentEpochRequest(); + message.identifier = object.identifier ?? ""; + return message; + }, + fromSDK(object: QueryCurrentEpochRequestSDKType): QueryCurrentEpochRequest { + return { + identifier: object?.identifier + }; + }, + fromSDKJSON(object: any): QueryCurrentEpochRequestSDKType { + return { + identifier: isSet(object.identifier) ? String(object.identifier) : "" + }; + }, + toSDK(message: QueryCurrentEpochRequest): QueryCurrentEpochRequestSDKType { + const obj: any = {}; + obj.identifier = message.identifier; + return obj; + }, + fromAmino(object: QueryCurrentEpochRequestAmino): QueryCurrentEpochRequest { + const message = createBaseQueryCurrentEpochRequest(); + if (object.identifier !== undefined && object.identifier !== null) { + message.identifier = object.identifier; + } + return message; + }, + toAmino(message: QueryCurrentEpochRequest): QueryCurrentEpochRequestAmino { + const obj: any = {}; + obj.identifier = message.identifier === "" ? undefined : message.identifier; + return obj; + }, + fromAminoMsg(object: QueryCurrentEpochRequestAminoMsg): QueryCurrentEpochRequest { + return QueryCurrentEpochRequest.fromAmino(object.value); + }, + fromProtoMsg(message: QueryCurrentEpochRequestProtoMsg): QueryCurrentEpochRequest { + return QueryCurrentEpochRequest.decode(message.value); + }, + toProto(message: QueryCurrentEpochRequest): Uint8Array { + return QueryCurrentEpochRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryCurrentEpochRequest): QueryCurrentEpochRequestProtoMsg { + return { + typeUrl: "/evmos.epochs.v1.QueryCurrentEpochRequest", + value: QueryCurrentEpochRequest.encode(message).finish() + }; + } +}; +function createBaseQueryCurrentEpochResponse(): QueryCurrentEpochResponse { + return { + currentEpoch: BigInt(0) + }; +} +export const QueryCurrentEpochResponse = { + typeUrl: "/evmos.epochs.v1.QueryCurrentEpochResponse", + encode(message: QueryCurrentEpochResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.currentEpoch !== undefined) { + writer.uint32(8).int64(message.currentEpoch); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryCurrentEpochResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryCurrentEpochResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.currentEpoch = reader.int64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryCurrentEpochResponse { + const obj = createBaseQueryCurrentEpochResponse(); + if (isSet(object.currentEpoch)) obj.currentEpoch = BigInt(object.currentEpoch.toString()); + return obj; + }, + toJSON(message: QueryCurrentEpochResponse): JsonSafe { + const obj: any = {}; + message.currentEpoch !== undefined && (obj.currentEpoch = (message.currentEpoch || BigInt(0)).toString()); + return obj; + }, + fromPartial(object: DeepPartial): QueryCurrentEpochResponse { + const message = createBaseQueryCurrentEpochResponse(); + if (object.currentEpoch !== undefined && object.currentEpoch !== null) { + message.currentEpoch = BigInt(object.currentEpoch.toString()); + } + return message; + }, + fromSDK(object: QueryCurrentEpochResponseSDKType): QueryCurrentEpochResponse { + return { + currentEpoch: object?.current_epoch + }; + }, + fromSDKJSON(object: any): QueryCurrentEpochResponseSDKType { + return { + current_epoch: isSet(object.current_epoch) ? BigInt(object.current_epoch.toString()) : BigInt(0) + }; + }, + toSDK(message: QueryCurrentEpochResponse): QueryCurrentEpochResponseSDKType { + const obj: any = {}; + obj.current_epoch = message.currentEpoch; + return obj; + }, + fromAmino(object: QueryCurrentEpochResponseAmino): QueryCurrentEpochResponse { + const message = createBaseQueryCurrentEpochResponse(); + if (object.current_epoch !== undefined && object.current_epoch !== null) { + message.currentEpoch = BigInt(object.current_epoch); + } + return message; + }, + toAmino(message: QueryCurrentEpochResponse): QueryCurrentEpochResponseAmino { + const obj: any = {}; + obj.current_epoch = message.currentEpoch !== BigInt(0) ? message.currentEpoch?.toString() : undefined; + return obj; + }, + fromAminoMsg(object: QueryCurrentEpochResponseAminoMsg): QueryCurrentEpochResponse { + return QueryCurrentEpochResponse.fromAmino(object.value); + }, + fromProtoMsg(message: QueryCurrentEpochResponseProtoMsg): QueryCurrentEpochResponse { + return QueryCurrentEpochResponse.decode(message.value); + }, + toProto(message: QueryCurrentEpochResponse): Uint8Array { + return QueryCurrentEpochResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryCurrentEpochResponse): QueryCurrentEpochResponseProtoMsg { + return { + typeUrl: "/evmos.epochs.v1.QueryCurrentEpochResponse", + value: QueryCurrentEpochResponse.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/evmos/erc20/v1/erc20.ts b/__fixtures__/v-next/outputicjsdeps/evmos/erc20/v1/erc20.ts new file mode 100644 index 0000000000..0f907122ba --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/evmos/erc20/v1/erc20.ts @@ -0,0 +1,659 @@ +import { Metadata, MetadataSDKType } from "../../../cosmos/bank/v1beta1/bank.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "evmos.erc20.v1"; +/** Owner enumerates the ownership of a ERC20 contract. */ +export enum Owner { + /** OWNER_UNSPECIFIED - OWNER_UNSPECIFIED defines an invalid/undefined owner. */ + OWNER_UNSPECIFIED = 0, + /** OWNER_MODULE - OWNER_MODULE erc20 is owned by the erc20 module account. */ + OWNER_MODULE = 1, + /** OWNER_EXTERNAL - EXTERNAL erc20 is owned by an external account. */ + OWNER_EXTERNAL = 2, + UNRECOGNIZED = -1, +} +export const OwnerSDKType = Owner; +export function ownerFromJSON(object: any): Owner { + switch (object) { + case 0: + case "OWNER_UNSPECIFIED": + return Owner.OWNER_UNSPECIFIED; + case 1: + case "OWNER_MODULE": + return Owner.OWNER_MODULE; + case 2: + case "OWNER_EXTERNAL": + return Owner.OWNER_EXTERNAL; + case -1: + case "UNRECOGNIZED": + default: + return Owner.UNRECOGNIZED; + } +} +export function ownerToJSON(object: Owner): string { + switch (object) { + case Owner.OWNER_UNSPECIFIED: + return "OWNER_UNSPECIFIED"; + case Owner.OWNER_MODULE: + return "OWNER_MODULE"; + case Owner.OWNER_EXTERNAL: + return "OWNER_EXTERNAL"; + case Owner.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** + * TokenPair defines an instance that records a pairing consisting of a native + * Cosmos Coin and an ERC20 token address. + */ +export interface TokenPair { + /** address of ERC20 contract token */ + erc20Address: string; + /** cosmos base denomination to be mapped to */ + denom: string; + /** shows token mapping enable status */ + enabled: boolean; + /** ERC20 owner address ENUM (0 invalid, 1 ModuleAccount, 2 external address) */ + contractOwner: Owner; +} +export interface TokenPairProtoMsg { + typeUrl: "/evmos.erc20.v1.TokenPair"; + value: Uint8Array; +} +/** + * TokenPair defines an instance that records a pairing consisting of a native + * Cosmos Coin and an ERC20 token address. + */ +export interface TokenPairSDKType { + erc20_address: string; + denom: string; + enabled: boolean; + contract_owner: Owner; +} +/** + * RegisterCoinProposal is a gov Content type to register a token pair for a + * native Cosmos coin. + */ +export interface RegisterCoinProposal { + /** title of the proposal */ + title: string; + /** proposal description */ + description: string; + /** metadata of the native Cosmos coin */ + metadata: Metadata; +} +export interface RegisterCoinProposalProtoMsg { + typeUrl: "/evmos.erc20.v1.RegisterCoinProposal"; + value: Uint8Array; +} +/** + * RegisterCoinProposal is a gov Content type to register a token pair for a + * native Cosmos coin. + */ +export interface RegisterCoinProposalSDKType { + title: string; + description: string; + metadata: MetadataSDKType; +} +/** + * RegisterERC20Proposal is a gov Content type to register a token pair for an + * ERC20 token + */ +export interface RegisterERC20Proposal { + /** title of the proposal */ + title: string; + /** proposal description */ + description: string; + /** contract address of ERC20 token */ + erc20address: string; +} +export interface RegisterERC20ProposalProtoMsg { + typeUrl: "/evmos.erc20.v1.RegisterERC20Proposal"; + value: Uint8Array; +} +/** + * RegisterERC20Proposal is a gov Content type to register a token pair for an + * ERC20 token + */ +export interface RegisterERC20ProposalSDKType { + title: string; + description: string; + erc20address: string; +} +/** + * ToggleTokenConversionProposal is a gov Content type to toggle the conversion + * of a token pair. + */ +export interface ToggleTokenConversionProposal { + /** title of the proposal */ + title: string; + /** proposal description */ + description: string; + /** + * token identifier can be either the hex contract address of the ERC20 or the + * Cosmos base denomination + */ + token: string; +} +export interface ToggleTokenConversionProposalProtoMsg { + typeUrl: "/evmos.erc20.v1.ToggleTokenConversionProposal"; + value: Uint8Array; +} +/** + * ToggleTokenConversionProposal is a gov Content type to toggle the conversion + * of a token pair. + */ +export interface ToggleTokenConversionProposalSDKType { + title: string; + description: string; + token: string; +} +function createBaseTokenPair(): TokenPair { + return { + erc20Address: "", + denom: "", + enabled: false, + contractOwner: 0 + }; +} +export const TokenPair = { + typeUrl: "/evmos.erc20.v1.TokenPair", + encode(message: TokenPair, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.erc20Address !== undefined) { + writer.uint32(10).string(message.erc20Address); + } + if (message.denom !== undefined) { + writer.uint32(18).string(message.denom); + } + if (message.enabled !== undefined) { + writer.uint32(24).bool(message.enabled); + } + if (message.contractOwner !== 0) { + writer.uint32(32).int32(message.contractOwner); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): TokenPair { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseTokenPair(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.erc20Address = reader.string(); + break; + case 2: + message.denom = reader.string(); + break; + case 3: + message.enabled = reader.bool(); + break; + case 4: + message.contractOwner = (reader.int32() as any); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): TokenPair { + const obj = createBaseTokenPair(); + if (isSet(object.erc20Address)) obj.erc20Address = String(object.erc20Address); + if (isSet(object.denom)) obj.denom = String(object.denom); + if (isSet(object.enabled)) obj.enabled = Boolean(object.enabled); + if (isSet(object.contractOwner)) obj.contractOwner = ownerFromJSON(object.contractOwner); + return obj; + }, + toJSON(message: TokenPair): JsonSafe { + const obj: any = {}; + message.erc20Address !== undefined && (obj.erc20Address = message.erc20Address); + message.denom !== undefined && (obj.denom = message.denom); + message.enabled !== undefined && (obj.enabled = message.enabled); + message.contractOwner !== undefined && (obj.contractOwner = ownerToJSON(message.contractOwner)); + return obj; + }, + fromPartial(object: DeepPartial): TokenPair { + const message = createBaseTokenPair(); + message.erc20Address = object.erc20Address ?? ""; + message.denom = object.denom ?? ""; + message.enabled = object.enabled ?? false; + message.contractOwner = object.contractOwner ?? 0; + return message; + }, + fromSDK(object: TokenPairSDKType): TokenPair { + return { + erc20Address: object?.erc20_address, + denom: object?.denom, + enabled: object?.enabled, + contractOwner: isSet(object.contract_owner) ? ownerFromJSON(object.contract_owner) : -1 + }; + }, + fromSDKJSON(object: any): TokenPairSDKType { + return { + erc20_address: isSet(object.erc20_address) ? String(object.erc20_address) : "", + denom: isSet(object.denom) ? String(object.denom) : "", + enabled: isSet(object.enabled) ? Boolean(object.enabled) : false, + contract_owner: isSet(object.contract_owner) ? ownerFromJSON(object.contract_owner) : -1 + }; + }, + toSDK(message: TokenPair): TokenPairSDKType { + const obj: any = {}; + obj.erc20_address = message.erc20Address; + obj.denom = message.denom; + obj.enabled = message.enabled; + message.contractOwner !== undefined && (obj.contract_owner = ownerToJSON(message.contractOwner)); + return obj; + }, + fromAmino(object: TokenPairAmino): TokenPair { + const message = createBaseTokenPair(); + if (object.erc20_address !== undefined && object.erc20_address !== null) { + message.erc20Address = object.erc20_address; + } + if (object.denom !== undefined && object.denom !== null) { + message.denom = object.denom; + } + if (object.enabled !== undefined && object.enabled !== null) { + message.enabled = object.enabled; + } + if (object.contract_owner !== undefined && object.contract_owner !== null) { + message.contractOwner = object.contract_owner; + } + return message; + }, + toAmino(message: TokenPair): TokenPairAmino { + const obj: any = {}; + obj.erc20_address = message.erc20Address === "" ? undefined : message.erc20Address; + obj.denom = message.denom === "" ? undefined : message.denom; + obj.enabled = message.enabled === false ? undefined : message.enabled; + obj.contract_owner = message.contractOwner === 0 ? undefined : message.contractOwner; + return obj; + }, + fromAminoMsg(object: TokenPairAminoMsg): TokenPair { + return TokenPair.fromAmino(object.value); + }, + fromProtoMsg(message: TokenPairProtoMsg): TokenPair { + return TokenPair.decode(message.value); + }, + toProto(message: TokenPair): Uint8Array { + return TokenPair.encode(message).finish(); + }, + toProtoMsg(message: TokenPair): TokenPairProtoMsg { + return { + typeUrl: "/evmos.erc20.v1.TokenPair", + value: TokenPair.encode(message).finish() + }; + } +}; +function createBaseRegisterCoinProposal(): RegisterCoinProposal { + return { + title: "", + description: "", + metadata: Metadata.fromPartial({}) + }; +} +export const RegisterCoinProposal = { + typeUrl: "/evmos.erc20.v1.RegisterCoinProposal", + encode(message: RegisterCoinProposal, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.title !== undefined) { + writer.uint32(10).string(message.title); + } + if (message.description !== undefined) { + writer.uint32(18).string(message.description); + } + if (message.metadata !== undefined) { + Metadata.encode(message.metadata, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): RegisterCoinProposal { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseRegisterCoinProposal(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.title = reader.string(); + break; + case 2: + message.description = reader.string(); + break; + case 3: + message.metadata = Metadata.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): RegisterCoinProposal { + const obj = createBaseRegisterCoinProposal(); + if (isSet(object.title)) obj.title = String(object.title); + if (isSet(object.description)) obj.description = String(object.description); + if (isSet(object.metadata)) obj.metadata = Metadata.fromJSON(object.metadata); + return obj; + }, + toJSON(message: RegisterCoinProposal): JsonSafe { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && (obj.description = message.description); + message.metadata !== undefined && (obj.metadata = message.metadata ? Metadata.toJSON(message.metadata) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): RegisterCoinProposal { + const message = createBaseRegisterCoinProposal(); + message.title = object.title ?? ""; + message.description = object.description ?? ""; + if (object.metadata !== undefined && object.metadata !== null) { + message.metadata = Metadata.fromPartial(object.metadata); + } + return message; + }, + fromSDK(object: RegisterCoinProposalSDKType): RegisterCoinProposal { + return { + title: object?.title, + description: object?.description, + metadata: object.metadata ? Metadata.fromSDK(object.metadata) : undefined + }; + }, + fromSDKJSON(object: any): RegisterCoinProposalSDKType { + return { + title: isSet(object.title) ? String(object.title) : "", + description: isSet(object.description) ? String(object.description) : "", + metadata: isSet(object.metadata) ? Metadata.fromSDKJSON(object.metadata) : undefined + }; + }, + toSDK(message: RegisterCoinProposal): RegisterCoinProposalSDKType { + const obj: any = {}; + obj.title = message.title; + obj.description = message.description; + message.metadata !== undefined && (obj.metadata = message.metadata ? Metadata.toSDK(message.metadata) : undefined); + return obj; + }, + fromAmino(object: RegisterCoinProposalAmino): RegisterCoinProposal { + const message = createBaseRegisterCoinProposal(); + if (object.title !== undefined && object.title !== null) { + message.title = object.title; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } + if (object.metadata !== undefined && object.metadata !== null) { + message.metadata = Metadata.fromAmino(object.metadata); + } + return message; + }, + toAmino(message: RegisterCoinProposal): RegisterCoinProposalAmino { + const obj: any = {}; + obj.title = message.title === "" ? undefined : message.title; + obj.description = message.description === "" ? undefined : message.description; + obj.metadata = message.metadata ? Metadata.toAmino(message.metadata) : undefined; + return obj; + }, + fromAminoMsg(object: RegisterCoinProposalAminoMsg): RegisterCoinProposal { + return RegisterCoinProposal.fromAmino(object.value); + }, + fromProtoMsg(message: RegisterCoinProposalProtoMsg): RegisterCoinProposal { + return RegisterCoinProposal.decode(message.value); + }, + toProto(message: RegisterCoinProposal): Uint8Array { + return RegisterCoinProposal.encode(message).finish(); + }, + toProtoMsg(message: RegisterCoinProposal): RegisterCoinProposalProtoMsg { + return { + typeUrl: "/evmos.erc20.v1.RegisterCoinProposal", + value: RegisterCoinProposal.encode(message).finish() + }; + } +}; +function createBaseRegisterERC20Proposal(): RegisterERC20Proposal { + return { + title: "", + description: "", + erc20address: "" + }; +} +export const RegisterERC20Proposal = { + typeUrl: "/evmos.erc20.v1.RegisterERC20Proposal", + encode(message: RegisterERC20Proposal, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.title !== undefined) { + writer.uint32(10).string(message.title); + } + if (message.description !== undefined) { + writer.uint32(18).string(message.description); + } + if (message.erc20address !== undefined) { + writer.uint32(26).string(message.erc20address); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): RegisterERC20Proposal { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseRegisterERC20Proposal(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.title = reader.string(); + break; + case 2: + message.description = reader.string(); + break; + case 3: + message.erc20address = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): RegisterERC20Proposal { + const obj = createBaseRegisterERC20Proposal(); + if (isSet(object.title)) obj.title = String(object.title); + if (isSet(object.description)) obj.description = String(object.description); + if (isSet(object.erc20address)) obj.erc20address = String(object.erc20address); + return obj; + }, + toJSON(message: RegisterERC20Proposal): JsonSafe { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && (obj.description = message.description); + message.erc20address !== undefined && (obj.erc20address = message.erc20address); + return obj; + }, + fromPartial(object: DeepPartial): RegisterERC20Proposal { + const message = createBaseRegisterERC20Proposal(); + message.title = object.title ?? ""; + message.description = object.description ?? ""; + message.erc20address = object.erc20address ?? ""; + return message; + }, + fromSDK(object: RegisterERC20ProposalSDKType): RegisterERC20Proposal { + return { + title: object?.title, + description: object?.description, + erc20address: object?.erc20address + }; + }, + fromSDKJSON(object: any): RegisterERC20ProposalSDKType { + return { + title: isSet(object.title) ? String(object.title) : "", + description: isSet(object.description) ? String(object.description) : "", + erc20address: isSet(object.erc20address) ? String(object.erc20address) : "" + }; + }, + toSDK(message: RegisterERC20Proposal): RegisterERC20ProposalSDKType { + const obj: any = {}; + obj.title = message.title; + obj.description = message.description; + obj.erc20address = message.erc20address; + return obj; + }, + fromAmino(object: RegisterERC20ProposalAmino): RegisterERC20Proposal { + const message = createBaseRegisterERC20Proposal(); + if (object.title !== undefined && object.title !== null) { + message.title = object.title; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } + if (object.erc20address !== undefined && object.erc20address !== null) { + message.erc20address = object.erc20address; + } + return message; + }, + toAmino(message: RegisterERC20Proposal): RegisterERC20ProposalAmino { + const obj: any = {}; + obj.title = message.title === "" ? undefined : message.title; + obj.description = message.description === "" ? undefined : message.description; + obj.erc20address = message.erc20address === "" ? undefined : message.erc20address; + return obj; + }, + fromAminoMsg(object: RegisterERC20ProposalAminoMsg): RegisterERC20Proposal { + return RegisterERC20Proposal.fromAmino(object.value); + }, + fromProtoMsg(message: RegisterERC20ProposalProtoMsg): RegisterERC20Proposal { + return RegisterERC20Proposal.decode(message.value); + }, + toProto(message: RegisterERC20Proposal): Uint8Array { + return RegisterERC20Proposal.encode(message).finish(); + }, + toProtoMsg(message: RegisterERC20Proposal): RegisterERC20ProposalProtoMsg { + return { + typeUrl: "/evmos.erc20.v1.RegisterERC20Proposal", + value: RegisterERC20Proposal.encode(message).finish() + }; + } +}; +function createBaseToggleTokenConversionProposal(): ToggleTokenConversionProposal { + return { + title: "", + description: "", + token: "" + }; +} +export const ToggleTokenConversionProposal = { + typeUrl: "/evmos.erc20.v1.ToggleTokenConversionProposal", + encode(message: ToggleTokenConversionProposal, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.title !== undefined) { + writer.uint32(10).string(message.title); + } + if (message.description !== undefined) { + writer.uint32(18).string(message.description); + } + if (message.token !== undefined) { + writer.uint32(26).string(message.token); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ToggleTokenConversionProposal { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseToggleTokenConversionProposal(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.title = reader.string(); + break; + case 2: + message.description = reader.string(); + break; + case 3: + message.token = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ToggleTokenConversionProposal { + const obj = createBaseToggleTokenConversionProposal(); + if (isSet(object.title)) obj.title = String(object.title); + if (isSet(object.description)) obj.description = String(object.description); + if (isSet(object.token)) obj.token = String(object.token); + return obj; + }, + toJSON(message: ToggleTokenConversionProposal): JsonSafe { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && (obj.description = message.description); + message.token !== undefined && (obj.token = message.token); + return obj; + }, + fromPartial(object: DeepPartial): ToggleTokenConversionProposal { + const message = createBaseToggleTokenConversionProposal(); + message.title = object.title ?? ""; + message.description = object.description ?? ""; + message.token = object.token ?? ""; + return message; + }, + fromSDK(object: ToggleTokenConversionProposalSDKType): ToggleTokenConversionProposal { + return { + title: object?.title, + description: object?.description, + token: object?.token + }; + }, + fromSDKJSON(object: any): ToggleTokenConversionProposalSDKType { + return { + title: isSet(object.title) ? String(object.title) : "", + description: isSet(object.description) ? String(object.description) : "", + token: isSet(object.token) ? String(object.token) : "" + }; + }, + toSDK(message: ToggleTokenConversionProposal): ToggleTokenConversionProposalSDKType { + const obj: any = {}; + obj.title = message.title; + obj.description = message.description; + obj.token = message.token; + return obj; + }, + fromAmino(object: ToggleTokenConversionProposalAmino): ToggleTokenConversionProposal { + const message = createBaseToggleTokenConversionProposal(); + if (object.title !== undefined && object.title !== null) { + message.title = object.title; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } + if (object.token !== undefined && object.token !== null) { + message.token = object.token; + } + return message; + }, + toAmino(message: ToggleTokenConversionProposal): ToggleTokenConversionProposalAmino { + const obj: any = {}; + obj.title = message.title === "" ? undefined : message.title; + obj.description = message.description === "" ? undefined : message.description; + obj.token = message.token === "" ? undefined : message.token; + return obj; + }, + fromAminoMsg(object: ToggleTokenConversionProposalAminoMsg): ToggleTokenConversionProposal { + return ToggleTokenConversionProposal.fromAmino(object.value); + }, + fromProtoMsg(message: ToggleTokenConversionProposalProtoMsg): ToggleTokenConversionProposal { + return ToggleTokenConversionProposal.decode(message.value); + }, + toProto(message: ToggleTokenConversionProposal): Uint8Array { + return ToggleTokenConversionProposal.encode(message).finish(); + }, + toProtoMsg(message: ToggleTokenConversionProposal): ToggleTokenConversionProposalProtoMsg { + return { + typeUrl: "/evmos.erc20.v1.ToggleTokenConversionProposal", + value: ToggleTokenConversionProposal.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/evmos/erc20/v1/genesis.ts b/__fixtures__/v-next/outputicjsdeps/evmos/erc20/v1/genesis.ts new file mode 100644 index 0000000000..ab01fa0129 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/evmos/erc20/v1/genesis.ts @@ -0,0 +1,263 @@ +import { TokenPair, TokenPairSDKType } from "./erc20.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "evmos.erc20.v1"; +/** GenesisState defines the module's genesis state. */ +export interface GenesisState { + /** module parameters */ + params: Params; + /** registered token pairs */ + tokenPairs: TokenPair[]; +} +export interface GenesisStateProtoMsg { + typeUrl: "/evmos.erc20.v1.GenesisState"; + value: Uint8Array; +} +/** GenesisState defines the module's genesis state. */ +export interface GenesisStateSDKType { + params: ParamsSDKType; + token_pairs: TokenPairSDKType[]; +} +/** Params defines the erc20 module params */ +export interface Params { + /** parameter to enable the conversion of Cosmos coins <--> ERC20 tokens. */ + enableErc20: boolean; + /** + * parameter to enable the EVM hook that converts an ERC20 token to a Cosmos + * Coin by transferring the Tokens through a MsgEthereumTx to the + * ModuleAddress Ethereum address. + */ + enableEvmHook: boolean; +} +export interface ParamsProtoMsg { + typeUrl: "/evmos.erc20.v1.Params"; + value: Uint8Array; +} +/** Params defines the erc20 module params */ +export interface ParamsSDKType { + enable_erc20: boolean; + enable_evm_hook: boolean; +} +function createBaseGenesisState(): GenesisState { + return { + params: Params.fromPartial({}), + tokenPairs: [] + }; +} +export const GenesisState = { + typeUrl: "/evmos.erc20.v1.GenesisState", + encode(message: GenesisState, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.tokenPairs) { + TokenPair.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GenesisState { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGenesisState(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.params = Params.decode(reader, reader.uint32()); + break; + case 2: + message.tokenPairs.push(TokenPair.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GenesisState { + const obj = createBaseGenesisState(); + if (isSet(object.params)) obj.params = Params.fromJSON(object.params); + if (Array.isArray(object?.tokenPairs)) obj.tokenPairs = object.tokenPairs.map((e: any) => TokenPair.fromJSON(e)); + return obj; + }, + toJSON(message: GenesisState): JsonSafe { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); + if (message.tokenPairs) { + obj.tokenPairs = message.tokenPairs.map(e => e ? TokenPair.toJSON(e) : undefined); + } else { + obj.tokenPairs = []; + } + return obj; + }, + fromPartial(object: DeepPartial): GenesisState { + const message = createBaseGenesisState(); + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } + message.tokenPairs = object.tokenPairs?.map(e => TokenPair.fromPartial(e)) || []; + return message; + }, + fromSDK(object: GenesisStateSDKType): GenesisState { + return { + params: object.params ? Params.fromSDK(object.params) : undefined, + tokenPairs: Array.isArray(object?.token_pairs) ? object.token_pairs.map((e: any) => TokenPair.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): GenesisStateSDKType { + return { + params: isSet(object.params) ? Params.fromSDKJSON(object.params) : undefined, + token_pairs: Array.isArray(object?.token_pairs) ? object.token_pairs.map((e: any) => TokenPair.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: GenesisState): GenesisStateSDKType { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toSDK(message.params) : undefined); + if (message.tokenPairs) { + obj.token_pairs = message.tokenPairs.map(e => e ? TokenPair.toSDK(e) : undefined); + } else { + obj.token_pairs = []; + } + return obj; + }, + fromAmino(object: GenesisStateAmino): GenesisState { + const message = createBaseGenesisState(); + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromAmino(object.params); + } + message.tokenPairs = object.token_pairs?.map(e => TokenPair.fromAmino(e)) || []; + return message; + }, + toAmino(message: GenesisState): GenesisStateAmino { + const obj: any = {}; + obj.params = message.params ? Params.toAmino(message.params) : undefined; + if (message.tokenPairs) { + obj.token_pairs = message.tokenPairs.map(e => e ? TokenPair.toAmino(e) : undefined); + } else { + obj.token_pairs = message.tokenPairs; + } + return obj; + }, + fromAminoMsg(object: GenesisStateAminoMsg): GenesisState { + return GenesisState.fromAmino(object.value); + }, + fromProtoMsg(message: GenesisStateProtoMsg): GenesisState { + return GenesisState.decode(message.value); + }, + toProto(message: GenesisState): Uint8Array { + return GenesisState.encode(message).finish(); + }, + toProtoMsg(message: GenesisState): GenesisStateProtoMsg { + return { + typeUrl: "/evmos.erc20.v1.GenesisState", + value: GenesisState.encode(message).finish() + }; + } +}; +function createBaseParams(): Params { + return { + enableErc20: false, + enableEvmHook: false + }; +} +export const Params = { + typeUrl: "/evmos.erc20.v1.Params", + encode(message: Params, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.enableErc20 !== undefined) { + writer.uint32(8).bool(message.enableErc20); + } + if (message.enableEvmHook !== undefined) { + writer.uint32(16).bool(message.enableEvmHook); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Params { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseParams(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.enableErc20 = reader.bool(); + break; + case 2: + message.enableEvmHook = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Params { + const obj = createBaseParams(); + if (isSet(object.enableErc20)) obj.enableErc20 = Boolean(object.enableErc20); + if (isSet(object.enableEvmHook)) obj.enableEvmHook = Boolean(object.enableEvmHook); + return obj; + }, + toJSON(message: Params): JsonSafe { + const obj: any = {}; + message.enableErc20 !== undefined && (obj.enableErc20 = message.enableErc20); + message.enableEvmHook !== undefined && (obj.enableEvmHook = message.enableEvmHook); + return obj; + }, + fromPartial(object: DeepPartial): Params { + const message = createBaseParams(); + message.enableErc20 = object.enableErc20 ?? false; + message.enableEvmHook = object.enableEvmHook ?? false; + return message; + }, + fromSDK(object: ParamsSDKType): Params { + return { + enableErc20: object?.enable_erc20, + enableEvmHook: object?.enable_evm_hook + }; + }, + fromSDKJSON(object: any): ParamsSDKType { + return { + enable_erc20: isSet(object.enable_erc20) ? Boolean(object.enable_erc20) : false, + enable_evm_hook: isSet(object.enable_evm_hook) ? Boolean(object.enable_evm_hook) : false + }; + }, + toSDK(message: Params): ParamsSDKType { + const obj: any = {}; + obj.enable_erc20 = message.enableErc20; + obj.enable_evm_hook = message.enableEvmHook; + return obj; + }, + fromAmino(object: ParamsAmino): Params { + const message = createBaseParams(); + if (object.enable_erc20 !== undefined && object.enable_erc20 !== null) { + message.enableErc20 = object.enable_erc20; + } + if (object.enable_evm_hook !== undefined && object.enable_evm_hook !== null) { + message.enableEvmHook = object.enable_evm_hook; + } + return message; + }, + toAmino(message: Params): ParamsAmino { + const obj: any = {}; + obj.enable_erc20 = message.enableErc20 === false ? undefined : message.enableErc20; + obj.enable_evm_hook = message.enableEvmHook === false ? undefined : message.enableEvmHook; + return obj; + }, + fromAminoMsg(object: ParamsAminoMsg): Params { + return Params.fromAmino(object.value); + }, + fromProtoMsg(message: ParamsProtoMsg): Params { + return Params.decode(message.value); + }, + toProto(message: Params): Uint8Array { + return Params.encode(message).finish(); + }, + toProtoMsg(message: Params): ParamsProtoMsg { + return { + typeUrl: "/evmos.erc20.v1.Params", + value: Params.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/evmos/erc20/v1/query.lcd.ts b/__fixtures__/v-next/outputicjsdeps/evmos/erc20/v1/query.lcd.ts new file mode 100644 index 0000000000..342838d766 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/evmos/erc20/v1/query.lcd.ts @@ -0,0 +1,42 @@ +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../../cosmos/base/query/v1beta1/pagination.js"; +import { TokenPair, TokenPairSDKType } from "./erc20.js"; +import { Params, ParamsSDKType } from "./genesis.js"; +import { setPaginationParams } from "../../../helpers.js"; +import { LCDClient } from "@cosmology/lcd"; +import { QueryTokenPairsRequest, QueryTokenPairsRequestSDKType, QueryTokenPairsResponse, QueryTokenPairsResponseSDKType, QueryTokenPairRequest, QueryTokenPairRequestSDKType, QueryTokenPairResponse, QueryTokenPairResponseSDKType, QueryParamsRequest, QueryParamsRequestSDKType, QueryParamsResponse, QueryParamsResponseSDKType } from "./query.js"; +export class LCDQueryClient { + req: LCDClient; + constructor({ + requestClient + }: { + requestClient: LCDClient; + }) { + this.req = requestClient; + this.tokenPairs = this.tokenPairs.bind(this); + this.tokenPair = this.tokenPair.bind(this); + this.params = this.params.bind(this); + } + /* TokenPairs retrieves registered token pairs */ + async tokenPairs(params: QueryTokenPairsRequest = { + pagination: PageRequest.fromPartial({}) + }): Promise { + const options: any = { + params: {} + }; + if (typeof params?.pagination !== "undefined") { + setPaginationParams(options, params.pagination); + } + const endpoint = `evmos/erc20/v1/token_pairs`; + return QueryTokenPairsResponse.fromSDKJSON(await this.req.get(endpoint, options)); + } + /* TokenPair retrieves a registered token pair */ + async tokenPair(params: QueryTokenPairRequest): Promise { + const endpoint = `evmos/erc20/v1/token_pairs/${params.token}`; + return QueryTokenPairResponse.fromSDKJSON(await this.req.get(endpoint)); + } + /* Params retrieves the erc20 module params */ + async params(_params: QueryParamsRequest = {}): Promise { + const endpoint = `evmos/erc20/v1/params`; + return QueryParamsResponse.fromSDKJSON(await this.req.get(endpoint)); + } +} \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/evmos/erc20/v1/query.pinia.store.ts b/__fixtures__/v-next/outputicjsdeps/evmos/erc20/v1/query.pinia.store.ts new file mode 100644 index 0000000000..590477a43d --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/evmos/erc20/v1/query.pinia.store.ts @@ -0,0 +1,37 @@ +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../../cosmos/base/query/v1beta1/pagination.js"; +import { TokenPair, TokenPairSDKType } from "./erc20.js"; +import { Params, ParamsSDKType } from "./genesis.js"; +import { LCDClient } from "@cosmology/lcd"; +import { useEndpoint } from "../../../pinia-endpoint.js"; +import { QueryTokenPairsRequest, QueryTokenPairsRequestSDKType, QueryTokenPairsResponse, QueryTokenPairsResponseSDKType, QueryTokenPairRequest, QueryTokenPairRequestSDKType, QueryTokenPairResponse, QueryTokenPairResponseSDKType, QueryParamsRequest, QueryParamsRequestSDKType, QueryParamsResponse, QueryParamsResponseSDKType } from "./query.js"; +import { defineStore } from "pinia"; +import { LCDQueryClient } from "./query.lcd.js"; +export const usePiniaStore = defineStore('evmos/erc20/v1/query.proto', { + state: () => { + return { + tokenPairs: ({} as QueryTokenPairsResponseSDKType), + tokenPair: ({} as QueryTokenPairResponseSDKType), + params: ({} as QueryParamsResponseSDKType) + }; + }, + getters: { + lcdClient() { + const requestClient = useEndpoint().restClient; + return new LCDQueryClient({ requestClient }); + } + }, + actions: { + async fetchTokenPairs(param : QueryTokenPairsRequestSDKType) { + this.tokenPairs = await this.lcdClient.tokenPairs(param); + return this.tokenPairs; + }, + async fetchTokenPair(param : QueryTokenPairRequestSDKType) { + this.tokenPair = await this.lcdClient.tokenPair(param); + return this.tokenPair; + }, + async fetchParams(param : QueryParamsRequestSDKType) { + this.params = await this.lcdClient.params(param); + return this.params; + } + } +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/evmos/erc20/v1/query.rpc.Query.ts b/__fixtures__/v-next/outputicjsdeps/evmos/erc20/v1/query.rpc.Query.ts new file mode 100644 index 0000000000..39cb552d59 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/evmos/erc20/v1/query.rpc.Query.ts @@ -0,0 +1,57 @@ +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../../cosmos/base/query/v1beta1/pagination.js"; +import { TokenPair, TokenPairSDKType } from "./erc20.js"; +import { Params, ParamsSDKType } from "./genesis.js"; +import { Rpc } from "../../../helpers.js"; +import { BinaryReader } from "../../../binary.js"; +import { QueryClient, createProtobufRpcClient } from "@cosmjs/stargate"; +import { QueryTokenPairsRequest, QueryTokenPairsRequestSDKType, QueryTokenPairsResponse, QueryTokenPairsResponseSDKType, QueryTokenPairRequest, QueryTokenPairRequestSDKType, QueryTokenPairResponse, QueryTokenPairResponseSDKType, QueryParamsRequest, QueryParamsRequestSDKType, QueryParamsResponse, QueryParamsResponseSDKType } from "./query.js"; +/** Query defines the gRPC querier service. */ +export interface Query { + /** TokenPairs retrieves registered token pairs */ + tokenPairs(request?: QueryTokenPairsRequest): Promise; + /** TokenPair retrieves a registered token pair */ + tokenPair(request: QueryTokenPairRequest): Promise; + /** Params retrieves the erc20 module params */ + params(request?: QueryParamsRequest): Promise; +} +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + this.tokenPairs = this.tokenPairs.bind(this); + this.tokenPair = this.tokenPair.bind(this); + this.params = this.params.bind(this); + } + tokenPairs(request: QueryTokenPairsRequest = { + pagination: PageRequest.fromPartial({}) + }): Promise { + const data = QueryTokenPairsRequest.encode(request).finish(); + const promise = this.rpc.request("evmos.erc20.v1.Query", "TokenPairs", data); + return promise.then(data => QueryTokenPairsResponse.decode(new BinaryReader(data))); + } + tokenPair(request: QueryTokenPairRequest): Promise { + const data = QueryTokenPairRequest.encode(request).finish(); + const promise = this.rpc.request("evmos.erc20.v1.Query", "TokenPair", data); + return promise.then(data => QueryTokenPairResponse.decode(new BinaryReader(data))); + } + params(request: QueryParamsRequest = {}): Promise { + const data = QueryParamsRequest.encode(request).finish(); + const promise = this.rpc.request("evmos.erc20.v1.Query", "Params", data); + return promise.then(data => QueryParamsResponse.decode(new BinaryReader(data))); + } +} +export const createRpcQueryExtension = (base: QueryClient) => { + const rpc = createProtobufRpcClient(base); + const queryService = new QueryClientImpl(rpc); + return { + tokenPairs(request?: QueryTokenPairsRequest): Promise { + return queryService.tokenPairs(request); + }, + tokenPair(request: QueryTokenPairRequest): Promise { + return queryService.tokenPair(request); + }, + params(request?: QueryParamsRequest): Promise { + return queryService.params(request); + } + }; +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/evmos/erc20/v1/query.rpc.func.ts b/__fixtures__/v-next/outputicjsdeps/evmos/erc20/v1/query.rpc.func.ts new file mode 100644 index 0000000000..263f29c0d8 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/evmos/erc20/v1/query.rpc.func.ts @@ -0,0 +1,36 @@ +import { RpcResolver, buildQuery } from "../../../helper-func-types"; +import { buildUseQuery } from "../../../react-query"; +import { QueryTokenPairsRequest, QueryTokenPairsResponse, QueryTokenPairRequest, QueryTokenPairResponse, QueryParamsRequest, QueryParamsResponse } from "./query"; +export const createGetTokenPairs = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryTokenPairsRequest.encode, + decode: QueryTokenPairsResponse.decode, + service: "evmos.erc20.v1.Query", + method: "TokenPairs", + getRpcInstance: getRpcInstance +}); +export const useGetTokenPairs = buildUseQuery({ + builderQueryFn: createGetTokenPairs, + queryKeyPrefix: "TokenPairsQuery" +}); +export const createGetTokenPair = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryTokenPairRequest.encode, + decode: QueryTokenPairResponse.decode, + service: "evmos.erc20.v1.Query", + method: "TokenPair", + getRpcInstance: getRpcInstance +}); +export const useGetTokenPair = buildUseQuery({ + builderQueryFn: createGetTokenPair, + queryKeyPrefix: "TokenPairQuery" +}); +export const createGetParams = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryParamsRequest.encode, + decode: QueryParamsResponse.decode, + service: "evmos.erc20.v1.Query", + method: "Params", + getRpcInstance: getRpcInstance +}); +export const useGetParams = buildUseQuery({ + builderQueryFn: createGetParams, + queryKeyPrefix: "ParamsQuery" +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/evmos/erc20/v1/query.ts b/__fixtures__/v-next/outputicjsdeps/evmos/erc20/v1/query.ts new file mode 100644 index 0000000000..f61037c59e --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/evmos/erc20/v1/query.ts @@ -0,0 +1,650 @@ +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../../cosmos/base/query/v1beta1/pagination.js"; +import { TokenPair, TokenPairSDKType } from "./erc20.js"; +import { Params, ParamsSDKType } from "./genesis.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "evmos.erc20.v1"; +/** + * QueryTokenPairsRequest is the request type for the Query/TokenPairs RPC + * method. + */ +export interface QueryTokenPairsRequest { + /** pagination defines an optional pagination for the request. */ + pagination?: PageRequest; +} +export interface QueryTokenPairsRequestProtoMsg { + typeUrl: "/evmos.erc20.v1.QueryTokenPairsRequest"; + value: Uint8Array; +} +/** + * QueryTokenPairsRequest is the request type for the Query/TokenPairs RPC + * method. + */ +export interface QueryTokenPairsRequestSDKType { + pagination?: PageRequestSDKType; +} +/** + * QueryTokenPairsResponse is the response type for the Query/TokenPairs RPC + * method. + */ +export interface QueryTokenPairsResponse { + tokenPairs: TokenPair[]; + /** pagination defines the pagination in the response. */ + pagination?: PageResponse; +} +export interface QueryTokenPairsResponseProtoMsg { + typeUrl: "/evmos.erc20.v1.QueryTokenPairsResponse"; + value: Uint8Array; +} +/** + * QueryTokenPairsResponse is the response type for the Query/TokenPairs RPC + * method. + */ +export interface QueryTokenPairsResponseSDKType { + token_pairs: TokenPairSDKType[]; + pagination?: PageResponseSDKType; +} +/** QueryTokenPairRequest is the request type for the Query/TokenPair RPC method. */ +export interface QueryTokenPairRequest { + /** + * token identifier can be either the hex contract address of the ERC20 or the + * Cosmos base denomination + */ + token: string; +} +export interface QueryTokenPairRequestProtoMsg { + typeUrl: "/evmos.erc20.v1.QueryTokenPairRequest"; + value: Uint8Array; +} +/** QueryTokenPairRequest is the request type for the Query/TokenPair RPC method. */ +export interface QueryTokenPairRequestSDKType { + token: string; +} +/** + * QueryTokenPairResponse is the response type for the Query/TokenPair RPC + * method. + */ +export interface QueryTokenPairResponse { + tokenPair: TokenPair; +} +export interface QueryTokenPairResponseProtoMsg { + typeUrl: "/evmos.erc20.v1.QueryTokenPairResponse"; + value: Uint8Array; +} +/** + * QueryTokenPairResponse is the response type for the Query/TokenPair RPC + * method. + */ +export interface QueryTokenPairResponseSDKType { + token_pair: TokenPairSDKType; +} +/** QueryParamsRequest is the request type for the Query/Params RPC method. */ +export interface QueryParamsRequest {} +export interface QueryParamsRequestProtoMsg { + typeUrl: "/evmos.erc20.v1.QueryParamsRequest"; + value: Uint8Array; +} +/** QueryParamsRequest is the request type for the Query/Params RPC method. */ +export interface QueryParamsRequestSDKType {} +/** + * QueryParamsResponse is the response type for the Query/Params RPC + * method. + */ +export interface QueryParamsResponse { + params: Params; +} +export interface QueryParamsResponseProtoMsg { + typeUrl: "/evmos.erc20.v1.QueryParamsResponse"; + value: Uint8Array; +} +/** + * QueryParamsResponse is the response type for the Query/Params RPC + * method. + */ +export interface QueryParamsResponseSDKType { + params: ParamsSDKType; +} +function createBaseQueryTokenPairsRequest(): QueryTokenPairsRequest { + return { + pagination: undefined + }; +} +export const QueryTokenPairsRequest = { + typeUrl: "/evmos.erc20.v1.QueryTokenPairsRequest", + encode(message: QueryTokenPairsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryTokenPairsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryTokenPairsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryTokenPairsRequest { + const obj = createBaseQueryTokenPairsRequest(); + if (isSet(object.pagination)) obj.pagination = PageRequest.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryTokenPairsRequest): JsonSafe { + const obj: any = {}; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryTokenPairsRequest { + const message = createBaseQueryTokenPairsRequest(); + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryTokenPairsRequestSDKType): QueryTokenPairsRequest { + return { + pagination: object.pagination ? PageRequest.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryTokenPairsRequestSDKType { + return { + pagination: isSet(object.pagination) ? PageRequest.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryTokenPairsRequest): QueryTokenPairsRequestSDKType { + const obj: any = {}; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryTokenPairsRequestAmino): QueryTokenPairsRequest { + const message = createBaseQueryTokenPairsRequest(); + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryTokenPairsRequest): QueryTokenPairsRequestAmino { + const obj: any = {}; + obj.pagination = message.pagination ? PageRequest.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryTokenPairsRequestAminoMsg): QueryTokenPairsRequest { + return QueryTokenPairsRequest.fromAmino(object.value); + }, + fromProtoMsg(message: QueryTokenPairsRequestProtoMsg): QueryTokenPairsRequest { + return QueryTokenPairsRequest.decode(message.value); + }, + toProto(message: QueryTokenPairsRequest): Uint8Array { + return QueryTokenPairsRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryTokenPairsRequest): QueryTokenPairsRequestProtoMsg { + return { + typeUrl: "/evmos.erc20.v1.QueryTokenPairsRequest", + value: QueryTokenPairsRequest.encode(message).finish() + }; + } +}; +function createBaseQueryTokenPairsResponse(): QueryTokenPairsResponse { + return { + tokenPairs: [], + pagination: undefined + }; +} +export const QueryTokenPairsResponse = { + typeUrl: "/evmos.erc20.v1.QueryTokenPairsResponse", + encode(message: QueryTokenPairsResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.tokenPairs) { + TokenPair.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryTokenPairsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryTokenPairsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.tokenPairs.push(TokenPair.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryTokenPairsResponse { + const obj = createBaseQueryTokenPairsResponse(); + if (Array.isArray(object?.tokenPairs)) obj.tokenPairs = object.tokenPairs.map((e: any) => TokenPair.fromJSON(e)); + if (isSet(object.pagination)) obj.pagination = PageResponse.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryTokenPairsResponse): JsonSafe { + const obj: any = {}; + if (message.tokenPairs) { + obj.tokenPairs = message.tokenPairs.map(e => e ? TokenPair.toJSON(e) : undefined); + } else { + obj.tokenPairs = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryTokenPairsResponse { + const message = createBaseQueryTokenPairsResponse(); + message.tokenPairs = object.tokenPairs?.map(e => TokenPair.fromPartial(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryTokenPairsResponseSDKType): QueryTokenPairsResponse { + return { + tokenPairs: Array.isArray(object?.token_pairs) ? object.token_pairs.map((e: any) => TokenPair.fromSDK(e)) : [], + pagination: object.pagination ? PageResponse.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryTokenPairsResponseSDKType { + return { + token_pairs: Array.isArray(object?.token_pairs) ? object.token_pairs.map((e: any) => TokenPair.fromSDKJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryTokenPairsResponse): QueryTokenPairsResponseSDKType { + const obj: any = {}; + if (message.tokenPairs) { + obj.token_pairs = message.tokenPairs.map(e => e ? TokenPair.toSDK(e) : undefined); + } else { + obj.token_pairs = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryTokenPairsResponseAmino): QueryTokenPairsResponse { + const message = createBaseQueryTokenPairsResponse(); + message.tokenPairs = object.token_pairs?.map(e => TokenPair.fromAmino(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryTokenPairsResponse): QueryTokenPairsResponseAmino { + const obj: any = {}; + if (message.tokenPairs) { + obj.token_pairs = message.tokenPairs.map(e => e ? TokenPair.toAmino(e) : undefined); + } else { + obj.token_pairs = message.tokenPairs; + } + obj.pagination = message.pagination ? PageResponse.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryTokenPairsResponseAminoMsg): QueryTokenPairsResponse { + return QueryTokenPairsResponse.fromAmino(object.value); + }, + fromProtoMsg(message: QueryTokenPairsResponseProtoMsg): QueryTokenPairsResponse { + return QueryTokenPairsResponse.decode(message.value); + }, + toProto(message: QueryTokenPairsResponse): Uint8Array { + return QueryTokenPairsResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryTokenPairsResponse): QueryTokenPairsResponseProtoMsg { + return { + typeUrl: "/evmos.erc20.v1.QueryTokenPairsResponse", + value: QueryTokenPairsResponse.encode(message).finish() + }; + } +}; +function createBaseQueryTokenPairRequest(): QueryTokenPairRequest { + return { + token: "" + }; +} +export const QueryTokenPairRequest = { + typeUrl: "/evmos.erc20.v1.QueryTokenPairRequest", + encode(message: QueryTokenPairRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.token !== undefined) { + writer.uint32(10).string(message.token); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryTokenPairRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryTokenPairRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.token = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryTokenPairRequest { + const obj = createBaseQueryTokenPairRequest(); + if (isSet(object.token)) obj.token = String(object.token); + return obj; + }, + toJSON(message: QueryTokenPairRequest): JsonSafe { + const obj: any = {}; + message.token !== undefined && (obj.token = message.token); + return obj; + }, + fromPartial(object: DeepPartial): QueryTokenPairRequest { + const message = createBaseQueryTokenPairRequest(); + message.token = object.token ?? ""; + return message; + }, + fromSDK(object: QueryTokenPairRequestSDKType): QueryTokenPairRequest { + return { + token: object?.token + }; + }, + fromSDKJSON(object: any): QueryTokenPairRequestSDKType { + return { + token: isSet(object.token) ? String(object.token) : "" + }; + }, + toSDK(message: QueryTokenPairRequest): QueryTokenPairRequestSDKType { + const obj: any = {}; + obj.token = message.token; + return obj; + }, + fromAmino(object: QueryTokenPairRequestAmino): QueryTokenPairRequest { + const message = createBaseQueryTokenPairRequest(); + if (object.token !== undefined && object.token !== null) { + message.token = object.token; + } + return message; + }, + toAmino(message: QueryTokenPairRequest): QueryTokenPairRequestAmino { + const obj: any = {}; + obj.token = message.token === "" ? undefined : message.token; + return obj; + }, + fromAminoMsg(object: QueryTokenPairRequestAminoMsg): QueryTokenPairRequest { + return QueryTokenPairRequest.fromAmino(object.value); + }, + fromProtoMsg(message: QueryTokenPairRequestProtoMsg): QueryTokenPairRequest { + return QueryTokenPairRequest.decode(message.value); + }, + toProto(message: QueryTokenPairRequest): Uint8Array { + return QueryTokenPairRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryTokenPairRequest): QueryTokenPairRequestProtoMsg { + return { + typeUrl: "/evmos.erc20.v1.QueryTokenPairRequest", + value: QueryTokenPairRequest.encode(message).finish() + }; + } +}; +function createBaseQueryTokenPairResponse(): QueryTokenPairResponse { + return { + tokenPair: TokenPair.fromPartial({}) + }; +} +export const QueryTokenPairResponse = { + typeUrl: "/evmos.erc20.v1.QueryTokenPairResponse", + encode(message: QueryTokenPairResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.tokenPair !== undefined) { + TokenPair.encode(message.tokenPair, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryTokenPairResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryTokenPairResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.tokenPair = TokenPair.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryTokenPairResponse { + const obj = createBaseQueryTokenPairResponse(); + if (isSet(object.tokenPair)) obj.tokenPair = TokenPair.fromJSON(object.tokenPair); + return obj; + }, + toJSON(message: QueryTokenPairResponse): JsonSafe { + const obj: any = {}; + message.tokenPair !== undefined && (obj.tokenPair = message.tokenPair ? TokenPair.toJSON(message.tokenPair) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryTokenPairResponse { + const message = createBaseQueryTokenPairResponse(); + if (object.tokenPair !== undefined && object.tokenPair !== null) { + message.tokenPair = TokenPair.fromPartial(object.tokenPair); + } + return message; + }, + fromSDK(object: QueryTokenPairResponseSDKType): QueryTokenPairResponse { + return { + tokenPair: object.token_pair ? TokenPair.fromSDK(object.token_pair) : undefined + }; + }, + fromSDKJSON(object: any): QueryTokenPairResponseSDKType { + return { + token_pair: isSet(object.token_pair) ? TokenPair.fromSDKJSON(object.token_pair) : undefined + }; + }, + toSDK(message: QueryTokenPairResponse): QueryTokenPairResponseSDKType { + const obj: any = {}; + message.tokenPair !== undefined && (obj.token_pair = message.tokenPair ? TokenPair.toSDK(message.tokenPair) : undefined); + return obj; + }, + fromAmino(object: QueryTokenPairResponseAmino): QueryTokenPairResponse { + const message = createBaseQueryTokenPairResponse(); + if (object.token_pair !== undefined && object.token_pair !== null) { + message.tokenPair = TokenPair.fromAmino(object.token_pair); + } + return message; + }, + toAmino(message: QueryTokenPairResponse): QueryTokenPairResponseAmino { + const obj: any = {}; + obj.token_pair = message.tokenPair ? TokenPair.toAmino(message.tokenPair) : undefined; + return obj; + }, + fromAminoMsg(object: QueryTokenPairResponseAminoMsg): QueryTokenPairResponse { + return QueryTokenPairResponse.fromAmino(object.value); + }, + fromProtoMsg(message: QueryTokenPairResponseProtoMsg): QueryTokenPairResponse { + return QueryTokenPairResponse.decode(message.value); + }, + toProto(message: QueryTokenPairResponse): Uint8Array { + return QueryTokenPairResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryTokenPairResponse): QueryTokenPairResponseProtoMsg { + return { + typeUrl: "/evmos.erc20.v1.QueryTokenPairResponse", + value: QueryTokenPairResponse.encode(message).finish() + }; + } +}; +function createBaseQueryParamsRequest(): QueryParamsRequest { + return {}; +} +export const QueryParamsRequest = { + typeUrl: "/evmos.erc20.v1.QueryParamsRequest", + encode(_: QueryParamsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryParamsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryParamsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): QueryParamsRequest { + const obj = createBaseQueryParamsRequest(); + return obj; + }, + toJSON(_: QueryParamsRequest): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): QueryParamsRequest { + const message = createBaseQueryParamsRequest(); + return message; + }, + fromSDK(_: QueryParamsRequestSDKType): QueryParamsRequest { + return {}; + }, + fromSDKJSON(_: any): QueryParamsRequestSDKType { + return {}; + }, + toSDK(_: QueryParamsRequest): QueryParamsRequestSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: QueryParamsRequestAmino): QueryParamsRequest { + const message = createBaseQueryParamsRequest(); + return message; + }, + toAmino(_: QueryParamsRequest): QueryParamsRequestAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: QueryParamsRequestAminoMsg): QueryParamsRequest { + return QueryParamsRequest.fromAmino(object.value); + }, + fromProtoMsg(message: QueryParamsRequestProtoMsg): QueryParamsRequest { + return QueryParamsRequest.decode(message.value); + }, + toProto(message: QueryParamsRequest): Uint8Array { + return QueryParamsRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryParamsRequest): QueryParamsRequestProtoMsg { + return { + typeUrl: "/evmos.erc20.v1.QueryParamsRequest", + value: QueryParamsRequest.encode(message).finish() + }; + } +}; +function createBaseQueryParamsResponse(): QueryParamsResponse { + return { + params: Params.fromPartial({}) + }; +} +export const QueryParamsResponse = { + typeUrl: "/evmos.erc20.v1.QueryParamsResponse", + encode(message: QueryParamsResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryParamsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryParamsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.params = Params.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryParamsResponse { + const obj = createBaseQueryParamsResponse(); + if (isSet(object.params)) obj.params = Params.fromJSON(object.params); + return obj; + }, + toJSON(message: QueryParamsResponse): JsonSafe { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryParamsResponse { + const message = createBaseQueryParamsResponse(); + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } + return message; + }, + fromSDK(object: QueryParamsResponseSDKType): QueryParamsResponse { + return { + params: object.params ? Params.fromSDK(object.params) : undefined + }; + }, + fromSDKJSON(object: any): QueryParamsResponseSDKType { + return { + params: isSet(object.params) ? Params.fromSDKJSON(object.params) : undefined + }; + }, + toSDK(message: QueryParamsResponse): QueryParamsResponseSDKType { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toSDK(message.params) : undefined); + return obj; + }, + fromAmino(object: QueryParamsResponseAmino): QueryParamsResponse { + const message = createBaseQueryParamsResponse(); + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromAmino(object.params); + } + return message; + }, + toAmino(message: QueryParamsResponse): QueryParamsResponseAmino { + const obj: any = {}; + obj.params = message.params ? Params.toAmino(message.params) : undefined; + return obj; + }, + fromAminoMsg(object: QueryParamsResponseAminoMsg): QueryParamsResponse { + return QueryParamsResponse.fromAmino(object.value); + }, + fromProtoMsg(message: QueryParamsResponseProtoMsg): QueryParamsResponse { + return QueryParamsResponse.decode(message.value); + }, + toProto(message: QueryParamsResponse): Uint8Array { + return QueryParamsResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryParamsResponse): QueryParamsResponseProtoMsg { + return { + typeUrl: "/evmos.erc20.v1.QueryParamsResponse", + value: QueryParamsResponse.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/evmos/erc20/v1/tx.amino.ts b/__fixtures__/v-next/outputicjsdeps/evmos/erc20/v1/tx.amino.ts new file mode 100644 index 0000000000..8318a25cac --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/evmos/erc20/v1/tx.amino.ts @@ -0,0 +1,85 @@ +import { Coin, CoinSDKType } from "../../../cosmos/base/v1beta1/coin.js"; +import { ReadOnlyAminoMsg as AminoMsg } from "@interchainjs/ReadOnlyAminoMsg"; +import { MsgConvertCoin, MsgConvertCoinSDKType, MsgConvertERC20, MsgConvertERC20SDKType } from "./tx.js"; +export interface MsgConvertCoinAminoType extends AminoMsg { + type: "/evmos.erc20.v1.MsgConvertCoin"; + value: { + coin: { + denom: string; + amount: string; + }; + receiver: string; + sender: string; + }; +} +export interface MsgConvertERC20AminoType extends AminoMsg { + type: "/evmos.erc20.v1.MsgConvertERC20"; + value: { + contract_address: string; + amount: string; + receiver: string; + sender: string; + }; +} +export const AminoConverter = { + "/evmos.erc20.v1.MsgConvertCoin": { + aminoType: "/evmos.erc20.v1.MsgConvertCoin", + toAmino: ({ + coin, + receiver, + sender + }: MsgConvertCoin): MsgConvertCoinAminoType["value"] => { + return { + coin: { + denom: coin.denom, + amount: coin.amount + }, + receiver, + sender + }; + }, + fromAmino: ({ + coin, + receiver, + sender + }: MsgConvertCoinAminoType["value"]): MsgConvertCoin => { + return { + coin: { + denom: coin.denom, + amount: coin.amount + }, + receiver, + sender + }; + } + }, + "/evmos.erc20.v1.MsgConvertERC20": { + aminoType: "/evmos.erc20.v1.MsgConvertERC20", + toAmino: ({ + contractAddress, + amount, + receiver, + sender + }: MsgConvertERC20): MsgConvertERC20AminoType["value"] => { + return { + contract_address: contractAddress, + amount, + receiver, + sender + }; + }, + fromAmino: ({ + contract_address, + amount, + receiver, + sender + }: MsgConvertERC20AminoType["value"]): MsgConvertERC20 => { + return { + contractAddress: contract_address, + amount, + receiver, + sender + }; + } + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/evmos/erc20/v1/tx.registry.ts b/__fixtures__/v-next/outputicjsdeps/evmos/erc20/v1/tx.registry.ts new file mode 100644 index 0000000000..a7fa2b4a32 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/evmos/erc20/v1/tx.registry.ts @@ -0,0 +1,81 @@ +import { Coin, CoinSDKType } from "../../../cosmos/base/v1beta1/coin.js"; +import { GeneratedType, Registry } from "@cosmjs/proto-signing"; +import { MsgConvertCoin, MsgConvertCoinSDKType, MsgConvertERC20, MsgConvertERC20SDKType } from "./tx.js"; +export const registry: ReadonlyArray<[string, GeneratedType]> = [["/evmos.erc20.v1.MsgConvertCoin", MsgConvertCoin], ["/evmos.erc20.v1.MsgConvertERC20", MsgConvertERC20]]; +export const load = (protoRegistry: Registry) => { + registry.forEach(([typeUrl, mod]) => { + protoRegistry.register(typeUrl, mod); + }); +}; +export const MessageComposer = { + encoded: { + convertCoin(value: MsgConvertCoin) { + return { + typeUrl: "/evmos.erc20.v1.MsgConvertCoin", + value: MsgConvertCoin.encode(value).finish() + }; + }, + convertERC20(value: MsgConvertERC20) { + return { + typeUrl: "/evmos.erc20.v1.MsgConvertERC20", + value: MsgConvertERC20.encode(value).finish() + }; + } + }, + withTypeUrl: { + convertCoin(value: MsgConvertCoin) { + return { + typeUrl: "/evmos.erc20.v1.MsgConvertCoin", + value + }; + }, + convertERC20(value: MsgConvertERC20) { + return { + typeUrl: "/evmos.erc20.v1.MsgConvertERC20", + value + }; + } + }, + toJSON: { + convertCoin(value: MsgConvertCoin) { + return { + typeUrl: "/evmos.erc20.v1.MsgConvertCoin", + value: MsgConvertCoin.toJSON(value) + }; + }, + convertERC20(value: MsgConvertERC20) { + return { + typeUrl: "/evmos.erc20.v1.MsgConvertERC20", + value: MsgConvertERC20.toJSON(value) + }; + } + }, + fromJSON: { + convertCoin(value: any) { + return { + typeUrl: "/evmos.erc20.v1.MsgConvertCoin", + value: MsgConvertCoin.fromJSON(value) + }; + }, + convertERC20(value: any) { + return { + typeUrl: "/evmos.erc20.v1.MsgConvertERC20", + value: MsgConvertERC20.fromJSON(value) + }; + } + }, + fromPartial: { + convertCoin(value: MsgConvertCoin) { + return { + typeUrl: "/evmos.erc20.v1.MsgConvertCoin", + value: MsgConvertCoin.fromPartial(value) + }; + }, + convertERC20(value: MsgConvertERC20) { + return { + typeUrl: "/evmos.erc20.v1.MsgConvertERC20", + value: MsgConvertERC20.fromPartial(value) + }; + } + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/evmos/erc20/v1/tx.rpc.func.ts b/__fixtures__/v-next/outputicjsdeps/evmos/erc20/v1/tx.rpc.func.ts new file mode 100644 index 0000000000..a9340b1e27 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/evmos/erc20/v1/tx.rpc.func.ts @@ -0,0 +1,22 @@ +import { buildTx, SigningClientResolver } from "../../../helper-func-types"; +import { buildUseMutation } from "../../../react-query"; +import { toEncoders, toConverters } from "@interchainjs/cosmos/utils"; +import { MsgConvertCoin, MsgConvertERC20 } from "./tx"; +export const createConvertCoin = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgConvertCoin.typeUrl, + encoders: toEncoders(MsgConvertCoin), + converters: toConverters(MsgConvertCoin) +}); +export const useConvertCoin = buildUseMutation({ + builderMutationFn: createConvertCoin +}); +export const createConvertERC20 = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgConvertERC20.typeUrl, + encoders: toEncoders(MsgConvertERC20), + converters: toConverters(MsgConvertERC20) +}); +export const useConvertERC20 = buildUseMutation({ + builderMutationFn: createConvertERC20 +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/evmos/erc20/v1/tx.rpc.msg.ts b/__fixtures__/v-next/outputicjsdeps/evmos/erc20/v1/tx.rpc.msg.ts new file mode 100644 index 0000000000..34d5454eff --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/evmos/erc20/v1/tx.rpc.msg.ts @@ -0,0 +1,38 @@ +import { Coin, CoinSDKType } from "../../../cosmos/base/v1beta1/coin.js"; +import { Rpc } from "../../../helpers.js"; +import { BinaryReader } from "../../../binary.js"; +import { MsgConvertCoin, MsgConvertCoinSDKType, MsgConvertCoinResponse, MsgConvertCoinResponseSDKType, MsgConvertERC20, MsgConvertERC20SDKType, MsgConvertERC20Response, MsgConvertERC20ResponseSDKType } from "./tx.js"; +/** Msg defines the erc20 Msg service. */ +export interface Msg { + /** + * ConvertCoin mints a ERC20 representation of the native Cosmos coin denom + * that is registered on the token mapping. + */ + convertCoin(request: MsgConvertCoin): Promise; + /** + * ConvertERC20 mints a native Cosmos coin representation of the ERC20 token + * contract that is registered on the token mapping. + */ + convertERC20(request: MsgConvertERC20): Promise; +} +export class MsgClientImpl implements Msg { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + this.convertCoin = this.convertCoin.bind(this); + this.convertERC20 = this.convertERC20.bind(this); + } + convertCoin(request: MsgConvertCoin): Promise { + const data = MsgConvertCoin.encode(request).finish(); + const promise = this.rpc.request("evmos.erc20.v1.Msg", "ConvertCoin", data); + return promise.then(data => MsgConvertCoinResponse.decode(new BinaryReader(data))); + } + convertERC20(request: MsgConvertERC20): Promise { + const data = MsgConvertERC20.encode(request).finish(); + const promise = this.rpc.request("evmos.erc20.v1.Msg", "ConvertERC20", data); + return promise.then(data => MsgConvertERC20Response.decode(new BinaryReader(data))); + } +} +export const createClientImpl = (rpc: Rpc) => { + return new MsgClientImpl(rpc); +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/evmos/erc20/v1/tx.ts b/__fixtures__/v-next/outputicjsdeps/evmos/erc20/v1/tx.ts new file mode 100644 index 0000000000..1eceacd9a2 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/evmos/erc20/v1/tx.ts @@ -0,0 +1,470 @@ +import { Coin, CoinSDKType } from "../../../cosmos/base/v1beta1/coin.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "evmos.erc20.v1"; +/** MsgConvertCoin defines a Msg to convert a native Cosmos coin to a ERC20 token */ +export interface MsgConvertCoin { + /** + * Cosmos coin which denomination is registered in a token pair. The coin + * amount defines the amount of coins to convert. + */ + coin: Coin; + /** recipient hex address to receive ERC20 token */ + receiver: string; + /** cosmos bech32 address from the owner of the given Cosmos coins */ + sender: string; +} +export interface MsgConvertCoinProtoMsg { + typeUrl: "/evmos.erc20.v1.MsgConvertCoin"; + value: Uint8Array; +} +/** MsgConvertCoin defines a Msg to convert a native Cosmos coin to a ERC20 token */ +export interface MsgConvertCoinSDKType { + coin: CoinSDKType; + receiver: string; + sender: string; +} +/** MsgConvertCoinResponse returns no fields */ +export interface MsgConvertCoinResponse {} +export interface MsgConvertCoinResponseProtoMsg { + typeUrl: "/evmos.erc20.v1.MsgConvertCoinResponse"; + value: Uint8Array; +} +/** MsgConvertCoinResponse returns no fields */ +export interface MsgConvertCoinResponseSDKType {} +/** + * MsgConvertERC20 defines a Msg to convert a ERC20 token to a native Cosmos + * coin. + */ +export interface MsgConvertERC20 { + /** ERC20 token contract address registered in a token pair */ + contractAddress: string; + /** amount of ERC20 tokens to convert */ + amount: string; + /** bech32 address to receive native Cosmos coins */ + receiver: string; + /** sender hex address from the owner of the given ERC20 tokens */ + sender: string; +} +export interface MsgConvertERC20ProtoMsg { + typeUrl: "/evmos.erc20.v1.MsgConvertERC20"; + value: Uint8Array; +} +/** + * MsgConvertERC20 defines a Msg to convert a ERC20 token to a native Cosmos + * coin. + */ +export interface MsgConvertERC20SDKType { + contract_address: string; + amount: string; + receiver: string; + sender: string; +} +/** MsgConvertERC20Response returns no fields */ +export interface MsgConvertERC20Response {} +export interface MsgConvertERC20ResponseProtoMsg { + typeUrl: "/evmos.erc20.v1.MsgConvertERC20Response"; + value: Uint8Array; +} +/** MsgConvertERC20Response returns no fields */ +export interface MsgConvertERC20ResponseSDKType {} +function createBaseMsgConvertCoin(): MsgConvertCoin { + return { + coin: Coin.fromPartial({}), + receiver: "", + sender: "" + }; +} +export const MsgConvertCoin = { + typeUrl: "/evmos.erc20.v1.MsgConvertCoin", + encode(message: MsgConvertCoin, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.coin !== undefined) { + Coin.encode(message.coin, writer.uint32(10).fork()).ldelim(); + } + if (message.receiver !== undefined) { + writer.uint32(18).string(message.receiver); + } + if (message.sender !== undefined) { + writer.uint32(26).string(message.sender); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgConvertCoin { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgConvertCoin(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.coin = Coin.decode(reader, reader.uint32()); + break; + case 2: + message.receiver = reader.string(); + break; + case 3: + message.sender = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgConvertCoin { + const obj = createBaseMsgConvertCoin(); + if (isSet(object.coin)) obj.coin = Coin.fromJSON(object.coin); + if (isSet(object.receiver)) obj.receiver = String(object.receiver); + if (isSet(object.sender)) obj.sender = String(object.sender); + return obj; + }, + toJSON(message: MsgConvertCoin): JsonSafe { + const obj: any = {}; + message.coin !== undefined && (obj.coin = message.coin ? Coin.toJSON(message.coin) : undefined); + message.receiver !== undefined && (obj.receiver = message.receiver); + message.sender !== undefined && (obj.sender = message.sender); + return obj; + }, + fromPartial(object: DeepPartial): MsgConvertCoin { + const message = createBaseMsgConvertCoin(); + if (object.coin !== undefined && object.coin !== null) { + message.coin = Coin.fromPartial(object.coin); + } + message.receiver = object.receiver ?? ""; + message.sender = object.sender ?? ""; + return message; + }, + fromSDK(object: MsgConvertCoinSDKType): MsgConvertCoin { + return { + coin: object.coin ? Coin.fromSDK(object.coin) : undefined, + receiver: object?.receiver, + sender: object?.sender + }; + }, + fromSDKJSON(object: any): MsgConvertCoinSDKType { + return { + coin: isSet(object.coin) ? Coin.fromSDKJSON(object.coin) : undefined, + receiver: isSet(object.receiver) ? String(object.receiver) : "", + sender: isSet(object.sender) ? String(object.sender) : "" + }; + }, + toSDK(message: MsgConvertCoin): MsgConvertCoinSDKType { + const obj: any = {}; + message.coin !== undefined && (obj.coin = message.coin ? Coin.toSDK(message.coin) : undefined); + obj.receiver = message.receiver; + obj.sender = message.sender; + return obj; + }, + fromAmino(object: MsgConvertCoinAmino): MsgConvertCoin { + const message = createBaseMsgConvertCoin(); + if (object.coin !== undefined && object.coin !== null) { + message.coin = Coin.fromAmino(object.coin); + } + if (object.receiver !== undefined && object.receiver !== null) { + message.receiver = object.receiver; + } + if (object.sender !== undefined && object.sender !== null) { + message.sender = object.sender; + } + return message; + }, + toAmino(message: MsgConvertCoin): MsgConvertCoinAmino { + const obj: any = {}; + obj.coin = message.coin ? Coin.toAmino(message.coin) : undefined; + obj.receiver = message.receiver === "" ? undefined : message.receiver; + obj.sender = message.sender === "" ? undefined : message.sender; + return obj; + }, + fromAminoMsg(object: MsgConvertCoinAminoMsg): MsgConvertCoin { + return MsgConvertCoin.fromAmino(object.value); + }, + fromProtoMsg(message: MsgConvertCoinProtoMsg): MsgConvertCoin { + return MsgConvertCoin.decode(message.value); + }, + toProto(message: MsgConvertCoin): Uint8Array { + return MsgConvertCoin.encode(message).finish(); + }, + toProtoMsg(message: MsgConvertCoin): MsgConvertCoinProtoMsg { + return { + typeUrl: "/evmos.erc20.v1.MsgConvertCoin", + value: MsgConvertCoin.encode(message).finish() + }; + } +}; +function createBaseMsgConvertCoinResponse(): MsgConvertCoinResponse { + return {}; +} +export const MsgConvertCoinResponse = { + typeUrl: "/evmos.erc20.v1.MsgConvertCoinResponse", + encode(_: MsgConvertCoinResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgConvertCoinResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgConvertCoinResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgConvertCoinResponse { + const obj = createBaseMsgConvertCoinResponse(); + return obj; + }, + toJSON(_: MsgConvertCoinResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): MsgConvertCoinResponse { + const message = createBaseMsgConvertCoinResponse(); + return message; + }, + fromSDK(_: MsgConvertCoinResponseSDKType): MsgConvertCoinResponse { + return {}; + }, + fromSDKJSON(_: any): MsgConvertCoinResponseSDKType { + return {}; + }, + toSDK(_: MsgConvertCoinResponse): MsgConvertCoinResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgConvertCoinResponseAmino): MsgConvertCoinResponse { + const message = createBaseMsgConvertCoinResponse(); + return message; + }, + toAmino(_: MsgConvertCoinResponse): MsgConvertCoinResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgConvertCoinResponseAminoMsg): MsgConvertCoinResponse { + return MsgConvertCoinResponse.fromAmino(object.value); + }, + fromProtoMsg(message: MsgConvertCoinResponseProtoMsg): MsgConvertCoinResponse { + return MsgConvertCoinResponse.decode(message.value); + }, + toProto(message: MsgConvertCoinResponse): Uint8Array { + return MsgConvertCoinResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgConvertCoinResponse): MsgConvertCoinResponseProtoMsg { + return { + typeUrl: "/evmos.erc20.v1.MsgConvertCoinResponse", + value: MsgConvertCoinResponse.encode(message).finish() + }; + } +}; +function createBaseMsgConvertERC20(): MsgConvertERC20 { + return { + contractAddress: "", + amount: "", + receiver: "", + sender: "" + }; +} +export const MsgConvertERC20 = { + typeUrl: "/evmos.erc20.v1.MsgConvertERC20", + encode(message: MsgConvertERC20, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.contractAddress !== undefined) { + writer.uint32(10).string(message.contractAddress); + } + if (message.amount !== undefined) { + writer.uint32(18).string(message.amount); + } + if (message.receiver !== undefined) { + writer.uint32(26).string(message.receiver); + } + if (message.sender !== undefined) { + writer.uint32(34).string(message.sender); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgConvertERC20 { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgConvertERC20(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.contractAddress = reader.string(); + break; + case 2: + message.amount = reader.string(); + break; + case 3: + message.receiver = reader.string(); + break; + case 4: + message.sender = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgConvertERC20 { + const obj = createBaseMsgConvertERC20(); + if (isSet(object.contractAddress)) obj.contractAddress = String(object.contractAddress); + if (isSet(object.amount)) obj.amount = String(object.amount); + if (isSet(object.receiver)) obj.receiver = String(object.receiver); + if (isSet(object.sender)) obj.sender = String(object.sender); + return obj; + }, + toJSON(message: MsgConvertERC20): JsonSafe { + const obj: any = {}; + message.contractAddress !== undefined && (obj.contractAddress = message.contractAddress); + message.amount !== undefined && (obj.amount = message.amount); + message.receiver !== undefined && (obj.receiver = message.receiver); + message.sender !== undefined && (obj.sender = message.sender); + return obj; + }, + fromPartial(object: DeepPartial): MsgConvertERC20 { + const message = createBaseMsgConvertERC20(); + message.contractAddress = object.contractAddress ?? ""; + message.amount = object.amount ?? ""; + message.receiver = object.receiver ?? ""; + message.sender = object.sender ?? ""; + return message; + }, + fromSDK(object: MsgConvertERC20SDKType): MsgConvertERC20 { + return { + contractAddress: object?.contract_address, + amount: object?.amount, + receiver: object?.receiver, + sender: object?.sender + }; + }, + fromSDKJSON(object: any): MsgConvertERC20SDKType { + return { + contract_address: isSet(object.contract_address) ? String(object.contract_address) : "", + amount: isSet(object.amount) ? String(object.amount) : "", + receiver: isSet(object.receiver) ? String(object.receiver) : "", + sender: isSet(object.sender) ? String(object.sender) : "" + }; + }, + toSDK(message: MsgConvertERC20): MsgConvertERC20SDKType { + const obj: any = {}; + obj.contract_address = message.contractAddress; + obj.amount = message.amount; + obj.receiver = message.receiver; + obj.sender = message.sender; + return obj; + }, + fromAmino(object: MsgConvertERC20Amino): MsgConvertERC20 { + const message = createBaseMsgConvertERC20(); + if (object.contract_address !== undefined && object.contract_address !== null) { + message.contractAddress = object.contract_address; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = object.amount; + } + if (object.receiver !== undefined && object.receiver !== null) { + message.receiver = object.receiver; + } + if (object.sender !== undefined && object.sender !== null) { + message.sender = object.sender; + } + return message; + }, + toAmino(message: MsgConvertERC20): MsgConvertERC20Amino { + const obj: any = {}; + obj.contract_address = message.contractAddress === "" ? undefined : message.contractAddress; + obj.amount = message.amount === "" ? undefined : message.amount; + obj.receiver = message.receiver === "" ? undefined : message.receiver; + obj.sender = message.sender === "" ? undefined : message.sender; + return obj; + }, + fromAminoMsg(object: MsgConvertERC20AminoMsg): MsgConvertERC20 { + return MsgConvertERC20.fromAmino(object.value); + }, + fromProtoMsg(message: MsgConvertERC20ProtoMsg): MsgConvertERC20 { + return MsgConvertERC20.decode(message.value); + }, + toProto(message: MsgConvertERC20): Uint8Array { + return MsgConvertERC20.encode(message).finish(); + }, + toProtoMsg(message: MsgConvertERC20): MsgConvertERC20ProtoMsg { + return { + typeUrl: "/evmos.erc20.v1.MsgConvertERC20", + value: MsgConvertERC20.encode(message).finish() + }; + } +}; +function createBaseMsgConvertERC20Response(): MsgConvertERC20Response { + return {}; +} +export const MsgConvertERC20Response = { + typeUrl: "/evmos.erc20.v1.MsgConvertERC20Response", + encode(_: MsgConvertERC20Response, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgConvertERC20Response { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgConvertERC20Response(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgConvertERC20Response { + const obj = createBaseMsgConvertERC20Response(); + return obj; + }, + toJSON(_: MsgConvertERC20Response): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): MsgConvertERC20Response { + const message = createBaseMsgConvertERC20Response(); + return message; + }, + fromSDK(_: MsgConvertERC20ResponseSDKType): MsgConvertERC20Response { + return {}; + }, + fromSDKJSON(_: any): MsgConvertERC20ResponseSDKType { + return {}; + }, + toSDK(_: MsgConvertERC20Response): MsgConvertERC20ResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgConvertERC20ResponseAmino): MsgConvertERC20Response { + const message = createBaseMsgConvertERC20Response(); + return message; + }, + toAmino(_: MsgConvertERC20Response): MsgConvertERC20ResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgConvertERC20ResponseAminoMsg): MsgConvertERC20Response { + return MsgConvertERC20Response.fromAmino(object.value); + }, + fromProtoMsg(message: MsgConvertERC20ResponseProtoMsg): MsgConvertERC20Response { + return MsgConvertERC20Response.decode(message.value); + }, + toProto(message: MsgConvertERC20Response): Uint8Array { + return MsgConvertERC20Response.encode(message).finish(); + }, + toProtoMsg(message: MsgConvertERC20Response): MsgConvertERC20ResponseProtoMsg { + return { + typeUrl: "/evmos.erc20.v1.MsgConvertERC20Response", + value: MsgConvertERC20Response.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/evmos/evmos-rpc-client.query.ts b/__fixtures__/v-next/outputicjsdeps/evmos/evmos-rpc-client.query.ts new file mode 100644 index 0000000000..84977f0638 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/evmos/evmos-rpc-client.query.ts @@ -0,0 +1,26 @@ +import { Rpc } from "../helpers.js"; +import { connectComet, HttpEndpoint } from "@cosmjs/tendermint-rpc"; +import { QueryClient } from "@cosmjs/stargate"; +export const createEvmosRPCQueryClient = async ({ + rpcEndpoint +}: { + rpcEndpoint: string | HttpEndpoint; +}) => { + const tmClient = await connectComet(rpcEndpoint); + const client = new QueryClient(tmClient); + return { + cosmos: { + bank: { + v1beta1: (await import("../cosmos/bank/v1beta1/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + gov: { + v1beta1: (await import("../cosmos/gov/v1beta1/query.rpc.Query.js")).createRpcQueryExtension(client) + } + }, + evmos: { + erc20: { + v1: (await import("./erc20/v1/query.rpc.Query.js")).createRpcQueryExtension(client) + } + } + }; +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/evmos/evmos-rpc-client.tx.ts b/__fixtures__/v-next/outputicjsdeps/evmos/evmos-rpc-client.tx.ts new file mode 100644 index 0000000000..4ca08e9373 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/evmos/evmos-rpc-client.tx.ts @@ -0,0 +1,20 @@ +import { Rpc } from "../helpers.js"; +export const createEvmosRPCTxClient = async ({ + rpc +}: { + rpc: Rpc; +}) => ({ + cosmos: { + bank: { + v1beta1: new (await import("../cosmos/bank/v1beta1/tx.rpc.msg.js")).MsgClientImpl(rpc) + }, + gov: { + v1beta1: new (await import("../cosmos/gov/v1beta1/tx.rpc.msg.js")).MsgClientImpl(rpc) + } + }, + evmos: { + erc20: { + v1: new (await import("./erc20/v1/tx.rpc.msg.js")).MsgClientImpl(rpc) + } + } +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/evmos/fees/v1/fees.ts b/__fixtures__/v-next/outputicjsdeps/evmos/fees/v1/fees.ts new file mode 100644 index 0000000000..f6dbec7d70 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/evmos/fees/v1/fees.ts @@ -0,0 +1,154 @@ +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "evmos.fees.v1"; +/** + * DevFeeInfo defines an instance that organizes fee distribution conditions + * for the owner of a given smart contract + */ +export interface DevFeeInfo { + /** hex address of registered contract */ + contractAddress: string; + /** bech32 address of contract deployer */ + deployerAddress: string; + /** + * bech32 address of account receiving the transaction fees + * it defaults to deployer_address + */ + withdrawAddress: string; +} +export interface DevFeeInfoProtoMsg { + typeUrl: "/evmos.fees.v1.DevFeeInfo"; + value: Uint8Array; +} +/** + * DevFeeInfo defines an instance that organizes fee distribution conditions + * for the owner of a given smart contract + */ +export interface DevFeeInfoSDKType { + contract_address: string; + deployer_address: string; + withdraw_address: string; +} +function createBaseDevFeeInfo(): DevFeeInfo { + return { + contractAddress: "", + deployerAddress: "", + withdrawAddress: "" + }; +} +export const DevFeeInfo = { + typeUrl: "/evmos.fees.v1.DevFeeInfo", + encode(message: DevFeeInfo, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.contractAddress !== undefined) { + writer.uint32(10).string(message.contractAddress); + } + if (message.deployerAddress !== undefined) { + writer.uint32(18).string(message.deployerAddress); + } + if (message.withdrawAddress !== undefined) { + writer.uint32(26).string(message.withdrawAddress); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): DevFeeInfo { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDevFeeInfo(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.contractAddress = reader.string(); + break; + case 2: + message.deployerAddress = reader.string(); + break; + case 3: + message.withdrawAddress = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): DevFeeInfo { + const obj = createBaseDevFeeInfo(); + if (isSet(object.contractAddress)) obj.contractAddress = String(object.contractAddress); + if (isSet(object.deployerAddress)) obj.deployerAddress = String(object.deployerAddress); + if (isSet(object.withdrawAddress)) obj.withdrawAddress = String(object.withdrawAddress); + return obj; + }, + toJSON(message: DevFeeInfo): JsonSafe { + const obj: any = {}; + message.contractAddress !== undefined && (obj.contractAddress = message.contractAddress); + message.deployerAddress !== undefined && (obj.deployerAddress = message.deployerAddress); + message.withdrawAddress !== undefined && (obj.withdrawAddress = message.withdrawAddress); + return obj; + }, + fromPartial(object: DeepPartial): DevFeeInfo { + const message = createBaseDevFeeInfo(); + message.contractAddress = object.contractAddress ?? ""; + message.deployerAddress = object.deployerAddress ?? ""; + message.withdrawAddress = object.withdrawAddress ?? ""; + return message; + }, + fromSDK(object: DevFeeInfoSDKType): DevFeeInfo { + return { + contractAddress: object?.contract_address, + deployerAddress: object?.deployer_address, + withdrawAddress: object?.withdraw_address + }; + }, + fromSDKJSON(object: any): DevFeeInfoSDKType { + return { + contract_address: isSet(object.contract_address) ? String(object.contract_address) : "", + deployer_address: isSet(object.deployer_address) ? String(object.deployer_address) : "", + withdraw_address: isSet(object.withdraw_address) ? String(object.withdraw_address) : "" + }; + }, + toSDK(message: DevFeeInfo): DevFeeInfoSDKType { + const obj: any = {}; + obj.contract_address = message.contractAddress; + obj.deployer_address = message.deployerAddress; + obj.withdraw_address = message.withdrawAddress; + return obj; + }, + fromAmino(object: DevFeeInfoAmino): DevFeeInfo { + const message = createBaseDevFeeInfo(); + if (object.contract_address !== undefined && object.contract_address !== null) { + message.contractAddress = object.contract_address; + } + if (object.deployer_address !== undefined && object.deployer_address !== null) { + message.deployerAddress = object.deployer_address; + } + if (object.withdraw_address !== undefined && object.withdraw_address !== null) { + message.withdrawAddress = object.withdraw_address; + } + return message; + }, + toAmino(message: DevFeeInfo): DevFeeInfoAmino { + const obj: any = {}; + obj.contract_address = message.contractAddress === "" ? undefined : message.contractAddress; + obj.deployer_address = message.deployerAddress === "" ? undefined : message.deployerAddress; + obj.withdraw_address = message.withdrawAddress === "" ? undefined : message.withdrawAddress; + return obj; + }, + fromAminoMsg(object: DevFeeInfoAminoMsg): DevFeeInfo { + return DevFeeInfo.fromAmino(object.value); + }, + fromProtoMsg(message: DevFeeInfoProtoMsg): DevFeeInfo { + return DevFeeInfo.decode(message.value); + }, + toProto(message: DevFeeInfo): Uint8Array { + return DevFeeInfo.encode(message).finish(); + }, + toProtoMsg(message: DevFeeInfo): DevFeeInfoProtoMsg { + return { + typeUrl: "/evmos.fees.v1.DevFeeInfo", + value: DevFeeInfo.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/evmos/fees/v1/genesis.ts b/__fixtures__/v-next/outputicjsdeps/evmos/fees/v1/genesis.ts new file mode 100644 index 0000000000..28a14bc369 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/evmos/fees/v1/genesis.ts @@ -0,0 +1,331 @@ +import { DevFeeInfo, DevFeeInfoSDKType } from "./fees.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +import { Decimal } from "@cosmjs/math"; +export const protobufPackage = "evmos.fees.v1"; +/** GenesisState defines the module's genesis state. */ +export interface GenesisState { + /** module parameters */ + params: Params; + /** active registered contracts */ + devFeeInfos: DevFeeInfo[]; +} +export interface GenesisStateProtoMsg { + typeUrl: "/evmos.fees.v1.GenesisState"; + value: Uint8Array; +} +/** GenesisState defines the module's genesis state. */ +export interface GenesisStateSDKType { + params: ParamsSDKType; + dev_fee_infos: DevFeeInfoSDKType[]; +} +/** Params defines the fees module params */ +export interface Params { + /** parameter to enable fees */ + enableFees: boolean; + /** + * developer_shares defines the proportion of the transaction fees to be + * distributed to the registered contract owner + */ + developerShares: string; + /** + * developer_shares defines the proportion of the transaction fees to be + * distributed to validators + */ + validatorShares: string; + /** + * addr_derivation_cost_create defines the cost of address derivation for + * verifying the contract deployer at fee registration + */ + addrDerivationCostCreate: bigint; + /** min_gas_price defines the minimum gas price value for cosmos and eth transactions */ + minGasPrice: string; +} +export interface ParamsProtoMsg { + typeUrl: "/evmos.fees.v1.Params"; + value: Uint8Array; +} +/** Params defines the fees module params */ +export interface ParamsSDKType { + enable_fees: boolean; + developer_shares: string; + validator_shares: string; + addr_derivation_cost_create: bigint; + min_gas_price: string; +} +function createBaseGenesisState(): GenesisState { + return { + params: Params.fromPartial({}), + devFeeInfos: [] + }; +} +export const GenesisState = { + typeUrl: "/evmos.fees.v1.GenesisState", + encode(message: GenesisState, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.devFeeInfos) { + DevFeeInfo.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GenesisState { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGenesisState(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.params = Params.decode(reader, reader.uint32()); + break; + case 2: + message.devFeeInfos.push(DevFeeInfo.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GenesisState { + const obj = createBaseGenesisState(); + if (isSet(object.params)) obj.params = Params.fromJSON(object.params); + if (Array.isArray(object?.devFeeInfos)) obj.devFeeInfos = object.devFeeInfos.map((e: any) => DevFeeInfo.fromJSON(e)); + return obj; + }, + toJSON(message: GenesisState): JsonSafe { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); + if (message.devFeeInfos) { + obj.devFeeInfos = message.devFeeInfos.map(e => e ? DevFeeInfo.toJSON(e) : undefined); + } else { + obj.devFeeInfos = []; + } + return obj; + }, + fromPartial(object: DeepPartial): GenesisState { + const message = createBaseGenesisState(); + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } + message.devFeeInfos = object.devFeeInfos?.map(e => DevFeeInfo.fromPartial(e)) || []; + return message; + }, + fromSDK(object: GenesisStateSDKType): GenesisState { + return { + params: object.params ? Params.fromSDK(object.params) : undefined, + devFeeInfos: Array.isArray(object?.dev_fee_infos) ? object.dev_fee_infos.map((e: any) => DevFeeInfo.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): GenesisStateSDKType { + return { + params: isSet(object.params) ? Params.fromSDKJSON(object.params) : undefined, + dev_fee_infos: Array.isArray(object?.dev_fee_infos) ? object.dev_fee_infos.map((e: any) => DevFeeInfo.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: GenesisState): GenesisStateSDKType { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toSDK(message.params) : undefined); + if (message.devFeeInfos) { + obj.dev_fee_infos = message.devFeeInfos.map(e => e ? DevFeeInfo.toSDK(e) : undefined); + } else { + obj.dev_fee_infos = []; + } + return obj; + }, + fromAmino(object: GenesisStateAmino): GenesisState { + const message = createBaseGenesisState(); + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromAmino(object.params); + } + message.devFeeInfos = object.dev_fee_infos?.map(e => DevFeeInfo.fromAmino(e)) || []; + return message; + }, + toAmino(message: GenesisState): GenesisStateAmino { + const obj: any = {}; + obj.params = message.params ? Params.toAmino(message.params) : undefined; + if (message.devFeeInfos) { + obj.dev_fee_infos = message.devFeeInfos.map(e => e ? DevFeeInfo.toAmino(e) : undefined); + } else { + obj.dev_fee_infos = message.devFeeInfos; + } + return obj; + }, + fromAminoMsg(object: GenesisStateAminoMsg): GenesisState { + return GenesisState.fromAmino(object.value); + }, + fromProtoMsg(message: GenesisStateProtoMsg): GenesisState { + return GenesisState.decode(message.value); + }, + toProto(message: GenesisState): Uint8Array { + return GenesisState.encode(message).finish(); + }, + toProtoMsg(message: GenesisState): GenesisStateProtoMsg { + return { + typeUrl: "/evmos.fees.v1.GenesisState", + value: GenesisState.encode(message).finish() + }; + } +}; +function createBaseParams(): Params { + return { + enableFees: false, + developerShares: "", + validatorShares: "", + addrDerivationCostCreate: BigInt(0), + minGasPrice: "" + }; +} +export const Params = { + typeUrl: "/evmos.fees.v1.Params", + encode(message: Params, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.enableFees !== undefined) { + writer.uint32(8).bool(message.enableFees); + } + if (message.developerShares !== undefined) { + writer.uint32(18).string(Decimal.fromUserInput(message.developerShares, 18).atomics); + } + if (message.validatorShares !== undefined) { + writer.uint32(26).string(Decimal.fromUserInput(message.validatorShares, 18).atomics); + } + if (message.addrDerivationCostCreate !== undefined) { + writer.uint32(32).uint64(message.addrDerivationCostCreate); + } + if (message.minGasPrice !== undefined) { + writer.uint32(42).string(Decimal.fromUserInput(message.minGasPrice, 18).atomics); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Params { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseParams(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.enableFees = reader.bool(); + break; + case 2: + message.developerShares = Decimal.fromAtomics(reader.string(), 18).toString(); + break; + case 3: + message.validatorShares = Decimal.fromAtomics(reader.string(), 18).toString(); + break; + case 4: + message.addrDerivationCostCreate = reader.uint64(); + break; + case 5: + message.minGasPrice = Decimal.fromAtomics(reader.string(), 18).toString(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Params { + const obj = createBaseParams(); + if (isSet(object.enableFees)) obj.enableFees = Boolean(object.enableFees); + if (isSet(object.developerShares)) obj.developerShares = String(object.developerShares); + if (isSet(object.validatorShares)) obj.validatorShares = String(object.validatorShares); + if (isSet(object.addrDerivationCostCreate)) obj.addrDerivationCostCreate = BigInt(object.addrDerivationCostCreate.toString()); + if (isSet(object.minGasPrice)) obj.minGasPrice = String(object.minGasPrice); + return obj; + }, + toJSON(message: Params): JsonSafe { + const obj: any = {}; + message.enableFees !== undefined && (obj.enableFees = message.enableFees); + message.developerShares !== undefined && (obj.developerShares = message.developerShares); + message.validatorShares !== undefined && (obj.validatorShares = message.validatorShares); + message.addrDerivationCostCreate !== undefined && (obj.addrDerivationCostCreate = (message.addrDerivationCostCreate || BigInt(0)).toString()); + message.minGasPrice !== undefined && (obj.minGasPrice = message.minGasPrice); + return obj; + }, + fromPartial(object: DeepPartial): Params { + const message = createBaseParams(); + message.enableFees = object.enableFees ?? false; + message.developerShares = object.developerShares ?? ""; + message.validatorShares = object.validatorShares ?? ""; + if (object.addrDerivationCostCreate !== undefined && object.addrDerivationCostCreate !== null) { + message.addrDerivationCostCreate = BigInt(object.addrDerivationCostCreate.toString()); + } + message.minGasPrice = object.minGasPrice ?? ""; + return message; + }, + fromSDK(object: ParamsSDKType): Params { + return { + enableFees: object?.enable_fees, + developerShares: object?.developer_shares, + validatorShares: object?.validator_shares, + addrDerivationCostCreate: object?.addr_derivation_cost_create, + minGasPrice: object?.min_gas_price + }; + }, + fromSDKJSON(object: any): ParamsSDKType { + return { + enable_fees: isSet(object.enable_fees) ? Boolean(object.enable_fees) : false, + developer_shares: isSet(object.developer_shares) ? String(object.developer_shares) : "", + validator_shares: isSet(object.validator_shares) ? String(object.validator_shares) : "", + addr_derivation_cost_create: isSet(object.addr_derivation_cost_create) ? BigInt(object.addr_derivation_cost_create.toString()) : BigInt(0), + min_gas_price: isSet(object.min_gas_price) ? String(object.min_gas_price) : "" + }; + }, + toSDK(message: Params): ParamsSDKType { + const obj: any = {}; + obj.enable_fees = message.enableFees; + obj.developer_shares = message.developerShares; + obj.validator_shares = message.validatorShares; + obj.addr_derivation_cost_create = message.addrDerivationCostCreate; + obj.min_gas_price = message.minGasPrice; + return obj; + }, + fromAmino(object: ParamsAmino): Params { + const message = createBaseParams(); + if (object.enable_fees !== undefined && object.enable_fees !== null) { + message.enableFees = object.enable_fees; + } + if (object.developer_shares !== undefined && object.developer_shares !== null) { + message.developerShares = object.developer_shares; + } + if (object.validator_shares !== undefined && object.validator_shares !== null) { + message.validatorShares = object.validator_shares; + } + if (object.addr_derivation_cost_create !== undefined && object.addr_derivation_cost_create !== null) { + message.addrDerivationCostCreate = BigInt(object.addr_derivation_cost_create); + } + if (object.min_gas_price !== undefined && object.min_gas_price !== null) { + message.minGasPrice = object.min_gas_price; + } + return message; + }, + toAmino(message: Params): ParamsAmino { + const obj: any = {}; + obj.enable_fees = message.enableFees === false ? undefined : message.enableFees; + obj.developer_shares = message.developerShares === "" ? undefined : message.developerShares; + obj.validator_shares = message.validatorShares === "" ? undefined : message.validatorShares; + obj.addr_derivation_cost_create = message.addrDerivationCostCreate !== BigInt(0) ? message.addrDerivationCostCreate?.toString() : undefined; + obj.min_gas_price = message.minGasPrice === "" ? undefined : message.minGasPrice; + return obj; + }, + fromAminoMsg(object: ParamsAminoMsg): Params { + return Params.fromAmino(object.value); + }, + fromProtoMsg(message: ParamsProtoMsg): Params { + return Params.decode(message.value); + }, + toProto(message: Params): Uint8Array { + return Params.encode(message).finish(); + }, + toProtoMsg(message: Params): ParamsProtoMsg { + return { + typeUrl: "/evmos.fees.v1.Params", + value: Params.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/evmos/fees/v1/query.lcd.ts b/__fixtures__/v-next/outputicjsdeps/evmos/fees/v1/query.lcd.ts new file mode 100644 index 0000000000..75046f4615 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/evmos/fees/v1/query.lcd.ts @@ -0,0 +1,55 @@ +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../../cosmos/base/query/v1beta1/pagination.js"; +import { DevFeeInfo, DevFeeInfoSDKType } from "./fees.js"; +import { Params, ParamsSDKType } from "./genesis.js"; +import { setPaginationParams } from "../../../helpers.js"; +import { LCDClient } from "@cosmology/lcd"; +import { QueryDevFeeInfosRequest, QueryDevFeeInfosRequestSDKType, QueryDevFeeInfosResponse, QueryDevFeeInfosResponseSDKType, QueryDevFeeInfoRequest, QueryDevFeeInfoRequestSDKType, QueryDevFeeInfoResponse, QueryDevFeeInfoResponseSDKType, QueryParamsRequest, QueryParamsRequestSDKType, QueryParamsResponse, QueryParamsResponseSDKType, QueryDevFeeInfosPerDeployerRequest, QueryDevFeeInfosPerDeployerRequestSDKType, QueryDevFeeInfosPerDeployerResponse, QueryDevFeeInfosPerDeployerResponseSDKType } from "./query.js"; +export class LCDQueryClient { + req: LCDClient; + constructor({ + requestClient + }: { + requestClient: LCDClient; + }) { + this.req = requestClient; + this.devFeeInfos = this.devFeeInfos.bind(this); + this.devFeeInfo = this.devFeeInfo.bind(this); + this.params = this.params.bind(this); + this.devFeeInfosPerDeployer = this.devFeeInfosPerDeployer.bind(this); + } + /* DevFeeInfos retrieves all registered contracts for fee distribution */ + async devFeeInfos(params: QueryDevFeeInfosRequest = { + pagination: PageRequest.fromPartial({}) + }): Promise { + const options: any = { + params: {} + }; + if (typeof params?.pagination !== "undefined") { + setPaginationParams(options, params.pagination); + } + const endpoint = `evmos/fees/v1/fees`; + return QueryDevFeeInfosResponse.fromSDKJSON(await this.req.get(endpoint, options)); + } + /* DevFeeInfo retrieves a registered contract for fee distribution */ + async devFeeInfo(params: QueryDevFeeInfoRequest): Promise { + const endpoint = `evmos/fees/v1/fees/${params.contractAddress}`; + return QueryDevFeeInfoResponse.fromSDKJSON(await this.req.get(endpoint)); + } + /* Params retrieves the fees module params */ + async params(_params: QueryParamsRequest = {}): Promise { + const endpoint = `evmos/fees/v1/params`; + return QueryParamsResponse.fromSDKJSON(await this.req.get(endpoint)); + } + /* DevFeeInfosPerDeployer retrieves all contracts that a deployer has + registered for fee distribution */ + async devFeeInfosPerDeployer(params: QueryDevFeeInfosPerDeployerRequest): Promise { + const options: any = { + params: {} + }; + if (typeof params?.pagination !== "undefined") { + setPaginationParams(options, params.pagination); + } + const endpoint = `evmos/fees/v1/fees/${params.deployerAddress}`; + return QueryDevFeeInfosPerDeployerResponse.fromSDKJSON(await this.req.get(endpoint, options)); + } +} \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/evmos/fees/v1/query.rpc.Query.ts b/__fixtures__/v-next/outputicjsdeps/evmos/fees/v1/query.rpc.Query.ts new file mode 100644 index 0000000000..a7297b6f74 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/evmos/fees/v1/query.rpc.Query.ts @@ -0,0 +1,71 @@ +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../../cosmos/base/query/v1beta1/pagination.js"; +import { DevFeeInfo, DevFeeInfoSDKType } from "./fees.js"; +import { Params, ParamsSDKType } from "./genesis.js"; +import { Rpc } from "../../../helpers.js"; +import { BinaryReader } from "../../../binary.js"; +import { QueryClient, createProtobufRpcClient } from "@cosmjs/stargate"; +import { QueryDevFeeInfosRequest, QueryDevFeeInfosRequestSDKType, QueryDevFeeInfosResponse, QueryDevFeeInfosResponseSDKType, QueryDevFeeInfoRequest, QueryDevFeeInfoRequestSDKType, QueryDevFeeInfoResponse, QueryDevFeeInfoResponseSDKType, QueryParamsRequest, QueryParamsRequestSDKType, QueryParamsResponse, QueryParamsResponseSDKType, QueryDevFeeInfosPerDeployerRequest, QueryDevFeeInfosPerDeployerRequestSDKType, QueryDevFeeInfosPerDeployerResponse, QueryDevFeeInfosPerDeployerResponseSDKType } from "./query.js"; +/** Query defines the gRPC querier service. */ +export interface Query { + /** DevFeeInfos retrieves all registered contracts for fee distribution */ + devFeeInfos(request?: QueryDevFeeInfosRequest): Promise; + /** DevFeeInfo retrieves a registered contract for fee distribution */ + devFeeInfo(request: QueryDevFeeInfoRequest): Promise; + /** Params retrieves the fees module params */ + params(request?: QueryParamsRequest): Promise; + /** + * DevFeeInfosPerDeployer retrieves all contracts that a deployer has + * registered for fee distribution + */ + devFeeInfosPerDeployer(request: QueryDevFeeInfosPerDeployerRequest): Promise; +} +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + this.devFeeInfos = this.devFeeInfos.bind(this); + this.devFeeInfo = this.devFeeInfo.bind(this); + this.params = this.params.bind(this); + this.devFeeInfosPerDeployer = this.devFeeInfosPerDeployer.bind(this); + } + devFeeInfos(request: QueryDevFeeInfosRequest = { + pagination: PageRequest.fromPartial({}) + }): Promise { + const data = QueryDevFeeInfosRequest.encode(request).finish(); + const promise = this.rpc.request("evmos.fees.v1.Query", "DevFeeInfos", data); + return promise.then(data => QueryDevFeeInfosResponse.decode(new BinaryReader(data))); + } + devFeeInfo(request: QueryDevFeeInfoRequest): Promise { + const data = QueryDevFeeInfoRequest.encode(request).finish(); + const promise = this.rpc.request("evmos.fees.v1.Query", "DevFeeInfo", data); + return promise.then(data => QueryDevFeeInfoResponse.decode(new BinaryReader(data))); + } + params(request: QueryParamsRequest = {}): Promise { + const data = QueryParamsRequest.encode(request).finish(); + const promise = this.rpc.request("evmos.fees.v1.Query", "Params", data); + return promise.then(data => QueryParamsResponse.decode(new BinaryReader(data))); + } + devFeeInfosPerDeployer(request: QueryDevFeeInfosPerDeployerRequest): Promise { + const data = QueryDevFeeInfosPerDeployerRequest.encode(request).finish(); + const promise = this.rpc.request("evmos.fees.v1.Query", "DevFeeInfosPerDeployer", data); + return promise.then(data => QueryDevFeeInfosPerDeployerResponse.decode(new BinaryReader(data))); + } +} +export const createRpcQueryExtension = (base: QueryClient) => { + const rpc = createProtobufRpcClient(base); + const queryService = new QueryClientImpl(rpc); + return { + devFeeInfos(request?: QueryDevFeeInfosRequest): Promise { + return queryService.devFeeInfos(request); + }, + devFeeInfo(request: QueryDevFeeInfoRequest): Promise { + return queryService.devFeeInfo(request); + }, + params(request?: QueryParamsRequest): Promise { + return queryService.params(request); + }, + devFeeInfosPerDeployer(request: QueryDevFeeInfosPerDeployerRequest): Promise { + return queryService.devFeeInfosPerDeployer(request); + } + }; +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/evmos/fees/v1/query.rpc.func.ts b/__fixtures__/v-next/outputicjsdeps/evmos/fees/v1/query.rpc.func.ts new file mode 100644 index 0000000000..abc5dfe908 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/evmos/fees/v1/query.rpc.func.ts @@ -0,0 +1,47 @@ +import { RpcResolver, buildQuery } from "../../../helper-func-types"; +import { buildUseQuery } from "../../../react-query"; +import { QueryDevFeeInfosRequest, QueryDevFeeInfosResponse, QueryDevFeeInfoRequest, QueryDevFeeInfoResponse, QueryParamsRequest, QueryParamsResponse, QueryDevFeeInfosPerDeployerRequest, QueryDevFeeInfosPerDeployerResponse } from "./query"; +export const createGetDevFeeInfos = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryDevFeeInfosRequest.encode, + decode: QueryDevFeeInfosResponse.decode, + service: "evmos.fees.v1.Query", + method: "DevFeeInfos", + getRpcInstance: getRpcInstance +}); +export const useGetDevFeeInfos = buildUseQuery({ + builderQueryFn: createGetDevFeeInfos, + queryKeyPrefix: "DevFeeInfosQuery" +}); +export const createGetDevFeeInfo = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryDevFeeInfoRequest.encode, + decode: QueryDevFeeInfoResponse.decode, + service: "evmos.fees.v1.Query", + method: "DevFeeInfo", + getRpcInstance: getRpcInstance +}); +export const useGetDevFeeInfo = buildUseQuery({ + builderQueryFn: createGetDevFeeInfo, + queryKeyPrefix: "DevFeeInfoQuery" +}); +export const createGetParams = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryParamsRequest.encode, + decode: QueryParamsResponse.decode, + service: "evmos.fees.v1.Query", + method: "Params", + getRpcInstance: getRpcInstance +}); +export const useGetParams = buildUseQuery({ + builderQueryFn: createGetParams, + queryKeyPrefix: "ParamsQuery" +}); +export const createGetDevFeeInfosPerDeployer = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryDevFeeInfosPerDeployerRequest.encode, + decode: QueryDevFeeInfosPerDeployerResponse.decode, + service: "evmos.fees.v1.Query", + method: "DevFeeInfosPerDeployer", + getRpcInstance: getRpcInstance +}); +export const useGetDevFeeInfosPerDeployer = buildUseQuery({ + builderQueryFn: createGetDevFeeInfosPerDeployer, + queryKeyPrefix: "DevFeeInfosPerDeployerQuery" +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/evmos/fees/v1/query.ts b/__fixtures__/v-next/outputicjsdeps/evmos/fees/v1/query.ts new file mode 100644 index 0000000000..3b1df4fbb6 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/evmos/fees/v1/query.ts @@ -0,0 +1,920 @@ +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../../cosmos/base/query/v1beta1/pagination.js"; +import { DevFeeInfo, DevFeeInfoSDKType } from "./fees.js"; +import { Params, ParamsSDKType } from "./genesis.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "evmos.fees.v1"; +/** + * QueryDevFeeInfosRequest is the request type for the Query/DevFeeInfos RPC + * method. + */ +export interface QueryDevFeeInfosRequest { + /** pagination defines an optional pagination for the request. */ + pagination?: PageRequest; +} +export interface QueryDevFeeInfosRequestProtoMsg { + typeUrl: "/evmos.fees.v1.QueryDevFeeInfosRequest"; + value: Uint8Array; +} +/** + * QueryDevFeeInfosRequest is the request type for the Query/DevFeeInfos RPC + * method. + */ +export interface QueryDevFeeInfosRequestSDKType { + pagination?: PageRequestSDKType; +} +/** + * QueryDevFeeInfosResponse is the response type for the Query/DevFeeInfos + * RPC method. + */ +export interface QueryDevFeeInfosResponse { + fees: DevFeeInfo[]; + /** pagination defines the pagination in the response. */ + pagination?: PageResponse; +} +export interface QueryDevFeeInfosResponseProtoMsg { + typeUrl: "/evmos.fees.v1.QueryDevFeeInfosResponse"; + value: Uint8Array; +} +/** + * QueryDevFeeInfosResponse is the response type for the Query/DevFeeInfos + * RPC method. + */ +export interface QueryDevFeeInfosResponseSDKType { + fees: DevFeeInfoSDKType[]; + pagination?: PageResponseSDKType; +} +/** + * QueryDevFeeInfoRequest is the request type for the Query/DevFeeInfo RPC + * method. + */ +export interface QueryDevFeeInfoRequest { + /** contract identifier is the hex contract address of a contract */ + contractAddress: string; +} +export interface QueryDevFeeInfoRequestProtoMsg { + typeUrl: "/evmos.fees.v1.QueryDevFeeInfoRequest"; + value: Uint8Array; +} +/** + * QueryDevFeeInfoRequest is the request type for the Query/DevFeeInfo RPC + * method. + */ +export interface QueryDevFeeInfoRequestSDKType { + contract_address: string; +} +/** + * QueryDevFeeInfoResponse is the response type for the Query/DevFeeInfo RPC + * method. + */ +export interface QueryDevFeeInfoResponse { + fee: DevFeeInfo; +} +export interface QueryDevFeeInfoResponseProtoMsg { + typeUrl: "/evmos.fees.v1.QueryDevFeeInfoResponse"; + value: Uint8Array; +} +/** + * QueryDevFeeInfoResponse is the response type for the Query/DevFeeInfo RPC + * method. + */ +export interface QueryDevFeeInfoResponseSDKType { + fee: DevFeeInfoSDKType; +} +/** QueryParamsRequest is the request type for the Query/Params RPC method. */ +export interface QueryParamsRequest {} +export interface QueryParamsRequestProtoMsg { + typeUrl: "/evmos.fees.v1.QueryParamsRequest"; + value: Uint8Array; +} +/** QueryParamsRequest is the request type for the Query/Params RPC method. */ +export interface QueryParamsRequestSDKType {} +/** + * QueryParamsResponse is the response type for the Query/Params RPC + * method. + */ +export interface QueryParamsResponse { + params: Params; +} +export interface QueryParamsResponseProtoMsg { + typeUrl: "/evmos.fees.v1.QueryParamsResponse"; + value: Uint8Array; +} +/** + * QueryParamsResponse is the response type for the Query/Params RPC + * method. + */ +export interface QueryParamsResponseSDKType { + params: ParamsSDKType; +} +/** + * QueryDevFeeInfosPerDeployerRequest is the request type for the + * Query/DevFeeInfosPerDeployer RPC method. + */ +export interface QueryDevFeeInfosPerDeployerRequest { + /** deployer bech32 address */ + deployerAddress: string; + /** pagination defines an optional pagination for the request. */ + pagination?: PageRequest; +} +export interface QueryDevFeeInfosPerDeployerRequestProtoMsg { + typeUrl: "/evmos.fees.v1.QueryDevFeeInfosPerDeployerRequest"; + value: Uint8Array; +} +/** + * QueryDevFeeInfosPerDeployerRequest is the request type for the + * Query/DevFeeInfosPerDeployer RPC method. + */ +export interface QueryDevFeeInfosPerDeployerRequestSDKType { + deployer_address: string; + pagination?: PageRequestSDKType; +} +/** + * QueryDevFeeInfosPerDeployerResponse is the response type for the + * Query/DevFeeInfosPerDeployer RPC method. + */ +export interface QueryDevFeeInfosPerDeployerResponse { + fees: DevFeeInfo[]; + /** pagination defines the pagination in the response. */ + pagination?: PageResponse; +} +export interface QueryDevFeeInfosPerDeployerResponseProtoMsg { + typeUrl: "/evmos.fees.v1.QueryDevFeeInfosPerDeployerResponse"; + value: Uint8Array; +} +/** + * QueryDevFeeInfosPerDeployerResponse is the response type for the + * Query/DevFeeInfosPerDeployer RPC method. + */ +export interface QueryDevFeeInfosPerDeployerResponseSDKType { + fees: DevFeeInfoSDKType[]; + pagination?: PageResponseSDKType; +} +function createBaseQueryDevFeeInfosRequest(): QueryDevFeeInfosRequest { + return { + pagination: undefined + }; +} +export const QueryDevFeeInfosRequest = { + typeUrl: "/evmos.fees.v1.QueryDevFeeInfosRequest", + encode(message: QueryDevFeeInfosRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryDevFeeInfosRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryDevFeeInfosRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryDevFeeInfosRequest { + const obj = createBaseQueryDevFeeInfosRequest(); + if (isSet(object.pagination)) obj.pagination = PageRequest.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryDevFeeInfosRequest): JsonSafe { + const obj: any = {}; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryDevFeeInfosRequest { + const message = createBaseQueryDevFeeInfosRequest(); + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryDevFeeInfosRequestSDKType): QueryDevFeeInfosRequest { + return { + pagination: object.pagination ? PageRequest.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryDevFeeInfosRequestSDKType { + return { + pagination: isSet(object.pagination) ? PageRequest.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryDevFeeInfosRequest): QueryDevFeeInfosRequestSDKType { + const obj: any = {}; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryDevFeeInfosRequestAmino): QueryDevFeeInfosRequest { + const message = createBaseQueryDevFeeInfosRequest(); + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryDevFeeInfosRequest): QueryDevFeeInfosRequestAmino { + const obj: any = {}; + obj.pagination = message.pagination ? PageRequest.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryDevFeeInfosRequestAminoMsg): QueryDevFeeInfosRequest { + return QueryDevFeeInfosRequest.fromAmino(object.value); + }, + fromProtoMsg(message: QueryDevFeeInfosRequestProtoMsg): QueryDevFeeInfosRequest { + return QueryDevFeeInfosRequest.decode(message.value); + }, + toProto(message: QueryDevFeeInfosRequest): Uint8Array { + return QueryDevFeeInfosRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryDevFeeInfosRequest): QueryDevFeeInfosRequestProtoMsg { + return { + typeUrl: "/evmos.fees.v1.QueryDevFeeInfosRequest", + value: QueryDevFeeInfosRequest.encode(message).finish() + }; + } +}; +function createBaseQueryDevFeeInfosResponse(): QueryDevFeeInfosResponse { + return { + fees: [], + pagination: undefined + }; +} +export const QueryDevFeeInfosResponse = { + typeUrl: "/evmos.fees.v1.QueryDevFeeInfosResponse", + encode(message: QueryDevFeeInfosResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.fees) { + DevFeeInfo.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryDevFeeInfosResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryDevFeeInfosResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.fees.push(DevFeeInfo.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryDevFeeInfosResponse { + const obj = createBaseQueryDevFeeInfosResponse(); + if (Array.isArray(object?.fees)) obj.fees = object.fees.map((e: any) => DevFeeInfo.fromJSON(e)); + if (isSet(object.pagination)) obj.pagination = PageResponse.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryDevFeeInfosResponse): JsonSafe { + const obj: any = {}; + if (message.fees) { + obj.fees = message.fees.map(e => e ? DevFeeInfo.toJSON(e) : undefined); + } else { + obj.fees = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryDevFeeInfosResponse { + const message = createBaseQueryDevFeeInfosResponse(); + message.fees = object.fees?.map(e => DevFeeInfo.fromPartial(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryDevFeeInfosResponseSDKType): QueryDevFeeInfosResponse { + return { + fees: Array.isArray(object?.fees) ? object.fees.map((e: any) => DevFeeInfo.fromSDK(e)) : [], + pagination: object.pagination ? PageResponse.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryDevFeeInfosResponseSDKType { + return { + fees: Array.isArray(object?.fees) ? object.fees.map((e: any) => DevFeeInfo.fromSDKJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryDevFeeInfosResponse): QueryDevFeeInfosResponseSDKType { + const obj: any = {}; + if (message.fees) { + obj.fees = message.fees.map(e => e ? DevFeeInfo.toSDK(e) : undefined); + } else { + obj.fees = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryDevFeeInfosResponseAmino): QueryDevFeeInfosResponse { + const message = createBaseQueryDevFeeInfosResponse(); + message.fees = object.fees?.map(e => DevFeeInfo.fromAmino(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryDevFeeInfosResponse): QueryDevFeeInfosResponseAmino { + const obj: any = {}; + if (message.fees) { + obj.fees = message.fees.map(e => e ? DevFeeInfo.toAmino(e) : undefined); + } else { + obj.fees = message.fees; + } + obj.pagination = message.pagination ? PageResponse.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryDevFeeInfosResponseAminoMsg): QueryDevFeeInfosResponse { + return QueryDevFeeInfosResponse.fromAmino(object.value); + }, + fromProtoMsg(message: QueryDevFeeInfosResponseProtoMsg): QueryDevFeeInfosResponse { + return QueryDevFeeInfosResponse.decode(message.value); + }, + toProto(message: QueryDevFeeInfosResponse): Uint8Array { + return QueryDevFeeInfosResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryDevFeeInfosResponse): QueryDevFeeInfosResponseProtoMsg { + return { + typeUrl: "/evmos.fees.v1.QueryDevFeeInfosResponse", + value: QueryDevFeeInfosResponse.encode(message).finish() + }; + } +}; +function createBaseQueryDevFeeInfoRequest(): QueryDevFeeInfoRequest { + return { + contractAddress: "" + }; +} +export const QueryDevFeeInfoRequest = { + typeUrl: "/evmos.fees.v1.QueryDevFeeInfoRequest", + encode(message: QueryDevFeeInfoRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.contractAddress !== undefined) { + writer.uint32(10).string(message.contractAddress); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryDevFeeInfoRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryDevFeeInfoRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.contractAddress = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryDevFeeInfoRequest { + const obj = createBaseQueryDevFeeInfoRequest(); + if (isSet(object.contractAddress)) obj.contractAddress = String(object.contractAddress); + return obj; + }, + toJSON(message: QueryDevFeeInfoRequest): JsonSafe { + const obj: any = {}; + message.contractAddress !== undefined && (obj.contractAddress = message.contractAddress); + return obj; + }, + fromPartial(object: DeepPartial): QueryDevFeeInfoRequest { + const message = createBaseQueryDevFeeInfoRequest(); + message.contractAddress = object.contractAddress ?? ""; + return message; + }, + fromSDK(object: QueryDevFeeInfoRequestSDKType): QueryDevFeeInfoRequest { + return { + contractAddress: object?.contract_address + }; + }, + fromSDKJSON(object: any): QueryDevFeeInfoRequestSDKType { + return { + contract_address: isSet(object.contract_address) ? String(object.contract_address) : "" + }; + }, + toSDK(message: QueryDevFeeInfoRequest): QueryDevFeeInfoRequestSDKType { + const obj: any = {}; + obj.contract_address = message.contractAddress; + return obj; + }, + fromAmino(object: QueryDevFeeInfoRequestAmino): QueryDevFeeInfoRequest { + const message = createBaseQueryDevFeeInfoRequest(); + if (object.contract_address !== undefined && object.contract_address !== null) { + message.contractAddress = object.contract_address; + } + return message; + }, + toAmino(message: QueryDevFeeInfoRequest): QueryDevFeeInfoRequestAmino { + const obj: any = {}; + obj.contract_address = message.contractAddress === "" ? undefined : message.contractAddress; + return obj; + }, + fromAminoMsg(object: QueryDevFeeInfoRequestAminoMsg): QueryDevFeeInfoRequest { + return QueryDevFeeInfoRequest.fromAmino(object.value); + }, + fromProtoMsg(message: QueryDevFeeInfoRequestProtoMsg): QueryDevFeeInfoRequest { + return QueryDevFeeInfoRequest.decode(message.value); + }, + toProto(message: QueryDevFeeInfoRequest): Uint8Array { + return QueryDevFeeInfoRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryDevFeeInfoRequest): QueryDevFeeInfoRequestProtoMsg { + return { + typeUrl: "/evmos.fees.v1.QueryDevFeeInfoRequest", + value: QueryDevFeeInfoRequest.encode(message).finish() + }; + } +}; +function createBaseQueryDevFeeInfoResponse(): QueryDevFeeInfoResponse { + return { + fee: DevFeeInfo.fromPartial({}) + }; +} +export const QueryDevFeeInfoResponse = { + typeUrl: "/evmos.fees.v1.QueryDevFeeInfoResponse", + encode(message: QueryDevFeeInfoResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.fee !== undefined) { + DevFeeInfo.encode(message.fee, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryDevFeeInfoResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryDevFeeInfoResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.fee = DevFeeInfo.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryDevFeeInfoResponse { + const obj = createBaseQueryDevFeeInfoResponse(); + if (isSet(object.fee)) obj.fee = DevFeeInfo.fromJSON(object.fee); + return obj; + }, + toJSON(message: QueryDevFeeInfoResponse): JsonSafe { + const obj: any = {}; + message.fee !== undefined && (obj.fee = message.fee ? DevFeeInfo.toJSON(message.fee) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryDevFeeInfoResponse { + const message = createBaseQueryDevFeeInfoResponse(); + if (object.fee !== undefined && object.fee !== null) { + message.fee = DevFeeInfo.fromPartial(object.fee); + } + return message; + }, + fromSDK(object: QueryDevFeeInfoResponseSDKType): QueryDevFeeInfoResponse { + return { + fee: object.fee ? DevFeeInfo.fromSDK(object.fee) : undefined + }; + }, + fromSDKJSON(object: any): QueryDevFeeInfoResponseSDKType { + return { + fee: isSet(object.fee) ? DevFeeInfo.fromSDKJSON(object.fee) : undefined + }; + }, + toSDK(message: QueryDevFeeInfoResponse): QueryDevFeeInfoResponseSDKType { + const obj: any = {}; + message.fee !== undefined && (obj.fee = message.fee ? DevFeeInfo.toSDK(message.fee) : undefined); + return obj; + }, + fromAmino(object: QueryDevFeeInfoResponseAmino): QueryDevFeeInfoResponse { + const message = createBaseQueryDevFeeInfoResponse(); + if (object.fee !== undefined && object.fee !== null) { + message.fee = DevFeeInfo.fromAmino(object.fee); + } + return message; + }, + toAmino(message: QueryDevFeeInfoResponse): QueryDevFeeInfoResponseAmino { + const obj: any = {}; + obj.fee = message.fee ? DevFeeInfo.toAmino(message.fee) : undefined; + return obj; + }, + fromAminoMsg(object: QueryDevFeeInfoResponseAminoMsg): QueryDevFeeInfoResponse { + return QueryDevFeeInfoResponse.fromAmino(object.value); + }, + fromProtoMsg(message: QueryDevFeeInfoResponseProtoMsg): QueryDevFeeInfoResponse { + return QueryDevFeeInfoResponse.decode(message.value); + }, + toProto(message: QueryDevFeeInfoResponse): Uint8Array { + return QueryDevFeeInfoResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryDevFeeInfoResponse): QueryDevFeeInfoResponseProtoMsg { + return { + typeUrl: "/evmos.fees.v1.QueryDevFeeInfoResponse", + value: QueryDevFeeInfoResponse.encode(message).finish() + }; + } +}; +function createBaseQueryParamsRequest(): QueryParamsRequest { + return {}; +} +export const QueryParamsRequest = { + typeUrl: "/evmos.fees.v1.QueryParamsRequest", + encode(_: QueryParamsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryParamsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryParamsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): QueryParamsRequest { + const obj = createBaseQueryParamsRequest(); + return obj; + }, + toJSON(_: QueryParamsRequest): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): QueryParamsRequest { + const message = createBaseQueryParamsRequest(); + return message; + }, + fromSDK(_: QueryParamsRequestSDKType): QueryParamsRequest { + return {}; + }, + fromSDKJSON(_: any): QueryParamsRequestSDKType { + return {}; + }, + toSDK(_: QueryParamsRequest): QueryParamsRequestSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: QueryParamsRequestAmino): QueryParamsRequest { + const message = createBaseQueryParamsRequest(); + return message; + }, + toAmino(_: QueryParamsRequest): QueryParamsRequestAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: QueryParamsRequestAminoMsg): QueryParamsRequest { + return QueryParamsRequest.fromAmino(object.value); + }, + fromProtoMsg(message: QueryParamsRequestProtoMsg): QueryParamsRequest { + return QueryParamsRequest.decode(message.value); + }, + toProto(message: QueryParamsRequest): Uint8Array { + return QueryParamsRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryParamsRequest): QueryParamsRequestProtoMsg { + return { + typeUrl: "/evmos.fees.v1.QueryParamsRequest", + value: QueryParamsRequest.encode(message).finish() + }; + } +}; +function createBaseQueryParamsResponse(): QueryParamsResponse { + return { + params: Params.fromPartial({}) + }; +} +export const QueryParamsResponse = { + typeUrl: "/evmos.fees.v1.QueryParamsResponse", + encode(message: QueryParamsResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryParamsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryParamsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.params = Params.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryParamsResponse { + const obj = createBaseQueryParamsResponse(); + if (isSet(object.params)) obj.params = Params.fromJSON(object.params); + return obj; + }, + toJSON(message: QueryParamsResponse): JsonSafe { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryParamsResponse { + const message = createBaseQueryParamsResponse(); + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } + return message; + }, + fromSDK(object: QueryParamsResponseSDKType): QueryParamsResponse { + return { + params: object.params ? Params.fromSDK(object.params) : undefined + }; + }, + fromSDKJSON(object: any): QueryParamsResponseSDKType { + return { + params: isSet(object.params) ? Params.fromSDKJSON(object.params) : undefined + }; + }, + toSDK(message: QueryParamsResponse): QueryParamsResponseSDKType { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toSDK(message.params) : undefined); + return obj; + }, + fromAmino(object: QueryParamsResponseAmino): QueryParamsResponse { + const message = createBaseQueryParamsResponse(); + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromAmino(object.params); + } + return message; + }, + toAmino(message: QueryParamsResponse): QueryParamsResponseAmino { + const obj: any = {}; + obj.params = message.params ? Params.toAmino(message.params) : undefined; + return obj; + }, + fromAminoMsg(object: QueryParamsResponseAminoMsg): QueryParamsResponse { + return QueryParamsResponse.fromAmino(object.value); + }, + fromProtoMsg(message: QueryParamsResponseProtoMsg): QueryParamsResponse { + return QueryParamsResponse.decode(message.value); + }, + toProto(message: QueryParamsResponse): Uint8Array { + return QueryParamsResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryParamsResponse): QueryParamsResponseProtoMsg { + return { + typeUrl: "/evmos.fees.v1.QueryParamsResponse", + value: QueryParamsResponse.encode(message).finish() + }; + } +}; +function createBaseQueryDevFeeInfosPerDeployerRequest(): QueryDevFeeInfosPerDeployerRequest { + return { + deployerAddress: "", + pagination: undefined + }; +} +export const QueryDevFeeInfosPerDeployerRequest = { + typeUrl: "/evmos.fees.v1.QueryDevFeeInfosPerDeployerRequest", + encode(message: QueryDevFeeInfosPerDeployerRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.deployerAddress !== undefined) { + writer.uint32(10).string(message.deployerAddress); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryDevFeeInfosPerDeployerRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryDevFeeInfosPerDeployerRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.deployerAddress = reader.string(); + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryDevFeeInfosPerDeployerRequest { + const obj = createBaseQueryDevFeeInfosPerDeployerRequest(); + if (isSet(object.deployerAddress)) obj.deployerAddress = String(object.deployerAddress); + if (isSet(object.pagination)) obj.pagination = PageRequest.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryDevFeeInfosPerDeployerRequest): JsonSafe { + const obj: any = {}; + message.deployerAddress !== undefined && (obj.deployerAddress = message.deployerAddress); + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryDevFeeInfosPerDeployerRequest { + const message = createBaseQueryDevFeeInfosPerDeployerRequest(); + message.deployerAddress = object.deployerAddress ?? ""; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryDevFeeInfosPerDeployerRequestSDKType): QueryDevFeeInfosPerDeployerRequest { + return { + deployerAddress: object?.deployer_address, + pagination: object.pagination ? PageRequest.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryDevFeeInfosPerDeployerRequestSDKType { + return { + deployer_address: isSet(object.deployer_address) ? String(object.deployer_address) : "", + pagination: isSet(object.pagination) ? PageRequest.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryDevFeeInfosPerDeployerRequest): QueryDevFeeInfosPerDeployerRequestSDKType { + const obj: any = {}; + obj.deployer_address = message.deployerAddress; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryDevFeeInfosPerDeployerRequestAmino): QueryDevFeeInfosPerDeployerRequest { + const message = createBaseQueryDevFeeInfosPerDeployerRequest(); + if (object.deployer_address !== undefined && object.deployer_address !== null) { + message.deployerAddress = object.deployer_address; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryDevFeeInfosPerDeployerRequest): QueryDevFeeInfosPerDeployerRequestAmino { + const obj: any = {}; + obj.deployer_address = message.deployerAddress === "" ? undefined : message.deployerAddress; + obj.pagination = message.pagination ? PageRequest.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryDevFeeInfosPerDeployerRequestAminoMsg): QueryDevFeeInfosPerDeployerRequest { + return QueryDevFeeInfosPerDeployerRequest.fromAmino(object.value); + }, + fromProtoMsg(message: QueryDevFeeInfosPerDeployerRequestProtoMsg): QueryDevFeeInfosPerDeployerRequest { + return QueryDevFeeInfosPerDeployerRequest.decode(message.value); + }, + toProto(message: QueryDevFeeInfosPerDeployerRequest): Uint8Array { + return QueryDevFeeInfosPerDeployerRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryDevFeeInfosPerDeployerRequest): QueryDevFeeInfosPerDeployerRequestProtoMsg { + return { + typeUrl: "/evmos.fees.v1.QueryDevFeeInfosPerDeployerRequest", + value: QueryDevFeeInfosPerDeployerRequest.encode(message).finish() + }; + } +}; +function createBaseQueryDevFeeInfosPerDeployerResponse(): QueryDevFeeInfosPerDeployerResponse { + return { + fees: [], + pagination: undefined + }; +} +export const QueryDevFeeInfosPerDeployerResponse = { + typeUrl: "/evmos.fees.v1.QueryDevFeeInfosPerDeployerResponse", + encode(message: QueryDevFeeInfosPerDeployerResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.fees) { + DevFeeInfo.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryDevFeeInfosPerDeployerResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryDevFeeInfosPerDeployerResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.fees.push(DevFeeInfo.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryDevFeeInfosPerDeployerResponse { + const obj = createBaseQueryDevFeeInfosPerDeployerResponse(); + if (Array.isArray(object?.fees)) obj.fees = object.fees.map((e: any) => DevFeeInfo.fromJSON(e)); + if (isSet(object.pagination)) obj.pagination = PageResponse.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryDevFeeInfosPerDeployerResponse): JsonSafe { + const obj: any = {}; + if (message.fees) { + obj.fees = message.fees.map(e => e ? DevFeeInfo.toJSON(e) : undefined); + } else { + obj.fees = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryDevFeeInfosPerDeployerResponse { + const message = createBaseQueryDevFeeInfosPerDeployerResponse(); + message.fees = object.fees?.map(e => DevFeeInfo.fromPartial(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryDevFeeInfosPerDeployerResponseSDKType): QueryDevFeeInfosPerDeployerResponse { + return { + fees: Array.isArray(object?.fees) ? object.fees.map((e: any) => DevFeeInfo.fromSDK(e)) : [], + pagination: object.pagination ? PageResponse.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryDevFeeInfosPerDeployerResponseSDKType { + return { + fees: Array.isArray(object?.fees) ? object.fees.map((e: any) => DevFeeInfo.fromSDKJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryDevFeeInfosPerDeployerResponse): QueryDevFeeInfosPerDeployerResponseSDKType { + const obj: any = {}; + if (message.fees) { + obj.fees = message.fees.map(e => e ? DevFeeInfo.toSDK(e) : undefined); + } else { + obj.fees = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryDevFeeInfosPerDeployerResponseAmino): QueryDevFeeInfosPerDeployerResponse { + const message = createBaseQueryDevFeeInfosPerDeployerResponse(); + message.fees = object.fees?.map(e => DevFeeInfo.fromAmino(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryDevFeeInfosPerDeployerResponse): QueryDevFeeInfosPerDeployerResponseAmino { + const obj: any = {}; + if (message.fees) { + obj.fees = message.fees.map(e => e ? DevFeeInfo.toAmino(e) : undefined); + } else { + obj.fees = message.fees; + } + obj.pagination = message.pagination ? PageResponse.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryDevFeeInfosPerDeployerResponseAminoMsg): QueryDevFeeInfosPerDeployerResponse { + return QueryDevFeeInfosPerDeployerResponse.fromAmino(object.value); + }, + fromProtoMsg(message: QueryDevFeeInfosPerDeployerResponseProtoMsg): QueryDevFeeInfosPerDeployerResponse { + return QueryDevFeeInfosPerDeployerResponse.decode(message.value); + }, + toProto(message: QueryDevFeeInfosPerDeployerResponse): Uint8Array { + return QueryDevFeeInfosPerDeployerResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryDevFeeInfosPerDeployerResponse): QueryDevFeeInfosPerDeployerResponseProtoMsg { + return { + typeUrl: "/evmos.fees.v1.QueryDevFeeInfosPerDeployerResponse", + value: QueryDevFeeInfosPerDeployerResponse.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/evmos/fees/v1/tx.amino.ts b/__fixtures__/v-next/outputicjsdeps/evmos/fees/v1/tx.amino.ts new file mode 100644 index 0000000000..f86d34b6e2 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/evmos/fees/v1/tx.amino.ts @@ -0,0 +1,103 @@ +import { ReadOnlyAminoMsg as AminoMsg } from "@interchainjs/ReadOnlyAminoMsg"; +import { MsgRegisterDevFeeInfo, MsgRegisterDevFeeInfoSDKType, MsgCancelDevFeeInfo, MsgCancelDevFeeInfoSDKType, MsgUpdateDevFeeInfo, MsgUpdateDevFeeInfoSDKType } from "./tx.js"; +export interface MsgRegisterDevFeeInfoAminoType extends AminoMsg { + type: "/evmos.fees.v1.MsgRegisterDevFeeInfo"; + value: { + contract_address: string; + deployer_address: string; + withdraw_address: string; + nonces: string[]; + }; +} +export interface MsgCancelDevFeeInfoAminoType extends AminoMsg { + type: "/evmos.fees.v1.MsgCancelDevFeeInfo"; + value: { + contract_address: string; + deployer_address: string; + }; +} +export interface MsgUpdateDevFeeInfoAminoType extends AminoMsg { + type: "/evmos.fees.v1.MsgUpdateDevFeeInfo"; + value: { + contract_address: string; + deployer_address: string; + withdraw_address: string; + }; +} +export const AminoConverter = { + "/evmos.fees.v1.MsgRegisterDevFeeInfo": { + aminoType: "/evmos.fees.v1.MsgRegisterDevFeeInfo", + toAmino: ({ + contractAddress, + deployerAddress, + withdrawAddress, + nonces + }: MsgRegisterDevFeeInfo): MsgRegisterDevFeeInfoAminoType["value"] => { + return { + contract_address: contractAddress, + deployer_address: deployerAddress, + withdraw_address: withdrawAddress, + nonces: nonces.map(el0 => el0.toString()) + }; + }, + fromAmino: ({ + contract_address, + deployer_address, + withdraw_address, + nonces + }: MsgRegisterDevFeeInfoAminoType["value"]): MsgRegisterDevFeeInfo => { + return { + contractAddress: contract_address, + deployerAddress: deployer_address, + withdrawAddress: withdraw_address, + nonces: nonces.map(el0 => BigInt(el0)) + }; + } + }, + "/evmos.fees.v1.MsgCancelDevFeeInfo": { + aminoType: "/evmos.fees.v1.MsgCancelDevFeeInfo", + toAmino: ({ + contractAddress, + deployerAddress + }: MsgCancelDevFeeInfo): MsgCancelDevFeeInfoAminoType["value"] => { + return { + contract_address: contractAddress, + deployer_address: deployerAddress + }; + }, + fromAmino: ({ + contract_address, + deployer_address + }: MsgCancelDevFeeInfoAminoType["value"]): MsgCancelDevFeeInfo => { + return { + contractAddress: contract_address, + deployerAddress: deployer_address + }; + } + }, + "/evmos.fees.v1.MsgUpdateDevFeeInfo": { + aminoType: "/evmos.fees.v1.MsgUpdateDevFeeInfo", + toAmino: ({ + contractAddress, + deployerAddress, + withdrawAddress + }: MsgUpdateDevFeeInfo): MsgUpdateDevFeeInfoAminoType["value"] => { + return { + contract_address: contractAddress, + deployer_address: deployerAddress, + withdraw_address: withdrawAddress + }; + }, + fromAmino: ({ + contract_address, + deployer_address, + withdraw_address + }: MsgUpdateDevFeeInfoAminoType["value"]): MsgUpdateDevFeeInfo => { + return { + contractAddress: contract_address, + deployerAddress: deployer_address, + withdrawAddress: withdraw_address + }; + } + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/evmos/fees/v1/tx.registry.ts b/__fixtures__/v-next/outputicjsdeps/evmos/fees/v1/tx.registry.ts new file mode 100644 index 0000000000..9b58158d72 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/evmos/fees/v1/tx.registry.ts @@ -0,0 +1,110 @@ +import { GeneratedType, Registry } from "@cosmjs/proto-signing"; +import { MsgRegisterDevFeeInfo, MsgRegisterDevFeeInfoSDKType, MsgCancelDevFeeInfo, MsgCancelDevFeeInfoSDKType, MsgUpdateDevFeeInfo, MsgUpdateDevFeeInfoSDKType } from "./tx.js"; +export const registry: ReadonlyArray<[string, GeneratedType]> = [["/evmos.fees.v1.MsgRegisterDevFeeInfo", MsgRegisterDevFeeInfo], ["/evmos.fees.v1.MsgCancelDevFeeInfo", MsgCancelDevFeeInfo], ["/evmos.fees.v1.MsgUpdateDevFeeInfo", MsgUpdateDevFeeInfo]]; +export const load = (protoRegistry: Registry) => { + registry.forEach(([typeUrl, mod]) => { + protoRegistry.register(typeUrl, mod); + }); +}; +export const MessageComposer = { + encoded: { + registerDevFeeInfo(value: MsgRegisterDevFeeInfo) { + return { + typeUrl: "/evmos.fees.v1.MsgRegisterDevFeeInfo", + value: MsgRegisterDevFeeInfo.encode(value).finish() + }; + }, + cancelDevFeeInfo(value: MsgCancelDevFeeInfo) { + return { + typeUrl: "/evmos.fees.v1.MsgCancelDevFeeInfo", + value: MsgCancelDevFeeInfo.encode(value).finish() + }; + }, + updateDevFeeInfo(value: MsgUpdateDevFeeInfo) { + return { + typeUrl: "/evmos.fees.v1.MsgUpdateDevFeeInfo", + value: MsgUpdateDevFeeInfo.encode(value).finish() + }; + } + }, + withTypeUrl: { + registerDevFeeInfo(value: MsgRegisterDevFeeInfo) { + return { + typeUrl: "/evmos.fees.v1.MsgRegisterDevFeeInfo", + value + }; + }, + cancelDevFeeInfo(value: MsgCancelDevFeeInfo) { + return { + typeUrl: "/evmos.fees.v1.MsgCancelDevFeeInfo", + value + }; + }, + updateDevFeeInfo(value: MsgUpdateDevFeeInfo) { + return { + typeUrl: "/evmos.fees.v1.MsgUpdateDevFeeInfo", + value + }; + } + }, + toJSON: { + registerDevFeeInfo(value: MsgRegisterDevFeeInfo) { + return { + typeUrl: "/evmos.fees.v1.MsgRegisterDevFeeInfo", + value: MsgRegisterDevFeeInfo.toJSON(value) + }; + }, + cancelDevFeeInfo(value: MsgCancelDevFeeInfo) { + return { + typeUrl: "/evmos.fees.v1.MsgCancelDevFeeInfo", + value: MsgCancelDevFeeInfo.toJSON(value) + }; + }, + updateDevFeeInfo(value: MsgUpdateDevFeeInfo) { + return { + typeUrl: "/evmos.fees.v1.MsgUpdateDevFeeInfo", + value: MsgUpdateDevFeeInfo.toJSON(value) + }; + } + }, + fromJSON: { + registerDevFeeInfo(value: any) { + return { + typeUrl: "/evmos.fees.v1.MsgRegisterDevFeeInfo", + value: MsgRegisterDevFeeInfo.fromJSON(value) + }; + }, + cancelDevFeeInfo(value: any) { + return { + typeUrl: "/evmos.fees.v1.MsgCancelDevFeeInfo", + value: MsgCancelDevFeeInfo.fromJSON(value) + }; + }, + updateDevFeeInfo(value: any) { + return { + typeUrl: "/evmos.fees.v1.MsgUpdateDevFeeInfo", + value: MsgUpdateDevFeeInfo.fromJSON(value) + }; + } + }, + fromPartial: { + registerDevFeeInfo(value: MsgRegisterDevFeeInfo) { + return { + typeUrl: "/evmos.fees.v1.MsgRegisterDevFeeInfo", + value: MsgRegisterDevFeeInfo.fromPartial(value) + }; + }, + cancelDevFeeInfo(value: MsgCancelDevFeeInfo) { + return { + typeUrl: "/evmos.fees.v1.MsgCancelDevFeeInfo", + value: MsgCancelDevFeeInfo.fromPartial(value) + }; + }, + updateDevFeeInfo(value: MsgUpdateDevFeeInfo) { + return { + typeUrl: "/evmos.fees.v1.MsgUpdateDevFeeInfo", + value: MsgUpdateDevFeeInfo.fromPartial(value) + }; + } + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/evmos/fees/v1/tx.rpc.func.ts b/__fixtures__/v-next/outputicjsdeps/evmos/fees/v1/tx.rpc.func.ts new file mode 100644 index 0000000000..2510215af2 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/evmos/fees/v1/tx.rpc.func.ts @@ -0,0 +1,31 @@ +import { buildTx, SigningClientResolver } from "../../../helper-func-types"; +import { buildUseMutation } from "../../../react-query"; +import { toEncoders, toConverters } from "@interchainjs/cosmos/utils"; +import { MsgRegisterDevFeeInfo, MsgCancelDevFeeInfo, MsgUpdateDevFeeInfo } from "./tx"; +export const createRegisterDevFeeInfo = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgRegisterDevFeeInfo.typeUrl, + encoders: toEncoders(MsgRegisterDevFeeInfo), + converters: toConverters(MsgRegisterDevFeeInfo) +}); +export const useRegisterDevFeeInfo = buildUseMutation({ + builderMutationFn: createRegisterDevFeeInfo +}); +export const createCancelDevFeeInfo = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgCancelDevFeeInfo.typeUrl, + encoders: toEncoders(MsgCancelDevFeeInfo), + converters: toConverters(MsgCancelDevFeeInfo) +}); +export const useCancelDevFeeInfo = buildUseMutation({ + builderMutationFn: createCancelDevFeeInfo +}); +export const createUpdateDevFeeInfo = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgUpdateDevFeeInfo.typeUrl, + encoders: toEncoders(MsgUpdateDevFeeInfo), + converters: toConverters(MsgUpdateDevFeeInfo) +}); +export const useUpdateDevFeeInfo = buildUseMutation({ + builderMutationFn: createUpdateDevFeeInfo +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/evmos/fees/v1/tx.rpc.msg.ts b/__fixtures__/v-next/outputicjsdeps/evmos/fees/v1/tx.rpc.msg.ts new file mode 100644 index 0000000000..54e96de557 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/evmos/fees/v1/tx.rpc.msg.ts @@ -0,0 +1,45 @@ +import { Rpc } from "../../../helpers.js"; +import { BinaryReader } from "../../../binary.js"; +import { MsgRegisterDevFeeInfo, MsgRegisterDevFeeInfoSDKType, MsgRegisterDevFeeInfoResponse, MsgRegisterDevFeeInfoResponseSDKType, MsgCancelDevFeeInfo, MsgCancelDevFeeInfoSDKType, MsgCancelDevFeeInfoResponse, MsgCancelDevFeeInfoResponseSDKType, MsgUpdateDevFeeInfo, MsgUpdateDevFeeInfoSDKType, MsgUpdateDevFeeInfoResponse, MsgUpdateDevFeeInfoResponseSDKType } from "./tx.js"; +/** Msg defines the fees Msg service. */ +export interface Msg { + /** + * RegisterDevFeeInfo is used by a deployer to register a new contract for + * receiving transaction fees + */ + registerDevFeeInfo(request: MsgRegisterDevFeeInfo): Promise; + /** + * CancelDevFeeInfo is used by a deployer to cancel a registered contract + * and stop receiving transaction fees + */ + cancelDevFeeInfo(request: MsgCancelDevFeeInfo): Promise; + /** UpdateDevFeeInfo is used by a deployer to update the withdraw address */ + updateDevFeeInfo(request: MsgUpdateDevFeeInfo): Promise; +} +export class MsgClientImpl implements Msg { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + this.registerDevFeeInfo = this.registerDevFeeInfo.bind(this); + this.cancelDevFeeInfo = this.cancelDevFeeInfo.bind(this); + this.updateDevFeeInfo = this.updateDevFeeInfo.bind(this); + } + registerDevFeeInfo(request: MsgRegisterDevFeeInfo): Promise { + const data = MsgRegisterDevFeeInfo.encode(request).finish(); + const promise = this.rpc.request("evmos.fees.v1.Msg", "RegisterDevFeeInfo", data); + return promise.then(data => MsgRegisterDevFeeInfoResponse.decode(new BinaryReader(data))); + } + cancelDevFeeInfo(request: MsgCancelDevFeeInfo): Promise { + const data = MsgCancelDevFeeInfo.encode(request).finish(); + const promise = this.rpc.request("evmos.fees.v1.Msg", "CancelDevFeeInfo", data); + return promise.then(data => MsgCancelDevFeeInfoResponse.decode(new BinaryReader(data))); + } + updateDevFeeInfo(request: MsgUpdateDevFeeInfo): Promise { + const data = MsgUpdateDevFeeInfo.encode(request).finish(); + const promise = this.rpc.request("evmos.fees.v1.Msg", "UpdateDevFeeInfo", data); + return promise.then(data => MsgUpdateDevFeeInfoResponse.decode(new BinaryReader(data))); + } +} +export const createClientImpl = (rpc: Rpc) => { + return new MsgClientImpl(rpc); +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/evmos/fees/v1/tx.ts b/__fixtures__/v-next/outputicjsdeps/evmos/fees/v1/tx.ts new file mode 100644 index 0000000000..73c0171c9c --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/evmos/fees/v1/tx.ts @@ -0,0 +1,699 @@ +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "evmos.fees.v1"; +/** MsgRegisterFeesContract defines a message that registers a DevFeeInfo */ +export interface MsgRegisterDevFeeInfo { + /** contract hex address */ + contractAddress: string; + /** + * bech32 address of message sender, must be the same as the origin EOA + * sending the transaction which deploys the contract + */ + deployerAddress: string; + /** bech32 address of account receiving the transaction fees */ + withdrawAddress: string; + /** + * array of nonces from the address path, where the last nonce is + * the nonce that determines the contract's address - it can be an EOA nonce + * or a factory contract nonce + */ + nonces: bigint[]; +} +export interface MsgRegisterDevFeeInfoProtoMsg { + typeUrl: "/evmos.fees.v1.MsgRegisterDevFeeInfo"; + value: Uint8Array; +} +/** MsgRegisterFeesContract defines a message that registers a DevFeeInfo */ +export interface MsgRegisterDevFeeInfoSDKType { + contract_address: string; + deployer_address: string; + withdraw_address: string; + nonces: bigint[]; +} +/** + * MsgRegisterDevFeeInfoResponse defines the MsgRegisterDevFeeInfo response + * type + */ +export interface MsgRegisterDevFeeInfoResponse {} +export interface MsgRegisterDevFeeInfoResponseProtoMsg { + typeUrl: "/evmos.fees.v1.MsgRegisterDevFeeInfoResponse"; + value: Uint8Array; +} +/** + * MsgRegisterDevFeeInfoResponse defines the MsgRegisterDevFeeInfo response + * type + */ +export interface MsgRegisterDevFeeInfoResponseSDKType {} +/** + * MsgCancelDevFeeInfo defines a message that cancels a registered a + * DevFeeInfo + */ +export interface MsgCancelDevFeeInfo { + /** contract hex address */ + contractAddress: string; + /** deployer bech32 address */ + deployerAddress: string; +} +export interface MsgCancelDevFeeInfoProtoMsg { + typeUrl: "/evmos.fees.v1.MsgCancelDevFeeInfo"; + value: Uint8Array; +} +/** + * MsgCancelDevFeeInfo defines a message that cancels a registered a + * DevFeeInfo + */ +export interface MsgCancelDevFeeInfoSDKType { + contract_address: string; + deployer_address: string; +} +/** MsgCancelDevFeeInfoResponse defines the MsgCancelDevFeeInfo response type */ +export interface MsgCancelDevFeeInfoResponse {} +export interface MsgCancelDevFeeInfoResponseProtoMsg { + typeUrl: "/evmos.fees.v1.MsgCancelDevFeeInfoResponse"; + value: Uint8Array; +} +/** MsgCancelDevFeeInfoResponse defines the MsgCancelDevFeeInfo response type */ +export interface MsgCancelDevFeeInfoResponseSDKType {} +/** + * MsgUpdateDevFeeInfo defines a message that updates the withdraw address for + * a registered DevFeeInfo + */ +export interface MsgUpdateDevFeeInfo { + /** contract hex address */ + contractAddress: string; + /** deployer bech32 address */ + deployerAddress: string; + /** new withdraw bech32 address for receiving the transaction fees */ + withdrawAddress: string; +} +export interface MsgUpdateDevFeeInfoProtoMsg { + typeUrl: "/evmos.fees.v1.MsgUpdateDevFeeInfo"; + value: Uint8Array; +} +/** + * MsgUpdateDevFeeInfo defines a message that updates the withdraw address for + * a registered DevFeeInfo + */ +export interface MsgUpdateDevFeeInfoSDKType { + contract_address: string; + deployer_address: string; + withdraw_address: string; +} +/** MsgUpdateDevFeeInfoResponse defines the MsgUpdateDevFeeInfo response type */ +export interface MsgUpdateDevFeeInfoResponse {} +export interface MsgUpdateDevFeeInfoResponseProtoMsg { + typeUrl: "/evmos.fees.v1.MsgUpdateDevFeeInfoResponse"; + value: Uint8Array; +} +/** MsgUpdateDevFeeInfoResponse defines the MsgUpdateDevFeeInfo response type */ +export interface MsgUpdateDevFeeInfoResponseSDKType {} +function createBaseMsgRegisterDevFeeInfo(): MsgRegisterDevFeeInfo { + return { + contractAddress: "", + deployerAddress: "", + withdrawAddress: "", + nonces: [] + }; +} +export const MsgRegisterDevFeeInfo = { + typeUrl: "/evmos.fees.v1.MsgRegisterDevFeeInfo", + encode(message: MsgRegisterDevFeeInfo, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.contractAddress !== undefined) { + writer.uint32(10).string(message.contractAddress); + } + if (message.deployerAddress !== undefined) { + writer.uint32(18).string(message.deployerAddress); + } + if (message.withdrawAddress !== undefined) { + writer.uint32(26).string(message.withdrawAddress); + } + writer.uint32(34).fork(); + for (const v of message.nonces) { + writer.uint64(v); + } + writer.ldelim(); + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgRegisterDevFeeInfo { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgRegisterDevFeeInfo(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.contractAddress = reader.string(); + break; + case 2: + message.deployerAddress = reader.string(); + break; + case 3: + message.withdrawAddress = reader.string(); + break; + case 4: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.nonces.push(reader.uint64()); + } + } else { + message.nonces.push(reader.uint64()); + } + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgRegisterDevFeeInfo { + const obj = createBaseMsgRegisterDevFeeInfo(); + if (isSet(object.contractAddress)) obj.contractAddress = String(object.contractAddress); + if (isSet(object.deployerAddress)) obj.deployerAddress = String(object.deployerAddress); + if (isSet(object.withdrawAddress)) obj.withdrawAddress = String(object.withdrawAddress); + if (Array.isArray(object?.nonces)) obj.nonces = object.nonces.map((e: any) => BigInt(e.toString())); + return obj; + }, + toJSON(message: MsgRegisterDevFeeInfo): JsonSafe { + const obj: any = {}; + message.contractAddress !== undefined && (obj.contractAddress = message.contractAddress); + message.deployerAddress !== undefined && (obj.deployerAddress = message.deployerAddress); + message.withdrawAddress !== undefined && (obj.withdrawAddress = message.withdrawAddress); + if (message.nonces) { + obj.nonces = message.nonces.map(e => (e || BigInt(0)).toString()); + } else { + obj.nonces = []; + } + return obj; + }, + fromPartial(object: DeepPartial): MsgRegisterDevFeeInfo { + const message = createBaseMsgRegisterDevFeeInfo(); + message.contractAddress = object.contractAddress ?? ""; + message.deployerAddress = object.deployerAddress ?? ""; + message.withdrawAddress = object.withdrawAddress ?? ""; + message.nonces = object.nonces?.map(e => BigInt(e.toString())) || []; + return message; + }, + fromSDK(object: MsgRegisterDevFeeInfoSDKType): MsgRegisterDevFeeInfo { + return { + contractAddress: object?.contract_address, + deployerAddress: object?.deployer_address, + withdrawAddress: object?.withdraw_address, + nonces: Array.isArray(object?.nonces) ? object.nonces.map((e: any) => e) : [] + }; + }, + fromSDKJSON(object: any): MsgRegisterDevFeeInfoSDKType { + return { + contract_address: isSet(object.contract_address) ? String(object.contract_address) : "", + deployer_address: isSet(object.deployer_address) ? String(object.deployer_address) : "", + withdraw_address: isSet(object.withdraw_address) ? String(object.withdraw_address) : "", + nonces: Array.isArray(object?.nonces) ? object.nonces.map((e: any) => BigInt(e.toString())) : [] + }; + }, + toSDK(message: MsgRegisterDevFeeInfo): MsgRegisterDevFeeInfoSDKType { + const obj: any = {}; + obj.contract_address = message.contractAddress; + obj.deployer_address = message.deployerAddress; + obj.withdraw_address = message.withdrawAddress; + if (message.nonces) { + obj.nonces = message.nonces.map(e => e); + } else { + obj.nonces = []; + } + return obj; + }, + fromAmino(object: MsgRegisterDevFeeInfoAmino): MsgRegisterDevFeeInfo { + const message = createBaseMsgRegisterDevFeeInfo(); + if (object.contract_address !== undefined && object.contract_address !== null) { + message.contractAddress = object.contract_address; + } + if (object.deployer_address !== undefined && object.deployer_address !== null) { + message.deployerAddress = object.deployer_address; + } + if (object.withdraw_address !== undefined && object.withdraw_address !== null) { + message.withdrawAddress = object.withdraw_address; + } + message.nonces = object.nonces?.map(e => BigInt(e)) || []; + return message; + }, + toAmino(message: MsgRegisterDevFeeInfo): MsgRegisterDevFeeInfoAmino { + const obj: any = {}; + obj.contract_address = message.contractAddress === "" ? undefined : message.contractAddress; + obj.deployer_address = message.deployerAddress === "" ? undefined : message.deployerAddress; + obj.withdraw_address = message.withdrawAddress === "" ? undefined : message.withdrawAddress; + if (message.nonces) { + obj.nonces = message.nonces.map(e => e.toString()); + } else { + obj.nonces = message.nonces; + } + return obj; + }, + fromAminoMsg(object: MsgRegisterDevFeeInfoAminoMsg): MsgRegisterDevFeeInfo { + return MsgRegisterDevFeeInfo.fromAmino(object.value); + }, + fromProtoMsg(message: MsgRegisterDevFeeInfoProtoMsg): MsgRegisterDevFeeInfo { + return MsgRegisterDevFeeInfo.decode(message.value); + }, + toProto(message: MsgRegisterDevFeeInfo): Uint8Array { + return MsgRegisterDevFeeInfo.encode(message).finish(); + }, + toProtoMsg(message: MsgRegisterDevFeeInfo): MsgRegisterDevFeeInfoProtoMsg { + return { + typeUrl: "/evmos.fees.v1.MsgRegisterDevFeeInfo", + value: MsgRegisterDevFeeInfo.encode(message).finish() + }; + } +}; +function createBaseMsgRegisterDevFeeInfoResponse(): MsgRegisterDevFeeInfoResponse { + return {}; +} +export const MsgRegisterDevFeeInfoResponse = { + typeUrl: "/evmos.fees.v1.MsgRegisterDevFeeInfoResponse", + encode(_: MsgRegisterDevFeeInfoResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgRegisterDevFeeInfoResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgRegisterDevFeeInfoResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgRegisterDevFeeInfoResponse { + const obj = createBaseMsgRegisterDevFeeInfoResponse(); + return obj; + }, + toJSON(_: MsgRegisterDevFeeInfoResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): MsgRegisterDevFeeInfoResponse { + const message = createBaseMsgRegisterDevFeeInfoResponse(); + return message; + }, + fromSDK(_: MsgRegisterDevFeeInfoResponseSDKType): MsgRegisterDevFeeInfoResponse { + return {}; + }, + fromSDKJSON(_: any): MsgRegisterDevFeeInfoResponseSDKType { + return {}; + }, + toSDK(_: MsgRegisterDevFeeInfoResponse): MsgRegisterDevFeeInfoResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgRegisterDevFeeInfoResponseAmino): MsgRegisterDevFeeInfoResponse { + const message = createBaseMsgRegisterDevFeeInfoResponse(); + return message; + }, + toAmino(_: MsgRegisterDevFeeInfoResponse): MsgRegisterDevFeeInfoResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgRegisterDevFeeInfoResponseAminoMsg): MsgRegisterDevFeeInfoResponse { + return MsgRegisterDevFeeInfoResponse.fromAmino(object.value); + }, + fromProtoMsg(message: MsgRegisterDevFeeInfoResponseProtoMsg): MsgRegisterDevFeeInfoResponse { + return MsgRegisterDevFeeInfoResponse.decode(message.value); + }, + toProto(message: MsgRegisterDevFeeInfoResponse): Uint8Array { + return MsgRegisterDevFeeInfoResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgRegisterDevFeeInfoResponse): MsgRegisterDevFeeInfoResponseProtoMsg { + return { + typeUrl: "/evmos.fees.v1.MsgRegisterDevFeeInfoResponse", + value: MsgRegisterDevFeeInfoResponse.encode(message).finish() + }; + } +}; +function createBaseMsgCancelDevFeeInfo(): MsgCancelDevFeeInfo { + return { + contractAddress: "", + deployerAddress: "" + }; +} +export const MsgCancelDevFeeInfo = { + typeUrl: "/evmos.fees.v1.MsgCancelDevFeeInfo", + encode(message: MsgCancelDevFeeInfo, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.contractAddress !== undefined) { + writer.uint32(10).string(message.contractAddress); + } + if (message.deployerAddress !== undefined) { + writer.uint32(18).string(message.deployerAddress); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgCancelDevFeeInfo { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgCancelDevFeeInfo(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.contractAddress = reader.string(); + break; + case 2: + message.deployerAddress = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgCancelDevFeeInfo { + const obj = createBaseMsgCancelDevFeeInfo(); + if (isSet(object.contractAddress)) obj.contractAddress = String(object.contractAddress); + if (isSet(object.deployerAddress)) obj.deployerAddress = String(object.deployerAddress); + return obj; + }, + toJSON(message: MsgCancelDevFeeInfo): JsonSafe { + const obj: any = {}; + message.contractAddress !== undefined && (obj.contractAddress = message.contractAddress); + message.deployerAddress !== undefined && (obj.deployerAddress = message.deployerAddress); + return obj; + }, + fromPartial(object: DeepPartial): MsgCancelDevFeeInfo { + const message = createBaseMsgCancelDevFeeInfo(); + message.contractAddress = object.contractAddress ?? ""; + message.deployerAddress = object.deployerAddress ?? ""; + return message; + }, + fromSDK(object: MsgCancelDevFeeInfoSDKType): MsgCancelDevFeeInfo { + return { + contractAddress: object?.contract_address, + deployerAddress: object?.deployer_address + }; + }, + fromSDKJSON(object: any): MsgCancelDevFeeInfoSDKType { + return { + contract_address: isSet(object.contract_address) ? String(object.contract_address) : "", + deployer_address: isSet(object.deployer_address) ? String(object.deployer_address) : "" + }; + }, + toSDK(message: MsgCancelDevFeeInfo): MsgCancelDevFeeInfoSDKType { + const obj: any = {}; + obj.contract_address = message.contractAddress; + obj.deployer_address = message.deployerAddress; + return obj; + }, + fromAmino(object: MsgCancelDevFeeInfoAmino): MsgCancelDevFeeInfo { + const message = createBaseMsgCancelDevFeeInfo(); + if (object.contract_address !== undefined && object.contract_address !== null) { + message.contractAddress = object.contract_address; + } + if (object.deployer_address !== undefined && object.deployer_address !== null) { + message.deployerAddress = object.deployer_address; + } + return message; + }, + toAmino(message: MsgCancelDevFeeInfo): MsgCancelDevFeeInfoAmino { + const obj: any = {}; + obj.contract_address = message.contractAddress === "" ? undefined : message.contractAddress; + obj.deployer_address = message.deployerAddress === "" ? undefined : message.deployerAddress; + return obj; + }, + fromAminoMsg(object: MsgCancelDevFeeInfoAminoMsg): MsgCancelDevFeeInfo { + return MsgCancelDevFeeInfo.fromAmino(object.value); + }, + fromProtoMsg(message: MsgCancelDevFeeInfoProtoMsg): MsgCancelDevFeeInfo { + return MsgCancelDevFeeInfo.decode(message.value); + }, + toProto(message: MsgCancelDevFeeInfo): Uint8Array { + return MsgCancelDevFeeInfo.encode(message).finish(); + }, + toProtoMsg(message: MsgCancelDevFeeInfo): MsgCancelDevFeeInfoProtoMsg { + return { + typeUrl: "/evmos.fees.v1.MsgCancelDevFeeInfo", + value: MsgCancelDevFeeInfo.encode(message).finish() + }; + } +}; +function createBaseMsgCancelDevFeeInfoResponse(): MsgCancelDevFeeInfoResponse { + return {}; +} +export const MsgCancelDevFeeInfoResponse = { + typeUrl: "/evmos.fees.v1.MsgCancelDevFeeInfoResponse", + encode(_: MsgCancelDevFeeInfoResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgCancelDevFeeInfoResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgCancelDevFeeInfoResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgCancelDevFeeInfoResponse { + const obj = createBaseMsgCancelDevFeeInfoResponse(); + return obj; + }, + toJSON(_: MsgCancelDevFeeInfoResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): MsgCancelDevFeeInfoResponse { + const message = createBaseMsgCancelDevFeeInfoResponse(); + return message; + }, + fromSDK(_: MsgCancelDevFeeInfoResponseSDKType): MsgCancelDevFeeInfoResponse { + return {}; + }, + fromSDKJSON(_: any): MsgCancelDevFeeInfoResponseSDKType { + return {}; + }, + toSDK(_: MsgCancelDevFeeInfoResponse): MsgCancelDevFeeInfoResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgCancelDevFeeInfoResponseAmino): MsgCancelDevFeeInfoResponse { + const message = createBaseMsgCancelDevFeeInfoResponse(); + return message; + }, + toAmino(_: MsgCancelDevFeeInfoResponse): MsgCancelDevFeeInfoResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgCancelDevFeeInfoResponseAminoMsg): MsgCancelDevFeeInfoResponse { + return MsgCancelDevFeeInfoResponse.fromAmino(object.value); + }, + fromProtoMsg(message: MsgCancelDevFeeInfoResponseProtoMsg): MsgCancelDevFeeInfoResponse { + return MsgCancelDevFeeInfoResponse.decode(message.value); + }, + toProto(message: MsgCancelDevFeeInfoResponse): Uint8Array { + return MsgCancelDevFeeInfoResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgCancelDevFeeInfoResponse): MsgCancelDevFeeInfoResponseProtoMsg { + return { + typeUrl: "/evmos.fees.v1.MsgCancelDevFeeInfoResponse", + value: MsgCancelDevFeeInfoResponse.encode(message).finish() + }; + } +}; +function createBaseMsgUpdateDevFeeInfo(): MsgUpdateDevFeeInfo { + return { + contractAddress: "", + deployerAddress: "", + withdrawAddress: "" + }; +} +export const MsgUpdateDevFeeInfo = { + typeUrl: "/evmos.fees.v1.MsgUpdateDevFeeInfo", + encode(message: MsgUpdateDevFeeInfo, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.contractAddress !== undefined) { + writer.uint32(10).string(message.contractAddress); + } + if (message.deployerAddress !== undefined) { + writer.uint32(18).string(message.deployerAddress); + } + if (message.withdrawAddress !== undefined) { + writer.uint32(26).string(message.withdrawAddress); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgUpdateDevFeeInfo { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgUpdateDevFeeInfo(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.contractAddress = reader.string(); + break; + case 2: + message.deployerAddress = reader.string(); + break; + case 3: + message.withdrawAddress = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgUpdateDevFeeInfo { + const obj = createBaseMsgUpdateDevFeeInfo(); + if (isSet(object.contractAddress)) obj.contractAddress = String(object.contractAddress); + if (isSet(object.deployerAddress)) obj.deployerAddress = String(object.deployerAddress); + if (isSet(object.withdrawAddress)) obj.withdrawAddress = String(object.withdrawAddress); + return obj; + }, + toJSON(message: MsgUpdateDevFeeInfo): JsonSafe { + const obj: any = {}; + message.contractAddress !== undefined && (obj.contractAddress = message.contractAddress); + message.deployerAddress !== undefined && (obj.deployerAddress = message.deployerAddress); + message.withdrawAddress !== undefined && (obj.withdrawAddress = message.withdrawAddress); + return obj; + }, + fromPartial(object: DeepPartial): MsgUpdateDevFeeInfo { + const message = createBaseMsgUpdateDevFeeInfo(); + message.contractAddress = object.contractAddress ?? ""; + message.deployerAddress = object.deployerAddress ?? ""; + message.withdrawAddress = object.withdrawAddress ?? ""; + return message; + }, + fromSDK(object: MsgUpdateDevFeeInfoSDKType): MsgUpdateDevFeeInfo { + return { + contractAddress: object?.contract_address, + deployerAddress: object?.deployer_address, + withdrawAddress: object?.withdraw_address + }; + }, + fromSDKJSON(object: any): MsgUpdateDevFeeInfoSDKType { + return { + contract_address: isSet(object.contract_address) ? String(object.contract_address) : "", + deployer_address: isSet(object.deployer_address) ? String(object.deployer_address) : "", + withdraw_address: isSet(object.withdraw_address) ? String(object.withdraw_address) : "" + }; + }, + toSDK(message: MsgUpdateDevFeeInfo): MsgUpdateDevFeeInfoSDKType { + const obj: any = {}; + obj.contract_address = message.contractAddress; + obj.deployer_address = message.deployerAddress; + obj.withdraw_address = message.withdrawAddress; + return obj; + }, + fromAmino(object: MsgUpdateDevFeeInfoAmino): MsgUpdateDevFeeInfo { + const message = createBaseMsgUpdateDevFeeInfo(); + if (object.contract_address !== undefined && object.contract_address !== null) { + message.contractAddress = object.contract_address; + } + if (object.deployer_address !== undefined && object.deployer_address !== null) { + message.deployerAddress = object.deployer_address; + } + if (object.withdraw_address !== undefined && object.withdraw_address !== null) { + message.withdrawAddress = object.withdraw_address; + } + return message; + }, + toAmino(message: MsgUpdateDevFeeInfo): MsgUpdateDevFeeInfoAmino { + const obj: any = {}; + obj.contract_address = message.contractAddress === "" ? undefined : message.contractAddress; + obj.deployer_address = message.deployerAddress === "" ? undefined : message.deployerAddress; + obj.withdraw_address = message.withdrawAddress === "" ? undefined : message.withdrawAddress; + return obj; + }, + fromAminoMsg(object: MsgUpdateDevFeeInfoAminoMsg): MsgUpdateDevFeeInfo { + return MsgUpdateDevFeeInfo.fromAmino(object.value); + }, + fromProtoMsg(message: MsgUpdateDevFeeInfoProtoMsg): MsgUpdateDevFeeInfo { + return MsgUpdateDevFeeInfo.decode(message.value); + }, + toProto(message: MsgUpdateDevFeeInfo): Uint8Array { + return MsgUpdateDevFeeInfo.encode(message).finish(); + }, + toProtoMsg(message: MsgUpdateDevFeeInfo): MsgUpdateDevFeeInfoProtoMsg { + return { + typeUrl: "/evmos.fees.v1.MsgUpdateDevFeeInfo", + value: MsgUpdateDevFeeInfo.encode(message).finish() + }; + } +}; +function createBaseMsgUpdateDevFeeInfoResponse(): MsgUpdateDevFeeInfoResponse { + return {}; +} +export const MsgUpdateDevFeeInfoResponse = { + typeUrl: "/evmos.fees.v1.MsgUpdateDevFeeInfoResponse", + encode(_: MsgUpdateDevFeeInfoResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgUpdateDevFeeInfoResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgUpdateDevFeeInfoResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgUpdateDevFeeInfoResponse { + const obj = createBaseMsgUpdateDevFeeInfoResponse(); + return obj; + }, + toJSON(_: MsgUpdateDevFeeInfoResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): MsgUpdateDevFeeInfoResponse { + const message = createBaseMsgUpdateDevFeeInfoResponse(); + return message; + }, + fromSDK(_: MsgUpdateDevFeeInfoResponseSDKType): MsgUpdateDevFeeInfoResponse { + return {}; + }, + fromSDKJSON(_: any): MsgUpdateDevFeeInfoResponseSDKType { + return {}; + }, + toSDK(_: MsgUpdateDevFeeInfoResponse): MsgUpdateDevFeeInfoResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgUpdateDevFeeInfoResponseAmino): MsgUpdateDevFeeInfoResponse { + const message = createBaseMsgUpdateDevFeeInfoResponse(); + return message; + }, + toAmino(_: MsgUpdateDevFeeInfoResponse): MsgUpdateDevFeeInfoResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgUpdateDevFeeInfoResponseAminoMsg): MsgUpdateDevFeeInfoResponse { + return MsgUpdateDevFeeInfoResponse.fromAmino(object.value); + }, + fromProtoMsg(message: MsgUpdateDevFeeInfoResponseProtoMsg): MsgUpdateDevFeeInfoResponse { + return MsgUpdateDevFeeInfoResponse.decode(message.value); + }, + toProto(message: MsgUpdateDevFeeInfoResponse): Uint8Array { + return MsgUpdateDevFeeInfoResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgUpdateDevFeeInfoResponse): MsgUpdateDevFeeInfoResponseProtoMsg { + return { + typeUrl: "/evmos.fees.v1.MsgUpdateDevFeeInfoResponse", + value: MsgUpdateDevFeeInfoResponse.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/evmos/incentives/v1/genesis.ts b/__fixtures__/v-next/outputicjsdeps/evmos/incentives/v1/genesis.ts new file mode 100644 index 0000000000..de48b538ca --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/evmos/incentives/v1/genesis.ts @@ -0,0 +1,330 @@ +import { Incentive, IncentiveSDKType, GasMeter, GasMeterSDKType } from "./incentives.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +import { Decimal } from "@cosmjs/math"; +export const protobufPackage = "evmos.incentives.v1"; +/** GenesisState defines the module's genesis state. */ +export interface GenesisState { + /** module parameters */ + params: Params; + /** active incentives */ + incentives: Incentive[]; + /** active Gasmeters */ + gasMeters: GasMeter[]; +} +export interface GenesisStateProtoMsg { + typeUrl: "/evmos.incentives.v1.GenesisState"; + value: Uint8Array; +} +/** GenesisState defines the module's genesis state. */ +export interface GenesisStateSDKType { + params: ParamsSDKType; + incentives: IncentiveSDKType[]; + gas_meters: GasMeterSDKType[]; +} +/** Params defines the incentives module params */ +export interface Params { + /** parameter to enable incentives */ + enableIncentives: boolean; + /** maximum percentage an incentive can allocate per denomination */ + allocationLimit: string; + /** identifier for the epochs module hooks */ + incentivesEpochIdentifier: string; + /** scaling factor for capping rewards */ + rewardScaler: string; +} +export interface ParamsProtoMsg { + typeUrl: "/evmos.incentives.v1.Params"; + value: Uint8Array; +} +/** Params defines the incentives module params */ +export interface ParamsSDKType { + enable_incentives: boolean; + allocation_limit: string; + incentives_epoch_identifier: string; + reward_scaler: string; +} +function createBaseGenesisState(): GenesisState { + return { + params: Params.fromPartial({}), + incentives: [], + gasMeters: [] + }; +} +export const GenesisState = { + typeUrl: "/evmos.incentives.v1.GenesisState", + encode(message: GenesisState, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.incentives) { + Incentive.encode(v!, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.gasMeters) { + GasMeter.encode(v!, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GenesisState { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGenesisState(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.params = Params.decode(reader, reader.uint32()); + break; + case 2: + message.incentives.push(Incentive.decode(reader, reader.uint32())); + break; + case 3: + message.gasMeters.push(GasMeter.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GenesisState { + const obj = createBaseGenesisState(); + if (isSet(object.params)) obj.params = Params.fromJSON(object.params); + if (Array.isArray(object?.incentives)) obj.incentives = object.incentives.map((e: any) => Incentive.fromJSON(e)); + if (Array.isArray(object?.gasMeters)) obj.gasMeters = object.gasMeters.map((e: any) => GasMeter.fromJSON(e)); + return obj; + }, + toJSON(message: GenesisState): JsonSafe { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); + if (message.incentives) { + obj.incentives = message.incentives.map(e => e ? Incentive.toJSON(e) : undefined); + } else { + obj.incentives = []; + } + if (message.gasMeters) { + obj.gasMeters = message.gasMeters.map(e => e ? GasMeter.toJSON(e) : undefined); + } else { + obj.gasMeters = []; + } + return obj; + }, + fromPartial(object: DeepPartial): GenesisState { + const message = createBaseGenesisState(); + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } + message.incentives = object.incentives?.map(e => Incentive.fromPartial(e)) || []; + message.gasMeters = object.gasMeters?.map(e => GasMeter.fromPartial(e)) || []; + return message; + }, + fromSDK(object: GenesisStateSDKType): GenesisState { + return { + params: object.params ? Params.fromSDK(object.params) : undefined, + incentives: Array.isArray(object?.incentives) ? object.incentives.map((e: any) => Incentive.fromSDK(e)) : [], + gasMeters: Array.isArray(object?.gas_meters) ? object.gas_meters.map((e: any) => GasMeter.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): GenesisStateSDKType { + return { + params: isSet(object.params) ? Params.fromSDKJSON(object.params) : undefined, + incentives: Array.isArray(object?.incentives) ? object.incentives.map((e: any) => Incentive.fromSDKJSON(e)) : [], + gas_meters: Array.isArray(object?.gas_meters) ? object.gas_meters.map((e: any) => GasMeter.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: GenesisState): GenesisStateSDKType { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toSDK(message.params) : undefined); + if (message.incentives) { + obj.incentives = message.incentives.map(e => e ? Incentive.toSDK(e) : undefined); + } else { + obj.incentives = []; + } + if (message.gasMeters) { + obj.gas_meters = message.gasMeters.map(e => e ? GasMeter.toSDK(e) : undefined); + } else { + obj.gas_meters = []; + } + return obj; + }, + fromAmino(object: GenesisStateAmino): GenesisState { + const message = createBaseGenesisState(); + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromAmino(object.params); + } + message.incentives = object.incentives?.map(e => Incentive.fromAmino(e)) || []; + message.gasMeters = object.gas_meters?.map(e => GasMeter.fromAmino(e)) || []; + return message; + }, + toAmino(message: GenesisState): GenesisStateAmino { + const obj: any = {}; + obj.params = message.params ? Params.toAmino(message.params) : undefined; + if (message.incentives) { + obj.incentives = message.incentives.map(e => e ? Incentive.toAmino(e) : undefined); + } else { + obj.incentives = message.incentives; + } + if (message.gasMeters) { + obj.gas_meters = message.gasMeters.map(e => e ? GasMeter.toAmino(e) : undefined); + } else { + obj.gas_meters = message.gasMeters; + } + return obj; + }, + fromAminoMsg(object: GenesisStateAminoMsg): GenesisState { + return GenesisState.fromAmino(object.value); + }, + fromProtoMsg(message: GenesisStateProtoMsg): GenesisState { + return GenesisState.decode(message.value); + }, + toProto(message: GenesisState): Uint8Array { + return GenesisState.encode(message).finish(); + }, + toProtoMsg(message: GenesisState): GenesisStateProtoMsg { + return { + typeUrl: "/evmos.incentives.v1.GenesisState", + value: GenesisState.encode(message).finish() + }; + } +}; +function createBaseParams(): Params { + return { + enableIncentives: false, + allocationLimit: "", + incentivesEpochIdentifier: "", + rewardScaler: "" + }; +} +export const Params = { + typeUrl: "/evmos.incentives.v1.Params", + encode(message: Params, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.enableIncentives !== undefined) { + writer.uint32(8).bool(message.enableIncentives); + } + if (message.allocationLimit !== undefined) { + writer.uint32(18).string(Decimal.fromUserInput(message.allocationLimit, 18).atomics); + } + if (message.incentivesEpochIdentifier !== undefined) { + writer.uint32(26).string(message.incentivesEpochIdentifier); + } + if (message.rewardScaler !== undefined) { + writer.uint32(34).string(Decimal.fromUserInput(message.rewardScaler, 18).atomics); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Params { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseParams(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.enableIncentives = reader.bool(); + break; + case 2: + message.allocationLimit = Decimal.fromAtomics(reader.string(), 18).toString(); + break; + case 3: + message.incentivesEpochIdentifier = reader.string(); + break; + case 4: + message.rewardScaler = Decimal.fromAtomics(reader.string(), 18).toString(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Params { + const obj = createBaseParams(); + if (isSet(object.enableIncentives)) obj.enableIncentives = Boolean(object.enableIncentives); + if (isSet(object.allocationLimit)) obj.allocationLimit = String(object.allocationLimit); + if (isSet(object.incentivesEpochIdentifier)) obj.incentivesEpochIdentifier = String(object.incentivesEpochIdentifier); + if (isSet(object.rewardScaler)) obj.rewardScaler = String(object.rewardScaler); + return obj; + }, + toJSON(message: Params): JsonSafe { + const obj: any = {}; + message.enableIncentives !== undefined && (obj.enableIncentives = message.enableIncentives); + message.allocationLimit !== undefined && (obj.allocationLimit = message.allocationLimit); + message.incentivesEpochIdentifier !== undefined && (obj.incentivesEpochIdentifier = message.incentivesEpochIdentifier); + message.rewardScaler !== undefined && (obj.rewardScaler = message.rewardScaler); + return obj; + }, + fromPartial(object: DeepPartial): Params { + const message = createBaseParams(); + message.enableIncentives = object.enableIncentives ?? false; + message.allocationLimit = object.allocationLimit ?? ""; + message.incentivesEpochIdentifier = object.incentivesEpochIdentifier ?? ""; + message.rewardScaler = object.rewardScaler ?? ""; + return message; + }, + fromSDK(object: ParamsSDKType): Params { + return { + enableIncentives: object?.enable_incentives, + allocationLimit: object?.allocation_limit, + incentivesEpochIdentifier: object?.incentives_epoch_identifier, + rewardScaler: object?.reward_scaler + }; + }, + fromSDKJSON(object: any): ParamsSDKType { + return { + enable_incentives: isSet(object.enable_incentives) ? Boolean(object.enable_incentives) : false, + allocation_limit: isSet(object.allocation_limit) ? String(object.allocation_limit) : "", + incentives_epoch_identifier: isSet(object.incentives_epoch_identifier) ? String(object.incentives_epoch_identifier) : "", + reward_scaler: isSet(object.reward_scaler) ? String(object.reward_scaler) : "" + }; + }, + toSDK(message: Params): ParamsSDKType { + const obj: any = {}; + obj.enable_incentives = message.enableIncentives; + obj.allocation_limit = message.allocationLimit; + obj.incentives_epoch_identifier = message.incentivesEpochIdentifier; + obj.reward_scaler = message.rewardScaler; + return obj; + }, + fromAmino(object: ParamsAmino): Params { + const message = createBaseParams(); + if (object.enable_incentives !== undefined && object.enable_incentives !== null) { + message.enableIncentives = object.enable_incentives; + } + if (object.allocation_limit !== undefined && object.allocation_limit !== null) { + message.allocationLimit = object.allocation_limit; + } + if (object.incentives_epoch_identifier !== undefined && object.incentives_epoch_identifier !== null) { + message.incentivesEpochIdentifier = object.incentives_epoch_identifier; + } + if (object.reward_scaler !== undefined && object.reward_scaler !== null) { + message.rewardScaler = object.reward_scaler; + } + return message; + }, + toAmino(message: Params): ParamsAmino { + const obj: any = {}; + obj.enable_incentives = message.enableIncentives === false ? undefined : message.enableIncentives; + obj.allocation_limit = message.allocationLimit === "" ? undefined : message.allocationLimit; + obj.incentives_epoch_identifier = message.incentivesEpochIdentifier === "" ? undefined : message.incentivesEpochIdentifier; + obj.reward_scaler = message.rewardScaler === "" ? undefined : message.rewardScaler; + return obj; + }, + fromAminoMsg(object: ParamsAminoMsg): Params { + return Params.fromAmino(object.value); + }, + fromProtoMsg(message: ParamsProtoMsg): Params { + return Params.decode(message.value); + }, + toProto(message: Params): Uint8Array { + return Params.encode(message).finish(); + }, + toProtoMsg(message: Params): ParamsProtoMsg { + return { + typeUrl: "/evmos.incentives.v1.Params", + value: Params.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/evmos/incentives/v1/incentives.ts b/__fixtures__/v-next/outputicjsdeps/evmos/incentives/v1/incentives.ts new file mode 100644 index 0000000000..10773706f2 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/evmos/incentives/v1/incentives.ts @@ -0,0 +1,680 @@ +import { DecCoin, DecCoinSDKType } from "../../../cosmos/base/v1beta1/coin.js"; +import { Timestamp, TimestampSDKType } from "../../../google/protobuf/timestamp.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { toTimestamp, fromTimestamp, isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "evmos.incentives.v1"; +/** + * Incentive defines an instance that organizes distribution conditions for a + * given smart contract + */ +export interface Incentive { + /** contract address */ + contract: string; + /** denoms and percentage of rewards to be allocated */ + allocations: DecCoin[]; + /** number of remaining epochs */ + epochs: number; + /** distribution start time */ + startTime: Date; + /** cumulative gas spent by all gasmeters of the incentive during the epoch */ + totalGas: bigint; +} +export interface IncentiveProtoMsg { + typeUrl: "/evmos.incentives.v1.Incentive"; + value: Uint8Array; +} +/** + * Incentive defines an instance that organizes distribution conditions for a + * given smart contract + */ +export interface IncentiveSDKType { + contract: string; + allocations: DecCoinSDKType[]; + epochs: number; + start_time: Date; + total_gas: bigint; +} +/** GasMeter tracks the cumulative gas spent per participant in one epoch */ +export interface GasMeter { + /** hex address of the incentivized contract */ + contract: string; + /** participant address that interacts with the incentive */ + participant: string; + /** cumulative gas spent during the epoch */ + cumulativeGas: bigint; +} +export interface GasMeterProtoMsg { + typeUrl: "/evmos.incentives.v1.GasMeter"; + value: Uint8Array; +} +/** GasMeter tracks the cumulative gas spent per participant in one epoch */ +export interface GasMeterSDKType { + contract: string; + participant: string; + cumulative_gas: bigint; +} +/** RegisterIncentiveProposal is a gov Content type to register an incentive */ +export interface RegisterIncentiveProposal { + /** title of the proposal */ + title: string; + /** proposal description */ + description: string; + /** contract address */ + contract: string; + /** denoms and percentage of rewards to be allocated */ + allocations: DecCoin[]; + /** number of remaining epochs */ + epochs: number; +} +export interface RegisterIncentiveProposalProtoMsg { + typeUrl: "/evmos.incentives.v1.RegisterIncentiveProposal"; + value: Uint8Array; +} +/** RegisterIncentiveProposal is a gov Content type to register an incentive */ +export interface RegisterIncentiveProposalSDKType { + title: string; + description: string; + contract: string; + allocations: DecCoinSDKType[]; + epochs: number; +} +/** CancelIncentiveProposal is a gov Content type to cancel an incentive */ +export interface CancelIncentiveProposal { + /** title of the proposal */ + title: string; + /** proposal description */ + description: string; + /** contract address */ + contract: string; +} +export interface CancelIncentiveProposalProtoMsg { + typeUrl: "/evmos.incentives.v1.CancelIncentiveProposal"; + value: Uint8Array; +} +/** CancelIncentiveProposal is a gov Content type to cancel an incentive */ +export interface CancelIncentiveProposalSDKType { + title: string; + description: string; + contract: string; +} +function createBaseIncentive(): Incentive { + return { + contract: "", + allocations: [], + epochs: 0, + startTime: new Date(), + totalGas: BigInt(0) + }; +} +export const Incentive = { + typeUrl: "/evmos.incentives.v1.Incentive", + encode(message: Incentive, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.contract !== undefined) { + writer.uint32(10).string(message.contract); + } + for (const v of message.allocations) { + DecCoin.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.epochs !== undefined) { + writer.uint32(24).uint32(message.epochs); + } + if (message.startTime !== undefined) { + Timestamp.encode(toTimestamp(message.startTime), writer.uint32(34).fork()).ldelim(); + } + if (message.totalGas !== undefined) { + writer.uint32(40).uint64(message.totalGas); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Incentive { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseIncentive(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.contract = reader.string(); + break; + case 2: + message.allocations.push(DecCoin.decode(reader, reader.uint32())); + break; + case 3: + message.epochs = reader.uint32(); + break; + case 4: + message.startTime = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + break; + case 5: + message.totalGas = reader.uint64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Incentive { + const obj = createBaseIncentive(); + if (isSet(object.contract)) obj.contract = String(object.contract); + if (Array.isArray(object?.allocations)) obj.allocations = object.allocations.map((e: any) => DecCoin.fromJSON(e)); + if (isSet(object.epochs)) obj.epochs = Number(object.epochs); + if (isSet(object.startTime)) obj.startTime = new Date(object.startTime); + if (isSet(object.totalGas)) obj.totalGas = BigInt(object.totalGas.toString()); + return obj; + }, + toJSON(message: Incentive): JsonSafe { + const obj: any = {}; + message.contract !== undefined && (obj.contract = message.contract); + if (message.allocations) { + obj.allocations = message.allocations.map(e => e ? DecCoin.toJSON(e) : undefined); + } else { + obj.allocations = []; + } + message.epochs !== undefined && (obj.epochs = Math.round(message.epochs)); + message.startTime !== undefined && (obj.startTime = message.startTime.toISOString()); + message.totalGas !== undefined && (obj.totalGas = (message.totalGas || BigInt(0)).toString()); + return obj; + }, + fromPartial(object: DeepPartial): Incentive { + const message = createBaseIncentive(); + message.contract = object.contract ?? ""; + message.allocations = object.allocations?.map(e => DecCoin.fromPartial(e)) || []; + message.epochs = object.epochs ?? 0; + message.startTime = object.startTime ?? undefined; + if (object.totalGas !== undefined && object.totalGas !== null) { + message.totalGas = BigInt(object.totalGas.toString()); + } + return message; + }, + fromSDK(object: IncentiveSDKType): Incentive { + return { + contract: object?.contract, + allocations: Array.isArray(object?.allocations) ? object.allocations.map((e: any) => DecCoin.fromSDK(e)) : [], + epochs: object?.epochs, + startTime: object.start_time ?? undefined, + totalGas: object?.total_gas + }; + }, + fromSDKJSON(object: any): IncentiveSDKType { + return { + contract: isSet(object.contract) ? String(object.contract) : "", + allocations: Array.isArray(object?.allocations) ? object.allocations.map((e: any) => DecCoin.fromSDKJSON(e)) : [], + epochs: isSet(object.epochs) ? Number(object.epochs) : 0, + start_time: isSet(object.start_time) ? new Date(object.start_time) : undefined, + total_gas: isSet(object.total_gas) ? BigInt(object.total_gas.toString()) : BigInt(0) + }; + }, + toSDK(message: Incentive): IncentiveSDKType { + const obj: any = {}; + obj.contract = message.contract; + if (message.allocations) { + obj.allocations = message.allocations.map(e => e ? DecCoin.toSDK(e) : undefined); + } else { + obj.allocations = []; + } + obj.epochs = message.epochs; + message.startTime !== undefined && (obj.start_time = message.startTime ?? undefined); + obj.total_gas = message.totalGas; + return obj; + }, + fromAmino(object: IncentiveAmino): Incentive { + const message = createBaseIncentive(); + if (object.contract !== undefined && object.contract !== null) { + message.contract = object.contract; + } + message.allocations = object.allocations?.map(e => DecCoin.fromAmino(e)) || []; + if (object.epochs !== undefined && object.epochs !== null) { + message.epochs = object.epochs; + } + if (object.start_time !== undefined && object.start_time !== null) { + message.startTime = fromTimestamp(Timestamp.fromAmino(object.start_time)); + } + if (object.total_gas !== undefined && object.total_gas !== null) { + message.totalGas = BigInt(object.total_gas); + } + return message; + }, + toAmino(message: Incentive): IncentiveAmino { + const obj: any = {}; + obj.contract = message.contract === "" ? undefined : message.contract; + if (message.allocations) { + obj.allocations = message.allocations.map(e => e ? DecCoin.toAmino(e) : undefined); + } else { + obj.allocations = message.allocations; + } + obj.epochs = message.epochs === 0 ? undefined : message.epochs; + obj.start_time = message.startTime ? Timestamp.toAmino(toTimestamp(message.startTime)) : undefined; + obj.total_gas = message.totalGas !== BigInt(0) ? message.totalGas?.toString() : undefined; + return obj; + }, + fromAminoMsg(object: IncentiveAminoMsg): Incentive { + return Incentive.fromAmino(object.value); + }, + fromProtoMsg(message: IncentiveProtoMsg): Incentive { + return Incentive.decode(message.value); + }, + toProto(message: Incentive): Uint8Array { + return Incentive.encode(message).finish(); + }, + toProtoMsg(message: Incentive): IncentiveProtoMsg { + return { + typeUrl: "/evmos.incentives.v1.Incentive", + value: Incentive.encode(message).finish() + }; + } +}; +function createBaseGasMeter(): GasMeter { + return { + contract: "", + participant: "", + cumulativeGas: BigInt(0) + }; +} +export const GasMeter = { + typeUrl: "/evmos.incentives.v1.GasMeter", + encode(message: GasMeter, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.contract !== undefined) { + writer.uint32(10).string(message.contract); + } + if (message.participant !== undefined) { + writer.uint32(18).string(message.participant); + } + if (message.cumulativeGas !== undefined) { + writer.uint32(24).uint64(message.cumulativeGas); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GasMeter { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGasMeter(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.contract = reader.string(); + break; + case 2: + message.participant = reader.string(); + break; + case 3: + message.cumulativeGas = reader.uint64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GasMeter { + const obj = createBaseGasMeter(); + if (isSet(object.contract)) obj.contract = String(object.contract); + if (isSet(object.participant)) obj.participant = String(object.participant); + if (isSet(object.cumulativeGas)) obj.cumulativeGas = BigInt(object.cumulativeGas.toString()); + return obj; + }, + toJSON(message: GasMeter): JsonSafe { + const obj: any = {}; + message.contract !== undefined && (obj.contract = message.contract); + message.participant !== undefined && (obj.participant = message.participant); + message.cumulativeGas !== undefined && (obj.cumulativeGas = (message.cumulativeGas || BigInt(0)).toString()); + return obj; + }, + fromPartial(object: DeepPartial): GasMeter { + const message = createBaseGasMeter(); + message.contract = object.contract ?? ""; + message.participant = object.participant ?? ""; + if (object.cumulativeGas !== undefined && object.cumulativeGas !== null) { + message.cumulativeGas = BigInt(object.cumulativeGas.toString()); + } + return message; + }, + fromSDK(object: GasMeterSDKType): GasMeter { + return { + contract: object?.contract, + participant: object?.participant, + cumulativeGas: object?.cumulative_gas + }; + }, + fromSDKJSON(object: any): GasMeterSDKType { + return { + contract: isSet(object.contract) ? String(object.contract) : "", + participant: isSet(object.participant) ? String(object.participant) : "", + cumulative_gas: isSet(object.cumulative_gas) ? BigInt(object.cumulative_gas.toString()) : BigInt(0) + }; + }, + toSDK(message: GasMeter): GasMeterSDKType { + const obj: any = {}; + obj.contract = message.contract; + obj.participant = message.participant; + obj.cumulative_gas = message.cumulativeGas; + return obj; + }, + fromAmino(object: GasMeterAmino): GasMeter { + const message = createBaseGasMeter(); + if (object.contract !== undefined && object.contract !== null) { + message.contract = object.contract; + } + if (object.participant !== undefined && object.participant !== null) { + message.participant = object.participant; + } + if (object.cumulative_gas !== undefined && object.cumulative_gas !== null) { + message.cumulativeGas = BigInt(object.cumulative_gas); + } + return message; + }, + toAmino(message: GasMeter): GasMeterAmino { + const obj: any = {}; + obj.contract = message.contract === "" ? undefined : message.contract; + obj.participant = message.participant === "" ? undefined : message.participant; + obj.cumulative_gas = message.cumulativeGas !== BigInt(0) ? message.cumulativeGas?.toString() : undefined; + return obj; + }, + fromAminoMsg(object: GasMeterAminoMsg): GasMeter { + return GasMeter.fromAmino(object.value); + }, + fromProtoMsg(message: GasMeterProtoMsg): GasMeter { + return GasMeter.decode(message.value); + }, + toProto(message: GasMeter): Uint8Array { + return GasMeter.encode(message).finish(); + }, + toProtoMsg(message: GasMeter): GasMeterProtoMsg { + return { + typeUrl: "/evmos.incentives.v1.GasMeter", + value: GasMeter.encode(message).finish() + }; + } +}; +function createBaseRegisterIncentiveProposal(): RegisterIncentiveProposal { + return { + title: "", + description: "", + contract: "", + allocations: [], + epochs: 0 + }; +} +export const RegisterIncentiveProposal = { + typeUrl: "/evmos.incentives.v1.RegisterIncentiveProposal", + encode(message: RegisterIncentiveProposal, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.title !== undefined) { + writer.uint32(10).string(message.title); + } + if (message.description !== undefined) { + writer.uint32(18).string(message.description); + } + if (message.contract !== undefined) { + writer.uint32(26).string(message.contract); + } + for (const v of message.allocations) { + DecCoin.encode(v!, writer.uint32(34).fork()).ldelim(); + } + if (message.epochs !== undefined) { + writer.uint32(40).uint32(message.epochs); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): RegisterIncentiveProposal { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseRegisterIncentiveProposal(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.title = reader.string(); + break; + case 2: + message.description = reader.string(); + break; + case 3: + message.contract = reader.string(); + break; + case 4: + message.allocations.push(DecCoin.decode(reader, reader.uint32())); + break; + case 5: + message.epochs = reader.uint32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): RegisterIncentiveProposal { + const obj = createBaseRegisterIncentiveProposal(); + if (isSet(object.title)) obj.title = String(object.title); + if (isSet(object.description)) obj.description = String(object.description); + if (isSet(object.contract)) obj.contract = String(object.contract); + if (Array.isArray(object?.allocations)) obj.allocations = object.allocations.map((e: any) => DecCoin.fromJSON(e)); + if (isSet(object.epochs)) obj.epochs = Number(object.epochs); + return obj; + }, + toJSON(message: RegisterIncentiveProposal): JsonSafe { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && (obj.description = message.description); + message.contract !== undefined && (obj.contract = message.contract); + if (message.allocations) { + obj.allocations = message.allocations.map(e => e ? DecCoin.toJSON(e) : undefined); + } else { + obj.allocations = []; + } + message.epochs !== undefined && (obj.epochs = Math.round(message.epochs)); + return obj; + }, + fromPartial(object: DeepPartial): RegisterIncentiveProposal { + const message = createBaseRegisterIncentiveProposal(); + message.title = object.title ?? ""; + message.description = object.description ?? ""; + message.contract = object.contract ?? ""; + message.allocations = object.allocations?.map(e => DecCoin.fromPartial(e)) || []; + message.epochs = object.epochs ?? 0; + return message; + }, + fromSDK(object: RegisterIncentiveProposalSDKType): RegisterIncentiveProposal { + return { + title: object?.title, + description: object?.description, + contract: object?.contract, + allocations: Array.isArray(object?.allocations) ? object.allocations.map((e: any) => DecCoin.fromSDK(e)) : [], + epochs: object?.epochs + }; + }, + fromSDKJSON(object: any): RegisterIncentiveProposalSDKType { + return { + title: isSet(object.title) ? String(object.title) : "", + description: isSet(object.description) ? String(object.description) : "", + contract: isSet(object.contract) ? String(object.contract) : "", + allocations: Array.isArray(object?.allocations) ? object.allocations.map((e: any) => DecCoin.fromSDKJSON(e)) : [], + epochs: isSet(object.epochs) ? Number(object.epochs) : 0 + }; + }, + toSDK(message: RegisterIncentiveProposal): RegisterIncentiveProposalSDKType { + const obj: any = {}; + obj.title = message.title; + obj.description = message.description; + obj.contract = message.contract; + if (message.allocations) { + obj.allocations = message.allocations.map(e => e ? DecCoin.toSDK(e) : undefined); + } else { + obj.allocations = []; + } + obj.epochs = message.epochs; + return obj; + }, + fromAmino(object: RegisterIncentiveProposalAmino): RegisterIncentiveProposal { + const message = createBaseRegisterIncentiveProposal(); + if (object.title !== undefined && object.title !== null) { + message.title = object.title; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } + if (object.contract !== undefined && object.contract !== null) { + message.contract = object.contract; + } + message.allocations = object.allocations?.map(e => DecCoin.fromAmino(e)) || []; + if (object.epochs !== undefined && object.epochs !== null) { + message.epochs = object.epochs; + } + return message; + }, + toAmino(message: RegisterIncentiveProposal): RegisterIncentiveProposalAmino { + const obj: any = {}; + obj.title = message.title === "" ? undefined : message.title; + obj.description = message.description === "" ? undefined : message.description; + obj.contract = message.contract === "" ? undefined : message.contract; + if (message.allocations) { + obj.allocations = message.allocations.map(e => e ? DecCoin.toAmino(e) : undefined); + } else { + obj.allocations = message.allocations; + } + obj.epochs = message.epochs === 0 ? undefined : message.epochs; + return obj; + }, + fromAminoMsg(object: RegisterIncentiveProposalAminoMsg): RegisterIncentiveProposal { + return RegisterIncentiveProposal.fromAmino(object.value); + }, + fromProtoMsg(message: RegisterIncentiveProposalProtoMsg): RegisterIncentiveProposal { + return RegisterIncentiveProposal.decode(message.value); + }, + toProto(message: RegisterIncentiveProposal): Uint8Array { + return RegisterIncentiveProposal.encode(message).finish(); + }, + toProtoMsg(message: RegisterIncentiveProposal): RegisterIncentiveProposalProtoMsg { + return { + typeUrl: "/evmos.incentives.v1.RegisterIncentiveProposal", + value: RegisterIncentiveProposal.encode(message).finish() + }; + } +}; +function createBaseCancelIncentiveProposal(): CancelIncentiveProposal { + return { + title: "", + description: "", + contract: "" + }; +} +export const CancelIncentiveProposal = { + typeUrl: "/evmos.incentives.v1.CancelIncentiveProposal", + encode(message: CancelIncentiveProposal, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.title !== undefined) { + writer.uint32(10).string(message.title); + } + if (message.description !== undefined) { + writer.uint32(18).string(message.description); + } + if (message.contract !== undefined) { + writer.uint32(26).string(message.contract); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): CancelIncentiveProposal { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCancelIncentiveProposal(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.title = reader.string(); + break; + case 2: + message.description = reader.string(); + break; + case 3: + message.contract = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): CancelIncentiveProposal { + const obj = createBaseCancelIncentiveProposal(); + if (isSet(object.title)) obj.title = String(object.title); + if (isSet(object.description)) obj.description = String(object.description); + if (isSet(object.contract)) obj.contract = String(object.contract); + return obj; + }, + toJSON(message: CancelIncentiveProposal): JsonSafe { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && (obj.description = message.description); + message.contract !== undefined && (obj.contract = message.contract); + return obj; + }, + fromPartial(object: DeepPartial): CancelIncentiveProposal { + const message = createBaseCancelIncentiveProposal(); + message.title = object.title ?? ""; + message.description = object.description ?? ""; + message.contract = object.contract ?? ""; + return message; + }, + fromSDK(object: CancelIncentiveProposalSDKType): CancelIncentiveProposal { + return { + title: object?.title, + description: object?.description, + contract: object?.contract + }; + }, + fromSDKJSON(object: any): CancelIncentiveProposalSDKType { + return { + title: isSet(object.title) ? String(object.title) : "", + description: isSet(object.description) ? String(object.description) : "", + contract: isSet(object.contract) ? String(object.contract) : "" + }; + }, + toSDK(message: CancelIncentiveProposal): CancelIncentiveProposalSDKType { + const obj: any = {}; + obj.title = message.title; + obj.description = message.description; + obj.contract = message.contract; + return obj; + }, + fromAmino(object: CancelIncentiveProposalAmino): CancelIncentiveProposal { + const message = createBaseCancelIncentiveProposal(); + if (object.title !== undefined && object.title !== null) { + message.title = object.title; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } + if (object.contract !== undefined && object.contract !== null) { + message.contract = object.contract; + } + return message; + }, + toAmino(message: CancelIncentiveProposal): CancelIncentiveProposalAmino { + const obj: any = {}; + obj.title = message.title === "" ? undefined : message.title; + obj.description = message.description === "" ? undefined : message.description; + obj.contract = message.contract === "" ? undefined : message.contract; + return obj; + }, + fromAminoMsg(object: CancelIncentiveProposalAminoMsg): CancelIncentiveProposal { + return CancelIncentiveProposal.fromAmino(object.value); + }, + fromProtoMsg(message: CancelIncentiveProposalProtoMsg): CancelIncentiveProposal { + return CancelIncentiveProposal.decode(message.value); + }, + toProto(message: CancelIncentiveProposal): Uint8Array { + return CancelIncentiveProposal.encode(message).finish(); + }, + toProtoMsg(message: CancelIncentiveProposal): CancelIncentiveProposalProtoMsg { + return { + typeUrl: "/evmos.incentives.v1.CancelIncentiveProposal", + value: CancelIncentiveProposal.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/evmos/incentives/v1/query.lcd.ts b/__fixtures__/v-next/outputicjsdeps/evmos/incentives/v1/query.lcd.ts new file mode 100644 index 0000000000..db8fb0ef56 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/evmos/incentives/v1/query.lcd.ts @@ -0,0 +1,82 @@ +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../../cosmos/base/query/v1beta1/pagination.js"; +import { Incentive, IncentiveSDKType, GasMeter, GasMeterSDKType } from "./incentives.js"; +import { DecCoin, DecCoinSDKType } from "../../../cosmos/base/v1beta1/coin.js"; +import { Params, ParamsSDKType } from "./genesis.js"; +import { setPaginationParams } from "../../../helpers.js"; +import { LCDClient } from "@cosmology/lcd"; +import { QueryIncentivesRequest, QueryIncentivesRequestSDKType, QueryIncentivesResponse, QueryIncentivesResponseSDKType, QueryIncentiveRequest, QueryIncentiveRequestSDKType, QueryIncentiveResponse, QueryIncentiveResponseSDKType, QueryGasMetersRequest, QueryGasMetersRequestSDKType, QueryGasMetersResponse, QueryGasMetersResponseSDKType, QueryGasMeterRequest, QueryGasMeterRequestSDKType, QueryGasMeterResponse, QueryGasMeterResponseSDKType, QueryAllocationMetersRequest, QueryAllocationMetersRequestSDKType, QueryAllocationMetersResponse, QueryAllocationMetersResponseSDKType, QueryAllocationMeterRequest, QueryAllocationMeterRequestSDKType, QueryAllocationMeterResponse, QueryAllocationMeterResponseSDKType, QueryParamsRequest, QueryParamsRequestSDKType, QueryParamsResponse, QueryParamsResponseSDKType } from "./query.js"; +export class LCDQueryClient { + req: LCDClient; + constructor({ + requestClient + }: { + requestClient: LCDClient; + }) { + this.req = requestClient; + this.incentives = this.incentives.bind(this); + this.incentive = this.incentive.bind(this); + this.gasMeters = this.gasMeters.bind(this); + this.gasMeter = this.gasMeter.bind(this); + this.allocationMeters = this.allocationMeters.bind(this); + this.allocationMeter = this.allocationMeter.bind(this); + this.params = this.params.bind(this); + } + /* Incentives retrieves registered incentives */ + async incentives(params: QueryIncentivesRequest = { + pagination: PageRequest.fromPartial({}) + }): Promise { + const options: any = { + params: {} + }; + if (typeof params?.pagination !== "undefined") { + setPaginationParams(options, params.pagination); + } + const endpoint = `evmos/incentives/v1/incentives`; + return QueryIncentivesResponse.fromSDKJSON(await this.req.get(endpoint, options)); + } + /* Incentive retrieves a registered incentive */ + async incentive(params: QueryIncentiveRequest): Promise { + const endpoint = `evmos/incentives/v1/incentives/${params.contract}`; + return QueryIncentiveResponse.fromSDKJSON(await this.req.get(endpoint)); + } + /* GasMeters retrieves active gas meters for a given contract */ + async gasMeters(params: QueryGasMetersRequest): Promise { + const options: any = { + params: {} + }; + if (typeof params?.pagination !== "undefined") { + setPaginationParams(options, params.pagination); + } + const endpoint = `evmos/incentives/v1/gas_meters/${params.contract}`; + return QueryGasMetersResponse.fromSDKJSON(await this.req.get(endpoint, options)); + } + /* GasMeter Retrieves a active gas meter */ + async gasMeter(params: QueryGasMeterRequest): Promise { + const endpoint = `evmos/incentives/v1/gas_meters/${params.contract}/${params.participant}`; + return QueryGasMeterResponse.fromSDKJSON(await this.req.get(endpoint)); + } + /* AllocationMeters retrieves active allocation meters for a given + denomination */ + async allocationMeters(params: QueryAllocationMetersRequest = { + pagination: PageRequest.fromPartial({}) + }): Promise { + const options: any = { + params: {} + }; + if (typeof params?.pagination !== "undefined") { + setPaginationParams(options, params.pagination); + } + const endpoint = `evmos/incentives/v1/allocation_meters`; + return QueryAllocationMetersResponse.fromSDKJSON(await this.req.get(endpoint, options)); + } + /* AllocationMeter Retrieves a active gas meter */ + async allocationMeter(params: QueryAllocationMeterRequest): Promise { + const endpoint = `evmos/incentives/v1/allocation_meters/${params.denom}`; + return QueryAllocationMeterResponse.fromSDKJSON(await this.req.get(endpoint)); + } + /* Params retrieves the incentives module params */ + async params(_params: QueryParamsRequest = {}): Promise { + const endpoint = `evmos/incentives/v1/params`; + return QueryParamsResponse.fromSDKJSON(await this.req.get(endpoint)); + } +} \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/evmos/incentives/v1/query.rpc.Query.ts b/__fixtures__/v-next/outputicjsdeps/evmos/incentives/v1/query.rpc.Query.ts new file mode 100644 index 0000000000..fbb2185e21 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/evmos/incentives/v1/query.rpc.Query.ts @@ -0,0 +1,107 @@ +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../../cosmos/base/query/v1beta1/pagination.js"; +import { Incentive, IncentiveSDKType, GasMeter, GasMeterSDKType } from "./incentives.js"; +import { DecCoin, DecCoinSDKType } from "../../../cosmos/base/v1beta1/coin.js"; +import { Params, ParamsSDKType } from "./genesis.js"; +import { Rpc } from "../../../helpers.js"; +import { BinaryReader } from "../../../binary.js"; +import { QueryClient, createProtobufRpcClient } from "@cosmjs/stargate"; +import { QueryIncentivesRequest, QueryIncentivesRequestSDKType, QueryIncentivesResponse, QueryIncentivesResponseSDKType, QueryIncentiveRequest, QueryIncentiveRequestSDKType, QueryIncentiveResponse, QueryIncentiveResponseSDKType, QueryGasMetersRequest, QueryGasMetersRequestSDKType, QueryGasMetersResponse, QueryGasMetersResponseSDKType, QueryGasMeterRequest, QueryGasMeterRequestSDKType, QueryGasMeterResponse, QueryGasMeterResponseSDKType, QueryAllocationMetersRequest, QueryAllocationMetersRequestSDKType, QueryAllocationMetersResponse, QueryAllocationMetersResponseSDKType, QueryAllocationMeterRequest, QueryAllocationMeterRequestSDKType, QueryAllocationMeterResponse, QueryAllocationMeterResponseSDKType, QueryParamsRequest, QueryParamsRequestSDKType, QueryParamsResponse, QueryParamsResponseSDKType } from "./query.js"; +/** Query defines the gRPC querier service. */ +export interface Query { + /** Incentives retrieves registered incentives */ + incentives(request?: QueryIncentivesRequest): Promise; + /** Incentive retrieves a registered incentive */ + incentive(request: QueryIncentiveRequest): Promise; + /** GasMeters retrieves active gas meters for a given contract */ + gasMeters(request: QueryGasMetersRequest): Promise; + /** GasMeter Retrieves a active gas meter */ + gasMeter(request: QueryGasMeterRequest): Promise; + /** + * AllocationMeters retrieves active allocation meters for a given + * denomination + */ + allocationMeters(request?: QueryAllocationMetersRequest): Promise; + /** AllocationMeter Retrieves a active gas meter */ + allocationMeter(request: QueryAllocationMeterRequest): Promise; + /** Params retrieves the incentives module params */ + params(request?: QueryParamsRequest): Promise; +} +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + this.incentives = this.incentives.bind(this); + this.incentive = this.incentive.bind(this); + this.gasMeters = this.gasMeters.bind(this); + this.gasMeter = this.gasMeter.bind(this); + this.allocationMeters = this.allocationMeters.bind(this); + this.allocationMeter = this.allocationMeter.bind(this); + this.params = this.params.bind(this); + } + incentives(request: QueryIncentivesRequest = { + pagination: PageRequest.fromPartial({}) + }): Promise { + const data = QueryIncentivesRequest.encode(request).finish(); + const promise = this.rpc.request("evmos.incentives.v1.Query", "Incentives", data); + return promise.then(data => QueryIncentivesResponse.decode(new BinaryReader(data))); + } + incentive(request: QueryIncentiveRequest): Promise { + const data = QueryIncentiveRequest.encode(request).finish(); + const promise = this.rpc.request("evmos.incentives.v1.Query", "Incentive", data); + return promise.then(data => QueryIncentiveResponse.decode(new BinaryReader(data))); + } + gasMeters(request: QueryGasMetersRequest): Promise { + const data = QueryGasMetersRequest.encode(request).finish(); + const promise = this.rpc.request("evmos.incentives.v1.Query", "GasMeters", data); + return promise.then(data => QueryGasMetersResponse.decode(new BinaryReader(data))); + } + gasMeter(request: QueryGasMeterRequest): Promise { + const data = QueryGasMeterRequest.encode(request).finish(); + const promise = this.rpc.request("evmos.incentives.v1.Query", "GasMeter", data); + return promise.then(data => QueryGasMeterResponse.decode(new BinaryReader(data))); + } + allocationMeters(request: QueryAllocationMetersRequest = { + pagination: PageRequest.fromPartial({}) + }): Promise { + const data = QueryAllocationMetersRequest.encode(request).finish(); + const promise = this.rpc.request("evmos.incentives.v1.Query", "AllocationMeters", data); + return promise.then(data => QueryAllocationMetersResponse.decode(new BinaryReader(data))); + } + allocationMeter(request: QueryAllocationMeterRequest): Promise { + const data = QueryAllocationMeterRequest.encode(request).finish(); + const promise = this.rpc.request("evmos.incentives.v1.Query", "AllocationMeter", data); + return promise.then(data => QueryAllocationMeterResponse.decode(new BinaryReader(data))); + } + params(request: QueryParamsRequest = {}): Promise { + const data = QueryParamsRequest.encode(request).finish(); + const promise = this.rpc.request("evmos.incentives.v1.Query", "Params", data); + return promise.then(data => QueryParamsResponse.decode(new BinaryReader(data))); + } +} +export const createRpcQueryExtension = (base: QueryClient) => { + const rpc = createProtobufRpcClient(base); + const queryService = new QueryClientImpl(rpc); + return { + incentives(request?: QueryIncentivesRequest): Promise { + return queryService.incentives(request); + }, + incentive(request: QueryIncentiveRequest): Promise { + return queryService.incentive(request); + }, + gasMeters(request: QueryGasMetersRequest): Promise { + return queryService.gasMeters(request); + }, + gasMeter(request: QueryGasMeterRequest): Promise { + return queryService.gasMeter(request); + }, + allocationMeters(request?: QueryAllocationMetersRequest): Promise { + return queryService.allocationMeters(request); + }, + allocationMeter(request: QueryAllocationMeterRequest): Promise { + return queryService.allocationMeter(request); + }, + params(request?: QueryParamsRequest): Promise { + return queryService.params(request); + } + }; +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/evmos/incentives/v1/query.rpc.func.ts b/__fixtures__/v-next/outputicjsdeps/evmos/incentives/v1/query.rpc.func.ts new file mode 100644 index 0000000000..54cba73f2a --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/evmos/incentives/v1/query.rpc.func.ts @@ -0,0 +1,80 @@ +import { RpcResolver, buildQuery } from "../../../helper-func-types"; +import { buildUseQuery } from "../../../react-query"; +import { QueryIncentivesRequest, QueryIncentivesResponse, QueryIncentiveRequest, QueryIncentiveResponse, QueryGasMetersRequest, QueryGasMetersResponse, QueryGasMeterRequest, QueryGasMeterResponse, QueryAllocationMetersRequest, QueryAllocationMetersResponse, QueryAllocationMeterRequest, QueryAllocationMeterResponse, QueryParamsRequest, QueryParamsResponse } from "./query"; +export const createGetIncentives = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryIncentivesRequest.encode, + decode: QueryIncentivesResponse.decode, + service: "evmos.incentives.v1.Query", + method: "Incentives", + getRpcInstance: getRpcInstance +}); +export const useGetIncentives = buildUseQuery({ + builderQueryFn: createGetIncentives, + queryKeyPrefix: "IncentivesQuery" +}); +export const createGetIncentive = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryIncentiveRequest.encode, + decode: QueryIncentiveResponse.decode, + service: "evmos.incentives.v1.Query", + method: "Incentive", + getRpcInstance: getRpcInstance +}); +export const useGetIncentive = buildUseQuery({ + builderQueryFn: createGetIncentive, + queryKeyPrefix: "IncentiveQuery" +}); +export const createGetGasMeters = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryGasMetersRequest.encode, + decode: QueryGasMetersResponse.decode, + service: "evmos.incentives.v1.Query", + method: "GasMeters", + getRpcInstance: getRpcInstance +}); +export const useGetGasMeters = buildUseQuery({ + builderQueryFn: createGetGasMeters, + queryKeyPrefix: "GasMetersQuery" +}); +export const createGetGasMeter = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryGasMeterRequest.encode, + decode: QueryGasMeterResponse.decode, + service: "evmos.incentives.v1.Query", + method: "GasMeter", + getRpcInstance: getRpcInstance +}); +export const useGetGasMeter = buildUseQuery({ + builderQueryFn: createGetGasMeter, + queryKeyPrefix: "GasMeterQuery" +}); +export const createGetAllocationMeters = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryAllocationMetersRequest.encode, + decode: QueryAllocationMetersResponse.decode, + service: "evmos.incentives.v1.Query", + method: "AllocationMeters", + getRpcInstance: getRpcInstance +}); +export const useGetAllocationMeters = buildUseQuery({ + builderQueryFn: createGetAllocationMeters, + queryKeyPrefix: "AllocationMetersQuery" +}); +export const createGetAllocationMeter = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryAllocationMeterRequest.encode, + decode: QueryAllocationMeterResponse.decode, + service: "evmos.incentives.v1.Query", + method: "AllocationMeter", + getRpcInstance: getRpcInstance +}); +export const useGetAllocationMeter = buildUseQuery({ + builderQueryFn: createGetAllocationMeter, + queryKeyPrefix: "AllocationMeterQuery" +}); +export const createGetParams = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryParamsRequest.encode, + decode: QueryParamsResponse.decode, + service: "evmos.incentives.v1.Query", + method: "Params", + getRpcInstance: getRpcInstance +}); +export const useGetParams = buildUseQuery({ + builderQueryFn: createGetParams, + queryKeyPrefix: "ParamsQuery" +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/evmos/incentives/v1/query.ts b/__fixtures__/v-next/outputicjsdeps/evmos/incentives/v1/query.ts new file mode 100644 index 0000000000..269c2b95ea --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/evmos/incentives/v1/query.ts @@ -0,0 +1,1606 @@ +import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../../cosmos/base/query/v1beta1/pagination.js"; +import { Incentive, IncentiveSDKType, GasMeter, GasMeterSDKType } from "./incentives.js"; +import { DecCoin, DecCoinSDKType } from "../../../cosmos/base/v1beta1/coin.js"; +import { Params, ParamsSDKType } from "./genesis.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "evmos.incentives.v1"; +/** + * QueryIncentivesRequest is the request type for the Query/Incentives RPC + * method. + */ +export interface QueryIncentivesRequest { + /** pagination defines an optional pagination for the request. */ + pagination?: PageRequest; +} +export interface QueryIncentivesRequestProtoMsg { + typeUrl: "/evmos.incentives.v1.QueryIncentivesRequest"; + value: Uint8Array; +} +/** + * QueryIncentivesRequest is the request type for the Query/Incentives RPC + * method. + */ +export interface QueryIncentivesRequestSDKType { + pagination?: PageRequestSDKType; +} +/** + * QueryIncentivesResponse is the response type for the Query/Incentives RPC + * method. + */ +export interface QueryIncentivesResponse { + incentives: Incentive[]; + /** pagination defines the pagination in the response. */ + pagination?: PageResponse; +} +export interface QueryIncentivesResponseProtoMsg { + typeUrl: "/evmos.incentives.v1.QueryIncentivesResponse"; + value: Uint8Array; +} +/** + * QueryIncentivesResponse is the response type for the Query/Incentives RPC + * method. + */ +export interface QueryIncentivesResponseSDKType { + incentives: IncentiveSDKType[]; + pagination?: PageResponseSDKType; +} +/** QueryIncentiveRequest is the request type for the Query/Incentive RPC method. */ +export interface QueryIncentiveRequest { + /** contract identifier is the hex contract address of a contract */ + contract: string; +} +export interface QueryIncentiveRequestProtoMsg { + typeUrl: "/evmos.incentives.v1.QueryIncentiveRequest"; + value: Uint8Array; +} +/** QueryIncentiveRequest is the request type for the Query/Incentive RPC method. */ +export interface QueryIncentiveRequestSDKType { + contract: string; +} +/** + * QueryIncentiveResponse is the response type for the Query/Incentive RPC + * method. + */ +export interface QueryIncentiveResponse { + incentive: Incentive; +} +export interface QueryIncentiveResponseProtoMsg { + typeUrl: "/evmos.incentives.v1.QueryIncentiveResponse"; + value: Uint8Array; +} +/** + * QueryIncentiveResponse is the response type for the Query/Incentive RPC + * method. + */ +export interface QueryIncentiveResponseSDKType { + incentive: IncentiveSDKType; +} +/** + * QueryGasMetersRequest is the request type for the Query/Incentives RPC + * method. + */ +export interface QueryGasMetersRequest { + /** contract is the hex contract address of a incentivized smart contract */ + contract: string; + /** pagination defines an optional pagination for the request. */ + pagination?: PageRequest; +} +export interface QueryGasMetersRequestProtoMsg { + typeUrl: "/evmos.incentives.v1.QueryGasMetersRequest"; + value: Uint8Array; +} +/** + * QueryGasMetersRequest is the request type for the Query/Incentives RPC + * method. + */ +export interface QueryGasMetersRequestSDKType { + contract: string; + pagination?: PageRequestSDKType; +} +/** + * QueryGasMetersResponse is the response type for the Query/Incentives RPC + * method. + */ +export interface QueryGasMetersResponse { + gasMeters: GasMeter[]; + /** pagination defines the pagination in the response. */ + pagination?: PageResponse; +} +export interface QueryGasMetersResponseProtoMsg { + typeUrl: "/evmos.incentives.v1.QueryGasMetersResponse"; + value: Uint8Array; +} +/** + * QueryGasMetersResponse is the response type for the Query/Incentives RPC + * method. + */ +export interface QueryGasMetersResponseSDKType { + gas_meters: GasMeterSDKType[]; + pagination?: PageResponseSDKType; +} +/** QueryGasMeterRequest is the request type for the Query/Incentive RPC method. */ +export interface QueryGasMeterRequest { + /** contract identifier is the hex contract address of a contract */ + contract: string; + /** participant identifier is the hex address of a user */ + participant: string; +} +export interface QueryGasMeterRequestProtoMsg { + typeUrl: "/evmos.incentives.v1.QueryGasMeterRequest"; + value: Uint8Array; +} +/** QueryGasMeterRequest is the request type for the Query/Incentive RPC method. */ +export interface QueryGasMeterRequestSDKType { + contract: string; + participant: string; +} +/** + * QueryGasMeterResponse is the response type for the Query/Incentive RPC + * method. + */ +export interface QueryGasMeterResponse { + gasMeter: bigint; +} +export interface QueryGasMeterResponseProtoMsg { + typeUrl: "/evmos.incentives.v1.QueryGasMeterResponse"; + value: Uint8Array; +} +/** + * QueryGasMeterResponse is the response type for the Query/Incentive RPC + * method. + */ +export interface QueryGasMeterResponseSDKType { + gas_meter: bigint; +} +/** + * QueryAllocationMetersRequest is the request type for the + * Query/AllocationMeters RPC method. + */ +export interface QueryAllocationMetersRequest { + /** pagination defines an optional pagination for the request. */ + pagination?: PageRequest; +} +export interface QueryAllocationMetersRequestProtoMsg { + typeUrl: "/evmos.incentives.v1.QueryAllocationMetersRequest"; + value: Uint8Array; +} +/** + * QueryAllocationMetersRequest is the request type for the + * Query/AllocationMeters RPC method. + */ +export interface QueryAllocationMetersRequestSDKType { + pagination?: PageRequestSDKType; +} +/** + * QueryAllocationMetersResponse is the response type for the + * Query/AllocationMeters RPC method. + */ +export interface QueryAllocationMetersResponse { + allocationMeters: DecCoin[]; + /** pagination defines the pagination in the response. */ + pagination?: PageResponse; +} +export interface QueryAllocationMetersResponseProtoMsg { + typeUrl: "/evmos.incentives.v1.QueryAllocationMetersResponse"; + value: Uint8Array; +} +/** + * QueryAllocationMetersResponse is the response type for the + * Query/AllocationMeters RPC method. + */ +export interface QueryAllocationMetersResponseSDKType { + allocation_meters: DecCoinSDKType[]; + pagination?: PageResponseSDKType; +} +/** + * QueryAllocationMeterRequest is the request type for the Query/AllocationMeter + * RPC method. + */ +export interface QueryAllocationMeterRequest { + /** denom is the coin denom to query an allocation meter for. */ + denom: string; +} +export interface QueryAllocationMeterRequestProtoMsg { + typeUrl: "/evmos.incentives.v1.QueryAllocationMeterRequest"; + value: Uint8Array; +} +/** + * QueryAllocationMeterRequest is the request type for the Query/AllocationMeter + * RPC method. + */ +export interface QueryAllocationMeterRequestSDKType { + denom: string; +} +/** + * QueryAllocationMeterResponse is the response type for the + * Query/AllocationMeter RPC method. + */ +export interface QueryAllocationMeterResponse { + allocationMeter: DecCoin; +} +export interface QueryAllocationMeterResponseProtoMsg { + typeUrl: "/evmos.incentives.v1.QueryAllocationMeterResponse"; + value: Uint8Array; +} +/** + * QueryAllocationMeterResponse is the response type for the + * Query/AllocationMeter RPC method. + */ +export interface QueryAllocationMeterResponseSDKType { + allocation_meter: DecCoinSDKType; +} +/** QueryParamsRequest is the request type for the Query/Params RPC method. */ +export interface QueryParamsRequest {} +export interface QueryParamsRequestProtoMsg { + typeUrl: "/evmos.incentives.v1.QueryParamsRequest"; + value: Uint8Array; +} +/** QueryParamsRequest is the request type for the Query/Params RPC method. */ +export interface QueryParamsRequestSDKType {} +/** + * QueryParamsResponse is the response type for the Query/Params RPC + * method. + */ +export interface QueryParamsResponse { + params: Params; +} +export interface QueryParamsResponseProtoMsg { + typeUrl: "/evmos.incentives.v1.QueryParamsResponse"; + value: Uint8Array; +} +/** + * QueryParamsResponse is the response type for the Query/Params RPC + * method. + */ +export interface QueryParamsResponseSDKType { + params: ParamsSDKType; +} +function createBaseQueryIncentivesRequest(): QueryIncentivesRequest { + return { + pagination: undefined + }; +} +export const QueryIncentivesRequest = { + typeUrl: "/evmos.incentives.v1.QueryIncentivesRequest", + encode(message: QueryIncentivesRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryIncentivesRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryIncentivesRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryIncentivesRequest { + const obj = createBaseQueryIncentivesRequest(); + if (isSet(object.pagination)) obj.pagination = PageRequest.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryIncentivesRequest): JsonSafe { + const obj: any = {}; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryIncentivesRequest { + const message = createBaseQueryIncentivesRequest(); + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryIncentivesRequestSDKType): QueryIncentivesRequest { + return { + pagination: object.pagination ? PageRequest.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryIncentivesRequestSDKType { + return { + pagination: isSet(object.pagination) ? PageRequest.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryIncentivesRequest): QueryIncentivesRequestSDKType { + const obj: any = {}; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryIncentivesRequestAmino): QueryIncentivesRequest { + const message = createBaseQueryIncentivesRequest(); + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryIncentivesRequest): QueryIncentivesRequestAmino { + const obj: any = {}; + obj.pagination = message.pagination ? PageRequest.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryIncentivesRequestAminoMsg): QueryIncentivesRequest { + return QueryIncentivesRequest.fromAmino(object.value); + }, + fromProtoMsg(message: QueryIncentivesRequestProtoMsg): QueryIncentivesRequest { + return QueryIncentivesRequest.decode(message.value); + }, + toProto(message: QueryIncentivesRequest): Uint8Array { + return QueryIncentivesRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryIncentivesRequest): QueryIncentivesRequestProtoMsg { + return { + typeUrl: "/evmos.incentives.v1.QueryIncentivesRequest", + value: QueryIncentivesRequest.encode(message).finish() + }; + } +}; +function createBaseQueryIncentivesResponse(): QueryIncentivesResponse { + return { + incentives: [], + pagination: undefined + }; +} +export const QueryIncentivesResponse = { + typeUrl: "/evmos.incentives.v1.QueryIncentivesResponse", + encode(message: QueryIncentivesResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.incentives) { + Incentive.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryIncentivesResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryIncentivesResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.incentives.push(Incentive.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryIncentivesResponse { + const obj = createBaseQueryIncentivesResponse(); + if (Array.isArray(object?.incentives)) obj.incentives = object.incentives.map((e: any) => Incentive.fromJSON(e)); + if (isSet(object.pagination)) obj.pagination = PageResponse.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryIncentivesResponse): JsonSafe { + const obj: any = {}; + if (message.incentives) { + obj.incentives = message.incentives.map(e => e ? Incentive.toJSON(e) : undefined); + } else { + obj.incentives = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryIncentivesResponse { + const message = createBaseQueryIncentivesResponse(); + message.incentives = object.incentives?.map(e => Incentive.fromPartial(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryIncentivesResponseSDKType): QueryIncentivesResponse { + return { + incentives: Array.isArray(object?.incentives) ? object.incentives.map((e: any) => Incentive.fromSDK(e)) : [], + pagination: object.pagination ? PageResponse.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryIncentivesResponseSDKType { + return { + incentives: Array.isArray(object?.incentives) ? object.incentives.map((e: any) => Incentive.fromSDKJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryIncentivesResponse): QueryIncentivesResponseSDKType { + const obj: any = {}; + if (message.incentives) { + obj.incentives = message.incentives.map(e => e ? Incentive.toSDK(e) : undefined); + } else { + obj.incentives = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryIncentivesResponseAmino): QueryIncentivesResponse { + const message = createBaseQueryIncentivesResponse(); + message.incentives = object.incentives?.map(e => Incentive.fromAmino(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryIncentivesResponse): QueryIncentivesResponseAmino { + const obj: any = {}; + if (message.incentives) { + obj.incentives = message.incentives.map(e => e ? Incentive.toAmino(e) : undefined); + } else { + obj.incentives = message.incentives; + } + obj.pagination = message.pagination ? PageResponse.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryIncentivesResponseAminoMsg): QueryIncentivesResponse { + return QueryIncentivesResponse.fromAmino(object.value); + }, + fromProtoMsg(message: QueryIncentivesResponseProtoMsg): QueryIncentivesResponse { + return QueryIncentivesResponse.decode(message.value); + }, + toProto(message: QueryIncentivesResponse): Uint8Array { + return QueryIncentivesResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryIncentivesResponse): QueryIncentivesResponseProtoMsg { + return { + typeUrl: "/evmos.incentives.v1.QueryIncentivesResponse", + value: QueryIncentivesResponse.encode(message).finish() + }; + } +}; +function createBaseQueryIncentiveRequest(): QueryIncentiveRequest { + return { + contract: "" + }; +} +export const QueryIncentiveRequest = { + typeUrl: "/evmos.incentives.v1.QueryIncentiveRequest", + encode(message: QueryIncentiveRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.contract !== undefined) { + writer.uint32(10).string(message.contract); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryIncentiveRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryIncentiveRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.contract = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryIncentiveRequest { + const obj = createBaseQueryIncentiveRequest(); + if (isSet(object.contract)) obj.contract = String(object.contract); + return obj; + }, + toJSON(message: QueryIncentiveRequest): JsonSafe { + const obj: any = {}; + message.contract !== undefined && (obj.contract = message.contract); + return obj; + }, + fromPartial(object: DeepPartial): QueryIncentiveRequest { + const message = createBaseQueryIncentiveRequest(); + message.contract = object.contract ?? ""; + return message; + }, + fromSDK(object: QueryIncentiveRequestSDKType): QueryIncentiveRequest { + return { + contract: object?.contract + }; + }, + fromSDKJSON(object: any): QueryIncentiveRequestSDKType { + return { + contract: isSet(object.contract) ? String(object.contract) : "" + }; + }, + toSDK(message: QueryIncentiveRequest): QueryIncentiveRequestSDKType { + const obj: any = {}; + obj.contract = message.contract; + return obj; + }, + fromAmino(object: QueryIncentiveRequestAmino): QueryIncentiveRequest { + const message = createBaseQueryIncentiveRequest(); + if (object.contract !== undefined && object.contract !== null) { + message.contract = object.contract; + } + return message; + }, + toAmino(message: QueryIncentiveRequest): QueryIncentiveRequestAmino { + const obj: any = {}; + obj.contract = message.contract === "" ? undefined : message.contract; + return obj; + }, + fromAminoMsg(object: QueryIncentiveRequestAminoMsg): QueryIncentiveRequest { + return QueryIncentiveRequest.fromAmino(object.value); + }, + fromProtoMsg(message: QueryIncentiveRequestProtoMsg): QueryIncentiveRequest { + return QueryIncentiveRequest.decode(message.value); + }, + toProto(message: QueryIncentiveRequest): Uint8Array { + return QueryIncentiveRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryIncentiveRequest): QueryIncentiveRequestProtoMsg { + return { + typeUrl: "/evmos.incentives.v1.QueryIncentiveRequest", + value: QueryIncentiveRequest.encode(message).finish() + }; + } +}; +function createBaseQueryIncentiveResponse(): QueryIncentiveResponse { + return { + incentive: Incentive.fromPartial({}) + }; +} +export const QueryIncentiveResponse = { + typeUrl: "/evmos.incentives.v1.QueryIncentiveResponse", + encode(message: QueryIncentiveResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.incentive !== undefined) { + Incentive.encode(message.incentive, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryIncentiveResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryIncentiveResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.incentive = Incentive.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryIncentiveResponse { + const obj = createBaseQueryIncentiveResponse(); + if (isSet(object.incentive)) obj.incentive = Incentive.fromJSON(object.incentive); + return obj; + }, + toJSON(message: QueryIncentiveResponse): JsonSafe { + const obj: any = {}; + message.incentive !== undefined && (obj.incentive = message.incentive ? Incentive.toJSON(message.incentive) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryIncentiveResponse { + const message = createBaseQueryIncentiveResponse(); + if (object.incentive !== undefined && object.incentive !== null) { + message.incentive = Incentive.fromPartial(object.incentive); + } + return message; + }, + fromSDK(object: QueryIncentiveResponseSDKType): QueryIncentiveResponse { + return { + incentive: object.incentive ? Incentive.fromSDK(object.incentive) : undefined + }; + }, + fromSDKJSON(object: any): QueryIncentiveResponseSDKType { + return { + incentive: isSet(object.incentive) ? Incentive.fromSDKJSON(object.incentive) : undefined + }; + }, + toSDK(message: QueryIncentiveResponse): QueryIncentiveResponseSDKType { + const obj: any = {}; + message.incentive !== undefined && (obj.incentive = message.incentive ? Incentive.toSDK(message.incentive) : undefined); + return obj; + }, + fromAmino(object: QueryIncentiveResponseAmino): QueryIncentiveResponse { + const message = createBaseQueryIncentiveResponse(); + if (object.incentive !== undefined && object.incentive !== null) { + message.incentive = Incentive.fromAmino(object.incentive); + } + return message; + }, + toAmino(message: QueryIncentiveResponse): QueryIncentiveResponseAmino { + const obj: any = {}; + obj.incentive = message.incentive ? Incentive.toAmino(message.incentive) : undefined; + return obj; + }, + fromAminoMsg(object: QueryIncentiveResponseAminoMsg): QueryIncentiveResponse { + return QueryIncentiveResponse.fromAmino(object.value); + }, + fromProtoMsg(message: QueryIncentiveResponseProtoMsg): QueryIncentiveResponse { + return QueryIncentiveResponse.decode(message.value); + }, + toProto(message: QueryIncentiveResponse): Uint8Array { + return QueryIncentiveResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryIncentiveResponse): QueryIncentiveResponseProtoMsg { + return { + typeUrl: "/evmos.incentives.v1.QueryIncentiveResponse", + value: QueryIncentiveResponse.encode(message).finish() + }; + } +}; +function createBaseQueryGasMetersRequest(): QueryGasMetersRequest { + return { + contract: "", + pagination: undefined + }; +} +export const QueryGasMetersRequest = { + typeUrl: "/evmos.incentives.v1.QueryGasMetersRequest", + encode(message: QueryGasMetersRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.contract !== undefined) { + writer.uint32(10).string(message.contract); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryGasMetersRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryGasMetersRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.contract = reader.string(); + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryGasMetersRequest { + const obj = createBaseQueryGasMetersRequest(); + if (isSet(object.contract)) obj.contract = String(object.contract); + if (isSet(object.pagination)) obj.pagination = PageRequest.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryGasMetersRequest): JsonSafe { + const obj: any = {}; + message.contract !== undefined && (obj.contract = message.contract); + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryGasMetersRequest { + const message = createBaseQueryGasMetersRequest(); + message.contract = object.contract ?? ""; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryGasMetersRequestSDKType): QueryGasMetersRequest { + return { + contract: object?.contract, + pagination: object.pagination ? PageRequest.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryGasMetersRequestSDKType { + return { + contract: isSet(object.contract) ? String(object.contract) : "", + pagination: isSet(object.pagination) ? PageRequest.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryGasMetersRequest): QueryGasMetersRequestSDKType { + const obj: any = {}; + obj.contract = message.contract; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryGasMetersRequestAmino): QueryGasMetersRequest { + const message = createBaseQueryGasMetersRequest(); + if (object.contract !== undefined && object.contract !== null) { + message.contract = object.contract; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryGasMetersRequest): QueryGasMetersRequestAmino { + const obj: any = {}; + obj.contract = message.contract === "" ? undefined : message.contract; + obj.pagination = message.pagination ? PageRequest.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryGasMetersRequestAminoMsg): QueryGasMetersRequest { + return QueryGasMetersRequest.fromAmino(object.value); + }, + fromProtoMsg(message: QueryGasMetersRequestProtoMsg): QueryGasMetersRequest { + return QueryGasMetersRequest.decode(message.value); + }, + toProto(message: QueryGasMetersRequest): Uint8Array { + return QueryGasMetersRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryGasMetersRequest): QueryGasMetersRequestProtoMsg { + return { + typeUrl: "/evmos.incentives.v1.QueryGasMetersRequest", + value: QueryGasMetersRequest.encode(message).finish() + }; + } +}; +function createBaseQueryGasMetersResponse(): QueryGasMetersResponse { + return { + gasMeters: [], + pagination: undefined + }; +} +export const QueryGasMetersResponse = { + typeUrl: "/evmos.incentives.v1.QueryGasMetersResponse", + encode(message: QueryGasMetersResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.gasMeters) { + GasMeter.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryGasMetersResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryGasMetersResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.gasMeters.push(GasMeter.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryGasMetersResponse { + const obj = createBaseQueryGasMetersResponse(); + if (Array.isArray(object?.gasMeters)) obj.gasMeters = object.gasMeters.map((e: any) => GasMeter.fromJSON(e)); + if (isSet(object.pagination)) obj.pagination = PageResponse.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryGasMetersResponse): JsonSafe { + const obj: any = {}; + if (message.gasMeters) { + obj.gasMeters = message.gasMeters.map(e => e ? GasMeter.toJSON(e) : undefined); + } else { + obj.gasMeters = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryGasMetersResponse { + const message = createBaseQueryGasMetersResponse(); + message.gasMeters = object.gasMeters?.map(e => GasMeter.fromPartial(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryGasMetersResponseSDKType): QueryGasMetersResponse { + return { + gasMeters: Array.isArray(object?.gas_meters) ? object.gas_meters.map((e: any) => GasMeter.fromSDK(e)) : [], + pagination: object.pagination ? PageResponse.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryGasMetersResponseSDKType { + return { + gas_meters: Array.isArray(object?.gas_meters) ? object.gas_meters.map((e: any) => GasMeter.fromSDKJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryGasMetersResponse): QueryGasMetersResponseSDKType { + const obj: any = {}; + if (message.gasMeters) { + obj.gas_meters = message.gasMeters.map(e => e ? GasMeter.toSDK(e) : undefined); + } else { + obj.gas_meters = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryGasMetersResponseAmino): QueryGasMetersResponse { + const message = createBaseQueryGasMetersResponse(); + message.gasMeters = object.gas_meters?.map(e => GasMeter.fromAmino(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryGasMetersResponse): QueryGasMetersResponseAmino { + const obj: any = {}; + if (message.gasMeters) { + obj.gas_meters = message.gasMeters.map(e => e ? GasMeter.toAmino(e) : undefined); + } else { + obj.gas_meters = message.gasMeters; + } + obj.pagination = message.pagination ? PageResponse.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryGasMetersResponseAminoMsg): QueryGasMetersResponse { + return QueryGasMetersResponse.fromAmino(object.value); + }, + fromProtoMsg(message: QueryGasMetersResponseProtoMsg): QueryGasMetersResponse { + return QueryGasMetersResponse.decode(message.value); + }, + toProto(message: QueryGasMetersResponse): Uint8Array { + return QueryGasMetersResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryGasMetersResponse): QueryGasMetersResponseProtoMsg { + return { + typeUrl: "/evmos.incentives.v1.QueryGasMetersResponse", + value: QueryGasMetersResponse.encode(message).finish() + }; + } +}; +function createBaseQueryGasMeterRequest(): QueryGasMeterRequest { + return { + contract: "", + participant: "" + }; +} +export const QueryGasMeterRequest = { + typeUrl: "/evmos.incentives.v1.QueryGasMeterRequest", + encode(message: QueryGasMeterRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.contract !== undefined) { + writer.uint32(10).string(message.contract); + } + if (message.participant !== undefined) { + writer.uint32(18).string(message.participant); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryGasMeterRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryGasMeterRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.contract = reader.string(); + break; + case 2: + message.participant = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryGasMeterRequest { + const obj = createBaseQueryGasMeterRequest(); + if (isSet(object.contract)) obj.contract = String(object.contract); + if (isSet(object.participant)) obj.participant = String(object.participant); + return obj; + }, + toJSON(message: QueryGasMeterRequest): JsonSafe { + const obj: any = {}; + message.contract !== undefined && (obj.contract = message.contract); + message.participant !== undefined && (obj.participant = message.participant); + return obj; + }, + fromPartial(object: DeepPartial): QueryGasMeterRequest { + const message = createBaseQueryGasMeterRequest(); + message.contract = object.contract ?? ""; + message.participant = object.participant ?? ""; + return message; + }, + fromSDK(object: QueryGasMeterRequestSDKType): QueryGasMeterRequest { + return { + contract: object?.contract, + participant: object?.participant + }; + }, + fromSDKJSON(object: any): QueryGasMeterRequestSDKType { + return { + contract: isSet(object.contract) ? String(object.contract) : "", + participant: isSet(object.participant) ? String(object.participant) : "" + }; + }, + toSDK(message: QueryGasMeterRequest): QueryGasMeterRequestSDKType { + const obj: any = {}; + obj.contract = message.contract; + obj.participant = message.participant; + return obj; + }, + fromAmino(object: QueryGasMeterRequestAmino): QueryGasMeterRequest { + const message = createBaseQueryGasMeterRequest(); + if (object.contract !== undefined && object.contract !== null) { + message.contract = object.contract; + } + if (object.participant !== undefined && object.participant !== null) { + message.participant = object.participant; + } + return message; + }, + toAmino(message: QueryGasMeterRequest): QueryGasMeterRequestAmino { + const obj: any = {}; + obj.contract = message.contract === "" ? undefined : message.contract; + obj.participant = message.participant === "" ? undefined : message.participant; + return obj; + }, + fromAminoMsg(object: QueryGasMeterRequestAminoMsg): QueryGasMeterRequest { + return QueryGasMeterRequest.fromAmino(object.value); + }, + fromProtoMsg(message: QueryGasMeterRequestProtoMsg): QueryGasMeterRequest { + return QueryGasMeterRequest.decode(message.value); + }, + toProto(message: QueryGasMeterRequest): Uint8Array { + return QueryGasMeterRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryGasMeterRequest): QueryGasMeterRequestProtoMsg { + return { + typeUrl: "/evmos.incentives.v1.QueryGasMeterRequest", + value: QueryGasMeterRequest.encode(message).finish() + }; + } +}; +function createBaseQueryGasMeterResponse(): QueryGasMeterResponse { + return { + gasMeter: BigInt(0) + }; +} +export const QueryGasMeterResponse = { + typeUrl: "/evmos.incentives.v1.QueryGasMeterResponse", + encode(message: QueryGasMeterResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.gasMeter !== undefined) { + writer.uint32(8).uint64(message.gasMeter); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryGasMeterResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryGasMeterResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.gasMeter = reader.uint64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryGasMeterResponse { + const obj = createBaseQueryGasMeterResponse(); + if (isSet(object.gasMeter)) obj.gasMeter = BigInt(object.gasMeter.toString()); + return obj; + }, + toJSON(message: QueryGasMeterResponse): JsonSafe { + const obj: any = {}; + message.gasMeter !== undefined && (obj.gasMeter = (message.gasMeter || BigInt(0)).toString()); + return obj; + }, + fromPartial(object: DeepPartial): QueryGasMeterResponse { + const message = createBaseQueryGasMeterResponse(); + if (object.gasMeter !== undefined && object.gasMeter !== null) { + message.gasMeter = BigInt(object.gasMeter.toString()); + } + return message; + }, + fromSDK(object: QueryGasMeterResponseSDKType): QueryGasMeterResponse { + return { + gasMeter: object?.gas_meter + }; + }, + fromSDKJSON(object: any): QueryGasMeterResponseSDKType { + return { + gas_meter: isSet(object.gas_meter) ? BigInt(object.gas_meter.toString()) : BigInt(0) + }; + }, + toSDK(message: QueryGasMeterResponse): QueryGasMeterResponseSDKType { + const obj: any = {}; + obj.gas_meter = message.gasMeter; + return obj; + }, + fromAmino(object: QueryGasMeterResponseAmino): QueryGasMeterResponse { + const message = createBaseQueryGasMeterResponse(); + if (object.gas_meter !== undefined && object.gas_meter !== null) { + message.gasMeter = BigInt(object.gas_meter); + } + return message; + }, + toAmino(message: QueryGasMeterResponse): QueryGasMeterResponseAmino { + const obj: any = {}; + obj.gas_meter = message.gasMeter !== BigInt(0) ? message.gasMeter?.toString() : undefined; + return obj; + }, + fromAminoMsg(object: QueryGasMeterResponseAminoMsg): QueryGasMeterResponse { + return QueryGasMeterResponse.fromAmino(object.value); + }, + fromProtoMsg(message: QueryGasMeterResponseProtoMsg): QueryGasMeterResponse { + return QueryGasMeterResponse.decode(message.value); + }, + toProto(message: QueryGasMeterResponse): Uint8Array { + return QueryGasMeterResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryGasMeterResponse): QueryGasMeterResponseProtoMsg { + return { + typeUrl: "/evmos.incentives.v1.QueryGasMeterResponse", + value: QueryGasMeterResponse.encode(message).finish() + }; + } +}; +function createBaseQueryAllocationMetersRequest(): QueryAllocationMetersRequest { + return { + pagination: undefined + }; +} +export const QueryAllocationMetersRequest = { + typeUrl: "/evmos.incentives.v1.QueryAllocationMetersRequest", + encode(message: QueryAllocationMetersRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryAllocationMetersRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryAllocationMetersRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryAllocationMetersRequest { + const obj = createBaseQueryAllocationMetersRequest(); + if (isSet(object.pagination)) obj.pagination = PageRequest.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryAllocationMetersRequest): JsonSafe { + const obj: any = {}; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryAllocationMetersRequest { + const message = createBaseQueryAllocationMetersRequest(); + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryAllocationMetersRequestSDKType): QueryAllocationMetersRequest { + return { + pagination: object.pagination ? PageRequest.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryAllocationMetersRequestSDKType { + return { + pagination: isSet(object.pagination) ? PageRequest.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryAllocationMetersRequest): QueryAllocationMetersRequestSDKType { + const obj: any = {}; + message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryAllocationMetersRequestAmino): QueryAllocationMetersRequest { + const message = createBaseQueryAllocationMetersRequest(); + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryAllocationMetersRequest): QueryAllocationMetersRequestAmino { + const obj: any = {}; + obj.pagination = message.pagination ? PageRequest.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryAllocationMetersRequestAminoMsg): QueryAllocationMetersRequest { + return QueryAllocationMetersRequest.fromAmino(object.value); + }, + fromProtoMsg(message: QueryAllocationMetersRequestProtoMsg): QueryAllocationMetersRequest { + return QueryAllocationMetersRequest.decode(message.value); + }, + toProto(message: QueryAllocationMetersRequest): Uint8Array { + return QueryAllocationMetersRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryAllocationMetersRequest): QueryAllocationMetersRequestProtoMsg { + return { + typeUrl: "/evmos.incentives.v1.QueryAllocationMetersRequest", + value: QueryAllocationMetersRequest.encode(message).finish() + }; + } +}; +function createBaseQueryAllocationMetersResponse(): QueryAllocationMetersResponse { + return { + allocationMeters: [], + pagination: undefined + }; +} +export const QueryAllocationMetersResponse = { + typeUrl: "/evmos.incentives.v1.QueryAllocationMetersResponse", + encode(message: QueryAllocationMetersResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.allocationMeters) { + DecCoin.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryAllocationMetersResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryAllocationMetersResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.allocationMeters.push(DecCoin.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryAllocationMetersResponse { + const obj = createBaseQueryAllocationMetersResponse(); + if (Array.isArray(object?.allocationMeters)) obj.allocationMeters = object.allocationMeters.map((e: any) => DecCoin.fromJSON(e)); + if (isSet(object.pagination)) obj.pagination = PageResponse.fromJSON(object.pagination); + return obj; + }, + toJSON(message: QueryAllocationMetersResponse): JsonSafe { + const obj: any = {}; + if (message.allocationMeters) { + obj.allocationMeters = message.allocationMeters.map(e => e ? DecCoin.toJSON(e) : undefined); + } else { + obj.allocationMeters = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryAllocationMetersResponse { + const message = createBaseQueryAllocationMetersResponse(); + message.allocationMeters = object.allocationMeters?.map(e => DecCoin.fromPartial(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } + return message; + }, + fromSDK(object: QueryAllocationMetersResponseSDKType): QueryAllocationMetersResponse { + return { + allocationMeters: Array.isArray(object?.allocation_meters) ? object.allocation_meters.map((e: any) => DecCoin.fromSDK(e)) : [], + pagination: object.pagination ? PageResponse.fromSDK(object.pagination) : undefined + }; + }, + fromSDKJSON(object: any): QueryAllocationMetersResponseSDKType { + return { + allocation_meters: Array.isArray(object?.allocation_meters) ? object.allocation_meters.map((e: any) => DecCoin.fromSDKJSON(e)) : [], + pagination: isSet(object.pagination) ? PageResponse.fromSDKJSON(object.pagination) : undefined + }; + }, + toSDK(message: QueryAllocationMetersResponse): QueryAllocationMetersResponseSDKType { + const obj: any = {}; + if (message.allocationMeters) { + obj.allocation_meters = message.allocationMeters.map(e => e ? DecCoin.toSDK(e) : undefined); + } else { + obj.allocation_meters = []; + } + message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toSDK(message.pagination) : undefined); + return obj; + }, + fromAmino(object: QueryAllocationMetersResponseAmino): QueryAllocationMetersResponse { + const message = createBaseQueryAllocationMetersResponse(); + message.allocationMeters = object.allocation_meters?.map(e => DecCoin.fromAmino(e)) || []; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromAmino(object.pagination); + } + return message; + }, + toAmino(message: QueryAllocationMetersResponse): QueryAllocationMetersResponseAmino { + const obj: any = {}; + if (message.allocationMeters) { + obj.allocation_meters = message.allocationMeters.map(e => e ? DecCoin.toAmino(e) : undefined); + } else { + obj.allocation_meters = message.allocationMeters; + } + obj.pagination = message.pagination ? PageResponse.toAmino(message.pagination) : undefined; + return obj; + }, + fromAminoMsg(object: QueryAllocationMetersResponseAminoMsg): QueryAllocationMetersResponse { + return QueryAllocationMetersResponse.fromAmino(object.value); + }, + fromProtoMsg(message: QueryAllocationMetersResponseProtoMsg): QueryAllocationMetersResponse { + return QueryAllocationMetersResponse.decode(message.value); + }, + toProto(message: QueryAllocationMetersResponse): Uint8Array { + return QueryAllocationMetersResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryAllocationMetersResponse): QueryAllocationMetersResponseProtoMsg { + return { + typeUrl: "/evmos.incentives.v1.QueryAllocationMetersResponse", + value: QueryAllocationMetersResponse.encode(message).finish() + }; + } +}; +function createBaseQueryAllocationMeterRequest(): QueryAllocationMeterRequest { + return { + denom: "" + }; +} +export const QueryAllocationMeterRequest = { + typeUrl: "/evmos.incentives.v1.QueryAllocationMeterRequest", + encode(message: QueryAllocationMeterRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.denom !== undefined) { + writer.uint32(10).string(message.denom); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryAllocationMeterRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryAllocationMeterRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.denom = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryAllocationMeterRequest { + const obj = createBaseQueryAllocationMeterRequest(); + if (isSet(object.denom)) obj.denom = String(object.denom); + return obj; + }, + toJSON(message: QueryAllocationMeterRequest): JsonSafe { + const obj: any = {}; + message.denom !== undefined && (obj.denom = message.denom); + return obj; + }, + fromPartial(object: DeepPartial): QueryAllocationMeterRequest { + const message = createBaseQueryAllocationMeterRequest(); + message.denom = object.denom ?? ""; + return message; + }, + fromSDK(object: QueryAllocationMeterRequestSDKType): QueryAllocationMeterRequest { + return { + denom: object?.denom + }; + }, + fromSDKJSON(object: any): QueryAllocationMeterRequestSDKType { + return { + denom: isSet(object.denom) ? String(object.denom) : "" + }; + }, + toSDK(message: QueryAllocationMeterRequest): QueryAllocationMeterRequestSDKType { + const obj: any = {}; + obj.denom = message.denom; + return obj; + }, + fromAmino(object: QueryAllocationMeterRequestAmino): QueryAllocationMeterRequest { + const message = createBaseQueryAllocationMeterRequest(); + if (object.denom !== undefined && object.denom !== null) { + message.denom = object.denom; + } + return message; + }, + toAmino(message: QueryAllocationMeterRequest): QueryAllocationMeterRequestAmino { + const obj: any = {}; + obj.denom = message.denom === "" ? undefined : message.denom; + return obj; + }, + fromAminoMsg(object: QueryAllocationMeterRequestAminoMsg): QueryAllocationMeterRequest { + return QueryAllocationMeterRequest.fromAmino(object.value); + }, + fromProtoMsg(message: QueryAllocationMeterRequestProtoMsg): QueryAllocationMeterRequest { + return QueryAllocationMeterRequest.decode(message.value); + }, + toProto(message: QueryAllocationMeterRequest): Uint8Array { + return QueryAllocationMeterRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryAllocationMeterRequest): QueryAllocationMeterRequestProtoMsg { + return { + typeUrl: "/evmos.incentives.v1.QueryAllocationMeterRequest", + value: QueryAllocationMeterRequest.encode(message).finish() + }; + } +}; +function createBaseQueryAllocationMeterResponse(): QueryAllocationMeterResponse { + return { + allocationMeter: DecCoin.fromPartial({}) + }; +} +export const QueryAllocationMeterResponse = { + typeUrl: "/evmos.incentives.v1.QueryAllocationMeterResponse", + encode(message: QueryAllocationMeterResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.allocationMeter !== undefined) { + DecCoin.encode(message.allocationMeter, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryAllocationMeterResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryAllocationMeterResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.allocationMeter = DecCoin.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryAllocationMeterResponse { + const obj = createBaseQueryAllocationMeterResponse(); + if (isSet(object.allocationMeter)) obj.allocationMeter = DecCoin.fromJSON(object.allocationMeter); + return obj; + }, + toJSON(message: QueryAllocationMeterResponse): JsonSafe { + const obj: any = {}; + message.allocationMeter !== undefined && (obj.allocationMeter = message.allocationMeter ? DecCoin.toJSON(message.allocationMeter) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryAllocationMeterResponse { + const message = createBaseQueryAllocationMeterResponse(); + if (object.allocationMeter !== undefined && object.allocationMeter !== null) { + message.allocationMeter = DecCoin.fromPartial(object.allocationMeter); + } + return message; + }, + fromSDK(object: QueryAllocationMeterResponseSDKType): QueryAllocationMeterResponse { + return { + allocationMeter: object.allocation_meter ? DecCoin.fromSDK(object.allocation_meter) : undefined + }; + }, + fromSDKJSON(object: any): QueryAllocationMeterResponseSDKType { + return { + allocation_meter: isSet(object.allocation_meter) ? DecCoin.fromSDKJSON(object.allocation_meter) : undefined + }; + }, + toSDK(message: QueryAllocationMeterResponse): QueryAllocationMeterResponseSDKType { + const obj: any = {}; + message.allocationMeter !== undefined && (obj.allocation_meter = message.allocationMeter ? DecCoin.toSDK(message.allocationMeter) : undefined); + return obj; + }, + fromAmino(object: QueryAllocationMeterResponseAmino): QueryAllocationMeterResponse { + const message = createBaseQueryAllocationMeterResponse(); + if (object.allocation_meter !== undefined && object.allocation_meter !== null) { + message.allocationMeter = DecCoin.fromAmino(object.allocation_meter); + } + return message; + }, + toAmino(message: QueryAllocationMeterResponse): QueryAllocationMeterResponseAmino { + const obj: any = {}; + obj.allocation_meter = message.allocationMeter ? DecCoin.toAmino(message.allocationMeter) : undefined; + return obj; + }, + fromAminoMsg(object: QueryAllocationMeterResponseAminoMsg): QueryAllocationMeterResponse { + return QueryAllocationMeterResponse.fromAmino(object.value); + }, + fromProtoMsg(message: QueryAllocationMeterResponseProtoMsg): QueryAllocationMeterResponse { + return QueryAllocationMeterResponse.decode(message.value); + }, + toProto(message: QueryAllocationMeterResponse): Uint8Array { + return QueryAllocationMeterResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryAllocationMeterResponse): QueryAllocationMeterResponseProtoMsg { + return { + typeUrl: "/evmos.incentives.v1.QueryAllocationMeterResponse", + value: QueryAllocationMeterResponse.encode(message).finish() + }; + } +}; +function createBaseQueryParamsRequest(): QueryParamsRequest { + return {}; +} +export const QueryParamsRequest = { + typeUrl: "/evmos.incentives.v1.QueryParamsRequest", + encode(_: QueryParamsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryParamsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryParamsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): QueryParamsRequest { + const obj = createBaseQueryParamsRequest(); + return obj; + }, + toJSON(_: QueryParamsRequest): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): QueryParamsRequest { + const message = createBaseQueryParamsRequest(); + return message; + }, + fromSDK(_: QueryParamsRequestSDKType): QueryParamsRequest { + return {}; + }, + fromSDKJSON(_: any): QueryParamsRequestSDKType { + return {}; + }, + toSDK(_: QueryParamsRequest): QueryParamsRequestSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: QueryParamsRequestAmino): QueryParamsRequest { + const message = createBaseQueryParamsRequest(); + return message; + }, + toAmino(_: QueryParamsRequest): QueryParamsRequestAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: QueryParamsRequestAminoMsg): QueryParamsRequest { + return QueryParamsRequest.fromAmino(object.value); + }, + fromProtoMsg(message: QueryParamsRequestProtoMsg): QueryParamsRequest { + return QueryParamsRequest.decode(message.value); + }, + toProto(message: QueryParamsRequest): Uint8Array { + return QueryParamsRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryParamsRequest): QueryParamsRequestProtoMsg { + return { + typeUrl: "/evmos.incentives.v1.QueryParamsRequest", + value: QueryParamsRequest.encode(message).finish() + }; + } +}; +function createBaseQueryParamsResponse(): QueryParamsResponse { + return { + params: Params.fromPartial({}) + }; +} +export const QueryParamsResponse = { + typeUrl: "/evmos.incentives.v1.QueryParamsResponse", + encode(message: QueryParamsResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryParamsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryParamsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.params = Params.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryParamsResponse { + const obj = createBaseQueryParamsResponse(); + if (isSet(object.params)) obj.params = Params.fromJSON(object.params); + return obj; + }, + toJSON(message: QueryParamsResponse): JsonSafe { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryParamsResponse { + const message = createBaseQueryParamsResponse(); + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } + return message; + }, + fromSDK(object: QueryParamsResponseSDKType): QueryParamsResponse { + return { + params: object.params ? Params.fromSDK(object.params) : undefined + }; + }, + fromSDKJSON(object: any): QueryParamsResponseSDKType { + return { + params: isSet(object.params) ? Params.fromSDKJSON(object.params) : undefined + }; + }, + toSDK(message: QueryParamsResponse): QueryParamsResponseSDKType { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toSDK(message.params) : undefined); + return obj; + }, + fromAmino(object: QueryParamsResponseAmino): QueryParamsResponse { + const message = createBaseQueryParamsResponse(); + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromAmino(object.params); + } + return message; + }, + toAmino(message: QueryParamsResponse): QueryParamsResponseAmino { + const obj: any = {}; + obj.params = message.params ? Params.toAmino(message.params) : undefined; + return obj; + }, + fromAminoMsg(object: QueryParamsResponseAminoMsg): QueryParamsResponse { + return QueryParamsResponse.fromAmino(object.value); + }, + fromProtoMsg(message: QueryParamsResponseProtoMsg): QueryParamsResponse { + return QueryParamsResponse.decode(message.value); + }, + toProto(message: QueryParamsResponse): Uint8Array { + return QueryParamsResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryParamsResponse): QueryParamsResponseProtoMsg { + return { + typeUrl: "/evmos.incentives.v1.QueryParamsResponse", + value: QueryParamsResponse.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/evmos/inflation/v1/genesis.ts b/__fixtures__/v-next/outputicjsdeps/evmos/inflation/v1/genesis.ts new file mode 100644 index 0000000000..afd1e2695b --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/evmos/inflation/v1/genesis.ts @@ -0,0 +1,359 @@ +import { ExponentialCalculation, ExponentialCalculationSDKType, InflationDistribution, InflationDistributionSDKType } from "./inflation.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "evmos.inflation.v1"; +/** GenesisState defines the inflation module's genesis state. */ +export interface GenesisState { + /** params defines all the paramaters of the module. */ + params: Params; + /** amount of past periods, based on the epochs per period param */ + period: bigint; + /** inflation epoch identifier */ + epochIdentifier: string; + /** number of epochs after which inflation is recalculated */ + epochsPerPeriod: bigint; + /** number of epochs that have passed while inflation is disabled */ + skippedEpochs: bigint; +} +export interface GenesisStateProtoMsg { + typeUrl: "/evmos.inflation.v1.GenesisState"; + value: Uint8Array; +} +/** GenesisState defines the inflation module's genesis state. */ +export interface GenesisStateSDKType { + params: ParamsSDKType; + period: bigint; + epoch_identifier: string; + epochs_per_period: bigint; + skipped_epochs: bigint; +} +/** Params holds parameters for the inflation module. */ +export interface Params { + /** type of coin to mint */ + mintDenom: string; + /** variables to calculate exponential inflation */ + exponentialCalculation: ExponentialCalculation; + /** inflation distribution of the minted denom */ + inflationDistribution: InflationDistribution; + /** parameter to enable inflation and halt increasing the skipped_epochs */ + enableInflation: boolean; +} +export interface ParamsProtoMsg { + typeUrl: "/evmos.inflation.v1.Params"; + value: Uint8Array; +} +/** Params holds parameters for the inflation module. */ +export interface ParamsSDKType { + mint_denom: string; + exponential_calculation: ExponentialCalculationSDKType; + inflation_distribution: InflationDistributionSDKType; + enable_inflation: boolean; +} +function createBaseGenesisState(): GenesisState { + return { + params: Params.fromPartial({}), + period: BigInt(0), + epochIdentifier: "", + epochsPerPeriod: BigInt(0), + skippedEpochs: BigInt(0) + }; +} +export const GenesisState = { + typeUrl: "/evmos.inflation.v1.GenesisState", + encode(message: GenesisState, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(10).fork()).ldelim(); + } + if (message.period !== undefined) { + writer.uint32(16).uint64(message.period); + } + if (message.epochIdentifier !== undefined) { + writer.uint32(26).string(message.epochIdentifier); + } + if (message.epochsPerPeriod !== undefined) { + writer.uint32(32).int64(message.epochsPerPeriod); + } + if (message.skippedEpochs !== undefined) { + writer.uint32(40).uint64(message.skippedEpochs); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GenesisState { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGenesisState(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.params = Params.decode(reader, reader.uint32()); + break; + case 2: + message.period = reader.uint64(); + break; + case 3: + message.epochIdentifier = reader.string(); + break; + case 4: + message.epochsPerPeriod = reader.int64(); + break; + case 5: + message.skippedEpochs = reader.uint64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GenesisState { + const obj = createBaseGenesisState(); + if (isSet(object.params)) obj.params = Params.fromJSON(object.params); + if (isSet(object.period)) obj.period = BigInt(object.period.toString()); + if (isSet(object.epochIdentifier)) obj.epochIdentifier = String(object.epochIdentifier); + if (isSet(object.epochsPerPeriod)) obj.epochsPerPeriod = BigInt(object.epochsPerPeriod.toString()); + if (isSet(object.skippedEpochs)) obj.skippedEpochs = BigInt(object.skippedEpochs.toString()); + return obj; + }, + toJSON(message: GenesisState): JsonSafe { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); + message.period !== undefined && (obj.period = (message.period || BigInt(0)).toString()); + message.epochIdentifier !== undefined && (obj.epochIdentifier = message.epochIdentifier); + message.epochsPerPeriod !== undefined && (obj.epochsPerPeriod = (message.epochsPerPeriod || BigInt(0)).toString()); + message.skippedEpochs !== undefined && (obj.skippedEpochs = (message.skippedEpochs || BigInt(0)).toString()); + return obj; + }, + fromPartial(object: DeepPartial): GenesisState { + const message = createBaseGenesisState(); + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } + if (object.period !== undefined && object.period !== null) { + message.period = BigInt(object.period.toString()); + } + message.epochIdentifier = object.epochIdentifier ?? ""; + if (object.epochsPerPeriod !== undefined && object.epochsPerPeriod !== null) { + message.epochsPerPeriod = BigInt(object.epochsPerPeriod.toString()); + } + if (object.skippedEpochs !== undefined && object.skippedEpochs !== null) { + message.skippedEpochs = BigInt(object.skippedEpochs.toString()); + } + return message; + }, + fromSDK(object: GenesisStateSDKType): GenesisState { + return { + params: object.params ? Params.fromSDK(object.params) : undefined, + period: object?.period, + epochIdentifier: object?.epoch_identifier, + epochsPerPeriod: object?.epochs_per_period, + skippedEpochs: object?.skipped_epochs + }; + }, + fromSDKJSON(object: any): GenesisStateSDKType { + return { + params: isSet(object.params) ? Params.fromSDKJSON(object.params) : undefined, + period: isSet(object.period) ? BigInt(object.period.toString()) : BigInt(0), + epoch_identifier: isSet(object.epoch_identifier) ? String(object.epoch_identifier) : "", + epochs_per_period: isSet(object.epochs_per_period) ? BigInt(object.epochs_per_period.toString()) : BigInt(0), + skipped_epochs: isSet(object.skipped_epochs) ? BigInt(object.skipped_epochs.toString()) : BigInt(0) + }; + }, + toSDK(message: GenesisState): GenesisStateSDKType { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toSDK(message.params) : undefined); + obj.period = message.period; + obj.epoch_identifier = message.epochIdentifier; + obj.epochs_per_period = message.epochsPerPeriod; + obj.skipped_epochs = message.skippedEpochs; + return obj; + }, + fromAmino(object: GenesisStateAmino): GenesisState { + const message = createBaseGenesisState(); + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromAmino(object.params); + } + if (object.period !== undefined && object.period !== null) { + message.period = BigInt(object.period); + } + if (object.epoch_identifier !== undefined && object.epoch_identifier !== null) { + message.epochIdentifier = object.epoch_identifier; + } + if (object.epochs_per_period !== undefined && object.epochs_per_period !== null) { + message.epochsPerPeriod = BigInt(object.epochs_per_period); + } + if (object.skipped_epochs !== undefined && object.skipped_epochs !== null) { + message.skippedEpochs = BigInt(object.skipped_epochs); + } + return message; + }, + toAmino(message: GenesisState): GenesisStateAmino { + const obj: any = {}; + obj.params = message.params ? Params.toAmino(message.params) : undefined; + obj.period = message.period !== BigInt(0) ? message.period?.toString() : undefined; + obj.epoch_identifier = message.epochIdentifier === "" ? undefined : message.epochIdentifier; + obj.epochs_per_period = message.epochsPerPeriod !== BigInt(0) ? message.epochsPerPeriod?.toString() : undefined; + obj.skipped_epochs = message.skippedEpochs !== BigInt(0) ? message.skippedEpochs?.toString() : undefined; + return obj; + }, + fromAminoMsg(object: GenesisStateAminoMsg): GenesisState { + return GenesisState.fromAmino(object.value); + }, + fromProtoMsg(message: GenesisStateProtoMsg): GenesisState { + return GenesisState.decode(message.value); + }, + toProto(message: GenesisState): Uint8Array { + return GenesisState.encode(message).finish(); + }, + toProtoMsg(message: GenesisState): GenesisStateProtoMsg { + return { + typeUrl: "/evmos.inflation.v1.GenesisState", + value: GenesisState.encode(message).finish() + }; + } +}; +function createBaseParams(): Params { + return { + mintDenom: "", + exponentialCalculation: ExponentialCalculation.fromPartial({}), + inflationDistribution: InflationDistribution.fromPartial({}), + enableInflation: false + }; +} +export const Params = { + typeUrl: "/evmos.inflation.v1.Params", + encode(message: Params, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.mintDenom !== undefined) { + writer.uint32(10).string(message.mintDenom); + } + if (message.exponentialCalculation !== undefined) { + ExponentialCalculation.encode(message.exponentialCalculation, writer.uint32(18).fork()).ldelim(); + } + if (message.inflationDistribution !== undefined) { + InflationDistribution.encode(message.inflationDistribution, writer.uint32(26).fork()).ldelim(); + } + if (message.enableInflation !== undefined) { + writer.uint32(32).bool(message.enableInflation); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Params { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseParams(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.mintDenom = reader.string(); + break; + case 2: + message.exponentialCalculation = ExponentialCalculation.decode(reader, reader.uint32()); + break; + case 3: + message.inflationDistribution = InflationDistribution.decode(reader, reader.uint32()); + break; + case 4: + message.enableInflation = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Params { + const obj = createBaseParams(); + if (isSet(object.mintDenom)) obj.mintDenom = String(object.mintDenom); + if (isSet(object.exponentialCalculation)) obj.exponentialCalculation = ExponentialCalculation.fromJSON(object.exponentialCalculation); + if (isSet(object.inflationDistribution)) obj.inflationDistribution = InflationDistribution.fromJSON(object.inflationDistribution); + if (isSet(object.enableInflation)) obj.enableInflation = Boolean(object.enableInflation); + return obj; + }, + toJSON(message: Params): JsonSafe { + const obj: any = {}; + message.mintDenom !== undefined && (obj.mintDenom = message.mintDenom); + message.exponentialCalculation !== undefined && (obj.exponentialCalculation = message.exponentialCalculation ? ExponentialCalculation.toJSON(message.exponentialCalculation) : undefined); + message.inflationDistribution !== undefined && (obj.inflationDistribution = message.inflationDistribution ? InflationDistribution.toJSON(message.inflationDistribution) : undefined); + message.enableInflation !== undefined && (obj.enableInflation = message.enableInflation); + return obj; + }, + fromPartial(object: DeepPartial): Params { + const message = createBaseParams(); + message.mintDenom = object.mintDenom ?? ""; + if (object.exponentialCalculation !== undefined && object.exponentialCalculation !== null) { + message.exponentialCalculation = ExponentialCalculation.fromPartial(object.exponentialCalculation); + } + if (object.inflationDistribution !== undefined && object.inflationDistribution !== null) { + message.inflationDistribution = InflationDistribution.fromPartial(object.inflationDistribution); + } + message.enableInflation = object.enableInflation ?? false; + return message; + }, + fromSDK(object: ParamsSDKType): Params { + return { + mintDenom: object?.mint_denom, + exponentialCalculation: object.exponential_calculation ? ExponentialCalculation.fromSDK(object.exponential_calculation) : undefined, + inflationDistribution: object.inflation_distribution ? InflationDistribution.fromSDK(object.inflation_distribution) : undefined, + enableInflation: object?.enable_inflation + }; + }, + fromSDKJSON(object: any): ParamsSDKType { + return { + mint_denom: isSet(object.mint_denom) ? String(object.mint_denom) : "", + exponential_calculation: isSet(object.exponential_calculation) ? ExponentialCalculation.fromSDKJSON(object.exponential_calculation) : undefined, + inflation_distribution: isSet(object.inflation_distribution) ? InflationDistribution.fromSDKJSON(object.inflation_distribution) : undefined, + enable_inflation: isSet(object.enable_inflation) ? Boolean(object.enable_inflation) : false + }; + }, + toSDK(message: Params): ParamsSDKType { + const obj: any = {}; + obj.mint_denom = message.mintDenom; + message.exponentialCalculation !== undefined && (obj.exponential_calculation = message.exponentialCalculation ? ExponentialCalculation.toSDK(message.exponentialCalculation) : undefined); + message.inflationDistribution !== undefined && (obj.inflation_distribution = message.inflationDistribution ? InflationDistribution.toSDK(message.inflationDistribution) : undefined); + obj.enable_inflation = message.enableInflation; + return obj; + }, + fromAmino(object: ParamsAmino): Params { + const message = createBaseParams(); + if (object.mint_denom !== undefined && object.mint_denom !== null) { + message.mintDenom = object.mint_denom; + } + if (object.exponential_calculation !== undefined && object.exponential_calculation !== null) { + message.exponentialCalculation = ExponentialCalculation.fromAmino(object.exponential_calculation); + } + if (object.inflation_distribution !== undefined && object.inflation_distribution !== null) { + message.inflationDistribution = InflationDistribution.fromAmino(object.inflation_distribution); + } + if (object.enable_inflation !== undefined && object.enable_inflation !== null) { + message.enableInflation = object.enable_inflation; + } + return message; + }, + toAmino(message: Params): ParamsAmino { + const obj: any = {}; + obj.mint_denom = message.mintDenom === "" ? undefined : message.mintDenom; + obj.exponential_calculation = message.exponentialCalculation ? ExponentialCalculation.toAmino(message.exponentialCalculation) : undefined; + obj.inflation_distribution = message.inflationDistribution ? InflationDistribution.toAmino(message.inflationDistribution) : undefined; + obj.enable_inflation = message.enableInflation === false ? undefined : message.enableInflation; + return obj; + }, + fromAminoMsg(object: ParamsAminoMsg): Params { + return Params.fromAmino(object.value); + }, + fromProtoMsg(message: ParamsProtoMsg): Params { + return Params.decode(message.value); + }, + toProto(message: Params): Uint8Array { + return Params.encode(message).finish(); + }, + toProtoMsg(message: Params): ParamsProtoMsg { + return { + typeUrl: "/evmos.inflation.v1.Params", + value: Params.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/evmos/inflation/v1/inflation.ts b/__fixtures__/v-next/outputicjsdeps/evmos/inflation/v1/inflation.ts new file mode 100644 index 0000000000..3e3e763054 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/evmos/inflation/v1/inflation.ts @@ -0,0 +1,364 @@ +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { Decimal } from "@cosmjs/math"; +import { isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "evmos.inflation.v1"; +/** + * InflationDistribution defines the distribution in which inflation is + * allocated through minting on each epoch (staking, incentives, community). It + * excludes the team vesting distribution, as this is minted once at genesis. + * The initial InflationDistribution can be calculated from the Evmos Token + * Model like this: + * mintDistribution1 = distribution1 / (1 - teamVestingDistribution) + * 0.5333333 = 40% / (1 - 25%) + */ +export interface InflationDistribution { + /** + * staking_rewards defines the proportion of the minted minted_denom that is + * to be allocated as staking rewards + */ + stakingRewards: string; + /** + * usage_incentives defines the proportion of the minted minted_denom that is + * to be allocated to the incentives module address + */ + usageIncentives: string; + /** + * community_pool defines the proportion of the minted minted_denom that is to + * be allocated to the community pool + */ + communityPool: string; +} +export interface InflationDistributionProtoMsg { + typeUrl: "/evmos.inflation.v1.InflationDistribution"; + value: Uint8Array; +} +/** + * InflationDistribution defines the distribution in which inflation is + * allocated through minting on each epoch (staking, incentives, community). It + * excludes the team vesting distribution, as this is minted once at genesis. + * The initial InflationDistribution can be calculated from the Evmos Token + * Model like this: + * mintDistribution1 = distribution1 / (1 - teamVestingDistribution) + * 0.5333333 = 40% / (1 - 25%) + */ +export interface InflationDistributionSDKType { + staking_rewards: string; + usage_incentives: string; + community_pool: string; +} +/** + * ExponentialCalculation holds factors to calculate exponential inflation on + * each period. Calculation reference: + * periodProvision = exponentialDecay * bondingIncentive + * f(x) = (a * (1 - r) ^ x + c) * (1 + max_variance - bondedRatio * + * (max_variance / bonding_target)) + */ +export interface ExponentialCalculation { + /** initial value */ + a: string; + /** reduction factor */ + r: string; + /** long term inflation */ + c: string; + /** bonding target */ + bondingTarget: string; + /** max variance */ + maxVariance: string; +} +export interface ExponentialCalculationProtoMsg { + typeUrl: "/evmos.inflation.v1.ExponentialCalculation"; + value: Uint8Array; +} +/** + * ExponentialCalculation holds factors to calculate exponential inflation on + * each period. Calculation reference: + * periodProvision = exponentialDecay * bondingIncentive + * f(x) = (a * (1 - r) ^ x + c) * (1 + max_variance - bondedRatio * + * (max_variance / bonding_target)) + */ +export interface ExponentialCalculationSDKType { + a: string; + r: string; + c: string; + bonding_target: string; + max_variance: string; +} +function createBaseInflationDistribution(): InflationDistribution { + return { + stakingRewards: "", + usageIncentives: "", + communityPool: "" + }; +} +export const InflationDistribution = { + typeUrl: "/evmos.inflation.v1.InflationDistribution", + encode(message: InflationDistribution, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.stakingRewards !== undefined) { + writer.uint32(10).string(Decimal.fromUserInput(message.stakingRewards, 18).atomics); + } + if (message.usageIncentives !== undefined) { + writer.uint32(18).string(Decimal.fromUserInput(message.usageIncentives, 18).atomics); + } + if (message.communityPool !== undefined) { + writer.uint32(26).string(Decimal.fromUserInput(message.communityPool, 18).atomics); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): InflationDistribution { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseInflationDistribution(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.stakingRewards = Decimal.fromAtomics(reader.string(), 18).toString(); + break; + case 2: + message.usageIncentives = Decimal.fromAtomics(reader.string(), 18).toString(); + break; + case 3: + message.communityPool = Decimal.fromAtomics(reader.string(), 18).toString(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): InflationDistribution { + const obj = createBaseInflationDistribution(); + if (isSet(object.stakingRewards)) obj.stakingRewards = String(object.stakingRewards); + if (isSet(object.usageIncentives)) obj.usageIncentives = String(object.usageIncentives); + if (isSet(object.communityPool)) obj.communityPool = String(object.communityPool); + return obj; + }, + toJSON(message: InflationDistribution): JsonSafe { + const obj: any = {}; + message.stakingRewards !== undefined && (obj.stakingRewards = message.stakingRewards); + message.usageIncentives !== undefined && (obj.usageIncentives = message.usageIncentives); + message.communityPool !== undefined && (obj.communityPool = message.communityPool); + return obj; + }, + fromPartial(object: DeepPartial): InflationDistribution { + const message = createBaseInflationDistribution(); + message.stakingRewards = object.stakingRewards ?? ""; + message.usageIncentives = object.usageIncentives ?? ""; + message.communityPool = object.communityPool ?? ""; + return message; + }, + fromSDK(object: InflationDistributionSDKType): InflationDistribution { + return { + stakingRewards: object?.staking_rewards, + usageIncentives: object?.usage_incentives, + communityPool: object?.community_pool + }; + }, + fromSDKJSON(object: any): InflationDistributionSDKType { + return { + staking_rewards: isSet(object.staking_rewards) ? String(object.staking_rewards) : "", + usage_incentives: isSet(object.usage_incentives) ? String(object.usage_incentives) : "", + community_pool: isSet(object.community_pool) ? String(object.community_pool) : "" + }; + }, + toSDK(message: InflationDistribution): InflationDistributionSDKType { + const obj: any = {}; + obj.staking_rewards = message.stakingRewards; + obj.usage_incentives = message.usageIncentives; + obj.community_pool = message.communityPool; + return obj; + }, + fromAmino(object: InflationDistributionAmino): InflationDistribution { + const message = createBaseInflationDistribution(); + if (object.staking_rewards !== undefined && object.staking_rewards !== null) { + message.stakingRewards = object.staking_rewards; + } + if (object.usage_incentives !== undefined && object.usage_incentives !== null) { + message.usageIncentives = object.usage_incentives; + } + if (object.community_pool !== undefined && object.community_pool !== null) { + message.communityPool = object.community_pool; + } + return message; + }, + toAmino(message: InflationDistribution): InflationDistributionAmino { + const obj: any = {}; + obj.staking_rewards = message.stakingRewards === "" ? undefined : message.stakingRewards; + obj.usage_incentives = message.usageIncentives === "" ? undefined : message.usageIncentives; + obj.community_pool = message.communityPool === "" ? undefined : message.communityPool; + return obj; + }, + fromAminoMsg(object: InflationDistributionAminoMsg): InflationDistribution { + return InflationDistribution.fromAmino(object.value); + }, + fromProtoMsg(message: InflationDistributionProtoMsg): InflationDistribution { + return InflationDistribution.decode(message.value); + }, + toProto(message: InflationDistribution): Uint8Array { + return InflationDistribution.encode(message).finish(); + }, + toProtoMsg(message: InflationDistribution): InflationDistributionProtoMsg { + return { + typeUrl: "/evmos.inflation.v1.InflationDistribution", + value: InflationDistribution.encode(message).finish() + }; + } +}; +function createBaseExponentialCalculation(): ExponentialCalculation { + return { + a: "", + r: "", + c: "", + bondingTarget: "", + maxVariance: "" + }; +} +export const ExponentialCalculation = { + typeUrl: "/evmos.inflation.v1.ExponentialCalculation", + encode(message: ExponentialCalculation, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.a !== undefined) { + writer.uint32(10).string(Decimal.fromUserInput(message.a, 18).atomics); + } + if (message.r !== undefined) { + writer.uint32(18).string(Decimal.fromUserInput(message.r, 18).atomics); + } + if (message.c !== undefined) { + writer.uint32(26).string(Decimal.fromUserInput(message.c, 18).atomics); + } + if (message.bondingTarget !== undefined) { + writer.uint32(34).string(Decimal.fromUserInput(message.bondingTarget, 18).atomics); + } + if (message.maxVariance !== undefined) { + writer.uint32(42).string(Decimal.fromUserInput(message.maxVariance, 18).atomics); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ExponentialCalculation { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseExponentialCalculation(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.a = Decimal.fromAtomics(reader.string(), 18).toString(); + break; + case 2: + message.r = Decimal.fromAtomics(reader.string(), 18).toString(); + break; + case 3: + message.c = Decimal.fromAtomics(reader.string(), 18).toString(); + break; + case 4: + message.bondingTarget = Decimal.fromAtomics(reader.string(), 18).toString(); + break; + case 5: + message.maxVariance = Decimal.fromAtomics(reader.string(), 18).toString(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ExponentialCalculation { + const obj = createBaseExponentialCalculation(); + if (isSet(object.a)) obj.a = String(object.a); + if (isSet(object.r)) obj.r = String(object.r); + if (isSet(object.c)) obj.c = String(object.c); + if (isSet(object.bondingTarget)) obj.bondingTarget = String(object.bondingTarget); + if (isSet(object.maxVariance)) obj.maxVariance = String(object.maxVariance); + return obj; + }, + toJSON(message: ExponentialCalculation): JsonSafe { + const obj: any = {}; + message.a !== undefined && (obj.a = message.a); + message.r !== undefined && (obj.r = message.r); + message.c !== undefined && (obj.c = message.c); + message.bondingTarget !== undefined && (obj.bondingTarget = message.bondingTarget); + message.maxVariance !== undefined && (obj.maxVariance = message.maxVariance); + return obj; + }, + fromPartial(object: DeepPartial): ExponentialCalculation { + const message = createBaseExponentialCalculation(); + message.a = object.a ?? ""; + message.r = object.r ?? ""; + message.c = object.c ?? ""; + message.bondingTarget = object.bondingTarget ?? ""; + message.maxVariance = object.maxVariance ?? ""; + return message; + }, + fromSDK(object: ExponentialCalculationSDKType): ExponentialCalculation { + return { + a: object?.a, + r: object?.r, + c: object?.c, + bondingTarget: object?.bonding_target, + maxVariance: object?.max_variance + }; + }, + fromSDKJSON(object: any): ExponentialCalculationSDKType { + return { + a: isSet(object.a) ? String(object.a) : "", + r: isSet(object.r) ? String(object.r) : "", + c: isSet(object.c) ? String(object.c) : "", + bonding_target: isSet(object.bonding_target) ? String(object.bonding_target) : "", + max_variance: isSet(object.max_variance) ? String(object.max_variance) : "" + }; + }, + toSDK(message: ExponentialCalculation): ExponentialCalculationSDKType { + const obj: any = {}; + obj.a = message.a; + obj.r = message.r; + obj.c = message.c; + obj.bonding_target = message.bondingTarget; + obj.max_variance = message.maxVariance; + return obj; + }, + fromAmino(object: ExponentialCalculationAmino): ExponentialCalculation { + const message = createBaseExponentialCalculation(); + if (object.a !== undefined && object.a !== null) { + message.a = object.a; + } + if (object.r !== undefined && object.r !== null) { + message.r = object.r; + } + if (object.c !== undefined && object.c !== null) { + message.c = object.c; + } + if (object.bonding_target !== undefined && object.bonding_target !== null) { + message.bondingTarget = object.bonding_target; + } + if (object.max_variance !== undefined && object.max_variance !== null) { + message.maxVariance = object.max_variance; + } + return message; + }, + toAmino(message: ExponentialCalculation): ExponentialCalculationAmino { + const obj: any = {}; + obj.a = message.a === "" ? undefined : message.a; + obj.r = message.r === "" ? undefined : message.r; + obj.c = message.c === "" ? undefined : message.c; + obj.bonding_target = message.bondingTarget === "" ? undefined : message.bondingTarget; + obj.max_variance = message.maxVariance === "" ? undefined : message.maxVariance; + return obj; + }, + fromAminoMsg(object: ExponentialCalculationAminoMsg): ExponentialCalculation { + return ExponentialCalculation.fromAmino(object.value); + }, + fromProtoMsg(message: ExponentialCalculationProtoMsg): ExponentialCalculation { + return ExponentialCalculation.decode(message.value); + }, + toProto(message: ExponentialCalculation): Uint8Array { + return ExponentialCalculation.encode(message).finish(); + }, + toProtoMsg(message: ExponentialCalculation): ExponentialCalculationProtoMsg { + return { + typeUrl: "/evmos.inflation.v1.ExponentialCalculation", + value: ExponentialCalculation.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/evmos/inflation/v1/query.lcd.ts b/__fixtures__/v-next/outputicjsdeps/evmos/inflation/v1/query.lcd.ts new file mode 100644 index 0000000000..c0003be8a7 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/evmos/inflation/v1/query.lcd.ts @@ -0,0 +1,51 @@ +import { DecCoin, DecCoinSDKType } from "../../../cosmos/base/v1beta1/coin.js"; +import { Params, ParamsSDKType } from "./genesis.js"; +import { LCDClient } from "@cosmology/lcd"; +import { QueryPeriodRequest, QueryPeriodRequestSDKType, QueryPeriodResponse, QueryPeriodResponseSDKType, QueryEpochMintProvisionRequest, QueryEpochMintProvisionRequestSDKType, QueryEpochMintProvisionResponse, QueryEpochMintProvisionResponseSDKType, QuerySkippedEpochsRequest, QuerySkippedEpochsRequestSDKType, QuerySkippedEpochsResponse, QuerySkippedEpochsResponseSDKType, QueryCirculatingSupplyRequest, QueryCirculatingSupplyRequestSDKType, QueryCirculatingSupplyResponse, QueryCirculatingSupplyResponseSDKType, QueryInflationRateRequest, QueryInflationRateRequestSDKType, QueryInflationRateResponse, QueryInflationRateResponseSDKType, QueryParamsRequest, QueryParamsRequestSDKType, QueryParamsResponse, QueryParamsResponseSDKType } from "./query.js"; +export class LCDQueryClient { + req: LCDClient; + constructor({ + requestClient + }: { + requestClient: LCDClient; + }) { + this.req = requestClient; + this.period = this.period.bind(this); + this.epochMintProvision = this.epochMintProvision.bind(this); + this.skippedEpochs = this.skippedEpochs.bind(this); + this.circulatingSupply = this.circulatingSupply.bind(this); + this.inflationRate = this.inflationRate.bind(this); + this.params = this.params.bind(this); + } + /* Period retrieves current period. */ + async period(_params: QueryPeriodRequest = {}): Promise { + const endpoint = `evmos/inflation/v1/period`; + return QueryPeriodResponse.fromSDKJSON(await this.req.get(endpoint)); + } + /* EpochMintProvision retrieves current minting epoch provision value. */ + async epochMintProvision(_params: QueryEpochMintProvisionRequest = {}): Promise { + const endpoint = `evmos/inflation/v1/epoch_mint_provision`; + return QueryEpochMintProvisionResponse.fromSDKJSON(await this.req.get(endpoint)); + } + /* SkippedEpochs retrieves the total number of skipped epochs. */ + async skippedEpochs(_params: QuerySkippedEpochsRequest = {}): Promise { + const endpoint = `evmos/inflation/v1/skipped_epochs`; + return QuerySkippedEpochsResponse.fromSDKJSON(await this.req.get(endpoint)); + } + /* CirculatingSupply retrieves the total number of tokens that are in + circulation (i.e. excluding unvested tokens). */ + async circulatingSupply(_params: QueryCirculatingSupplyRequest = {}): Promise { + const endpoint = `evmos/inflation/v1/circulating_supply`; + return QueryCirculatingSupplyResponse.fromSDKJSON(await this.req.get(endpoint)); + } + /* InflationRate retrieves the inflation rate of the current period. */ + async inflationRate(_params: QueryInflationRateRequest = {}): Promise { + const endpoint = `evmos/inflation/v1/inflation_rate`; + return QueryInflationRateResponse.fromSDKJSON(await this.req.get(endpoint)); + } + /* Params retrieves the total set of minting parameters. */ + async params(_params: QueryParamsRequest = {}): Promise { + const endpoint = `evmos/inflation/v1/params`; + return QueryParamsResponse.fromSDKJSON(await this.req.get(endpoint)); + } +} \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/evmos/inflation/v1/query.rpc.Query.ts b/__fixtures__/v-next/outputicjsdeps/evmos/inflation/v1/query.rpc.Query.ts new file mode 100644 index 0000000000..8fd4bb0327 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/evmos/inflation/v1/query.rpc.Query.ts @@ -0,0 +1,90 @@ +import { DecCoin, DecCoinSDKType } from "../../../cosmos/base/v1beta1/coin.js"; +import { Params, ParamsSDKType } from "./genesis.js"; +import { Rpc } from "../../../helpers.js"; +import { BinaryReader } from "../../../binary.js"; +import { QueryClient, createProtobufRpcClient } from "@cosmjs/stargate"; +import { QueryPeriodRequest, QueryPeriodRequestSDKType, QueryPeriodResponse, QueryPeriodResponseSDKType, QueryEpochMintProvisionRequest, QueryEpochMintProvisionRequestSDKType, QueryEpochMintProvisionResponse, QueryEpochMintProvisionResponseSDKType, QuerySkippedEpochsRequest, QuerySkippedEpochsRequestSDKType, QuerySkippedEpochsResponse, QuerySkippedEpochsResponseSDKType, QueryCirculatingSupplyRequest, QueryCirculatingSupplyRequestSDKType, QueryCirculatingSupplyResponse, QueryCirculatingSupplyResponseSDKType, QueryInflationRateRequest, QueryInflationRateRequestSDKType, QueryInflationRateResponse, QueryInflationRateResponseSDKType, QueryParamsRequest, QueryParamsRequestSDKType, QueryParamsResponse, QueryParamsResponseSDKType } from "./query.js"; +/** Query provides defines the gRPC querier service. */ +export interface Query { + /** Period retrieves current period. */ + period(request?: QueryPeriodRequest): Promise; + /** EpochMintProvision retrieves current minting epoch provision value. */ + epochMintProvision(request?: QueryEpochMintProvisionRequest): Promise; + /** SkippedEpochs retrieves the total number of skipped epochs. */ + skippedEpochs(request?: QuerySkippedEpochsRequest): Promise; + /** + * CirculatingSupply retrieves the total number of tokens that are in + * circulation (i.e. excluding unvested tokens). + */ + circulatingSupply(request?: QueryCirculatingSupplyRequest): Promise; + /** InflationRate retrieves the inflation rate of the current period. */ + inflationRate(request?: QueryInflationRateRequest): Promise; + /** Params retrieves the total set of minting parameters. */ + params(request?: QueryParamsRequest): Promise; +} +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + this.period = this.period.bind(this); + this.epochMintProvision = this.epochMintProvision.bind(this); + this.skippedEpochs = this.skippedEpochs.bind(this); + this.circulatingSupply = this.circulatingSupply.bind(this); + this.inflationRate = this.inflationRate.bind(this); + this.params = this.params.bind(this); + } + period(request: QueryPeriodRequest = {}): Promise { + const data = QueryPeriodRequest.encode(request).finish(); + const promise = this.rpc.request("evmos.inflation.v1.Query", "Period", data); + return promise.then(data => QueryPeriodResponse.decode(new BinaryReader(data))); + } + epochMintProvision(request: QueryEpochMintProvisionRequest = {}): Promise { + const data = QueryEpochMintProvisionRequest.encode(request).finish(); + const promise = this.rpc.request("evmos.inflation.v1.Query", "EpochMintProvision", data); + return promise.then(data => QueryEpochMintProvisionResponse.decode(new BinaryReader(data))); + } + skippedEpochs(request: QuerySkippedEpochsRequest = {}): Promise { + const data = QuerySkippedEpochsRequest.encode(request).finish(); + const promise = this.rpc.request("evmos.inflation.v1.Query", "SkippedEpochs", data); + return promise.then(data => QuerySkippedEpochsResponse.decode(new BinaryReader(data))); + } + circulatingSupply(request: QueryCirculatingSupplyRequest = {}): Promise { + const data = QueryCirculatingSupplyRequest.encode(request).finish(); + const promise = this.rpc.request("evmos.inflation.v1.Query", "CirculatingSupply", data); + return promise.then(data => QueryCirculatingSupplyResponse.decode(new BinaryReader(data))); + } + inflationRate(request: QueryInflationRateRequest = {}): Promise { + const data = QueryInflationRateRequest.encode(request).finish(); + const promise = this.rpc.request("evmos.inflation.v1.Query", "InflationRate", data); + return promise.then(data => QueryInflationRateResponse.decode(new BinaryReader(data))); + } + params(request: QueryParamsRequest = {}): Promise { + const data = QueryParamsRequest.encode(request).finish(); + const promise = this.rpc.request("evmos.inflation.v1.Query", "Params", data); + return promise.then(data => QueryParamsResponse.decode(new BinaryReader(data))); + } +} +export const createRpcQueryExtension = (base: QueryClient) => { + const rpc = createProtobufRpcClient(base); + const queryService = new QueryClientImpl(rpc); + return { + period(request?: QueryPeriodRequest): Promise { + return queryService.period(request); + }, + epochMintProvision(request?: QueryEpochMintProvisionRequest): Promise { + return queryService.epochMintProvision(request); + }, + skippedEpochs(request?: QuerySkippedEpochsRequest): Promise { + return queryService.skippedEpochs(request); + }, + circulatingSupply(request?: QueryCirculatingSupplyRequest): Promise { + return queryService.circulatingSupply(request); + }, + inflationRate(request?: QueryInflationRateRequest): Promise { + return queryService.inflationRate(request); + }, + params(request?: QueryParamsRequest): Promise { + return queryService.params(request); + } + }; +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/evmos/inflation/v1/query.rpc.func.ts b/__fixtures__/v-next/outputicjsdeps/evmos/inflation/v1/query.rpc.func.ts new file mode 100644 index 0000000000..255c9a9224 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/evmos/inflation/v1/query.rpc.func.ts @@ -0,0 +1,69 @@ +import { RpcResolver, buildQuery } from "../../../helper-func-types"; +import { buildUseQuery } from "../../../react-query"; +import { QueryPeriodRequest, QueryPeriodResponse, QueryEpochMintProvisionRequest, QueryEpochMintProvisionResponse, QuerySkippedEpochsRequest, QuerySkippedEpochsResponse, QueryCirculatingSupplyRequest, QueryCirculatingSupplyResponse, QueryInflationRateRequest, QueryInflationRateResponse, QueryParamsRequest, QueryParamsResponse } from "./query"; +export const createGetPeriod = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryPeriodRequest.encode, + decode: QueryPeriodResponse.decode, + service: "evmos.inflation.v1.Query", + method: "Period", + getRpcInstance: getRpcInstance +}); +export const useGetPeriod = buildUseQuery({ + builderQueryFn: createGetPeriod, + queryKeyPrefix: "PeriodQuery" +}); +export const createGetEpochMintProvision = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryEpochMintProvisionRequest.encode, + decode: QueryEpochMintProvisionResponse.decode, + service: "evmos.inflation.v1.Query", + method: "EpochMintProvision", + getRpcInstance: getRpcInstance +}); +export const useGetEpochMintProvision = buildUseQuery({ + builderQueryFn: createGetEpochMintProvision, + queryKeyPrefix: "EpochMintProvisionQuery" +}); +export const createGetSkippedEpochs = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QuerySkippedEpochsRequest.encode, + decode: QuerySkippedEpochsResponse.decode, + service: "evmos.inflation.v1.Query", + method: "SkippedEpochs", + getRpcInstance: getRpcInstance +}); +export const useGetSkippedEpochs = buildUseQuery({ + builderQueryFn: createGetSkippedEpochs, + queryKeyPrefix: "SkippedEpochsQuery" +}); +export const createGetCirculatingSupply = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryCirculatingSupplyRequest.encode, + decode: QueryCirculatingSupplyResponse.decode, + service: "evmos.inflation.v1.Query", + method: "CirculatingSupply", + getRpcInstance: getRpcInstance +}); +export const useGetCirculatingSupply = buildUseQuery({ + builderQueryFn: createGetCirculatingSupply, + queryKeyPrefix: "CirculatingSupplyQuery" +}); +export const createGetInflationRate = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryInflationRateRequest.encode, + decode: QueryInflationRateResponse.decode, + service: "evmos.inflation.v1.Query", + method: "InflationRate", + getRpcInstance: getRpcInstance +}); +export const useGetInflationRate = buildUseQuery({ + builderQueryFn: createGetInflationRate, + queryKeyPrefix: "InflationRateQuery" +}); +export const createGetParams = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryParamsRequest.encode, + decode: QueryParamsResponse.decode, + service: "evmos.inflation.v1.Query", + method: "Params", + getRpcInstance: getRpcInstance +}); +export const useGetParams = buildUseQuery({ + builderQueryFn: createGetParams, + queryKeyPrefix: "ParamsQuery" +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/evmos/inflation/v1/query.ts b/__fixtures__/v-next/outputicjsdeps/evmos/inflation/v1/query.ts new file mode 100644 index 0000000000..3baa5c0dde --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/evmos/inflation/v1/query.ts @@ -0,0 +1,1127 @@ +import { DecCoin, DecCoinSDKType } from "../../../cosmos/base/v1beta1/coin.js"; +import { Params, ParamsSDKType } from "./genesis.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { JsonSafe } from "../../../json-safe.js"; +import { DeepPartial, isSet } from "../../../helpers.js"; +import { Decimal } from "@cosmjs/math"; +export const protobufPackage = "evmos.inflation.v1"; +/** QueryPeriodRequest is the request type for the Query/Period RPC method. */ +export interface QueryPeriodRequest {} +export interface QueryPeriodRequestProtoMsg { + typeUrl: "/evmos.inflation.v1.QueryPeriodRequest"; + value: Uint8Array; +} +/** QueryPeriodRequest is the request type for the Query/Period RPC method. */ +export interface QueryPeriodRequestSDKType {} +/** QueryPeriodResponse is the response type for the Query/Period RPC method. */ +export interface QueryPeriodResponse { + /** period is the current minting per epoch provision value. */ + period: bigint; +} +export interface QueryPeriodResponseProtoMsg { + typeUrl: "/evmos.inflation.v1.QueryPeriodResponse"; + value: Uint8Array; +} +/** QueryPeriodResponse is the response type for the Query/Period RPC method. */ +export interface QueryPeriodResponseSDKType { + period: bigint; +} +/** + * QueryEpochMintProvisionRequest is the request type for the + * Query/EpochMintProvision RPC method. + */ +export interface QueryEpochMintProvisionRequest {} +export interface QueryEpochMintProvisionRequestProtoMsg { + typeUrl: "/evmos.inflation.v1.QueryEpochMintProvisionRequest"; + value: Uint8Array; +} +/** + * QueryEpochMintProvisionRequest is the request type for the + * Query/EpochMintProvision RPC method. + */ +export interface QueryEpochMintProvisionRequestSDKType {} +/** + * QueryEpochMintProvisionResponse is the response type for the + * Query/EpochMintProvision RPC method. + */ +export interface QueryEpochMintProvisionResponse { + /** epoch_mint_provision is the current minting per epoch provision value. */ + epochMintProvision: DecCoin; +} +export interface QueryEpochMintProvisionResponseProtoMsg { + typeUrl: "/evmos.inflation.v1.QueryEpochMintProvisionResponse"; + value: Uint8Array; +} +/** + * QueryEpochMintProvisionResponse is the response type for the + * Query/EpochMintProvision RPC method. + */ +export interface QueryEpochMintProvisionResponseSDKType { + epoch_mint_provision: DecCoinSDKType; +} +/** + * QuerySkippedEpochsRequest is the request type for the Query/SkippedEpochs RPC + * method. + */ +export interface QuerySkippedEpochsRequest {} +export interface QuerySkippedEpochsRequestProtoMsg { + typeUrl: "/evmos.inflation.v1.QuerySkippedEpochsRequest"; + value: Uint8Array; +} +/** + * QuerySkippedEpochsRequest is the request type for the Query/SkippedEpochs RPC + * method. + */ +export interface QuerySkippedEpochsRequestSDKType {} +/** + * QuerySkippedEpochsResponse is the response type for the Query/SkippedEpochs + * RPC method. + */ +export interface QuerySkippedEpochsResponse { + /** number of epochs that the inflation module has been disabled. */ + skippedEpochs: bigint; +} +export interface QuerySkippedEpochsResponseProtoMsg { + typeUrl: "/evmos.inflation.v1.QuerySkippedEpochsResponse"; + value: Uint8Array; +} +/** + * QuerySkippedEpochsResponse is the response type for the Query/SkippedEpochs + * RPC method. + */ +export interface QuerySkippedEpochsResponseSDKType { + skipped_epochs: bigint; +} +/** + * QueryCirculatingSupplyRequest is the request type for the + * Query/CirculatingSupply RPC method. + */ +export interface QueryCirculatingSupplyRequest {} +export interface QueryCirculatingSupplyRequestProtoMsg { + typeUrl: "/evmos.inflation.v1.QueryCirculatingSupplyRequest"; + value: Uint8Array; +} +/** + * QueryCirculatingSupplyRequest is the request type for the + * Query/CirculatingSupply RPC method. + */ +export interface QueryCirculatingSupplyRequestSDKType {} +/** + * QueryCirculatingSupplyResponse is the response type for the + * Query/CirculatingSupply RPC method. + */ +export interface QueryCirculatingSupplyResponse { + /** total amount of coins in circulation */ + circulatingSupply: DecCoin; +} +export interface QueryCirculatingSupplyResponseProtoMsg { + typeUrl: "/evmos.inflation.v1.QueryCirculatingSupplyResponse"; + value: Uint8Array; +} +/** + * QueryCirculatingSupplyResponse is the response type for the + * Query/CirculatingSupply RPC method. + */ +export interface QueryCirculatingSupplyResponseSDKType { + circulating_supply: DecCoinSDKType; +} +/** + * QueryInflationRateRequest is the request type for the Query/InflationRate RPC + * method. + */ +export interface QueryInflationRateRequest {} +export interface QueryInflationRateRequestProtoMsg { + typeUrl: "/evmos.inflation.v1.QueryInflationRateRequest"; + value: Uint8Array; +} +/** + * QueryInflationRateRequest is the request type for the Query/InflationRate RPC + * method. + */ +export interface QueryInflationRateRequestSDKType {} +/** + * QueryInflationRateResponse is the response type for the Query/InflationRate + * RPC method. + */ +export interface QueryInflationRateResponse { + /** rate by which the total supply increases within one period */ + inflationRate: string; +} +export interface QueryInflationRateResponseProtoMsg { + typeUrl: "/evmos.inflation.v1.QueryInflationRateResponse"; + value: Uint8Array; +} +/** + * QueryInflationRateResponse is the response type for the Query/InflationRate + * RPC method. + */ +export interface QueryInflationRateResponseSDKType { + inflation_rate: string; +} +/** QueryParamsRequest is the request type for the Query/Params RPC method. */ +export interface QueryParamsRequest {} +export interface QueryParamsRequestProtoMsg { + typeUrl: "/evmos.inflation.v1.QueryParamsRequest"; + value: Uint8Array; +} +/** QueryParamsRequest is the request type for the Query/Params RPC method. */ +export interface QueryParamsRequestSDKType {} +/** QueryParamsResponse is the response type for the Query/Params RPC method. */ +export interface QueryParamsResponse { + /** params defines the parameters of the module. */ + params: Params; +} +export interface QueryParamsResponseProtoMsg { + typeUrl: "/evmos.inflation.v1.QueryParamsResponse"; + value: Uint8Array; +} +/** QueryParamsResponse is the response type for the Query/Params RPC method. */ +export interface QueryParamsResponseSDKType { + params: ParamsSDKType; +} +function createBaseQueryPeriodRequest(): QueryPeriodRequest { + return {}; +} +export const QueryPeriodRequest = { + typeUrl: "/evmos.inflation.v1.QueryPeriodRequest", + encode(_: QueryPeriodRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryPeriodRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryPeriodRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): QueryPeriodRequest { + const obj = createBaseQueryPeriodRequest(); + return obj; + }, + toJSON(_: QueryPeriodRequest): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): QueryPeriodRequest { + const message = createBaseQueryPeriodRequest(); + return message; + }, + fromSDK(_: QueryPeriodRequestSDKType): QueryPeriodRequest { + return {}; + }, + fromSDKJSON(_: any): QueryPeriodRequestSDKType { + return {}; + }, + toSDK(_: QueryPeriodRequest): QueryPeriodRequestSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: QueryPeriodRequestAmino): QueryPeriodRequest { + const message = createBaseQueryPeriodRequest(); + return message; + }, + toAmino(_: QueryPeriodRequest): QueryPeriodRequestAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: QueryPeriodRequestAminoMsg): QueryPeriodRequest { + return QueryPeriodRequest.fromAmino(object.value); + }, + fromProtoMsg(message: QueryPeriodRequestProtoMsg): QueryPeriodRequest { + return QueryPeriodRequest.decode(message.value); + }, + toProto(message: QueryPeriodRequest): Uint8Array { + return QueryPeriodRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryPeriodRequest): QueryPeriodRequestProtoMsg { + return { + typeUrl: "/evmos.inflation.v1.QueryPeriodRequest", + value: QueryPeriodRequest.encode(message).finish() + }; + } +}; +function createBaseQueryPeriodResponse(): QueryPeriodResponse { + return { + period: BigInt(0) + }; +} +export const QueryPeriodResponse = { + typeUrl: "/evmos.inflation.v1.QueryPeriodResponse", + encode(message: QueryPeriodResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.period !== undefined) { + writer.uint32(8).uint64(message.period); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryPeriodResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryPeriodResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.period = reader.uint64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryPeriodResponse { + const obj = createBaseQueryPeriodResponse(); + if (isSet(object.period)) obj.period = BigInt(object.period.toString()); + return obj; + }, + toJSON(message: QueryPeriodResponse): JsonSafe { + const obj: any = {}; + message.period !== undefined && (obj.period = (message.period || BigInt(0)).toString()); + return obj; + }, + fromPartial(object: DeepPartial): QueryPeriodResponse { + const message = createBaseQueryPeriodResponse(); + if (object.period !== undefined && object.period !== null) { + message.period = BigInt(object.period.toString()); + } + return message; + }, + fromSDK(object: QueryPeriodResponseSDKType): QueryPeriodResponse { + return { + period: object?.period + }; + }, + fromSDKJSON(object: any): QueryPeriodResponseSDKType { + return { + period: isSet(object.period) ? BigInt(object.period.toString()) : BigInt(0) + }; + }, + toSDK(message: QueryPeriodResponse): QueryPeriodResponseSDKType { + const obj: any = {}; + obj.period = message.period; + return obj; + }, + fromAmino(object: QueryPeriodResponseAmino): QueryPeriodResponse { + const message = createBaseQueryPeriodResponse(); + if (object.period !== undefined && object.period !== null) { + message.period = BigInt(object.period); + } + return message; + }, + toAmino(message: QueryPeriodResponse): QueryPeriodResponseAmino { + const obj: any = {}; + obj.period = message.period !== BigInt(0) ? message.period?.toString() : undefined; + return obj; + }, + fromAminoMsg(object: QueryPeriodResponseAminoMsg): QueryPeriodResponse { + return QueryPeriodResponse.fromAmino(object.value); + }, + fromProtoMsg(message: QueryPeriodResponseProtoMsg): QueryPeriodResponse { + return QueryPeriodResponse.decode(message.value); + }, + toProto(message: QueryPeriodResponse): Uint8Array { + return QueryPeriodResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryPeriodResponse): QueryPeriodResponseProtoMsg { + return { + typeUrl: "/evmos.inflation.v1.QueryPeriodResponse", + value: QueryPeriodResponse.encode(message).finish() + }; + } +}; +function createBaseQueryEpochMintProvisionRequest(): QueryEpochMintProvisionRequest { + return {}; +} +export const QueryEpochMintProvisionRequest = { + typeUrl: "/evmos.inflation.v1.QueryEpochMintProvisionRequest", + encode(_: QueryEpochMintProvisionRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryEpochMintProvisionRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryEpochMintProvisionRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): QueryEpochMintProvisionRequest { + const obj = createBaseQueryEpochMintProvisionRequest(); + return obj; + }, + toJSON(_: QueryEpochMintProvisionRequest): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): QueryEpochMintProvisionRequest { + const message = createBaseQueryEpochMintProvisionRequest(); + return message; + }, + fromSDK(_: QueryEpochMintProvisionRequestSDKType): QueryEpochMintProvisionRequest { + return {}; + }, + fromSDKJSON(_: any): QueryEpochMintProvisionRequestSDKType { + return {}; + }, + toSDK(_: QueryEpochMintProvisionRequest): QueryEpochMintProvisionRequestSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: QueryEpochMintProvisionRequestAmino): QueryEpochMintProvisionRequest { + const message = createBaseQueryEpochMintProvisionRequest(); + return message; + }, + toAmino(_: QueryEpochMintProvisionRequest): QueryEpochMintProvisionRequestAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: QueryEpochMintProvisionRequestAminoMsg): QueryEpochMintProvisionRequest { + return QueryEpochMintProvisionRequest.fromAmino(object.value); + }, + fromProtoMsg(message: QueryEpochMintProvisionRequestProtoMsg): QueryEpochMintProvisionRequest { + return QueryEpochMintProvisionRequest.decode(message.value); + }, + toProto(message: QueryEpochMintProvisionRequest): Uint8Array { + return QueryEpochMintProvisionRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryEpochMintProvisionRequest): QueryEpochMintProvisionRequestProtoMsg { + return { + typeUrl: "/evmos.inflation.v1.QueryEpochMintProvisionRequest", + value: QueryEpochMintProvisionRequest.encode(message).finish() + }; + } +}; +function createBaseQueryEpochMintProvisionResponse(): QueryEpochMintProvisionResponse { + return { + epochMintProvision: DecCoin.fromPartial({}) + }; +} +export const QueryEpochMintProvisionResponse = { + typeUrl: "/evmos.inflation.v1.QueryEpochMintProvisionResponse", + encode(message: QueryEpochMintProvisionResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.epochMintProvision !== undefined) { + DecCoin.encode(message.epochMintProvision, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryEpochMintProvisionResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryEpochMintProvisionResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.epochMintProvision = DecCoin.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryEpochMintProvisionResponse { + const obj = createBaseQueryEpochMintProvisionResponse(); + if (isSet(object.epochMintProvision)) obj.epochMintProvision = DecCoin.fromJSON(object.epochMintProvision); + return obj; + }, + toJSON(message: QueryEpochMintProvisionResponse): JsonSafe { + const obj: any = {}; + message.epochMintProvision !== undefined && (obj.epochMintProvision = message.epochMintProvision ? DecCoin.toJSON(message.epochMintProvision) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryEpochMintProvisionResponse { + const message = createBaseQueryEpochMintProvisionResponse(); + if (object.epochMintProvision !== undefined && object.epochMintProvision !== null) { + message.epochMintProvision = DecCoin.fromPartial(object.epochMintProvision); + } + return message; + }, + fromSDK(object: QueryEpochMintProvisionResponseSDKType): QueryEpochMintProvisionResponse { + return { + epochMintProvision: object.epoch_mint_provision ? DecCoin.fromSDK(object.epoch_mint_provision) : undefined + }; + }, + fromSDKJSON(object: any): QueryEpochMintProvisionResponseSDKType { + return { + epoch_mint_provision: isSet(object.epoch_mint_provision) ? DecCoin.fromSDKJSON(object.epoch_mint_provision) : undefined + }; + }, + toSDK(message: QueryEpochMintProvisionResponse): QueryEpochMintProvisionResponseSDKType { + const obj: any = {}; + message.epochMintProvision !== undefined && (obj.epoch_mint_provision = message.epochMintProvision ? DecCoin.toSDK(message.epochMintProvision) : undefined); + return obj; + }, + fromAmino(object: QueryEpochMintProvisionResponseAmino): QueryEpochMintProvisionResponse { + const message = createBaseQueryEpochMintProvisionResponse(); + if (object.epoch_mint_provision !== undefined && object.epoch_mint_provision !== null) { + message.epochMintProvision = DecCoin.fromAmino(object.epoch_mint_provision); + } + return message; + }, + toAmino(message: QueryEpochMintProvisionResponse): QueryEpochMintProvisionResponseAmino { + const obj: any = {}; + obj.epoch_mint_provision = message.epochMintProvision ? DecCoin.toAmino(message.epochMintProvision) : undefined; + return obj; + }, + fromAminoMsg(object: QueryEpochMintProvisionResponseAminoMsg): QueryEpochMintProvisionResponse { + return QueryEpochMintProvisionResponse.fromAmino(object.value); + }, + fromProtoMsg(message: QueryEpochMintProvisionResponseProtoMsg): QueryEpochMintProvisionResponse { + return QueryEpochMintProvisionResponse.decode(message.value); + }, + toProto(message: QueryEpochMintProvisionResponse): Uint8Array { + return QueryEpochMintProvisionResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryEpochMintProvisionResponse): QueryEpochMintProvisionResponseProtoMsg { + return { + typeUrl: "/evmos.inflation.v1.QueryEpochMintProvisionResponse", + value: QueryEpochMintProvisionResponse.encode(message).finish() + }; + } +}; +function createBaseQuerySkippedEpochsRequest(): QuerySkippedEpochsRequest { + return {}; +} +export const QuerySkippedEpochsRequest = { + typeUrl: "/evmos.inflation.v1.QuerySkippedEpochsRequest", + encode(_: QuerySkippedEpochsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QuerySkippedEpochsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQuerySkippedEpochsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): QuerySkippedEpochsRequest { + const obj = createBaseQuerySkippedEpochsRequest(); + return obj; + }, + toJSON(_: QuerySkippedEpochsRequest): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): QuerySkippedEpochsRequest { + const message = createBaseQuerySkippedEpochsRequest(); + return message; + }, + fromSDK(_: QuerySkippedEpochsRequestSDKType): QuerySkippedEpochsRequest { + return {}; + }, + fromSDKJSON(_: any): QuerySkippedEpochsRequestSDKType { + return {}; + }, + toSDK(_: QuerySkippedEpochsRequest): QuerySkippedEpochsRequestSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: QuerySkippedEpochsRequestAmino): QuerySkippedEpochsRequest { + const message = createBaseQuerySkippedEpochsRequest(); + return message; + }, + toAmino(_: QuerySkippedEpochsRequest): QuerySkippedEpochsRequestAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: QuerySkippedEpochsRequestAminoMsg): QuerySkippedEpochsRequest { + return QuerySkippedEpochsRequest.fromAmino(object.value); + }, + fromProtoMsg(message: QuerySkippedEpochsRequestProtoMsg): QuerySkippedEpochsRequest { + return QuerySkippedEpochsRequest.decode(message.value); + }, + toProto(message: QuerySkippedEpochsRequest): Uint8Array { + return QuerySkippedEpochsRequest.encode(message).finish(); + }, + toProtoMsg(message: QuerySkippedEpochsRequest): QuerySkippedEpochsRequestProtoMsg { + return { + typeUrl: "/evmos.inflation.v1.QuerySkippedEpochsRequest", + value: QuerySkippedEpochsRequest.encode(message).finish() + }; + } +}; +function createBaseQuerySkippedEpochsResponse(): QuerySkippedEpochsResponse { + return { + skippedEpochs: BigInt(0) + }; +} +export const QuerySkippedEpochsResponse = { + typeUrl: "/evmos.inflation.v1.QuerySkippedEpochsResponse", + encode(message: QuerySkippedEpochsResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.skippedEpochs !== undefined) { + writer.uint32(8).uint64(message.skippedEpochs); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QuerySkippedEpochsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQuerySkippedEpochsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.skippedEpochs = reader.uint64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QuerySkippedEpochsResponse { + const obj = createBaseQuerySkippedEpochsResponse(); + if (isSet(object.skippedEpochs)) obj.skippedEpochs = BigInt(object.skippedEpochs.toString()); + return obj; + }, + toJSON(message: QuerySkippedEpochsResponse): JsonSafe { + const obj: any = {}; + message.skippedEpochs !== undefined && (obj.skippedEpochs = (message.skippedEpochs || BigInt(0)).toString()); + return obj; + }, + fromPartial(object: DeepPartial): QuerySkippedEpochsResponse { + const message = createBaseQuerySkippedEpochsResponse(); + if (object.skippedEpochs !== undefined && object.skippedEpochs !== null) { + message.skippedEpochs = BigInt(object.skippedEpochs.toString()); + } + return message; + }, + fromSDK(object: QuerySkippedEpochsResponseSDKType): QuerySkippedEpochsResponse { + return { + skippedEpochs: object?.skipped_epochs + }; + }, + fromSDKJSON(object: any): QuerySkippedEpochsResponseSDKType { + return { + skipped_epochs: isSet(object.skipped_epochs) ? BigInt(object.skipped_epochs.toString()) : BigInt(0) + }; + }, + toSDK(message: QuerySkippedEpochsResponse): QuerySkippedEpochsResponseSDKType { + const obj: any = {}; + obj.skipped_epochs = message.skippedEpochs; + return obj; + }, + fromAmino(object: QuerySkippedEpochsResponseAmino): QuerySkippedEpochsResponse { + const message = createBaseQuerySkippedEpochsResponse(); + if (object.skipped_epochs !== undefined && object.skipped_epochs !== null) { + message.skippedEpochs = BigInt(object.skipped_epochs); + } + return message; + }, + toAmino(message: QuerySkippedEpochsResponse): QuerySkippedEpochsResponseAmino { + const obj: any = {}; + obj.skipped_epochs = message.skippedEpochs !== BigInt(0) ? message.skippedEpochs?.toString() : undefined; + return obj; + }, + fromAminoMsg(object: QuerySkippedEpochsResponseAminoMsg): QuerySkippedEpochsResponse { + return QuerySkippedEpochsResponse.fromAmino(object.value); + }, + fromProtoMsg(message: QuerySkippedEpochsResponseProtoMsg): QuerySkippedEpochsResponse { + return QuerySkippedEpochsResponse.decode(message.value); + }, + toProto(message: QuerySkippedEpochsResponse): Uint8Array { + return QuerySkippedEpochsResponse.encode(message).finish(); + }, + toProtoMsg(message: QuerySkippedEpochsResponse): QuerySkippedEpochsResponseProtoMsg { + return { + typeUrl: "/evmos.inflation.v1.QuerySkippedEpochsResponse", + value: QuerySkippedEpochsResponse.encode(message).finish() + }; + } +}; +function createBaseQueryCirculatingSupplyRequest(): QueryCirculatingSupplyRequest { + return {}; +} +export const QueryCirculatingSupplyRequest = { + typeUrl: "/evmos.inflation.v1.QueryCirculatingSupplyRequest", + encode(_: QueryCirculatingSupplyRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryCirculatingSupplyRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryCirculatingSupplyRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): QueryCirculatingSupplyRequest { + const obj = createBaseQueryCirculatingSupplyRequest(); + return obj; + }, + toJSON(_: QueryCirculatingSupplyRequest): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): QueryCirculatingSupplyRequest { + const message = createBaseQueryCirculatingSupplyRequest(); + return message; + }, + fromSDK(_: QueryCirculatingSupplyRequestSDKType): QueryCirculatingSupplyRequest { + return {}; + }, + fromSDKJSON(_: any): QueryCirculatingSupplyRequestSDKType { + return {}; + }, + toSDK(_: QueryCirculatingSupplyRequest): QueryCirculatingSupplyRequestSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: QueryCirculatingSupplyRequestAmino): QueryCirculatingSupplyRequest { + const message = createBaseQueryCirculatingSupplyRequest(); + return message; + }, + toAmino(_: QueryCirculatingSupplyRequest): QueryCirculatingSupplyRequestAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: QueryCirculatingSupplyRequestAminoMsg): QueryCirculatingSupplyRequest { + return QueryCirculatingSupplyRequest.fromAmino(object.value); + }, + fromProtoMsg(message: QueryCirculatingSupplyRequestProtoMsg): QueryCirculatingSupplyRequest { + return QueryCirculatingSupplyRequest.decode(message.value); + }, + toProto(message: QueryCirculatingSupplyRequest): Uint8Array { + return QueryCirculatingSupplyRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryCirculatingSupplyRequest): QueryCirculatingSupplyRequestProtoMsg { + return { + typeUrl: "/evmos.inflation.v1.QueryCirculatingSupplyRequest", + value: QueryCirculatingSupplyRequest.encode(message).finish() + }; + } +}; +function createBaseQueryCirculatingSupplyResponse(): QueryCirculatingSupplyResponse { + return { + circulatingSupply: DecCoin.fromPartial({}) + }; +} +export const QueryCirculatingSupplyResponse = { + typeUrl: "/evmos.inflation.v1.QueryCirculatingSupplyResponse", + encode(message: QueryCirculatingSupplyResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.circulatingSupply !== undefined) { + DecCoin.encode(message.circulatingSupply, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryCirculatingSupplyResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryCirculatingSupplyResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.circulatingSupply = DecCoin.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryCirculatingSupplyResponse { + const obj = createBaseQueryCirculatingSupplyResponse(); + if (isSet(object.circulatingSupply)) obj.circulatingSupply = DecCoin.fromJSON(object.circulatingSupply); + return obj; + }, + toJSON(message: QueryCirculatingSupplyResponse): JsonSafe { + const obj: any = {}; + message.circulatingSupply !== undefined && (obj.circulatingSupply = message.circulatingSupply ? DecCoin.toJSON(message.circulatingSupply) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryCirculatingSupplyResponse { + const message = createBaseQueryCirculatingSupplyResponse(); + if (object.circulatingSupply !== undefined && object.circulatingSupply !== null) { + message.circulatingSupply = DecCoin.fromPartial(object.circulatingSupply); + } + return message; + }, + fromSDK(object: QueryCirculatingSupplyResponseSDKType): QueryCirculatingSupplyResponse { + return { + circulatingSupply: object.circulating_supply ? DecCoin.fromSDK(object.circulating_supply) : undefined + }; + }, + fromSDKJSON(object: any): QueryCirculatingSupplyResponseSDKType { + return { + circulating_supply: isSet(object.circulating_supply) ? DecCoin.fromSDKJSON(object.circulating_supply) : undefined + }; + }, + toSDK(message: QueryCirculatingSupplyResponse): QueryCirculatingSupplyResponseSDKType { + const obj: any = {}; + message.circulatingSupply !== undefined && (obj.circulating_supply = message.circulatingSupply ? DecCoin.toSDK(message.circulatingSupply) : undefined); + return obj; + }, + fromAmino(object: QueryCirculatingSupplyResponseAmino): QueryCirculatingSupplyResponse { + const message = createBaseQueryCirculatingSupplyResponse(); + if (object.circulating_supply !== undefined && object.circulating_supply !== null) { + message.circulatingSupply = DecCoin.fromAmino(object.circulating_supply); + } + return message; + }, + toAmino(message: QueryCirculatingSupplyResponse): QueryCirculatingSupplyResponseAmino { + const obj: any = {}; + obj.circulating_supply = message.circulatingSupply ? DecCoin.toAmino(message.circulatingSupply) : undefined; + return obj; + }, + fromAminoMsg(object: QueryCirculatingSupplyResponseAminoMsg): QueryCirculatingSupplyResponse { + return QueryCirculatingSupplyResponse.fromAmino(object.value); + }, + fromProtoMsg(message: QueryCirculatingSupplyResponseProtoMsg): QueryCirculatingSupplyResponse { + return QueryCirculatingSupplyResponse.decode(message.value); + }, + toProto(message: QueryCirculatingSupplyResponse): Uint8Array { + return QueryCirculatingSupplyResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryCirculatingSupplyResponse): QueryCirculatingSupplyResponseProtoMsg { + return { + typeUrl: "/evmos.inflation.v1.QueryCirculatingSupplyResponse", + value: QueryCirculatingSupplyResponse.encode(message).finish() + }; + } +}; +function createBaseQueryInflationRateRequest(): QueryInflationRateRequest { + return {}; +} +export const QueryInflationRateRequest = { + typeUrl: "/evmos.inflation.v1.QueryInflationRateRequest", + encode(_: QueryInflationRateRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryInflationRateRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryInflationRateRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): QueryInflationRateRequest { + const obj = createBaseQueryInflationRateRequest(); + return obj; + }, + toJSON(_: QueryInflationRateRequest): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): QueryInflationRateRequest { + const message = createBaseQueryInflationRateRequest(); + return message; + }, + fromSDK(_: QueryInflationRateRequestSDKType): QueryInflationRateRequest { + return {}; + }, + fromSDKJSON(_: any): QueryInflationRateRequestSDKType { + return {}; + }, + toSDK(_: QueryInflationRateRequest): QueryInflationRateRequestSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: QueryInflationRateRequestAmino): QueryInflationRateRequest { + const message = createBaseQueryInflationRateRequest(); + return message; + }, + toAmino(_: QueryInflationRateRequest): QueryInflationRateRequestAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: QueryInflationRateRequestAminoMsg): QueryInflationRateRequest { + return QueryInflationRateRequest.fromAmino(object.value); + }, + fromProtoMsg(message: QueryInflationRateRequestProtoMsg): QueryInflationRateRequest { + return QueryInflationRateRequest.decode(message.value); + }, + toProto(message: QueryInflationRateRequest): Uint8Array { + return QueryInflationRateRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryInflationRateRequest): QueryInflationRateRequestProtoMsg { + return { + typeUrl: "/evmos.inflation.v1.QueryInflationRateRequest", + value: QueryInflationRateRequest.encode(message).finish() + }; + } +}; +function createBaseQueryInflationRateResponse(): QueryInflationRateResponse { + return { + inflationRate: "" + }; +} +export const QueryInflationRateResponse = { + typeUrl: "/evmos.inflation.v1.QueryInflationRateResponse", + encode(message: QueryInflationRateResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.inflationRate !== undefined) { + writer.uint32(10).string(Decimal.fromUserInput(message.inflationRate, 18).atomics); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryInflationRateResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryInflationRateResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.inflationRate = Decimal.fromAtomics(reader.string(), 18).toString(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryInflationRateResponse { + const obj = createBaseQueryInflationRateResponse(); + if (isSet(object.inflationRate)) obj.inflationRate = String(object.inflationRate); + return obj; + }, + toJSON(message: QueryInflationRateResponse): JsonSafe { + const obj: any = {}; + message.inflationRate !== undefined && (obj.inflationRate = message.inflationRate); + return obj; + }, + fromPartial(object: DeepPartial): QueryInflationRateResponse { + const message = createBaseQueryInflationRateResponse(); + message.inflationRate = object.inflationRate ?? ""; + return message; + }, + fromSDK(object: QueryInflationRateResponseSDKType): QueryInflationRateResponse { + return { + inflationRate: object?.inflation_rate + }; + }, + fromSDKJSON(object: any): QueryInflationRateResponseSDKType { + return { + inflation_rate: isSet(object.inflation_rate) ? String(object.inflation_rate) : "" + }; + }, + toSDK(message: QueryInflationRateResponse): QueryInflationRateResponseSDKType { + const obj: any = {}; + obj.inflation_rate = message.inflationRate; + return obj; + }, + fromAmino(object: QueryInflationRateResponseAmino): QueryInflationRateResponse { + const message = createBaseQueryInflationRateResponse(); + if (object.inflation_rate !== undefined && object.inflation_rate !== null) { + message.inflationRate = object.inflation_rate; + } + return message; + }, + toAmino(message: QueryInflationRateResponse): QueryInflationRateResponseAmino { + const obj: any = {}; + obj.inflation_rate = message.inflationRate === "" ? undefined : message.inflationRate; + return obj; + }, + fromAminoMsg(object: QueryInflationRateResponseAminoMsg): QueryInflationRateResponse { + return QueryInflationRateResponse.fromAmino(object.value); + }, + fromProtoMsg(message: QueryInflationRateResponseProtoMsg): QueryInflationRateResponse { + return QueryInflationRateResponse.decode(message.value); + }, + toProto(message: QueryInflationRateResponse): Uint8Array { + return QueryInflationRateResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryInflationRateResponse): QueryInflationRateResponseProtoMsg { + return { + typeUrl: "/evmos.inflation.v1.QueryInflationRateResponse", + value: QueryInflationRateResponse.encode(message).finish() + }; + } +}; +function createBaseQueryParamsRequest(): QueryParamsRequest { + return {}; +} +export const QueryParamsRequest = { + typeUrl: "/evmos.inflation.v1.QueryParamsRequest", + encode(_: QueryParamsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryParamsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryParamsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): QueryParamsRequest { + const obj = createBaseQueryParamsRequest(); + return obj; + }, + toJSON(_: QueryParamsRequest): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): QueryParamsRequest { + const message = createBaseQueryParamsRequest(); + return message; + }, + fromSDK(_: QueryParamsRequestSDKType): QueryParamsRequest { + return {}; + }, + fromSDKJSON(_: any): QueryParamsRequestSDKType { + return {}; + }, + toSDK(_: QueryParamsRequest): QueryParamsRequestSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: QueryParamsRequestAmino): QueryParamsRequest { + const message = createBaseQueryParamsRequest(); + return message; + }, + toAmino(_: QueryParamsRequest): QueryParamsRequestAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: QueryParamsRequestAminoMsg): QueryParamsRequest { + return QueryParamsRequest.fromAmino(object.value); + }, + fromProtoMsg(message: QueryParamsRequestProtoMsg): QueryParamsRequest { + return QueryParamsRequest.decode(message.value); + }, + toProto(message: QueryParamsRequest): Uint8Array { + return QueryParamsRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryParamsRequest): QueryParamsRequestProtoMsg { + return { + typeUrl: "/evmos.inflation.v1.QueryParamsRequest", + value: QueryParamsRequest.encode(message).finish() + }; + } +}; +function createBaseQueryParamsResponse(): QueryParamsResponse { + return { + params: Params.fromPartial({}) + }; +} +export const QueryParamsResponse = { + typeUrl: "/evmos.inflation.v1.QueryParamsResponse", + encode(message: QueryParamsResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryParamsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryParamsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.params = Params.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryParamsResponse { + const obj = createBaseQueryParamsResponse(); + if (isSet(object.params)) obj.params = Params.fromJSON(object.params); + return obj; + }, + toJSON(message: QueryParamsResponse): JsonSafe { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryParamsResponse { + const message = createBaseQueryParamsResponse(); + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } + return message; + }, + fromSDK(object: QueryParamsResponseSDKType): QueryParamsResponse { + return { + params: object.params ? Params.fromSDK(object.params) : undefined + }; + }, + fromSDKJSON(object: any): QueryParamsResponseSDKType { + return { + params: isSet(object.params) ? Params.fromSDKJSON(object.params) : undefined + }; + }, + toSDK(message: QueryParamsResponse): QueryParamsResponseSDKType { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toSDK(message.params) : undefined); + return obj; + }, + fromAmino(object: QueryParamsResponseAmino): QueryParamsResponse { + const message = createBaseQueryParamsResponse(); + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromAmino(object.params); + } + return message; + }, + toAmino(message: QueryParamsResponse): QueryParamsResponseAmino { + const obj: any = {}; + obj.params = message.params ? Params.toAmino(message.params) : undefined; + return obj; + }, + fromAminoMsg(object: QueryParamsResponseAminoMsg): QueryParamsResponse { + return QueryParamsResponse.fromAmino(object.value); + }, + fromProtoMsg(message: QueryParamsResponseProtoMsg): QueryParamsResponse { + return QueryParamsResponse.decode(message.value); + }, + toProto(message: QueryParamsResponse): Uint8Array { + return QueryParamsResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryParamsResponse): QueryParamsResponseProtoMsg { + return { + typeUrl: "/evmos.inflation.v1.QueryParamsResponse", + value: QueryParamsResponse.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/evmos/lcd.ts b/__fixtures__/v-next/outputicjsdeps/evmos/lcd.ts new file mode 100644 index 0000000000..5656a9fe3f --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/evmos/lcd.ts @@ -0,0 +1,149 @@ +import { LCDClient } from "@cosmology/lcd"; +export const createLCDClient = async ({ + restEndpoint +}: { + restEndpoint: string; +}) => { + const requestClient = new LCDClient({ + restEndpoint + }); + return { + cosmos: { + auth: { + v1beta1: new (await import("../cosmos/auth/v1beta1/query.lcd")).LCDQueryClient({ + requestClient + }) + }, + authz: { + v1beta1: new (await import("../cosmos/authz/v1beta1/query.lcd")).LCDQueryClient({ + requestClient + }) + }, + bank: { + v1beta1: new (await import("../cosmos/bank/v1beta1/query.lcd")).LCDQueryClient({ + requestClient + }) + }, + base: { + reflection: { + v1beta1: new (await import("../cosmos/base/reflection/v1beta1/reflection.lcd")).LCDQueryClient({ + requestClient + }), + v2alpha1: new (await import("../cosmos/base/reflection/v2alpha1/reflection.lcd")).LCDQueryClient({ + requestClient + }) + }, + tendermint: { + v1beta1: new (await import("../cosmos/base/tendermint/v1beta1/query.lcd")).LCDQueryClient({ + requestClient + }) + } + }, + distribution: { + v1beta1: new (await import("../cosmos/distribution/v1beta1/query.lcd")).LCDQueryClient({ + requestClient + }) + }, + evidence: { + v1beta1: new (await import("../cosmos/evidence/v1beta1/query.lcd")).LCDQueryClient({ + requestClient + }) + }, + feegrant: { + v1beta1: new (await import("../cosmos/feegrant/v1beta1/query.lcd")).LCDQueryClient({ + requestClient + }) + }, + gov: { + v1: new (await import("../cosmos/gov/v1/query.lcd")).LCDQueryClient({ + requestClient + }), + v1beta1: new (await import("../cosmos/gov/v1beta1/query.lcd")).LCDQueryClient({ + requestClient + }) + }, + group: { + v1: new (await import("../cosmos/group/v1/query.lcd")).LCDQueryClient({ + requestClient + }) + }, + mint: { + v1beta1: new (await import("../cosmos/mint/v1beta1/query.lcd")).LCDQueryClient({ + requestClient + }) + }, + nft: { + v1beta1: new (await import("../cosmos/nft/v1beta1/query.lcd")).LCDQueryClient({ + requestClient + }) + }, + params: { + v1beta1: new (await import("../cosmos/params/v1beta1/query.lcd")).LCDQueryClient({ + requestClient + }) + }, + slashing: { + v1beta1: new (await import("../cosmos/slashing/v1beta1/query.lcd")).LCDQueryClient({ + requestClient + }) + }, + staking: { + v1beta1: new (await import("../cosmos/staking/v1beta1/query.lcd")).LCDQueryClient({ + requestClient + }) + }, + tx: { + v1beta1: new (await import("../cosmos/tx/v1beta1/service.lcd")).LCDQueryClient({ + requestClient + }) + }, + upgrade: { + v1beta1: new (await import("../cosmos/upgrade/v1beta1/query.lcd")).LCDQueryClient({ + requestClient + }) + } + }, + evmos: { + claims: { + v1: new (await import("./claims/v1/query.lcd")).LCDQueryClient({ + requestClient + }) + }, + epochs: { + v1: new (await import("./epochs/v1/query.lcd")).LCDQueryClient({ + requestClient + }) + }, + erc20: { + v1: new (await import("./erc20/v1/query.lcd")).LCDQueryClient({ + requestClient + }) + }, + fees: { + v1: new (await import("./fees/v1/query.lcd")).LCDQueryClient({ + requestClient + }) + }, + incentives: { + v1: new (await import("./incentives/v1/query.lcd")).LCDQueryClient({ + requestClient + }) + }, + inflation: { + v1: new (await import("./inflation/v1/query.lcd")).LCDQueryClient({ + requestClient + }) + }, + recovery: { + v1: new (await import("./recovery/v1/query.lcd")).LCDQueryClient({ + requestClient + }) + }, + vesting: { + v1: new (await import("./vesting/v1/query.lcd")).LCDQueryClient({ + requestClient + }) + } + } + }; +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/evmos/recovery/v1/genesis.ts b/__fixtures__/v-next/outputicjsdeps/evmos/recovery/v1/genesis.ts new file mode 100644 index 0000000000..846a95ccb1 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/evmos/recovery/v1/genesis.ts @@ -0,0 +1,231 @@ +import { Duration, DurationSDKType } from "../../../google/protobuf/duration.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "evmos.recovery.v1"; +/** GenesisState defines the recovery module's genesis state. */ +export interface GenesisState { + /** params defines all the paramaters of the module. */ + params: Params; +} +export interface GenesisStateProtoMsg { + typeUrl: "/evmos.recovery.v1.GenesisState"; + value: Uint8Array; +} +/** GenesisState defines the recovery module's genesis state. */ +export interface GenesisStateSDKType { + params: ParamsSDKType; +} +/** Params holds parameters for the recovery module */ +export interface Params { + /** enable recovery IBC middleware */ + enableRecovery: boolean; + /** duration added to timeout timestamp for balances recovered via IBC packets */ + packetTimeoutDuration: Duration; +} +export interface ParamsProtoMsg { + typeUrl: "/evmos.recovery.v1.Params"; + value: Uint8Array; +} +/** Params holds parameters for the recovery module */ +export interface ParamsSDKType { + enable_recovery: boolean; + packet_timeout_duration: DurationSDKType; +} +function createBaseGenesisState(): GenesisState { + return { + params: Params.fromPartial({}) + }; +} +export const GenesisState = { + typeUrl: "/evmos.recovery.v1.GenesisState", + encode(message: GenesisState, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GenesisState { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGenesisState(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.params = Params.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GenesisState { + const obj = createBaseGenesisState(); + if (isSet(object.params)) obj.params = Params.fromJSON(object.params); + return obj; + }, + toJSON(message: GenesisState): JsonSafe { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): GenesisState { + const message = createBaseGenesisState(); + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } + return message; + }, + fromSDK(object: GenesisStateSDKType): GenesisState { + return { + params: object.params ? Params.fromSDK(object.params) : undefined + }; + }, + fromSDKJSON(object: any): GenesisStateSDKType { + return { + params: isSet(object.params) ? Params.fromSDKJSON(object.params) : undefined + }; + }, + toSDK(message: GenesisState): GenesisStateSDKType { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toSDK(message.params) : undefined); + return obj; + }, + fromAmino(object: GenesisStateAmino): GenesisState { + const message = createBaseGenesisState(); + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromAmino(object.params); + } + return message; + }, + toAmino(message: GenesisState): GenesisStateAmino { + const obj: any = {}; + obj.params = message.params ? Params.toAmino(message.params) : undefined; + return obj; + }, + fromAminoMsg(object: GenesisStateAminoMsg): GenesisState { + return GenesisState.fromAmino(object.value); + }, + fromProtoMsg(message: GenesisStateProtoMsg): GenesisState { + return GenesisState.decode(message.value); + }, + toProto(message: GenesisState): Uint8Array { + return GenesisState.encode(message).finish(); + }, + toProtoMsg(message: GenesisState): GenesisStateProtoMsg { + return { + typeUrl: "/evmos.recovery.v1.GenesisState", + value: GenesisState.encode(message).finish() + }; + } +}; +function createBaseParams(): Params { + return { + enableRecovery: false, + packetTimeoutDuration: Duration.fromPartial({}) + }; +} +export const Params = { + typeUrl: "/evmos.recovery.v1.Params", + encode(message: Params, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.enableRecovery !== undefined) { + writer.uint32(8).bool(message.enableRecovery); + } + if (message.packetTimeoutDuration !== undefined) { + Duration.encode(message.packetTimeoutDuration, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Params { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseParams(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.enableRecovery = reader.bool(); + break; + case 2: + message.packetTimeoutDuration = Duration.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Params { + const obj = createBaseParams(); + if (isSet(object.enableRecovery)) obj.enableRecovery = Boolean(object.enableRecovery); + if (isSet(object.packetTimeoutDuration)) obj.packetTimeoutDuration = Duration.fromJSON(object.packetTimeoutDuration); + return obj; + }, + toJSON(message: Params): JsonSafe { + const obj: any = {}; + message.enableRecovery !== undefined && (obj.enableRecovery = message.enableRecovery); + message.packetTimeoutDuration !== undefined && (obj.packetTimeoutDuration = message.packetTimeoutDuration ? Duration.toJSON(message.packetTimeoutDuration) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): Params { + const message = createBaseParams(); + message.enableRecovery = object.enableRecovery ?? false; + if (object.packetTimeoutDuration !== undefined && object.packetTimeoutDuration !== null) { + message.packetTimeoutDuration = Duration.fromPartial(object.packetTimeoutDuration); + } + return message; + }, + fromSDK(object: ParamsSDKType): Params { + return { + enableRecovery: object?.enable_recovery, + packetTimeoutDuration: object.packet_timeout_duration ? Duration.fromSDK(object.packet_timeout_duration) : undefined + }; + }, + fromSDKJSON(object: any): ParamsSDKType { + return { + enable_recovery: isSet(object.enable_recovery) ? Boolean(object.enable_recovery) : false, + packet_timeout_duration: isSet(object.packet_timeout_duration) ? Duration.fromSDKJSON(object.packet_timeout_duration) : undefined + }; + }, + toSDK(message: Params): ParamsSDKType { + const obj: any = {}; + obj.enable_recovery = message.enableRecovery; + message.packetTimeoutDuration !== undefined && (obj.packet_timeout_duration = message.packetTimeoutDuration ? Duration.toSDK(message.packetTimeoutDuration) : undefined); + return obj; + }, + fromAmino(object: ParamsAmino): Params { + const message = createBaseParams(); + if (object.enable_recovery !== undefined && object.enable_recovery !== null) { + message.enableRecovery = object.enable_recovery; + } + if (object.packet_timeout_duration !== undefined && object.packet_timeout_duration !== null) { + message.packetTimeoutDuration = Duration.fromAmino(object.packet_timeout_duration); + } + return message; + }, + toAmino(message: Params): ParamsAmino { + const obj: any = {}; + obj.enable_recovery = message.enableRecovery === false ? undefined : message.enableRecovery; + obj.packet_timeout_duration = message.packetTimeoutDuration ? Duration.toAmino(message.packetTimeoutDuration) : undefined; + return obj; + }, + fromAminoMsg(object: ParamsAminoMsg): Params { + return Params.fromAmino(object.value); + }, + fromProtoMsg(message: ParamsProtoMsg): Params { + return Params.decode(message.value); + }, + toProto(message: Params): Uint8Array { + return Params.encode(message).finish(); + }, + toProtoMsg(message: Params): ParamsProtoMsg { + return { + typeUrl: "/evmos.recovery.v1.Params", + value: Params.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/evmos/recovery/v1/query.lcd.ts b/__fixtures__/v-next/outputicjsdeps/evmos/recovery/v1/query.lcd.ts new file mode 100644 index 0000000000..a0ca2d6f6a --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/evmos/recovery/v1/query.lcd.ts @@ -0,0 +1,19 @@ +import { Params, ParamsSDKType } from "./genesis.js"; +import { LCDClient } from "@cosmology/lcd"; +import { QueryParamsRequest, QueryParamsRequestSDKType, QueryParamsResponse, QueryParamsResponseSDKType } from "./query.js"; +export class LCDQueryClient { + req: LCDClient; + constructor({ + requestClient + }: { + requestClient: LCDClient; + }) { + this.req = requestClient; + this.params = this.params.bind(this); + } + /* Params retrieves the total set of recovery parameters. */ + async params(_params: QueryParamsRequest = {}): Promise { + const endpoint = `evmos/recovery/v1/params`; + return QueryParamsResponse.fromSDKJSON(await this.req.get(endpoint)); + } +} \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/evmos/recovery/v1/query.rpc.Query.ts b/__fixtures__/v-next/outputicjsdeps/evmos/recovery/v1/query.rpc.Query.ts new file mode 100644 index 0000000000..c04b6e4e94 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/evmos/recovery/v1/query.rpc.Query.ts @@ -0,0 +1,31 @@ +import { Params, ParamsSDKType } from "./genesis.js"; +import { Rpc } from "../../../helpers.js"; +import { BinaryReader } from "../../../binary.js"; +import { QueryClient, createProtobufRpcClient } from "@cosmjs/stargate"; +import { QueryParamsRequest, QueryParamsRequestSDKType, QueryParamsResponse, QueryParamsResponseSDKType } from "./query.js"; +/** Query defines the gRPC querier service. */ +export interface Query { + /** Params retrieves the total set of recovery parameters. */ + params(request?: QueryParamsRequest): Promise; +} +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + this.params = this.params.bind(this); + } + params(request: QueryParamsRequest = {}): Promise { + const data = QueryParamsRequest.encode(request).finish(); + const promise = this.rpc.request("evmos.recovery.v1.Query", "Params", data); + return promise.then(data => QueryParamsResponse.decode(new BinaryReader(data))); + } +} +export const createRpcQueryExtension = (base: QueryClient) => { + const rpc = createProtobufRpcClient(base); + const queryService = new QueryClientImpl(rpc); + return { + params(request?: QueryParamsRequest): Promise { + return queryService.params(request); + } + }; +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/evmos/recovery/v1/query.rpc.func.ts b/__fixtures__/v-next/outputicjsdeps/evmos/recovery/v1/query.rpc.func.ts new file mode 100644 index 0000000000..3385aa9666 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/evmos/recovery/v1/query.rpc.func.ts @@ -0,0 +1,14 @@ +import { RpcResolver, buildQuery } from "../../../helper-func-types"; +import { buildUseQuery } from "../../../react-query"; +import { QueryParamsRequest, QueryParamsResponse } from "./query"; +export const createGetParams = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryParamsRequest.encode, + decode: QueryParamsResponse.decode, + service: "evmos.recovery.v1.Query", + method: "Params", + getRpcInstance: getRpcInstance +}); +export const useGetParams = buildUseQuery({ + builderQueryFn: createGetParams, + queryKeyPrefix: "ParamsQuery" +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/evmos/recovery/v1/query.ts b/__fixtures__/v-next/outputicjsdeps/evmos/recovery/v1/query.ts new file mode 100644 index 0000000000..42c4a10bd4 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/evmos/recovery/v1/query.ts @@ -0,0 +1,184 @@ +import { Params, ParamsSDKType } from "./genesis.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { JsonSafe } from "../../../json-safe.js"; +import { DeepPartial, isSet } from "../../../helpers.js"; +export const protobufPackage = "evmos.recovery.v1"; +/** QueryParamsRequest is the request type for the Query/Params RPC method. */ +export interface QueryParamsRequest {} +export interface QueryParamsRequestProtoMsg { + typeUrl: "/evmos.recovery.v1.QueryParamsRequest"; + value: Uint8Array; +} +/** QueryParamsRequest is the request type for the Query/Params RPC method. */ +export interface QueryParamsRequestSDKType {} +/** QueryParamsResponse is the response type for the Query/Params RPC method. */ +export interface QueryParamsResponse { + /** params defines the parameters of the module. */ + params: Params; +} +export interface QueryParamsResponseProtoMsg { + typeUrl: "/evmos.recovery.v1.QueryParamsResponse"; + value: Uint8Array; +} +/** QueryParamsResponse is the response type for the Query/Params RPC method. */ +export interface QueryParamsResponseSDKType { + params: ParamsSDKType; +} +function createBaseQueryParamsRequest(): QueryParamsRequest { + return {}; +} +export const QueryParamsRequest = { + typeUrl: "/evmos.recovery.v1.QueryParamsRequest", + encode(_: QueryParamsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryParamsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryParamsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): QueryParamsRequest { + const obj = createBaseQueryParamsRequest(); + return obj; + }, + toJSON(_: QueryParamsRequest): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): QueryParamsRequest { + const message = createBaseQueryParamsRequest(); + return message; + }, + fromSDK(_: QueryParamsRequestSDKType): QueryParamsRequest { + return {}; + }, + fromSDKJSON(_: any): QueryParamsRequestSDKType { + return {}; + }, + toSDK(_: QueryParamsRequest): QueryParamsRequestSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: QueryParamsRequestAmino): QueryParamsRequest { + const message = createBaseQueryParamsRequest(); + return message; + }, + toAmino(_: QueryParamsRequest): QueryParamsRequestAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: QueryParamsRequestAminoMsg): QueryParamsRequest { + return QueryParamsRequest.fromAmino(object.value); + }, + fromProtoMsg(message: QueryParamsRequestProtoMsg): QueryParamsRequest { + return QueryParamsRequest.decode(message.value); + }, + toProto(message: QueryParamsRequest): Uint8Array { + return QueryParamsRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryParamsRequest): QueryParamsRequestProtoMsg { + return { + typeUrl: "/evmos.recovery.v1.QueryParamsRequest", + value: QueryParamsRequest.encode(message).finish() + }; + } +}; +function createBaseQueryParamsResponse(): QueryParamsResponse { + return { + params: Params.fromPartial({}) + }; +} +export const QueryParamsResponse = { + typeUrl: "/evmos.recovery.v1.QueryParamsResponse", + encode(message: QueryParamsResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryParamsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryParamsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.params = Params.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryParamsResponse { + const obj = createBaseQueryParamsResponse(); + if (isSet(object.params)) obj.params = Params.fromJSON(object.params); + return obj; + }, + toJSON(message: QueryParamsResponse): JsonSafe { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QueryParamsResponse { + const message = createBaseQueryParamsResponse(); + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } + return message; + }, + fromSDK(object: QueryParamsResponseSDKType): QueryParamsResponse { + return { + params: object.params ? Params.fromSDK(object.params) : undefined + }; + }, + fromSDKJSON(object: any): QueryParamsResponseSDKType { + return { + params: isSet(object.params) ? Params.fromSDKJSON(object.params) : undefined + }; + }, + toSDK(message: QueryParamsResponse): QueryParamsResponseSDKType { + const obj: any = {}; + message.params !== undefined && (obj.params = message.params ? Params.toSDK(message.params) : undefined); + return obj; + }, + fromAmino(object: QueryParamsResponseAmino): QueryParamsResponse { + const message = createBaseQueryParamsResponse(); + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromAmino(object.params); + } + return message; + }, + toAmino(message: QueryParamsResponse): QueryParamsResponseAmino { + const obj: any = {}; + obj.params = message.params ? Params.toAmino(message.params) : undefined; + return obj; + }, + fromAminoMsg(object: QueryParamsResponseAminoMsg): QueryParamsResponse { + return QueryParamsResponse.fromAmino(object.value); + }, + fromProtoMsg(message: QueryParamsResponseProtoMsg): QueryParamsResponse { + return QueryParamsResponse.decode(message.value); + }, + toProto(message: QueryParamsResponse): Uint8Array { + return QueryParamsResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryParamsResponse): QueryParamsResponseProtoMsg { + return { + typeUrl: "/evmos.recovery.v1.QueryParamsResponse", + value: QueryParamsResponse.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/evmos/rpc.query.ts b/__fixtures__/v-next/outputicjsdeps/evmos/rpc.query.ts new file mode 100644 index 0000000000..9169126902 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/evmos/rpc.query.ts @@ -0,0 +1,99 @@ +import { Rpc } from "../helpers.js"; +import { connectComet, HttpEndpoint } from "@cosmjs/tendermint-rpc"; +import { QueryClient } from "@cosmjs/stargate"; +export const createRPCQueryClient = async ({ + rpcEndpoint +}: { + rpcEndpoint: string | HttpEndpoint; +}) => { + const tmClient = await connectComet(rpcEndpoint); + const client = new QueryClient(tmClient); + return { + cosmos: { + app: { + v1alpha1: (await import("../cosmos/app/v1alpha1/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + auth: { + v1beta1: (await import("../cosmos/auth/v1beta1/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + authz: { + v1beta1: (await import("../cosmos/authz/v1beta1/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + bank: { + v1beta1: (await import("../cosmos/bank/v1beta1/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + base: { + reflection: { + v1beta1: (await import("../cosmos/base/reflection/v1beta1/reflection.rpc.ReflectionService.js")).createRpcQueryExtension(client), + v2alpha1: (await import("../cosmos/base/reflection/v2alpha1/reflection.rpc.ReflectionService.js")).createRpcQueryExtension(client) + }, + tendermint: { + v1beta1: (await import("../cosmos/base/tendermint/v1beta1/query.rpc.Service.js")).createRpcQueryExtension(client) + } + }, + distribution: { + v1beta1: (await import("../cosmos/distribution/v1beta1/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + evidence: { + v1beta1: (await import("../cosmos/evidence/v1beta1/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + feegrant: { + v1beta1: (await import("../cosmos/feegrant/v1beta1/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + gov: { + v1: (await import("../cosmos/gov/v1/query.rpc.Query.js")).createRpcQueryExtension(client), + v1beta1: (await import("../cosmos/gov/v1beta1/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + group: { + v1: (await import("../cosmos/group/v1/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + mint: { + v1beta1: (await import("../cosmos/mint/v1beta1/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + nft: { + v1beta1: (await import("../cosmos/nft/v1beta1/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + params: { + v1beta1: (await import("../cosmos/params/v1beta1/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + slashing: { + v1beta1: (await import("../cosmos/slashing/v1beta1/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + staking: { + v1beta1: (await import("../cosmos/staking/v1beta1/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + tx: { + v1beta1: (await import("../cosmos/tx/v1beta1/service.rpc.Service.js")).createRpcQueryExtension(client) + }, + upgrade: { + v1beta1: (await import("../cosmos/upgrade/v1beta1/query.rpc.Query.js")).createRpcQueryExtension(client) + } + }, + evmos: { + claims: { + v1: (await import("./claims/v1/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + epochs: { + v1: (await import("./epochs/v1/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + erc20: { + v1: (await import("./erc20/v1/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + fees: { + v1: (await import("./fees/v1/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + incentives: { + v1: (await import("./incentives/v1/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + inflation: { + v1: (await import("./inflation/v1/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + recovery: { + v1: (await import("./recovery/v1/query.rpc.Query.js")).createRpcQueryExtension(client) + }, + vesting: { + v1: (await import("./vesting/v1/query.rpc.Query.js")).createRpcQueryExtension(client) + } + } + }; +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/evmos/rpc.tx.ts b/__fixtures__/v-next/outputicjsdeps/evmos/rpc.tx.ts new file mode 100644 index 0000000000..d5df45eb42 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/evmos/rpc.tx.ts @@ -0,0 +1,60 @@ +import { Rpc } from "../helpers.js"; +export const createRPCMsgClient = async ({ + rpc +}: { + rpc: Rpc; +}) => ({ + cosmos: { + authz: { + v1beta1: new (await import("../cosmos/authz/v1beta1/tx.rpc.msg.js")).MsgClientImpl(rpc) + }, + bank: { + v1beta1: new (await import("../cosmos/bank/v1beta1/tx.rpc.msg.js")).MsgClientImpl(rpc) + }, + crisis: { + v1beta1: new (await import("../cosmos/crisis/v1beta1/tx.rpc.msg.js")).MsgClientImpl(rpc) + }, + distribution: { + v1beta1: new (await import("../cosmos/distribution/v1beta1/tx.rpc.msg.js")).MsgClientImpl(rpc) + }, + evidence: { + v1beta1: new (await import("../cosmos/evidence/v1beta1/tx.rpc.msg.js")).MsgClientImpl(rpc) + }, + feegrant: { + v1beta1: new (await import("../cosmos/feegrant/v1beta1/tx.rpc.msg.js")).MsgClientImpl(rpc) + }, + gov: { + v1: new (await import("../cosmos/gov/v1/tx.rpc.msg.js")).MsgClientImpl(rpc), + v1beta1: new (await import("../cosmos/gov/v1beta1/tx.rpc.msg.js")).MsgClientImpl(rpc) + }, + group: { + v1: new (await import("../cosmos/group/v1/tx.rpc.msg.js")).MsgClientImpl(rpc) + }, + nft: { + v1beta1: new (await import("../cosmos/nft/v1beta1/tx.rpc.msg.js")).MsgClientImpl(rpc) + }, + slashing: { + v1beta1: new (await import("../cosmos/slashing/v1beta1/tx.rpc.msg.js")).MsgClientImpl(rpc) + }, + staking: { + v1beta1: new (await import("../cosmos/staking/v1beta1/tx.rpc.msg.js")).MsgClientImpl(rpc) + }, + upgrade: { + v1beta1: new (await import("../cosmos/upgrade/v1beta1/tx.rpc.msg.js")).MsgClientImpl(rpc) + }, + vesting: { + v1beta1: new (await import("../cosmos/vesting/v1beta1/tx.rpc.msg.js")).MsgClientImpl(rpc) + } + }, + evmos: { + erc20: { + v1: new (await import("./erc20/v1/tx.rpc.msg.js")).MsgClientImpl(rpc) + }, + fees: { + v1: new (await import("./fees/v1/tx.rpc.msg.js")).MsgClientImpl(rpc) + }, + vesting: { + v1: new (await import("./vesting/v1/tx.rpc.msg.js")).MsgClientImpl(rpc) + } + } +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/evmos/vesting/v1/query.lcd.ts b/__fixtures__/v-next/outputicjsdeps/evmos/vesting/v1/query.lcd.ts new file mode 100644 index 0000000000..74d8aa2f62 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/evmos/vesting/v1/query.lcd.ts @@ -0,0 +1,19 @@ +import { Coin, CoinSDKType } from "../../../cosmos/base/v1beta1/coin.js"; +import { LCDClient } from "@cosmology/lcd"; +import { QueryBalancesRequest, QueryBalancesRequestSDKType, QueryBalancesResponse, QueryBalancesResponseSDKType } from "./query.js"; +export class LCDQueryClient { + req: LCDClient; + constructor({ + requestClient + }: { + requestClient: LCDClient; + }) { + this.req = requestClient; + this.balances = this.balances.bind(this); + } + /* Retrieves the unvested, vested and locked tokens for a vesting account */ + async balances(params: QueryBalancesRequest): Promise { + const endpoint = `evmos/vesting/v1/balances/${params.address}`; + return QueryBalancesResponse.fromSDKJSON(await this.req.get(endpoint)); + } +} \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/evmos/vesting/v1/query.rpc.Query.ts b/__fixtures__/v-next/outputicjsdeps/evmos/vesting/v1/query.rpc.Query.ts new file mode 100644 index 0000000000..f74296c6ac --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/evmos/vesting/v1/query.rpc.Query.ts @@ -0,0 +1,31 @@ +import { Coin, CoinSDKType } from "../../../cosmos/base/v1beta1/coin.js"; +import { Rpc } from "../../../helpers.js"; +import { BinaryReader } from "../../../binary.js"; +import { QueryClient, createProtobufRpcClient } from "@cosmjs/stargate"; +import { QueryBalancesRequest, QueryBalancesRequestSDKType, QueryBalancesResponse, QueryBalancesResponseSDKType } from "./query.js"; +/** Query defines the gRPC querier service. */ +export interface Query { + /** Retrieves the unvested, vested and locked tokens for a vesting account */ + balances(request: QueryBalancesRequest): Promise; +} +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + this.balances = this.balances.bind(this); + } + balances(request: QueryBalancesRequest): Promise { + const data = QueryBalancesRequest.encode(request).finish(); + const promise = this.rpc.request("evmos.vesting.v1.Query", "Balances", data); + return promise.then(data => QueryBalancesResponse.decode(new BinaryReader(data))); + } +} +export const createRpcQueryExtension = (base: QueryClient) => { + const rpc = createProtobufRpcClient(base); + const queryService = new QueryClientImpl(rpc); + return { + balances(request: QueryBalancesRequest): Promise { + return queryService.balances(request); + } + }; +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/evmos/vesting/v1/query.rpc.func.ts b/__fixtures__/v-next/outputicjsdeps/evmos/vesting/v1/query.rpc.func.ts new file mode 100644 index 0000000000..a0f8359249 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/evmos/vesting/v1/query.rpc.func.ts @@ -0,0 +1,14 @@ +import { RpcResolver, buildQuery } from "../../../helper-func-types"; +import { buildUseQuery } from "../../../react-query"; +import { QueryBalancesRequest, QueryBalancesResponse } from "./query"; +export const createGetBalances = (getRpcInstance: RpcResolver) => buildQuery({ + encode: QueryBalancesRequest.encode, + decode: QueryBalancesResponse.decode, + service: "evmos.vesting.v1.Query", + method: "Balances", + getRpcInstance: getRpcInstance +}); +export const useGetBalances = buildUseQuery({ + builderQueryFn: createGetBalances, + queryKeyPrefix: "BalancesQuery" +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/evmos/vesting/v1/query.ts b/__fixtures__/v-next/outputicjsdeps/evmos/vesting/v1/query.ts new file mode 100644 index 0000000000..9327e5db67 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/evmos/vesting/v1/query.ts @@ -0,0 +1,283 @@ +import { Coin, CoinSDKType } from "../../../cosmos/base/v1beta1/coin.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "evmos.vesting.v1"; +/** QueryBalancesRequest is the request type for the Query/Balances RPC method. */ +export interface QueryBalancesRequest { + /** address of the clawback vesting account */ + address: string; +} +export interface QueryBalancesRequestProtoMsg { + typeUrl: "/evmos.vesting.v1.QueryBalancesRequest"; + value: Uint8Array; +} +/** QueryBalancesRequest is the request type for the Query/Balances RPC method. */ +export interface QueryBalancesRequestSDKType { + address: string; +} +/** + * QueryBalancesResponse is the response type for the Query/Balances RPC + * method. + */ +export interface QueryBalancesResponse { + /** current amount of locked tokens */ + locked: Coin[]; + /** current amount of unvested tokens */ + unvested: Coin[]; + /** current amount of vested tokens */ + vested: Coin[]; +} +export interface QueryBalancesResponseProtoMsg { + typeUrl: "/evmos.vesting.v1.QueryBalancesResponse"; + value: Uint8Array; +} +/** + * QueryBalancesResponse is the response type for the Query/Balances RPC + * method. + */ +export interface QueryBalancesResponseSDKType { + locked: CoinSDKType[]; + unvested: CoinSDKType[]; + vested: CoinSDKType[]; +} +function createBaseQueryBalancesRequest(): QueryBalancesRequest { + return { + address: "" + }; +} +export const QueryBalancesRequest = { + typeUrl: "/evmos.vesting.v1.QueryBalancesRequest", + encode(message: QueryBalancesRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.address !== undefined) { + writer.uint32(10).string(message.address); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryBalancesRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryBalancesRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryBalancesRequest { + const obj = createBaseQueryBalancesRequest(); + if (isSet(object.address)) obj.address = String(object.address); + return obj; + }, + toJSON(message: QueryBalancesRequest): JsonSafe { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + return obj; + }, + fromPartial(object: DeepPartial): QueryBalancesRequest { + const message = createBaseQueryBalancesRequest(); + message.address = object.address ?? ""; + return message; + }, + fromSDK(object: QueryBalancesRequestSDKType): QueryBalancesRequest { + return { + address: object?.address + }; + }, + fromSDKJSON(object: any): QueryBalancesRequestSDKType { + return { + address: isSet(object.address) ? String(object.address) : "" + }; + }, + toSDK(message: QueryBalancesRequest): QueryBalancesRequestSDKType { + const obj: any = {}; + obj.address = message.address; + return obj; + }, + fromAmino(object: QueryBalancesRequestAmino): QueryBalancesRequest { + const message = createBaseQueryBalancesRequest(); + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } + return message; + }, + toAmino(message: QueryBalancesRequest): QueryBalancesRequestAmino { + const obj: any = {}; + obj.address = message.address === "" ? undefined : message.address; + return obj; + }, + fromAminoMsg(object: QueryBalancesRequestAminoMsg): QueryBalancesRequest { + return QueryBalancesRequest.fromAmino(object.value); + }, + fromProtoMsg(message: QueryBalancesRequestProtoMsg): QueryBalancesRequest { + return QueryBalancesRequest.decode(message.value); + }, + toProto(message: QueryBalancesRequest): Uint8Array { + return QueryBalancesRequest.encode(message).finish(); + }, + toProtoMsg(message: QueryBalancesRequest): QueryBalancesRequestProtoMsg { + return { + typeUrl: "/evmos.vesting.v1.QueryBalancesRequest", + value: QueryBalancesRequest.encode(message).finish() + }; + } +}; +function createBaseQueryBalancesResponse(): QueryBalancesResponse { + return { + locked: [], + unvested: [], + vested: [] + }; +} +export const QueryBalancesResponse = { + typeUrl: "/evmos.vesting.v1.QueryBalancesResponse", + encode(message: QueryBalancesResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.locked) { + Coin.encode(v!, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.unvested) { + Coin.encode(v!, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.vested) { + Coin.encode(v!, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QueryBalancesResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryBalancesResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.locked.push(Coin.decode(reader, reader.uint32())); + break; + case 2: + message.unvested.push(Coin.decode(reader, reader.uint32())); + break; + case 3: + message.vested.push(Coin.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QueryBalancesResponse { + const obj = createBaseQueryBalancesResponse(); + if (Array.isArray(object?.locked)) obj.locked = object.locked.map((e: any) => Coin.fromJSON(e)); + if (Array.isArray(object?.unvested)) obj.unvested = object.unvested.map((e: any) => Coin.fromJSON(e)); + if (Array.isArray(object?.vested)) obj.vested = object.vested.map((e: any) => Coin.fromJSON(e)); + return obj; + }, + toJSON(message: QueryBalancesResponse): JsonSafe { + const obj: any = {}; + if (message.locked) { + obj.locked = message.locked.map(e => e ? Coin.toJSON(e) : undefined); + } else { + obj.locked = []; + } + if (message.unvested) { + obj.unvested = message.unvested.map(e => e ? Coin.toJSON(e) : undefined); + } else { + obj.unvested = []; + } + if (message.vested) { + obj.vested = message.vested.map(e => e ? Coin.toJSON(e) : undefined); + } else { + obj.vested = []; + } + return obj; + }, + fromPartial(object: DeepPartial): QueryBalancesResponse { + const message = createBaseQueryBalancesResponse(); + message.locked = object.locked?.map(e => Coin.fromPartial(e)) || []; + message.unvested = object.unvested?.map(e => Coin.fromPartial(e)) || []; + message.vested = object.vested?.map(e => Coin.fromPartial(e)) || []; + return message; + }, + fromSDK(object: QueryBalancesResponseSDKType): QueryBalancesResponse { + return { + locked: Array.isArray(object?.locked) ? object.locked.map((e: any) => Coin.fromSDK(e)) : [], + unvested: Array.isArray(object?.unvested) ? object.unvested.map((e: any) => Coin.fromSDK(e)) : [], + vested: Array.isArray(object?.vested) ? object.vested.map((e: any) => Coin.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): QueryBalancesResponseSDKType { + return { + locked: Array.isArray(object?.locked) ? object.locked.map((e: any) => Coin.fromSDKJSON(e)) : [], + unvested: Array.isArray(object?.unvested) ? object.unvested.map((e: any) => Coin.fromSDKJSON(e)) : [], + vested: Array.isArray(object?.vested) ? object.vested.map((e: any) => Coin.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: QueryBalancesResponse): QueryBalancesResponseSDKType { + const obj: any = {}; + if (message.locked) { + obj.locked = message.locked.map(e => e ? Coin.toSDK(e) : undefined); + } else { + obj.locked = []; + } + if (message.unvested) { + obj.unvested = message.unvested.map(e => e ? Coin.toSDK(e) : undefined); + } else { + obj.unvested = []; + } + if (message.vested) { + obj.vested = message.vested.map(e => e ? Coin.toSDK(e) : undefined); + } else { + obj.vested = []; + } + return obj; + }, + fromAmino(object: QueryBalancesResponseAmino): QueryBalancesResponse { + const message = createBaseQueryBalancesResponse(); + message.locked = object.locked?.map(e => Coin.fromAmino(e)) || []; + message.unvested = object.unvested?.map(e => Coin.fromAmino(e)) || []; + message.vested = object.vested?.map(e => Coin.fromAmino(e)) || []; + return message; + }, + toAmino(message: QueryBalancesResponse): QueryBalancesResponseAmino { + const obj: any = {}; + if (message.locked) { + obj.locked = message.locked.map(e => e ? Coin.toAmino(e) : undefined); + } else { + obj.locked = message.locked; + } + if (message.unvested) { + obj.unvested = message.unvested.map(e => e ? Coin.toAmino(e) : undefined); + } else { + obj.unvested = message.unvested; + } + if (message.vested) { + obj.vested = message.vested.map(e => e ? Coin.toAmino(e) : undefined); + } else { + obj.vested = message.vested; + } + return obj; + }, + fromAminoMsg(object: QueryBalancesResponseAminoMsg): QueryBalancesResponse { + return QueryBalancesResponse.fromAmino(object.value); + }, + fromProtoMsg(message: QueryBalancesResponseProtoMsg): QueryBalancesResponse { + return QueryBalancesResponse.decode(message.value); + }, + toProto(message: QueryBalancesResponse): Uint8Array { + return QueryBalancesResponse.encode(message).finish(); + }, + toProtoMsg(message: QueryBalancesResponse): QueryBalancesResponseProtoMsg { + return { + typeUrl: "/evmos.vesting.v1.QueryBalancesResponse", + value: QueryBalancesResponse.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/evmos/vesting/v1/tx.amino.ts b/__fixtures__/v-next/outputicjsdeps/evmos/vesting/v1/tx.amino.ts new file mode 100644 index 0000000000..cf9727ec0c --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/evmos/vesting/v1/tx.amino.ts @@ -0,0 +1,124 @@ +import { Timestamp, TimestampSDKType } from "../../../google/protobuf/timestamp.js"; +import { Period, PeriodSDKType } from "../../../cosmos/vesting/v1beta1/vesting.js"; +import { ReadOnlyAminoMsg as AminoMsg } from "@interchainjs/ReadOnlyAminoMsg"; +import { Coin, CoinSDKType } from "../../../cosmos/base/v1beta1/coin.js"; +import { MsgCreateClawbackVestingAccount, MsgCreateClawbackVestingAccountSDKType, MsgClawback, MsgClawbackSDKType } from "./tx.js"; +export interface MsgCreateClawbackVestingAccountAminoType extends AminoMsg { + type: "/evmos.vesting.v1.MsgCreateClawbackVestingAccount"; + value: { + from_address: string; + to_address: string; + start_time: string; + lockup_periods: { + length: string; + amount: { + denom: string; + amount: string; + }[]; + }[]; + vesting_periods: { + length: string; + amount: { + denom: string; + amount: string; + }[]; + }[]; + merge: boolean; + }; +} +export interface MsgClawbackAminoType extends AminoMsg { + type: "/evmos.vesting.v1.MsgClawback"; + value: { + funder_address: string; + account_address: string; + dest_address: string; + }; +} +export const AminoConverter = { + "/evmos.vesting.v1.MsgCreateClawbackVestingAccount": { + aminoType: "/evmos.vesting.v1.MsgCreateClawbackVestingAccount", + toAmino: ({ + fromAddress, + toAddress, + startTime, + lockupPeriods, + vestingPeriods, + merge + }: MsgCreateClawbackVestingAccount): MsgCreateClawbackVestingAccountAminoType["value"] => { + return { + from_address: fromAddress, + to_address: toAddress, + start_time: startTime, + lockup_periods: lockupPeriods.map(el0 => ({ + length: el0.length.toString(), + amount: el0.amount.map(el1 => ({ + denom: el1.denom, + amount: el1.amount + })) + })), + vesting_periods: vestingPeriods.map(el0 => ({ + length: el0.length.toString(), + amount: el0.amount.map(el1 => ({ + denom: el1.denom, + amount: el1.amount + })) + })), + merge + }; + }, + fromAmino: ({ + from_address, + to_address, + start_time, + lockup_periods, + vesting_periods, + merge + }: MsgCreateClawbackVestingAccountAminoType["value"]): MsgCreateClawbackVestingAccount => { + return { + fromAddress: from_address, + toAddress: to_address, + startTime: start_time, + lockupPeriods: lockup_periods.map(el0 => ({ + length: BigInt(el0.length), + amount: el0.amount.map(el1 => ({ + denom: el1.denom, + amount: el1.amount + })) + })), + vestingPeriods: vesting_periods.map(el0 => ({ + length: BigInt(el0.length), + amount: el0.amount.map(el1 => ({ + denom: el1.denom, + amount: el1.amount + })) + })), + merge + }; + } + }, + "/evmos.vesting.v1.MsgClawback": { + aminoType: "/evmos.vesting.v1.MsgClawback", + toAmino: ({ + funderAddress, + accountAddress, + destAddress + }: MsgClawback): MsgClawbackAminoType["value"] => { + return { + funder_address: funderAddress, + account_address: accountAddress, + dest_address: destAddress + }; + }, + fromAmino: ({ + funder_address, + account_address, + dest_address + }: MsgClawbackAminoType["value"]): MsgClawback => { + return { + funderAddress: funder_address, + accountAddress: account_address, + destAddress: dest_address + }; + } + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/evmos/vesting/v1/tx.registry.ts b/__fixtures__/v-next/outputicjsdeps/evmos/vesting/v1/tx.registry.ts new file mode 100644 index 0000000000..cc6a7ed7e2 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/evmos/vesting/v1/tx.registry.ts @@ -0,0 +1,82 @@ +import { Timestamp, TimestampSDKType } from "../../../google/protobuf/timestamp.js"; +import { Period, PeriodSDKType } from "../../../cosmos/vesting/v1beta1/vesting.js"; +import { GeneratedType, Registry } from "@cosmjs/proto-signing"; +import { MsgCreateClawbackVestingAccount, MsgCreateClawbackVestingAccountSDKType, MsgClawback, MsgClawbackSDKType } from "./tx.js"; +export const registry: ReadonlyArray<[string, GeneratedType]> = [["/evmos.vesting.v1.MsgCreateClawbackVestingAccount", MsgCreateClawbackVestingAccount], ["/evmos.vesting.v1.MsgClawback", MsgClawback]]; +export const load = (protoRegistry: Registry) => { + registry.forEach(([typeUrl, mod]) => { + protoRegistry.register(typeUrl, mod); + }); +}; +export const MessageComposer = { + encoded: { + createClawbackVestingAccount(value: MsgCreateClawbackVestingAccount) { + return { + typeUrl: "/evmos.vesting.v1.MsgCreateClawbackVestingAccount", + value: MsgCreateClawbackVestingAccount.encode(value).finish() + }; + }, + clawback(value: MsgClawback) { + return { + typeUrl: "/evmos.vesting.v1.MsgClawback", + value: MsgClawback.encode(value).finish() + }; + } + }, + withTypeUrl: { + createClawbackVestingAccount(value: MsgCreateClawbackVestingAccount) { + return { + typeUrl: "/evmos.vesting.v1.MsgCreateClawbackVestingAccount", + value + }; + }, + clawback(value: MsgClawback) { + return { + typeUrl: "/evmos.vesting.v1.MsgClawback", + value + }; + } + }, + toJSON: { + createClawbackVestingAccount(value: MsgCreateClawbackVestingAccount) { + return { + typeUrl: "/evmos.vesting.v1.MsgCreateClawbackVestingAccount", + value: MsgCreateClawbackVestingAccount.toJSON(value) + }; + }, + clawback(value: MsgClawback) { + return { + typeUrl: "/evmos.vesting.v1.MsgClawback", + value: MsgClawback.toJSON(value) + }; + } + }, + fromJSON: { + createClawbackVestingAccount(value: any) { + return { + typeUrl: "/evmos.vesting.v1.MsgCreateClawbackVestingAccount", + value: MsgCreateClawbackVestingAccount.fromJSON(value) + }; + }, + clawback(value: any) { + return { + typeUrl: "/evmos.vesting.v1.MsgClawback", + value: MsgClawback.fromJSON(value) + }; + } + }, + fromPartial: { + createClawbackVestingAccount(value: MsgCreateClawbackVestingAccount) { + return { + typeUrl: "/evmos.vesting.v1.MsgCreateClawbackVestingAccount", + value: MsgCreateClawbackVestingAccount.fromPartial(value) + }; + }, + clawback(value: MsgClawback) { + return { + typeUrl: "/evmos.vesting.v1.MsgClawback", + value: MsgClawback.fromPartial(value) + }; + } + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/evmos/vesting/v1/tx.rpc.func.ts b/__fixtures__/v-next/outputicjsdeps/evmos/vesting/v1/tx.rpc.func.ts new file mode 100644 index 0000000000..88a5d4ca4a --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/evmos/vesting/v1/tx.rpc.func.ts @@ -0,0 +1,22 @@ +import { buildTx, SigningClientResolver } from "../../../helper-func-types"; +import { buildUseMutation } from "../../../react-query"; +import { toEncoders, toConverters } from "@interchainjs/cosmos/utils"; +import { MsgCreateClawbackVestingAccount, MsgClawback } from "./tx"; +export const createCreateClawbackVestingAccount = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgCreateClawbackVestingAccount.typeUrl, + encoders: toEncoders(MsgCreateClawbackVestingAccount), + converters: toConverters(MsgCreateClawbackVestingAccount) +}); +export const useCreateClawbackVestingAccount = buildUseMutation({ + builderMutationFn: createCreateClawbackVestingAccount +}); +export const createClawback = (getSigningClient: SigningClientResolver) => buildTx({ + getSigningClient: getSigningClient, + typeUrl: MsgClawback.typeUrl, + encoders: toEncoders(MsgClawback), + converters: toConverters(MsgClawback) +}); +export const useClawback = buildUseMutation({ + builderMutationFn: createClawback +}); \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/evmos/vesting/v1/tx.rpc.msg.ts b/__fixtures__/v-next/outputicjsdeps/evmos/vesting/v1/tx.rpc.msg.ts new file mode 100644 index 0000000000..23323e5074 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/evmos/vesting/v1/tx.rpc.msg.ts @@ -0,0 +1,36 @@ +import { Timestamp, TimestampSDKType } from "../../../google/protobuf/timestamp.js"; +import { Period, PeriodSDKType } from "../../../cosmos/vesting/v1beta1/vesting.js"; +import { Rpc } from "../../../helpers.js"; +import { BinaryReader } from "../../../binary.js"; +import { MsgCreateClawbackVestingAccount, MsgCreateClawbackVestingAccountSDKType, MsgCreateClawbackVestingAccountResponse, MsgCreateClawbackVestingAccountResponseSDKType, MsgClawback, MsgClawbackSDKType, MsgClawbackResponse, MsgClawbackResponseSDKType } from "./tx.js"; +/** Msg defines the vesting Msg service. */ +export interface Msg { + /** + * CreateClawbackVestingAccount creats a vesting account that is subject to + * clawback and the configuration of vesting and lockup schedules. + */ + createClawbackVestingAccount(request: MsgCreateClawbackVestingAccount): Promise; + /** Clawback removes the unvested tokens from a ClawbackVestingAccount. */ + clawback(request: MsgClawback): Promise; +} +export class MsgClientImpl implements Msg { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + this.createClawbackVestingAccount = this.createClawbackVestingAccount.bind(this); + this.clawback = this.clawback.bind(this); + } + createClawbackVestingAccount(request: MsgCreateClawbackVestingAccount): Promise { + const data = MsgCreateClawbackVestingAccount.encode(request).finish(); + const promise = this.rpc.request("evmos.vesting.v1.Msg", "CreateClawbackVestingAccount", data); + return promise.then(data => MsgCreateClawbackVestingAccountResponse.decode(new BinaryReader(data))); + } + clawback(request: MsgClawback): Promise { + const data = MsgClawback.encode(request).finish(); + const promise = this.rpc.request("evmos.vesting.v1.Msg", "Clawback", data); + return promise.then(data => MsgClawbackResponse.decode(new BinaryReader(data))); + } +} +export const createClientImpl = (rpc: Rpc) => { + return new MsgClientImpl(rpc); +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/evmos/vesting/v1/tx.ts b/__fixtures__/v-next/outputicjsdeps/evmos/vesting/v1/tx.ts new file mode 100644 index 0000000000..91e7084dbd --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/evmos/vesting/v1/tx.ts @@ -0,0 +1,545 @@ +import { Timestamp, TimestampSDKType } from "../../../google/protobuf/timestamp.js"; +import { Period, PeriodSDKType } from "../../../cosmos/vesting/v1beta1/vesting.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { toTimestamp, fromTimestamp, isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "evmos.vesting.v1"; +/** MsgCreateClawbackVestingAccount defines a message that enables creating a ClawbackVestingAccount. */ +export interface MsgCreateClawbackVestingAccount { + /** + * from_address specifies the account to provide the funds and sign the + * clawback request + */ + fromAddress: string; + /** to_address specifies the account to receive the funds */ + toAddress: string; + /** start_time defines the time at which the vesting period begins */ + startTime: Date; + /** lockup_periods defines the unlocking schedule relative to the start_time */ + lockupPeriods: Period[]; + /** vesting_periods defines thevesting schedule relative to the start_time */ + vestingPeriods: Period[]; + /** + * merge specifies a the creation mechanism for existing + * ClawbackVestingAccounts. If true, merge this new grant into an existing + * ClawbackVestingAccount, or create it if it does not exist. If false, + * creates a new account. New grants to an existing account must be from the + * same from_address. + */ + merge: boolean; +} +export interface MsgCreateClawbackVestingAccountProtoMsg { + typeUrl: "/evmos.vesting.v1.MsgCreateClawbackVestingAccount"; + value: Uint8Array; +} +/** MsgCreateClawbackVestingAccount defines a message that enables creating a ClawbackVestingAccount. */ +export interface MsgCreateClawbackVestingAccountSDKType { + from_address: string; + to_address: string; + start_time: Date; + lockup_periods: PeriodSDKType[]; + vesting_periods: PeriodSDKType[]; + merge: boolean; +} +/** + * MsgCreateClawbackVestingAccountResponse defines the + * MsgCreateClawbackVestingAccount response type. + */ +export interface MsgCreateClawbackVestingAccountResponse {} +export interface MsgCreateClawbackVestingAccountResponseProtoMsg { + typeUrl: "/evmos.vesting.v1.MsgCreateClawbackVestingAccountResponse"; + value: Uint8Array; +} +/** + * MsgCreateClawbackVestingAccountResponse defines the + * MsgCreateClawbackVestingAccount response type. + */ +export interface MsgCreateClawbackVestingAccountResponseSDKType {} +/** + * MsgClawback defines a message that removes unvested tokens from a + * ClawbackVestingAccount. + */ +export interface MsgClawback { + /** funder_address is the address which funded the account */ + funderAddress: string; + /** account_address is the address of the ClawbackVestingAccount to claw back from. */ + accountAddress: string; + /** + * dest_address specifies where the clawed-back tokens should be transferred + * to. If empty, the tokens will be transferred back to the original funder of + * the account. + */ + destAddress: string; +} +export interface MsgClawbackProtoMsg { + typeUrl: "/evmos.vesting.v1.MsgClawback"; + value: Uint8Array; +} +/** + * MsgClawback defines a message that removes unvested tokens from a + * ClawbackVestingAccount. + */ +export interface MsgClawbackSDKType { + funder_address: string; + account_address: string; + dest_address: string; +} +/** MsgClawbackResponse defines the MsgClawback response type. */ +export interface MsgClawbackResponse {} +export interface MsgClawbackResponseProtoMsg { + typeUrl: "/evmos.vesting.v1.MsgClawbackResponse"; + value: Uint8Array; +} +/** MsgClawbackResponse defines the MsgClawback response type. */ +export interface MsgClawbackResponseSDKType {} +function createBaseMsgCreateClawbackVestingAccount(): MsgCreateClawbackVestingAccount { + return { + fromAddress: "", + toAddress: "", + startTime: new Date(), + lockupPeriods: [], + vestingPeriods: [], + merge: false + }; +} +export const MsgCreateClawbackVestingAccount = { + typeUrl: "/evmos.vesting.v1.MsgCreateClawbackVestingAccount", + encode(message: MsgCreateClawbackVestingAccount, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.fromAddress !== undefined) { + writer.uint32(10).string(message.fromAddress); + } + if (message.toAddress !== undefined) { + writer.uint32(18).string(message.toAddress); + } + if (message.startTime !== undefined) { + Timestamp.encode(toTimestamp(message.startTime), writer.uint32(26).fork()).ldelim(); + } + for (const v of message.lockupPeriods) { + Period.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.vestingPeriods) { + Period.encode(v!, writer.uint32(42).fork()).ldelim(); + } + if (message.merge !== undefined) { + writer.uint32(48).bool(message.merge); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgCreateClawbackVestingAccount { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgCreateClawbackVestingAccount(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.fromAddress = reader.string(); + break; + case 2: + message.toAddress = reader.string(); + break; + case 3: + message.startTime = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + break; + case 4: + message.lockupPeriods.push(Period.decode(reader, reader.uint32())); + break; + case 5: + message.vestingPeriods.push(Period.decode(reader, reader.uint32())); + break; + case 6: + message.merge = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgCreateClawbackVestingAccount { + const obj = createBaseMsgCreateClawbackVestingAccount(); + if (isSet(object.fromAddress)) obj.fromAddress = String(object.fromAddress); + if (isSet(object.toAddress)) obj.toAddress = String(object.toAddress); + if (isSet(object.startTime)) obj.startTime = new Date(object.startTime); + if (Array.isArray(object?.lockupPeriods)) obj.lockupPeriods = object.lockupPeriods.map((e: any) => Period.fromJSON(e)); + if (Array.isArray(object?.vestingPeriods)) obj.vestingPeriods = object.vestingPeriods.map((e: any) => Period.fromJSON(e)); + if (isSet(object.merge)) obj.merge = Boolean(object.merge); + return obj; + }, + toJSON(message: MsgCreateClawbackVestingAccount): JsonSafe { + const obj: any = {}; + message.fromAddress !== undefined && (obj.fromAddress = message.fromAddress); + message.toAddress !== undefined && (obj.toAddress = message.toAddress); + message.startTime !== undefined && (obj.startTime = message.startTime.toISOString()); + if (message.lockupPeriods) { + obj.lockupPeriods = message.lockupPeriods.map(e => e ? Period.toJSON(e) : undefined); + } else { + obj.lockupPeriods = []; + } + if (message.vestingPeriods) { + obj.vestingPeriods = message.vestingPeriods.map(e => e ? Period.toJSON(e) : undefined); + } else { + obj.vestingPeriods = []; + } + message.merge !== undefined && (obj.merge = message.merge); + return obj; + }, + fromPartial(object: DeepPartial): MsgCreateClawbackVestingAccount { + const message = createBaseMsgCreateClawbackVestingAccount(); + message.fromAddress = object.fromAddress ?? ""; + message.toAddress = object.toAddress ?? ""; + message.startTime = object.startTime ?? undefined; + message.lockupPeriods = object.lockupPeriods?.map(e => Period.fromPartial(e)) || []; + message.vestingPeriods = object.vestingPeriods?.map(e => Period.fromPartial(e)) || []; + message.merge = object.merge ?? false; + return message; + }, + fromSDK(object: MsgCreateClawbackVestingAccountSDKType): MsgCreateClawbackVestingAccount { + return { + fromAddress: object?.from_address, + toAddress: object?.to_address, + startTime: object.start_time ?? undefined, + lockupPeriods: Array.isArray(object?.lockup_periods) ? object.lockup_periods.map((e: any) => Period.fromSDK(e)) : [], + vestingPeriods: Array.isArray(object?.vesting_periods) ? object.vesting_periods.map((e: any) => Period.fromSDK(e)) : [], + merge: object?.merge + }; + }, + fromSDKJSON(object: any): MsgCreateClawbackVestingAccountSDKType { + return { + from_address: isSet(object.from_address) ? String(object.from_address) : "", + to_address: isSet(object.to_address) ? String(object.to_address) : "", + start_time: isSet(object.start_time) ? new Date(object.start_time) : undefined, + lockup_periods: Array.isArray(object?.lockup_periods) ? object.lockup_periods.map((e: any) => Period.fromSDKJSON(e)) : [], + vesting_periods: Array.isArray(object?.vesting_periods) ? object.vesting_periods.map((e: any) => Period.fromSDKJSON(e)) : [], + merge: isSet(object.merge) ? Boolean(object.merge) : false + }; + }, + toSDK(message: MsgCreateClawbackVestingAccount): MsgCreateClawbackVestingAccountSDKType { + const obj: any = {}; + obj.from_address = message.fromAddress; + obj.to_address = message.toAddress; + message.startTime !== undefined && (obj.start_time = message.startTime ?? undefined); + if (message.lockupPeriods) { + obj.lockup_periods = message.lockupPeriods.map(e => e ? Period.toSDK(e) : undefined); + } else { + obj.lockup_periods = []; + } + if (message.vestingPeriods) { + obj.vesting_periods = message.vestingPeriods.map(e => e ? Period.toSDK(e) : undefined); + } else { + obj.vesting_periods = []; + } + obj.merge = message.merge; + return obj; + }, + fromAmino(object: MsgCreateClawbackVestingAccountAmino): MsgCreateClawbackVestingAccount { + const message = createBaseMsgCreateClawbackVestingAccount(); + if (object.from_address !== undefined && object.from_address !== null) { + message.fromAddress = object.from_address; + } + if (object.to_address !== undefined && object.to_address !== null) { + message.toAddress = object.to_address; + } + if (object.start_time !== undefined && object.start_time !== null) { + message.startTime = fromTimestamp(Timestamp.fromAmino(object.start_time)); + } + message.lockupPeriods = object.lockup_periods?.map(e => Period.fromAmino(e)) || []; + message.vestingPeriods = object.vesting_periods?.map(e => Period.fromAmino(e)) || []; + if (object.merge !== undefined && object.merge !== null) { + message.merge = object.merge; + } + return message; + }, + toAmino(message: MsgCreateClawbackVestingAccount): MsgCreateClawbackVestingAccountAmino { + const obj: any = {}; + obj.from_address = message.fromAddress === "" ? undefined : message.fromAddress; + obj.to_address = message.toAddress === "" ? undefined : message.toAddress; + obj.start_time = message.startTime ? Timestamp.toAmino(toTimestamp(message.startTime)) : undefined; + if (message.lockupPeriods) { + obj.lockup_periods = message.lockupPeriods.map(e => e ? Period.toAmino(e) : undefined); + } else { + obj.lockup_periods = message.lockupPeriods; + } + if (message.vestingPeriods) { + obj.vesting_periods = message.vestingPeriods.map(e => e ? Period.toAmino(e) : undefined); + } else { + obj.vesting_periods = message.vestingPeriods; + } + obj.merge = message.merge === false ? undefined : message.merge; + return obj; + }, + fromAminoMsg(object: MsgCreateClawbackVestingAccountAminoMsg): MsgCreateClawbackVestingAccount { + return MsgCreateClawbackVestingAccount.fromAmino(object.value); + }, + fromProtoMsg(message: MsgCreateClawbackVestingAccountProtoMsg): MsgCreateClawbackVestingAccount { + return MsgCreateClawbackVestingAccount.decode(message.value); + }, + toProto(message: MsgCreateClawbackVestingAccount): Uint8Array { + return MsgCreateClawbackVestingAccount.encode(message).finish(); + }, + toProtoMsg(message: MsgCreateClawbackVestingAccount): MsgCreateClawbackVestingAccountProtoMsg { + return { + typeUrl: "/evmos.vesting.v1.MsgCreateClawbackVestingAccount", + value: MsgCreateClawbackVestingAccount.encode(message).finish() + }; + } +}; +function createBaseMsgCreateClawbackVestingAccountResponse(): MsgCreateClawbackVestingAccountResponse { + return {}; +} +export const MsgCreateClawbackVestingAccountResponse = { + typeUrl: "/evmos.vesting.v1.MsgCreateClawbackVestingAccountResponse", + encode(_: MsgCreateClawbackVestingAccountResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgCreateClawbackVestingAccountResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgCreateClawbackVestingAccountResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgCreateClawbackVestingAccountResponse { + const obj = createBaseMsgCreateClawbackVestingAccountResponse(); + return obj; + }, + toJSON(_: MsgCreateClawbackVestingAccountResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): MsgCreateClawbackVestingAccountResponse { + const message = createBaseMsgCreateClawbackVestingAccountResponse(); + return message; + }, + fromSDK(_: MsgCreateClawbackVestingAccountResponseSDKType): MsgCreateClawbackVestingAccountResponse { + return {}; + }, + fromSDKJSON(_: any): MsgCreateClawbackVestingAccountResponseSDKType { + return {}; + }, + toSDK(_: MsgCreateClawbackVestingAccountResponse): MsgCreateClawbackVestingAccountResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgCreateClawbackVestingAccountResponseAmino): MsgCreateClawbackVestingAccountResponse { + const message = createBaseMsgCreateClawbackVestingAccountResponse(); + return message; + }, + toAmino(_: MsgCreateClawbackVestingAccountResponse): MsgCreateClawbackVestingAccountResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgCreateClawbackVestingAccountResponseAminoMsg): MsgCreateClawbackVestingAccountResponse { + return MsgCreateClawbackVestingAccountResponse.fromAmino(object.value); + }, + fromProtoMsg(message: MsgCreateClawbackVestingAccountResponseProtoMsg): MsgCreateClawbackVestingAccountResponse { + return MsgCreateClawbackVestingAccountResponse.decode(message.value); + }, + toProto(message: MsgCreateClawbackVestingAccountResponse): Uint8Array { + return MsgCreateClawbackVestingAccountResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgCreateClawbackVestingAccountResponse): MsgCreateClawbackVestingAccountResponseProtoMsg { + return { + typeUrl: "/evmos.vesting.v1.MsgCreateClawbackVestingAccountResponse", + value: MsgCreateClawbackVestingAccountResponse.encode(message).finish() + }; + } +}; +function createBaseMsgClawback(): MsgClawback { + return { + funderAddress: "", + accountAddress: "", + destAddress: "" + }; +} +export const MsgClawback = { + typeUrl: "/evmos.vesting.v1.MsgClawback", + encode(message: MsgClawback, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.funderAddress !== undefined) { + writer.uint32(10).string(message.funderAddress); + } + if (message.accountAddress !== undefined) { + writer.uint32(18).string(message.accountAddress); + } + if (message.destAddress !== undefined) { + writer.uint32(26).string(message.destAddress); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgClawback { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgClawback(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.funderAddress = reader.string(); + break; + case 2: + message.accountAddress = reader.string(); + break; + case 3: + message.destAddress = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MsgClawback { + const obj = createBaseMsgClawback(); + if (isSet(object.funderAddress)) obj.funderAddress = String(object.funderAddress); + if (isSet(object.accountAddress)) obj.accountAddress = String(object.accountAddress); + if (isSet(object.destAddress)) obj.destAddress = String(object.destAddress); + return obj; + }, + toJSON(message: MsgClawback): JsonSafe { + const obj: any = {}; + message.funderAddress !== undefined && (obj.funderAddress = message.funderAddress); + message.accountAddress !== undefined && (obj.accountAddress = message.accountAddress); + message.destAddress !== undefined && (obj.destAddress = message.destAddress); + return obj; + }, + fromPartial(object: DeepPartial): MsgClawback { + const message = createBaseMsgClawback(); + message.funderAddress = object.funderAddress ?? ""; + message.accountAddress = object.accountAddress ?? ""; + message.destAddress = object.destAddress ?? ""; + return message; + }, + fromSDK(object: MsgClawbackSDKType): MsgClawback { + return { + funderAddress: object?.funder_address, + accountAddress: object?.account_address, + destAddress: object?.dest_address + }; + }, + fromSDKJSON(object: any): MsgClawbackSDKType { + return { + funder_address: isSet(object.funder_address) ? String(object.funder_address) : "", + account_address: isSet(object.account_address) ? String(object.account_address) : "", + dest_address: isSet(object.dest_address) ? String(object.dest_address) : "" + }; + }, + toSDK(message: MsgClawback): MsgClawbackSDKType { + const obj: any = {}; + obj.funder_address = message.funderAddress; + obj.account_address = message.accountAddress; + obj.dest_address = message.destAddress; + return obj; + }, + fromAmino(object: MsgClawbackAmino): MsgClawback { + const message = createBaseMsgClawback(); + if (object.funder_address !== undefined && object.funder_address !== null) { + message.funderAddress = object.funder_address; + } + if (object.account_address !== undefined && object.account_address !== null) { + message.accountAddress = object.account_address; + } + if (object.dest_address !== undefined && object.dest_address !== null) { + message.destAddress = object.dest_address; + } + return message; + }, + toAmino(message: MsgClawback): MsgClawbackAmino { + const obj: any = {}; + obj.funder_address = message.funderAddress === "" ? undefined : message.funderAddress; + obj.account_address = message.accountAddress === "" ? undefined : message.accountAddress; + obj.dest_address = message.destAddress === "" ? undefined : message.destAddress; + return obj; + }, + fromAminoMsg(object: MsgClawbackAminoMsg): MsgClawback { + return MsgClawback.fromAmino(object.value); + }, + fromProtoMsg(message: MsgClawbackProtoMsg): MsgClawback { + return MsgClawback.decode(message.value); + }, + toProto(message: MsgClawback): Uint8Array { + return MsgClawback.encode(message).finish(); + }, + toProtoMsg(message: MsgClawback): MsgClawbackProtoMsg { + return { + typeUrl: "/evmos.vesting.v1.MsgClawback", + value: MsgClawback.encode(message).finish() + }; + } +}; +function createBaseMsgClawbackResponse(): MsgClawbackResponse { + return {}; +} +export const MsgClawbackResponse = { + typeUrl: "/evmos.vesting.v1.MsgClawbackResponse", + encode(_: MsgClawbackResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgClawbackResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgClawbackResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgClawbackResponse { + const obj = createBaseMsgClawbackResponse(); + return obj; + }, + toJSON(_: MsgClawbackResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): MsgClawbackResponse { + const message = createBaseMsgClawbackResponse(); + return message; + }, + fromSDK(_: MsgClawbackResponseSDKType): MsgClawbackResponse { + return {}; + }, + fromSDKJSON(_: any): MsgClawbackResponseSDKType { + return {}; + }, + toSDK(_: MsgClawbackResponse): MsgClawbackResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgClawbackResponseAmino): MsgClawbackResponse { + const message = createBaseMsgClawbackResponse(); + return message; + }, + toAmino(_: MsgClawbackResponse): MsgClawbackResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgClawbackResponseAminoMsg): MsgClawbackResponse { + return MsgClawbackResponse.fromAmino(object.value); + }, + fromProtoMsg(message: MsgClawbackResponseProtoMsg): MsgClawbackResponse { + return MsgClawbackResponse.decode(message.value); + }, + toProto(message: MsgClawbackResponse): Uint8Array { + return MsgClawbackResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgClawbackResponse): MsgClawbackResponseProtoMsg { + return { + typeUrl: "/evmos.vesting.v1.MsgClawbackResponse", + value: MsgClawbackResponse.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/evmos/vesting/v1/vesting.ts b/__fixtures__/v-next/outputicjsdeps/evmos/vesting/v1/vesting.ts new file mode 100644 index 0000000000..1a5cddd31a --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/evmos/vesting/v1/vesting.ts @@ -0,0 +1,222 @@ +import { BaseVestingAccount, BaseVestingAccountSDKType, Period, PeriodSDKType } from "../../../cosmos/vesting/v1beta1/vesting.js"; +import { Timestamp, TimestampSDKType } from "../../../google/protobuf/timestamp.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { toTimestamp, fromTimestamp, isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "evmos.vesting.v1"; +/** + * ClawbackVestingAccount implements the VestingAccount interface. It provides + * an account that can hold contributions subject to "lockup" (like a + * PeriodicVestingAccount), or vesting which is subject to clawback + * of unvested tokens, or a combination (tokens vest, but are still locked). + */ +export interface ClawbackVestingAccount { + /** + * base_vesting_account implements the VestingAccount interface. It contains + * all the necessary fields needed for any vesting account implementation + */ + baseVestingAccount?: BaseVestingAccount; + /** funder_address specifies the account which can perform clawback */ + funderAddress: string; + /** start_time defines the time at which the vesting period begins */ + startTime: Date; + /** lockup_periods defines the unlocking schedule relative to the start_time */ + lockupPeriods: Period[]; + /** vesting_periods defines the vesting schedule relative to the start_time */ + vestingPeriods: Period[]; +} +export interface ClawbackVestingAccountProtoMsg { + typeUrl: "/evmos.vesting.v1.ClawbackVestingAccount"; + value: Uint8Array; +} +/** + * ClawbackVestingAccount implements the VestingAccount interface. It provides + * an account that can hold contributions subject to "lockup" (like a + * PeriodicVestingAccount), or vesting which is subject to clawback + * of unvested tokens, or a combination (tokens vest, but are still locked). + */ +export interface ClawbackVestingAccountSDKType { + base_vesting_account?: BaseVestingAccountSDKType; + funder_address: string; + start_time: Date; + lockup_periods: PeriodSDKType[]; + vesting_periods: PeriodSDKType[]; +} +function createBaseClawbackVestingAccount(): ClawbackVestingAccount { + return { + baseVestingAccount: undefined, + funderAddress: "", + startTime: new Date(), + lockupPeriods: [], + vestingPeriods: [] + }; +} +export const ClawbackVestingAccount = { + typeUrl: "/evmos.vesting.v1.ClawbackVestingAccount", + encode(message: ClawbackVestingAccount, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.baseVestingAccount !== undefined) { + BaseVestingAccount.encode(message.baseVestingAccount, writer.uint32(10).fork()).ldelim(); + } + if (message.funderAddress !== undefined) { + writer.uint32(18).string(message.funderAddress); + } + if (message.startTime !== undefined) { + Timestamp.encode(toTimestamp(message.startTime), writer.uint32(26).fork()).ldelim(); + } + for (const v of message.lockupPeriods) { + Period.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.vestingPeriods) { + Period.encode(v!, writer.uint32(42).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ClawbackVestingAccount { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseClawbackVestingAccount(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.baseVestingAccount = BaseVestingAccount.decode(reader, reader.uint32()); + break; + case 2: + message.funderAddress = reader.string(); + break; + case 3: + message.startTime = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + break; + case 4: + message.lockupPeriods.push(Period.decode(reader, reader.uint32())); + break; + case 5: + message.vestingPeriods.push(Period.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ClawbackVestingAccount { + const obj = createBaseClawbackVestingAccount(); + if (isSet(object.baseVestingAccount)) obj.baseVestingAccount = BaseVestingAccount.fromJSON(object.baseVestingAccount); + if (isSet(object.funderAddress)) obj.funderAddress = String(object.funderAddress); + if (isSet(object.startTime)) obj.startTime = new Date(object.startTime); + if (Array.isArray(object?.lockupPeriods)) obj.lockupPeriods = object.lockupPeriods.map((e: any) => Period.fromJSON(e)); + if (Array.isArray(object?.vestingPeriods)) obj.vestingPeriods = object.vestingPeriods.map((e: any) => Period.fromJSON(e)); + return obj; + }, + toJSON(message: ClawbackVestingAccount): JsonSafe { + const obj: any = {}; + message.baseVestingAccount !== undefined && (obj.baseVestingAccount = message.baseVestingAccount ? BaseVestingAccount.toJSON(message.baseVestingAccount) : undefined); + message.funderAddress !== undefined && (obj.funderAddress = message.funderAddress); + message.startTime !== undefined && (obj.startTime = message.startTime.toISOString()); + if (message.lockupPeriods) { + obj.lockupPeriods = message.lockupPeriods.map(e => e ? Period.toJSON(e) : undefined); + } else { + obj.lockupPeriods = []; + } + if (message.vestingPeriods) { + obj.vestingPeriods = message.vestingPeriods.map(e => e ? Period.toJSON(e) : undefined); + } else { + obj.vestingPeriods = []; + } + return obj; + }, + fromPartial(object: DeepPartial): ClawbackVestingAccount { + const message = createBaseClawbackVestingAccount(); + if (object.baseVestingAccount !== undefined && object.baseVestingAccount !== null) { + message.baseVestingAccount = BaseVestingAccount.fromPartial(object.baseVestingAccount); + } + message.funderAddress = object.funderAddress ?? ""; + message.startTime = object.startTime ?? undefined; + message.lockupPeriods = object.lockupPeriods?.map(e => Period.fromPartial(e)) || []; + message.vestingPeriods = object.vestingPeriods?.map(e => Period.fromPartial(e)) || []; + return message; + }, + fromSDK(object: ClawbackVestingAccountSDKType): ClawbackVestingAccount { + return { + baseVestingAccount: object.base_vesting_account ? BaseVestingAccount.fromSDK(object.base_vesting_account) : undefined, + funderAddress: object?.funder_address, + startTime: object.start_time ?? undefined, + lockupPeriods: Array.isArray(object?.lockup_periods) ? object.lockup_periods.map((e: any) => Period.fromSDK(e)) : [], + vestingPeriods: Array.isArray(object?.vesting_periods) ? object.vesting_periods.map((e: any) => Period.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): ClawbackVestingAccountSDKType { + return { + base_vesting_account: isSet(object.base_vesting_account) ? BaseVestingAccount.fromSDKJSON(object.base_vesting_account) : undefined, + funder_address: isSet(object.funder_address) ? String(object.funder_address) : "", + start_time: isSet(object.start_time) ? new Date(object.start_time) : undefined, + lockup_periods: Array.isArray(object?.lockup_periods) ? object.lockup_periods.map((e: any) => Period.fromSDKJSON(e)) : [], + vesting_periods: Array.isArray(object?.vesting_periods) ? object.vesting_periods.map((e: any) => Period.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: ClawbackVestingAccount): ClawbackVestingAccountSDKType { + const obj: any = {}; + message.baseVestingAccount !== undefined && (obj.base_vesting_account = message.baseVestingAccount ? BaseVestingAccount.toSDK(message.baseVestingAccount) : undefined); + obj.funder_address = message.funderAddress; + message.startTime !== undefined && (obj.start_time = message.startTime ?? undefined); + if (message.lockupPeriods) { + obj.lockup_periods = message.lockupPeriods.map(e => e ? Period.toSDK(e) : undefined); + } else { + obj.lockup_periods = []; + } + if (message.vestingPeriods) { + obj.vesting_periods = message.vestingPeriods.map(e => e ? Period.toSDK(e) : undefined); + } else { + obj.vesting_periods = []; + } + return obj; + }, + fromAmino(object: ClawbackVestingAccountAmino): ClawbackVestingAccount { + const message = createBaseClawbackVestingAccount(); + if (object.base_vesting_account !== undefined && object.base_vesting_account !== null) { + message.baseVestingAccount = BaseVestingAccount.fromAmino(object.base_vesting_account); + } + if (object.funder_address !== undefined && object.funder_address !== null) { + message.funderAddress = object.funder_address; + } + if (object.start_time !== undefined && object.start_time !== null) { + message.startTime = fromTimestamp(Timestamp.fromAmino(object.start_time)); + } + message.lockupPeriods = object.lockup_periods?.map(e => Period.fromAmino(e)) || []; + message.vestingPeriods = object.vesting_periods?.map(e => Period.fromAmino(e)) || []; + return message; + }, + toAmino(message: ClawbackVestingAccount): ClawbackVestingAccountAmino { + const obj: any = {}; + obj.base_vesting_account = message.baseVestingAccount ? BaseVestingAccount.toAmino(message.baseVestingAccount) : undefined; + obj.funder_address = message.funderAddress === "" ? undefined : message.funderAddress; + obj.start_time = message.startTime ? Timestamp.toAmino(toTimestamp(message.startTime)) : undefined; + if (message.lockupPeriods) { + obj.lockup_periods = message.lockupPeriods.map(e => e ? Period.toAmino(e) : undefined); + } else { + obj.lockup_periods = message.lockupPeriods; + } + if (message.vestingPeriods) { + obj.vesting_periods = message.vestingPeriods.map(e => e ? Period.toAmino(e) : undefined); + } else { + obj.vesting_periods = message.vestingPeriods; + } + return obj; + }, + fromAminoMsg(object: ClawbackVestingAccountAminoMsg): ClawbackVestingAccount { + return ClawbackVestingAccount.fromAmino(object.value); + }, + fromProtoMsg(message: ClawbackVestingAccountProtoMsg): ClawbackVestingAccount { + return ClawbackVestingAccount.decode(message.value); + }, + toProto(message: ClawbackVestingAccount): Uint8Array { + return ClawbackVestingAccount.encode(message).finish(); + }, + toProtoMsg(message: ClawbackVestingAccount): ClawbackVestingAccountProtoMsg { + return { + typeUrl: "/evmos.vesting.v1.ClawbackVestingAccount", + value: ClawbackVestingAccount.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/extern.ts b/__fixtures__/v-next/outputicjsdeps/extern.ts new file mode 100644 index 0000000000..b56caf20e4 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/extern.ts @@ -0,0 +1,42 @@ +/** +* This file and any referenced files were automatically generated by @cosmology/telescope@latest +* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain +* and run the transpile command or npm scripts command that is used to regenerate this bundle. +*/ + +import { QueryClient, createProtobufRpcClient, ProtobufRpcClient } from '@cosmjs/stargate' +import { connectComet, HttpEndpoint } from "@cosmjs/tendermint-rpc"; + +const _rpcClients: Record = {}; + +export const getRpcEndpointKey = (rpcEndpoint: string | HttpEndpoint) => { + if (typeof rpcEndpoint === 'string') { + return rpcEndpoint; + } else if (!!rpcEndpoint) { + //@ts-ignore + return rpcEndpoint.url; + } +} + +export const getRpcClient = async (rpcEndpoint: string | HttpEndpoint) => { + const key = getRpcEndpointKey(rpcEndpoint); + if (!key) return; + if (_rpcClients.hasOwnProperty(key)) { + return _rpcClients[key]; + } + const cometClient = await connectComet(rpcEndpoint); + //@ts-ignore + const client = new QueryClient(cometClient); + const rpc = createProtobufRpcClient(client); + _rpcClients[key] = rpc; + return rpc; +} + +export const createRpcClient = async (rpcEndpoint: string | HttpEndpoint) => { + const cometClient = await connectComet(rpcEndpoint); + //@ts-ignore + const client = new QueryClient(cometClient); + const rpc = createProtobufRpcClient(client); + + return rpc; +} diff --git a/__fixtures__/v-next/outputicjsdeps/gogoproto/bundle.ts b/__fixtures__/v-next/outputicjsdeps/gogoproto/bundle.ts new file mode 100644 index 0000000000..2ce1d53fa4 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/gogoproto/bundle.ts @@ -0,0 +1,4 @@ +import * as _177 from "./gogo.js"; +export const gogoproto = { + ..._177 +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/gogoproto/gogo.ts b/__fixtures__/v-next/outputicjsdeps/gogoproto/gogo.ts new file mode 100644 index 0000000000..693da49fc4 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/gogoproto/gogo.ts @@ -0,0 +1 @@ +export {} \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/api/annotations.ts b/__fixtures__/v-next/outputicjsdeps/google/api/annotations.ts new file mode 100644 index 0000000000..693da49fc4 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/api/annotations.ts @@ -0,0 +1 @@ +export {} \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/api/auth.ts b/__fixtures__/v-next/outputicjsdeps/google/api/auth.ts new file mode 100644 index 0000000000..37ab1a6359 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/api/auth.ts @@ -0,0 +1,1119 @@ +import { BinaryReader, BinaryWriter } from "../../binary.js"; +import { JsonSafe } from "../../json-safe.js"; +import { DeepPartial, isSet } from "../../helpers.js"; +export const protobufPackage = "google.api"; +/** + * `Authentication` defines the authentication configuration for API methods + * provided by an API service. + * + * Example: + * + * name: calendar.googleapis.com + * authentication: + * providers: + * - id: google_calendar_auth + * jwks_uri: https://www.googleapis.com/oauth2/v1/certs + * issuer: https://securetoken.google.com + * rules: + * - selector: "*" + * requirements: + * provider_id: google_calendar_auth + * - selector: google.calendar.Delegate + * oauth: + * canonical_scopes: https://www.googleapis.com/auth/calendar.read + */ +export interface Authentication { + /** + * A list of authentication rules that apply to individual API methods. + * + * **NOTE:** All service configuration rules follow "last one wins" order. + */ + rules: AuthenticationRule[]; + /** Defines a set of authentication providers that a service supports. */ + providers: AuthProvider[]; +} +export interface AuthenticationProtoMsg { + typeUrl: "/google.api.Authentication"; + value: Uint8Array; +} +/** + * `Authentication` defines the authentication configuration for API methods + * provided by an API service. + * + * Example: + * + * name: calendar.googleapis.com + * authentication: + * providers: + * - id: google_calendar_auth + * jwks_uri: https://www.googleapis.com/oauth2/v1/certs + * issuer: https://securetoken.google.com + * rules: + * - selector: "*" + * requirements: + * provider_id: google_calendar_auth + * - selector: google.calendar.Delegate + * oauth: + * canonical_scopes: https://www.googleapis.com/auth/calendar.read + */ +export interface AuthenticationSDKType { + rules: AuthenticationRuleSDKType[]; + providers: AuthProviderSDKType[]; +} +/** + * Authentication rules for the service. + * + * By default, if a method has any authentication requirements, every request + * must include a valid credential matching one of the requirements. + * It's an error to include more than one kind of credential in a single + * request. + * + * If a method doesn't have any auth requirements, request credentials will be + * ignored. + */ +export interface AuthenticationRule { + /** + * Selects the methods to which this rule applies. + * + * Refer to [selector][google.api.DocumentationRule.selector] for syntax details. + */ + selector: string; + /** The requirements for OAuth credentials. */ + oauth?: OAuthRequirements; + /** + * If true, the service accepts API keys without any other credential. + * This flag only applies to HTTP and gRPC requests. + */ + allowWithoutCredential: boolean; + /** Requirements for additional authentication providers. */ + requirements: AuthRequirement[]; +} +export interface AuthenticationRuleProtoMsg { + typeUrl: "/google.api.AuthenticationRule"; + value: Uint8Array; +} +/** + * Authentication rules for the service. + * + * By default, if a method has any authentication requirements, every request + * must include a valid credential matching one of the requirements. + * It's an error to include more than one kind of credential in a single + * request. + * + * If a method doesn't have any auth requirements, request credentials will be + * ignored. + */ +export interface AuthenticationRuleSDKType { + selector: string; + oauth?: OAuthRequirementsSDKType; + allow_without_credential: boolean; + requirements: AuthRequirementSDKType[]; +} +/** Specifies a location to extract JWT from an API request. */ +export interface JwtLocation { + /** Specifies HTTP header name to extract JWT token. */ + header?: string; + /** Specifies URL query parameter name to extract JWT token. */ + query?: string; + /** + * The value prefix. The value format is "value_prefix{token}" + * Only applies to "in" header type. Must be empty for "in" query type. + * If not empty, the header value has to match (case sensitive) this prefix. + * If not matched, JWT will not be extracted. If matched, JWT will be + * extracted after the prefix is removed. + * + * For example, for "Authorization: Bearer {JWT}", + * value_prefix="Bearer " with a space at the end. + */ + valuePrefix: string; +} +export interface JwtLocationProtoMsg { + typeUrl: "/google.api.JwtLocation"; + value: Uint8Array; +} +/** Specifies a location to extract JWT from an API request. */ +export interface JwtLocationSDKType { + header?: string; + query?: string; + value_prefix: string; +} +/** + * Configuration for an authentication provider, including support for + * [JSON Web Token + * (JWT)](https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-32). + */ +export interface AuthProvider { + /** + * The unique identifier of the auth provider. It will be referred to by + * `AuthRequirement.provider_id`. + * + * Example: "bookstore_auth". + */ + id: string; + /** + * Identifies the principal that issued the JWT. See + * https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-32#section-4.1.1 + * Usually a URL or an email address. + * + * Example: https://securetoken.google.com + * Example: 1234567-compute@developer.gserviceaccount.com + */ + issuer: string; + /** + * URL of the provider's public key set to validate signature of the JWT. See + * [OpenID + * Discovery](https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata). + * Optional if the key set document: + * - can be retrieved from + * [OpenID + * Discovery](https://openid.net/specs/openid-connect-discovery-1_0.html) + * of the issuer. + * - can be inferred from the email domain of the issuer (e.g. a Google + * service account). + * + * Example: https://www.googleapis.com/oauth2/v1/certs + */ + jwksUri: string; + /** + * The list of JWT + * [audiences](https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-32#section-4.1.3). + * that are allowed to access. A JWT containing any of these audiences will + * be accepted. When this setting is absent, JWTs with audiences: + * - "https://[service.name]/[google.protobuf.Api.name]" + * - "https://[service.name]/" + * will be accepted. + * For example, if no audiences are in the setting, LibraryService API will + * accept JWTs with the following audiences: + * - + * https://library-example.googleapis.com/google.example.library.v1.LibraryService + * - https://library-example.googleapis.com/ + * + * Example: + * + * audiences: bookstore_android.apps.googleusercontent.com, + * bookstore_web.apps.googleusercontent.com + */ + audiences: string; + /** + * Redirect URL if JWT token is required but not present or is expired. + * Implement authorizationUrl of securityDefinitions in OpenAPI spec. + */ + authorizationUrl: string; + /** + * Defines the locations to extract the JWT. + * + * JWT locations can be either from HTTP headers or URL query parameters. + * The rule is that the first match wins. The checking order is: checking + * all headers first, then URL query parameters. + * + * If not specified, default to use following 3 locations: + * 1) Authorization: Bearer + * 2) x-goog-iap-jwt-assertion + * 3) access_token query parameter + * + * Default locations can be specified as followings: + * jwt_locations: + * - header: Authorization + * value_prefix: "Bearer " + * - header: x-goog-iap-jwt-assertion + * - query: access_token + */ + jwtLocations: JwtLocation[]; +} +export interface AuthProviderProtoMsg { + typeUrl: "/google.api.AuthProvider"; + value: Uint8Array; +} +/** + * Configuration for an authentication provider, including support for + * [JSON Web Token + * (JWT)](https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-32). + */ +export interface AuthProviderSDKType { + id: string; + issuer: string; + jwks_uri: string; + audiences: string; + authorization_url: string; + jwt_locations: JwtLocationSDKType[]; +} +/** + * OAuth scopes are a way to define data and permissions on data. For example, + * there are scopes defined for "Read-only access to Google Calendar" and + * "Access to Cloud Platform". Users can consent to a scope for an application, + * giving it permission to access that data on their behalf. + * + * OAuth scope specifications should be fairly coarse grained; a user will need + * to see and understand the text description of what your scope means. + * + * In most cases: use one or at most two OAuth scopes for an entire family of + * products. If your product has multiple APIs, you should probably be sharing + * the OAuth scope across all of those APIs. + * + * When you need finer grained OAuth consent screens: talk with your product + * management about how developers will use them in practice. + * + * Please note that even though each of the canonical scopes is enough for a + * request to be accepted and passed to the backend, a request can still fail + * due to the backend requiring additional scopes or permissions. + */ +export interface OAuthRequirements { + /** + * The list of publicly documented OAuth scopes that are allowed access. An + * OAuth token containing any of these scopes will be accepted. + * + * Example: + * + * canonical_scopes: https://www.googleapis.com/auth/calendar, + * https://www.googleapis.com/auth/calendar.read + */ + canonicalScopes: string; +} +export interface OAuthRequirementsProtoMsg { + typeUrl: "/google.api.OAuthRequirements"; + value: Uint8Array; +} +/** + * OAuth scopes are a way to define data and permissions on data. For example, + * there are scopes defined for "Read-only access to Google Calendar" and + * "Access to Cloud Platform". Users can consent to a scope for an application, + * giving it permission to access that data on their behalf. + * + * OAuth scope specifications should be fairly coarse grained; a user will need + * to see and understand the text description of what your scope means. + * + * In most cases: use one or at most two OAuth scopes for an entire family of + * products. If your product has multiple APIs, you should probably be sharing + * the OAuth scope across all of those APIs. + * + * When you need finer grained OAuth consent screens: talk with your product + * management about how developers will use them in practice. + * + * Please note that even though each of the canonical scopes is enough for a + * request to be accepted and passed to the backend, a request can still fail + * due to the backend requiring additional scopes or permissions. + */ +export interface OAuthRequirementsSDKType { + canonical_scopes: string; +} +/** + * User-defined authentication requirements, including support for + * [JSON Web Token + * (JWT)](https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-32). + */ +export interface AuthRequirement { + /** + * [id][google.api.AuthProvider.id] from authentication provider. + * + * Example: + * + * provider_id: bookstore_auth + */ + providerId: string; + /** + * NOTE: This will be deprecated soon, once AuthProvider.audiences is + * implemented and accepted in all the runtime components. + * + * The list of JWT + * [audiences](https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-32#section-4.1.3). + * that are allowed to access. A JWT containing any of these audiences will + * be accepted. When this setting is absent, only JWTs with audience + * "https://[Service_name][google.api.Service.name]/[API_name][google.protobuf.Api.name]" + * will be accepted. For example, if no audiences are in the setting, + * LibraryService API will only accept JWTs with the following audience + * "https://library-example.googleapis.com/google.example.library.v1.LibraryService". + * + * Example: + * + * audiences: bookstore_android.apps.googleusercontent.com, + * bookstore_web.apps.googleusercontent.com + */ + audiences: string; +} +export interface AuthRequirementProtoMsg { + typeUrl: "/google.api.AuthRequirement"; + value: Uint8Array; +} +/** + * User-defined authentication requirements, including support for + * [JSON Web Token + * (JWT)](https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-32). + */ +export interface AuthRequirementSDKType { + provider_id: string; + audiences: string; +} +function createBaseAuthentication(): Authentication { + return { + rules: [], + providers: [] + }; +} +export const Authentication = { + typeUrl: "/google.api.Authentication", + encode(message: Authentication, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.rules) { + AuthenticationRule.encode(v!, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.providers) { + AuthProvider.encode(v!, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Authentication { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseAuthentication(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 3: + message.rules.push(AuthenticationRule.decode(reader, reader.uint32())); + break; + case 4: + message.providers.push(AuthProvider.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Authentication { + const obj = createBaseAuthentication(); + if (Array.isArray(object?.rules)) obj.rules = object.rules.map((e: any) => AuthenticationRule.fromJSON(e)); + if (Array.isArray(object?.providers)) obj.providers = object.providers.map((e: any) => AuthProvider.fromJSON(e)); + return obj; + }, + toJSON(message: Authentication): JsonSafe { + const obj: any = {}; + if (message.rules) { + obj.rules = message.rules.map(e => e ? AuthenticationRule.toJSON(e) : undefined); + } else { + obj.rules = []; + } + if (message.providers) { + obj.providers = message.providers.map(e => e ? AuthProvider.toJSON(e) : undefined); + } else { + obj.providers = []; + } + return obj; + }, + fromPartial(object: DeepPartial): Authentication { + const message = createBaseAuthentication(); + message.rules = object.rules?.map(e => AuthenticationRule.fromPartial(e)) || []; + message.providers = object.providers?.map(e => AuthProvider.fromPartial(e)) || []; + return message; + }, + fromSDK(object: AuthenticationSDKType): Authentication { + return { + rules: Array.isArray(object?.rules) ? object.rules.map((e: any) => AuthenticationRule.fromSDK(e)) : [], + providers: Array.isArray(object?.providers) ? object.providers.map((e: any) => AuthProvider.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): AuthenticationSDKType { + return { + rules: Array.isArray(object?.rules) ? object.rules.map((e: any) => AuthenticationRule.fromSDKJSON(e)) : [], + providers: Array.isArray(object?.providers) ? object.providers.map((e: any) => AuthProvider.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: Authentication): AuthenticationSDKType { + const obj: any = {}; + if (message.rules) { + obj.rules = message.rules.map(e => e ? AuthenticationRule.toSDK(e) : undefined); + } else { + obj.rules = []; + } + if (message.providers) { + obj.providers = message.providers.map(e => e ? AuthProvider.toSDK(e) : undefined); + } else { + obj.providers = []; + } + return obj; + }, + fromAmino(object: AuthenticationAmino): Authentication { + const message = createBaseAuthentication(); + message.rules = object.rules?.map(e => AuthenticationRule.fromAmino(e)) || []; + message.providers = object.providers?.map(e => AuthProvider.fromAmino(e)) || []; + return message; + }, + toAmino(message: Authentication): AuthenticationAmino { + const obj: any = {}; + if (message.rules) { + obj.rules = message.rules.map(e => e ? AuthenticationRule.toAmino(e) : undefined); + } else { + obj.rules = message.rules; + } + if (message.providers) { + obj.providers = message.providers.map(e => e ? AuthProvider.toAmino(e) : undefined); + } else { + obj.providers = message.providers; + } + return obj; + }, + fromAminoMsg(object: AuthenticationAminoMsg): Authentication { + return Authentication.fromAmino(object.value); + }, + fromProtoMsg(message: AuthenticationProtoMsg): Authentication { + return Authentication.decode(message.value); + }, + toProto(message: Authentication): Uint8Array { + return Authentication.encode(message).finish(); + }, + toProtoMsg(message: Authentication): AuthenticationProtoMsg { + return { + typeUrl: "/google.api.Authentication", + value: Authentication.encode(message).finish() + }; + } +}; +function createBaseAuthenticationRule(): AuthenticationRule { + return { + selector: "", + oauth: undefined, + allowWithoutCredential: false, + requirements: [] + }; +} +export const AuthenticationRule = { + typeUrl: "/google.api.AuthenticationRule", + encode(message: AuthenticationRule, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.selector !== undefined) { + writer.uint32(10).string(message.selector); + } + if (message.oauth !== undefined) { + OAuthRequirements.encode(message.oauth, writer.uint32(18).fork()).ldelim(); + } + if (message.allowWithoutCredential !== undefined) { + writer.uint32(40).bool(message.allowWithoutCredential); + } + for (const v of message.requirements) { + AuthRequirement.encode(v!, writer.uint32(58).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): AuthenticationRule { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseAuthenticationRule(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.selector = reader.string(); + break; + case 2: + message.oauth = OAuthRequirements.decode(reader, reader.uint32()); + break; + case 5: + message.allowWithoutCredential = reader.bool(); + break; + case 7: + message.requirements.push(AuthRequirement.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): AuthenticationRule { + const obj = createBaseAuthenticationRule(); + if (isSet(object.selector)) obj.selector = String(object.selector); + if (isSet(object.oauth)) obj.oauth = OAuthRequirements.fromJSON(object.oauth); + if (isSet(object.allowWithoutCredential)) obj.allowWithoutCredential = Boolean(object.allowWithoutCredential); + if (Array.isArray(object?.requirements)) obj.requirements = object.requirements.map((e: any) => AuthRequirement.fromJSON(e)); + return obj; + }, + toJSON(message: AuthenticationRule): JsonSafe { + const obj: any = {}; + message.selector !== undefined && (obj.selector = message.selector); + message.oauth !== undefined && (obj.oauth = message.oauth ? OAuthRequirements.toJSON(message.oauth) : undefined); + message.allowWithoutCredential !== undefined && (obj.allowWithoutCredential = message.allowWithoutCredential); + if (message.requirements) { + obj.requirements = message.requirements.map(e => e ? AuthRequirement.toJSON(e) : undefined); + } else { + obj.requirements = []; + } + return obj; + }, + fromPartial(object: DeepPartial): AuthenticationRule { + const message = createBaseAuthenticationRule(); + message.selector = object.selector ?? ""; + if (object.oauth !== undefined && object.oauth !== null) { + message.oauth = OAuthRequirements.fromPartial(object.oauth); + } + message.allowWithoutCredential = object.allowWithoutCredential ?? false; + message.requirements = object.requirements?.map(e => AuthRequirement.fromPartial(e)) || []; + return message; + }, + fromSDK(object: AuthenticationRuleSDKType): AuthenticationRule { + return { + selector: object?.selector, + oauth: object.oauth ? OAuthRequirements.fromSDK(object.oauth) : undefined, + allowWithoutCredential: object?.allow_without_credential, + requirements: Array.isArray(object?.requirements) ? object.requirements.map((e: any) => AuthRequirement.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): AuthenticationRuleSDKType { + return { + selector: isSet(object.selector) ? String(object.selector) : "", + oauth: isSet(object.oauth) ? OAuthRequirements.fromSDKJSON(object.oauth) : undefined, + allow_without_credential: isSet(object.allow_without_credential) ? Boolean(object.allow_without_credential) : false, + requirements: Array.isArray(object?.requirements) ? object.requirements.map((e: any) => AuthRequirement.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: AuthenticationRule): AuthenticationRuleSDKType { + const obj: any = {}; + obj.selector = message.selector; + message.oauth !== undefined && (obj.oauth = message.oauth ? OAuthRequirements.toSDK(message.oauth) : undefined); + obj.allow_without_credential = message.allowWithoutCredential; + if (message.requirements) { + obj.requirements = message.requirements.map(e => e ? AuthRequirement.toSDK(e) : undefined); + } else { + obj.requirements = []; + } + return obj; + }, + fromAmino(object: AuthenticationRuleAmino): AuthenticationRule { + const message = createBaseAuthenticationRule(); + if (object.selector !== undefined && object.selector !== null) { + message.selector = object.selector; + } + if (object.oauth !== undefined && object.oauth !== null) { + message.oauth = OAuthRequirements.fromAmino(object.oauth); + } + if (object.allow_without_credential !== undefined && object.allow_without_credential !== null) { + message.allowWithoutCredential = object.allow_without_credential; + } + message.requirements = object.requirements?.map(e => AuthRequirement.fromAmino(e)) || []; + return message; + }, + toAmino(message: AuthenticationRule): AuthenticationRuleAmino { + const obj: any = {}; + obj.selector = message.selector === "" ? undefined : message.selector; + obj.oauth = message.oauth ? OAuthRequirements.toAmino(message.oauth) : undefined; + obj.allow_without_credential = message.allowWithoutCredential === false ? undefined : message.allowWithoutCredential; + if (message.requirements) { + obj.requirements = message.requirements.map(e => e ? AuthRequirement.toAmino(e) : undefined); + } else { + obj.requirements = message.requirements; + } + return obj; + }, + fromAminoMsg(object: AuthenticationRuleAminoMsg): AuthenticationRule { + return AuthenticationRule.fromAmino(object.value); + }, + fromProtoMsg(message: AuthenticationRuleProtoMsg): AuthenticationRule { + return AuthenticationRule.decode(message.value); + }, + toProto(message: AuthenticationRule): Uint8Array { + return AuthenticationRule.encode(message).finish(); + }, + toProtoMsg(message: AuthenticationRule): AuthenticationRuleProtoMsg { + return { + typeUrl: "/google.api.AuthenticationRule", + value: AuthenticationRule.encode(message).finish() + }; + } +}; +function createBaseJwtLocation(): JwtLocation { + return { + header: undefined, + query: undefined, + valuePrefix: "" + }; +} +export const JwtLocation = { + typeUrl: "/google.api.JwtLocation", + encode(message: JwtLocation, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.header !== undefined) { + writer.uint32(10).string(message.header); + } + if (message.query !== undefined) { + writer.uint32(18).string(message.query); + } + if (message.valuePrefix !== undefined) { + writer.uint32(26).string(message.valuePrefix); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): JwtLocation { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseJwtLocation(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.header = reader.string(); + break; + case 2: + message.query = reader.string(); + break; + case 3: + message.valuePrefix = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): JwtLocation { + const obj = createBaseJwtLocation(); + if (isSet(object.header)) obj.header = String(object.header); + if (isSet(object.query)) obj.query = String(object.query); + if (isSet(object.valuePrefix)) obj.valuePrefix = String(object.valuePrefix); + return obj; + }, + toJSON(message: JwtLocation): JsonSafe { + const obj: any = {}; + message.header !== undefined && (obj.header = message.header); + message.query !== undefined && (obj.query = message.query); + message.valuePrefix !== undefined && (obj.valuePrefix = message.valuePrefix); + return obj; + }, + fromPartial(object: DeepPartial): JwtLocation { + const message = createBaseJwtLocation(); + message.header = object.header ?? undefined; + message.query = object.query ?? undefined; + message.valuePrefix = object.valuePrefix ?? ""; + return message; + }, + fromSDK(object: JwtLocationSDKType): JwtLocation { + return { + header: object?.header, + query: object?.query, + valuePrefix: object?.value_prefix + }; + }, + fromSDKJSON(object: any): JwtLocationSDKType { + return { + header: isSet(object.header) ? String(object.header) : undefined, + query: isSet(object.query) ? String(object.query) : undefined, + value_prefix: isSet(object.value_prefix) ? String(object.value_prefix) : "" + }; + }, + toSDK(message: JwtLocation): JwtLocationSDKType { + const obj: any = {}; + obj.header = message.header; + obj.query = message.query; + obj.value_prefix = message.valuePrefix; + return obj; + }, + fromAmino(object: JwtLocationAmino): JwtLocation { + const message = createBaseJwtLocation(); + if (object.header !== undefined && object.header !== null) { + message.header = object.header; + } + if (object.query !== undefined && object.query !== null) { + message.query = object.query; + } + if (object.value_prefix !== undefined && object.value_prefix !== null) { + message.valuePrefix = object.value_prefix; + } + return message; + }, + toAmino(message: JwtLocation): JwtLocationAmino { + const obj: any = {}; + obj.header = message.header === null ? undefined : message.header; + obj.query = message.query === null ? undefined : message.query; + obj.value_prefix = message.valuePrefix === "" ? undefined : message.valuePrefix; + return obj; + }, + fromAminoMsg(object: JwtLocationAminoMsg): JwtLocation { + return JwtLocation.fromAmino(object.value); + }, + fromProtoMsg(message: JwtLocationProtoMsg): JwtLocation { + return JwtLocation.decode(message.value); + }, + toProto(message: JwtLocation): Uint8Array { + return JwtLocation.encode(message).finish(); + }, + toProtoMsg(message: JwtLocation): JwtLocationProtoMsg { + return { + typeUrl: "/google.api.JwtLocation", + value: JwtLocation.encode(message).finish() + }; + } +}; +function createBaseAuthProvider(): AuthProvider { + return { + id: "", + issuer: "", + jwksUri: "", + audiences: "", + authorizationUrl: "", + jwtLocations: [] + }; +} +export const AuthProvider = { + typeUrl: "/google.api.AuthProvider", + encode(message: AuthProvider, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.id !== undefined) { + writer.uint32(10).string(message.id); + } + if (message.issuer !== undefined) { + writer.uint32(18).string(message.issuer); + } + if (message.jwksUri !== undefined) { + writer.uint32(26).string(message.jwksUri); + } + if (message.audiences !== undefined) { + writer.uint32(34).string(message.audiences); + } + if (message.authorizationUrl !== undefined) { + writer.uint32(42).string(message.authorizationUrl); + } + for (const v of message.jwtLocations) { + JwtLocation.encode(v!, writer.uint32(50).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): AuthProvider { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseAuthProvider(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.id = reader.string(); + break; + case 2: + message.issuer = reader.string(); + break; + case 3: + message.jwksUri = reader.string(); + break; + case 4: + message.audiences = reader.string(); + break; + case 5: + message.authorizationUrl = reader.string(); + break; + case 6: + message.jwtLocations.push(JwtLocation.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): AuthProvider { + const obj = createBaseAuthProvider(); + if (isSet(object.id)) obj.id = String(object.id); + if (isSet(object.issuer)) obj.issuer = String(object.issuer); + if (isSet(object.jwksUri)) obj.jwksUri = String(object.jwksUri); + if (isSet(object.audiences)) obj.audiences = String(object.audiences); + if (isSet(object.authorizationUrl)) obj.authorizationUrl = String(object.authorizationUrl); + if (Array.isArray(object?.jwtLocations)) obj.jwtLocations = object.jwtLocations.map((e: any) => JwtLocation.fromJSON(e)); + return obj; + }, + toJSON(message: AuthProvider): JsonSafe { + const obj: any = {}; + message.id !== undefined && (obj.id = message.id); + message.issuer !== undefined && (obj.issuer = message.issuer); + message.jwksUri !== undefined && (obj.jwksUri = message.jwksUri); + message.audiences !== undefined && (obj.audiences = message.audiences); + message.authorizationUrl !== undefined && (obj.authorizationUrl = message.authorizationUrl); + if (message.jwtLocations) { + obj.jwtLocations = message.jwtLocations.map(e => e ? JwtLocation.toJSON(e) : undefined); + } else { + obj.jwtLocations = []; + } + return obj; + }, + fromPartial(object: DeepPartial): AuthProvider { + const message = createBaseAuthProvider(); + message.id = object.id ?? ""; + message.issuer = object.issuer ?? ""; + message.jwksUri = object.jwksUri ?? ""; + message.audiences = object.audiences ?? ""; + message.authorizationUrl = object.authorizationUrl ?? ""; + message.jwtLocations = object.jwtLocations?.map(e => JwtLocation.fromPartial(e)) || []; + return message; + }, + fromSDK(object: AuthProviderSDKType): AuthProvider { + return { + id: object?.id, + issuer: object?.issuer, + jwksUri: object?.jwks_uri, + audiences: object?.audiences, + authorizationUrl: object?.authorization_url, + jwtLocations: Array.isArray(object?.jwt_locations) ? object.jwt_locations.map((e: any) => JwtLocation.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): AuthProviderSDKType { + return { + id: isSet(object.id) ? String(object.id) : "", + issuer: isSet(object.issuer) ? String(object.issuer) : "", + jwks_uri: isSet(object.jwks_uri) ? String(object.jwks_uri) : "", + audiences: isSet(object.audiences) ? String(object.audiences) : "", + authorization_url: isSet(object.authorization_url) ? String(object.authorization_url) : "", + jwt_locations: Array.isArray(object?.jwt_locations) ? object.jwt_locations.map((e: any) => JwtLocation.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: AuthProvider): AuthProviderSDKType { + const obj: any = {}; + obj.id = message.id; + obj.issuer = message.issuer; + obj.jwks_uri = message.jwksUri; + obj.audiences = message.audiences; + obj.authorization_url = message.authorizationUrl; + if (message.jwtLocations) { + obj.jwt_locations = message.jwtLocations.map(e => e ? JwtLocation.toSDK(e) : undefined); + } else { + obj.jwt_locations = []; + } + return obj; + }, + fromAmino(object: AuthProviderAmino): AuthProvider { + const message = createBaseAuthProvider(); + if (object.id !== undefined && object.id !== null) { + message.id = object.id; + } + if (object.issuer !== undefined && object.issuer !== null) { + message.issuer = object.issuer; + } + if (object.jwks_uri !== undefined && object.jwks_uri !== null) { + message.jwksUri = object.jwks_uri; + } + if (object.audiences !== undefined && object.audiences !== null) { + message.audiences = object.audiences; + } + if (object.authorization_url !== undefined && object.authorization_url !== null) { + message.authorizationUrl = object.authorization_url; + } + message.jwtLocations = object.jwt_locations?.map(e => JwtLocation.fromAmino(e)) || []; + return message; + }, + toAmino(message: AuthProvider): AuthProviderAmino { + const obj: any = {}; + obj.id = message.id === "" ? undefined : message.id; + obj.issuer = message.issuer === "" ? undefined : message.issuer; + obj.jwks_uri = message.jwksUri === "" ? undefined : message.jwksUri; + obj.audiences = message.audiences === "" ? undefined : message.audiences; + obj.authorization_url = message.authorizationUrl === "" ? undefined : message.authorizationUrl; + if (message.jwtLocations) { + obj.jwt_locations = message.jwtLocations.map(e => e ? JwtLocation.toAmino(e) : undefined); + } else { + obj.jwt_locations = message.jwtLocations; + } + return obj; + }, + fromAminoMsg(object: AuthProviderAminoMsg): AuthProvider { + return AuthProvider.fromAmino(object.value); + }, + fromProtoMsg(message: AuthProviderProtoMsg): AuthProvider { + return AuthProvider.decode(message.value); + }, + toProto(message: AuthProvider): Uint8Array { + return AuthProvider.encode(message).finish(); + }, + toProtoMsg(message: AuthProvider): AuthProviderProtoMsg { + return { + typeUrl: "/google.api.AuthProvider", + value: AuthProvider.encode(message).finish() + }; + } +}; +function createBaseOAuthRequirements(): OAuthRequirements { + return { + canonicalScopes: "" + }; +} +export const OAuthRequirements = { + typeUrl: "/google.api.OAuthRequirements", + encode(message: OAuthRequirements, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.canonicalScopes !== undefined) { + writer.uint32(10).string(message.canonicalScopes); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): OAuthRequirements { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseOAuthRequirements(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.canonicalScopes = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): OAuthRequirements { + const obj = createBaseOAuthRequirements(); + if (isSet(object.canonicalScopes)) obj.canonicalScopes = String(object.canonicalScopes); + return obj; + }, + toJSON(message: OAuthRequirements): JsonSafe { + const obj: any = {}; + message.canonicalScopes !== undefined && (obj.canonicalScopes = message.canonicalScopes); + return obj; + }, + fromPartial(object: DeepPartial): OAuthRequirements { + const message = createBaseOAuthRequirements(); + message.canonicalScopes = object.canonicalScopes ?? ""; + return message; + }, + fromSDK(object: OAuthRequirementsSDKType): OAuthRequirements { + return { + canonicalScopes: object?.canonical_scopes + }; + }, + fromSDKJSON(object: any): OAuthRequirementsSDKType { + return { + canonical_scopes: isSet(object.canonical_scopes) ? String(object.canonical_scopes) : "" + }; + }, + toSDK(message: OAuthRequirements): OAuthRequirementsSDKType { + const obj: any = {}; + obj.canonical_scopes = message.canonicalScopes; + return obj; + }, + fromAmino(object: OAuthRequirementsAmino): OAuthRequirements { + const message = createBaseOAuthRequirements(); + if (object.canonical_scopes !== undefined && object.canonical_scopes !== null) { + message.canonicalScopes = object.canonical_scopes; + } + return message; + }, + toAmino(message: OAuthRequirements): OAuthRequirementsAmino { + const obj: any = {}; + obj.canonical_scopes = message.canonicalScopes === "" ? undefined : message.canonicalScopes; + return obj; + }, + fromAminoMsg(object: OAuthRequirementsAminoMsg): OAuthRequirements { + return OAuthRequirements.fromAmino(object.value); + }, + fromProtoMsg(message: OAuthRequirementsProtoMsg): OAuthRequirements { + return OAuthRequirements.decode(message.value); + }, + toProto(message: OAuthRequirements): Uint8Array { + return OAuthRequirements.encode(message).finish(); + }, + toProtoMsg(message: OAuthRequirements): OAuthRequirementsProtoMsg { + return { + typeUrl: "/google.api.OAuthRequirements", + value: OAuthRequirements.encode(message).finish() + }; + } +}; +function createBaseAuthRequirement(): AuthRequirement { + return { + providerId: "", + audiences: "" + }; +} +export const AuthRequirement = { + typeUrl: "/google.api.AuthRequirement", + encode(message: AuthRequirement, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.providerId !== undefined) { + writer.uint32(10).string(message.providerId); + } + if (message.audiences !== undefined) { + writer.uint32(18).string(message.audiences); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): AuthRequirement { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseAuthRequirement(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.providerId = reader.string(); + break; + case 2: + message.audiences = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): AuthRequirement { + const obj = createBaseAuthRequirement(); + if (isSet(object.providerId)) obj.providerId = String(object.providerId); + if (isSet(object.audiences)) obj.audiences = String(object.audiences); + return obj; + }, + toJSON(message: AuthRequirement): JsonSafe { + const obj: any = {}; + message.providerId !== undefined && (obj.providerId = message.providerId); + message.audiences !== undefined && (obj.audiences = message.audiences); + return obj; + }, + fromPartial(object: DeepPartial): AuthRequirement { + const message = createBaseAuthRequirement(); + message.providerId = object.providerId ?? ""; + message.audiences = object.audiences ?? ""; + return message; + }, + fromSDK(object: AuthRequirementSDKType): AuthRequirement { + return { + providerId: object?.provider_id, + audiences: object?.audiences + }; + }, + fromSDKJSON(object: any): AuthRequirementSDKType { + return { + provider_id: isSet(object.provider_id) ? String(object.provider_id) : "", + audiences: isSet(object.audiences) ? String(object.audiences) : "" + }; + }, + toSDK(message: AuthRequirement): AuthRequirementSDKType { + const obj: any = {}; + obj.provider_id = message.providerId; + obj.audiences = message.audiences; + return obj; + }, + fromAmino(object: AuthRequirementAmino): AuthRequirement { + const message = createBaseAuthRequirement(); + if (object.provider_id !== undefined && object.provider_id !== null) { + message.providerId = object.provider_id; + } + if (object.audiences !== undefined && object.audiences !== null) { + message.audiences = object.audiences; + } + return message; + }, + toAmino(message: AuthRequirement): AuthRequirementAmino { + const obj: any = {}; + obj.provider_id = message.providerId === "" ? undefined : message.providerId; + obj.audiences = message.audiences === "" ? undefined : message.audiences; + return obj; + }, + fromAminoMsg(object: AuthRequirementAminoMsg): AuthRequirement { + return AuthRequirement.fromAmino(object.value); + }, + fromProtoMsg(message: AuthRequirementProtoMsg): AuthRequirement { + return AuthRequirement.decode(message.value); + }, + toProto(message: AuthRequirement): Uint8Array { + return AuthRequirement.encode(message).finish(); + }, + toProtoMsg(message: AuthRequirement): AuthRequirementProtoMsg { + return { + typeUrl: "/google.api.AuthRequirement", + value: AuthRequirement.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/api/backend.ts b/__fixtures__/v-next/outputicjsdeps/google/api/backend.ts new file mode 100644 index 0000000000..8a1cdc029e --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/api/backend.ts @@ -0,0 +1,536 @@ +import { BinaryReader, BinaryWriter } from "../../binary.js"; +import { JsonSafe } from "../../json-safe.js"; +import { DeepPartial, isSet } from "../../helpers.js"; +export const protobufPackage = "google.api"; +/** + * Path Translation specifies how to combine the backend address with the + * request path in order to produce the appropriate forwarding URL for the + * request. + * + * Path Translation is applicable only to HTTP-based backends. Backends which + * do not accept requests over HTTP/HTTPS should leave `path_translation` + * unspecified. + */ +export enum BackendRule_PathTranslation { + PATH_TRANSLATION_UNSPECIFIED = 0, + /** + * CONSTANT_ADDRESS - Use the backend address as-is, with no modification to the path. If the + * URL pattern contains variables, the variable names and values will be + * appended to the query string. If a query string parameter and a URL + * pattern variable have the same name, this may result in duplicate keys in + * the query string. + * + * # Examples + * + * Given the following operation config: + * + * Method path: /api/company/{cid}/user/{uid} + * Backend address: https://example.cloudfunctions.net/getUser + * + * Requests to the following request paths will call the backend at the + * translated path: + * + * Request path: /api/company/widgetworks/user/johndoe + * Translated: + * https://example.cloudfunctions.net/getUser?cid=widgetworks&uid=johndoe + * + * Request path: /api/company/widgetworks/user/johndoe?timezone=EST + * Translated: + * https://example.cloudfunctions.net/getUser?timezone=EST&cid=widgetworks&uid=johndoe + */ + CONSTANT_ADDRESS = 1, + /** + * APPEND_PATH_TO_ADDRESS - The request path will be appended to the backend address. + * + * # Examples + * + * Given the following operation config: + * + * Method path: /api/company/{cid}/user/{uid} + * Backend address: https://example.appspot.com + * + * Requests to the following request paths will call the backend at the + * translated path: + * + * Request path: /api/company/widgetworks/user/johndoe + * Translated: + * https://example.appspot.com/api/company/widgetworks/user/johndoe + * + * Request path: /api/company/widgetworks/user/johndoe?timezone=EST + * Translated: + * https://example.appspot.com/api/company/widgetworks/user/johndoe?timezone=EST + */ + APPEND_PATH_TO_ADDRESS = 2, + UNRECOGNIZED = -1, +} +export const BackendRule_PathTranslationSDKType = BackendRule_PathTranslation; +export function backendRule_PathTranslationFromJSON(object: any): BackendRule_PathTranslation { + switch (object) { + case 0: + case "PATH_TRANSLATION_UNSPECIFIED": + return BackendRule_PathTranslation.PATH_TRANSLATION_UNSPECIFIED; + case 1: + case "CONSTANT_ADDRESS": + return BackendRule_PathTranslation.CONSTANT_ADDRESS; + case 2: + case "APPEND_PATH_TO_ADDRESS": + return BackendRule_PathTranslation.APPEND_PATH_TO_ADDRESS; + case -1: + case "UNRECOGNIZED": + default: + return BackendRule_PathTranslation.UNRECOGNIZED; + } +} +export function backendRule_PathTranslationToJSON(object: BackendRule_PathTranslation): string { + switch (object) { + case BackendRule_PathTranslation.PATH_TRANSLATION_UNSPECIFIED: + return "PATH_TRANSLATION_UNSPECIFIED"; + case BackendRule_PathTranslation.CONSTANT_ADDRESS: + return "CONSTANT_ADDRESS"; + case BackendRule_PathTranslation.APPEND_PATH_TO_ADDRESS: + return "APPEND_PATH_TO_ADDRESS"; + case BackendRule_PathTranslation.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** `Backend` defines the backend configuration for a service. */ +export interface Backend { + /** + * A list of API backend rules that apply to individual API methods. + * + * **NOTE:** All service configuration rules follow "last one wins" order. + */ + rules: BackendRule[]; +} +export interface BackendProtoMsg { + typeUrl: "/google.api.Backend"; + value: Uint8Array; +} +/** `Backend` defines the backend configuration for a service. */ +export interface BackendSDKType { + rules: BackendRuleSDKType[]; +} +/** A backend rule provides configuration for an individual API element. */ +export interface BackendRule { + /** + * Selects the methods to which this rule applies. + * + * Refer to [selector][google.api.DocumentationRule.selector] for syntax details. + */ + selector: string; + /** + * The address of the API backend. + * + * The scheme is used to determine the backend protocol and security. + * The following schemes are accepted: + * + * SCHEME PROTOCOL SECURITY + * http:// HTTP None + * https:// HTTP TLS + * grpc:// gRPC None + * grpcs:// gRPC TLS + * + * It is recommended to explicitly include a scheme. Leaving out the scheme + * may cause constrasting behaviors across platforms. + * + * If the port is unspecified, the default is: + * - 80 for schemes without TLS + * - 443 for schemes with TLS + * + * For HTTP backends, use [protocol][google.api.BackendRule.protocol] + * to specify the protocol version. + */ + address: string; + /** + * The number of seconds to wait for a response from a request. The default + * varies based on the request protocol and deployment environment. + */ + deadline: number; + /** + * Minimum deadline in seconds needed for this method. Calls having deadline + * value lower than this will be rejected. + */ + minDeadline: number; + /** + * The number of seconds to wait for the completion of a long running + * operation. The default is no deadline. + */ + operationDeadline: number; + pathTranslation: BackendRule_PathTranslation; + /** + * The JWT audience is used when generating a JWT ID token for the backend. + * This ID token will be added in the HTTP "authorization" header, and sent + * to the backend. + */ + jwtAudience?: string; + /** + * When disable_auth is true, a JWT ID token won't be generated and the + * original "Authorization" HTTP header will be preserved. If the header is + * used to carry the original token and is expected by the backend, this + * field must be set to true to preserve the header. + */ + disableAuth?: boolean; + /** + * The protocol used for sending a request to the backend. + * The supported values are "http/1.1" and "h2". + * + * The default value is inferred from the scheme in the + * [address][google.api.BackendRule.address] field: + * + * SCHEME PROTOCOL + * http:// http/1.1 + * https:// http/1.1 + * grpc:// h2 + * grpcs:// h2 + * + * For secure HTTP backends (https://) that support HTTP/2, set this field + * to "h2" for improved performance. + * + * Configuring this field to non-default values is only supported for secure + * HTTP backends. This field will be ignored for all other backends. + * + * See + * https://www.iana.org/assignments/tls-extensiontype-values/tls-extensiontype-values.xhtml#alpn-protocol-ids + * for more details on the supported values. + */ + protocol: string; +} +export interface BackendRuleProtoMsg { + typeUrl: "/google.api.BackendRule"; + value: Uint8Array; +} +/** A backend rule provides configuration for an individual API element. */ +export interface BackendRuleSDKType { + selector: string; + address: string; + deadline: number; + min_deadline: number; + operation_deadline: number; + path_translation: BackendRule_PathTranslation; + jwt_audience?: string; + disable_auth?: boolean; + protocol: string; +} +function createBaseBackend(): Backend { + return { + rules: [] + }; +} +export const Backend = { + typeUrl: "/google.api.Backend", + encode(message: Backend, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.rules) { + BackendRule.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Backend { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseBackend(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.rules.push(BackendRule.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Backend { + const obj = createBaseBackend(); + if (Array.isArray(object?.rules)) obj.rules = object.rules.map((e: any) => BackendRule.fromJSON(e)); + return obj; + }, + toJSON(message: Backend): JsonSafe { + const obj: any = {}; + if (message.rules) { + obj.rules = message.rules.map(e => e ? BackendRule.toJSON(e) : undefined); + } else { + obj.rules = []; + } + return obj; + }, + fromPartial(object: DeepPartial): Backend { + const message = createBaseBackend(); + message.rules = object.rules?.map(e => BackendRule.fromPartial(e)) || []; + return message; + }, + fromSDK(object: BackendSDKType): Backend { + return { + rules: Array.isArray(object?.rules) ? object.rules.map((e: any) => BackendRule.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): BackendSDKType { + return { + rules: Array.isArray(object?.rules) ? object.rules.map((e: any) => BackendRule.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: Backend): BackendSDKType { + const obj: any = {}; + if (message.rules) { + obj.rules = message.rules.map(e => e ? BackendRule.toSDK(e) : undefined); + } else { + obj.rules = []; + } + return obj; + }, + fromAmino(object: BackendAmino): Backend { + const message = createBaseBackend(); + message.rules = object.rules?.map(e => BackendRule.fromAmino(e)) || []; + return message; + }, + toAmino(message: Backend): BackendAmino { + const obj: any = {}; + if (message.rules) { + obj.rules = message.rules.map(e => e ? BackendRule.toAmino(e) : undefined); + } else { + obj.rules = message.rules; + } + return obj; + }, + fromAminoMsg(object: BackendAminoMsg): Backend { + return Backend.fromAmino(object.value); + }, + fromProtoMsg(message: BackendProtoMsg): Backend { + return Backend.decode(message.value); + }, + toProto(message: Backend): Uint8Array { + return Backend.encode(message).finish(); + }, + toProtoMsg(message: Backend): BackendProtoMsg { + return { + typeUrl: "/google.api.Backend", + value: Backend.encode(message).finish() + }; + } +}; +function createBaseBackendRule(): BackendRule { + return { + selector: "", + address: "", + deadline: 0, + minDeadline: 0, + operationDeadline: 0, + pathTranslation: 0, + jwtAudience: undefined, + disableAuth: undefined, + protocol: "" + }; +} +export const BackendRule = { + typeUrl: "/google.api.BackendRule", + encode(message: BackendRule, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.selector !== undefined) { + writer.uint32(10).string(message.selector); + } + if (message.address !== undefined) { + writer.uint32(18).string(message.address); + } + if (message.deadline !== undefined) { + writer.uint32(25).double(message.deadline); + } + if (message.minDeadline !== undefined) { + writer.uint32(33).double(message.minDeadline); + } + if (message.operationDeadline !== undefined) { + writer.uint32(41).double(message.operationDeadline); + } + if (message.pathTranslation !== 0) { + writer.uint32(48).int32(message.pathTranslation); + } + if (message.jwtAudience !== undefined) { + writer.uint32(58).string(message.jwtAudience); + } + if (message.disableAuth !== undefined) { + writer.uint32(64).bool(message.disableAuth); + } + if (message.protocol !== undefined) { + writer.uint32(74).string(message.protocol); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): BackendRule { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseBackendRule(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.selector = reader.string(); + break; + case 2: + message.address = reader.string(); + break; + case 3: + message.deadline = reader.double(); + break; + case 4: + message.minDeadline = reader.double(); + break; + case 5: + message.operationDeadline = reader.double(); + break; + case 6: + message.pathTranslation = (reader.int32() as any); + break; + case 7: + message.jwtAudience = reader.string(); + break; + case 8: + message.disableAuth = reader.bool(); + break; + case 9: + message.protocol = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): BackendRule { + const obj = createBaseBackendRule(); + if (isSet(object.selector)) obj.selector = String(object.selector); + if (isSet(object.address)) obj.address = String(object.address); + if (isSet(object.deadline)) obj.deadline = Number(object.deadline); + if (isSet(object.minDeadline)) obj.minDeadline = Number(object.minDeadline); + if (isSet(object.operationDeadline)) obj.operationDeadline = Number(object.operationDeadline); + if (isSet(object.pathTranslation)) obj.pathTranslation = backendRule_PathTranslationFromJSON(object.pathTranslation); + if (isSet(object.jwtAudience)) obj.jwtAudience = String(object.jwtAudience); + if (isSet(object.disableAuth)) obj.disableAuth = Boolean(object.disableAuth); + if (isSet(object.protocol)) obj.protocol = String(object.protocol); + return obj; + }, + toJSON(message: BackendRule): JsonSafe { + const obj: any = {}; + message.selector !== undefined && (obj.selector = message.selector); + message.address !== undefined && (obj.address = message.address); + message.deadline !== undefined && (obj.deadline = message.deadline); + message.minDeadline !== undefined && (obj.minDeadline = message.minDeadline); + message.operationDeadline !== undefined && (obj.operationDeadline = message.operationDeadline); + message.pathTranslation !== undefined && (obj.pathTranslation = backendRule_PathTranslationToJSON(message.pathTranslation)); + message.jwtAudience !== undefined && (obj.jwtAudience = message.jwtAudience); + message.disableAuth !== undefined && (obj.disableAuth = message.disableAuth); + message.protocol !== undefined && (obj.protocol = message.protocol); + return obj; + }, + fromPartial(object: DeepPartial): BackendRule { + const message = createBaseBackendRule(); + message.selector = object.selector ?? ""; + message.address = object.address ?? ""; + message.deadline = object.deadline ?? 0; + message.minDeadline = object.minDeadline ?? 0; + message.operationDeadline = object.operationDeadline ?? 0; + message.pathTranslation = object.pathTranslation ?? 0; + message.jwtAudience = object.jwtAudience ?? undefined; + message.disableAuth = object.disableAuth ?? undefined; + message.protocol = object.protocol ?? ""; + return message; + }, + fromSDK(object: BackendRuleSDKType): BackendRule { + return { + selector: object?.selector, + address: object?.address, + deadline: object?.deadline, + minDeadline: object?.min_deadline, + operationDeadline: object?.operation_deadline, + pathTranslation: isSet(object.path_translation) ? backendRule_PathTranslationFromJSON(object.path_translation) : -1, + jwtAudience: object?.jwt_audience, + disableAuth: object?.disable_auth, + protocol: object?.protocol + }; + }, + fromSDKJSON(object: any): BackendRuleSDKType { + return { + selector: isSet(object.selector) ? String(object.selector) : "", + address: isSet(object.address) ? String(object.address) : "", + deadline: isSet(object.deadline) ? Number(object.deadline) : 0, + min_deadline: isSet(object.min_deadline) ? Number(object.min_deadline) : 0, + operation_deadline: isSet(object.operation_deadline) ? Number(object.operation_deadline) : 0, + path_translation: isSet(object.path_translation) ? backendRule_PathTranslationFromJSON(object.path_translation) : -1, + jwt_audience: isSet(object.jwt_audience) ? String(object.jwt_audience) : undefined, + disable_auth: isSet(object.disable_auth) ? Boolean(object.disable_auth) : undefined, + protocol: isSet(object.protocol) ? String(object.protocol) : "" + }; + }, + toSDK(message: BackendRule): BackendRuleSDKType { + const obj: any = {}; + obj.selector = message.selector; + obj.address = message.address; + obj.deadline = message.deadline; + obj.min_deadline = message.minDeadline; + obj.operation_deadline = message.operationDeadline; + message.pathTranslation !== undefined && (obj.path_translation = backendRule_PathTranslationToJSON(message.pathTranslation)); + obj.jwt_audience = message.jwtAudience; + obj.disable_auth = message.disableAuth; + obj.protocol = message.protocol; + return obj; + }, + fromAmino(object: BackendRuleAmino): BackendRule { + const message = createBaseBackendRule(); + if (object.selector !== undefined && object.selector !== null) { + message.selector = object.selector; + } + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } + if (object.deadline !== undefined && object.deadline !== null) { + message.deadline = object.deadline; + } + if (object.min_deadline !== undefined && object.min_deadline !== null) { + message.minDeadline = object.min_deadline; + } + if (object.operation_deadline !== undefined && object.operation_deadline !== null) { + message.operationDeadline = object.operation_deadline; + } + if (object.path_translation !== undefined && object.path_translation !== null) { + message.pathTranslation = object.path_translation; + } + if (object.jwt_audience !== undefined && object.jwt_audience !== null) { + message.jwtAudience = object.jwt_audience; + } + if (object.disable_auth !== undefined && object.disable_auth !== null) { + message.disableAuth = object.disable_auth; + } + if (object.protocol !== undefined && object.protocol !== null) { + message.protocol = object.protocol; + } + return message; + }, + toAmino(message: BackendRule): BackendRuleAmino { + const obj: any = {}; + obj.selector = message.selector === "" ? undefined : message.selector; + obj.address = message.address === "" ? undefined : message.address; + obj.deadline = message.deadline === 0 ? undefined : message.deadline; + obj.min_deadline = message.minDeadline === 0 ? undefined : message.minDeadline; + obj.operation_deadline = message.operationDeadline === 0 ? undefined : message.operationDeadline; + obj.path_translation = message.pathTranslation === 0 ? undefined : message.pathTranslation; + obj.jwt_audience = message.jwtAudience === null ? undefined : message.jwtAudience; + obj.disable_auth = message.disableAuth === null ? undefined : message.disableAuth; + obj.protocol = message.protocol === "" ? undefined : message.protocol; + return obj; + }, + fromAminoMsg(object: BackendRuleAminoMsg): BackendRule { + return BackendRule.fromAmino(object.value); + }, + fromProtoMsg(message: BackendRuleProtoMsg): BackendRule { + return BackendRule.decode(message.value); + }, + toProto(message: BackendRule): Uint8Array { + return BackendRule.encode(message).finish(); + }, + toProtoMsg(message: BackendRule): BackendRuleProtoMsg { + return { + typeUrl: "/google.api.BackendRule", + value: BackendRule.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/api/billing.ts b/__fixtures__/v-next/outputicjsdeps/google/api/billing.ts new file mode 100644 index 0000000000..3767cd5423 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/api/billing.ts @@ -0,0 +1,329 @@ +import { BinaryReader, BinaryWriter } from "../../binary.js"; +import { JsonSafe } from "../../json-safe.js"; +import { DeepPartial, isSet } from "../../helpers.js"; +export const protobufPackage = "google.api"; +/** + * Billing related configuration of the service. + * + * The following example shows how to configure monitored resources and metrics + * for billing, `consumer_destinations` is the only supported destination and + * the monitored resources need at least one label key + * `cloud.googleapis.com/location` to indicate the location of the billing + * usage, using different monitored resources between monitoring and billing is + * recommended so they can be evolved independently: + * + * + * monitored_resources: + * - type: library.googleapis.com/billing_branch + * labels: + * - key: cloud.googleapis.com/location + * description: | + * Predefined label to support billing location restriction. + * - key: city + * description: | + * Custom label to define the city where the library branch is located + * in. + * - key: name + * description: Custom label to define the name of the library branch. + * metrics: + * - name: library.googleapis.com/book/borrowed_count + * metric_kind: DELTA + * value_type: INT64 + * unit: "1" + * billing: + * consumer_destinations: + * - monitored_resource: library.googleapis.com/billing_branch + * metrics: + * - library.googleapis.com/book/borrowed_count + */ +export interface Billing { + /** + * Billing configurations for sending metrics to the consumer project. + * There can be multiple consumer destinations per service, each one must have + * a different monitored resource type. A metric can be used in at most + * one consumer destination. + */ + consumerDestinations: Billing_BillingDestination[]; +} +export interface BillingProtoMsg { + typeUrl: "/google.api.Billing"; + value: Uint8Array; +} +/** + * Billing related configuration of the service. + * + * The following example shows how to configure monitored resources and metrics + * for billing, `consumer_destinations` is the only supported destination and + * the monitored resources need at least one label key + * `cloud.googleapis.com/location` to indicate the location of the billing + * usage, using different monitored resources between monitoring and billing is + * recommended so they can be evolved independently: + * + * + * monitored_resources: + * - type: library.googleapis.com/billing_branch + * labels: + * - key: cloud.googleapis.com/location + * description: | + * Predefined label to support billing location restriction. + * - key: city + * description: | + * Custom label to define the city where the library branch is located + * in. + * - key: name + * description: Custom label to define the name of the library branch. + * metrics: + * - name: library.googleapis.com/book/borrowed_count + * metric_kind: DELTA + * value_type: INT64 + * unit: "1" + * billing: + * consumer_destinations: + * - monitored_resource: library.googleapis.com/billing_branch + * metrics: + * - library.googleapis.com/book/borrowed_count + */ +export interface BillingSDKType { + consumer_destinations: Billing_BillingDestinationSDKType[]; +} +/** + * Configuration of a specific billing destination (Currently only support + * bill against consumer project). + */ +export interface Billing_BillingDestination { + /** + * The monitored resource type. The type must be defined in + * [Service.monitored_resources][google.api.Service.monitored_resources] section. + */ + monitoredResource: string; + /** + * Names of the metrics to report to this billing destination. + * Each name must be defined in [Service.metrics][google.api.Service.metrics] section. + */ + metrics: string[]; +} +export interface Billing_BillingDestinationProtoMsg { + typeUrl: "/google.api.BillingDestination"; + value: Uint8Array; +} +/** + * Configuration of a specific billing destination (Currently only support + * bill against consumer project). + */ +export interface Billing_BillingDestinationSDKType { + monitored_resource: string; + metrics: string[]; +} +function createBaseBilling(): Billing { + return { + consumerDestinations: [] + }; +} +export const Billing = { + typeUrl: "/google.api.Billing", + encode(message: Billing, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.consumerDestinations) { + Billing_BillingDestination.encode(v!, writer.uint32(66).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Billing { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseBilling(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 8: + message.consumerDestinations.push(Billing_BillingDestination.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Billing { + const obj = createBaseBilling(); + if (Array.isArray(object?.consumerDestinations)) obj.consumerDestinations = object.consumerDestinations.map((e: any) => Billing_BillingDestination.fromJSON(e)); + return obj; + }, + toJSON(message: Billing): JsonSafe { + const obj: any = {}; + if (message.consumerDestinations) { + obj.consumerDestinations = message.consumerDestinations.map(e => e ? Billing_BillingDestination.toJSON(e) : undefined); + } else { + obj.consumerDestinations = []; + } + return obj; + }, + fromPartial(object: DeepPartial): Billing { + const message = createBaseBilling(); + message.consumerDestinations = object.consumerDestinations?.map(e => Billing_BillingDestination.fromPartial(e)) || []; + return message; + }, + fromSDK(object: BillingSDKType): Billing { + return { + consumerDestinations: Array.isArray(object?.consumer_destinations) ? object.consumer_destinations.map((e: any) => Billing_BillingDestination.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): BillingSDKType { + return { + consumer_destinations: Array.isArray(object?.consumer_destinations) ? object.consumer_destinations.map((e: any) => Billing_BillingDestination.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: Billing): BillingSDKType { + const obj: any = {}; + if (message.consumerDestinations) { + obj.consumer_destinations = message.consumerDestinations.map(e => e ? Billing_BillingDestination.toSDK(e) : undefined); + } else { + obj.consumer_destinations = []; + } + return obj; + }, + fromAmino(object: BillingAmino): Billing { + const message = createBaseBilling(); + message.consumerDestinations = object.consumer_destinations?.map(e => Billing_BillingDestination.fromAmino(e)) || []; + return message; + }, + toAmino(message: Billing): BillingAmino { + const obj: any = {}; + if (message.consumerDestinations) { + obj.consumer_destinations = message.consumerDestinations.map(e => e ? Billing_BillingDestination.toAmino(e) : undefined); + } else { + obj.consumer_destinations = message.consumerDestinations; + } + return obj; + }, + fromAminoMsg(object: BillingAminoMsg): Billing { + return Billing.fromAmino(object.value); + }, + fromProtoMsg(message: BillingProtoMsg): Billing { + return Billing.decode(message.value); + }, + toProto(message: Billing): Uint8Array { + return Billing.encode(message).finish(); + }, + toProtoMsg(message: Billing): BillingProtoMsg { + return { + typeUrl: "/google.api.Billing", + value: Billing.encode(message).finish() + }; + } +}; +function createBaseBilling_BillingDestination(): Billing_BillingDestination { + return { + monitoredResource: "", + metrics: [] + }; +} +export const Billing_BillingDestination = { + typeUrl: "/google.api.BillingDestination", + encode(message: Billing_BillingDestination, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.monitoredResource !== undefined) { + writer.uint32(10).string(message.monitoredResource); + } + for (const v of message.metrics) { + writer.uint32(18).string(v!); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Billing_BillingDestination { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseBilling_BillingDestination(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.monitoredResource = reader.string(); + break; + case 2: + message.metrics.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Billing_BillingDestination { + const obj = createBaseBilling_BillingDestination(); + if (isSet(object.monitoredResource)) obj.monitoredResource = String(object.monitoredResource); + if (Array.isArray(object?.metrics)) obj.metrics = object.metrics.map((e: any) => String(e)); + return obj; + }, + toJSON(message: Billing_BillingDestination): JsonSafe { + const obj: any = {}; + message.monitoredResource !== undefined && (obj.monitoredResource = message.monitoredResource); + if (message.metrics) { + obj.metrics = message.metrics.map(e => e); + } else { + obj.metrics = []; + } + return obj; + }, + fromPartial(object: DeepPartial): Billing_BillingDestination { + const message = createBaseBilling_BillingDestination(); + message.monitoredResource = object.monitoredResource ?? ""; + message.metrics = object.metrics?.map(e => e) || []; + return message; + }, + fromSDK(object: Billing_BillingDestinationSDKType): Billing_BillingDestination { + return { + monitoredResource: object?.monitored_resource, + metrics: Array.isArray(object?.metrics) ? object.metrics.map((e: any) => e) : [] + }; + }, + fromSDKJSON(object: any): Billing_BillingDestinationSDKType { + return { + monitored_resource: isSet(object.monitored_resource) ? String(object.monitored_resource) : "", + metrics: Array.isArray(object?.metrics) ? object.metrics.map((e: any) => String(e)) : [] + }; + }, + toSDK(message: Billing_BillingDestination): Billing_BillingDestinationSDKType { + const obj: any = {}; + obj.monitored_resource = message.monitoredResource; + if (message.metrics) { + obj.metrics = message.metrics.map(e => e); + } else { + obj.metrics = []; + } + return obj; + }, + fromAmino(object: Billing_BillingDestinationAmino): Billing_BillingDestination { + const message = createBaseBilling_BillingDestination(); + if (object.monitored_resource !== undefined && object.monitored_resource !== null) { + message.monitoredResource = object.monitored_resource; + } + message.metrics = object.metrics?.map(e => e) || []; + return message; + }, + toAmino(message: Billing_BillingDestination): Billing_BillingDestinationAmino { + const obj: any = {}; + obj.monitored_resource = message.monitoredResource === "" ? undefined : message.monitoredResource; + if (message.metrics) { + obj.metrics = message.metrics.map(e => e); + } else { + obj.metrics = message.metrics; + } + return obj; + }, + fromAminoMsg(object: Billing_BillingDestinationAminoMsg): Billing_BillingDestination { + return Billing_BillingDestination.fromAmino(object.value); + }, + fromProtoMsg(message: Billing_BillingDestinationProtoMsg): Billing_BillingDestination { + return Billing_BillingDestination.decode(message.value); + }, + toProto(message: Billing_BillingDestination): Uint8Array { + return Billing_BillingDestination.encode(message).finish(); + }, + toProtoMsg(message: Billing_BillingDestination): Billing_BillingDestinationProtoMsg { + return { + typeUrl: "/google.api.BillingDestination", + value: Billing_BillingDestination.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/api/client.ts b/__fixtures__/v-next/outputicjsdeps/google/api/client.ts new file mode 100644 index 0000000000..693da49fc4 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/api/client.ts @@ -0,0 +1 @@ +export {} \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/api/config_change.ts b/__fixtures__/v-next/outputicjsdeps/google/api/config_change.ts new file mode 100644 index 0000000000..6602d4b451 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/api/config_change.ts @@ -0,0 +1,398 @@ +import { BinaryReader, BinaryWriter } from "../../binary.js"; +import { isSet, DeepPartial } from "../../helpers.js"; +import { JsonSafe } from "../../json-safe.js"; +export const protobufPackage = "google.api"; +/** + * Classifies set of possible modifications to an object in the service + * configuration. + */ +export enum ChangeType { + /** CHANGE_TYPE_UNSPECIFIED - No value was provided. */ + CHANGE_TYPE_UNSPECIFIED = 0, + /** + * ADDED - The changed object exists in the 'new' service configuration, but not + * in the 'old' service configuration. + */ + ADDED = 1, + /** + * REMOVED - The changed object exists in the 'old' service configuration, but not + * in the 'new' service configuration. + */ + REMOVED = 2, + /** + * MODIFIED - The changed object exists in both service configurations, but its value + * is different. + */ + MODIFIED = 3, + UNRECOGNIZED = -1, +} +export const ChangeTypeSDKType = ChangeType; +export function changeTypeFromJSON(object: any): ChangeType { + switch (object) { + case 0: + case "CHANGE_TYPE_UNSPECIFIED": + return ChangeType.CHANGE_TYPE_UNSPECIFIED; + case 1: + case "ADDED": + return ChangeType.ADDED; + case 2: + case "REMOVED": + return ChangeType.REMOVED; + case 3: + case "MODIFIED": + return ChangeType.MODIFIED; + case -1: + case "UNRECOGNIZED": + default: + return ChangeType.UNRECOGNIZED; + } +} +export function changeTypeToJSON(object: ChangeType): string { + switch (object) { + case ChangeType.CHANGE_TYPE_UNSPECIFIED: + return "CHANGE_TYPE_UNSPECIFIED"; + case ChangeType.ADDED: + return "ADDED"; + case ChangeType.REMOVED: + return "REMOVED"; + case ChangeType.MODIFIED: + return "MODIFIED"; + case ChangeType.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** + * Output generated from semantically comparing two versions of a service + * configuration. + * + * Includes detailed information about a field that have changed with + * applicable advice about potential consequences for the change, such as + * backwards-incompatibility. + */ +export interface ConfigChange { + /** + * Object hierarchy path to the change, with levels separated by a '.' + * character. For repeated fields, an applicable unique identifier field is + * used for the index (usually selector, name, or id). For maps, the term + * 'key' is used. If the field has no unique identifier, the numeric index + * is used. + * Examples: + * - visibility.rules[selector=="google.LibraryService.ListBooks"].restriction + * - quota.metric_rules[selector=="google"].metric_costs[key=="reads"].value + * - logging.producer_destinations[0] + */ + element: string; + /** + * Value of the changed object in the old Service configuration, + * in JSON format. This field will not be populated if ChangeType == ADDED. + */ + oldValue: string; + /** + * Value of the changed object in the new Service configuration, + * in JSON format. This field will not be populated if ChangeType == REMOVED. + */ + newValue: string; + /** The type for this change, either ADDED, REMOVED, or MODIFIED. */ + changeType: ChangeType; + /** + * Collection of advice provided for this change, useful for determining the + * possible impact of this change. + */ + advices: Advice[]; +} +export interface ConfigChangeProtoMsg { + typeUrl: "/google.api.ConfigChange"; + value: Uint8Array; +} +/** + * Output generated from semantically comparing two versions of a service + * configuration. + * + * Includes detailed information about a field that have changed with + * applicable advice about potential consequences for the change, such as + * backwards-incompatibility. + */ +export interface ConfigChangeSDKType { + element: string; + old_value: string; + new_value: string; + change_type: ChangeType; + advices: AdviceSDKType[]; +} +/** + * Generated advice about this change, used for providing more + * information about how a change will affect the existing service. + */ +export interface Advice { + /** + * Useful description for why this advice was applied and what actions should + * be taken to mitigate any implied risks. + */ + description: string; +} +export interface AdviceProtoMsg { + typeUrl: "/google.api.Advice"; + value: Uint8Array; +} +/** + * Generated advice about this change, used for providing more + * information about how a change will affect the existing service. + */ +export interface AdviceSDKType { + description: string; +} +function createBaseConfigChange(): ConfigChange { + return { + element: "", + oldValue: "", + newValue: "", + changeType: 0, + advices: [] + }; +} +export const ConfigChange = { + typeUrl: "/google.api.ConfigChange", + encode(message: ConfigChange, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.element !== undefined) { + writer.uint32(10).string(message.element); + } + if (message.oldValue !== undefined) { + writer.uint32(18).string(message.oldValue); + } + if (message.newValue !== undefined) { + writer.uint32(26).string(message.newValue); + } + if (message.changeType !== 0) { + writer.uint32(32).int32(message.changeType); + } + for (const v of message.advices) { + Advice.encode(v!, writer.uint32(42).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ConfigChange { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseConfigChange(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.element = reader.string(); + break; + case 2: + message.oldValue = reader.string(); + break; + case 3: + message.newValue = reader.string(); + break; + case 4: + message.changeType = (reader.int32() as any); + break; + case 5: + message.advices.push(Advice.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ConfigChange { + const obj = createBaseConfigChange(); + if (isSet(object.element)) obj.element = String(object.element); + if (isSet(object.oldValue)) obj.oldValue = String(object.oldValue); + if (isSet(object.newValue)) obj.newValue = String(object.newValue); + if (isSet(object.changeType)) obj.changeType = changeTypeFromJSON(object.changeType); + if (Array.isArray(object?.advices)) obj.advices = object.advices.map((e: any) => Advice.fromJSON(e)); + return obj; + }, + toJSON(message: ConfigChange): JsonSafe { + const obj: any = {}; + message.element !== undefined && (obj.element = message.element); + message.oldValue !== undefined && (obj.oldValue = message.oldValue); + message.newValue !== undefined && (obj.newValue = message.newValue); + message.changeType !== undefined && (obj.changeType = changeTypeToJSON(message.changeType)); + if (message.advices) { + obj.advices = message.advices.map(e => e ? Advice.toJSON(e) : undefined); + } else { + obj.advices = []; + } + return obj; + }, + fromPartial(object: DeepPartial): ConfigChange { + const message = createBaseConfigChange(); + message.element = object.element ?? ""; + message.oldValue = object.oldValue ?? ""; + message.newValue = object.newValue ?? ""; + message.changeType = object.changeType ?? 0; + message.advices = object.advices?.map(e => Advice.fromPartial(e)) || []; + return message; + }, + fromSDK(object: ConfigChangeSDKType): ConfigChange { + return { + element: object?.element, + oldValue: object?.old_value, + newValue: object?.new_value, + changeType: isSet(object.change_type) ? changeTypeFromJSON(object.change_type) : -1, + advices: Array.isArray(object?.advices) ? object.advices.map((e: any) => Advice.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): ConfigChangeSDKType { + return { + element: isSet(object.element) ? String(object.element) : "", + old_value: isSet(object.old_value) ? String(object.old_value) : "", + new_value: isSet(object.new_value) ? String(object.new_value) : "", + change_type: isSet(object.change_type) ? changeTypeFromJSON(object.change_type) : -1, + advices: Array.isArray(object?.advices) ? object.advices.map((e: any) => Advice.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: ConfigChange): ConfigChangeSDKType { + const obj: any = {}; + obj.element = message.element; + obj.old_value = message.oldValue; + obj.new_value = message.newValue; + message.changeType !== undefined && (obj.change_type = changeTypeToJSON(message.changeType)); + if (message.advices) { + obj.advices = message.advices.map(e => e ? Advice.toSDK(e) : undefined); + } else { + obj.advices = []; + } + return obj; + }, + fromAmino(object: ConfigChangeAmino): ConfigChange { + const message = createBaseConfigChange(); + if (object.element !== undefined && object.element !== null) { + message.element = object.element; + } + if (object.old_value !== undefined && object.old_value !== null) { + message.oldValue = object.old_value; + } + if (object.new_value !== undefined && object.new_value !== null) { + message.newValue = object.new_value; + } + if (object.change_type !== undefined && object.change_type !== null) { + message.changeType = object.change_type; + } + message.advices = object.advices?.map(e => Advice.fromAmino(e)) || []; + return message; + }, + toAmino(message: ConfigChange): ConfigChangeAmino { + const obj: any = {}; + obj.element = message.element === "" ? undefined : message.element; + obj.old_value = message.oldValue === "" ? undefined : message.oldValue; + obj.new_value = message.newValue === "" ? undefined : message.newValue; + obj.change_type = message.changeType === 0 ? undefined : message.changeType; + if (message.advices) { + obj.advices = message.advices.map(e => e ? Advice.toAmino(e) : undefined); + } else { + obj.advices = message.advices; + } + return obj; + }, + fromAminoMsg(object: ConfigChangeAminoMsg): ConfigChange { + return ConfigChange.fromAmino(object.value); + }, + fromProtoMsg(message: ConfigChangeProtoMsg): ConfigChange { + return ConfigChange.decode(message.value); + }, + toProto(message: ConfigChange): Uint8Array { + return ConfigChange.encode(message).finish(); + }, + toProtoMsg(message: ConfigChange): ConfigChangeProtoMsg { + return { + typeUrl: "/google.api.ConfigChange", + value: ConfigChange.encode(message).finish() + }; + } +}; +function createBaseAdvice(): Advice { + return { + description: "" + }; +} +export const Advice = { + typeUrl: "/google.api.Advice", + encode(message: Advice, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.description !== undefined) { + writer.uint32(18).string(message.description); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Advice { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseAdvice(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.description = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Advice { + const obj = createBaseAdvice(); + if (isSet(object.description)) obj.description = String(object.description); + return obj; + }, + toJSON(message: Advice): JsonSafe { + const obj: any = {}; + message.description !== undefined && (obj.description = message.description); + return obj; + }, + fromPartial(object: DeepPartial): Advice { + const message = createBaseAdvice(); + message.description = object.description ?? ""; + return message; + }, + fromSDK(object: AdviceSDKType): Advice { + return { + description: object?.description + }; + }, + fromSDKJSON(object: any): AdviceSDKType { + return { + description: isSet(object.description) ? String(object.description) : "" + }; + }, + toSDK(message: Advice): AdviceSDKType { + const obj: any = {}; + obj.description = message.description; + return obj; + }, + fromAmino(object: AdviceAmino): Advice { + const message = createBaseAdvice(); + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } + return message; + }, + toAmino(message: Advice): AdviceAmino { + const obj: any = {}; + obj.description = message.description === "" ? undefined : message.description; + return obj; + }, + fromAminoMsg(object: AdviceAminoMsg): Advice { + return Advice.fromAmino(object.value); + }, + fromProtoMsg(message: AdviceProtoMsg): Advice { + return Advice.decode(message.value); + }, + toProto(message: Advice): Uint8Array { + return Advice.encode(message).finish(); + }, + toProtoMsg(message: Advice): AdviceProtoMsg { + return { + typeUrl: "/google.api.Advice", + value: Advice.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/api/consumer.ts b/__fixtures__/v-next/outputicjsdeps/google/api/consumer.ts new file mode 100644 index 0000000000..f16c13dd81 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/api/consumer.ts @@ -0,0 +1,367 @@ +import { BinaryReader, BinaryWriter } from "../../binary.js"; +import { JsonSafe } from "../../json-safe.js"; +import { DeepPartial, isSet } from "../../helpers.js"; +export const protobufPackage = "google.api"; +/** Supported data type of the property values */ +export enum Property_PropertyType { + /** UNSPECIFIED - The type is unspecified, and will result in an error. */ + UNSPECIFIED = 0, + /** INT64 - The type is `int64`. */ + INT64 = 1, + /** BOOL - The type is `bool`. */ + BOOL = 2, + /** STRING - The type is `string`. */ + STRING = 3, + /** DOUBLE - The type is 'double'. */ + DOUBLE = 4, + UNRECOGNIZED = -1, +} +export const Property_PropertyTypeSDKType = Property_PropertyType; +export function property_PropertyTypeFromJSON(object: any): Property_PropertyType { + switch (object) { + case 0: + case "UNSPECIFIED": + return Property_PropertyType.UNSPECIFIED; + case 1: + case "INT64": + return Property_PropertyType.INT64; + case 2: + case "BOOL": + return Property_PropertyType.BOOL; + case 3: + case "STRING": + return Property_PropertyType.STRING; + case 4: + case "DOUBLE": + return Property_PropertyType.DOUBLE; + case -1: + case "UNRECOGNIZED": + default: + return Property_PropertyType.UNRECOGNIZED; + } +} +export function property_PropertyTypeToJSON(object: Property_PropertyType): string { + switch (object) { + case Property_PropertyType.UNSPECIFIED: + return "UNSPECIFIED"; + case Property_PropertyType.INT64: + return "INT64"; + case Property_PropertyType.BOOL: + return "BOOL"; + case Property_PropertyType.STRING: + return "STRING"; + case Property_PropertyType.DOUBLE: + return "DOUBLE"; + case Property_PropertyType.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** + * A descriptor for defining project properties for a service. One service may + * have many consumer projects, and the service may want to behave differently + * depending on some properties on the project. For example, a project may be + * associated with a school, or a business, or a government agency, a business + * type property on the project may affect how a service responds to the client. + * This descriptor defines which properties are allowed to be set on a project. + * + * Example: + * + * project_properties: + * properties: + * - name: NO_WATERMARK + * type: BOOL + * description: Allows usage of the API without watermarks. + * - name: EXTENDED_TILE_CACHE_PERIOD + * type: INT64 + */ +export interface ProjectProperties { + /** List of per consumer project-specific properties. */ + properties: Property[]; +} +export interface ProjectPropertiesProtoMsg { + typeUrl: "/google.api.ProjectProperties"; + value: Uint8Array; +} +/** + * A descriptor for defining project properties for a service. One service may + * have many consumer projects, and the service may want to behave differently + * depending on some properties on the project. For example, a project may be + * associated with a school, or a business, or a government agency, a business + * type property on the project may affect how a service responds to the client. + * This descriptor defines which properties are allowed to be set on a project. + * + * Example: + * + * project_properties: + * properties: + * - name: NO_WATERMARK + * type: BOOL + * description: Allows usage of the API without watermarks. + * - name: EXTENDED_TILE_CACHE_PERIOD + * type: INT64 + */ +export interface ProjectPropertiesSDKType { + properties: PropertySDKType[]; +} +/** + * Defines project properties. + * + * API services can define properties that can be assigned to consumer projects + * so that backends can perform response customization without having to make + * additional calls or maintain additional storage. For example, Maps API + * defines properties that controls map tile cache period, or whether to embed a + * watermark in a result. + * + * These values can be set via API producer console. Only API providers can + * define and set these properties. + */ +export interface Property { + /** The name of the property (a.k.a key). */ + name: string; + /** The type of this property. */ + type: Property_PropertyType; + /** The description of the property */ + description: string; +} +export interface PropertyProtoMsg { + typeUrl: "/google.api.Property"; + value: Uint8Array; +} +/** + * Defines project properties. + * + * API services can define properties that can be assigned to consumer projects + * so that backends can perform response customization without having to make + * additional calls or maintain additional storage. For example, Maps API + * defines properties that controls map tile cache period, or whether to embed a + * watermark in a result. + * + * These values can be set via API producer console. Only API providers can + * define and set these properties. + */ +export interface PropertySDKType { + name: string; + type: Property_PropertyType; + description: string; +} +function createBaseProjectProperties(): ProjectProperties { + return { + properties: [] + }; +} +export const ProjectProperties = { + typeUrl: "/google.api.ProjectProperties", + encode(message: ProjectProperties, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.properties) { + Property.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ProjectProperties { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseProjectProperties(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.properties.push(Property.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ProjectProperties { + const obj = createBaseProjectProperties(); + if (Array.isArray(object?.properties)) obj.properties = object.properties.map((e: any) => Property.fromJSON(e)); + return obj; + }, + toJSON(message: ProjectProperties): JsonSafe { + const obj: any = {}; + if (message.properties) { + obj.properties = message.properties.map(e => e ? Property.toJSON(e) : undefined); + } else { + obj.properties = []; + } + return obj; + }, + fromPartial(object: DeepPartial): ProjectProperties { + const message = createBaseProjectProperties(); + message.properties = object.properties?.map(e => Property.fromPartial(e)) || []; + return message; + }, + fromSDK(object: ProjectPropertiesSDKType): ProjectProperties { + return { + properties: Array.isArray(object?.properties) ? object.properties.map((e: any) => Property.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): ProjectPropertiesSDKType { + return { + properties: Array.isArray(object?.properties) ? object.properties.map((e: any) => Property.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: ProjectProperties): ProjectPropertiesSDKType { + const obj: any = {}; + if (message.properties) { + obj.properties = message.properties.map(e => e ? Property.toSDK(e) : undefined); + } else { + obj.properties = []; + } + return obj; + }, + fromAmino(object: ProjectPropertiesAmino): ProjectProperties { + const message = createBaseProjectProperties(); + message.properties = object.properties?.map(e => Property.fromAmino(e)) || []; + return message; + }, + toAmino(message: ProjectProperties): ProjectPropertiesAmino { + const obj: any = {}; + if (message.properties) { + obj.properties = message.properties.map(e => e ? Property.toAmino(e) : undefined); + } else { + obj.properties = message.properties; + } + return obj; + }, + fromAminoMsg(object: ProjectPropertiesAminoMsg): ProjectProperties { + return ProjectProperties.fromAmino(object.value); + }, + fromProtoMsg(message: ProjectPropertiesProtoMsg): ProjectProperties { + return ProjectProperties.decode(message.value); + }, + toProto(message: ProjectProperties): Uint8Array { + return ProjectProperties.encode(message).finish(); + }, + toProtoMsg(message: ProjectProperties): ProjectPropertiesProtoMsg { + return { + typeUrl: "/google.api.ProjectProperties", + value: ProjectProperties.encode(message).finish() + }; + } +}; +function createBaseProperty(): Property { + return { + name: "", + type: 0, + description: "" + }; +} +export const Property = { + typeUrl: "/google.api.Property", + encode(message: Property, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + if (message.type !== 0) { + writer.uint32(16).int32(message.type); + } + if (message.description !== undefined) { + writer.uint32(26).string(message.description); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Property { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseProperty(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.type = (reader.int32() as any); + break; + case 3: + message.description = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Property { + const obj = createBaseProperty(); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.type)) obj.type = property_PropertyTypeFromJSON(object.type); + if (isSet(object.description)) obj.description = String(object.description); + return obj; + }, + toJSON(message: Property): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.type !== undefined && (obj.type = property_PropertyTypeToJSON(message.type)); + message.description !== undefined && (obj.description = message.description); + return obj; + }, + fromPartial(object: DeepPartial): Property { + const message = createBaseProperty(); + message.name = object.name ?? ""; + message.type = object.type ?? 0; + message.description = object.description ?? ""; + return message; + }, + fromSDK(object: PropertySDKType): Property { + return { + name: object?.name, + type: isSet(object.type) ? property_PropertyTypeFromJSON(object.type) : -1, + description: object?.description + }; + }, + fromSDKJSON(object: any): PropertySDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + type: isSet(object.type) ? property_PropertyTypeFromJSON(object.type) : -1, + description: isSet(object.description) ? String(object.description) : "" + }; + }, + toSDK(message: Property): PropertySDKType { + const obj: any = {}; + obj.name = message.name; + message.type !== undefined && (obj.type = property_PropertyTypeToJSON(message.type)); + obj.description = message.description; + return obj; + }, + fromAmino(object: PropertyAmino): Property { + const message = createBaseProperty(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + if (object.type !== undefined && object.type !== null) { + message.type = object.type; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } + return message; + }, + toAmino(message: Property): PropertyAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + obj.type = message.type === 0 ? undefined : message.type; + obj.description = message.description === "" ? undefined : message.description; + return obj; + }, + fromAminoMsg(object: PropertyAminoMsg): Property { + return Property.fromAmino(object.value); + }, + fromProtoMsg(message: PropertyProtoMsg): Property { + return Property.decode(message.value); + }, + toProto(message: Property): Uint8Array { + return Property.encode(message).finish(); + }, + toProtoMsg(message: Property): PropertyProtoMsg { + return { + typeUrl: "/google.api.Property", + value: Property.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/api/context.ts b/__fixtures__/v-next/outputicjsdeps/google/api/context.ts new file mode 100644 index 0000000000..20634acf30 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/api/context.ts @@ -0,0 +1,430 @@ +import { BinaryReader, BinaryWriter } from "../../binary.js"; +import { JsonSafe } from "../../json-safe.js"; +import { DeepPartial, isSet } from "../../helpers.js"; +export const protobufPackage = "google.api"; +/** + * `Context` defines which contexts an API requests. + * + * Example: + * + * context: + * rules: + * - selector: "*" + * requested: + * - google.rpc.context.ProjectContext + * - google.rpc.context.OriginContext + * + * The above specifies that all methods in the API request + * `google.rpc.context.ProjectContext` and + * `google.rpc.context.OriginContext`. + * + * Available context types are defined in package + * `google.rpc.context`. + * + * This also provides mechanism to allowlist any protobuf message extension that + * can be sent in grpc metadata using “x-goog-ext--bin” and + * “x-goog-ext--jspb” format. For example, list any service + * specific protobuf types that can appear in grpc metadata as follows in your + * yaml file: + * + * Example: + * + * context: + * rules: + * - selector: "google.example.library.v1.LibraryService.CreateBook" + * allowed_request_extensions: + * - google.foo.v1.NewExtension + * allowed_response_extensions: + * - google.foo.v1.NewExtension + * + * You can also specify extension ID instead of fully qualified extension name + * here. + */ +export interface Context { + /** + * A list of RPC context rules that apply to individual API methods. + * + * **NOTE:** All service configuration rules follow "last one wins" order. + */ + rules: ContextRule[]; +} +export interface ContextProtoMsg { + typeUrl: "/google.api.Context"; + value: Uint8Array; +} +/** + * `Context` defines which contexts an API requests. + * + * Example: + * + * context: + * rules: + * - selector: "*" + * requested: + * - google.rpc.context.ProjectContext + * - google.rpc.context.OriginContext + * + * The above specifies that all methods in the API request + * `google.rpc.context.ProjectContext` and + * `google.rpc.context.OriginContext`. + * + * Available context types are defined in package + * `google.rpc.context`. + * + * This also provides mechanism to allowlist any protobuf message extension that + * can be sent in grpc metadata using “x-goog-ext--bin” and + * “x-goog-ext--jspb” format. For example, list any service + * specific protobuf types that can appear in grpc metadata as follows in your + * yaml file: + * + * Example: + * + * context: + * rules: + * - selector: "google.example.library.v1.LibraryService.CreateBook" + * allowed_request_extensions: + * - google.foo.v1.NewExtension + * allowed_response_extensions: + * - google.foo.v1.NewExtension + * + * You can also specify extension ID instead of fully qualified extension name + * here. + */ +export interface ContextSDKType { + rules: ContextRuleSDKType[]; +} +/** + * A context rule provides information about the context for an individual API + * element. + */ +export interface ContextRule { + /** + * Selects the methods to which this rule applies. + * + * Refer to [selector][google.api.DocumentationRule.selector] for syntax details. + */ + selector: string; + /** A list of full type names of requested contexts. */ + requested: string[]; + /** A list of full type names of provided contexts. */ + provided: string[]; + /** + * A list of full type names or extension IDs of extensions allowed in grpc + * side channel from client to backend. + */ + allowedRequestExtensions: string[]; + /** + * A list of full type names or extension IDs of extensions allowed in grpc + * side channel from backend to client. + */ + allowedResponseExtensions: string[]; +} +export interface ContextRuleProtoMsg { + typeUrl: "/google.api.ContextRule"; + value: Uint8Array; +} +/** + * A context rule provides information about the context for an individual API + * element. + */ +export interface ContextRuleSDKType { + selector: string; + requested: string[]; + provided: string[]; + allowed_request_extensions: string[]; + allowed_response_extensions: string[]; +} +function createBaseContext(): Context { + return { + rules: [] + }; +} +export const Context = { + typeUrl: "/google.api.Context", + encode(message: Context, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.rules) { + ContextRule.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Context { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseContext(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.rules.push(ContextRule.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Context { + const obj = createBaseContext(); + if (Array.isArray(object?.rules)) obj.rules = object.rules.map((e: any) => ContextRule.fromJSON(e)); + return obj; + }, + toJSON(message: Context): JsonSafe { + const obj: any = {}; + if (message.rules) { + obj.rules = message.rules.map(e => e ? ContextRule.toJSON(e) : undefined); + } else { + obj.rules = []; + } + return obj; + }, + fromPartial(object: DeepPartial): Context { + const message = createBaseContext(); + message.rules = object.rules?.map(e => ContextRule.fromPartial(e)) || []; + return message; + }, + fromSDK(object: ContextSDKType): Context { + return { + rules: Array.isArray(object?.rules) ? object.rules.map((e: any) => ContextRule.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): ContextSDKType { + return { + rules: Array.isArray(object?.rules) ? object.rules.map((e: any) => ContextRule.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: Context): ContextSDKType { + const obj: any = {}; + if (message.rules) { + obj.rules = message.rules.map(e => e ? ContextRule.toSDK(e) : undefined); + } else { + obj.rules = []; + } + return obj; + }, + fromAmino(object: ContextAmino): Context { + const message = createBaseContext(); + message.rules = object.rules?.map(e => ContextRule.fromAmino(e)) || []; + return message; + }, + toAmino(message: Context): ContextAmino { + const obj: any = {}; + if (message.rules) { + obj.rules = message.rules.map(e => e ? ContextRule.toAmino(e) : undefined); + } else { + obj.rules = message.rules; + } + return obj; + }, + fromAminoMsg(object: ContextAminoMsg): Context { + return Context.fromAmino(object.value); + }, + fromProtoMsg(message: ContextProtoMsg): Context { + return Context.decode(message.value); + }, + toProto(message: Context): Uint8Array { + return Context.encode(message).finish(); + }, + toProtoMsg(message: Context): ContextProtoMsg { + return { + typeUrl: "/google.api.Context", + value: Context.encode(message).finish() + }; + } +}; +function createBaseContextRule(): ContextRule { + return { + selector: "", + requested: [], + provided: [], + allowedRequestExtensions: [], + allowedResponseExtensions: [] + }; +} +export const ContextRule = { + typeUrl: "/google.api.ContextRule", + encode(message: ContextRule, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.selector !== undefined) { + writer.uint32(10).string(message.selector); + } + for (const v of message.requested) { + writer.uint32(18).string(v!); + } + for (const v of message.provided) { + writer.uint32(26).string(v!); + } + for (const v of message.allowedRequestExtensions) { + writer.uint32(34).string(v!); + } + for (const v of message.allowedResponseExtensions) { + writer.uint32(42).string(v!); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ContextRule { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseContextRule(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.selector = reader.string(); + break; + case 2: + message.requested.push(reader.string()); + break; + case 3: + message.provided.push(reader.string()); + break; + case 4: + message.allowedRequestExtensions.push(reader.string()); + break; + case 5: + message.allowedResponseExtensions.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ContextRule { + const obj = createBaseContextRule(); + if (isSet(object.selector)) obj.selector = String(object.selector); + if (Array.isArray(object?.requested)) obj.requested = object.requested.map((e: any) => String(e)); + if (Array.isArray(object?.provided)) obj.provided = object.provided.map((e: any) => String(e)); + if (Array.isArray(object?.allowedRequestExtensions)) obj.allowedRequestExtensions = object.allowedRequestExtensions.map((e: any) => String(e)); + if (Array.isArray(object?.allowedResponseExtensions)) obj.allowedResponseExtensions = object.allowedResponseExtensions.map((e: any) => String(e)); + return obj; + }, + toJSON(message: ContextRule): JsonSafe { + const obj: any = {}; + message.selector !== undefined && (obj.selector = message.selector); + if (message.requested) { + obj.requested = message.requested.map(e => e); + } else { + obj.requested = []; + } + if (message.provided) { + obj.provided = message.provided.map(e => e); + } else { + obj.provided = []; + } + if (message.allowedRequestExtensions) { + obj.allowedRequestExtensions = message.allowedRequestExtensions.map(e => e); + } else { + obj.allowedRequestExtensions = []; + } + if (message.allowedResponseExtensions) { + obj.allowedResponseExtensions = message.allowedResponseExtensions.map(e => e); + } else { + obj.allowedResponseExtensions = []; + } + return obj; + }, + fromPartial(object: DeepPartial): ContextRule { + const message = createBaseContextRule(); + message.selector = object.selector ?? ""; + message.requested = object.requested?.map(e => e) || []; + message.provided = object.provided?.map(e => e) || []; + message.allowedRequestExtensions = object.allowedRequestExtensions?.map(e => e) || []; + message.allowedResponseExtensions = object.allowedResponseExtensions?.map(e => e) || []; + return message; + }, + fromSDK(object: ContextRuleSDKType): ContextRule { + return { + selector: object?.selector, + requested: Array.isArray(object?.requested) ? object.requested.map((e: any) => e) : [], + provided: Array.isArray(object?.provided) ? object.provided.map((e: any) => e) : [], + allowedRequestExtensions: Array.isArray(object?.allowed_request_extensions) ? object.allowed_request_extensions.map((e: any) => e) : [], + allowedResponseExtensions: Array.isArray(object?.allowed_response_extensions) ? object.allowed_response_extensions.map((e: any) => e) : [] + }; + }, + fromSDKJSON(object: any): ContextRuleSDKType { + return { + selector: isSet(object.selector) ? String(object.selector) : "", + requested: Array.isArray(object?.requested) ? object.requested.map((e: any) => String(e)) : [], + provided: Array.isArray(object?.provided) ? object.provided.map((e: any) => String(e)) : [], + allowed_request_extensions: Array.isArray(object?.allowed_request_extensions) ? object.allowed_request_extensions.map((e: any) => String(e)) : [], + allowed_response_extensions: Array.isArray(object?.allowed_response_extensions) ? object.allowed_response_extensions.map((e: any) => String(e)) : [] + }; + }, + toSDK(message: ContextRule): ContextRuleSDKType { + const obj: any = {}; + obj.selector = message.selector; + if (message.requested) { + obj.requested = message.requested.map(e => e); + } else { + obj.requested = []; + } + if (message.provided) { + obj.provided = message.provided.map(e => e); + } else { + obj.provided = []; + } + if (message.allowedRequestExtensions) { + obj.allowed_request_extensions = message.allowedRequestExtensions.map(e => e); + } else { + obj.allowed_request_extensions = []; + } + if (message.allowedResponseExtensions) { + obj.allowed_response_extensions = message.allowedResponseExtensions.map(e => e); + } else { + obj.allowed_response_extensions = []; + } + return obj; + }, + fromAmino(object: ContextRuleAmino): ContextRule { + const message = createBaseContextRule(); + if (object.selector !== undefined && object.selector !== null) { + message.selector = object.selector; + } + message.requested = object.requested?.map(e => e) || []; + message.provided = object.provided?.map(e => e) || []; + message.allowedRequestExtensions = object.allowed_request_extensions?.map(e => e) || []; + message.allowedResponseExtensions = object.allowed_response_extensions?.map(e => e) || []; + return message; + }, + toAmino(message: ContextRule): ContextRuleAmino { + const obj: any = {}; + obj.selector = message.selector === "" ? undefined : message.selector; + if (message.requested) { + obj.requested = message.requested.map(e => e); + } else { + obj.requested = message.requested; + } + if (message.provided) { + obj.provided = message.provided.map(e => e); + } else { + obj.provided = message.provided; + } + if (message.allowedRequestExtensions) { + obj.allowed_request_extensions = message.allowedRequestExtensions.map(e => e); + } else { + obj.allowed_request_extensions = message.allowedRequestExtensions; + } + if (message.allowedResponseExtensions) { + obj.allowed_response_extensions = message.allowedResponseExtensions.map(e => e); + } else { + obj.allowed_response_extensions = message.allowedResponseExtensions; + } + return obj; + }, + fromAminoMsg(object: ContextRuleAminoMsg): ContextRule { + return ContextRule.fromAmino(object.value); + }, + fromProtoMsg(message: ContextRuleProtoMsg): ContextRule { + return ContextRule.decode(message.value); + }, + toProto(message: ContextRule): Uint8Array { + return ContextRule.encode(message).finish(); + }, + toProtoMsg(message: ContextRule): ContextRuleProtoMsg { + return { + typeUrl: "/google.api.ContextRule", + value: ContextRule.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/api/control.ts b/__fixtures__/v-next/outputicjsdeps/google/api/control.ts new file mode 100644 index 0000000000..a021cfcb77 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/api/control.ts @@ -0,0 +1,116 @@ +import { BinaryReader, BinaryWriter } from "../../binary.js"; +import { isSet, DeepPartial } from "../../helpers.js"; +import { JsonSafe } from "../../json-safe.js"; +export const protobufPackage = "google.api"; +/** + * Selects and configures the service controller used by the service. The + * service controller handles features like abuse, quota, billing, logging, + * monitoring, etc. + */ +export interface Control { + /** + * The service control environment to use. If empty, no control plane + * feature (like quota and billing) will be enabled. + */ + environment: string; +} +export interface ControlProtoMsg { + typeUrl: "/google.api.Control"; + value: Uint8Array; +} +/** + * Selects and configures the service controller used by the service. The + * service controller handles features like abuse, quota, billing, logging, + * monitoring, etc. + */ +export interface ControlSDKType { + environment: string; +} +function createBaseControl(): Control { + return { + environment: "" + }; +} +export const Control = { + typeUrl: "/google.api.Control", + encode(message: Control, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.environment !== undefined) { + writer.uint32(10).string(message.environment); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Control { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseControl(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.environment = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Control { + const obj = createBaseControl(); + if (isSet(object.environment)) obj.environment = String(object.environment); + return obj; + }, + toJSON(message: Control): JsonSafe { + const obj: any = {}; + message.environment !== undefined && (obj.environment = message.environment); + return obj; + }, + fromPartial(object: DeepPartial): Control { + const message = createBaseControl(); + message.environment = object.environment ?? ""; + return message; + }, + fromSDK(object: ControlSDKType): Control { + return { + environment: object?.environment + }; + }, + fromSDKJSON(object: any): ControlSDKType { + return { + environment: isSet(object.environment) ? String(object.environment) : "" + }; + }, + toSDK(message: Control): ControlSDKType { + const obj: any = {}; + obj.environment = message.environment; + return obj; + }, + fromAmino(object: ControlAmino): Control { + const message = createBaseControl(); + if (object.environment !== undefined && object.environment !== null) { + message.environment = object.environment; + } + return message; + }, + toAmino(message: Control): ControlAmino { + const obj: any = {}; + obj.environment = message.environment === "" ? undefined : message.environment; + return obj; + }, + fromAminoMsg(object: ControlAminoMsg): Control { + return Control.fromAmino(object.value); + }, + fromProtoMsg(message: ControlProtoMsg): Control { + return Control.decode(message.value); + }, + toProto(message: Control): Uint8Array { + return Control.encode(message).finish(); + }, + toProtoMsg(message: Control): ControlProtoMsg { + return { + typeUrl: "/google.api.Control", + value: Control.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/api/distribution.ts b/__fixtures__/v-next/outputicjsdeps/google/api/distribution.ts new file mode 100644 index 0000000000..78227415e7 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/api/distribution.ts @@ -0,0 +1,1275 @@ +import { Timestamp, TimestampSDKType } from "../protobuf/timestamp.js"; +import { Any, AnySDKType } from "../protobuf/any.js"; +import { BinaryReader, BinaryWriter } from "../../binary.js"; +import { isSet, DeepPartial, toTimestamp, fromTimestamp } from "../../helpers.js"; +import { JsonSafe } from "../../json-safe.js"; +export const protobufPackage = "google.api"; +/** + * `Distribution` contains summary statistics for a population of values. It + * optionally contains a histogram representing the distribution of those values + * across a set of buckets. + * + * The summary statistics are the count, mean, sum of the squared deviation from + * the mean, the minimum, and the maximum of the set of population of values. + * The histogram is based on a sequence of buckets and gives a count of values + * that fall into each bucket. The boundaries of the buckets are given either + * explicitly or by formulas for buckets of fixed or exponentially increasing + * widths. + * + * Although it is not forbidden, it is generally a bad idea to include + * non-finite values (infinities or NaNs) in the population of values, as this + * will render the `mean` and `sum_of_squared_deviation` fields meaningless. + */ +export interface Distribution { + /** + * The number of values in the population. Must be non-negative. This value + * must equal the sum of the values in `bucket_counts` if a histogram is + * provided. + */ + count: bigint; + /** + * The arithmetic mean of the values in the population. If `count` is zero + * then this field must be zero. + */ + mean: number; + /** + * The sum of squared deviations from the mean of the values in the + * population. For values x_i this is: + * + * Sum[i=1..n]((x_i - mean)^2) + * + * Knuth, "The Art of Computer Programming", Vol. 2, page 232, 3rd edition + * describes Welford's method for accumulating this sum in one pass. + * + * If `count` is zero then this field must be zero. + */ + sumOfSquaredDeviation: number; + /** + * If specified, contains the range of the population values. The field + * must not be present if the `count` is zero. + */ + range?: Distribution_Range; + /** + * Defines the histogram bucket boundaries. If the distribution does not + * contain a histogram, then omit this field. + */ + bucketOptions?: Distribution_BucketOptions; + /** + * The number of values in each bucket of the histogram, as described in + * `bucket_options`. If the distribution does not have a histogram, then omit + * this field. If there is a histogram, then the sum of the values in + * `bucket_counts` must equal the value in the `count` field of the + * distribution. + * + * If present, `bucket_counts` should contain N values, where N is the number + * of buckets specified in `bucket_options`. If you supply fewer than N + * values, the remaining values are assumed to be 0. + * + * The order of the values in `bucket_counts` follows the bucket numbering + * schemes described for the three bucket types. The first value must be the + * count for the underflow bucket (number 0). The next N-2 values are the + * counts for the finite buckets (number 1 through N-2). The N'th value in + * `bucket_counts` is the count for the overflow bucket (number N-1). + */ + bucketCounts: bigint[]; + /** Must be in increasing order of `value` field. */ + exemplars: Distribution_Exemplar[]; +} +export interface DistributionProtoMsg { + typeUrl: "/google.api.Distribution"; + value: Uint8Array; +} +/** + * `Distribution` contains summary statistics for a population of values. It + * optionally contains a histogram representing the distribution of those values + * across a set of buckets. + * + * The summary statistics are the count, mean, sum of the squared deviation from + * the mean, the minimum, and the maximum of the set of population of values. + * The histogram is based on a sequence of buckets and gives a count of values + * that fall into each bucket. The boundaries of the buckets are given either + * explicitly or by formulas for buckets of fixed or exponentially increasing + * widths. + * + * Although it is not forbidden, it is generally a bad idea to include + * non-finite values (infinities or NaNs) in the population of values, as this + * will render the `mean` and `sum_of_squared_deviation` fields meaningless. + */ +export interface DistributionSDKType { + count: bigint; + mean: number; + sum_of_squared_deviation: number; + range?: Distribution_RangeSDKType; + bucket_options?: Distribution_BucketOptionsSDKType; + bucket_counts: bigint[]; + exemplars: Distribution_ExemplarSDKType[]; +} +/** The range of the population values. */ +export interface Distribution_Range { + /** The minimum of the population values. */ + min: number; + /** The maximum of the population values. */ + max: number; +} +export interface Distribution_RangeProtoMsg { + typeUrl: "/google.api.Range"; + value: Uint8Array; +} +/** The range of the population values. */ +export interface Distribution_RangeSDKType { + min: number; + max: number; +} +/** + * `BucketOptions` describes the bucket boundaries used to create a histogram + * for the distribution. The buckets can be in a linear sequence, an + * exponential sequence, or each bucket can be specified explicitly. + * `BucketOptions` does not include the number of values in each bucket. + * + * A bucket has an inclusive lower bound and exclusive upper bound for the + * values that are counted for that bucket. The upper bound of a bucket must + * be strictly greater than the lower bound. The sequence of N buckets for a + * distribution consists of an underflow bucket (number 0), zero or more + * finite buckets (number 1 through N - 2) and an overflow bucket (number N - + * 1). The buckets are contiguous: the lower bound of bucket i (i > 0) is the + * same as the upper bound of bucket i - 1. The buckets span the whole range + * of finite values: lower bound of the underflow bucket is -infinity and the + * upper bound of the overflow bucket is +infinity. The finite buckets are + * so-called because both bounds are finite. + */ +export interface Distribution_BucketOptions { + /** The linear bucket. */ + linearBuckets?: Distribution_BucketOptions_Linear; + /** The exponential buckets. */ + exponentialBuckets?: Distribution_BucketOptions_Exponential; + /** The explicit buckets. */ + explicitBuckets?: Distribution_BucketOptions_Explicit; +} +export interface Distribution_BucketOptionsProtoMsg { + typeUrl: "/google.api.BucketOptions"; + value: Uint8Array; +} +/** + * `BucketOptions` describes the bucket boundaries used to create a histogram + * for the distribution. The buckets can be in a linear sequence, an + * exponential sequence, or each bucket can be specified explicitly. + * `BucketOptions` does not include the number of values in each bucket. + * + * A bucket has an inclusive lower bound and exclusive upper bound for the + * values that are counted for that bucket. The upper bound of a bucket must + * be strictly greater than the lower bound. The sequence of N buckets for a + * distribution consists of an underflow bucket (number 0), zero or more + * finite buckets (number 1 through N - 2) and an overflow bucket (number N - + * 1). The buckets are contiguous: the lower bound of bucket i (i > 0) is the + * same as the upper bound of bucket i - 1. The buckets span the whole range + * of finite values: lower bound of the underflow bucket is -infinity and the + * upper bound of the overflow bucket is +infinity. The finite buckets are + * so-called because both bounds are finite. + */ +export interface Distribution_BucketOptionsSDKType { + linear_buckets?: Distribution_BucketOptions_LinearSDKType; + exponential_buckets?: Distribution_BucketOptions_ExponentialSDKType; + explicit_buckets?: Distribution_BucketOptions_ExplicitSDKType; +} +/** + * Specifies a linear sequence of buckets that all have the same width + * (except overflow and underflow). Each bucket represents a constant + * absolute uncertainty on the specific value in the bucket. + * + * There are `num_finite_buckets + 2` (= N) buckets. Bucket `i` has the + * following boundaries: + * + * Upper bound (0 <= i < N-1): offset + (width * i). + * Lower bound (1 <= i < N): offset + (width * (i - 1)). + */ +export interface Distribution_BucketOptions_Linear { + /** Must be greater than 0. */ + numFiniteBuckets: number; + /** Must be greater than 0. */ + width: number; + /** Lower bound of the first bucket. */ + offset: number; +} +export interface Distribution_BucketOptions_LinearProtoMsg { + typeUrl: "/google.api.Linear"; + value: Uint8Array; +} +/** + * Specifies a linear sequence of buckets that all have the same width + * (except overflow and underflow). Each bucket represents a constant + * absolute uncertainty on the specific value in the bucket. + * + * There are `num_finite_buckets + 2` (= N) buckets. Bucket `i` has the + * following boundaries: + * + * Upper bound (0 <= i < N-1): offset + (width * i). + * Lower bound (1 <= i < N): offset + (width * (i - 1)). + */ +export interface Distribution_BucketOptions_LinearSDKType { + num_finite_buckets: number; + width: number; + offset: number; +} +/** + * Specifies an exponential sequence of buckets that have a width that is + * proportional to the value of the lower bound. Each bucket represents a + * constant relative uncertainty on a specific value in the bucket. + * + * There are `num_finite_buckets + 2` (= N) buckets. Bucket `i` has the + * following boundaries: + * + * Upper bound (0 <= i < N-1): scale * (growth_factor ^ i). + * Lower bound (1 <= i < N): scale * (growth_factor ^ (i - 1)). + */ +export interface Distribution_BucketOptions_Exponential { + /** Must be greater than 0. */ + numFiniteBuckets: number; + /** Must be greater than 1. */ + growthFactor: number; + /** Must be greater than 0. */ + scale: number; +} +export interface Distribution_BucketOptions_ExponentialProtoMsg { + typeUrl: "/google.api.Exponential"; + value: Uint8Array; +} +/** + * Specifies an exponential sequence of buckets that have a width that is + * proportional to the value of the lower bound. Each bucket represents a + * constant relative uncertainty on a specific value in the bucket. + * + * There are `num_finite_buckets + 2` (= N) buckets. Bucket `i` has the + * following boundaries: + * + * Upper bound (0 <= i < N-1): scale * (growth_factor ^ i). + * Lower bound (1 <= i < N): scale * (growth_factor ^ (i - 1)). + */ +export interface Distribution_BucketOptions_ExponentialSDKType { + num_finite_buckets: number; + growth_factor: number; + scale: number; +} +/** + * Specifies a set of buckets with arbitrary widths. + * + * There are `size(bounds) + 1` (= N) buckets. Bucket `i` has the following + * boundaries: + * + * Upper bound (0 <= i < N-1): bounds[i] + * Lower bound (1 <= i < N); bounds[i - 1] + * + * The `bounds` field must contain at least one element. If `bounds` has + * only one element, then there are no finite buckets, and that single + * element is the common boundary of the overflow and underflow buckets. + */ +export interface Distribution_BucketOptions_Explicit { + /** The values must be monotonically increasing. */ + bounds: number[]; +} +export interface Distribution_BucketOptions_ExplicitProtoMsg { + typeUrl: "/google.api.Explicit"; + value: Uint8Array; +} +/** + * Specifies a set of buckets with arbitrary widths. + * + * There are `size(bounds) + 1` (= N) buckets. Bucket `i` has the following + * boundaries: + * + * Upper bound (0 <= i < N-1): bounds[i] + * Lower bound (1 <= i < N); bounds[i - 1] + * + * The `bounds` field must contain at least one element. If `bounds` has + * only one element, then there are no finite buckets, and that single + * element is the common boundary of the overflow and underflow buckets. + */ +export interface Distribution_BucketOptions_ExplicitSDKType { + bounds: number[]; +} +/** + * Exemplars are example points that may be used to annotate aggregated + * distribution values. They are metadata that gives information about a + * particular value added to a Distribution bucket, such as a trace ID that + * was active when a value was added. They may contain further information, + * such as a example values and timestamps, origin, etc. + */ +export interface Distribution_Exemplar { + /** + * Value of the exemplar point. This value determines to which bucket the + * exemplar belongs. + */ + value: number; + /** The observation (sampling) time of the above value. */ + timestamp?: Date; + /** + * Contextual information about the example value. Examples are: + * + * Trace: type.googleapis.com/google.monitoring.v3.SpanContext + * + * Literal string: type.googleapis.com/google.protobuf.StringValue + * + * Labels dropped during aggregation: + * type.googleapis.com/google.monitoring.v3.DroppedLabels + * + * There may be only a single attachment of any given message type in a + * single exemplar, and this is enforced by the system. + */ + attachments: Any[]; +} +export interface Distribution_ExemplarProtoMsg { + typeUrl: "/google.api.Exemplar"; + value: Uint8Array; +} +/** + * Exemplars are example points that may be used to annotate aggregated + * distribution values. They are metadata that gives information about a + * particular value added to a Distribution bucket, such as a trace ID that + * was active when a value was added. They may contain further information, + * such as a example values and timestamps, origin, etc. + */ +export interface Distribution_ExemplarSDKType { + value: number; + timestamp?: Date; + attachments: AnySDKType[]; +} +function createBaseDistribution(): Distribution { + return { + count: BigInt(0), + mean: 0, + sumOfSquaredDeviation: 0, + range: undefined, + bucketOptions: undefined, + bucketCounts: [], + exemplars: [] + }; +} +export const Distribution = { + typeUrl: "/google.api.Distribution", + encode(message: Distribution, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.count !== undefined) { + writer.uint32(8).int64(message.count); + } + if (message.mean !== undefined) { + writer.uint32(17).double(message.mean); + } + if (message.sumOfSquaredDeviation !== undefined) { + writer.uint32(25).double(message.sumOfSquaredDeviation); + } + if (message.range !== undefined) { + Distribution_Range.encode(message.range, writer.uint32(34).fork()).ldelim(); + } + if (message.bucketOptions !== undefined) { + Distribution_BucketOptions.encode(message.bucketOptions, writer.uint32(50).fork()).ldelim(); + } + writer.uint32(58).fork(); + for (const v of message.bucketCounts) { + writer.int64(v); + } + writer.ldelim(); + for (const v of message.exemplars) { + Distribution_Exemplar.encode(v!, writer.uint32(82).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Distribution { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDistribution(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.count = reader.int64(); + break; + case 2: + message.mean = reader.double(); + break; + case 3: + message.sumOfSquaredDeviation = reader.double(); + break; + case 4: + message.range = Distribution_Range.decode(reader, reader.uint32()); + break; + case 6: + message.bucketOptions = Distribution_BucketOptions.decode(reader, reader.uint32()); + break; + case 7: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.bucketCounts.push(reader.int64()); + } + } else { + message.bucketCounts.push(reader.int64()); + } + break; + case 10: + message.exemplars.push(Distribution_Exemplar.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Distribution { + const obj = createBaseDistribution(); + if (isSet(object.count)) obj.count = BigInt(object.count.toString()); + if (isSet(object.mean)) obj.mean = Number(object.mean); + if (isSet(object.sumOfSquaredDeviation)) obj.sumOfSquaredDeviation = Number(object.sumOfSquaredDeviation); + if (isSet(object.range)) obj.range = Distribution_Range.fromJSON(object.range); + if (isSet(object.bucketOptions)) obj.bucketOptions = Distribution_BucketOptions.fromJSON(object.bucketOptions); + if (Array.isArray(object?.bucketCounts)) obj.bucketCounts = object.bucketCounts.map((e: any) => BigInt(e.toString())); + if (Array.isArray(object?.exemplars)) obj.exemplars = object.exemplars.map((e: any) => Distribution_Exemplar.fromJSON(e)); + return obj; + }, + toJSON(message: Distribution): JsonSafe { + const obj: any = {}; + message.count !== undefined && (obj.count = (message.count || BigInt(0)).toString()); + message.mean !== undefined && (obj.mean = message.mean); + message.sumOfSquaredDeviation !== undefined && (obj.sumOfSquaredDeviation = message.sumOfSquaredDeviation); + message.range !== undefined && (obj.range = message.range ? Distribution_Range.toJSON(message.range) : undefined); + message.bucketOptions !== undefined && (obj.bucketOptions = message.bucketOptions ? Distribution_BucketOptions.toJSON(message.bucketOptions) : undefined); + if (message.bucketCounts) { + obj.bucketCounts = message.bucketCounts.map(e => (e || BigInt(0)).toString()); + } else { + obj.bucketCounts = []; + } + if (message.exemplars) { + obj.exemplars = message.exemplars.map(e => e ? Distribution_Exemplar.toJSON(e) : undefined); + } else { + obj.exemplars = []; + } + return obj; + }, + fromPartial(object: DeepPartial): Distribution { + const message = createBaseDistribution(); + if (object.count !== undefined && object.count !== null) { + message.count = BigInt(object.count.toString()); + } + message.mean = object.mean ?? 0; + message.sumOfSquaredDeviation = object.sumOfSquaredDeviation ?? 0; + if (object.range !== undefined && object.range !== null) { + message.range = Distribution_Range.fromPartial(object.range); + } + if (object.bucketOptions !== undefined && object.bucketOptions !== null) { + message.bucketOptions = Distribution_BucketOptions.fromPartial(object.bucketOptions); + } + message.bucketCounts = object.bucketCounts?.map(e => BigInt(e.toString())) || []; + message.exemplars = object.exemplars?.map(e => Distribution_Exemplar.fromPartial(e)) || []; + return message; + }, + fromSDK(object: DistributionSDKType): Distribution { + return { + count: object?.count, + mean: object?.mean, + sumOfSquaredDeviation: object?.sum_of_squared_deviation, + range: object.range ? Distribution_Range.fromSDK(object.range) : undefined, + bucketOptions: object.bucket_options ? Distribution_BucketOptions.fromSDK(object.bucket_options) : undefined, + bucketCounts: Array.isArray(object?.bucket_counts) ? object.bucket_counts.map((e: any) => e) : [], + exemplars: Array.isArray(object?.exemplars) ? object.exemplars.map((e: any) => Distribution_Exemplar.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): DistributionSDKType { + return { + count: isSet(object.count) ? BigInt(object.count.toString()) : BigInt(0), + mean: isSet(object.mean) ? Number(object.mean) : 0, + sum_of_squared_deviation: isSet(object.sum_of_squared_deviation) ? Number(object.sum_of_squared_deviation) : 0, + range: isSet(object.range) ? Distribution_Range.fromSDKJSON(object.range) : undefined, + bucket_options: isSet(object.bucket_options) ? Distribution_BucketOptions.fromSDKJSON(object.bucket_options) : undefined, + bucket_counts: Array.isArray(object?.bucket_counts) ? object.bucket_counts.map((e: any) => BigInt(e.toString())) : [], + exemplars: Array.isArray(object?.exemplars) ? object.exemplars.map((e: any) => Distribution_Exemplar.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: Distribution): DistributionSDKType { + const obj: any = {}; + obj.count = message.count; + obj.mean = message.mean; + obj.sum_of_squared_deviation = message.sumOfSquaredDeviation; + message.range !== undefined && (obj.range = message.range ? Distribution_Range.toSDK(message.range) : undefined); + message.bucketOptions !== undefined && (obj.bucket_options = message.bucketOptions ? Distribution_BucketOptions.toSDK(message.bucketOptions) : undefined); + if (message.bucketCounts) { + obj.bucket_counts = message.bucketCounts.map(e => e); + } else { + obj.bucket_counts = []; + } + if (message.exemplars) { + obj.exemplars = message.exemplars.map(e => e ? Distribution_Exemplar.toSDK(e) : undefined); + } else { + obj.exemplars = []; + } + return obj; + }, + fromAmino(object: DistributionAmino): Distribution { + const message = createBaseDistribution(); + if (object.count !== undefined && object.count !== null) { + message.count = BigInt(object.count); + } + if (object.mean !== undefined && object.mean !== null) { + message.mean = object.mean; + } + if (object.sum_of_squared_deviation !== undefined && object.sum_of_squared_deviation !== null) { + message.sumOfSquaredDeviation = object.sum_of_squared_deviation; + } + if (object.range !== undefined && object.range !== null) { + message.range = Distribution_Range.fromAmino(object.range); + } + if (object.bucket_options !== undefined && object.bucket_options !== null) { + message.bucketOptions = Distribution_BucketOptions.fromAmino(object.bucket_options); + } + message.bucketCounts = object.bucket_counts?.map(e => BigInt(e)) || []; + message.exemplars = object.exemplars?.map(e => Distribution_Exemplar.fromAmino(e)) || []; + return message; + }, + toAmino(message: Distribution): DistributionAmino { + const obj: any = {}; + obj.count = message.count !== BigInt(0) ? message.count?.toString() : undefined; + obj.mean = message.mean === 0 ? undefined : message.mean; + obj.sum_of_squared_deviation = message.sumOfSquaredDeviation === 0 ? undefined : message.sumOfSquaredDeviation; + obj.range = message.range ? Distribution_Range.toAmino(message.range) : undefined; + obj.bucket_options = message.bucketOptions ? Distribution_BucketOptions.toAmino(message.bucketOptions) : undefined; + if (message.bucketCounts) { + obj.bucket_counts = message.bucketCounts.map(e => e.toString()); + } else { + obj.bucket_counts = message.bucketCounts; + } + if (message.exemplars) { + obj.exemplars = message.exemplars.map(e => e ? Distribution_Exemplar.toAmino(e) : undefined); + } else { + obj.exemplars = message.exemplars; + } + return obj; + }, + fromAminoMsg(object: DistributionAminoMsg): Distribution { + return Distribution.fromAmino(object.value); + }, + fromProtoMsg(message: DistributionProtoMsg): Distribution { + return Distribution.decode(message.value); + }, + toProto(message: Distribution): Uint8Array { + return Distribution.encode(message).finish(); + }, + toProtoMsg(message: Distribution): DistributionProtoMsg { + return { + typeUrl: "/google.api.Distribution", + value: Distribution.encode(message).finish() + }; + } +}; +function createBaseDistribution_Range(): Distribution_Range { + return { + min: 0, + max: 0 + }; +} +export const Distribution_Range = { + typeUrl: "/google.api.Range", + encode(message: Distribution_Range, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.min !== undefined) { + writer.uint32(9).double(message.min); + } + if (message.max !== undefined) { + writer.uint32(17).double(message.max); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Distribution_Range { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDistribution_Range(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.min = reader.double(); + break; + case 2: + message.max = reader.double(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Distribution_Range { + const obj = createBaseDistribution_Range(); + if (isSet(object.min)) obj.min = Number(object.min); + if (isSet(object.max)) obj.max = Number(object.max); + return obj; + }, + toJSON(message: Distribution_Range): JsonSafe { + const obj: any = {}; + message.min !== undefined && (obj.min = message.min); + message.max !== undefined && (obj.max = message.max); + return obj; + }, + fromPartial(object: DeepPartial): Distribution_Range { + const message = createBaseDistribution_Range(); + message.min = object.min ?? 0; + message.max = object.max ?? 0; + return message; + }, + fromSDK(object: Distribution_RangeSDKType): Distribution_Range { + return { + min: object?.min, + max: object?.max + }; + }, + fromSDKJSON(object: any): Distribution_RangeSDKType { + return { + min: isSet(object.min) ? Number(object.min) : 0, + max: isSet(object.max) ? Number(object.max) : 0 + }; + }, + toSDK(message: Distribution_Range): Distribution_RangeSDKType { + const obj: any = {}; + obj.min = message.min; + obj.max = message.max; + return obj; + }, + fromAmino(object: Distribution_RangeAmino): Distribution_Range { + const message = createBaseDistribution_Range(); + if (object.min !== undefined && object.min !== null) { + message.min = object.min; + } + if (object.max !== undefined && object.max !== null) { + message.max = object.max; + } + return message; + }, + toAmino(message: Distribution_Range): Distribution_RangeAmino { + const obj: any = {}; + obj.min = message.min === 0 ? undefined : message.min; + obj.max = message.max === 0 ? undefined : message.max; + return obj; + }, + fromAminoMsg(object: Distribution_RangeAminoMsg): Distribution_Range { + return Distribution_Range.fromAmino(object.value); + }, + fromProtoMsg(message: Distribution_RangeProtoMsg): Distribution_Range { + return Distribution_Range.decode(message.value); + }, + toProto(message: Distribution_Range): Uint8Array { + return Distribution_Range.encode(message).finish(); + }, + toProtoMsg(message: Distribution_Range): Distribution_RangeProtoMsg { + return { + typeUrl: "/google.api.Range", + value: Distribution_Range.encode(message).finish() + }; + } +}; +function createBaseDistribution_BucketOptions(): Distribution_BucketOptions { + return { + linearBuckets: undefined, + exponentialBuckets: undefined, + explicitBuckets: undefined + }; +} +export const Distribution_BucketOptions = { + typeUrl: "/google.api.BucketOptions", + encode(message: Distribution_BucketOptions, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.linearBuckets !== undefined) { + Distribution_BucketOptions_Linear.encode(message.linearBuckets, writer.uint32(10).fork()).ldelim(); + } + if (message.exponentialBuckets !== undefined) { + Distribution_BucketOptions_Exponential.encode(message.exponentialBuckets, writer.uint32(18).fork()).ldelim(); + } + if (message.explicitBuckets !== undefined) { + Distribution_BucketOptions_Explicit.encode(message.explicitBuckets, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Distribution_BucketOptions { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDistribution_BucketOptions(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.linearBuckets = Distribution_BucketOptions_Linear.decode(reader, reader.uint32()); + break; + case 2: + message.exponentialBuckets = Distribution_BucketOptions_Exponential.decode(reader, reader.uint32()); + break; + case 3: + message.explicitBuckets = Distribution_BucketOptions_Explicit.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Distribution_BucketOptions { + const obj = createBaseDistribution_BucketOptions(); + if (isSet(object.linearBuckets)) obj.linearBuckets = Distribution_BucketOptions_Linear.fromJSON(object.linearBuckets); + if (isSet(object.exponentialBuckets)) obj.exponentialBuckets = Distribution_BucketOptions_Exponential.fromJSON(object.exponentialBuckets); + if (isSet(object.explicitBuckets)) obj.explicitBuckets = Distribution_BucketOptions_Explicit.fromJSON(object.explicitBuckets); + return obj; + }, + toJSON(message: Distribution_BucketOptions): JsonSafe { + const obj: any = {}; + message.linearBuckets !== undefined && (obj.linearBuckets = message.linearBuckets ? Distribution_BucketOptions_Linear.toJSON(message.linearBuckets) : undefined); + message.exponentialBuckets !== undefined && (obj.exponentialBuckets = message.exponentialBuckets ? Distribution_BucketOptions_Exponential.toJSON(message.exponentialBuckets) : undefined); + message.explicitBuckets !== undefined && (obj.explicitBuckets = message.explicitBuckets ? Distribution_BucketOptions_Explicit.toJSON(message.explicitBuckets) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): Distribution_BucketOptions { + const message = createBaseDistribution_BucketOptions(); + if (object.linearBuckets !== undefined && object.linearBuckets !== null) { + message.linearBuckets = Distribution_BucketOptions_Linear.fromPartial(object.linearBuckets); + } + if (object.exponentialBuckets !== undefined && object.exponentialBuckets !== null) { + message.exponentialBuckets = Distribution_BucketOptions_Exponential.fromPartial(object.exponentialBuckets); + } + if (object.explicitBuckets !== undefined && object.explicitBuckets !== null) { + message.explicitBuckets = Distribution_BucketOptions_Explicit.fromPartial(object.explicitBuckets); + } + return message; + }, + fromSDK(object: Distribution_BucketOptionsSDKType): Distribution_BucketOptions { + return { + linearBuckets: object.linear_buckets ? Distribution_BucketOptions_Linear.fromSDK(object.linear_buckets) : undefined, + exponentialBuckets: object.exponential_buckets ? Distribution_BucketOptions_Exponential.fromSDK(object.exponential_buckets) : undefined, + explicitBuckets: object.explicit_buckets ? Distribution_BucketOptions_Explicit.fromSDK(object.explicit_buckets) : undefined + }; + }, + fromSDKJSON(object: any): Distribution_BucketOptionsSDKType { + return { + linear_buckets: isSet(object.linear_buckets) ? Distribution_BucketOptions_Linear.fromSDKJSON(object.linear_buckets) : undefined, + exponential_buckets: isSet(object.exponential_buckets) ? Distribution_BucketOptions_Exponential.fromSDKJSON(object.exponential_buckets) : undefined, + explicit_buckets: isSet(object.explicit_buckets) ? Distribution_BucketOptions_Explicit.fromSDKJSON(object.explicit_buckets) : undefined + }; + }, + toSDK(message: Distribution_BucketOptions): Distribution_BucketOptionsSDKType { + const obj: any = {}; + message.linearBuckets !== undefined && (obj.linear_buckets = message.linearBuckets ? Distribution_BucketOptions_Linear.toSDK(message.linearBuckets) : undefined); + message.exponentialBuckets !== undefined && (obj.exponential_buckets = message.exponentialBuckets ? Distribution_BucketOptions_Exponential.toSDK(message.exponentialBuckets) : undefined); + message.explicitBuckets !== undefined && (obj.explicit_buckets = message.explicitBuckets ? Distribution_BucketOptions_Explicit.toSDK(message.explicitBuckets) : undefined); + return obj; + }, + fromAmino(object: Distribution_BucketOptionsAmino): Distribution_BucketOptions { + const message = createBaseDistribution_BucketOptions(); + if (object.linear_buckets !== undefined && object.linear_buckets !== null) { + message.linearBuckets = Distribution_BucketOptions_Linear.fromAmino(object.linear_buckets); + } + if (object.exponential_buckets !== undefined && object.exponential_buckets !== null) { + message.exponentialBuckets = Distribution_BucketOptions_Exponential.fromAmino(object.exponential_buckets); + } + if (object.explicit_buckets !== undefined && object.explicit_buckets !== null) { + message.explicitBuckets = Distribution_BucketOptions_Explicit.fromAmino(object.explicit_buckets); + } + return message; + }, + toAmino(message: Distribution_BucketOptions): Distribution_BucketOptionsAmino { + const obj: any = {}; + obj.linear_buckets = message.linearBuckets ? Distribution_BucketOptions_Linear.toAmino(message.linearBuckets) : undefined; + obj.exponential_buckets = message.exponentialBuckets ? Distribution_BucketOptions_Exponential.toAmino(message.exponentialBuckets) : undefined; + obj.explicit_buckets = message.explicitBuckets ? Distribution_BucketOptions_Explicit.toAmino(message.explicitBuckets) : undefined; + return obj; + }, + fromAminoMsg(object: Distribution_BucketOptionsAminoMsg): Distribution_BucketOptions { + return Distribution_BucketOptions.fromAmino(object.value); + }, + fromProtoMsg(message: Distribution_BucketOptionsProtoMsg): Distribution_BucketOptions { + return Distribution_BucketOptions.decode(message.value); + }, + toProto(message: Distribution_BucketOptions): Uint8Array { + return Distribution_BucketOptions.encode(message).finish(); + }, + toProtoMsg(message: Distribution_BucketOptions): Distribution_BucketOptionsProtoMsg { + return { + typeUrl: "/google.api.BucketOptions", + value: Distribution_BucketOptions.encode(message).finish() + }; + } +}; +function createBaseDistribution_BucketOptions_Linear(): Distribution_BucketOptions_Linear { + return { + numFiniteBuckets: 0, + width: 0, + offset: 0 + }; +} +export const Distribution_BucketOptions_Linear = { + typeUrl: "/google.api.Linear", + encode(message: Distribution_BucketOptions_Linear, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.numFiniteBuckets !== undefined) { + writer.uint32(8).int32(message.numFiniteBuckets); + } + if (message.width !== undefined) { + writer.uint32(17).double(message.width); + } + if (message.offset !== undefined) { + writer.uint32(25).double(message.offset); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Distribution_BucketOptions_Linear { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDistribution_BucketOptions_Linear(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.numFiniteBuckets = reader.int32(); + break; + case 2: + message.width = reader.double(); + break; + case 3: + message.offset = reader.double(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Distribution_BucketOptions_Linear { + const obj = createBaseDistribution_BucketOptions_Linear(); + if (isSet(object.numFiniteBuckets)) obj.numFiniteBuckets = Number(object.numFiniteBuckets); + if (isSet(object.width)) obj.width = Number(object.width); + if (isSet(object.offset)) obj.offset = Number(object.offset); + return obj; + }, + toJSON(message: Distribution_BucketOptions_Linear): JsonSafe { + const obj: any = {}; + message.numFiniteBuckets !== undefined && (obj.numFiniteBuckets = Math.round(message.numFiniteBuckets)); + message.width !== undefined && (obj.width = message.width); + message.offset !== undefined && (obj.offset = message.offset); + return obj; + }, + fromPartial(object: DeepPartial): Distribution_BucketOptions_Linear { + const message = createBaseDistribution_BucketOptions_Linear(); + message.numFiniteBuckets = object.numFiniteBuckets ?? 0; + message.width = object.width ?? 0; + message.offset = object.offset ?? 0; + return message; + }, + fromSDK(object: Distribution_BucketOptions_LinearSDKType): Distribution_BucketOptions_Linear { + return { + numFiniteBuckets: object?.num_finite_buckets, + width: object?.width, + offset: object?.offset + }; + }, + fromSDKJSON(object: any): Distribution_BucketOptions_LinearSDKType { + return { + num_finite_buckets: isSet(object.num_finite_buckets) ? Number(object.num_finite_buckets) : 0, + width: isSet(object.width) ? Number(object.width) : 0, + offset: isSet(object.offset) ? Number(object.offset) : 0 + }; + }, + toSDK(message: Distribution_BucketOptions_Linear): Distribution_BucketOptions_LinearSDKType { + const obj: any = {}; + obj.num_finite_buckets = message.numFiniteBuckets; + obj.width = message.width; + obj.offset = message.offset; + return obj; + }, + fromAmino(object: Distribution_BucketOptions_LinearAmino): Distribution_BucketOptions_Linear { + const message = createBaseDistribution_BucketOptions_Linear(); + if (object.num_finite_buckets !== undefined && object.num_finite_buckets !== null) { + message.numFiniteBuckets = object.num_finite_buckets; + } + if (object.width !== undefined && object.width !== null) { + message.width = object.width; + } + if (object.offset !== undefined && object.offset !== null) { + message.offset = object.offset; + } + return message; + }, + toAmino(message: Distribution_BucketOptions_Linear): Distribution_BucketOptions_LinearAmino { + const obj: any = {}; + obj.num_finite_buckets = message.numFiniteBuckets === 0 ? undefined : message.numFiniteBuckets; + obj.width = message.width === 0 ? undefined : message.width; + obj.offset = message.offset === 0 ? undefined : message.offset; + return obj; + }, + fromAminoMsg(object: Distribution_BucketOptions_LinearAminoMsg): Distribution_BucketOptions_Linear { + return Distribution_BucketOptions_Linear.fromAmino(object.value); + }, + fromProtoMsg(message: Distribution_BucketOptions_LinearProtoMsg): Distribution_BucketOptions_Linear { + return Distribution_BucketOptions_Linear.decode(message.value); + }, + toProto(message: Distribution_BucketOptions_Linear): Uint8Array { + return Distribution_BucketOptions_Linear.encode(message).finish(); + }, + toProtoMsg(message: Distribution_BucketOptions_Linear): Distribution_BucketOptions_LinearProtoMsg { + return { + typeUrl: "/google.api.Linear", + value: Distribution_BucketOptions_Linear.encode(message).finish() + }; + } +}; +function createBaseDistribution_BucketOptions_Exponential(): Distribution_BucketOptions_Exponential { + return { + numFiniteBuckets: 0, + growthFactor: 0, + scale: 0 + }; +} +export const Distribution_BucketOptions_Exponential = { + typeUrl: "/google.api.Exponential", + encode(message: Distribution_BucketOptions_Exponential, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.numFiniteBuckets !== undefined) { + writer.uint32(8).int32(message.numFiniteBuckets); + } + if (message.growthFactor !== undefined) { + writer.uint32(17).double(message.growthFactor); + } + if (message.scale !== undefined) { + writer.uint32(25).double(message.scale); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Distribution_BucketOptions_Exponential { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDistribution_BucketOptions_Exponential(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.numFiniteBuckets = reader.int32(); + break; + case 2: + message.growthFactor = reader.double(); + break; + case 3: + message.scale = reader.double(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Distribution_BucketOptions_Exponential { + const obj = createBaseDistribution_BucketOptions_Exponential(); + if (isSet(object.numFiniteBuckets)) obj.numFiniteBuckets = Number(object.numFiniteBuckets); + if (isSet(object.growthFactor)) obj.growthFactor = Number(object.growthFactor); + if (isSet(object.scale)) obj.scale = Number(object.scale); + return obj; + }, + toJSON(message: Distribution_BucketOptions_Exponential): JsonSafe { + const obj: any = {}; + message.numFiniteBuckets !== undefined && (obj.numFiniteBuckets = Math.round(message.numFiniteBuckets)); + message.growthFactor !== undefined && (obj.growthFactor = message.growthFactor); + message.scale !== undefined && (obj.scale = message.scale); + return obj; + }, + fromPartial(object: DeepPartial): Distribution_BucketOptions_Exponential { + const message = createBaseDistribution_BucketOptions_Exponential(); + message.numFiniteBuckets = object.numFiniteBuckets ?? 0; + message.growthFactor = object.growthFactor ?? 0; + message.scale = object.scale ?? 0; + return message; + }, + fromSDK(object: Distribution_BucketOptions_ExponentialSDKType): Distribution_BucketOptions_Exponential { + return { + numFiniteBuckets: object?.num_finite_buckets, + growthFactor: object?.growth_factor, + scale: object?.scale + }; + }, + fromSDKJSON(object: any): Distribution_BucketOptions_ExponentialSDKType { + return { + num_finite_buckets: isSet(object.num_finite_buckets) ? Number(object.num_finite_buckets) : 0, + growth_factor: isSet(object.growth_factor) ? Number(object.growth_factor) : 0, + scale: isSet(object.scale) ? Number(object.scale) : 0 + }; + }, + toSDK(message: Distribution_BucketOptions_Exponential): Distribution_BucketOptions_ExponentialSDKType { + const obj: any = {}; + obj.num_finite_buckets = message.numFiniteBuckets; + obj.growth_factor = message.growthFactor; + obj.scale = message.scale; + return obj; + }, + fromAmino(object: Distribution_BucketOptions_ExponentialAmino): Distribution_BucketOptions_Exponential { + const message = createBaseDistribution_BucketOptions_Exponential(); + if (object.num_finite_buckets !== undefined && object.num_finite_buckets !== null) { + message.numFiniteBuckets = object.num_finite_buckets; + } + if (object.growth_factor !== undefined && object.growth_factor !== null) { + message.growthFactor = object.growth_factor; + } + if (object.scale !== undefined && object.scale !== null) { + message.scale = object.scale; + } + return message; + }, + toAmino(message: Distribution_BucketOptions_Exponential): Distribution_BucketOptions_ExponentialAmino { + const obj: any = {}; + obj.num_finite_buckets = message.numFiniteBuckets === 0 ? undefined : message.numFiniteBuckets; + obj.growth_factor = message.growthFactor === 0 ? undefined : message.growthFactor; + obj.scale = message.scale === 0 ? undefined : message.scale; + return obj; + }, + fromAminoMsg(object: Distribution_BucketOptions_ExponentialAminoMsg): Distribution_BucketOptions_Exponential { + return Distribution_BucketOptions_Exponential.fromAmino(object.value); + }, + fromProtoMsg(message: Distribution_BucketOptions_ExponentialProtoMsg): Distribution_BucketOptions_Exponential { + return Distribution_BucketOptions_Exponential.decode(message.value); + }, + toProto(message: Distribution_BucketOptions_Exponential): Uint8Array { + return Distribution_BucketOptions_Exponential.encode(message).finish(); + }, + toProtoMsg(message: Distribution_BucketOptions_Exponential): Distribution_BucketOptions_ExponentialProtoMsg { + return { + typeUrl: "/google.api.Exponential", + value: Distribution_BucketOptions_Exponential.encode(message).finish() + }; + } +}; +function createBaseDistribution_BucketOptions_Explicit(): Distribution_BucketOptions_Explicit { + return { + bounds: [] + }; +} +export const Distribution_BucketOptions_Explicit = { + typeUrl: "/google.api.Explicit", + encode(message: Distribution_BucketOptions_Explicit, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + writer.uint32(10).fork(); + for (const v of message.bounds) { + writer.double(v); + } + writer.ldelim(); + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Distribution_BucketOptions_Explicit { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDistribution_BucketOptions_Explicit(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.bounds.push(reader.double()); + } + } else { + message.bounds.push(reader.double()); + } + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Distribution_BucketOptions_Explicit { + const obj = createBaseDistribution_BucketOptions_Explicit(); + if (Array.isArray(object?.bounds)) obj.bounds = object.bounds.map((e: any) => Number(e)); + return obj; + }, + toJSON(message: Distribution_BucketOptions_Explicit): JsonSafe { + const obj: any = {}; + if (message.bounds) { + obj.bounds = message.bounds.map(e => e); + } else { + obj.bounds = []; + } + return obj; + }, + fromPartial(object: DeepPartial): Distribution_BucketOptions_Explicit { + const message = createBaseDistribution_BucketOptions_Explicit(); + message.bounds = object.bounds?.map(e => e) || []; + return message; + }, + fromSDK(object: Distribution_BucketOptions_ExplicitSDKType): Distribution_BucketOptions_Explicit { + return { + bounds: Array.isArray(object?.bounds) ? object.bounds.map((e: any) => e) : [] + }; + }, + fromSDKJSON(object: any): Distribution_BucketOptions_ExplicitSDKType { + return { + bounds: Array.isArray(object?.bounds) ? object.bounds.map((e: any) => Number(e)) : [] + }; + }, + toSDK(message: Distribution_BucketOptions_Explicit): Distribution_BucketOptions_ExplicitSDKType { + const obj: any = {}; + if (message.bounds) { + obj.bounds = message.bounds.map(e => e); + } else { + obj.bounds = []; + } + return obj; + }, + fromAmino(object: Distribution_BucketOptions_ExplicitAmino): Distribution_BucketOptions_Explicit { + const message = createBaseDistribution_BucketOptions_Explicit(); + message.bounds = object.bounds?.map(e => e) || []; + return message; + }, + toAmino(message: Distribution_BucketOptions_Explicit): Distribution_BucketOptions_ExplicitAmino { + const obj: any = {}; + if (message.bounds) { + obj.bounds = message.bounds.map(e => e); + } else { + obj.bounds = message.bounds; + } + return obj; + }, + fromAminoMsg(object: Distribution_BucketOptions_ExplicitAminoMsg): Distribution_BucketOptions_Explicit { + return Distribution_BucketOptions_Explicit.fromAmino(object.value); + }, + fromProtoMsg(message: Distribution_BucketOptions_ExplicitProtoMsg): Distribution_BucketOptions_Explicit { + return Distribution_BucketOptions_Explicit.decode(message.value); + }, + toProto(message: Distribution_BucketOptions_Explicit): Uint8Array { + return Distribution_BucketOptions_Explicit.encode(message).finish(); + }, + toProtoMsg(message: Distribution_BucketOptions_Explicit): Distribution_BucketOptions_ExplicitProtoMsg { + return { + typeUrl: "/google.api.Explicit", + value: Distribution_BucketOptions_Explicit.encode(message).finish() + }; + } +}; +function createBaseDistribution_Exemplar(): Distribution_Exemplar { + return { + value: 0, + timestamp: undefined, + attachments: [] + }; +} +export const Distribution_Exemplar = { + typeUrl: "/google.api.Exemplar", + encode(message: Distribution_Exemplar, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.value !== undefined) { + writer.uint32(9).double(message.value); + } + if (message.timestamp !== undefined) { + Timestamp.encode(toTimestamp(message.timestamp), writer.uint32(18).fork()).ldelim(); + } + for (const v of message.attachments) { + Any.encode(v!, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Distribution_Exemplar { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDistribution_Exemplar(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.value = reader.double(); + break; + case 2: + message.timestamp = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + break; + case 3: + message.attachments.push(Any.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Distribution_Exemplar { + const obj = createBaseDistribution_Exemplar(); + if (isSet(object.value)) obj.value = Number(object.value); + if (isSet(object.timestamp)) obj.timestamp = new Date(object.timestamp); + if (Array.isArray(object?.attachments)) obj.attachments = object.attachments.map((e: any) => Any.fromJSON(e)); + return obj; + }, + toJSON(message: Distribution_Exemplar): JsonSafe { + const obj: any = {}; + message.value !== undefined && (obj.value = message.value); + message.timestamp !== undefined && (obj.timestamp = message.timestamp.toISOString()); + if (message.attachments) { + obj.attachments = message.attachments.map(e => e ? Any.toJSON(e) : undefined); + } else { + obj.attachments = []; + } + return obj; + }, + fromPartial(object: DeepPartial): Distribution_Exemplar { + const message = createBaseDistribution_Exemplar(); + message.value = object.value ?? 0; + message.timestamp = object.timestamp ?? undefined; + message.attachments = object.attachments?.map(e => Any.fromPartial(e)) || []; + return message; + }, + fromSDK(object: Distribution_ExemplarSDKType): Distribution_Exemplar { + return { + value: object?.value, + timestamp: object.timestamp ?? undefined, + attachments: Array.isArray(object?.attachments) ? object.attachments.map((e: any) => Any.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): Distribution_ExemplarSDKType { + return { + value: isSet(object.value) ? Number(object.value) : 0, + timestamp: isSet(object.timestamp) ? new Date(object.timestamp) : undefined, + attachments: Array.isArray(object?.attachments) ? object.attachments.map((e: any) => Any.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: Distribution_Exemplar): Distribution_ExemplarSDKType { + const obj: any = {}; + obj.value = message.value; + message.timestamp !== undefined && (obj.timestamp = message.timestamp ?? undefined); + if (message.attachments) { + obj.attachments = message.attachments.map(e => e ? Any.toSDK(e) : undefined); + } else { + obj.attachments = []; + } + return obj; + }, + fromAmino(object: Distribution_ExemplarAmino): Distribution_Exemplar { + const message = createBaseDistribution_Exemplar(); + if (object.value !== undefined && object.value !== null) { + message.value = object.value; + } + if (object.timestamp !== undefined && object.timestamp !== null) { + message.timestamp = fromTimestamp(Timestamp.fromAmino(object.timestamp)); + } + message.attachments = object.attachments?.map(e => Any.fromAmino(e)) || []; + return message; + }, + toAmino(message: Distribution_Exemplar): Distribution_ExemplarAmino { + const obj: any = {}; + obj.value = message.value === 0 ? undefined : message.value; + obj.timestamp = message.timestamp ? Timestamp.toAmino(toTimestamp(message.timestamp)) : undefined; + if (message.attachments) { + obj.attachments = message.attachments.map(e => e ? Any.toAmino(e) : undefined); + } else { + obj.attachments = message.attachments; + } + return obj; + }, + fromAminoMsg(object: Distribution_ExemplarAminoMsg): Distribution_Exemplar { + return Distribution_Exemplar.fromAmino(object.value); + }, + fromProtoMsg(message: Distribution_ExemplarProtoMsg): Distribution_Exemplar { + return Distribution_Exemplar.decode(message.value); + }, + toProto(message: Distribution_Exemplar): Uint8Array { + return Distribution_Exemplar.encode(message).finish(); + }, + toProtoMsg(message: Distribution_Exemplar): Distribution_ExemplarProtoMsg { + return { + typeUrl: "/google.api.Exemplar", + value: Distribution_Exemplar.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/api/documentation.ts b/__fixtures__/v-next/outputicjsdeps/google/api/documentation.ts new file mode 100644 index 0000000000..ac7891c63e --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/api/documentation.ts @@ -0,0 +1,692 @@ +import { BinaryReader, BinaryWriter } from "../../binary.js"; +import { isSet, DeepPartial } from "../../helpers.js"; +import { JsonSafe } from "../../json-safe.js"; +export const protobufPackage = "google.api"; +/** + * `Documentation` provides the information for describing a service. + * + * Example: + *
documentation:
+ *   summary: >
+ *     The Google Calendar API gives access
+ *     to most calendar features.
+ *   pages:
+ *   - name: Overview
+ *     content: (== include google/foo/overview.md ==)
+ *   - name: Tutorial
+ *     content: (== include google/foo/tutorial.md ==)
+ *     subpages;
+ *     - name: Java
+ *       content: (== include google/foo/tutorial_java.md ==)
+ *   rules:
+ *   - selector: google.calendar.Calendar.Get
+ *     description: >
+ *       ...
+ *   - selector: google.calendar.Calendar.Put
+ *     description: >
+ *       ...
+ * 
+ * Documentation is provided in markdown syntax. In addition to + * standard markdown features, definition lists, tables and fenced + * code blocks are supported. Section headers can be provided and are + * interpreted relative to the section nesting of the context where + * a documentation fragment is embedded. + * + * Documentation from the IDL is merged with documentation defined + * via the config at normalization time, where documentation provided + * by config rules overrides IDL provided. + * + * A number of constructs specific to the API platform are supported + * in documentation text. + * + * In order to reference a proto element, the following + * notation can be used: + *
[fully.qualified.proto.name][]
+ * To override the display text used for the link, this can be used: + *
[display text][fully.qualified.proto.name]
+ * Text can be excluded from doc using the following notation: + *
(-- internal comment --)
+ * + * A few directives are available in documentation. Note that + * directives must appear on a single line to be properly + * identified. The `include` directive includes a markdown file from + * an external source: + *
(== include path/to/file ==)
+ * The `resource_for` directive marks a message to be the resource of + * a collection in REST view. If it is not specified, tools attempt + * to infer the resource from the operations in a collection: + *
(== resource_for v1.shelves.books ==)
+ * The directive `suppress_warning` does not directly affect documentation + * and is documented together with service config validation. + */ +export interface Documentation { + /** + * A short summary of what the service does. Can only be provided by + * plain text. + */ + summary: string; + /** The top level pages for the documentation set. */ + pages: Page[]; + /** + * A list of documentation rules that apply to individual API elements. + * + * **NOTE:** All service configuration rules follow "last one wins" order. + */ + rules: DocumentationRule[]; + /** The URL to the root of documentation. */ + documentationRootUrl: string; + /** + * Specifies the service root url if the default one (the service name + * from the yaml file) is not suitable. This can be seen in any fully + * specified service urls as well as sections that show a base that other + * urls are relative to. + */ + serviceRootUrl: string; + /** + * Declares a single overview page. For example: + *
documentation:
+   *   summary: ...
+   *   overview: (== include overview.md ==)
+   * 
+ * This is a shortcut for the following declaration (using pages style): + *
documentation:
+   *   summary: ...
+   *   pages:
+   *   - name: Overview
+   *     content: (== include overview.md ==)
+   * 
+ * Note: you cannot specify both `overview` field and `pages` field. + */ + overview: string; +} +export interface DocumentationProtoMsg { + typeUrl: "/google.api.Documentation"; + value: Uint8Array; +} +/** + * `Documentation` provides the information for describing a service. + * + * Example: + *
documentation:
+ *   summary: >
+ *     The Google Calendar API gives access
+ *     to most calendar features.
+ *   pages:
+ *   - name: Overview
+ *     content: (== include google/foo/overview.md ==)
+ *   - name: Tutorial
+ *     content: (== include google/foo/tutorial.md ==)
+ *     subpages;
+ *     - name: Java
+ *       content: (== include google/foo/tutorial_java.md ==)
+ *   rules:
+ *   - selector: google.calendar.Calendar.Get
+ *     description: >
+ *       ...
+ *   - selector: google.calendar.Calendar.Put
+ *     description: >
+ *       ...
+ * 
+ * Documentation is provided in markdown syntax. In addition to + * standard markdown features, definition lists, tables and fenced + * code blocks are supported. Section headers can be provided and are + * interpreted relative to the section nesting of the context where + * a documentation fragment is embedded. + * + * Documentation from the IDL is merged with documentation defined + * via the config at normalization time, where documentation provided + * by config rules overrides IDL provided. + * + * A number of constructs specific to the API platform are supported + * in documentation text. + * + * In order to reference a proto element, the following + * notation can be used: + *
[fully.qualified.proto.name][]
+ * To override the display text used for the link, this can be used: + *
[display text][fully.qualified.proto.name]
+ * Text can be excluded from doc using the following notation: + *
(-- internal comment --)
+ * + * A few directives are available in documentation. Note that + * directives must appear on a single line to be properly + * identified. The `include` directive includes a markdown file from + * an external source: + *
(== include path/to/file ==)
+ * The `resource_for` directive marks a message to be the resource of + * a collection in REST view. If it is not specified, tools attempt + * to infer the resource from the operations in a collection: + *
(== resource_for v1.shelves.books ==)
+ * The directive `suppress_warning` does not directly affect documentation + * and is documented together with service config validation. + */ +export interface DocumentationSDKType { + summary: string; + pages: PageSDKType[]; + rules: DocumentationRuleSDKType[]; + documentation_root_url: string; + service_root_url: string; + overview: string; +} +/** A documentation rule provides information about individual API elements. */ +export interface DocumentationRule { + /** + * The selector is a comma-separated list of patterns. Each pattern is a + * qualified name of the element which may end in "*", indicating a wildcard. + * Wildcards are only allowed at the end and for a whole component of the + * qualified name, i.e. "foo.*" is ok, but not "foo.b*" or "foo.*.bar". A + * wildcard will match one or more components. To specify a default for all + * applicable elements, the whole pattern "*" is used. + */ + selector: string; + /** Description of the selected API(s). */ + description: string; + /** + * Deprecation description of the selected element(s). It can be provided if + * an element is marked as `deprecated`. + */ + deprecationDescription: string; +} +export interface DocumentationRuleProtoMsg { + typeUrl: "/google.api.DocumentationRule"; + value: Uint8Array; +} +/** A documentation rule provides information about individual API elements. */ +export interface DocumentationRuleSDKType { + selector: string; + description: string; + deprecation_description: string; +} +/** + * Represents a documentation page. A page can contain subpages to represent + * nested documentation set structure. + */ +export interface Page { + /** + * The name of the page. It will be used as an identity of the page to + * generate URI of the page, text of the link to this page in navigation, + * etc. The full page name (start from the root page name to this page + * concatenated with `.`) can be used as reference to the page in your + * documentation. For example: + *
pages:
+   * - name: Tutorial
+   *   content: (== include tutorial.md ==)
+   *   subpages:
+   *   - name: Java
+   *     content: (== include tutorial_java.md ==)
+   * 
+ * You can reference `Java` page using Markdown reference link syntax: + * `[Java][Tutorial.Java]`. + */ + name: string; + /** + * The Markdown content of the page. You can use (== include {path} + * ==) to include content from a Markdown file. + */ + content: string; + /** + * Subpages of this page. The order of subpages specified here will be + * honored in the generated docset. + */ + subpages: Page[]; +} +export interface PageProtoMsg { + typeUrl: "/google.api.Page"; + value: Uint8Array; +} +/** + * Represents a documentation page. A page can contain subpages to represent + * nested documentation set structure. + */ +export interface PageSDKType { + name: string; + content: string; + subpages: PageSDKType[]; +} +function createBaseDocumentation(): Documentation { + return { + summary: "", + pages: [], + rules: [], + documentationRootUrl: "", + serviceRootUrl: "", + overview: "" + }; +} +export const Documentation = { + typeUrl: "/google.api.Documentation", + encode(message: Documentation, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.summary !== undefined) { + writer.uint32(10).string(message.summary); + } + for (const v of message.pages) { + Page.encode(v!, writer.uint32(42).fork()).ldelim(); + } + for (const v of message.rules) { + DocumentationRule.encode(v!, writer.uint32(26).fork()).ldelim(); + } + if (message.documentationRootUrl !== undefined) { + writer.uint32(34).string(message.documentationRootUrl); + } + if (message.serviceRootUrl !== undefined) { + writer.uint32(50).string(message.serviceRootUrl); + } + if (message.overview !== undefined) { + writer.uint32(18).string(message.overview); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Documentation { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDocumentation(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.summary = reader.string(); + break; + case 5: + message.pages.push(Page.decode(reader, reader.uint32())); + break; + case 3: + message.rules.push(DocumentationRule.decode(reader, reader.uint32())); + break; + case 4: + message.documentationRootUrl = reader.string(); + break; + case 6: + message.serviceRootUrl = reader.string(); + break; + case 2: + message.overview = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Documentation { + const obj = createBaseDocumentation(); + if (isSet(object.summary)) obj.summary = String(object.summary); + if (Array.isArray(object?.pages)) obj.pages = object.pages.map((e: any) => Page.fromJSON(e)); + if (Array.isArray(object?.rules)) obj.rules = object.rules.map((e: any) => DocumentationRule.fromJSON(e)); + if (isSet(object.documentationRootUrl)) obj.documentationRootUrl = String(object.documentationRootUrl); + if (isSet(object.serviceRootUrl)) obj.serviceRootUrl = String(object.serviceRootUrl); + if (isSet(object.overview)) obj.overview = String(object.overview); + return obj; + }, + toJSON(message: Documentation): JsonSafe { + const obj: any = {}; + message.summary !== undefined && (obj.summary = message.summary); + if (message.pages) { + obj.pages = message.pages.map(e => e ? Page.toJSON(e) : undefined); + } else { + obj.pages = []; + } + if (message.rules) { + obj.rules = message.rules.map(e => e ? DocumentationRule.toJSON(e) : undefined); + } else { + obj.rules = []; + } + message.documentationRootUrl !== undefined && (obj.documentationRootUrl = message.documentationRootUrl); + message.serviceRootUrl !== undefined && (obj.serviceRootUrl = message.serviceRootUrl); + message.overview !== undefined && (obj.overview = message.overview); + return obj; + }, + fromPartial(object: DeepPartial): Documentation { + const message = createBaseDocumentation(); + message.summary = object.summary ?? ""; + message.pages = object.pages?.map(e => Page.fromPartial(e)) || []; + message.rules = object.rules?.map(e => DocumentationRule.fromPartial(e)) || []; + message.documentationRootUrl = object.documentationRootUrl ?? ""; + message.serviceRootUrl = object.serviceRootUrl ?? ""; + message.overview = object.overview ?? ""; + return message; + }, + fromSDK(object: DocumentationSDKType): Documentation { + return { + summary: object?.summary, + pages: Array.isArray(object?.pages) ? object.pages.map((e: any) => Page.fromSDK(e)) : [], + rules: Array.isArray(object?.rules) ? object.rules.map((e: any) => DocumentationRule.fromSDK(e)) : [], + documentationRootUrl: object?.documentation_root_url, + serviceRootUrl: object?.service_root_url, + overview: object?.overview + }; + }, + fromSDKJSON(object: any): DocumentationSDKType { + return { + summary: isSet(object.summary) ? String(object.summary) : "", + pages: Array.isArray(object?.pages) ? object.pages.map((e: any) => Page.fromSDKJSON(e)) : [], + rules: Array.isArray(object?.rules) ? object.rules.map((e: any) => DocumentationRule.fromSDKJSON(e)) : [], + documentation_root_url: isSet(object.documentation_root_url) ? String(object.documentation_root_url) : "", + service_root_url: isSet(object.service_root_url) ? String(object.service_root_url) : "", + overview: isSet(object.overview) ? String(object.overview) : "" + }; + }, + toSDK(message: Documentation): DocumentationSDKType { + const obj: any = {}; + obj.summary = message.summary; + if (message.pages) { + obj.pages = message.pages.map(e => e ? Page.toSDK(e) : undefined); + } else { + obj.pages = []; + } + if (message.rules) { + obj.rules = message.rules.map(e => e ? DocumentationRule.toSDK(e) : undefined); + } else { + obj.rules = []; + } + obj.documentation_root_url = message.documentationRootUrl; + obj.service_root_url = message.serviceRootUrl; + obj.overview = message.overview; + return obj; + }, + fromAmino(object: DocumentationAmino): Documentation { + const message = createBaseDocumentation(); + if (object.summary !== undefined && object.summary !== null) { + message.summary = object.summary; + } + message.pages = object.pages?.map(e => Page.fromAmino(e)) || []; + message.rules = object.rules?.map(e => DocumentationRule.fromAmino(e)) || []; + if (object.documentation_root_url !== undefined && object.documentation_root_url !== null) { + message.documentationRootUrl = object.documentation_root_url; + } + if (object.service_root_url !== undefined && object.service_root_url !== null) { + message.serviceRootUrl = object.service_root_url; + } + if (object.overview !== undefined && object.overview !== null) { + message.overview = object.overview; + } + return message; + }, + toAmino(message: Documentation): DocumentationAmino { + const obj: any = {}; + obj.summary = message.summary === "" ? undefined : message.summary; + if (message.pages) { + obj.pages = message.pages.map(e => e ? Page.toAmino(e) : undefined); + } else { + obj.pages = message.pages; + } + if (message.rules) { + obj.rules = message.rules.map(e => e ? DocumentationRule.toAmino(e) : undefined); + } else { + obj.rules = message.rules; + } + obj.documentation_root_url = message.documentationRootUrl === "" ? undefined : message.documentationRootUrl; + obj.service_root_url = message.serviceRootUrl === "" ? undefined : message.serviceRootUrl; + obj.overview = message.overview === "" ? undefined : message.overview; + return obj; + }, + fromAminoMsg(object: DocumentationAminoMsg): Documentation { + return Documentation.fromAmino(object.value); + }, + fromProtoMsg(message: DocumentationProtoMsg): Documentation { + return Documentation.decode(message.value); + }, + toProto(message: Documentation): Uint8Array { + return Documentation.encode(message).finish(); + }, + toProtoMsg(message: Documentation): DocumentationProtoMsg { + return { + typeUrl: "/google.api.Documentation", + value: Documentation.encode(message).finish() + }; + } +}; +function createBaseDocumentationRule(): DocumentationRule { + return { + selector: "", + description: "", + deprecationDescription: "" + }; +} +export const DocumentationRule = { + typeUrl: "/google.api.DocumentationRule", + encode(message: DocumentationRule, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.selector !== undefined) { + writer.uint32(10).string(message.selector); + } + if (message.description !== undefined) { + writer.uint32(18).string(message.description); + } + if (message.deprecationDescription !== undefined) { + writer.uint32(26).string(message.deprecationDescription); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): DocumentationRule { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDocumentationRule(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.selector = reader.string(); + break; + case 2: + message.description = reader.string(); + break; + case 3: + message.deprecationDescription = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): DocumentationRule { + const obj = createBaseDocumentationRule(); + if (isSet(object.selector)) obj.selector = String(object.selector); + if (isSet(object.description)) obj.description = String(object.description); + if (isSet(object.deprecationDescription)) obj.deprecationDescription = String(object.deprecationDescription); + return obj; + }, + toJSON(message: DocumentationRule): JsonSafe { + const obj: any = {}; + message.selector !== undefined && (obj.selector = message.selector); + message.description !== undefined && (obj.description = message.description); + message.deprecationDescription !== undefined && (obj.deprecationDescription = message.deprecationDescription); + return obj; + }, + fromPartial(object: DeepPartial): DocumentationRule { + const message = createBaseDocumentationRule(); + message.selector = object.selector ?? ""; + message.description = object.description ?? ""; + message.deprecationDescription = object.deprecationDescription ?? ""; + return message; + }, + fromSDK(object: DocumentationRuleSDKType): DocumentationRule { + return { + selector: object?.selector, + description: object?.description, + deprecationDescription: object?.deprecation_description + }; + }, + fromSDKJSON(object: any): DocumentationRuleSDKType { + return { + selector: isSet(object.selector) ? String(object.selector) : "", + description: isSet(object.description) ? String(object.description) : "", + deprecation_description: isSet(object.deprecation_description) ? String(object.deprecation_description) : "" + }; + }, + toSDK(message: DocumentationRule): DocumentationRuleSDKType { + const obj: any = {}; + obj.selector = message.selector; + obj.description = message.description; + obj.deprecation_description = message.deprecationDescription; + return obj; + }, + fromAmino(object: DocumentationRuleAmino): DocumentationRule { + const message = createBaseDocumentationRule(); + if (object.selector !== undefined && object.selector !== null) { + message.selector = object.selector; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } + if (object.deprecation_description !== undefined && object.deprecation_description !== null) { + message.deprecationDescription = object.deprecation_description; + } + return message; + }, + toAmino(message: DocumentationRule): DocumentationRuleAmino { + const obj: any = {}; + obj.selector = message.selector === "" ? undefined : message.selector; + obj.description = message.description === "" ? undefined : message.description; + obj.deprecation_description = message.deprecationDescription === "" ? undefined : message.deprecationDescription; + return obj; + }, + fromAminoMsg(object: DocumentationRuleAminoMsg): DocumentationRule { + return DocumentationRule.fromAmino(object.value); + }, + fromProtoMsg(message: DocumentationRuleProtoMsg): DocumentationRule { + return DocumentationRule.decode(message.value); + }, + toProto(message: DocumentationRule): Uint8Array { + return DocumentationRule.encode(message).finish(); + }, + toProtoMsg(message: DocumentationRule): DocumentationRuleProtoMsg { + return { + typeUrl: "/google.api.DocumentationRule", + value: DocumentationRule.encode(message).finish() + }; + } +}; +function createBasePage(): Page { + return { + name: "", + content: "", + subpages: [] + }; +} +export const Page = { + typeUrl: "/google.api.Page", + encode(message: Page, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + if (message.content !== undefined) { + writer.uint32(18).string(message.content); + } + for (const v of message.subpages) { + Page.encode(v!, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Page { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBasePage(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.content = reader.string(); + break; + case 3: + message.subpages.push(Page.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Page { + const obj = createBasePage(); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.content)) obj.content = String(object.content); + if (Array.isArray(object?.subpages)) obj.subpages = object.subpages.map((e: any) => Page.fromJSON(e)); + return obj; + }, + toJSON(message: Page): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.content !== undefined && (obj.content = message.content); + if (message.subpages) { + obj.subpages = message.subpages.map(e => e ? Page.toJSON(e) : undefined); + } else { + obj.subpages = []; + } + return obj; + }, + fromPartial(object: DeepPartial): Page { + const message = createBasePage(); + message.name = object.name ?? ""; + message.content = object.content ?? ""; + message.subpages = object.subpages?.map(e => Page.fromPartial(e)) || []; + return message; + }, + fromSDK(object: PageSDKType): Page { + return { + name: object?.name, + content: object?.content, + subpages: Array.isArray(object?.subpages) ? object.subpages.map((e: any) => Page.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): PageSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + content: isSet(object.content) ? String(object.content) : "", + subpages: Array.isArray(object?.subpages) ? object.subpages.map((e: any) => Page.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: Page): PageSDKType { + const obj: any = {}; + obj.name = message.name; + obj.content = message.content; + if (message.subpages) { + obj.subpages = message.subpages.map(e => e ? Page.toSDK(e) : undefined); + } else { + obj.subpages = []; + } + return obj; + }, + fromAmino(object: PageAmino): Page { + const message = createBasePage(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + if (object.content !== undefined && object.content !== null) { + message.content = object.content; + } + message.subpages = object.subpages?.map(e => Page.fromAmino(e)) || []; + return message; + }, + toAmino(message: Page): PageAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + obj.content = message.content === "" ? undefined : message.content; + if (message.subpages) { + obj.subpages = message.subpages.map(e => e ? Page.toAmino(e) : undefined); + } else { + obj.subpages = message.subpages; + } + return obj; + }, + fromAminoMsg(object: PageAminoMsg): Page { + return Page.fromAmino(object.value); + }, + fromProtoMsg(message: PageProtoMsg): Page { + return Page.decode(message.value); + }, + toProto(message: Page): Uint8Array { + return Page.encode(message).finish(); + }, + toProtoMsg(message: Page): PageProtoMsg { + return { + typeUrl: "/google.api.Page", + value: Page.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/api/endpoint.ts b/__fixtures__/v-next/outputicjsdeps/google/api/endpoint.ts new file mode 100644 index 0000000000..df0ef1e71e --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/api/endpoint.ts @@ -0,0 +1,232 @@ +import { BinaryReader, BinaryWriter } from "../../binary.js"; +import { isSet, DeepPartial } from "../../helpers.js"; +import { JsonSafe } from "../../json-safe.js"; +export const protobufPackage = "google.api"; +/** + * `Endpoint` describes a network endpoint of a service that serves a set of + * APIs. It is commonly known as a service endpoint. A service may expose + * any number of service endpoints, and all service endpoints share the same + * service definition, such as quota limits and monitoring metrics. + * + * Example service configuration: + * + * name: library-example.googleapis.com + * endpoints: + * # Below entry makes 'google.example.library.v1.Library' + * # API be served from endpoint address library-example.googleapis.com. + * # It also allows HTTP OPTIONS calls to be passed to the backend, for + * # it to decide whether the subsequent cross-origin request is + * # allowed to proceed. + * - name: library-example.googleapis.com + * allow_cors: true + */ +export interface Endpoint { + /** The canonical name of this endpoint. */ + name: string; + /** + * Unimplemented. Dot not use. + * + * DEPRECATED: This field is no longer supported. Instead of using aliases, + * please specify multiple [google.api.Endpoint][google.api.Endpoint] for each of the intended + * aliases. + * + * Additional names that this endpoint will be hosted on. + */ + /** @deprecated */ + aliases: string[]; + /** + * The specification of an Internet routable address of API frontend that will + * handle requests to this [API + * Endpoint](https://cloud.google.com/apis/design/glossary). It should be + * either a valid IPv4 address or a fully-qualified domain name. For example, + * "8.8.8.8" or "myservice.appspot.com". + */ + target: string; + /** + * Allowing + * [CORS](https://en.wikipedia.org/wiki/Cross-origin_resource_sharing), aka + * cross-domain traffic, would allow the backends served from this endpoint to + * receive and respond to HTTP OPTIONS requests. The response will be used by + * the browser to determine whether the subsequent cross-origin request is + * allowed to proceed. + */ + allowCors: boolean; +} +export interface EndpointProtoMsg { + typeUrl: "/google.api.Endpoint"; + value: Uint8Array; +} +/** + * `Endpoint` describes a network endpoint of a service that serves a set of + * APIs. It is commonly known as a service endpoint. A service may expose + * any number of service endpoints, and all service endpoints share the same + * service definition, such as quota limits and monitoring metrics. + * + * Example service configuration: + * + * name: library-example.googleapis.com + * endpoints: + * # Below entry makes 'google.example.library.v1.Library' + * # API be served from endpoint address library-example.googleapis.com. + * # It also allows HTTP OPTIONS calls to be passed to the backend, for + * # it to decide whether the subsequent cross-origin request is + * # allowed to proceed. + * - name: library-example.googleapis.com + * allow_cors: true + */ +export interface EndpointSDKType { + name: string; + /** @deprecated */ + aliases: string[]; + target: string; + allow_cors: boolean; +} +function createBaseEndpoint(): Endpoint { + return { + name: "", + aliases: [], + target: "", + allowCors: false + }; +} +export const Endpoint = { + typeUrl: "/google.api.Endpoint", + encode(message: Endpoint, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + for (const v of message.aliases) { + writer.uint32(18).string(v!); + } + if (message.target !== undefined) { + writer.uint32(810).string(message.target); + } + if (message.allowCors !== undefined) { + writer.uint32(40).bool(message.allowCors); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Endpoint { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseEndpoint(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.aliases.push(reader.string()); + break; + case 101: + message.target = reader.string(); + break; + case 5: + message.allowCors = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Endpoint { + const obj = createBaseEndpoint(); + if (isSet(object.name)) obj.name = String(object.name); + if (Array.isArray(object?.aliases)) obj.aliases = object.aliases.map((e: any) => String(e)); + if (isSet(object.target)) obj.target = String(object.target); + if (isSet(object.allowCors)) obj.allowCors = Boolean(object.allowCors); + return obj; + }, + toJSON(message: Endpoint): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.aliases) { + obj.aliases = message.aliases.map(e => e); + } else { + obj.aliases = []; + } + message.target !== undefined && (obj.target = message.target); + message.allowCors !== undefined && (obj.allowCors = message.allowCors); + return obj; + }, + fromPartial(object: DeepPartial): Endpoint { + const message = createBaseEndpoint(); + message.name = object.name ?? ""; + message.aliases = object.aliases?.map(e => e) || []; + message.target = object.target ?? ""; + message.allowCors = object.allowCors ?? false; + return message; + }, + fromSDK(object: EndpointSDKType): Endpoint { + return { + name: object?.name, + aliases: Array.isArray(object?.aliases) ? object.aliases.map((e: any) => e) : [], + target: object?.target, + allowCors: object?.allow_cors + }; + }, + fromSDKJSON(object: any): EndpointSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + aliases: Array.isArray(object?.aliases) ? object.aliases.map((e: any) => String(e)) : [], + target: isSet(object.target) ? String(object.target) : "", + allow_cors: isSet(object.allow_cors) ? Boolean(object.allow_cors) : false + }; + }, + toSDK(message: Endpoint): EndpointSDKType { + const obj: any = {}; + obj.name = message.name; + if (message.aliases) { + obj.aliases = message.aliases.map(e => e); + } else { + obj.aliases = []; + } + obj.target = message.target; + obj.allow_cors = message.allowCors; + return obj; + }, + fromAmino(object: EndpointAmino): Endpoint { + const message = createBaseEndpoint(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + message.aliases = object.aliases?.map(e => e) || []; + if (object.target !== undefined && object.target !== null) { + message.target = object.target; + } + if (object.allow_cors !== undefined && object.allow_cors !== null) { + message.allowCors = object.allow_cors; + } + return message; + }, + toAmino(message: Endpoint): EndpointAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + if (message.aliases) { + obj.aliases = message.aliases.map(e => e); + } else { + obj.aliases = message.aliases; + } + obj.target = message.target === "" ? undefined : message.target; + obj.allow_cors = message.allowCors === false ? undefined : message.allowCors; + return obj; + }, + fromAminoMsg(object: EndpointAminoMsg): Endpoint { + return Endpoint.fromAmino(object.value); + }, + fromProtoMsg(message: EndpointProtoMsg): Endpoint { + return Endpoint.decode(message.value); + }, + toProto(message: Endpoint): Uint8Array { + return Endpoint.encode(message).finish(); + }, + toProtoMsg(message: Endpoint): EndpointProtoMsg { + return { + typeUrl: "/google.api.Endpoint", + value: Endpoint.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/api/error_reason.ts b/__fixtures__/v-next/outputicjsdeps/google/api/error_reason.ts new file mode 100644 index 0000000000..1052f8145d --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/api/error_reason.ts @@ -0,0 +1,512 @@ +export const protobufPackage = "google.api"; +/** + * Defines the supported values for `google.rpc.ErrorInfo.reason` for the + * `googleapis.com` error domain. This error domain is reserved for [Service + * Infrastructure](https://cloud.google.com/service-infrastructure/docs/overview). + * For each error info of this domain, the metadata key "service" refers to the + * logical identifier of an API service, such as "pubsub.googleapis.com". The + * "consumer" refers to the entity that consumes an API Service. It typically is + * a Google project that owns the client application or the server resource, + * such as "projects/123". Other metadata keys are specific to each error + * reason. For more information, see the definition of the specific error + * reason. + */ +export enum ErrorReason { + /** ERROR_REASON_UNSPECIFIED - Do not use this default value. */ + ERROR_REASON_UNSPECIFIED = 0, + /** + * SERVICE_DISABLED - The request is calling a disabled service for a consumer. + * + * Example of an ErrorInfo when the consumer "projects/123" contacting + * "pubsub.googleapis.com" service which is disabled: + * + * { "reason": "SERVICE_DISABLED", + * "domain": "googleapis.com", + * "metadata": { + * "consumer": "projects/123", + * "service": "pubsub.googleapis.com" + * } + * } + * + * This response indicates the "pubsub.googleapis.com" has been disabled in + * "projects/123". + */ + SERVICE_DISABLED = 1, + /** + * BILLING_DISABLED - The request whose associated billing account is disabled. + * + * Example of an ErrorInfo when the consumer "projects/123" fails to contact + * "pubsub.googleapis.com" service because the associated billing account is + * disabled: + * + * { "reason": "BILLING_DISABLED", + * "domain": "googleapis.com", + * "metadata": { + * "consumer": "projects/123", + * "service": "pubsub.googleapis.com" + * } + * } + * + * This response indicates the billing account associated has been disabled. + */ + BILLING_DISABLED = 2, + /** + * API_KEY_INVALID - The request is denied because the provided [API + * key](https://cloud.google.com/docs/authentication/api-keys) is invalid. It + * may be in a bad format, cannot be found, or has been expired). + * + * Example of an ErrorInfo when the request is contacting + * "storage.googleapis.com" service with an invalid API key: + * + * { "reason": "API_KEY_INVALID", + * "domain": "googleapis.com", + * "metadata": { + * "service": "storage.googleapis.com", + * } + * } + */ + API_KEY_INVALID = 3, + /** + * API_KEY_SERVICE_BLOCKED - The request is denied because it violates [API key API + * restrictions](https://cloud.google.com/docs/authentication/api-keys#adding_api_restrictions). + * + * Example of an ErrorInfo when the consumer "projects/123" fails to call the + * "storage.googleapis.com" service because this service is restricted in the + * API key: + * + * { "reason": "API_KEY_SERVICE_BLOCKED", + * "domain": "googleapis.com", + * "metadata": { + * "consumer": "projects/123", + * "service": "storage.googleapis.com" + * } + * } + */ + API_KEY_SERVICE_BLOCKED = 4, + /** + * API_KEY_HTTP_REFERRER_BLOCKED - The request is denied because it violates [API key HTTP + * restrictions](https://cloud.google.com/docs/authentication/api-keys#adding_http_restrictions). + * + * Example of an ErrorInfo when the consumer "projects/123" fails to call + * "storage.googleapis.com" service because the http referrer of the request + * violates API key HTTP restrictions: + * + * { "reason": "API_KEY_HTTP_REFERRER_BLOCKED", + * "domain": "googleapis.com", + * "metadata": { + * "consumer": "projects/123", + * "service": "storage.googleapis.com", + * } + * } + */ + API_KEY_HTTP_REFERRER_BLOCKED = 7, + /** + * API_KEY_IP_ADDRESS_BLOCKED - The request is denied because it violates [API key IP address + * restrictions](https://cloud.google.com/docs/authentication/api-keys#adding_application_restrictions). + * + * Example of an ErrorInfo when the consumer "projects/123" fails to call + * "storage.googleapis.com" service because the caller IP of the request + * violates API key IP address restrictions: + * + * { "reason": "API_KEY_IP_ADDRESS_BLOCKED", + * "domain": "googleapis.com", + * "metadata": { + * "consumer": "projects/123", + * "service": "storage.googleapis.com", + * } + * } + */ + API_KEY_IP_ADDRESS_BLOCKED = 8, + /** + * API_KEY_ANDROID_APP_BLOCKED - The request is denied because it violates [API key Android application + * restrictions](https://cloud.google.com/docs/authentication/api-keys#adding_application_restrictions). + * + * Example of an ErrorInfo when the consumer "projects/123" fails to call + * "storage.googleapis.com" service because the request from the Android apps + * violates the API key Android application restrictions: + * + * { "reason": "API_KEY_ANDROID_APP_BLOCKED", + * "domain": "googleapis.com", + * "metadata": { + * "consumer": "projects/123", + * "service": "storage.googleapis.com" + * } + * } + */ + API_KEY_ANDROID_APP_BLOCKED = 9, + /** + * API_KEY_IOS_APP_BLOCKED - The request is denied because it violates [API key iOS application + * restrictions](https://cloud.google.com/docs/authentication/api-keys#adding_application_restrictions). + * + * Example of an ErrorInfo when the consumer "projects/123" fails to call + * "storage.googleapis.com" service because the request from the iOS apps + * violates the API key iOS application restrictions: + * + * { "reason": "API_KEY_IOS_APP_BLOCKED", + * "domain": "googleapis.com", + * "metadata": { + * "consumer": "projects/123", + * "service": "storage.googleapis.com" + * } + * } + */ + API_KEY_IOS_APP_BLOCKED = 13, + /** + * RATE_LIMIT_EXCEEDED - The request is denied because there is not enough rate quota for the + * consumer. + * + * Example of an ErrorInfo when the consumer "projects/123" fails to contact + * "pubsub.googleapis.com" service because consumer's rate quota usage has + * reached the maximum value set for the quota limit + * "ReadsPerMinutePerProject" on the quota metric + * "pubsub.googleapis.com/read_requests": + * + * { "reason": "RATE_LIMIT_EXCEEDED", + * "domain": "googleapis.com", + * "metadata": { + * "consumer": "projects/123", + * "service": "pubsub.googleapis.com", + * "quota_metric": "pubsub.googleapis.com/read_requests", + * "quota_limit": "ReadsPerMinutePerProject" + * } + * } + * + * Example of an ErrorInfo when the consumer "projects/123" checks quota on + * the service "dataflow.googleapis.com" and hits the organization quota + * limit "DefaultRequestsPerMinutePerOrganization" on the metric + * "dataflow.googleapis.com/default_requests". + * + * { "reason": "RATE_LIMIT_EXCEEDED", + * "domain": "googleapis.com", + * "metadata": { + * "consumer": "projects/123", + * "service": "dataflow.googleapis.com", + * "quota_metric": "dataflow.googleapis.com/default_requests", + * "quota_limit": "DefaultRequestsPerMinutePerOrganization" + * } + * } + */ + RATE_LIMIT_EXCEEDED = 5, + /** + * RESOURCE_QUOTA_EXCEEDED - The request is denied because there is not enough resource quota for the + * consumer. + * + * Example of an ErrorInfo when the consumer "projects/123" fails to contact + * "compute.googleapis.com" service because consumer's resource quota usage + * has reached the maximum value set for the quota limit "VMsPerProject" + * on the quota metric "compute.googleapis.com/vms": + * + * { "reason": "RESOURCE_QUOTA_EXCEEDED", + * "domain": "googleapis.com", + * "metadata": { + * "consumer": "projects/123", + * "service": "compute.googleapis.com", + * "quota_metric": "compute.googleapis.com/vms", + * "quota_limit": "VMsPerProject" + * } + * } + * + * Example of an ErrorInfo when the consumer "projects/123" checks resource + * quota on the service "dataflow.googleapis.com" and hits the organization + * quota limit "jobs-per-organization" on the metric + * "dataflow.googleapis.com/job_count". + * + * { "reason": "RESOURCE_QUOTA_EXCEEDED", + * "domain": "googleapis.com", + * "metadata": { + * "consumer": "projects/123", + * "service": "dataflow.googleapis.com", + * "quota_metric": "dataflow.googleapis.com/job_count", + * "quota_limit": "jobs-per-organization" + * } + * } + */ + RESOURCE_QUOTA_EXCEEDED = 6, + /** + * LOCATION_TAX_POLICY_VIOLATED - The request whose associated billing account address is in a tax restricted + * location, violates the local tax restrictions when creating resources in + * the restricted region. + * + * Example of an ErrorInfo when creating the Cloud Storage Bucket in the + * container "projects/123" under a tax restricted region + * "locations/asia-northeast3": + * + * { "reason": "LOCATION_TAX_POLICY_VIOLATED", + * "domain": "googleapis.com", + * "metadata": { + * "consumer": "projects/123", + * "service": "storage.googleapis.com", + * "location": "locations/asia-northeast3" + * } + * } + * + * This response indicates creating the Cloud Storage Bucket in + * "locations/asia-northeast3" violates the location tax restriction. + */ + LOCATION_TAX_POLICY_VIOLATED = 10, + /** + * USER_PROJECT_DENIED - The request is denied because the caller does not have required permission + * on the user project "projects/123" or the user project is invalid. For more + * information, check the [userProject System + * Parameters](https://cloud.google.com/apis/docs/system-parameters). + * + * Example of an ErrorInfo when the caller is calling Cloud Storage service + * with insufficient permissions on the user project: + * + * { "reason": "USER_PROJECT_DENIED", + * "domain": "googleapis.com", + * "metadata": { + * "consumer": "projects/123", + * "service": "storage.googleapis.com" + * } + * } + */ + USER_PROJECT_DENIED = 11, + /** + * CONSUMER_SUSPENDED - The request is denied because the consumer "projects/123" is suspended due + * to Terms of Service(Tos) violations. Check [Project suspension + * guidelines](https://cloud.google.com/resource-manager/docs/project-suspension-guidelines) + * for more information. + * + * Example of an ErrorInfo when calling Cloud Storage service with the + * suspended consumer "projects/123": + * + * { "reason": "CONSUMER_SUSPENDED", + * "domain": "googleapis.com", + * "metadata": { + * "consumer": "projects/123", + * "service": "storage.googleapis.com" + * } + * } + */ + CONSUMER_SUSPENDED = 12, + /** + * CONSUMER_INVALID - The request is denied because the associated consumer is invalid. It may be + * in a bad format, cannot be found, or have been deleted. + * + * Example of an ErrorInfo when calling Cloud Storage service with the + * invalid consumer "projects/123": + * + * { "reason": "CONSUMER_INVALID", + * "domain": "googleapis.com", + * "metadata": { + * "consumer": "projects/123", + * "service": "storage.googleapis.com" + * } + * } + */ + CONSUMER_INVALID = 14, + /** + * SECURITY_POLICY_VIOLATED - The request is denied because it violates [VPC Service + * Controls](https://cloud.google.com/vpc-service-controls/docs/overview). + * The 'uid' field is a random generated identifier that customer can use it + * to search the audit log for a request rejected by VPC Service Controls. For + * more information, please refer [VPC Service Controls + * Troubleshooting](https://cloud.google.com/vpc-service-controls/docs/troubleshooting#unique-id) + * + * Example of an ErrorInfo when the consumer "projects/123" fails to call + * Cloud Storage service because the request is prohibited by the VPC Service + * Controls. + * + * { "reason": "SECURITY_POLICY_VIOLATED", + * "domain": "googleapis.com", + * "metadata": { + * "uid": "123456789abcde", + * "consumer": "projects/123", + * "service": "storage.googleapis.com" + * } + * } + */ + SECURITY_POLICY_VIOLATED = 15, + /** + * ACCESS_TOKEN_EXPIRED - The request is denied because the provided access token has expired. + * + * Example of an ErrorInfo when the request is calling Cloud Storage service + * with an expired access token: + * + * { "reason": "ACCESS_TOKEN_EXPIRED", + * "domain": "googleapis.com", + * "metadata": { + * "service": "storage.googleapis.com", + * "method": "google.storage.v1.Storage.GetObject" + * } + * } + */ + ACCESS_TOKEN_EXPIRED = 16, + /** + * ACCESS_TOKEN_SCOPE_INSUFFICIENT - The request is denied because the provided access token doesn't have at + * least one of the acceptable scopes required for the API. Please check + * [OAuth 2.0 Scopes for Google + * APIs](https://developers.google.com/identity/protocols/oauth2/scopes) for + * the list of the OAuth 2.0 scopes that you might need to request to access + * the API. + * + * Example of an ErrorInfo when the request is calling Cloud Storage service + * with an access token that is missing required scopes: + * + * { "reason": "ACCESS_TOKEN_SCOPE_INSUFFICIENT", + * "domain": "googleapis.com", + * "metadata": { + * "service": "storage.googleapis.com", + * "method": "google.storage.v1.Storage.GetObject" + * } + * } + */ + ACCESS_TOKEN_SCOPE_INSUFFICIENT = 17, + /** + * ACCOUNT_STATE_INVALID - The request is denied because the account associated with the provided + * access token is in an invalid state, such as disabled or deleted. + * For more information, see https://cloud.google.com/docs/authentication. + * + * Warning: For privacy reasons, the server may not be able to disclose the + * email address for some accounts. The client MUST NOT depend on the + * availability of the `email` attribute. + * + * Example of an ErrorInfo when the request is to the Cloud Storage API with + * an access token that is associated with a disabled or deleted [service + * account](http://cloud/iam/docs/service-accounts): + * + * { "reason": "ACCOUNT_STATE_INVALID", + * "domain": "googleapis.com", + * "metadata": { + * "service": "storage.googleapis.com", + * "method": "google.storage.v1.Storage.GetObject", + * "email": "user@123.iam.gserviceaccount.com" + * } + * } + */ + ACCOUNT_STATE_INVALID = 18, + /** + * ACCESS_TOKEN_TYPE_UNSUPPORTED - The request is denied because the type of the provided access token is not + * supported by the API being called. + * + * Example of an ErrorInfo when the request is to the Cloud Storage API with + * an unsupported token type. + * + * { "reason": "ACCESS_TOKEN_TYPE_UNSUPPORTED", + * "domain": "googleapis.com", + * "metadata": { + * "service": "storage.googleapis.com", + * "method": "google.storage.v1.Storage.GetObject" + * } + * } + */ + ACCESS_TOKEN_TYPE_UNSUPPORTED = 19, + UNRECOGNIZED = -1, +} +export const ErrorReasonSDKType = ErrorReason; +export function errorReasonFromJSON(object: any): ErrorReason { + switch (object) { + case 0: + case "ERROR_REASON_UNSPECIFIED": + return ErrorReason.ERROR_REASON_UNSPECIFIED; + case 1: + case "SERVICE_DISABLED": + return ErrorReason.SERVICE_DISABLED; + case 2: + case "BILLING_DISABLED": + return ErrorReason.BILLING_DISABLED; + case 3: + case "API_KEY_INVALID": + return ErrorReason.API_KEY_INVALID; + case 4: + case "API_KEY_SERVICE_BLOCKED": + return ErrorReason.API_KEY_SERVICE_BLOCKED; + case 7: + case "API_KEY_HTTP_REFERRER_BLOCKED": + return ErrorReason.API_KEY_HTTP_REFERRER_BLOCKED; + case 8: + case "API_KEY_IP_ADDRESS_BLOCKED": + return ErrorReason.API_KEY_IP_ADDRESS_BLOCKED; + case 9: + case "API_KEY_ANDROID_APP_BLOCKED": + return ErrorReason.API_KEY_ANDROID_APP_BLOCKED; + case 13: + case "API_KEY_IOS_APP_BLOCKED": + return ErrorReason.API_KEY_IOS_APP_BLOCKED; + case 5: + case "RATE_LIMIT_EXCEEDED": + return ErrorReason.RATE_LIMIT_EXCEEDED; + case 6: + case "RESOURCE_QUOTA_EXCEEDED": + return ErrorReason.RESOURCE_QUOTA_EXCEEDED; + case 10: + case "LOCATION_TAX_POLICY_VIOLATED": + return ErrorReason.LOCATION_TAX_POLICY_VIOLATED; + case 11: + case "USER_PROJECT_DENIED": + return ErrorReason.USER_PROJECT_DENIED; + case 12: + case "CONSUMER_SUSPENDED": + return ErrorReason.CONSUMER_SUSPENDED; + case 14: + case "CONSUMER_INVALID": + return ErrorReason.CONSUMER_INVALID; + case 15: + case "SECURITY_POLICY_VIOLATED": + return ErrorReason.SECURITY_POLICY_VIOLATED; + case 16: + case "ACCESS_TOKEN_EXPIRED": + return ErrorReason.ACCESS_TOKEN_EXPIRED; + case 17: + case "ACCESS_TOKEN_SCOPE_INSUFFICIENT": + return ErrorReason.ACCESS_TOKEN_SCOPE_INSUFFICIENT; + case 18: + case "ACCOUNT_STATE_INVALID": + return ErrorReason.ACCOUNT_STATE_INVALID; + case 19: + case "ACCESS_TOKEN_TYPE_UNSUPPORTED": + return ErrorReason.ACCESS_TOKEN_TYPE_UNSUPPORTED; + case -1: + case "UNRECOGNIZED": + default: + return ErrorReason.UNRECOGNIZED; + } +} +export function errorReasonToJSON(object: ErrorReason): string { + switch (object) { + case ErrorReason.ERROR_REASON_UNSPECIFIED: + return "ERROR_REASON_UNSPECIFIED"; + case ErrorReason.SERVICE_DISABLED: + return "SERVICE_DISABLED"; + case ErrorReason.BILLING_DISABLED: + return "BILLING_DISABLED"; + case ErrorReason.API_KEY_INVALID: + return "API_KEY_INVALID"; + case ErrorReason.API_KEY_SERVICE_BLOCKED: + return "API_KEY_SERVICE_BLOCKED"; + case ErrorReason.API_KEY_HTTP_REFERRER_BLOCKED: + return "API_KEY_HTTP_REFERRER_BLOCKED"; + case ErrorReason.API_KEY_IP_ADDRESS_BLOCKED: + return "API_KEY_IP_ADDRESS_BLOCKED"; + case ErrorReason.API_KEY_ANDROID_APP_BLOCKED: + return "API_KEY_ANDROID_APP_BLOCKED"; + case ErrorReason.API_KEY_IOS_APP_BLOCKED: + return "API_KEY_IOS_APP_BLOCKED"; + case ErrorReason.RATE_LIMIT_EXCEEDED: + return "RATE_LIMIT_EXCEEDED"; + case ErrorReason.RESOURCE_QUOTA_EXCEEDED: + return "RESOURCE_QUOTA_EXCEEDED"; + case ErrorReason.LOCATION_TAX_POLICY_VIOLATED: + return "LOCATION_TAX_POLICY_VIOLATED"; + case ErrorReason.USER_PROJECT_DENIED: + return "USER_PROJECT_DENIED"; + case ErrorReason.CONSUMER_SUSPENDED: + return "CONSUMER_SUSPENDED"; + case ErrorReason.CONSUMER_INVALID: + return "CONSUMER_INVALID"; + case ErrorReason.SECURITY_POLICY_VIOLATED: + return "SECURITY_POLICY_VIOLATED"; + case ErrorReason.ACCESS_TOKEN_EXPIRED: + return "ACCESS_TOKEN_EXPIRED"; + case ErrorReason.ACCESS_TOKEN_SCOPE_INSUFFICIENT: + return "ACCESS_TOKEN_SCOPE_INSUFFICIENT"; + case ErrorReason.ACCOUNT_STATE_INVALID: + return "ACCOUNT_STATE_INVALID"; + case ErrorReason.ACCESS_TOKEN_TYPE_UNSUPPORTED: + return "ACCESS_TOKEN_TYPE_UNSUPPORTED"; + case ErrorReason.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/api/expr/conformance/v1alpha1/conformance_service.ts b/__fixtures__/v-next/outputicjsdeps/google/api/expr/conformance/v1alpha1/conformance_service.ts new file mode 100644 index 0000000000..501ba956ec --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/api/expr/conformance/v1alpha1/conformance_service.ts @@ -0,0 +1,1293 @@ +import { ParsedExpr, ParsedExprSDKType, SourcePosition, SourcePositionSDKType } from "../../v1alpha1/syntax.js"; +import { Decl, DeclSDKType, CheckedExpr, CheckedExprSDKType } from "../../v1alpha1/checked.js"; +import { ExprValue, ExprValueSDKType } from "../../v1alpha1/eval.js"; +import { Status, StatusSDKType } from "../../../../rpc/status.js"; +import { BinaryReader, BinaryWriter } from "../../../../../binary.js"; +import { isSet, DeepPartial, isObject } from "../../../../../helpers.js"; +import { JsonSafe } from "../../../../../json-safe.js"; +export const protobufPackage = "google.api.expr.conformance.v1alpha1"; +/** Severities of issues. */ +export enum IssueDetails_Severity { + /** SEVERITY_UNSPECIFIED - An unspecified severity. */ + SEVERITY_UNSPECIFIED = 0, + /** + * DEPRECATION - Deprecation issue for statements and method that may no longer be + * supported or maintained. + */ + DEPRECATION = 1, + /** WARNING - Warnings such as: unused variables. */ + WARNING = 2, + /** ERROR - Errors such as: unmatched curly braces or variable redefinition. */ + ERROR = 3, + UNRECOGNIZED = -1, +} +export const IssueDetails_SeveritySDKType = IssueDetails_Severity; +export function issueDetails_SeverityFromJSON(object: any): IssueDetails_Severity { + switch (object) { + case 0: + case "SEVERITY_UNSPECIFIED": + return IssueDetails_Severity.SEVERITY_UNSPECIFIED; + case 1: + case "DEPRECATION": + return IssueDetails_Severity.DEPRECATION; + case 2: + case "WARNING": + return IssueDetails_Severity.WARNING; + case 3: + case "ERROR": + return IssueDetails_Severity.ERROR; + case -1: + case "UNRECOGNIZED": + default: + return IssueDetails_Severity.UNRECOGNIZED; + } +} +export function issueDetails_SeverityToJSON(object: IssueDetails_Severity): string { + switch (object) { + case IssueDetails_Severity.SEVERITY_UNSPECIFIED: + return "SEVERITY_UNSPECIFIED"; + case IssueDetails_Severity.DEPRECATION: + return "DEPRECATION"; + case IssueDetails_Severity.WARNING: + return "WARNING"; + case IssueDetails_Severity.ERROR: + return "ERROR"; + case IssueDetails_Severity.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** Request message for the Parse method. */ +export interface ParseRequest { + /** Required. Source text in CEL syntax. */ + celSource: string; + /** Tag for version of CEL syntax, for future use. */ + syntaxVersion: string; + /** File or resource for source text, used in [SourceInfo][google.api.SourceInfo]. */ + sourceLocation: string; + /** Prevent macro expansion. See "Macros" in Language Defiinition. */ + disableMacros: boolean; +} +export interface ParseRequestProtoMsg { + typeUrl: "/google.api.expr.conformance.v1alpha1.ParseRequest"; + value: Uint8Array; +} +/** Request message for the Parse method. */ +export interface ParseRequestSDKType { + cel_source: string; + syntax_version: string; + source_location: string; + disable_macros: boolean; +} +/** Response message for the Parse method. */ +export interface ParseResponse { + /** The parsed representation, or unset if parsing failed. */ + parsedExpr?: ParsedExpr; + /** Any number of issues with [StatusDetails][] as the details. */ + issues: Status[]; +} +export interface ParseResponseProtoMsg { + typeUrl: "/google.api.expr.conformance.v1alpha1.ParseResponse"; + value: Uint8Array; +} +/** Response message for the Parse method. */ +export interface ParseResponseSDKType { + parsed_expr?: ParsedExprSDKType; + issues: StatusSDKType[]; +} +/** Request message for the Check method. */ +export interface CheckRequest { + /** Required. The parsed representation of the CEL program. */ + parsedExpr?: ParsedExpr; + /** + * Declarations of types for external variables and functions. + * Required if program uses external variables or functions + * not in the default environment. + */ + typeEnv: Decl[]; + /** + * The protocol buffer context. See "Name Resolution" in the + * Language Definition. + */ + container: string; + /** + * If true, use only the declarations in [type_env][google.api.expr.conformance.v1alpha1.CheckRequest.type_env]. If false (default), + * add declarations for the standard definitions to the type environment. See + * "Standard Definitions" in the Language Definition. + */ + noStdEnv: boolean; +} +export interface CheckRequestProtoMsg { + typeUrl: "/google.api.expr.conformance.v1alpha1.CheckRequest"; + value: Uint8Array; +} +/** Request message for the Check method. */ +export interface CheckRequestSDKType { + parsed_expr?: ParsedExprSDKType; + type_env: DeclSDKType[]; + container: string; + no_std_env: boolean; +} +/** Response message for the Check method. */ +export interface CheckResponse { + /** The annotated representation, or unset if checking failed. */ + checkedExpr?: CheckedExpr; + /** Any number of issues with [StatusDetails][] as the details. */ + issues: Status[]; +} +export interface CheckResponseProtoMsg { + typeUrl: "/google.api.expr.conformance.v1alpha1.CheckResponse"; + value: Uint8Array; +} +/** Response message for the Check method. */ +export interface CheckResponseSDKType { + checked_expr?: CheckedExprSDKType; + issues: StatusSDKType[]; +} +export interface EvalRequest_BindingsEntry { + key: string; + value?: ExprValue; +} +export interface EvalRequest_BindingsEntryProtoMsg { + typeUrl: string; + value: Uint8Array; +} +export interface EvalRequest_BindingsEntrySDKType { + key: string; + value?: ExprValueSDKType; +} +/** Request message for the Eval method. */ +export interface EvalRequest { + /** Evaluate based on the parsed representation. */ + parsedExpr?: ParsedExpr; + /** Evaluate based on the checked representation. */ + checkedExpr?: CheckedExpr; + /** + * Bindings for the external variables. The types SHOULD be compatible + * with the type environment in [CheckRequest][google.api.expr.conformance.v1alpha1.CheckRequest], if checked. + */ + bindings: { + [key: string]: ExprValue; + }; + /** SHOULD be the same container as used in [CheckRequest][google.api.expr.conformance.v1alpha1.CheckRequest], if checked. */ + container: string; +} +export interface EvalRequestProtoMsg { + typeUrl: "/google.api.expr.conformance.v1alpha1.EvalRequest"; + value: Uint8Array; +} +/** Request message for the Eval method. */ +export interface EvalRequestSDKType { + parsed_expr?: ParsedExprSDKType; + checked_expr?: CheckedExprSDKType; + bindings: { + [key: string]: ExprValueSDKType; + }; + container: string; +} +/** Response message for the Eval method. */ +export interface EvalResponse { + /** The execution result, or unset if execution couldn't start. */ + result?: ExprValue; + /** + * Any number of issues with [StatusDetails][] as the details. + * Note that CEL execution errors are reified into [ExprValue][]. + * Nevertheless, we'll allow out-of-band issues to be raised, + * which also makes the replies more regular. + */ + issues: Status[]; +} +export interface EvalResponseProtoMsg { + typeUrl: "/google.api.expr.conformance.v1alpha1.EvalResponse"; + value: Uint8Array; +} +/** Response message for the Eval method. */ +export interface EvalResponseSDKType { + result?: ExprValueSDKType; + issues: StatusSDKType[]; +} +/** + * Warnings or errors in service execution are represented by + * [google.rpc.Status][google.rpc.Status] messages, with the following message + * in the details field. + */ +export interface IssueDetails { + /** The severity of the issue. */ + severity: IssueDetails_Severity; + /** Position in the source, if known. */ + position?: SourcePosition; + /** Expression ID from [Expr][], 0 if unknown. */ + id: bigint; +} +export interface IssueDetailsProtoMsg { + typeUrl: "/google.api.expr.conformance.v1alpha1.IssueDetails"; + value: Uint8Array; +} +/** + * Warnings or errors in service execution are represented by + * [google.rpc.Status][google.rpc.Status] messages, with the following message + * in the details field. + */ +export interface IssueDetailsSDKType { + severity: IssueDetails_Severity; + position?: SourcePositionSDKType; + id: bigint; +} +function createBaseParseRequest(): ParseRequest { + return { + celSource: "", + syntaxVersion: "", + sourceLocation: "", + disableMacros: false + }; +} +export const ParseRequest = { + typeUrl: "/google.api.expr.conformance.v1alpha1.ParseRequest", + encode(message: ParseRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.celSource !== undefined) { + writer.uint32(10).string(message.celSource); + } + if (message.syntaxVersion !== undefined) { + writer.uint32(18).string(message.syntaxVersion); + } + if (message.sourceLocation !== undefined) { + writer.uint32(26).string(message.sourceLocation); + } + if (message.disableMacros !== undefined) { + writer.uint32(32).bool(message.disableMacros); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ParseRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseParseRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.celSource = reader.string(); + break; + case 2: + message.syntaxVersion = reader.string(); + break; + case 3: + message.sourceLocation = reader.string(); + break; + case 4: + message.disableMacros = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ParseRequest { + const obj = createBaseParseRequest(); + if (isSet(object.celSource)) obj.celSource = String(object.celSource); + if (isSet(object.syntaxVersion)) obj.syntaxVersion = String(object.syntaxVersion); + if (isSet(object.sourceLocation)) obj.sourceLocation = String(object.sourceLocation); + if (isSet(object.disableMacros)) obj.disableMacros = Boolean(object.disableMacros); + return obj; + }, + toJSON(message: ParseRequest): JsonSafe { + const obj: any = {}; + message.celSource !== undefined && (obj.celSource = message.celSource); + message.syntaxVersion !== undefined && (obj.syntaxVersion = message.syntaxVersion); + message.sourceLocation !== undefined && (obj.sourceLocation = message.sourceLocation); + message.disableMacros !== undefined && (obj.disableMacros = message.disableMacros); + return obj; + }, + fromPartial(object: DeepPartial): ParseRequest { + const message = createBaseParseRequest(); + message.celSource = object.celSource ?? ""; + message.syntaxVersion = object.syntaxVersion ?? ""; + message.sourceLocation = object.sourceLocation ?? ""; + message.disableMacros = object.disableMacros ?? false; + return message; + }, + fromSDK(object: ParseRequestSDKType): ParseRequest { + return { + celSource: object?.cel_source, + syntaxVersion: object?.syntax_version, + sourceLocation: object?.source_location, + disableMacros: object?.disable_macros + }; + }, + fromSDKJSON(object: any): ParseRequestSDKType { + return { + cel_source: isSet(object.cel_source) ? String(object.cel_source) : "", + syntax_version: isSet(object.syntax_version) ? String(object.syntax_version) : "", + source_location: isSet(object.source_location) ? String(object.source_location) : "", + disable_macros: isSet(object.disable_macros) ? Boolean(object.disable_macros) : false + }; + }, + toSDK(message: ParseRequest): ParseRequestSDKType { + const obj: any = {}; + obj.cel_source = message.celSource; + obj.syntax_version = message.syntaxVersion; + obj.source_location = message.sourceLocation; + obj.disable_macros = message.disableMacros; + return obj; + }, + fromAmino(object: ParseRequestAmino): ParseRequest { + const message = createBaseParseRequest(); + if (object.cel_source !== undefined && object.cel_source !== null) { + message.celSource = object.cel_source; + } + if (object.syntax_version !== undefined && object.syntax_version !== null) { + message.syntaxVersion = object.syntax_version; + } + if (object.source_location !== undefined && object.source_location !== null) { + message.sourceLocation = object.source_location; + } + if (object.disable_macros !== undefined && object.disable_macros !== null) { + message.disableMacros = object.disable_macros; + } + return message; + }, + toAmino(message: ParseRequest): ParseRequestAmino { + const obj: any = {}; + obj.cel_source = message.celSource === "" ? undefined : message.celSource; + obj.syntax_version = message.syntaxVersion === "" ? undefined : message.syntaxVersion; + obj.source_location = message.sourceLocation === "" ? undefined : message.sourceLocation; + obj.disable_macros = message.disableMacros === false ? undefined : message.disableMacros; + return obj; + }, + fromAminoMsg(object: ParseRequestAminoMsg): ParseRequest { + return ParseRequest.fromAmino(object.value); + }, + fromProtoMsg(message: ParseRequestProtoMsg): ParseRequest { + return ParseRequest.decode(message.value); + }, + toProto(message: ParseRequest): Uint8Array { + return ParseRequest.encode(message).finish(); + }, + toProtoMsg(message: ParseRequest): ParseRequestProtoMsg { + return { + typeUrl: "/google.api.expr.conformance.v1alpha1.ParseRequest", + value: ParseRequest.encode(message).finish() + }; + } +}; +function createBaseParseResponse(): ParseResponse { + return { + parsedExpr: undefined, + issues: [] + }; +} +export const ParseResponse = { + typeUrl: "/google.api.expr.conformance.v1alpha1.ParseResponse", + encode(message: ParseResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.parsedExpr !== undefined) { + ParsedExpr.encode(message.parsedExpr, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.issues) { + Status.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ParseResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseParseResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.parsedExpr = ParsedExpr.decode(reader, reader.uint32()); + break; + case 2: + message.issues.push(Status.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ParseResponse { + const obj = createBaseParseResponse(); + if (isSet(object.parsedExpr)) obj.parsedExpr = ParsedExpr.fromJSON(object.parsedExpr); + if (Array.isArray(object?.issues)) obj.issues = object.issues.map((e: any) => Status.fromJSON(e)); + return obj; + }, + toJSON(message: ParseResponse): JsonSafe { + const obj: any = {}; + message.parsedExpr !== undefined && (obj.parsedExpr = message.parsedExpr ? ParsedExpr.toJSON(message.parsedExpr) : undefined); + if (message.issues) { + obj.issues = message.issues.map(e => e ? Status.toJSON(e) : undefined); + } else { + obj.issues = []; + } + return obj; + }, + fromPartial(object: DeepPartial): ParseResponse { + const message = createBaseParseResponse(); + if (object.parsedExpr !== undefined && object.parsedExpr !== null) { + message.parsedExpr = ParsedExpr.fromPartial(object.parsedExpr); + } + message.issues = object.issues?.map(e => Status.fromPartial(e)) || []; + return message; + }, + fromSDK(object: ParseResponseSDKType): ParseResponse { + return { + parsedExpr: object.parsed_expr ? ParsedExpr.fromSDK(object.parsed_expr) : undefined, + issues: Array.isArray(object?.issues) ? object.issues.map((e: any) => Status.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): ParseResponseSDKType { + return { + parsed_expr: isSet(object.parsed_expr) ? ParsedExpr.fromSDKJSON(object.parsed_expr) : undefined, + issues: Array.isArray(object?.issues) ? object.issues.map((e: any) => Status.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: ParseResponse): ParseResponseSDKType { + const obj: any = {}; + message.parsedExpr !== undefined && (obj.parsed_expr = message.parsedExpr ? ParsedExpr.toSDK(message.parsedExpr) : undefined); + if (message.issues) { + obj.issues = message.issues.map(e => e ? Status.toSDK(e) : undefined); + } else { + obj.issues = []; + } + return obj; + }, + fromAmino(object: ParseResponseAmino): ParseResponse { + const message = createBaseParseResponse(); + if (object.parsed_expr !== undefined && object.parsed_expr !== null) { + message.parsedExpr = ParsedExpr.fromAmino(object.parsed_expr); + } + message.issues = object.issues?.map(e => Status.fromAmino(e)) || []; + return message; + }, + toAmino(message: ParseResponse): ParseResponseAmino { + const obj: any = {}; + obj.parsed_expr = message.parsedExpr ? ParsedExpr.toAmino(message.parsedExpr) : undefined; + if (message.issues) { + obj.issues = message.issues.map(e => e ? Status.toAmino(e) : undefined); + } else { + obj.issues = message.issues; + } + return obj; + }, + fromAminoMsg(object: ParseResponseAminoMsg): ParseResponse { + return ParseResponse.fromAmino(object.value); + }, + fromProtoMsg(message: ParseResponseProtoMsg): ParseResponse { + return ParseResponse.decode(message.value); + }, + toProto(message: ParseResponse): Uint8Array { + return ParseResponse.encode(message).finish(); + }, + toProtoMsg(message: ParseResponse): ParseResponseProtoMsg { + return { + typeUrl: "/google.api.expr.conformance.v1alpha1.ParseResponse", + value: ParseResponse.encode(message).finish() + }; + } +}; +function createBaseCheckRequest(): CheckRequest { + return { + parsedExpr: undefined, + typeEnv: [], + container: "", + noStdEnv: false + }; +} +export const CheckRequest = { + typeUrl: "/google.api.expr.conformance.v1alpha1.CheckRequest", + encode(message: CheckRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.parsedExpr !== undefined) { + ParsedExpr.encode(message.parsedExpr, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.typeEnv) { + Decl.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.container !== undefined) { + writer.uint32(26).string(message.container); + } + if (message.noStdEnv !== undefined) { + writer.uint32(32).bool(message.noStdEnv); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): CheckRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCheckRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.parsedExpr = ParsedExpr.decode(reader, reader.uint32()); + break; + case 2: + message.typeEnv.push(Decl.decode(reader, reader.uint32())); + break; + case 3: + message.container = reader.string(); + break; + case 4: + message.noStdEnv = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): CheckRequest { + const obj = createBaseCheckRequest(); + if (isSet(object.parsedExpr)) obj.parsedExpr = ParsedExpr.fromJSON(object.parsedExpr); + if (Array.isArray(object?.typeEnv)) obj.typeEnv = object.typeEnv.map((e: any) => Decl.fromJSON(e)); + if (isSet(object.container)) obj.container = String(object.container); + if (isSet(object.noStdEnv)) obj.noStdEnv = Boolean(object.noStdEnv); + return obj; + }, + toJSON(message: CheckRequest): JsonSafe { + const obj: any = {}; + message.parsedExpr !== undefined && (obj.parsedExpr = message.parsedExpr ? ParsedExpr.toJSON(message.parsedExpr) : undefined); + if (message.typeEnv) { + obj.typeEnv = message.typeEnv.map(e => e ? Decl.toJSON(e) : undefined); + } else { + obj.typeEnv = []; + } + message.container !== undefined && (obj.container = message.container); + message.noStdEnv !== undefined && (obj.noStdEnv = message.noStdEnv); + return obj; + }, + fromPartial(object: DeepPartial): CheckRequest { + const message = createBaseCheckRequest(); + if (object.parsedExpr !== undefined && object.parsedExpr !== null) { + message.parsedExpr = ParsedExpr.fromPartial(object.parsedExpr); + } + message.typeEnv = object.typeEnv?.map(e => Decl.fromPartial(e)) || []; + message.container = object.container ?? ""; + message.noStdEnv = object.noStdEnv ?? false; + return message; + }, + fromSDK(object: CheckRequestSDKType): CheckRequest { + return { + parsedExpr: object.parsed_expr ? ParsedExpr.fromSDK(object.parsed_expr) : undefined, + typeEnv: Array.isArray(object?.type_env) ? object.type_env.map((e: any) => Decl.fromSDK(e)) : [], + container: object?.container, + noStdEnv: object?.no_std_env + }; + }, + fromSDKJSON(object: any): CheckRequestSDKType { + return { + parsed_expr: isSet(object.parsed_expr) ? ParsedExpr.fromSDKJSON(object.parsed_expr) : undefined, + type_env: Array.isArray(object?.type_env) ? object.type_env.map((e: any) => Decl.fromSDKJSON(e)) : [], + container: isSet(object.container) ? String(object.container) : "", + no_std_env: isSet(object.no_std_env) ? Boolean(object.no_std_env) : false + }; + }, + toSDK(message: CheckRequest): CheckRequestSDKType { + const obj: any = {}; + message.parsedExpr !== undefined && (obj.parsed_expr = message.parsedExpr ? ParsedExpr.toSDK(message.parsedExpr) : undefined); + if (message.typeEnv) { + obj.type_env = message.typeEnv.map(e => e ? Decl.toSDK(e) : undefined); + } else { + obj.type_env = []; + } + obj.container = message.container; + obj.no_std_env = message.noStdEnv; + return obj; + }, + fromAmino(object: CheckRequestAmino): CheckRequest { + const message = createBaseCheckRequest(); + if (object.parsed_expr !== undefined && object.parsed_expr !== null) { + message.parsedExpr = ParsedExpr.fromAmino(object.parsed_expr); + } + message.typeEnv = object.type_env?.map(e => Decl.fromAmino(e)) || []; + if (object.container !== undefined && object.container !== null) { + message.container = object.container; + } + if (object.no_std_env !== undefined && object.no_std_env !== null) { + message.noStdEnv = object.no_std_env; + } + return message; + }, + toAmino(message: CheckRequest): CheckRequestAmino { + const obj: any = {}; + obj.parsed_expr = message.parsedExpr ? ParsedExpr.toAmino(message.parsedExpr) : undefined; + if (message.typeEnv) { + obj.type_env = message.typeEnv.map(e => e ? Decl.toAmino(e) : undefined); + } else { + obj.type_env = message.typeEnv; + } + obj.container = message.container === "" ? undefined : message.container; + obj.no_std_env = message.noStdEnv === false ? undefined : message.noStdEnv; + return obj; + }, + fromAminoMsg(object: CheckRequestAminoMsg): CheckRequest { + return CheckRequest.fromAmino(object.value); + }, + fromProtoMsg(message: CheckRequestProtoMsg): CheckRequest { + return CheckRequest.decode(message.value); + }, + toProto(message: CheckRequest): Uint8Array { + return CheckRequest.encode(message).finish(); + }, + toProtoMsg(message: CheckRequest): CheckRequestProtoMsg { + return { + typeUrl: "/google.api.expr.conformance.v1alpha1.CheckRequest", + value: CheckRequest.encode(message).finish() + }; + } +}; +function createBaseCheckResponse(): CheckResponse { + return { + checkedExpr: undefined, + issues: [] + }; +} +export const CheckResponse = { + typeUrl: "/google.api.expr.conformance.v1alpha1.CheckResponse", + encode(message: CheckResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.checkedExpr !== undefined) { + CheckedExpr.encode(message.checkedExpr, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.issues) { + Status.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): CheckResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCheckResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.checkedExpr = CheckedExpr.decode(reader, reader.uint32()); + break; + case 2: + message.issues.push(Status.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): CheckResponse { + const obj = createBaseCheckResponse(); + if (isSet(object.checkedExpr)) obj.checkedExpr = CheckedExpr.fromJSON(object.checkedExpr); + if (Array.isArray(object?.issues)) obj.issues = object.issues.map((e: any) => Status.fromJSON(e)); + return obj; + }, + toJSON(message: CheckResponse): JsonSafe { + const obj: any = {}; + message.checkedExpr !== undefined && (obj.checkedExpr = message.checkedExpr ? CheckedExpr.toJSON(message.checkedExpr) : undefined); + if (message.issues) { + obj.issues = message.issues.map(e => e ? Status.toJSON(e) : undefined); + } else { + obj.issues = []; + } + return obj; + }, + fromPartial(object: DeepPartial): CheckResponse { + const message = createBaseCheckResponse(); + if (object.checkedExpr !== undefined && object.checkedExpr !== null) { + message.checkedExpr = CheckedExpr.fromPartial(object.checkedExpr); + } + message.issues = object.issues?.map(e => Status.fromPartial(e)) || []; + return message; + }, + fromSDK(object: CheckResponseSDKType): CheckResponse { + return { + checkedExpr: object.checked_expr ? CheckedExpr.fromSDK(object.checked_expr) : undefined, + issues: Array.isArray(object?.issues) ? object.issues.map((e: any) => Status.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): CheckResponseSDKType { + return { + checked_expr: isSet(object.checked_expr) ? CheckedExpr.fromSDKJSON(object.checked_expr) : undefined, + issues: Array.isArray(object?.issues) ? object.issues.map((e: any) => Status.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: CheckResponse): CheckResponseSDKType { + const obj: any = {}; + message.checkedExpr !== undefined && (obj.checked_expr = message.checkedExpr ? CheckedExpr.toSDK(message.checkedExpr) : undefined); + if (message.issues) { + obj.issues = message.issues.map(e => e ? Status.toSDK(e) : undefined); + } else { + obj.issues = []; + } + return obj; + }, + fromAmino(object: CheckResponseAmino): CheckResponse { + const message = createBaseCheckResponse(); + if (object.checked_expr !== undefined && object.checked_expr !== null) { + message.checkedExpr = CheckedExpr.fromAmino(object.checked_expr); + } + message.issues = object.issues?.map(e => Status.fromAmino(e)) || []; + return message; + }, + toAmino(message: CheckResponse): CheckResponseAmino { + const obj: any = {}; + obj.checked_expr = message.checkedExpr ? CheckedExpr.toAmino(message.checkedExpr) : undefined; + if (message.issues) { + obj.issues = message.issues.map(e => e ? Status.toAmino(e) : undefined); + } else { + obj.issues = message.issues; + } + return obj; + }, + fromAminoMsg(object: CheckResponseAminoMsg): CheckResponse { + return CheckResponse.fromAmino(object.value); + }, + fromProtoMsg(message: CheckResponseProtoMsg): CheckResponse { + return CheckResponse.decode(message.value); + }, + toProto(message: CheckResponse): Uint8Array { + return CheckResponse.encode(message).finish(); + }, + toProtoMsg(message: CheckResponse): CheckResponseProtoMsg { + return { + typeUrl: "/google.api.expr.conformance.v1alpha1.CheckResponse", + value: CheckResponse.encode(message).finish() + }; + } +}; +function createBaseEvalRequest_BindingsEntry(): EvalRequest_BindingsEntry { + return { + key: "", + value: undefined + }; +} +export const EvalRequest_BindingsEntry = { + encode(message: EvalRequest_BindingsEntry, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.key !== undefined) { + writer.uint32(10).string(message.key); + } + if (message.value !== undefined) { + ExprValue.encode(message.value, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): EvalRequest_BindingsEntry { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseEvalRequest_BindingsEntry(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.string(); + break; + case 2: + message.value = ExprValue.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): EvalRequest_BindingsEntry { + const obj = createBaseEvalRequest_BindingsEntry(); + if (isSet(object.key)) obj.key = String(object.key); + if (isSet(object.value)) obj.value = ExprValue.fromJSON(object.value); + return obj; + }, + toJSON(message: EvalRequest_BindingsEntry): JsonSafe { + const obj: any = {}; + message.key !== undefined && (obj.key = message.key); + message.value !== undefined && (obj.value = message.value ? ExprValue.toJSON(message.value) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): EvalRequest_BindingsEntry { + const message = createBaseEvalRequest_BindingsEntry(); + message.key = object.key ?? ""; + if (object.value !== undefined && object.value !== null) { + message.value = ExprValue.fromPartial(object.value); + } + return message; + }, + fromSDK(object: EvalRequest_BindingsEntrySDKType): EvalRequest_BindingsEntry { + return { + key: object?.key, + value: object.value ? ExprValue.fromSDK(object.value) : undefined + }; + }, + fromSDKJSON(object: any): EvalRequest_BindingsEntrySDKType { + return { + key: isSet(object.key) ? String(object.key) : "", + value: isSet(object.value) ? ExprValue.fromSDKJSON(object.value) : undefined + }; + }, + toSDK(message: EvalRequest_BindingsEntry): EvalRequest_BindingsEntrySDKType { + const obj: any = {}; + obj.key = message.key; + message.value !== undefined && (obj.value = message.value ? ExprValue.toSDK(message.value) : undefined); + return obj; + }, + fromAmino(object: EvalRequest_BindingsEntryAmino): EvalRequest_BindingsEntry { + const message = createBaseEvalRequest_BindingsEntry(); + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } + if (object.value !== undefined && object.value !== null) { + message.value = ExprValue.fromAmino(object.value); + } + return message; + }, + toAmino(message: EvalRequest_BindingsEntry): EvalRequest_BindingsEntryAmino { + const obj: any = {}; + obj.key = message.key === "" ? undefined : message.key; + obj.value = message.value ? ExprValue.toAmino(message.value) : undefined; + return obj; + }, + fromAminoMsg(object: EvalRequest_BindingsEntryAminoMsg): EvalRequest_BindingsEntry { + return EvalRequest_BindingsEntry.fromAmino(object.value); + }, + fromProtoMsg(message: EvalRequest_BindingsEntryProtoMsg): EvalRequest_BindingsEntry { + return EvalRequest_BindingsEntry.decode(message.value); + }, + toProto(message: EvalRequest_BindingsEntry): Uint8Array { + return EvalRequest_BindingsEntry.encode(message).finish(); + } +}; +function createBaseEvalRequest(): EvalRequest { + return { + parsedExpr: undefined, + checkedExpr: undefined, + bindings: {}, + container: "" + }; +} +export const EvalRequest = { + typeUrl: "/google.api.expr.conformance.v1alpha1.EvalRequest", + encode(message: EvalRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.parsedExpr !== undefined) { + ParsedExpr.encode(message.parsedExpr, writer.uint32(10).fork()).ldelim(); + } + if (message.checkedExpr !== undefined) { + CheckedExpr.encode(message.checkedExpr, writer.uint32(18).fork()).ldelim(); + } + Object.entries(message.bindings).forEach(([key, value]) => { + EvalRequest_BindingsEntry.encode({ + key: (key as any), + value + }, writer.uint32(26).fork()).ldelim(); + }); + if (message.container !== undefined) { + writer.uint32(34).string(message.container); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): EvalRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseEvalRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.parsedExpr = ParsedExpr.decode(reader, reader.uint32()); + break; + case 2: + message.checkedExpr = CheckedExpr.decode(reader, reader.uint32()); + break; + case 3: + const entry3 = EvalRequest_BindingsEntry.decode(reader, reader.uint32()); + if (entry3.value !== undefined) { + message.bindings[entry3.key] = entry3.value; + } + break; + case 4: + message.container = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): EvalRequest { + const obj = createBaseEvalRequest(); + if (isSet(object.parsedExpr)) obj.parsedExpr = ParsedExpr.fromJSON(object.parsedExpr); + if (isSet(object.checkedExpr)) obj.checkedExpr = CheckedExpr.fromJSON(object.checkedExpr); + if (isObject(object.bindings)) obj.bindings = Object.entries(object.bindings).reduce<{ + [key: string]: ExprValue; + }>((acc, [key, value]) => { + acc[key] = ExprValue.fromJSON(value); + return acc; + }, {}); + if (isSet(object.container)) obj.container = String(object.container); + return obj; + }, + toJSON(message: EvalRequest): JsonSafe { + const obj: any = {}; + message.parsedExpr !== undefined && (obj.parsedExpr = message.parsedExpr ? ParsedExpr.toJSON(message.parsedExpr) : undefined); + message.checkedExpr !== undefined && (obj.checkedExpr = message.checkedExpr ? CheckedExpr.toJSON(message.checkedExpr) : undefined); + obj.bindings = {}; + if (message.bindings) { + Object.entries(message.bindings).forEach(([k, v]) => { + obj.bindings[k] = ExprValue.toJSON(v); + }); + } + message.container !== undefined && (obj.container = message.container); + return obj; + }, + fromPartial(object: DeepPartial): EvalRequest { + const message = createBaseEvalRequest(); + if (object.parsedExpr !== undefined && object.parsedExpr !== null) { + message.parsedExpr = ParsedExpr.fromPartial(object.parsedExpr); + } + if (object.checkedExpr !== undefined && object.checkedExpr !== null) { + message.checkedExpr = CheckedExpr.fromPartial(object.checkedExpr); + } + message.bindings = Object.entries(object.bindings ?? {}).reduce<{ + [key: string]: ExprValue; + }>((acc, [key, value]) => { + if (value !== undefined) { + acc[key] = ExprValue.fromPartial(value); + } + return acc; + }, {}); + message.container = object.container ?? ""; + return message; + }, + fromSDK(object: EvalRequestSDKType): EvalRequest { + return { + parsedExpr: object.parsed_expr ? ParsedExpr.fromSDK(object.parsed_expr) : undefined, + checkedExpr: object.checked_expr ? CheckedExpr.fromSDK(object.checked_expr) : undefined, + bindings: isObject(object.bindings) ? Object.entries(object.bindings).reduce<{ + [key: string]: ExprValue; + }>((acc, [key, value]) => { + acc[key] = ExprValue.fromSDK(value); + return acc; + }, {}) : {}, + container: object?.container + }; + }, + fromSDKJSON(object: any): EvalRequestSDKType { + return { + parsed_expr: isSet(object.parsed_expr) ? ParsedExpr.fromSDKJSON(object.parsed_expr) : undefined, + checked_expr: isSet(object.checked_expr) ? CheckedExpr.fromSDKJSON(object.checked_expr) : undefined, + bindings: isObject(object.bindings) ? Object.entries(object.bindings).reduce<{ + [key: string]: ExprValue; + }>((acc, [key, value]) => { + acc[key] = ExprValue.fromSDKJSON(value); + return acc; + }, {}) : {}, + container: isSet(object.container) ? String(object.container) : "" + }; + }, + toSDK(message: EvalRequest): EvalRequestSDKType { + const obj: any = {}; + message.parsedExpr !== undefined && (obj.parsed_expr = message.parsedExpr ? ParsedExpr.toSDK(message.parsedExpr) : undefined); + message.checkedExpr !== undefined && (obj.checked_expr = message.checkedExpr ? CheckedExpr.toSDK(message.checkedExpr) : undefined); + obj.bindings = {}; + if (message.bindings) { + Object.entries(message.bindings).forEach(([k, v]) => { + obj.bindings[k] = ExprValue.toSDK(v); + }); + } + obj.container = message.container; + return obj; + }, + fromAmino(object: EvalRequestAmino): EvalRequest { + const message = createBaseEvalRequest(); + if (object.parsed_expr !== undefined && object.parsed_expr !== null) { + message.parsedExpr = ParsedExpr.fromAmino(object.parsed_expr); + } + if (object.checked_expr !== undefined && object.checked_expr !== null) { + message.checkedExpr = CheckedExpr.fromAmino(object.checked_expr); + } + message.bindings = Object.entries(object.bindings ?? {}).reduce<{ + [key: string]: ExprValue; + }>((acc, [key, value]) => { + if (value !== undefined) { + acc[key] = ExprValue.fromAmino(value); + } + return acc; + }, {}); + if (object.container !== undefined && object.container !== null) { + message.container = object.container; + } + return message; + }, + toAmino(message: EvalRequest): EvalRequestAmino { + const obj: any = {}; + obj.parsed_expr = message.parsedExpr ? ParsedExpr.toAmino(message.parsedExpr) : undefined; + obj.checked_expr = message.checkedExpr ? CheckedExpr.toAmino(message.checkedExpr) : undefined; + obj.bindings = {}; + if (message.bindings) { + Object.entries(message.bindings).forEach(([k, v]) => { + obj.bindings[k] = ExprValue.toAmino(v); + }); + } + obj.container = message.container === "" ? undefined : message.container; + return obj; + }, + fromAminoMsg(object: EvalRequestAminoMsg): EvalRequest { + return EvalRequest.fromAmino(object.value); + }, + fromProtoMsg(message: EvalRequestProtoMsg): EvalRequest { + return EvalRequest.decode(message.value); + }, + toProto(message: EvalRequest): Uint8Array { + return EvalRequest.encode(message).finish(); + }, + toProtoMsg(message: EvalRequest): EvalRequestProtoMsg { + return { + typeUrl: "/google.api.expr.conformance.v1alpha1.EvalRequest", + value: EvalRequest.encode(message).finish() + }; + } +}; +function createBaseEvalResponse(): EvalResponse { + return { + result: undefined, + issues: [] + }; +} +export const EvalResponse = { + typeUrl: "/google.api.expr.conformance.v1alpha1.EvalResponse", + encode(message: EvalResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.result !== undefined) { + ExprValue.encode(message.result, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.issues) { + Status.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): EvalResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseEvalResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.result = ExprValue.decode(reader, reader.uint32()); + break; + case 2: + message.issues.push(Status.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): EvalResponse { + const obj = createBaseEvalResponse(); + if (isSet(object.result)) obj.result = ExprValue.fromJSON(object.result); + if (Array.isArray(object?.issues)) obj.issues = object.issues.map((e: any) => Status.fromJSON(e)); + return obj; + }, + toJSON(message: EvalResponse): JsonSafe { + const obj: any = {}; + message.result !== undefined && (obj.result = message.result ? ExprValue.toJSON(message.result) : undefined); + if (message.issues) { + obj.issues = message.issues.map(e => e ? Status.toJSON(e) : undefined); + } else { + obj.issues = []; + } + return obj; + }, + fromPartial(object: DeepPartial): EvalResponse { + const message = createBaseEvalResponse(); + if (object.result !== undefined && object.result !== null) { + message.result = ExprValue.fromPartial(object.result); + } + message.issues = object.issues?.map(e => Status.fromPartial(e)) || []; + return message; + }, + fromSDK(object: EvalResponseSDKType): EvalResponse { + return { + result: object.result ? ExprValue.fromSDK(object.result) : undefined, + issues: Array.isArray(object?.issues) ? object.issues.map((e: any) => Status.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): EvalResponseSDKType { + return { + result: isSet(object.result) ? ExprValue.fromSDKJSON(object.result) : undefined, + issues: Array.isArray(object?.issues) ? object.issues.map((e: any) => Status.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: EvalResponse): EvalResponseSDKType { + const obj: any = {}; + message.result !== undefined && (obj.result = message.result ? ExprValue.toSDK(message.result) : undefined); + if (message.issues) { + obj.issues = message.issues.map(e => e ? Status.toSDK(e) : undefined); + } else { + obj.issues = []; + } + return obj; + }, + fromAmino(object: EvalResponseAmino): EvalResponse { + const message = createBaseEvalResponse(); + if (object.result !== undefined && object.result !== null) { + message.result = ExprValue.fromAmino(object.result); + } + message.issues = object.issues?.map(e => Status.fromAmino(e)) || []; + return message; + }, + toAmino(message: EvalResponse): EvalResponseAmino { + const obj: any = {}; + obj.result = message.result ? ExprValue.toAmino(message.result) : undefined; + if (message.issues) { + obj.issues = message.issues.map(e => e ? Status.toAmino(e) : undefined); + } else { + obj.issues = message.issues; + } + return obj; + }, + fromAminoMsg(object: EvalResponseAminoMsg): EvalResponse { + return EvalResponse.fromAmino(object.value); + }, + fromProtoMsg(message: EvalResponseProtoMsg): EvalResponse { + return EvalResponse.decode(message.value); + }, + toProto(message: EvalResponse): Uint8Array { + return EvalResponse.encode(message).finish(); + }, + toProtoMsg(message: EvalResponse): EvalResponseProtoMsg { + return { + typeUrl: "/google.api.expr.conformance.v1alpha1.EvalResponse", + value: EvalResponse.encode(message).finish() + }; + } +}; +function createBaseIssueDetails(): IssueDetails { + return { + severity: 0, + position: undefined, + id: BigInt(0) + }; +} +export const IssueDetails = { + typeUrl: "/google.api.expr.conformance.v1alpha1.IssueDetails", + encode(message: IssueDetails, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.severity !== 0) { + writer.uint32(8).int32(message.severity); + } + if (message.position !== undefined) { + SourcePosition.encode(message.position, writer.uint32(18).fork()).ldelim(); + } + if (message.id !== undefined) { + writer.uint32(24).int64(message.id); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): IssueDetails { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseIssueDetails(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.severity = (reader.int32() as any); + break; + case 2: + message.position = SourcePosition.decode(reader, reader.uint32()); + break; + case 3: + message.id = reader.int64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): IssueDetails { + const obj = createBaseIssueDetails(); + if (isSet(object.severity)) obj.severity = issueDetails_SeverityFromJSON(object.severity); + if (isSet(object.position)) obj.position = SourcePosition.fromJSON(object.position); + if (isSet(object.id)) obj.id = BigInt(object.id.toString()); + return obj; + }, + toJSON(message: IssueDetails): JsonSafe { + const obj: any = {}; + message.severity !== undefined && (obj.severity = issueDetails_SeverityToJSON(message.severity)); + message.position !== undefined && (obj.position = message.position ? SourcePosition.toJSON(message.position) : undefined); + message.id !== undefined && (obj.id = (message.id || BigInt(0)).toString()); + return obj; + }, + fromPartial(object: DeepPartial): IssueDetails { + const message = createBaseIssueDetails(); + message.severity = object.severity ?? 0; + if (object.position !== undefined && object.position !== null) { + message.position = SourcePosition.fromPartial(object.position); + } + if (object.id !== undefined && object.id !== null) { + message.id = BigInt(object.id.toString()); + } + return message; + }, + fromSDK(object: IssueDetailsSDKType): IssueDetails { + return { + severity: isSet(object.severity) ? issueDetails_SeverityFromJSON(object.severity) : -1, + position: object.position ? SourcePosition.fromSDK(object.position) : undefined, + id: object?.id + }; + }, + fromSDKJSON(object: any): IssueDetailsSDKType { + return { + severity: isSet(object.severity) ? issueDetails_SeverityFromJSON(object.severity) : -1, + position: isSet(object.position) ? SourcePosition.fromSDKJSON(object.position) : undefined, + id: isSet(object.id) ? BigInt(object.id.toString()) : BigInt(0) + }; + }, + toSDK(message: IssueDetails): IssueDetailsSDKType { + const obj: any = {}; + message.severity !== undefined && (obj.severity = issueDetails_SeverityToJSON(message.severity)); + message.position !== undefined && (obj.position = message.position ? SourcePosition.toSDK(message.position) : undefined); + obj.id = message.id; + return obj; + }, + fromAmino(object: IssueDetailsAmino): IssueDetails { + const message = createBaseIssueDetails(); + if (object.severity !== undefined && object.severity !== null) { + message.severity = object.severity; + } + if (object.position !== undefined && object.position !== null) { + message.position = SourcePosition.fromAmino(object.position); + } + if (object.id !== undefined && object.id !== null) { + message.id = BigInt(object.id); + } + return message; + }, + toAmino(message: IssueDetails): IssueDetailsAmino { + const obj: any = {}; + obj.severity = message.severity === 0 ? undefined : message.severity; + obj.position = message.position ? SourcePosition.toAmino(message.position) : undefined; + obj.id = message.id !== BigInt(0) ? message.id?.toString() : undefined; + return obj; + }, + fromAminoMsg(object: IssueDetailsAminoMsg): IssueDetails { + return IssueDetails.fromAmino(object.value); + }, + fromProtoMsg(message: IssueDetailsProtoMsg): IssueDetails { + return IssueDetails.decode(message.value); + }, + toProto(message: IssueDetails): Uint8Array { + return IssueDetails.encode(message).finish(); + }, + toProtoMsg(message: IssueDetails): IssueDetailsProtoMsg { + return { + typeUrl: "/google.api.expr.conformance.v1alpha1.IssueDetails", + value: IssueDetails.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/api/expr/v1alpha1/checked.ts b/__fixtures__/v-next/outputicjsdeps/google/api/expr/v1alpha1/checked.ts new file mode 100644 index 0000000000..893f1e63f0 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/api/expr/v1alpha1/checked.ts @@ -0,0 +1,2454 @@ +import { SourceInfo, SourceInfoSDKType, Expr, ExprSDKType, Constant, ConstantSDKType } from "./syntax.js"; +import { Empty, EmptySDKType } from "../../../protobuf/empty.js"; +import { NullValue, NullValueSDKType, nullValueFromJSON, nullValueToJSON } from "../../../protobuf/struct.js"; +import { BinaryReader, BinaryWriter } from "../../../../binary.js"; +import { isSet, DeepPartial, isObject } from "../../../../helpers.js"; +import { JsonSafe } from "../../../../json-safe.js"; +export const protobufPackage = "google.api.expr.v1alpha1"; +/** CEL primitive types. */ +export enum Type_PrimitiveType { + /** PRIMITIVE_TYPE_UNSPECIFIED - Unspecified type. */ + PRIMITIVE_TYPE_UNSPECIFIED = 0, + /** BOOL - Boolean type. */ + BOOL = 1, + /** + * INT64 - Int64 type. + * + * Proto-based integer values are widened to int64. + */ + INT64 = 2, + /** + * UINT64 - Uint64 type. + * + * Proto-based unsigned integer values are widened to uint64. + */ + UINT64 = 3, + /** + * DOUBLE - Double type. + * + * Proto-based float values are widened to double values. + */ + DOUBLE = 4, + /** STRING - String type. */ + STRING = 5, + /** BYTES - Bytes type. */ + BYTES = 6, + UNRECOGNIZED = -1, +} +export const Type_PrimitiveTypeSDKType = Type_PrimitiveType; +export function type_PrimitiveTypeFromJSON(object: any): Type_PrimitiveType { + switch (object) { + case 0: + case "PRIMITIVE_TYPE_UNSPECIFIED": + return Type_PrimitiveType.PRIMITIVE_TYPE_UNSPECIFIED; + case 1: + case "BOOL": + return Type_PrimitiveType.BOOL; + case 2: + case "INT64": + return Type_PrimitiveType.INT64; + case 3: + case "UINT64": + return Type_PrimitiveType.UINT64; + case 4: + case "DOUBLE": + return Type_PrimitiveType.DOUBLE; + case 5: + case "STRING": + return Type_PrimitiveType.STRING; + case 6: + case "BYTES": + return Type_PrimitiveType.BYTES; + case -1: + case "UNRECOGNIZED": + default: + return Type_PrimitiveType.UNRECOGNIZED; + } +} +export function type_PrimitiveTypeToJSON(object: Type_PrimitiveType): string { + switch (object) { + case Type_PrimitiveType.PRIMITIVE_TYPE_UNSPECIFIED: + return "PRIMITIVE_TYPE_UNSPECIFIED"; + case Type_PrimitiveType.BOOL: + return "BOOL"; + case Type_PrimitiveType.INT64: + return "INT64"; + case Type_PrimitiveType.UINT64: + return "UINT64"; + case Type_PrimitiveType.DOUBLE: + return "DOUBLE"; + case Type_PrimitiveType.STRING: + return "STRING"; + case Type_PrimitiveType.BYTES: + return "BYTES"; + case Type_PrimitiveType.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** Well-known protobuf types treated with first-class support in CEL. */ +export enum Type_WellKnownType { + /** WELL_KNOWN_TYPE_UNSPECIFIED - Unspecified type. */ + WELL_KNOWN_TYPE_UNSPECIFIED = 0, + /** + * ANY - Well-known protobuf.Any type. + * + * Any types are a polymorphic message type. During type-checking they are + * treated like `DYN` types, but at runtime they are resolved to a specific + * message type specified at evaluation time. + */ + ANY = 1, + /** TIMESTAMP - Well-known protobuf.Timestamp type, internally referenced as `timestamp`. */ + TIMESTAMP = 2, + /** DURATION - Well-known protobuf.Duration type, internally referenced as `duration`. */ + DURATION = 3, + UNRECOGNIZED = -1, +} +export const Type_WellKnownTypeSDKType = Type_WellKnownType; +export function type_WellKnownTypeFromJSON(object: any): Type_WellKnownType { + switch (object) { + case 0: + case "WELL_KNOWN_TYPE_UNSPECIFIED": + return Type_WellKnownType.WELL_KNOWN_TYPE_UNSPECIFIED; + case 1: + case "ANY": + return Type_WellKnownType.ANY; + case 2: + case "TIMESTAMP": + return Type_WellKnownType.TIMESTAMP; + case 3: + case "DURATION": + return Type_WellKnownType.DURATION; + case -1: + case "UNRECOGNIZED": + default: + return Type_WellKnownType.UNRECOGNIZED; + } +} +export function type_WellKnownTypeToJSON(object: Type_WellKnownType): string { + switch (object) { + case Type_WellKnownType.WELL_KNOWN_TYPE_UNSPECIFIED: + return "WELL_KNOWN_TYPE_UNSPECIFIED"; + case Type_WellKnownType.ANY: + return "ANY"; + case Type_WellKnownType.TIMESTAMP: + return "TIMESTAMP"; + case Type_WellKnownType.DURATION: + return "DURATION"; + case Type_WellKnownType.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +export interface CheckedExpr_ReferenceMapEntry { + key: bigint; + value?: Reference; +} +export interface CheckedExpr_ReferenceMapEntryProtoMsg { + typeUrl: string; + value: Uint8Array; +} +export interface CheckedExpr_ReferenceMapEntrySDKType { + key: bigint; + value?: ReferenceSDKType; +} +export interface CheckedExpr_TypeMapEntry { + key: bigint; + value?: Type; +} +export interface CheckedExpr_TypeMapEntryProtoMsg { + typeUrl: string; + value: Uint8Array; +} +export interface CheckedExpr_TypeMapEntrySDKType { + key: bigint; + value?: TypeSDKType; +} +/** A CEL expression which has been successfully type checked. */ +export interface CheckedExpr { + /** + * A map from expression ids to resolved references. + * + * The following entries are in this table: + * + * - An Ident or Select expression is represented here if it resolves to a + * declaration. For instance, if `a.b.c` is represented by + * `select(select(id(a), b), c)`, and `a.b` resolves to a declaration, + * while `c` is a field selection, then the reference is attached to the + * nested select expression (but not to the id or or the outer select). + * In turn, if `a` resolves to a declaration and `b.c` are field selections, + * the reference is attached to the ident expression. + * - Every Call expression has an entry here, identifying the function being + * called. + * - Every CreateStruct expression for a message has an entry, identifying + * the message. + */ + referenceMap: { + [key: bigint]: Reference; + }; + /** + * A map from expression ids to types. + * + * Every expression node which has a type different than DYN has a mapping + * here. If an expression has type DYN, it is omitted from this map to save + * space. + */ + typeMap: { + [key: bigint]: Type; + }; + /** + * The source info derived from input that generated the parsed `expr` and + * any optimizations made during the type-checking pass. + */ + sourceInfo?: SourceInfo; + /** + * The expr version indicates the major / minor version number of the `expr` + * representation. + * + * The most common reason for a version change will be to indicate to the CEL + * runtimes that transformations have been performed on the expr during static + * analysis. In some cases, this will save the runtime the work of applying + * the same or similar transformations prior to evaluation. + */ + exprVersion: string; + /** + * The checked expression. Semantically equivalent to the parsed `expr`, but + * may have structural differences. + */ + expr?: Expr; +} +export interface CheckedExprProtoMsg { + typeUrl: "/google.api.expr.v1alpha1.CheckedExpr"; + value: Uint8Array; +} +/** A CEL expression which has been successfully type checked. */ +export interface CheckedExprSDKType { + reference_map: { + [key: bigint]: ReferenceSDKType; + }; + type_map: { + [key: bigint]: TypeSDKType; + }; + source_info?: SourceInfoSDKType; + expr_version: string; + expr?: ExprSDKType; +} +/** Represents a CEL type. */ +export interface Type { + /** Dynamic type. */ + dyn?: Empty; + /** Null value. */ + null?: NullValue; + /** Primitive types: `true`, `1u`, `-2.0`, `'string'`, `b'bytes'`. */ + primitive?: Type_PrimitiveType; + /** Wrapper of a primitive type, e.g. `google.protobuf.Int64Value`. */ + wrapper?: Type_PrimitiveType; + /** Well-known protobuf type such as `google.protobuf.Timestamp`. */ + wellKnown?: Type_WellKnownType; + /** Parameterized list with elements of `list_type`, e.g. `list`. */ + listType?: Type_ListType; + /** Parameterized map with typed keys and values. */ + mapType?: Type_MapType; + /** Function type. */ + function?: Type_FunctionType; + /** + * Protocol buffer message type. + * + * The `message_type` string specifies the qualified message type name. For + * example, `google.plus.Profile`. + */ + messageType?: string; + /** + * Type param type. + * + * The `type_param` string specifies the type parameter name, e.g. `list` + * would be a `list_type` whose element type was a `type_param` type + * named `E`. + */ + typeParam?: string; + /** + * Type type. + * + * The `type` value specifies the target type. e.g. int is type with a + * target type of `Primitive.INT`. + */ + type?: Type; + /** + * Error type. + * + * During type-checking if an expression is an error, its type is propagated + * as the `ERROR` type. This permits the type-checker to discover other + * errors present in the expression. + */ + error?: Empty; + /** Abstract, application defined type. */ + abstractType?: Type_AbstractType; +} +export interface TypeProtoMsg { + typeUrl: "/google.api.expr.v1alpha1.Type"; + value: Uint8Array; +} +/** Represents a CEL type. */ +export interface TypeSDKType { + dyn?: EmptySDKType; + null?: NullValue; + primitive?: Type_PrimitiveType; + wrapper?: Type_PrimitiveType; + well_known?: Type_WellKnownType; + list_type?: Type_ListTypeSDKType; + map_type?: Type_MapTypeSDKType; + function?: Type_FunctionTypeSDKType; + message_type?: string; + type_param?: string; + type?: TypeSDKType; + error?: EmptySDKType; + abstract_type?: Type_AbstractTypeSDKType; +} +/** List type with typed elements, e.g. `list`. */ +export interface Type_ListType { + /** The element type. */ + elemType?: Type; +} +export interface Type_ListTypeProtoMsg { + typeUrl: "/google.api.expr.v1alpha1.ListType"; + value: Uint8Array; +} +/** List type with typed elements, e.g. `list`. */ +export interface Type_ListTypeSDKType { + elem_type?: TypeSDKType; +} +/** Map type with parameterized key and value types, e.g. `map`. */ +export interface Type_MapType { + /** The type of the key. */ + keyType?: Type; + /** The type of the value. */ + valueType?: Type; +} +export interface Type_MapTypeProtoMsg { + typeUrl: "/google.api.expr.v1alpha1.MapType"; + value: Uint8Array; +} +/** Map type with parameterized key and value types, e.g. `map`. */ +export interface Type_MapTypeSDKType { + key_type?: TypeSDKType; + value_type?: TypeSDKType; +} +/** Function type with result and arg types. */ +export interface Type_FunctionType { + /** Result type of the function. */ + resultType?: Type; + /** Argument types of the function. */ + argTypes: Type[]; +} +export interface Type_FunctionTypeProtoMsg { + typeUrl: "/google.api.expr.v1alpha1.FunctionType"; + value: Uint8Array; +} +/** Function type with result and arg types. */ +export interface Type_FunctionTypeSDKType { + result_type?: TypeSDKType; + arg_types: TypeSDKType[]; +} +/** Application defined abstract type. */ +export interface Type_AbstractType { + /** The fully qualified name of this abstract type. */ + name: string; + /** Parameter types for this abstract type. */ + parameterTypes: Type[]; +} +export interface Type_AbstractTypeProtoMsg { + typeUrl: "/google.api.expr.v1alpha1.AbstractType"; + value: Uint8Array; +} +/** Application defined abstract type. */ +export interface Type_AbstractTypeSDKType { + name: string; + parameter_types: TypeSDKType[]; +} +/** + * Represents a declaration of a named value or function. + * + * A declaration is part of the contract between the expression, the agent + * evaluating that expression, and the caller requesting evaluation. + */ +export interface Decl { + /** + * The fully qualified name of the declaration. + * + * Declarations are organized in containers and this represents the full path + * to the declaration in its container, as in `google.api.expr.Decl`. + * + * Declarations used as [FunctionDecl.Overload][google.api.expr.v1alpha1.Decl.FunctionDecl.Overload] parameters may or may not + * have a name depending on whether the overload is function declaration or a + * function definition containing a result [Expr][google.api.expr.v1alpha1.Expr]. + */ + name: string; + /** Identifier declaration. */ + ident?: Decl_IdentDecl; + /** Function declaration. */ + function?: Decl_FunctionDecl; +} +export interface DeclProtoMsg { + typeUrl: "/google.api.expr.v1alpha1.Decl"; + value: Uint8Array; +} +/** + * Represents a declaration of a named value or function. + * + * A declaration is part of the contract between the expression, the agent + * evaluating that expression, and the caller requesting evaluation. + */ +export interface DeclSDKType { + name: string; + ident?: Decl_IdentDeclSDKType; + function?: Decl_FunctionDeclSDKType; +} +/** + * Identifier declaration which specifies its type and optional `Expr` value. + * + * An identifier without a value is a declaration that must be provided at + * evaluation time. An identifier with a value should resolve to a constant, + * but may be used in conjunction with other identifiers bound at evaluation + * time. + */ +export interface Decl_IdentDecl { + /** Required. The type of the identifier. */ + type?: Type; + /** + * The constant value of the identifier. If not specified, the identifier + * must be supplied at evaluation time. + */ + value?: Constant; + /** Documentation string for the identifier. */ + doc: string; +} +export interface Decl_IdentDeclProtoMsg { + typeUrl: "/google.api.expr.v1alpha1.IdentDecl"; + value: Uint8Array; +} +/** + * Identifier declaration which specifies its type and optional `Expr` value. + * + * An identifier without a value is a declaration that must be provided at + * evaluation time. An identifier with a value should resolve to a constant, + * but may be used in conjunction with other identifiers bound at evaluation + * time. + */ +export interface Decl_IdentDeclSDKType { + type?: TypeSDKType; + value?: ConstantSDKType; + doc: string; +} +/** + * Function declaration specifies one or more overloads which indicate the + * function's parameter types and return type. + * + * Functions have no observable side-effects (there may be side-effects like + * logging which are not observable from CEL). + */ +export interface Decl_FunctionDecl { + /** Required. List of function overloads, must contain at least one overload. */ + overloads: Decl_FunctionDecl_Overload[]; +} +export interface Decl_FunctionDeclProtoMsg { + typeUrl: "/google.api.expr.v1alpha1.FunctionDecl"; + value: Uint8Array; +} +/** + * Function declaration specifies one or more overloads which indicate the + * function's parameter types and return type. + * + * Functions have no observable side-effects (there may be side-effects like + * logging which are not observable from CEL). + */ +export interface Decl_FunctionDeclSDKType { + overloads: Decl_FunctionDecl_OverloadSDKType[]; +} +/** + * An overload indicates a function's parameter types and return type, and + * may optionally include a function body described in terms of [Expr][google.api.expr.v1alpha1.Expr] + * values. + * + * Functions overloads are declared in either a function or method + * call-style. For methods, the `params[0]` is the expected type of the + * target receiver. + * + * Overloads must have non-overlapping argument types after erasure of all + * parameterized type variables (similar as type erasure in Java). + */ +export interface Decl_FunctionDecl_Overload { + /** + * Required. Globally unique overload name of the function which reflects + * the function name and argument types. + * + * This will be used by a [Reference][google.api.expr.v1alpha1.Reference] to indicate the `overload_id` that + * was resolved for the function `name`. + */ + overloadId: string; + /** + * List of function parameter [Type][google.api.expr.v1alpha1.Type] values. + * + * Param types are disjoint after generic type parameters have been + * replaced with the type `DYN`. Since the `DYN` type is compatible with + * any other type, this means that if `A` is a type parameter, the + * function types `int` and `int` are not disjoint. Likewise, + * `map` is not disjoint from `map`. + * + * When the `result_type` of a function is a generic type param, the + * type param name also appears as the `type` of on at least one params. + */ + params: Type[]; + /** + * The type param names associated with the function declaration. + * + * For example, `function ex(K key, map map) : V` would yield + * the type params of `K, V`. + */ + typeParams: string[]; + /** + * Required. The result type of the function. For example, the operator + * `string.isEmpty()` would have `result_type` of `kind: BOOL`. + */ + resultType?: Type; + /** + * Whether the function is to be used in a method call-style `x.f(...)` + * of a function call-style `f(x, ...)`. + * + * For methods, the first parameter declaration, `params[0]` is the + * expected type of the target receiver. + */ + isInstanceFunction: boolean; + /** Documentation string for the overload. */ + doc: string; +} +export interface Decl_FunctionDecl_OverloadProtoMsg { + typeUrl: "/google.api.expr.v1alpha1.Overload"; + value: Uint8Array; +} +/** + * An overload indicates a function's parameter types and return type, and + * may optionally include a function body described in terms of [Expr][google.api.expr.v1alpha1.Expr] + * values. + * + * Functions overloads are declared in either a function or method + * call-style. For methods, the `params[0]` is the expected type of the + * target receiver. + * + * Overloads must have non-overlapping argument types after erasure of all + * parameterized type variables (similar as type erasure in Java). + */ +export interface Decl_FunctionDecl_OverloadSDKType { + overload_id: string; + params: TypeSDKType[]; + type_params: string[]; + result_type?: TypeSDKType; + is_instance_function: boolean; + doc: string; +} +/** Describes a resolved reference to a declaration. */ +export interface Reference { + /** The fully qualified name of the declaration. */ + name: string; + /** + * For references to functions, this is a list of `Overload.overload_id` + * values which match according to typing rules. + * + * If the list has more than one element, overload resolution among the + * presented candidates must happen at runtime because of dynamic types. The + * type checker attempts to narrow down this list as much as possible. + * + * Empty if this is not a reference to a [Decl.FunctionDecl][google.api.expr.v1alpha1.Decl.FunctionDecl]. + */ + overloadId: string[]; + /** + * For references to constants, this may contain the value of the + * constant if known at compile time. + */ + value?: Constant; +} +export interface ReferenceProtoMsg { + typeUrl: "/google.api.expr.v1alpha1.Reference"; + value: Uint8Array; +} +/** Describes a resolved reference to a declaration. */ +export interface ReferenceSDKType { + name: string; + overload_id: string[]; + value?: ConstantSDKType; +} +function createBaseCheckedExpr_ReferenceMapEntry(): CheckedExpr_ReferenceMapEntry { + return { + key: BigInt(0), + value: undefined + }; +} +export const CheckedExpr_ReferenceMapEntry = { + encode(message: CheckedExpr_ReferenceMapEntry, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.key !== undefined) { + writer.uint32(8).int64(message.key); + } + if (message.value !== undefined) { + Reference.encode(message.value, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): CheckedExpr_ReferenceMapEntry { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCheckedExpr_ReferenceMapEntry(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.int64(); + break; + case 2: + message.value = Reference.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): CheckedExpr_ReferenceMapEntry { + const obj = createBaseCheckedExpr_ReferenceMapEntry(); + if (isSet(object.key)) obj.key = BigInt(object.key.toString()); + if (isSet(object.value)) obj.value = Reference.fromJSON(object.value); + return obj; + }, + toJSON(message: CheckedExpr_ReferenceMapEntry): JsonSafe { + const obj: any = {}; + message.key !== undefined && (obj.key = (message.key || BigInt(0)).toString()); + message.value !== undefined && (obj.value = message.value ? Reference.toJSON(message.value) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): CheckedExpr_ReferenceMapEntry { + const message = createBaseCheckedExpr_ReferenceMapEntry(); + if (object.key !== undefined && object.key !== null) { + message.key = BigInt(object.key.toString()); + } + if (object.value !== undefined && object.value !== null) { + message.value = Reference.fromPartial(object.value); + } + return message; + }, + fromSDK(object: CheckedExpr_ReferenceMapEntrySDKType): CheckedExpr_ReferenceMapEntry { + return { + key: object?.key, + value: object.value ? Reference.fromSDK(object.value) : undefined + }; + }, + fromSDKJSON(object: any): CheckedExpr_ReferenceMapEntrySDKType { + return { + key: isSet(object.key) ? BigInt(object.key.toString()) : BigInt(0), + value: isSet(object.value) ? Reference.fromSDKJSON(object.value) : undefined + }; + }, + toSDK(message: CheckedExpr_ReferenceMapEntry): CheckedExpr_ReferenceMapEntrySDKType { + const obj: any = {}; + obj.key = message.key; + message.value !== undefined && (obj.value = message.value ? Reference.toSDK(message.value) : undefined); + return obj; + }, + fromAmino(object: CheckedExpr_ReferenceMapEntryAmino): CheckedExpr_ReferenceMapEntry { + const message = createBaseCheckedExpr_ReferenceMapEntry(); + if (object.key !== undefined && object.key !== null) { + message.key = BigInt(object.key); + } + if (object.value !== undefined && object.value !== null) { + message.value = Reference.fromAmino(object.value); + } + return message; + }, + toAmino(message: CheckedExpr_ReferenceMapEntry): CheckedExpr_ReferenceMapEntryAmino { + const obj: any = {}; + obj.key = message.key !== BigInt(0) ? message.key?.toString() : undefined; + obj.value = message.value ? Reference.toAmino(message.value) : undefined; + return obj; + }, + fromAminoMsg(object: CheckedExpr_ReferenceMapEntryAminoMsg): CheckedExpr_ReferenceMapEntry { + return CheckedExpr_ReferenceMapEntry.fromAmino(object.value); + }, + fromProtoMsg(message: CheckedExpr_ReferenceMapEntryProtoMsg): CheckedExpr_ReferenceMapEntry { + return CheckedExpr_ReferenceMapEntry.decode(message.value); + }, + toProto(message: CheckedExpr_ReferenceMapEntry): Uint8Array { + return CheckedExpr_ReferenceMapEntry.encode(message).finish(); + } +}; +function createBaseCheckedExpr_TypeMapEntry(): CheckedExpr_TypeMapEntry { + return { + key: BigInt(0), + value: undefined + }; +} +export const CheckedExpr_TypeMapEntry = { + encode(message: CheckedExpr_TypeMapEntry, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.key !== undefined) { + writer.uint32(8).int64(message.key); + } + if (message.value !== undefined) { + Type.encode(message.value, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): CheckedExpr_TypeMapEntry { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCheckedExpr_TypeMapEntry(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.int64(); + break; + case 2: + message.value = Type.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): CheckedExpr_TypeMapEntry { + const obj = createBaseCheckedExpr_TypeMapEntry(); + if (isSet(object.key)) obj.key = BigInt(object.key.toString()); + if (isSet(object.value)) obj.value = Type.fromJSON(object.value); + return obj; + }, + toJSON(message: CheckedExpr_TypeMapEntry): JsonSafe { + const obj: any = {}; + message.key !== undefined && (obj.key = (message.key || BigInt(0)).toString()); + message.value !== undefined && (obj.value = message.value ? Type.toJSON(message.value) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): CheckedExpr_TypeMapEntry { + const message = createBaseCheckedExpr_TypeMapEntry(); + if (object.key !== undefined && object.key !== null) { + message.key = BigInt(object.key.toString()); + } + if (object.value !== undefined && object.value !== null) { + message.value = Type.fromPartial(object.value); + } + return message; + }, + fromSDK(object: CheckedExpr_TypeMapEntrySDKType): CheckedExpr_TypeMapEntry { + return { + key: object?.key, + value: object.value ? Type.fromSDK(object.value) : undefined + }; + }, + fromSDKJSON(object: any): CheckedExpr_TypeMapEntrySDKType { + return { + key: isSet(object.key) ? BigInt(object.key.toString()) : BigInt(0), + value: isSet(object.value) ? Type.fromSDKJSON(object.value) : undefined + }; + }, + toSDK(message: CheckedExpr_TypeMapEntry): CheckedExpr_TypeMapEntrySDKType { + const obj: any = {}; + obj.key = message.key; + message.value !== undefined && (obj.value = message.value ? Type.toSDK(message.value) : undefined); + return obj; + }, + fromAmino(object: CheckedExpr_TypeMapEntryAmino): CheckedExpr_TypeMapEntry { + const message = createBaseCheckedExpr_TypeMapEntry(); + if (object.key !== undefined && object.key !== null) { + message.key = BigInt(object.key); + } + if (object.value !== undefined && object.value !== null) { + message.value = Type.fromAmino(object.value); + } + return message; + }, + toAmino(message: CheckedExpr_TypeMapEntry): CheckedExpr_TypeMapEntryAmino { + const obj: any = {}; + obj.key = message.key !== BigInt(0) ? message.key?.toString() : undefined; + obj.value = message.value ? Type.toAmino(message.value) : undefined; + return obj; + }, + fromAminoMsg(object: CheckedExpr_TypeMapEntryAminoMsg): CheckedExpr_TypeMapEntry { + return CheckedExpr_TypeMapEntry.fromAmino(object.value); + }, + fromProtoMsg(message: CheckedExpr_TypeMapEntryProtoMsg): CheckedExpr_TypeMapEntry { + return CheckedExpr_TypeMapEntry.decode(message.value); + }, + toProto(message: CheckedExpr_TypeMapEntry): Uint8Array { + return CheckedExpr_TypeMapEntry.encode(message).finish(); + } +}; +function createBaseCheckedExpr(): CheckedExpr { + return { + referenceMap: {}, + typeMap: {}, + sourceInfo: undefined, + exprVersion: "", + expr: undefined + }; +} +export const CheckedExpr = { + typeUrl: "/google.api.expr.v1alpha1.CheckedExpr", + encode(message: CheckedExpr, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + Object.entries(message.referenceMap).forEach(([key, value]) => { + CheckedExpr_ReferenceMapEntry.encode({ + key: (key as any), + value + }, writer.uint32(18).fork()).ldelim(); + }); + Object.entries(message.typeMap).forEach(([key, value]) => { + CheckedExpr_TypeMapEntry.encode({ + key: (key as any), + value + }, writer.uint32(26).fork()).ldelim(); + }); + if (message.sourceInfo !== undefined) { + SourceInfo.encode(message.sourceInfo, writer.uint32(42).fork()).ldelim(); + } + if (message.exprVersion !== undefined) { + writer.uint32(50).string(message.exprVersion); + } + if (message.expr !== undefined) { + Expr.encode(message.expr, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): CheckedExpr { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCheckedExpr(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + const entry2 = CheckedExpr_ReferenceMapEntry.decode(reader, reader.uint32()); + if (entry2.value !== undefined) { + message.referenceMap[entry2.key] = entry2.value; + } + break; + case 3: + const entry3 = CheckedExpr_TypeMapEntry.decode(reader, reader.uint32()); + if (entry3.value !== undefined) { + message.typeMap[entry3.key] = entry3.value; + } + break; + case 5: + message.sourceInfo = SourceInfo.decode(reader, reader.uint32()); + break; + case 6: + message.exprVersion = reader.string(); + break; + case 4: + message.expr = Expr.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): CheckedExpr { + const obj = createBaseCheckedExpr(); + if (isObject(object.referenceMap)) obj.referenceMap = Object.entries(object.referenceMap).reduce<{ + [key: bigint]: Reference; + }>((acc, [key, value]) => { + acc[Number(key)] = Reference.fromJSON(value); + return acc; + }, {}); + if (isObject(object.typeMap)) obj.typeMap = Object.entries(object.typeMap).reduce<{ + [key: bigint]: Type; + }>((acc, [key, value]) => { + acc[Number(key)] = Type.fromJSON(value); + return acc; + }, {}); + if (isSet(object.sourceInfo)) obj.sourceInfo = SourceInfo.fromJSON(object.sourceInfo); + if (isSet(object.exprVersion)) obj.exprVersion = String(object.exprVersion); + if (isSet(object.expr)) obj.expr = Expr.fromJSON(object.expr); + return obj; + }, + toJSON(message: CheckedExpr): JsonSafe { + const obj: any = {}; + obj.referenceMap = {}; + if (message.referenceMap) { + Object.entries(message.referenceMap).forEach(([k, v]) => { + obj.referenceMap[k] = Reference.toJSON(v); + }); + } + obj.typeMap = {}; + if (message.typeMap) { + Object.entries(message.typeMap).forEach(([k, v]) => { + obj.typeMap[k] = Type.toJSON(v); + }); + } + message.sourceInfo !== undefined && (obj.sourceInfo = message.sourceInfo ? SourceInfo.toJSON(message.sourceInfo) : undefined); + message.exprVersion !== undefined && (obj.exprVersion = message.exprVersion); + message.expr !== undefined && (obj.expr = message.expr ? Expr.toJSON(message.expr) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): CheckedExpr { + const message = createBaseCheckedExpr(); + message.referenceMap = Object.entries(object.referenceMap ?? {}).reduce<{ + [key: bigint]: Reference; + }>((acc, [key, value]) => { + if (value !== undefined) { + acc[Number(key)] = Reference.fromPartial(value); + } + return acc; + }, {}); + message.typeMap = Object.entries(object.typeMap ?? {}).reduce<{ + [key: bigint]: Type; + }>((acc, [key, value]) => { + if (value !== undefined) { + acc[Number(key)] = Type.fromPartial(value); + } + return acc; + }, {}); + if (object.sourceInfo !== undefined && object.sourceInfo !== null) { + message.sourceInfo = SourceInfo.fromPartial(object.sourceInfo); + } + message.exprVersion = object.exprVersion ?? ""; + if (object.expr !== undefined && object.expr !== null) { + message.expr = Expr.fromPartial(object.expr); + } + return message; + }, + fromSDK(object: CheckedExprSDKType): CheckedExpr { + return { + referenceMap: isObject(object.reference_map) ? Object.entries(object.reference_map).reduce<{ + [key: bigint]: Reference; + }>((acc, [key, value]) => { + acc[Number(key)] = Reference.fromSDK(value); + return acc; + }, {}) : {}, + typeMap: isObject(object.type_map) ? Object.entries(object.type_map).reduce<{ + [key: bigint]: Type; + }>((acc, [key, value]) => { + acc[Number(key)] = Type.fromSDK(value); + return acc; + }, {}) : {}, + sourceInfo: object.source_info ? SourceInfo.fromSDK(object.source_info) : undefined, + exprVersion: object?.expr_version, + expr: object.expr ? Expr.fromSDK(object.expr) : undefined + }; + }, + fromSDKJSON(object: any): CheckedExprSDKType { + return { + reference_map: isObject(object.reference_map) ? Object.entries(object.reference_map).reduce<{ + [key: bigint]: Reference; + }>((acc, [key, value]) => { + acc[Number(key)] = Reference.fromSDKJSON(value); + return acc; + }, {}) : {}, + type_map: isObject(object.type_map) ? Object.entries(object.type_map).reduce<{ + [key: bigint]: Type; + }>((acc, [key, value]) => { + acc[Number(key)] = Type.fromSDKJSON(value); + return acc; + }, {}) : {}, + source_info: isSet(object.source_info) ? SourceInfo.fromSDKJSON(object.source_info) : undefined, + expr_version: isSet(object.expr_version) ? String(object.expr_version) : "", + expr: isSet(object.expr) ? Expr.fromSDKJSON(object.expr) : undefined + }; + }, + toSDK(message: CheckedExpr): CheckedExprSDKType { + const obj: any = {}; + obj.reference_map = {}; + if (message.referenceMap) { + Object.entries(message.referenceMap).forEach(([k, v]) => { + obj.reference_map[k] = Reference.toSDK(v); + }); + } + obj.type_map = {}; + if (message.typeMap) { + Object.entries(message.typeMap).forEach(([k, v]) => { + obj.type_map[k] = Type.toSDK(v); + }); + } + message.sourceInfo !== undefined && (obj.source_info = message.sourceInfo ? SourceInfo.toSDK(message.sourceInfo) : undefined); + obj.expr_version = message.exprVersion; + message.expr !== undefined && (obj.expr = message.expr ? Expr.toSDK(message.expr) : undefined); + return obj; + }, + fromAmino(object: CheckedExprAmino): CheckedExpr { + const message = createBaseCheckedExpr(); + message.referenceMap = Object.entries(object.reference_map ?? {}).reduce<{ + [key: bigint]: Reference; + }>((acc, [key, value]) => { + if (value !== undefined) { + acc[Number(key)] = Reference.fromAmino(value); + } + return acc; + }, {}); + message.typeMap = Object.entries(object.type_map ?? {}).reduce<{ + [key: bigint]: Type; + }>((acc, [key, value]) => { + if (value !== undefined) { + acc[Number(key)] = Type.fromAmino(value); + } + return acc; + }, {}); + if (object.source_info !== undefined && object.source_info !== null) { + message.sourceInfo = SourceInfo.fromAmino(object.source_info); + } + if (object.expr_version !== undefined && object.expr_version !== null) { + message.exprVersion = object.expr_version; + } + if (object.expr !== undefined && object.expr !== null) { + message.expr = Expr.fromAmino(object.expr); + } + return message; + }, + toAmino(message: CheckedExpr): CheckedExprAmino { + const obj: any = {}; + obj.reference_map = {}; + if (message.referenceMap) { + Object.entries(message.referenceMap).forEach(([k, v]) => { + obj.reference_map[k] = Reference.toAmino(v); + }); + } + obj.type_map = {}; + if (message.typeMap) { + Object.entries(message.typeMap).forEach(([k, v]) => { + obj.type_map[k] = Type.toAmino(v); + }); + } + obj.source_info = message.sourceInfo ? SourceInfo.toAmino(message.sourceInfo) : undefined; + obj.expr_version = message.exprVersion === "" ? undefined : message.exprVersion; + obj.expr = message.expr ? Expr.toAmino(message.expr) : undefined; + return obj; + }, + fromAminoMsg(object: CheckedExprAminoMsg): CheckedExpr { + return CheckedExpr.fromAmino(object.value); + }, + fromProtoMsg(message: CheckedExprProtoMsg): CheckedExpr { + return CheckedExpr.decode(message.value); + }, + toProto(message: CheckedExpr): Uint8Array { + return CheckedExpr.encode(message).finish(); + }, + toProtoMsg(message: CheckedExpr): CheckedExprProtoMsg { + return { + typeUrl: "/google.api.expr.v1alpha1.CheckedExpr", + value: CheckedExpr.encode(message).finish() + }; + } +}; +function createBaseType(): Type { + return { + dyn: undefined, + null: undefined, + primitive: undefined, + wrapper: undefined, + wellKnown: undefined, + listType: undefined, + mapType: undefined, + function: undefined, + messageType: undefined, + typeParam: undefined, + type: undefined, + error: undefined, + abstractType: undefined + }; +} +export const Type = { + typeUrl: "/google.api.expr.v1alpha1.Type", + encode(message: Type, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.dyn !== undefined) { + Empty.encode(message.dyn, writer.uint32(10).fork()).ldelim(); + } + if (message.null !== undefined) { + writer.uint32(16).int32(message.null); + } + if (message.primitive !== undefined) { + writer.uint32(24).int32(message.primitive); + } + if (message.wrapper !== undefined) { + writer.uint32(32).int32(message.wrapper); + } + if (message.wellKnown !== undefined) { + writer.uint32(40).int32(message.wellKnown); + } + if (message.listType !== undefined) { + Type_ListType.encode(message.listType, writer.uint32(50).fork()).ldelim(); + } + if (message.mapType !== undefined) { + Type_MapType.encode(message.mapType, writer.uint32(58).fork()).ldelim(); + } + if (message.function !== undefined) { + Type_FunctionType.encode(message.function, writer.uint32(66).fork()).ldelim(); + } + if (message.messageType !== undefined) { + writer.uint32(74).string(message.messageType); + } + if (message.typeParam !== undefined) { + writer.uint32(82).string(message.typeParam); + } + if (message.type !== undefined) { + Type.encode(message.type, writer.uint32(90).fork()).ldelim(); + } + if (message.error !== undefined) { + Empty.encode(message.error, writer.uint32(98).fork()).ldelim(); + } + if (message.abstractType !== undefined) { + Type_AbstractType.encode(message.abstractType, writer.uint32(114).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Type { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseType(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.dyn = Empty.decode(reader, reader.uint32()); + break; + case 2: + message.null = (reader.int32() as any); + break; + case 3: + message.primitive = (reader.int32() as any); + break; + case 4: + message.wrapper = (reader.int32() as any); + break; + case 5: + message.wellKnown = (reader.int32() as any); + break; + case 6: + message.listType = Type_ListType.decode(reader, reader.uint32()); + break; + case 7: + message.mapType = Type_MapType.decode(reader, reader.uint32()); + break; + case 8: + message.function = Type_FunctionType.decode(reader, reader.uint32()); + break; + case 9: + message.messageType = reader.string(); + break; + case 10: + message.typeParam = reader.string(); + break; + case 11: + message.type = Type.decode(reader, reader.uint32()); + break; + case 12: + message.error = Empty.decode(reader, reader.uint32()); + break; + case 14: + message.abstractType = Type_AbstractType.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Type { + const obj = createBaseType(); + if (isSet(object.dyn)) obj.dyn = Empty.fromJSON(object.dyn); + if (isSet(object.null)) obj.null = nullValueFromJSON(object.null); + if (isSet(object.primitive)) obj.primitive = type_PrimitiveTypeFromJSON(object.primitive); + if (isSet(object.wrapper)) obj.wrapper = type_PrimitiveTypeFromJSON(object.wrapper); + if (isSet(object.wellKnown)) obj.wellKnown = type_WellKnownTypeFromJSON(object.wellKnown); + if (isSet(object.listType)) obj.listType = Type_ListType.fromJSON(object.listType); + if (isSet(object.mapType)) obj.mapType = Type_MapType.fromJSON(object.mapType); + if (isSet(object.function)) obj.function = Type_FunctionType.fromJSON(object.function); + if (isSet(object.messageType)) obj.messageType = String(object.messageType); + if (isSet(object.typeParam)) obj.typeParam = String(object.typeParam); + if (isSet(object.type)) obj.type = Type.fromJSON(object.type); + if (isSet(object.error)) obj.error = Empty.fromJSON(object.error); + if (isSet(object.abstractType)) obj.abstractType = Type_AbstractType.fromJSON(object.abstractType); + return obj; + }, + toJSON(message: Type): JsonSafe { + const obj: any = {}; + message.dyn !== undefined && (obj.dyn = message.dyn ? Empty.toJSON(message.dyn) : undefined); + message.null !== undefined && (obj.null = nullValueToJSON(message.null)); + message.primitive !== undefined && (obj.primitive = type_PrimitiveTypeToJSON(message.primitive)); + message.wrapper !== undefined && (obj.wrapper = type_PrimitiveTypeToJSON(message.wrapper)); + message.wellKnown !== undefined && (obj.wellKnown = type_WellKnownTypeToJSON(message.wellKnown)); + message.listType !== undefined && (obj.listType = message.listType ? Type_ListType.toJSON(message.listType) : undefined); + message.mapType !== undefined && (obj.mapType = message.mapType ? Type_MapType.toJSON(message.mapType) : undefined); + message.function !== undefined && (obj.function = message.function ? Type_FunctionType.toJSON(message.function) : undefined); + message.messageType !== undefined && (obj.messageType = message.messageType); + message.typeParam !== undefined && (obj.typeParam = message.typeParam); + message.type !== undefined && (obj.type = message.type ? Type.toJSON(message.type) : undefined); + message.error !== undefined && (obj.error = message.error ? Empty.toJSON(message.error) : undefined); + message.abstractType !== undefined && (obj.abstractType = message.abstractType ? Type_AbstractType.toJSON(message.abstractType) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): Type { + const message = createBaseType(); + if (object.dyn !== undefined && object.dyn !== null) { + message.dyn = Empty.fromPartial(object.dyn); + } + message.null = object.null ?? undefined; + message.primitive = object.primitive ?? undefined; + message.wrapper = object.wrapper ?? undefined; + message.wellKnown = object.wellKnown ?? undefined; + if (object.listType !== undefined && object.listType !== null) { + message.listType = Type_ListType.fromPartial(object.listType); + } + if (object.mapType !== undefined && object.mapType !== null) { + message.mapType = Type_MapType.fromPartial(object.mapType); + } + if (object.function !== undefined && object.function !== null) { + message.function = Type_FunctionType.fromPartial(object.function); + } + message.messageType = object.messageType ?? undefined; + message.typeParam = object.typeParam ?? undefined; + if (object.type !== undefined && object.type !== null) { + message.type = Type.fromPartial(object.type); + } + if (object.error !== undefined && object.error !== null) { + message.error = Empty.fromPartial(object.error); + } + if (object.abstractType !== undefined && object.abstractType !== null) { + message.abstractType = Type_AbstractType.fromPartial(object.abstractType); + } + return message; + }, + fromSDK(object: TypeSDKType): Type { + return { + dyn: object.dyn ? Empty.fromSDK(object.dyn) : undefined, + null: isSet(object.null) ? nullValueFromJSON(object.null) : undefined, + primitive: isSet(object.primitive) ? type_PrimitiveTypeFromJSON(object.primitive) : undefined, + wrapper: isSet(object.wrapper) ? type_PrimitiveTypeFromJSON(object.wrapper) : undefined, + wellKnown: isSet(object.well_known) ? type_WellKnownTypeFromJSON(object.well_known) : undefined, + listType: object.list_type ? Type_ListType.fromSDK(object.list_type) : undefined, + mapType: object.map_type ? Type_MapType.fromSDK(object.map_type) : undefined, + function: object.function ? Type_FunctionType.fromSDK(object.function) : undefined, + messageType: object?.message_type, + typeParam: object?.type_param, + type: object.type ? Type.fromSDK(object.type) : undefined, + error: object.error ? Empty.fromSDK(object.error) : undefined, + abstractType: object.abstract_type ? Type_AbstractType.fromSDK(object.abstract_type) : undefined + }; + }, + fromSDKJSON(object: any): TypeSDKType { + return { + dyn: isSet(object.dyn) ? Empty.fromSDKJSON(object.dyn) : undefined, + null: isSet(object.null) ? nullValueFromJSON(object.null) : undefined, + primitive: isSet(object.primitive) ? type_PrimitiveTypeFromJSON(object.primitive) : undefined, + wrapper: isSet(object.wrapper) ? type_PrimitiveTypeFromJSON(object.wrapper) : undefined, + well_known: isSet(object.well_known) ? type_WellKnownTypeFromJSON(object.well_known) : undefined, + list_type: isSet(object.list_type) ? Type_ListType.fromSDKJSON(object.list_type) : undefined, + map_type: isSet(object.map_type) ? Type_MapType.fromSDKJSON(object.map_type) : undefined, + function: isSet(object.function) ? Type_FunctionType.fromSDKJSON(object.function) : undefined, + message_type: isSet(object.message_type) ? String(object.message_type) : undefined, + type_param: isSet(object.type_param) ? String(object.type_param) : undefined, + type: isSet(object.type) ? Type.fromSDKJSON(object.type) : undefined, + error: isSet(object.error) ? Empty.fromSDKJSON(object.error) : undefined, + abstract_type: isSet(object.abstract_type) ? Type_AbstractType.fromSDKJSON(object.abstract_type) : undefined + }; + }, + toSDK(message: Type): TypeSDKType { + const obj: any = {}; + message.dyn !== undefined && (obj.dyn = message.dyn ? Empty.toSDK(message.dyn) : undefined); + message.null !== undefined && (obj.null = nullValueToJSON(message.null)); + message.primitive !== undefined && (obj.primitive = type_PrimitiveTypeToJSON(message.primitive)); + message.wrapper !== undefined && (obj.wrapper = type_PrimitiveTypeToJSON(message.wrapper)); + message.wellKnown !== undefined && (obj.well_known = type_WellKnownTypeToJSON(message.wellKnown)); + message.listType !== undefined && (obj.list_type = message.listType ? Type_ListType.toSDK(message.listType) : undefined); + message.mapType !== undefined && (obj.map_type = message.mapType ? Type_MapType.toSDK(message.mapType) : undefined); + message.function !== undefined && (obj.function = message.function ? Type_FunctionType.toSDK(message.function) : undefined); + obj.message_type = message.messageType; + obj.type_param = message.typeParam; + message.type !== undefined && (obj.type = message.type ? Type.toSDK(message.type) : undefined); + message.error !== undefined && (obj.error = message.error ? Empty.toSDK(message.error) : undefined); + message.abstractType !== undefined && (obj.abstract_type = message.abstractType ? Type_AbstractType.toSDK(message.abstractType) : undefined); + return obj; + }, + fromAmino(object: TypeAmino): Type { + const message = createBaseType(); + if (object.dyn !== undefined && object.dyn !== null) { + message.dyn = Empty.fromAmino(object.dyn); + } + if (object.null !== undefined && object.null !== null) { + message.null = object.null; + } + if (object.primitive !== undefined && object.primitive !== null) { + message.primitive = object.primitive; + } + if (object.wrapper !== undefined && object.wrapper !== null) { + message.wrapper = object.wrapper; + } + if (object.well_known !== undefined && object.well_known !== null) { + message.wellKnown = object.well_known; + } + if (object.list_type !== undefined && object.list_type !== null) { + message.listType = Type_ListType.fromAmino(object.list_type); + } + if (object.map_type !== undefined && object.map_type !== null) { + message.mapType = Type_MapType.fromAmino(object.map_type); + } + if (object.function !== undefined && object.function !== null) { + message.function = Type_FunctionType.fromAmino(object.function); + } + if (object.message_type !== undefined && object.message_type !== null) { + message.messageType = object.message_type; + } + if (object.type_param !== undefined && object.type_param !== null) { + message.typeParam = object.type_param; + } + if (object.type !== undefined && object.type !== null) { + message.type = Type.fromAmino(object.type); + } + if (object.error !== undefined && object.error !== null) { + message.error = Empty.fromAmino(object.error); + } + if (object.abstract_type !== undefined && object.abstract_type !== null) { + message.abstractType = Type_AbstractType.fromAmino(object.abstract_type); + } + return message; + }, + toAmino(message: Type): TypeAmino { + const obj: any = {}; + obj.dyn = message.dyn ? Empty.toAmino(message.dyn) : undefined; + obj.null = message.null === null ? undefined : message.null; + obj.primitive = message.primitive === null ? undefined : message.primitive; + obj.wrapper = message.wrapper === null ? undefined : message.wrapper; + obj.well_known = message.wellKnown === null ? undefined : message.wellKnown; + obj.list_type = message.listType ? Type_ListType.toAmino(message.listType) : undefined; + obj.map_type = message.mapType ? Type_MapType.toAmino(message.mapType) : undefined; + obj.function = message.function ? Type_FunctionType.toAmino(message.function) : undefined; + obj.message_type = message.messageType === null ? undefined : message.messageType; + obj.type_param = message.typeParam === null ? undefined : message.typeParam; + obj.type = message.type ? Type.toAmino(message.type) : undefined; + obj.error = message.error ? Empty.toAmino(message.error) : undefined; + obj.abstract_type = message.abstractType ? Type_AbstractType.toAmino(message.abstractType) : undefined; + return obj; + }, + fromAminoMsg(object: TypeAminoMsg): Type { + return Type.fromAmino(object.value); + }, + fromProtoMsg(message: TypeProtoMsg): Type { + return Type.decode(message.value); + }, + toProto(message: Type): Uint8Array { + return Type.encode(message).finish(); + }, + toProtoMsg(message: Type): TypeProtoMsg { + return { + typeUrl: "/google.api.expr.v1alpha1.Type", + value: Type.encode(message).finish() + }; + } +}; +function createBaseType_ListType(): Type_ListType { + return { + elemType: undefined + }; +} +export const Type_ListType = { + typeUrl: "/google.api.expr.v1alpha1.ListType", + encode(message: Type_ListType, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.elemType !== undefined) { + Type.encode(message.elemType, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Type_ListType { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseType_ListType(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.elemType = Type.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Type_ListType { + const obj = createBaseType_ListType(); + if (isSet(object.elemType)) obj.elemType = Type.fromJSON(object.elemType); + return obj; + }, + toJSON(message: Type_ListType): JsonSafe { + const obj: any = {}; + message.elemType !== undefined && (obj.elemType = message.elemType ? Type.toJSON(message.elemType) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): Type_ListType { + const message = createBaseType_ListType(); + if (object.elemType !== undefined && object.elemType !== null) { + message.elemType = Type.fromPartial(object.elemType); + } + return message; + }, + fromSDK(object: Type_ListTypeSDKType): Type_ListType { + return { + elemType: object.elem_type ? Type.fromSDK(object.elem_type) : undefined + }; + }, + fromSDKJSON(object: any): Type_ListTypeSDKType { + return { + elem_type: isSet(object.elem_type) ? Type.fromSDKJSON(object.elem_type) : undefined + }; + }, + toSDK(message: Type_ListType): Type_ListTypeSDKType { + const obj: any = {}; + message.elemType !== undefined && (obj.elem_type = message.elemType ? Type.toSDK(message.elemType) : undefined); + return obj; + }, + fromAmino(object: Type_ListTypeAmino): Type_ListType { + const message = createBaseType_ListType(); + if (object.elem_type !== undefined && object.elem_type !== null) { + message.elemType = Type.fromAmino(object.elem_type); + } + return message; + }, + toAmino(message: Type_ListType): Type_ListTypeAmino { + const obj: any = {}; + obj.elem_type = message.elemType ? Type.toAmino(message.elemType) : undefined; + return obj; + }, + fromAminoMsg(object: Type_ListTypeAminoMsg): Type_ListType { + return Type_ListType.fromAmino(object.value); + }, + fromProtoMsg(message: Type_ListTypeProtoMsg): Type_ListType { + return Type_ListType.decode(message.value); + }, + toProto(message: Type_ListType): Uint8Array { + return Type_ListType.encode(message).finish(); + }, + toProtoMsg(message: Type_ListType): Type_ListTypeProtoMsg { + return { + typeUrl: "/google.api.expr.v1alpha1.ListType", + value: Type_ListType.encode(message).finish() + }; + } +}; +function createBaseType_MapType(): Type_MapType { + return { + keyType: undefined, + valueType: undefined + }; +} +export const Type_MapType = { + typeUrl: "/google.api.expr.v1alpha1.MapType", + encode(message: Type_MapType, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.keyType !== undefined) { + Type.encode(message.keyType, writer.uint32(10).fork()).ldelim(); + } + if (message.valueType !== undefined) { + Type.encode(message.valueType, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Type_MapType { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseType_MapType(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.keyType = Type.decode(reader, reader.uint32()); + break; + case 2: + message.valueType = Type.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Type_MapType { + const obj = createBaseType_MapType(); + if (isSet(object.keyType)) obj.keyType = Type.fromJSON(object.keyType); + if (isSet(object.valueType)) obj.valueType = Type.fromJSON(object.valueType); + return obj; + }, + toJSON(message: Type_MapType): JsonSafe { + const obj: any = {}; + message.keyType !== undefined && (obj.keyType = message.keyType ? Type.toJSON(message.keyType) : undefined); + message.valueType !== undefined && (obj.valueType = message.valueType ? Type.toJSON(message.valueType) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): Type_MapType { + const message = createBaseType_MapType(); + if (object.keyType !== undefined && object.keyType !== null) { + message.keyType = Type.fromPartial(object.keyType); + } + if (object.valueType !== undefined && object.valueType !== null) { + message.valueType = Type.fromPartial(object.valueType); + } + return message; + }, + fromSDK(object: Type_MapTypeSDKType): Type_MapType { + return { + keyType: object.key_type ? Type.fromSDK(object.key_type) : undefined, + valueType: object.value_type ? Type.fromSDK(object.value_type) : undefined + }; + }, + fromSDKJSON(object: any): Type_MapTypeSDKType { + return { + key_type: isSet(object.key_type) ? Type.fromSDKJSON(object.key_type) : undefined, + value_type: isSet(object.value_type) ? Type.fromSDKJSON(object.value_type) : undefined + }; + }, + toSDK(message: Type_MapType): Type_MapTypeSDKType { + const obj: any = {}; + message.keyType !== undefined && (obj.key_type = message.keyType ? Type.toSDK(message.keyType) : undefined); + message.valueType !== undefined && (obj.value_type = message.valueType ? Type.toSDK(message.valueType) : undefined); + return obj; + }, + fromAmino(object: Type_MapTypeAmino): Type_MapType { + const message = createBaseType_MapType(); + if (object.key_type !== undefined && object.key_type !== null) { + message.keyType = Type.fromAmino(object.key_type); + } + if (object.value_type !== undefined && object.value_type !== null) { + message.valueType = Type.fromAmino(object.value_type); + } + return message; + }, + toAmino(message: Type_MapType): Type_MapTypeAmino { + const obj: any = {}; + obj.key_type = message.keyType ? Type.toAmino(message.keyType) : undefined; + obj.value_type = message.valueType ? Type.toAmino(message.valueType) : undefined; + return obj; + }, + fromAminoMsg(object: Type_MapTypeAminoMsg): Type_MapType { + return Type_MapType.fromAmino(object.value); + }, + fromProtoMsg(message: Type_MapTypeProtoMsg): Type_MapType { + return Type_MapType.decode(message.value); + }, + toProto(message: Type_MapType): Uint8Array { + return Type_MapType.encode(message).finish(); + }, + toProtoMsg(message: Type_MapType): Type_MapTypeProtoMsg { + return { + typeUrl: "/google.api.expr.v1alpha1.MapType", + value: Type_MapType.encode(message).finish() + }; + } +}; +function createBaseType_FunctionType(): Type_FunctionType { + return { + resultType: undefined, + argTypes: [] + }; +} +export const Type_FunctionType = { + typeUrl: "/google.api.expr.v1alpha1.FunctionType", + encode(message: Type_FunctionType, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.resultType !== undefined) { + Type.encode(message.resultType, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.argTypes) { + Type.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Type_FunctionType { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseType_FunctionType(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.resultType = Type.decode(reader, reader.uint32()); + break; + case 2: + message.argTypes.push(Type.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Type_FunctionType { + const obj = createBaseType_FunctionType(); + if (isSet(object.resultType)) obj.resultType = Type.fromJSON(object.resultType); + if (Array.isArray(object?.argTypes)) obj.argTypes = object.argTypes.map((e: any) => Type.fromJSON(e)); + return obj; + }, + toJSON(message: Type_FunctionType): JsonSafe { + const obj: any = {}; + message.resultType !== undefined && (obj.resultType = message.resultType ? Type.toJSON(message.resultType) : undefined); + if (message.argTypes) { + obj.argTypes = message.argTypes.map(e => e ? Type.toJSON(e) : undefined); + } else { + obj.argTypes = []; + } + return obj; + }, + fromPartial(object: DeepPartial): Type_FunctionType { + const message = createBaseType_FunctionType(); + if (object.resultType !== undefined && object.resultType !== null) { + message.resultType = Type.fromPartial(object.resultType); + } + message.argTypes = object.argTypes?.map(e => Type.fromPartial(e)) || []; + return message; + }, + fromSDK(object: Type_FunctionTypeSDKType): Type_FunctionType { + return { + resultType: object.result_type ? Type.fromSDK(object.result_type) : undefined, + argTypes: Array.isArray(object?.arg_types) ? object.arg_types.map((e: any) => Type.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): Type_FunctionTypeSDKType { + return { + result_type: isSet(object.result_type) ? Type.fromSDKJSON(object.result_type) : undefined, + arg_types: Array.isArray(object?.arg_types) ? object.arg_types.map((e: any) => Type.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: Type_FunctionType): Type_FunctionTypeSDKType { + const obj: any = {}; + message.resultType !== undefined && (obj.result_type = message.resultType ? Type.toSDK(message.resultType) : undefined); + if (message.argTypes) { + obj.arg_types = message.argTypes.map(e => e ? Type.toSDK(e) : undefined); + } else { + obj.arg_types = []; + } + return obj; + }, + fromAmino(object: Type_FunctionTypeAmino): Type_FunctionType { + const message = createBaseType_FunctionType(); + if (object.result_type !== undefined && object.result_type !== null) { + message.resultType = Type.fromAmino(object.result_type); + } + message.argTypes = object.arg_types?.map(e => Type.fromAmino(e)) || []; + return message; + }, + toAmino(message: Type_FunctionType): Type_FunctionTypeAmino { + const obj: any = {}; + obj.result_type = message.resultType ? Type.toAmino(message.resultType) : undefined; + if (message.argTypes) { + obj.arg_types = message.argTypes.map(e => e ? Type.toAmino(e) : undefined); + } else { + obj.arg_types = message.argTypes; + } + return obj; + }, + fromAminoMsg(object: Type_FunctionTypeAminoMsg): Type_FunctionType { + return Type_FunctionType.fromAmino(object.value); + }, + fromProtoMsg(message: Type_FunctionTypeProtoMsg): Type_FunctionType { + return Type_FunctionType.decode(message.value); + }, + toProto(message: Type_FunctionType): Uint8Array { + return Type_FunctionType.encode(message).finish(); + }, + toProtoMsg(message: Type_FunctionType): Type_FunctionTypeProtoMsg { + return { + typeUrl: "/google.api.expr.v1alpha1.FunctionType", + value: Type_FunctionType.encode(message).finish() + }; + } +}; +function createBaseType_AbstractType(): Type_AbstractType { + return { + name: "", + parameterTypes: [] + }; +} +export const Type_AbstractType = { + typeUrl: "/google.api.expr.v1alpha1.AbstractType", + encode(message: Type_AbstractType, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + for (const v of message.parameterTypes) { + Type.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Type_AbstractType { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseType_AbstractType(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.parameterTypes.push(Type.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Type_AbstractType { + const obj = createBaseType_AbstractType(); + if (isSet(object.name)) obj.name = String(object.name); + if (Array.isArray(object?.parameterTypes)) obj.parameterTypes = object.parameterTypes.map((e: any) => Type.fromJSON(e)); + return obj; + }, + toJSON(message: Type_AbstractType): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.parameterTypes) { + obj.parameterTypes = message.parameterTypes.map(e => e ? Type.toJSON(e) : undefined); + } else { + obj.parameterTypes = []; + } + return obj; + }, + fromPartial(object: DeepPartial): Type_AbstractType { + const message = createBaseType_AbstractType(); + message.name = object.name ?? ""; + message.parameterTypes = object.parameterTypes?.map(e => Type.fromPartial(e)) || []; + return message; + }, + fromSDK(object: Type_AbstractTypeSDKType): Type_AbstractType { + return { + name: object?.name, + parameterTypes: Array.isArray(object?.parameter_types) ? object.parameter_types.map((e: any) => Type.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): Type_AbstractTypeSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + parameter_types: Array.isArray(object?.parameter_types) ? object.parameter_types.map((e: any) => Type.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: Type_AbstractType): Type_AbstractTypeSDKType { + const obj: any = {}; + obj.name = message.name; + if (message.parameterTypes) { + obj.parameter_types = message.parameterTypes.map(e => e ? Type.toSDK(e) : undefined); + } else { + obj.parameter_types = []; + } + return obj; + }, + fromAmino(object: Type_AbstractTypeAmino): Type_AbstractType { + const message = createBaseType_AbstractType(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + message.parameterTypes = object.parameter_types?.map(e => Type.fromAmino(e)) || []; + return message; + }, + toAmino(message: Type_AbstractType): Type_AbstractTypeAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + if (message.parameterTypes) { + obj.parameter_types = message.parameterTypes.map(e => e ? Type.toAmino(e) : undefined); + } else { + obj.parameter_types = message.parameterTypes; + } + return obj; + }, + fromAminoMsg(object: Type_AbstractTypeAminoMsg): Type_AbstractType { + return Type_AbstractType.fromAmino(object.value); + }, + fromProtoMsg(message: Type_AbstractTypeProtoMsg): Type_AbstractType { + return Type_AbstractType.decode(message.value); + }, + toProto(message: Type_AbstractType): Uint8Array { + return Type_AbstractType.encode(message).finish(); + }, + toProtoMsg(message: Type_AbstractType): Type_AbstractTypeProtoMsg { + return { + typeUrl: "/google.api.expr.v1alpha1.AbstractType", + value: Type_AbstractType.encode(message).finish() + }; + } +}; +function createBaseDecl(): Decl { + return { + name: "", + ident: undefined, + function: undefined + }; +} +export const Decl = { + typeUrl: "/google.api.expr.v1alpha1.Decl", + encode(message: Decl, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + if (message.ident !== undefined) { + Decl_IdentDecl.encode(message.ident, writer.uint32(18).fork()).ldelim(); + } + if (message.function !== undefined) { + Decl_FunctionDecl.encode(message.function, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Decl { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDecl(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.ident = Decl_IdentDecl.decode(reader, reader.uint32()); + break; + case 3: + message.function = Decl_FunctionDecl.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Decl { + const obj = createBaseDecl(); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.ident)) obj.ident = Decl_IdentDecl.fromJSON(object.ident); + if (isSet(object.function)) obj.function = Decl_FunctionDecl.fromJSON(object.function); + return obj; + }, + toJSON(message: Decl): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.ident !== undefined && (obj.ident = message.ident ? Decl_IdentDecl.toJSON(message.ident) : undefined); + message.function !== undefined && (obj.function = message.function ? Decl_FunctionDecl.toJSON(message.function) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): Decl { + const message = createBaseDecl(); + message.name = object.name ?? ""; + if (object.ident !== undefined && object.ident !== null) { + message.ident = Decl_IdentDecl.fromPartial(object.ident); + } + if (object.function !== undefined && object.function !== null) { + message.function = Decl_FunctionDecl.fromPartial(object.function); + } + return message; + }, + fromSDK(object: DeclSDKType): Decl { + return { + name: object?.name, + ident: object.ident ? Decl_IdentDecl.fromSDK(object.ident) : undefined, + function: object.function ? Decl_FunctionDecl.fromSDK(object.function) : undefined + }; + }, + fromSDKJSON(object: any): DeclSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + ident: isSet(object.ident) ? Decl_IdentDecl.fromSDKJSON(object.ident) : undefined, + function: isSet(object.function) ? Decl_FunctionDecl.fromSDKJSON(object.function) : undefined + }; + }, + toSDK(message: Decl): DeclSDKType { + const obj: any = {}; + obj.name = message.name; + message.ident !== undefined && (obj.ident = message.ident ? Decl_IdentDecl.toSDK(message.ident) : undefined); + message.function !== undefined && (obj.function = message.function ? Decl_FunctionDecl.toSDK(message.function) : undefined); + return obj; + }, + fromAmino(object: DeclAmino): Decl { + const message = createBaseDecl(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + if (object.ident !== undefined && object.ident !== null) { + message.ident = Decl_IdentDecl.fromAmino(object.ident); + } + if (object.function !== undefined && object.function !== null) { + message.function = Decl_FunctionDecl.fromAmino(object.function); + } + return message; + }, + toAmino(message: Decl): DeclAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + obj.ident = message.ident ? Decl_IdentDecl.toAmino(message.ident) : undefined; + obj.function = message.function ? Decl_FunctionDecl.toAmino(message.function) : undefined; + return obj; + }, + fromAminoMsg(object: DeclAminoMsg): Decl { + return Decl.fromAmino(object.value); + }, + fromProtoMsg(message: DeclProtoMsg): Decl { + return Decl.decode(message.value); + }, + toProto(message: Decl): Uint8Array { + return Decl.encode(message).finish(); + }, + toProtoMsg(message: Decl): DeclProtoMsg { + return { + typeUrl: "/google.api.expr.v1alpha1.Decl", + value: Decl.encode(message).finish() + }; + } +}; +function createBaseDecl_IdentDecl(): Decl_IdentDecl { + return { + type: undefined, + value: undefined, + doc: "" + }; +} +export const Decl_IdentDecl = { + typeUrl: "/google.api.expr.v1alpha1.IdentDecl", + encode(message: Decl_IdentDecl, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.type !== undefined) { + Type.encode(message.type, writer.uint32(10).fork()).ldelim(); + } + if (message.value !== undefined) { + Constant.encode(message.value, writer.uint32(18).fork()).ldelim(); + } + if (message.doc !== undefined) { + writer.uint32(26).string(message.doc); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Decl_IdentDecl { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDecl_IdentDecl(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.type = Type.decode(reader, reader.uint32()); + break; + case 2: + message.value = Constant.decode(reader, reader.uint32()); + break; + case 3: + message.doc = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Decl_IdentDecl { + const obj = createBaseDecl_IdentDecl(); + if (isSet(object.type)) obj.type = Type.fromJSON(object.type); + if (isSet(object.value)) obj.value = Constant.fromJSON(object.value); + if (isSet(object.doc)) obj.doc = String(object.doc); + return obj; + }, + toJSON(message: Decl_IdentDecl): JsonSafe { + const obj: any = {}; + message.type !== undefined && (obj.type = message.type ? Type.toJSON(message.type) : undefined); + message.value !== undefined && (obj.value = message.value ? Constant.toJSON(message.value) : undefined); + message.doc !== undefined && (obj.doc = message.doc); + return obj; + }, + fromPartial(object: DeepPartial): Decl_IdentDecl { + const message = createBaseDecl_IdentDecl(); + if (object.type !== undefined && object.type !== null) { + message.type = Type.fromPartial(object.type); + } + if (object.value !== undefined && object.value !== null) { + message.value = Constant.fromPartial(object.value); + } + message.doc = object.doc ?? ""; + return message; + }, + fromSDK(object: Decl_IdentDeclSDKType): Decl_IdentDecl { + return { + type: object.type ? Type.fromSDK(object.type) : undefined, + value: object.value ? Constant.fromSDK(object.value) : undefined, + doc: object?.doc + }; + }, + fromSDKJSON(object: any): Decl_IdentDeclSDKType { + return { + type: isSet(object.type) ? Type.fromSDKJSON(object.type) : undefined, + value: isSet(object.value) ? Constant.fromSDKJSON(object.value) : undefined, + doc: isSet(object.doc) ? String(object.doc) : "" + }; + }, + toSDK(message: Decl_IdentDecl): Decl_IdentDeclSDKType { + const obj: any = {}; + message.type !== undefined && (obj.type = message.type ? Type.toSDK(message.type) : undefined); + message.value !== undefined && (obj.value = message.value ? Constant.toSDK(message.value) : undefined); + obj.doc = message.doc; + return obj; + }, + fromAmino(object: Decl_IdentDeclAmino): Decl_IdentDecl { + const message = createBaseDecl_IdentDecl(); + if (object.type !== undefined && object.type !== null) { + message.type = Type.fromAmino(object.type); + } + if (object.value !== undefined && object.value !== null) { + message.value = Constant.fromAmino(object.value); + } + if (object.doc !== undefined && object.doc !== null) { + message.doc = object.doc; + } + return message; + }, + toAmino(message: Decl_IdentDecl): Decl_IdentDeclAmino { + const obj: any = {}; + obj.type = message.type ? Type.toAmino(message.type) : undefined; + obj.value = message.value ? Constant.toAmino(message.value) : undefined; + obj.doc = message.doc === "" ? undefined : message.doc; + return obj; + }, + fromAminoMsg(object: Decl_IdentDeclAminoMsg): Decl_IdentDecl { + return Decl_IdentDecl.fromAmino(object.value); + }, + fromProtoMsg(message: Decl_IdentDeclProtoMsg): Decl_IdentDecl { + return Decl_IdentDecl.decode(message.value); + }, + toProto(message: Decl_IdentDecl): Uint8Array { + return Decl_IdentDecl.encode(message).finish(); + }, + toProtoMsg(message: Decl_IdentDecl): Decl_IdentDeclProtoMsg { + return { + typeUrl: "/google.api.expr.v1alpha1.IdentDecl", + value: Decl_IdentDecl.encode(message).finish() + }; + } +}; +function createBaseDecl_FunctionDecl(): Decl_FunctionDecl { + return { + overloads: [] + }; +} +export const Decl_FunctionDecl = { + typeUrl: "/google.api.expr.v1alpha1.FunctionDecl", + encode(message: Decl_FunctionDecl, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.overloads) { + Decl_FunctionDecl_Overload.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Decl_FunctionDecl { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDecl_FunctionDecl(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.overloads.push(Decl_FunctionDecl_Overload.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Decl_FunctionDecl { + const obj = createBaseDecl_FunctionDecl(); + if (Array.isArray(object?.overloads)) obj.overloads = object.overloads.map((e: any) => Decl_FunctionDecl_Overload.fromJSON(e)); + return obj; + }, + toJSON(message: Decl_FunctionDecl): JsonSafe { + const obj: any = {}; + if (message.overloads) { + obj.overloads = message.overloads.map(e => e ? Decl_FunctionDecl_Overload.toJSON(e) : undefined); + } else { + obj.overloads = []; + } + return obj; + }, + fromPartial(object: DeepPartial): Decl_FunctionDecl { + const message = createBaseDecl_FunctionDecl(); + message.overloads = object.overloads?.map(e => Decl_FunctionDecl_Overload.fromPartial(e)) || []; + return message; + }, + fromSDK(object: Decl_FunctionDeclSDKType): Decl_FunctionDecl { + return { + overloads: Array.isArray(object?.overloads) ? object.overloads.map((e: any) => Decl_FunctionDecl_Overload.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): Decl_FunctionDeclSDKType { + return { + overloads: Array.isArray(object?.overloads) ? object.overloads.map((e: any) => Decl_FunctionDecl_Overload.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: Decl_FunctionDecl): Decl_FunctionDeclSDKType { + const obj: any = {}; + if (message.overloads) { + obj.overloads = message.overloads.map(e => e ? Decl_FunctionDecl_Overload.toSDK(e) : undefined); + } else { + obj.overloads = []; + } + return obj; + }, + fromAmino(object: Decl_FunctionDeclAmino): Decl_FunctionDecl { + const message = createBaseDecl_FunctionDecl(); + message.overloads = object.overloads?.map(e => Decl_FunctionDecl_Overload.fromAmino(e)) || []; + return message; + }, + toAmino(message: Decl_FunctionDecl): Decl_FunctionDeclAmino { + const obj: any = {}; + if (message.overloads) { + obj.overloads = message.overloads.map(e => e ? Decl_FunctionDecl_Overload.toAmino(e) : undefined); + } else { + obj.overloads = message.overloads; + } + return obj; + }, + fromAminoMsg(object: Decl_FunctionDeclAminoMsg): Decl_FunctionDecl { + return Decl_FunctionDecl.fromAmino(object.value); + }, + fromProtoMsg(message: Decl_FunctionDeclProtoMsg): Decl_FunctionDecl { + return Decl_FunctionDecl.decode(message.value); + }, + toProto(message: Decl_FunctionDecl): Uint8Array { + return Decl_FunctionDecl.encode(message).finish(); + }, + toProtoMsg(message: Decl_FunctionDecl): Decl_FunctionDeclProtoMsg { + return { + typeUrl: "/google.api.expr.v1alpha1.FunctionDecl", + value: Decl_FunctionDecl.encode(message).finish() + }; + } +}; +function createBaseDecl_FunctionDecl_Overload(): Decl_FunctionDecl_Overload { + return { + overloadId: "", + params: [], + typeParams: [], + resultType: undefined, + isInstanceFunction: false, + doc: "" + }; +} +export const Decl_FunctionDecl_Overload = { + typeUrl: "/google.api.expr.v1alpha1.Overload", + encode(message: Decl_FunctionDecl_Overload, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.overloadId !== undefined) { + writer.uint32(10).string(message.overloadId); + } + for (const v of message.params) { + Type.encode(v!, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.typeParams) { + writer.uint32(26).string(v!); + } + if (message.resultType !== undefined) { + Type.encode(message.resultType, writer.uint32(34).fork()).ldelim(); + } + if (message.isInstanceFunction !== undefined) { + writer.uint32(40).bool(message.isInstanceFunction); + } + if (message.doc !== undefined) { + writer.uint32(50).string(message.doc); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Decl_FunctionDecl_Overload { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDecl_FunctionDecl_Overload(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.overloadId = reader.string(); + break; + case 2: + message.params.push(Type.decode(reader, reader.uint32())); + break; + case 3: + message.typeParams.push(reader.string()); + break; + case 4: + message.resultType = Type.decode(reader, reader.uint32()); + break; + case 5: + message.isInstanceFunction = reader.bool(); + break; + case 6: + message.doc = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Decl_FunctionDecl_Overload { + const obj = createBaseDecl_FunctionDecl_Overload(); + if (isSet(object.overloadId)) obj.overloadId = String(object.overloadId); + if (Array.isArray(object?.params)) obj.params = object.params.map((e: any) => Type.fromJSON(e)); + if (Array.isArray(object?.typeParams)) obj.typeParams = object.typeParams.map((e: any) => String(e)); + if (isSet(object.resultType)) obj.resultType = Type.fromJSON(object.resultType); + if (isSet(object.isInstanceFunction)) obj.isInstanceFunction = Boolean(object.isInstanceFunction); + if (isSet(object.doc)) obj.doc = String(object.doc); + return obj; + }, + toJSON(message: Decl_FunctionDecl_Overload): JsonSafe { + const obj: any = {}; + message.overloadId !== undefined && (obj.overloadId = message.overloadId); + if (message.params) { + obj.params = message.params.map(e => e ? Type.toJSON(e) : undefined); + } else { + obj.params = []; + } + if (message.typeParams) { + obj.typeParams = message.typeParams.map(e => e); + } else { + obj.typeParams = []; + } + message.resultType !== undefined && (obj.resultType = message.resultType ? Type.toJSON(message.resultType) : undefined); + message.isInstanceFunction !== undefined && (obj.isInstanceFunction = message.isInstanceFunction); + message.doc !== undefined && (obj.doc = message.doc); + return obj; + }, + fromPartial(object: DeepPartial): Decl_FunctionDecl_Overload { + const message = createBaseDecl_FunctionDecl_Overload(); + message.overloadId = object.overloadId ?? ""; + message.params = object.params?.map(e => Type.fromPartial(e)) || []; + message.typeParams = object.typeParams?.map(e => e) || []; + if (object.resultType !== undefined && object.resultType !== null) { + message.resultType = Type.fromPartial(object.resultType); + } + message.isInstanceFunction = object.isInstanceFunction ?? false; + message.doc = object.doc ?? ""; + return message; + }, + fromSDK(object: Decl_FunctionDecl_OverloadSDKType): Decl_FunctionDecl_Overload { + return { + overloadId: object?.overload_id, + params: Array.isArray(object?.params) ? object.params.map((e: any) => Type.fromSDK(e)) : [], + typeParams: Array.isArray(object?.type_params) ? object.type_params.map((e: any) => e) : [], + resultType: object.result_type ? Type.fromSDK(object.result_type) : undefined, + isInstanceFunction: object?.is_instance_function, + doc: object?.doc + }; + }, + fromSDKJSON(object: any): Decl_FunctionDecl_OverloadSDKType { + return { + overload_id: isSet(object.overload_id) ? String(object.overload_id) : "", + params: Array.isArray(object?.params) ? object.params.map((e: any) => Type.fromSDKJSON(e)) : [], + type_params: Array.isArray(object?.type_params) ? object.type_params.map((e: any) => String(e)) : [], + result_type: isSet(object.result_type) ? Type.fromSDKJSON(object.result_type) : undefined, + is_instance_function: isSet(object.is_instance_function) ? Boolean(object.is_instance_function) : false, + doc: isSet(object.doc) ? String(object.doc) : "" + }; + }, + toSDK(message: Decl_FunctionDecl_Overload): Decl_FunctionDecl_OverloadSDKType { + const obj: any = {}; + obj.overload_id = message.overloadId; + if (message.params) { + obj.params = message.params.map(e => e ? Type.toSDK(e) : undefined); + } else { + obj.params = []; + } + if (message.typeParams) { + obj.type_params = message.typeParams.map(e => e); + } else { + obj.type_params = []; + } + message.resultType !== undefined && (obj.result_type = message.resultType ? Type.toSDK(message.resultType) : undefined); + obj.is_instance_function = message.isInstanceFunction; + obj.doc = message.doc; + return obj; + }, + fromAmino(object: Decl_FunctionDecl_OverloadAmino): Decl_FunctionDecl_Overload { + const message = createBaseDecl_FunctionDecl_Overload(); + if (object.overload_id !== undefined && object.overload_id !== null) { + message.overloadId = object.overload_id; + } + message.params = object.params?.map(e => Type.fromAmino(e)) || []; + message.typeParams = object.type_params?.map(e => e) || []; + if (object.result_type !== undefined && object.result_type !== null) { + message.resultType = Type.fromAmino(object.result_type); + } + if (object.is_instance_function !== undefined && object.is_instance_function !== null) { + message.isInstanceFunction = object.is_instance_function; + } + if (object.doc !== undefined && object.doc !== null) { + message.doc = object.doc; + } + return message; + }, + toAmino(message: Decl_FunctionDecl_Overload): Decl_FunctionDecl_OverloadAmino { + const obj: any = {}; + obj.overload_id = message.overloadId === "" ? undefined : message.overloadId; + if (message.params) { + obj.params = message.params.map(e => e ? Type.toAmino(e) : undefined); + } else { + obj.params = message.params; + } + if (message.typeParams) { + obj.type_params = message.typeParams.map(e => e); + } else { + obj.type_params = message.typeParams; + } + obj.result_type = message.resultType ? Type.toAmino(message.resultType) : undefined; + obj.is_instance_function = message.isInstanceFunction === false ? undefined : message.isInstanceFunction; + obj.doc = message.doc === "" ? undefined : message.doc; + return obj; + }, + fromAminoMsg(object: Decl_FunctionDecl_OverloadAminoMsg): Decl_FunctionDecl_Overload { + return Decl_FunctionDecl_Overload.fromAmino(object.value); + }, + fromProtoMsg(message: Decl_FunctionDecl_OverloadProtoMsg): Decl_FunctionDecl_Overload { + return Decl_FunctionDecl_Overload.decode(message.value); + }, + toProto(message: Decl_FunctionDecl_Overload): Uint8Array { + return Decl_FunctionDecl_Overload.encode(message).finish(); + }, + toProtoMsg(message: Decl_FunctionDecl_Overload): Decl_FunctionDecl_OverloadProtoMsg { + return { + typeUrl: "/google.api.expr.v1alpha1.Overload", + value: Decl_FunctionDecl_Overload.encode(message).finish() + }; + } +}; +function createBaseReference(): Reference { + return { + name: "", + overloadId: [], + value: undefined + }; +} +export const Reference = { + typeUrl: "/google.api.expr.v1alpha1.Reference", + encode(message: Reference, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + for (const v of message.overloadId) { + writer.uint32(26).string(v!); + } + if (message.value !== undefined) { + Constant.encode(message.value, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Reference { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseReference(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 3: + message.overloadId.push(reader.string()); + break; + case 4: + message.value = Constant.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Reference { + const obj = createBaseReference(); + if (isSet(object.name)) obj.name = String(object.name); + if (Array.isArray(object?.overloadId)) obj.overloadId = object.overloadId.map((e: any) => String(e)); + if (isSet(object.value)) obj.value = Constant.fromJSON(object.value); + return obj; + }, + toJSON(message: Reference): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.overloadId) { + obj.overloadId = message.overloadId.map(e => e); + } else { + obj.overloadId = []; + } + message.value !== undefined && (obj.value = message.value ? Constant.toJSON(message.value) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): Reference { + const message = createBaseReference(); + message.name = object.name ?? ""; + message.overloadId = object.overloadId?.map(e => e) || []; + if (object.value !== undefined && object.value !== null) { + message.value = Constant.fromPartial(object.value); + } + return message; + }, + fromSDK(object: ReferenceSDKType): Reference { + return { + name: object?.name, + overloadId: Array.isArray(object?.overload_id) ? object.overload_id.map((e: any) => e) : [], + value: object.value ? Constant.fromSDK(object.value) : undefined + }; + }, + fromSDKJSON(object: any): ReferenceSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + overload_id: Array.isArray(object?.overload_id) ? object.overload_id.map((e: any) => String(e)) : [], + value: isSet(object.value) ? Constant.fromSDKJSON(object.value) : undefined + }; + }, + toSDK(message: Reference): ReferenceSDKType { + const obj: any = {}; + obj.name = message.name; + if (message.overloadId) { + obj.overload_id = message.overloadId.map(e => e); + } else { + obj.overload_id = []; + } + message.value !== undefined && (obj.value = message.value ? Constant.toSDK(message.value) : undefined); + return obj; + }, + fromAmino(object: ReferenceAmino): Reference { + const message = createBaseReference(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + message.overloadId = object.overload_id?.map(e => e) || []; + if (object.value !== undefined && object.value !== null) { + message.value = Constant.fromAmino(object.value); + } + return message; + }, + toAmino(message: Reference): ReferenceAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + if (message.overloadId) { + obj.overload_id = message.overloadId.map(e => e); + } else { + obj.overload_id = message.overloadId; + } + obj.value = message.value ? Constant.toAmino(message.value) : undefined; + return obj; + }, + fromAminoMsg(object: ReferenceAminoMsg): Reference { + return Reference.fromAmino(object.value); + }, + fromProtoMsg(message: ReferenceProtoMsg): Reference { + return Reference.decode(message.value); + }, + toProto(message: Reference): Uint8Array { + return Reference.encode(message).finish(); + }, + toProtoMsg(message: Reference): ReferenceProtoMsg { + return { + typeUrl: "/google.api.expr.v1alpha1.Reference", + value: Reference.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/api/expr/v1alpha1/eval.ts b/__fixtures__/v-next/outputicjsdeps/google/api/expr/v1alpha1/eval.ts new file mode 100644 index 0000000000..3d622489c7 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/api/expr/v1alpha1/eval.ts @@ -0,0 +1,721 @@ +import { Value, ValueSDKType } from "./value.js"; +import { Status, StatusSDKType } from "../../../rpc/status.js"; +import { BinaryReader, BinaryWriter } from "../../../../binary.js"; +import { JsonSafe } from "../../../../json-safe.js"; +import { DeepPartial, isSet } from "../../../../helpers.js"; +export const protobufPackage = "google.api.expr.v1alpha1"; +/** + * The state of an evaluation. + * + * Can represent an inital, partial, or completed state of evaluation. + */ +export interface EvalState { + /** The unique values referenced in this message. */ + values: ExprValue[]; + /** + * An ordered list of results. + * + * Tracks the flow of evaluation through the expression. + * May be sparse. + */ + results: EvalState_Result[]; +} +export interface EvalStateProtoMsg { + typeUrl: "/google.api.expr.v1alpha1.EvalState"; + value: Uint8Array; +} +/** + * The state of an evaluation. + * + * Can represent an inital, partial, or completed state of evaluation. + */ +export interface EvalStateSDKType { + values: ExprValueSDKType[]; + results: EvalState_ResultSDKType[]; +} +/** A single evalution result. */ +export interface EvalState_Result { + /** The id of the expression this result if for. */ + expr: bigint; + /** The index in `values` of the resulting value. */ + value: bigint; +} +export interface EvalState_ResultProtoMsg { + typeUrl: "/google.api.expr.v1alpha1.Result"; + value: Uint8Array; +} +/** A single evalution result. */ +export interface EvalState_ResultSDKType { + expr: bigint; + value: bigint; +} +/** The value of an evaluated expression. */ +export interface ExprValue { + /** A concrete value. */ + value?: Value; + /** + * The set of errors in the critical path of evalution. + * + * Only errors in the critical path are included. For example, + * `( || true) && ` will only result in ``, + * while ` || ` will result in both `` and + * ``. + * + * Errors cause by the presence of other errors are not included in the + * set. For example `.foo`, `foo()`, and ` + 1` will + * only result in ``. + * + * Multiple errors *might* be included when evaluation could result + * in different errors. For example ` + ` and + * `foo(, )` may result in ``, `` or both. + * The exact subset of errors included for this case is unspecified and + * depends on the implementation details of the evaluator. + */ + error?: ErrorSet; + /** + * The set of unknowns in the critical path of evaluation. + * + * Unknown behaves identically to Error with regards to propagation. + * Specifically, only unknowns in the critical path are included, unknowns + * caused by the presence of other unknowns are not included, and multiple + * unknowns *might* be included included when evaluation could result in + * different unknowns. For example: + * + * ( || true) && -> + * || -> + * .foo -> + * foo() -> + * + -> or + * + * Unknown takes precidence over Error in cases where a `Value` can short + * circuit the result: + * + * || -> + * && -> + * + * Errors take precidence in all other cases: + * + * + -> + * foo(, ) -> + */ + unknown?: UnknownSet; +} +export interface ExprValueProtoMsg { + typeUrl: "/google.api.expr.v1alpha1.ExprValue"; + value: Uint8Array; +} +/** The value of an evaluated expression. */ +export interface ExprValueSDKType { + value?: ValueSDKType; + error?: ErrorSetSDKType; + unknown?: UnknownSetSDKType; +} +/** + * A set of errors. + * + * The errors included depend on the context. See `ExprValue.error`. + */ +export interface ErrorSet { + /** The errors in the set. */ + errors: Status[]; +} +export interface ErrorSetProtoMsg { + typeUrl: "/google.api.expr.v1alpha1.ErrorSet"; + value: Uint8Array; +} +/** + * A set of errors. + * + * The errors included depend on the context. See `ExprValue.error`. + */ +export interface ErrorSetSDKType { + errors: StatusSDKType[]; +} +/** + * A set of expressions for which the value is unknown. + * + * The unknowns included depend on the context. See `ExprValue.unknown`. + */ +export interface UnknownSet { + /** The ids of the expressions with unknown values. */ + exprs: bigint[]; +} +export interface UnknownSetProtoMsg { + typeUrl: "/google.api.expr.v1alpha1.UnknownSet"; + value: Uint8Array; +} +/** + * A set of expressions for which the value is unknown. + * + * The unknowns included depend on the context. See `ExprValue.unknown`. + */ +export interface UnknownSetSDKType { + exprs: bigint[]; +} +function createBaseEvalState(): EvalState { + return { + values: [], + results: [] + }; +} +export const EvalState = { + typeUrl: "/google.api.expr.v1alpha1.EvalState", + encode(message: EvalState, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.values) { + ExprValue.encode(v!, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.results) { + EvalState_Result.encode(v!, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): EvalState { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseEvalState(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.values.push(ExprValue.decode(reader, reader.uint32())); + break; + case 3: + message.results.push(EvalState_Result.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): EvalState { + const obj = createBaseEvalState(); + if (Array.isArray(object?.values)) obj.values = object.values.map((e: any) => ExprValue.fromJSON(e)); + if (Array.isArray(object?.results)) obj.results = object.results.map((e: any) => EvalState_Result.fromJSON(e)); + return obj; + }, + toJSON(message: EvalState): JsonSafe { + const obj: any = {}; + if (message.values) { + obj.values = message.values.map(e => e ? ExprValue.toJSON(e) : undefined); + } else { + obj.values = []; + } + if (message.results) { + obj.results = message.results.map(e => e ? EvalState_Result.toJSON(e) : undefined); + } else { + obj.results = []; + } + return obj; + }, + fromPartial(object: DeepPartial): EvalState { + const message = createBaseEvalState(); + message.values = object.values?.map(e => ExprValue.fromPartial(e)) || []; + message.results = object.results?.map(e => EvalState_Result.fromPartial(e)) || []; + return message; + }, + fromSDK(object: EvalStateSDKType): EvalState { + return { + values: Array.isArray(object?.values) ? object.values.map((e: any) => ExprValue.fromSDK(e)) : [], + results: Array.isArray(object?.results) ? object.results.map((e: any) => EvalState_Result.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): EvalStateSDKType { + return { + values: Array.isArray(object?.values) ? object.values.map((e: any) => ExprValue.fromSDKJSON(e)) : [], + results: Array.isArray(object?.results) ? object.results.map((e: any) => EvalState_Result.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: EvalState): EvalStateSDKType { + const obj: any = {}; + if (message.values) { + obj.values = message.values.map(e => e ? ExprValue.toSDK(e) : undefined); + } else { + obj.values = []; + } + if (message.results) { + obj.results = message.results.map(e => e ? EvalState_Result.toSDK(e) : undefined); + } else { + obj.results = []; + } + return obj; + }, + fromAmino(object: EvalStateAmino): EvalState { + const message = createBaseEvalState(); + message.values = object.values?.map(e => ExprValue.fromAmino(e)) || []; + message.results = object.results?.map(e => EvalState_Result.fromAmino(e)) || []; + return message; + }, + toAmino(message: EvalState): EvalStateAmino { + const obj: any = {}; + if (message.values) { + obj.values = message.values.map(e => e ? ExprValue.toAmino(e) : undefined); + } else { + obj.values = message.values; + } + if (message.results) { + obj.results = message.results.map(e => e ? EvalState_Result.toAmino(e) : undefined); + } else { + obj.results = message.results; + } + return obj; + }, + fromAminoMsg(object: EvalStateAminoMsg): EvalState { + return EvalState.fromAmino(object.value); + }, + fromProtoMsg(message: EvalStateProtoMsg): EvalState { + return EvalState.decode(message.value); + }, + toProto(message: EvalState): Uint8Array { + return EvalState.encode(message).finish(); + }, + toProtoMsg(message: EvalState): EvalStateProtoMsg { + return { + typeUrl: "/google.api.expr.v1alpha1.EvalState", + value: EvalState.encode(message).finish() + }; + } +}; +function createBaseEvalState_Result(): EvalState_Result { + return { + expr: BigInt(0), + value: BigInt(0) + }; +} +export const EvalState_Result = { + typeUrl: "/google.api.expr.v1alpha1.Result", + encode(message: EvalState_Result, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.expr !== undefined) { + writer.uint32(8).int64(message.expr); + } + if (message.value !== undefined) { + writer.uint32(16).int64(message.value); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): EvalState_Result { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseEvalState_Result(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.expr = reader.int64(); + break; + case 2: + message.value = reader.int64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): EvalState_Result { + const obj = createBaseEvalState_Result(); + if (isSet(object.expr)) obj.expr = BigInt(object.expr.toString()); + if (isSet(object.value)) obj.value = BigInt(object.value.toString()); + return obj; + }, + toJSON(message: EvalState_Result): JsonSafe { + const obj: any = {}; + message.expr !== undefined && (obj.expr = (message.expr || BigInt(0)).toString()); + message.value !== undefined && (obj.value = (message.value || BigInt(0)).toString()); + return obj; + }, + fromPartial(object: DeepPartial): EvalState_Result { + const message = createBaseEvalState_Result(); + if (object.expr !== undefined && object.expr !== null) { + message.expr = BigInt(object.expr.toString()); + } + if (object.value !== undefined && object.value !== null) { + message.value = BigInt(object.value.toString()); + } + return message; + }, + fromSDK(object: EvalState_ResultSDKType): EvalState_Result { + return { + expr: object?.expr, + value: object?.value + }; + }, + fromSDKJSON(object: any): EvalState_ResultSDKType { + return { + expr: isSet(object.expr) ? BigInt(object.expr.toString()) : BigInt(0), + value: isSet(object.value) ? BigInt(object.value.toString()) : BigInt(0) + }; + }, + toSDK(message: EvalState_Result): EvalState_ResultSDKType { + const obj: any = {}; + obj.expr = message.expr; + obj.value = message.value; + return obj; + }, + fromAmino(object: EvalState_ResultAmino): EvalState_Result { + const message = createBaseEvalState_Result(); + if (object.expr !== undefined && object.expr !== null) { + message.expr = BigInt(object.expr); + } + if (object.value !== undefined && object.value !== null) { + message.value = BigInt(object.value); + } + return message; + }, + toAmino(message: EvalState_Result): EvalState_ResultAmino { + const obj: any = {}; + obj.expr = message.expr !== BigInt(0) ? message.expr?.toString() : undefined; + obj.value = message.value !== BigInt(0) ? message.value?.toString() : undefined; + return obj; + }, + fromAminoMsg(object: EvalState_ResultAminoMsg): EvalState_Result { + return EvalState_Result.fromAmino(object.value); + }, + fromProtoMsg(message: EvalState_ResultProtoMsg): EvalState_Result { + return EvalState_Result.decode(message.value); + }, + toProto(message: EvalState_Result): Uint8Array { + return EvalState_Result.encode(message).finish(); + }, + toProtoMsg(message: EvalState_Result): EvalState_ResultProtoMsg { + return { + typeUrl: "/google.api.expr.v1alpha1.Result", + value: EvalState_Result.encode(message).finish() + }; + } +}; +function createBaseExprValue(): ExprValue { + return { + value: undefined, + error: undefined, + unknown: undefined + }; +} +export const ExprValue = { + typeUrl: "/google.api.expr.v1alpha1.ExprValue", + encode(message: ExprValue, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.value !== undefined) { + Value.encode(message.value, writer.uint32(10).fork()).ldelim(); + } + if (message.error !== undefined) { + ErrorSet.encode(message.error, writer.uint32(18).fork()).ldelim(); + } + if (message.unknown !== undefined) { + UnknownSet.encode(message.unknown, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ExprValue { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseExprValue(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.value = Value.decode(reader, reader.uint32()); + break; + case 2: + message.error = ErrorSet.decode(reader, reader.uint32()); + break; + case 3: + message.unknown = UnknownSet.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ExprValue { + const obj = createBaseExprValue(); + if (isSet(object.value)) obj.value = Value.fromJSON(object.value); + if (isSet(object.error)) obj.error = ErrorSet.fromJSON(object.error); + if (isSet(object.unknown)) obj.unknown = UnknownSet.fromJSON(object.unknown); + return obj; + }, + toJSON(message: ExprValue): JsonSafe { + const obj: any = {}; + message.value !== undefined && (obj.value = message.value ? Value.toJSON(message.value) : undefined); + message.error !== undefined && (obj.error = message.error ? ErrorSet.toJSON(message.error) : undefined); + message.unknown !== undefined && (obj.unknown = message.unknown ? UnknownSet.toJSON(message.unknown) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): ExprValue { + const message = createBaseExprValue(); + if (object.value !== undefined && object.value !== null) { + message.value = Value.fromPartial(object.value); + } + if (object.error !== undefined && object.error !== null) { + message.error = ErrorSet.fromPartial(object.error); + } + if (object.unknown !== undefined && object.unknown !== null) { + message.unknown = UnknownSet.fromPartial(object.unknown); + } + return message; + }, + fromSDK(object: ExprValueSDKType): ExprValue { + return { + value: object.value ? Value.fromSDK(object.value) : undefined, + error: object.error ? ErrorSet.fromSDK(object.error) : undefined, + unknown: object.unknown ? UnknownSet.fromSDK(object.unknown) : undefined + }; + }, + fromSDKJSON(object: any): ExprValueSDKType { + return { + value: isSet(object.value) ? Value.fromSDKJSON(object.value) : undefined, + error: isSet(object.error) ? ErrorSet.fromSDKJSON(object.error) : undefined, + unknown: isSet(object.unknown) ? UnknownSet.fromSDKJSON(object.unknown) : undefined + }; + }, + toSDK(message: ExprValue): ExprValueSDKType { + const obj: any = {}; + message.value !== undefined && (obj.value = message.value ? Value.toSDK(message.value) : undefined); + message.error !== undefined && (obj.error = message.error ? ErrorSet.toSDK(message.error) : undefined); + message.unknown !== undefined && (obj.unknown = message.unknown ? UnknownSet.toSDK(message.unknown) : undefined); + return obj; + }, + fromAmino(object: ExprValueAmino): ExprValue { + const message = createBaseExprValue(); + if (object.value !== undefined && object.value !== null) { + message.value = Value.fromAmino(object.value); + } + if (object.error !== undefined && object.error !== null) { + message.error = ErrorSet.fromAmino(object.error); + } + if (object.unknown !== undefined && object.unknown !== null) { + message.unknown = UnknownSet.fromAmino(object.unknown); + } + return message; + }, + toAmino(message: ExprValue): ExprValueAmino { + const obj: any = {}; + obj.value = message.value ? Value.toAmino(message.value) : undefined; + obj.error = message.error ? ErrorSet.toAmino(message.error) : undefined; + obj.unknown = message.unknown ? UnknownSet.toAmino(message.unknown) : undefined; + return obj; + }, + fromAminoMsg(object: ExprValueAminoMsg): ExprValue { + return ExprValue.fromAmino(object.value); + }, + fromProtoMsg(message: ExprValueProtoMsg): ExprValue { + return ExprValue.decode(message.value); + }, + toProto(message: ExprValue): Uint8Array { + return ExprValue.encode(message).finish(); + }, + toProtoMsg(message: ExprValue): ExprValueProtoMsg { + return { + typeUrl: "/google.api.expr.v1alpha1.ExprValue", + value: ExprValue.encode(message).finish() + }; + } +}; +function createBaseErrorSet(): ErrorSet { + return { + errors: [] + }; +} +export const ErrorSet = { + typeUrl: "/google.api.expr.v1alpha1.ErrorSet", + encode(message: ErrorSet, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.errors) { + Status.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ErrorSet { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseErrorSet(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.errors.push(Status.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ErrorSet { + const obj = createBaseErrorSet(); + if (Array.isArray(object?.errors)) obj.errors = object.errors.map((e: any) => Status.fromJSON(e)); + return obj; + }, + toJSON(message: ErrorSet): JsonSafe { + const obj: any = {}; + if (message.errors) { + obj.errors = message.errors.map(e => e ? Status.toJSON(e) : undefined); + } else { + obj.errors = []; + } + return obj; + }, + fromPartial(object: DeepPartial): ErrorSet { + const message = createBaseErrorSet(); + message.errors = object.errors?.map(e => Status.fromPartial(e)) || []; + return message; + }, + fromSDK(object: ErrorSetSDKType): ErrorSet { + return { + errors: Array.isArray(object?.errors) ? object.errors.map((e: any) => Status.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): ErrorSetSDKType { + return { + errors: Array.isArray(object?.errors) ? object.errors.map((e: any) => Status.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: ErrorSet): ErrorSetSDKType { + const obj: any = {}; + if (message.errors) { + obj.errors = message.errors.map(e => e ? Status.toSDK(e) : undefined); + } else { + obj.errors = []; + } + return obj; + }, + fromAmino(object: ErrorSetAmino): ErrorSet { + const message = createBaseErrorSet(); + message.errors = object.errors?.map(e => Status.fromAmino(e)) || []; + return message; + }, + toAmino(message: ErrorSet): ErrorSetAmino { + const obj: any = {}; + if (message.errors) { + obj.errors = message.errors.map(e => e ? Status.toAmino(e) : undefined); + } else { + obj.errors = message.errors; + } + return obj; + }, + fromAminoMsg(object: ErrorSetAminoMsg): ErrorSet { + return ErrorSet.fromAmino(object.value); + }, + fromProtoMsg(message: ErrorSetProtoMsg): ErrorSet { + return ErrorSet.decode(message.value); + }, + toProto(message: ErrorSet): Uint8Array { + return ErrorSet.encode(message).finish(); + }, + toProtoMsg(message: ErrorSet): ErrorSetProtoMsg { + return { + typeUrl: "/google.api.expr.v1alpha1.ErrorSet", + value: ErrorSet.encode(message).finish() + }; + } +}; +function createBaseUnknownSet(): UnknownSet { + return { + exprs: [] + }; +} +export const UnknownSet = { + typeUrl: "/google.api.expr.v1alpha1.UnknownSet", + encode(message: UnknownSet, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + writer.uint32(10).fork(); + for (const v of message.exprs) { + writer.int64(v); + } + writer.ldelim(); + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): UnknownSet { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseUnknownSet(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.exprs.push(reader.int64()); + } + } else { + message.exprs.push(reader.int64()); + } + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): UnknownSet { + const obj = createBaseUnknownSet(); + if (Array.isArray(object?.exprs)) obj.exprs = object.exprs.map((e: any) => BigInt(e.toString())); + return obj; + }, + toJSON(message: UnknownSet): JsonSafe { + const obj: any = {}; + if (message.exprs) { + obj.exprs = message.exprs.map(e => (e || BigInt(0)).toString()); + } else { + obj.exprs = []; + } + return obj; + }, + fromPartial(object: DeepPartial): UnknownSet { + const message = createBaseUnknownSet(); + message.exprs = object.exprs?.map(e => BigInt(e.toString())) || []; + return message; + }, + fromSDK(object: UnknownSetSDKType): UnknownSet { + return { + exprs: Array.isArray(object?.exprs) ? object.exprs.map((e: any) => e) : [] + }; + }, + fromSDKJSON(object: any): UnknownSetSDKType { + return { + exprs: Array.isArray(object?.exprs) ? object.exprs.map((e: any) => BigInt(e.toString())) : [] + }; + }, + toSDK(message: UnknownSet): UnknownSetSDKType { + const obj: any = {}; + if (message.exprs) { + obj.exprs = message.exprs.map(e => e); + } else { + obj.exprs = []; + } + return obj; + }, + fromAmino(object: UnknownSetAmino): UnknownSet { + const message = createBaseUnknownSet(); + message.exprs = object.exprs?.map(e => BigInt(e)) || []; + return message; + }, + toAmino(message: UnknownSet): UnknownSetAmino { + const obj: any = {}; + if (message.exprs) { + obj.exprs = message.exprs.map(e => e.toString()); + } else { + obj.exprs = message.exprs; + } + return obj; + }, + fromAminoMsg(object: UnknownSetAminoMsg): UnknownSet { + return UnknownSet.fromAmino(object.value); + }, + fromProtoMsg(message: UnknownSetProtoMsg): UnknownSet { + return UnknownSet.decode(message.value); + }, + toProto(message: UnknownSet): Uint8Array { + return UnknownSet.encode(message).finish(); + }, + toProtoMsg(message: UnknownSet): UnknownSetProtoMsg { + return { + typeUrl: "/google.api.expr.v1alpha1.UnknownSet", + value: UnknownSet.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/api/expr/v1alpha1/explain.ts b/__fixtures__/v-next/outputicjsdeps/google/api/expr/v1alpha1/explain.ts new file mode 100644 index 0000000000..f24dd302f3 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/api/expr/v1alpha1/explain.ts @@ -0,0 +1,288 @@ +import { Value, ValueSDKType } from "./value.js"; +import { BinaryReader, BinaryWriter } from "../../../../binary.js"; +import { JsonSafe } from "../../../../json-safe.js"; +import { DeepPartial, isSet } from "../../../../helpers.js"; +export const protobufPackage = "google.api.expr.v1alpha1"; +/** + * Values of intermediate expressions produced when evaluating expression. + * Deprecated, use `EvalState` instead. + */ +/** @deprecated */ +export interface Explain { + /** + * All of the observed values. + * + * The field value_index is an index in the values list. + * Separating values from steps is needed to remove redundant values. + */ + values: Value[]; + /** + * List of steps. + * + * Repeated evaluations of the same expression generate new ExprStep + * instances. The order of such ExprStep instances matches the order of + * elements returned by Comprehension.iter_range. + */ + exprSteps: Explain_ExprStep[]; +} +export interface ExplainProtoMsg { + typeUrl: "/google.api.expr.v1alpha1.Explain"; + value: Uint8Array; +} +/** + * Values of intermediate expressions produced when evaluating expression. + * Deprecated, use `EvalState` instead. + */ +/** @deprecated */ +export interface ExplainSDKType { + values: ValueSDKType[]; + expr_steps: Explain_ExprStepSDKType[]; +} +/** ID and value index of one step. */ +export interface Explain_ExprStep { + /** ID of corresponding Expr node. */ + id: bigint; + /** Index of the value in the values list. */ + valueIndex: number; +} +export interface Explain_ExprStepProtoMsg { + typeUrl: "/google.api.expr.v1alpha1.ExprStep"; + value: Uint8Array; +} +/** ID and value index of one step. */ +export interface Explain_ExprStepSDKType { + id: bigint; + value_index: number; +} +function createBaseExplain(): Explain { + return { + values: [], + exprSteps: [] + }; +} +export const Explain = { + typeUrl: "/google.api.expr.v1alpha1.Explain", + encode(message: Explain, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.values) { + Value.encode(v!, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.exprSteps) { + Explain_ExprStep.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Explain { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseExplain(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.values.push(Value.decode(reader, reader.uint32())); + break; + case 2: + message.exprSteps.push(Explain_ExprStep.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Explain { + const obj = createBaseExplain(); + if (Array.isArray(object?.values)) obj.values = object.values.map((e: any) => Value.fromJSON(e)); + if (Array.isArray(object?.exprSteps)) obj.exprSteps = object.exprSteps.map((e: any) => Explain_ExprStep.fromJSON(e)); + return obj; + }, + toJSON(message: Explain): JsonSafe { + const obj: any = {}; + if (message.values) { + obj.values = message.values.map(e => e ? Value.toJSON(e) : undefined); + } else { + obj.values = []; + } + if (message.exprSteps) { + obj.exprSteps = message.exprSteps.map(e => e ? Explain_ExprStep.toJSON(e) : undefined); + } else { + obj.exprSteps = []; + } + return obj; + }, + fromPartial(object: DeepPartial): Explain { + const message = createBaseExplain(); + message.values = object.values?.map(e => Value.fromPartial(e)) || []; + message.exprSteps = object.exprSteps?.map(e => Explain_ExprStep.fromPartial(e)) || []; + return message; + }, + fromSDK(object: ExplainSDKType): Explain { + return { + values: Array.isArray(object?.values) ? object.values.map((e: any) => Value.fromSDK(e)) : [], + exprSteps: Array.isArray(object?.expr_steps) ? object.expr_steps.map((e: any) => Explain_ExprStep.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): ExplainSDKType { + return { + values: Array.isArray(object?.values) ? object.values.map((e: any) => Value.fromSDKJSON(e)) : [], + expr_steps: Array.isArray(object?.expr_steps) ? object.expr_steps.map((e: any) => Explain_ExprStep.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: Explain): ExplainSDKType { + const obj: any = {}; + if (message.values) { + obj.values = message.values.map(e => e ? Value.toSDK(e) : undefined); + } else { + obj.values = []; + } + if (message.exprSteps) { + obj.expr_steps = message.exprSteps.map(e => e ? Explain_ExprStep.toSDK(e) : undefined); + } else { + obj.expr_steps = []; + } + return obj; + }, + fromAmino(object: ExplainAmino): Explain { + const message = createBaseExplain(); + message.values = object.values?.map(e => Value.fromAmino(e)) || []; + message.exprSteps = object.expr_steps?.map(e => Explain_ExprStep.fromAmino(e)) || []; + return message; + }, + toAmino(message: Explain): ExplainAmino { + const obj: any = {}; + if (message.values) { + obj.values = message.values.map(e => e ? Value.toAmino(e) : undefined); + } else { + obj.values = message.values; + } + if (message.exprSteps) { + obj.expr_steps = message.exprSteps.map(e => e ? Explain_ExprStep.toAmino(e) : undefined); + } else { + obj.expr_steps = message.exprSteps; + } + return obj; + }, + fromAminoMsg(object: ExplainAminoMsg): Explain { + return Explain.fromAmino(object.value); + }, + fromProtoMsg(message: ExplainProtoMsg): Explain { + return Explain.decode(message.value); + }, + toProto(message: Explain): Uint8Array { + return Explain.encode(message).finish(); + }, + toProtoMsg(message: Explain): ExplainProtoMsg { + return { + typeUrl: "/google.api.expr.v1alpha1.Explain", + value: Explain.encode(message).finish() + }; + } +}; +function createBaseExplain_ExprStep(): Explain_ExprStep { + return { + id: BigInt(0), + valueIndex: 0 + }; +} +export const Explain_ExprStep = { + typeUrl: "/google.api.expr.v1alpha1.ExprStep", + encode(message: Explain_ExprStep, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.id !== undefined) { + writer.uint32(8).int64(message.id); + } + if (message.valueIndex !== undefined) { + writer.uint32(16).int32(message.valueIndex); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Explain_ExprStep { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseExplain_ExprStep(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.id = reader.int64(); + break; + case 2: + message.valueIndex = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Explain_ExprStep { + const obj = createBaseExplain_ExprStep(); + if (isSet(object.id)) obj.id = BigInt(object.id.toString()); + if (isSet(object.valueIndex)) obj.valueIndex = Number(object.valueIndex); + return obj; + }, + toJSON(message: Explain_ExprStep): JsonSafe { + const obj: any = {}; + message.id !== undefined && (obj.id = (message.id || BigInt(0)).toString()); + message.valueIndex !== undefined && (obj.valueIndex = Math.round(message.valueIndex)); + return obj; + }, + fromPartial(object: DeepPartial): Explain_ExprStep { + const message = createBaseExplain_ExprStep(); + if (object.id !== undefined && object.id !== null) { + message.id = BigInt(object.id.toString()); + } + message.valueIndex = object.valueIndex ?? 0; + return message; + }, + fromSDK(object: Explain_ExprStepSDKType): Explain_ExprStep { + return { + id: object?.id, + valueIndex: object?.value_index + }; + }, + fromSDKJSON(object: any): Explain_ExprStepSDKType { + return { + id: isSet(object.id) ? BigInt(object.id.toString()) : BigInt(0), + value_index: isSet(object.value_index) ? Number(object.value_index) : 0 + }; + }, + toSDK(message: Explain_ExprStep): Explain_ExprStepSDKType { + const obj: any = {}; + obj.id = message.id; + obj.value_index = message.valueIndex; + return obj; + }, + fromAmino(object: Explain_ExprStepAmino): Explain_ExprStep { + const message = createBaseExplain_ExprStep(); + if (object.id !== undefined && object.id !== null) { + message.id = BigInt(object.id); + } + if (object.value_index !== undefined && object.value_index !== null) { + message.valueIndex = object.value_index; + } + return message; + }, + toAmino(message: Explain_ExprStep): Explain_ExprStepAmino { + const obj: any = {}; + obj.id = message.id !== BigInt(0) ? message.id?.toString() : undefined; + obj.value_index = message.valueIndex === 0 ? undefined : message.valueIndex; + return obj; + }, + fromAminoMsg(object: Explain_ExprStepAminoMsg): Explain_ExprStep { + return Explain_ExprStep.fromAmino(object.value); + }, + fromProtoMsg(message: Explain_ExprStepProtoMsg): Explain_ExprStep { + return Explain_ExprStep.decode(message.value); + }, + toProto(message: Explain_ExprStep): Uint8Array { + return Explain_ExprStep.encode(message).finish(); + }, + toProtoMsg(message: Explain_ExprStep): Explain_ExprStepProtoMsg { + return { + typeUrl: "/google.api.expr.v1alpha1.ExprStep", + value: Explain_ExprStep.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/api/expr/v1alpha1/syntax.ts b/__fixtures__/v-next/outputicjsdeps/google/api/expr/v1alpha1/syntax.ts new file mode 100644 index 0000000000..4d1fb151e3 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/api/expr/v1alpha1/syntax.ts @@ -0,0 +1,2621 @@ +import { NullValue, NullValueSDKType, nullValueFromJSON, nullValueToJSON } from "../../../protobuf/struct.js"; +import { Duration, DurationSDKType } from "../../../protobuf/duration.js"; +import { Timestamp, TimestampSDKType } from "../../../protobuf/timestamp.js"; +import { BinaryReader, BinaryWriter } from "../../../../binary.js"; +import { isSet, DeepPartial, toTimestamp, fromTimestamp, bytesFromBase64, base64FromBytes, isObject } from "../../../../helpers.js"; +import { JsonSafe } from "../../../../json-safe.js"; +export const protobufPackage = "google.api.expr.v1alpha1"; +/** An expression together with source information as returned by the parser. */ +export interface ParsedExpr { + /** The parsed expression. */ + expr?: Expr; + /** The source info derived from input that generated the parsed `expr`. */ + sourceInfo?: SourceInfo; +} +export interface ParsedExprProtoMsg { + typeUrl: "/google.api.expr.v1alpha1.ParsedExpr"; + value: Uint8Array; +} +/** An expression together with source information as returned by the parser. */ +export interface ParsedExprSDKType { + expr?: ExprSDKType; + source_info?: SourceInfoSDKType; +} +/** + * An abstract representation of a common expression. + * + * Expressions are abstractly represented as a collection of identifiers, + * select statements, function calls, literals, and comprehensions. All + * operators with the exception of the '.' operator are modelled as function + * calls. This makes it easy to represent new operators into the existing AST. + * + * All references within expressions must resolve to a [Decl][google.api.expr.v1alpha1.Decl] provided at + * type-check for an expression to be valid. A reference may either be a bare + * identifier `name` or a qualified identifier `google.api.name`. References + * may either refer to a value or a function declaration. + * + * For example, the expression `google.api.name.startsWith('expr')` references + * the declaration `google.api.name` within a [Expr.Select][google.api.expr.v1alpha1.Expr.Select] expression, and + * the function declaration `startsWith`. + */ +export interface Expr { + /** + * Required. An id assigned to this node by the parser which is unique in a + * given expression tree. This is used to associate type information and other + * attributes to a node in the parse tree. + */ + id: bigint; + /** A literal expression. */ + constExpr?: Constant; + /** An identifier expression. */ + identExpr?: Expr_Ident; + /** A field selection expression, e.g. `request.auth`. */ + selectExpr?: Expr_Select; + /** A call expression, including calls to predefined functions and operators. */ + callExpr?: Expr_Call; + /** A list creation expression. */ + listExpr?: Expr_CreateList; + /** A map or message creation expression. */ + structExpr?: Expr_CreateStruct; + /** A comprehension expression. */ + comprehensionExpr?: Expr_Comprehension; +} +export interface ExprProtoMsg { + typeUrl: "/google.api.expr.v1alpha1.Expr"; + value: Uint8Array; +} +/** + * An abstract representation of a common expression. + * + * Expressions are abstractly represented as a collection of identifiers, + * select statements, function calls, literals, and comprehensions. All + * operators with the exception of the '.' operator are modelled as function + * calls. This makes it easy to represent new operators into the existing AST. + * + * All references within expressions must resolve to a [Decl][google.api.expr.v1alpha1.Decl] provided at + * type-check for an expression to be valid. A reference may either be a bare + * identifier `name` or a qualified identifier `google.api.name`. References + * may either refer to a value or a function declaration. + * + * For example, the expression `google.api.name.startsWith('expr')` references + * the declaration `google.api.name` within a [Expr.Select][google.api.expr.v1alpha1.Expr.Select] expression, and + * the function declaration `startsWith`. + */ +export interface ExprSDKType { + id: bigint; + const_expr?: ConstantSDKType; + ident_expr?: Expr_IdentSDKType; + select_expr?: Expr_SelectSDKType; + call_expr?: Expr_CallSDKType; + list_expr?: Expr_CreateListSDKType; + struct_expr?: Expr_CreateStructSDKType; + comprehension_expr?: Expr_ComprehensionSDKType; +} +/** An identifier expression. e.g. `request`. */ +export interface Expr_Ident { + /** + * Required. Holds a single, unqualified identifier, possibly preceded by a + * '.'. + * + * Qualified names are represented by the [Expr.Select][google.api.expr.v1alpha1.Expr.Select] expression. + */ + name: string; +} +export interface Expr_IdentProtoMsg { + typeUrl: "/google.api.expr.v1alpha1.Ident"; + value: Uint8Array; +} +/** An identifier expression. e.g. `request`. */ +export interface Expr_IdentSDKType { + name: string; +} +/** A field selection expression. e.g. `request.auth`. */ +export interface Expr_Select { + /** + * Required. The target of the selection expression. + * + * For example, in the select expression `request.auth`, the `request` + * portion of the expression is the `operand`. + */ + operand?: Expr; + /** + * Required. The name of the field to select. + * + * For example, in the select expression `request.auth`, the `auth` portion + * of the expression would be the `field`. + */ + field: string; + /** + * Whether the select is to be interpreted as a field presence test. + * + * This results from the macro `has(request.auth)`. + */ + testOnly: boolean; +} +export interface Expr_SelectProtoMsg { + typeUrl: "/google.api.expr.v1alpha1.Select"; + value: Uint8Array; +} +/** A field selection expression. e.g. `request.auth`. */ +export interface Expr_SelectSDKType { + operand?: ExprSDKType; + field: string; + test_only: boolean; +} +/** + * A call expression, including calls to predefined functions and operators. + * + * For example, `value == 10`, `size(map_value)`. + */ +export interface Expr_Call { + /** + * The target of an method call-style expression. For example, `x` in + * `x.f()`. + */ + target?: Expr; + /** Required. The name of the function or method being called. */ + function: string; + /** The arguments. */ + args: Expr[]; +} +export interface Expr_CallProtoMsg { + typeUrl: "/google.api.expr.v1alpha1.Call"; + value: Uint8Array; +} +/** + * A call expression, including calls to predefined functions and operators. + * + * For example, `value == 10`, `size(map_value)`. + */ +export interface Expr_CallSDKType { + target?: ExprSDKType; + function: string; + args: ExprSDKType[]; +} +/** + * A list creation expression. + * + * Lists may either be homogenous, e.g. `[1, 2, 3]`, or heterogeneous, e.g. + * `dyn([1, 'hello', 2.0])` + */ +export interface Expr_CreateList { + /** The elements part of the list. */ + elements: Expr[]; +} +export interface Expr_CreateListProtoMsg { + typeUrl: "/google.api.expr.v1alpha1.CreateList"; + value: Uint8Array; +} +/** + * A list creation expression. + * + * Lists may either be homogenous, e.g. `[1, 2, 3]`, or heterogeneous, e.g. + * `dyn([1, 'hello', 2.0])` + */ +export interface Expr_CreateListSDKType { + elements: ExprSDKType[]; +} +/** + * A map or message creation expression. + * + * Maps are constructed as `{'key_name': 'value'}`. Message construction is + * similar, but prefixed with a type name and composed of field ids: + * `types.MyType{field_id: 'value'}`. + */ +export interface Expr_CreateStruct { + /** + * The type name of the message to be created, empty when creating map + * literals. + */ + messageName: string; + /** The entries in the creation expression. */ + entries: Expr_CreateStruct_Entry[]; +} +export interface Expr_CreateStructProtoMsg { + typeUrl: "/google.api.expr.v1alpha1.CreateStruct"; + value: Uint8Array; +} +/** + * A map or message creation expression. + * + * Maps are constructed as `{'key_name': 'value'}`. Message construction is + * similar, but prefixed with a type name and composed of field ids: + * `types.MyType{field_id: 'value'}`. + */ +export interface Expr_CreateStructSDKType { + message_name: string; + entries: Expr_CreateStruct_EntrySDKType[]; +} +/** Represents an entry. */ +export interface Expr_CreateStruct_Entry { + /** + * Required. An id assigned to this node by the parser which is unique + * in a given expression tree. This is used to associate type + * information and other attributes to the node. + */ + id: bigint; + /** The field key for a message creator statement. */ + fieldKey?: string; + /** The key expression for a map creation statement. */ + mapKey?: Expr; + /** Required. The value assigned to the key. */ + value?: Expr; +} +export interface Expr_CreateStruct_EntryProtoMsg { + typeUrl: "/google.api.expr.v1alpha1.Entry"; + value: Uint8Array; +} +/** Represents an entry. */ +export interface Expr_CreateStruct_EntrySDKType { + id: bigint; + field_key?: string; + map_key?: ExprSDKType; + value?: ExprSDKType; +} +/** + * A comprehension expression applied to a list or map. + * + * Comprehensions are not part of the core syntax, but enabled with macros. + * A macro matches a specific call signature within a parsed AST and replaces + * the call with an alternate AST block. Macro expansion happens at parse + * time. + * + * The following macros are supported within CEL: + * + * Aggregate type macros may be applied to all elements in a list or all keys + * in a map: + * + * * `all`, `exists`, `exists_one` - test a predicate expression against + * the inputs and return `true` if the predicate is satisfied for all, + * any, or only one value `list.all(x, x < 10)`. + * * `filter` - test a predicate expression against the inputs and return + * the subset of elements which satisfy the predicate: + * `payments.filter(p, p > 1000)`. + * * `map` - apply an expression to all elements in the input and return the + * output aggregate type: `[1, 2, 3].map(i, i * i)`. + * + * The `has(m.x)` macro tests whether the property `x` is present in struct + * `m`. The semantics of this macro depend on the type of `m`. For proto2 + * messages `has(m.x)` is defined as 'defined, but not set`. For proto3, the + * macro tests whether the property is set to its default. For map and struct + * types, the macro tests whether the property `x` is defined on `m`. + */ +export interface Expr_Comprehension { + /** The name of the iteration variable. */ + iterVar: string; + /** The range over which var iterates. */ + iterRange?: Expr; + /** The name of the variable used for accumulation of the result. */ + accuVar: string; + /** The initial value of the accumulator. */ + accuInit?: Expr; + /** + * An expression which can contain iter_var and accu_var. + * + * Returns false when the result has been computed and may be used as + * a hint to short-circuit the remainder of the comprehension. + */ + loopCondition?: Expr; + /** + * An expression which can contain iter_var and accu_var. + * + * Computes the next value of accu_var. + */ + loopStep?: Expr; + /** + * An expression which can contain accu_var. + * + * Computes the result. + */ + result?: Expr; +} +export interface Expr_ComprehensionProtoMsg { + typeUrl: "/google.api.expr.v1alpha1.Comprehension"; + value: Uint8Array; +} +/** + * A comprehension expression applied to a list or map. + * + * Comprehensions are not part of the core syntax, but enabled with macros. + * A macro matches a specific call signature within a parsed AST and replaces + * the call with an alternate AST block. Macro expansion happens at parse + * time. + * + * The following macros are supported within CEL: + * + * Aggregate type macros may be applied to all elements in a list or all keys + * in a map: + * + * * `all`, `exists`, `exists_one` - test a predicate expression against + * the inputs and return `true` if the predicate is satisfied for all, + * any, or only one value `list.all(x, x < 10)`. + * * `filter` - test a predicate expression against the inputs and return + * the subset of elements which satisfy the predicate: + * `payments.filter(p, p > 1000)`. + * * `map` - apply an expression to all elements in the input and return the + * output aggregate type: `[1, 2, 3].map(i, i * i)`. + * + * The `has(m.x)` macro tests whether the property `x` is present in struct + * `m`. The semantics of this macro depend on the type of `m`. For proto2 + * messages `has(m.x)` is defined as 'defined, but not set`. For proto3, the + * macro tests whether the property is set to its default. For map and struct + * types, the macro tests whether the property `x` is defined on `m`. + */ +export interface Expr_ComprehensionSDKType { + iter_var: string; + iter_range?: ExprSDKType; + accu_var: string; + accu_init?: ExprSDKType; + loop_condition?: ExprSDKType; + loop_step?: ExprSDKType; + result?: ExprSDKType; +} +/** + * Represents a primitive literal. + * + * Named 'Constant' here for backwards compatibility. + * + * This is similar as the primitives supported in the well-known type + * `google.protobuf.Value`, but richer so it can represent CEL's full range of + * primitives. + * + * Lists and structs are not included as constants as these aggregate types may + * contain [Expr][google.api.expr.v1alpha1.Expr] elements which require evaluation and are thus not constant. + * + * Examples of literals include: `"hello"`, `b'bytes'`, `1u`, `4.2`, `-2`, + * `true`, `null`. + */ +export interface Constant { + /** null value. */ + nullValue?: NullValue; + /** boolean value. */ + boolValue?: boolean; + /** int64 value. */ + int64Value?: bigint; + /** uint64 value. */ + uint64Value?: bigint; + /** double value. */ + doubleValue?: number; + /** string value. */ + stringValue?: string; + /** bytes value. */ + bytesValue?: Uint8Array; + /** + * protobuf.Duration value. + * + * Deprecated: duration is no longer considered a builtin cel type. + */ + /** @deprecated */ + durationValue?: Duration; + /** + * protobuf.Timestamp value. + * + * Deprecated: timestamp is no longer considered a builtin cel type. + */ + /** @deprecated */ + timestampValue?: Date; +} +export interface ConstantProtoMsg { + typeUrl: "/google.api.expr.v1alpha1.Constant"; + value: Uint8Array; +} +/** + * Represents a primitive literal. + * + * Named 'Constant' here for backwards compatibility. + * + * This is similar as the primitives supported in the well-known type + * `google.protobuf.Value`, but richer so it can represent CEL's full range of + * primitives. + * + * Lists and structs are not included as constants as these aggregate types may + * contain [Expr][google.api.expr.v1alpha1.Expr] elements which require evaluation and are thus not constant. + * + * Examples of literals include: `"hello"`, `b'bytes'`, `1u`, `4.2`, `-2`, + * `true`, `null`. + */ +export interface ConstantSDKType { + null_value?: NullValue; + bool_value?: boolean; + int64_value?: bigint; + uint64_value?: bigint; + double_value?: number; + string_value?: string; + bytes_value?: Uint8Array; + /** @deprecated */ + duration_value?: DurationSDKType; + /** @deprecated */ + timestamp_value?: Date; +} +export interface SourceInfo_PositionsEntry { + key: bigint; + value: number; +} +export interface SourceInfo_PositionsEntryProtoMsg { + typeUrl: string; + value: Uint8Array; +} +export interface SourceInfo_PositionsEntrySDKType { + key: bigint; + value: number; +} +export interface SourceInfo_MacroCallsEntry { + key: bigint; + value?: Expr; +} +export interface SourceInfo_MacroCallsEntryProtoMsg { + typeUrl: string; + value: Uint8Array; +} +export interface SourceInfo_MacroCallsEntrySDKType { + key: bigint; + value?: ExprSDKType; +} +/** Source information collected at parse time. */ +export interface SourceInfo { + /** The syntax version of the source, e.g. `cel1`. */ + syntaxVersion: string; + /** + * The location name. All position information attached to an expression is + * relative to this location. + * + * The location could be a file, UI element, or similar. For example, + * `acme/app/AnvilPolicy.cel`. + */ + location: string; + /** + * Monotonically increasing list of code point offsets where newlines + * `\n` appear. + * + * The line number of a given position is the index `i` where for a given + * `id` the `line_offsets[i] < id_positions[id] < line_offsets[i+1]`. The + * column may be derivd from `id_positions[id] - line_offsets[i]`. + */ + lineOffsets: number[]; + /** + * A map from the parse node id (e.g. `Expr.id`) to the code point offset + * within the source. + */ + positions: { + [key: bigint]: number; + }; + /** + * A map from the parse node id where a macro replacement was made to the + * call `Expr` that resulted in a macro expansion. + * + * For example, `has(value.field)` is a function call that is replaced by a + * `test_only` field selection in the AST. Likewise, the call + * `list.exists(e, e > 10)` translates to a comprehension expression. The key + * in the map corresponds to the expression id of the expanded macro, and the + * value is the call `Expr` that was replaced. + */ + macroCalls: { + [key: bigint]: Expr; + }; +} +export interface SourceInfoProtoMsg { + typeUrl: "/google.api.expr.v1alpha1.SourceInfo"; + value: Uint8Array; +} +/** Source information collected at parse time. */ +export interface SourceInfoSDKType { + syntax_version: string; + location: string; + line_offsets: number[]; + positions: { + [key: bigint]: number; + }; + macro_calls: { + [key: bigint]: ExprSDKType; + }; +} +/** A specific position in source. */ +export interface SourcePosition { + /** The soucre location name (e.g. file name). */ + location: string; + /** The UTF-8 code unit offset. */ + offset: number; + /** + * The 1-based index of the starting line in the source text + * where the issue occurs, or 0 if unknown. + */ + line: number; + /** + * The 0-based index of the starting position within the line of source text + * where the issue occurs. Only meaningful if line is nonzero. + */ + column: number; +} +export interface SourcePositionProtoMsg { + typeUrl: "/google.api.expr.v1alpha1.SourcePosition"; + value: Uint8Array; +} +/** A specific position in source. */ +export interface SourcePositionSDKType { + location: string; + offset: number; + line: number; + column: number; +} +function createBaseParsedExpr(): ParsedExpr { + return { + expr: undefined, + sourceInfo: undefined + }; +} +export const ParsedExpr = { + typeUrl: "/google.api.expr.v1alpha1.ParsedExpr", + encode(message: ParsedExpr, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.expr !== undefined) { + Expr.encode(message.expr, writer.uint32(18).fork()).ldelim(); + } + if (message.sourceInfo !== undefined) { + SourceInfo.encode(message.sourceInfo, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ParsedExpr { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseParsedExpr(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.expr = Expr.decode(reader, reader.uint32()); + break; + case 3: + message.sourceInfo = SourceInfo.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ParsedExpr { + const obj = createBaseParsedExpr(); + if (isSet(object.expr)) obj.expr = Expr.fromJSON(object.expr); + if (isSet(object.sourceInfo)) obj.sourceInfo = SourceInfo.fromJSON(object.sourceInfo); + return obj; + }, + toJSON(message: ParsedExpr): JsonSafe { + const obj: any = {}; + message.expr !== undefined && (obj.expr = message.expr ? Expr.toJSON(message.expr) : undefined); + message.sourceInfo !== undefined && (obj.sourceInfo = message.sourceInfo ? SourceInfo.toJSON(message.sourceInfo) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): ParsedExpr { + const message = createBaseParsedExpr(); + if (object.expr !== undefined && object.expr !== null) { + message.expr = Expr.fromPartial(object.expr); + } + if (object.sourceInfo !== undefined && object.sourceInfo !== null) { + message.sourceInfo = SourceInfo.fromPartial(object.sourceInfo); + } + return message; + }, + fromSDK(object: ParsedExprSDKType): ParsedExpr { + return { + expr: object.expr ? Expr.fromSDK(object.expr) : undefined, + sourceInfo: object.source_info ? SourceInfo.fromSDK(object.source_info) : undefined + }; + }, + fromSDKJSON(object: any): ParsedExprSDKType { + return { + expr: isSet(object.expr) ? Expr.fromSDKJSON(object.expr) : undefined, + source_info: isSet(object.source_info) ? SourceInfo.fromSDKJSON(object.source_info) : undefined + }; + }, + toSDK(message: ParsedExpr): ParsedExprSDKType { + const obj: any = {}; + message.expr !== undefined && (obj.expr = message.expr ? Expr.toSDK(message.expr) : undefined); + message.sourceInfo !== undefined && (obj.source_info = message.sourceInfo ? SourceInfo.toSDK(message.sourceInfo) : undefined); + return obj; + }, + fromAmino(object: ParsedExprAmino): ParsedExpr { + const message = createBaseParsedExpr(); + if (object.expr !== undefined && object.expr !== null) { + message.expr = Expr.fromAmino(object.expr); + } + if (object.source_info !== undefined && object.source_info !== null) { + message.sourceInfo = SourceInfo.fromAmino(object.source_info); + } + return message; + }, + toAmino(message: ParsedExpr): ParsedExprAmino { + const obj: any = {}; + obj.expr = message.expr ? Expr.toAmino(message.expr) : undefined; + obj.source_info = message.sourceInfo ? SourceInfo.toAmino(message.sourceInfo) : undefined; + return obj; + }, + fromAminoMsg(object: ParsedExprAminoMsg): ParsedExpr { + return ParsedExpr.fromAmino(object.value); + }, + fromProtoMsg(message: ParsedExprProtoMsg): ParsedExpr { + return ParsedExpr.decode(message.value); + }, + toProto(message: ParsedExpr): Uint8Array { + return ParsedExpr.encode(message).finish(); + }, + toProtoMsg(message: ParsedExpr): ParsedExprProtoMsg { + return { + typeUrl: "/google.api.expr.v1alpha1.ParsedExpr", + value: ParsedExpr.encode(message).finish() + }; + } +}; +function createBaseExpr(): Expr { + return { + id: BigInt(0), + constExpr: undefined, + identExpr: undefined, + selectExpr: undefined, + callExpr: undefined, + listExpr: undefined, + structExpr: undefined, + comprehensionExpr: undefined + }; +} +export const Expr = { + typeUrl: "/google.api.expr.v1alpha1.Expr", + encode(message: Expr, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.id !== undefined) { + writer.uint32(16).int64(message.id); + } + if (message.constExpr !== undefined) { + Constant.encode(message.constExpr, writer.uint32(26).fork()).ldelim(); + } + if (message.identExpr !== undefined) { + Expr_Ident.encode(message.identExpr, writer.uint32(34).fork()).ldelim(); + } + if (message.selectExpr !== undefined) { + Expr_Select.encode(message.selectExpr, writer.uint32(42).fork()).ldelim(); + } + if (message.callExpr !== undefined) { + Expr_Call.encode(message.callExpr, writer.uint32(50).fork()).ldelim(); + } + if (message.listExpr !== undefined) { + Expr_CreateList.encode(message.listExpr, writer.uint32(58).fork()).ldelim(); + } + if (message.structExpr !== undefined) { + Expr_CreateStruct.encode(message.structExpr, writer.uint32(66).fork()).ldelim(); + } + if (message.comprehensionExpr !== undefined) { + Expr_Comprehension.encode(message.comprehensionExpr, writer.uint32(74).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Expr { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseExpr(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.id = reader.int64(); + break; + case 3: + message.constExpr = Constant.decode(reader, reader.uint32()); + break; + case 4: + message.identExpr = Expr_Ident.decode(reader, reader.uint32()); + break; + case 5: + message.selectExpr = Expr_Select.decode(reader, reader.uint32()); + break; + case 6: + message.callExpr = Expr_Call.decode(reader, reader.uint32()); + break; + case 7: + message.listExpr = Expr_CreateList.decode(reader, reader.uint32()); + break; + case 8: + message.structExpr = Expr_CreateStruct.decode(reader, reader.uint32()); + break; + case 9: + message.comprehensionExpr = Expr_Comprehension.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Expr { + const obj = createBaseExpr(); + if (isSet(object.id)) obj.id = BigInt(object.id.toString()); + if (isSet(object.constExpr)) obj.constExpr = Constant.fromJSON(object.constExpr); + if (isSet(object.identExpr)) obj.identExpr = Expr_Ident.fromJSON(object.identExpr); + if (isSet(object.selectExpr)) obj.selectExpr = Expr_Select.fromJSON(object.selectExpr); + if (isSet(object.callExpr)) obj.callExpr = Expr_Call.fromJSON(object.callExpr); + if (isSet(object.listExpr)) obj.listExpr = Expr_CreateList.fromJSON(object.listExpr); + if (isSet(object.structExpr)) obj.structExpr = Expr_CreateStruct.fromJSON(object.structExpr); + if (isSet(object.comprehensionExpr)) obj.comprehensionExpr = Expr_Comprehension.fromJSON(object.comprehensionExpr); + return obj; + }, + toJSON(message: Expr): JsonSafe { + const obj: any = {}; + message.id !== undefined && (obj.id = (message.id || BigInt(0)).toString()); + message.constExpr !== undefined && (obj.constExpr = message.constExpr ? Constant.toJSON(message.constExpr) : undefined); + message.identExpr !== undefined && (obj.identExpr = message.identExpr ? Expr_Ident.toJSON(message.identExpr) : undefined); + message.selectExpr !== undefined && (obj.selectExpr = message.selectExpr ? Expr_Select.toJSON(message.selectExpr) : undefined); + message.callExpr !== undefined && (obj.callExpr = message.callExpr ? Expr_Call.toJSON(message.callExpr) : undefined); + message.listExpr !== undefined && (obj.listExpr = message.listExpr ? Expr_CreateList.toJSON(message.listExpr) : undefined); + message.structExpr !== undefined && (obj.structExpr = message.structExpr ? Expr_CreateStruct.toJSON(message.structExpr) : undefined); + message.comprehensionExpr !== undefined && (obj.comprehensionExpr = message.comprehensionExpr ? Expr_Comprehension.toJSON(message.comprehensionExpr) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): Expr { + const message = createBaseExpr(); + if (object.id !== undefined && object.id !== null) { + message.id = BigInt(object.id.toString()); + } + if (object.constExpr !== undefined && object.constExpr !== null) { + message.constExpr = Constant.fromPartial(object.constExpr); + } + if (object.identExpr !== undefined && object.identExpr !== null) { + message.identExpr = Expr_Ident.fromPartial(object.identExpr); + } + if (object.selectExpr !== undefined && object.selectExpr !== null) { + message.selectExpr = Expr_Select.fromPartial(object.selectExpr); + } + if (object.callExpr !== undefined && object.callExpr !== null) { + message.callExpr = Expr_Call.fromPartial(object.callExpr); + } + if (object.listExpr !== undefined && object.listExpr !== null) { + message.listExpr = Expr_CreateList.fromPartial(object.listExpr); + } + if (object.structExpr !== undefined && object.structExpr !== null) { + message.structExpr = Expr_CreateStruct.fromPartial(object.structExpr); + } + if (object.comprehensionExpr !== undefined && object.comprehensionExpr !== null) { + message.comprehensionExpr = Expr_Comprehension.fromPartial(object.comprehensionExpr); + } + return message; + }, + fromSDK(object: ExprSDKType): Expr { + return { + id: object?.id, + constExpr: object.const_expr ? Constant.fromSDK(object.const_expr) : undefined, + identExpr: object.ident_expr ? Expr_Ident.fromSDK(object.ident_expr) : undefined, + selectExpr: object.select_expr ? Expr_Select.fromSDK(object.select_expr) : undefined, + callExpr: object.call_expr ? Expr_Call.fromSDK(object.call_expr) : undefined, + listExpr: object.list_expr ? Expr_CreateList.fromSDK(object.list_expr) : undefined, + structExpr: object.struct_expr ? Expr_CreateStruct.fromSDK(object.struct_expr) : undefined, + comprehensionExpr: object.comprehension_expr ? Expr_Comprehension.fromSDK(object.comprehension_expr) : undefined + }; + }, + fromSDKJSON(object: any): ExprSDKType { + return { + id: isSet(object.id) ? BigInt(object.id.toString()) : BigInt(0), + const_expr: isSet(object.const_expr) ? Constant.fromSDKJSON(object.const_expr) : undefined, + ident_expr: isSet(object.ident_expr) ? Expr_Ident.fromSDKJSON(object.ident_expr) : undefined, + select_expr: isSet(object.select_expr) ? Expr_Select.fromSDKJSON(object.select_expr) : undefined, + call_expr: isSet(object.call_expr) ? Expr_Call.fromSDKJSON(object.call_expr) : undefined, + list_expr: isSet(object.list_expr) ? Expr_CreateList.fromSDKJSON(object.list_expr) : undefined, + struct_expr: isSet(object.struct_expr) ? Expr_CreateStruct.fromSDKJSON(object.struct_expr) : undefined, + comprehension_expr: isSet(object.comprehension_expr) ? Expr_Comprehension.fromSDKJSON(object.comprehension_expr) : undefined + }; + }, + toSDK(message: Expr): ExprSDKType { + const obj: any = {}; + obj.id = message.id; + message.constExpr !== undefined && (obj.const_expr = message.constExpr ? Constant.toSDK(message.constExpr) : undefined); + message.identExpr !== undefined && (obj.ident_expr = message.identExpr ? Expr_Ident.toSDK(message.identExpr) : undefined); + message.selectExpr !== undefined && (obj.select_expr = message.selectExpr ? Expr_Select.toSDK(message.selectExpr) : undefined); + message.callExpr !== undefined && (obj.call_expr = message.callExpr ? Expr_Call.toSDK(message.callExpr) : undefined); + message.listExpr !== undefined && (obj.list_expr = message.listExpr ? Expr_CreateList.toSDK(message.listExpr) : undefined); + message.structExpr !== undefined && (obj.struct_expr = message.structExpr ? Expr_CreateStruct.toSDK(message.structExpr) : undefined); + message.comprehensionExpr !== undefined && (obj.comprehension_expr = message.comprehensionExpr ? Expr_Comprehension.toSDK(message.comprehensionExpr) : undefined); + return obj; + }, + fromAmino(object: ExprAmino): Expr { + const message = createBaseExpr(); + if (object.id !== undefined && object.id !== null) { + message.id = BigInt(object.id); + } + if (object.const_expr !== undefined && object.const_expr !== null) { + message.constExpr = Constant.fromAmino(object.const_expr); + } + if (object.ident_expr !== undefined && object.ident_expr !== null) { + message.identExpr = Expr_Ident.fromAmino(object.ident_expr); + } + if (object.select_expr !== undefined && object.select_expr !== null) { + message.selectExpr = Expr_Select.fromAmino(object.select_expr); + } + if (object.call_expr !== undefined && object.call_expr !== null) { + message.callExpr = Expr_Call.fromAmino(object.call_expr); + } + if (object.list_expr !== undefined && object.list_expr !== null) { + message.listExpr = Expr_CreateList.fromAmino(object.list_expr); + } + if (object.struct_expr !== undefined && object.struct_expr !== null) { + message.structExpr = Expr_CreateStruct.fromAmino(object.struct_expr); + } + if (object.comprehension_expr !== undefined && object.comprehension_expr !== null) { + message.comprehensionExpr = Expr_Comprehension.fromAmino(object.comprehension_expr); + } + return message; + }, + toAmino(message: Expr): ExprAmino { + const obj: any = {}; + obj.id = message.id !== BigInt(0) ? message.id?.toString() : undefined; + obj.const_expr = message.constExpr ? Constant.toAmino(message.constExpr) : undefined; + obj.ident_expr = message.identExpr ? Expr_Ident.toAmino(message.identExpr) : undefined; + obj.select_expr = message.selectExpr ? Expr_Select.toAmino(message.selectExpr) : undefined; + obj.call_expr = message.callExpr ? Expr_Call.toAmino(message.callExpr) : undefined; + obj.list_expr = message.listExpr ? Expr_CreateList.toAmino(message.listExpr) : undefined; + obj.struct_expr = message.structExpr ? Expr_CreateStruct.toAmino(message.structExpr) : undefined; + obj.comprehension_expr = message.comprehensionExpr ? Expr_Comprehension.toAmino(message.comprehensionExpr) : undefined; + return obj; + }, + fromAminoMsg(object: ExprAminoMsg): Expr { + return Expr.fromAmino(object.value); + }, + fromProtoMsg(message: ExprProtoMsg): Expr { + return Expr.decode(message.value); + }, + toProto(message: Expr): Uint8Array { + return Expr.encode(message).finish(); + }, + toProtoMsg(message: Expr): ExprProtoMsg { + return { + typeUrl: "/google.api.expr.v1alpha1.Expr", + value: Expr.encode(message).finish() + }; + } +}; +function createBaseExpr_Ident(): Expr_Ident { + return { + name: "" + }; +} +export const Expr_Ident = { + typeUrl: "/google.api.expr.v1alpha1.Ident", + encode(message: Expr_Ident, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Expr_Ident { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseExpr_Ident(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Expr_Ident { + const obj = createBaseExpr_Ident(); + if (isSet(object.name)) obj.name = String(object.name); + return obj; + }, + toJSON(message: Expr_Ident): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + return obj; + }, + fromPartial(object: DeepPartial): Expr_Ident { + const message = createBaseExpr_Ident(); + message.name = object.name ?? ""; + return message; + }, + fromSDK(object: Expr_IdentSDKType): Expr_Ident { + return { + name: object?.name + }; + }, + fromSDKJSON(object: any): Expr_IdentSDKType { + return { + name: isSet(object.name) ? String(object.name) : "" + }; + }, + toSDK(message: Expr_Ident): Expr_IdentSDKType { + const obj: any = {}; + obj.name = message.name; + return obj; + }, + fromAmino(object: Expr_IdentAmino): Expr_Ident { + const message = createBaseExpr_Ident(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + return message; + }, + toAmino(message: Expr_Ident): Expr_IdentAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + return obj; + }, + fromAminoMsg(object: Expr_IdentAminoMsg): Expr_Ident { + return Expr_Ident.fromAmino(object.value); + }, + fromProtoMsg(message: Expr_IdentProtoMsg): Expr_Ident { + return Expr_Ident.decode(message.value); + }, + toProto(message: Expr_Ident): Uint8Array { + return Expr_Ident.encode(message).finish(); + }, + toProtoMsg(message: Expr_Ident): Expr_IdentProtoMsg { + return { + typeUrl: "/google.api.expr.v1alpha1.Ident", + value: Expr_Ident.encode(message).finish() + }; + } +}; +function createBaseExpr_Select(): Expr_Select { + return { + operand: undefined, + field: "", + testOnly: false + }; +} +export const Expr_Select = { + typeUrl: "/google.api.expr.v1alpha1.Select", + encode(message: Expr_Select, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.operand !== undefined) { + Expr.encode(message.operand, writer.uint32(10).fork()).ldelim(); + } + if (message.field !== undefined) { + writer.uint32(18).string(message.field); + } + if (message.testOnly !== undefined) { + writer.uint32(24).bool(message.testOnly); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Expr_Select { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseExpr_Select(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.operand = Expr.decode(reader, reader.uint32()); + break; + case 2: + message.field = reader.string(); + break; + case 3: + message.testOnly = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Expr_Select { + const obj = createBaseExpr_Select(); + if (isSet(object.operand)) obj.operand = Expr.fromJSON(object.operand); + if (isSet(object.field)) obj.field = String(object.field); + if (isSet(object.testOnly)) obj.testOnly = Boolean(object.testOnly); + return obj; + }, + toJSON(message: Expr_Select): JsonSafe { + const obj: any = {}; + message.operand !== undefined && (obj.operand = message.operand ? Expr.toJSON(message.operand) : undefined); + message.field !== undefined && (obj.field = message.field); + message.testOnly !== undefined && (obj.testOnly = message.testOnly); + return obj; + }, + fromPartial(object: DeepPartial): Expr_Select { + const message = createBaseExpr_Select(); + if (object.operand !== undefined && object.operand !== null) { + message.operand = Expr.fromPartial(object.operand); + } + message.field = object.field ?? ""; + message.testOnly = object.testOnly ?? false; + return message; + }, + fromSDK(object: Expr_SelectSDKType): Expr_Select { + return { + operand: object.operand ? Expr.fromSDK(object.operand) : undefined, + field: object?.field, + testOnly: object?.test_only + }; + }, + fromSDKJSON(object: any): Expr_SelectSDKType { + return { + operand: isSet(object.operand) ? Expr.fromSDKJSON(object.operand) : undefined, + field: isSet(object.field) ? String(object.field) : "", + test_only: isSet(object.test_only) ? Boolean(object.test_only) : false + }; + }, + toSDK(message: Expr_Select): Expr_SelectSDKType { + const obj: any = {}; + message.operand !== undefined && (obj.operand = message.operand ? Expr.toSDK(message.operand) : undefined); + obj.field = message.field; + obj.test_only = message.testOnly; + return obj; + }, + fromAmino(object: Expr_SelectAmino): Expr_Select { + const message = createBaseExpr_Select(); + if (object.operand !== undefined && object.operand !== null) { + message.operand = Expr.fromAmino(object.operand); + } + if (object.field !== undefined && object.field !== null) { + message.field = object.field; + } + if (object.test_only !== undefined && object.test_only !== null) { + message.testOnly = object.test_only; + } + return message; + }, + toAmino(message: Expr_Select): Expr_SelectAmino { + const obj: any = {}; + obj.operand = message.operand ? Expr.toAmino(message.operand) : undefined; + obj.field = message.field === "" ? undefined : message.field; + obj.test_only = message.testOnly === false ? undefined : message.testOnly; + return obj; + }, + fromAminoMsg(object: Expr_SelectAminoMsg): Expr_Select { + return Expr_Select.fromAmino(object.value); + }, + fromProtoMsg(message: Expr_SelectProtoMsg): Expr_Select { + return Expr_Select.decode(message.value); + }, + toProto(message: Expr_Select): Uint8Array { + return Expr_Select.encode(message).finish(); + }, + toProtoMsg(message: Expr_Select): Expr_SelectProtoMsg { + return { + typeUrl: "/google.api.expr.v1alpha1.Select", + value: Expr_Select.encode(message).finish() + }; + } +}; +function createBaseExpr_Call(): Expr_Call { + return { + target: undefined, + function: "", + args: [] + }; +} +export const Expr_Call = { + typeUrl: "/google.api.expr.v1alpha1.Call", + encode(message: Expr_Call, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.target !== undefined) { + Expr.encode(message.target, writer.uint32(10).fork()).ldelim(); + } + if (message.function !== undefined) { + writer.uint32(18).string(message.function); + } + for (const v of message.args) { + Expr.encode(v!, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Expr_Call { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseExpr_Call(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.target = Expr.decode(reader, reader.uint32()); + break; + case 2: + message.function = reader.string(); + break; + case 3: + message.args.push(Expr.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Expr_Call { + const obj = createBaseExpr_Call(); + if (isSet(object.target)) obj.target = Expr.fromJSON(object.target); + if (isSet(object.function)) obj.function = String(object.function); + if (Array.isArray(object?.args)) obj.args = object.args.map((e: any) => Expr.fromJSON(e)); + return obj; + }, + toJSON(message: Expr_Call): JsonSafe { + const obj: any = {}; + message.target !== undefined && (obj.target = message.target ? Expr.toJSON(message.target) : undefined); + message.function !== undefined && (obj.function = message.function); + if (message.args) { + obj.args = message.args.map(e => e ? Expr.toJSON(e) : undefined); + } else { + obj.args = []; + } + return obj; + }, + fromPartial(object: DeepPartial): Expr_Call { + const message = createBaseExpr_Call(); + if (object.target !== undefined && object.target !== null) { + message.target = Expr.fromPartial(object.target); + } + message.function = object.function ?? ""; + message.args = object.args?.map(e => Expr.fromPartial(e)) || []; + return message; + }, + fromSDK(object: Expr_CallSDKType): Expr_Call { + return { + target: object.target ? Expr.fromSDK(object.target) : undefined, + function: object?.function, + args: Array.isArray(object?.args) ? object.args.map((e: any) => Expr.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): Expr_CallSDKType { + return { + target: isSet(object.target) ? Expr.fromSDKJSON(object.target) : undefined, + function: isSet(object.function) ? String(object.function) : "", + args: Array.isArray(object?.args) ? object.args.map((e: any) => Expr.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: Expr_Call): Expr_CallSDKType { + const obj: any = {}; + message.target !== undefined && (obj.target = message.target ? Expr.toSDK(message.target) : undefined); + obj.function = message.function; + if (message.args) { + obj.args = message.args.map(e => e ? Expr.toSDK(e) : undefined); + } else { + obj.args = []; + } + return obj; + }, + fromAmino(object: Expr_CallAmino): Expr_Call { + const message = createBaseExpr_Call(); + if (object.target !== undefined && object.target !== null) { + message.target = Expr.fromAmino(object.target); + } + if (object.function !== undefined && object.function !== null) { + message.function = object.function; + } + message.args = object.args?.map(e => Expr.fromAmino(e)) || []; + return message; + }, + toAmino(message: Expr_Call): Expr_CallAmino { + const obj: any = {}; + obj.target = message.target ? Expr.toAmino(message.target) : undefined; + obj.function = message.function === "" ? undefined : message.function; + if (message.args) { + obj.args = message.args.map(e => e ? Expr.toAmino(e) : undefined); + } else { + obj.args = message.args; + } + return obj; + }, + fromAminoMsg(object: Expr_CallAminoMsg): Expr_Call { + return Expr_Call.fromAmino(object.value); + }, + fromProtoMsg(message: Expr_CallProtoMsg): Expr_Call { + return Expr_Call.decode(message.value); + }, + toProto(message: Expr_Call): Uint8Array { + return Expr_Call.encode(message).finish(); + }, + toProtoMsg(message: Expr_Call): Expr_CallProtoMsg { + return { + typeUrl: "/google.api.expr.v1alpha1.Call", + value: Expr_Call.encode(message).finish() + }; + } +}; +function createBaseExpr_CreateList(): Expr_CreateList { + return { + elements: [] + }; +} +export const Expr_CreateList = { + typeUrl: "/google.api.expr.v1alpha1.CreateList", + encode(message: Expr_CreateList, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.elements) { + Expr.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Expr_CreateList { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseExpr_CreateList(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.elements.push(Expr.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Expr_CreateList { + const obj = createBaseExpr_CreateList(); + if (Array.isArray(object?.elements)) obj.elements = object.elements.map((e: any) => Expr.fromJSON(e)); + return obj; + }, + toJSON(message: Expr_CreateList): JsonSafe { + const obj: any = {}; + if (message.elements) { + obj.elements = message.elements.map(e => e ? Expr.toJSON(e) : undefined); + } else { + obj.elements = []; + } + return obj; + }, + fromPartial(object: DeepPartial): Expr_CreateList { + const message = createBaseExpr_CreateList(); + message.elements = object.elements?.map(e => Expr.fromPartial(e)) || []; + return message; + }, + fromSDK(object: Expr_CreateListSDKType): Expr_CreateList { + return { + elements: Array.isArray(object?.elements) ? object.elements.map((e: any) => Expr.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): Expr_CreateListSDKType { + return { + elements: Array.isArray(object?.elements) ? object.elements.map((e: any) => Expr.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: Expr_CreateList): Expr_CreateListSDKType { + const obj: any = {}; + if (message.elements) { + obj.elements = message.elements.map(e => e ? Expr.toSDK(e) : undefined); + } else { + obj.elements = []; + } + return obj; + }, + fromAmino(object: Expr_CreateListAmino): Expr_CreateList { + const message = createBaseExpr_CreateList(); + message.elements = object.elements?.map(e => Expr.fromAmino(e)) || []; + return message; + }, + toAmino(message: Expr_CreateList): Expr_CreateListAmino { + const obj: any = {}; + if (message.elements) { + obj.elements = message.elements.map(e => e ? Expr.toAmino(e) : undefined); + } else { + obj.elements = message.elements; + } + return obj; + }, + fromAminoMsg(object: Expr_CreateListAminoMsg): Expr_CreateList { + return Expr_CreateList.fromAmino(object.value); + }, + fromProtoMsg(message: Expr_CreateListProtoMsg): Expr_CreateList { + return Expr_CreateList.decode(message.value); + }, + toProto(message: Expr_CreateList): Uint8Array { + return Expr_CreateList.encode(message).finish(); + }, + toProtoMsg(message: Expr_CreateList): Expr_CreateListProtoMsg { + return { + typeUrl: "/google.api.expr.v1alpha1.CreateList", + value: Expr_CreateList.encode(message).finish() + }; + } +}; +function createBaseExpr_CreateStruct(): Expr_CreateStruct { + return { + messageName: "", + entries: [] + }; +} +export const Expr_CreateStruct = { + typeUrl: "/google.api.expr.v1alpha1.CreateStruct", + encode(message: Expr_CreateStruct, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.messageName !== undefined) { + writer.uint32(10).string(message.messageName); + } + for (const v of message.entries) { + Expr_CreateStruct_Entry.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Expr_CreateStruct { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseExpr_CreateStruct(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.messageName = reader.string(); + break; + case 2: + message.entries.push(Expr_CreateStruct_Entry.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Expr_CreateStruct { + const obj = createBaseExpr_CreateStruct(); + if (isSet(object.messageName)) obj.messageName = String(object.messageName); + if (Array.isArray(object?.entries)) obj.entries = object.entries.map((e: any) => Expr_CreateStruct_Entry.fromJSON(e)); + return obj; + }, + toJSON(message: Expr_CreateStruct): JsonSafe { + const obj: any = {}; + message.messageName !== undefined && (obj.messageName = message.messageName); + if (message.entries) { + obj.entries = message.entries.map(e => e ? Expr_CreateStruct_Entry.toJSON(e) : undefined); + } else { + obj.entries = []; + } + return obj; + }, + fromPartial(object: DeepPartial): Expr_CreateStruct { + const message = createBaseExpr_CreateStruct(); + message.messageName = object.messageName ?? ""; + message.entries = object.entries?.map(e => Expr_CreateStruct_Entry.fromPartial(e)) || []; + return message; + }, + fromSDK(object: Expr_CreateStructSDKType): Expr_CreateStruct { + return { + messageName: object?.message_name, + entries: Array.isArray(object?.entries) ? object.entries.map((e: any) => Expr_CreateStruct_Entry.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): Expr_CreateStructSDKType { + return { + message_name: isSet(object.message_name) ? String(object.message_name) : "", + entries: Array.isArray(object?.entries) ? object.entries.map((e: any) => Expr_CreateStruct_Entry.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: Expr_CreateStruct): Expr_CreateStructSDKType { + const obj: any = {}; + obj.message_name = message.messageName; + if (message.entries) { + obj.entries = message.entries.map(e => e ? Expr_CreateStruct_Entry.toSDK(e) : undefined); + } else { + obj.entries = []; + } + return obj; + }, + fromAmino(object: Expr_CreateStructAmino): Expr_CreateStruct { + const message = createBaseExpr_CreateStruct(); + if (object.message_name !== undefined && object.message_name !== null) { + message.messageName = object.message_name; + } + message.entries = object.entries?.map(e => Expr_CreateStruct_Entry.fromAmino(e)) || []; + return message; + }, + toAmino(message: Expr_CreateStruct): Expr_CreateStructAmino { + const obj: any = {}; + obj.message_name = message.messageName === "" ? undefined : message.messageName; + if (message.entries) { + obj.entries = message.entries.map(e => e ? Expr_CreateStruct_Entry.toAmino(e) : undefined); + } else { + obj.entries = message.entries; + } + return obj; + }, + fromAminoMsg(object: Expr_CreateStructAminoMsg): Expr_CreateStruct { + return Expr_CreateStruct.fromAmino(object.value); + }, + fromProtoMsg(message: Expr_CreateStructProtoMsg): Expr_CreateStruct { + return Expr_CreateStruct.decode(message.value); + }, + toProto(message: Expr_CreateStruct): Uint8Array { + return Expr_CreateStruct.encode(message).finish(); + }, + toProtoMsg(message: Expr_CreateStruct): Expr_CreateStructProtoMsg { + return { + typeUrl: "/google.api.expr.v1alpha1.CreateStruct", + value: Expr_CreateStruct.encode(message).finish() + }; + } +}; +function createBaseExpr_CreateStruct_Entry(): Expr_CreateStruct_Entry { + return { + id: BigInt(0), + fieldKey: undefined, + mapKey: undefined, + value: undefined + }; +} +export const Expr_CreateStruct_Entry = { + typeUrl: "/google.api.expr.v1alpha1.Entry", + encode(message: Expr_CreateStruct_Entry, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.id !== undefined) { + writer.uint32(8).int64(message.id); + } + if (message.fieldKey !== undefined) { + writer.uint32(18).string(message.fieldKey); + } + if (message.mapKey !== undefined) { + Expr.encode(message.mapKey, writer.uint32(26).fork()).ldelim(); + } + if (message.value !== undefined) { + Expr.encode(message.value, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Expr_CreateStruct_Entry { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseExpr_CreateStruct_Entry(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.id = reader.int64(); + break; + case 2: + message.fieldKey = reader.string(); + break; + case 3: + message.mapKey = Expr.decode(reader, reader.uint32()); + break; + case 4: + message.value = Expr.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Expr_CreateStruct_Entry { + const obj = createBaseExpr_CreateStruct_Entry(); + if (isSet(object.id)) obj.id = BigInt(object.id.toString()); + if (isSet(object.fieldKey)) obj.fieldKey = String(object.fieldKey); + if (isSet(object.mapKey)) obj.mapKey = Expr.fromJSON(object.mapKey); + if (isSet(object.value)) obj.value = Expr.fromJSON(object.value); + return obj; + }, + toJSON(message: Expr_CreateStruct_Entry): JsonSafe { + const obj: any = {}; + message.id !== undefined && (obj.id = (message.id || BigInt(0)).toString()); + message.fieldKey !== undefined && (obj.fieldKey = message.fieldKey); + message.mapKey !== undefined && (obj.mapKey = message.mapKey ? Expr.toJSON(message.mapKey) : undefined); + message.value !== undefined && (obj.value = message.value ? Expr.toJSON(message.value) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): Expr_CreateStruct_Entry { + const message = createBaseExpr_CreateStruct_Entry(); + if (object.id !== undefined && object.id !== null) { + message.id = BigInt(object.id.toString()); + } + message.fieldKey = object.fieldKey ?? undefined; + if (object.mapKey !== undefined && object.mapKey !== null) { + message.mapKey = Expr.fromPartial(object.mapKey); + } + if (object.value !== undefined && object.value !== null) { + message.value = Expr.fromPartial(object.value); + } + return message; + }, + fromSDK(object: Expr_CreateStruct_EntrySDKType): Expr_CreateStruct_Entry { + return { + id: object?.id, + fieldKey: object?.field_key, + mapKey: object.map_key ? Expr.fromSDK(object.map_key) : undefined, + value: object.value ? Expr.fromSDK(object.value) : undefined + }; + }, + fromSDKJSON(object: any): Expr_CreateStruct_EntrySDKType { + return { + id: isSet(object.id) ? BigInt(object.id.toString()) : BigInt(0), + field_key: isSet(object.field_key) ? String(object.field_key) : undefined, + map_key: isSet(object.map_key) ? Expr.fromSDKJSON(object.map_key) : undefined, + value: isSet(object.value) ? Expr.fromSDKJSON(object.value) : undefined + }; + }, + toSDK(message: Expr_CreateStruct_Entry): Expr_CreateStruct_EntrySDKType { + const obj: any = {}; + obj.id = message.id; + obj.field_key = message.fieldKey; + message.mapKey !== undefined && (obj.map_key = message.mapKey ? Expr.toSDK(message.mapKey) : undefined); + message.value !== undefined && (obj.value = message.value ? Expr.toSDK(message.value) : undefined); + return obj; + }, + fromAmino(object: Expr_CreateStruct_EntryAmino): Expr_CreateStruct_Entry { + const message = createBaseExpr_CreateStruct_Entry(); + if (object.id !== undefined && object.id !== null) { + message.id = BigInt(object.id); + } + if (object.field_key !== undefined && object.field_key !== null) { + message.fieldKey = object.field_key; + } + if (object.map_key !== undefined && object.map_key !== null) { + message.mapKey = Expr.fromAmino(object.map_key); + } + if (object.value !== undefined && object.value !== null) { + message.value = Expr.fromAmino(object.value); + } + return message; + }, + toAmino(message: Expr_CreateStruct_Entry): Expr_CreateStruct_EntryAmino { + const obj: any = {}; + obj.id = message.id !== BigInt(0) ? message.id?.toString() : undefined; + obj.field_key = message.fieldKey === null ? undefined : message.fieldKey; + obj.map_key = message.mapKey ? Expr.toAmino(message.mapKey) : undefined; + obj.value = message.value ? Expr.toAmino(message.value) : undefined; + return obj; + }, + fromAminoMsg(object: Expr_CreateStruct_EntryAminoMsg): Expr_CreateStruct_Entry { + return Expr_CreateStruct_Entry.fromAmino(object.value); + }, + fromProtoMsg(message: Expr_CreateStruct_EntryProtoMsg): Expr_CreateStruct_Entry { + return Expr_CreateStruct_Entry.decode(message.value); + }, + toProto(message: Expr_CreateStruct_Entry): Uint8Array { + return Expr_CreateStruct_Entry.encode(message).finish(); + }, + toProtoMsg(message: Expr_CreateStruct_Entry): Expr_CreateStruct_EntryProtoMsg { + return { + typeUrl: "/google.api.expr.v1alpha1.Entry", + value: Expr_CreateStruct_Entry.encode(message).finish() + }; + } +}; +function createBaseExpr_Comprehension(): Expr_Comprehension { + return { + iterVar: "", + iterRange: undefined, + accuVar: "", + accuInit: undefined, + loopCondition: undefined, + loopStep: undefined, + result: undefined + }; +} +export const Expr_Comprehension = { + typeUrl: "/google.api.expr.v1alpha1.Comprehension", + encode(message: Expr_Comprehension, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.iterVar !== undefined) { + writer.uint32(10).string(message.iterVar); + } + if (message.iterRange !== undefined) { + Expr.encode(message.iterRange, writer.uint32(18).fork()).ldelim(); + } + if (message.accuVar !== undefined) { + writer.uint32(26).string(message.accuVar); + } + if (message.accuInit !== undefined) { + Expr.encode(message.accuInit, writer.uint32(34).fork()).ldelim(); + } + if (message.loopCondition !== undefined) { + Expr.encode(message.loopCondition, writer.uint32(42).fork()).ldelim(); + } + if (message.loopStep !== undefined) { + Expr.encode(message.loopStep, writer.uint32(50).fork()).ldelim(); + } + if (message.result !== undefined) { + Expr.encode(message.result, writer.uint32(58).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Expr_Comprehension { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseExpr_Comprehension(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.iterVar = reader.string(); + break; + case 2: + message.iterRange = Expr.decode(reader, reader.uint32()); + break; + case 3: + message.accuVar = reader.string(); + break; + case 4: + message.accuInit = Expr.decode(reader, reader.uint32()); + break; + case 5: + message.loopCondition = Expr.decode(reader, reader.uint32()); + break; + case 6: + message.loopStep = Expr.decode(reader, reader.uint32()); + break; + case 7: + message.result = Expr.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Expr_Comprehension { + const obj = createBaseExpr_Comprehension(); + if (isSet(object.iterVar)) obj.iterVar = String(object.iterVar); + if (isSet(object.iterRange)) obj.iterRange = Expr.fromJSON(object.iterRange); + if (isSet(object.accuVar)) obj.accuVar = String(object.accuVar); + if (isSet(object.accuInit)) obj.accuInit = Expr.fromJSON(object.accuInit); + if (isSet(object.loopCondition)) obj.loopCondition = Expr.fromJSON(object.loopCondition); + if (isSet(object.loopStep)) obj.loopStep = Expr.fromJSON(object.loopStep); + if (isSet(object.result)) obj.result = Expr.fromJSON(object.result); + return obj; + }, + toJSON(message: Expr_Comprehension): JsonSafe { + const obj: any = {}; + message.iterVar !== undefined && (obj.iterVar = message.iterVar); + message.iterRange !== undefined && (obj.iterRange = message.iterRange ? Expr.toJSON(message.iterRange) : undefined); + message.accuVar !== undefined && (obj.accuVar = message.accuVar); + message.accuInit !== undefined && (obj.accuInit = message.accuInit ? Expr.toJSON(message.accuInit) : undefined); + message.loopCondition !== undefined && (obj.loopCondition = message.loopCondition ? Expr.toJSON(message.loopCondition) : undefined); + message.loopStep !== undefined && (obj.loopStep = message.loopStep ? Expr.toJSON(message.loopStep) : undefined); + message.result !== undefined && (obj.result = message.result ? Expr.toJSON(message.result) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): Expr_Comprehension { + const message = createBaseExpr_Comprehension(); + message.iterVar = object.iterVar ?? ""; + if (object.iterRange !== undefined && object.iterRange !== null) { + message.iterRange = Expr.fromPartial(object.iterRange); + } + message.accuVar = object.accuVar ?? ""; + if (object.accuInit !== undefined && object.accuInit !== null) { + message.accuInit = Expr.fromPartial(object.accuInit); + } + if (object.loopCondition !== undefined && object.loopCondition !== null) { + message.loopCondition = Expr.fromPartial(object.loopCondition); + } + if (object.loopStep !== undefined && object.loopStep !== null) { + message.loopStep = Expr.fromPartial(object.loopStep); + } + if (object.result !== undefined && object.result !== null) { + message.result = Expr.fromPartial(object.result); + } + return message; + }, + fromSDK(object: Expr_ComprehensionSDKType): Expr_Comprehension { + return { + iterVar: object?.iter_var, + iterRange: object.iter_range ? Expr.fromSDK(object.iter_range) : undefined, + accuVar: object?.accu_var, + accuInit: object.accu_init ? Expr.fromSDK(object.accu_init) : undefined, + loopCondition: object.loop_condition ? Expr.fromSDK(object.loop_condition) : undefined, + loopStep: object.loop_step ? Expr.fromSDK(object.loop_step) : undefined, + result: object.result ? Expr.fromSDK(object.result) : undefined + }; + }, + fromSDKJSON(object: any): Expr_ComprehensionSDKType { + return { + iter_var: isSet(object.iter_var) ? String(object.iter_var) : "", + iter_range: isSet(object.iter_range) ? Expr.fromSDKJSON(object.iter_range) : undefined, + accu_var: isSet(object.accu_var) ? String(object.accu_var) : "", + accu_init: isSet(object.accu_init) ? Expr.fromSDKJSON(object.accu_init) : undefined, + loop_condition: isSet(object.loop_condition) ? Expr.fromSDKJSON(object.loop_condition) : undefined, + loop_step: isSet(object.loop_step) ? Expr.fromSDKJSON(object.loop_step) : undefined, + result: isSet(object.result) ? Expr.fromSDKJSON(object.result) : undefined + }; + }, + toSDK(message: Expr_Comprehension): Expr_ComprehensionSDKType { + const obj: any = {}; + obj.iter_var = message.iterVar; + message.iterRange !== undefined && (obj.iter_range = message.iterRange ? Expr.toSDK(message.iterRange) : undefined); + obj.accu_var = message.accuVar; + message.accuInit !== undefined && (obj.accu_init = message.accuInit ? Expr.toSDK(message.accuInit) : undefined); + message.loopCondition !== undefined && (obj.loop_condition = message.loopCondition ? Expr.toSDK(message.loopCondition) : undefined); + message.loopStep !== undefined && (obj.loop_step = message.loopStep ? Expr.toSDK(message.loopStep) : undefined); + message.result !== undefined && (obj.result = message.result ? Expr.toSDK(message.result) : undefined); + return obj; + }, + fromAmino(object: Expr_ComprehensionAmino): Expr_Comprehension { + const message = createBaseExpr_Comprehension(); + if (object.iter_var !== undefined && object.iter_var !== null) { + message.iterVar = object.iter_var; + } + if (object.iter_range !== undefined && object.iter_range !== null) { + message.iterRange = Expr.fromAmino(object.iter_range); + } + if (object.accu_var !== undefined && object.accu_var !== null) { + message.accuVar = object.accu_var; + } + if (object.accu_init !== undefined && object.accu_init !== null) { + message.accuInit = Expr.fromAmino(object.accu_init); + } + if (object.loop_condition !== undefined && object.loop_condition !== null) { + message.loopCondition = Expr.fromAmino(object.loop_condition); + } + if (object.loop_step !== undefined && object.loop_step !== null) { + message.loopStep = Expr.fromAmino(object.loop_step); + } + if (object.result !== undefined && object.result !== null) { + message.result = Expr.fromAmino(object.result); + } + return message; + }, + toAmino(message: Expr_Comprehension): Expr_ComprehensionAmino { + const obj: any = {}; + obj.iter_var = message.iterVar === "" ? undefined : message.iterVar; + obj.iter_range = message.iterRange ? Expr.toAmino(message.iterRange) : undefined; + obj.accu_var = message.accuVar === "" ? undefined : message.accuVar; + obj.accu_init = message.accuInit ? Expr.toAmino(message.accuInit) : undefined; + obj.loop_condition = message.loopCondition ? Expr.toAmino(message.loopCondition) : undefined; + obj.loop_step = message.loopStep ? Expr.toAmino(message.loopStep) : undefined; + obj.result = message.result ? Expr.toAmino(message.result) : undefined; + return obj; + }, + fromAminoMsg(object: Expr_ComprehensionAminoMsg): Expr_Comprehension { + return Expr_Comprehension.fromAmino(object.value); + }, + fromProtoMsg(message: Expr_ComprehensionProtoMsg): Expr_Comprehension { + return Expr_Comprehension.decode(message.value); + }, + toProto(message: Expr_Comprehension): Uint8Array { + return Expr_Comprehension.encode(message).finish(); + }, + toProtoMsg(message: Expr_Comprehension): Expr_ComprehensionProtoMsg { + return { + typeUrl: "/google.api.expr.v1alpha1.Comprehension", + value: Expr_Comprehension.encode(message).finish() + }; + } +}; +function createBaseConstant(): Constant { + return { + nullValue: undefined, + boolValue: undefined, + int64Value: undefined, + uint64Value: undefined, + doubleValue: undefined, + stringValue: undefined, + bytesValue: undefined, + durationValue: undefined, + timestampValue: undefined + }; +} +export const Constant = { + typeUrl: "/google.api.expr.v1alpha1.Constant", + encode(message: Constant, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.nullValue !== undefined) { + writer.uint32(8).int32(message.nullValue); + } + if (message.boolValue !== undefined) { + writer.uint32(16).bool(message.boolValue); + } + if (message.int64Value !== undefined) { + writer.uint32(24).int64(message.int64Value); + } + if (message.uint64Value !== undefined) { + writer.uint32(32).uint64(message.uint64Value); + } + if (message.doubleValue !== undefined) { + writer.uint32(41).double(message.doubleValue); + } + if (message.stringValue !== undefined) { + writer.uint32(50).string(message.stringValue); + } + if (message.bytesValue !== undefined) { + writer.uint32(58).bytes(message.bytesValue); + } + if (message.durationValue !== undefined) { + Duration.encode(message.durationValue, writer.uint32(66).fork()).ldelim(); + } + if (message.timestampValue !== undefined) { + Timestamp.encode(toTimestamp(message.timestampValue), writer.uint32(74).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Constant { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseConstant(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.nullValue = (reader.int32() as any); + break; + case 2: + message.boolValue = reader.bool(); + break; + case 3: + message.int64Value = reader.int64(); + break; + case 4: + message.uint64Value = reader.uint64(); + break; + case 5: + message.doubleValue = reader.double(); + break; + case 6: + message.stringValue = reader.string(); + break; + case 7: + message.bytesValue = reader.bytes(); + break; + case 8: + message.durationValue = Duration.decode(reader, reader.uint32()); + break; + case 9: + message.timestampValue = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Constant { + const obj = createBaseConstant(); + if (isSet(object.nullValue)) obj.nullValue = nullValueFromJSON(object.nullValue); + if (isSet(object.boolValue)) obj.boolValue = Boolean(object.boolValue); + if (isSet(object.int64Value)) obj.int64Value = BigInt(object.int64Value.toString()); + if (isSet(object.uint64Value)) obj.uint64Value = BigInt(object.uint64Value.toString()); + if (isSet(object.doubleValue)) obj.doubleValue = Number(object.doubleValue); + if (isSet(object.stringValue)) obj.stringValue = String(object.stringValue); + if (isSet(object.bytesValue)) obj.bytesValue = bytesFromBase64(object.bytesValue); + if (isSet(object.durationValue)) obj.durationValue = Duration.fromJSON(object.durationValue); + if (isSet(object.timestampValue)) obj.timestampValue = new Date(object.timestampValue); + return obj; + }, + toJSON(message: Constant): JsonSafe { + const obj: any = {}; + message.nullValue !== undefined && (obj.nullValue = nullValueToJSON(message.nullValue)); + message.boolValue !== undefined && (obj.boolValue = message.boolValue); + if (message.int64Value !== undefined) { + obj.int64Value = message.int64Value.toString(); + } + if (message.uint64Value !== undefined) { + obj.uint64Value = message.uint64Value.toString(); + } + message.doubleValue !== undefined && (obj.doubleValue = message.doubleValue); + message.stringValue !== undefined && (obj.stringValue = message.stringValue); + message.bytesValue !== undefined && (obj.bytesValue = message.bytesValue !== undefined ? base64FromBytes(message.bytesValue) : undefined); + message.durationValue !== undefined && (obj.durationValue = message.durationValue ? Duration.toJSON(message.durationValue) : undefined); + message.timestampValue !== undefined && (obj.timestampValue = message.timestampValue.toISOString()); + return obj; + }, + fromPartial(object: DeepPartial): Constant { + const message = createBaseConstant(); + message.nullValue = object.nullValue ?? undefined; + message.boolValue = object.boolValue ?? undefined; + if (object.int64Value !== undefined && object.int64Value !== null) { + message.int64Value = BigInt(object.int64Value.toString()); + } + if (object.uint64Value !== undefined && object.uint64Value !== null) { + message.uint64Value = BigInt(object.uint64Value.toString()); + } + message.doubleValue = object.doubleValue ?? undefined; + message.stringValue = object.stringValue ?? undefined; + message.bytesValue = object.bytesValue ?? undefined; + if (object.durationValue !== undefined && object.durationValue !== null) { + message.durationValue = Duration.fromPartial(object.durationValue); + } + message.timestampValue = object.timestampValue ?? undefined; + return message; + }, + fromSDK(object: ConstantSDKType): Constant { + return { + nullValue: isSet(object.null_value) ? nullValueFromJSON(object.null_value) : undefined, + boolValue: object?.bool_value, + int64Value: object?.int64_value, + uint64Value: object?.uint64_value, + doubleValue: object?.double_value, + stringValue: object?.string_value, + bytesValue: object?.bytes_value, + durationValue: object.duration_value ? Duration.fromSDK(object.duration_value) : undefined, + timestampValue: object.timestamp_value ?? undefined + }; + }, + fromSDKJSON(object: any): ConstantSDKType { + return { + null_value: isSet(object.null_value) ? nullValueFromJSON(object.null_value) : undefined, + bool_value: isSet(object.bool_value) ? Boolean(object.bool_value) : undefined, + int64_value: isSet(object.int64_value) ? BigInt(object.int64_value.toString()) : undefined, + uint64_value: isSet(object.uint64_value) ? BigInt(object.uint64_value.toString()) : undefined, + double_value: isSet(object.double_value) ? Number(object.double_value) : undefined, + string_value: isSet(object.string_value) ? String(object.string_value) : undefined, + bytes_value: isSet(object.bytes_value) ? bytesFromBase64(object.bytes_value) : undefined, + duration_value: isSet(object.duration_value) ? Duration.fromSDKJSON(object.duration_value) : undefined, + timestamp_value: isSet(object.timestamp_value) ? new Date(object.timestamp_value) : undefined + }; + }, + toSDK(message: Constant): ConstantSDKType { + const obj: any = {}; + message.nullValue !== undefined && (obj.null_value = nullValueToJSON(message.nullValue)); + obj.bool_value = message.boolValue; + obj.int64_value = message.int64Value; + obj.uint64_value = message.uint64Value; + obj.double_value = message.doubleValue; + obj.string_value = message.stringValue; + obj.bytes_value = message.bytesValue; + message.durationValue !== undefined && (obj.duration_value = message.durationValue ? Duration.toSDK(message.durationValue) : undefined); + message.timestampValue !== undefined && (obj.timestamp_value = message.timestampValue ?? undefined); + return obj; + }, + fromAmino(object: ConstantAmino): Constant { + const message = createBaseConstant(); + if (object.null_value !== undefined && object.null_value !== null) { + message.nullValue = object.null_value; + } + if (object.bool_value !== undefined && object.bool_value !== null) { + message.boolValue = object.bool_value; + } + if (object.int64_value !== undefined && object.int64_value !== null) { + message.int64Value = BigInt(object.int64_value); + } + if (object.uint64_value !== undefined && object.uint64_value !== null) { + message.uint64Value = BigInt(object.uint64_value); + } + if (object.double_value !== undefined && object.double_value !== null) { + message.doubleValue = object.double_value; + } + if (object.string_value !== undefined && object.string_value !== null) { + message.stringValue = object.string_value; + } + if (object.bytes_value !== undefined && object.bytes_value !== null) { + message.bytesValue = bytesFromBase64(object.bytes_value); + } + if (object.duration_value !== undefined && object.duration_value !== null) { + message.durationValue = Duration.fromAmino(object.duration_value); + } + if (object.timestamp_value !== undefined && object.timestamp_value !== null) { + message.timestampValue = fromTimestamp(Timestamp.fromAmino(object.timestamp_value)); + } + return message; + }, + toAmino(message: Constant): ConstantAmino { + const obj: any = {}; + obj.null_value = message.nullValue === null ? undefined : message.nullValue; + obj.bool_value = message.boolValue === null ? undefined : message.boolValue; + obj.int64_value = message.int64Value !== BigInt(0) ? message.int64Value?.toString() : undefined; + obj.uint64_value = message.uint64Value !== BigInt(0) ? message.uint64Value?.toString() : undefined; + obj.double_value = message.doubleValue === null ? undefined : message.doubleValue; + obj.string_value = message.stringValue === null ? undefined : message.stringValue; + obj.bytes_value = message.bytesValue ? base64FromBytes(message.bytesValue) : undefined; + obj.duration_value = message.durationValue ? Duration.toAmino(message.durationValue) : undefined; + obj.timestamp_value = message.timestampValue ? Timestamp.toAmino(toTimestamp(message.timestampValue)) : undefined; + return obj; + }, + fromAminoMsg(object: ConstantAminoMsg): Constant { + return Constant.fromAmino(object.value); + }, + fromProtoMsg(message: ConstantProtoMsg): Constant { + return Constant.decode(message.value); + }, + toProto(message: Constant): Uint8Array { + return Constant.encode(message).finish(); + }, + toProtoMsg(message: Constant): ConstantProtoMsg { + return { + typeUrl: "/google.api.expr.v1alpha1.Constant", + value: Constant.encode(message).finish() + }; + } +}; +function createBaseSourceInfo_PositionsEntry(): SourceInfo_PositionsEntry { + return { + key: BigInt(0), + value: 0 + }; +} +export const SourceInfo_PositionsEntry = { + encode(message: SourceInfo_PositionsEntry, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.key !== undefined) { + writer.uint32(8).int64(message.key); + } + if (message.value !== undefined) { + writer.uint32(16).int32(message.value); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): SourceInfo_PositionsEntry { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseSourceInfo_PositionsEntry(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.int64(); + break; + case 2: + message.value = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): SourceInfo_PositionsEntry { + const obj = createBaseSourceInfo_PositionsEntry(); + if (isSet(object.key)) obj.key = BigInt(object.key.toString()); + if (isSet(object.value)) obj.value = Number(object.value); + return obj; + }, + toJSON(message: SourceInfo_PositionsEntry): JsonSafe { + const obj: any = {}; + message.key !== undefined && (obj.key = (message.key || BigInt(0)).toString()); + message.value !== undefined && (obj.value = Math.round(message.value)); + return obj; + }, + fromPartial(object: DeepPartial): SourceInfo_PositionsEntry { + const message = createBaseSourceInfo_PositionsEntry(); + if (object.key !== undefined && object.key !== null) { + message.key = BigInt(object.key.toString()); + } + message.value = object.value ?? 0; + return message; + }, + fromSDK(object: SourceInfo_PositionsEntrySDKType): SourceInfo_PositionsEntry { + return { + key: object?.key, + value: object?.value + }; + }, + fromSDKJSON(object: any): SourceInfo_PositionsEntrySDKType { + return { + key: isSet(object.key) ? BigInt(object.key.toString()) : BigInt(0), + value: isSet(object.value) ? Number(object.value) : 0 + }; + }, + toSDK(message: SourceInfo_PositionsEntry): SourceInfo_PositionsEntrySDKType { + const obj: any = {}; + obj.key = message.key; + obj.value = message.value; + return obj; + }, + fromAmino(object: SourceInfo_PositionsEntryAmino): SourceInfo_PositionsEntry { + const message = createBaseSourceInfo_PositionsEntry(); + if (object.key !== undefined && object.key !== null) { + message.key = BigInt(object.key); + } + if (object.value !== undefined && object.value !== null) { + message.value = object.value; + } + return message; + }, + toAmino(message: SourceInfo_PositionsEntry): SourceInfo_PositionsEntryAmino { + const obj: any = {}; + obj.key = message.key !== BigInt(0) ? message.key?.toString() : undefined; + obj.value = message.value === 0 ? undefined : message.value; + return obj; + }, + fromAminoMsg(object: SourceInfo_PositionsEntryAminoMsg): SourceInfo_PositionsEntry { + return SourceInfo_PositionsEntry.fromAmino(object.value); + }, + fromProtoMsg(message: SourceInfo_PositionsEntryProtoMsg): SourceInfo_PositionsEntry { + return SourceInfo_PositionsEntry.decode(message.value); + }, + toProto(message: SourceInfo_PositionsEntry): Uint8Array { + return SourceInfo_PositionsEntry.encode(message).finish(); + } +}; +function createBaseSourceInfo_MacroCallsEntry(): SourceInfo_MacroCallsEntry { + return { + key: BigInt(0), + value: undefined + }; +} +export const SourceInfo_MacroCallsEntry = { + encode(message: SourceInfo_MacroCallsEntry, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.key !== undefined) { + writer.uint32(8).int64(message.key); + } + if (message.value !== undefined) { + Expr.encode(message.value, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): SourceInfo_MacroCallsEntry { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseSourceInfo_MacroCallsEntry(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.int64(); + break; + case 2: + message.value = Expr.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): SourceInfo_MacroCallsEntry { + const obj = createBaseSourceInfo_MacroCallsEntry(); + if (isSet(object.key)) obj.key = BigInt(object.key.toString()); + if (isSet(object.value)) obj.value = Expr.fromJSON(object.value); + return obj; + }, + toJSON(message: SourceInfo_MacroCallsEntry): JsonSafe { + const obj: any = {}; + message.key !== undefined && (obj.key = (message.key || BigInt(0)).toString()); + message.value !== undefined && (obj.value = message.value ? Expr.toJSON(message.value) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): SourceInfo_MacroCallsEntry { + const message = createBaseSourceInfo_MacroCallsEntry(); + if (object.key !== undefined && object.key !== null) { + message.key = BigInt(object.key.toString()); + } + if (object.value !== undefined && object.value !== null) { + message.value = Expr.fromPartial(object.value); + } + return message; + }, + fromSDK(object: SourceInfo_MacroCallsEntrySDKType): SourceInfo_MacroCallsEntry { + return { + key: object?.key, + value: object.value ? Expr.fromSDK(object.value) : undefined + }; + }, + fromSDKJSON(object: any): SourceInfo_MacroCallsEntrySDKType { + return { + key: isSet(object.key) ? BigInt(object.key.toString()) : BigInt(0), + value: isSet(object.value) ? Expr.fromSDKJSON(object.value) : undefined + }; + }, + toSDK(message: SourceInfo_MacroCallsEntry): SourceInfo_MacroCallsEntrySDKType { + const obj: any = {}; + obj.key = message.key; + message.value !== undefined && (obj.value = message.value ? Expr.toSDK(message.value) : undefined); + return obj; + }, + fromAmino(object: SourceInfo_MacroCallsEntryAmino): SourceInfo_MacroCallsEntry { + const message = createBaseSourceInfo_MacroCallsEntry(); + if (object.key !== undefined && object.key !== null) { + message.key = BigInt(object.key); + } + if (object.value !== undefined && object.value !== null) { + message.value = Expr.fromAmino(object.value); + } + return message; + }, + toAmino(message: SourceInfo_MacroCallsEntry): SourceInfo_MacroCallsEntryAmino { + const obj: any = {}; + obj.key = message.key !== BigInt(0) ? message.key?.toString() : undefined; + obj.value = message.value ? Expr.toAmino(message.value) : undefined; + return obj; + }, + fromAminoMsg(object: SourceInfo_MacroCallsEntryAminoMsg): SourceInfo_MacroCallsEntry { + return SourceInfo_MacroCallsEntry.fromAmino(object.value); + }, + fromProtoMsg(message: SourceInfo_MacroCallsEntryProtoMsg): SourceInfo_MacroCallsEntry { + return SourceInfo_MacroCallsEntry.decode(message.value); + }, + toProto(message: SourceInfo_MacroCallsEntry): Uint8Array { + return SourceInfo_MacroCallsEntry.encode(message).finish(); + } +}; +function createBaseSourceInfo(): SourceInfo { + return { + syntaxVersion: "", + location: "", + lineOffsets: [], + positions: {}, + macroCalls: {} + }; +} +export const SourceInfo = { + typeUrl: "/google.api.expr.v1alpha1.SourceInfo", + encode(message: SourceInfo, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.syntaxVersion !== undefined) { + writer.uint32(10).string(message.syntaxVersion); + } + if (message.location !== undefined) { + writer.uint32(18).string(message.location); + } + writer.uint32(26).fork(); + for (const v of message.lineOffsets) { + writer.int32(v); + } + writer.ldelim(); + Object.entries(message.positions).forEach(([key, value]) => { + SourceInfo_PositionsEntry.encode({ + key: (key as any), + value + }, writer.uint32(32).fork()).ldelim(); + }); + Object.entries(message.macroCalls).forEach(([key, value]) => { + SourceInfo_MacroCallsEntry.encode({ + key: (key as any), + value + }, writer.uint32(42).fork()).ldelim(); + }); + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): SourceInfo { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseSourceInfo(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.syntaxVersion = reader.string(); + break; + case 2: + message.location = reader.string(); + break; + case 3: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.lineOffsets.push(reader.int32()); + } + } else { + message.lineOffsets.push(reader.int32()); + } + break; + case 4: + const entry4 = SourceInfo_PositionsEntry.decode(reader, reader.uint32()); + if (entry4.value !== undefined) { + message.positions[entry4.key] = entry4.value; + } + break; + case 5: + const entry5 = SourceInfo_MacroCallsEntry.decode(reader, reader.uint32()); + if (entry5.value !== undefined) { + message.macroCalls[entry5.key] = entry5.value; + } + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): SourceInfo { + const obj = createBaseSourceInfo(); + if (isSet(object.syntaxVersion)) obj.syntaxVersion = String(object.syntaxVersion); + if (isSet(object.location)) obj.location = String(object.location); + if (Array.isArray(object?.lineOffsets)) obj.lineOffsets = object.lineOffsets.map((e: any) => Number(e)); + if (isObject(object.positions)) obj.positions = Object.entries(object.positions).reduce<{ + [key: bigint]: number; + }>((acc, [key, value]) => { + acc[Number(key)] = Number(value); + return acc; + }, {}); + if (isObject(object.macroCalls)) obj.macroCalls = Object.entries(object.macroCalls).reduce<{ + [key: bigint]: Expr; + }>((acc, [key, value]) => { + acc[Number(key)] = Expr.fromJSON(value); + return acc; + }, {}); + return obj; + }, + toJSON(message: SourceInfo): JsonSafe { + const obj: any = {}; + message.syntaxVersion !== undefined && (obj.syntaxVersion = message.syntaxVersion); + message.location !== undefined && (obj.location = message.location); + if (message.lineOffsets) { + obj.lineOffsets = message.lineOffsets.map(e => Math.round(e)); + } else { + obj.lineOffsets = []; + } + obj.positions = {}; + if (message.positions) { + Object.entries(message.positions).forEach(([k, v]) => { + obj.positions[k] = Math.round(v); + }); + } + obj.macroCalls = {}; + if (message.macroCalls) { + Object.entries(message.macroCalls).forEach(([k, v]) => { + obj.macroCalls[k] = Expr.toJSON(v); + }); + } + return obj; + }, + fromPartial(object: DeepPartial): SourceInfo { + const message = createBaseSourceInfo(); + message.syntaxVersion = object.syntaxVersion ?? ""; + message.location = object.location ?? ""; + message.lineOffsets = object.lineOffsets?.map(e => e) || []; + message.positions = Object.entries(object.positions ?? {}).reduce<{ + [key: bigint]: number; + }>((acc, [key, value]) => { + if (value !== undefined) { + acc[Number(key)] = Number(value); + } + return acc; + }, {}); + message.macroCalls = Object.entries(object.macroCalls ?? {}).reduce<{ + [key: bigint]: Expr; + }>((acc, [key, value]) => { + if (value !== undefined) { + acc[Number(key)] = Expr.fromPartial(value); + } + return acc; + }, {}); + return message; + }, + fromSDK(object: SourceInfoSDKType): SourceInfo { + return { + syntaxVersion: object?.syntax_version, + location: object?.location, + lineOffsets: Array.isArray(object?.line_offsets) ? object.line_offsets.map((e: any) => e) : [], + positions: isObject(object.positions) ? Object.entries(object.positions).reduce<{ + [key: bigint]: number; + }>((acc, [key, value]) => { + acc[Number(key)] = Number(value); + return acc; + }, {}) : {}, + macroCalls: isObject(object.macro_calls) ? Object.entries(object.macro_calls).reduce<{ + [key: bigint]: Expr; + }>((acc, [key, value]) => { + acc[Number(key)] = Expr.fromSDK(value); + return acc; + }, {}) : {} + }; + }, + fromSDKJSON(object: any): SourceInfoSDKType { + return { + syntax_version: isSet(object.syntax_version) ? String(object.syntax_version) : "", + location: isSet(object.location) ? String(object.location) : "", + line_offsets: Array.isArray(object?.line_offsets) ? object.line_offsets.map((e: any) => Number(e)) : [], + positions: isObject(object.positions) ? Object.entries(object.positions).reduce<{ + [key: bigint]: number; + }>((acc, [key, value]) => { + acc[Number(key)] = Number(value); + return acc; + }, {}) : {}, + macro_calls: isObject(object.macro_calls) ? Object.entries(object.macro_calls).reduce<{ + [key: bigint]: Expr; + }>((acc, [key, value]) => { + acc[Number(key)] = Expr.fromSDKJSON(value); + return acc; + }, {}) : {} + }; + }, + toSDK(message: SourceInfo): SourceInfoSDKType { + const obj: any = {}; + obj.syntax_version = message.syntaxVersion; + obj.location = message.location; + if (message.lineOffsets) { + obj.line_offsets = message.lineOffsets.map(e => e); + } else { + obj.line_offsets = []; + } + obj.positions = {}; + if (message.positions) { + Object.entries(message.positions).forEach(([k, v]) => { + obj.positions[k] = Math.round(v); + }); + } + obj.macro_calls = {}; + if (message.macroCalls) { + Object.entries(message.macroCalls).forEach(([k, v]) => { + obj.macro_calls[k] = Expr.toSDK(v); + }); + } + return obj; + }, + fromAmino(object: SourceInfoAmino): SourceInfo { + const message = createBaseSourceInfo(); + if (object.syntax_version !== undefined && object.syntax_version !== null) { + message.syntaxVersion = object.syntax_version; + } + if (object.location !== undefined && object.location !== null) { + message.location = object.location; + } + message.lineOffsets = object.line_offsets?.map(e => e) || []; + message.positions = Object.entries(object.positions ?? {}).reduce<{ + [key: bigint]: number; + }>((acc, [key, value]) => { + if (value !== undefined) { + acc[Number(key)] = Number(value); + } + return acc; + }, {}); + message.macroCalls = Object.entries(object.macro_calls ?? {}).reduce<{ + [key: bigint]: Expr; + }>((acc, [key, value]) => { + if (value !== undefined) { + acc[Number(key)] = Expr.fromAmino(value); + } + return acc; + }, {}); + return message; + }, + toAmino(message: SourceInfo): SourceInfoAmino { + const obj: any = {}; + obj.syntax_version = message.syntaxVersion === "" ? undefined : message.syntaxVersion; + obj.location = message.location === "" ? undefined : message.location; + if (message.lineOffsets) { + obj.line_offsets = message.lineOffsets.map(e => e); + } else { + obj.line_offsets = message.lineOffsets; + } + obj.positions = {}; + if (message.positions) { + Object.entries(message.positions).forEach(([k, v]) => { + obj.positions[k] = Math.round(v); + }); + } + obj.macro_calls = {}; + if (message.macroCalls) { + Object.entries(message.macroCalls).forEach(([k, v]) => { + obj.macro_calls[k] = Expr.toAmino(v); + }); + } + return obj; + }, + fromAminoMsg(object: SourceInfoAminoMsg): SourceInfo { + return SourceInfo.fromAmino(object.value); + }, + fromProtoMsg(message: SourceInfoProtoMsg): SourceInfo { + return SourceInfo.decode(message.value); + }, + toProto(message: SourceInfo): Uint8Array { + return SourceInfo.encode(message).finish(); + }, + toProtoMsg(message: SourceInfo): SourceInfoProtoMsg { + return { + typeUrl: "/google.api.expr.v1alpha1.SourceInfo", + value: SourceInfo.encode(message).finish() + }; + } +}; +function createBaseSourcePosition(): SourcePosition { + return { + location: "", + offset: 0, + line: 0, + column: 0 + }; +} +export const SourcePosition = { + typeUrl: "/google.api.expr.v1alpha1.SourcePosition", + encode(message: SourcePosition, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.location !== undefined) { + writer.uint32(10).string(message.location); + } + if (message.offset !== undefined) { + writer.uint32(16).int32(message.offset); + } + if (message.line !== undefined) { + writer.uint32(24).int32(message.line); + } + if (message.column !== undefined) { + writer.uint32(32).int32(message.column); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): SourcePosition { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseSourcePosition(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.location = reader.string(); + break; + case 2: + message.offset = reader.int32(); + break; + case 3: + message.line = reader.int32(); + break; + case 4: + message.column = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): SourcePosition { + const obj = createBaseSourcePosition(); + if (isSet(object.location)) obj.location = String(object.location); + if (isSet(object.offset)) obj.offset = Number(object.offset); + if (isSet(object.line)) obj.line = Number(object.line); + if (isSet(object.column)) obj.column = Number(object.column); + return obj; + }, + toJSON(message: SourcePosition): JsonSafe { + const obj: any = {}; + message.location !== undefined && (obj.location = message.location); + message.offset !== undefined && (obj.offset = Math.round(message.offset)); + message.line !== undefined && (obj.line = Math.round(message.line)); + message.column !== undefined && (obj.column = Math.round(message.column)); + return obj; + }, + fromPartial(object: DeepPartial): SourcePosition { + const message = createBaseSourcePosition(); + message.location = object.location ?? ""; + message.offset = object.offset ?? 0; + message.line = object.line ?? 0; + message.column = object.column ?? 0; + return message; + }, + fromSDK(object: SourcePositionSDKType): SourcePosition { + return { + location: object?.location, + offset: object?.offset, + line: object?.line, + column: object?.column + }; + }, + fromSDKJSON(object: any): SourcePositionSDKType { + return { + location: isSet(object.location) ? String(object.location) : "", + offset: isSet(object.offset) ? Number(object.offset) : 0, + line: isSet(object.line) ? Number(object.line) : 0, + column: isSet(object.column) ? Number(object.column) : 0 + }; + }, + toSDK(message: SourcePosition): SourcePositionSDKType { + const obj: any = {}; + obj.location = message.location; + obj.offset = message.offset; + obj.line = message.line; + obj.column = message.column; + return obj; + }, + fromAmino(object: SourcePositionAmino): SourcePosition { + const message = createBaseSourcePosition(); + if (object.location !== undefined && object.location !== null) { + message.location = object.location; + } + if (object.offset !== undefined && object.offset !== null) { + message.offset = object.offset; + } + if (object.line !== undefined && object.line !== null) { + message.line = object.line; + } + if (object.column !== undefined && object.column !== null) { + message.column = object.column; + } + return message; + }, + toAmino(message: SourcePosition): SourcePositionAmino { + const obj: any = {}; + obj.location = message.location === "" ? undefined : message.location; + obj.offset = message.offset === 0 ? undefined : message.offset; + obj.line = message.line === 0 ? undefined : message.line; + obj.column = message.column === 0 ? undefined : message.column; + return obj; + }, + fromAminoMsg(object: SourcePositionAminoMsg): SourcePosition { + return SourcePosition.fromAmino(object.value); + }, + fromProtoMsg(message: SourcePositionProtoMsg): SourcePosition { + return SourcePosition.decode(message.value); + }, + toProto(message: SourcePosition): Uint8Array { + return SourcePosition.encode(message).finish(); + }, + toProtoMsg(message: SourcePosition): SourcePositionProtoMsg { + return { + typeUrl: "/google.api.expr.v1alpha1.SourcePosition", + value: SourcePosition.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/api/expr/v1alpha1/value.ts b/__fixtures__/v-next/outputicjsdeps/google/api/expr/v1alpha1/value.ts new file mode 100644 index 0000000000..f6a2b19c5c --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/api/expr/v1alpha1/value.ts @@ -0,0 +1,851 @@ +import { NullValue, NullValueSDKType, nullValueFromJSON, nullValueToJSON } from "../../../protobuf/struct.js"; +import { Any, AnySDKType } from "../../../protobuf/any.js"; +import { BinaryReader, BinaryWriter } from "../../../../binary.js"; +import { isSet, bytesFromBase64, base64FromBytes, DeepPartial } from "../../../../helpers.js"; +import { JsonSafe } from "../../../../json-safe.js"; +export const protobufPackage = "google.api.expr.v1alpha1"; +/** + * Represents a CEL value. + * + * This is similar to `google.protobuf.Value`, but can represent CEL's full + * range of values. + */ +export interface Value { + /** Null value. */ + nullValue?: NullValue; + /** Boolean value. */ + boolValue?: boolean; + /** Signed integer value. */ + int64Value?: bigint; + /** Unsigned integer value. */ + uint64Value?: bigint; + /** Floating point value. */ + doubleValue?: number; + /** UTF-8 string value. */ + stringValue?: string; + /** Byte string value. */ + bytesValue?: Uint8Array; + /** An enum value. */ + enumValue?: EnumValue; + /** The proto message backing an object value. */ + objectValue?: Any; + /** Map value. */ + mapValue?: MapValue; + /** List value. */ + listValue?: ListValue; + /** Type value. */ + typeValue?: string; +} +export interface ValueProtoMsg { + typeUrl: "/google.api.expr.v1alpha1.Value"; + value: Uint8Array; +} +/** + * Represents a CEL value. + * + * This is similar to `google.protobuf.Value`, but can represent CEL's full + * range of values. + */ +export interface ValueSDKType { + null_value?: NullValue; + bool_value?: boolean; + int64_value?: bigint; + uint64_value?: bigint; + double_value?: number; + string_value?: string; + bytes_value?: Uint8Array; + enum_value?: EnumValueSDKType; + object_value?: AnySDKType; + map_value?: MapValueSDKType; + list_value?: ListValueSDKType; + type_value?: string; +} +/** An enum value. */ +export interface EnumValue { + /** The fully qualified name of the enum type. */ + type: string; + /** The value of the enum. */ + value: number; +} +export interface EnumValueProtoMsg { + typeUrl: "/google.api.expr.v1alpha1.EnumValue"; + value: Uint8Array; +} +/** An enum value. */ +export interface EnumValueSDKType { + type: string; + value: number; +} +/** + * A list. + * + * Wrapped in a message so 'not set' and empty can be differentiated, which is + * required for use in a 'oneof'. + */ +export interface ListValue { + /** The ordered values in the list. */ + values: Value[]; +} +export interface ListValueProtoMsg { + typeUrl: "/google.api.expr.v1alpha1.ListValue"; + value: Uint8Array; +} +/** + * A list. + * + * Wrapped in a message so 'not set' and empty can be differentiated, which is + * required for use in a 'oneof'. + */ +export interface ListValueSDKType { + values: ValueSDKType[]; +} +/** + * A map. + * + * Wrapped in a message so 'not set' and empty can be differentiated, which is + * required for use in a 'oneof'. + */ +export interface MapValue { + /** + * The set of map entries. + * + * CEL has fewer restrictions on keys, so a protobuf map represenation + * cannot be used. + */ + entries: MapValue_Entry[]; +} +export interface MapValueProtoMsg { + typeUrl: "/google.api.expr.v1alpha1.MapValue"; + value: Uint8Array; +} +/** + * A map. + * + * Wrapped in a message so 'not set' and empty can be differentiated, which is + * required for use in a 'oneof'. + */ +export interface MapValueSDKType { + entries: MapValue_EntrySDKType[]; +} +/** An entry in the map. */ +export interface MapValue_Entry { + /** + * The key. + * + * Must be unique with in the map. + * Currently only boolean, int, uint, and string values can be keys. + */ + key?: Value; + /** The value. */ + value?: Value; +} +export interface MapValue_EntryProtoMsg { + typeUrl: "/google.api.expr.v1alpha1.Entry"; + value: Uint8Array; +} +/** An entry in the map. */ +export interface MapValue_EntrySDKType { + key?: ValueSDKType; + value?: ValueSDKType; +} +function createBaseValue(): Value { + return { + nullValue: undefined, + boolValue: undefined, + int64Value: undefined, + uint64Value: undefined, + doubleValue: undefined, + stringValue: undefined, + bytesValue: undefined, + enumValue: undefined, + objectValue: undefined, + mapValue: undefined, + listValue: undefined, + typeValue: undefined + }; +} +export const Value = { + typeUrl: "/google.api.expr.v1alpha1.Value", + encode(message: Value, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.nullValue !== undefined) { + writer.uint32(8).int32(message.nullValue); + } + if (message.boolValue !== undefined) { + writer.uint32(16).bool(message.boolValue); + } + if (message.int64Value !== undefined) { + writer.uint32(24).int64(message.int64Value); + } + if (message.uint64Value !== undefined) { + writer.uint32(32).uint64(message.uint64Value); + } + if (message.doubleValue !== undefined) { + writer.uint32(41).double(message.doubleValue); + } + if (message.stringValue !== undefined) { + writer.uint32(50).string(message.stringValue); + } + if (message.bytesValue !== undefined) { + writer.uint32(58).bytes(message.bytesValue); + } + if (message.enumValue !== undefined) { + EnumValue.encode(message.enumValue, writer.uint32(74).fork()).ldelim(); + } + if (message.objectValue !== undefined) { + Any.encode(message.objectValue, writer.uint32(82).fork()).ldelim(); + } + if (message.mapValue !== undefined) { + MapValue.encode(message.mapValue, writer.uint32(90).fork()).ldelim(); + } + if (message.listValue !== undefined) { + ListValue.encode(message.listValue, writer.uint32(98).fork()).ldelim(); + } + if (message.typeValue !== undefined) { + writer.uint32(122).string(message.typeValue); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Value { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseValue(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.nullValue = (reader.int32() as any); + break; + case 2: + message.boolValue = reader.bool(); + break; + case 3: + message.int64Value = reader.int64(); + break; + case 4: + message.uint64Value = reader.uint64(); + break; + case 5: + message.doubleValue = reader.double(); + break; + case 6: + message.stringValue = reader.string(); + break; + case 7: + message.bytesValue = reader.bytes(); + break; + case 9: + message.enumValue = EnumValue.decode(reader, reader.uint32()); + break; + case 10: + message.objectValue = Any.decode(reader, reader.uint32()); + break; + case 11: + message.mapValue = MapValue.decode(reader, reader.uint32()); + break; + case 12: + message.listValue = ListValue.decode(reader, reader.uint32()); + break; + case 15: + message.typeValue = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Value { + const obj = createBaseValue(); + if (isSet(object.nullValue)) obj.nullValue = nullValueFromJSON(object.nullValue); + if (isSet(object.boolValue)) obj.boolValue = Boolean(object.boolValue); + if (isSet(object.int64Value)) obj.int64Value = BigInt(object.int64Value.toString()); + if (isSet(object.uint64Value)) obj.uint64Value = BigInt(object.uint64Value.toString()); + if (isSet(object.doubleValue)) obj.doubleValue = Number(object.doubleValue); + if (isSet(object.stringValue)) obj.stringValue = String(object.stringValue); + if (isSet(object.bytesValue)) obj.bytesValue = bytesFromBase64(object.bytesValue); + if (isSet(object.enumValue)) obj.enumValue = EnumValue.fromJSON(object.enumValue); + if (isSet(object.objectValue)) obj.objectValue = Any.fromJSON(object.objectValue); + if (isSet(object.mapValue)) obj.mapValue = MapValue.fromJSON(object.mapValue); + if (isSet(object.listValue)) obj.listValue = ListValue.fromJSON(object.listValue); + if (isSet(object.typeValue)) obj.typeValue = String(object.typeValue); + return obj; + }, + toJSON(message: Value): JsonSafe { + const obj: any = {}; + message.nullValue !== undefined && (obj.nullValue = nullValueToJSON(message.nullValue)); + message.boolValue !== undefined && (obj.boolValue = message.boolValue); + if (message.int64Value !== undefined) { + obj.int64Value = message.int64Value.toString(); + } + if (message.uint64Value !== undefined) { + obj.uint64Value = message.uint64Value.toString(); + } + message.doubleValue !== undefined && (obj.doubleValue = message.doubleValue); + message.stringValue !== undefined && (obj.stringValue = message.stringValue); + message.bytesValue !== undefined && (obj.bytesValue = message.bytesValue !== undefined ? base64FromBytes(message.bytesValue) : undefined); + message.enumValue !== undefined && (obj.enumValue = message.enumValue ? EnumValue.toJSON(message.enumValue) : undefined); + message.objectValue !== undefined && (obj.objectValue = message.objectValue ? Any.toJSON(message.objectValue) : undefined); + message.mapValue !== undefined && (obj.mapValue = message.mapValue ? MapValue.toJSON(message.mapValue) : undefined); + message.listValue !== undefined && (obj.listValue = message.listValue ? ListValue.toJSON(message.listValue) : undefined); + message.typeValue !== undefined && (obj.typeValue = message.typeValue); + return obj; + }, + fromPartial(object: DeepPartial): Value { + const message = createBaseValue(); + message.nullValue = object.nullValue ?? undefined; + message.boolValue = object.boolValue ?? undefined; + if (object.int64Value !== undefined && object.int64Value !== null) { + message.int64Value = BigInt(object.int64Value.toString()); + } + if (object.uint64Value !== undefined && object.uint64Value !== null) { + message.uint64Value = BigInt(object.uint64Value.toString()); + } + message.doubleValue = object.doubleValue ?? undefined; + message.stringValue = object.stringValue ?? undefined; + message.bytesValue = object.bytesValue ?? undefined; + if (object.enumValue !== undefined && object.enumValue !== null) { + message.enumValue = EnumValue.fromPartial(object.enumValue); + } + if (object.objectValue !== undefined && object.objectValue !== null) { + message.objectValue = Any.fromPartial(object.objectValue); + } + if (object.mapValue !== undefined && object.mapValue !== null) { + message.mapValue = MapValue.fromPartial(object.mapValue); + } + if (object.listValue !== undefined && object.listValue !== null) { + message.listValue = ListValue.fromPartial(object.listValue); + } + message.typeValue = object.typeValue ?? undefined; + return message; + }, + fromSDK(object: ValueSDKType): Value { + return { + nullValue: isSet(object.null_value) ? nullValueFromJSON(object.null_value) : undefined, + boolValue: object?.bool_value, + int64Value: object?.int64_value, + uint64Value: object?.uint64_value, + doubleValue: object?.double_value, + stringValue: object?.string_value, + bytesValue: object?.bytes_value, + enumValue: object.enum_value ? EnumValue.fromSDK(object.enum_value) : undefined, + objectValue: object.object_value ? Any.fromSDK(object.object_value) : undefined, + mapValue: object.map_value ? MapValue.fromSDK(object.map_value) : undefined, + listValue: object.list_value ? ListValue.fromSDK(object.list_value) : undefined, + typeValue: object?.type_value + }; + }, + fromSDKJSON(object: any): ValueSDKType { + return { + null_value: isSet(object.null_value) ? nullValueFromJSON(object.null_value) : undefined, + bool_value: isSet(object.bool_value) ? Boolean(object.bool_value) : undefined, + int64_value: isSet(object.int64_value) ? BigInt(object.int64_value.toString()) : undefined, + uint64_value: isSet(object.uint64_value) ? BigInt(object.uint64_value.toString()) : undefined, + double_value: isSet(object.double_value) ? Number(object.double_value) : undefined, + string_value: isSet(object.string_value) ? String(object.string_value) : undefined, + bytes_value: isSet(object.bytes_value) ? bytesFromBase64(object.bytes_value) : undefined, + enum_value: isSet(object.enum_value) ? EnumValue.fromSDKJSON(object.enum_value) : undefined, + object_value: isSet(object.object_value) ? Any.fromSDKJSON(object.object_value) : undefined, + map_value: isSet(object.map_value) ? MapValue.fromSDKJSON(object.map_value) : undefined, + list_value: isSet(object.list_value) ? ListValue.fromSDKJSON(object.list_value) : undefined, + type_value: isSet(object.type_value) ? String(object.type_value) : undefined + }; + }, + toSDK(message: Value): ValueSDKType { + const obj: any = {}; + message.nullValue !== undefined && (obj.null_value = nullValueToJSON(message.nullValue)); + obj.bool_value = message.boolValue; + obj.int64_value = message.int64Value; + obj.uint64_value = message.uint64Value; + obj.double_value = message.doubleValue; + obj.string_value = message.stringValue; + obj.bytes_value = message.bytesValue; + message.enumValue !== undefined && (obj.enum_value = message.enumValue ? EnumValue.toSDK(message.enumValue) : undefined); + message.objectValue !== undefined && (obj.object_value = message.objectValue ? Any.toSDK(message.objectValue) : undefined); + message.mapValue !== undefined && (obj.map_value = message.mapValue ? MapValue.toSDK(message.mapValue) : undefined); + message.listValue !== undefined && (obj.list_value = message.listValue ? ListValue.toSDK(message.listValue) : undefined); + obj.type_value = message.typeValue; + return obj; + }, + fromAmino(object: ValueAmino): Value { + const message = createBaseValue(); + if (object.null_value !== undefined && object.null_value !== null) { + message.nullValue = object.null_value; + } + if (object.bool_value !== undefined && object.bool_value !== null) { + message.boolValue = object.bool_value; + } + if (object.int64_value !== undefined && object.int64_value !== null) { + message.int64Value = BigInt(object.int64_value); + } + if (object.uint64_value !== undefined && object.uint64_value !== null) { + message.uint64Value = BigInt(object.uint64_value); + } + if (object.double_value !== undefined && object.double_value !== null) { + message.doubleValue = object.double_value; + } + if (object.string_value !== undefined && object.string_value !== null) { + message.stringValue = object.string_value; + } + if (object.bytes_value !== undefined && object.bytes_value !== null) { + message.bytesValue = bytesFromBase64(object.bytes_value); + } + if (object.enum_value !== undefined && object.enum_value !== null) { + message.enumValue = EnumValue.fromAmino(object.enum_value); + } + if (object.object_value !== undefined && object.object_value !== null) { + message.objectValue = Any.fromAmino(object.object_value); + } + if (object.map_value !== undefined && object.map_value !== null) { + message.mapValue = MapValue.fromAmino(object.map_value); + } + if (object.list_value !== undefined && object.list_value !== null) { + message.listValue = ListValue.fromAmino(object.list_value); + } + if (object.type_value !== undefined && object.type_value !== null) { + message.typeValue = object.type_value; + } + return message; + }, + toAmino(message: Value): ValueAmino { + const obj: any = {}; + obj.null_value = message.nullValue === null ? undefined : message.nullValue; + obj.bool_value = message.boolValue === null ? undefined : message.boolValue; + obj.int64_value = message.int64Value !== BigInt(0) ? message.int64Value?.toString() : undefined; + obj.uint64_value = message.uint64Value !== BigInt(0) ? message.uint64Value?.toString() : undefined; + obj.double_value = message.doubleValue === null ? undefined : message.doubleValue; + obj.string_value = message.stringValue === null ? undefined : message.stringValue; + obj.bytes_value = message.bytesValue ? base64FromBytes(message.bytesValue) : undefined; + obj.enum_value = message.enumValue ? EnumValue.toAmino(message.enumValue) : undefined; + obj.object_value = message.objectValue ? Any.toAmino(message.objectValue) : undefined; + obj.map_value = message.mapValue ? MapValue.toAmino(message.mapValue) : undefined; + obj.list_value = message.listValue ? ListValue.toAmino(message.listValue) : undefined; + obj.type_value = message.typeValue === null ? undefined : message.typeValue; + return obj; + }, + fromAminoMsg(object: ValueAminoMsg): Value { + return Value.fromAmino(object.value); + }, + fromProtoMsg(message: ValueProtoMsg): Value { + return Value.decode(message.value); + }, + toProto(message: Value): Uint8Array { + return Value.encode(message).finish(); + }, + toProtoMsg(message: Value): ValueProtoMsg { + return { + typeUrl: "/google.api.expr.v1alpha1.Value", + value: Value.encode(message).finish() + }; + } +}; +function createBaseEnumValue(): EnumValue { + return { + type: "", + value: 0 + }; +} +export const EnumValue = { + typeUrl: "/google.api.expr.v1alpha1.EnumValue", + encode(message: EnumValue, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.type !== undefined) { + writer.uint32(10).string(message.type); + } + if (message.value !== undefined) { + writer.uint32(16).int32(message.value); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): EnumValue { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseEnumValue(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.type = reader.string(); + break; + case 2: + message.value = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): EnumValue { + const obj = createBaseEnumValue(); + if (isSet(object.type)) obj.type = String(object.type); + if (isSet(object.value)) obj.value = Number(object.value); + return obj; + }, + toJSON(message: EnumValue): JsonSafe { + const obj: any = {}; + message.type !== undefined && (obj.type = message.type); + message.value !== undefined && (obj.value = Math.round(message.value)); + return obj; + }, + fromPartial(object: DeepPartial): EnumValue { + const message = createBaseEnumValue(); + message.type = object.type ?? ""; + message.value = object.value ?? 0; + return message; + }, + fromSDK(object: EnumValueSDKType): EnumValue { + return { + type: object?.type, + value: object?.value + }; + }, + fromSDKJSON(object: any): EnumValueSDKType { + return { + type: isSet(object.type) ? String(object.type) : "", + value: isSet(object.value) ? Number(object.value) : 0 + }; + }, + toSDK(message: EnumValue): EnumValueSDKType { + const obj: any = {}; + obj.type = message.type; + obj.value = message.value; + return obj; + }, + fromAmino(object: EnumValueAmino): EnumValue { + const message = createBaseEnumValue(); + if (object.type !== undefined && object.type !== null) { + message.type = object.type; + } + if (object.value !== undefined && object.value !== null) { + message.value = object.value; + } + return message; + }, + toAmino(message: EnumValue): EnumValueAmino { + const obj: any = {}; + obj.type = message.type === "" ? undefined : message.type; + obj.value = message.value === 0 ? undefined : message.value; + return obj; + }, + fromAminoMsg(object: EnumValueAminoMsg): EnumValue { + return EnumValue.fromAmino(object.value); + }, + fromProtoMsg(message: EnumValueProtoMsg): EnumValue { + return EnumValue.decode(message.value); + }, + toProto(message: EnumValue): Uint8Array { + return EnumValue.encode(message).finish(); + }, + toProtoMsg(message: EnumValue): EnumValueProtoMsg { + return { + typeUrl: "/google.api.expr.v1alpha1.EnumValue", + value: EnumValue.encode(message).finish() + }; + } +}; +function createBaseListValue(): ListValue { + return { + values: [] + }; +} +export const ListValue = { + typeUrl: "/google.api.expr.v1alpha1.ListValue", + encode(message: ListValue, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.values) { + Value.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ListValue { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseListValue(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.values.push(Value.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ListValue { + const obj = createBaseListValue(); + if (Array.isArray(object?.values)) obj.values = object.values.map((e: any) => Value.fromJSON(e)); + return obj; + }, + toJSON(message: ListValue): JsonSafe { + const obj: any = {}; + if (message.values) { + obj.values = message.values.map(e => e ? Value.toJSON(e) : undefined); + } else { + obj.values = []; + } + return obj; + }, + fromPartial(object: DeepPartial): ListValue { + const message = createBaseListValue(); + message.values = object.values?.map(e => Value.fromPartial(e)) || []; + return message; + }, + fromSDK(object: ListValueSDKType): ListValue { + return { + values: Array.isArray(object?.values) ? object.values.map((e: any) => Value.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): ListValueSDKType { + return { + values: Array.isArray(object?.values) ? object.values.map((e: any) => Value.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: ListValue): ListValueSDKType { + const obj: any = {}; + if (message.values) { + obj.values = message.values.map(e => e ? Value.toSDK(e) : undefined); + } else { + obj.values = []; + } + return obj; + }, + fromAmino(object: ListValueAmino): ListValue { + const message = createBaseListValue(); + message.values = object.values?.map(e => Value.fromAmino(e)) || []; + return message; + }, + toAmino(message: ListValue): ListValueAmino { + const obj: any = {}; + if (message.values) { + obj.values = message.values.map(e => e ? Value.toAmino(e) : undefined); + } else { + obj.values = message.values; + } + return obj; + }, + fromAminoMsg(object: ListValueAminoMsg): ListValue { + return ListValue.fromAmino(object.value); + }, + fromProtoMsg(message: ListValueProtoMsg): ListValue { + return ListValue.decode(message.value); + }, + toProto(message: ListValue): Uint8Array { + return ListValue.encode(message).finish(); + }, + toProtoMsg(message: ListValue): ListValueProtoMsg { + return { + typeUrl: "/google.api.expr.v1alpha1.ListValue", + value: ListValue.encode(message).finish() + }; + } +}; +function createBaseMapValue(): MapValue { + return { + entries: [] + }; +} +export const MapValue = { + typeUrl: "/google.api.expr.v1alpha1.MapValue", + encode(message: MapValue, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.entries) { + MapValue_Entry.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MapValue { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMapValue(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.entries.push(MapValue_Entry.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MapValue { + const obj = createBaseMapValue(); + if (Array.isArray(object?.entries)) obj.entries = object.entries.map((e: any) => MapValue_Entry.fromJSON(e)); + return obj; + }, + toJSON(message: MapValue): JsonSafe { + const obj: any = {}; + if (message.entries) { + obj.entries = message.entries.map(e => e ? MapValue_Entry.toJSON(e) : undefined); + } else { + obj.entries = []; + } + return obj; + }, + fromPartial(object: DeepPartial): MapValue { + const message = createBaseMapValue(); + message.entries = object.entries?.map(e => MapValue_Entry.fromPartial(e)) || []; + return message; + }, + fromSDK(object: MapValueSDKType): MapValue { + return { + entries: Array.isArray(object?.entries) ? object.entries.map((e: any) => MapValue_Entry.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): MapValueSDKType { + return { + entries: Array.isArray(object?.entries) ? object.entries.map((e: any) => MapValue_Entry.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: MapValue): MapValueSDKType { + const obj: any = {}; + if (message.entries) { + obj.entries = message.entries.map(e => e ? MapValue_Entry.toSDK(e) : undefined); + } else { + obj.entries = []; + } + return obj; + }, + fromAmino(object: MapValueAmino): MapValue { + const message = createBaseMapValue(); + message.entries = object.entries?.map(e => MapValue_Entry.fromAmino(e)) || []; + return message; + }, + toAmino(message: MapValue): MapValueAmino { + const obj: any = {}; + if (message.entries) { + obj.entries = message.entries.map(e => e ? MapValue_Entry.toAmino(e) : undefined); + } else { + obj.entries = message.entries; + } + return obj; + }, + fromAminoMsg(object: MapValueAminoMsg): MapValue { + return MapValue.fromAmino(object.value); + }, + fromProtoMsg(message: MapValueProtoMsg): MapValue { + return MapValue.decode(message.value); + }, + toProto(message: MapValue): Uint8Array { + return MapValue.encode(message).finish(); + }, + toProtoMsg(message: MapValue): MapValueProtoMsg { + return { + typeUrl: "/google.api.expr.v1alpha1.MapValue", + value: MapValue.encode(message).finish() + }; + } +}; +function createBaseMapValue_Entry(): MapValue_Entry { + return { + key: undefined, + value: undefined + }; +} +export const MapValue_Entry = { + typeUrl: "/google.api.expr.v1alpha1.Entry", + encode(message: MapValue_Entry, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.key !== undefined) { + Value.encode(message.key, writer.uint32(10).fork()).ldelim(); + } + if (message.value !== undefined) { + Value.encode(message.value, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MapValue_Entry { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMapValue_Entry(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = Value.decode(reader, reader.uint32()); + break; + case 2: + message.value = Value.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MapValue_Entry { + const obj = createBaseMapValue_Entry(); + if (isSet(object.key)) obj.key = Value.fromJSON(object.key); + if (isSet(object.value)) obj.value = Value.fromJSON(object.value); + return obj; + }, + toJSON(message: MapValue_Entry): JsonSafe { + const obj: any = {}; + message.key !== undefined && (obj.key = message.key ? Value.toJSON(message.key) : undefined); + message.value !== undefined && (obj.value = message.value ? Value.toJSON(message.value) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): MapValue_Entry { + const message = createBaseMapValue_Entry(); + if (object.key !== undefined && object.key !== null) { + message.key = Value.fromPartial(object.key); + } + if (object.value !== undefined && object.value !== null) { + message.value = Value.fromPartial(object.value); + } + return message; + }, + fromSDK(object: MapValue_EntrySDKType): MapValue_Entry { + return { + key: object.key ? Value.fromSDK(object.key) : undefined, + value: object.value ? Value.fromSDK(object.value) : undefined + }; + }, + fromSDKJSON(object: any): MapValue_EntrySDKType { + return { + key: isSet(object.key) ? Value.fromSDKJSON(object.key) : undefined, + value: isSet(object.value) ? Value.fromSDKJSON(object.value) : undefined + }; + }, + toSDK(message: MapValue_Entry): MapValue_EntrySDKType { + const obj: any = {}; + message.key !== undefined && (obj.key = message.key ? Value.toSDK(message.key) : undefined); + message.value !== undefined && (obj.value = message.value ? Value.toSDK(message.value) : undefined); + return obj; + }, + fromAmino(object: MapValue_EntryAmino): MapValue_Entry { + const message = createBaseMapValue_Entry(); + if (object.key !== undefined && object.key !== null) { + message.key = Value.fromAmino(object.key); + } + if (object.value !== undefined && object.value !== null) { + message.value = Value.fromAmino(object.value); + } + return message; + }, + toAmino(message: MapValue_Entry): MapValue_EntryAmino { + const obj: any = {}; + obj.key = message.key ? Value.toAmino(message.key) : undefined; + obj.value = message.value ? Value.toAmino(message.value) : undefined; + return obj; + }, + fromAminoMsg(object: MapValue_EntryAminoMsg): MapValue_Entry { + return MapValue_Entry.fromAmino(object.value); + }, + fromProtoMsg(message: MapValue_EntryProtoMsg): MapValue_Entry { + return MapValue_Entry.decode(message.value); + }, + toProto(message: MapValue_Entry): Uint8Array { + return MapValue_Entry.encode(message).finish(); + }, + toProtoMsg(message: MapValue_Entry): MapValue_EntryProtoMsg { + return { + typeUrl: "/google.api.expr.v1alpha1.Entry", + value: MapValue_Entry.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/api/expr/v1beta1/decl.ts b/__fixtures__/v-next/outputicjsdeps/google/api/expr/v1beta1/decl.ts new file mode 100644 index 0000000000..441dd94c7d --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/api/expr/v1beta1/decl.ts @@ -0,0 +1,632 @@ +import { Expr, ExprSDKType } from "./expr.js"; +import { BinaryReader, BinaryWriter } from "../../../../binary.js"; +import { isSet, DeepPartial } from "../../../../helpers.js"; +import { JsonSafe } from "../../../../json-safe.js"; +export const protobufPackage = "google.api.expr.v1beta1"; +/** A declaration. */ +export interface Decl { + /** The id of the declaration. */ + id: number; + /** The name of the declaration. */ + name: string; + /** The documentation string for the declaration. */ + doc: string; + /** An identifier declaration. */ + ident?: IdentDecl; + /** A function declaration. */ + function?: FunctionDecl; +} +export interface DeclProtoMsg { + typeUrl: "/google.api.expr.v1beta1.Decl"; + value: Uint8Array; +} +/** A declaration. */ +export interface DeclSDKType { + id: number; + name: string; + doc: string; + ident?: IdentDeclSDKType; + function?: FunctionDeclSDKType; +} +/** + * The declared type of a variable. + * + * Extends runtime type values with extra information used for type checking + * and dispatching. + */ +export interface DeclType { + /** The expression id of the declared type, if applicable. */ + id: number; + /** The type name, e.g. 'int', 'my.type.Type' or 'T' */ + type: string; + /** + * An ordered list of type parameters, e.g. ``. + * Only applies to a subset of types, e.g. `map`, `list`. + */ + typeParams: DeclType[]; +} +export interface DeclTypeProtoMsg { + typeUrl: "/google.api.expr.v1beta1.DeclType"; + value: Uint8Array; +} +/** + * The declared type of a variable. + * + * Extends runtime type values with extra information used for type checking + * and dispatching. + */ +export interface DeclTypeSDKType { + id: number; + type: string; + type_params: DeclTypeSDKType[]; +} +/** An identifier declaration. */ +export interface IdentDecl { + /** Optional type of the identifier. */ + type?: DeclType; + /** Optional value of the identifier. */ + value?: Expr; +} +export interface IdentDeclProtoMsg { + typeUrl: "/google.api.expr.v1beta1.IdentDecl"; + value: Uint8Array; +} +/** An identifier declaration. */ +export interface IdentDeclSDKType { + type?: DeclTypeSDKType; + value?: ExprSDKType; +} +/** A function declaration. */ +export interface FunctionDecl { + /** The function arguments. */ + args: IdentDecl[]; + /** Optional declared return type. */ + returnType?: DeclType; + /** If the first argument of the function is the receiver. */ + receiverFunction: boolean; +} +export interface FunctionDeclProtoMsg { + typeUrl: "/google.api.expr.v1beta1.FunctionDecl"; + value: Uint8Array; +} +/** A function declaration. */ +export interface FunctionDeclSDKType { + args: IdentDeclSDKType[]; + return_type?: DeclTypeSDKType; + receiver_function: boolean; +} +function createBaseDecl(): Decl { + return { + id: 0, + name: "", + doc: "", + ident: undefined, + function: undefined + }; +} +export const Decl = { + typeUrl: "/google.api.expr.v1beta1.Decl", + encode(message: Decl, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.id !== undefined) { + writer.uint32(8).int32(message.id); + } + if (message.name !== undefined) { + writer.uint32(18).string(message.name); + } + if (message.doc !== undefined) { + writer.uint32(26).string(message.doc); + } + if (message.ident !== undefined) { + IdentDecl.encode(message.ident, writer.uint32(34).fork()).ldelim(); + } + if (message.function !== undefined) { + FunctionDecl.encode(message.function, writer.uint32(42).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Decl { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDecl(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.id = reader.int32(); + break; + case 2: + message.name = reader.string(); + break; + case 3: + message.doc = reader.string(); + break; + case 4: + message.ident = IdentDecl.decode(reader, reader.uint32()); + break; + case 5: + message.function = FunctionDecl.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Decl { + const obj = createBaseDecl(); + if (isSet(object.id)) obj.id = Number(object.id); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.doc)) obj.doc = String(object.doc); + if (isSet(object.ident)) obj.ident = IdentDecl.fromJSON(object.ident); + if (isSet(object.function)) obj.function = FunctionDecl.fromJSON(object.function); + return obj; + }, + toJSON(message: Decl): JsonSafe { + const obj: any = {}; + message.id !== undefined && (obj.id = Math.round(message.id)); + message.name !== undefined && (obj.name = message.name); + message.doc !== undefined && (obj.doc = message.doc); + message.ident !== undefined && (obj.ident = message.ident ? IdentDecl.toJSON(message.ident) : undefined); + message.function !== undefined && (obj.function = message.function ? FunctionDecl.toJSON(message.function) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): Decl { + const message = createBaseDecl(); + message.id = object.id ?? 0; + message.name = object.name ?? ""; + message.doc = object.doc ?? ""; + if (object.ident !== undefined && object.ident !== null) { + message.ident = IdentDecl.fromPartial(object.ident); + } + if (object.function !== undefined && object.function !== null) { + message.function = FunctionDecl.fromPartial(object.function); + } + return message; + }, + fromSDK(object: DeclSDKType): Decl { + return { + id: object?.id, + name: object?.name, + doc: object?.doc, + ident: object.ident ? IdentDecl.fromSDK(object.ident) : undefined, + function: object.function ? FunctionDecl.fromSDK(object.function) : undefined + }; + }, + fromSDKJSON(object: any): DeclSDKType { + return { + id: isSet(object.id) ? Number(object.id) : 0, + name: isSet(object.name) ? String(object.name) : "", + doc: isSet(object.doc) ? String(object.doc) : "", + ident: isSet(object.ident) ? IdentDecl.fromSDKJSON(object.ident) : undefined, + function: isSet(object.function) ? FunctionDecl.fromSDKJSON(object.function) : undefined + }; + }, + toSDK(message: Decl): DeclSDKType { + const obj: any = {}; + obj.id = message.id; + obj.name = message.name; + obj.doc = message.doc; + message.ident !== undefined && (obj.ident = message.ident ? IdentDecl.toSDK(message.ident) : undefined); + message.function !== undefined && (obj.function = message.function ? FunctionDecl.toSDK(message.function) : undefined); + return obj; + }, + fromAmino(object: DeclAmino): Decl { + const message = createBaseDecl(); + if (object.id !== undefined && object.id !== null) { + message.id = object.id; + } + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + if (object.doc !== undefined && object.doc !== null) { + message.doc = object.doc; + } + if (object.ident !== undefined && object.ident !== null) { + message.ident = IdentDecl.fromAmino(object.ident); + } + if (object.function !== undefined && object.function !== null) { + message.function = FunctionDecl.fromAmino(object.function); + } + return message; + }, + toAmino(message: Decl): DeclAmino { + const obj: any = {}; + obj.id = message.id === 0 ? undefined : message.id; + obj.name = message.name === "" ? undefined : message.name; + obj.doc = message.doc === "" ? undefined : message.doc; + obj.ident = message.ident ? IdentDecl.toAmino(message.ident) : undefined; + obj.function = message.function ? FunctionDecl.toAmino(message.function) : undefined; + return obj; + }, + fromAminoMsg(object: DeclAminoMsg): Decl { + return Decl.fromAmino(object.value); + }, + fromProtoMsg(message: DeclProtoMsg): Decl { + return Decl.decode(message.value); + }, + toProto(message: Decl): Uint8Array { + return Decl.encode(message).finish(); + }, + toProtoMsg(message: Decl): DeclProtoMsg { + return { + typeUrl: "/google.api.expr.v1beta1.Decl", + value: Decl.encode(message).finish() + }; + } +}; +function createBaseDeclType(): DeclType { + return { + id: 0, + type: "", + typeParams: [] + }; +} +export const DeclType = { + typeUrl: "/google.api.expr.v1beta1.DeclType", + encode(message: DeclType, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.id !== undefined) { + writer.uint32(8).int32(message.id); + } + if (message.type !== undefined) { + writer.uint32(18).string(message.type); + } + for (const v of message.typeParams) { + DeclType.encode(v!, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): DeclType { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDeclType(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.id = reader.int32(); + break; + case 2: + message.type = reader.string(); + break; + case 4: + message.typeParams.push(DeclType.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): DeclType { + const obj = createBaseDeclType(); + if (isSet(object.id)) obj.id = Number(object.id); + if (isSet(object.type)) obj.type = String(object.type); + if (Array.isArray(object?.typeParams)) obj.typeParams = object.typeParams.map((e: any) => DeclType.fromJSON(e)); + return obj; + }, + toJSON(message: DeclType): JsonSafe { + const obj: any = {}; + message.id !== undefined && (obj.id = Math.round(message.id)); + message.type !== undefined && (obj.type = message.type); + if (message.typeParams) { + obj.typeParams = message.typeParams.map(e => e ? DeclType.toJSON(e) : undefined); + } else { + obj.typeParams = []; + } + return obj; + }, + fromPartial(object: DeepPartial): DeclType { + const message = createBaseDeclType(); + message.id = object.id ?? 0; + message.type = object.type ?? ""; + message.typeParams = object.typeParams?.map(e => DeclType.fromPartial(e)) || []; + return message; + }, + fromSDK(object: DeclTypeSDKType): DeclType { + return { + id: object?.id, + type: object?.type, + typeParams: Array.isArray(object?.type_params) ? object.type_params.map((e: any) => DeclType.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): DeclTypeSDKType { + return { + id: isSet(object.id) ? Number(object.id) : 0, + type: isSet(object.type) ? String(object.type) : "", + type_params: Array.isArray(object?.type_params) ? object.type_params.map((e: any) => DeclType.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: DeclType): DeclTypeSDKType { + const obj: any = {}; + obj.id = message.id; + obj.type = message.type; + if (message.typeParams) { + obj.type_params = message.typeParams.map(e => e ? DeclType.toSDK(e) : undefined); + } else { + obj.type_params = []; + } + return obj; + }, + fromAmino(object: DeclTypeAmino): DeclType { + const message = createBaseDeclType(); + if (object.id !== undefined && object.id !== null) { + message.id = object.id; + } + if (object.type !== undefined && object.type !== null) { + message.type = object.type; + } + message.typeParams = object.type_params?.map(e => DeclType.fromAmino(e)) || []; + return message; + }, + toAmino(message: DeclType): DeclTypeAmino { + const obj: any = {}; + obj.id = message.id === 0 ? undefined : message.id; + obj.type = message.type === "" ? undefined : message.type; + if (message.typeParams) { + obj.type_params = message.typeParams.map(e => e ? DeclType.toAmino(e) : undefined); + } else { + obj.type_params = message.typeParams; + } + return obj; + }, + fromAminoMsg(object: DeclTypeAminoMsg): DeclType { + return DeclType.fromAmino(object.value); + }, + fromProtoMsg(message: DeclTypeProtoMsg): DeclType { + return DeclType.decode(message.value); + }, + toProto(message: DeclType): Uint8Array { + return DeclType.encode(message).finish(); + }, + toProtoMsg(message: DeclType): DeclTypeProtoMsg { + return { + typeUrl: "/google.api.expr.v1beta1.DeclType", + value: DeclType.encode(message).finish() + }; + } +}; +function createBaseIdentDecl(): IdentDecl { + return { + type: undefined, + value: undefined + }; +} +export const IdentDecl = { + typeUrl: "/google.api.expr.v1beta1.IdentDecl", + encode(message: IdentDecl, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.type !== undefined) { + DeclType.encode(message.type, writer.uint32(26).fork()).ldelim(); + } + if (message.value !== undefined) { + Expr.encode(message.value, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): IdentDecl { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseIdentDecl(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 3: + message.type = DeclType.decode(reader, reader.uint32()); + break; + case 4: + message.value = Expr.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): IdentDecl { + const obj = createBaseIdentDecl(); + if (isSet(object.type)) obj.type = DeclType.fromJSON(object.type); + if (isSet(object.value)) obj.value = Expr.fromJSON(object.value); + return obj; + }, + toJSON(message: IdentDecl): JsonSafe { + const obj: any = {}; + message.type !== undefined && (obj.type = message.type ? DeclType.toJSON(message.type) : undefined); + message.value !== undefined && (obj.value = message.value ? Expr.toJSON(message.value) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): IdentDecl { + const message = createBaseIdentDecl(); + if (object.type !== undefined && object.type !== null) { + message.type = DeclType.fromPartial(object.type); + } + if (object.value !== undefined && object.value !== null) { + message.value = Expr.fromPartial(object.value); + } + return message; + }, + fromSDK(object: IdentDeclSDKType): IdentDecl { + return { + type: object.type ? DeclType.fromSDK(object.type) : undefined, + value: object.value ? Expr.fromSDK(object.value) : undefined + }; + }, + fromSDKJSON(object: any): IdentDeclSDKType { + return { + type: isSet(object.type) ? DeclType.fromSDKJSON(object.type) : undefined, + value: isSet(object.value) ? Expr.fromSDKJSON(object.value) : undefined + }; + }, + toSDK(message: IdentDecl): IdentDeclSDKType { + const obj: any = {}; + message.type !== undefined && (obj.type = message.type ? DeclType.toSDK(message.type) : undefined); + message.value !== undefined && (obj.value = message.value ? Expr.toSDK(message.value) : undefined); + return obj; + }, + fromAmino(object: IdentDeclAmino): IdentDecl { + const message = createBaseIdentDecl(); + if (object.type !== undefined && object.type !== null) { + message.type = DeclType.fromAmino(object.type); + } + if (object.value !== undefined && object.value !== null) { + message.value = Expr.fromAmino(object.value); + } + return message; + }, + toAmino(message: IdentDecl): IdentDeclAmino { + const obj: any = {}; + obj.type = message.type ? DeclType.toAmino(message.type) : undefined; + obj.value = message.value ? Expr.toAmino(message.value) : undefined; + return obj; + }, + fromAminoMsg(object: IdentDeclAminoMsg): IdentDecl { + return IdentDecl.fromAmino(object.value); + }, + fromProtoMsg(message: IdentDeclProtoMsg): IdentDecl { + return IdentDecl.decode(message.value); + }, + toProto(message: IdentDecl): Uint8Array { + return IdentDecl.encode(message).finish(); + }, + toProtoMsg(message: IdentDecl): IdentDeclProtoMsg { + return { + typeUrl: "/google.api.expr.v1beta1.IdentDecl", + value: IdentDecl.encode(message).finish() + }; + } +}; +function createBaseFunctionDecl(): FunctionDecl { + return { + args: [], + returnType: undefined, + receiverFunction: false + }; +} +export const FunctionDecl = { + typeUrl: "/google.api.expr.v1beta1.FunctionDecl", + encode(message: FunctionDecl, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.args) { + IdentDecl.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.returnType !== undefined) { + DeclType.encode(message.returnType, writer.uint32(18).fork()).ldelim(); + } + if (message.receiverFunction !== undefined) { + writer.uint32(24).bool(message.receiverFunction); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): FunctionDecl { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseFunctionDecl(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.args.push(IdentDecl.decode(reader, reader.uint32())); + break; + case 2: + message.returnType = DeclType.decode(reader, reader.uint32()); + break; + case 3: + message.receiverFunction = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): FunctionDecl { + const obj = createBaseFunctionDecl(); + if (Array.isArray(object?.args)) obj.args = object.args.map((e: any) => IdentDecl.fromJSON(e)); + if (isSet(object.returnType)) obj.returnType = DeclType.fromJSON(object.returnType); + if (isSet(object.receiverFunction)) obj.receiverFunction = Boolean(object.receiverFunction); + return obj; + }, + toJSON(message: FunctionDecl): JsonSafe { + const obj: any = {}; + if (message.args) { + obj.args = message.args.map(e => e ? IdentDecl.toJSON(e) : undefined); + } else { + obj.args = []; + } + message.returnType !== undefined && (obj.returnType = message.returnType ? DeclType.toJSON(message.returnType) : undefined); + message.receiverFunction !== undefined && (obj.receiverFunction = message.receiverFunction); + return obj; + }, + fromPartial(object: DeepPartial): FunctionDecl { + const message = createBaseFunctionDecl(); + message.args = object.args?.map(e => IdentDecl.fromPartial(e)) || []; + if (object.returnType !== undefined && object.returnType !== null) { + message.returnType = DeclType.fromPartial(object.returnType); + } + message.receiverFunction = object.receiverFunction ?? false; + return message; + }, + fromSDK(object: FunctionDeclSDKType): FunctionDecl { + return { + args: Array.isArray(object?.args) ? object.args.map((e: any) => IdentDecl.fromSDK(e)) : [], + returnType: object.return_type ? DeclType.fromSDK(object.return_type) : undefined, + receiverFunction: object?.receiver_function + }; + }, + fromSDKJSON(object: any): FunctionDeclSDKType { + return { + args: Array.isArray(object?.args) ? object.args.map((e: any) => IdentDecl.fromSDKJSON(e)) : [], + return_type: isSet(object.return_type) ? DeclType.fromSDKJSON(object.return_type) : undefined, + receiver_function: isSet(object.receiver_function) ? Boolean(object.receiver_function) : false + }; + }, + toSDK(message: FunctionDecl): FunctionDeclSDKType { + const obj: any = {}; + if (message.args) { + obj.args = message.args.map(e => e ? IdentDecl.toSDK(e) : undefined); + } else { + obj.args = []; + } + message.returnType !== undefined && (obj.return_type = message.returnType ? DeclType.toSDK(message.returnType) : undefined); + obj.receiver_function = message.receiverFunction; + return obj; + }, + fromAmino(object: FunctionDeclAmino): FunctionDecl { + const message = createBaseFunctionDecl(); + message.args = object.args?.map(e => IdentDecl.fromAmino(e)) || []; + if (object.return_type !== undefined && object.return_type !== null) { + message.returnType = DeclType.fromAmino(object.return_type); + } + if (object.receiver_function !== undefined && object.receiver_function !== null) { + message.receiverFunction = object.receiver_function; + } + return message; + }, + toAmino(message: FunctionDecl): FunctionDeclAmino { + const obj: any = {}; + if (message.args) { + obj.args = message.args.map(e => e ? IdentDecl.toAmino(e) : undefined); + } else { + obj.args = message.args; + } + obj.return_type = message.returnType ? DeclType.toAmino(message.returnType) : undefined; + obj.receiver_function = message.receiverFunction === false ? undefined : message.receiverFunction; + return obj; + }, + fromAminoMsg(object: FunctionDeclAminoMsg): FunctionDecl { + return FunctionDecl.fromAmino(object.value); + }, + fromProtoMsg(message: FunctionDeclProtoMsg): FunctionDecl { + return FunctionDecl.decode(message.value); + }, + toProto(message: FunctionDecl): Uint8Array { + return FunctionDecl.encode(message).finish(); + }, + toProtoMsg(message: FunctionDecl): FunctionDeclProtoMsg { + return { + typeUrl: "/google.api.expr.v1beta1.FunctionDecl", + value: FunctionDecl.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/api/expr/v1beta1/eval.ts b/__fixtures__/v-next/outputicjsdeps/google/api/expr/v1beta1/eval.ts new file mode 100644 index 0000000000..f3d7fa3abf --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/api/expr/v1beta1/eval.ts @@ -0,0 +1,811 @@ +import { Value, ValueSDKType } from "./value.js"; +import { Status, StatusSDKType } from "../../../rpc/status.js"; +import { BinaryReader, BinaryWriter } from "../../../../binary.js"; +import { JsonSafe } from "../../../../json-safe.js"; +import { DeepPartial, isSet } from "../../../../helpers.js"; +export const protobufPackage = "google.api.expr.v1beta1"; +/** + * The state of an evaluation. + * + * Can represent an initial, partial, or completed state of evaluation. + */ +export interface EvalState { + /** The unique values referenced in this message. */ + values: ExprValue[]; + /** + * An ordered list of results. + * + * Tracks the flow of evaluation through the expression. + * May be sparse. + */ + results: EvalState_Result[]; +} +export interface EvalStateProtoMsg { + typeUrl: "/google.api.expr.v1beta1.EvalState"; + value: Uint8Array; +} +/** + * The state of an evaluation. + * + * Can represent an initial, partial, or completed state of evaluation. + */ +export interface EvalStateSDKType { + values: ExprValueSDKType[]; + results: EvalState_ResultSDKType[]; +} +/** A single evaluation result. */ +export interface EvalState_Result { + /** The expression this result is for. */ + expr?: IdRef; + /** The index in `values` of the resulting value. */ + value: number; +} +export interface EvalState_ResultProtoMsg { + typeUrl: "/google.api.expr.v1beta1.Result"; + value: Uint8Array; +} +/** A single evaluation result. */ +export interface EvalState_ResultSDKType { + expr?: IdRefSDKType; + value: number; +} +/** The value of an evaluated expression. */ +export interface ExprValue { + /** A concrete value. */ + value?: Value; + /** + * The set of errors in the critical path of evalution. + * + * Only errors in the critical path are included. For example, + * `( || true) && ` will only result in ``, + * while ` || ` will result in both `` and + * ``. + * + * Errors cause by the presence of other errors are not included in the + * set. For example `.foo`, `foo()`, and ` + 1` will + * only result in ``. + * + * Multiple errors *might* be included when evaluation could result + * in different errors. For example ` + ` and + * `foo(, )` may result in ``, `` or both. + * The exact subset of errors included for this case is unspecified and + * depends on the implementation details of the evaluator. + */ + error?: ErrorSet; + /** + * The set of unknowns in the critical path of evaluation. + * + * Unknown behaves identically to Error with regards to propagation. + * Specifically, only unknowns in the critical path are included, unknowns + * caused by the presence of other unknowns are not included, and multiple + * unknowns *might* be included included when evaluation could result in + * different unknowns. For example: + * + * ( || true) && -> + * || -> + * .foo -> + * foo() -> + * + -> or + * + * Unknown takes precidence over Error in cases where a `Value` can short + * circuit the result: + * + * || -> + * && -> + * + * Errors take precidence in all other cases: + * + * + -> + * foo(, ) -> + */ + unknown?: UnknownSet; +} +export interface ExprValueProtoMsg { + typeUrl: "/google.api.expr.v1beta1.ExprValue"; + value: Uint8Array; +} +/** The value of an evaluated expression. */ +export interface ExprValueSDKType { + value?: ValueSDKType; + error?: ErrorSetSDKType; + unknown?: UnknownSetSDKType; +} +/** + * A set of errors. + * + * The errors included depend on the context. See `ExprValue.error`. + */ +export interface ErrorSet { + /** The errors in the set. */ + errors: Status[]; +} +export interface ErrorSetProtoMsg { + typeUrl: "/google.api.expr.v1beta1.ErrorSet"; + value: Uint8Array; +} +/** + * A set of errors. + * + * The errors included depend on the context. See `ExprValue.error`. + */ +export interface ErrorSetSDKType { + errors: StatusSDKType[]; +} +/** + * A set of expressions for which the value is unknown. + * + * The unknowns included depend on the context. See `ExprValue.unknown`. + */ +export interface UnknownSet { + /** The ids of the expressions with unknown values. */ + exprs: IdRef[]; +} +export interface UnknownSetProtoMsg { + typeUrl: "/google.api.expr.v1beta1.UnknownSet"; + value: Uint8Array; +} +/** + * A set of expressions for which the value is unknown. + * + * The unknowns included depend on the context. See `ExprValue.unknown`. + */ +export interface UnknownSetSDKType { + exprs: IdRefSDKType[]; +} +/** A reference to an expression id. */ +export interface IdRef { + /** The expression id. */ + id: number; +} +export interface IdRefProtoMsg { + typeUrl: "/google.api.expr.v1beta1.IdRef"; + value: Uint8Array; +} +/** A reference to an expression id. */ +export interface IdRefSDKType { + id: number; +} +function createBaseEvalState(): EvalState { + return { + values: [], + results: [] + }; +} +export const EvalState = { + typeUrl: "/google.api.expr.v1beta1.EvalState", + encode(message: EvalState, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.values) { + ExprValue.encode(v!, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.results) { + EvalState_Result.encode(v!, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): EvalState { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseEvalState(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.values.push(ExprValue.decode(reader, reader.uint32())); + break; + case 3: + message.results.push(EvalState_Result.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): EvalState { + const obj = createBaseEvalState(); + if (Array.isArray(object?.values)) obj.values = object.values.map((e: any) => ExprValue.fromJSON(e)); + if (Array.isArray(object?.results)) obj.results = object.results.map((e: any) => EvalState_Result.fromJSON(e)); + return obj; + }, + toJSON(message: EvalState): JsonSafe { + const obj: any = {}; + if (message.values) { + obj.values = message.values.map(e => e ? ExprValue.toJSON(e) : undefined); + } else { + obj.values = []; + } + if (message.results) { + obj.results = message.results.map(e => e ? EvalState_Result.toJSON(e) : undefined); + } else { + obj.results = []; + } + return obj; + }, + fromPartial(object: DeepPartial): EvalState { + const message = createBaseEvalState(); + message.values = object.values?.map(e => ExprValue.fromPartial(e)) || []; + message.results = object.results?.map(e => EvalState_Result.fromPartial(e)) || []; + return message; + }, + fromSDK(object: EvalStateSDKType): EvalState { + return { + values: Array.isArray(object?.values) ? object.values.map((e: any) => ExprValue.fromSDK(e)) : [], + results: Array.isArray(object?.results) ? object.results.map((e: any) => EvalState_Result.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): EvalStateSDKType { + return { + values: Array.isArray(object?.values) ? object.values.map((e: any) => ExprValue.fromSDKJSON(e)) : [], + results: Array.isArray(object?.results) ? object.results.map((e: any) => EvalState_Result.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: EvalState): EvalStateSDKType { + const obj: any = {}; + if (message.values) { + obj.values = message.values.map(e => e ? ExprValue.toSDK(e) : undefined); + } else { + obj.values = []; + } + if (message.results) { + obj.results = message.results.map(e => e ? EvalState_Result.toSDK(e) : undefined); + } else { + obj.results = []; + } + return obj; + }, + fromAmino(object: EvalStateAmino): EvalState { + const message = createBaseEvalState(); + message.values = object.values?.map(e => ExprValue.fromAmino(e)) || []; + message.results = object.results?.map(e => EvalState_Result.fromAmino(e)) || []; + return message; + }, + toAmino(message: EvalState): EvalStateAmino { + const obj: any = {}; + if (message.values) { + obj.values = message.values.map(e => e ? ExprValue.toAmino(e) : undefined); + } else { + obj.values = message.values; + } + if (message.results) { + obj.results = message.results.map(e => e ? EvalState_Result.toAmino(e) : undefined); + } else { + obj.results = message.results; + } + return obj; + }, + fromAminoMsg(object: EvalStateAminoMsg): EvalState { + return EvalState.fromAmino(object.value); + }, + fromProtoMsg(message: EvalStateProtoMsg): EvalState { + return EvalState.decode(message.value); + }, + toProto(message: EvalState): Uint8Array { + return EvalState.encode(message).finish(); + }, + toProtoMsg(message: EvalState): EvalStateProtoMsg { + return { + typeUrl: "/google.api.expr.v1beta1.EvalState", + value: EvalState.encode(message).finish() + }; + } +}; +function createBaseEvalState_Result(): EvalState_Result { + return { + expr: undefined, + value: 0 + }; +} +export const EvalState_Result = { + typeUrl: "/google.api.expr.v1beta1.Result", + encode(message: EvalState_Result, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.expr !== undefined) { + IdRef.encode(message.expr, writer.uint32(10).fork()).ldelim(); + } + if (message.value !== undefined) { + writer.uint32(16).int32(message.value); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): EvalState_Result { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseEvalState_Result(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.expr = IdRef.decode(reader, reader.uint32()); + break; + case 2: + message.value = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): EvalState_Result { + const obj = createBaseEvalState_Result(); + if (isSet(object.expr)) obj.expr = IdRef.fromJSON(object.expr); + if (isSet(object.value)) obj.value = Number(object.value); + return obj; + }, + toJSON(message: EvalState_Result): JsonSafe { + const obj: any = {}; + message.expr !== undefined && (obj.expr = message.expr ? IdRef.toJSON(message.expr) : undefined); + message.value !== undefined && (obj.value = Math.round(message.value)); + return obj; + }, + fromPartial(object: DeepPartial): EvalState_Result { + const message = createBaseEvalState_Result(); + if (object.expr !== undefined && object.expr !== null) { + message.expr = IdRef.fromPartial(object.expr); + } + message.value = object.value ?? 0; + return message; + }, + fromSDK(object: EvalState_ResultSDKType): EvalState_Result { + return { + expr: object.expr ? IdRef.fromSDK(object.expr) : undefined, + value: object?.value + }; + }, + fromSDKJSON(object: any): EvalState_ResultSDKType { + return { + expr: isSet(object.expr) ? IdRef.fromSDKJSON(object.expr) : undefined, + value: isSet(object.value) ? Number(object.value) : 0 + }; + }, + toSDK(message: EvalState_Result): EvalState_ResultSDKType { + const obj: any = {}; + message.expr !== undefined && (obj.expr = message.expr ? IdRef.toSDK(message.expr) : undefined); + obj.value = message.value; + return obj; + }, + fromAmino(object: EvalState_ResultAmino): EvalState_Result { + const message = createBaseEvalState_Result(); + if (object.expr !== undefined && object.expr !== null) { + message.expr = IdRef.fromAmino(object.expr); + } + if (object.value !== undefined && object.value !== null) { + message.value = object.value; + } + return message; + }, + toAmino(message: EvalState_Result): EvalState_ResultAmino { + const obj: any = {}; + obj.expr = message.expr ? IdRef.toAmino(message.expr) : undefined; + obj.value = message.value === 0 ? undefined : message.value; + return obj; + }, + fromAminoMsg(object: EvalState_ResultAminoMsg): EvalState_Result { + return EvalState_Result.fromAmino(object.value); + }, + fromProtoMsg(message: EvalState_ResultProtoMsg): EvalState_Result { + return EvalState_Result.decode(message.value); + }, + toProto(message: EvalState_Result): Uint8Array { + return EvalState_Result.encode(message).finish(); + }, + toProtoMsg(message: EvalState_Result): EvalState_ResultProtoMsg { + return { + typeUrl: "/google.api.expr.v1beta1.Result", + value: EvalState_Result.encode(message).finish() + }; + } +}; +function createBaseExprValue(): ExprValue { + return { + value: undefined, + error: undefined, + unknown: undefined + }; +} +export const ExprValue = { + typeUrl: "/google.api.expr.v1beta1.ExprValue", + encode(message: ExprValue, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.value !== undefined) { + Value.encode(message.value, writer.uint32(10).fork()).ldelim(); + } + if (message.error !== undefined) { + ErrorSet.encode(message.error, writer.uint32(18).fork()).ldelim(); + } + if (message.unknown !== undefined) { + UnknownSet.encode(message.unknown, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ExprValue { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseExprValue(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.value = Value.decode(reader, reader.uint32()); + break; + case 2: + message.error = ErrorSet.decode(reader, reader.uint32()); + break; + case 3: + message.unknown = UnknownSet.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ExprValue { + const obj = createBaseExprValue(); + if (isSet(object.value)) obj.value = Value.fromJSON(object.value); + if (isSet(object.error)) obj.error = ErrorSet.fromJSON(object.error); + if (isSet(object.unknown)) obj.unknown = UnknownSet.fromJSON(object.unknown); + return obj; + }, + toJSON(message: ExprValue): JsonSafe { + const obj: any = {}; + message.value !== undefined && (obj.value = message.value ? Value.toJSON(message.value) : undefined); + message.error !== undefined && (obj.error = message.error ? ErrorSet.toJSON(message.error) : undefined); + message.unknown !== undefined && (obj.unknown = message.unknown ? UnknownSet.toJSON(message.unknown) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): ExprValue { + const message = createBaseExprValue(); + if (object.value !== undefined && object.value !== null) { + message.value = Value.fromPartial(object.value); + } + if (object.error !== undefined && object.error !== null) { + message.error = ErrorSet.fromPartial(object.error); + } + if (object.unknown !== undefined && object.unknown !== null) { + message.unknown = UnknownSet.fromPartial(object.unknown); + } + return message; + }, + fromSDK(object: ExprValueSDKType): ExprValue { + return { + value: object.value ? Value.fromSDK(object.value) : undefined, + error: object.error ? ErrorSet.fromSDK(object.error) : undefined, + unknown: object.unknown ? UnknownSet.fromSDK(object.unknown) : undefined + }; + }, + fromSDKJSON(object: any): ExprValueSDKType { + return { + value: isSet(object.value) ? Value.fromSDKJSON(object.value) : undefined, + error: isSet(object.error) ? ErrorSet.fromSDKJSON(object.error) : undefined, + unknown: isSet(object.unknown) ? UnknownSet.fromSDKJSON(object.unknown) : undefined + }; + }, + toSDK(message: ExprValue): ExprValueSDKType { + const obj: any = {}; + message.value !== undefined && (obj.value = message.value ? Value.toSDK(message.value) : undefined); + message.error !== undefined && (obj.error = message.error ? ErrorSet.toSDK(message.error) : undefined); + message.unknown !== undefined && (obj.unknown = message.unknown ? UnknownSet.toSDK(message.unknown) : undefined); + return obj; + }, + fromAmino(object: ExprValueAmino): ExprValue { + const message = createBaseExprValue(); + if (object.value !== undefined && object.value !== null) { + message.value = Value.fromAmino(object.value); + } + if (object.error !== undefined && object.error !== null) { + message.error = ErrorSet.fromAmino(object.error); + } + if (object.unknown !== undefined && object.unknown !== null) { + message.unknown = UnknownSet.fromAmino(object.unknown); + } + return message; + }, + toAmino(message: ExprValue): ExprValueAmino { + const obj: any = {}; + obj.value = message.value ? Value.toAmino(message.value) : undefined; + obj.error = message.error ? ErrorSet.toAmino(message.error) : undefined; + obj.unknown = message.unknown ? UnknownSet.toAmino(message.unknown) : undefined; + return obj; + }, + fromAminoMsg(object: ExprValueAminoMsg): ExprValue { + return ExprValue.fromAmino(object.value); + }, + fromProtoMsg(message: ExprValueProtoMsg): ExprValue { + return ExprValue.decode(message.value); + }, + toProto(message: ExprValue): Uint8Array { + return ExprValue.encode(message).finish(); + }, + toProtoMsg(message: ExprValue): ExprValueProtoMsg { + return { + typeUrl: "/google.api.expr.v1beta1.ExprValue", + value: ExprValue.encode(message).finish() + }; + } +}; +function createBaseErrorSet(): ErrorSet { + return { + errors: [] + }; +} +export const ErrorSet = { + typeUrl: "/google.api.expr.v1beta1.ErrorSet", + encode(message: ErrorSet, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.errors) { + Status.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ErrorSet { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseErrorSet(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.errors.push(Status.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ErrorSet { + const obj = createBaseErrorSet(); + if (Array.isArray(object?.errors)) obj.errors = object.errors.map((e: any) => Status.fromJSON(e)); + return obj; + }, + toJSON(message: ErrorSet): JsonSafe { + const obj: any = {}; + if (message.errors) { + obj.errors = message.errors.map(e => e ? Status.toJSON(e) : undefined); + } else { + obj.errors = []; + } + return obj; + }, + fromPartial(object: DeepPartial): ErrorSet { + const message = createBaseErrorSet(); + message.errors = object.errors?.map(e => Status.fromPartial(e)) || []; + return message; + }, + fromSDK(object: ErrorSetSDKType): ErrorSet { + return { + errors: Array.isArray(object?.errors) ? object.errors.map((e: any) => Status.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): ErrorSetSDKType { + return { + errors: Array.isArray(object?.errors) ? object.errors.map((e: any) => Status.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: ErrorSet): ErrorSetSDKType { + const obj: any = {}; + if (message.errors) { + obj.errors = message.errors.map(e => e ? Status.toSDK(e) : undefined); + } else { + obj.errors = []; + } + return obj; + }, + fromAmino(object: ErrorSetAmino): ErrorSet { + const message = createBaseErrorSet(); + message.errors = object.errors?.map(e => Status.fromAmino(e)) || []; + return message; + }, + toAmino(message: ErrorSet): ErrorSetAmino { + const obj: any = {}; + if (message.errors) { + obj.errors = message.errors.map(e => e ? Status.toAmino(e) : undefined); + } else { + obj.errors = message.errors; + } + return obj; + }, + fromAminoMsg(object: ErrorSetAminoMsg): ErrorSet { + return ErrorSet.fromAmino(object.value); + }, + fromProtoMsg(message: ErrorSetProtoMsg): ErrorSet { + return ErrorSet.decode(message.value); + }, + toProto(message: ErrorSet): Uint8Array { + return ErrorSet.encode(message).finish(); + }, + toProtoMsg(message: ErrorSet): ErrorSetProtoMsg { + return { + typeUrl: "/google.api.expr.v1beta1.ErrorSet", + value: ErrorSet.encode(message).finish() + }; + } +}; +function createBaseUnknownSet(): UnknownSet { + return { + exprs: [] + }; +} +export const UnknownSet = { + typeUrl: "/google.api.expr.v1beta1.UnknownSet", + encode(message: UnknownSet, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.exprs) { + IdRef.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): UnknownSet { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseUnknownSet(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.exprs.push(IdRef.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): UnknownSet { + const obj = createBaseUnknownSet(); + if (Array.isArray(object?.exprs)) obj.exprs = object.exprs.map((e: any) => IdRef.fromJSON(e)); + return obj; + }, + toJSON(message: UnknownSet): JsonSafe { + const obj: any = {}; + if (message.exprs) { + obj.exprs = message.exprs.map(e => e ? IdRef.toJSON(e) : undefined); + } else { + obj.exprs = []; + } + return obj; + }, + fromPartial(object: DeepPartial): UnknownSet { + const message = createBaseUnknownSet(); + message.exprs = object.exprs?.map(e => IdRef.fromPartial(e)) || []; + return message; + }, + fromSDK(object: UnknownSetSDKType): UnknownSet { + return { + exprs: Array.isArray(object?.exprs) ? object.exprs.map((e: any) => IdRef.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): UnknownSetSDKType { + return { + exprs: Array.isArray(object?.exprs) ? object.exprs.map((e: any) => IdRef.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: UnknownSet): UnknownSetSDKType { + const obj: any = {}; + if (message.exprs) { + obj.exprs = message.exprs.map(e => e ? IdRef.toSDK(e) : undefined); + } else { + obj.exprs = []; + } + return obj; + }, + fromAmino(object: UnknownSetAmino): UnknownSet { + const message = createBaseUnknownSet(); + message.exprs = object.exprs?.map(e => IdRef.fromAmino(e)) || []; + return message; + }, + toAmino(message: UnknownSet): UnknownSetAmino { + const obj: any = {}; + if (message.exprs) { + obj.exprs = message.exprs.map(e => e ? IdRef.toAmino(e) : undefined); + } else { + obj.exprs = message.exprs; + } + return obj; + }, + fromAminoMsg(object: UnknownSetAminoMsg): UnknownSet { + return UnknownSet.fromAmino(object.value); + }, + fromProtoMsg(message: UnknownSetProtoMsg): UnknownSet { + return UnknownSet.decode(message.value); + }, + toProto(message: UnknownSet): Uint8Array { + return UnknownSet.encode(message).finish(); + }, + toProtoMsg(message: UnknownSet): UnknownSetProtoMsg { + return { + typeUrl: "/google.api.expr.v1beta1.UnknownSet", + value: UnknownSet.encode(message).finish() + }; + } +}; +function createBaseIdRef(): IdRef { + return { + id: 0 + }; +} +export const IdRef = { + typeUrl: "/google.api.expr.v1beta1.IdRef", + encode(message: IdRef, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.id !== undefined) { + writer.uint32(8).int32(message.id); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): IdRef { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseIdRef(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.id = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): IdRef { + const obj = createBaseIdRef(); + if (isSet(object.id)) obj.id = Number(object.id); + return obj; + }, + toJSON(message: IdRef): JsonSafe { + const obj: any = {}; + message.id !== undefined && (obj.id = Math.round(message.id)); + return obj; + }, + fromPartial(object: DeepPartial): IdRef { + const message = createBaseIdRef(); + message.id = object.id ?? 0; + return message; + }, + fromSDK(object: IdRefSDKType): IdRef { + return { + id: object?.id + }; + }, + fromSDKJSON(object: any): IdRefSDKType { + return { + id: isSet(object.id) ? Number(object.id) : 0 + }; + }, + toSDK(message: IdRef): IdRefSDKType { + const obj: any = {}; + obj.id = message.id; + return obj; + }, + fromAmino(object: IdRefAmino): IdRef { + const message = createBaseIdRef(); + if (object.id !== undefined && object.id !== null) { + message.id = object.id; + } + return message; + }, + toAmino(message: IdRef): IdRefAmino { + const obj: any = {}; + obj.id = message.id === 0 ? undefined : message.id; + return obj; + }, + fromAminoMsg(object: IdRefAminoMsg): IdRef { + return IdRef.fromAmino(object.value); + }, + fromProtoMsg(message: IdRefProtoMsg): IdRef { + return IdRef.decode(message.value); + }, + toProto(message: IdRef): Uint8Array { + return IdRef.encode(message).finish(); + }, + toProtoMsg(message: IdRef): IdRefProtoMsg { + return { + typeUrl: "/google.api.expr.v1beta1.IdRef", + value: IdRef.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/api/expr/v1beta1/expr.ts b/__fixtures__/v-next/outputicjsdeps/google/api/expr/v1beta1/expr.ts new file mode 100644 index 0000000000..387732b235 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/api/expr/v1beta1/expr.ts @@ -0,0 +1,1856 @@ +import { SourceInfo, SourceInfoSDKType } from "./source.js"; +import { NullValue, NullValueSDKType, nullValueFromJSON, nullValueToJSON } from "../../../protobuf/struct.js"; +import { BinaryReader, BinaryWriter } from "../../../../binary.js"; +import { isSet, DeepPartial, bytesFromBase64, base64FromBytes } from "../../../../helpers.js"; +import { JsonSafe } from "../../../../json-safe.js"; +export const protobufPackage = "google.api.expr.v1beta1"; +/** An expression together with source information as returned by the parser. */ +export interface ParsedExpr { + /** The parsed expression. */ + expr?: Expr; + /** The source info derived from input that generated the parsed `expr`. */ + sourceInfo?: SourceInfo; + /** The syntax version of the source, e.g. `cel1`. */ + syntaxVersion: string; +} +export interface ParsedExprProtoMsg { + typeUrl: "/google.api.expr.v1beta1.ParsedExpr"; + value: Uint8Array; +} +/** An expression together with source information as returned by the parser. */ +export interface ParsedExprSDKType { + expr?: ExprSDKType; + source_info?: SourceInfoSDKType; + syntax_version: string; +} +/** + * An abstract representation of a common expression. + * + * Expressions are abstractly represented as a collection of identifiers, + * select statements, function calls, literals, and comprehensions. All + * operators with the exception of the '.' operator are modelled as function + * calls. This makes it easy to represent new operators into the existing AST. + * + * All references within expressions must resolve to a [Decl][google.api.expr.v1beta1.Decl] provided at + * type-check for an expression to be valid. A reference may either be a bare + * identifier `name` or a qualified identifier `google.api.name`. References + * may either refer to a value or a function declaration. + * + * For example, the expression `google.api.name.startsWith('expr')` references + * the declaration `google.api.name` within a [Expr.Select][google.api.expr.v1beta1.Expr.Select] expression, and + * the function declaration `startsWith`. + */ +export interface Expr { + /** + * Required. An id assigned to this node by the parser which is unique in a + * given expression tree. This is used to associate type information and other + * attributes to a node in the parse tree. + */ + id: number; + /** A literal expression. */ + literalExpr?: Literal; + /** An identifier expression. */ + identExpr?: Expr_Ident; + /** A field selection expression, e.g. `request.auth`. */ + selectExpr?: Expr_Select; + /** A call expression, including calls to predefined functions and operators. */ + callExpr?: Expr_Call; + /** A list creation expression. */ + listExpr?: Expr_CreateList; + /** A map or object creation expression. */ + structExpr?: Expr_CreateStruct; + /** A comprehension expression. */ + comprehensionExpr?: Expr_Comprehension; +} +export interface ExprProtoMsg { + typeUrl: "/google.api.expr.v1beta1.Expr"; + value: Uint8Array; +} +/** + * An abstract representation of a common expression. + * + * Expressions are abstractly represented as a collection of identifiers, + * select statements, function calls, literals, and comprehensions. All + * operators with the exception of the '.' operator are modelled as function + * calls. This makes it easy to represent new operators into the existing AST. + * + * All references within expressions must resolve to a [Decl][google.api.expr.v1beta1.Decl] provided at + * type-check for an expression to be valid. A reference may either be a bare + * identifier `name` or a qualified identifier `google.api.name`. References + * may either refer to a value or a function declaration. + * + * For example, the expression `google.api.name.startsWith('expr')` references + * the declaration `google.api.name` within a [Expr.Select][google.api.expr.v1beta1.Expr.Select] expression, and + * the function declaration `startsWith`. + */ +export interface ExprSDKType { + id: number; + literal_expr?: LiteralSDKType; + ident_expr?: Expr_IdentSDKType; + select_expr?: Expr_SelectSDKType; + call_expr?: Expr_CallSDKType; + list_expr?: Expr_CreateListSDKType; + struct_expr?: Expr_CreateStructSDKType; + comprehension_expr?: Expr_ComprehensionSDKType; +} +/** An identifier expression. e.g. `request`. */ +export interface Expr_Ident { + /** + * Required. Holds a single, unqualified identifier, possibly preceded by a + * '.'. + * + * Qualified names are represented by the [Expr.Select][google.api.expr.v1beta1.Expr.Select] expression. + */ + name: string; +} +export interface Expr_IdentProtoMsg { + typeUrl: "/google.api.expr.v1beta1.Ident"; + value: Uint8Array; +} +/** An identifier expression. e.g. `request`. */ +export interface Expr_IdentSDKType { + name: string; +} +/** A field selection expression. e.g. `request.auth`. */ +export interface Expr_Select { + /** + * Required. The target of the selection expression. + * + * For example, in the select expression `request.auth`, the `request` + * portion of the expression is the `operand`. + */ + operand?: Expr; + /** + * Required. The name of the field to select. + * + * For example, in the select expression `request.auth`, the `auth` portion + * of the expression would be the `field`. + */ + field: string; + /** + * Whether the select is to be interpreted as a field presence test. + * + * This results from the macro `has(request.auth)`. + */ + testOnly: boolean; +} +export interface Expr_SelectProtoMsg { + typeUrl: "/google.api.expr.v1beta1.Select"; + value: Uint8Array; +} +/** A field selection expression. e.g. `request.auth`. */ +export interface Expr_SelectSDKType { + operand?: ExprSDKType; + field: string; + test_only: boolean; +} +/** + * A call expression, including calls to predefined functions and operators. + * + * For example, `value == 10`, `size(map_value)`. + */ +export interface Expr_Call { + /** + * The target of an method call-style expression. For example, `x` in + * `x.f()`. + */ + target?: Expr; + /** Required. The name of the function or method being called. */ + function: string; + /** The arguments. */ + args: Expr[]; +} +export interface Expr_CallProtoMsg { + typeUrl: "/google.api.expr.v1beta1.Call"; + value: Uint8Array; +} +/** + * A call expression, including calls to predefined functions and operators. + * + * For example, `value == 10`, `size(map_value)`. + */ +export interface Expr_CallSDKType { + target?: ExprSDKType; + function: string; + args: ExprSDKType[]; +} +/** + * A list creation expression. + * + * Lists may either be homogenous, e.g. `[1, 2, 3]`, or heterogenous, e.g. + * `dyn([1, 'hello', 2.0])` + */ +export interface Expr_CreateList { + /** The elements part of the list. */ + elements: Expr[]; +} +export interface Expr_CreateListProtoMsg { + typeUrl: "/google.api.expr.v1beta1.CreateList"; + value: Uint8Array; +} +/** + * A list creation expression. + * + * Lists may either be homogenous, e.g. `[1, 2, 3]`, or heterogenous, e.g. + * `dyn([1, 'hello', 2.0])` + */ +export interface Expr_CreateListSDKType { + elements: ExprSDKType[]; +} +/** + * A map or message creation expression. + * + * Maps are constructed as `{'key_name': 'value'}`. Message construction is + * similar, but prefixed with a type name and composed of field ids: + * `types.MyType{field_id: 'value'}`. + */ +export interface Expr_CreateStruct { + /** + * The type name of the message to be created, empty when creating map + * literals. + */ + type: string; + /** The entries in the creation expression. */ + entries: Expr_CreateStruct_Entry[]; +} +export interface Expr_CreateStructProtoMsg { + typeUrl: "/google.api.expr.v1beta1.CreateStruct"; + value: Uint8Array; +} +/** + * A map or message creation expression. + * + * Maps are constructed as `{'key_name': 'value'}`. Message construction is + * similar, but prefixed with a type name and composed of field ids: + * `types.MyType{field_id: 'value'}`. + */ +export interface Expr_CreateStructSDKType { + type: string; + entries: Expr_CreateStruct_EntrySDKType[]; +} +/** Represents an entry. */ +export interface Expr_CreateStruct_Entry { + /** + * Required. An id assigned to this node by the parser which is unique + * in a given expression tree. This is used to associate type + * information and other attributes to the node. + */ + id: number; + /** The field key for a message creator statement. */ + fieldKey?: string; + /** The key expression for a map creation statement. */ + mapKey?: Expr; + /** Required. The value assigned to the key. */ + value?: Expr; +} +export interface Expr_CreateStruct_EntryProtoMsg { + typeUrl: "/google.api.expr.v1beta1.Entry"; + value: Uint8Array; +} +/** Represents an entry. */ +export interface Expr_CreateStruct_EntrySDKType { + id: number; + field_key?: string; + map_key?: ExprSDKType; + value?: ExprSDKType; +} +/** + * A comprehension expression applied to a list or map. + * + * Comprehensions are not part of the core syntax, but enabled with macros. + * A macro matches a specific call signature within a parsed AST and replaces + * the call with an alternate AST block. Macro expansion happens at parse + * time. + * + * The following macros are supported within CEL: + * + * Aggregate type macros may be applied to all elements in a list or all keys + * in a map: + * + * * `all`, `exists`, `exists_one` - test a predicate expression against + * the inputs and return `true` if the predicate is satisfied for all, + * any, or only one value `list.all(x, x < 10)`. + * * `filter` - test a predicate expression against the inputs and return + * the subset of elements which satisfy the predicate: + * `payments.filter(p, p > 1000)`. + * * `map` - apply an expression to all elements in the input and return the + * output aggregate type: `[1, 2, 3].map(i, i * i)`. + * + * The `has(m.x)` macro tests whether the property `x` is present in struct + * `m`. The semantics of this macro depend on the type of `m`. For proto2 + * messages `has(m.x)` is defined as 'defined, but not set`. For proto3, the + * macro tests whether the property is set to its default. For map and struct + * types, the macro tests whether the property `x` is defined on `m`. + */ +export interface Expr_Comprehension { + /** The name of the iteration variable. */ + iterVar: string; + /** The range over which var iterates. */ + iterRange?: Expr; + /** The name of the variable used for accumulation of the result. */ + accuVar: string; + /** The initial value of the accumulator. */ + accuInit?: Expr; + /** + * An expression which can contain iter_var and accu_var. + * + * Returns false when the result has been computed and may be used as + * a hint to short-circuit the remainder of the comprehension. + */ + loopCondition?: Expr; + /** + * An expression which can contain iter_var and accu_var. + * + * Computes the next value of accu_var. + */ + loopStep?: Expr; + /** + * An expression which can contain accu_var. + * + * Computes the result. + */ + result?: Expr; +} +export interface Expr_ComprehensionProtoMsg { + typeUrl: "/google.api.expr.v1beta1.Comprehension"; + value: Uint8Array; +} +/** + * A comprehension expression applied to a list or map. + * + * Comprehensions are not part of the core syntax, but enabled with macros. + * A macro matches a specific call signature within a parsed AST and replaces + * the call with an alternate AST block. Macro expansion happens at parse + * time. + * + * The following macros are supported within CEL: + * + * Aggregate type macros may be applied to all elements in a list or all keys + * in a map: + * + * * `all`, `exists`, `exists_one` - test a predicate expression against + * the inputs and return `true` if the predicate is satisfied for all, + * any, or only one value `list.all(x, x < 10)`. + * * `filter` - test a predicate expression against the inputs and return + * the subset of elements which satisfy the predicate: + * `payments.filter(p, p > 1000)`. + * * `map` - apply an expression to all elements in the input and return the + * output aggregate type: `[1, 2, 3].map(i, i * i)`. + * + * The `has(m.x)` macro tests whether the property `x` is present in struct + * `m`. The semantics of this macro depend on the type of `m`. For proto2 + * messages `has(m.x)` is defined as 'defined, but not set`. For proto3, the + * macro tests whether the property is set to its default. For map and struct + * types, the macro tests whether the property `x` is defined on `m`. + */ +export interface Expr_ComprehensionSDKType { + iter_var: string; + iter_range?: ExprSDKType; + accu_var: string; + accu_init?: ExprSDKType; + loop_condition?: ExprSDKType; + loop_step?: ExprSDKType; + result?: ExprSDKType; +} +/** + * Represents a primitive literal. + * + * This is similar to the primitives supported in the well-known type + * `google.protobuf.Value`, but richer so it can represent CEL's full range of + * primitives. + * + * Lists and structs are not included as constants as these aggregate types may + * contain [Expr][google.api.expr.v1beta1.Expr] elements which require evaluation and are thus not constant. + * + * Examples of literals include: `"hello"`, `b'bytes'`, `1u`, `4.2`, `-2`, + * `true`, `null`. + */ +export interface Literal { + /** null value. */ + nullValue?: NullValue; + /** boolean value. */ + boolValue?: boolean; + /** int64 value. */ + int64Value?: bigint; + /** uint64 value. */ + uint64Value?: bigint; + /** double value. */ + doubleValue?: number; + /** string value. */ + stringValue?: string; + /** bytes value. */ + bytesValue?: Uint8Array; +} +export interface LiteralProtoMsg { + typeUrl: "/google.api.expr.v1beta1.Literal"; + value: Uint8Array; +} +/** + * Represents a primitive literal. + * + * This is similar to the primitives supported in the well-known type + * `google.protobuf.Value`, but richer so it can represent CEL's full range of + * primitives. + * + * Lists and structs are not included as constants as these aggregate types may + * contain [Expr][google.api.expr.v1beta1.Expr] elements which require evaluation and are thus not constant. + * + * Examples of literals include: `"hello"`, `b'bytes'`, `1u`, `4.2`, `-2`, + * `true`, `null`. + */ +export interface LiteralSDKType { + null_value?: NullValue; + bool_value?: boolean; + int64_value?: bigint; + uint64_value?: bigint; + double_value?: number; + string_value?: string; + bytes_value?: Uint8Array; +} +function createBaseParsedExpr(): ParsedExpr { + return { + expr: undefined, + sourceInfo: undefined, + syntaxVersion: "" + }; +} +export const ParsedExpr = { + typeUrl: "/google.api.expr.v1beta1.ParsedExpr", + encode(message: ParsedExpr, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.expr !== undefined) { + Expr.encode(message.expr, writer.uint32(18).fork()).ldelim(); + } + if (message.sourceInfo !== undefined) { + SourceInfo.encode(message.sourceInfo, writer.uint32(26).fork()).ldelim(); + } + if (message.syntaxVersion !== undefined) { + writer.uint32(34).string(message.syntaxVersion); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ParsedExpr { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseParsedExpr(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.expr = Expr.decode(reader, reader.uint32()); + break; + case 3: + message.sourceInfo = SourceInfo.decode(reader, reader.uint32()); + break; + case 4: + message.syntaxVersion = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ParsedExpr { + const obj = createBaseParsedExpr(); + if (isSet(object.expr)) obj.expr = Expr.fromJSON(object.expr); + if (isSet(object.sourceInfo)) obj.sourceInfo = SourceInfo.fromJSON(object.sourceInfo); + if (isSet(object.syntaxVersion)) obj.syntaxVersion = String(object.syntaxVersion); + return obj; + }, + toJSON(message: ParsedExpr): JsonSafe { + const obj: any = {}; + message.expr !== undefined && (obj.expr = message.expr ? Expr.toJSON(message.expr) : undefined); + message.sourceInfo !== undefined && (obj.sourceInfo = message.sourceInfo ? SourceInfo.toJSON(message.sourceInfo) : undefined); + message.syntaxVersion !== undefined && (obj.syntaxVersion = message.syntaxVersion); + return obj; + }, + fromPartial(object: DeepPartial): ParsedExpr { + const message = createBaseParsedExpr(); + if (object.expr !== undefined && object.expr !== null) { + message.expr = Expr.fromPartial(object.expr); + } + if (object.sourceInfo !== undefined && object.sourceInfo !== null) { + message.sourceInfo = SourceInfo.fromPartial(object.sourceInfo); + } + message.syntaxVersion = object.syntaxVersion ?? ""; + return message; + }, + fromSDK(object: ParsedExprSDKType): ParsedExpr { + return { + expr: object.expr ? Expr.fromSDK(object.expr) : undefined, + sourceInfo: object.source_info ? SourceInfo.fromSDK(object.source_info) : undefined, + syntaxVersion: object?.syntax_version + }; + }, + fromSDKJSON(object: any): ParsedExprSDKType { + return { + expr: isSet(object.expr) ? Expr.fromSDKJSON(object.expr) : undefined, + source_info: isSet(object.source_info) ? SourceInfo.fromSDKJSON(object.source_info) : undefined, + syntax_version: isSet(object.syntax_version) ? String(object.syntax_version) : "" + }; + }, + toSDK(message: ParsedExpr): ParsedExprSDKType { + const obj: any = {}; + message.expr !== undefined && (obj.expr = message.expr ? Expr.toSDK(message.expr) : undefined); + message.sourceInfo !== undefined && (obj.source_info = message.sourceInfo ? SourceInfo.toSDK(message.sourceInfo) : undefined); + obj.syntax_version = message.syntaxVersion; + return obj; + }, + fromAmino(object: ParsedExprAmino): ParsedExpr { + const message = createBaseParsedExpr(); + if (object.expr !== undefined && object.expr !== null) { + message.expr = Expr.fromAmino(object.expr); + } + if (object.source_info !== undefined && object.source_info !== null) { + message.sourceInfo = SourceInfo.fromAmino(object.source_info); + } + if (object.syntax_version !== undefined && object.syntax_version !== null) { + message.syntaxVersion = object.syntax_version; + } + return message; + }, + toAmino(message: ParsedExpr): ParsedExprAmino { + const obj: any = {}; + obj.expr = message.expr ? Expr.toAmino(message.expr) : undefined; + obj.source_info = message.sourceInfo ? SourceInfo.toAmino(message.sourceInfo) : undefined; + obj.syntax_version = message.syntaxVersion === "" ? undefined : message.syntaxVersion; + return obj; + }, + fromAminoMsg(object: ParsedExprAminoMsg): ParsedExpr { + return ParsedExpr.fromAmino(object.value); + }, + fromProtoMsg(message: ParsedExprProtoMsg): ParsedExpr { + return ParsedExpr.decode(message.value); + }, + toProto(message: ParsedExpr): Uint8Array { + return ParsedExpr.encode(message).finish(); + }, + toProtoMsg(message: ParsedExpr): ParsedExprProtoMsg { + return { + typeUrl: "/google.api.expr.v1beta1.ParsedExpr", + value: ParsedExpr.encode(message).finish() + }; + } +}; +function createBaseExpr(): Expr { + return { + id: 0, + literalExpr: undefined, + identExpr: undefined, + selectExpr: undefined, + callExpr: undefined, + listExpr: undefined, + structExpr: undefined, + comprehensionExpr: undefined + }; +} +export const Expr = { + typeUrl: "/google.api.expr.v1beta1.Expr", + encode(message: Expr, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.id !== undefined) { + writer.uint32(16).int32(message.id); + } + if (message.literalExpr !== undefined) { + Literal.encode(message.literalExpr, writer.uint32(26).fork()).ldelim(); + } + if (message.identExpr !== undefined) { + Expr_Ident.encode(message.identExpr, writer.uint32(34).fork()).ldelim(); + } + if (message.selectExpr !== undefined) { + Expr_Select.encode(message.selectExpr, writer.uint32(42).fork()).ldelim(); + } + if (message.callExpr !== undefined) { + Expr_Call.encode(message.callExpr, writer.uint32(50).fork()).ldelim(); + } + if (message.listExpr !== undefined) { + Expr_CreateList.encode(message.listExpr, writer.uint32(58).fork()).ldelim(); + } + if (message.structExpr !== undefined) { + Expr_CreateStruct.encode(message.structExpr, writer.uint32(66).fork()).ldelim(); + } + if (message.comprehensionExpr !== undefined) { + Expr_Comprehension.encode(message.comprehensionExpr, writer.uint32(74).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Expr { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseExpr(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.id = reader.int32(); + break; + case 3: + message.literalExpr = Literal.decode(reader, reader.uint32()); + break; + case 4: + message.identExpr = Expr_Ident.decode(reader, reader.uint32()); + break; + case 5: + message.selectExpr = Expr_Select.decode(reader, reader.uint32()); + break; + case 6: + message.callExpr = Expr_Call.decode(reader, reader.uint32()); + break; + case 7: + message.listExpr = Expr_CreateList.decode(reader, reader.uint32()); + break; + case 8: + message.structExpr = Expr_CreateStruct.decode(reader, reader.uint32()); + break; + case 9: + message.comprehensionExpr = Expr_Comprehension.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Expr { + const obj = createBaseExpr(); + if (isSet(object.id)) obj.id = Number(object.id); + if (isSet(object.literalExpr)) obj.literalExpr = Literal.fromJSON(object.literalExpr); + if (isSet(object.identExpr)) obj.identExpr = Expr_Ident.fromJSON(object.identExpr); + if (isSet(object.selectExpr)) obj.selectExpr = Expr_Select.fromJSON(object.selectExpr); + if (isSet(object.callExpr)) obj.callExpr = Expr_Call.fromJSON(object.callExpr); + if (isSet(object.listExpr)) obj.listExpr = Expr_CreateList.fromJSON(object.listExpr); + if (isSet(object.structExpr)) obj.structExpr = Expr_CreateStruct.fromJSON(object.structExpr); + if (isSet(object.comprehensionExpr)) obj.comprehensionExpr = Expr_Comprehension.fromJSON(object.comprehensionExpr); + return obj; + }, + toJSON(message: Expr): JsonSafe { + const obj: any = {}; + message.id !== undefined && (obj.id = Math.round(message.id)); + message.literalExpr !== undefined && (obj.literalExpr = message.literalExpr ? Literal.toJSON(message.literalExpr) : undefined); + message.identExpr !== undefined && (obj.identExpr = message.identExpr ? Expr_Ident.toJSON(message.identExpr) : undefined); + message.selectExpr !== undefined && (obj.selectExpr = message.selectExpr ? Expr_Select.toJSON(message.selectExpr) : undefined); + message.callExpr !== undefined && (obj.callExpr = message.callExpr ? Expr_Call.toJSON(message.callExpr) : undefined); + message.listExpr !== undefined && (obj.listExpr = message.listExpr ? Expr_CreateList.toJSON(message.listExpr) : undefined); + message.structExpr !== undefined && (obj.structExpr = message.structExpr ? Expr_CreateStruct.toJSON(message.structExpr) : undefined); + message.comprehensionExpr !== undefined && (obj.comprehensionExpr = message.comprehensionExpr ? Expr_Comprehension.toJSON(message.comprehensionExpr) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): Expr { + const message = createBaseExpr(); + message.id = object.id ?? 0; + if (object.literalExpr !== undefined && object.literalExpr !== null) { + message.literalExpr = Literal.fromPartial(object.literalExpr); + } + if (object.identExpr !== undefined && object.identExpr !== null) { + message.identExpr = Expr_Ident.fromPartial(object.identExpr); + } + if (object.selectExpr !== undefined && object.selectExpr !== null) { + message.selectExpr = Expr_Select.fromPartial(object.selectExpr); + } + if (object.callExpr !== undefined && object.callExpr !== null) { + message.callExpr = Expr_Call.fromPartial(object.callExpr); + } + if (object.listExpr !== undefined && object.listExpr !== null) { + message.listExpr = Expr_CreateList.fromPartial(object.listExpr); + } + if (object.structExpr !== undefined && object.structExpr !== null) { + message.structExpr = Expr_CreateStruct.fromPartial(object.structExpr); + } + if (object.comprehensionExpr !== undefined && object.comprehensionExpr !== null) { + message.comprehensionExpr = Expr_Comprehension.fromPartial(object.comprehensionExpr); + } + return message; + }, + fromSDK(object: ExprSDKType): Expr { + return { + id: object?.id, + literalExpr: object.literal_expr ? Literal.fromSDK(object.literal_expr) : undefined, + identExpr: object.ident_expr ? Expr_Ident.fromSDK(object.ident_expr) : undefined, + selectExpr: object.select_expr ? Expr_Select.fromSDK(object.select_expr) : undefined, + callExpr: object.call_expr ? Expr_Call.fromSDK(object.call_expr) : undefined, + listExpr: object.list_expr ? Expr_CreateList.fromSDK(object.list_expr) : undefined, + structExpr: object.struct_expr ? Expr_CreateStruct.fromSDK(object.struct_expr) : undefined, + comprehensionExpr: object.comprehension_expr ? Expr_Comprehension.fromSDK(object.comprehension_expr) : undefined + }; + }, + fromSDKJSON(object: any): ExprSDKType { + return { + id: isSet(object.id) ? Number(object.id) : 0, + literal_expr: isSet(object.literal_expr) ? Literal.fromSDKJSON(object.literal_expr) : undefined, + ident_expr: isSet(object.ident_expr) ? Expr_Ident.fromSDKJSON(object.ident_expr) : undefined, + select_expr: isSet(object.select_expr) ? Expr_Select.fromSDKJSON(object.select_expr) : undefined, + call_expr: isSet(object.call_expr) ? Expr_Call.fromSDKJSON(object.call_expr) : undefined, + list_expr: isSet(object.list_expr) ? Expr_CreateList.fromSDKJSON(object.list_expr) : undefined, + struct_expr: isSet(object.struct_expr) ? Expr_CreateStruct.fromSDKJSON(object.struct_expr) : undefined, + comprehension_expr: isSet(object.comprehension_expr) ? Expr_Comprehension.fromSDKJSON(object.comprehension_expr) : undefined + }; + }, + toSDK(message: Expr): ExprSDKType { + const obj: any = {}; + obj.id = message.id; + message.literalExpr !== undefined && (obj.literal_expr = message.literalExpr ? Literal.toSDK(message.literalExpr) : undefined); + message.identExpr !== undefined && (obj.ident_expr = message.identExpr ? Expr_Ident.toSDK(message.identExpr) : undefined); + message.selectExpr !== undefined && (obj.select_expr = message.selectExpr ? Expr_Select.toSDK(message.selectExpr) : undefined); + message.callExpr !== undefined && (obj.call_expr = message.callExpr ? Expr_Call.toSDK(message.callExpr) : undefined); + message.listExpr !== undefined && (obj.list_expr = message.listExpr ? Expr_CreateList.toSDK(message.listExpr) : undefined); + message.structExpr !== undefined && (obj.struct_expr = message.structExpr ? Expr_CreateStruct.toSDK(message.structExpr) : undefined); + message.comprehensionExpr !== undefined && (obj.comprehension_expr = message.comprehensionExpr ? Expr_Comprehension.toSDK(message.comprehensionExpr) : undefined); + return obj; + }, + fromAmino(object: ExprAmino): Expr { + const message = createBaseExpr(); + if (object.id !== undefined && object.id !== null) { + message.id = object.id; + } + if (object.literal_expr !== undefined && object.literal_expr !== null) { + message.literalExpr = Literal.fromAmino(object.literal_expr); + } + if (object.ident_expr !== undefined && object.ident_expr !== null) { + message.identExpr = Expr_Ident.fromAmino(object.ident_expr); + } + if (object.select_expr !== undefined && object.select_expr !== null) { + message.selectExpr = Expr_Select.fromAmino(object.select_expr); + } + if (object.call_expr !== undefined && object.call_expr !== null) { + message.callExpr = Expr_Call.fromAmino(object.call_expr); + } + if (object.list_expr !== undefined && object.list_expr !== null) { + message.listExpr = Expr_CreateList.fromAmino(object.list_expr); + } + if (object.struct_expr !== undefined && object.struct_expr !== null) { + message.structExpr = Expr_CreateStruct.fromAmino(object.struct_expr); + } + if (object.comprehension_expr !== undefined && object.comprehension_expr !== null) { + message.comprehensionExpr = Expr_Comprehension.fromAmino(object.comprehension_expr); + } + return message; + }, + toAmino(message: Expr): ExprAmino { + const obj: any = {}; + obj.id = message.id === 0 ? undefined : message.id; + obj.literal_expr = message.literalExpr ? Literal.toAmino(message.literalExpr) : undefined; + obj.ident_expr = message.identExpr ? Expr_Ident.toAmino(message.identExpr) : undefined; + obj.select_expr = message.selectExpr ? Expr_Select.toAmino(message.selectExpr) : undefined; + obj.call_expr = message.callExpr ? Expr_Call.toAmino(message.callExpr) : undefined; + obj.list_expr = message.listExpr ? Expr_CreateList.toAmino(message.listExpr) : undefined; + obj.struct_expr = message.structExpr ? Expr_CreateStruct.toAmino(message.structExpr) : undefined; + obj.comprehension_expr = message.comprehensionExpr ? Expr_Comprehension.toAmino(message.comprehensionExpr) : undefined; + return obj; + }, + fromAminoMsg(object: ExprAminoMsg): Expr { + return Expr.fromAmino(object.value); + }, + fromProtoMsg(message: ExprProtoMsg): Expr { + return Expr.decode(message.value); + }, + toProto(message: Expr): Uint8Array { + return Expr.encode(message).finish(); + }, + toProtoMsg(message: Expr): ExprProtoMsg { + return { + typeUrl: "/google.api.expr.v1beta1.Expr", + value: Expr.encode(message).finish() + }; + } +}; +function createBaseExpr_Ident(): Expr_Ident { + return { + name: "" + }; +} +export const Expr_Ident = { + typeUrl: "/google.api.expr.v1beta1.Ident", + encode(message: Expr_Ident, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Expr_Ident { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseExpr_Ident(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Expr_Ident { + const obj = createBaseExpr_Ident(); + if (isSet(object.name)) obj.name = String(object.name); + return obj; + }, + toJSON(message: Expr_Ident): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + return obj; + }, + fromPartial(object: DeepPartial): Expr_Ident { + const message = createBaseExpr_Ident(); + message.name = object.name ?? ""; + return message; + }, + fromSDK(object: Expr_IdentSDKType): Expr_Ident { + return { + name: object?.name + }; + }, + fromSDKJSON(object: any): Expr_IdentSDKType { + return { + name: isSet(object.name) ? String(object.name) : "" + }; + }, + toSDK(message: Expr_Ident): Expr_IdentSDKType { + const obj: any = {}; + obj.name = message.name; + return obj; + }, + fromAmino(object: Expr_IdentAmino): Expr_Ident { + const message = createBaseExpr_Ident(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + return message; + }, + toAmino(message: Expr_Ident): Expr_IdentAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + return obj; + }, + fromAminoMsg(object: Expr_IdentAminoMsg): Expr_Ident { + return Expr_Ident.fromAmino(object.value); + }, + fromProtoMsg(message: Expr_IdentProtoMsg): Expr_Ident { + return Expr_Ident.decode(message.value); + }, + toProto(message: Expr_Ident): Uint8Array { + return Expr_Ident.encode(message).finish(); + }, + toProtoMsg(message: Expr_Ident): Expr_IdentProtoMsg { + return { + typeUrl: "/google.api.expr.v1beta1.Ident", + value: Expr_Ident.encode(message).finish() + }; + } +}; +function createBaseExpr_Select(): Expr_Select { + return { + operand: undefined, + field: "", + testOnly: false + }; +} +export const Expr_Select = { + typeUrl: "/google.api.expr.v1beta1.Select", + encode(message: Expr_Select, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.operand !== undefined) { + Expr.encode(message.operand, writer.uint32(10).fork()).ldelim(); + } + if (message.field !== undefined) { + writer.uint32(18).string(message.field); + } + if (message.testOnly !== undefined) { + writer.uint32(24).bool(message.testOnly); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Expr_Select { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseExpr_Select(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.operand = Expr.decode(reader, reader.uint32()); + break; + case 2: + message.field = reader.string(); + break; + case 3: + message.testOnly = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Expr_Select { + const obj = createBaseExpr_Select(); + if (isSet(object.operand)) obj.operand = Expr.fromJSON(object.operand); + if (isSet(object.field)) obj.field = String(object.field); + if (isSet(object.testOnly)) obj.testOnly = Boolean(object.testOnly); + return obj; + }, + toJSON(message: Expr_Select): JsonSafe { + const obj: any = {}; + message.operand !== undefined && (obj.operand = message.operand ? Expr.toJSON(message.operand) : undefined); + message.field !== undefined && (obj.field = message.field); + message.testOnly !== undefined && (obj.testOnly = message.testOnly); + return obj; + }, + fromPartial(object: DeepPartial): Expr_Select { + const message = createBaseExpr_Select(); + if (object.operand !== undefined && object.operand !== null) { + message.operand = Expr.fromPartial(object.operand); + } + message.field = object.field ?? ""; + message.testOnly = object.testOnly ?? false; + return message; + }, + fromSDK(object: Expr_SelectSDKType): Expr_Select { + return { + operand: object.operand ? Expr.fromSDK(object.operand) : undefined, + field: object?.field, + testOnly: object?.test_only + }; + }, + fromSDKJSON(object: any): Expr_SelectSDKType { + return { + operand: isSet(object.operand) ? Expr.fromSDKJSON(object.operand) : undefined, + field: isSet(object.field) ? String(object.field) : "", + test_only: isSet(object.test_only) ? Boolean(object.test_only) : false + }; + }, + toSDK(message: Expr_Select): Expr_SelectSDKType { + const obj: any = {}; + message.operand !== undefined && (obj.operand = message.operand ? Expr.toSDK(message.operand) : undefined); + obj.field = message.field; + obj.test_only = message.testOnly; + return obj; + }, + fromAmino(object: Expr_SelectAmino): Expr_Select { + const message = createBaseExpr_Select(); + if (object.operand !== undefined && object.operand !== null) { + message.operand = Expr.fromAmino(object.operand); + } + if (object.field !== undefined && object.field !== null) { + message.field = object.field; + } + if (object.test_only !== undefined && object.test_only !== null) { + message.testOnly = object.test_only; + } + return message; + }, + toAmino(message: Expr_Select): Expr_SelectAmino { + const obj: any = {}; + obj.operand = message.operand ? Expr.toAmino(message.operand) : undefined; + obj.field = message.field === "" ? undefined : message.field; + obj.test_only = message.testOnly === false ? undefined : message.testOnly; + return obj; + }, + fromAminoMsg(object: Expr_SelectAminoMsg): Expr_Select { + return Expr_Select.fromAmino(object.value); + }, + fromProtoMsg(message: Expr_SelectProtoMsg): Expr_Select { + return Expr_Select.decode(message.value); + }, + toProto(message: Expr_Select): Uint8Array { + return Expr_Select.encode(message).finish(); + }, + toProtoMsg(message: Expr_Select): Expr_SelectProtoMsg { + return { + typeUrl: "/google.api.expr.v1beta1.Select", + value: Expr_Select.encode(message).finish() + }; + } +}; +function createBaseExpr_Call(): Expr_Call { + return { + target: undefined, + function: "", + args: [] + }; +} +export const Expr_Call = { + typeUrl: "/google.api.expr.v1beta1.Call", + encode(message: Expr_Call, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.target !== undefined) { + Expr.encode(message.target, writer.uint32(10).fork()).ldelim(); + } + if (message.function !== undefined) { + writer.uint32(18).string(message.function); + } + for (const v of message.args) { + Expr.encode(v!, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Expr_Call { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseExpr_Call(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.target = Expr.decode(reader, reader.uint32()); + break; + case 2: + message.function = reader.string(); + break; + case 3: + message.args.push(Expr.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Expr_Call { + const obj = createBaseExpr_Call(); + if (isSet(object.target)) obj.target = Expr.fromJSON(object.target); + if (isSet(object.function)) obj.function = String(object.function); + if (Array.isArray(object?.args)) obj.args = object.args.map((e: any) => Expr.fromJSON(e)); + return obj; + }, + toJSON(message: Expr_Call): JsonSafe { + const obj: any = {}; + message.target !== undefined && (obj.target = message.target ? Expr.toJSON(message.target) : undefined); + message.function !== undefined && (obj.function = message.function); + if (message.args) { + obj.args = message.args.map(e => e ? Expr.toJSON(e) : undefined); + } else { + obj.args = []; + } + return obj; + }, + fromPartial(object: DeepPartial): Expr_Call { + const message = createBaseExpr_Call(); + if (object.target !== undefined && object.target !== null) { + message.target = Expr.fromPartial(object.target); + } + message.function = object.function ?? ""; + message.args = object.args?.map(e => Expr.fromPartial(e)) || []; + return message; + }, + fromSDK(object: Expr_CallSDKType): Expr_Call { + return { + target: object.target ? Expr.fromSDK(object.target) : undefined, + function: object?.function, + args: Array.isArray(object?.args) ? object.args.map((e: any) => Expr.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): Expr_CallSDKType { + return { + target: isSet(object.target) ? Expr.fromSDKJSON(object.target) : undefined, + function: isSet(object.function) ? String(object.function) : "", + args: Array.isArray(object?.args) ? object.args.map((e: any) => Expr.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: Expr_Call): Expr_CallSDKType { + const obj: any = {}; + message.target !== undefined && (obj.target = message.target ? Expr.toSDK(message.target) : undefined); + obj.function = message.function; + if (message.args) { + obj.args = message.args.map(e => e ? Expr.toSDK(e) : undefined); + } else { + obj.args = []; + } + return obj; + }, + fromAmino(object: Expr_CallAmino): Expr_Call { + const message = createBaseExpr_Call(); + if (object.target !== undefined && object.target !== null) { + message.target = Expr.fromAmino(object.target); + } + if (object.function !== undefined && object.function !== null) { + message.function = object.function; + } + message.args = object.args?.map(e => Expr.fromAmino(e)) || []; + return message; + }, + toAmino(message: Expr_Call): Expr_CallAmino { + const obj: any = {}; + obj.target = message.target ? Expr.toAmino(message.target) : undefined; + obj.function = message.function === "" ? undefined : message.function; + if (message.args) { + obj.args = message.args.map(e => e ? Expr.toAmino(e) : undefined); + } else { + obj.args = message.args; + } + return obj; + }, + fromAminoMsg(object: Expr_CallAminoMsg): Expr_Call { + return Expr_Call.fromAmino(object.value); + }, + fromProtoMsg(message: Expr_CallProtoMsg): Expr_Call { + return Expr_Call.decode(message.value); + }, + toProto(message: Expr_Call): Uint8Array { + return Expr_Call.encode(message).finish(); + }, + toProtoMsg(message: Expr_Call): Expr_CallProtoMsg { + return { + typeUrl: "/google.api.expr.v1beta1.Call", + value: Expr_Call.encode(message).finish() + }; + } +}; +function createBaseExpr_CreateList(): Expr_CreateList { + return { + elements: [] + }; +} +export const Expr_CreateList = { + typeUrl: "/google.api.expr.v1beta1.CreateList", + encode(message: Expr_CreateList, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.elements) { + Expr.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Expr_CreateList { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseExpr_CreateList(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.elements.push(Expr.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Expr_CreateList { + const obj = createBaseExpr_CreateList(); + if (Array.isArray(object?.elements)) obj.elements = object.elements.map((e: any) => Expr.fromJSON(e)); + return obj; + }, + toJSON(message: Expr_CreateList): JsonSafe { + const obj: any = {}; + if (message.elements) { + obj.elements = message.elements.map(e => e ? Expr.toJSON(e) : undefined); + } else { + obj.elements = []; + } + return obj; + }, + fromPartial(object: DeepPartial): Expr_CreateList { + const message = createBaseExpr_CreateList(); + message.elements = object.elements?.map(e => Expr.fromPartial(e)) || []; + return message; + }, + fromSDK(object: Expr_CreateListSDKType): Expr_CreateList { + return { + elements: Array.isArray(object?.elements) ? object.elements.map((e: any) => Expr.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): Expr_CreateListSDKType { + return { + elements: Array.isArray(object?.elements) ? object.elements.map((e: any) => Expr.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: Expr_CreateList): Expr_CreateListSDKType { + const obj: any = {}; + if (message.elements) { + obj.elements = message.elements.map(e => e ? Expr.toSDK(e) : undefined); + } else { + obj.elements = []; + } + return obj; + }, + fromAmino(object: Expr_CreateListAmino): Expr_CreateList { + const message = createBaseExpr_CreateList(); + message.elements = object.elements?.map(e => Expr.fromAmino(e)) || []; + return message; + }, + toAmino(message: Expr_CreateList): Expr_CreateListAmino { + const obj: any = {}; + if (message.elements) { + obj.elements = message.elements.map(e => e ? Expr.toAmino(e) : undefined); + } else { + obj.elements = message.elements; + } + return obj; + }, + fromAminoMsg(object: Expr_CreateListAminoMsg): Expr_CreateList { + return Expr_CreateList.fromAmino(object.value); + }, + fromProtoMsg(message: Expr_CreateListProtoMsg): Expr_CreateList { + return Expr_CreateList.decode(message.value); + }, + toProto(message: Expr_CreateList): Uint8Array { + return Expr_CreateList.encode(message).finish(); + }, + toProtoMsg(message: Expr_CreateList): Expr_CreateListProtoMsg { + return { + typeUrl: "/google.api.expr.v1beta1.CreateList", + value: Expr_CreateList.encode(message).finish() + }; + } +}; +function createBaseExpr_CreateStruct(): Expr_CreateStruct { + return { + type: "", + entries: [] + }; +} +export const Expr_CreateStruct = { + typeUrl: "/google.api.expr.v1beta1.CreateStruct", + encode(message: Expr_CreateStruct, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.type !== undefined) { + writer.uint32(10).string(message.type); + } + for (const v of message.entries) { + Expr_CreateStruct_Entry.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Expr_CreateStruct { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseExpr_CreateStruct(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.type = reader.string(); + break; + case 2: + message.entries.push(Expr_CreateStruct_Entry.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Expr_CreateStruct { + const obj = createBaseExpr_CreateStruct(); + if (isSet(object.type)) obj.type = String(object.type); + if (Array.isArray(object?.entries)) obj.entries = object.entries.map((e: any) => Expr_CreateStruct_Entry.fromJSON(e)); + return obj; + }, + toJSON(message: Expr_CreateStruct): JsonSafe { + const obj: any = {}; + message.type !== undefined && (obj.type = message.type); + if (message.entries) { + obj.entries = message.entries.map(e => e ? Expr_CreateStruct_Entry.toJSON(e) : undefined); + } else { + obj.entries = []; + } + return obj; + }, + fromPartial(object: DeepPartial): Expr_CreateStruct { + const message = createBaseExpr_CreateStruct(); + message.type = object.type ?? ""; + message.entries = object.entries?.map(e => Expr_CreateStruct_Entry.fromPartial(e)) || []; + return message; + }, + fromSDK(object: Expr_CreateStructSDKType): Expr_CreateStruct { + return { + type: object?.type, + entries: Array.isArray(object?.entries) ? object.entries.map((e: any) => Expr_CreateStruct_Entry.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): Expr_CreateStructSDKType { + return { + type: isSet(object.type) ? String(object.type) : "", + entries: Array.isArray(object?.entries) ? object.entries.map((e: any) => Expr_CreateStruct_Entry.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: Expr_CreateStruct): Expr_CreateStructSDKType { + const obj: any = {}; + obj.type = message.type; + if (message.entries) { + obj.entries = message.entries.map(e => e ? Expr_CreateStruct_Entry.toSDK(e) : undefined); + } else { + obj.entries = []; + } + return obj; + }, + fromAmino(object: Expr_CreateStructAmino): Expr_CreateStruct { + const message = createBaseExpr_CreateStruct(); + if (object.type !== undefined && object.type !== null) { + message.type = object.type; + } + message.entries = object.entries?.map(e => Expr_CreateStruct_Entry.fromAmino(e)) || []; + return message; + }, + toAmino(message: Expr_CreateStruct): Expr_CreateStructAmino { + const obj: any = {}; + obj.type = message.type === "" ? undefined : message.type; + if (message.entries) { + obj.entries = message.entries.map(e => e ? Expr_CreateStruct_Entry.toAmino(e) : undefined); + } else { + obj.entries = message.entries; + } + return obj; + }, + fromAminoMsg(object: Expr_CreateStructAminoMsg): Expr_CreateStruct { + return Expr_CreateStruct.fromAmino(object.value); + }, + fromProtoMsg(message: Expr_CreateStructProtoMsg): Expr_CreateStruct { + return Expr_CreateStruct.decode(message.value); + }, + toProto(message: Expr_CreateStruct): Uint8Array { + return Expr_CreateStruct.encode(message).finish(); + }, + toProtoMsg(message: Expr_CreateStruct): Expr_CreateStructProtoMsg { + return { + typeUrl: "/google.api.expr.v1beta1.CreateStruct", + value: Expr_CreateStruct.encode(message).finish() + }; + } +}; +function createBaseExpr_CreateStruct_Entry(): Expr_CreateStruct_Entry { + return { + id: 0, + fieldKey: undefined, + mapKey: undefined, + value: undefined + }; +} +export const Expr_CreateStruct_Entry = { + typeUrl: "/google.api.expr.v1beta1.Entry", + encode(message: Expr_CreateStruct_Entry, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.id !== undefined) { + writer.uint32(8).int32(message.id); + } + if (message.fieldKey !== undefined) { + writer.uint32(18).string(message.fieldKey); + } + if (message.mapKey !== undefined) { + Expr.encode(message.mapKey, writer.uint32(26).fork()).ldelim(); + } + if (message.value !== undefined) { + Expr.encode(message.value, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Expr_CreateStruct_Entry { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseExpr_CreateStruct_Entry(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.id = reader.int32(); + break; + case 2: + message.fieldKey = reader.string(); + break; + case 3: + message.mapKey = Expr.decode(reader, reader.uint32()); + break; + case 4: + message.value = Expr.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Expr_CreateStruct_Entry { + const obj = createBaseExpr_CreateStruct_Entry(); + if (isSet(object.id)) obj.id = Number(object.id); + if (isSet(object.fieldKey)) obj.fieldKey = String(object.fieldKey); + if (isSet(object.mapKey)) obj.mapKey = Expr.fromJSON(object.mapKey); + if (isSet(object.value)) obj.value = Expr.fromJSON(object.value); + return obj; + }, + toJSON(message: Expr_CreateStruct_Entry): JsonSafe { + const obj: any = {}; + message.id !== undefined && (obj.id = Math.round(message.id)); + message.fieldKey !== undefined && (obj.fieldKey = message.fieldKey); + message.mapKey !== undefined && (obj.mapKey = message.mapKey ? Expr.toJSON(message.mapKey) : undefined); + message.value !== undefined && (obj.value = message.value ? Expr.toJSON(message.value) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): Expr_CreateStruct_Entry { + const message = createBaseExpr_CreateStruct_Entry(); + message.id = object.id ?? 0; + message.fieldKey = object.fieldKey ?? undefined; + if (object.mapKey !== undefined && object.mapKey !== null) { + message.mapKey = Expr.fromPartial(object.mapKey); + } + if (object.value !== undefined && object.value !== null) { + message.value = Expr.fromPartial(object.value); + } + return message; + }, + fromSDK(object: Expr_CreateStruct_EntrySDKType): Expr_CreateStruct_Entry { + return { + id: object?.id, + fieldKey: object?.field_key, + mapKey: object.map_key ? Expr.fromSDK(object.map_key) : undefined, + value: object.value ? Expr.fromSDK(object.value) : undefined + }; + }, + fromSDKJSON(object: any): Expr_CreateStruct_EntrySDKType { + return { + id: isSet(object.id) ? Number(object.id) : 0, + field_key: isSet(object.field_key) ? String(object.field_key) : undefined, + map_key: isSet(object.map_key) ? Expr.fromSDKJSON(object.map_key) : undefined, + value: isSet(object.value) ? Expr.fromSDKJSON(object.value) : undefined + }; + }, + toSDK(message: Expr_CreateStruct_Entry): Expr_CreateStruct_EntrySDKType { + const obj: any = {}; + obj.id = message.id; + obj.field_key = message.fieldKey; + message.mapKey !== undefined && (obj.map_key = message.mapKey ? Expr.toSDK(message.mapKey) : undefined); + message.value !== undefined && (obj.value = message.value ? Expr.toSDK(message.value) : undefined); + return obj; + }, + fromAmino(object: Expr_CreateStruct_EntryAmino): Expr_CreateStruct_Entry { + const message = createBaseExpr_CreateStruct_Entry(); + if (object.id !== undefined && object.id !== null) { + message.id = object.id; + } + if (object.field_key !== undefined && object.field_key !== null) { + message.fieldKey = object.field_key; + } + if (object.map_key !== undefined && object.map_key !== null) { + message.mapKey = Expr.fromAmino(object.map_key); + } + if (object.value !== undefined && object.value !== null) { + message.value = Expr.fromAmino(object.value); + } + return message; + }, + toAmino(message: Expr_CreateStruct_Entry): Expr_CreateStruct_EntryAmino { + const obj: any = {}; + obj.id = message.id === 0 ? undefined : message.id; + obj.field_key = message.fieldKey === null ? undefined : message.fieldKey; + obj.map_key = message.mapKey ? Expr.toAmino(message.mapKey) : undefined; + obj.value = message.value ? Expr.toAmino(message.value) : undefined; + return obj; + }, + fromAminoMsg(object: Expr_CreateStruct_EntryAminoMsg): Expr_CreateStruct_Entry { + return Expr_CreateStruct_Entry.fromAmino(object.value); + }, + fromProtoMsg(message: Expr_CreateStruct_EntryProtoMsg): Expr_CreateStruct_Entry { + return Expr_CreateStruct_Entry.decode(message.value); + }, + toProto(message: Expr_CreateStruct_Entry): Uint8Array { + return Expr_CreateStruct_Entry.encode(message).finish(); + }, + toProtoMsg(message: Expr_CreateStruct_Entry): Expr_CreateStruct_EntryProtoMsg { + return { + typeUrl: "/google.api.expr.v1beta1.Entry", + value: Expr_CreateStruct_Entry.encode(message).finish() + }; + } +}; +function createBaseExpr_Comprehension(): Expr_Comprehension { + return { + iterVar: "", + iterRange: undefined, + accuVar: "", + accuInit: undefined, + loopCondition: undefined, + loopStep: undefined, + result: undefined + }; +} +export const Expr_Comprehension = { + typeUrl: "/google.api.expr.v1beta1.Comprehension", + encode(message: Expr_Comprehension, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.iterVar !== undefined) { + writer.uint32(10).string(message.iterVar); + } + if (message.iterRange !== undefined) { + Expr.encode(message.iterRange, writer.uint32(18).fork()).ldelim(); + } + if (message.accuVar !== undefined) { + writer.uint32(26).string(message.accuVar); + } + if (message.accuInit !== undefined) { + Expr.encode(message.accuInit, writer.uint32(34).fork()).ldelim(); + } + if (message.loopCondition !== undefined) { + Expr.encode(message.loopCondition, writer.uint32(42).fork()).ldelim(); + } + if (message.loopStep !== undefined) { + Expr.encode(message.loopStep, writer.uint32(50).fork()).ldelim(); + } + if (message.result !== undefined) { + Expr.encode(message.result, writer.uint32(58).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Expr_Comprehension { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseExpr_Comprehension(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.iterVar = reader.string(); + break; + case 2: + message.iterRange = Expr.decode(reader, reader.uint32()); + break; + case 3: + message.accuVar = reader.string(); + break; + case 4: + message.accuInit = Expr.decode(reader, reader.uint32()); + break; + case 5: + message.loopCondition = Expr.decode(reader, reader.uint32()); + break; + case 6: + message.loopStep = Expr.decode(reader, reader.uint32()); + break; + case 7: + message.result = Expr.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Expr_Comprehension { + const obj = createBaseExpr_Comprehension(); + if (isSet(object.iterVar)) obj.iterVar = String(object.iterVar); + if (isSet(object.iterRange)) obj.iterRange = Expr.fromJSON(object.iterRange); + if (isSet(object.accuVar)) obj.accuVar = String(object.accuVar); + if (isSet(object.accuInit)) obj.accuInit = Expr.fromJSON(object.accuInit); + if (isSet(object.loopCondition)) obj.loopCondition = Expr.fromJSON(object.loopCondition); + if (isSet(object.loopStep)) obj.loopStep = Expr.fromJSON(object.loopStep); + if (isSet(object.result)) obj.result = Expr.fromJSON(object.result); + return obj; + }, + toJSON(message: Expr_Comprehension): JsonSafe { + const obj: any = {}; + message.iterVar !== undefined && (obj.iterVar = message.iterVar); + message.iterRange !== undefined && (obj.iterRange = message.iterRange ? Expr.toJSON(message.iterRange) : undefined); + message.accuVar !== undefined && (obj.accuVar = message.accuVar); + message.accuInit !== undefined && (obj.accuInit = message.accuInit ? Expr.toJSON(message.accuInit) : undefined); + message.loopCondition !== undefined && (obj.loopCondition = message.loopCondition ? Expr.toJSON(message.loopCondition) : undefined); + message.loopStep !== undefined && (obj.loopStep = message.loopStep ? Expr.toJSON(message.loopStep) : undefined); + message.result !== undefined && (obj.result = message.result ? Expr.toJSON(message.result) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): Expr_Comprehension { + const message = createBaseExpr_Comprehension(); + message.iterVar = object.iterVar ?? ""; + if (object.iterRange !== undefined && object.iterRange !== null) { + message.iterRange = Expr.fromPartial(object.iterRange); + } + message.accuVar = object.accuVar ?? ""; + if (object.accuInit !== undefined && object.accuInit !== null) { + message.accuInit = Expr.fromPartial(object.accuInit); + } + if (object.loopCondition !== undefined && object.loopCondition !== null) { + message.loopCondition = Expr.fromPartial(object.loopCondition); + } + if (object.loopStep !== undefined && object.loopStep !== null) { + message.loopStep = Expr.fromPartial(object.loopStep); + } + if (object.result !== undefined && object.result !== null) { + message.result = Expr.fromPartial(object.result); + } + return message; + }, + fromSDK(object: Expr_ComprehensionSDKType): Expr_Comprehension { + return { + iterVar: object?.iter_var, + iterRange: object.iter_range ? Expr.fromSDK(object.iter_range) : undefined, + accuVar: object?.accu_var, + accuInit: object.accu_init ? Expr.fromSDK(object.accu_init) : undefined, + loopCondition: object.loop_condition ? Expr.fromSDK(object.loop_condition) : undefined, + loopStep: object.loop_step ? Expr.fromSDK(object.loop_step) : undefined, + result: object.result ? Expr.fromSDK(object.result) : undefined + }; + }, + fromSDKJSON(object: any): Expr_ComprehensionSDKType { + return { + iter_var: isSet(object.iter_var) ? String(object.iter_var) : "", + iter_range: isSet(object.iter_range) ? Expr.fromSDKJSON(object.iter_range) : undefined, + accu_var: isSet(object.accu_var) ? String(object.accu_var) : "", + accu_init: isSet(object.accu_init) ? Expr.fromSDKJSON(object.accu_init) : undefined, + loop_condition: isSet(object.loop_condition) ? Expr.fromSDKJSON(object.loop_condition) : undefined, + loop_step: isSet(object.loop_step) ? Expr.fromSDKJSON(object.loop_step) : undefined, + result: isSet(object.result) ? Expr.fromSDKJSON(object.result) : undefined + }; + }, + toSDK(message: Expr_Comprehension): Expr_ComprehensionSDKType { + const obj: any = {}; + obj.iter_var = message.iterVar; + message.iterRange !== undefined && (obj.iter_range = message.iterRange ? Expr.toSDK(message.iterRange) : undefined); + obj.accu_var = message.accuVar; + message.accuInit !== undefined && (obj.accu_init = message.accuInit ? Expr.toSDK(message.accuInit) : undefined); + message.loopCondition !== undefined && (obj.loop_condition = message.loopCondition ? Expr.toSDK(message.loopCondition) : undefined); + message.loopStep !== undefined && (obj.loop_step = message.loopStep ? Expr.toSDK(message.loopStep) : undefined); + message.result !== undefined && (obj.result = message.result ? Expr.toSDK(message.result) : undefined); + return obj; + }, + fromAmino(object: Expr_ComprehensionAmino): Expr_Comprehension { + const message = createBaseExpr_Comprehension(); + if (object.iter_var !== undefined && object.iter_var !== null) { + message.iterVar = object.iter_var; + } + if (object.iter_range !== undefined && object.iter_range !== null) { + message.iterRange = Expr.fromAmino(object.iter_range); + } + if (object.accu_var !== undefined && object.accu_var !== null) { + message.accuVar = object.accu_var; + } + if (object.accu_init !== undefined && object.accu_init !== null) { + message.accuInit = Expr.fromAmino(object.accu_init); + } + if (object.loop_condition !== undefined && object.loop_condition !== null) { + message.loopCondition = Expr.fromAmino(object.loop_condition); + } + if (object.loop_step !== undefined && object.loop_step !== null) { + message.loopStep = Expr.fromAmino(object.loop_step); + } + if (object.result !== undefined && object.result !== null) { + message.result = Expr.fromAmino(object.result); + } + return message; + }, + toAmino(message: Expr_Comprehension): Expr_ComprehensionAmino { + const obj: any = {}; + obj.iter_var = message.iterVar === "" ? undefined : message.iterVar; + obj.iter_range = message.iterRange ? Expr.toAmino(message.iterRange) : undefined; + obj.accu_var = message.accuVar === "" ? undefined : message.accuVar; + obj.accu_init = message.accuInit ? Expr.toAmino(message.accuInit) : undefined; + obj.loop_condition = message.loopCondition ? Expr.toAmino(message.loopCondition) : undefined; + obj.loop_step = message.loopStep ? Expr.toAmino(message.loopStep) : undefined; + obj.result = message.result ? Expr.toAmino(message.result) : undefined; + return obj; + }, + fromAminoMsg(object: Expr_ComprehensionAminoMsg): Expr_Comprehension { + return Expr_Comprehension.fromAmino(object.value); + }, + fromProtoMsg(message: Expr_ComprehensionProtoMsg): Expr_Comprehension { + return Expr_Comprehension.decode(message.value); + }, + toProto(message: Expr_Comprehension): Uint8Array { + return Expr_Comprehension.encode(message).finish(); + }, + toProtoMsg(message: Expr_Comprehension): Expr_ComprehensionProtoMsg { + return { + typeUrl: "/google.api.expr.v1beta1.Comprehension", + value: Expr_Comprehension.encode(message).finish() + }; + } +}; +function createBaseLiteral(): Literal { + return { + nullValue: undefined, + boolValue: undefined, + int64Value: undefined, + uint64Value: undefined, + doubleValue: undefined, + stringValue: undefined, + bytesValue: undefined + }; +} +export const Literal = { + typeUrl: "/google.api.expr.v1beta1.Literal", + encode(message: Literal, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.nullValue !== undefined) { + writer.uint32(8).int32(message.nullValue); + } + if (message.boolValue !== undefined) { + writer.uint32(16).bool(message.boolValue); + } + if (message.int64Value !== undefined) { + writer.uint32(24).int64(message.int64Value); + } + if (message.uint64Value !== undefined) { + writer.uint32(32).uint64(message.uint64Value); + } + if (message.doubleValue !== undefined) { + writer.uint32(41).double(message.doubleValue); + } + if (message.stringValue !== undefined) { + writer.uint32(50).string(message.stringValue); + } + if (message.bytesValue !== undefined) { + writer.uint32(58).bytes(message.bytesValue); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Literal { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseLiteral(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.nullValue = (reader.int32() as any); + break; + case 2: + message.boolValue = reader.bool(); + break; + case 3: + message.int64Value = reader.int64(); + break; + case 4: + message.uint64Value = reader.uint64(); + break; + case 5: + message.doubleValue = reader.double(); + break; + case 6: + message.stringValue = reader.string(); + break; + case 7: + message.bytesValue = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Literal { + const obj = createBaseLiteral(); + if (isSet(object.nullValue)) obj.nullValue = nullValueFromJSON(object.nullValue); + if (isSet(object.boolValue)) obj.boolValue = Boolean(object.boolValue); + if (isSet(object.int64Value)) obj.int64Value = BigInt(object.int64Value.toString()); + if (isSet(object.uint64Value)) obj.uint64Value = BigInt(object.uint64Value.toString()); + if (isSet(object.doubleValue)) obj.doubleValue = Number(object.doubleValue); + if (isSet(object.stringValue)) obj.stringValue = String(object.stringValue); + if (isSet(object.bytesValue)) obj.bytesValue = bytesFromBase64(object.bytesValue); + return obj; + }, + toJSON(message: Literal): JsonSafe { + const obj: any = {}; + message.nullValue !== undefined && (obj.nullValue = nullValueToJSON(message.nullValue)); + message.boolValue !== undefined && (obj.boolValue = message.boolValue); + if (message.int64Value !== undefined) { + obj.int64Value = message.int64Value.toString(); + } + if (message.uint64Value !== undefined) { + obj.uint64Value = message.uint64Value.toString(); + } + message.doubleValue !== undefined && (obj.doubleValue = message.doubleValue); + message.stringValue !== undefined && (obj.stringValue = message.stringValue); + message.bytesValue !== undefined && (obj.bytesValue = message.bytesValue !== undefined ? base64FromBytes(message.bytesValue) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): Literal { + const message = createBaseLiteral(); + message.nullValue = object.nullValue ?? undefined; + message.boolValue = object.boolValue ?? undefined; + if (object.int64Value !== undefined && object.int64Value !== null) { + message.int64Value = BigInt(object.int64Value.toString()); + } + if (object.uint64Value !== undefined && object.uint64Value !== null) { + message.uint64Value = BigInt(object.uint64Value.toString()); + } + message.doubleValue = object.doubleValue ?? undefined; + message.stringValue = object.stringValue ?? undefined; + message.bytesValue = object.bytesValue ?? undefined; + return message; + }, + fromSDK(object: LiteralSDKType): Literal { + return { + nullValue: isSet(object.null_value) ? nullValueFromJSON(object.null_value) : undefined, + boolValue: object?.bool_value, + int64Value: object?.int64_value, + uint64Value: object?.uint64_value, + doubleValue: object?.double_value, + stringValue: object?.string_value, + bytesValue: object?.bytes_value + }; + }, + fromSDKJSON(object: any): LiteralSDKType { + return { + null_value: isSet(object.null_value) ? nullValueFromJSON(object.null_value) : undefined, + bool_value: isSet(object.bool_value) ? Boolean(object.bool_value) : undefined, + int64_value: isSet(object.int64_value) ? BigInt(object.int64_value.toString()) : undefined, + uint64_value: isSet(object.uint64_value) ? BigInt(object.uint64_value.toString()) : undefined, + double_value: isSet(object.double_value) ? Number(object.double_value) : undefined, + string_value: isSet(object.string_value) ? String(object.string_value) : undefined, + bytes_value: isSet(object.bytes_value) ? bytesFromBase64(object.bytes_value) : undefined + }; + }, + toSDK(message: Literal): LiteralSDKType { + const obj: any = {}; + message.nullValue !== undefined && (obj.null_value = nullValueToJSON(message.nullValue)); + obj.bool_value = message.boolValue; + obj.int64_value = message.int64Value; + obj.uint64_value = message.uint64Value; + obj.double_value = message.doubleValue; + obj.string_value = message.stringValue; + obj.bytes_value = message.bytesValue; + return obj; + }, + fromAmino(object: LiteralAmino): Literal { + const message = createBaseLiteral(); + if (object.null_value !== undefined && object.null_value !== null) { + message.nullValue = object.null_value; + } + if (object.bool_value !== undefined && object.bool_value !== null) { + message.boolValue = object.bool_value; + } + if (object.int64_value !== undefined && object.int64_value !== null) { + message.int64Value = BigInt(object.int64_value); + } + if (object.uint64_value !== undefined && object.uint64_value !== null) { + message.uint64Value = BigInt(object.uint64_value); + } + if (object.double_value !== undefined && object.double_value !== null) { + message.doubleValue = object.double_value; + } + if (object.string_value !== undefined && object.string_value !== null) { + message.stringValue = object.string_value; + } + if (object.bytes_value !== undefined && object.bytes_value !== null) { + message.bytesValue = bytesFromBase64(object.bytes_value); + } + return message; + }, + toAmino(message: Literal): LiteralAmino { + const obj: any = {}; + obj.null_value = message.nullValue === null ? undefined : message.nullValue; + obj.bool_value = message.boolValue === null ? undefined : message.boolValue; + obj.int64_value = message.int64Value !== BigInt(0) ? message.int64Value?.toString() : undefined; + obj.uint64_value = message.uint64Value !== BigInt(0) ? message.uint64Value?.toString() : undefined; + obj.double_value = message.doubleValue === null ? undefined : message.doubleValue; + obj.string_value = message.stringValue === null ? undefined : message.stringValue; + obj.bytes_value = message.bytesValue ? base64FromBytes(message.bytesValue) : undefined; + return obj; + }, + fromAminoMsg(object: LiteralAminoMsg): Literal { + return Literal.fromAmino(object.value); + }, + fromProtoMsg(message: LiteralProtoMsg): Literal { + return Literal.decode(message.value); + }, + toProto(message: Literal): Uint8Array { + return Literal.encode(message).finish(); + }, + toProtoMsg(message: Literal): LiteralProtoMsg { + return { + typeUrl: "/google.api.expr.v1beta1.Literal", + value: Literal.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/api/expr/v1beta1/source.ts b/__fixtures__/v-next/outputicjsdeps/google/api/expr/v1beta1/source.ts new file mode 100644 index 0000000000..ec052b5a2f --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/api/expr/v1beta1/source.ts @@ -0,0 +1,508 @@ +import { BinaryReader, BinaryWriter } from "../../../../binary.js"; +import { isSet, DeepPartial, isObject } from "../../../../helpers.js"; +import { JsonSafe } from "../../../../json-safe.js"; +export const protobufPackage = "google.api.expr.v1beta1"; +export interface SourceInfo_PositionsEntry { + key: number; + value: number; +} +export interface SourceInfo_PositionsEntryProtoMsg { + typeUrl: string; + value: Uint8Array; +} +export interface SourceInfo_PositionsEntrySDKType { + key: number; + value: number; +} +/** Source information collected at parse time. */ +export interface SourceInfo { + /** + * The location name. All position information attached to an expression is + * relative to this location. + * + * The location could be a file, UI element, or similar. For example, + * `acme/app/AnvilPolicy.cel`. + */ + location: string; + /** + * Monotonically increasing list of character offsets where newlines appear. + * + * The line number of a given position is the index `i` where for a given + * `id` the `line_offsets[i] < id_positions[id] < line_offsets[i+1]`. The + * column may be derivd from `id_positions[id] - line_offsets[i]`. + */ + lineOffsets: number[]; + /** + * A map from the parse node id (e.g. `Expr.id`) to the character offset + * within source. + */ + positions: { + [key: number]: number; + }; +} +export interface SourceInfoProtoMsg { + typeUrl: "/google.api.expr.v1beta1.SourceInfo"; + value: Uint8Array; +} +/** Source information collected at parse time. */ +export interface SourceInfoSDKType { + location: string; + line_offsets: number[]; + positions: { + [key: number]: number; + }; +} +/** A specific position in source. */ +export interface SourcePosition { + /** The soucre location name (e.g. file name). */ + location: string; + /** The character offset. */ + offset: number; + /** + * The 1-based index of the starting line in the source text + * where the issue occurs, or 0 if unknown. + */ + line: number; + /** + * The 0-based index of the starting position within the line of source text + * where the issue occurs. Only meaningful if line is nonzer.. + */ + column: number; +} +export interface SourcePositionProtoMsg { + typeUrl: "/google.api.expr.v1beta1.SourcePosition"; + value: Uint8Array; +} +/** A specific position in source. */ +export interface SourcePositionSDKType { + location: string; + offset: number; + line: number; + column: number; +} +function createBaseSourceInfo_PositionsEntry(): SourceInfo_PositionsEntry { + return { + key: 0, + value: 0 + }; +} +export const SourceInfo_PositionsEntry = { + encode(message: SourceInfo_PositionsEntry, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.key !== undefined) { + writer.uint32(8).int32(message.key); + } + if (message.value !== undefined) { + writer.uint32(16).int32(message.value); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): SourceInfo_PositionsEntry { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseSourceInfo_PositionsEntry(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.int32(); + break; + case 2: + message.value = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): SourceInfo_PositionsEntry { + const obj = createBaseSourceInfo_PositionsEntry(); + if (isSet(object.key)) obj.key = Number(object.key); + if (isSet(object.value)) obj.value = Number(object.value); + return obj; + }, + toJSON(message: SourceInfo_PositionsEntry): JsonSafe { + const obj: any = {}; + message.key !== undefined && (obj.key = Math.round(message.key)); + message.value !== undefined && (obj.value = Math.round(message.value)); + return obj; + }, + fromPartial(object: DeepPartial): SourceInfo_PositionsEntry { + const message = createBaseSourceInfo_PositionsEntry(); + message.key = object.key ?? 0; + message.value = object.value ?? 0; + return message; + }, + fromSDK(object: SourceInfo_PositionsEntrySDKType): SourceInfo_PositionsEntry { + return { + key: object?.key, + value: object?.value + }; + }, + fromSDKJSON(object: any): SourceInfo_PositionsEntrySDKType { + return { + key: isSet(object.key) ? Number(object.key) : 0, + value: isSet(object.value) ? Number(object.value) : 0 + }; + }, + toSDK(message: SourceInfo_PositionsEntry): SourceInfo_PositionsEntrySDKType { + const obj: any = {}; + obj.key = message.key; + obj.value = message.value; + return obj; + }, + fromAmino(object: SourceInfo_PositionsEntryAmino): SourceInfo_PositionsEntry { + const message = createBaseSourceInfo_PositionsEntry(); + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } + if (object.value !== undefined && object.value !== null) { + message.value = object.value; + } + return message; + }, + toAmino(message: SourceInfo_PositionsEntry): SourceInfo_PositionsEntryAmino { + const obj: any = {}; + obj.key = message.key === 0 ? undefined : message.key; + obj.value = message.value === 0 ? undefined : message.value; + return obj; + }, + fromAminoMsg(object: SourceInfo_PositionsEntryAminoMsg): SourceInfo_PositionsEntry { + return SourceInfo_PositionsEntry.fromAmino(object.value); + }, + fromProtoMsg(message: SourceInfo_PositionsEntryProtoMsg): SourceInfo_PositionsEntry { + return SourceInfo_PositionsEntry.decode(message.value); + }, + toProto(message: SourceInfo_PositionsEntry): Uint8Array { + return SourceInfo_PositionsEntry.encode(message).finish(); + } +}; +function createBaseSourceInfo(): SourceInfo { + return { + location: "", + lineOffsets: [], + positions: {} + }; +} +export const SourceInfo = { + typeUrl: "/google.api.expr.v1beta1.SourceInfo", + encode(message: SourceInfo, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.location !== undefined) { + writer.uint32(18).string(message.location); + } + writer.uint32(26).fork(); + for (const v of message.lineOffsets) { + writer.int32(v); + } + writer.ldelim(); + Object.entries(message.positions).forEach(([key, value]) => { + SourceInfo_PositionsEntry.encode({ + key: (key as any), + value + }, writer.uint32(32).fork()).ldelim(); + }); + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): SourceInfo { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseSourceInfo(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.location = reader.string(); + break; + case 3: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.lineOffsets.push(reader.int32()); + } + } else { + message.lineOffsets.push(reader.int32()); + } + break; + case 4: + const entry4 = SourceInfo_PositionsEntry.decode(reader, reader.uint32()); + if (entry4.value !== undefined) { + message.positions[entry4.key] = entry4.value; + } + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): SourceInfo { + const obj = createBaseSourceInfo(); + if (isSet(object.location)) obj.location = String(object.location); + if (Array.isArray(object?.lineOffsets)) obj.lineOffsets = object.lineOffsets.map((e: any) => Number(e)); + if (isObject(object.positions)) obj.positions = Object.entries(object.positions).reduce<{ + [key: number]: number; + }>((acc, [key, value]) => { + acc[Number(key)] = Number(value); + return acc; + }, {}); + return obj; + }, + toJSON(message: SourceInfo): JsonSafe { + const obj: any = {}; + message.location !== undefined && (obj.location = message.location); + if (message.lineOffsets) { + obj.lineOffsets = message.lineOffsets.map(e => Math.round(e)); + } else { + obj.lineOffsets = []; + } + obj.positions = {}; + if (message.positions) { + Object.entries(message.positions).forEach(([k, v]) => { + obj.positions[k] = Math.round(v); + }); + } + return obj; + }, + fromPartial(object: DeepPartial): SourceInfo { + const message = createBaseSourceInfo(); + message.location = object.location ?? ""; + message.lineOffsets = object.lineOffsets?.map(e => e) || []; + message.positions = Object.entries(object.positions ?? {}).reduce<{ + [key: number]: number; + }>((acc, [key, value]) => { + if (value !== undefined) { + acc[Number(key)] = Number(value); + } + return acc; + }, {}); + return message; + }, + fromSDK(object: SourceInfoSDKType): SourceInfo { + return { + location: object?.location, + lineOffsets: Array.isArray(object?.line_offsets) ? object.line_offsets.map((e: any) => e) : [], + positions: isObject(object.positions) ? Object.entries(object.positions).reduce<{ + [key: number]: number; + }>((acc, [key, value]) => { + acc[Number(key)] = Number(value); + return acc; + }, {}) : {} + }; + }, + fromSDKJSON(object: any): SourceInfoSDKType { + return { + location: isSet(object.location) ? String(object.location) : "", + line_offsets: Array.isArray(object?.line_offsets) ? object.line_offsets.map((e: any) => Number(e)) : [], + positions: isObject(object.positions) ? Object.entries(object.positions).reduce<{ + [key: number]: number; + }>((acc, [key, value]) => { + acc[Number(key)] = Number(value); + return acc; + }, {}) : {} + }; + }, + toSDK(message: SourceInfo): SourceInfoSDKType { + const obj: any = {}; + obj.location = message.location; + if (message.lineOffsets) { + obj.line_offsets = message.lineOffsets.map(e => e); + } else { + obj.line_offsets = []; + } + obj.positions = {}; + if (message.positions) { + Object.entries(message.positions).forEach(([k, v]) => { + obj.positions[k] = Math.round(v); + }); + } + return obj; + }, + fromAmino(object: SourceInfoAmino): SourceInfo { + const message = createBaseSourceInfo(); + if (object.location !== undefined && object.location !== null) { + message.location = object.location; + } + message.lineOffsets = object.line_offsets?.map(e => e) || []; + message.positions = Object.entries(object.positions ?? {}).reduce<{ + [key: number]: number; + }>((acc, [key, value]) => { + if (value !== undefined) { + acc[Number(key)] = Number(value); + } + return acc; + }, {}); + return message; + }, + toAmino(message: SourceInfo): SourceInfoAmino { + const obj: any = {}; + obj.location = message.location === "" ? undefined : message.location; + if (message.lineOffsets) { + obj.line_offsets = message.lineOffsets.map(e => e); + } else { + obj.line_offsets = message.lineOffsets; + } + obj.positions = {}; + if (message.positions) { + Object.entries(message.positions).forEach(([k, v]) => { + obj.positions[k] = Math.round(v); + }); + } + return obj; + }, + fromAminoMsg(object: SourceInfoAminoMsg): SourceInfo { + return SourceInfo.fromAmino(object.value); + }, + fromProtoMsg(message: SourceInfoProtoMsg): SourceInfo { + return SourceInfo.decode(message.value); + }, + toProto(message: SourceInfo): Uint8Array { + return SourceInfo.encode(message).finish(); + }, + toProtoMsg(message: SourceInfo): SourceInfoProtoMsg { + return { + typeUrl: "/google.api.expr.v1beta1.SourceInfo", + value: SourceInfo.encode(message).finish() + }; + } +}; +function createBaseSourcePosition(): SourcePosition { + return { + location: "", + offset: 0, + line: 0, + column: 0 + }; +} +export const SourcePosition = { + typeUrl: "/google.api.expr.v1beta1.SourcePosition", + encode(message: SourcePosition, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.location !== undefined) { + writer.uint32(10).string(message.location); + } + if (message.offset !== undefined) { + writer.uint32(16).int32(message.offset); + } + if (message.line !== undefined) { + writer.uint32(24).int32(message.line); + } + if (message.column !== undefined) { + writer.uint32(32).int32(message.column); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): SourcePosition { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseSourcePosition(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.location = reader.string(); + break; + case 2: + message.offset = reader.int32(); + break; + case 3: + message.line = reader.int32(); + break; + case 4: + message.column = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): SourcePosition { + const obj = createBaseSourcePosition(); + if (isSet(object.location)) obj.location = String(object.location); + if (isSet(object.offset)) obj.offset = Number(object.offset); + if (isSet(object.line)) obj.line = Number(object.line); + if (isSet(object.column)) obj.column = Number(object.column); + return obj; + }, + toJSON(message: SourcePosition): JsonSafe { + const obj: any = {}; + message.location !== undefined && (obj.location = message.location); + message.offset !== undefined && (obj.offset = Math.round(message.offset)); + message.line !== undefined && (obj.line = Math.round(message.line)); + message.column !== undefined && (obj.column = Math.round(message.column)); + return obj; + }, + fromPartial(object: DeepPartial): SourcePosition { + const message = createBaseSourcePosition(); + message.location = object.location ?? ""; + message.offset = object.offset ?? 0; + message.line = object.line ?? 0; + message.column = object.column ?? 0; + return message; + }, + fromSDK(object: SourcePositionSDKType): SourcePosition { + return { + location: object?.location, + offset: object?.offset, + line: object?.line, + column: object?.column + }; + }, + fromSDKJSON(object: any): SourcePositionSDKType { + return { + location: isSet(object.location) ? String(object.location) : "", + offset: isSet(object.offset) ? Number(object.offset) : 0, + line: isSet(object.line) ? Number(object.line) : 0, + column: isSet(object.column) ? Number(object.column) : 0 + }; + }, + toSDK(message: SourcePosition): SourcePositionSDKType { + const obj: any = {}; + obj.location = message.location; + obj.offset = message.offset; + obj.line = message.line; + obj.column = message.column; + return obj; + }, + fromAmino(object: SourcePositionAmino): SourcePosition { + const message = createBaseSourcePosition(); + if (object.location !== undefined && object.location !== null) { + message.location = object.location; + } + if (object.offset !== undefined && object.offset !== null) { + message.offset = object.offset; + } + if (object.line !== undefined && object.line !== null) { + message.line = object.line; + } + if (object.column !== undefined && object.column !== null) { + message.column = object.column; + } + return message; + }, + toAmino(message: SourcePosition): SourcePositionAmino { + const obj: any = {}; + obj.location = message.location === "" ? undefined : message.location; + obj.offset = message.offset === 0 ? undefined : message.offset; + obj.line = message.line === 0 ? undefined : message.line; + obj.column = message.column === 0 ? undefined : message.column; + return obj; + }, + fromAminoMsg(object: SourcePositionAminoMsg): SourcePosition { + return SourcePosition.fromAmino(object.value); + }, + fromProtoMsg(message: SourcePositionProtoMsg): SourcePosition { + return SourcePosition.decode(message.value); + }, + toProto(message: SourcePosition): Uint8Array { + return SourcePosition.encode(message).finish(); + }, + toProtoMsg(message: SourcePosition): SourcePositionProtoMsg { + return { + typeUrl: "/google.api.expr.v1beta1.SourcePosition", + value: SourcePosition.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/api/expr/v1beta1/value.ts b/__fixtures__/v-next/outputicjsdeps/google/api/expr/v1beta1/value.ts new file mode 100644 index 0000000000..4eaa31c41e --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/api/expr/v1beta1/value.ts @@ -0,0 +1,851 @@ +import { NullValue, NullValueSDKType, nullValueFromJSON, nullValueToJSON } from "../../../protobuf/struct.js"; +import { Any, AnySDKType } from "../../../protobuf/any.js"; +import { BinaryReader, BinaryWriter } from "../../../../binary.js"; +import { isSet, bytesFromBase64, base64FromBytes, DeepPartial } from "../../../../helpers.js"; +import { JsonSafe } from "../../../../json-safe.js"; +export const protobufPackage = "google.api.expr.v1beta1"; +/** + * Represents a CEL value. + * + * This is similar to `google.protobuf.Value`, but can represent CEL's full + * range of values. + */ +export interface Value { + /** Null value. */ + nullValue?: NullValue; + /** Boolean value. */ + boolValue?: boolean; + /** Signed integer value. */ + int64Value?: bigint; + /** Unsigned integer value. */ + uint64Value?: bigint; + /** Floating point value. */ + doubleValue?: number; + /** UTF-8 string value. */ + stringValue?: string; + /** Byte string value. */ + bytesValue?: Uint8Array; + /** An enum value. */ + enumValue?: EnumValue; + /** The proto message backing an object value. */ + objectValue?: Any; + /** Map value. */ + mapValue?: MapValue; + /** List value. */ + listValue?: ListValue; + /** A Type value represented by the fully qualified name of the type. */ + typeValue?: string; +} +export interface ValueProtoMsg { + typeUrl: "/google.api.expr.v1beta1.Value"; + value: Uint8Array; +} +/** + * Represents a CEL value. + * + * This is similar to `google.protobuf.Value`, but can represent CEL's full + * range of values. + */ +export interface ValueSDKType { + null_value?: NullValue; + bool_value?: boolean; + int64_value?: bigint; + uint64_value?: bigint; + double_value?: number; + string_value?: string; + bytes_value?: Uint8Array; + enum_value?: EnumValueSDKType; + object_value?: AnySDKType; + map_value?: MapValueSDKType; + list_value?: ListValueSDKType; + type_value?: string; +} +/** An enum value. */ +export interface EnumValue { + /** The fully qualified name of the enum type. */ + type: string; + /** The value of the enum. */ + value: number; +} +export interface EnumValueProtoMsg { + typeUrl: "/google.api.expr.v1beta1.EnumValue"; + value: Uint8Array; +} +/** An enum value. */ +export interface EnumValueSDKType { + type: string; + value: number; +} +/** + * A list. + * + * Wrapped in a message so 'not set' and empty can be differentiated, which is + * required for use in a 'oneof'. + */ +export interface ListValue { + /** The ordered values in the list. */ + values: Value[]; +} +export interface ListValueProtoMsg { + typeUrl: "/google.api.expr.v1beta1.ListValue"; + value: Uint8Array; +} +/** + * A list. + * + * Wrapped in a message so 'not set' and empty can be differentiated, which is + * required for use in a 'oneof'. + */ +export interface ListValueSDKType { + values: ValueSDKType[]; +} +/** + * A map. + * + * Wrapped in a message so 'not set' and empty can be differentiated, which is + * required for use in a 'oneof'. + */ +export interface MapValue { + /** + * The set of map entries. + * + * CEL has fewer restrictions on keys, so a protobuf map represenation + * cannot be used. + */ + entries: MapValue_Entry[]; +} +export interface MapValueProtoMsg { + typeUrl: "/google.api.expr.v1beta1.MapValue"; + value: Uint8Array; +} +/** + * A map. + * + * Wrapped in a message so 'not set' and empty can be differentiated, which is + * required for use in a 'oneof'. + */ +export interface MapValueSDKType { + entries: MapValue_EntrySDKType[]; +} +/** An entry in the map. */ +export interface MapValue_Entry { + /** + * The key. + * + * Must be unique with in the map. + * Currently only boolean, int, uint, and string values can be keys. + */ + key?: Value; + /** The value. */ + value?: Value; +} +export interface MapValue_EntryProtoMsg { + typeUrl: "/google.api.expr.v1beta1.Entry"; + value: Uint8Array; +} +/** An entry in the map. */ +export interface MapValue_EntrySDKType { + key?: ValueSDKType; + value?: ValueSDKType; +} +function createBaseValue(): Value { + return { + nullValue: undefined, + boolValue: undefined, + int64Value: undefined, + uint64Value: undefined, + doubleValue: undefined, + stringValue: undefined, + bytesValue: undefined, + enumValue: undefined, + objectValue: undefined, + mapValue: undefined, + listValue: undefined, + typeValue: undefined + }; +} +export const Value = { + typeUrl: "/google.api.expr.v1beta1.Value", + encode(message: Value, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.nullValue !== undefined) { + writer.uint32(8).int32(message.nullValue); + } + if (message.boolValue !== undefined) { + writer.uint32(16).bool(message.boolValue); + } + if (message.int64Value !== undefined) { + writer.uint32(24).int64(message.int64Value); + } + if (message.uint64Value !== undefined) { + writer.uint32(32).uint64(message.uint64Value); + } + if (message.doubleValue !== undefined) { + writer.uint32(41).double(message.doubleValue); + } + if (message.stringValue !== undefined) { + writer.uint32(50).string(message.stringValue); + } + if (message.bytesValue !== undefined) { + writer.uint32(58).bytes(message.bytesValue); + } + if (message.enumValue !== undefined) { + EnumValue.encode(message.enumValue, writer.uint32(74).fork()).ldelim(); + } + if (message.objectValue !== undefined) { + Any.encode(message.objectValue, writer.uint32(82).fork()).ldelim(); + } + if (message.mapValue !== undefined) { + MapValue.encode(message.mapValue, writer.uint32(90).fork()).ldelim(); + } + if (message.listValue !== undefined) { + ListValue.encode(message.listValue, writer.uint32(98).fork()).ldelim(); + } + if (message.typeValue !== undefined) { + writer.uint32(122).string(message.typeValue); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Value { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseValue(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.nullValue = (reader.int32() as any); + break; + case 2: + message.boolValue = reader.bool(); + break; + case 3: + message.int64Value = reader.int64(); + break; + case 4: + message.uint64Value = reader.uint64(); + break; + case 5: + message.doubleValue = reader.double(); + break; + case 6: + message.stringValue = reader.string(); + break; + case 7: + message.bytesValue = reader.bytes(); + break; + case 9: + message.enumValue = EnumValue.decode(reader, reader.uint32()); + break; + case 10: + message.objectValue = Any.decode(reader, reader.uint32()); + break; + case 11: + message.mapValue = MapValue.decode(reader, reader.uint32()); + break; + case 12: + message.listValue = ListValue.decode(reader, reader.uint32()); + break; + case 15: + message.typeValue = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Value { + const obj = createBaseValue(); + if (isSet(object.nullValue)) obj.nullValue = nullValueFromJSON(object.nullValue); + if (isSet(object.boolValue)) obj.boolValue = Boolean(object.boolValue); + if (isSet(object.int64Value)) obj.int64Value = BigInt(object.int64Value.toString()); + if (isSet(object.uint64Value)) obj.uint64Value = BigInt(object.uint64Value.toString()); + if (isSet(object.doubleValue)) obj.doubleValue = Number(object.doubleValue); + if (isSet(object.stringValue)) obj.stringValue = String(object.stringValue); + if (isSet(object.bytesValue)) obj.bytesValue = bytesFromBase64(object.bytesValue); + if (isSet(object.enumValue)) obj.enumValue = EnumValue.fromJSON(object.enumValue); + if (isSet(object.objectValue)) obj.objectValue = Any.fromJSON(object.objectValue); + if (isSet(object.mapValue)) obj.mapValue = MapValue.fromJSON(object.mapValue); + if (isSet(object.listValue)) obj.listValue = ListValue.fromJSON(object.listValue); + if (isSet(object.typeValue)) obj.typeValue = String(object.typeValue); + return obj; + }, + toJSON(message: Value): JsonSafe { + const obj: any = {}; + message.nullValue !== undefined && (obj.nullValue = nullValueToJSON(message.nullValue)); + message.boolValue !== undefined && (obj.boolValue = message.boolValue); + if (message.int64Value !== undefined) { + obj.int64Value = message.int64Value.toString(); + } + if (message.uint64Value !== undefined) { + obj.uint64Value = message.uint64Value.toString(); + } + message.doubleValue !== undefined && (obj.doubleValue = message.doubleValue); + message.stringValue !== undefined && (obj.stringValue = message.stringValue); + message.bytesValue !== undefined && (obj.bytesValue = message.bytesValue !== undefined ? base64FromBytes(message.bytesValue) : undefined); + message.enumValue !== undefined && (obj.enumValue = message.enumValue ? EnumValue.toJSON(message.enumValue) : undefined); + message.objectValue !== undefined && (obj.objectValue = message.objectValue ? Any.toJSON(message.objectValue) : undefined); + message.mapValue !== undefined && (obj.mapValue = message.mapValue ? MapValue.toJSON(message.mapValue) : undefined); + message.listValue !== undefined && (obj.listValue = message.listValue ? ListValue.toJSON(message.listValue) : undefined); + message.typeValue !== undefined && (obj.typeValue = message.typeValue); + return obj; + }, + fromPartial(object: DeepPartial): Value { + const message = createBaseValue(); + message.nullValue = object.nullValue ?? undefined; + message.boolValue = object.boolValue ?? undefined; + if (object.int64Value !== undefined && object.int64Value !== null) { + message.int64Value = BigInt(object.int64Value.toString()); + } + if (object.uint64Value !== undefined && object.uint64Value !== null) { + message.uint64Value = BigInt(object.uint64Value.toString()); + } + message.doubleValue = object.doubleValue ?? undefined; + message.stringValue = object.stringValue ?? undefined; + message.bytesValue = object.bytesValue ?? undefined; + if (object.enumValue !== undefined && object.enumValue !== null) { + message.enumValue = EnumValue.fromPartial(object.enumValue); + } + if (object.objectValue !== undefined && object.objectValue !== null) { + message.objectValue = Any.fromPartial(object.objectValue); + } + if (object.mapValue !== undefined && object.mapValue !== null) { + message.mapValue = MapValue.fromPartial(object.mapValue); + } + if (object.listValue !== undefined && object.listValue !== null) { + message.listValue = ListValue.fromPartial(object.listValue); + } + message.typeValue = object.typeValue ?? undefined; + return message; + }, + fromSDK(object: ValueSDKType): Value { + return { + nullValue: isSet(object.null_value) ? nullValueFromJSON(object.null_value) : undefined, + boolValue: object?.bool_value, + int64Value: object?.int64_value, + uint64Value: object?.uint64_value, + doubleValue: object?.double_value, + stringValue: object?.string_value, + bytesValue: object?.bytes_value, + enumValue: object.enum_value ? EnumValue.fromSDK(object.enum_value) : undefined, + objectValue: object.object_value ? Any.fromSDK(object.object_value) : undefined, + mapValue: object.map_value ? MapValue.fromSDK(object.map_value) : undefined, + listValue: object.list_value ? ListValue.fromSDK(object.list_value) : undefined, + typeValue: object?.type_value + }; + }, + fromSDKJSON(object: any): ValueSDKType { + return { + null_value: isSet(object.null_value) ? nullValueFromJSON(object.null_value) : undefined, + bool_value: isSet(object.bool_value) ? Boolean(object.bool_value) : undefined, + int64_value: isSet(object.int64_value) ? BigInt(object.int64_value.toString()) : undefined, + uint64_value: isSet(object.uint64_value) ? BigInt(object.uint64_value.toString()) : undefined, + double_value: isSet(object.double_value) ? Number(object.double_value) : undefined, + string_value: isSet(object.string_value) ? String(object.string_value) : undefined, + bytes_value: isSet(object.bytes_value) ? bytesFromBase64(object.bytes_value) : undefined, + enum_value: isSet(object.enum_value) ? EnumValue.fromSDKJSON(object.enum_value) : undefined, + object_value: isSet(object.object_value) ? Any.fromSDKJSON(object.object_value) : undefined, + map_value: isSet(object.map_value) ? MapValue.fromSDKJSON(object.map_value) : undefined, + list_value: isSet(object.list_value) ? ListValue.fromSDKJSON(object.list_value) : undefined, + type_value: isSet(object.type_value) ? String(object.type_value) : undefined + }; + }, + toSDK(message: Value): ValueSDKType { + const obj: any = {}; + message.nullValue !== undefined && (obj.null_value = nullValueToJSON(message.nullValue)); + obj.bool_value = message.boolValue; + obj.int64_value = message.int64Value; + obj.uint64_value = message.uint64Value; + obj.double_value = message.doubleValue; + obj.string_value = message.stringValue; + obj.bytes_value = message.bytesValue; + message.enumValue !== undefined && (obj.enum_value = message.enumValue ? EnumValue.toSDK(message.enumValue) : undefined); + message.objectValue !== undefined && (obj.object_value = message.objectValue ? Any.toSDK(message.objectValue) : undefined); + message.mapValue !== undefined && (obj.map_value = message.mapValue ? MapValue.toSDK(message.mapValue) : undefined); + message.listValue !== undefined && (obj.list_value = message.listValue ? ListValue.toSDK(message.listValue) : undefined); + obj.type_value = message.typeValue; + return obj; + }, + fromAmino(object: ValueAmino): Value { + const message = createBaseValue(); + if (object.null_value !== undefined && object.null_value !== null) { + message.nullValue = object.null_value; + } + if (object.bool_value !== undefined && object.bool_value !== null) { + message.boolValue = object.bool_value; + } + if (object.int64_value !== undefined && object.int64_value !== null) { + message.int64Value = BigInt(object.int64_value); + } + if (object.uint64_value !== undefined && object.uint64_value !== null) { + message.uint64Value = BigInt(object.uint64_value); + } + if (object.double_value !== undefined && object.double_value !== null) { + message.doubleValue = object.double_value; + } + if (object.string_value !== undefined && object.string_value !== null) { + message.stringValue = object.string_value; + } + if (object.bytes_value !== undefined && object.bytes_value !== null) { + message.bytesValue = bytesFromBase64(object.bytes_value); + } + if (object.enum_value !== undefined && object.enum_value !== null) { + message.enumValue = EnumValue.fromAmino(object.enum_value); + } + if (object.object_value !== undefined && object.object_value !== null) { + message.objectValue = Any.fromAmino(object.object_value); + } + if (object.map_value !== undefined && object.map_value !== null) { + message.mapValue = MapValue.fromAmino(object.map_value); + } + if (object.list_value !== undefined && object.list_value !== null) { + message.listValue = ListValue.fromAmino(object.list_value); + } + if (object.type_value !== undefined && object.type_value !== null) { + message.typeValue = object.type_value; + } + return message; + }, + toAmino(message: Value): ValueAmino { + const obj: any = {}; + obj.null_value = message.nullValue === null ? undefined : message.nullValue; + obj.bool_value = message.boolValue === null ? undefined : message.boolValue; + obj.int64_value = message.int64Value !== BigInt(0) ? message.int64Value?.toString() : undefined; + obj.uint64_value = message.uint64Value !== BigInt(0) ? message.uint64Value?.toString() : undefined; + obj.double_value = message.doubleValue === null ? undefined : message.doubleValue; + obj.string_value = message.stringValue === null ? undefined : message.stringValue; + obj.bytes_value = message.bytesValue ? base64FromBytes(message.bytesValue) : undefined; + obj.enum_value = message.enumValue ? EnumValue.toAmino(message.enumValue) : undefined; + obj.object_value = message.objectValue ? Any.toAmino(message.objectValue) : undefined; + obj.map_value = message.mapValue ? MapValue.toAmino(message.mapValue) : undefined; + obj.list_value = message.listValue ? ListValue.toAmino(message.listValue) : undefined; + obj.type_value = message.typeValue === null ? undefined : message.typeValue; + return obj; + }, + fromAminoMsg(object: ValueAminoMsg): Value { + return Value.fromAmino(object.value); + }, + fromProtoMsg(message: ValueProtoMsg): Value { + return Value.decode(message.value); + }, + toProto(message: Value): Uint8Array { + return Value.encode(message).finish(); + }, + toProtoMsg(message: Value): ValueProtoMsg { + return { + typeUrl: "/google.api.expr.v1beta1.Value", + value: Value.encode(message).finish() + }; + } +}; +function createBaseEnumValue(): EnumValue { + return { + type: "", + value: 0 + }; +} +export const EnumValue = { + typeUrl: "/google.api.expr.v1beta1.EnumValue", + encode(message: EnumValue, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.type !== undefined) { + writer.uint32(10).string(message.type); + } + if (message.value !== undefined) { + writer.uint32(16).int32(message.value); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): EnumValue { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseEnumValue(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.type = reader.string(); + break; + case 2: + message.value = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): EnumValue { + const obj = createBaseEnumValue(); + if (isSet(object.type)) obj.type = String(object.type); + if (isSet(object.value)) obj.value = Number(object.value); + return obj; + }, + toJSON(message: EnumValue): JsonSafe { + const obj: any = {}; + message.type !== undefined && (obj.type = message.type); + message.value !== undefined && (obj.value = Math.round(message.value)); + return obj; + }, + fromPartial(object: DeepPartial): EnumValue { + const message = createBaseEnumValue(); + message.type = object.type ?? ""; + message.value = object.value ?? 0; + return message; + }, + fromSDK(object: EnumValueSDKType): EnumValue { + return { + type: object?.type, + value: object?.value + }; + }, + fromSDKJSON(object: any): EnumValueSDKType { + return { + type: isSet(object.type) ? String(object.type) : "", + value: isSet(object.value) ? Number(object.value) : 0 + }; + }, + toSDK(message: EnumValue): EnumValueSDKType { + const obj: any = {}; + obj.type = message.type; + obj.value = message.value; + return obj; + }, + fromAmino(object: EnumValueAmino): EnumValue { + const message = createBaseEnumValue(); + if (object.type !== undefined && object.type !== null) { + message.type = object.type; + } + if (object.value !== undefined && object.value !== null) { + message.value = object.value; + } + return message; + }, + toAmino(message: EnumValue): EnumValueAmino { + const obj: any = {}; + obj.type = message.type === "" ? undefined : message.type; + obj.value = message.value === 0 ? undefined : message.value; + return obj; + }, + fromAminoMsg(object: EnumValueAminoMsg): EnumValue { + return EnumValue.fromAmino(object.value); + }, + fromProtoMsg(message: EnumValueProtoMsg): EnumValue { + return EnumValue.decode(message.value); + }, + toProto(message: EnumValue): Uint8Array { + return EnumValue.encode(message).finish(); + }, + toProtoMsg(message: EnumValue): EnumValueProtoMsg { + return { + typeUrl: "/google.api.expr.v1beta1.EnumValue", + value: EnumValue.encode(message).finish() + }; + } +}; +function createBaseListValue(): ListValue { + return { + values: [] + }; +} +export const ListValue = { + typeUrl: "/google.api.expr.v1beta1.ListValue", + encode(message: ListValue, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.values) { + Value.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ListValue { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseListValue(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.values.push(Value.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ListValue { + const obj = createBaseListValue(); + if (Array.isArray(object?.values)) obj.values = object.values.map((e: any) => Value.fromJSON(e)); + return obj; + }, + toJSON(message: ListValue): JsonSafe { + const obj: any = {}; + if (message.values) { + obj.values = message.values.map(e => e ? Value.toJSON(e) : undefined); + } else { + obj.values = []; + } + return obj; + }, + fromPartial(object: DeepPartial): ListValue { + const message = createBaseListValue(); + message.values = object.values?.map(e => Value.fromPartial(e)) || []; + return message; + }, + fromSDK(object: ListValueSDKType): ListValue { + return { + values: Array.isArray(object?.values) ? object.values.map((e: any) => Value.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): ListValueSDKType { + return { + values: Array.isArray(object?.values) ? object.values.map((e: any) => Value.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: ListValue): ListValueSDKType { + const obj: any = {}; + if (message.values) { + obj.values = message.values.map(e => e ? Value.toSDK(e) : undefined); + } else { + obj.values = []; + } + return obj; + }, + fromAmino(object: ListValueAmino): ListValue { + const message = createBaseListValue(); + message.values = object.values?.map(e => Value.fromAmino(e)) || []; + return message; + }, + toAmino(message: ListValue): ListValueAmino { + const obj: any = {}; + if (message.values) { + obj.values = message.values.map(e => e ? Value.toAmino(e) : undefined); + } else { + obj.values = message.values; + } + return obj; + }, + fromAminoMsg(object: ListValueAminoMsg): ListValue { + return ListValue.fromAmino(object.value); + }, + fromProtoMsg(message: ListValueProtoMsg): ListValue { + return ListValue.decode(message.value); + }, + toProto(message: ListValue): Uint8Array { + return ListValue.encode(message).finish(); + }, + toProtoMsg(message: ListValue): ListValueProtoMsg { + return { + typeUrl: "/google.api.expr.v1beta1.ListValue", + value: ListValue.encode(message).finish() + }; + } +}; +function createBaseMapValue(): MapValue { + return { + entries: [] + }; +} +export const MapValue = { + typeUrl: "/google.api.expr.v1beta1.MapValue", + encode(message: MapValue, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.entries) { + MapValue_Entry.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MapValue { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMapValue(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.entries.push(MapValue_Entry.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MapValue { + const obj = createBaseMapValue(); + if (Array.isArray(object?.entries)) obj.entries = object.entries.map((e: any) => MapValue_Entry.fromJSON(e)); + return obj; + }, + toJSON(message: MapValue): JsonSafe { + const obj: any = {}; + if (message.entries) { + obj.entries = message.entries.map(e => e ? MapValue_Entry.toJSON(e) : undefined); + } else { + obj.entries = []; + } + return obj; + }, + fromPartial(object: DeepPartial): MapValue { + const message = createBaseMapValue(); + message.entries = object.entries?.map(e => MapValue_Entry.fromPartial(e)) || []; + return message; + }, + fromSDK(object: MapValueSDKType): MapValue { + return { + entries: Array.isArray(object?.entries) ? object.entries.map((e: any) => MapValue_Entry.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): MapValueSDKType { + return { + entries: Array.isArray(object?.entries) ? object.entries.map((e: any) => MapValue_Entry.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: MapValue): MapValueSDKType { + const obj: any = {}; + if (message.entries) { + obj.entries = message.entries.map(e => e ? MapValue_Entry.toSDK(e) : undefined); + } else { + obj.entries = []; + } + return obj; + }, + fromAmino(object: MapValueAmino): MapValue { + const message = createBaseMapValue(); + message.entries = object.entries?.map(e => MapValue_Entry.fromAmino(e)) || []; + return message; + }, + toAmino(message: MapValue): MapValueAmino { + const obj: any = {}; + if (message.entries) { + obj.entries = message.entries.map(e => e ? MapValue_Entry.toAmino(e) : undefined); + } else { + obj.entries = message.entries; + } + return obj; + }, + fromAminoMsg(object: MapValueAminoMsg): MapValue { + return MapValue.fromAmino(object.value); + }, + fromProtoMsg(message: MapValueProtoMsg): MapValue { + return MapValue.decode(message.value); + }, + toProto(message: MapValue): Uint8Array { + return MapValue.encode(message).finish(); + }, + toProtoMsg(message: MapValue): MapValueProtoMsg { + return { + typeUrl: "/google.api.expr.v1beta1.MapValue", + value: MapValue.encode(message).finish() + }; + } +}; +function createBaseMapValue_Entry(): MapValue_Entry { + return { + key: undefined, + value: undefined + }; +} +export const MapValue_Entry = { + typeUrl: "/google.api.expr.v1beta1.Entry", + encode(message: MapValue_Entry, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.key !== undefined) { + Value.encode(message.key, writer.uint32(10).fork()).ldelim(); + } + if (message.value !== undefined) { + Value.encode(message.value, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MapValue_Entry { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMapValue_Entry(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = Value.decode(reader, reader.uint32()); + break; + case 2: + message.value = Value.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MapValue_Entry { + const obj = createBaseMapValue_Entry(); + if (isSet(object.key)) obj.key = Value.fromJSON(object.key); + if (isSet(object.value)) obj.value = Value.fromJSON(object.value); + return obj; + }, + toJSON(message: MapValue_Entry): JsonSafe { + const obj: any = {}; + message.key !== undefined && (obj.key = message.key ? Value.toJSON(message.key) : undefined); + message.value !== undefined && (obj.value = message.value ? Value.toJSON(message.value) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): MapValue_Entry { + const message = createBaseMapValue_Entry(); + if (object.key !== undefined && object.key !== null) { + message.key = Value.fromPartial(object.key); + } + if (object.value !== undefined && object.value !== null) { + message.value = Value.fromPartial(object.value); + } + return message; + }, + fromSDK(object: MapValue_EntrySDKType): MapValue_Entry { + return { + key: object.key ? Value.fromSDK(object.key) : undefined, + value: object.value ? Value.fromSDK(object.value) : undefined + }; + }, + fromSDKJSON(object: any): MapValue_EntrySDKType { + return { + key: isSet(object.key) ? Value.fromSDKJSON(object.key) : undefined, + value: isSet(object.value) ? Value.fromSDKJSON(object.value) : undefined + }; + }, + toSDK(message: MapValue_Entry): MapValue_EntrySDKType { + const obj: any = {}; + message.key !== undefined && (obj.key = message.key ? Value.toSDK(message.key) : undefined); + message.value !== undefined && (obj.value = message.value ? Value.toSDK(message.value) : undefined); + return obj; + }, + fromAmino(object: MapValue_EntryAmino): MapValue_Entry { + const message = createBaseMapValue_Entry(); + if (object.key !== undefined && object.key !== null) { + message.key = Value.fromAmino(object.key); + } + if (object.value !== undefined && object.value !== null) { + message.value = Value.fromAmino(object.value); + } + return message; + }, + toAmino(message: MapValue_Entry): MapValue_EntryAmino { + const obj: any = {}; + obj.key = message.key ? Value.toAmino(message.key) : undefined; + obj.value = message.value ? Value.toAmino(message.value) : undefined; + return obj; + }, + fromAminoMsg(object: MapValue_EntryAminoMsg): MapValue_Entry { + return MapValue_Entry.fromAmino(object.value); + }, + fromProtoMsg(message: MapValue_EntryProtoMsg): MapValue_Entry { + return MapValue_Entry.decode(message.value); + }, + toProto(message: MapValue_Entry): Uint8Array { + return MapValue_Entry.encode(message).finish(); + }, + toProtoMsg(message: MapValue_Entry): MapValue_EntryProtoMsg { + return { + typeUrl: "/google.api.expr.v1beta1.Entry", + value: MapValue_Entry.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/api/field_behavior.ts b/__fixtures__/v-next/outputicjsdeps/google/api/field_behavior.ts new file mode 100644 index 0000000000..15b1a8e1b6 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/api/field_behavior.ts @@ -0,0 +1,115 @@ +export const protobufPackage = "google.api"; +/** + * An indicator of the behavior of a given field (for example, that a field + * is required in requests, or given as output but ignored as input). + * This **does not** change the behavior in protocol buffers itself; it only + * denotes the behavior and may affect how API tooling handles the field. + * + * Note: This enum **may** receive new values in the future. + */ +export enum FieldBehavior { + /** FIELD_BEHAVIOR_UNSPECIFIED - Conventional default for enums. Do not use this. */ + FIELD_BEHAVIOR_UNSPECIFIED = 0, + /** + * OPTIONAL - Specifically denotes a field as optional. + * While all fields in protocol buffers are optional, this may be specified + * for emphasis if appropriate. + */ + OPTIONAL = 1, + /** + * REQUIRED - Denotes a field as required. + * This indicates that the field **must** be provided as part of the request, + * and failure to do so will cause an error (usually `INVALID_ARGUMENT`). + */ + REQUIRED = 2, + /** + * OUTPUT_ONLY - Denotes a field as output only. + * This indicates that the field is provided in responses, but including the + * field in a request does nothing (the server *must* ignore it and + * *must not* throw an error as a result of the field's presence). + */ + OUTPUT_ONLY = 3, + /** + * INPUT_ONLY - Denotes a field as input only. + * This indicates that the field is provided in requests, and the + * corresponding field is not included in output. + */ + INPUT_ONLY = 4, + /** + * IMMUTABLE - Denotes a field as immutable. + * This indicates that the field may be set once in a request to create a + * resource, but may not be changed thereafter. + */ + IMMUTABLE = 5, + /** + * UNORDERED_LIST - Denotes that a (repeated) field is an unordered list. + * This indicates that the service may provide the elements of the list + * in any arbitrary order, rather than the order the user originally + * provided. Additionally, the list's order may or may not be stable. + */ + UNORDERED_LIST = 6, + /** + * NON_EMPTY_DEFAULT - Denotes that this field returns a non-empty default value if not set. + * This indicates that if the user provides the empty value in a request, + * a non-empty value will be returned. The user will not be aware of what + * non-empty value to expect. + */ + NON_EMPTY_DEFAULT = 7, + UNRECOGNIZED = -1, +} +export const FieldBehaviorSDKType = FieldBehavior; +export function fieldBehaviorFromJSON(object: any): FieldBehavior { + switch (object) { + case 0: + case "FIELD_BEHAVIOR_UNSPECIFIED": + return FieldBehavior.FIELD_BEHAVIOR_UNSPECIFIED; + case 1: + case "OPTIONAL": + return FieldBehavior.OPTIONAL; + case 2: + case "REQUIRED": + return FieldBehavior.REQUIRED; + case 3: + case "OUTPUT_ONLY": + return FieldBehavior.OUTPUT_ONLY; + case 4: + case "INPUT_ONLY": + return FieldBehavior.INPUT_ONLY; + case 5: + case "IMMUTABLE": + return FieldBehavior.IMMUTABLE; + case 6: + case "UNORDERED_LIST": + return FieldBehavior.UNORDERED_LIST; + case 7: + case "NON_EMPTY_DEFAULT": + return FieldBehavior.NON_EMPTY_DEFAULT; + case -1: + case "UNRECOGNIZED": + default: + return FieldBehavior.UNRECOGNIZED; + } +} +export function fieldBehaviorToJSON(object: FieldBehavior): string { + switch (object) { + case FieldBehavior.FIELD_BEHAVIOR_UNSPECIFIED: + return "FIELD_BEHAVIOR_UNSPECIFIED"; + case FieldBehavior.OPTIONAL: + return "OPTIONAL"; + case FieldBehavior.REQUIRED: + return "REQUIRED"; + case FieldBehavior.OUTPUT_ONLY: + return "OUTPUT_ONLY"; + case FieldBehavior.INPUT_ONLY: + return "INPUT_ONLY"; + case FieldBehavior.IMMUTABLE: + return "IMMUTABLE"; + case FieldBehavior.UNORDERED_LIST: + return "UNORDERED_LIST"; + case FieldBehavior.NON_EMPTY_DEFAULT: + return "NON_EMPTY_DEFAULT"; + case FieldBehavior.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/api/http.ts b/__fixtures__/v-next/outputicjsdeps/google/api/http.ts new file mode 100644 index 0000000000..f964e4d912 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/api/http.ts @@ -0,0 +1,1138 @@ +import { BinaryReader, BinaryWriter } from "../../binary.js"; +import { isSet, DeepPartial } from "../../helpers.js"; +import { JsonSafe } from "../../json-safe.js"; +export const protobufPackage = "google.api"; +/** + * Defines the HTTP configuration for an API service. It contains a list of + * [HttpRule][google.api.HttpRule], each specifying the mapping of an RPC method + * to one or more HTTP REST API methods. + */ +export interface Http { + /** + * A list of HTTP configuration rules that apply to individual API methods. + * + * **NOTE:** All service configuration rules follow "last one wins" order. + */ + rules: HttpRule[]; + /** + * When set to true, URL path parameters will be fully URI-decoded except in + * cases of single segment matches in reserved expansion, where "%2F" will be + * left encoded. + * + * The default behavior is to not decode RFC 6570 reserved characters in multi + * segment matches. + */ + fullyDecodeReservedExpansion: boolean; +} +export interface HttpProtoMsg { + typeUrl: "/google.api.Http"; + value: Uint8Array; +} +/** + * Defines the HTTP configuration for an API service. It contains a list of + * [HttpRule][google.api.HttpRule], each specifying the mapping of an RPC method + * to one or more HTTP REST API methods. + */ +export interface HttpSDKType { + rules: HttpRuleSDKType[]; + fully_decode_reserved_expansion: boolean; +} +/** + * # gRPC Transcoding + * + * gRPC Transcoding is a feature for mapping between a gRPC method and one or + * more HTTP REST endpoints. It allows developers to build a single API service + * that supports both gRPC APIs and REST APIs. Many systems, including [Google + * APIs](https://github.com/googleapis/googleapis), + * [Cloud Endpoints](https://cloud.google.com/endpoints), [gRPC + * Gateway](https://github.com/grpc-ecosystem/grpc-gateway), + * and [Envoy](https://github.com/envoyproxy/envoy) proxy support this feature + * and use it for large scale production services. + * + * `HttpRule` defines the schema of the gRPC/REST mapping. The mapping specifies + * how different portions of the gRPC request message are mapped to the URL + * path, URL query parameters, and HTTP request body. It also controls how the + * gRPC response message is mapped to the HTTP response body. `HttpRule` is + * typically specified as an `google.api.http` annotation on the gRPC method. + * + * Each mapping specifies a URL path template and an HTTP method. The path + * template may refer to one or more fields in the gRPC request message, as long + * as each field is a non-repeated field with a primitive (non-message) type. + * The path template controls how fields of the request message are mapped to + * the URL path. + * + * Example: + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http) = { + * get: "/v1/{name=messages/*}" + * }; + * } + * } + * message GetMessageRequest { + * string name = 1; // Mapped to URL path. + * } + * message Message { + * string text = 1; // The resource content. + * } + * + * This enables an HTTP REST to gRPC mapping as below: + * + * HTTP | gRPC + * -----|----- + * `GET /v1/messages/123456` | `GetMessage(name: "messages/123456")` + * + * Any fields in the request message which are not bound by the path template + * automatically become HTTP query parameters if there is no HTTP request body. + * For example: + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http) = { + * get:"/v1/messages/{message_id}" + * }; + * } + * } + * message GetMessageRequest { + * message SubMessage { + * string subfield = 1; + * } + * string message_id = 1; // Mapped to URL path. + * int64 revision = 2; // Mapped to URL query parameter `revision`. + * SubMessage sub = 3; // Mapped to URL query parameter `sub.subfield`. + * } + * + * This enables a HTTP JSON to RPC mapping as below: + * + * HTTP | gRPC + * -----|----- + * `GET /v1/messages/123456?revision=2&sub.subfield=foo` | + * `GetMessage(message_id: "123456" revision: 2 sub: SubMessage(subfield: + * "foo"))` + * + * Note that fields which are mapped to URL query parameters must have a + * primitive type or a repeated primitive type or a non-repeated message type. + * In the case of a repeated type, the parameter can be repeated in the URL + * as `...?param=A¶m=B`. In the case of a message type, each field of the + * message is mapped to a separate parameter, such as + * `...?foo.a=A&foo.b=B&foo.c=C`. + * + * For HTTP methods that allow a request body, the `body` field + * specifies the mapping. Consider a REST update method on the + * message resource collection: + * + * service Messaging { + * rpc UpdateMessage(UpdateMessageRequest) returns (Message) { + * option (google.api.http) = { + * patch: "/v1/messages/{message_id}" + * body: "message" + * }; + * } + * } + * message UpdateMessageRequest { + * string message_id = 1; // mapped to the URL + * Message message = 2; // mapped to the body + * } + * + * The following HTTP JSON to RPC mapping is enabled, where the + * representation of the JSON in the request body is determined by + * protos JSON encoding: + * + * HTTP | gRPC + * -----|----- + * `PATCH /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: + * "123456" message { text: "Hi!" })` + * + * The special name `*` can be used in the body mapping to define that + * every field not bound by the path template should be mapped to the + * request body. This enables the following alternative definition of + * the update method: + * + * service Messaging { + * rpc UpdateMessage(Message) returns (Message) { + * option (google.api.http) = { + * patch: "/v1/messages/{message_id}" + * body: "*" + * }; + * } + * } + * message Message { + * string message_id = 1; + * string text = 2; + * } + * + * + * The following HTTP JSON to RPC mapping is enabled: + * + * HTTP | gRPC + * -----|----- + * `PATCH /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: + * "123456" text: "Hi!")` + * + * Note that when using `*` in the body mapping, it is not possible to + * have HTTP parameters, as all fields not bound by the path end in + * the body. This makes this option more rarely used in practice when + * defining REST APIs. The common usage of `*` is in custom methods + * which don't use the URL at all for transferring data. + * + * It is possible to define multiple HTTP methods for one RPC by using + * the `additional_bindings` option. Example: + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http) = { + * get: "/v1/messages/{message_id}" + * additional_bindings { + * get: "/v1/users/{user_id}/messages/{message_id}" + * } + * }; + * } + * } + * message GetMessageRequest { + * string message_id = 1; + * string user_id = 2; + * } + * + * This enables the following two alternative HTTP JSON to RPC mappings: + * + * HTTP | gRPC + * -----|----- + * `GET /v1/messages/123456` | `GetMessage(message_id: "123456")` + * `GET /v1/users/me/messages/123456` | `GetMessage(user_id: "me" message_id: + * "123456")` + * + * ## Rules for HTTP mapping + * + * 1. Leaf request fields (recursive expansion nested messages in the request + * message) are classified into three categories: + * - Fields referred by the path template. They are passed via the URL path. + * - Fields referred by the [HttpRule.body][google.api.HttpRule.body]. They are passed via the HTTP + * request body. + * - All other fields are passed via the URL query parameters, and the + * parameter name is the field path in the request message. A repeated + * field can be represented as multiple query parameters under the same + * name. + * 2. If [HttpRule.body][google.api.HttpRule.body] is "*", there is no URL query parameter, all fields + * are passed via URL path and HTTP request body. + * 3. If [HttpRule.body][google.api.HttpRule.body] is omitted, there is no HTTP request body, all + * fields are passed via URL path and URL query parameters. + * + * ### Path template syntax + * + * Template = "/" Segments [ Verb ] ; + * Segments = Segment { "/" Segment } ; + * Segment = "*" | "**" | LITERAL | Variable ; + * Variable = "{" FieldPath [ "=" Segments ] "}" ; + * FieldPath = IDENT { "." IDENT } ; + * Verb = ":" LITERAL ; + * + * The syntax `*` matches a single URL path segment. The syntax `**` matches + * zero or more URL path segments, which must be the last part of the URL path + * except the `Verb`. + * + * The syntax `Variable` matches part of the URL path as specified by its + * template. A variable template must not contain other variables. If a variable + * matches a single path segment, its template may be omitted, e.g. `{var}` + * is equivalent to `{var=*}`. + * + * The syntax `LITERAL` matches literal text in the URL path. If the `LITERAL` + * contains any reserved character, such characters should be percent-encoded + * before the matching. + * + * If a variable contains exactly one path segment, such as `"{var}"` or + * `"{var=*}"`, when such a variable is expanded into a URL path on the client + * side, all characters except `[-_.~0-9a-zA-Z]` are percent-encoded. The + * server side does the reverse decoding. Such variables show up in the + * [Discovery + * Document](https://developers.google.com/discovery/v1/reference/apis) as + * `{var}`. + * + * If a variable contains multiple path segments, such as `"{var=foo/*}"` + * or `"{var=**}"`, when such a variable is expanded into a URL path on the + * client side, all characters except `[-_.~/0-9a-zA-Z]` are percent-encoded. + * The server side does the reverse decoding, except "%2F" and "%2f" are left + * unchanged. Such variables show up in the + * [Discovery + * Document](https://developers.google.com/discovery/v1/reference/apis) as + * `{+var}`. + * + * ## Using gRPC API Service Configuration + * + * gRPC API Service Configuration (service config) is a configuration language + * for configuring a gRPC service to become a user-facing product. The + * service config is simply the YAML representation of the `google.api.Service` + * proto message. + * + * As an alternative to annotating your proto file, you can configure gRPC + * transcoding in your service config YAML files. You do this by specifying a + * `HttpRule` that maps the gRPC method to a REST endpoint, achieving the same + * effect as the proto annotation. This can be particularly useful if you + * have a proto that is reused in multiple services. Note that any transcoding + * specified in the service config will override any matching transcoding + * configuration in the proto. + * + * Example: + * + * http: + * rules: + * # Selects a gRPC method and applies HttpRule to it. + * - selector: example.v1.Messaging.GetMessage + * get: /v1/messages/{message_id}/{sub.subfield} + * + * ## Special notes + * + * When gRPC Transcoding is used to map a gRPC to JSON REST endpoints, the + * proto to JSON conversion must follow the [proto3 + * specification](https://developers.google.com/protocol-buffers/docs/proto3#json). + * + * While the single segment variable follows the semantics of + * [RFC 6570](https://tools.ietf.org/html/rfc6570) Section 3.2.2 Simple String + * Expansion, the multi segment variable **does not** follow RFC 6570 Section + * 3.2.3 Reserved Expansion. The reason is that the Reserved Expansion + * does not expand special characters like `?` and `#`, which would lead + * to invalid URLs. As the result, gRPC Transcoding uses a custom encoding + * for multi segment variables. + * + * The path variables **must not** refer to any repeated or mapped field, + * because client libraries are not capable of handling such variable expansion. + * + * The path variables **must not** capture the leading "/" character. The reason + * is that the most common use case "{var}" does not capture the leading "/" + * character. For consistency, all path variables must share the same behavior. + * + * Repeated message fields must not be mapped to URL query parameters, because + * no client library can support such complicated mapping. + * + * If an API needs to use a JSON array for request or response body, it can map + * the request or response body to a repeated field. However, some gRPC + * Transcoding implementations may not support this feature. + */ +export interface HttpRule { + /** + * Selects a method to which this rule applies. + * + * Refer to [selector][google.api.DocumentationRule.selector] for syntax details. + */ + selector: string; + /** + * Maps to HTTP GET. Used for listing and getting information about + * resources. + */ + get?: string; + /** Maps to HTTP PUT. Used for replacing a resource. */ + put?: string; + /** Maps to HTTP POST. Used for creating a resource or performing an action. */ + post?: string; + /** Maps to HTTP DELETE. Used for deleting a resource. */ + delete?: string; + /** Maps to HTTP PATCH. Used for updating a resource. */ + patch?: string; + /** + * The custom pattern is used for specifying an HTTP method that is not + * included in the `pattern` field, such as HEAD, or "*" to leave the + * HTTP method unspecified for this rule. The wild-card rule is useful + * for services that provide content to Web (HTML) clients. + */ + custom?: CustomHttpPattern; + /** + * The name of the request field whose value is mapped to the HTTP request + * body, or `*` for mapping all request fields not captured by the path + * pattern to the HTTP body, or omitted for not having any HTTP request body. + * + * NOTE: the referred field must be present at the top-level of the request + * message type. + */ + body: string; + /** + * Optional. The name of the response field whose value is mapped to the HTTP + * response body. When omitted, the entire response message will be used + * as the HTTP response body. + * + * NOTE: The referred field must be present at the top-level of the response + * message type. + */ + responseBody: string; + /** + * Additional HTTP bindings for the selector. Nested bindings must + * not contain an `additional_bindings` field themselves (that is, + * the nesting may only be one level deep). + */ + additionalBindings: HttpRule[]; +} +export interface HttpRuleProtoMsg { + typeUrl: "/google.api.HttpRule"; + value: Uint8Array; +} +/** + * # gRPC Transcoding + * + * gRPC Transcoding is a feature for mapping between a gRPC method and one or + * more HTTP REST endpoints. It allows developers to build a single API service + * that supports both gRPC APIs and REST APIs. Many systems, including [Google + * APIs](https://github.com/googleapis/googleapis), + * [Cloud Endpoints](https://cloud.google.com/endpoints), [gRPC + * Gateway](https://github.com/grpc-ecosystem/grpc-gateway), + * and [Envoy](https://github.com/envoyproxy/envoy) proxy support this feature + * and use it for large scale production services. + * + * `HttpRule` defines the schema of the gRPC/REST mapping. The mapping specifies + * how different portions of the gRPC request message are mapped to the URL + * path, URL query parameters, and HTTP request body. It also controls how the + * gRPC response message is mapped to the HTTP response body. `HttpRule` is + * typically specified as an `google.api.http` annotation on the gRPC method. + * + * Each mapping specifies a URL path template and an HTTP method. The path + * template may refer to one or more fields in the gRPC request message, as long + * as each field is a non-repeated field with a primitive (non-message) type. + * The path template controls how fields of the request message are mapped to + * the URL path. + * + * Example: + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http) = { + * get: "/v1/{name=messages/*}" + * }; + * } + * } + * message GetMessageRequest { + * string name = 1; // Mapped to URL path. + * } + * message Message { + * string text = 1; // The resource content. + * } + * + * This enables an HTTP REST to gRPC mapping as below: + * + * HTTP | gRPC + * -----|----- + * `GET /v1/messages/123456` | `GetMessage(name: "messages/123456")` + * + * Any fields in the request message which are not bound by the path template + * automatically become HTTP query parameters if there is no HTTP request body. + * For example: + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http) = { + * get:"/v1/messages/{message_id}" + * }; + * } + * } + * message GetMessageRequest { + * message SubMessage { + * string subfield = 1; + * } + * string message_id = 1; // Mapped to URL path. + * int64 revision = 2; // Mapped to URL query parameter `revision`. + * SubMessage sub = 3; // Mapped to URL query parameter `sub.subfield`. + * } + * + * This enables a HTTP JSON to RPC mapping as below: + * + * HTTP | gRPC + * -----|----- + * `GET /v1/messages/123456?revision=2&sub.subfield=foo` | + * `GetMessage(message_id: "123456" revision: 2 sub: SubMessage(subfield: + * "foo"))` + * + * Note that fields which are mapped to URL query parameters must have a + * primitive type or a repeated primitive type or a non-repeated message type. + * In the case of a repeated type, the parameter can be repeated in the URL + * as `...?param=A¶m=B`. In the case of a message type, each field of the + * message is mapped to a separate parameter, such as + * `...?foo.a=A&foo.b=B&foo.c=C`. + * + * For HTTP methods that allow a request body, the `body` field + * specifies the mapping. Consider a REST update method on the + * message resource collection: + * + * service Messaging { + * rpc UpdateMessage(UpdateMessageRequest) returns (Message) { + * option (google.api.http) = { + * patch: "/v1/messages/{message_id}" + * body: "message" + * }; + * } + * } + * message UpdateMessageRequest { + * string message_id = 1; // mapped to the URL + * Message message = 2; // mapped to the body + * } + * + * The following HTTP JSON to RPC mapping is enabled, where the + * representation of the JSON in the request body is determined by + * protos JSON encoding: + * + * HTTP | gRPC + * -----|----- + * `PATCH /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: + * "123456" message { text: "Hi!" })` + * + * The special name `*` can be used in the body mapping to define that + * every field not bound by the path template should be mapped to the + * request body. This enables the following alternative definition of + * the update method: + * + * service Messaging { + * rpc UpdateMessage(Message) returns (Message) { + * option (google.api.http) = { + * patch: "/v1/messages/{message_id}" + * body: "*" + * }; + * } + * } + * message Message { + * string message_id = 1; + * string text = 2; + * } + * + * + * The following HTTP JSON to RPC mapping is enabled: + * + * HTTP | gRPC + * -----|----- + * `PATCH /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: + * "123456" text: "Hi!")` + * + * Note that when using `*` in the body mapping, it is not possible to + * have HTTP parameters, as all fields not bound by the path end in + * the body. This makes this option more rarely used in practice when + * defining REST APIs. The common usage of `*` is in custom methods + * which don't use the URL at all for transferring data. + * + * It is possible to define multiple HTTP methods for one RPC by using + * the `additional_bindings` option. Example: + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http) = { + * get: "/v1/messages/{message_id}" + * additional_bindings { + * get: "/v1/users/{user_id}/messages/{message_id}" + * } + * }; + * } + * } + * message GetMessageRequest { + * string message_id = 1; + * string user_id = 2; + * } + * + * This enables the following two alternative HTTP JSON to RPC mappings: + * + * HTTP | gRPC + * -----|----- + * `GET /v1/messages/123456` | `GetMessage(message_id: "123456")` + * `GET /v1/users/me/messages/123456` | `GetMessage(user_id: "me" message_id: + * "123456")` + * + * ## Rules for HTTP mapping + * + * 1. Leaf request fields (recursive expansion nested messages in the request + * message) are classified into three categories: + * - Fields referred by the path template. They are passed via the URL path. + * - Fields referred by the [HttpRule.body][google.api.HttpRule.body]. They are passed via the HTTP + * request body. + * - All other fields are passed via the URL query parameters, and the + * parameter name is the field path in the request message. A repeated + * field can be represented as multiple query parameters under the same + * name. + * 2. If [HttpRule.body][google.api.HttpRule.body] is "*", there is no URL query parameter, all fields + * are passed via URL path and HTTP request body. + * 3. If [HttpRule.body][google.api.HttpRule.body] is omitted, there is no HTTP request body, all + * fields are passed via URL path and URL query parameters. + * + * ### Path template syntax + * + * Template = "/" Segments [ Verb ] ; + * Segments = Segment { "/" Segment } ; + * Segment = "*" | "**" | LITERAL | Variable ; + * Variable = "{" FieldPath [ "=" Segments ] "}" ; + * FieldPath = IDENT { "." IDENT } ; + * Verb = ":" LITERAL ; + * + * The syntax `*` matches a single URL path segment. The syntax `**` matches + * zero or more URL path segments, which must be the last part of the URL path + * except the `Verb`. + * + * The syntax `Variable` matches part of the URL path as specified by its + * template. A variable template must not contain other variables. If a variable + * matches a single path segment, its template may be omitted, e.g. `{var}` + * is equivalent to `{var=*}`. + * + * The syntax `LITERAL` matches literal text in the URL path. If the `LITERAL` + * contains any reserved character, such characters should be percent-encoded + * before the matching. + * + * If a variable contains exactly one path segment, such as `"{var}"` or + * `"{var=*}"`, when such a variable is expanded into a URL path on the client + * side, all characters except `[-_.~0-9a-zA-Z]` are percent-encoded. The + * server side does the reverse decoding. Such variables show up in the + * [Discovery + * Document](https://developers.google.com/discovery/v1/reference/apis) as + * `{var}`. + * + * If a variable contains multiple path segments, such as `"{var=foo/*}"` + * or `"{var=**}"`, when such a variable is expanded into a URL path on the + * client side, all characters except `[-_.~/0-9a-zA-Z]` are percent-encoded. + * The server side does the reverse decoding, except "%2F" and "%2f" are left + * unchanged. Such variables show up in the + * [Discovery + * Document](https://developers.google.com/discovery/v1/reference/apis) as + * `{+var}`. + * + * ## Using gRPC API Service Configuration + * + * gRPC API Service Configuration (service config) is a configuration language + * for configuring a gRPC service to become a user-facing product. The + * service config is simply the YAML representation of the `google.api.Service` + * proto message. + * + * As an alternative to annotating your proto file, you can configure gRPC + * transcoding in your service config YAML files. You do this by specifying a + * `HttpRule` that maps the gRPC method to a REST endpoint, achieving the same + * effect as the proto annotation. This can be particularly useful if you + * have a proto that is reused in multiple services. Note that any transcoding + * specified in the service config will override any matching transcoding + * configuration in the proto. + * + * Example: + * + * http: + * rules: + * # Selects a gRPC method and applies HttpRule to it. + * - selector: example.v1.Messaging.GetMessage + * get: /v1/messages/{message_id}/{sub.subfield} + * + * ## Special notes + * + * When gRPC Transcoding is used to map a gRPC to JSON REST endpoints, the + * proto to JSON conversion must follow the [proto3 + * specification](https://developers.google.com/protocol-buffers/docs/proto3#json). + * + * While the single segment variable follows the semantics of + * [RFC 6570](https://tools.ietf.org/html/rfc6570) Section 3.2.2 Simple String + * Expansion, the multi segment variable **does not** follow RFC 6570 Section + * 3.2.3 Reserved Expansion. The reason is that the Reserved Expansion + * does not expand special characters like `?` and `#`, which would lead + * to invalid URLs. As the result, gRPC Transcoding uses a custom encoding + * for multi segment variables. + * + * The path variables **must not** refer to any repeated or mapped field, + * because client libraries are not capable of handling such variable expansion. + * + * The path variables **must not** capture the leading "/" character. The reason + * is that the most common use case "{var}" does not capture the leading "/" + * character. For consistency, all path variables must share the same behavior. + * + * Repeated message fields must not be mapped to URL query parameters, because + * no client library can support such complicated mapping. + * + * If an API needs to use a JSON array for request or response body, it can map + * the request or response body to a repeated field. However, some gRPC + * Transcoding implementations may not support this feature. + */ +export interface HttpRuleSDKType { + selector: string; + get?: string; + put?: string; + post?: string; + delete?: string; + patch?: string; + custom?: CustomHttpPatternSDKType; + body: string; + response_body: string; + additional_bindings: HttpRuleSDKType[]; +} +/** A custom pattern is used for defining custom HTTP verb. */ +export interface CustomHttpPattern { + /** The name of this custom HTTP verb. */ + kind: string; + /** The path matched by this custom verb. */ + path: string; +} +export interface CustomHttpPatternProtoMsg { + typeUrl: "/google.api.CustomHttpPattern"; + value: Uint8Array; +} +/** A custom pattern is used for defining custom HTTP verb. */ +export interface CustomHttpPatternSDKType { + kind: string; + path: string; +} +function createBaseHttp(): Http { + return { + rules: [], + fullyDecodeReservedExpansion: false + }; +} +export const Http = { + typeUrl: "/google.api.Http", + encode(message: Http, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.rules) { + HttpRule.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.fullyDecodeReservedExpansion !== undefined) { + writer.uint32(16).bool(message.fullyDecodeReservedExpansion); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Http { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseHttp(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.rules.push(HttpRule.decode(reader, reader.uint32())); + break; + case 2: + message.fullyDecodeReservedExpansion = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Http { + const obj = createBaseHttp(); + if (Array.isArray(object?.rules)) obj.rules = object.rules.map((e: any) => HttpRule.fromJSON(e)); + if (isSet(object.fullyDecodeReservedExpansion)) obj.fullyDecodeReservedExpansion = Boolean(object.fullyDecodeReservedExpansion); + return obj; + }, + toJSON(message: Http): JsonSafe { + const obj: any = {}; + if (message.rules) { + obj.rules = message.rules.map(e => e ? HttpRule.toJSON(e) : undefined); + } else { + obj.rules = []; + } + message.fullyDecodeReservedExpansion !== undefined && (obj.fullyDecodeReservedExpansion = message.fullyDecodeReservedExpansion); + return obj; + }, + fromPartial(object: DeepPartial): Http { + const message = createBaseHttp(); + message.rules = object.rules?.map(e => HttpRule.fromPartial(e)) || []; + message.fullyDecodeReservedExpansion = object.fullyDecodeReservedExpansion ?? false; + return message; + }, + fromSDK(object: HttpSDKType): Http { + return { + rules: Array.isArray(object?.rules) ? object.rules.map((e: any) => HttpRule.fromSDK(e)) : [], + fullyDecodeReservedExpansion: object?.fully_decode_reserved_expansion + }; + }, + fromSDKJSON(object: any): HttpSDKType { + return { + rules: Array.isArray(object?.rules) ? object.rules.map((e: any) => HttpRule.fromSDKJSON(e)) : [], + fully_decode_reserved_expansion: isSet(object.fully_decode_reserved_expansion) ? Boolean(object.fully_decode_reserved_expansion) : false + }; + }, + toSDK(message: Http): HttpSDKType { + const obj: any = {}; + if (message.rules) { + obj.rules = message.rules.map(e => e ? HttpRule.toSDK(e) : undefined); + } else { + obj.rules = []; + } + obj.fully_decode_reserved_expansion = message.fullyDecodeReservedExpansion; + return obj; + }, + fromAmino(object: HttpAmino): Http { + const message = createBaseHttp(); + message.rules = object.rules?.map(e => HttpRule.fromAmino(e)) || []; + if (object.fully_decode_reserved_expansion !== undefined && object.fully_decode_reserved_expansion !== null) { + message.fullyDecodeReservedExpansion = object.fully_decode_reserved_expansion; + } + return message; + }, + toAmino(message: Http): HttpAmino { + const obj: any = {}; + if (message.rules) { + obj.rules = message.rules.map(e => e ? HttpRule.toAmino(e) : undefined); + } else { + obj.rules = message.rules; + } + obj.fully_decode_reserved_expansion = message.fullyDecodeReservedExpansion === false ? undefined : message.fullyDecodeReservedExpansion; + return obj; + }, + fromAminoMsg(object: HttpAminoMsg): Http { + return Http.fromAmino(object.value); + }, + fromProtoMsg(message: HttpProtoMsg): Http { + return Http.decode(message.value); + }, + toProto(message: Http): Uint8Array { + return Http.encode(message).finish(); + }, + toProtoMsg(message: Http): HttpProtoMsg { + return { + typeUrl: "/google.api.Http", + value: Http.encode(message).finish() + }; + } +}; +function createBaseHttpRule(): HttpRule { + return { + selector: "", + get: undefined, + put: undefined, + post: undefined, + delete: undefined, + patch: undefined, + custom: undefined, + body: "", + responseBody: "", + additionalBindings: [] + }; +} +export const HttpRule = { + typeUrl: "/google.api.HttpRule", + encode(message: HttpRule, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.selector !== undefined) { + writer.uint32(10).string(message.selector); + } + if (message.get !== undefined) { + writer.uint32(18).string(message.get); + } + if (message.put !== undefined) { + writer.uint32(26).string(message.put); + } + if (message.post !== undefined) { + writer.uint32(34).string(message.post); + } + if (message.delete !== undefined) { + writer.uint32(42).string(message.delete); + } + if (message.patch !== undefined) { + writer.uint32(50).string(message.patch); + } + if (message.custom !== undefined) { + CustomHttpPattern.encode(message.custom, writer.uint32(66).fork()).ldelim(); + } + if (message.body !== undefined) { + writer.uint32(58).string(message.body); + } + if (message.responseBody !== undefined) { + writer.uint32(98).string(message.responseBody); + } + for (const v of message.additionalBindings) { + HttpRule.encode(v!, writer.uint32(90).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): HttpRule { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseHttpRule(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.selector = reader.string(); + break; + case 2: + message.get = reader.string(); + break; + case 3: + message.put = reader.string(); + break; + case 4: + message.post = reader.string(); + break; + case 5: + message.delete = reader.string(); + break; + case 6: + message.patch = reader.string(); + break; + case 8: + message.custom = CustomHttpPattern.decode(reader, reader.uint32()); + break; + case 7: + message.body = reader.string(); + break; + case 12: + message.responseBody = reader.string(); + break; + case 11: + message.additionalBindings.push(HttpRule.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): HttpRule { + const obj = createBaseHttpRule(); + if (isSet(object.selector)) obj.selector = String(object.selector); + if (isSet(object.get)) obj.get = String(object.get); + if (isSet(object.put)) obj.put = String(object.put); + if (isSet(object.post)) obj.post = String(object.post); + if (isSet(object.delete)) obj.delete = String(object.delete); + if (isSet(object.patch)) obj.patch = String(object.patch); + if (isSet(object.custom)) obj.custom = CustomHttpPattern.fromJSON(object.custom); + if (isSet(object.body)) obj.body = String(object.body); + if (isSet(object.responseBody)) obj.responseBody = String(object.responseBody); + if (Array.isArray(object?.additionalBindings)) obj.additionalBindings = object.additionalBindings.map((e: any) => HttpRule.fromJSON(e)); + return obj; + }, + toJSON(message: HttpRule): JsonSafe { + const obj: any = {}; + message.selector !== undefined && (obj.selector = message.selector); + message.get !== undefined && (obj.get = message.get); + message.put !== undefined && (obj.put = message.put); + message.post !== undefined && (obj.post = message.post); + message.delete !== undefined && (obj.delete = message.delete); + message.patch !== undefined && (obj.patch = message.patch); + message.custom !== undefined && (obj.custom = message.custom ? CustomHttpPattern.toJSON(message.custom) : undefined); + message.body !== undefined && (obj.body = message.body); + message.responseBody !== undefined && (obj.responseBody = message.responseBody); + if (message.additionalBindings) { + obj.additionalBindings = message.additionalBindings.map(e => e ? HttpRule.toJSON(e) : undefined); + } else { + obj.additionalBindings = []; + } + return obj; + }, + fromPartial(object: DeepPartial): HttpRule { + const message = createBaseHttpRule(); + message.selector = object.selector ?? ""; + message.get = object.get ?? undefined; + message.put = object.put ?? undefined; + message.post = object.post ?? undefined; + message.delete = object.delete ?? undefined; + message.patch = object.patch ?? undefined; + if (object.custom !== undefined && object.custom !== null) { + message.custom = CustomHttpPattern.fromPartial(object.custom); + } + message.body = object.body ?? ""; + message.responseBody = object.responseBody ?? ""; + message.additionalBindings = object.additionalBindings?.map(e => HttpRule.fromPartial(e)) || []; + return message; + }, + fromSDK(object: HttpRuleSDKType): HttpRule { + return { + selector: object?.selector, + get: object?.get, + put: object?.put, + post: object?.post, + delete: object?.delete, + patch: object?.patch, + custom: object.custom ? CustomHttpPattern.fromSDK(object.custom) : undefined, + body: object?.body, + responseBody: object?.response_body, + additionalBindings: Array.isArray(object?.additional_bindings) ? object.additional_bindings.map((e: any) => HttpRule.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): HttpRuleSDKType { + return { + selector: isSet(object.selector) ? String(object.selector) : "", + get: isSet(object.get) ? String(object.get) : undefined, + put: isSet(object.put) ? String(object.put) : undefined, + post: isSet(object.post) ? String(object.post) : undefined, + delete: isSet(object.delete) ? String(object.delete) : undefined, + patch: isSet(object.patch) ? String(object.patch) : undefined, + custom: isSet(object.custom) ? CustomHttpPattern.fromSDKJSON(object.custom) : undefined, + body: isSet(object.body) ? String(object.body) : "", + response_body: isSet(object.response_body) ? String(object.response_body) : "", + additional_bindings: Array.isArray(object?.additional_bindings) ? object.additional_bindings.map((e: any) => HttpRule.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: HttpRule): HttpRuleSDKType { + const obj: any = {}; + obj.selector = message.selector; + obj.get = message.get; + obj.put = message.put; + obj.post = message.post; + obj.delete = message.delete; + obj.patch = message.patch; + message.custom !== undefined && (obj.custom = message.custom ? CustomHttpPattern.toSDK(message.custom) : undefined); + obj.body = message.body; + obj.response_body = message.responseBody; + if (message.additionalBindings) { + obj.additional_bindings = message.additionalBindings.map(e => e ? HttpRule.toSDK(e) : undefined); + } else { + obj.additional_bindings = []; + } + return obj; + }, + fromAmino(object: HttpRuleAmino): HttpRule { + const message = createBaseHttpRule(); + if (object.selector !== undefined && object.selector !== null) { + message.selector = object.selector; + } + if (object.get !== undefined && object.get !== null) { + message.get = object.get; + } + if (object.put !== undefined && object.put !== null) { + message.put = object.put; + } + if (object.post !== undefined && object.post !== null) { + message.post = object.post; + } + if (object.delete !== undefined && object.delete !== null) { + message.delete = object.delete; + } + if (object.patch !== undefined && object.patch !== null) { + message.patch = object.patch; + } + if (object.custom !== undefined && object.custom !== null) { + message.custom = CustomHttpPattern.fromAmino(object.custom); + } + if (object.body !== undefined && object.body !== null) { + message.body = object.body; + } + if (object.response_body !== undefined && object.response_body !== null) { + message.responseBody = object.response_body; + } + message.additionalBindings = object.additional_bindings?.map(e => HttpRule.fromAmino(e)) || []; + return message; + }, + toAmino(message: HttpRule): HttpRuleAmino { + const obj: any = {}; + obj.selector = message.selector === "" ? undefined : message.selector; + obj.get = message.get === null ? undefined : message.get; + obj.put = message.put === null ? undefined : message.put; + obj.post = message.post === null ? undefined : message.post; + obj.delete = message.delete === null ? undefined : message.delete; + obj.patch = message.patch === null ? undefined : message.patch; + obj.custom = message.custom ? CustomHttpPattern.toAmino(message.custom) : undefined; + obj.body = message.body === "" ? undefined : message.body; + obj.response_body = message.responseBody === "" ? undefined : message.responseBody; + if (message.additionalBindings) { + obj.additional_bindings = message.additionalBindings.map(e => e ? HttpRule.toAmino(e) : undefined); + } else { + obj.additional_bindings = message.additionalBindings; + } + return obj; + }, + fromAminoMsg(object: HttpRuleAminoMsg): HttpRule { + return HttpRule.fromAmino(object.value); + }, + fromProtoMsg(message: HttpRuleProtoMsg): HttpRule { + return HttpRule.decode(message.value); + }, + toProto(message: HttpRule): Uint8Array { + return HttpRule.encode(message).finish(); + }, + toProtoMsg(message: HttpRule): HttpRuleProtoMsg { + return { + typeUrl: "/google.api.HttpRule", + value: HttpRule.encode(message).finish() + }; + } +}; +function createBaseCustomHttpPattern(): CustomHttpPattern { + return { + kind: "", + path: "" + }; +} +export const CustomHttpPattern = { + typeUrl: "/google.api.CustomHttpPattern", + encode(message: CustomHttpPattern, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.kind !== undefined) { + writer.uint32(10).string(message.kind); + } + if (message.path !== undefined) { + writer.uint32(18).string(message.path); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): CustomHttpPattern { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCustomHttpPattern(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.kind = reader.string(); + break; + case 2: + message.path = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): CustomHttpPattern { + const obj = createBaseCustomHttpPattern(); + if (isSet(object.kind)) obj.kind = String(object.kind); + if (isSet(object.path)) obj.path = String(object.path); + return obj; + }, + toJSON(message: CustomHttpPattern): JsonSafe { + const obj: any = {}; + message.kind !== undefined && (obj.kind = message.kind); + message.path !== undefined && (obj.path = message.path); + return obj; + }, + fromPartial(object: DeepPartial): CustomHttpPattern { + const message = createBaseCustomHttpPattern(); + message.kind = object.kind ?? ""; + message.path = object.path ?? ""; + return message; + }, + fromSDK(object: CustomHttpPatternSDKType): CustomHttpPattern { + return { + kind: object?.kind, + path: object?.path + }; + }, + fromSDKJSON(object: any): CustomHttpPatternSDKType { + return { + kind: isSet(object.kind) ? String(object.kind) : "", + path: isSet(object.path) ? String(object.path) : "" + }; + }, + toSDK(message: CustomHttpPattern): CustomHttpPatternSDKType { + const obj: any = {}; + obj.kind = message.kind; + obj.path = message.path; + return obj; + }, + fromAmino(object: CustomHttpPatternAmino): CustomHttpPattern { + const message = createBaseCustomHttpPattern(); + if (object.kind !== undefined && object.kind !== null) { + message.kind = object.kind; + } + if (object.path !== undefined && object.path !== null) { + message.path = object.path; + } + return message; + }, + toAmino(message: CustomHttpPattern): CustomHttpPatternAmino { + const obj: any = {}; + obj.kind = message.kind === "" ? undefined : message.kind; + obj.path = message.path === "" ? undefined : message.path; + return obj; + }, + fromAminoMsg(object: CustomHttpPatternAminoMsg): CustomHttpPattern { + return CustomHttpPattern.fromAmino(object.value); + }, + fromProtoMsg(message: CustomHttpPatternProtoMsg): CustomHttpPattern { + return CustomHttpPattern.decode(message.value); + }, + toProto(message: CustomHttpPattern): Uint8Array { + return CustomHttpPattern.encode(message).finish(); + }, + toProtoMsg(message: CustomHttpPattern): CustomHttpPatternProtoMsg { + return { + typeUrl: "/google.api.CustomHttpPattern", + value: CustomHttpPattern.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/api/httpbody.ts b/__fixtures__/v-next/outputicjsdeps/google/api/httpbody.ts new file mode 100644 index 0000000000..d0e10f302b --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/api/httpbody.ts @@ -0,0 +1,247 @@ +import { Any, AnySDKType } from "../protobuf/any.js"; +import { BinaryReader, BinaryWriter } from "../../binary.js"; +import { isSet, bytesFromBase64, base64FromBytes, DeepPartial } from "../../helpers.js"; +import { JsonSafe } from "../../json-safe.js"; +export const protobufPackage = "google.api"; +/** + * Message that represents an arbitrary HTTP body. It should only be used for + * payload formats that can't be represented as JSON, such as raw binary or + * an HTML page. + * + * + * This message can be used both in streaming and non-streaming API methods in + * the request as well as the response. + * + * It can be used as a top-level request field, which is convenient if one + * wants to extract parameters from either the URL or HTTP template into the + * request fields and also want access to the raw HTTP body. + * + * Example: + * + * message GetResourceRequest { + * // A unique request id. + * string request_id = 1; + * + * // The raw HTTP body is bound to this field. + * google.api.HttpBody http_body = 2; + * + * } + * + * service ResourceService { + * rpc GetResource(GetResourceRequest) + * returns (google.api.HttpBody); + * rpc UpdateResource(google.api.HttpBody) + * returns (google.protobuf.Empty); + * + * } + * + * Example with streaming methods: + * + * service CaldavService { + * rpc GetCalendar(stream google.api.HttpBody) + * returns (stream google.api.HttpBody); + * rpc UpdateCalendar(stream google.api.HttpBody) + * returns (stream google.api.HttpBody); + * + * } + * + * Use of this type only changes how the request and response bodies are + * handled, all other features will continue to work unchanged. + */ +export interface HttpBody { + /** The HTTP Content-Type header value specifying the content type of the body. */ + contentType: string; + /** The HTTP request/response body as raw binary. */ + data: Uint8Array; + /** + * Application specific response metadata. Must be set in the first response + * for streaming APIs. + */ + extensions: Any[]; +} +export interface HttpBodyProtoMsg { + typeUrl: "/google.api.HttpBody"; + value: Uint8Array; +} +/** + * Message that represents an arbitrary HTTP body. It should only be used for + * payload formats that can't be represented as JSON, such as raw binary or + * an HTML page. + * + * + * This message can be used both in streaming and non-streaming API methods in + * the request as well as the response. + * + * It can be used as a top-level request field, which is convenient if one + * wants to extract parameters from either the URL or HTTP template into the + * request fields and also want access to the raw HTTP body. + * + * Example: + * + * message GetResourceRequest { + * // A unique request id. + * string request_id = 1; + * + * // The raw HTTP body is bound to this field. + * google.api.HttpBody http_body = 2; + * + * } + * + * service ResourceService { + * rpc GetResource(GetResourceRequest) + * returns (google.api.HttpBody); + * rpc UpdateResource(google.api.HttpBody) + * returns (google.protobuf.Empty); + * + * } + * + * Example with streaming methods: + * + * service CaldavService { + * rpc GetCalendar(stream google.api.HttpBody) + * returns (stream google.api.HttpBody); + * rpc UpdateCalendar(stream google.api.HttpBody) + * returns (stream google.api.HttpBody); + * + * } + * + * Use of this type only changes how the request and response bodies are + * handled, all other features will continue to work unchanged. + */ +export interface HttpBodySDKType { + content_type: string; + data: Uint8Array; + extensions: AnySDKType[]; +} +function createBaseHttpBody(): HttpBody { + return { + contentType: "", + data: new Uint8Array(), + extensions: [] + }; +} +export const HttpBody = { + typeUrl: "/google.api.HttpBody", + encode(message: HttpBody, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.contentType !== undefined) { + writer.uint32(10).string(message.contentType); + } + if (message.data.length !== 0) { + writer.uint32(18).bytes(message.data); + } + for (const v of message.extensions) { + Any.encode(v!, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): HttpBody { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseHttpBody(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.contentType = reader.string(); + break; + case 2: + message.data = reader.bytes(); + break; + case 3: + message.extensions.push(Any.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): HttpBody { + const obj = createBaseHttpBody(); + if (isSet(object.contentType)) obj.contentType = String(object.contentType); + if (isSet(object.data)) obj.data = bytesFromBase64(object.data); + if (Array.isArray(object?.extensions)) obj.extensions = object.extensions.map((e: any) => Any.fromJSON(e)); + return obj; + }, + toJSON(message: HttpBody): JsonSafe { + const obj: any = {}; + message.contentType !== undefined && (obj.contentType = message.contentType); + message.data !== undefined && (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array())); + if (message.extensions) { + obj.extensions = message.extensions.map(e => e ? Any.toJSON(e) : undefined); + } else { + obj.extensions = []; + } + return obj; + }, + fromPartial(object: DeepPartial): HttpBody { + const message = createBaseHttpBody(); + message.contentType = object.contentType ?? ""; + message.data = object.data ?? new Uint8Array(); + message.extensions = object.extensions?.map(e => Any.fromPartial(e)) || []; + return message; + }, + fromSDK(object: HttpBodySDKType): HttpBody { + return { + contentType: object?.content_type, + data: object?.data, + extensions: Array.isArray(object?.extensions) ? object.extensions.map((e: any) => Any.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): HttpBodySDKType { + return { + content_type: isSet(object.content_type) ? String(object.content_type) : "", + data: isSet(object.data) ? bytesFromBase64(object.data) : new Uint8Array(), + extensions: Array.isArray(object?.extensions) ? object.extensions.map((e: any) => Any.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: HttpBody): HttpBodySDKType { + const obj: any = {}; + obj.content_type = message.contentType; + obj.data = message.data; + if (message.extensions) { + obj.extensions = message.extensions.map(e => e ? Any.toSDK(e) : undefined); + } else { + obj.extensions = []; + } + return obj; + }, + fromAmino(object: HttpBodyAmino): HttpBody { + const message = createBaseHttpBody(); + if (object.content_type !== undefined && object.content_type !== null) { + message.contentType = object.content_type; + } + if (object.data !== undefined && object.data !== null) { + message.data = bytesFromBase64(object.data); + } + message.extensions = object.extensions?.map(e => Any.fromAmino(e)) || []; + return message; + }, + toAmino(message: HttpBody): HttpBodyAmino { + const obj: any = {}; + obj.content_type = message.contentType === "" ? undefined : message.contentType; + obj.data = message.data ? base64FromBytes(message.data) : undefined; + if (message.extensions) { + obj.extensions = message.extensions.map(e => e ? Any.toAmino(e) : undefined); + } else { + obj.extensions = message.extensions; + } + return obj; + }, + fromAminoMsg(object: HttpBodyAminoMsg): HttpBody { + return HttpBody.fromAmino(object.value); + }, + fromProtoMsg(message: HttpBodyProtoMsg): HttpBody { + return HttpBody.decode(message.value); + }, + toProto(message: HttpBody): Uint8Array { + return HttpBody.encode(message).finish(); + }, + toProtoMsg(message: HttpBody): HttpBodyProtoMsg { + return { + typeUrl: "/google.api.HttpBody", + value: HttpBody.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/api/label.ts b/__fixtures__/v-next/outputicjsdeps/google/api/label.ts new file mode 100644 index 0000000000..806911edc5 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/api/label.ts @@ -0,0 +1,186 @@ +import { BinaryReader, BinaryWriter } from "../../binary.js"; +import { isSet, DeepPartial } from "../../helpers.js"; +import { JsonSafe } from "../../json-safe.js"; +export const protobufPackage = "google.api"; +/** Value types that can be used as label values. */ +export enum LabelDescriptor_ValueType { + /** STRING - A variable-length string. This is the default. */ + STRING = 0, + /** BOOL - Boolean; true or false. */ + BOOL = 1, + /** INT64 - A 64-bit signed integer. */ + INT64 = 2, + UNRECOGNIZED = -1, +} +export const LabelDescriptor_ValueTypeSDKType = LabelDescriptor_ValueType; +export function labelDescriptor_ValueTypeFromJSON(object: any): LabelDescriptor_ValueType { + switch (object) { + case 0: + case "STRING": + return LabelDescriptor_ValueType.STRING; + case 1: + case "BOOL": + return LabelDescriptor_ValueType.BOOL; + case 2: + case "INT64": + return LabelDescriptor_ValueType.INT64; + case -1: + case "UNRECOGNIZED": + default: + return LabelDescriptor_ValueType.UNRECOGNIZED; + } +} +export function labelDescriptor_ValueTypeToJSON(object: LabelDescriptor_ValueType): string { + switch (object) { + case LabelDescriptor_ValueType.STRING: + return "STRING"; + case LabelDescriptor_ValueType.BOOL: + return "BOOL"; + case LabelDescriptor_ValueType.INT64: + return "INT64"; + case LabelDescriptor_ValueType.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** A description of a label. */ +export interface LabelDescriptor { + /** The label key. */ + key: string; + /** The type of data that can be assigned to the label. */ + valueType: LabelDescriptor_ValueType; + /** A human-readable description for the label. */ + description: string; +} +export interface LabelDescriptorProtoMsg { + typeUrl: "/google.api.LabelDescriptor"; + value: Uint8Array; +} +/** A description of a label. */ +export interface LabelDescriptorSDKType { + key: string; + value_type: LabelDescriptor_ValueType; + description: string; +} +function createBaseLabelDescriptor(): LabelDescriptor { + return { + key: "", + valueType: 0, + description: "" + }; +} +export const LabelDescriptor = { + typeUrl: "/google.api.LabelDescriptor", + encode(message: LabelDescriptor, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.key !== undefined) { + writer.uint32(10).string(message.key); + } + if (message.valueType !== 0) { + writer.uint32(16).int32(message.valueType); + } + if (message.description !== undefined) { + writer.uint32(26).string(message.description); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): LabelDescriptor { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseLabelDescriptor(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.string(); + break; + case 2: + message.valueType = (reader.int32() as any); + break; + case 3: + message.description = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): LabelDescriptor { + const obj = createBaseLabelDescriptor(); + if (isSet(object.key)) obj.key = String(object.key); + if (isSet(object.valueType)) obj.valueType = labelDescriptor_ValueTypeFromJSON(object.valueType); + if (isSet(object.description)) obj.description = String(object.description); + return obj; + }, + toJSON(message: LabelDescriptor): JsonSafe { + const obj: any = {}; + message.key !== undefined && (obj.key = message.key); + message.valueType !== undefined && (obj.valueType = labelDescriptor_ValueTypeToJSON(message.valueType)); + message.description !== undefined && (obj.description = message.description); + return obj; + }, + fromPartial(object: DeepPartial): LabelDescriptor { + const message = createBaseLabelDescriptor(); + message.key = object.key ?? ""; + message.valueType = object.valueType ?? 0; + message.description = object.description ?? ""; + return message; + }, + fromSDK(object: LabelDescriptorSDKType): LabelDescriptor { + return { + key: object?.key, + valueType: isSet(object.value_type) ? labelDescriptor_ValueTypeFromJSON(object.value_type) : -1, + description: object?.description + }; + }, + fromSDKJSON(object: any): LabelDescriptorSDKType { + return { + key: isSet(object.key) ? String(object.key) : "", + value_type: isSet(object.value_type) ? labelDescriptor_ValueTypeFromJSON(object.value_type) : -1, + description: isSet(object.description) ? String(object.description) : "" + }; + }, + toSDK(message: LabelDescriptor): LabelDescriptorSDKType { + const obj: any = {}; + obj.key = message.key; + message.valueType !== undefined && (obj.value_type = labelDescriptor_ValueTypeToJSON(message.valueType)); + obj.description = message.description; + return obj; + }, + fromAmino(object: LabelDescriptorAmino): LabelDescriptor { + const message = createBaseLabelDescriptor(); + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } + if (object.value_type !== undefined && object.value_type !== null) { + message.valueType = object.value_type; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } + return message; + }, + toAmino(message: LabelDescriptor): LabelDescriptorAmino { + const obj: any = {}; + obj.key = message.key === "" ? undefined : message.key; + obj.value_type = message.valueType === 0 ? undefined : message.valueType; + obj.description = message.description === "" ? undefined : message.description; + return obj; + }, + fromAminoMsg(object: LabelDescriptorAminoMsg): LabelDescriptor { + return LabelDescriptor.fromAmino(object.value); + }, + fromProtoMsg(message: LabelDescriptorProtoMsg): LabelDescriptor { + return LabelDescriptor.decode(message.value); + }, + toProto(message: LabelDescriptor): Uint8Array { + return LabelDescriptor.encode(message).finish(); + }, + toProtoMsg(message: LabelDescriptor): LabelDescriptorProtoMsg { + return { + typeUrl: "/google.api.LabelDescriptor", + value: LabelDescriptor.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/api/launch_stage.ts b/__fixtures__/v-next/outputicjsdeps/google/api/launch_stage.ts new file mode 100644 index 0000000000..6abb3525f3 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/api/launch_stage.ts @@ -0,0 +1,111 @@ +export const protobufPackage = "google.api"; +/** + * The launch stage as defined by [Google Cloud Platform + * Launch Stages](http://cloud.google.com/terms/launch-stages). + */ +export enum LaunchStage { + /** LAUNCH_STAGE_UNSPECIFIED - Do not use this default value. */ + LAUNCH_STAGE_UNSPECIFIED = 0, + /** UNIMPLEMENTED - The feature is not yet implemented. Users can not use it. */ + UNIMPLEMENTED = 6, + /** PRELAUNCH - Prelaunch features are hidden from users and are only visible internally. */ + PRELAUNCH = 7, + /** + * EARLY_ACCESS - Early Access features are limited to a closed group of testers. To use + * these features, you must sign up in advance and sign a Trusted Tester + * agreement (which includes confidentiality provisions). These features may + * be unstable, changed in backward-incompatible ways, and are not + * guaranteed to be released. + */ + EARLY_ACCESS = 1, + /** + * ALPHA - Alpha is a limited availability test for releases before they are cleared + * for widespread use. By Alpha, all significant design issues are resolved + * and we are in the process of verifying functionality. Alpha customers + * need to apply for access, agree to applicable terms, and have their + * projects allowlisted. Alpha releases don’t have to be feature complete, + * no SLAs are provided, and there are no technical support obligations, but + * they will be far enough along that customers can actually use them in + * test environments or for limited-use tests -- just like they would in + * normal production cases. + */ + ALPHA = 2, + /** + * BETA - Beta is the point at which we are ready to open a release for any + * customer to use. There are no SLA or technical support obligations in a + * Beta release. Products will be complete from a feature perspective, but + * may have some open outstanding issues. Beta releases are suitable for + * limited production use cases. + */ + BETA = 3, + /** + * GA - GA features are open to all developers and are considered stable and + * fully qualified for production use. + */ + GA = 4, + /** + * DEPRECATED - Deprecated features are scheduled to be shut down and removed. For more + * information, see the “Deprecation Policy” section of our [Terms of + * Service](https://cloud.google.com/terms/) + * and the [Google Cloud Platform Subject to the Deprecation + * Policy](https://cloud.google.com/terms/deprecation) documentation. + */ + DEPRECATED = 5, + UNRECOGNIZED = -1, +} +export const LaunchStageSDKType = LaunchStage; +export function launchStageFromJSON(object: any): LaunchStage { + switch (object) { + case 0: + case "LAUNCH_STAGE_UNSPECIFIED": + return LaunchStage.LAUNCH_STAGE_UNSPECIFIED; + case 6: + case "UNIMPLEMENTED": + return LaunchStage.UNIMPLEMENTED; + case 7: + case "PRELAUNCH": + return LaunchStage.PRELAUNCH; + case 1: + case "EARLY_ACCESS": + return LaunchStage.EARLY_ACCESS; + case 2: + case "ALPHA": + return LaunchStage.ALPHA; + case 3: + case "BETA": + return LaunchStage.BETA; + case 4: + case "GA": + return LaunchStage.GA; + case 5: + case "DEPRECATED": + return LaunchStage.DEPRECATED; + case -1: + case "UNRECOGNIZED": + default: + return LaunchStage.UNRECOGNIZED; + } +} +export function launchStageToJSON(object: LaunchStage): string { + switch (object) { + case LaunchStage.LAUNCH_STAGE_UNSPECIFIED: + return "LAUNCH_STAGE_UNSPECIFIED"; + case LaunchStage.UNIMPLEMENTED: + return "UNIMPLEMENTED"; + case LaunchStage.PRELAUNCH: + return "PRELAUNCH"; + case LaunchStage.EARLY_ACCESS: + return "EARLY_ACCESS"; + case LaunchStage.ALPHA: + return "ALPHA"; + case LaunchStage.BETA: + return "BETA"; + case LaunchStage.GA: + return "GA"; + case LaunchStage.DEPRECATED: + return "DEPRECATED"; + case LaunchStage.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/api/log.ts b/__fixtures__/v-next/outputicjsdeps/google/api/log.ts new file mode 100644 index 0000000000..f96c626293 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/api/log.ts @@ -0,0 +1,209 @@ +import { LabelDescriptor, LabelDescriptorSDKType } from "./label.js"; +import { BinaryReader, BinaryWriter } from "../../binary.js"; +import { isSet, DeepPartial } from "../../helpers.js"; +import { JsonSafe } from "../../json-safe.js"; +export const protobufPackage = "google.api"; +/** + * A description of a log type. Example in YAML format: + * + * - name: library.googleapis.com/activity_history + * description: The history of borrowing and returning library items. + * display_name: Activity + * labels: + * - key: /customer_id + * description: Identifier of a library customer + */ +export interface LogDescriptor { + /** + * The name of the log. It must be less than 512 characters long and can + * include the following characters: upper- and lower-case alphanumeric + * characters [A-Za-z0-9], and punctuation characters including + * slash, underscore, hyphen, period [/_-.]. + */ + name: string; + /** + * The set of labels that are available to describe a specific log entry. + * Runtime requests that contain labels not specified here are + * considered invalid. + */ + labels: LabelDescriptor[]; + /** + * A human-readable description of this log. This information appears in + * the documentation and can contain details. + */ + description: string; + /** + * The human-readable name for this log. This information appears on + * the user interface and should be concise. + */ + displayName: string; +} +export interface LogDescriptorProtoMsg { + typeUrl: "/google.api.LogDescriptor"; + value: Uint8Array; +} +/** + * A description of a log type. Example in YAML format: + * + * - name: library.googleapis.com/activity_history + * description: The history of borrowing and returning library items. + * display_name: Activity + * labels: + * - key: /customer_id + * description: Identifier of a library customer + */ +export interface LogDescriptorSDKType { + name: string; + labels: LabelDescriptorSDKType[]; + description: string; + display_name: string; +} +function createBaseLogDescriptor(): LogDescriptor { + return { + name: "", + labels: [], + description: "", + displayName: "" + }; +} +export const LogDescriptor = { + typeUrl: "/google.api.LogDescriptor", + encode(message: LogDescriptor, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + for (const v of message.labels) { + LabelDescriptor.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.description !== undefined) { + writer.uint32(26).string(message.description); + } + if (message.displayName !== undefined) { + writer.uint32(34).string(message.displayName); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): LogDescriptor { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseLogDescriptor(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.labels.push(LabelDescriptor.decode(reader, reader.uint32())); + break; + case 3: + message.description = reader.string(); + break; + case 4: + message.displayName = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): LogDescriptor { + const obj = createBaseLogDescriptor(); + if (isSet(object.name)) obj.name = String(object.name); + if (Array.isArray(object?.labels)) obj.labels = object.labels.map((e: any) => LabelDescriptor.fromJSON(e)); + if (isSet(object.description)) obj.description = String(object.description); + if (isSet(object.displayName)) obj.displayName = String(object.displayName); + return obj; + }, + toJSON(message: LogDescriptor): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.labels) { + obj.labels = message.labels.map(e => e ? LabelDescriptor.toJSON(e) : undefined); + } else { + obj.labels = []; + } + message.description !== undefined && (obj.description = message.description); + message.displayName !== undefined && (obj.displayName = message.displayName); + return obj; + }, + fromPartial(object: DeepPartial): LogDescriptor { + const message = createBaseLogDescriptor(); + message.name = object.name ?? ""; + message.labels = object.labels?.map(e => LabelDescriptor.fromPartial(e)) || []; + message.description = object.description ?? ""; + message.displayName = object.displayName ?? ""; + return message; + }, + fromSDK(object: LogDescriptorSDKType): LogDescriptor { + return { + name: object?.name, + labels: Array.isArray(object?.labels) ? object.labels.map((e: any) => LabelDescriptor.fromSDK(e)) : [], + description: object?.description, + displayName: object?.display_name + }; + }, + fromSDKJSON(object: any): LogDescriptorSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + labels: Array.isArray(object?.labels) ? object.labels.map((e: any) => LabelDescriptor.fromSDKJSON(e)) : [], + description: isSet(object.description) ? String(object.description) : "", + display_name: isSet(object.display_name) ? String(object.display_name) : "" + }; + }, + toSDK(message: LogDescriptor): LogDescriptorSDKType { + const obj: any = {}; + obj.name = message.name; + if (message.labels) { + obj.labels = message.labels.map(e => e ? LabelDescriptor.toSDK(e) : undefined); + } else { + obj.labels = []; + } + obj.description = message.description; + obj.display_name = message.displayName; + return obj; + }, + fromAmino(object: LogDescriptorAmino): LogDescriptor { + const message = createBaseLogDescriptor(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + message.labels = object.labels?.map(e => LabelDescriptor.fromAmino(e)) || []; + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } + if (object.display_name !== undefined && object.display_name !== null) { + message.displayName = object.display_name; + } + return message; + }, + toAmino(message: LogDescriptor): LogDescriptorAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + if (message.labels) { + obj.labels = message.labels.map(e => e ? LabelDescriptor.toAmino(e) : undefined); + } else { + obj.labels = message.labels; + } + obj.description = message.description === "" ? undefined : message.description; + obj.display_name = message.displayName === "" ? undefined : message.displayName; + return obj; + }, + fromAminoMsg(object: LogDescriptorAminoMsg): LogDescriptor { + return LogDescriptor.fromAmino(object.value); + }, + fromProtoMsg(message: LogDescriptorProtoMsg): LogDescriptor { + return LogDescriptor.decode(message.value); + }, + toProto(message: LogDescriptor): Uint8Array { + return LogDescriptor.encode(message).finish(); + }, + toProtoMsg(message: LogDescriptor): LogDescriptorProtoMsg { + return { + typeUrl: "/google.api.LogDescriptor", + value: LogDescriptor.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/api/logging.ts b/__fixtures__/v-next/outputicjsdeps/google/api/logging.ts new file mode 100644 index 0000000000..52e42d32a6 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/api/logging.ts @@ -0,0 +1,360 @@ +import { BinaryReader, BinaryWriter } from "../../binary.js"; +import { JsonSafe } from "../../json-safe.js"; +import { DeepPartial, isSet } from "../../helpers.js"; +export const protobufPackage = "google.api"; +/** + * Logging configuration of the service. + * + * The following example shows how to configure logs to be sent to the + * producer and consumer projects. In the example, the `activity_history` + * log is sent to both the producer and consumer projects, whereas the + * `purchase_history` log is only sent to the producer project. + * + * monitored_resources: + * - type: library.googleapis.com/branch + * labels: + * - key: /city + * description: The city where the library branch is located in. + * - key: /name + * description: The name of the branch. + * logs: + * - name: activity_history + * labels: + * - key: /customer_id + * - name: purchase_history + * logging: + * producer_destinations: + * - monitored_resource: library.googleapis.com/branch + * logs: + * - activity_history + * - purchase_history + * consumer_destinations: + * - monitored_resource: library.googleapis.com/branch + * logs: + * - activity_history + */ +export interface Logging { + /** + * Logging configurations for sending logs to the producer project. + * There can be multiple producer destinations, each one must have a + * different monitored resource type. A log can be used in at most + * one producer destination. + */ + producerDestinations: Logging_LoggingDestination[]; + /** + * Logging configurations for sending logs to the consumer project. + * There can be multiple consumer destinations, each one must have a + * different monitored resource type. A log can be used in at most + * one consumer destination. + */ + consumerDestinations: Logging_LoggingDestination[]; +} +export interface LoggingProtoMsg { + typeUrl: "/google.api.Logging"; + value: Uint8Array; +} +/** + * Logging configuration of the service. + * + * The following example shows how to configure logs to be sent to the + * producer and consumer projects. In the example, the `activity_history` + * log is sent to both the producer and consumer projects, whereas the + * `purchase_history` log is only sent to the producer project. + * + * monitored_resources: + * - type: library.googleapis.com/branch + * labels: + * - key: /city + * description: The city where the library branch is located in. + * - key: /name + * description: The name of the branch. + * logs: + * - name: activity_history + * labels: + * - key: /customer_id + * - name: purchase_history + * logging: + * producer_destinations: + * - monitored_resource: library.googleapis.com/branch + * logs: + * - activity_history + * - purchase_history + * consumer_destinations: + * - monitored_resource: library.googleapis.com/branch + * logs: + * - activity_history + */ +export interface LoggingSDKType { + producer_destinations: Logging_LoggingDestinationSDKType[]; + consumer_destinations: Logging_LoggingDestinationSDKType[]; +} +/** + * Configuration of a specific logging destination (the producer project + * or the consumer project). + */ +export interface Logging_LoggingDestination { + /** + * The monitored resource type. The type must be defined in the + * [Service.monitored_resources][google.api.Service.monitored_resources] section. + */ + monitoredResource: string; + /** + * Names of the logs to be sent to this destination. Each name must + * be defined in the [Service.logs][google.api.Service.logs] section. If the log name is + * not a domain scoped name, it will be automatically prefixed with + * the service name followed by "/". + */ + logs: string[]; +} +export interface Logging_LoggingDestinationProtoMsg { + typeUrl: "/google.api.LoggingDestination"; + value: Uint8Array; +} +/** + * Configuration of a specific logging destination (the producer project + * or the consumer project). + */ +export interface Logging_LoggingDestinationSDKType { + monitored_resource: string; + logs: string[]; +} +function createBaseLogging(): Logging { + return { + producerDestinations: [], + consumerDestinations: [] + }; +} +export const Logging = { + typeUrl: "/google.api.Logging", + encode(message: Logging, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.producerDestinations) { + Logging_LoggingDestination.encode(v!, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.consumerDestinations) { + Logging_LoggingDestination.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Logging { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseLogging(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.producerDestinations.push(Logging_LoggingDestination.decode(reader, reader.uint32())); + break; + case 2: + message.consumerDestinations.push(Logging_LoggingDestination.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Logging { + const obj = createBaseLogging(); + if (Array.isArray(object?.producerDestinations)) obj.producerDestinations = object.producerDestinations.map((e: any) => Logging_LoggingDestination.fromJSON(e)); + if (Array.isArray(object?.consumerDestinations)) obj.consumerDestinations = object.consumerDestinations.map((e: any) => Logging_LoggingDestination.fromJSON(e)); + return obj; + }, + toJSON(message: Logging): JsonSafe { + const obj: any = {}; + if (message.producerDestinations) { + obj.producerDestinations = message.producerDestinations.map(e => e ? Logging_LoggingDestination.toJSON(e) : undefined); + } else { + obj.producerDestinations = []; + } + if (message.consumerDestinations) { + obj.consumerDestinations = message.consumerDestinations.map(e => e ? Logging_LoggingDestination.toJSON(e) : undefined); + } else { + obj.consumerDestinations = []; + } + return obj; + }, + fromPartial(object: DeepPartial): Logging { + const message = createBaseLogging(); + message.producerDestinations = object.producerDestinations?.map(e => Logging_LoggingDestination.fromPartial(e)) || []; + message.consumerDestinations = object.consumerDestinations?.map(e => Logging_LoggingDestination.fromPartial(e)) || []; + return message; + }, + fromSDK(object: LoggingSDKType): Logging { + return { + producerDestinations: Array.isArray(object?.producer_destinations) ? object.producer_destinations.map((e: any) => Logging_LoggingDestination.fromSDK(e)) : [], + consumerDestinations: Array.isArray(object?.consumer_destinations) ? object.consumer_destinations.map((e: any) => Logging_LoggingDestination.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): LoggingSDKType { + return { + producer_destinations: Array.isArray(object?.producer_destinations) ? object.producer_destinations.map((e: any) => Logging_LoggingDestination.fromSDKJSON(e)) : [], + consumer_destinations: Array.isArray(object?.consumer_destinations) ? object.consumer_destinations.map((e: any) => Logging_LoggingDestination.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: Logging): LoggingSDKType { + const obj: any = {}; + if (message.producerDestinations) { + obj.producer_destinations = message.producerDestinations.map(e => e ? Logging_LoggingDestination.toSDK(e) : undefined); + } else { + obj.producer_destinations = []; + } + if (message.consumerDestinations) { + obj.consumer_destinations = message.consumerDestinations.map(e => e ? Logging_LoggingDestination.toSDK(e) : undefined); + } else { + obj.consumer_destinations = []; + } + return obj; + }, + fromAmino(object: LoggingAmino): Logging { + const message = createBaseLogging(); + message.producerDestinations = object.producer_destinations?.map(e => Logging_LoggingDestination.fromAmino(e)) || []; + message.consumerDestinations = object.consumer_destinations?.map(e => Logging_LoggingDestination.fromAmino(e)) || []; + return message; + }, + toAmino(message: Logging): LoggingAmino { + const obj: any = {}; + if (message.producerDestinations) { + obj.producer_destinations = message.producerDestinations.map(e => e ? Logging_LoggingDestination.toAmino(e) : undefined); + } else { + obj.producer_destinations = message.producerDestinations; + } + if (message.consumerDestinations) { + obj.consumer_destinations = message.consumerDestinations.map(e => e ? Logging_LoggingDestination.toAmino(e) : undefined); + } else { + obj.consumer_destinations = message.consumerDestinations; + } + return obj; + }, + fromAminoMsg(object: LoggingAminoMsg): Logging { + return Logging.fromAmino(object.value); + }, + fromProtoMsg(message: LoggingProtoMsg): Logging { + return Logging.decode(message.value); + }, + toProto(message: Logging): Uint8Array { + return Logging.encode(message).finish(); + }, + toProtoMsg(message: Logging): LoggingProtoMsg { + return { + typeUrl: "/google.api.Logging", + value: Logging.encode(message).finish() + }; + } +}; +function createBaseLogging_LoggingDestination(): Logging_LoggingDestination { + return { + monitoredResource: "", + logs: [] + }; +} +export const Logging_LoggingDestination = { + typeUrl: "/google.api.LoggingDestination", + encode(message: Logging_LoggingDestination, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.monitoredResource !== undefined) { + writer.uint32(26).string(message.monitoredResource); + } + for (const v of message.logs) { + writer.uint32(10).string(v!); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Logging_LoggingDestination { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseLogging_LoggingDestination(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 3: + message.monitoredResource = reader.string(); + break; + case 1: + message.logs.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Logging_LoggingDestination { + const obj = createBaseLogging_LoggingDestination(); + if (isSet(object.monitoredResource)) obj.monitoredResource = String(object.monitoredResource); + if (Array.isArray(object?.logs)) obj.logs = object.logs.map((e: any) => String(e)); + return obj; + }, + toJSON(message: Logging_LoggingDestination): JsonSafe { + const obj: any = {}; + message.monitoredResource !== undefined && (obj.monitoredResource = message.monitoredResource); + if (message.logs) { + obj.logs = message.logs.map(e => e); + } else { + obj.logs = []; + } + return obj; + }, + fromPartial(object: DeepPartial): Logging_LoggingDestination { + const message = createBaseLogging_LoggingDestination(); + message.monitoredResource = object.monitoredResource ?? ""; + message.logs = object.logs?.map(e => e) || []; + return message; + }, + fromSDK(object: Logging_LoggingDestinationSDKType): Logging_LoggingDestination { + return { + monitoredResource: object?.monitored_resource, + logs: Array.isArray(object?.logs) ? object.logs.map((e: any) => e) : [] + }; + }, + fromSDKJSON(object: any): Logging_LoggingDestinationSDKType { + return { + monitored_resource: isSet(object.monitored_resource) ? String(object.monitored_resource) : "", + logs: Array.isArray(object?.logs) ? object.logs.map((e: any) => String(e)) : [] + }; + }, + toSDK(message: Logging_LoggingDestination): Logging_LoggingDestinationSDKType { + const obj: any = {}; + obj.monitored_resource = message.monitoredResource; + if (message.logs) { + obj.logs = message.logs.map(e => e); + } else { + obj.logs = []; + } + return obj; + }, + fromAmino(object: Logging_LoggingDestinationAmino): Logging_LoggingDestination { + const message = createBaseLogging_LoggingDestination(); + if (object.monitored_resource !== undefined && object.monitored_resource !== null) { + message.monitoredResource = object.monitored_resource; + } + message.logs = object.logs?.map(e => e) || []; + return message; + }, + toAmino(message: Logging_LoggingDestination): Logging_LoggingDestinationAmino { + const obj: any = {}; + obj.monitored_resource = message.monitoredResource === "" ? undefined : message.monitoredResource; + if (message.logs) { + obj.logs = message.logs.map(e => e); + } else { + obj.logs = message.logs; + } + return obj; + }, + fromAminoMsg(object: Logging_LoggingDestinationAminoMsg): Logging_LoggingDestination { + return Logging_LoggingDestination.fromAmino(object.value); + }, + fromProtoMsg(message: Logging_LoggingDestinationProtoMsg): Logging_LoggingDestination { + return Logging_LoggingDestination.decode(message.value); + }, + toProto(message: Logging_LoggingDestination): Uint8Array { + return Logging_LoggingDestination.encode(message).finish(); + }, + toProtoMsg(message: Logging_LoggingDestination): Logging_LoggingDestinationProtoMsg { + return { + typeUrl: "/google.api.LoggingDestination", + value: Logging_LoggingDestination.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/api/metric.ts b/__fixtures__/v-next/outputicjsdeps/google/api/metric.ts new file mode 100644 index 0000000000..b146a9bd45 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/api/metric.ts @@ -0,0 +1,1058 @@ +import { LaunchStage, LaunchStageSDKType, launchStageFromJSON, launchStageToJSON } from "./launch_stage.js"; +import { Duration, DurationSDKType } from "../protobuf/duration.js"; +import { LabelDescriptor, LabelDescriptorSDKType } from "./label.js"; +import { BinaryReader, BinaryWriter } from "../../binary.js"; +import { isSet, DeepPartial, isObject } from "../../helpers.js"; +import { JsonSafe } from "../../json-safe.js"; +export const protobufPackage = "google.api"; +/** + * The kind of measurement. It describes how the data is reported. + * For information on setting the start time and end time based on + * the MetricKind, see [TimeInterval][google.monitoring.v3.TimeInterval]. + */ +export enum MetricDescriptor_MetricKind { + /** METRIC_KIND_UNSPECIFIED - Do not use this default value. */ + METRIC_KIND_UNSPECIFIED = 0, + /** GAUGE - An instantaneous measurement of a value. */ + GAUGE = 1, + /** DELTA - The change in a value during a time interval. */ + DELTA = 2, + /** + * CUMULATIVE - A value accumulated over a time interval. Cumulative + * measurements in a time series should have the same start time + * and increasing end times, until an event resets the cumulative + * value to zero and sets a new start time for the following + * points. + */ + CUMULATIVE = 3, + UNRECOGNIZED = -1, +} +export const MetricDescriptor_MetricKindSDKType = MetricDescriptor_MetricKind; +export function metricDescriptor_MetricKindFromJSON(object: any): MetricDescriptor_MetricKind { + switch (object) { + case 0: + case "METRIC_KIND_UNSPECIFIED": + return MetricDescriptor_MetricKind.METRIC_KIND_UNSPECIFIED; + case 1: + case "GAUGE": + return MetricDescriptor_MetricKind.GAUGE; + case 2: + case "DELTA": + return MetricDescriptor_MetricKind.DELTA; + case 3: + case "CUMULATIVE": + return MetricDescriptor_MetricKind.CUMULATIVE; + case -1: + case "UNRECOGNIZED": + default: + return MetricDescriptor_MetricKind.UNRECOGNIZED; + } +} +export function metricDescriptor_MetricKindToJSON(object: MetricDescriptor_MetricKind): string { + switch (object) { + case MetricDescriptor_MetricKind.METRIC_KIND_UNSPECIFIED: + return "METRIC_KIND_UNSPECIFIED"; + case MetricDescriptor_MetricKind.GAUGE: + return "GAUGE"; + case MetricDescriptor_MetricKind.DELTA: + return "DELTA"; + case MetricDescriptor_MetricKind.CUMULATIVE: + return "CUMULATIVE"; + case MetricDescriptor_MetricKind.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** The value type of a metric. */ +export enum MetricDescriptor_ValueType { + /** VALUE_TYPE_UNSPECIFIED - Do not use this default value. */ + VALUE_TYPE_UNSPECIFIED = 0, + /** + * BOOL - The value is a boolean. + * This value type can be used only if the metric kind is `GAUGE`. + */ + BOOL = 1, + /** INT64 - The value is a signed 64-bit integer. */ + INT64 = 2, + /** DOUBLE - The value is a double precision floating point number. */ + DOUBLE = 3, + /** + * STRING - The value is a text string. + * This value type can be used only if the metric kind is `GAUGE`. + */ + STRING = 4, + /** DISTRIBUTION - The value is a [`Distribution`][google.api.Distribution]. */ + DISTRIBUTION = 5, + /** MONEY - The value is money. */ + MONEY = 6, + UNRECOGNIZED = -1, +} +export const MetricDescriptor_ValueTypeSDKType = MetricDescriptor_ValueType; +export function metricDescriptor_ValueTypeFromJSON(object: any): MetricDescriptor_ValueType { + switch (object) { + case 0: + case "VALUE_TYPE_UNSPECIFIED": + return MetricDescriptor_ValueType.VALUE_TYPE_UNSPECIFIED; + case 1: + case "BOOL": + return MetricDescriptor_ValueType.BOOL; + case 2: + case "INT64": + return MetricDescriptor_ValueType.INT64; + case 3: + case "DOUBLE": + return MetricDescriptor_ValueType.DOUBLE; + case 4: + case "STRING": + return MetricDescriptor_ValueType.STRING; + case 5: + case "DISTRIBUTION": + return MetricDescriptor_ValueType.DISTRIBUTION; + case 6: + case "MONEY": + return MetricDescriptor_ValueType.MONEY; + case -1: + case "UNRECOGNIZED": + default: + return MetricDescriptor_ValueType.UNRECOGNIZED; + } +} +export function metricDescriptor_ValueTypeToJSON(object: MetricDescriptor_ValueType): string { + switch (object) { + case MetricDescriptor_ValueType.VALUE_TYPE_UNSPECIFIED: + return "VALUE_TYPE_UNSPECIFIED"; + case MetricDescriptor_ValueType.BOOL: + return "BOOL"; + case MetricDescriptor_ValueType.INT64: + return "INT64"; + case MetricDescriptor_ValueType.DOUBLE: + return "DOUBLE"; + case MetricDescriptor_ValueType.STRING: + return "STRING"; + case MetricDescriptor_ValueType.DISTRIBUTION: + return "DISTRIBUTION"; + case MetricDescriptor_ValueType.MONEY: + return "MONEY"; + case MetricDescriptor_ValueType.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** + * Defines a metric type and its schema. Once a metric descriptor is created, + * deleting or altering it stops data collection and makes the metric type's + * existing data unusable. + */ +export interface MetricDescriptor { + /** The resource name of the metric descriptor. */ + name: string; + /** + * The metric type, including its DNS name prefix. The type is not + * URL-encoded. All user-defined metric types have the DNS name + * `custom.googleapis.com` or `external.googleapis.com`. Metric types should + * use a natural hierarchical grouping. For example: + * + * "custom.googleapis.com/invoice/paid/amount" + * "external.googleapis.com/prometheus/up" + * "appengine.googleapis.com/http/server/response_latencies" + */ + type: string; + /** + * The set of labels that can be used to describe a specific + * instance of this metric type. For example, the + * `appengine.googleapis.com/http/server/response_latencies` metric + * type has a label for the HTTP response code, `response_code`, so + * you can look at latencies for successful responses or just + * for responses that failed. + */ + labels: LabelDescriptor[]; + /** + * Whether the metric records instantaneous values, changes to a value, etc. + * Some combinations of `metric_kind` and `value_type` might not be supported. + */ + metricKind: MetricDescriptor_MetricKind; + /** + * Whether the measurement is an integer, a floating-point number, etc. + * Some combinations of `metric_kind` and `value_type` might not be supported. + */ + valueType: MetricDescriptor_ValueType; + /** + * The units in which the metric value is reported. It is only applicable + * if the `value_type` is `INT64`, `DOUBLE`, or `DISTRIBUTION`. The `unit` + * defines the representation of the stored metric values. + * + * Different systems might scale the values to be more easily displayed (so a + * value of `0.02kBy` _might_ be displayed as `20By`, and a value of + * `3523kBy` _might_ be displayed as `3.5MBy`). However, if the `unit` is + * `kBy`, then the value of the metric is always in thousands of bytes, no + * matter how it might be displayed. + * + * If you want a custom metric to record the exact number of CPU-seconds used + * by a job, you can create an `INT64 CUMULATIVE` metric whose `unit` is + * `s{CPU}` (or equivalently `1s{CPU}` or just `s`). If the job uses 12,005 + * CPU-seconds, then the value is written as `12005`. + * + * Alternatively, if you want a custom metric to record data in a more + * granular way, you can create a `DOUBLE CUMULATIVE` metric whose `unit` is + * `ks{CPU}`, and then write the value `12.005` (which is `12005/1000`), + * or use `Kis{CPU}` and write `11.723` (which is `12005/1024`). + * + * The supported units are a subset of [The Unified Code for Units of + * Measure](https://unitsofmeasure.org/ucum.html) standard: + * + * **Basic units (UNIT)** + * + * * `bit` bit + * * `By` byte + * * `s` second + * * `min` minute + * * `h` hour + * * `d` day + * * `1` dimensionless + * + * **Prefixes (PREFIX)** + * + * * `k` kilo (10^3) + * * `M` mega (10^6) + * * `G` giga (10^9) + * * `T` tera (10^12) + * * `P` peta (10^15) + * * `E` exa (10^18) + * * `Z` zetta (10^21) + * * `Y` yotta (10^24) + * + * * `m` milli (10^-3) + * * `u` micro (10^-6) + * * `n` nano (10^-9) + * * `p` pico (10^-12) + * * `f` femto (10^-15) + * * `a` atto (10^-18) + * * `z` zepto (10^-21) + * * `y` yocto (10^-24) + * + * * `Ki` kibi (2^10) + * * `Mi` mebi (2^20) + * * `Gi` gibi (2^30) + * * `Ti` tebi (2^40) + * * `Pi` pebi (2^50) + * + * **Grammar** + * + * The grammar also includes these connectors: + * + * * `/` division or ratio (as an infix operator). For examples, + * `kBy/{email}` or `MiBy/10ms` (although you should almost never + * have `/s` in a metric `unit`; rates should always be computed at + * query time from the underlying cumulative or delta value). + * * `.` multiplication or composition (as an infix operator). For + * examples, `GBy.d` or `k{watt}.h`. + * + * The grammar for a unit is as follows: + * + * Expression = Component { "." Component } { "/" Component } ; + * + * Component = ( [ PREFIX ] UNIT | "%" ) [ Annotation ] + * | Annotation + * | "1" + * ; + * + * Annotation = "{" NAME "}" ; + * + * Notes: + * + * * `Annotation` is just a comment if it follows a `UNIT`. If the annotation + * is used alone, then the unit is equivalent to `1`. For examples, + * `{request}/s == 1/s`, `By{transmitted}/s == By/s`. + * * `NAME` is a sequence of non-blank printable ASCII characters not + * containing `{` or `}`. + * * `1` represents a unitary [dimensionless + * unit](https://en.wikipedia.org/wiki/Dimensionless_quantity) of 1, such + * as in `1/s`. It is typically used when none of the basic units are + * appropriate. For example, "new users per day" can be represented as + * `1/d` or `{new-users}/d` (and a metric value `5` would mean "5 new + * users). Alternatively, "thousands of page views per day" would be + * represented as `1000/d` or `k1/d` or `k{page_views}/d` (and a metric + * value of `5.3` would mean "5300 page views per day"). + * * `%` represents dimensionless value of 1/100, and annotates values giving + * a percentage (so the metric values are typically in the range of 0..100, + * and a metric value `3` means "3 percent"). + * * `10^2.%` indicates a metric contains a ratio, typically in the range + * 0..1, that will be multiplied by 100 and displayed as a percentage + * (so a metric value `0.03` means "3 percent"). + */ + unit: string; + /** A detailed description of the metric, which can be used in documentation. */ + description: string; + /** + * A concise name for the metric, which can be displayed in user interfaces. + * Use sentence case without an ending period, for example "Request count". + * This field is optional but it is recommended to be set for any metrics + * associated with user-visible concepts, such as Quota. + */ + displayName: string; + /** Optional. Metadata which can be used to guide usage of the metric. */ + metadata?: MetricDescriptor_MetricDescriptorMetadata; + /** Optional. The launch stage of the metric definition. */ + launchStage: LaunchStage; + /** + * Read-only. If present, then a [time + * series][google.monitoring.v3.TimeSeries], which is identified partially by + * a metric type and a [MonitoredResourceDescriptor][google.api.MonitoredResourceDescriptor], that is associated + * with this metric type can only be associated with one of the monitored + * resource types listed here. + */ + monitoredResourceTypes: string[]; +} +export interface MetricDescriptorProtoMsg { + typeUrl: "/google.api.MetricDescriptor"; + value: Uint8Array; +} +/** + * Defines a metric type and its schema. Once a metric descriptor is created, + * deleting or altering it stops data collection and makes the metric type's + * existing data unusable. + */ +export interface MetricDescriptorSDKType { + name: string; + type: string; + labels: LabelDescriptorSDKType[]; + metric_kind: MetricDescriptor_MetricKind; + value_type: MetricDescriptor_ValueType; + unit: string; + description: string; + display_name: string; + metadata?: MetricDescriptor_MetricDescriptorMetadataSDKType; + launch_stage: LaunchStage; + monitored_resource_types: string[]; +} +/** Additional annotations that can be used to guide the usage of a metric. */ +export interface MetricDescriptor_MetricDescriptorMetadata { + /** Deprecated. Must use the [MetricDescriptor.launch_stage][google.api.MetricDescriptor.launch_stage] instead. */ + /** @deprecated */ + launchStage: LaunchStage; + /** + * The sampling period of metric data points. For metrics which are written + * periodically, consecutive data points are stored at this time interval, + * excluding data loss due to errors. Metrics with a higher granularity have + * a smaller sampling period. + */ + samplePeriod?: Duration; + /** + * The delay of data points caused by ingestion. Data points older than this + * age are guaranteed to be ingested and available to be read, excluding + * data loss due to errors. + */ + ingestDelay?: Duration; +} +export interface MetricDescriptor_MetricDescriptorMetadataProtoMsg { + typeUrl: "/google.api.MetricDescriptorMetadata"; + value: Uint8Array; +} +/** Additional annotations that can be used to guide the usage of a metric. */ +export interface MetricDescriptor_MetricDescriptorMetadataSDKType { + /** @deprecated */ + launch_stage: LaunchStage; + sample_period?: DurationSDKType; + ingest_delay?: DurationSDKType; +} +export interface Metric_LabelsEntry { + key: string; + value: string; +} +export interface Metric_LabelsEntryProtoMsg { + typeUrl: string; + value: Uint8Array; +} +export interface Metric_LabelsEntrySDKType { + key: string; + value: string; +} +/** + * A specific metric, identified by specifying values for all of the + * labels of a [`MetricDescriptor`][google.api.MetricDescriptor]. + */ +export interface Metric { + /** + * An existing metric type, see [google.api.MetricDescriptor][google.api.MetricDescriptor]. + * For example, `custom.googleapis.com/invoice/paid/amount`. + */ + type: string; + /** + * The set of label values that uniquely identify this metric. All + * labels listed in the `MetricDescriptor` must be assigned values. + */ + labels: { + [key: string]: string; + }; +} +export interface MetricProtoMsg { + typeUrl: "/google.api.Metric"; + value: Uint8Array; +} +/** + * A specific metric, identified by specifying values for all of the + * labels of a [`MetricDescriptor`][google.api.MetricDescriptor]. + */ +export interface MetricSDKType { + type: string; + labels: { + [key: string]: string; + }; +} +function createBaseMetricDescriptor(): MetricDescriptor { + return { + name: "", + type: "", + labels: [], + metricKind: 0, + valueType: 0, + unit: "", + description: "", + displayName: "", + metadata: undefined, + launchStage: 0, + monitoredResourceTypes: [] + }; +} +export const MetricDescriptor = { + typeUrl: "/google.api.MetricDescriptor", + encode(message: MetricDescriptor, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + if (message.type !== undefined) { + writer.uint32(66).string(message.type); + } + for (const v of message.labels) { + LabelDescriptor.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.metricKind !== 0) { + writer.uint32(24).int32(message.metricKind); + } + if (message.valueType !== 0) { + writer.uint32(32).int32(message.valueType); + } + if (message.unit !== undefined) { + writer.uint32(42).string(message.unit); + } + if (message.description !== undefined) { + writer.uint32(50).string(message.description); + } + if (message.displayName !== undefined) { + writer.uint32(58).string(message.displayName); + } + if (message.metadata !== undefined) { + MetricDescriptor_MetricDescriptorMetadata.encode(message.metadata, writer.uint32(82).fork()).ldelim(); + } + if (message.launchStage !== 0) { + writer.uint32(96).int32(message.launchStage); + } + for (const v of message.monitoredResourceTypes) { + writer.uint32(106).string(v!); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MetricDescriptor { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMetricDescriptor(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 8: + message.type = reader.string(); + break; + case 2: + message.labels.push(LabelDescriptor.decode(reader, reader.uint32())); + break; + case 3: + message.metricKind = (reader.int32() as any); + break; + case 4: + message.valueType = (reader.int32() as any); + break; + case 5: + message.unit = reader.string(); + break; + case 6: + message.description = reader.string(); + break; + case 7: + message.displayName = reader.string(); + break; + case 10: + message.metadata = MetricDescriptor_MetricDescriptorMetadata.decode(reader, reader.uint32()); + break; + case 12: + message.launchStage = (reader.int32() as any); + break; + case 13: + message.monitoredResourceTypes.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MetricDescriptor { + const obj = createBaseMetricDescriptor(); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.type)) obj.type = String(object.type); + if (Array.isArray(object?.labels)) obj.labels = object.labels.map((e: any) => LabelDescriptor.fromJSON(e)); + if (isSet(object.metricKind)) obj.metricKind = metricDescriptor_MetricKindFromJSON(object.metricKind); + if (isSet(object.valueType)) obj.valueType = metricDescriptor_ValueTypeFromJSON(object.valueType); + if (isSet(object.unit)) obj.unit = String(object.unit); + if (isSet(object.description)) obj.description = String(object.description); + if (isSet(object.displayName)) obj.displayName = String(object.displayName); + if (isSet(object.metadata)) obj.metadata = MetricDescriptor_MetricDescriptorMetadata.fromJSON(object.metadata); + if (isSet(object.launchStage)) obj.launchStage = launchStageFromJSON(object.launchStage); + if (Array.isArray(object?.monitoredResourceTypes)) obj.monitoredResourceTypes = object.monitoredResourceTypes.map((e: any) => String(e)); + return obj; + }, + toJSON(message: MetricDescriptor): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.type !== undefined && (obj.type = message.type); + if (message.labels) { + obj.labels = message.labels.map(e => e ? LabelDescriptor.toJSON(e) : undefined); + } else { + obj.labels = []; + } + message.metricKind !== undefined && (obj.metricKind = metricDescriptor_MetricKindToJSON(message.metricKind)); + message.valueType !== undefined && (obj.valueType = metricDescriptor_ValueTypeToJSON(message.valueType)); + message.unit !== undefined && (obj.unit = message.unit); + message.description !== undefined && (obj.description = message.description); + message.displayName !== undefined && (obj.displayName = message.displayName); + message.metadata !== undefined && (obj.metadata = message.metadata ? MetricDescriptor_MetricDescriptorMetadata.toJSON(message.metadata) : undefined); + message.launchStage !== undefined && (obj.launchStage = launchStageToJSON(message.launchStage)); + if (message.monitoredResourceTypes) { + obj.monitoredResourceTypes = message.monitoredResourceTypes.map(e => e); + } else { + obj.monitoredResourceTypes = []; + } + return obj; + }, + fromPartial(object: DeepPartial): MetricDescriptor { + const message = createBaseMetricDescriptor(); + message.name = object.name ?? ""; + message.type = object.type ?? ""; + message.labels = object.labels?.map(e => LabelDescriptor.fromPartial(e)) || []; + message.metricKind = object.metricKind ?? 0; + message.valueType = object.valueType ?? 0; + message.unit = object.unit ?? ""; + message.description = object.description ?? ""; + message.displayName = object.displayName ?? ""; + if (object.metadata !== undefined && object.metadata !== null) { + message.metadata = MetricDescriptor_MetricDescriptorMetadata.fromPartial(object.metadata); + } + message.launchStage = object.launchStage ?? 0; + message.monitoredResourceTypes = object.monitoredResourceTypes?.map(e => e) || []; + return message; + }, + fromSDK(object: MetricDescriptorSDKType): MetricDescriptor { + return { + name: object?.name, + type: object?.type, + labels: Array.isArray(object?.labels) ? object.labels.map((e: any) => LabelDescriptor.fromSDK(e)) : [], + metricKind: isSet(object.metric_kind) ? metricDescriptor_MetricKindFromJSON(object.metric_kind) : -1, + valueType: isSet(object.value_type) ? metricDescriptor_ValueTypeFromJSON(object.value_type) : -1, + unit: object?.unit, + description: object?.description, + displayName: object?.display_name, + metadata: object.metadata ? MetricDescriptor_MetricDescriptorMetadata.fromSDK(object.metadata) : undefined, + launchStage: isSet(object.launch_stage) ? launchStageFromJSON(object.launch_stage) : -1, + monitoredResourceTypes: Array.isArray(object?.monitored_resource_types) ? object.monitored_resource_types.map((e: any) => e) : [] + }; + }, + fromSDKJSON(object: any): MetricDescriptorSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + type: isSet(object.type) ? String(object.type) : "", + labels: Array.isArray(object?.labels) ? object.labels.map((e: any) => LabelDescriptor.fromSDKJSON(e)) : [], + metric_kind: isSet(object.metric_kind) ? metricDescriptor_MetricKindFromJSON(object.metric_kind) : -1, + value_type: isSet(object.value_type) ? metricDescriptor_ValueTypeFromJSON(object.value_type) : -1, + unit: isSet(object.unit) ? String(object.unit) : "", + description: isSet(object.description) ? String(object.description) : "", + display_name: isSet(object.display_name) ? String(object.display_name) : "", + metadata: isSet(object.metadata) ? MetricDescriptor_MetricDescriptorMetadata.fromSDKJSON(object.metadata) : undefined, + launch_stage: isSet(object.launch_stage) ? launchStageFromJSON(object.launch_stage) : -1, + monitored_resource_types: Array.isArray(object?.monitored_resource_types) ? object.monitored_resource_types.map((e: any) => String(e)) : [] + }; + }, + toSDK(message: MetricDescriptor): MetricDescriptorSDKType { + const obj: any = {}; + obj.name = message.name; + obj.type = message.type; + if (message.labels) { + obj.labels = message.labels.map(e => e ? LabelDescriptor.toSDK(e) : undefined); + } else { + obj.labels = []; + } + message.metricKind !== undefined && (obj.metric_kind = metricDescriptor_MetricKindToJSON(message.metricKind)); + message.valueType !== undefined && (obj.value_type = metricDescriptor_ValueTypeToJSON(message.valueType)); + obj.unit = message.unit; + obj.description = message.description; + obj.display_name = message.displayName; + message.metadata !== undefined && (obj.metadata = message.metadata ? MetricDescriptor_MetricDescriptorMetadata.toSDK(message.metadata) : undefined); + message.launchStage !== undefined && (obj.launch_stage = launchStageToJSON(message.launchStage)); + if (message.monitoredResourceTypes) { + obj.monitored_resource_types = message.monitoredResourceTypes.map(e => e); + } else { + obj.monitored_resource_types = []; + } + return obj; + }, + fromAmino(object: MetricDescriptorAmino): MetricDescriptor { + const message = createBaseMetricDescriptor(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + if (object.type !== undefined && object.type !== null) { + message.type = object.type; + } + message.labels = object.labels?.map(e => LabelDescriptor.fromAmino(e)) || []; + if (object.metric_kind !== undefined && object.metric_kind !== null) { + message.metricKind = object.metric_kind; + } + if (object.value_type !== undefined && object.value_type !== null) { + message.valueType = object.value_type; + } + if (object.unit !== undefined && object.unit !== null) { + message.unit = object.unit; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } + if (object.display_name !== undefined && object.display_name !== null) { + message.displayName = object.display_name; + } + if (object.metadata !== undefined && object.metadata !== null) { + message.metadata = MetricDescriptor_MetricDescriptorMetadata.fromAmino(object.metadata); + } + if (object.launch_stage !== undefined && object.launch_stage !== null) { + message.launchStage = object.launch_stage; + } + message.monitoredResourceTypes = object.monitored_resource_types?.map(e => e) || []; + return message; + }, + toAmino(message: MetricDescriptor): MetricDescriptorAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + obj.type = message.type === "" ? undefined : message.type; + if (message.labels) { + obj.labels = message.labels.map(e => e ? LabelDescriptor.toAmino(e) : undefined); + } else { + obj.labels = message.labels; + } + obj.metric_kind = message.metricKind === 0 ? undefined : message.metricKind; + obj.value_type = message.valueType === 0 ? undefined : message.valueType; + obj.unit = message.unit === "" ? undefined : message.unit; + obj.description = message.description === "" ? undefined : message.description; + obj.display_name = message.displayName === "" ? undefined : message.displayName; + obj.metadata = message.metadata ? MetricDescriptor_MetricDescriptorMetadata.toAmino(message.metadata) : undefined; + obj.launch_stage = message.launchStage === 0 ? undefined : message.launchStage; + if (message.monitoredResourceTypes) { + obj.monitored_resource_types = message.monitoredResourceTypes.map(e => e); + } else { + obj.monitored_resource_types = message.monitoredResourceTypes; + } + return obj; + }, + fromAminoMsg(object: MetricDescriptorAminoMsg): MetricDescriptor { + return MetricDescriptor.fromAmino(object.value); + }, + fromProtoMsg(message: MetricDescriptorProtoMsg): MetricDescriptor { + return MetricDescriptor.decode(message.value); + }, + toProto(message: MetricDescriptor): Uint8Array { + return MetricDescriptor.encode(message).finish(); + }, + toProtoMsg(message: MetricDescriptor): MetricDescriptorProtoMsg { + return { + typeUrl: "/google.api.MetricDescriptor", + value: MetricDescriptor.encode(message).finish() + }; + } +}; +function createBaseMetricDescriptor_MetricDescriptorMetadata(): MetricDescriptor_MetricDescriptorMetadata { + return { + launchStage: 0, + samplePeriod: undefined, + ingestDelay: undefined + }; +} +export const MetricDescriptor_MetricDescriptorMetadata = { + typeUrl: "/google.api.MetricDescriptorMetadata", + encode(message: MetricDescriptor_MetricDescriptorMetadata, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.launchStage !== 0) { + writer.uint32(8).int32(message.launchStage); + } + if (message.samplePeriod !== undefined) { + Duration.encode(message.samplePeriod, writer.uint32(18).fork()).ldelim(); + } + if (message.ingestDelay !== undefined) { + Duration.encode(message.ingestDelay, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MetricDescriptor_MetricDescriptorMetadata { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMetricDescriptor_MetricDescriptorMetadata(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.launchStage = (reader.int32() as any); + break; + case 2: + message.samplePeriod = Duration.decode(reader, reader.uint32()); + break; + case 3: + message.ingestDelay = Duration.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MetricDescriptor_MetricDescriptorMetadata { + const obj = createBaseMetricDescriptor_MetricDescriptorMetadata(); + if (isSet(object.launchStage)) obj.launchStage = launchStageFromJSON(object.launchStage); + if (isSet(object.samplePeriod)) obj.samplePeriod = Duration.fromJSON(object.samplePeriod); + if (isSet(object.ingestDelay)) obj.ingestDelay = Duration.fromJSON(object.ingestDelay); + return obj; + }, + toJSON(message: MetricDescriptor_MetricDescriptorMetadata): JsonSafe { + const obj: any = {}; + message.launchStage !== undefined && (obj.launchStage = launchStageToJSON(message.launchStage)); + message.samplePeriod !== undefined && (obj.samplePeriod = message.samplePeriod ? Duration.toJSON(message.samplePeriod) : undefined); + message.ingestDelay !== undefined && (obj.ingestDelay = message.ingestDelay ? Duration.toJSON(message.ingestDelay) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): MetricDescriptor_MetricDescriptorMetadata { + const message = createBaseMetricDescriptor_MetricDescriptorMetadata(); + message.launchStage = object.launchStage ?? 0; + if (object.samplePeriod !== undefined && object.samplePeriod !== null) { + message.samplePeriod = Duration.fromPartial(object.samplePeriod); + } + if (object.ingestDelay !== undefined && object.ingestDelay !== null) { + message.ingestDelay = Duration.fromPartial(object.ingestDelay); + } + return message; + }, + fromSDK(object: MetricDescriptor_MetricDescriptorMetadataSDKType): MetricDescriptor_MetricDescriptorMetadata { + return { + launchStage: isSet(object.launch_stage) ? launchStageFromJSON(object.launch_stage) : -1, + samplePeriod: object.sample_period ? Duration.fromSDK(object.sample_period) : undefined, + ingestDelay: object.ingest_delay ? Duration.fromSDK(object.ingest_delay) : undefined + }; + }, + fromSDKJSON(object: any): MetricDescriptor_MetricDescriptorMetadataSDKType { + return { + launch_stage: isSet(object.launch_stage) ? launchStageFromJSON(object.launch_stage) : -1, + sample_period: isSet(object.sample_period) ? Duration.fromSDKJSON(object.sample_period) : undefined, + ingest_delay: isSet(object.ingest_delay) ? Duration.fromSDKJSON(object.ingest_delay) : undefined + }; + }, + toSDK(message: MetricDescriptor_MetricDescriptorMetadata): MetricDescriptor_MetricDescriptorMetadataSDKType { + const obj: any = {}; + message.launchStage !== undefined && (obj.launch_stage = launchStageToJSON(message.launchStage)); + message.samplePeriod !== undefined && (obj.sample_period = message.samplePeriod ? Duration.toSDK(message.samplePeriod) : undefined); + message.ingestDelay !== undefined && (obj.ingest_delay = message.ingestDelay ? Duration.toSDK(message.ingestDelay) : undefined); + return obj; + }, + fromAmino(object: MetricDescriptor_MetricDescriptorMetadataAmino): MetricDescriptor_MetricDescriptorMetadata { + const message = createBaseMetricDescriptor_MetricDescriptorMetadata(); + if (object.launch_stage !== undefined && object.launch_stage !== null) { + message.launchStage = object.launch_stage; + } + if (object.sample_period !== undefined && object.sample_period !== null) { + message.samplePeriod = Duration.fromAmino(object.sample_period); + } + if (object.ingest_delay !== undefined && object.ingest_delay !== null) { + message.ingestDelay = Duration.fromAmino(object.ingest_delay); + } + return message; + }, + toAmino(message: MetricDescriptor_MetricDescriptorMetadata): MetricDescriptor_MetricDescriptorMetadataAmino { + const obj: any = {}; + obj.launch_stage = message.launchStage === 0 ? undefined : message.launchStage; + obj.sample_period = message.samplePeriod ? Duration.toAmino(message.samplePeriod) : undefined; + obj.ingest_delay = message.ingestDelay ? Duration.toAmino(message.ingestDelay) : undefined; + return obj; + }, + fromAminoMsg(object: MetricDescriptor_MetricDescriptorMetadataAminoMsg): MetricDescriptor_MetricDescriptorMetadata { + return MetricDescriptor_MetricDescriptorMetadata.fromAmino(object.value); + }, + fromProtoMsg(message: MetricDescriptor_MetricDescriptorMetadataProtoMsg): MetricDescriptor_MetricDescriptorMetadata { + return MetricDescriptor_MetricDescriptorMetadata.decode(message.value); + }, + toProto(message: MetricDescriptor_MetricDescriptorMetadata): Uint8Array { + return MetricDescriptor_MetricDescriptorMetadata.encode(message).finish(); + }, + toProtoMsg(message: MetricDescriptor_MetricDescriptorMetadata): MetricDescriptor_MetricDescriptorMetadataProtoMsg { + return { + typeUrl: "/google.api.MetricDescriptorMetadata", + value: MetricDescriptor_MetricDescriptorMetadata.encode(message).finish() + }; + } +}; +function createBaseMetric_LabelsEntry(): Metric_LabelsEntry { + return { + key: "", + value: "" + }; +} +export const Metric_LabelsEntry = { + encode(message: Metric_LabelsEntry, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.key !== undefined) { + writer.uint32(10).string(message.key); + } + if (message.value !== undefined) { + writer.uint32(18).string(message.value); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Metric_LabelsEntry { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMetric_LabelsEntry(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.string(); + break; + case 2: + message.value = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Metric_LabelsEntry { + const obj = createBaseMetric_LabelsEntry(); + if (isSet(object.key)) obj.key = String(object.key); + if (isSet(object.value)) obj.value = String(object.value); + return obj; + }, + toJSON(message: Metric_LabelsEntry): JsonSafe { + const obj: any = {}; + message.key !== undefined && (obj.key = message.key); + message.value !== undefined && (obj.value = message.value); + return obj; + }, + fromPartial(object: DeepPartial): Metric_LabelsEntry { + const message = createBaseMetric_LabelsEntry(); + message.key = object.key ?? ""; + message.value = object.value ?? ""; + return message; + }, + fromSDK(object: Metric_LabelsEntrySDKType): Metric_LabelsEntry { + return { + key: object?.key, + value: object?.value + }; + }, + fromSDKJSON(object: any): Metric_LabelsEntrySDKType { + return { + key: isSet(object.key) ? String(object.key) : "", + value: isSet(object.value) ? String(object.value) : "" + }; + }, + toSDK(message: Metric_LabelsEntry): Metric_LabelsEntrySDKType { + const obj: any = {}; + obj.key = message.key; + obj.value = message.value; + return obj; + }, + fromAmino(object: Metric_LabelsEntryAmino): Metric_LabelsEntry { + const message = createBaseMetric_LabelsEntry(); + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } + if (object.value !== undefined && object.value !== null) { + message.value = object.value; + } + return message; + }, + toAmino(message: Metric_LabelsEntry): Metric_LabelsEntryAmino { + const obj: any = {}; + obj.key = message.key === "" ? undefined : message.key; + obj.value = message.value === "" ? undefined : message.value; + return obj; + }, + fromAminoMsg(object: Metric_LabelsEntryAminoMsg): Metric_LabelsEntry { + return Metric_LabelsEntry.fromAmino(object.value); + }, + fromProtoMsg(message: Metric_LabelsEntryProtoMsg): Metric_LabelsEntry { + return Metric_LabelsEntry.decode(message.value); + }, + toProto(message: Metric_LabelsEntry): Uint8Array { + return Metric_LabelsEntry.encode(message).finish(); + } +}; +function createBaseMetric(): Metric { + return { + type: "", + labels: {} + }; +} +export const Metric = { + typeUrl: "/google.api.Metric", + encode(message: Metric, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.type !== undefined) { + writer.uint32(26).string(message.type); + } + Object.entries(message.labels).forEach(([key, value]) => { + Metric_LabelsEntry.encode({ + key: (key as any), + value + }, writer.uint32(18).fork()).ldelim(); + }); + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Metric { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMetric(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 3: + message.type = reader.string(); + break; + case 2: + const entry2 = Metric_LabelsEntry.decode(reader, reader.uint32()); + if (entry2.value !== undefined) { + message.labels[entry2.key] = entry2.value; + } + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Metric { + const obj = createBaseMetric(); + if (isSet(object.type)) obj.type = String(object.type); + if (isObject(object.labels)) obj.labels = Object.entries(object.labels).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + acc[key] = String(value); + return acc; + }, {}); + return obj; + }, + toJSON(message: Metric): JsonSafe { + const obj: any = {}; + message.type !== undefined && (obj.type = message.type); + obj.labels = {}; + if (message.labels) { + Object.entries(message.labels).forEach(([k, v]) => { + obj.labels[k] = v; + }); + } + return obj; + }, + fromPartial(object: DeepPartial): Metric { + const message = createBaseMetric(); + message.type = object.type ?? ""; + message.labels = Object.entries(object.labels ?? {}).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + if (value !== undefined) { + acc[key] = String(value); + } + return acc; + }, {}); + return message; + }, + fromSDK(object: MetricSDKType): Metric { + return { + type: object?.type, + labels: isObject(object.labels) ? Object.entries(object.labels).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + acc[key] = String(value); + return acc; + }, {}) : {} + }; + }, + fromSDKJSON(object: any): MetricSDKType { + return { + type: isSet(object.type) ? String(object.type) : "", + labels: isObject(object.labels) ? Object.entries(object.labels).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + acc[key] = String(value); + return acc; + }, {}) : {} + }; + }, + toSDK(message: Metric): MetricSDKType { + const obj: any = {}; + obj.type = message.type; + obj.labels = {}; + if (message.labels) { + Object.entries(message.labels).forEach(([k, v]) => { + obj.labels[k] = v; + }); + } + return obj; + }, + fromAmino(object: MetricAmino): Metric { + const message = createBaseMetric(); + if (object.type !== undefined && object.type !== null) { + message.type = object.type; + } + message.labels = Object.entries(object.labels ?? {}).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + if (value !== undefined) { + acc[key] = String(value); + } + return acc; + }, {}); + return message; + }, + toAmino(message: Metric): MetricAmino { + const obj: any = {}; + obj.type = message.type === "" ? undefined : message.type; + obj.labels = {}; + if (message.labels) { + Object.entries(message.labels).forEach(([k, v]) => { + obj.labels[k] = v; + }); + } + return obj; + }, + fromAminoMsg(object: MetricAminoMsg): Metric { + return Metric.fromAmino(object.value); + }, + fromProtoMsg(message: MetricProtoMsg): Metric { + return Metric.decode(message.value); + }, + toProto(message: Metric): Uint8Array { + return Metric.encode(message).finish(); + }, + toProtoMsg(message: Metric): MetricProtoMsg { + return { + typeUrl: "/google.api.Metric", + value: Metric.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/api/monitored_resource.ts b/__fixtures__/v-next/outputicjsdeps/google/api/monitored_resource.ts new file mode 100644 index 0000000000..145d16fdc8 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/api/monitored_resource.ts @@ -0,0 +1,889 @@ +import { LabelDescriptor, LabelDescriptorSDKType } from "./label.js"; +import { LaunchStage, LaunchStageSDKType, launchStageFromJSON, launchStageToJSON } from "./launch_stage.js"; +import { Struct, StructSDKType } from "../protobuf/struct.js"; +import { BinaryReader, BinaryWriter } from "../../binary.js"; +import { isSet, DeepPartial, isObject } from "../../helpers.js"; +import { JsonSafe } from "../../json-safe.js"; +export const protobufPackage = "google.api"; +/** + * An object that describes the schema of a [MonitoredResource][google.api.MonitoredResource] object using a + * type name and a set of labels. For example, the monitored resource + * descriptor for Google Compute Engine VM instances has a type of + * `"gce_instance"` and specifies the use of the labels `"instance_id"` and + * `"zone"` to identify particular VM instances. + * + * Different APIs can support different monitored resource types. APIs generally + * provide a `list` method that returns the monitored resource descriptors used + * by the API. + */ +export interface MonitoredResourceDescriptor { + /** + * Optional. The resource name of the monitored resource descriptor: + * `"projects/{project_id}/monitoredResourceDescriptors/{type}"` where + * {type} is the value of the `type` field in this object and + * {project_id} is a project ID that provides API-specific context for + * accessing the type. APIs that do not use project information can use the + * resource name format `"monitoredResourceDescriptors/{type}"`. + */ + name: string; + /** + * Required. The monitored resource type. For example, the type + * `"cloudsql_database"` represents databases in Google Cloud SQL. + */ + type: string; + /** + * Optional. A concise name for the monitored resource type that might be + * displayed in user interfaces. It should be a Title Cased Noun Phrase, + * without any article or other determiners. For example, + * `"Google Cloud SQL Database"`. + */ + displayName: string; + /** + * Optional. A detailed description of the monitored resource type that might + * be used in documentation. + */ + description: string; + /** + * Required. A set of labels used to describe instances of this monitored + * resource type. For example, an individual Google Cloud SQL database is + * identified by values for the labels `"database_id"` and `"zone"`. + */ + labels: LabelDescriptor[]; + /** Optional. The launch stage of the monitored resource definition. */ + launchStage: LaunchStage; +} +export interface MonitoredResourceDescriptorProtoMsg { + typeUrl: "/google.api.MonitoredResourceDescriptor"; + value: Uint8Array; +} +/** + * An object that describes the schema of a [MonitoredResource][google.api.MonitoredResource] object using a + * type name and a set of labels. For example, the monitored resource + * descriptor for Google Compute Engine VM instances has a type of + * `"gce_instance"` and specifies the use of the labels `"instance_id"` and + * `"zone"` to identify particular VM instances. + * + * Different APIs can support different monitored resource types. APIs generally + * provide a `list` method that returns the monitored resource descriptors used + * by the API. + */ +export interface MonitoredResourceDescriptorSDKType { + name: string; + type: string; + display_name: string; + description: string; + labels: LabelDescriptorSDKType[]; + launch_stage: LaunchStage; +} +export interface MonitoredResource_LabelsEntry { + key: string; + value: string; +} +export interface MonitoredResource_LabelsEntryProtoMsg { + typeUrl: string; + value: Uint8Array; +} +export interface MonitoredResource_LabelsEntrySDKType { + key: string; + value: string; +} +/** + * An object representing a resource that can be used for monitoring, logging, + * billing, or other purposes. Examples include virtual machine instances, + * databases, and storage devices such as disks. The `type` field identifies a + * [MonitoredResourceDescriptor][google.api.MonitoredResourceDescriptor] object that describes the resource's + * schema. Information in the `labels` field identifies the actual resource and + * its attributes according to the schema. For example, a particular Compute + * Engine VM instance could be represented by the following object, because the + * [MonitoredResourceDescriptor][google.api.MonitoredResourceDescriptor] for `"gce_instance"` has labels + * `"instance_id"` and `"zone"`: + * + * { "type": "gce_instance", + * "labels": { "instance_id": "12345678901234", + * "zone": "us-central1-a" }} + */ +export interface MonitoredResource { + /** + * Required. The monitored resource type. This field must match + * the `type` field of a [MonitoredResourceDescriptor][google.api.MonitoredResourceDescriptor] object. For + * example, the type of a Compute Engine VM instance is `gce_instance`. + */ + type: string; + /** + * Required. Values for all of the labels listed in the associated monitored + * resource descriptor. For example, Compute Engine VM instances use the + * labels `"project_id"`, `"instance_id"`, and `"zone"`. + */ + labels: { + [key: string]: string; + }; +} +export interface MonitoredResourceProtoMsg { + typeUrl: "/google.api.MonitoredResource"; + value: Uint8Array; +} +/** + * An object representing a resource that can be used for monitoring, logging, + * billing, or other purposes. Examples include virtual machine instances, + * databases, and storage devices such as disks. The `type` field identifies a + * [MonitoredResourceDescriptor][google.api.MonitoredResourceDescriptor] object that describes the resource's + * schema. Information in the `labels` field identifies the actual resource and + * its attributes according to the schema. For example, a particular Compute + * Engine VM instance could be represented by the following object, because the + * [MonitoredResourceDescriptor][google.api.MonitoredResourceDescriptor] for `"gce_instance"` has labels + * `"instance_id"` and `"zone"`: + * + * { "type": "gce_instance", + * "labels": { "instance_id": "12345678901234", + * "zone": "us-central1-a" }} + */ +export interface MonitoredResourceSDKType { + type: string; + labels: { + [key: string]: string; + }; +} +export interface MonitoredResourceMetadata_UserLabelsEntry { + key: string; + value: string; +} +export interface MonitoredResourceMetadata_UserLabelsEntryProtoMsg { + typeUrl: string; + value: Uint8Array; +} +export interface MonitoredResourceMetadata_UserLabelsEntrySDKType { + key: string; + value: string; +} +/** + * Auxiliary metadata for a [MonitoredResource][google.api.MonitoredResource] object. + * [MonitoredResource][google.api.MonitoredResource] objects contain the minimum set of information to + * uniquely identify a monitored resource instance. There is some other useful + * auxiliary metadata. Monitoring and Logging use an ingestion + * pipeline to extract metadata for cloud resources of all types, and store + * the metadata in this message. + */ +export interface MonitoredResourceMetadata { + /** + * Output only. Values for predefined system metadata labels. + * System labels are a kind of metadata extracted by Google, including + * "machine_image", "vpc", "subnet_id", + * "security_group", "name", etc. + * System label values can be only strings, Boolean values, or a list of + * strings. For example: + * + * { "name": "my-test-instance", + * "security_group": ["a", "b", "c"], + * "spot_instance": false } + */ + systemLabels?: Struct; + /** Output only. A map of user-defined metadata labels. */ + userLabels: { + [key: string]: string; + }; +} +export interface MonitoredResourceMetadataProtoMsg { + typeUrl: "/google.api.MonitoredResourceMetadata"; + value: Uint8Array; +} +/** + * Auxiliary metadata for a [MonitoredResource][google.api.MonitoredResource] object. + * [MonitoredResource][google.api.MonitoredResource] objects contain the minimum set of information to + * uniquely identify a monitored resource instance. There is some other useful + * auxiliary metadata. Monitoring and Logging use an ingestion + * pipeline to extract metadata for cloud resources of all types, and store + * the metadata in this message. + */ +export interface MonitoredResourceMetadataSDKType { + system_labels?: StructSDKType; + user_labels: { + [key: string]: string; + }; +} +function createBaseMonitoredResourceDescriptor(): MonitoredResourceDescriptor { + return { + name: "", + type: "", + displayName: "", + description: "", + labels: [], + launchStage: 0 + }; +} +export const MonitoredResourceDescriptor = { + typeUrl: "/google.api.MonitoredResourceDescriptor", + encode(message: MonitoredResourceDescriptor, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(42).string(message.name); + } + if (message.type !== undefined) { + writer.uint32(10).string(message.type); + } + if (message.displayName !== undefined) { + writer.uint32(18).string(message.displayName); + } + if (message.description !== undefined) { + writer.uint32(26).string(message.description); + } + for (const v of message.labels) { + LabelDescriptor.encode(v!, writer.uint32(34).fork()).ldelim(); + } + if (message.launchStage !== 0) { + writer.uint32(56).int32(message.launchStage); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MonitoredResourceDescriptor { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMonitoredResourceDescriptor(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 5: + message.name = reader.string(); + break; + case 1: + message.type = reader.string(); + break; + case 2: + message.displayName = reader.string(); + break; + case 3: + message.description = reader.string(); + break; + case 4: + message.labels.push(LabelDescriptor.decode(reader, reader.uint32())); + break; + case 7: + message.launchStage = (reader.int32() as any); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MonitoredResourceDescriptor { + const obj = createBaseMonitoredResourceDescriptor(); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.type)) obj.type = String(object.type); + if (isSet(object.displayName)) obj.displayName = String(object.displayName); + if (isSet(object.description)) obj.description = String(object.description); + if (Array.isArray(object?.labels)) obj.labels = object.labels.map((e: any) => LabelDescriptor.fromJSON(e)); + if (isSet(object.launchStage)) obj.launchStage = launchStageFromJSON(object.launchStage); + return obj; + }, + toJSON(message: MonitoredResourceDescriptor): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.type !== undefined && (obj.type = message.type); + message.displayName !== undefined && (obj.displayName = message.displayName); + message.description !== undefined && (obj.description = message.description); + if (message.labels) { + obj.labels = message.labels.map(e => e ? LabelDescriptor.toJSON(e) : undefined); + } else { + obj.labels = []; + } + message.launchStage !== undefined && (obj.launchStage = launchStageToJSON(message.launchStage)); + return obj; + }, + fromPartial(object: DeepPartial): MonitoredResourceDescriptor { + const message = createBaseMonitoredResourceDescriptor(); + message.name = object.name ?? ""; + message.type = object.type ?? ""; + message.displayName = object.displayName ?? ""; + message.description = object.description ?? ""; + message.labels = object.labels?.map(e => LabelDescriptor.fromPartial(e)) || []; + message.launchStage = object.launchStage ?? 0; + return message; + }, + fromSDK(object: MonitoredResourceDescriptorSDKType): MonitoredResourceDescriptor { + return { + name: object?.name, + type: object?.type, + displayName: object?.display_name, + description: object?.description, + labels: Array.isArray(object?.labels) ? object.labels.map((e: any) => LabelDescriptor.fromSDK(e)) : [], + launchStage: isSet(object.launch_stage) ? launchStageFromJSON(object.launch_stage) : -1 + }; + }, + fromSDKJSON(object: any): MonitoredResourceDescriptorSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + type: isSet(object.type) ? String(object.type) : "", + display_name: isSet(object.display_name) ? String(object.display_name) : "", + description: isSet(object.description) ? String(object.description) : "", + labels: Array.isArray(object?.labels) ? object.labels.map((e: any) => LabelDescriptor.fromSDKJSON(e)) : [], + launch_stage: isSet(object.launch_stage) ? launchStageFromJSON(object.launch_stage) : -1 + }; + }, + toSDK(message: MonitoredResourceDescriptor): MonitoredResourceDescriptorSDKType { + const obj: any = {}; + obj.name = message.name; + obj.type = message.type; + obj.display_name = message.displayName; + obj.description = message.description; + if (message.labels) { + obj.labels = message.labels.map(e => e ? LabelDescriptor.toSDK(e) : undefined); + } else { + obj.labels = []; + } + message.launchStage !== undefined && (obj.launch_stage = launchStageToJSON(message.launchStage)); + return obj; + }, + fromAmino(object: MonitoredResourceDescriptorAmino): MonitoredResourceDescriptor { + const message = createBaseMonitoredResourceDescriptor(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + if (object.type !== undefined && object.type !== null) { + message.type = object.type; + } + if (object.display_name !== undefined && object.display_name !== null) { + message.displayName = object.display_name; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } + message.labels = object.labels?.map(e => LabelDescriptor.fromAmino(e)) || []; + if (object.launch_stage !== undefined && object.launch_stage !== null) { + message.launchStage = object.launch_stage; + } + return message; + }, + toAmino(message: MonitoredResourceDescriptor): MonitoredResourceDescriptorAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + obj.type = message.type === "" ? undefined : message.type; + obj.display_name = message.displayName === "" ? undefined : message.displayName; + obj.description = message.description === "" ? undefined : message.description; + if (message.labels) { + obj.labels = message.labels.map(e => e ? LabelDescriptor.toAmino(e) : undefined); + } else { + obj.labels = message.labels; + } + obj.launch_stage = message.launchStage === 0 ? undefined : message.launchStage; + return obj; + }, + fromAminoMsg(object: MonitoredResourceDescriptorAminoMsg): MonitoredResourceDescriptor { + return MonitoredResourceDescriptor.fromAmino(object.value); + }, + fromProtoMsg(message: MonitoredResourceDescriptorProtoMsg): MonitoredResourceDescriptor { + return MonitoredResourceDescriptor.decode(message.value); + }, + toProto(message: MonitoredResourceDescriptor): Uint8Array { + return MonitoredResourceDescriptor.encode(message).finish(); + }, + toProtoMsg(message: MonitoredResourceDescriptor): MonitoredResourceDescriptorProtoMsg { + return { + typeUrl: "/google.api.MonitoredResourceDescriptor", + value: MonitoredResourceDescriptor.encode(message).finish() + }; + } +}; +function createBaseMonitoredResource_LabelsEntry(): MonitoredResource_LabelsEntry { + return { + key: "", + value: "" + }; +} +export const MonitoredResource_LabelsEntry = { + encode(message: MonitoredResource_LabelsEntry, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.key !== undefined) { + writer.uint32(10).string(message.key); + } + if (message.value !== undefined) { + writer.uint32(18).string(message.value); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MonitoredResource_LabelsEntry { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMonitoredResource_LabelsEntry(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.string(); + break; + case 2: + message.value = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MonitoredResource_LabelsEntry { + const obj = createBaseMonitoredResource_LabelsEntry(); + if (isSet(object.key)) obj.key = String(object.key); + if (isSet(object.value)) obj.value = String(object.value); + return obj; + }, + toJSON(message: MonitoredResource_LabelsEntry): JsonSafe { + const obj: any = {}; + message.key !== undefined && (obj.key = message.key); + message.value !== undefined && (obj.value = message.value); + return obj; + }, + fromPartial(object: DeepPartial): MonitoredResource_LabelsEntry { + const message = createBaseMonitoredResource_LabelsEntry(); + message.key = object.key ?? ""; + message.value = object.value ?? ""; + return message; + }, + fromSDK(object: MonitoredResource_LabelsEntrySDKType): MonitoredResource_LabelsEntry { + return { + key: object?.key, + value: object?.value + }; + }, + fromSDKJSON(object: any): MonitoredResource_LabelsEntrySDKType { + return { + key: isSet(object.key) ? String(object.key) : "", + value: isSet(object.value) ? String(object.value) : "" + }; + }, + toSDK(message: MonitoredResource_LabelsEntry): MonitoredResource_LabelsEntrySDKType { + const obj: any = {}; + obj.key = message.key; + obj.value = message.value; + return obj; + }, + fromAmino(object: MonitoredResource_LabelsEntryAmino): MonitoredResource_LabelsEntry { + const message = createBaseMonitoredResource_LabelsEntry(); + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } + if (object.value !== undefined && object.value !== null) { + message.value = object.value; + } + return message; + }, + toAmino(message: MonitoredResource_LabelsEntry): MonitoredResource_LabelsEntryAmino { + const obj: any = {}; + obj.key = message.key === "" ? undefined : message.key; + obj.value = message.value === "" ? undefined : message.value; + return obj; + }, + fromAminoMsg(object: MonitoredResource_LabelsEntryAminoMsg): MonitoredResource_LabelsEntry { + return MonitoredResource_LabelsEntry.fromAmino(object.value); + }, + fromProtoMsg(message: MonitoredResource_LabelsEntryProtoMsg): MonitoredResource_LabelsEntry { + return MonitoredResource_LabelsEntry.decode(message.value); + }, + toProto(message: MonitoredResource_LabelsEntry): Uint8Array { + return MonitoredResource_LabelsEntry.encode(message).finish(); + } +}; +function createBaseMonitoredResource(): MonitoredResource { + return { + type: "", + labels: {} + }; +} +export const MonitoredResource = { + typeUrl: "/google.api.MonitoredResource", + encode(message: MonitoredResource, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.type !== undefined) { + writer.uint32(10).string(message.type); + } + Object.entries(message.labels).forEach(([key, value]) => { + MonitoredResource_LabelsEntry.encode({ + key: (key as any), + value + }, writer.uint32(18).fork()).ldelim(); + }); + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MonitoredResource { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMonitoredResource(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.type = reader.string(); + break; + case 2: + const entry2 = MonitoredResource_LabelsEntry.decode(reader, reader.uint32()); + if (entry2.value !== undefined) { + message.labels[entry2.key] = entry2.value; + } + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MonitoredResource { + const obj = createBaseMonitoredResource(); + if (isSet(object.type)) obj.type = String(object.type); + if (isObject(object.labels)) obj.labels = Object.entries(object.labels).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + acc[key] = String(value); + return acc; + }, {}); + return obj; + }, + toJSON(message: MonitoredResource): JsonSafe { + const obj: any = {}; + message.type !== undefined && (obj.type = message.type); + obj.labels = {}; + if (message.labels) { + Object.entries(message.labels).forEach(([k, v]) => { + obj.labels[k] = v; + }); + } + return obj; + }, + fromPartial(object: DeepPartial): MonitoredResource { + const message = createBaseMonitoredResource(); + message.type = object.type ?? ""; + message.labels = Object.entries(object.labels ?? {}).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + if (value !== undefined) { + acc[key] = String(value); + } + return acc; + }, {}); + return message; + }, + fromSDK(object: MonitoredResourceSDKType): MonitoredResource { + return { + type: object?.type, + labels: isObject(object.labels) ? Object.entries(object.labels).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + acc[key] = String(value); + return acc; + }, {}) : {} + }; + }, + fromSDKJSON(object: any): MonitoredResourceSDKType { + return { + type: isSet(object.type) ? String(object.type) : "", + labels: isObject(object.labels) ? Object.entries(object.labels).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + acc[key] = String(value); + return acc; + }, {}) : {} + }; + }, + toSDK(message: MonitoredResource): MonitoredResourceSDKType { + const obj: any = {}; + obj.type = message.type; + obj.labels = {}; + if (message.labels) { + Object.entries(message.labels).forEach(([k, v]) => { + obj.labels[k] = v; + }); + } + return obj; + }, + fromAmino(object: MonitoredResourceAmino): MonitoredResource { + const message = createBaseMonitoredResource(); + if (object.type !== undefined && object.type !== null) { + message.type = object.type; + } + message.labels = Object.entries(object.labels ?? {}).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + if (value !== undefined) { + acc[key] = String(value); + } + return acc; + }, {}); + return message; + }, + toAmino(message: MonitoredResource): MonitoredResourceAmino { + const obj: any = {}; + obj.type = message.type === "" ? undefined : message.type; + obj.labels = {}; + if (message.labels) { + Object.entries(message.labels).forEach(([k, v]) => { + obj.labels[k] = v; + }); + } + return obj; + }, + fromAminoMsg(object: MonitoredResourceAminoMsg): MonitoredResource { + return MonitoredResource.fromAmino(object.value); + }, + fromProtoMsg(message: MonitoredResourceProtoMsg): MonitoredResource { + return MonitoredResource.decode(message.value); + }, + toProto(message: MonitoredResource): Uint8Array { + return MonitoredResource.encode(message).finish(); + }, + toProtoMsg(message: MonitoredResource): MonitoredResourceProtoMsg { + return { + typeUrl: "/google.api.MonitoredResource", + value: MonitoredResource.encode(message).finish() + }; + } +}; +function createBaseMonitoredResourceMetadata_UserLabelsEntry(): MonitoredResourceMetadata_UserLabelsEntry { + return { + key: "", + value: "" + }; +} +export const MonitoredResourceMetadata_UserLabelsEntry = { + encode(message: MonitoredResourceMetadata_UserLabelsEntry, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.key !== undefined) { + writer.uint32(10).string(message.key); + } + if (message.value !== undefined) { + writer.uint32(18).string(message.value); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MonitoredResourceMetadata_UserLabelsEntry { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMonitoredResourceMetadata_UserLabelsEntry(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.string(); + break; + case 2: + message.value = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MonitoredResourceMetadata_UserLabelsEntry { + const obj = createBaseMonitoredResourceMetadata_UserLabelsEntry(); + if (isSet(object.key)) obj.key = String(object.key); + if (isSet(object.value)) obj.value = String(object.value); + return obj; + }, + toJSON(message: MonitoredResourceMetadata_UserLabelsEntry): JsonSafe { + const obj: any = {}; + message.key !== undefined && (obj.key = message.key); + message.value !== undefined && (obj.value = message.value); + return obj; + }, + fromPartial(object: DeepPartial): MonitoredResourceMetadata_UserLabelsEntry { + const message = createBaseMonitoredResourceMetadata_UserLabelsEntry(); + message.key = object.key ?? ""; + message.value = object.value ?? ""; + return message; + }, + fromSDK(object: MonitoredResourceMetadata_UserLabelsEntrySDKType): MonitoredResourceMetadata_UserLabelsEntry { + return { + key: object?.key, + value: object?.value + }; + }, + fromSDKJSON(object: any): MonitoredResourceMetadata_UserLabelsEntrySDKType { + return { + key: isSet(object.key) ? String(object.key) : "", + value: isSet(object.value) ? String(object.value) : "" + }; + }, + toSDK(message: MonitoredResourceMetadata_UserLabelsEntry): MonitoredResourceMetadata_UserLabelsEntrySDKType { + const obj: any = {}; + obj.key = message.key; + obj.value = message.value; + return obj; + }, + fromAmino(object: MonitoredResourceMetadata_UserLabelsEntryAmino): MonitoredResourceMetadata_UserLabelsEntry { + const message = createBaseMonitoredResourceMetadata_UserLabelsEntry(); + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } + if (object.value !== undefined && object.value !== null) { + message.value = object.value; + } + return message; + }, + toAmino(message: MonitoredResourceMetadata_UserLabelsEntry): MonitoredResourceMetadata_UserLabelsEntryAmino { + const obj: any = {}; + obj.key = message.key === "" ? undefined : message.key; + obj.value = message.value === "" ? undefined : message.value; + return obj; + }, + fromAminoMsg(object: MonitoredResourceMetadata_UserLabelsEntryAminoMsg): MonitoredResourceMetadata_UserLabelsEntry { + return MonitoredResourceMetadata_UserLabelsEntry.fromAmino(object.value); + }, + fromProtoMsg(message: MonitoredResourceMetadata_UserLabelsEntryProtoMsg): MonitoredResourceMetadata_UserLabelsEntry { + return MonitoredResourceMetadata_UserLabelsEntry.decode(message.value); + }, + toProto(message: MonitoredResourceMetadata_UserLabelsEntry): Uint8Array { + return MonitoredResourceMetadata_UserLabelsEntry.encode(message).finish(); + } +}; +function createBaseMonitoredResourceMetadata(): MonitoredResourceMetadata { + return { + systemLabels: undefined, + userLabels: {} + }; +} +export const MonitoredResourceMetadata = { + typeUrl: "/google.api.MonitoredResourceMetadata", + encode(message: MonitoredResourceMetadata, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.systemLabels !== undefined) { + Struct.encode(message.systemLabels, writer.uint32(10).fork()).ldelim(); + } + Object.entries(message.userLabels).forEach(([key, value]) => { + MonitoredResourceMetadata_UserLabelsEntry.encode({ + key: (key as any), + value + }, writer.uint32(18).fork()).ldelim(); + }); + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MonitoredResourceMetadata { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMonitoredResourceMetadata(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.systemLabels = Struct.decode(reader, reader.uint32()); + break; + case 2: + const entry2 = MonitoredResourceMetadata_UserLabelsEntry.decode(reader, reader.uint32()); + if (entry2.value !== undefined) { + message.userLabels[entry2.key] = entry2.value; + } + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MonitoredResourceMetadata { + const obj = createBaseMonitoredResourceMetadata(); + if (isSet(object.systemLabels)) obj.systemLabels = Struct.fromJSON(object.systemLabels); + if (isObject(object.userLabels)) obj.userLabels = Object.entries(object.userLabels).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + acc[key] = String(value); + return acc; + }, {}); + return obj; + }, + toJSON(message: MonitoredResourceMetadata): JsonSafe { + const obj: any = {}; + message.systemLabels !== undefined && (obj.systemLabels = message.systemLabels ? Struct.toJSON(message.systemLabels) : undefined); + obj.userLabels = {}; + if (message.userLabels) { + Object.entries(message.userLabels).forEach(([k, v]) => { + obj.userLabels[k] = v; + }); + } + return obj; + }, + fromPartial(object: DeepPartial): MonitoredResourceMetadata { + const message = createBaseMonitoredResourceMetadata(); + if (object.systemLabels !== undefined && object.systemLabels !== null) { + message.systemLabels = Struct.fromPartial(object.systemLabels); + } + message.userLabels = Object.entries(object.userLabels ?? {}).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + if (value !== undefined) { + acc[key] = String(value); + } + return acc; + }, {}); + return message; + }, + fromSDK(object: MonitoredResourceMetadataSDKType): MonitoredResourceMetadata { + return { + systemLabels: object.system_labels ? Struct.fromSDK(object.system_labels) : undefined, + userLabels: isObject(object.user_labels) ? Object.entries(object.user_labels).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + acc[key] = String(value); + return acc; + }, {}) : {} + }; + }, + fromSDKJSON(object: any): MonitoredResourceMetadataSDKType { + return { + system_labels: isSet(object.system_labels) ? Struct.fromSDKJSON(object.system_labels) : undefined, + user_labels: isObject(object.user_labels) ? Object.entries(object.user_labels).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + acc[key] = String(value); + return acc; + }, {}) : {} + }; + }, + toSDK(message: MonitoredResourceMetadata): MonitoredResourceMetadataSDKType { + const obj: any = {}; + message.systemLabels !== undefined && (obj.system_labels = message.systemLabels ? Struct.toSDK(message.systemLabels) : undefined); + obj.user_labels = {}; + if (message.userLabels) { + Object.entries(message.userLabels).forEach(([k, v]) => { + obj.user_labels[k] = v; + }); + } + return obj; + }, + fromAmino(object: MonitoredResourceMetadataAmino): MonitoredResourceMetadata { + const message = createBaseMonitoredResourceMetadata(); + if (object.system_labels !== undefined && object.system_labels !== null) { + message.systemLabels = Struct.fromAmino(object.system_labels); + } + message.userLabels = Object.entries(object.user_labels ?? {}).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + if (value !== undefined) { + acc[key] = String(value); + } + return acc; + }, {}); + return message; + }, + toAmino(message: MonitoredResourceMetadata): MonitoredResourceMetadataAmino { + const obj: any = {}; + obj.system_labels = message.systemLabels ? Struct.toAmino(message.systemLabels) : undefined; + obj.user_labels = {}; + if (message.userLabels) { + Object.entries(message.userLabels).forEach(([k, v]) => { + obj.user_labels[k] = v; + }); + } + return obj; + }, + fromAminoMsg(object: MonitoredResourceMetadataAminoMsg): MonitoredResourceMetadata { + return MonitoredResourceMetadata.fromAmino(object.value); + }, + fromProtoMsg(message: MonitoredResourceMetadataProtoMsg): MonitoredResourceMetadata { + return MonitoredResourceMetadata.decode(message.value); + }, + toProto(message: MonitoredResourceMetadata): Uint8Array { + return MonitoredResourceMetadata.encode(message).finish(); + }, + toProtoMsg(message: MonitoredResourceMetadata): MonitoredResourceMetadataProtoMsg { + return { + typeUrl: "/google.api.MonitoredResourceMetadata", + value: MonitoredResourceMetadata.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/api/monitoring.ts b/__fixtures__/v-next/outputicjsdeps/google/api/monitoring.ts new file mode 100644 index 0000000000..8c498f9aab --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/api/monitoring.ts @@ -0,0 +1,408 @@ +import { BinaryReader, BinaryWriter } from "../../binary.js"; +import { JsonSafe } from "../../json-safe.js"; +import { DeepPartial, isSet } from "../../helpers.js"; +export const protobufPackage = "google.api"; +/** + * Monitoring configuration of the service. + * + * The example below shows how to configure monitored resources and metrics + * for monitoring. In the example, a monitored resource and two metrics are + * defined. The `library.googleapis.com/book/returned_count` metric is sent + * to both producer and consumer projects, whereas the + * `library.googleapis.com/book/num_overdue` metric is only sent to the + * consumer project. + * + * monitored_resources: + * - type: library.googleapis.com/Branch + * display_name: "Library Branch" + * description: "A branch of a library." + * launch_stage: GA + * labels: + * - key: resource_container + * description: "The Cloud container (ie. project id) for the Branch." + * - key: location + * description: "The location of the library branch." + * - key: branch_id + * description: "The id of the branch." + * metrics: + * - name: library.googleapis.com/book/returned_count + * display_name: "Books Returned" + * description: "The count of books that have been returned." + * launch_stage: GA + * metric_kind: DELTA + * value_type: INT64 + * unit: "1" + * labels: + * - key: customer_id + * description: "The id of the customer." + * - name: library.googleapis.com/book/num_overdue + * display_name: "Books Overdue" + * description: "The current number of overdue books." + * launch_stage: GA + * metric_kind: GAUGE + * value_type: INT64 + * unit: "1" + * labels: + * - key: customer_id + * description: "The id of the customer." + * monitoring: + * producer_destinations: + * - monitored_resource: library.googleapis.com/Branch + * metrics: + * - library.googleapis.com/book/returned_count + * consumer_destinations: + * - monitored_resource: library.googleapis.com/Branch + * metrics: + * - library.googleapis.com/book/returned_count + * - library.googleapis.com/book/num_overdue + */ +export interface Monitoring { + /** + * Monitoring configurations for sending metrics to the producer project. + * There can be multiple producer destinations. A monitored resource type may + * appear in multiple monitoring destinations if different aggregations are + * needed for different sets of metrics associated with that monitored + * resource type. A monitored resource and metric pair may only be used once + * in the Monitoring configuration. + */ + producerDestinations: Monitoring_MonitoringDestination[]; + /** + * Monitoring configurations for sending metrics to the consumer project. + * There can be multiple consumer destinations. A monitored resource type may + * appear in multiple monitoring destinations if different aggregations are + * needed for different sets of metrics associated with that monitored + * resource type. A monitored resource and metric pair may only be used once + * in the Monitoring configuration. + */ + consumerDestinations: Monitoring_MonitoringDestination[]; +} +export interface MonitoringProtoMsg { + typeUrl: "/google.api.Monitoring"; + value: Uint8Array; +} +/** + * Monitoring configuration of the service. + * + * The example below shows how to configure monitored resources and metrics + * for monitoring. In the example, a monitored resource and two metrics are + * defined. The `library.googleapis.com/book/returned_count` metric is sent + * to both producer and consumer projects, whereas the + * `library.googleapis.com/book/num_overdue` metric is only sent to the + * consumer project. + * + * monitored_resources: + * - type: library.googleapis.com/Branch + * display_name: "Library Branch" + * description: "A branch of a library." + * launch_stage: GA + * labels: + * - key: resource_container + * description: "The Cloud container (ie. project id) for the Branch." + * - key: location + * description: "The location of the library branch." + * - key: branch_id + * description: "The id of the branch." + * metrics: + * - name: library.googleapis.com/book/returned_count + * display_name: "Books Returned" + * description: "The count of books that have been returned." + * launch_stage: GA + * metric_kind: DELTA + * value_type: INT64 + * unit: "1" + * labels: + * - key: customer_id + * description: "The id of the customer." + * - name: library.googleapis.com/book/num_overdue + * display_name: "Books Overdue" + * description: "The current number of overdue books." + * launch_stage: GA + * metric_kind: GAUGE + * value_type: INT64 + * unit: "1" + * labels: + * - key: customer_id + * description: "The id of the customer." + * monitoring: + * producer_destinations: + * - monitored_resource: library.googleapis.com/Branch + * metrics: + * - library.googleapis.com/book/returned_count + * consumer_destinations: + * - monitored_resource: library.googleapis.com/Branch + * metrics: + * - library.googleapis.com/book/returned_count + * - library.googleapis.com/book/num_overdue + */ +export interface MonitoringSDKType { + producer_destinations: Monitoring_MonitoringDestinationSDKType[]; + consumer_destinations: Monitoring_MonitoringDestinationSDKType[]; +} +/** + * Configuration of a specific monitoring destination (the producer project + * or the consumer project). + */ +export interface Monitoring_MonitoringDestination { + /** + * The monitored resource type. The type must be defined in + * [Service.monitored_resources][google.api.Service.monitored_resources] section. + */ + monitoredResource: string; + /** + * Types of the metrics to report to this monitoring destination. + * Each type must be defined in [Service.metrics][google.api.Service.metrics] section. + */ + metrics: string[]; +} +export interface Monitoring_MonitoringDestinationProtoMsg { + typeUrl: "/google.api.MonitoringDestination"; + value: Uint8Array; +} +/** + * Configuration of a specific monitoring destination (the producer project + * or the consumer project). + */ +export interface Monitoring_MonitoringDestinationSDKType { + monitored_resource: string; + metrics: string[]; +} +function createBaseMonitoring(): Monitoring { + return { + producerDestinations: [], + consumerDestinations: [] + }; +} +export const Monitoring = { + typeUrl: "/google.api.Monitoring", + encode(message: Monitoring, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.producerDestinations) { + Monitoring_MonitoringDestination.encode(v!, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.consumerDestinations) { + Monitoring_MonitoringDestination.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Monitoring { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMonitoring(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.producerDestinations.push(Monitoring_MonitoringDestination.decode(reader, reader.uint32())); + break; + case 2: + message.consumerDestinations.push(Monitoring_MonitoringDestination.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Monitoring { + const obj = createBaseMonitoring(); + if (Array.isArray(object?.producerDestinations)) obj.producerDestinations = object.producerDestinations.map((e: any) => Monitoring_MonitoringDestination.fromJSON(e)); + if (Array.isArray(object?.consumerDestinations)) obj.consumerDestinations = object.consumerDestinations.map((e: any) => Monitoring_MonitoringDestination.fromJSON(e)); + return obj; + }, + toJSON(message: Monitoring): JsonSafe { + const obj: any = {}; + if (message.producerDestinations) { + obj.producerDestinations = message.producerDestinations.map(e => e ? Monitoring_MonitoringDestination.toJSON(e) : undefined); + } else { + obj.producerDestinations = []; + } + if (message.consumerDestinations) { + obj.consumerDestinations = message.consumerDestinations.map(e => e ? Monitoring_MonitoringDestination.toJSON(e) : undefined); + } else { + obj.consumerDestinations = []; + } + return obj; + }, + fromPartial(object: DeepPartial): Monitoring { + const message = createBaseMonitoring(); + message.producerDestinations = object.producerDestinations?.map(e => Monitoring_MonitoringDestination.fromPartial(e)) || []; + message.consumerDestinations = object.consumerDestinations?.map(e => Monitoring_MonitoringDestination.fromPartial(e)) || []; + return message; + }, + fromSDK(object: MonitoringSDKType): Monitoring { + return { + producerDestinations: Array.isArray(object?.producer_destinations) ? object.producer_destinations.map((e: any) => Monitoring_MonitoringDestination.fromSDK(e)) : [], + consumerDestinations: Array.isArray(object?.consumer_destinations) ? object.consumer_destinations.map((e: any) => Monitoring_MonitoringDestination.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): MonitoringSDKType { + return { + producer_destinations: Array.isArray(object?.producer_destinations) ? object.producer_destinations.map((e: any) => Monitoring_MonitoringDestination.fromSDKJSON(e)) : [], + consumer_destinations: Array.isArray(object?.consumer_destinations) ? object.consumer_destinations.map((e: any) => Monitoring_MonitoringDestination.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: Monitoring): MonitoringSDKType { + const obj: any = {}; + if (message.producerDestinations) { + obj.producer_destinations = message.producerDestinations.map(e => e ? Monitoring_MonitoringDestination.toSDK(e) : undefined); + } else { + obj.producer_destinations = []; + } + if (message.consumerDestinations) { + obj.consumer_destinations = message.consumerDestinations.map(e => e ? Monitoring_MonitoringDestination.toSDK(e) : undefined); + } else { + obj.consumer_destinations = []; + } + return obj; + }, + fromAmino(object: MonitoringAmino): Monitoring { + const message = createBaseMonitoring(); + message.producerDestinations = object.producer_destinations?.map(e => Monitoring_MonitoringDestination.fromAmino(e)) || []; + message.consumerDestinations = object.consumer_destinations?.map(e => Monitoring_MonitoringDestination.fromAmino(e)) || []; + return message; + }, + toAmino(message: Monitoring): MonitoringAmino { + const obj: any = {}; + if (message.producerDestinations) { + obj.producer_destinations = message.producerDestinations.map(e => e ? Monitoring_MonitoringDestination.toAmino(e) : undefined); + } else { + obj.producer_destinations = message.producerDestinations; + } + if (message.consumerDestinations) { + obj.consumer_destinations = message.consumerDestinations.map(e => e ? Monitoring_MonitoringDestination.toAmino(e) : undefined); + } else { + obj.consumer_destinations = message.consumerDestinations; + } + return obj; + }, + fromAminoMsg(object: MonitoringAminoMsg): Monitoring { + return Monitoring.fromAmino(object.value); + }, + fromProtoMsg(message: MonitoringProtoMsg): Monitoring { + return Monitoring.decode(message.value); + }, + toProto(message: Monitoring): Uint8Array { + return Monitoring.encode(message).finish(); + }, + toProtoMsg(message: Monitoring): MonitoringProtoMsg { + return { + typeUrl: "/google.api.Monitoring", + value: Monitoring.encode(message).finish() + }; + } +}; +function createBaseMonitoring_MonitoringDestination(): Monitoring_MonitoringDestination { + return { + monitoredResource: "", + metrics: [] + }; +} +export const Monitoring_MonitoringDestination = { + typeUrl: "/google.api.MonitoringDestination", + encode(message: Monitoring_MonitoringDestination, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.monitoredResource !== undefined) { + writer.uint32(10).string(message.monitoredResource); + } + for (const v of message.metrics) { + writer.uint32(18).string(v!); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Monitoring_MonitoringDestination { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMonitoring_MonitoringDestination(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.monitoredResource = reader.string(); + break; + case 2: + message.metrics.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Monitoring_MonitoringDestination { + const obj = createBaseMonitoring_MonitoringDestination(); + if (isSet(object.monitoredResource)) obj.monitoredResource = String(object.monitoredResource); + if (Array.isArray(object?.metrics)) obj.metrics = object.metrics.map((e: any) => String(e)); + return obj; + }, + toJSON(message: Monitoring_MonitoringDestination): JsonSafe { + const obj: any = {}; + message.monitoredResource !== undefined && (obj.monitoredResource = message.monitoredResource); + if (message.metrics) { + obj.metrics = message.metrics.map(e => e); + } else { + obj.metrics = []; + } + return obj; + }, + fromPartial(object: DeepPartial): Monitoring_MonitoringDestination { + const message = createBaseMonitoring_MonitoringDestination(); + message.monitoredResource = object.monitoredResource ?? ""; + message.metrics = object.metrics?.map(e => e) || []; + return message; + }, + fromSDK(object: Monitoring_MonitoringDestinationSDKType): Monitoring_MonitoringDestination { + return { + monitoredResource: object?.monitored_resource, + metrics: Array.isArray(object?.metrics) ? object.metrics.map((e: any) => e) : [] + }; + }, + fromSDKJSON(object: any): Monitoring_MonitoringDestinationSDKType { + return { + monitored_resource: isSet(object.monitored_resource) ? String(object.monitored_resource) : "", + metrics: Array.isArray(object?.metrics) ? object.metrics.map((e: any) => String(e)) : [] + }; + }, + toSDK(message: Monitoring_MonitoringDestination): Monitoring_MonitoringDestinationSDKType { + const obj: any = {}; + obj.monitored_resource = message.monitoredResource; + if (message.metrics) { + obj.metrics = message.metrics.map(e => e); + } else { + obj.metrics = []; + } + return obj; + }, + fromAmino(object: Monitoring_MonitoringDestinationAmino): Monitoring_MonitoringDestination { + const message = createBaseMonitoring_MonitoringDestination(); + if (object.monitored_resource !== undefined && object.monitored_resource !== null) { + message.monitoredResource = object.monitored_resource; + } + message.metrics = object.metrics?.map(e => e) || []; + return message; + }, + toAmino(message: Monitoring_MonitoringDestination): Monitoring_MonitoringDestinationAmino { + const obj: any = {}; + obj.monitored_resource = message.monitoredResource === "" ? undefined : message.monitoredResource; + if (message.metrics) { + obj.metrics = message.metrics.map(e => e); + } else { + obj.metrics = message.metrics; + } + return obj; + }, + fromAminoMsg(object: Monitoring_MonitoringDestinationAminoMsg): Monitoring_MonitoringDestination { + return Monitoring_MonitoringDestination.fromAmino(object.value); + }, + fromProtoMsg(message: Monitoring_MonitoringDestinationProtoMsg): Monitoring_MonitoringDestination { + return Monitoring_MonitoringDestination.decode(message.value); + }, + toProto(message: Monitoring_MonitoringDestination): Uint8Array { + return Monitoring_MonitoringDestination.encode(message).finish(); + }, + toProtoMsg(message: Monitoring_MonitoringDestination): Monitoring_MonitoringDestinationProtoMsg { + return { + typeUrl: "/google.api.MonitoringDestination", + value: Monitoring_MonitoringDestination.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/api/quota.ts b/__fixtures__/v-next/outputicjsdeps/google/api/quota.ts new file mode 100644 index 0000000000..fff33aa53e --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/api/quota.ts @@ -0,0 +1,1077 @@ +import { BinaryReader, BinaryWriter } from "../../binary.js"; +import { JsonSafe } from "../../json-safe.js"; +import { DeepPartial, isSet, isObject } from "../../helpers.js"; +export const protobufPackage = "google.api"; +/** + * Quota configuration helps to achieve fairness and budgeting in service + * usage. + * + * The metric based quota configuration works this way: + * - The service configuration defines a set of metrics. + * - For API calls, the quota.metric_rules maps methods to metrics with + * corresponding costs. + * - The quota.limits defines limits on the metrics, which will be used for + * quota checks at runtime. + * + * An example quota configuration in yaml format: + * + * quota: + * limits: + * + * - name: apiWriteQpsPerProject + * metric: library.googleapis.com/write_calls + * unit: "1/min/{project}" # rate limit for consumer projects + * values: + * STANDARD: 10000 + * + * + * # The metric rules bind all methods to the read_calls metric, + * # except for the UpdateBook and DeleteBook methods. These two methods + * # are mapped to the write_calls metric, with the UpdateBook method + * # consuming at twice rate as the DeleteBook method. + * metric_rules: + * - selector: "*" + * metric_costs: + * library.googleapis.com/read_calls: 1 + * - selector: google.example.library.v1.LibraryService.UpdateBook + * metric_costs: + * library.googleapis.com/write_calls: 2 + * - selector: google.example.library.v1.LibraryService.DeleteBook + * metric_costs: + * library.googleapis.com/write_calls: 1 + * + * Corresponding Metric definition: + * + * metrics: + * - name: library.googleapis.com/read_calls + * display_name: Read requests + * metric_kind: DELTA + * value_type: INT64 + * + * - name: library.googleapis.com/write_calls + * display_name: Write requests + * metric_kind: DELTA + * value_type: INT64 + */ +export interface Quota { + /** List of `QuotaLimit` definitions for the service. */ + limits: QuotaLimit[]; + /** + * List of `MetricRule` definitions, each one mapping a selected method to one + * or more metrics. + */ + metricRules: MetricRule[]; +} +export interface QuotaProtoMsg { + typeUrl: "/google.api.Quota"; + value: Uint8Array; +} +/** + * Quota configuration helps to achieve fairness and budgeting in service + * usage. + * + * The metric based quota configuration works this way: + * - The service configuration defines a set of metrics. + * - For API calls, the quota.metric_rules maps methods to metrics with + * corresponding costs. + * - The quota.limits defines limits on the metrics, which will be used for + * quota checks at runtime. + * + * An example quota configuration in yaml format: + * + * quota: + * limits: + * + * - name: apiWriteQpsPerProject + * metric: library.googleapis.com/write_calls + * unit: "1/min/{project}" # rate limit for consumer projects + * values: + * STANDARD: 10000 + * + * + * # The metric rules bind all methods to the read_calls metric, + * # except for the UpdateBook and DeleteBook methods. These two methods + * # are mapped to the write_calls metric, with the UpdateBook method + * # consuming at twice rate as the DeleteBook method. + * metric_rules: + * - selector: "*" + * metric_costs: + * library.googleapis.com/read_calls: 1 + * - selector: google.example.library.v1.LibraryService.UpdateBook + * metric_costs: + * library.googleapis.com/write_calls: 2 + * - selector: google.example.library.v1.LibraryService.DeleteBook + * metric_costs: + * library.googleapis.com/write_calls: 1 + * + * Corresponding Metric definition: + * + * metrics: + * - name: library.googleapis.com/read_calls + * display_name: Read requests + * metric_kind: DELTA + * value_type: INT64 + * + * - name: library.googleapis.com/write_calls + * display_name: Write requests + * metric_kind: DELTA + * value_type: INT64 + */ +export interface QuotaSDKType { + limits: QuotaLimitSDKType[]; + metric_rules: MetricRuleSDKType[]; +} +export interface MetricRule_MetricCostsEntry { + key: string; + value: bigint; +} +export interface MetricRule_MetricCostsEntryProtoMsg { + typeUrl: string; + value: Uint8Array; +} +export interface MetricRule_MetricCostsEntrySDKType { + key: string; + value: bigint; +} +/** + * Bind API methods to metrics. Binding a method to a metric causes that + * metric's configured quota behaviors to apply to the method call. + */ +export interface MetricRule { + /** + * Selects the methods to which this rule applies. + * + * Refer to [selector][google.api.DocumentationRule.selector] for syntax details. + */ + selector: string; + /** + * Metrics to update when the selected methods are called, and the associated + * cost applied to each metric. + * + * The key of the map is the metric name, and the values are the amount + * increased for the metric against which the quota limits are defined. + * The value must not be negative. + */ + metricCosts: { + [key: string]: bigint; + }; +} +export interface MetricRuleProtoMsg { + typeUrl: "/google.api.MetricRule"; + value: Uint8Array; +} +/** + * Bind API methods to metrics. Binding a method to a metric causes that + * metric's configured quota behaviors to apply to the method call. + */ +export interface MetricRuleSDKType { + selector: string; + metric_costs: { + [key: string]: bigint; + }; +} +export interface QuotaLimit_ValuesEntry { + key: string; + value: bigint; +} +export interface QuotaLimit_ValuesEntryProtoMsg { + typeUrl: string; + value: Uint8Array; +} +export interface QuotaLimit_ValuesEntrySDKType { + key: string; + value: bigint; +} +/** + * `QuotaLimit` defines a specific limit that applies over a specified duration + * for a limit type. There can be at most one limit for a duration and limit + * type combination defined within a `QuotaGroup`. + */ +export interface QuotaLimit { + /** + * Name of the quota limit. + * + * The name must be provided, and it must be unique within the service. The + * name can only include alphanumeric characters as well as '-'. + * + * The maximum length of the limit name is 64 characters. + */ + name: string; + /** + * Optional. User-visible, extended description for this quota limit. + * Should be used only when more context is needed to understand this limit + * than provided by the limit's display name (see: `display_name`). + */ + description: string; + /** + * Default number of tokens that can be consumed during the specified + * duration. This is the number of tokens assigned when a client + * application developer activates the service for his/her project. + * + * Specifying a value of 0 will block all requests. This can be used if you + * are provisioning quota to selected consumers and blocking others. + * Similarly, a value of -1 will indicate an unlimited quota. No other + * negative values are allowed. + * + * Used by group-based quotas only. + */ + defaultLimit: bigint; + /** + * Maximum number of tokens that can be consumed during the specified + * duration. Client application developers can override the default limit up + * to this maximum. If specified, this value cannot be set to a value less + * than the default limit. If not specified, it is set to the default limit. + * + * To allow clients to apply overrides with no upper bound, set this to -1, + * indicating unlimited maximum quota. + * + * Used by group-based quotas only. + */ + maxLimit: bigint; + /** + * Free tier value displayed in the Developers Console for this limit. + * The free tier is the number of tokens that will be subtracted from the + * billed amount when billing is enabled. + * This field can only be set on a limit with duration "1d", in a billable + * group; it is invalid on any other limit. If this field is not set, it + * defaults to 0, indicating that there is no free tier for this service. + * + * Used by group-based quotas only. + */ + freeTier: bigint; + /** + * Duration of this limit in textual notation. Must be "100s" or "1d". + * + * Used by group-based quotas only. + */ + duration: string; + /** + * The name of the metric this quota limit applies to. The quota limits with + * the same metric will be checked together during runtime. The metric must be + * defined within the service config. + */ + metric: string; + /** + * Specify the unit of the quota limit. It uses the same syntax as + * [Metric.unit][]. The supported unit kinds are determined by the quota + * backend system. + * + * Here are some examples: + * * "1/min/{project}" for quota per minute per project. + * + * Note: the order of unit components is insignificant. + * The "1" at the beginning is required to follow the metric unit syntax. + */ + unit: string; + /** + * Tiered limit values. You must specify this as a key:value pair, with an + * integer value that is the maximum number of requests allowed for the + * specified unit. Currently only STANDARD is supported. + */ + values: { + [key: string]: bigint; + }; + /** + * User-visible display name for this limit. + * Optional. If not set, the UI will provide a default display name based on + * the quota configuration. This field can be used to override the default + * display name generated from the configuration. + */ + displayName: string; +} +export interface QuotaLimitProtoMsg { + typeUrl: "/google.api.QuotaLimit"; + value: Uint8Array; +} +/** + * `QuotaLimit` defines a specific limit that applies over a specified duration + * for a limit type. There can be at most one limit for a duration and limit + * type combination defined within a `QuotaGroup`. + */ +export interface QuotaLimitSDKType { + name: string; + description: string; + default_limit: bigint; + max_limit: bigint; + free_tier: bigint; + duration: string; + metric: string; + unit: string; + values: { + [key: string]: bigint; + }; + display_name: string; +} +function createBaseQuota(): Quota { + return { + limits: [], + metricRules: [] + }; +} +export const Quota = { + typeUrl: "/google.api.Quota", + encode(message: Quota, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.limits) { + QuotaLimit.encode(v!, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.metricRules) { + MetricRule.encode(v!, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Quota { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQuota(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 3: + message.limits.push(QuotaLimit.decode(reader, reader.uint32())); + break; + case 4: + message.metricRules.push(MetricRule.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Quota { + const obj = createBaseQuota(); + if (Array.isArray(object?.limits)) obj.limits = object.limits.map((e: any) => QuotaLimit.fromJSON(e)); + if (Array.isArray(object?.metricRules)) obj.metricRules = object.metricRules.map((e: any) => MetricRule.fromJSON(e)); + return obj; + }, + toJSON(message: Quota): JsonSafe { + const obj: any = {}; + if (message.limits) { + obj.limits = message.limits.map(e => e ? QuotaLimit.toJSON(e) : undefined); + } else { + obj.limits = []; + } + if (message.metricRules) { + obj.metricRules = message.metricRules.map(e => e ? MetricRule.toJSON(e) : undefined); + } else { + obj.metricRules = []; + } + return obj; + }, + fromPartial(object: DeepPartial): Quota { + const message = createBaseQuota(); + message.limits = object.limits?.map(e => QuotaLimit.fromPartial(e)) || []; + message.metricRules = object.metricRules?.map(e => MetricRule.fromPartial(e)) || []; + return message; + }, + fromSDK(object: QuotaSDKType): Quota { + return { + limits: Array.isArray(object?.limits) ? object.limits.map((e: any) => QuotaLimit.fromSDK(e)) : [], + metricRules: Array.isArray(object?.metric_rules) ? object.metric_rules.map((e: any) => MetricRule.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): QuotaSDKType { + return { + limits: Array.isArray(object?.limits) ? object.limits.map((e: any) => QuotaLimit.fromSDKJSON(e)) : [], + metric_rules: Array.isArray(object?.metric_rules) ? object.metric_rules.map((e: any) => MetricRule.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: Quota): QuotaSDKType { + const obj: any = {}; + if (message.limits) { + obj.limits = message.limits.map(e => e ? QuotaLimit.toSDK(e) : undefined); + } else { + obj.limits = []; + } + if (message.metricRules) { + obj.metric_rules = message.metricRules.map(e => e ? MetricRule.toSDK(e) : undefined); + } else { + obj.metric_rules = []; + } + return obj; + }, + fromAmino(object: QuotaAmino): Quota { + const message = createBaseQuota(); + message.limits = object.limits?.map(e => QuotaLimit.fromAmino(e)) || []; + message.metricRules = object.metric_rules?.map(e => MetricRule.fromAmino(e)) || []; + return message; + }, + toAmino(message: Quota): QuotaAmino { + const obj: any = {}; + if (message.limits) { + obj.limits = message.limits.map(e => e ? QuotaLimit.toAmino(e) : undefined); + } else { + obj.limits = message.limits; + } + if (message.metricRules) { + obj.metric_rules = message.metricRules.map(e => e ? MetricRule.toAmino(e) : undefined); + } else { + obj.metric_rules = message.metricRules; + } + return obj; + }, + fromAminoMsg(object: QuotaAminoMsg): Quota { + return Quota.fromAmino(object.value); + }, + fromProtoMsg(message: QuotaProtoMsg): Quota { + return Quota.decode(message.value); + }, + toProto(message: Quota): Uint8Array { + return Quota.encode(message).finish(); + }, + toProtoMsg(message: Quota): QuotaProtoMsg { + return { + typeUrl: "/google.api.Quota", + value: Quota.encode(message).finish() + }; + } +}; +function createBaseMetricRule_MetricCostsEntry(): MetricRule_MetricCostsEntry { + return { + key: "", + value: BigInt(0) + }; +} +export const MetricRule_MetricCostsEntry = { + encode(message: MetricRule_MetricCostsEntry, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.key !== undefined) { + writer.uint32(10).string(message.key); + } + if (message.value !== undefined) { + writer.uint32(16).int64(message.value); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MetricRule_MetricCostsEntry { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMetricRule_MetricCostsEntry(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.string(); + break; + case 2: + message.value = reader.int64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MetricRule_MetricCostsEntry { + const obj = createBaseMetricRule_MetricCostsEntry(); + if (isSet(object.key)) obj.key = String(object.key); + if (isSet(object.value)) obj.value = BigInt(object.value.toString()); + return obj; + }, + toJSON(message: MetricRule_MetricCostsEntry): JsonSafe { + const obj: any = {}; + message.key !== undefined && (obj.key = message.key); + message.value !== undefined && (obj.value = (message.value || BigInt(0)).toString()); + return obj; + }, + fromPartial(object: DeepPartial): MetricRule_MetricCostsEntry { + const message = createBaseMetricRule_MetricCostsEntry(); + message.key = object.key ?? ""; + if (object.value !== undefined && object.value !== null) { + message.value = BigInt(object.value.toString()); + } + return message; + }, + fromSDK(object: MetricRule_MetricCostsEntrySDKType): MetricRule_MetricCostsEntry { + return { + key: object?.key, + value: object?.value + }; + }, + fromSDKJSON(object: any): MetricRule_MetricCostsEntrySDKType { + return { + key: isSet(object.key) ? String(object.key) : "", + value: isSet(object.value) ? BigInt(object.value.toString()) : BigInt(0) + }; + }, + toSDK(message: MetricRule_MetricCostsEntry): MetricRule_MetricCostsEntrySDKType { + const obj: any = {}; + obj.key = message.key; + obj.value = message.value; + return obj; + }, + fromAmino(object: MetricRule_MetricCostsEntryAmino): MetricRule_MetricCostsEntry { + const message = createBaseMetricRule_MetricCostsEntry(); + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } + if (object.value !== undefined && object.value !== null) { + message.value = BigInt(object.value); + } + return message; + }, + toAmino(message: MetricRule_MetricCostsEntry): MetricRule_MetricCostsEntryAmino { + const obj: any = {}; + obj.key = message.key === "" ? undefined : message.key; + obj.value = message.value !== BigInt(0) ? message.value?.toString() : undefined; + return obj; + }, + fromAminoMsg(object: MetricRule_MetricCostsEntryAminoMsg): MetricRule_MetricCostsEntry { + return MetricRule_MetricCostsEntry.fromAmino(object.value); + }, + fromProtoMsg(message: MetricRule_MetricCostsEntryProtoMsg): MetricRule_MetricCostsEntry { + return MetricRule_MetricCostsEntry.decode(message.value); + }, + toProto(message: MetricRule_MetricCostsEntry): Uint8Array { + return MetricRule_MetricCostsEntry.encode(message).finish(); + } +}; +function createBaseMetricRule(): MetricRule { + return { + selector: "", + metricCosts: {} + }; +} +export const MetricRule = { + typeUrl: "/google.api.MetricRule", + encode(message: MetricRule, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.selector !== undefined) { + writer.uint32(10).string(message.selector); + } + Object.entries(message.metricCosts).forEach(([key, value]) => { + MetricRule_MetricCostsEntry.encode({ + key: (key as any), + value + }, writer.uint32(16).fork()).ldelim(); + }); + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MetricRule { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMetricRule(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.selector = reader.string(); + break; + case 2: + const entry2 = MetricRule_MetricCostsEntry.decode(reader, reader.uint32()); + if (entry2.value !== undefined) { + message.metricCosts[entry2.key] = entry2.value; + } + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MetricRule { + const obj = createBaseMetricRule(); + if (isSet(object.selector)) obj.selector = String(object.selector); + if (isObject(object.metricCosts)) obj.metricCosts = Object.entries(object.metricCosts).reduce<{ + [key: string]: bigint; + }>((acc, [key, value]) => { + acc[key] = BigInt((value as bigint | string).toString()); + return acc; + }, {}); + return obj; + }, + toJSON(message: MetricRule): JsonSafe { + const obj: any = {}; + message.selector !== undefined && (obj.selector = message.selector); + obj.metricCosts = {}; + if (message.metricCosts) { + Object.entries(message.metricCosts).forEach(([k, v]) => { + obj.metricCosts[k] = v.toString(); + }); + } + return obj; + }, + fromPartial(object: DeepPartial): MetricRule { + const message = createBaseMetricRule(); + message.selector = object.selector ?? ""; + message.metricCosts = Object.entries(object.metricCosts ?? {}).reduce<{ + [key: string]: bigint; + }>((acc, [key, value]) => { + if (value !== undefined) { + acc[key] = BigInt(value.toString()); + } + return acc; + }, {}); + return message; + }, + fromSDK(object: MetricRuleSDKType): MetricRule { + return { + selector: object?.selector, + metricCosts: isObject(object.metric_costs) ? Object.entries(object.metric_costs).reduce<{ + [key: string]: bigint; + }>((acc, [key, value]) => { + acc[key] = BigInt((value as bigint | string).toString()); + return acc; + }, {}) : {} + }; + }, + fromSDKJSON(object: any): MetricRuleSDKType { + return { + selector: isSet(object.selector) ? String(object.selector) : "", + metric_costs: isObject(object.metric_costs) ? Object.entries(object.metric_costs).reduce<{ + [key: string]: bigint; + }>((acc, [key, value]) => { + acc[key] = BigInt((value as bigint | string).toString()); + return acc; + }, {}) : {} + }; + }, + toSDK(message: MetricRule): MetricRuleSDKType { + const obj: any = {}; + obj.selector = message.selector; + obj.metric_costs = {}; + if (message.metricCosts) { + Object.entries(message.metricCosts).forEach(([k, v]) => { + obj.metric_costs[k] = v.toString(); + }); + } + return obj; + }, + fromAmino(object: MetricRuleAmino): MetricRule { + const message = createBaseMetricRule(); + if (object.selector !== undefined && object.selector !== null) { + message.selector = object.selector; + } + message.metricCosts = Object.entries(object.metric_costs ?? {}).reduce<{ + [key: string]: bigint; + }>((acc, [key, value]) => { + if (value !== undefined) { + acc[key] = BigInt(value.toString()); + } + return acc; + }, {}); + return message; + }, + toAmino(message: MetricRule): MetricRuleAmino { + const obj: any = {}; + obj.selector = message.selector === "" ? undefined : message.selector; + obj.metric_costs = {}; + if (message.metricCosts) { + Object.entries(message.metricCosts).forEach(([k, v]) => { + obj.metric_costs[k] = v.toString(); + }); + } + return obj; + }, + fromAminoMsg(object: MetricRuleAminoMsg): MetricRule { + return MetricRule.fromAmino(object.value); + }, + fromProtoMsg(message: MetricRuleProtoMsg): MetricRule { + return MetricRule.decode(message.value); + }, + toProto(message: MetricRule): Uint8Array { + return MetricRule.encode(message).finish(); + }, + toProtoMsg(message: MetricRule): MetricRuleProtoMsg { + return { + typeUrl: "/google.api.MetricRule", + value: MetricRule.encode(message).finish() + }; + } +}; +function createBaseQuotaLimit_ValuesEntry(): QuotaLimit_ValuesEntry { + return { + key: "", + value: BigInt(0) + }; +} +export const QuotaLimit_ValuesEntry = { + encode(message: QuotaLimit_ValuesEntry, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.key !== undefined) { + writer.uint32(10).string(message.key); + } + if (message.value !== undefined) { + writer.uint32(16).int64(message.value); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QuotaLimit_ValuesEntry { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQuotaLimit_ValuesEntry(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.string(); + break; + case 2: + message.value = reader.int64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QuotaLimit_ValuesEntry { + const obj = createBaseQuotaLimit_ValuesEntry(); + if (isSet(object.key)) obj.key = String(object.key); + if (isSet(object.value)) obj.value = BigInt(object.value.toString()); + return obj; + }, + toJSON(message: QuotaLimit_ValuesEntry): JsonSafe { + const obj: any = {}; + message.key !== undefined && (obj.key = message.key); + message.value !== undefined && (obj.value = (message.value || BigInt(0)).toString()); + return obj; + }, + fromPartial(object: DeepPartial): QuotaLimit_ValuesEntry { + const message = createBaseQuotaLimit_ValuesEntry(); + message.key = object.key ?? ""; + if (object.value !== undefined && object.value !== null) { + message.value = BigInt(object.value.toString()); + } + return message; + }, + fromSDK(object: QuotaLimit_ValuesEntrySDKType): QuotaLimit_ValuesEntry { + return { + key: object?.key, + value: object?.value + }; + }, + fromSDKJSON(object: any): QuotaLimit_ValuesEntrySDKType { + return { + key: isSet(object.key) ? String(object.key) : "", + value: isSet(object.value) ? BigInt(object.value.toString()) : BigInt(0) + }; + }, + toSDK(message: QuotaLimit_ValuesEntry): QuotaLimit_ValuesEntrySDKType { + const obj: any = {}; + obj.key = message.key; + obj.value = message.value; + return obj; + }, + fromAmino(object: QuotaLimit_ValuesEntryAmino): QuotaLimit_ValuesEntry { + const message = createBaseQuotaLimit_ValuesEntry(); + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } + if (object.value !== undefined && object.value !== null) { + message.value = BigInt(object.value); + } + return message; + }, + toAmino(message: QuotaLimit_ValuesEntry): QuotaLimit_ValuesEntryAmino { + const obj: any = {}; + obj.key = message.key === "" ? undefined : message.key; + obj.value = message.value !== BigInt(0) ? message.value?.toString() : undefined; + return obj; + }, + fromAminoMsg(object: QuotaLimit_ValuesEntryAminoMsg): QuotaLimit_ValuesEntry { + return QuotaLimit_ValuesEntry.fromAmino(object.value); + }, + fromProtoMsg(message: QuotaLimit_ValuesEntryProtoMsg): QuotaLimit_ValuesEntry { + return QuotaLimit_ValuesEntry.decode(message.value); + }, + toProto(message: QuotaLimit_ValuesEntry): Uint8Array { + return QuotaLimit_ValuesEntry.encode(message).finish(); + } +}; +function createBaseQuotaLimit(): QuotaLimit { + return { + name: "", + description: "", + defaultLimit: BigInt(0), + maxLimit: BigInt(0), + freeTier: BigInt(0), + duration: "", + metric: "", + unit: "", + values: {}, + displayName: "" + }; +} +export const QuotaLimit = { + typeUrl: "/google.api.QuotaLimit", + encode(message: QuotaLimit, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(50).string(message.name); + } + if (message.description !== undefined) { + writer.uint32(18).string(message.description); + } + if (message.defaultLimit !== undefined) { + writer.uint32(24).int64(message.defaultLimit); + } + if (message.maxLimit !== undefined) { + writer.uint32(32).int64(message.maxLimit); + } + if (message.freeTier !== undefined) { + writer.uint32(56).int64(message.freeTier); + } + if (message.duration !== undefined) { + writer.uint32(42).string(message.duration); + } + if (message.metric !== undefined) { + writer.uint32(66).string(message.metric); + } + if (message.unit !== undefined) { + writer.uint32(74).string(message.unit); + } + Object.entries(message.values).forEach(([key, value]) => { + QuotaLimit_ValuesEntry.encode({ + key: (key as any), + value + }, writer.uint32(80).fork()).ldelim(); + }); + if (message.displayName !== undefined) { + writer.uint32(98).string(message.displayName); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QuotaLimit { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQuotaLimit(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 6: + message.name = reader.string(); + break; + case 2: + message.description = reader.string(); + break; + case 3: + message.defaultLimit = reader.int64(); + break; + case 4: + message.maxLimit = reader.int64(); + break; + case 7: + message.freeTier = reader.int64(); + break; + case 5: + message.duration = reader.string(); + break; + case 8: + message.metric = reader.string(); + break; + case 9: + message.unit = reader.string(); + break; + case 10: + const entry10 = QuotaLimit_ValuesEntry.decode(reader, reader.uint32()); + if (entry10.value !== undefined) { + message.values[entry10.key] = entry10.value; + } + break; + case 12: + message.displayName = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QuotaLimit { + const obj = createBaseQuotaLimit(); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.description)) obj.description = String(object.description); + if (isSet(object.defaultLimit)) obj.defaultLimit = BigInt(object.defaultLimit.toString()); + if (isSet(object.maxLimit)) obj.maxLimit = BigInt(object.maxLimit.toString()); + if (isSet(object.freeTier)) obj.freeTier = BigInt(object.freeTier.toString()); + if (isSet(object.duration)) obj.duration = String(object.duration); + if (isSet(object.metric)) obj.metric = String(object.metric); + if (isSet(object.unit)) obj.unit = String(object.unit); + if (isObject(object.values)) obj.values = Object.entries(object.values).reduce<{ + [key: string]: bigint; + }>((acc, [key, value]) => { + acc[key] = BigInt((value as bigint | string).toString()); + return acc; + }, {}); + if (isSet(object.displayName)) obj.displayName = String(object.displayName); + return obj; + }, + toJSON(message: QuotaLimit): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.description !== undefined && (obj.description = message.description); + message.defaultLimit !== undefined && (obj.defaultLimit = (message.defaultLimit || BigInt(0)).toString()); + message.maxLimit !== undefined && (obj.maxLimit = (message.maxLimit || BigInt(0)).toString()); + message.freeTier !== undefined && (obj.freeTier = (message.freeTier || BigInt(0)).toString()); + message.duration !== undefined && (obj.duration = message.duration); + message.metric !== undefined && (obj.metric = message.metric); + message.unit !== undefined && (obj.unit = message.unit); + obj.values = {}; + if (message.values) { + Object.entries(message.values).forEach(([k, v]) => { + obj.values[k] = v.toString(); + }); + } + message.displayName !== undefined && (obj.displayName = message.displayName); + return obj; + }, + fromPartial(object: DeepPartial): QuotaLimit { + const message = createBaseQuotaLimit(); + message.name = object.name ?? ""; + message.description = object.description ?? ""; + if (object.defaultLimit !== undefined && object.defaultLimit !== null) { + message.defaultLimit = BigInt(object.defaultLimit.toString()); + } + if (object.maxLimit !== undefined && object.maxLimit !== null) { + message.maxLimit = BigInt(object.maxLimit.toString()); + } + if (object.freeTier !== undefined && object.freeTier !== null) { + message.freeTier = BigInt(object.freeTier.toString()); + } + message.duration = object.duration ?? ""; + message.metric = object.metric ?? ""; + message.unit = object.unit ?? ""; + message.values = Object.entries(object.values ?? {}).reduce<{ + [key: string]: bigint; + }>((acc, [key, value]) => { + if (value !== undefined) { + acc[key] = BigInt(value.toString()); + } + return acc; + }, {}); + message.displayName = object.displayName ?? ""; + return message; + }, + fromSDK(object: QuotaLimitSDKType): QuotaLimit { + return { + name: object?.name, + description: object?.description, + defaultLimit: object?.default_limit, + maxLimit: object?.max_limit, + freeTier: object?.free_tier, + duration: object?.duration, + metric: object?.metric, + unit: object?.unit, + values: isObject(object.values) ? Object.entries(object.values).reduce<{ + [key: string]: bigint; + }>((acc, [key, value]) => { + acc[key] = BigInt((value as bigint | string).toString()); + return acc; + }, {}) : {}, + displayName: object?.display_name + }; + }, + fromSDKJSON(object: any): QuotaLimitSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + description: isSet(object.description) ? String(object.description) : "", + default_limit: isSet(object.default_limit) ? BigInt(object.default_limit.toString()) : BigInt(0), + max_limit: isSet(object.max_limit) ? BigInt(object.max_limit.toString()) : BigInt(0), + free_tier: isSet(object.free_tier) ? BigInt(object.free_tier.toString()) : BigInt(0), + duration: isSet(object.duration) ? String(object.duration) : "", + metric: isSet(object.metric) ? String(object.metric) : "", + unit: isSet(object.unit) ? String(object.unit) : "", + values: isObject(object.values) ? Object.entries(object.values).reduce<{ + [key: string]: bigint; + }>((acc, [key, value]) => { + acc[key] = BigInt((value as bigint | string).toString()); + return acc; + }, {}) : {}, + display_name: isSet(object.display_name) ? String(object.display_name) : "" + }; + }, + toSDK(message: QuotaLimit): QuotaLimitSDKType { + const obj: any = {}; + obj.name = message.name; + obj.description = message.description; + obj.default_limit = message.defaultLimit; + obj.max_limit = message.maxLimit; + obj.free_tier = message.freeTier; + obj.duration = message.duration; + obj.metric = message.metric; + obj.unit = message.unit; + obj.values = {}; + if (message.values) { + Object.entries(message.values).forEach(([k, v]) => { + obj.values[k] = v.toString(); + }); + } + obj.display_name = message.displayName; + return obj; + }, + fromAmino(object: QuotaLimitAmino): QuotaLimit { + const message = createBaseQuotaLimit(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } + if (object.default_limit !== undefined && object.default_limit !== null) { + message.defaultLimit = BigInt(object.default_limit); + } + if (object.max_limit !== undefined && object.max_limit !== null) { + message.maxLimit = BigInt(object.max_limit); + } + if (object.free_tier !== undefined && object.free_tier !== null) { + message.freeTier = BigInt(object.free_tier); + } + if (object.duration !== undefined && object.duration !== null) { + message.duration = object.duration; + } + if (object.metric !== undefined && object.metric !== null) { + message.metric = object.metric; + } + if (object.unit !== undefined && object.unit !== null) { + message.unit = object.unit; + } + message.values = Object.entries(object.values ?? {}).reduce<{ + [key: string]: bigint; + }>((acc, [key, value]) => { + if (value !== undefined) { + acc[key] = BigInt(value.toString()); + } + return acc; + }, {}); + if (object.display_name !== undefined && object.display_name !== null) { + message.displayName = object.display_name; + } + return message; + }, + toAmino(message: QuotaLimit): QuotaLimitAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + obj.description = message.description === "" ? undefined : message.description; + obj.default_limit = message.defaultLimit !== BigInt(0) ? message.defaultLimit?.toString() : undefined; + obj.max_limit = message.maxLimit !== BigInt(0) ? message.maxLimit?.toString() : undefined; + obj.free_tier = message.freeTier !== BigInt(0) ? message.freeTier?.toString() : undefined; + obj.duration = message.duration === "" ? undefined : message.duration; + obj.metric = message.metric === "" ? undefined : message.metric; + obj.unit = message.unit === "" ? undefined : message.unit; + obj.values = {}; + if (message.values) { + Object.entries(message.values).forEach(([k, v]) => { + obj.values[k] = v.toString(); + }); + } + obj.display_name = message.displayName === "" ? undefined : message.displayName; + return obj; + }, + fromAminoMsg(object: QuotaLimitAminoMsg): QuotaLimit { + return QuotaLimit.fromAmino(object.value); + }, + fromProtoMsg(message: QuotaLimitProtoMsg): QuotaLimit { + return QuotaLimit.decode(message.value); + }, + toProto(message: QuotaLimit): Uint8Array { + return QuotaLimit.encode(message).finish(); + }, + toProtoMsg(message: QuotaLimit): QuotaLimitProtoMsg { + return { + typeUrl: "/google.api.QuotaLimit", + value: QuotaLimit.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/api/resource.ts b/__fixtures__/v-next/outputicjsdeps/google/api/resource.ts new file mode 100644 index 0000000000..81b8db510d --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/api/resource.ts @@ -0,0 +1,671 @@ +import { BinaryReader, BinaryWriter } from "../../binary.js"; +import { isSet, DeepPartial } from "../../helpers.js"; +import { JsonSafe } from "../../json-safe.js"; +export const protobufPackage = "google.api"; +/** + * A description of the historical or future-looking state of the + * resource pattern. + */ +export enum ResourceDescriptor_History { + /** HISTORY_UNSPECIFIED - The "unset" value. */ + HISTORY_UNSPECIFIED = 0, + /** + * ORIGINALLY_SINGLE_PATTERN - The resource originally had one pattern and launched as such, and + * additional patterns were added later. + */ + ORIGINALLY_SINGLE_PATTERN = 1, + /** + * FUTURE_MULTI_PATTERN - The resource has one pattern, but the API owner expects to add more + * later. (This is the inverse of ORIGINALLY_SINGLE_PATTERN, and prevents + * that from being necessary once there are multiple patterns.) + */ + FUTURE_MULTI_PATTERN = 2, + UNRECOGNIZED = -1, +} +export const ResourceDescriptor_HistorySDKType = ResourceDescriptor_History; +export function resourceDescriptor_HistoryFromJSON(object: any): ResourceDescriptor_History { + switch (object) { + case 0: + case "HISTORY_UNSPECIFIED": + return ResourceDescriptor_History.HISTORY_UNSPECIFIED; + case 1: + case "ORIGINALLY_SINGLE_PATTERN": + return ResourceDescriptor_History.ORIGINALLY_SINGLE_PATTERN; + case 2: + case "FUTURE_MULTI_PATTERN": + return ResourceDescriptor_History.FUTURE_MULTI_PATTERN; + case -1: + case "UNRECOGNIZED": + default: + return ResourceDescriptor_History.UNRECOGNIZED; + } +} +export function resourceDescriptor_HistoryToJSON(object: ResourceDescriptor_History): string { + switch (object) { + case ResourceDescriptor_History.HISTORY_UNSPECIFIED: + return "HISTORY_UNSPECIFIED"; + case ResourceDescriptor_History.ORIGINALLY_SINGLE_PATTERN: + return "ORIGINALLY_SINGLE_PATTERN"; + case ResourceDescriptor_History.FUTURE_MULTI_PATTERN: + return "FUTURE_MULTI_PATTERN"; + case ResourceDescriptor_History.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** A flag representing a specific style that a resource claims to conform to. */ +export enum ResourceDescriptor_Style { + /** STYLE_UNSPECIFIED - The unspecified value. Do not use. */ + STYLE_UNSPECIFIED = 0, + /** + * DECLARATIVE_FRIENDLY - This resource is intended to be "declarative-friendly". + * + * Declarative-friendly resources must be more strictly consistent, and + * setting this to true communicates to tools that this resource should + * adhere to declarative-friendly expectations. + * + * Note: This is used by the API linter (linter.aip.dev) to enable + * additional checks. + */ + DECLARATIVE_FRIENDLY = 1, + UNRECOGNIZED = -1, +} +export const ResourceDescriptor_StyleSDKType = ResourceDescriptor_Style; +export function resourceDescriptor_StyleFromJSON(object: any): ResourceDescriptor_Style { + switch (object) { + case 0: + case "STYLE_UNSPECIFIED": + return ResourceDescriptor_Style.STYLE_UNSPECIFIED; + case 1: + case "DECLARATIVE_FRIENDLY": + return ResourceDescriptor_Style.DECLARATIVE_FRIENDLY; + case -1: + case "UNRECOGNIZED": + default: + return ResourceDescriptor_Style.UNRECOGNIZED; + } +} +export function resourceDescriptor_StyleToJSON(object: ResourceDescriptor_Style): string { + switch (object) { + case ResourceDescriptor_Style.STYLE_UNSPECIFIED: + return "STYLE_UNSPECIFIED"; + case ResourceDescriptor_Style.DECLARATIVE_FRIENDLY: + return "DECLARATIVE_FRIENDLY"; + case ResourceDescriptor_Style.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** + * A simple descriptor of a resource type. + * + * ResourceDescriptor annotates a resource message (either by means of a + * protobuf annotation or use in the service config), and associates the + * resource's schema, the resource type, and the pattern of the resource name. + * + * Example: + * + * message Topic { + * // Indicates this message defines a resource schema. + * // Declares the resource type in the format of {service}/{kind}. + * // For Kubernetes resources, the format is {api group}/{kind}. + * option (google.api.resource) = { + * type: "pubsub.googleapis.com/Topic" + * pattern: "projects/{project}/topics/{topic}" + * }; + * } + * + * The ResourceDescriptor Yaml config will look like: + * + * resources: + * - type: "pubsub.googleapis.com/Topic" + * pattern: "projects/{project}/topics/{topic}" + * + * Sometimes, resources have multiple patterns, typically because they can + * live under multiple parents. + * + * Example: + * + * message LogEntry { + * option (google.api.resource) = { + * type: "logging.googleapis.com/LogEntry" + * pattern: "projects/{project}/logs/{log}" + * pattern: "folders/{folder}/logs/{log}" + * pattern: "organizations/{organization}/logs/{log}" + * pattern: "billingAccounts/{billing_account}/logs/{log}" + * }; + * } + * + * The ResourceDescriptor Yaml config will look like: + * + * resources: + * - type: 'logging.googleapis.com/LogEntry' + * pattern: "projects/{project}/logs/{log}" + * pattern: "folders/{folder}/logs/{log}" + * pattern: "organizations/{organization}/logs/{log}" + * pattern: "billingAccounts/{billing_account}/logs/{log}" + */ +export interface ResourceDescriptor { + /** + * The resource type. It must be in the format of + * {service_name}/{resource_type_kind}. The `resource_type_kind` must be + * singular and must not include version numbers. + * + * Example: `storage.googleapis.com/Bucket` + * + * The value of the resource_type_kind must follow the regular expression + * /[A-Za-z][a-zA-Z0-9]+/. It should start with an upper case character and + * should use PascalCase (UpperCamelCase). The maximum number of + * characters allowed for the `resource_type_kind` is 100. + */ + type: string; + /** + * Optional. The relative resource name pattern associated with this resource + * type. The DNS prefix of the full resource name shouldn't be specified here. + * + * The path pattern must follow the syntax, which aligns with HTTP binding + * syntax: + * + * Template = Segment { "/" Segment } ; + * Segment = LITERAL | Variable ; + * Variable = "{" LITERAL "}" ; + * + * Examples: + * + * - "projects/{project}/topics/{topic}" + * - "projects/{project}/knowledgeBases/{knowledge_base}" + * + * The components in braces correspond to the IDs for each resource in the + * hierarchy. It is expected that, if multiple patterns are provided, + * the same component name (e.g. "project") refers to IDs of the same + * type of resource. + */ + pattern: string[]; + /** + * Optional. The field on the resource that designates the resource name + * field. If omitted, this is assumed to be "name". + */ + nameField: string; + /** + * Optional. The historical or future-looking state of the resource pattern. + * + * Example: + * + * // The InspectTemplate message originally only supported resource + * // names with organization, and project was added later. + * message InspectTemplate { + * option (google.api.resource) = { + * type: "dlp.googleapis.com/InspectTemplate" + * pattern: + * "organizations/{organization}/inspectTemplates/{inspect_template}" + * pattern: "projects/{project}/inspectTemplates/{inspect_template}" + * history: ORIGINALLY_SINGLE_PATTERN + * }; + * } + */ + history: ResourceDescriptor_History; + /** + * The plural name used in the resource name and permission names, such as + * 'projects' for the resource name of 'projects/{project}' and the permission + * name of 'cloudresourcemanager.googleapis.com/projects.get'. It is the same + * concept of the `plural` field in k8s CRD spec + * https://kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions/ + * + * Note: The plural form is required even for singleton resources. See + * https://aip.dev/156 + */ + plural: string; + /** + * The same concept of the `singular` field in k8s CRD spec + * https://kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions/ + * Such as "project" for the `resourcemanager.googleapis.com/Project` type. + */ + singular: string; + /** + * Style flag(s) for this resource. + * These indicate that a resource is expected to conform to a given + * style. See the specific style flags for additional information. + */ + style: ResourceDescriptor_Style[]; +} +export interface ResourceDescriptorProtoMsg { + typeUrl: "/google.api.ResourceDescriptor"; + value: Uint8Array; +} +/** + * A simple descriptor of a resource type. + * + * ResourceDescriptor annotates a resource message (either by means of a + * protobuf annotation or use in the service config), and associates the + * resource's schema, the resource type, and the pattern of the resource name. + * + * Example: + * + * message Topic { + * // Indicates this message defines a resource schema. + * // Declares the resource type in the format of {service}/{kind}. + * // For Kubernetes resources, the format is {api group}/{kind}. + * option (google.api.resource) = { + * type: "pubsub.googleapis.com/Topic" + * pattern: "projects/{project}/topics/{topic}" + * }; + * } + * + * The ResourceDescriptor Yaml config will look like: + * + * resources: + * - type: "pubsub.googleapis.com/Topic" + * pattern: "projects/{project}/topics/{topic}" + * + * Sometimes, resources have multiple patterns, typically because they can + * live under multiple parents. + * + * Example: + * + * message LogEntry { + * option (google.api.resource) = { + * type: "logging.googleapis.com/LogEntry" + * pattern: "projects/{project}/logs/{log}" + * pattern: "folders/{folder}/logs/{log}" + * pattern: "organizations/{organization}/logs/{log}" + * pattern: "billingAccounts/{billing_account}/logs/{log}" + * }; + * } + * + * The ResourceDescriptor Yaml config will look like: + * + * resources: + * - type: 'logging.googleapis.com/LogEntry' + * pattern: "projects/{project}/logs/{log}" + * pattern: "folders/{folder}/logs/{log}" + * pattern: "organizations/{organization}/logs/{log}" + * pattern: "billingAccounts/{billing_account}/logs/{log}" + */ +export interface ResourceDescriptorSDKType { + type: string; + pattern: string[]; + name_field: string; + history: ResourceDescriptor_History; + plural: string; + singular: string; + style: ResourceDescriptor_Style[]; +} +/** + * Defines a proto annotation that describes a string field that refers to + * an API resource. + */ +export interface ResourceReference { + /** + * The resource type that the annotated field references. + * + * Example: + * + * message Subscription { + * string topic = 2 [(google.api.resource_reference) = { + * type: "pubsub.googleapis.com/Topic" + * }]; + * } + * + * Occasionally, a field may reference an arbitrary resource. In this case, + * APIs use the special value * in their resource reference. + * + * Example: + * + * message GetIamPolicyRequest { + * string resource = 2 [(google.api.resource_reference) = { + * type: "*" + * }]; + * } + */ + type: string; + /** + * The resource type of a child collection that the annotated field + * references. This is useful for annotating the `parent` field that + * doesn't have a fixed resource type. + * + * Example: + * + * message ListLogEntriesRequest { + * string parent = 1 [(google.api.resource_reference) = { + * child_type: "logging.googleapis.com/LogEntry" + * }; + * } + */ + childType: string; +} +export interface ResourceReferenceProtoMsg { + typeUrl: "/google.api.ResourceReference"; + value: Uint8Array; +} +/** + * Defines a proto annotation that describes a string field that refers to + * an API resource. + */ +export interface ResourceReferenceSDKType { + type: string; + child_type: string; +} +function createBaseResourceDescriptor(): ResourceDescriptor { + return { + type: "", + pattern: [], + nameField: "", + history: 0, + plural: "", + singular: "", + style: [] + }; +} +export const ResourceDescriptor = { + typeUrl: "/google.api.ResourceDescriptor", + encode(message: ResourceDescriptor, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.type !== undefined) { + writer.uint32(10).string(message.type); + } + for (const v of message.pattern) { + writer.uint32(18).string(v!); + } + if (message.nameField !== undefined) { + writer.uint32(26).string(message.nameField); + } + if (message.history !== 0) { + writer.uint32(32).int32(message.history); + } + if (message.plural !== undefined) { + writer.uint32(42).string(message.plural); + } + if (message.singular !== undefined) { + writer.uint32(50).string(message.singular); + } + writer.uint32(82).fork(); + for (const v of message.style) { + writer.int32(v); + } + writer.ldelim(); + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ResourceDescriptor { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseResourceDescriptor(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.type = reader.string(); + break; + case 2: + message.pattern.push(reader.string()); + break; + case 3: + message.nameField = reader.string(); + break; + case 4: + message.history = (reader.int32() as any); + break; + case 5: + message.plural = reader.string(); + break; + case 6: + message.singular = reader.string(); + break; + case 10: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.style.push((reader.int32() as any)); + } + } else { + message.style.push((reader.int32() as any)); + } + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ResourceDescriptor { + const obj = createBaseResourceDescriptor(); + if (isSet(object.type)) obj.type = String(object.type); + if (Array.isArray(object?.pattern)) obj.pattern = object.pattern.map((e: any) => String(e)); + if (isSet(object.nameField)) obj.nameField = String(object.nameField); + if (isSet(object.history)) obj.history = resourceDescriptor_HistoryFromJSON(object.history); + if (isSet(object.plural)) obj.plural = String(object.plural); + if (isSet(object.singular)) obj.singular = String(object.singular); + if (Array.isArray(object?.style)) obj.style = object.style.map((e: any) => resourceDescriptor_StyleFromJSON(e)); + return obj; + }, + toJSON(message: ResourceDescriptor): JsonSafe { + const obj: any = {}; + message.type !== undefined && (obj.type = message.type); + if (message.pattern) { + obj.pattern = message.pattern.map(e => e); + } else { + obj.pattern = []; + } + message.nameField !== undefined && (obj.nameField = message.nameField); + message.history !== undefined && (obj.history = resourceDescriptor_HistoryToJSON(message.history)); + message.plural !== undefined && (obj.plural = message.plural); + message.singular !== undefined && (obj.singular = message.singular); + if (message.style) { + obj.style = message.style.map(e => resourceDescriptor_StyleToJSON(e)); + } else { + obj.style = []; + } + return obj; + }, + fromPartial(object: DeepPartial): ResourceDescriptor { + const message = createBaseResourceDescriptor(); + message.type = object.type ?? ""; + message.pattern = object.pattern?.map(e => e) || []; + message.nameField = object.nameField ?? ""; + message.history = object.history ?? 0; + message.plural = object.plural ?? ""; + message.singular = object.singular ?? ""; + message.style = object.style?.map(e => e) || []; + return message; + }, + fromSDK(object: ResourceDescriptorSDKType): ResourceDescriptor { + return { + type: object?.type, + pattern: Array.isArray(object?.pattern) ? object.pattern.map((e: any) => e) : [], + nameField: object?.name_field, + history: isSet(object.history) ? resourceDescriptor_HistoryFromJSON(object.history) : -1, + plural: object?.plural, + singular: object?.singular, + style: Array.isArray(object?.style) ? object.style.map((e: any) => resourceDescriptor_StyleFromJSON(e)) : [] + }; + }, + fromSDKJSON(object: any): ResourceDescriptorSDKType { + return { + type: isSet(object.type) ? String(object.type) : "", + pattern: Array.isArray(object?.pattern) ? object.pattern.map((e: any) => String(e)) : [], + name_field: isSet(object.name_field) ? String(object.name_field) : "", + history: isSet(object.history) ? resourceDescriptor_HistoryFromJSON(object.history) : -1, + plural: isSet(object.plural) ? String(object.plural) : "", + singular: isSet(object.singular) ? String(object.singular) : "", + style: Array.isArray(object?.style) ? object.style.map((e: any) => resourceDescriptor_StyleFromJSON(e)) : [] + }; + }, + toSDK(message: ResourceDescriptor): ResourceDescriptorSDKType { + const obj: any = {}; + obj.type = message.type; + if (message.pattern) { + obj.pattern = message.pattern.map(e => e); + } else { + obj.pattern = []; + } + obj.name_field = message.nameField; + message.history !== undefined && (obj.history = resourceDescriptor_HistoryToJSON(message.history)); + obj.plural = message.plural; + obj.singular = message.singular; + if (message.style) { + obj.style = message.style.map(e => resourceDescriptor_StyleToJSON(e)); + } else { + obj.style = []; + } + return obj; + }, + fromAmino(object: ResourceDescriptorAmino): ResourceDescriptor { + const message = createBaseResourceDescriptor(); + if (object.type !== undefined && object.type !== null) { + message.type = object.type; + } + message.pattern = object.pattern?.map(e => e) || []; + if (object.name_field !== undefined && object.name_field !== null) { + message.nameField = object.name_field; + } + if (object.history !== undefined && object.history !== null) { + message.history = object.history; + } + if (object.plural !== undefined && object.plural !== null) { + message.plural = object.plural; + } + if (object.singular !== undefined && object.singular !== null) { + message.singular = object.singular; + } + message.style = object.style?.map(e => e) || []; + return message; + }, + toAmino(message: ResourceDescriptor): ResourceDescriptorAmino { + const obj: any = {}; + obj.type = message.type === "" ? undefined : message.type; + if (message.pattern) { + obj.pattern = message.pattern.map(e => e); + } else { + obj.pattern = message.pattern; + } + obj.name_field = message.nameField === "" ? undefined : message.nameField; + obj.history = message.history === 0 ? undefined : message.history; + obj.plural = message.plural === "" ? undefined : message.plural; + obj.singular = message.singular === "" ? undefined : message.singular; + if (message.style) { + obj.style = message.style.map(e => e); + } else { + obj.style = message.style; + } + return obj; + }, + fromAminoMsg(object: ResourceDescriptorAminoMsg): ResourceDescriptor { + return ResourceDescriptor.fromAmino(object.value); + }, + fromProtoMsg(message: ResourceDescriptorProtoMsg): ResourceDescriptor { + return ResourceDescriptor.decode(message.value); + }, + toProto(message: ResourceDescriptor): Uint8Array { + return ResourceDescriptor.encode(message).finish(); + }, + toProtoMsg(message: ResourceDescriptor): ResourceDescriptorProtoMsg { + return { + typeUrl: "/google.api.ResourceDescriptor", + value: ResourceDescriptor.encode(message).finish() + }; + } +}; +function createBaseResourceReference(): ResourceReference { + return { + type: "", + childType: "" + }; +} +export const ResourceReference = { + typeUrl: "/google.api.ResourceReference", + encode(message: ResourceReference, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.type !== undefined) { + writer.uint32(10).string(message.type); + } + if (message.childType !== undefined) { + writer.uint32(18).string(message.childType); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ResourceReference { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseResourceReference(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.type = reader.string(); + break; + case 2: + message.childType = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ResourceReference { + const obj = createBaseResourceReference(); + if (isSet(object.type)) obj.type = String(object.type); + if (isSet(object.childType)) obj.childType = String(object.childType); + return obj; + }, + toJSON(message: ResourceReference): JsonSafe { + const obj: any = {}; + message.type !== undefined && (obj.type = message.type); + message.childType !== undefined && (obj.childType = message.childType); + return obj; + }, + fromPartial(object: DeepPartial): ResourceReference { + const message = createBaseResourceReference(); + message.type = object.type ?? ""; + message.childType = object.childType ?? ""; + return message; + }, + fromSDK(object: ResourceReferenceSDKType): ResourceReference { + return { + type: object?.type, + childType: object?.child_type + }; + }, + fromSDKJSON(object: any): ResourceReferenceSDKType { + return { + type: isSet(object.type) ? String(object.type) : "", + child_type: isSet(object.child_type) ? String(object.child_type) : "" + }; + }, + toSDK(message: ResourceReference): ResourceReferenceSDKType { + const obj: any = {}; + obj.type = message.type; + obj.child_type = message.childType; + return obj; + }, + fromAmino(object: ResourceReferenceAmino): ResourceReference { + const message = createBaseResourceReference(); + if (object.type !== undefined && object.type !== null) { + message.type = object.type; + } + if (object.child_type !== undefined && object.child_type !== null) { + message.childType = object.child_type; + } + return message; + }, + toAmino(message: ResourceReference): ResourceReferenceAmino { + const obj: any = {}; + obj.type = message.type === "" ? undefined : message.type; + obj.child_type = message.childType === "" ? undefined : message.childType; + return obj; + }, + fromAminoMsg(object: ResourceReferenceAminoMsg): ResourceReference { + return ResourceReference.fromAmino(object.value); + }, + fromProtoMsg(message: ResourceReferenceProtoMsg): ResourceReference { + return ResourceReference.decode(message.value); + }, + toProto(message: ResourceReference): Uint8Array { + return ResourceReference.encode(message).finish(); + }, + toProtoMsg(message: ResourceReference): ResourceReferenceProtoMsg { + return { + typeUrl: "/google.api.ResourceReference", + value: ResourceReference.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/api/routing.ts b/__fixtures__/v-next/outputicjsdeps/google/api/routing.ts new file mode 100644 index 0000000000..d86d2e3190 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/api/routing.ts @@ -0,0 +1,1018 @@ +import { BinaryReader, BinaryWriter } from "../../binary.js"; +import { JsonSafe } from "../../json-safe.js"; +import { DeepPartial, isSet } from "../../helpers.js"; +export const protobufPackage = "google.api"; +/** + * Specifies the routing information that should be sent along with the request + * in the form of routing header. + * **NOTE:** All service configuration rules follow the "last one wins" order. + * + * The examples below will apply to an RPC which has the following request type: + * + * Message Definition: + * + * message Request { + * // The name of the Table + * // Values can be of the following formats: + * // - `projects//tables/` + * // - `projects//instances//tables/
` + * // - `region//zones//tables/
` + * string table_name = 1; + * + * // This value specifies routing for replication. + * // It can be in the following formats: + * // - `profiles/` + * // - a legacy `profile_id` that can be any string + * string app_profile_id = 2; + * } + * + * Example message: + * + * { + * table_name: projects/proj_foo/instances/instance_bar/table/table_baz, + * app_profile_id: profiles/prof_qux + * } + * + * The routing header consists of one or multiple key-value pairs. Every key + * and value must be percent-encoded, and joined together in the format of + * `key1=value1&key2=value2`. + * In the examples below I am skipping the percent-encoding for readablity. + * + * Example 1 + * + * Extracting a field from the request to put into the routing header + * unchanged, with the key equal to the field name. + * + * annotation: + * + * option (google.api.routing) = { + * // Take the `app_profile_id`. + * routing_parameters { + * field: "app_profile_id" + * } + * }; + * + * result: + * + * x-goog-request-params: app_profile_id=profiles/prof_qux + * + * Example 2 + * + * Extracting a field from the request to put into the routing header + * unchanged, with the key different from the field name. + * + * annotation: + * + * option (google.api.routing) = { + * // Take the `app_profile_id`, but name it `routing_id` in the header. + * routing_parameters { + * field: "app_profile_id" + * path_template: "{routing_id=**}" + * } + * }; + * + * result: + * + * x-goog-request-params: routing_id=profiles/prof_qux + * + * Example 3 + * + * Extracting a field from the request to put into the routing + * header, while matching a path template syntax on the field's value. + * + * NB: it is more useful to send nothing than to send garbage for the purpose + * of dynamic routing, since garbage pollutes cache. Thus the matching. + * + * Sub-example 3a + * + * The field matches the template. + * + * annotation: + * + * option (google.api.routing) = { + * // Take the `table_name`, if it's well-formed (with project-based + * // syntax). + * routing_parameters { + * field: "table_name" + * path_template: "{table_name=projects/*\/instances/*\/**}" + * } + * }; + * + * result: + * + * x-goog-request-params: + * table_name=projects/proj_foo/instances/instance_bar/table/table_baz + * + * Sub-example 3b + * + * The field does not match the template. + * + * annotation: + * + * option (google.api.routing) = { + * // Take the `table_name`, if it's well-formed (with region-based + * // syntax). + * routing_parameters { + * field: "table_name" + * path_template: "{table_name=regions/*\/zones/*\/**}" + * } + * }; + * + * result: + * + * + * + * Sub-example 3c + * + * Multiple alternative conflictingly named path templates are + * specified. The one that matches is used to construct the header. + * + * annotation: + * + * option (google.api.routing) = { + * // Take the `table_name`, if it's well-formed, whether + * // using the region- or projects-based syntax. + * + * routing_parameters { + * field: "table_name" + * path_template: "{table_name=regions/*\/zones/*\/**}" + * } + * routing_parameters { + * field: "table_name" + * path_template: "{table_name=projects/*\/instances/*\/**}" + * } + * }; + * + * result: + * + * x-goog-request-params: + * table_name=projects/proj_foo/instances/instance_bar/table/table_baz + * + * Example 4 + * + * Extracting a single routing header key-value pair by matching a + * template syntax on (a part of) a single request field. + * + * annotation: + * + * option (google.api.routing) = { + * // Take just the project id from the `table_name` field. + * routing_parameters { + * field: "table_name" + * path_template: "{routing_id=projects/*}/**" + * } + * }; + * + * result: + * + * x-goog-request-params: routing_id=projects/proj_foo + * + * Example 5 + * + * Extracting a single routing header key-value pair by matching + * several conflictingly named path templates on (parts of) a single request + * field. The last template to match "wins" the conflict. + * + * annotation: + * + * option (google.api.routing) = { + * // If the `table_name` does not have instances information, + * // take just the project id for routing. + * // Otherwise take project + instance. + * + * routing_parameters { + * field: "table_name" + * path_template: "{routing_id=projects/*}/**" + * } + * routing_parameters { + * field: "table_name" + * path_template: "{routing_id=projects/*\/instances/*}/**" + * } + * }; + * + * result: + * + * x-goog-request-params: + * routing_id=projects/proj_foo/instances/instance_bar + * + * Example 6 + * + * Extracting multiple routing header key-value pairs by matching + * several non-conflicting path templates on (parts of) a single request field. + * + * Sub-example 6a + * + * Make the templates strict, so that if the `table_name` does not + * have an instance information, nothing is sent. + * + * annotation: + * + * option (google.api.routing) = { + * // The routing code needs two keys instead of one composite + * // but works only for the tables with the "project-instance" name + * // syntax. + * + * routing_parameters { + * field: "table_name" + * path_template: "{project_id=projects/*}/instances/*\/**" + * } + * routing_parameters { + * field: "table_name" + * path_template: "projects/*\/{instance_id=instances/*}/**" + * } + * }; + * + * result: + * + * x-goog-request-params: + * project_id=projects/proj_foo&instance_id=instances/instance_bar + * + * Sub-example 6b + * + * Make the templates loose, so that if the `table_name` does not + * have an instance information, just the project id part is sent. + * + * annotation: + * + * option (google.api.routing) = { + * // The routing code wants two keys instead of one composite + * // but will work with just the `project_id` for tables without + * // an instance in the `table_name`. + * + * routing_parameters { + * field: "table_name" + * path_template: "{project_id=projects/*}/**" + * } + * routing_parameters { + * field: "table_name" + * path_template: "projects/*\/{instance_id=instances/*}/**" + * } + * }; + * + * result (is the same as 6a for our example message because it has the instance + * information): + * + * x-goog-request-params: + * project_id=projects/proj_foo&instance_id=instances/instance_bar + * + * Example 7 + * + * Extracting multiple routing header key-value pairs by matching + * several path templates on multiple request fields. + * + * NB: note that here there is no way to specify sending nothing if one of the + * fields does not match its template. E.g. if the `table_name` is in the wrong + * format, the `project_id` will not be sent, but the `routing_id` will be. + * The backend routing code has to be aware of that and be prepared to not + * receive a full complement of keys if it expects multiple. + * + * annotation: + * + * option (google.api.routing) = { + * // The routing needs both `project_id` and `routing_id` + * // (from the `app_profile_id` field) for routing. + * + * routing_parameters { + * field: "table_name" + * path_template: "{project_id=projects/*}/**" + * } + * routing_parameters { + * field: "app_profile_id" + * path_template: "{routing_id=**}" + * } + * }; + * + * result: + * + * x-goog-request-params: + * project_id=projects/proj_foo&routing_id=profiles/prof_qux + * + * Example 8 + * + * Extracting a single routing header key-value pair by matching + * several conflictingly named path templates on several request fields. The + * last template to match "wins" the conflict. + * + * annotation: + * + * option (google.api.routing) = { + * // The `routing_id` can be a project id or a region id depending on + * // the table name format, but only if the `app_profile_id` is not set. + * // If `app_profile_id` is set it should be used instead. + * + * routing_parameters { + * field: "table_name" + * path_template: "{routing_id=projects/*}/**" + * } + * routing_parameters { + * field: "table_name" + * path_template: "{routing_id=regions/*}/**" + * } + * routing_parameters { + * field: "app_profile_id" + * path_template: "{routing_id=**}" + * } + * }; + * + * result: + * + * x-goog-request-params: routing_id=profiles/prof_qux + * + * Example 9 + * + * Bringing it all together. + * + * annotation: + * + * option (google.api.routing) = { + * // For routing both `table_location` and a `routing_id` are needed. + * // + * // table_location can be either an instance id or a region+zone id. + * // + * // For `routing_id`, take the value of `app_profile_id` + * // - If it's in the format `profiles/`, send + * // just the `` part. + * // - If it's any other literal, send it as is. + * // If the `app_profile_id` is empty, and the `table_name` starts with + * // the project_id, send that instead. + * + * routing_parameters { + * field: "table_name" + * path_template: "projects/*\/{table_location=instances/*}/tables/*" + * } + * routing_parameters { + * field: "table_name" + * path_template: "{table_location=regions/*\/zones/*}/tables/*" + * } + * routing_parameters { + * field: "table_name" + * path_template: "{routing_id=projects/*}/**" + * } + * routing_parameters { + * field: "app_profile_id" + * path_template: "{routing_id=**}" + * } + * routing_parameters { + * field: "app_profile_id" + * path_template: "profiles/{routing_id=*}" + * } + * }; + * + * result: + * + * x-goog-request-params: + * table_location=instances/instance_bar&routing_id=prof_qux + */ +export interface RoutingRule { + /** + * A collection of Routing Parameter specifications. + * **NOTE:** If multiple Routing Parameters describe the same key + * (via the `path_template` field or via the `field` field when + * `path_template` is not provided), "last one wins" rule + * determines which Parameter gets used. + * See the examples for more details. + */ + routingParameters: RoutingParameter[]; +} +export interface RoutingRuleProtoMsg { + typeUrl: "/google.api.RoutingRule"; + value: Uint8Array; +} +/** + * Specifies the routing information that should be sent along with the request + * in the form of routing header. + * **NOTE:** All service configuration rules follow the "last one wins" order. + * + * The examples below will apply to an RPC which has the following request type: + * + * Message Definition: + * + * message Request { + * // The name of the Table + * // Values can be of the following formats: + * // - `projects//tables/
` + * // - `projects//instances//tables/
` + * // - `region//zones//tables/
` + * string table_name = 1; + * + * // This value specifies routing for replication. + * // It can be in the following formats: + * // - `profiles/` + * // - a legacy `profile_id` that can be any string + * string app_profile_id = 2; + * } + * + * Example message: + * + * { + * table_name: projects/proj_foo/instances/instance_bar/table/table_baz, + * app_profile_id: profiles/prof_qux + * } + * + * The routing header consists of one or multiple key-value pairs. Every key + * and value must be percent-encoded, and joined together in the format of + * `key1=value1&key2=value2`. + * In the examples below I am skipping the percent-encoding for readablity. + * + * Example 1 + * + * Extracting a field from the request to put into the routing header + * unchanged, with the key equal to the field name. + * + * annotation: + * + * option (google.api.routing) = { + * // Take the `app_profile_id`. + * routing_parameters { + * field: "app_profile_id" + * } + * }; + * + * result: + * + * x-goog-request-params: app_profile_id=profiles/prof_qux + * + * Example 2 + * + * Extracting a field from the request to put into the routing header + * unchanged, with the key different from the field name. + * + * annotation: + * + * option (google.api.routing) = { + * // Take the `app_profile_id`, but name it `routing_id` in the header. + * routing_parameters { + * field: "app_profile_id" + * path_template: "{routing_id=**}" + * } + * }; + * + * result: + * + * x-goog-request-params: routing_id=profiles/prof_qux + * + * Example 3 + * + * Extracting a field from the request to put into the routing + * header, while matching a path template syntax on the field's value. + * + * NB: it is more useful to send nothing than to send garbage for the purpose + * of dynamic routing, since garbage pollutes cache. Thus the matching. + * + * Sub-example 3a + * + * The field matches the template. + * + * annotation: + * + * option (google.api.routing) = { + * // Take the `table_name`, if it's well-formed (with project-based + * // syntax). + * routing_parameters { + * field: "table_name" + * path_template: "{table_name=projects/*\/instances/*\/**}" + * } + * }; + * + * result: + * + * x-goog-request-params: + * table_name=projects/proj_foo/instances/instance_bar/table/table_baz + * + * Sub-example 3b + * + * The field does not match the template. + * + * annotation: + * + * option (google.api.routing) = { + * // Take the `table_name`, if it's well-formed (with region-based + * // syntax). + * routing_parameters { + * field: "table_name" + * path_template: "{table_name=regions/*\/zones/*\/**}" + * } + * }; + * + * result: + * + * + * + * Sub-example 3c + * + * Multiple alternative conflictingly named path templates are + * specified. The one that matches is used to construct the header. + * + * annotation: + * + * option (google.api.routing) = { + * // Take the `table_name`, if it's well-formed, whether + * // using the region- or projects-based syntax. + * + * routing_parameters { + * field: "table_name" + * path_template: "{table_name=regions/*\/zones/*\/**}" + * } + * routing_parameters { + * field: "table_name" + * path_template: "{table_name=projects/*\/instances/*\/**}" + * } + * }; + * + * result: + * + * x-goog-request-params: + * table_name=projects/proj_foo/instances/instance_bar/table/table_baz + * + * Example 4 + * + * Extracting a single routing header key-value pair by matching a + * template syntax on (a part of) a single request field. + * + * annotation: + * + * option (google.api.routing) = { + * // Take just the project id from the `table_name` field. + * routing_parameters { + * field: "table_name" + * path_template: "{routing_id=projects/*}/**" + * } + * }; + * + * result: + * + * x-goog-request-params: routing_id=projects/proj_foo + * + * Example 5 + * + * Extracting a single routing header key-value pair by matching + * several conflictingly named path templates on (parts of) a single request + * field. The last template to match "wins" the conflict. + * + * annotation: + * + * option (google.api.routing) = { + * // If the `table_name` does not have instances information, + * // take just the project id for routing. + * // Otherwise take project + instance. + * + * routing_parameters { + * field: "table_name" + * path_template: "{routing_id=projects/*}/**" + * } + * routing_parameters { + * field: "table_name" + * path_template: "{routing_id=projects/*\/instances/*}/**" + * } + * }; + * + * result: + * + * x-goog-request-params: + * routing_id=projects/proj_foo/instances/instance_bar + * + * Example 6 + * + * Extracting multiple routing header key-value pairs by matching + * several non-conflicting path templates on (parts of) a single request field. + * + * Sub-example 6a + * + * Make the templates strict, so that if the `table_name` does not + * have an instance information, nothing is sent. + * + * annotation: + * + * option (google.api.routing) = { + * // The routing code needs two keys instead of one composite + * // but works only for the tables with the "project-instance" name + * // syntax. + * + * routing_parameters { + * field: "table_name" + * path_template: "{project_id=projects/*}/instances/*\/**" + * } + * routing_parameters { + * field: "table_name" + * path_template: "projects/*\/{instance_id=instances/*}/**" + * } + * }; + * + * result: + * + * x-goog-request-params: + * project_id=projects/proj_foo&instance_id=instances/instance_bar + * + * Sub-example 6b + * + * Make the templates loose, so that if the `table_name` does not + * have an instance information, just the project id part is sent. + * + * annotation: + * + * option (google.api.routing) = { + * // The routing code wants two keys instead of one composite + * // but will work with just the `project_id` for tables without + * // an instance in the `table_name`. + * + * routing_parameters { + * field: "table_name" + * path_template: "{project_id=projects/*}/**" + * } + * routing_parameters { + * field: "table_name" + * path_template: "projects/*\/{instance_id=instances/*}/**" + * } + * }; + * + * result (is the same as 6a for our example message because it has the instance + * information): + * + * x-goog-request-params: + * project_id=projects/proj_foo&instance_id=instances/instance_bar + * + * Example 7 + * + * Extracting multiple routing header key-value pairs by matching + * several path templates on multiple request fields. + * + * NB: note that here there is no way to specify sending nothing if one of the + * fields does not match its template. E.g. if the `table_name` is in the wrong + * format, the `project_id` will not be sent, but the `routing_id` will be. + * The backend routing code has to be aware of that and be prepared to not + * receive a full complement of keys if it expects multiple. + * + * annotation: + * + * option (google.api.routing) = { + * // The routing needs both `project_id` and `routing_id` + * // (from the `app_profile_id` field) for routing. + * + * routing_parameters { + * field: "table_name" + * path_template: "{project_id=projects/*}/**" + * } + * routing_parameters { + * field: "app_profile_id" + * path_template: "{routing_id=**}" + * } + * }; + * + * result: + * + * x-goog-request-params: + * project_id=projects/proj_foo&routing_id=profiles/prof_qux + * + * Example 8 + * + * Extracting a single routing header key-value pair by matching + * several conflictingly named path templates on several request fields. The + * last template to match "wins" the conflict. + * + * annotation: + * + * option (google.api.routing) = { + * // The `routing_id` can be a project id or a region id depending on + * // the table name format, but only if the `app_profile_id` is not set. + * // If `app_profile_id` is set it should be used instead. + * + * routing_parameters { + * field: "table_name" + * path_template: "{routing_id=projects/*}/**" + * } + * routing_parameters { + * field: "table_name" + * path_template: "{routing_id=regions/*}/**" + * } + * routing_parameters { + * field: "app_profile_id" + * path_template: "{routing_id=**}" + * } + * }; + * + * result: + * + * x-goog-request-params: routing_id=profiles/prof_qux + * + * Example 9 + * + * Bringing it all together. + * + * annotation: + * + * option (google.api.routing) = { + * // For routing both `table_location` and a `routing_id` are needed. + * // + * // table_location can be either an instance id or a region+zone id. + * // + * // For `routing_id`, take the value of `app_profile_id` + * // - If it's in the format `profiles/`, send + * // just the `` part. + * // - If it's any other literal, send it as is. + * // If the `app_profile_id` is empty, and the `table_name` starts with + * // the project_id, send that instead. + * + * routing_parameters { + * field: "table_name" + * path_template: "projects/*\/{table_location=instances/*}/tables/*" + * } + * routing_parameters { + * field: "table_name" + * path_template: "{table_location=regions/*\/zones/*}/tables/*" + * } + * routing_parameters { + * field: "table_name" + * path_template: "{routing_id=projects/*}/**" + * } + * routing_parameters { + * field: "app_profile_id" + * path_template: "{routing_id=**}" + * } + * routing_parameters { + * field: "app_profile_id" + * path_template: "profiles/{routing_id=*}" + * } + * }; + * + * result: + * + * x-goog-request-params: + * table_location=instances/instance_bar&routing_id=prof_qux + */ +export interface RoutingRuleSDKType { + routing_parameters: RoutingParameterSDKType[]; +} +/** A projection from an input message to the GRPC or REST header. */ +export interface RoutingParameter { + /** A request field to extract the header key-value pair from. */ + field: string; + /** + * A pattern matching the key-value field. Optional. + * If not specified, the whole field specified in the `field` field will be + * taken as value, and its name used as key. If specified, it MUST contain + * exactly one named segment (along with any number of unnamed segments) The + * pattern will be matched over the field specified in the `field` field, then + * if the match is successful: + * - the name of the single named segment will be used as a header name, + * - the match value of the segment will be used as a header value; + * if the match is NOT successful, nothing will be sent. + * + * Example: + * + * -- This is a field in the request message + * | that the header value will be extracted from. + * | + * | -- This is the key name in the + * | | routing header. + * V | + * field: "table_name" v + * path_template: "projects/*\/{table_location=instances/*}/tables/*" + * ^ ^ + * | | + * In the {} brackets is the pattern that -- | + * specifies what to extract from the | + * field as a value to be sent. | + * | + * The string in the field must match the whole pattern -- + * before brackets, inside brackets, after brackets. + * + * When looking at this specific example, we can see that: + * - A key-value pair with the key `table_location` + * and the value matching `instances/*` should be added + * to the x-goog-request-params routing header. + * - The value is extracted from the request message's `table_name` field + * if it matches the full pattern specified: + * `projects/*\/instances/*\/tables/*`. + * + * **NB:** If the `path_template` field is not provided, the key name is + * equal to the field name, and the whole field should be sent as a value. + * This makes the pattern for the field and the value functionally equivalent + * to `**`, and the configuration + * + * { + * field: "table_name" + * } + * + * is a functionally equivalent shorthand to: + * + * { + * field: "table_name" + * path_template: "{table_name=**}" + * } + * + * See Example 1 for more details. + */ + pathTemplate: string; +} +export interface RoutingParameterProtoMsg { + typeUrl: "/google.api.RoutingParameter"; + value: Uint8Array; +} +/** A projection from an input message to the GRPC or REST header. */ +export interface RoutingParameterSDKType { + field: string; + path_template: string; +} +function createBaseRoutingRule(): RoutingRule { + return { + routingParameters: [] + }; +} +export const RoutingRule = { + typeUrl: "/google.api.RoutingRule", + encode(message: RoutingRule, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.routingParameters) { + RoutingParameter.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): RoutingRule { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseRoutingRule(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.routingParameters.push(RoutingParameter.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): RoutingRule { + const obj = createBaseRoutingRule(); + if (Array.isArray(object?.routingParameters)) obj.routingParameters = object.routingParameters.map((e: any) => RoutingParameter.fromJSON(e)); + return obj; + }, + toJSON(message: RoutingRule): JsonSafe { + const obj: any = {}; + if (message.routingParameters) { + obj.routingParameters = message.routingParameters.map(e => e ? RoutingParameter.toJSON(e) : undefined); + } else { + obj.routingParameters = []; + } + return obj; + }, + fromPartial(object: DeepPartial): RoutingRule { + const message = createBaseRoutingRule(); + message.routingParameters = object.routingParameters?.map(e => RoutingParameter.fromPartial(e)) || []; + return message; + }, + fromSDK(object: RoutingRuleSDKType): RoutingRule { + return { + routingParameters: Array.isArray(object?.routing_parameters) ? object.routing_parameters.map((e: any) => RoutingParameter.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): RoutingRuleSDKType { + return { + routing_parameters: Array.isArray(object?.routing_parameters) ? object.routing_parameters.map((e: any) => RoutingParameter.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: RoutingRule): RoutingRuleSDKType { + const obj: any = {}; + if (message.routingParameters) { + obj.routing_parameters = message.routingParameters.map(e => e ? RoutingParameter.toSDK(e) : undefined); + } else { + obj.routing_parameters = []; + } + return obj; + }, + fromAmino(object: RoutingRuleAmino): RoutingRule { + const message = createBaseRoutingRule(); + message.routingParameters = object.routing_parameters?.map(e => RoutingParameter.fromAmino(e)) || []; + return message; + }, + toAmino(message: RoutingRule): RoutingRuleAmino { + const obj: any = {}; + if (message.routingParameters) { + obj.routing_parameters = message.routingParameters.map(e => e ? RoutingParameter.toAmino(e) : undefined); + } else { + obj.routing_parameters = message.routingParameters; + } + return obj; + }, + fromAminoMsg(object: RoutingRuleAminoMsg): RoutingRule { + return RoutingRule.fromAmino(object.value); + }, + fromProtoMsg(message: RoutingRuleProtoMsg): RoutingRule { + return RoutingRule.decode(message.value); + }, + toProto(message: RoutingRule): Uint8Array { + return RoutingRule.encode(message).finish(); + }, + toProtoMsg(message: RoutingRule): RoutingRuleProtoMsg { + return { + typeUrl: "/google.api.RoutingRule", + value: RoutingRule.encode(message).finish() + }; + } +}; +function createBaseRoutingParameter(): RoutingParameter { + return { + field: "", + pathTemplate: "" + }; +} +export const RoutingParameter = { + typeUrl: "/google.api.RoutingParameter", + encode(message: RoutingParameter, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.field !== undefined) { + writer.uint32(10).string(message.field); + } + if (message.pathTemplate !== undefined) { + writer.uint32(18).string(message.pathTemplate); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): RoutingParameter { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseRoutingParameter(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.field = reader.string(); + break; + case 2: + message.pathTemplate = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): RoutingParameter { + const obj = createBaseRoutingParameter(); + if (isSet(object.field)) obj.field = String(object.field); + if (isSet(object.pathTemplate)) obj.pathTemplate = String(object.pathTemplate); + return obj; + }, + toJSON(message: RoutingParameter): JsonSafe { + const obj: any = {}; + message.field !== undefined && (obj.field = message.field); + message.pathTemplate !== undefined && (obj.pathTemplate = message.pathTemplate); + return obj; + }, + fromPartial(object: DeepPartial): RoutingParameter { + const message = createBaseRoutingParameter(); + message.field = object.field ?? ""; + message.pathTemplate = object.pathTemplate ?? ""; + return message; + }, + fromSDK(object: RoutingParameterSDKType): RoutingParameter { + return { + field: object?.field, + pathTemplate: object?.path_template + }; + }, + fromSDKJSON(object: any): RoutingParameterSDKType { + return { + field: isSet(object.field) ? String(object.field) : "", + path_template: isSet(object.path_template) ? String(object.path_template) : "" + }; + }, + toSDK(message: RoutingParameter): RoutingParameterSDKType { + const obj: any = {}; + obj.field = message.field; + obj.path_template = message.pathTemplate; + return obj; + }, + fromAmino(object: RoutingParameterAmino): RoutingParameter { + const message = createBaseRoutingParameter(); + if (object.field !== undefined && object.field !== null) { + message.field = object.field; + } + if (object.path_template !== undefined && object.path_template !== null) { + message.pathTemplate = object.path_template; + } + return message; + }, + toAmino(message: RoutingParameter): RoutingParameterAmino { + const obj: any = {}; + obj.field = message.field === "" ? undefined : message.field; + obj.path_template = message.pathTemplate === "" ? undefined : message.pathTemplate; + return obj; + }, + fromAminoMsg(object: RoutingParameterAminoMsg): RoutingParameter { + return RoutingParameter.fromAmino(object.value); + }, + fromProtoMsg(message: RoutingParameterProtoMsg): RoutingParameter { + return RoutingParameter.decode(message.value); + }, + toProto(message: RoutingParameter): Uint8Array { + return RoutingParameter.encode(message).finish(); + }, + toProtoMsg(message: RoutingParameter): RoutingParameterProtoMsg { + return { + typeUrl: "/google.api.RoutingParameter", + value: RoutingParameter.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/api/service.ts b/__fixtures__/v-next/outputicjsdeps/google/api/service.ts new file mode 100644 index 0000000000..61c5acb193 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/api/service.ts @@ -0,0 +1,796 @@ +import { Api, ApiSDKType } from "../protobuf/api.js"; +import { Type, TypeSDKType, Enum, EnumSDKType } from "../protobuf/type.js"; +import { Documentation, DocumentationSDKType } from "./documentation.js"; +import { Backend, BackendSDKType } from "./backend.js"; +import { Http, HttpSDKType } from "./http.js"; +import { Quota, QuotaSDKType } from "./quota.js"; +import { Authentication, AuthenticationSDKType } from "./auth.js"; +import { Context, ContextSDKType } from "./context.js"; +import { Usage, UsageSDKType } from "./usage.js"; +import { Endpoint, EndpointSDKType } from "./endpoint.js"; +import { Control, ControlSDKType } from "./control.js"; +import { LogDescriptor, LogDescriptorSDKType } from "./log.js"; +import { MetricDescriptor, MetricDescriptorSDKType } from "./metric.js"; +import { MonitoredResourceDescriptor, MonitoredResourceDescriptorSDKType } from "./monitored_resource.js"; +import { Billing, BillingSDKType } from "./billing.js"; +import { Logging, LoggingSDKType } from "./logging.js"; +import { Monitoring, MonitoringSDKType } from "./monitoring.js"; +import { SystemParameters, SystemParametersSDKType } from "./system_parameter.js"; +import { SourceInfo, SourceInfoSDKType } from "./source_info.js"; +import { UInt32Value, UInt32ValueSDKType } from "../protobuf/wrappers.js"; +import { BinaryReader, BinaryWriter } from "../../binary.js"; +import { isSet, DeepPartial } from "../../helpers.js"; +import { JsonSafe } from "../../json-safe.js"; +export const protobufPackage = "google.api"; +/** + * `Service` is the root object of Google service configuration schema. It + * describes basic information about a service, such as the name and the + * title, and delegates other aspects to sub-sections. Each sub-section is + * either a proto message or a repeated proto message that configures a + * specific aspect, such as auth. See each proto message definition for details. + * + * Example: + * + * type: google.api.Service + * name: calendar.googleapis.com + * title: Google Calendar API + * apis: + * - name: google.calendar.v3.Calendar + * authentication: + * providers: + * - id: google_calendar_auth + * jwks_uri: https://www.googleapis.com/oauth2/v1/certs + * issuer: https://securetoken.google.com + * rules: + * - selector: "*" + * requirements: + * provider_id: google_calendar_auth + */ +export interface Service { + /** + * The service name, which is a DNS-like logical identifier for the + * service, such as `calendar.googleapis.com`. The service name + * typically goes through DNS verification to make sure the owner + * of the service also owns the DNS name. + */ + name: string; + /** The product title for this service. */ + title: string; + /** The Google project that owns this service. */ + producerProjectId: string; + /** + * A unique ID for a specific instance of this message, typically assigned + * by the client for tracking purpose. Must be no longer than 63 characters + * and only lower case letters, digits, '.', '_' and '-' are allowed. If + * empty, the server may choose to generate one instead. + */ + id: string; + /** + * A list of API interfaces exported by this service. Only the `name` field + * of the [google.protobuf.Api][google.protobuf.Api] needs to be provided by the configuration + * author, as the remaining fields will be derived from the IDL during the + * normalization process. It is an error to specify an API interface here + * which cannot be resolved against the associated IDL files. + */ + apis: Api[]; + /** + * A list of all proto message types included in this API service. + * Types referenced directly or indirectly by the `apis` are + * automatically included. Messages which are not referenced but + * shall be included, such as types used by the `google.protobuf.Any` type, + * should be listed here by name. Example: + * + * types: + * - name: google.protobuf.Int32 + */ + types: Type[]; + /** + * A list of all enum types included in this API service. Enums + * referenced directly or indirectly by the `apis` are automatically + * included. Enums which are not referenced but shall be included + * should be listed here by name. Example: + * + * enums: + * - name: google.someapi.v1.SomeEnum + */ + enums: Enum[]; + /** Additional API documentation. */ + documentation?: Documentation; + /** API backend configuration. */ + backend?: Backend; + /** HTTP configuration. */ + http?: Http; + /** Quota configuration. */ + quota?: Quota; + /** Auth configuration. */ + authentication?: Authentication; + /** Context configuration. */ + context?: Context; + /** Configuration controlling usage of this service. */ + usage?: Usage; + /** + * Configuration for network endpoints. If this is empty, then an endpoint + * with the same name as the service is automatically generated to service all + * defined APIs. + */ + endpoints: Endpoint[]; + /** Configuration for the service control plane. */ + control?: Control; + /** Defines the logs used by this service. */ + logs: LogDescriptor[]; + /** Defines the metrics used by this service. */ + metrics: MetricDescriptor[]; + /** + * Defines the monitored resources used by this service. This is required + * by the [Service.monitoring][google.api.Service.monitoring] and [Service.logging][google.api.Service.logging] configurations. + */ + monitoredResources: MonitoredResourceDescriptor[]; + /** Billing configuration. */ + billing?: Billing; + /** Logging configuration. */ + logging?: Logging; + /** Monitoring configuration. */ + monitoring?: Monitoring; + /** System parameter configuration. */ + systemParameters?: SystemParameters; + /** Output only. The source information for this configuration if available. */ + sourceInfo?: SourceInfo; + /** + * Obsolete. Do not use. + * + * This field has no semantic meaning. The service config compiler always + * sets this field to `3`. + */ + /** @deprecated */ + configVersion?: UInt32Value; +} +export interface ServiceProtoMsg { + typeUrl: "/google.api.Service"; + value: Uint8Array; +} +/** + * `Service` is the root object of Google service configuration schema. It + * describes basic information about a service, such as the name and the + * title, and delegates other aspects to sub-sections. Each sub-section is + * either a proto message or a repeated proto message that configures a + * specific aspect, such as auth. See each proto message definition for details. + * + * Example: + * + * type: google.api.Service + * name: calendar.googleapis.com + * title: Google Calendar API + * apis: + * - name: google.calendar.v3.Calendar + * authentication: + * providers: + * - id: google_calendar_auth + * jwks_uri: https://www.googleapis.com/oauth2/v1/certs + * issuer: https://securetoken.google.com + * rules: + * - selector: "*" + * requirements: + * provider_id: google_calendar_auth + */ +export interface ServiceSDKType { + name: string; + title: string; + producer_project_id: string; + id: string; + apis: ApiSDKType[]; + types: TypeSDKType[]; + enums: EnumSDKType[]; + documentation?: DocumentationSDKType; + backend?: BackendSDKType; + http?: HttpSDKType; + quota?: QuotaSDKType; + authentication?: AuthenticationSDKType; + context?: ContextSDKType; + usage?: UsageSDKType; + endpoints: EndpointSDKType[]; + control?: ControlSDKType; + logs: LogDescriptorSDKType[]; + metrics: MetricDescriptorSDKType[]; + monitored_resources: MonitoredResourceDescriptorSDKType[]; + billing?: BillingSDKType; + logging?: LoggingSDKType; + monitoring?: MonitoringSDKType; + system_parameters?: SystemParametersSDKType; + source_info?: SourceInfoSDKType; + /** @deprecated */ + config_version?: UInt32ValueSDKType; +} +function createBaseService(): Service { + return { + name: "", + title: "", + producerProjectId: "", + id: "", + apis: [], + types: [], + enums: [], + documentation: undefined, + backend: undefined, + http: undefined, + quota: undefined, + authentication: undefined, + context: undefined, + usage: undefined, + endpoints: [], + control: undefined, + logs: [], + metrics: [], + monitoredResources: [], + billing: undefined, + logging: undefined, + monitoring: undefined, + systemParameters: undefined, + sourceInfo: undefined, + configVersion: undefined + }; +} +export const Service = { + typeUrl: "/google.api.Service", + encode(message: Service, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + if (message.title !== undefined) { + writer.uint32(18).string(message.title); + } + if (message.producerProjectId !== undefined) { + writer.uint32(178).string(message.producerProjectId); + } + if (message.id !== undefined) { + writer.uint32(266).string(message.id); + } + for (const v of message.apis) { + Api.encode(v!, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.types) { + Type.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.enums) { + Enum.encode(v!, writer.uint32(42).fork()).ldelim(); + } + if (message.documentation !== undefined) { + Documentation.encode(message.documentation, writer.uint32(50).fork()).ldelim(); + } + if (message.backend !== undefined) { + Backend.encode(message.backend, writer.uint32(66).fork()).ldelim(); + } + if (message.http !== undefined) { + Http.encode(message.http, writer.uint32(74).fork()).ldelim(); + } + if (message.quota !== undefined) { + Quota.encode(message.quota, writer.uint32(82).fork()).ldelim(); + } + if (message.authentication !== undefined) { + Authentication.encode(message.authentication, writer.uint32(90).fork()).ldelim(); + } + if (message.context !== undefined) { + Context.encode(message.context, writer.uint32(98).fork()).ldelim(); + } + if (message.usage !== undefined) { + Usage.encode(message.usage, writer.uint32(122).fork()).ldelim(); + } + for (const v of message.endpoints) { + Endpoint.encode(v!, writer.uint32(146).fork()).ldelim(); + } + if (message.control !== undefined) { + Control.encode(message.control, writer.uint32(170).fork()).ldelim(); + } + for (const v of message.logs) { + LogDescriptor.encode(v!, writer.uint32(186).fork()).ldelim(); + } + for (const v of message.metrics) { + MetricDescriptor.encode(v!, writer.uint32(194).fork()).ldelim(); + } + for (const v of message.monitoredResources) { + MonitoredResourceDescriptor.encode(v!, writer.uint32(202).fork()).ldelim(); + } + if (message.billing !== undefined) { + Billing.encode(message.billing, writer.uint32(210).fork()).ldelim(); + } + if (message.logging !== undefined) { + Logging.encode(message.logging, writer.uint32(218).fork()).ldelim(); + } + if (message.monitoring !== undefined) { + Monitoring.encode(message.monitoring, writer.uint32(226).fork()).ldelim(); + } + if (message.systemParameters !== undefined) { + SystemParameters.encode(message.systemParameters, writer.uint32(234).fork()).ldelim(); + } + if (message.sourceInfo !== undefined) { + SourceInfo.encode(message.sourceInfo, writer.uint32(298).fork()).ldelim(); + } + if (message.configVersion !== undefined) { + UInt32Value.encode(message.configVersion, writer.uint32(162).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Service { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseService(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.title = reader.string(); + break; + case 22: + message.producerProjectId = reader.string(); + break; + case 33: + message.id = reader.string(); + break; + case 3: + message.apis.push(Api.decode(reader, reader.uint32())); + break; + case 4: + message.types.push(Type.decode(reader, reader.uint32())); + break; + case 5: + message.enums.push(Enum.decode(reader, reader.uint32())); + break; + case 6: + message.documentation = Documentation.decode(reader, reader.uint32()); + break; + case 8: + message.backend = Backend.decode(reader, reader.uint32()); + break; + case 9: + message.http = Http.decode(reader, reader.uint32()); + break; + case 10: + message.quota = Quota.decode(reader, reader.uint32()); + break; + case 11: + message.authentication = Authentication.decode(reader, reader.uint32()); + break; + case 12: + message.context = Context.decode(reader, reader.uint32()); + break; + case 15: + message.usage = Usage.decode(reader, reader.uint32()); + break; + case 18: + message.endpoints.push(Endpoint.decode(reader, reader.uint32())); + break; + case 21: + message.control = Control.decode(reader, reader.uint32()); + break; + case 23: + message.logs.push(LogDescriptor.decode(reader, reader.uint32())); + break; + case 24: + message.metrics.push(MetricDescriptor.decode(reader, reader.uint32())); + break; + case 25: + message.monitoredResources.push(MonitoredResourceDescriptor.decode(reader, reader.uint32())); + break; + case 26: + message.billing = Billing.decode(reader, reader.uint32()); + break; + case 27: + message.logging = Logging.decode(reader, reader.uint32()); + break; + case 28: + message.monitoring = Monitoring.decode(reader, reader.uint32()); + break; + case 29: + message.systemParameters = SystemParameters.decode(reader, reader.uint32()); + break; + case 37: + message.sourceInfo = SourceInfo.decode(reader, reader.uint32()); + break; + case 20: + message.configVersion = UInt32Value.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Service { + const obj = createBaseService(); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.title)) obj.title = String(object.title); + if (isSet(object.producerProjectId)) obj.producerProjectId = String(object.producerProjectId); + if (isSet(object.id)) obj.id = String(object.id); + if (Array.isArray(object?.apis)) obj.apis = object.apis.map((e: any) => Api.fromJSON(e)); + if (Array.isArray(object?.types)) obj.types = object.types.map((e: any) => Type.fromJSON(e)); + if (Array.isArray(object?.enums)) obj.enums = object.enums.map((e: any) => Enum.fromJSON(e)); + if (isSet(object.documentation)) obj.documentation = Documentation.fromJSON(object.documentation); + if (isSet(object.backend)) obj.backend = Backend.fromJSON(object.backend); + if (isSet(object.http)) obj.http = Http.fromJSON(object.http); + if (isSet(object.quota)) obj.quota = Quota.fromJSON(object.quota); + if (isSet(object.authentication)) obj.authentication = Authentication.fromJSON(object.authentication); + if (isSet(object.context)) obj.context = Context.fromJSON(object.context); + if (isSet(object.usage)) obj.usage = Usage.fromJSON(object.usage); + if (Array.isArray(object?.endpoints)) obj.endpoints = object.endpoints.map((e: any) => Endpoint.fromJSON(e)); + if (isSet(object.control)) obj.control = Control.fromJSON(object.control); + if (Array.isArray(object?.logs)) obj.logs = object.logs.map((e: any) => LogDescriptor.fromJSON(e)); + if (Array.isArray(object?.metrics)) obj.metrics = object.metrics.map((e: any) => MetricDescriptor.fromJSON(e)); + if (Array.isArray(object?.monitoredResources)) obj.monitoredResources = object.monitoredResources.map((e: any) => MonitoredResourceDescriptor.fromJSON(e)); + if (isSet(object.billing)) obj.billing = Billing.fromJSON(object.billing); + if (isSet(object.logging)) obj.logging = Logging.fromJSON(object.logging); + if (isSet(object.monitoring)) obj.monitoring = Monitoring.fromJSON(object.monitoring); + if (isSet(object.systemParameters)) obj.systemParameters = SystemParameters.fromJSON(object.systemParameters); + if (isSet(object.sourceInfo)) obj.sourceInfo = SourceInfo.fromJSON(object.sourceInfo); + if (isSet(object.configVersion)) obj.configVersion = UInt32Value.fromJSON(object.configVersion); + return obj; + }, + toJSON(message: Service): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.title !== undefined && (obj.title = message.title); + message.producerProjectId !== undefined && (obj.producerProjectId = message.producerProjectId); + message.id !== undefined && (obj.id = message.id); + if (message.apis) { + obj.apis = message.apis.map(e => e ? Api.toJSON(e) : undefined); + } else { + obj.apis = []; + } + if (message.types) { + obj.types = message.types.map(e => e ? Type.toJSON(e) : undefined); + } else { + obj.types = []; + } + if (message.enums) { + obj.enums = message.enums.map(e => e ? Enum.toJSON(e) : undefined); + } else { + obj.enums = []; + } + message.documentation !== undefined && (obj.documentation = message.documentation ? Documentation.toJSON(message.documentation) : undefined); + message.backend !== undefined && (obj.backend = message.backend ? Backend.toJSON(message.backend) : undefined); + message.http !== undefined && (obj.http = message.http ? Http.toJSON(message.http) : undefined); + message.quota !== undefined && (obj.quota = message.quota ? Quota.toJSON(message.quota) : undefined); + message.authentication !== undefined && (obj.authentication = message.authentication ? Authentication.toJSON(message.authentication) : undefined); + message.context !== undefined && (obj.context = message.context ? Context.toJSON(message.context) : undefined); + message.usage !== undefined && (obj.usage = message.usage ? Usage.toJSON(message.usage) : undefined); + if (message.endpoints) { + obj.endpoints = message.endpoints.map(e => e ? Endpoint.toJSON(e) : undefined); + } else { + obj.endpoints = []; + } + message.control !== undefined && (obj.control = message.control ? Control.toJSON(message.control) : undefined); + if (message.logs) { + obj.logs = message.logs.map(e => e ? LogDescriptor.toJSON(e) : undefined); + } else { + obj.logs = []; + } + if (message.metrics) { + obj.metrics = message.metrics.map(e => e ? MetricDescriptor.toJSON(e) : undefined); + } else { + obj.metrics = []; + } + if (message.monitoredResources) { + obj.monitoredResources = message.monitoredResources.map(e => e ? MonitoredResourceDescriptor.toJSON(e) : undefined); + } else { + obj.monitoredResources = []; + } + message.billing !== undefined && (obj.billing = message.billing ? Billing.toJSON(message.billing) : undefined); + message.logging !== undefined && (obj.logging = message.logging ? Logging.toJSON(message.logging) : undefined); + message.monitoring !== undefined && (obj.monitoring = message.monitoring ? Monitoring.toJSON(message.monitoring) : undefined); + message.systemParameters !== undefined && (obj.systemParameters = message.systemParameters ? SystemParameters.toJSON(message.systemParameters) : undefined); + message.sourceInfo !== undefined && (obj.sourceInfo = message.sourceInfo ? SourceInfo.toJSON(message.sourceInfo) : undefined); + message.configVersion !== undefined && (obj.configVersion = message.configVersion ? UInt32Value.toJSON(message.configVersion) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): Service { + const message = createBaseService(); + message.name = object.name ?? ""; + message.title = object.title ?? ""; + message.producerProjectId = object.producerProjectId ?? ""; + message.id = object.id ?? ""; + message.apis = object.apis?.map(e => Api.fromPartial(e)) || []; + message.types = object.types?.map(e => Type.fromPartial(e)) || []; + message.enums = object.enums?.map(e => Enum.fromPartial(e)) || []; + if (object.documentation !== undefined && object.documentation !== null) { + message.documentation = Documentation.fromPartial(object.documentation); + } + if (object.backend !== undefined && object.backend !== null) { + message.backend = Backend.fromPartial(object.backend); + } + if (object.http !== undefined && object.http !== null) { + message.http = Http.fromPartial(object.http); + } + if (object.quota !== undefined && object.quota !== null) { + message.quota = Quota.fromPartial(object.quota); + } + if (object.authentication !== undefined && object.authentication !== null) { + message.authentication = Authentication.fromPartial(object.authentication); + } + if (object.context !== undefined && object.context !== null) { + message.context = Context.fromPartial(object.context); + } + if (object.usage !== undefined && object.usage !== null) { + message.usage = Usage.fromPartial(object.usage); + } + message.endpoints = object.endpoints?.map(e => Endpoint.fromPartial(e)) || []; + if (object.control !== undefined && object.control !== null) { + message.control = Control.fromPartial(object.control); + } + message.logs = object.logs?.map(e => LogDescriptor.fromPartial(e)) || []; + message.metrics = object.metrics?.map(e => MetricDescriptor.fromPartial(e)) || []; + message.monitoredResources = object.monitoredResources?.map(e => MonitoredResourceDescriptor.fromPartial(e)) || []; + if (object.billing !== undefined && object.billing !== null) { + message.billing = Billing.fromPartial(object.billing); + } + if (object.logging !== undefined && object.logging !== null) { + message.logging = Logging.fromPartial(object.logging); + } + if (object.monitoring !== undefined && object.monitoring !== null) { + message.monitoring = Monitoring.fromPartial(object.monitoring); + } + if (object.systemParameters !== undefined && object.systemParameters !== null) { + message.systemParameters = SystemParameters.fromPartial(object.systemParameters); + } + if (object.sourceInfo !== undefined && object.sourceInfo !== null) { + message.sourceInfo = SourceInfo.fromPartial(object.sourceInfo); + } + if (object.configVersion !== undefined && object.configVersion !== null) { + message.configVersion = UInt32Value.fromPartial(object.configVersion); + } + return message; + }, + fromSDK(object: ServiceSDKType): Service { + return { + name: object?.name, + title: object?.title, + producerProjectId: object?.producer_project_id, + id: object?.id, + apis: Array.isArray(object?.apis) ? object.apis.map((e: any) => Api.fromSDK(e)) : [], + types: Array.isArray(object?.types) ? object.types.map((e: any) => Type.fromSDK(e)) : [], + enums: Array.isArray(object?.enums) ? object.enums.map((e: any) => Enum.fromSDK(e)) : [], + documentation: object.documentation ? Documentation.fromSDK(object.documentation) : undefined, + backend: object.backend ? Backend.fromSDK(object.backend) : undefined, + http: object.http ? Http.fromSDK(object.http) : undefined, + quota: object.quota ? Quota.fromSDK(object.quota) : undefined, + authentication: object.authentication ? Authentication.fromSDK(object.authentication) : undefined, + context: object.context ? Context.fromSDK(object.context) : undefined, + usage: object.usage ? Usage.fromSDK(object.usage) : undefined, + endpoints: Array.isArray(object?.endpoints) ? object.endpoints.map((e: any) => Endpoint.fromSDK(e)) : [], + control: object.control ? Control.fromSDK(object.control) : undefined, + logs: Array.isArray(object?.logs) ? object.logs.map((e: any) => LogDescriptor.fromSDK(e)) : [], + metrics: Array.isArray(object?.metrics) ? object.metrics.map((e: any) => MetricDescriptor.fromSDK(e)) : [], + monitoredResources: Array.isArray(object?.monitored_resources) ? object.monitored_resources.map((e: any) => MonitoredResourceDescriptor.fromSDK(e)) : [], + billing: object.billing ? Billing.fromSDK(object.billing) : undefined, + logging: object.logging ? Logging.fromSDK(object.logging) : undefined, + monitoring: object.monitoring ? Monitoring.fromSDK(object.monitoring) : undefined, + systemParameters: object.system_parameters ? SystemParameters.fromSDK(object.system_parameters) : undefined, + sourceInfo: object.source_info ? SourceInfo.fromSDK(object.source_info) : undefined, + configVersion: object.config_version ? UInt32Value.fromSDK(object.config_version) : undefined + }; + }, + fromSDKJSON(object: any): ServiceSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + title: isSet(object.title) ? String(object.title) : "", + producer_project_id: isSet(object.producer_project_id) ? String(object.producer_project_id) : "", + id: isSet(object.id) ? String(object.id) : "", + apis: Array.isArray(object?.apis) ? object.apis.map((e: any) => Api.fromSDKJSON(e)) : [], + types: Array.isArray(object?.types) ? object.types.map((e: any) => Type.fromSDKJSON(e)) : [], + enums: Array.isArray(object?.enums) ? object.enums.map((e: any) => Enum.fromSDKJSON(e)) : [], + documentation: isSet(object.documentation) ? Documentation.fromSDKJSON(object.documentation) : undefined, + backend: isSet(object.backend) ? Backend.fromSDKJSON(object.backend) : undefined, + http: isSet(object.http) ? Http.fromSDKJSON(object.http) : undefined, + quota: isSet(object.quota) ? Quota.fromSDKJSON(object.quota) : undefined, + authentication: isSet(object.authentication) ? Authentication.fromSDKJSON(object.authentication) : undefined, + context: isSet(object.context) ? Context.fromSDKJSON(object.context) : undefined, + usage: isSet(object.usage) ? Usage.fromSDKJSON(object.usage) : undefined, + endpoints: Array.isArray(object?.endpoints) ? object.endpoints.map((e: any) => Endpoint.fromSDKJSON(e)) : [], + control: isSet(object.control) ? Control.fromSDKJSON(object.control) : undefined, + logs: Array.isArray(object?.logs) ? object.logs.map((e: any) => LogDescriptor.fromSDKJSON(e)) : [], + metrics: Array.isArray(object?.metrics) ? object.metrics.map((e: any) => MetricDescriptor.fromSDKJSON(e)) : [], + monitored_resources: Array.isArray(object?.monitored_resources) ? object.monitored_resources.map((e: any) => MonitoredResourceDescriptor.fromSDKJSON(e)) : [], + billing: isSet(object.billing) ? Billing.fromSDKJSON(object.billing) : undefined, + logging: isSet(object.logging) ? Logging.fromSDKJSON(object.logging) : undefined, + monitoring: isSet(object.monitoring) ? Monitoring.fromSDKJSON(object.monitoring) : undefined, + system_parameters: isSet(object.system_parameters) ? SystemParameters.fromSDKJSON(object.system_parameters) : undefined, + source_info: isSet(object.source_info) ? SourceInfo.fromSDKJSON(object.source_info) : undefined, + config_version: isSet(object.config_version) ? UInt32Value.fromSDKJSON(object.config_version) : undefined + }; + }, + toSDK(message: Service): ServiceSDKType { + const obj: any = {}; + obj.name = message.name; + obj.title = message.title; + obj.producer_project_id = message.producerProjectId; + obj.id = message.id; + if (message.apis) { + obj.apis = message.apis.map(e => e ? Api.toSDK(e) : undefined); + } else { + obj.apis = []; + } + if (message.types) { + obj.types = message.types.map(e => e ? Type.toSDK(e) : undefined); + } else { + obj.types = []; + } + if (message.enums) { + obj.enums = message.enums.map(e => e ? Enum.toSDK(e) : undefined); + } else { + obj.enums = []; + } + message.documentation !== undefined && (obj.documentation = message.documentation ? Documentation.toSDK(message.documentation) : undefined); + message.backend !== undefined && (obj.backend = message.backend ? Backend.toSDK(message.backend) : undefined); + message.http !== undefined && (obj.http = message.http ? Http.toSDK(message.http) : undefined); + message.quota !== undefined && (obj.quota = message.quota ? Quota.toSDK(message.quota) : undefined); + message.authentication !== undefined && (obj.authentication = message.authentication ? Authentication.toSDK(message.authentication) : undefined); + message.context !== undefined && (obj.context = message.context ? Context.toSDK(message.context) : undefined); + message.usage !== undefined && (obj.usage = message.usage ? Usage.toSDK(message.usage) : undefined); + if (message.endpoints) { + obj.endpoints = message.endpoints.map(e => e ? Endpoint.toSDK(e) : undefined); + } else { + obj.endpoints = []; + } + message.control !== undefined && (obj.control = message.control ? Control.toSDK(message.control) : undefined); + if (message.logs) { + obj.logs = message.logs.map(e => e ? LogDescriptor.toSDK(e) : undefined); + } else { + obj.logs = []; + } + if (message.metrics) { + obj.metrics = message.metrics.map(e => e ? MetricDescriptor.toSDK(e) : undefined); + } else { + obj.metrics = []; + } + if (message.monitoredResources) { + obj.monitored_resources = message.monitoredResources.map(e => e ? MonitoredResourceDescriptor.toSDK(e) : undefined); + } else { + obj.monitored_resources = []; + } + message.billing !== undefined && (obj.billing = message.billing ? Billing.toSDK(message.billing) : undefined); + message.logging !== undefined && (obj.logging = message.logging ? Logging.toSDK(message.logging) : undefined); + message.monitoring !== undefined && (obj.monitoring = message.monitoring ? Monitoring.toSDK(message.monitoring) : undefined); + message.systemParameters !== undefined && (obj.system_parameters = message.systemParameters ? SystemParameters.toSDK(message.systemParameters) : undefined); + message.sourceInfo !== undefined && (obj.source_info = message.sourceInfo ? SourceInfo.toSDK(message.sourceInfo) : undefined); + message.configVersion !== undefined && (obj.config_version = message.configVersion ? UInt32Value.toSDK(message.configVersion) : undefined); + return obj; + }, + fromAmino(object: ServiceAmino): Service { + const message = createBaseService(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + if (object.title !== undefined && object.title !== null) { + message.title = object.title; + } + if (object.producer_project_id !== undefined && object.producer_project_id !== null) { + message.producerProjectId = object.producer_project_id; + } + if (object.id !== undefined && object.id !== null) { + message.id = object.id; + } + message.apis = object.apis?.map(e => Api.fromAmino(e)) || []; + message.types = object.types?.map(e => Type.fromAmino(e)) || []; + message.enums = object.enums?.map(e => Enum.fromAmino(e)) || []; + if (object.documentation !== undefined && object.documentation !== null) { + message.documentation = Documentation.fromAmino(object.documentation); + } + if (object.backend !== undefined && object.backend !== null) { + message.backend = Backend.fromAmino(object.backend); + } + if (object.http !== undefined && object.http !== null) { + message.http = Http.fromAmino(object.http); + } + if (object.quota !== undefined && object.quota !== null) { + message.quota = Quota.fromAmino(object.quota); + } + if (object.authentication !== undefined && object.authentication !== null) { + message.authentication = Authentication.fromAmino(object.authentication); + } + if (object.context !== undefined && object.context !== null) { + message.context = Context.fromAmino(object.context); + } + if (object.usage !== undefined && object.usage !== null) { + message.usage = Usage.fromAmino(object.usage); + } + message.endpoints = object.endpoints?.map(e => Endpoint.fromAmino(e)) || []; + if (object.control !== undefined && object.control !== null) { + message.control = Control.fromAmino(object.control); + } + message.logs = object.logs?.map(e => LogDescriptor.fromAmino(e)) || []; + message.metrics = object.metrics?.map(e => MetricDescriptor.fromAmino(e)) || []; + message.monitoredResources = object.monitored_resources?.map(e => MonitoredResourceDescriptor.fromAmino(e)) || []; + if (object.billing !== undefined && object.billing !== null) { + message.billing = Billing.fromAmino(object.billing); + } + if (object.logging !== undefined && object.logging !== null) { + message.logging = Logging.fromAmino(object.logging); + } + if (object.monitoring !== undefined && object.monitoring !== null) { + message.monitoring = Monitoring.fromAmino(object.monitoring); + } + if (object.system_parameters !== undefined && object.system_parameters !== null) { + message.systemParameters = SystemParameters.fromAmino(object.system_parameters); + } + if (object.source_info !== undefined && object.source_info !== null) { + message.sourceInfo = SourceInfo.fromAmino(object.source_info); + } + if (object.config_version !== undefined && object.config_version !== null) { + message.configVersion = UInt32Value.fromAmino(object.config_version); + } + return message; + }, + toAmino(message: Service): ServiceAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + obj.title = message.title === "" ? undefined : message.title; + obj.producer_project_id = message.producerProjectId === "" ? undefined : message.producerProjectId; + obj.id = message.id === "" ? undefined : message.id; + if (message.apis) { + obj.apis = message.apis.map(e => e ? Api.toAmino(e) : undefined); + } else { + obj.apis = message.apis; + } + if (message.types) { + obj.types = message.types.map(e => e ? Type.toAmino(e) : undefined); + } else { + obj.types = message.types; + } + if (message.enums) { + obj.enums = message.enums.map(e => e ? Enum.toAmino(e) : undefined); + } else { + obj.enums = message.enums; + } + obj.documentation = message.documentation ? Documentation.toAmino(message.documentation) : undefined; + obj.backend = message.backend ? Backend.toAmino(message.backend) : undefined; + obj.http = message.http ? Http.toAmino(message.http) : undefined; + obj.quota = message.quota ? Quota.toAmino(message.quota) : undefined; + obj.authentication = message.authentication ? Authentication.toAmino(message.authentication) : undefined; + obj.context = message.context ? Context.toAmino(message.context) : undefined; + obj.usage = message.usage ? Usage.toAmino(message.usage) : undefined; + if (message.endpoints) { + obj.endpoints = message.endpoints.map(e => e ? Endpoint.toAmino(e) : undefined); + } else { + obj.endpoints = message.endpoints; + } + obj.control = message.control ? Control.toAmino(message.control) : undefined; + if (message.logs) { + obj.logs = message.logs.map(e => e ? LogDescriptor.toAmino(e) : undefined); + } else { + obj.logs = message.logs; + } + if (message.metrics) { + obj.metrics = message.metrics.map(e => e ? MetricDescriptor.toAmino(e) : undefined); + } else { + obj.metrics = message.metrics; + } + if (message.monitoredResources) { + obj.monitored_resources = message.monitoredResources.map(e => e ? MonitoredResourceDescriptor.toAmino(e) : undefined); + } else { + obj.monitored_resources = message.monitoredResources; + } + obj.billing = message.billing ? Billing.toAmino(message.billing) : undefined; + obj.logging = message.logging ? Logging.toAmino(message.logging) : undefined; + obj.monitoring = message.monitoring ? Monitoring.toAmino(message.monitoring) : undefined; + obj.system_parameters = message.systemParameters ? SystemParameters.toAmino(message.systemParameters) : undefined; + obj.source_info = message.sourceInfo ? SourceInfo.toAmino(message.sourceInfo) : undefined; + obj.config_version = message.configVersion ? UInt32Value.toAmino(message.configVersion) : undefined; + return obj; + }, + fromAminoMsg(object: ServiceAminoMsg): Service { + return Service.fromAmino(object.value); + }, + fromProtoMsg(message: ServiceProtoMsg): Service { + return Service.decode(message.value); + }, + toProto(message: Service): Uint8Array { + return Service.encode(message).finish(); + }, + toProtoMsg(message: Service): ServiceProtoMsg { + return { + typeUrl: "/google.api.Service", + value: Service.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/api/servicecontrol/v1/check_error.ts b/__fixtures__/v-next/outputicjsdeps/google/api/servicecontrol/v1/check_error.ts new file mode 100644 index 0000000000..cb644474a6 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/api/servicecontrol/v1/check_error.ts @@ -0,0 +1,373 @@ +import { Status, StatusSDKType } from "../../../rpc/status.js"; +import { BinaryReader, BinaryWriter } from "../../../../binary.js"; +import { isSet, DeepPartial } from "../../../../helpers.js"; +import { JsonSafe } from "../../../../json-safe.js"; +export const protobufPackage = "google.api.servicecontrol.v1"; +/** Error codes for Check responses. */ +export enum CheckError_Code { + /** ERROR_CODE_UNSPECIFIED - This is never used in `CheckResponse`. */ + ERROR_CODE_UNSPECIFIED = 0, + /** + * NOT_FOUND - The consumer's project id, network container, or resource container was + * not found. Same as [google.rpc.Code.NOT_FOUND][google.rpc.Code.NOT_FOUND]. + */ + NOT_FOUND = 5, + /** + * PERMISSION_DENIED - The consumer doesn't have access to the specified resource. + * Same as [google.rpc.Code.PERMISSION_DENIED][google.rpc.Code.PERMISSION_DENIED]. + */ + PERMISSION_DENIED = 7, + /** RESOURCE_EXHAUSTED - Quota check failed. Same as [google.rpc.Code.RESOURCE_EXHAUSTED][google.rpc.Code.RESOURCE_EXHAUSTED]. */ + RESOURCE_EXHAUSTED = 8, + /** SERVICE_NOT_ACTIVATED - The consumer hasn't activated the service. */ + SERVICE_NOT_ACTIVATED = 104, + /** BILLING_DISABLED - The consumer cannot access the service because billing is disabled. */ + BILLING_DISABLED = 107, + /** PROJECT_DELETED - The consumer's project has been marked as deleted (soft deletion). */ + PROJECT_DELETED = 108, + /** PROJECT_INVALID - The consumer's project number or id does not represent a valid project. */ + PROJECT_INVALID = 114, + /** + * CONSUMER_INVALID - The input consumer info does not represent a valid consumer folder or + * organization. + */ + CONSUMER_INVALID = 125, + /** + * IP_ADDRESS_BLOCKED - The IP address of the consumer is invalid for the specific consumer + * project. + */ + IP_ADDRESS_BLOCKED = 109, + /** + * REFERER_BLOCKED - The referer address of the consumer request is invalid for the specific + * consumer project. + */ + REFERER_BLOCKED = 110, + /** + * CLIENT_APP_BLOCKED - The client application of the consumer request is invalid for the + * specific consumer project. + */ + CLIENT_APP_BLOCKED = 111, + /** + * API_TARGET_BLOCKED - The API targeted by this request is invalid for the specified consumer + * project. + */ + API_TARGET_BLOCKED = 122, + /** API_KEY_INVALID - The consumer's API key is invalid. */ + API_KEY_INVALID = 105, + /** API_KEY_EXPIRED - The consumer's API Key has expired. */ + API_KEY_EXPIRED = 112, + /** API_KEY_NOT_FOUND - The consumer's API Key was not found in config record. */ + API_KEY_NOT_FOUND = 113, + /** INVALID_CREDENTIAL - The credential in the request can not be verified. */ + INVALID_CREDENTIAL = 123, + /** NAMESPACE_LOOKUP_UNAVAILABLE - The backend server for looking up project id/number is unavailable. */ + NAMESPACE_LOOKUP_UNAVAILABLE = 300, + /** SERVICE_STATUS_UNAVAILABLE - The backend server for checking service status is unavailable. */ + SERVICE_STATUS_UNAVAILABLE = 301, + /** BILLING_STATUS_UNAVAILABLE - The backend server for checking billing status is unavailable. */ + BILLING_STATUS_UNAVAILABLE = 302, + /** CLOUD_RESOURCE_MANAGER_BACKEND_UNAVAILABLE - Cloud Resource Manager backend server is unavailable. */ + CLOUD_RESOURCE_MANAGER_BACKEND_UNAVAILABLE = 305, + UNRECOGNIZED = -1, +} +export const CheckError_CodeSDKType = CheckError_Code; +export function checkError_CodeFromJSON(object: any): CheckError_Code { + switch (object) { + case 0: + case "ERROR_CODE_UNSPECIFIED": + return CheckError_Code.ERROR_CODE_UNSPECIFIED; + case 5: + case "NOT_FOUND": + return CheckError_Code.NOT_FOUND; + case 7: + case "PERMISSION_DENIED": + return CheckError_Code.PERMISSION_DENIED; + case 8: + case "RESOURCE_EXHAUSTED": + return CheckError_Code.RESOURCE_EXHAUSTED; + case 104: + case "SERVICE_NOT_ACTIVATED": + return CheckError_Code.SERVICE_NOT_ACTIVATED; + case 107: + case "BILLING_DISABLED": + return CheckError_Code.BILLING_DISABLED; + case 108: + case "PROJECT_DELETED": + return CheckError_Code.PROJECT_DELETED; + case 114: + case "PROJECT_INVALID": + return CheckError_Code.PROJECT_INVALID; + case 125: + case "CONSUMER_INVALID": + return CheckError_Code.CONSUMER_INVALID; + case 109: + case "IP_ADDRESS_BLOCKED": + return CheckError_Code.IP_ADDRESS_BLOCKED; + case 110: + case "REFERER_BLOCKED": + return CheckError_Code.REFERER_BLOCKED; + case 111: + case "CLIENT_APP_BLOCKED": + return CheckError_Code.CLIENT_APP_BLOCKED; + case 122: + case "API_TARGET_BLOCKED": + return CheckError_Code.API_TARGET_BLOCKED; + case 105: + case "API_KEY_INVALID": + return CheckError_Code.API_KEY_INVALID; + case 112: + case "API_KEY_EXPIRED": + return CheckError_Code.API_KEY_EXPIRED; + case 113: + case "API_KEY_NOT_FOUND": + return CheckError_Code.API_KEY_NOT_FOUND; + case 123: + case "INVALID_CREDENTIAL": + return CheckError_Code.INVALID_CREDENTIAL; + case 300: + case "NAMESPACE_LOOKUP_UNAVAILABLE": + return CheckError_Code.NAMESPACE_LOOKUP_UNAVAILABLE; + case 301: + case "SERVICE_STATUS_UNAVAILABLE": + return CheckError_Code.SERVICE_STATUS_UNAVAILABLE; + case 302: + case "BILLING_STATUS_UNAVAILABLE": + return CheckError_Code.BILLING_STATUS_UNAVAILABLE; + case 305: + case "CLOUD_RESOURCE_MANAGER_BACKEND_UNAVAILABLE": + return CheckError_Code.CLOUD_RESOURCE_MANAGER_BACKEND_UNAVAILABLE; + case -1: + case "UNRECOGNIZED": + default: + return CheckError_Code.UNRECOGNIZED; + } +} +export function checkError_CodeToJSON(object: CheckError_Code): string { + switch (object) { + case CheckError_Code.ERROR_CODE_UNSPECIFIED: + return "ERROR_CODE_UNSPECIFIED"; + case CheckError_Code.NOT_FOUND: + return "NOT_FOUND"; + case CheckError_Code.PERMISSION_DENIED: + return "PERMISSION_DENIED"; + case CheckError_Code.RESOURCE_EXHAUSTED: + return "RESOURCE_EXHAUSTED"; + case CheckError_Code.SERVICE_NOT_ACTIVATED: + return "SERVICE_NOT_ACTIVATED"; + case CheckError_Code.BILLING_DISABLED: + return "BILLING_DISABLED"; + case CheckError_Code.PROJECT_DELETED: + return "PROJECT_DELETED"; + case CheckError_Code.PROJECT_INVALID: + return "PROJECT_INVALID"; + case CheckError_Code.CONSUMER_INVALID: + return "CONSUMER_INVALID"; + case CheckError_Code.IP_ADDRESS_BLOCKED: + return "IP_ADDRESS_BLOCKED"; + case CheckError_Code.REFERER_BLOCKED: + return "REFERER_BLOCKED"; + case CheckError_Code.CLIENT_APP_BLOCKED: + return "CLIENT_APP_BLOCKED"; + case CheckError_Code.API_TARGET_BLOCKED: + return "API_TARGET_BLOCKED"; + case CheckError_Code.API_KEY_INVALID: + return "API_KEY_INVALID"; + case CheckError_Code.API_KEY_EXPIRED: + return "API_KEY_EXPIRED"; + case CheckError_Code.API_KEY_NOT_FOUND: + return "API_KEY_NOT_FOUND"; + case CheckError_Code.INVALID_CREDENTIAL: + return "INVALID_CREDENTIAL"; + case CheckError_Code.NAMESPACE_LOOKUP_UNAVAILABLE: + return "NAMESPACE_LOOKUP_UNAVAILABLE"; + case CheckError_Code.SERVICE_STATUS_UNAVAILABLE: + return "SERVICE_STATUS_UNAVAILABLE"; + case CheckError_Code.BILLING_STATUS_UNAVAILABLE: + return "BILLING_STATUS_UNAVAILABLE"; + case CheckError_Code.CLOUD_RESOURCE_MANAGER_BACKEND_UNAVAILABLE: + return "CLOUD_RESOURCE_MANAGER_BACKEND_UNAVAILABLE"; + case CheckError_Code.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** + * Defines the errors to be returned in + * [google.api.servicecontrol.v1.CheckResponse.check_errors][google.api.servicecontrol.v1.CheckResponse.check_errors]. + */ +export interface CheckError { + /** The error code. */ + code: CheckError_Code; + /** + * Subject to whom this error applies. See the specific code enum for more + * details on this field. For example: + * + * - "project:" + * - "folder:" + * - "organization:" + */ + subject: string; + /** Free-form text providing details on the error cause of the error. */ + detail: string; + /** + * Contains public information about the check error. If available, + * `status.code` will be non zero and client can propagate it out as public + * error. + */ + status?: Status; +} +export interface CheckErrorProtoMsg { + typeUrl: "/google.api.servicecontrol.v1.CheckError"; + value: Uint8Array; +} +/** + * Defines the errors to be returned in + * [google.api.servicecontrol.v1.CheckResponse.check_errors][google.api.servicecontrol.v1.CheckResponse.check_errors]. + */ +export interface CheckErrorSDKType { + code: CheckError_Code; + subject: string; + detail: string; + status?: StatusSDKType; +} +function createBaseCheckError(): CheckError { + return { + code: 0, + subject: "", + detail: "", + status: undefined + }; +} +export const CheckError = { + typeUrl: "/google.api.servicecontrol.v1.CheckError", + encode(message: CheckError, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.code !== 0) { + writer.uint32(8).int32(message.code); + } + if (message.subject !== undefined) { + writer.uint32(34).string(message.subject); + } + if (message.detail !== undefined) { + writer.uint32(18).string(message.detail); + } + if (message.status !== undefined) { + Status.encode(message.status, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): CheckError { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCheckError(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.code = (reader.int32() as any); + break; + case 4: + message.subject = reader.string(); + break; + case 2: + message.detail = reader.string(); + break; + case 3: + message.status = Status.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): CheckError { + const obj = createBaseCheckError(); + if (isSet(object.code)) obj.code = checkError_CodeFromJSON(object.code); + if (isSet(object.subject)) obj.subject = String(object.subject); + if (isSet(object.detail)) obj.detail = String(object.detail); + if (isSet(object.status)) obj.status = Status.fromJSON(object.status); + return obj; + }, + toJSON(message: CheckError): JsonSafe { + const obj: any = {}; + message.code !== undefined && (obj.code = checkError_CodeToJSON(message.code)); + message.subject !== undefined && (obj.subject = message.subject); + message.detail !== undefined && (obj.detail = message.detail); + message.status !== undefined && (obj.status = message.status ? Status.toJSON(message.status) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): CheckError { + const message = createBaseCheckError(); + message.code = object.code ?? 0; + message.subject = object.subject ?? ""; + message.detail = object.detail ?? ""; + if (object.status !== undefined && object.status !== null) { + message.status = Status.fromPartial(object.status); + } + return message; + }, + fromSDK(object: CheckErrorSDKType): CheckError { + return { + code: isSet(object.code) ? checkError_CodeFromJSON(object.code) : -1, + subject: object?.subject, + detail: object?.detail, + status: object.status ? Status.fromSDK(object.status) : undefined + }; + }, + fromSDKJSON(object: any): CheckErrorSDKType { + return { + code: isSet(object.code) ? checkError_CodeFromJSON(object.code) : -1, + subject: isSet(object.subject) ? String(object.subject) : "", + detail: isSet(object.detail) ? String(object.detail) : "", + status: isSet(object.status) ? Status.fromSDKJSON(object.status) : undefined + }; + }, + toSDK(message: CheckError): CheckErrorSDKType { + const obj: any = {}; + message.code !== undefined && (obj.code = checkError_CodeToJSON(message.code)); + obj.subject = message.subject; + obj.detail = message.detail; + message.status !== undefined && (obj.status = message.status ? Status.toSDK(message.status) : undefined); + return obj; + }, + fromAmino(object: CheckErrorAmino): CheckError { + const message = createBaseCheckError(); + if (object.code !== undefined && object.code !== null) { + message.code = object.code; + } + if (object.subject !== undefined && object.subject !== null) { + message.subject = object.subject; + } + if (object.detail !== undefined && object.detail !== null) { + message.detail = object.detail; + } + if (object.status !== undefined && object.status !== null) { + message.status = Status.fromAmino(object.status); + } + return message; + }, + toAmino(message: CheckError): CheckErrorAmino { + const obj: any = {}; + obj.code = message.code === 0 ? undefined : message.code; + obj.subject = message.subject === "" ? undefined : message.subject; + obj.detail = message.detail === "" ? undefined : message.detail; + obj.status = message.status ? Status.toAmino(message.status) : undefined; + return obj; + }, + fromAminoMsg(object: CheckErrorAminoMsg): CheckError { + return CheckError.fromAmino(object.value); + }, + fromProtoMsg(message: CheckErrorProtoMsg): CheckError { + return CheckError.decode(message.value); + }, + toProto(message: CheckError): Uint8Array { + return CheckError.encode(message).finish(); + }, + toProtoMsg(message: CheckError): CheckErrorProtoMsg { + return { + typeUrl: "/google.api.servicecontrol.v1.CheckError", + value: CheckError.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/api/servicecontrol/v1/distribution.ts b/__fixtures__/v-next/outputicjsdeps/google/api/servicecontrol/v1/distribution.ts new file mode 100644 index 0000000000..5e64cd199a --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/api/servicecontrol/v1/distribution.ts @@ -0,0 +1,806 @@ +import { Distribution_Exemplar, Distribution_ExemplarSDKType } from "../../distribution.js"; +import { BinaryReader, BinaryWriter } from "../../../../binary.js"; +import { isSet, DeepPartial } from "../../../../helpers.js"; +import { JsonSafe } from "../../../../json-safe.js"; +export const protobufPackage = "google.api.servicecontrol.v1"; +/** + * Distribution represents a frequency distribution of double-valued sample + * points. It contains the size of the population of sample points plus + * additional optional information: + * + * * the arithmetic mean of the samples + * * the minimum and maximum of the samples + * * the sum-squared-deviation of the samples, used to compute variance + * * a histogram of the values of the sample points + */ +export interface Distribution { + /** The total number of samples in the distribution. Must be >= 0. */ + count: bigint; + /** + * The arithmetic mean of the samples in the distribution. If `count` is + * zero then this field must be zero. + */ + mean: number; + /** The minimum of the population of values. Ignored if `count` is zero. */ + minimum: number; + /** The maximum of the population of values. Ignored if `count` is zero. */ + maximum: number; + /** + * The sum of squared deviations from the mean: + * Sum[i=1..count]((x_i - mean)^2) + * where each x_i is a sample values. If `count` is zero then this field + * must be zero, otherwise validation of the request fails. + */ + sumOfSquaredDeviation: number; + /** + * The number of samples in each histogram bucket. `bucket_counts` are + * optional. If present, they must sum to the `count` value. + * + * The buckets are defined below in `bucket_option`. There are N buckets. + * `bucket_counts[0]` is the number of samples in the underflow bucket. + * `bucket_counts[1]` to `bucket_counts[N-1]` are the numbers of samples + * in each of the finite buckets. And `bucket_counts[N] is the number + * of samples in the overflow bucket. See the comments of `bucket_option` + * below for more details. + * + * Any suffix of trailing zeros may be omitted. + */ + bucketCounts: bigint[]; + /** Buckets with constant width. */ + linearBuckets?: Distribution_LinearBuckets; + /** Buckets with exponentially growing width. */ + exponentialBuckets?: Distribution_ExponentialBuckets; + /** Buckets with arbitrary user-provided width. */ + explicitBuckets?: Distribution_ExplicitBuckets; + /** Example points. Must be in increasing order of `value` field. */ + exemplars: Distribution_Exemplar[]; +} +export interface DistributionProtoMsg { + typeUrl: "/google.api.servicecontrol.v1.Distribution"; + value: Uint8Array; +} +/** + * Distribution represents a frequency distribution of double-valued sample + * points. It contains the size of the population of sample points plus + * additional optional information: + * + * * the arithmetic mean of the samples + * * the minimum and maximum of the samples + * * the sum-squared-deviation of the samples, used to compute variance + * * a histogram of the values of the sample points + */ +export interface DistributionSDKType { + count: bigint; + mean: number; + minimum: number; + maximum: number; + sum_of_squared_deviation: number; + bucket_counts: bigint[]; + linear_buckets?: Distribution_LinearBucketsSDKType; + exponential_buckets?: Distribution_ExponentialBucketsSDKType; + explicit_buckets?: Distribution_ExplicitBucketsSDKType; + exemplars: Distribution_ExemplarSDKType[]; +} +/** Describing buckets with constant width. */ +export interface Distribution_LinearBuckets { + /** + * The number of finite buckets. With the underflow and overflow buckets, + * the total number of buckets is `num_finite_buckets` + 2. + * See comments on `bucket_options` for details. + */ + numFiniteBuckets: number; + /** + * The i'th linear bucket covers the interval + * [offset + (i-1) * width, offset + i * width) + * where i ranges from 1 to num_finite_buckets, inclusive. + * Must be strictly positive. + */ + width: number; + /** + * The i'th linear bucket covers the interval + * [offset + (i-1) * width, offset + i * width) + * where i ranges from 1 to num_finite_buckets, inclusive. + */ + offset: number; +} +export interface Distribution_LinearBucketsProtoMsg { + typeUrl: "/google.api.servicecontrol.v1.LinearBuckets"; + value: Uint8Array; +} +/** Describing buckets with constant width. */ +export interface Distribution_LinearBucketsSDKType { + num_finite_buckets: number; + width: number; + offset: number; +} +/** Describing buckets with exponentially growing width. */ +export interface Distribution_ExponentialBuckets { + /** + * The number of finite buckets. With the underflow and overflow buckets, + * the total number of buckets is `num_finite_buckets` + 2. + * See comments on `bucket_options` for details. + */ + numFiniteBuckets: number; + /** + * The i'th exponential bucket covers the interval + * [scale * growth_factor^(i-1), scale * growth_factor^i) + * where i ranges from 1 to num_finite_buckets inclusive. + * Must be larger than 1.0. + */ + growthFactor: number; + /** + * The i'th exponential bucket covers the interval + * [scale * growth_factor^(i-1), scale * growth_factor^i) + * where i ranges from 1 to num_finite_buckets inclusive. + * Must be > 0. + */ + scale: number; +} +export interface Distribution_ExponentialBucketsProtoMsg { + typeUrl: "/google.api.servicecontrol.v1.ExponentialBuckets"; + value: Uint8Array; +} +/** Describing buckets with exponentially growing width. */ +export interface Distribution_ExponentialBucketsSDKType { + num_finite_buckets: number; + growth_factor: number; + scale: number; +} +/** Describing buckets with arbitrary user-provided width. */ +export interface Distribution_ExplicitBuckets { + /** + * 'bound' is a list of strictly increasing boundaries between + * buckets. Note that a list of length N-1 defines N buckets because + * of fenceposting. See comments on `bucket_options` for details. + * + * The i'th finite bucket covers the interval + * [bound[i-1], bound[i]) + * where i ranges from 1 to bound_size() - 1. Note that there are no + * finite buckets at all if 'bound' only contains a single element; in + * that special case the single bound defines the boundary between the + * underflow and overflow buckets. + * + * bucket number lower bound upper bound + * i == 0 (underflow) -inf bound[i] + * 0 < i < bound_size() bound[i-1] bound[i] + * i == bound_size() (overflow) bound[i-1] +inf + */ + bounds: number[]; +} +export interface Distribution_ExplicitBucketsProtoMsg { + typeUrl: "/google.api.servicecontrol.v1.ExplicitBuckets"; + value: Uint8Array; +} +/** Describing buckets with arbitrary user-provided width. */ +export interface Distribution_ExplicitBucketsSDKType { + bounds: number[]; +} +function createBaseDistribution(): Distribution { + return { + count: BigInt(0), + mean: 0, + minimum: 0, + maximum: 0, + sumOfSquaredDeviation: 0, + bucketCounts: [], + linearBuckets: undefined, + exponentialBuckets: undefined, + explicitBuckets: undefined, + exemplars: [] + }; +} +export const Distribution = { + typeUrl: "/google.api.servicecontrol.v1.Distribution", + encode(message: Distribution, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.count !== undefined) { + writer.uint32(8).int64(message.count); + } + if (message.mean !== undefined) { + writer.uint32(17).double(message.mean); + } + if (message.minimum !== undefined) { + writer.uint32(25).double(message.minimum); + } + if (message.maximum !== undefined) { + writer.uint32(33).double(message.maximum); + } + if (message.sumOfSquaredDeviation !== undefined) { + writer.uint32(41).double(message.sumOfSquaredDeviation); + } + writer.uint32(50).fork(); + for (const v of message.bucketCounts) { + writer.int64(v); + } + writer.ldelim(); + if (message.linearBuckets !== undefined) { + Distribution_LinearBuckets.encode(message.linearBuckets, writer.uint32(58).fork()).ldelim(); + } + if (message.exponentialBuckets !== undefined) { + Distribution_ExponentialBuckets.encode(message.exponentialBuckets, writer.uint32(66).fork()).ldelim(); + } + if (message.explicitBuckets !== undefined) { + Distribution_ExplicitBuckets.encode(message.explicitBuckets, writer.uint32(74).fork()).ldelim(); + } + for (const v of message.exemplars) { + Distribution_Exemplar.encode(v!, writer.uint32(82).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Distribution { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDistribution(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.count = reader.int64(); + break; + case 2: + message.mean = reader.double(); + break; + case 3: + message.minimum = reader.double(); + break; + case 4: + message.maximum = reader.double(); + break; + case 5: + message.sumOfSquaredDeviation = reader.double(); + break; + case 6: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.bucketCounts.push(reader.int64()); + } + } else { + message.bucketCounts.push(reader.int64()); + } + break; + case 7: + message.linearBuckets = Distribution_LinearBuckets.decode(reader, reader.uint32()); + break; + case 8: + message.exponentialBuckets = Distribution_ExponentialBuckets.decode(reader, reader.uint32()); + break; + case 9: + message.explicitBuckets = Distribution_ExplicitBuckets.decode(reader, reader.uint32()); + break; + case 10: + message.exemplars.push(Distribution_Exemplar.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Distribution { + const obj = createBaseDistribution(); + if (isSet(object.count)) obj.count = BigInt(object.count.toString()); + if (isSet(object.mean)) obj.mean = Number(object.mean); + if (isSet(object.minimum)) obj.minimum = Number(object.minimum); + if (isSet(object.maximum)) obj.maximum = Number(object.maximum); + if (isSet(object.sumOfSquaredDeviation)) obj.sumOfSquaredDeviation = Number(object.sumOfSquaredDeviation); + if (Array.isArray(object?.bucketCounts)) obj.bucketCounts = object.bucketCounts.map((e: any) => BigInt(e.toString())); + if (isSet(object.linearBuckets)) obj.linearBuckets = Distribution_LinearBuckets.fromJSON(object.linearBuckets); + if (isSet(object.exponentialBuckets)) obj.exponentialBuckets = Distribution_ExponentialBuckets.fromJSON(object.exponentialBuckets); + if (isSet(object.explicitBuckets)) obj.explicitBuckets = Distribution_ExplicitBuckets.fromJSON(object.explicitBuckets); + if (Array.isArray(object?.exemplars)) obj.exemplars = object.exemplars.map((e: any) => Distribution_Exemplar.fromJSON(e)); + return obj; + }, + toJSON(message: Distribution): JsonSafe { + const obj: any = {}; + message.count !== undefined && (obj.count = (message.count || BigInt(0)).toString()); + message.mean !== undefined && (obj.mean = message.mean); + message.minimum !== undefined && (obj.minimum = message.minimum); + message.maximum !== undefined && (obj.maximum = message.maximum); + message.sumOfSquaredDeviation !== undefined && (obj.sumOfSquaredDeviation = message.sumOfSquaredDeviation); + if (message.bucketCounts) { + obj.bucketCounts = message.bucketCounts.map(e => (e || BigInt(0)).toString()); + } else { + obj.bucketCounts = []; + } + message.linearBuckets !== undefined && (obj.linearBuckets = message.linearBuckets ? Distribution_LinearBuckets.toJSON(message.linearBuckets) : undefined); + message.exponentialBuckets !== undefined && (obj.exponentialBuckets = message.exponentialBuckets ? Distribution_ExponentialBuckets.toJSON(message.exponentialBuckets) : undefined); + message.explicitBuckets !== undefined && (obj.explicitBuckets = message.explicitBuckets ? Distribution_ExplicitBuckets.toJSON(message.explicitBuckets) : undefined); + if (message.exemplars) { + obj.exemplars = message.exemplars.map(e => e ? Distribution_Exemplar.toJSON(e) : undefined); + } else { + obj.exemplars = []; + } + return obj; + }, + fromPartial(object: DeepPartial): Distribution { + const message = createBaseDistribution(); + if (object.count !== undefined && object.count !== null) { + message.count = BigInt(object.count.toString()); + } + message.mean = object.mean ?? 0; + message.minimum = object.minimum ?? 0; + message.maximum = object.maximum ?? 0; + message.sumOfSquaredDeviation = object.sumOfSquaredDeviation ?? 0; + message.bucketCounts = object.bucketCounts?.map(e => BigInt(e.toString())) || []; + if (object.linearBuckets !== undefined && object.linearBuckets !== null) { + message.linearBuckets = Distribution_LinearBuckets.fromPartial(object.linearBuckets); + } + if (object.exponentialBuckets !== undefined && object.exponentialBuckets !== null) { + message.exponentialBuckets = Distribution_ExponentialBuckets.fromPartial(object.exponentialBuckets); + } + if (object.explicitBuckets !== undefined && object.explicitBuckets !== null) { + message.explicitBuckets = Distribution_ExplicitBuckets.fromPartial(object.explicitBuckets); + } + message.exemplars = object.exemplars?.map(e => Distribution_Exemplar.fromPartial(e)) || []; + return message; + }, + fromSDK(object: DistributionSDKType): Distribution { + return { + count: object?.count, + mean: object?.mean, + minimum: object?.minimum, + maximum: object?.maximum, + sumOfSquaredDeviation: object?.sum_of_squared_deviation, + bucketCounts: Array.isArray(object?.bucket_counts) ? object.bucket_counts.map((e: any) => e) : [], + linearBuckets: object.linear_buckets ? Distribution_LinearBuckets.fromSDK(object.linear_buckets) : undefined, + exponentialBuckets: object.exponential_buckets ? Distribution_ExponentialBuckets.fromSDK(object.exponential_buckets) : undefined, + explicitBuckets: object.explicit_buckets ? Distribution_ExplicitBuckets.fromSDK(object.explicit_buckets) : undefined, + exemplars: Array.isArray(object?.exemplars) ? object.exemplars.map((e: any) => Distribution_Exemplar.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): DistributionSDKType { + return { + count: isSet(object.count) ? BigInt(object.count.toString()) : BigInt(0), + mean: isSet(object.mean) ? Number(object.mean) : 0, + minimum: isSet(object.minimum) ? Number(object.minimum) : 0, + maximum: isSet(object.maximum) ? Number(object.maximum) : 0, + sum_of_squared_deviation: isSet(object.sum_of_squared_deviation) ? Number(object.sum_of_squared_deviation) : 0, + bucket_counts: Array.isArray(object?.bucket_counts) ? object.bucket_counts.map((e: any) => BigInt(e.toString())) : [], + linear_buckets: isSet(object.linear_buckets) ? Distribution_LinearBuckets.fromSDKJSON(object.linear_buckets) : undefined, + exponential_buckets: isSet(object.exponential_buckets) ? Distribution_ExponentialBuckets.fromSDKJSON(object.exponential_buckets) : undefined, + explicit_buckets: isSet(object.explicit_buckets) ? Distribution_ExplicitBuckets.fromSDKJSON(object.explicit_buckets) : undefined, + exemplars: Array.isArray(object?.exemplars) ? object.exemplars.map((e: any) => Distribution_Exemplar.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: Distribution): DistributionSDKType { + const obj: any = {}; + obj.count = message.count; + obj.mean = message.mean; + obj.minimum = message.minimum; + obj.maximum = message.maximum; + obj.sum_of_squared_deviation = message.sumOfSquaredDeviation; + if (message.bucketCounts) { + obj.bucket_counts = message.bucketCounts.map(e => e); + } else { + obj.bucket_counts = []; + } + message.linearBuckets !== undefined && (obj.linear_buckets = message.linearBuckets ? Distribution_LinearBuckets.toSDK(message.linearBuckets) : undefined); + message.exponentialBuckets !== undefined && (obj.exponential_buckets = message.exponentialBuckets ? Distribution_ExponentialBuckets.toSDK(message.exponentialBuckets) : undefined); + message.explicitBuckets !== undefined && (obj.explicit_buckets = message.explicitBuckets ? Distribution_ExplicitBuckets.toSDK(message.explicitBuckets) : undefined); + if (message.exemplars) { + obj.exemplars = message.exemplars.map(e => e ? Distribution_Exemplar.toSDK(e) : undefined); + } else { + obj.exemplars = []; + } + return obj; + }, + fromAmino(object: DistributionAmino): Distribution { + const message = createBaseDistribution(); + if (object.count !== undefined && object.count !== null) { + message.count = BigInt(object.count); + } + if (object.mean !== undefined && object.mean !== null) { + message.mean = object.mean; + } + if (object.minimum !== undefined && object.minimum !== null) { + message.minimum = object.minimum; + } + if (object.maximum !== undefined && object.maximum !== null) { + message.maximum = object.maximum; + } + if (object.sum_of_squared_deviation !== undefined && object.sum_of_squared_deviation !== null) { + message.sumOfSquaredDeviation = object.sum_of_squared_deviation; + } + message.bucketCounts = object.bucket_counts?.map(e => BigInt(e)) || []; + if (object.linear_buckets !== undefined && object.linear_buckets !== null) { + message.linearBuckets = Distribution_LinearBuckets.fromAmino(object.linear_buckets); + } + if (object.exponential_buckets !== undefined && object.exponential_buckets !== null) { + message.exponentialBuckets = Distribution_ExponentialBuckets.fromAmino(object.exponential_buckets); + } + if (object.explicit_buckets !== undefined && object.explicit_buckets !== null) { + message.explicitBuckets = Distribution_ExplicitBuckets.fromAmino(object.explicit_buckets); + } + message.exemplars = object.exemplars?.map(e => Distribution_Exemplar.fromAmino(e)) || []; + return message; + }, + toAmino(message: Distribution): DistributionAmino { + const obj: any = {}; + obj.count = message.count !== BigInt(0) ? message.count?.toString() : undefined; + obj.mean = message.mean === 0 ? undefined : message.mean; + obj.minimum = message.minimum === 0 ? undefined : message.minimum; + obj.maximum = message.maximum === 0 ? undefined : message.maximum; + obj.sum_of_squared_deviation = message.sumOfSquaredDeviation === 0 ? undefined : message.sumOfSquaredDeviation; + if (message.bucketCounts) { + obj.bucket_counts = message.bucketCounts.map(e => e.toString()); + } else { + obj.bucket_counts = message.bucketCounts; + } + obj.linear_buckets = message.linearBuckets ? Distribution_LinearBuckets.toAmino(message.linearBuckets) : undefined; + obj.exponential_buckets = message.exponentialBuckets ? Distribution_ExponentialBuckets.toAmino(message.exponentialBuckets) : undefined; + obj.explicit_buckets = message.explicitBuckets ? Distribution_ExplicitBuckets.toAmino(message.explicitBuckets) : undefined; + if (message.exemplars) { + obj.exemplars = message.exemplars.map(e => e ? Distribution_Exemplar.toAmino(e) : undefined); + } else { + obj.exemplars = message.exemplars; + } + return obj; + }, + fromAminoMsg(object: DistributionAminoMsg): Distribution { + return Distribution.fromAmino(object.value); + }, + fromProtoMsg(message: DistributionProtoMsg): Distribution { + return Distribution.decode(message.value); + }, + toProto(message: Distribution): Uint8Array { + return Distribution.encode(message).finish(); + }, + toProtoMsg(message: Distribution): DistributionProtoMsg { + return { + typeUrl: "/google.api.servicecontrol.v1.Distribution", + value: Distribution.encode(message).finish() + }; + } +}; +function createBaseDistribution_LinearBuckets(): Distribution_LinearBuckets { + return { + numFiniteBuckets: 0, + width: 0, + offset: 0 + }; +} +export const Distribution_LinearBuckets = { + typeUrl: "/google.api.servicecontrol.v1.LinearBuckets", + encode(message: Distribution_LinearBuckets, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.numFiniteBuckets !== undefined) { + writer.uint32(8).int32(message.numFiniteBuckets); + } + if (message.width !== undefined) { + writer.uint32(17).double(message.width); + } + if (message.offset !== undefined) { + writer.uint32(25).double(message.offset); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Distribution_LinearBuckets { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDistribution_LinearBuckets(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.numFiniteBuckets = reader.int32(); + break; + case 2: + message.width = reader.double(); + break; + case 3: + message.offset = reader.double(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Distribution_LinearBuckets { + const obj = createBaseDistribution_LinearBuckets(); + if (isSet(object.numFiniteBuckets)) obj.numFiniteBuckets = Number(object.numFiniteBuckets); + if (isSet(object.width)) obj.width = Number(object.width); + if (isSet(object.offset)) obj.offset = Number(object.offset); + return obj; + }, + toJSON(message: Distribution_LinearBuckets): JsonSafe { + const obj: any = {}; + message.numFiniteBuckets !== undefined && (obj.numFiniteBuckets = Math.round(message.numFiniteBuckets)); + message.width !== undefined && (obj.width = message.width); + message.offset !== undefined && (obj.offset = message.offset); + return obj; + }, + fromPartial(object: DeepPartial): Distribution_LinearBuckets { + const message = createBaseDistribution_LinearBuckets(); + message.numFiniteBuckets = object.numFiniteBuckets ?? 0; + message.width = object.width ?? 0; + message.offset = object.offset ?? 0; + return message; + }, + fromSDK(object: Distribution_LinearBucketsSDKType): Distribution_LinearBuckets { + return { + numFiniteBuckets: object?.num_finite_buckets, + width: object?.width, + offset: object?.offset + }; + }, + fromSDKJSON(object: any): Distribution_LinearBucketsSDKType { + return { + num_finite_buckets: isSet(object.num_finite_buckets) ? Number(object.num_finite_buckets) : 0, + width: isSet(object.width) ? Number(object.width) : 0, + offset: isSet(object.offset) ? Number(object.offset) : 0 + }; + }, + toSDK(message: Distribution_LinearBuckets): Distribution_LinearBucketsSDKType { + const obj: any = {}; + obj.num_finite_buckets = message.numFiniteBuckets; + obj.width = message.width; + obj.offset = message.offset; + return obj; + }, + fromAmino(object: Distribution_LinearBucketsAmino): Distribution_LinearBuckets { + const message = createBaseDistribution_LinearBuckets(); + if (object.num_finite_buckets !== undefined && object.num_finite_buckets !== null) { + message.numFiniteBuckets = object.num_finite_buckets; + } + if (object.width !== undefined && object.width !== null) { + message.width = object.width; + } + if (object.offset !== undefined && object.offset !== null) { + message.offset = object.offset; + } + return message; + }, + toAmino(message: Distribution_LinearBuckets): Distribution_LinearBucketsAmino { + const obj: any = {}; + obj.num_finite_buckets = message.numFiniteBuckets === 0 ? undefined : message.numFiniteBuckets; + obj.width = message.width === 0 ? undefined : message.width; + obj.offset = message.offset === 0 ? undefined : message.offset; + return obj; + }, + fromAminoMsg(object: Distribution_LinearBucketsAminoMsg): Distribution_LinearBuckets { + return Distribution_LinearBuckets.fromAmino(object.value); + }, + fromProtoMsg(message: Distribution_LinearBucketsProtoMsg): Distribution_LinearBuckets { + return Distribution_LinearBuckets.decode(message.value); + }, + toProto(message: Distribution_LinearBuckets): Uint8Array { + return Distribution_LinearBuckets.encode(message).finish(); + }, + toProtoMsg(message: Distribution_LinearBuckets): Distribution_LinearBucketsProtoMsg { + return { + typeUrl: "/google.api.servicecontrol.v1.LinearBuckets", + value: Distribution_LinearBuckets.encode(message).finish() + }; + } +}; +function createBaseDistribution_ExponentialBuckets(): Distribution_ExponentialBuckets { + return { + numFiniteBuckets: 0, + growthFactor: 0, + scale: 0 + }; +} +export const Distribution_ExponentialBuckets = { + typeUrl: "/google.api.servicecontrol.v1.ExponentialBuckets", + encode(message: Distribution_ExponentialBuckets, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.numFiniteBuckets !== undefined) { + writer.uint32(8).int32(message.numFiniteBuckets); + } + if (message.growthFactor !== undefined) { + writer.uint32(17).double(message.growthFactor); + } + if (message.scale !== undefined) { + writer.uint32(25).double(message.scale); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Distribution_ExponentialBuckets { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDistribution_ExponentialBuckets(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.numFiniteBuckets = reader.int32(); + break; + case 2: + message.growthFactor = reader.double(); + break; + case 3: + message.scale = reader.double(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Distribution_ExponentialBuckets { + const obj = createBaseDistribution_ExponentialBuckets(); + if (isSet(object.numFiniteBuckets)) obj.numFiniteBuckets = Number(object.numFiniteBuckets); + if (isSet(object.growthFactor)) obj.growthFactor = Number(object.growthFactor); + if (isSet(object.scale)) obj.scale = Number(object.scale); + return obj; + }, + toJSON(message: Distribution_ExponentialBuckets): JsonSafe { + const obj: any = {}; + message.numFiniteBuckets !== undefined && (obj.numFiniteBuckets = Math.round(message.numFiniteBuckets)); + message.growthFactor !== undefined && (obj.growthFactor = message.growthFactor); + message.scale !== undefined && (obj.scale = message.scale); + return obj; + }, + fromPartial(object: DeepPartial): Distribution_ExponentialBuckets { + const message = createBaseDistribution_ExponentialBuckets(); + message.numFiniteBuckets = object.numFiniteBuckets ?? 0; + message.growthFactor = object.growthFactor ?? 0; + message.scale = object.scale ?? 0; + return message; + }, + fromSDK(object: Distribution_ExponentialBucketsSDKType): Distribution_ExponentialBuckets { + return { + numFiniteBuckets: object?.num_finite_buckets, + growthFactor: object?.growth_factor, + scale: object?.scale + }; + }, + fromSDKJSON(object: any): Distribution_ExponentialBucketsSDKType { + return { + num_finite_buckets: isSet(object.num_finite_buckets) ? Number(object.num_finite_buckets) : 0, + growth_factor: isSet(object.growth_factor) ? Number(object.growth_factor) : 0, + scale: isSet(object.scale) ? Number(object.scale) : 0 + }; + }, + toSDK(message: Distribution_ExponentialBuckets): Distribution_ExponentialBucketsSDKType { + const obj: any = {}; + obj.num_finite_buckets = message.numFiniteBuckets; + obj.growth_factor = message.growthFactor; + obj.scale = message.scale; + return obj; + }, + fromAmino(object: Distribution_ExponentialBucketsAmino): Distribution_ExponentialBuckets { + const message = createBaseDistribution_ExponentialBuckets(); + if (object.num_finite_buckets !== undefined && object.num_finite_buckets !== null) { + message.numFiniteBuckets = object.num_finite_buckets; + } + if (object.growth_factor !== undefined && object.growth_factor !== null) { + message.growthFactor = object.growth_factor; + } + if (object.scale !== undefined && object.scale !== null) { + message.scale = object.scale; + } + return message; + }, + toAmino(message: Distribution_ExponentialBuckets): Distribution_ExponentialBucketsAmino { + const obj: any = {}; + obj.num_finite_buckets = message.numFiniteBuckets === 0 ? undefined : message.numFiniteBuckets; + obj.growth_factor = message.growthFactor === 0 ? undefined : message.growthFactor; + obj.scale = message.scale === 0 ? undefined : message.scale; + return obj; + }, + fromAminoMsg(object: Distribution_ExponentialBucketsAminoMsg): Distribution_ExponentialBuckets { + return Distribution_ExponentialBuckets.fromAmino(object.value); + }, + fromProtoMsg(message: Distribution_ExponentialBucketsProtoMsg): Distribution_ExponentialBuckets { + return Distribution_ExponentialBuckets.decode(message.value); + }, + toProto(message: Distribution_ExponentialBuckets): Uint8Array { + return Distribution_ExponentialBuckets.encode(message).finish(); + }, + toProtoMsg(message: Distribution_ExponentialBuckets): Distribution_ExponentialBucketsProtoMsg { + return { + typeUrl: "/google.api.servicecontrol.v1.ExponentialBuckets", + value: Distribution_ExponentialBuckets.encode(message).finish() + }; + } +}; +function createBaseDistribution_ExplicitBuckets(): Distribution_ExplicitBuckets { + return { + bounds: [] + }; +} +export const Distribution_ExplicitBuckets = { + typeUrl: "/google.api.servicecontrol.v1.ExplicitBuckets", + encode(message: Distribution_ExplicitBuckets, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + writer.uint32(10).fork(); + for (const v of message.bounds) { + writer.double(v); + } + writer.ldelim(); + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Distribution_ExplicitBuckets { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDistribution_ExplicitBuckets(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.bounds.push(reader.double()); + } + } else { + message.bounds.push(reader.double()); + } + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Distribution_ExplicitBuckets { + const obj = createBaseDistribution_ExplicitBuckets(); + if (Array.isArray(object?.bounds)) obj.bounds = object.bounds.map((e: any) => Number(e)); + return obj; + }, + toJSON(message: Distribution_ExplicitBuckets): JsonSafe { + const obj: any = {}; + if (message.bounds) { + obj.bounds = message.bounds.map(e => e); + } else { + obj.bounds = []; + } + return obj; + }, + fromPartial(object: DeepPartial): Distribution_ExplicitBuckets { + const message = createBaseDistribution_ExplicitBuckets(); + message.bounds = object.bounds?.map(e => e) || []; + return message; + }, + fromSDK(object: Distribution_ExplicitBucketsSDKType): Distribution_ExplicitBuckets { + return { + bounds: Array.isArray(object?.bounds) ? object.bounds.map((e: any) => e) : [] + }; + }, + fromSDKJSON(object: any): Distribution_ExplicitBucketsSDKType { + return { + bounds: Array.isArray(object?.bounds) ? object.bounds.map((e: any) => Number(e)) : [] + }; + }, + toSDK(message: Distribution_ExplicitBuckets): Distribution_ExplicitBucketsSDKType { + const obj: any = {}; + if (message.bounds) { + obj.bounds = message.bounds.map(e => e); + } else { + obj.bounds = []; + } + return obj; + }, + fromAmino(object: Distribution_ExplicitBucketsAmino): Distribution_ExplicitBuckets { + const message = createBaseDistribution_ExplicitBuckets(); + message.bounds = object.bounds?.map(e => e) || []; + return message; + }, + toAmino(message: Distribution_ExplicitBuckets): Distribution_ExplicitBucketsAmino { + const obj: any = {}; + if (message.bounds) { + obj.bounds = message.bounds.map(e => e); + } else { + obj.bounds = message.bounds; + } + return obj; + }, + fromAminoMsg(object: Distribution_ExplicitBucketsAminoMsg): Distribution_ExplicitBuckets { + return Distribution_ExplicitBuckets.fromAmino(object.value); + }, + fromProtoMsg(message: Distribution_ExplicitBucketsProtoMsg): Distribution_ExplicitBuckets { + return Distribution_ExplicitBuckets.decode(message.value); + }, + toProto(message: Distribution_ExplicitBuckets): Uint8Array { + return Distribution_ExplicitBuckets.encode(message).finish(); + }, + toProtoMsg(message: Distribution_ExplicitBuckets): Distribution_ExplicitBucketsProtoMsg { + return { + typeUrl: "/google.api.servicecontrol.v1.ExplicitBuckets", + value: Distribution_ExplicitBuckets.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/api/servicecontrol/v1/http_request.ts b/__fixtures__/v-next/outputicjsdeps/google/api/servicecontrol/v1/http_request.ts new file mode 100644 index 0000000000..2c54f6b0db --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/api/servicecontrol/v1/http_request.ts @@ -0,0 +1,442 @@ +import { Duration, DurationSDKType } from "../../../protobuf/duration.js"; +import { BinaryReader, BinaryWriter } from "../../../../binary.js"; +import { isSet, DeepPartial } from "../../../../helpers.js"; +import { JsonSafe } from "../../../../json-safe.js"; +export const protobufPackage = "google.api.servicecontrol.v1"; +/** + * A common proto for logging HTTP requests. Only contains semantics + * defined by the HTTP specification. Product-specific logging + * information MUST be defined in a separate message. + */ +export interface HttpRequest { + /** The request method. Examples: `"GET"`, `"HEAD"`, `"PUT"`, `"POST"`. */ + requestMethod: string; + /** + * The scheme (http, https), the host name, the path, and the query + * portion of the URL that was requested. + * Example: `"http://example.com/some/info?color=red"`. + */ + requestUrl: string; + /** + * The size of the HTTP request message in bytes, including the request + * headers and the request body. + */ + requestSize: bigint; + /** + * The response code indicating the status of the response. + * Examples: 200, 404. + */ + status: number; + /** + * The size of the HTTP response message sent back to the client, in bytes, + * including the response headers and the response body. + */ + responseSize: bigint; + /** + * The user agent sent by the client. Example: + * `"Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; Q312461; .NET + * CLR 1.0.3705)"`. + */ + userAgent: string; + /** + * The IP address (IPv4 or IPv6) of the client that issued the HTTP + * request. Examples: `"192.168.1.1"`, `"FE80::0202:B3FF:FE1E:8329"`. + */ + remoteIp: string; + /** + * The IP address (IPv4 or IPv6) of the origin server that the request was + * sent to. + */ + serverIp: string; + /** + * The referer URL of the request, as defined in + * [HTTP/1.1 Header Field + * Definitions](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). + */ + referer: string; + /** + * The request processing latency on the server, from the time the request was + * received until the response was sent. + */ + latency?: Duration; + /** Whether or not a cache lookup was attempted. */ + cacheLookup: boolean; + /** + * Whether or not an entity was served from cache + * (with or without validation). + */ + cacheHit: boolean; + /** + * Whether or not the response was validated with the origin server before + * being served from cache. This field is only meaningful if `cache_hit` is + * True. + */ + cacheValidatedWithOriginServer: boolean; + /** + * The number of HTTP response bytes inserted into cache. Set only when a + * cache fill was attempted. + */ + cacheFillBytes: bigint; + /** Protocol used for the request. Examples: "HTTP/1.1", "HTTP/2", "websocket" */ + protocol: string; +} +export interface HttpRequestProtoMsg { + typeUrl: "/google.api.servicecontrol.v1.HttpRequest"; + value: Uint8Array; +} +/** + * A common proto for logging HTTP requests. Only contains semantics + * defined by the HTTP specification. Product-specific logging + * information MUST be defined in a separate message. + */ +export interface HttpRequestSDKType { + request_method: string; + request_url: string; + request_size: bigint; + status: number; + response_size: bigint; + user_agent: string; + remote_ip: string; + server_ip: string; + referer: string; + latency?: DurationSDKType; + cache_lookup: boolean; + cache_hit: boolean; + cache_validated_with_origin_server: boolean; + cache_fill_bytes: bigint; + protocol: string; +} +function createBaseHttpRequest(): HttpRequest { + return { + requestMethod: "", + requestUrl: "", + requestSize: BigInt(0), + status: 0, + responseSize: BigInt(0), + userAgent: "", + remoteIp: "", + serverIp: "", + referer: "", + latency: undefined, + cacheLookup: false, + cacheHit: false, + cacheValidatedWithOriginServer: false, + cacheFillBytes: BigInt(0), + protocol: "" + }; +} +export const HttpRequest = { + typeUrl: "/google.api.servicecontrol.v1.HttpRequest", + encode(message: HttpRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.requestMethod !== undefined) { + writer.uint32(10).string(message.requestMethod); + } + if (message.requestUrl !== undefined) { + writer.uint32(18).string(message.requestUrl); + } + if (message.requestSize !== undefined) { + writer.uint32(24).int64(message.requestSize); + } + if (message.status !== undefined) { + writer.uint32(32).int32(message.status); + } + if (message.responseSize !== undefined) { + writer.uint32(40).int64(message.responseSize); + } + if (message.userAgent !== undefined) { + writer.uint32(50).string(message.userAgent); + } + if (message.remoteIp !== undefined) { + writer.uint32(58).string(message.remoteIp); + } + if (message.serverIp !== undefined) { + writer.uint32(106).string(message.serverIp); + } + if (message.referer !== undefined) { + writer.uint32(66).string(message.referer); + } + if (message.latency !== undefined) { + Duration.encode(message.latency, writer.uint32(114).fork()).ldelim(); + } + if (message.cacheLookup !== undefined) { + writer.uint32(88).bool(message.cacheLookup); + } + if (message.cacheHit !== undefined) { + writer.uint32(72).bool(message.cacheHit); + } + if (message.cacheValidatedWithOriginServer !== undefined) { + writer.uint32(80).bool(message.cacheValidatedWithOriginServer); + } + if (message.cacheFillBytes !== undefined) { + writer.uint32(96).int64(message.cacheFillBytes); + } + if (message.protocol !== undefined) { + writer.uint32(122).string(message.protocol); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): HttpRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseHttpRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.requestMethod = reader.string(); + break; + case 2: + message.requestUrl = reader.string(); + break; + case 3: + message.requestSize = reader.int64(); + break; + case 4: + message.status = reader.int32(); + break; + case 5: + message.responseSize = reader.int64(); + break; + case 6: + message.userAgent = reader.string(); + break; + case 7: + message.remoteIp = reader.string(); + break; + case 13: + message.serverIp = reader.string(); + break; + case 8: + message.referer = reader.string(); + break; + case 14: + message.latency = Duration.decode(reader, reader.uint32()); + break; + case 11: + message.cacheLookup = reader.bool(); + break; + case 9: + message.cacheHit = reader.bool(); + break; + case 10: + message.cacheValidatedWithOriginServer = reader.bool(); + break; + case 12: + message.cacheFillBytes = reader.int64(); + break; + case 15: + message.protocol = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): HttpRequest { + const obj = createBaseHttpRequest(); + if (isSet(object.requestMethod)) obj.requestMethod = String(object.requestMethod); + if (isSet(object.requestUrl)) obj.requestUrl = String(object.requestUrl); + if (isSet(object.requestSize)) obj.requestSize = BigInt(object.requestSize.toString()); + if (isSet(object.status)) obj.status = Number(object.status); + if (isSet(object.responseSize)) obj.responseSize = BigInt(object.responseSize.toString()); + if (isSet(object.userAgent)) obj.userAgent = String(object.userAgent); + if (isSet(object.remoteIp)) obj.remoteIp = String(object.remoteIp); + if (isSet(object.serverIp)) obj.serverIp = String(object.serverIp); + if (isSet(object.referer)) obj.referer = String(object.referer); + if (isSet(object.latency)) obj.latency = Duration.fromJSON(object.latency); + if (isSet(object.cacheLookup)) obj.cacheLookup = Boolean(object.cacheLookup); + if (isSet(object.cacheHit)) obj.cacheHit = Boolean(object.cacheHit); + if (isSet(object.cacheValidatedWithOriginServer)) obj.cacheValidatedWithOriginServer = Boolean(object.cacheValidatedWithOriginServer); + if (isSet(object.cacheFillBytes)) obj.cacheFillBytes = BigInt(object.cacheFillBytes.toString()); + if (isSet(object.protocol)) obj.protocol = String(object.protocol); + return obj; + }, + toJSON(message: HttpRequest): JsonSafe { + const obj: any = {}; + message.requestMethod !== undefined && (obj.requestMethod = message.requestMethod); + message.requestUrl !== undefined && (obj.requestUrl = message.requestUrl); + message.requestSize !== undefined && (obj.requestSize = (message.requestSize || BigInt(0)).toString()); + message.status !== undefined && (obj.status = Math.round(message.status)); + message.responseSize !== undefined && (obj.responseSize = (message.responseSize || BigInt(0)).toString()); + message.userAgent !== undefined && (obj.userAgent = message.userAgent); + message.remoteIp !== undefined && (obj.remoteIp = message.remoteIp); + message.serverIp !== undefined && (obj.serverIp = message.serverIp); + message.referer !== undefined && (obj.referer = message.referer); + message.latency !== undefined && (obj.latency = message.latency ? Duration.toJSON(message.latency) : undefined); + message.cacheLookup !== undefined && (obj.cacheLookup = message.cacheLookup); + message.cacheHit !== undefined && (obj.cacheHit = message.cacheHit); + message.cacheValidatedWithOriginServer !== undefined && (obj.cacheValidatedWithOriginServer = message.cacheValidatedWithOriginServer); + message.cacheFillBytes !== undefined && (obj.cacheFillBytes = (message.cacheFillBytes || BigInt(0)).toString()); + message.protocol !== undefined && (obj.protocol = message.protocol); + return obj; + }, + fromPartial(object: DeepPartial): HttpRequest { + const message = createBaseHttpRequest(); + message.requestMethod = object.requestMethod ?? ""; + message.requestUrl = object.requestUrl ?? ""; + if (object.requestSize !== undefined && object.requestSize !== null) { + message.requestSize = BigInt(object.requestSize.toString()); + } + message.status = object.status ?? 0; + if (object.responseSize !== undefined && object.responseSize !== null) { + message.responseSize = BigInt(object.responseSize.toString()); + } + message.userAgent = object.userAgent ?? ""; + message.remoteIp = object.remoteIp ?? ""; + message.serverIp = object.serverIp ?? ""; + message.referer = object.referer ?? ""; + if (object.latency !== undefined && object.latency !== null) { + message.latency = Duration.fromPartial(object.latency); + } + message.cacheLookup = object.cacheLookup ?? false; + message.cacheHit = object.cacheHit ?? false; + message.cacheValidatedWithOriginServer = object.cacheValidatedWithOriginServer ?? false; + if (object.cacheFillBytes !== undefined && object.cacheFillBytes !== null) { + message.cacheFillBytes = BigInt(object.cacheFillBytes.toString()); + } + message.protocol = object.protocol ?? ""; + return message; + }, + fromSDK(object: HttpRequestSDKType): HttpRequest { + return { + requestMethod: object?.request_method, + requestUrl: object?.request_url, + requestSize: object?.request_size, + status: object?.status, + responseSize: object?.response_size, + userAgent: object?.user_agent, + remoteIp: object?.remote_ip, + serverIp: object?.server_ip, + referer: object?.referer, + latency: object.latency ? Duration.fromSDK(object.latency) : undefined, + cacheLookup: object?.cache_lookup, + cacheHit: object?.cache_hit, + cacheValidatedWithOriginServer: object?.cache_validated_with_origin_server, + cacheFillBytes: object?.cache_fill_bytes, + protocol: object?.protocol + }; + }, + fromSDKJSON(object: any): HttpRequestSDKType { + return { + request_method: isSet(object.request_method) ? String(object.request_method) : "", + request_url: isSet(object.request_url) ? String(object.request_url) : "", + request_size: isSet(object.request_size) ? BigInt(object.request_size.toString()) : BigInt(0), + status: isSet(object.status) ? Number(object.status) : 0, + response_size: isSet(object.response_size) ? BigInt(object.response_size.toString()) : BigInt(0), + user_agent: isSet(object.user_agent) ? String(object.user_agent) : "", + remote_ip: isSet(object.remote_ip) ? String(object.remote_ip) : "", + server_ip: isSet(object.server_ip) ? String(object.server_ip) : "", + referer: isSet(object.referer) ? String(object.referer) : "", + latency: isSet(object.latency) ? Duration.fromSDKJSON(object.latency) : undefined, + cache_lookup: isSet(object.cache_lookup) ? Boolean(object.cache_lookup) : false, + cache_hit: isSet(object.cache_hit) ? Boolean(object.cache_hit) : false, + cache_validated_with_origin_server: isSet(object.cache_validated_with_origin_server) ? Boolean(object.cache_validated_with_origin_server) : false, + cache_fill_bytes: isSet(object.cache_fill_bytes) ? BigInt(object.cache_fill_bytes.toString()) : BigInt(0), + protocol: isSet(object.protocol) ? String(object.protocol) : "" + }; + }, + toSDK(message: HttpRequest): HttpRequestSDKType { + const obj: any = {}; + obj.request_method = message.requestMethod; + obj.request_url = message.requestUrl; + obj.request_size = message.requestSize; + obj.status = message.status; + obj.response_size = message.responseSize; + obj.user_agent = message.userAgent; + obj.remote_ip = message.remoteIp; + obj.server_ip = message.serverIp; + obj.referer = message.referer; + message.latency !== undefined && (obj.latency = message.latency ? Duration.toSDK(message.latency) : undefined); + obj.cache_lookup = message.cacheLookup; + obj.cache_hit = message.cacheHit; + obj.cache_validated_with_origin_server = message.cacheValidatedWithOriginServer; + obj.cache_fill_bytes = message.cacheFillBytes; + obj.protocol = message.protocol; + return obj; + }, + fromAmino(object: HttpRequestAmino): HttpRequest { + const message = createBaseHttpRequest(); + if (object.request_method !== undefined && object.request_method !== null) { + message.requestMethod = object.request_method; + } + if (object.request_url !== undefined && object.request_url !== null) { + message.requestUrl = object.request_url; + } + if (object.request_size !== undefined && object.request_size !== null) { + message.requestSize = BigInt(object.request_size); + } + if (object.status !== undefined && object.status !== null) { + message.status = object.status; + } + if (object.response_size !== undefined && object.response_size !== null) { + message.responseSize = BigInt(object.response_size); + } + if (object.user_agent !== undefined && object.user_agent !== null) { + message.userAgent = object.user_agent; + } + if (object.remote_ip !== undefined && object.remote_ip !== null) { + message.remoteIp = object.remote_ip; + } + if (object.server_ip !== undefined && object.server_ip !== null) { + message.serverIp = object.server_ip; + } + if (object.referer !== undefined && object.referer !== null) { + message.referer = object.referer; + } + if (object.latency !== undefined && object.latency !== null) { + message.latency = Duration.fromAmino(object.latency); + } + if (object.cache_lookup !== undefined && object.cache_lookup !== null) { + message.cacheLookup = object.cache_lookup; + } + if (object.cache_hit !== undefined && object.cache_hit !== null) { + message.cacheHit = object.cache_hit; + } + if (object.cache_validated_with_origin_server !== undefined && object.cache_validated_with_origin_server !== null) { + message.cacheValidatedWithOriginServer = object.cache_validated_with_origin_server; + } + if (object.cache_fill_bytes !== undefined && object.cache_fill_bytes !== null) { + message.cacheFillBytes = BigInt(object.cache_fill_bytes); + } + if (object.protocol !== undefined && object.protocol !== null) { + message.protocol = object.protocol; + } + return message; + }, + toAmino(message: HttpRequest): HttpRequestAmino { + const obj: any = {}; + obj.request_method = message.requestMethod === "" ? undefined : message.requestMethod; + obj.request_url = message.requestUrl === "" ? undefined : message.requestUrl; + obj.request_size = message.requestSize !== BigInt(0) ? message.requestSize?.toString() : undefined; + obj.status = message.status === 0 ? undefined : message.status; + obj.response_size = message.responseSize !== BigInt(0) ? message.responseSize?.toString() : undefined; + obj.user_agent = message.userAgent === "" ? undefined : message.userAgent; + obj.remote_ip = message.remoteIp === "" ? undefined : message.remoteIp; + obj.server_ip = message.serverIp === "" ? undefined : message.serverIp; + obj.referer = message.referer === "" ? undefined : message.referer; + obj.latency = message.latency ? Duration.toAmino(message.latency) : undefined; + obj.cache_lookup = message.cacheLookup === false ? undefined : message.cacheLookup; + obj.cache_hit = message.cacheHit === false ? undefined : message.cacheHit; + obj.cache_validated_with_origin_server = message.cacheValidatedWithOriginServer === false ? undefined : message.cacheValidatedWithOriginServer; + obj.cache_fill_bytes = message.cacheFillBytes !== BigInt(0) ? message.cacheFillBytes?.toString() : undefined; + obj.protocol = message.protocol === "" ? undefined : message.protocol; + return obj; + }, + fromAminoMsg(object: HttpRequestAminoMsg): HttpRequest { + return HttpRequest.fromAmino(object.value); + }, + fromProtoMsg(message: HttpRequestProtoMsg): HttpRequest { + return HttpRequest.decode(message.value); + }, + toProto(message: HttpRequest): Uint8Array { + return HttpRequest.encode(message).finish(); + }, + toProtoMsg(message: HttpRequest): HttpRequestProtoMsg { + return { + typeUrl: "/google.api.servicecontrol.v1.HttpRequest", + value: HttpRequest.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/api/servicecontrol/v1/log_entry.ts b/__fixtures__/v-next/outputicjsdeps/google/api/servicecontrol/v1/log_entry.ts new file mode 100644 index 0000000000..8dfc555571 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/api/servicecontrol/v1/log_entry.ts @@ -0,0 +1,874 @@ +import { Timestamp, TimestampSDKType } from "../../../protobuf/timestamp.js"; +import { LogSeverity, LogSeveritySDKType, logSeverityFromJSON, logSeverityToJSON } from "../../../logging/type/log_severity.js"; +import { HttpRequest, HttpRequestSDKType } from "./http_request.js"; +import { Any, AnySDKType } from "../../../protobuf/any.js"; +import { Struct, StructSDKType } from "../../../protobuf/struct.js"; +import { BinaryReader, BinaryWriter } from "../../../../binary.js"; +import { isSet, DeepPartial, toTimestamp, fromTimestamp, isObject } from "../../../../helpers.js"; +import { JsonSafe } from "../../../../json-safe.js"; +export const protobufPackage = "google.api.servicecontrol.v1"; +export interface LogEntry_LabelsEntry { + key: string; + value: string; +} +export interface LogEntry_LabelsEntryProtoMsg { + typeUrl: string; + value: Uint8Array; +} +export interface LogEntry_LabelsEntrySDKType { + key: string; + value: string; +} +/** An individual log entry. */ +export interface LogEntry { + /** + * Required. The log to which this log entry belongs. Examples: `"syslog"`, + * `"book_log"`. + */ + name: string; + /** + * The time the event described by the log entry occurred. If + * omitted, defaults to operation start time. + */ + timestamp?: Date; + /** + * The severity of the log entry. The default value is + * `LogSeverity.DEFAULT`. + */ + severity: LogSeverity; + /** + * Optional. Information about the HTTP request associated with this + * log entry, if applicable. + */ + httpRequest?: HttpRequest; + /** + * Optional. Resource name of the trace associated with the log entry, if any. + * If this field contains a relative resource name, you can assume the name is + * relative to `//tracing.googleapis.com`. Example: + * `projects/my-projectid/traces/06796866738c859f2f19b7cfb3214824` + */ + trace: string; + /** + * A unique ID for the log entry used for deduplication. If omitted, + * the implementation will generate one based on operation_id. + */ + insertId: string; + /** + * A set of user-defined (key, value) data that provides additional + * information about the log entry. + */ + labels: { + [key: string]: string; + }; + /** + * The log entry payload, represented as a protocol buffer that is + * expressed as a JSON object. The only accepted type currently is + * [AuditLog][google.cloud.audit.AuditLog]. + */ + protoPayload?: Any; + /** The log entry payload, represented as a Unicode string (UTF-8). */ + textPayload?: string; + /** + * The log entry payload, represented as a structure that + * is expressed as a JSON object. + */ + structPayload?: Struct; + /** + * Optional. Information about an operation associated with the log entry, if + * applicable. + */ + operation?: LogEntryOperation; + /** + * Optional. Source code location information associated with the log entry, + * if any. + */ + sourceLocation?: LogEntrySourceLocation; +} +export interface LogEntryProtoMsg { + typeUrl: "/google.api.servicecontrol.v1.LogEntry"; + value: Uint8Array; +} +/** An individual log entry. */ +export interface LogEntrySDKType { + name: string; + timestamp?: Date; + severity: LogSeverity; + http_request?: HttpRequestSDKType; + trace: string; + insert_id: string; + labels: { + [key: string]: string; + }; + proto_payload?: AnySDKType; + text_payload?: string; + struct_payload?: StructSDKType; + operation?: LogEntryOperationSDKType; + source_location?: LogEntrySourceLocationSDKType; +} +/** + * Additional information about a potentially long-running operation with which + * a log entry is associated. + */ +export interface LogEntryOperation { + /** + * Optional. An arbitrary operation identifier. Log entries with the + * same identifier are assumed to be part of the same operation. + */ + id: string; + /** + * Optional. An arbitrary producer identifier. The combination of + * `id` and `producer` must be globally unique. Examples for `producer`: + * `"MyDivision.MyBigCompany.com"`, `"github.com/MyProject/MyApplication"`. + */ + producer: string; + /** Optional. Set this to True if this is the first log entry in the operation. */ + first: boolean; + /** Optional. Set this to True if this is the last log entry in the operation. */ + last: boolean; +} +export interface LogEntryOperationProtoMsg { + typeUrl: "/google.api.servicecontrol.v1.LogEntryOperation"; + value: Uint8Array; +} +/** + * Additional information about a potentially long-running operation with which + * a log entry is associated. + */ +export interface LogEntryOperationSDKType { + id: string; + producer: string; + first: boolean; + last: boolean; +} +/** + * Additional information about the source code location that produced the log + * entry. + */ +export interface LogEntrySourceLocation { + /** + * Optional. Source file name. Depending on the runtime environment, this + * might be a simple name or a fully-qualified name. + */ + file: string; + /** + * Optional. Line within the source file. 1-based; 0 indicates no line number + * available. + */ + line: bigint; + /** + * Optional. Human-readable name of the function or method being invoked, with + * optional context such as the class or package name. This information may be + * used in contexts such as the logs viewer, where a file and line number are + * less meaningful. The format can vary by language. For example: + * `qual.if.ied.Class.method` (Java), `dir/package.func` (Go), `function` + * (Python). + */ + function: string; +} +export interface LogEntrySourceLocationProtoMsg { + typeUrl: "/google.api.servicecontrol.v1.LogEntrySourceLocation"; + value: Uint8Array; +} +/** + * Additional information about the source code location that produced the log + * entry. + */ +export interface LogEntrySourceLocationSDKType { + file: string; + line: bigint; + function: string; +} +function createBaseLogEntry_LabelsEntry(): LogEntry_LabelsEntry { + return { + key: "", + value: "" + }; +} +export const LogEntry_LabelsEntry = { + encode(message: LogEntry_LabelsEntry, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.key !== undefined) { + writer.uint32(10).string(message.key); + } + if (message.value !== undefined) { + writer.uint32(18).string(message.value); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): LogEntry_LabelsEntry { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseLogEntry_LabelsEntry(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.string(); + break; + case 2: + message.value = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): LogEntry_LabelsEntry { + const obj = createBaseLogEntry_LabelsEntry(); + if (isSet(object.key)) obj.key = String(object.key); + if (isSet(object.value)) obj.value = String(object.value); + return obj; + }, + toJSON(message: LogEntry_LabelsEntry): JsonSafe { + const obj: any = {}; + message.key !== undefined && (obj.key = message.key); + message.value !== undefined && (obj.value = message.value); + return obj; + }, + fromPartial(object: DeepPartial): LogEntry_LabelsEntry { + const message = createBaseLogEntry_LabelsEntry(); + message.key = object.key ?? ""; + message.value = object.value ?? ""; + return message; + }, + fromSDK(object: LogEntry_LabelsEntrySDKType): LogEntry_LabelsEntry { + return { + key: object?.key, + value: object?.value + }; + }, + fromSDKJSON(object: any): LogEntry_LabelsEntrySDKType { + return { + key: isSet(object.key) ? String(object.key) : "", + value: isSet(object.value) ? String(object.value) : "" + }; + }, + toSDK(message: LogEntry_LabelsEntry): LogEntry_LabelsEntrySDKType { + const obj: any = {}; + obj.key = message.key; + obj.value = message.value; + return obj; + }, + fromAmino(object: LogEntry_LabelsEntryAmino): LogEntry_LabelsEntry { + const message = createBaseLogEntry_LabelsEntry(); + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } + if (object.value !== undefined && object.value !== null) { + message.value = object.value; + } + return message; + }, + toAmino(message: LogEntry_LabelsEntry): LogEntry_LabelsEntryAmino { + const obj: any = {}; + obj.key = message.key === "" ? undefined : message.key; + obj.value = message.value === "" ? undefined : message.value; + return obj; + }, + fromAminoMsg(object: LogEntry_LabelsEntryAminoMsg): LogEntry_LabelsEntry { + return LogEntry_LabelsEntry.fromAmino(object.value); + }, + fromProtoMsg(message: LogEntry_LabelsEntryProtoMsg): LogEntry_LabelsEntry { + return LogEntry_LabelsEntry.decode(message.value); + }, + toProto(message: LogEntry_LabelsEntry): Uint8Array { + return LogEntry_LabelsEntry.encode(message).finish(); + } +}; +function createBaseLogEntry(): LogEntry { + return { + name: "", + timestamp: undefined, + severity: 0, + httpRequest: undefined, + trace: "", + insertId: "", + labels: {}, + protoPayload: undefined, + textPayload: undefined, + structPayload: undefined, + operation: undefined, + sourceLocation: undefined + }; +} +export const LogEntry = { + typeUrl: "/google.api.servicecontrol.v1.LogEntry", + encode(message: LogEntry, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(82).string(message.name); + } + if (message.timestamp !== undefined) { + Timestamp.encode(toTimestamp(message.timestamp), writer.uint32(90).fork()).ldelim(); + } + if (message.severity !== 0) { + writer.uint32(96).int32(message.severity); + } + if (message.httpRequest !== undefined) { + HttpRequest.encode(message.httpRequest, writer.uint32(114).fork()).ldelim(); + } + if (message.trace !== undefined) { + writer.uint32(122).string(message.trace); + } + if (message.insertId !== undefined) { + writer.uint32(34).string(message.insertId); + } + Object.entries(message.labels).forEach(([key, value]) => { + LogEntry_LabelsEntry.encode({ + key: (key as any), + value + }, writer.uint32(106).fork()).ldelim(); + }); + if (message.protoPayload !== undefined) { + Any.encode(message.protoPayload, writer.uint32(18).fork()).ldelim(); + } + if (message.textPayload !== undefined) { + writer.uint32(26).string(message.textPayload); + } + if (message.structPayload !== undefined) { + Struct.encode(message.structPayload, writer.uint32(50).fork()).ldelim(); + } + if (message.operation !== undefined) { + LogEntryOperation.encode(message.operation, writer.uint32(130).fork()).ldelim(); + } + if (message.sourceLocation !== undefined) { + LogEntrySourceLocation.encode(message.sourceLocation, writer.uint32(138).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): LogEntry { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseLogEntry(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 10: + message.name = reader.string(); + break; + case 11: + message.timestamp = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + break; + case 12: + message.severity = (reader.int32() as any); + break; + case 14: + message.httpRequest = HttpRequest.decode(reader, reader.uint32()); + break; + case 15: + message.trace = reader.string(); + break; + case 4: + message.insertId = reader.string(); + break; + case 13: + const entry13 = LogEntry_LabelsEntry.decode(reader, reader.uint32()); + if (entry13.value !== undefined) { + message.labels[entry13.key] = entry13.value; + } + break; + case 2: + message.protoPayload = Any.decode(reader, reader.uint32()); + break; + case 3: + message.textPayload = reader.string(); + break; + case 6: + message.structPayload = Struct.decode(reader, reader.uint32()); + break; + case 16: + message.operation = LogEntryOperation.decode(reader, reader.uint32()); + break; + case 17: + message.sourceLocation = LogEntrySourceLocation.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): LogEntry { + const obj = createBaseLogEntry(); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.timestamp)) obj.timestamp = new Date(object.timestamp); + if (isSet(object.severity)) obj.severity = logSeverityFromJSON(object.severity); + if (isSet(object.httpRequest)) obj.httpRequest = HttpRequest.fromJSON(object.httpRequest); + if (isSet(object.trace)) obj.trace = String(object.trace); + if (isSet(object.insertId)) obj.insertId = String(object.insertId); + if (isObject(object.labels)) obj.labels = Object.entries(object.labels).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + acc[key] = String(value); + return acc; + }, {}); + if (isSet(object.protoPayload)) obj.protoPayload = Any.fromJSON(object.protoPayload); + if (isSet(object.textPayload)) obj.textPayload = String(object.textPayload); + if (isSet(object.structPayload)) obj.structPayload = Struct.fromJSON(object.structPayload); + if (isSet(object.operation)) obj.operation = LogEntryOperation.fromJSON(object.operation); + if (isSet(object.sourceLocation)) obj.sourceLocation = LogEntrySourceLocation.fromJSON(object.sourceLocation); + return obj; + }, + toJSON(message: LogEntry): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.timestamp !== undefined && (obj.timestamp = message.timestamp.toISOString()); + message.severity !== undefined && (obj.severity = logSeverityToJSON(message.severity)); + message.httpRequest !== undefined && (obj.httpRequest = message.httpRequest ? HttpRequest.toJSON(message.httpRequest) : undefined); + message.trace !== undefined && (obj.trace = message.trace); + message.insertId !== undefined && (obj.insertId = message.insertId); + obj.labels = {}; + if (message.labels) { + Object.entries(message.labels).forEach(([k, v]) => { + obj.labels[k] = v; + }); + } + message.protoPayload !== undefined && (obj.protoPayload = message.protoPayload ? Any.toJSON(message.protoPayload) : undefined); + message.textPayload !== undefined && (obj.textPayload = message.textPayload); + message.structPayload !== undefined && (obj.structPayload = message.structPayload ? Struct.toJSON(message.structPayload) : undefined); + message.operation !== undefined && (obj.operation = message.operation ? LogEntryOperation.toJSON(message.operation) : undefined); + message.sourceLocation !== undefined && (obj.sourceLocation = message.sourceLocation ? LogEntrySourceLocation.toJSON(message.sourceLocation) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): LogEntry { + const message = createBaseLogEntry(); + message.name = object.name ?? ""; + message.timestamp = object.timestamp ?? undefined; + message.severity = object.severity ?? 0; + if (object.httpRequest !== undefined && object.httpRequest !== null) { + message.httpRequest = HttpRequest.fromPartial(object.httpRequest); + } + message.trace = object.trace ?? ""; + message.insertId = object.insertId ?? ""; + message.labels = Object.entries(object.labels ?? {}).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + if (value !== undefined) { + acc[key] = String(value); + } + return acc; + }, {}); + if (object.protoPayload !== undefined && object.protoPayload !== null) { + message.protoPayload = Any.fromPartial(object.protoPayload); + } + message.textPayload = object.textPayload ?? undefined; + if (object.structPayload !== undefined && object.structPayload !== null) { + message.structPayload = Struct.fromPartial(object.structPayload); + } + if (object.operation !== undefined && object.operation !== null) { + message.operation = LogEntryOperation.fromPartial(object.operation); + } + if (object.sourceLocation !== undefined && object.sourceLocation !== null) { + message.sourceLocation = LogEntrySourceLocation.fromPartial(object.sourceLocation); + } + return message; + }, + fromSDK(object: LogEntrySDKType): LogEntry { + return { + name: object?.name, + timestamp: object.timestamp ?? undefined, + severity: isSet(object.severity) ? logSeverityFromJSON(object.severity) : -1, + httpRequest: object.http_request ? HttpRequest.fromSDK(object.http_request) : undefined, + trace: object?.trace, + insertId: object?.insert_id, + labels: isObject(object.labels) ? Object.entries(object.labels).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + acc[key] = String(value); + return acc; + }, {}) : {}, + protoPayload: object.proto_payload ? Any.fromSDK(object.proto_payload) : undefined, + textPayload: object?.text_payload, + structPayload: object.struct_payload ? Struct.fromSDK(object.struct_payload) : undefined, + operation: object.operation ? LogEntryOperation.fromSDK(object.operation) : undefined, + sourceLocation: object.source_location ? LogEntrySourceLocation.fromSDK(object.source_location) : undefined + }; + }, + fromSDKJSON(object: any): LogEntrySDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + timestamp: isSet(object.timestamp) ? new Date(object.timestamp) : undefined, + severity: isSet(object.severity) ? logSeverityFromJSON(object.severity) : -1, + http_request: isSet(object.http_request) ? HttpRequest.fromSDKJSON(object.http_request) : undefined, + trace: isSet(object.trace) ? String(object.trace) : "", + insert_id: isSet(object.insert_id) ? String(object.insert_id) : "", + labels: isObject(object.labels) ? Object.entries(object.labels).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + acc[key] = String(value); + return acc; + }, {}) : {}, + proto_payload: isSet(object.proto_payload) ? Any.fromSDKJSON(object.proto_payload) : undefined, + text_payload: isSet(object.text_payload) ? String(object.text_payload) : undefined, + struct_payload: isSet(object.struct_payload) ? Struct.fromSDKJSON(object.struct_payload) : undefined, + operation: isSet(object.operation) ? LogEntryOperation.fromSDKJSON(object.operation) : undefined, + source_location: isSet(object.source_location) ? LogEntrySourceLocation.fromSDKJSON(object.source_location) : undefined + }; + }, + toSDK(message: LogEntry): LogEntrySDKType { + const obj: any = {}; + obj.name = message.name; + message.timestamp !== undefined && (obj.timestamp = message.timestamp ?? undefined); + message.severity !== undefined && (obj.severity = logSeverityToJSON(message.severity)); + message.httpRequest !== undefined && (obj.http_request = message.httpRequest ? HttpRequest.toSDK(message.httpRequest) : undefined); + obj.trace = message.trace; + obj.insert_id = message.insertId; + obj.labels = {}; + if (message.labels) { + Object.entries(message.labels).forEach(([k, v]) => { + obj.labels[k] = v; + }); + } + message.protoPayload !== undefined && (obj.proto_payload = message.protoPayload ? Any.toSDK(message.protoPayload) : undefined); + obj.text_payload = message.textPayload; + message.structPayload !== undefined && (obj.struct_payload = message.structPayload ? Struct.toSDK(message.structPayload) : undefined); + message.operation !== undefined && (obj.operation = message.operation ? LogEntryOperation.toSDK(message.operation) : undefined); + message.sourceLocation !== undefined && (obj.source_location = message.sourceLocation ? LogEntrySourceLocation.toSDK(message.sourceLocation) : undefined); + return obj; + }, + fromAmino(object: LogEntryAmino): LogEntry { + const message = createBaseLogEntry(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + if (object.timestamp !== undefined && object.timestamp !== null) { + message.timestamp = fromTimestamp(Timestamp.fromAmino(object.timestamp)); + } + if (object.severity !== undefined && object.severity !== null) { + message.severity = object.severity; + } + if (object.http_request !== undefined && object.http_request !== null) { + message.httpRequest = HttpRequest.fromAmino(object.http_request); + } + if (object.trace !== undefined && object.trace !== null) { + message.trace = object.trace; + } + if (object.insert_id !== undefined && object.insert_id !== null) { + message.insertId = object.insert_id; + } + message.labels = Object.entries(object.labels ?? {}).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + if (value !== undefined) { + acc[key] = String(value); + } + return acc; + }, {}); + if (object.proto_payload !== undefined && object.proto_payload !== null) { + message.protoPayload = Any.fromAmino(object.proto_payload); + } + if (object.text_payload !== undefined && object.text_payload !== null) { + message.textPayload = object.text_payload; + } + if (object.struct_payload !== undefined && object.struct_payload !== null) { + message.structPayload = Struct.fromAmino(object.struct_payload); + } + if (object.operation !== undefined && object.operation !== null) { + message.operation = LogEntryOperation.fromAmino(object.operation); + } + if (object.source_location !== undefined && object.source_location !== null) { + message.sourceLocation = LogEntrySourceLocation.fromAmino(object.source_location); + } + return message; + }, + toAmino(message: LogEntry): LogEntryAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + obj.timestamp = message.timestamp ? Timestamp.toAmino(toTimestamp(message.timestamp)) : undefined; + obj.severity = message.severity === 0 ? undefined : message.severity; + obj.http_request = message.httpRequest ? HttpRequest.toAmino(message.httpRequest) : undefined; + obj.trace = message.trace === "" ? undefined : message.trace; + obj.insert_id = message.insertId === "" ? undefined : message.insertId; + obj.labels = {}; + if (message.labels) { + Object.entries(message.labels).forEach(([k, v]) => { + obj.labels[k] = v; + }); + } + obj.proto_payload = message.protoPayload ? Any.toAmino(message.protoPayload) : undefined; + obj.text_payload = message.textPayload === null ? undefined : message.textPayload; + obj.struct_payload = message.structPayload ? Struct.toAmino(message.structPayload) : undefined; + obj.operation = message.operation ? LogEntryOperation.toAmino(message.operation) : undefined; + obj.source_location = message.sourceLocation ? LogEntrySourceLocation.toAmino(message.sourceLocation) : undefined; + return obj; + }, + fromAminoMsg(object: LogEntryAminoMsg): LogEntry { + return LogEntry.fromAmino(object.value); + }, + fromProtoMsg(message: LogEntryProtoMsg): LogEntry { + return LogEntry.decode(message.value); + }, + toProto(message: LogEntry): Uint8Array { + return LogEntry.encode(message).finish(); + }, + toProtoMsg(message: LogEntry): LogEntryProtoMsg { + return { + typeUrl: "/google.api.servicecontrol.v1.LogEntry", + value: LogEntry.encode(message).finish() + }; + } +}; +function createBaseLogEntryOperation(): LogEntryOperation { + return { + id: "", + producer: "", + first: false, + last: false + }; +} +export const LogEntryOperation = { + typeUrl: "/google.api.servicecontrol.v1.LogEntryOperation", + encode(message: LogEntryOperation, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.id !== undefined) { + writer.uint32(10).string(message.id); + } + if (message.producer !== undefined) { + writer.uint32(18).string(message.producer); + } + if (message.first !== undefined) { + writer.uint32(24).bool(message.first); + } + if (message.last !== undefined) { + writer.uint32(32).bool(message.last); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): LogEntryOperation { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseLogEntryOperation(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.id = reader.string(); + break; + case 2: + message.producer = reader.string(); + break; + case 3: + message.first = reader.bool(); + break; + case 4: + message.last = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): LogEntryOperation { + const obj = createBaseLogEntryOperation(); + if (isSet(object.id)) obj.id = String(object.id); + if (isSet(object.producer)) obj.producer = String(object.producer); + if (isSet(object.first)) obj.first = Boolean(object.first); + if (isSet(object.last)) obj.last = Boolean(object.last); + return obj; + }, + toJSON(message: LogEntryOperation): JsonSafe { + const obj: any = {}; + message.id !== undefined && (obj.id = message.id); + message.producer !== undefined && (obj.producer = message.producer); + message.first !== undefined && (obj.first = message.first); + message.last !== undefined && (obj.last = message.last); + return obj; + }, + fromPartial(object: DeepPartial): LogEntryOperation { + const message = createBaseLogEntryOperation(); + message.id = object.id ?? ""; + message.producer = object.producer ?? ""; + message.first = object.first ?? false; + message.last = object.last ?? false; + return message; + }, + fromSDK(object: LogEntryOperationSDKType): LogEntryOperation { + return { + id: object?.id, + producer: object?.producer, + first: object?.first, + last: object?.last + }; + }, + fromSDKJSON(object: any): LogEntryOperationSDKType { + return { + id: isSet(object.id) ? String(object.id) : "", + producer: isSet(object.producer) ? String(object.producer) : "", + first: isSet(object.first) ? Boolean(object.first) : false, + last: isSet(object.last) ? Boolean(object.last) : false + }; + }, + toSDK(message: LogEntryOperation): LogEntryOperationSDKType { + const obj: any = {}; + obj.id = message.id; + obj.producer = message.producer; + obj.first = message.first; + obj.last = message.last; + return obj; + }, + fromAmino(object: LogEntryOperationAmino): LogEntryOperation { + const message = createBaseLogEntryOperation(); + if (object.id !== undefined && object.id !== null) { + message.id = object.id; + } + if (object.producer !== undefined && object.producer !== null) { + message.producer = object.producer; + } + if (object.first !== undefined && object.first !== null) { + message.first = object.first; + } + if (object.last !== undefined && object.last !== null) { + message.last = object.last; + } + return message; + }, + toAmino(message: LogEntryOperation): LogEntryOperationAmino { + const obj: any = {}; + obj.id = message.id === "" ? undefined : message.id; + obj.producer = message.producer === "" ? undefined : message.producer; + obj.first = message.first === false ? undefined : message.first; + obj.last = message.last === false ? undefined : message.last; + return obj; + }, + fromAminoMsg(object: LogEntryOperationAminoMsg): LogEntryOperation { + return LogEntryOperation.fromAmino(object.value); + }, + fromProtoMsg(message: LogEntryOperationProtoMsg): LogEntryOperation { + return LogEntryOperation.decode(message.value); + }, + toProto(message: LogEntryOperation): Uint8Array { + return LogEntryOperation.encode(message).finish(); + }, + toProtoMsg(message: LogEntryOperation): LogEntryOperationProtoMsg { + return { + typeUrl: "/google.api.servicecontrol.v1.LogEntryOperation", + value: LogEntryOperation.encode(message).finish() + }; + } +}; +function createBaseLogEntrySourceLocation(): LogEntrySourceLocation { + return { + file: "", + line: BigInt(0), + function: "" + }; +} +export const LogEntrySourceLocation = { + typeUrl: "/google.api.servicecontrol.v1.LogEntrySourceLocation", + encode(message: LogEntrySourceLocation, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.file !== undefined) { + writer.uint32(10).string(message.file); + } + if (message.line !== undefined) { + writer.uint32(16).int64(message.line); + } + if (message.function !== undefined) { + writer.uint32(26).string(message.function); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): LogEntrySourceLocation { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseLogEntrySourceLocation(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.file = reader.string(); + break; + case 2: + message.line = reader.int64(); + break; + case 3: + message.function = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): LogEntrySourceLocation { + const obj = createBaseLogEntrySourceLocation(); + if (isSet(object.file)) obj.file = String(object.file); + if (isSet(object.line)) obj.line = BigInt(object.line.toString()); + if (isSet(object.function)) obj.function = String(object.function); + return obj; + }, + toJSON(message: LogEntrySourceLocation): JsonSafe { + const obj: any = {}; + message.file !== undefined && (obj.file = message.file); + message.line !== undefined && (obj.line = (message.line || BigInt(0)).toString()); + message.function !== undefined && (obj.function = message.function); + return obj; + }, + fromPartial(object: DeepPartial): LogEntrySourceLocation { + const message = createBaseLogEntrySourceLocation(); + message.file = object.file ?? ""; + if (object.line !== undefined && object.line !== null) { + message.line = BigInt(object.line.toString()); + } + message.function = object.function ?? ""; + return message; + }, + fromSDK(object: LogEntrySourceLocationSDKType): LogEntrySourceLocation { + return { + file: object?.file, + line: object?.line, + function: object?.function + }; + }, + fromSDKJSON(object: any): LogEntrySourceLocationSDKType { + return { + file: isSet(object.file) ? String(object.file) : "", + line: isSet(object.line) ? BigInt(object.line.toString()) : BigInt(0), + function: isSet(object.function) ? String(object.function) : "" + }; + }, + toSDK(message: LogEntrySourceLocation): LogEntrySourceLocationSDKType { + const obj: any = {}; + obj.file = message.file; + obj.line = message.line; + obj.function = message.function; + return obj; + }, + fromAmino(object: LogEntrySourceLocationAmino): LogEntrySourceLocation { + const message = createBaseLogEntrySourceLocation(); + if (object.file !== undefined && object.file !== null) { + message.file = object.file; + } + if (object.line !== undefined && object.line !== null) { + message.line = BigInt(object.line); + } + if (object.function !== undefined && object.function !== null) { + message.function = object.function; + } + return message; + }, + toAmino(message: LogEntrySourceLocation): LogEntrySourceLocationAmino { + const obj: any = {}; + obj.file = message.file === "" ? undefined : message.file; + obj.line = message.line !== BigInt(0) ? message.line?.toString() : undefined; + obj.function = message.function === "" ? undefined : message.function; + return obj; + }, + fromAminoMsg(object: LogEntrySourceLocationAminoMsg): LogEntrySourceLocation { + return LogEntrySourceLocation.fromAmino(object.value); + }, + fromProtoMsg(message: LogEntrySourceLocationProtoMsg): LogEntrySourceLocation { + return LogEntrySourceLocation.decode(message.value); + }, + toProto(message: LogEntrySourceLocation): Uint8Array { + return LogEntrySourceLocation.encode(message).finish(); + }, + toProtoMsg(message: LogEntrySourceLocation): LogEntrySourceLocationProtoMsg { + return { + typeUrl: "/google.api.servicecontrol.v1.LogEntrySourceLocation", + value: LogEntrySourceLocation.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/api/servicecontrol/v1/metric_value.ts b/__fixtures__/v-next/outputicjsdeps/google/api/servicecontrol/v1/metric_value.ts new file mode 100644 index 0000000000..46230777df --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/api/servicecontrol/v1/metric_value.ts @@ -0,0 +1,569 @@ +import { Timestamp, TimestampSDKType } from "../../../protobuf/timestamp.js"; +import { Distribution, DistributionSDKType } from "./distribution.js"; +import { BinaryReader, BinaryWriter } from "../../../../binary.js"; +import { isSet, DeepPartial, toTimestamp, fromTimestamp, isObject } from "../../../../helpers.js"; +import { JsonSafe } from "../../../../json-safe.js"; +export const protobufPackage = "google.api.servicecontrol.v1"; +export interface MetricValue_LabelsEntry { + key: string; + value: string; +} +export interface MetricValue_LabelsEntryProtoMsg { + typeUrl: string; + value: Uint8Array; +} +export interface MetricValue_LabelsEntrySDKType { + key: string; + value: string; +} +/** Represents a single metric value. */ +export interface MetricValue { + /** + * The labels describing the metric value. + * See comments on [google.api.servicecontrol.v1.Operation.labels][google.api.servicecontrol.v1.Operation.labels] for + * the overriding relationship. + * Note that this map must not contain monitored resource labels. + */ + labels: { + [key: string]: string; + }; + /** + * The start of the time period over which this metric value's measurement + * applies. The time period has different semantics for different metric + * types (cumulative, delta, and gauge). See the metric definition + * documentation in the service configuration for details. If not specified, + * [google.api.servicecontrol.v1.Operation.start_time][google.api.servicecontrol.v1.Operation.start_time] will be used. + */ + startTime?: Date; + /** + * The end of the time period over which this metric value's measurement + * applies. If not specified, + * [google.api.servicecontrol.v1.Operation.end_time][google.api.servicecontrol.v1.Operation.end_time] will be used. + */ + endTime?: Date; + /** A boolean value. */ + boolValue?: boolean; + /** A signed 64-bit integer value. */ + int64Value?: bigint; + /** A double precision floating point value. */ + doubleValue?: number; + /** A text string value. */ + stringValue?: string; + /** A distribution value. */ + distributionValue?: Distribution; +} +export interface MetricValueProtoMsg { + typeUrl: "/google.api.servicecontrol.v1.MetricValue"; + value: Uint8Array; +} +/** Represents a single metric value. */ +export interface MetricValueSDKType { + labels: { + [key: string]: string; + }; + start_time?: Date; + end_time?: Date; + bool_value?: boolean; + int64_value?: bigint; + double_value?: number; + string_value?: string; + distribution_value?: DistributionSDKType; +} +/** + * Represents a set of metric values in the same metric. + * Each metric value in the set should have a unique combination of start time, + * end time, and label values. + */ +export interface MetricValueSet { + /** The metric name defined in the service configuration. */ + metricName: string; + /** The values in this metric. */ + metricValues: MetricValue[]; +} +export interface MetricValueSetProtoMsg { + typeUrl: "/google.api.servicecontrol.v1.MetricValueSet"; + value: Uint8Array; +} +/** + * Represents a set of metric values in the same metric. + * Each metric value in the set should have a unique combination of start time, + * end time, and label values. + */ +export interface MetricValueSetSDKType { + metric_name: string; + metric_values: MetricValueSDKType[]; +} +function createBaseMetricValue_LabelsEntry(): MetricValue_LabelsEntry { + return { + key: "", + value: "" + }; +} +export const MetricValue_LabelsEntry = { + encode(message: MetricValue_LabelsEntry, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.key !== undefined) { + writer.uint32(10).string(message.key); + } + if (message.value !== undefined) { + writer.uint32(18).string(message.value); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MetricValue_LabelsEntry { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMetricValue_LabelsEntry(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.string(); + break; + case 2: + message.value = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MetricValue_LabelsEntry { + const obj = createBaseMetricValue_LabelsEntry(); + if (isSet(object.key)) obj.key = String(object.key); + if (isSet(object.value)) obj.value = String(object.value); + return obj; + }, + toJSON(message: MetricValue_LabelsEntry): JsonSafe { + const obj: any = {}; + message.key !== undefined && (obj.key = message.key); + message.value !== undefined && (obj.value = message.value); + return obj; + }, + fromPartial(object: DeepPartial): MetricValue_LabelsEntry { + const message = createBaseMetricValue_LabelsEntry(); + message.key = object.key ?? ""; + message.value = object.value ?? ""; + return message; + }, + fromSDK(object: MetricValue_LabelsEntrySDKType): MetricValue_LabelsEntry { + return { + key: object?.key, + value: object?.value + }; + }, + fromSDKJSON(object: any): MetricValue_LabelsEntrySDKType { + return { + key: isSet(object.key) ? String(object.key) : "", + value: isSet(object.value) ? String(object.value) : "" + }; + }, + toSDK(message: MetricValue_LabelsEntry): MetricValue_LabelsEntrySDKType { + const obj: any = {}; + obj.key = message.key; + obj.value = message.value; + return obj; + }, + fromAmino(object: MetricValue_LabelsEntryAmino): MetricValue_LabelsEntry { + const message = createBaseMetricValue_LabelsEntry(); + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } + if (object.value !== undefined && object.value !== null) { + message.value = object.value; + } + return message; + }, + toAmino(message: MetricValue_LabelsEntry): MetricValue_LabelsEntryAmino { + const obj: any = {}; + obj.key = message.key === "" ? undefined : message.key; + obj.value = message.value === "" ? undefined : message.value; + return obj; + }, + fromAminoMsg(object: MetricValue_LabelsEntryAminoMsg): MetricValue_LabelsEntry { + return MetricValue_LabelsEntry.fromAmino(object.value); + }, + fromProtoMsg(message: MetricValue_LabelsEntryProtoMsg): MetricValue_LabelsEntry { + return MetricValue_LabelsEntry.decode(message.value); + }, + toProto(message: MetricValue_LabelsEntry): Uint8Array { + return MetricValue_LabelsEntry.encode(message).finish(); + } +}; +function createBaseMetricValue(): MetricValue { + return { + labels: {}, + startTime: undefined, + endTime: undefined, + boolValue: undefined, + int64Value: undefined, + doubleValue: undefined, + stringValue: undefined, + distributionValue: undefined + }; +} +export const MetricValue = { + typeUrl: "/google.api.servicecontrol.v1.MetricValue", + encode(message: MetricValue, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + Object.entries(message.labels).forEach(([key, value]) => { + MetricValue_LabelsEntry.encode({ + key: (key as any), + value + }, writer.uint32(10).fork()).ldelim(); + }); + if (message.startTime !== undefined) { + Timestamp.encode(toTimestamp(message.startTime), writer.uint32(18).fork()).ldelim(); + } + if (message.endTime !== undefined) { + Timestamp.encode(toTimestamp(message.endTime), writer.uint32(26).fork()).ldelim(); + } + if (message.boolValue !== undefined) { + writer.uint32(32).bool(message.boolValue); + } + if (message.int64Value !== undefined) { + writer.uint32(40).int64(message.int64Value); + } + if (message.doubleValue !== undefined) { + writer.uint32(49).double(message.doubleValue); + } + if (message.stringValue !== undefined) { + writer.uint32(58).string(message.stringValue); + } + if (message.distributionValue !== undefined) { + Distribution.encode(message.distributionValue, writer.uint32(66).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MetricValue { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMetricValue(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + const entry1 = MetricValue_LabelsEntry.decode(reader, reader.uint32()); + if (entry1.value !== undefined) { + message.labels[entry1.key] = entry1.value; + } + break; + case 2: + message.startTime = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + break; + case 3: + message.endTime = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + break; + case 4: + message.boolValue = reader.bool(); + break; + case 5: + message.int64Value = reader.int64(); + break; + case 6: + message.doubleValue = reader.double(); + break; + case 7: + message.stringValue = reader.string(); + break; + case 8: + message.distributionValue = Distribution.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MetricValue { + const obj = createBaseMetricValue(); + if (isObject(object.labels)) obj.labels = Object.entries(object.labels).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + acc[key] = String(value); + return acc; + }, {}); + if (isSet(object.startTime)) obj.startTime = new Date(object.startTime); + if (isSet(object.endTime)) obj.endTime = new Date(object.endTime); + if (isSet(object.boolValue)) obj.boolValue = Boolean(object.boolValue); + if (isSet(object.int64Value)) obj.int64Value = BigInt(object.int64Value.toString()); + if (isSet(object.doubleValue)) obj.doubleValue = Number(object.doubleValue); + if (isSet(object.stringValue)) obj.stringValue = String(object.stringValue); + if (isSet(object.distributionValue)) obj.distributionValue = Distribution.fromJSON(object.distributionValue); + return obj; + }, + toJSON(message: MetricValue): JsonSafe { + const obj: any = {}; + obj.labels = {}; + if (message.labels) { + Object.entries(message.labels).forEach(([k, v]) => { + obj.labels[k] = v; + }); + } + message.startTime !== undefined && (obj.startTime = message.startTime.toISOString()); + message.endTime !== undefined && (obj.endTime = message.endTime.toISOString()); + message.boolValue !== undefined && (obj.boolValue = message.boolValue); + if (message.int64Value !== undefined) { + obj.int64Value = message.int64Value.toString(); + } + message.doubleValue !== undefined && (obj.doubleValue = message.doubleValue); + message.stringValue !== undefined && (obj.stringValue = message.stringValue); + message.distributionValue !== undefined && (obj.distributionValue = message.distributionValue ? Distribution.toJSON(message.distributionValue) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): MetricValue { + const message = createBaseMetricValue(); + message.labels = Object.entries(object.labels ?? {}).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + if (value !== undefined) { + acc[key] = String(value); + } + return acc; + }, {}); + message.startTime = object.startTime ?? undefined; + message.endTime = object.endTime ?? undefined; + message.boolValue = object.boolValue ?? undefined; + if (object.int64Value !== undefined && object.int64Value !== null) { + message.int64Value = BigInt(object.int64Value.toString()); + } + message.doubleValue = object.doubleValue ?? undefined; + message.stringValue = object.stringValue ?? undefined; + if (object.distributionValue !== undefined && object.distributionValue !== null) { + message.distributionValue = Distribution.fromPartial(object.distributionValue); + } + return message; + }, + fromSDK(object: MetricValueSDKType): MetricValue { + return { + labels: isObject(object.labels) ? Object.entries(object.labels).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + acc[key] = String(value); + return acc; + }, {}) : {}, + startTime: object.start_time ?? undefined, + endTime: object.end_time ?? undefined, + boolValue: object?.bool_value, + int64Value: object?.int64_value, + doubleValue: object?.double_value, + stringValue: object?.string_value, + distributionValue: object.distribution_value ? Distribution.fromSDK(object.distribution_value) : undefined + }; + }, + fromSDKJSON(object: any): MetricValueSDKType { + return { + labels: isObject(object.labels) ? Object.entries(object.labels).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + acc[key] = String(value); + return acc; + }, {}) : {}, + start_time: isSet(object.start_time) ? new Date(object.start_time) : undefined, + end_time: isSet(object.end_time) ? new Date(object.end_time) : undefined, + bool_value: isSet(object.bool_value) ? Boolean(object.bool_value) : undefined, + int64_value: isSet(object.int64_value) ? BigInt(object.int64_value.toString()) : undefined, + double_value: isSet(object.double_value) ? Number(object.double_value) : undefined, + string_value: isSet(object.string_value) ? String(object.string_value) : undefined, + distribution_value: isSet(object.distribution_value) ? Distribution.fromSDKJSON(object.distribution_value) : undefined + }; + }, + toSDK(message: MetricValue): MetricValueSDKType { + const obj: any = {}; + obj.labels = {}; + if (message.labels) { + Object.entries(message.labels).forEach(([k, v]) => { + obj.labels[k] = v; + }); + } + message.startTime !== undefined && (obj.start_time = message.startTime ?? undefined); + message.endTime !== undefined && (obj.end_time = message.endTime ?? undefined); + obj.bool_value = message.boolValue; + obj.int64_value = message.int64Value; + obj.double_value = message.doubleValue; + obj.string_value = message.stringValue; + message.distributionValue !== undefined && (obj.distribution_value = message.distributionValue ? Distribution.toSDK(message.distributionValue) : undefined); + return obj; + }, + fromAmino(object: MetricValueAmino): MetricValue { + const message = createBaseMetricValue(); + message.labels = Object.entries(object.labels ?? {}).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + if (value !== undefined) { + acc[key] = String(value); + } + return acc; + }, {}); + if (object.start_time !== undefined && object.start_time !== null) { + message.startTime = fromTimestamp(Timestamp.fromAmino(object.start_time)); + } + if (object.end_time !== undefined && object.end_time !== null) { + message.endTime = fromTimestamp(Timestamp.fromAmino(object.end_time)); + } + if (object.bool_value !== undefined && object.bool_value !== null) { + message.boolValue = object.bool_value; + } + if (object.int64_value !== undefined && object.int64_value !== null) { + message.int64Value = BigInt(object.int64_value); + } + if (object.double_value !== undefined && object.double_value !== null) { + message.doubleValue = object.double_value; + } + if (object.string_value !== undefined && object.string_value !== null) { + message.stringValue = object.string_value; + } + if (object.distribution_value !== undefined && object.distribution_value !== null) { + message.distributionValue = Distribution.fromAmino(object.distribution_value); + } + return message; + }, + toAmino(message: MetricValue): MetricValueAmino { + const obj: any = {}; + obj.labels = {}; + if (message.labels) { + Object.entries(message.labels).forEach(([k, v]) => { + obj.labels[k] = v; + }); + } + obj.start_time = message.startTime ? Timestamp.toAmino(toTimestamp(message.startTime)) : undefined; + obj.end_time = message.endTime ? Timestamp.toAmino(toTimestamp(message.endTime)) : undefined; + obj.bool_value = message.boolValue === null ? undefined : message.boolValue; + obj.int64_value = message.int64Value !== BigInt(0) ? message.int64Value?.toString() : undefined; + obj.double_value = message.doubleValue === null ? undefined : message.doubleValue; + obj.string_value = message.stringValue === null ? undefined : message.stringValue; + obj.distribution_value = message.distributionValue ? Distribution.toAmino(message.distributionValue) : undefined; + return obj; + }, + fromAminoMsg(object: MetricValueAminoMsg): MetricValue { + return MetricValue.fromAmino(object.value); + }, + fromProtoMsg(message: MetricValueProtoMsg): MetricValue { + return MetricValue.decode(message.value); + }, + toProto(message: MetricValue): Uint8Array { + return MetricValue.encode(message).finish(); + }, + toProtoMsg(message: MetricValue): MetricValueProtoMsg { + return { + typeUrl: "/google.api.servicecontrol.v1.MetricValue", + value: MetricValue.encode(message).finish() + }; + } +}; +function createBaseMetricValueSet(): MetricValueSet { + return { + metricName: "", + metricValues: [] + }; +} +export const MetricValueSet = { + typeUrl: "/google.api.servicecontrol.v1.MetricValueSet", + encode(message: MetricValueSet, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.metricName !== undefined) { + writer.uint32(10).string(message.metricName); + } + for (const v of message.metricValues) { + MetricValue.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MetricValueSet { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMetricValueSet(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.metricName = reader.string(); + break; + case 2: + message.metricValues.push(MetricValue.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MetricValueSet { + const obj = createBaseMetricValueSet(); + if (isSet(object.metricName)) obj.metricName = String(object.metricName); + if (Array.isArray(object?.metricValues)) obj.metricValues = object.metricValues.map((e: any) => MetricValue.fromJSON(e)); + return obj; + }, + toJSON(message: MetricValueSet): JsonSafe { + const obj: any = {}; + message.metricName !== undefined && (obj.metricName = message.metricName); + if (message.metricValues) { + obj.metricValues = message.metricValues.map(e => e ? MetricValue.toJSON(e) : undefined); + } else { + obj.metricValues = []; + } + return obj; + }, + fromPartial(object: DeepPartial): MetricValueSet { + const message = createBaseMetricValueSet(); + message.metricName = object.metricName ?? ""; + message.metricValues = object.metricValues?.map(e => MetricValue.fromPartial(e)) || []; + return message; + }, + fromSDK(object: MetricValueSetSDKType): MetricValueSet { + return { + metricName: object?.metric_name, + metricValues: Array.isArray(object?.metric_values) ? object.metric_values.map((e: any) => MetricValue.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): MetricValueSetSDKType { + return { + metric_name: isSet(object.metric_name) ? String(object.metric_name) : "", + metric_values: Array.isArray(object?.metric_values) ? object.metric_values.map((e: any) => MetricValue.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: MetricValueSet): MetricValueSetSDKType { + const obj: any = {}; + obj.metric_name = message.metricName; + if (message.metricValues) { + obj.metric_values = message.metricValues.map(e => e ? MetricValue.toSDK(e) : undefined); + } else { + obj.metric_values = []; + } + return obj; + }, + fromAmino(object: MetricValueSetAmino): MetricValueSet { + const message = createBaseMetricValueSet(); + if (object.metric_name !== undefined && object.metric_name !== null) { + message.metricName = object.metric_name; + } + message.metricValues = object.metric_values?.map(e => MetricValue.fromAmino(e)) || []; + return message; + }, + toAmino(message: MetricValueSet): MetricValueSetAmino { + const obj: any = {}; + obj.metric_name = message.metricName === "" ? undefined : message.metricName; + if (message.metricValues) { + obj.metric_values = message.metricValues.map(e => e ? MetricValue.toAmino(e) : undefined); + } else { + obj.metric_values = message.metricValues; + } + return obj; + }, + fromAminoMsg(object: MetricValueSetAminoMsg): MetricValueSet { + return MetricValueSet.fromAmino(object.value); + }, + fromProtoMsg(message: MetricValueSetProtoMsg): MetricValueSet { + return MetricValueSet.decode(message.value); + }, + toProto(message: MetricValueSet): Uint8Array { + return MetricValueSet.encode(message).finish(); + }, + toProtoMsg(message: MetricValueSet): MetricValueSetProtoMsg { + return { + typeUrl: "/google.api.servicecontrol.v1.MetricValueSet", + value: MetricValueSet.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/api/servicecontrol/v1/operation.ts b/__fixtures__/v-next/outputicjsdeps/google/api/servicecontrol/v1/operation.ts new file mode 100644 index 0000000000..717d7008f3 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/api/servicecontrol/v1/operation.ts @@ -0,0 +1,579 @@ +import { Timestamp, TimestampSDKType } from "../../../protobuf/timestamp.js"; +import { MetricValueSet, MetricValueSetSDKType } from "./metric_value.js"; +import { LogEntry, LogEntrySDKType } from "./log_entry.js"; +import { Any, AnySDKType } from "../../../protobuf/any.js"; +import { BinaryReader, BinaryWriter } from "../../../../binary.js"; +import { isSet, DeepPartial, toTimestamp, fromTimestamp, isObject } from "../../../../helpers.js"; +import { JsonSafe } from "../../../../json-safe.js"; +export const protobufPackage = "google.api.servicecontrol.v1"; +/** Defines the importance of the data contained in the operation. */ +export enum Operation_Importance { + /** + * LOW - Allows data caching, batching, and aggregation. It provides + * higher performance with higher data loss risk. + */ + LOW = 0, + /** + * HIGH - Disables data aggregation to minimize data loss. It is for operations + * that contains significant monetary value or audit trail. This feature + * only applies to the client libraries. + */ + HIGH = 1, + UNRECOGNIZED = -1, +} +export const Operation_ImportanceSDKType = Operation_Importance; +export function operation_ImportanceFromJSON(object: any): Operation_Importance { + switch (object) { + case 0: + case "LOW": + return Operation_Importance.LOW; + case 1: + case "HIGH": + return Operation_Importance.HIGH; + case -1: + case "UNRECOGNIZED": + default: + return Operation_Importance.UNRECOGNIZED; + } +} +export function operation_ImportanceToJSON(object: Operation_Importance): string { + switch (object) { + case Operation_Importance.LOW: + return "LOW"; + case Operation_Importance.HIGH: + return "HIGH"; + case Operation_Importance.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +export interface Operation_LabelsEntry { + key: string; + value: string; +} +export interface Operation_LabelsEntryProtoMsg { + typeUrl: string; + value: Uint8Array; +} +export interface Operation_LabelsEntrySDKType { + key: string; + value: string; +} +/** Represents information regarding an operation. */ +export interface Operation { + /** + * Identity of the operation. This must be unique within the scope of the + * service that generated the operation. If the service calls + * Check() and Report() on the same operation, the two calls should carry + * the same id. + * + * UUID version 4 is recommended, though not required. + * In scenarios where an operation is computed from existing information + * and an idempotent id is desirable for deduplication purpose, UUID version 5 + * is recommended. See RFC 4122 for details. + */ + operationId: string; + /** Fully qualified name of the operation. Reserved for future use. */ + operationName: string; + /** + * Identity of the consumer who is using the service. + * This field should be filled in for the operations initiated by a + * consumer, but not for service-initiated operations that are + * not related to a specific consumer. + * + * - This can be in one of the following formats: + * - project:PROJECT_ID, + * - project`_`number:PROJECT_NUMBER, + * - projects/PROJECT_ID or PROJECT_NUMBER, + * - folders/FOLDER_NUMBER, + * - organizations/ORGANIZATION_NUMBER, + * - api`_`key:API_KEY. + */ + consumerId: string; + /** Required. Start time of the operation. */ + startTime?: Date; + /** + * End time of the operation. + * Required when the operation is used in + * [ServiceController.Report][google.api.servicecontrol.v1.ServiceController.Report], + * but optional when the operation is used in + * [ServiceController.Check][google.api.servicecontrol.v1.ServiceController.Check]. + */ + endTime?: Date; + /** + * Labels describing the operation. Only the following labels are allowed: + * + * - Labels describing monitored resources as defined in + * the service configuration. + * - Default labels of metric values. When specified, labels defined in the + * metric value override these default. + * - The following labels defined by Google Cloud Platform: + * - `cloud.googleapis.com/location` describing the location where the + * operation happened, + * - `servicecontrol.googleapis.com/user_agent` describing the user agent + * of the API request, + * - `servicecontrol.googleapis.com/service_agent` describing the service + * used to handle the API request (e.g. ESP), + * - `servicecontrol.googleapis.com/platform` describing the platform + * where the API is served, such as App Engine, Compute Engine, or + * Kubernetes Engine. + */ + labels: { + [key: string]: string; + }; + /** + * Represents information about this operation. Each MetricValueSet + * corresponds to a metric defined in the service configuration. + * The data type used in the MetricValueSet must agree with + * the data type specified in the metric definition. + * + * Within a single operation, it is not allowed to have more than one + * MetricValue instances that have the same metric names and identical + * label value combinations. If a request has such duplicated MetricValue + * instances, the entire request is rejected with + * an invalid argument error. + */ + metricValueSets: MetricValueSet[]; + /** Represents information to be logged. */ + logEntries: LogEntry[]; + /** DO NOT USE. This is an experimental field. */ + importance: Operation_Importance; + /** Unimplemented. */ + extensions: Any[]; +} +export interface OperationProtoMsg { + typeUrl: "/google.api.servicecontrol.v1.Operation"; + value: Uint8Array; +} +/** Represents information regarding an operation. */ +export interface OperationSDKType { + operation_id: string; + operation_name: string; + consumer_id: string; + start_time?: Date; + end_time?: Date; + labels: { + [key: string]: string; + }; + metric_value_sets: MetricValueSetSDKType[]; + log_entries: LogEntrySDKType[]; + importance: Operation_Importance; + extensions: AnySDKType[]; +} +function createBaseOperation_LabelsEntry(): Operation_LabelsEntry { + return { + key: "", + value: "" + }; +} +export const Operation_LabelsEntry = { + encode(message: Operation_LabelsEntry, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.key !== undefined) { + writer.uint32(10).string(message.key); + } + if (message.value !== undefined) { + writer.uint32(18).string(message.value); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Operation_LabelsEntry { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseOperation_LabelsEntry(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.string(); + break; + case 2: + message.value = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Operation_LabelsEntry { + const obj = createBaseOperation_LabelsEntry(); + if (isSet(object.key)) obj.key = String(object.key); + if (isSet(object.value)) obj.value = String(object.value); + return obj; + }, + toJSON(message: Operation_LabelsEntry): JsonSafe { + const obj: any = {}; + message.key !== undefined && (obj.key = message.key); + message.value !== undefined && (obj.value = message.value); + return obj; + }, + fromPartial(object: DeepPartial): Operation_LabelsEntry { + const message = createBaseOperation_LabelsEntry(); + message.key = object.key ?? ""; + message.value = object.value ?? ""; + return message; + }, + fromSDK(object: Operation_LabelsEntrySDKType): Operation_LabelsEntry { + return { + key: object?.key, + value: object?.value + }; + }, + fromSDKJSON(object: any): Operation_LabelsEntrySDKType { + return { + key: isSet(object.key) ? String(object.key) : "", + value: isSet(object.value) ? String(object.value) : "" + }; + }, + toSDK(message: Operation_LabelsEntry): Operation_LabelsEntrySDKType { + const obj: any = {}; + obj.key = message.key; + obj.value = message.value; + return obj; + }, + fromAmino(object: Operation_LabelsEntryAmino): Operation_LabelsEntry { + const message = createBaseOperation_LabelsEntry(); + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } + if (object.value !== undefined && object.value !== null) { + message.value = object.value; + } + return message; + }, + toAmino(message: Operation_LabelsEntry): Operation_LabelsEntryAmino { + const obj: any = {}; + obj.key = message.key === "" ? undefined : message.key; + obj.value = message.value === "" ? undefined : message.value; + return obj; + }, + fromAminoMsg(object: Operation_LabelsEntryAminoMsg): Operation_LabelsEntry { + return Operation_LabelsEntry.fromAmino(object.value); + }, + fromProtoMsg(message: Operation_LabelsEntryProtoMsg): Operation_LabelsEntry { + return Operation_LabelsEntry.decode(message.value); + }, + toProto(message: Operation_LabelsEntry): Uint8Array { + return Operation_LabelsEntry.encode(message).finish(); + } +}; +function createBaseOperation(): Operation { + return { + operationId: "", + operationName: "", + consumerId: "", + startTime: undefined, + endTime: undefined, + labels: {}, + metricValueSets: [], + logEntries: [], + importance: 0, + extensions: [] + }; +} +export const Operation = { + typeUrl: "/google.api.servicecontrol.v1.Operation", + encode(message: Operation, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.operationId !== undefined) { + writer.uint32(10).string(message.operationId); + } + if (message.operationName !== undefined) { + writer.uint32(18).string(message.operationName); + } + if (message.consumerId !== undefined) { + writer.uint32(26).string(message.consumerId); + } + if (message.startTime !== undefined) { + Timestamp.encode(toTimestamp(message.startTime), writer.uint32(34).fork()).ldelim(); + } + if (message.endTime !== undefined) { + Timestamp.encode(toTimestamp(message.endTime), writer.uint32(42).fork()).ldelim(); + } + Object.entries(message.labels).forEach(([key, value]) => { + Operation_LabelsEntry.encode({ + key: (key as any), + value + }, writer.uint32(50).fork()).ldelim(); + }); + for (const v of message.metricValueSets) { + MetricValueSet.encode(v!, writer.uint32(58).fork()).ldelim(); + } + for (const v of message.logEntries) { + LogEntry.encode(v!, writer.uint32(66).fork()).ldelim(); + } + if (message.importance !== 0) { + writer.uint32(88).int32(message.importance); + } + for (const v of message.extensions) { + Any.encode(v!, writer.uint32(130).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Operation { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseOperation(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.operationId = reader.string(); + break; + case 2: + message.operationName = reader.string(); + break; + case 3: + message.consumerId = reader.string(); + break; + case 4: + message.startTime = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + break; + case 5: + message.endTime = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + break; + case 6: + const entry6 = Operation_LabelsEntry.decode(reader, reader.uint32()); + if (entry6.value !== undefined) { + message.labels[entry6.key] = entry6.value; + } + break; + case 7: + message.metricValueSets.push(MetricValueSet.decode(reader, reader.uint32())); + break; + case 8: + message.logEntries.push(LogEntry.decode(reader, reader.uint32())); + break; + case 11: + message.importance = (reader.int32() as any); + break; + case 16: + message.extensions.push(Any.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Operation { + const obj = createBaseOperation(); + if (isSet(object.operationId)) obj.operationId = String(object.operationId); + if (isSet(object.operationName)) obj.operationName = String(object.operationName); + if (isSet(object.consumerId)) obj.consumerId = String(object.consumerId); + if (isSet(object.startTime)) obj.startTime = new Date(object.startTime); + if (isSet(object.endTime)) obj.endTime = new Date(object.endTime); + if (isObject(object.labels)) obj.labels = Object.entries(object.labels).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + acc[key] = String(value); + return acc; + }, {}); + if (Array.isArray(object?.metricValueSets)) obj.metricValueSets = object.metricValueSets.map((e: any) => MetricValueSet.fromJSON(e)); + if (Array.isArray(object?.logEntries)) obj.logEntries = object.logEntries.map((e: any) => LogEntry.fromJSON(e)); + if (isSet(object.importance)) obj.importance = operation_ImportanceFromJSON(object.importance); + if (Array.isArray(object?.extensions)) obj.extensions = object.extensions.map((e: any) => Any.fromJSON(e)); + return obj; + }, + toJSON(message: Operation): JsonSafe { + const obj: any = {}; + message.operationId !== undefined && (obj.operationId = message.operationId); + message.operationName !== undefined && (obj.operationName = message.operationName); + message.consumerId !== undefined && (obj.consumerId = message.consumerId); + message.startTime !== undefined && (obj.startTime = message.startTime.toISOString()); + message.endTime !== undefined && (obj.endTime = message.endTime.toISOString()); + obj.labels = {}; + if (message.labels) { + Object.entries(message.labels).forEach(([k, v]) => { + obj.labels[k] = v; + }); + } + if (message.metricValueSets) { + obj.metricValueSets = message.metricValueSets.map(e => e ? MetricValueSet.toJSON(e) : undefined); + } else { + obj.metricValueSets = []; + } + if (message.logEntries) { + obj.logEntries = message.logEntries.map(e => e ? LogEntry.toJSON(e) : undefined); + } else { + obj.logEntries = []; + } + message.importance !== undefined && (obj.importance = operation_ImportanceToJSON(message.importance)); + if (message.extensions) { + obj.extensions = message.extensions.map(e => e ? Any.toJSON(e) : undefined); + } else { + obj.extensions = []; + } + return obj; + }, + fromPartial(object: DeepPartial): Operation { + const message = createBaseOperation(); + message.operationId = object.operationId ?? ""; + message.operationName = object.operationName ?? ""; + message.consumerId = object.consumerId ?? ""; + message.startTime = object.startTime ?? undefined; + message.endTime = object.endTime ?? undefined; + message.labels = Object.entries(object.labels ?? {}).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + if (value !== undefined) { + acc[key] = String(value); + } + return acc; + }, {}); + message.metricValueSets = object.metricValueSets?.map(e => MetricValueSet.fromPartial(e)) || []; + message.logEntries = object.logEntries?.map(e => LogEntry.fromPartial(e)) || []; + message.importance = object.importance ?? 0; + message.extensions = object.extensions?.map(e => Any.fromPartial(e)) || []; + return message; + }, + fromSDK(object: OperationSDKType): Operation { + return { + operationId: object?.operation_id, + operationName: object?.operation_name, + consumerId: object?.consumer_id, + startTime: object.start_time ?? undefined, + endTime: object.end_time ?? undefined, + labels: isObject(object.labels) ? Object.entries(object.labels).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + acc[key] = String(value); + return acc; + }, {}) : {}, + metricValueSets: Array.isArray(object?.metric_value_sets) ? object.metric_value_sets.map((e: any) => MetricValueSet.fromSDK(e)) : [], + logEntries: Array.isArray(object?.log_entries) ? object.log_entries.map((e: any) => LogEntry.fromSDK(e)) : [], + importance: isSet(object.importance) ? operation_ImportanceFromJSON(object.importance) : -1, + extensions: Array.isArray(object?.extensions) ? object.extensions.map((e: any) => Any.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): OperationSDKType { + return { + operation_id: isSet(object.operation_id) ? String(object.operation_id) : "", + operation_name: isSet(object.operation_name) ? String(object.operation_name) : "", + consumer_id: isSet(object.consumer_id) ? String(object.consumer_id) : "", + start_time: isSet(object.start_time) ? new Date(object.start_time) : undefined, + end_time: isSet(object.end_time) ? new Date(object.end_time) : undefined, + labels: isObject(object.labels) ? Object.entries(object.labels).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + acc[key] = String(value); + return acc; + }, {}) : {}, + metric_value_sets: Array.isArray(object?.metric_value_sets) ? object.metric_value_sets.map((e: any) => MetricValueSet.fromSDKJSON(e)) : [], + log_entries: Array.isArray(object?.log_entries) ? object.log_entries.map((e: any) => LogEntry.fromSDKJSON(e)) : [], + importance: isSet(object.importance) ? operation_ImportanceFromJSON(object.importance) : -1, + extensions: Array.isArray(object?.extensions) ? object.extensions.map((e: any) => Any.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: Operation): OperationSDKType { + const obj: any = {}; + obj.operation_id = message.operationId; + obj.operation_name = message.operationName; + obj.consumer_id = message.consumerId; + message.startTime !== undefined && (obj.start_time = message.startTime ?? undefined); + message.endTime !== undefined && (obj.end_time = message.endTime ?? undefined); + obj.labels = {}; + if (message.labels) { + Object.entries(message.labels).forEach(([k, v]) => { + obj.labels[k] = v; + }); + } + if (message.metricValueSets) { + obj.metric_value_sets = message.metricValueSets.map(e => e ? MetricValueSet.toSDK(e) : undefined); + } else { + obj.metric_value_sets = []; + } + if (message.logEntries) { + obj.log_entries = message.logEntries.map(e => e ? LogEntry.toSDK(e) : undefined); + } else { + obj.log_entries = []; + } + message.importance !== undefined && (obj.importance = operation_ImportanceToJSON(message.importance)); + if (message.extensions) { + obj.extensions = message.extensions.map(e => e ? Any.toSDK(e) : undefined); + } else { + obj.extensions = []; + } + return obj; + }, + fromAmino(object: OperationAmino): Operation { + const message = createBaseOperation(); + if (object.operation_id !== undefined && object.operation_id !== null) { + message.operationId = object.operation_id; + } + if (object.operation_name !== undefined && object.operation_name !== null) { + message.operationName = object.operation_name; + } + if (object.consumer_id !== undefined && object.consumer_id !== null) { + message.consumerId = object.consumer_id; + } + if (object.start_time !== undefined && object.start_time !== null) { + message.startTime = fromTimestamp(Timestamp.fromAmino(object.start_time)); + } + if (object.end_time !== undefined && object.end_time !== null) { + message.endTime = fromTimestamp(Timestamp.fromAmino(object.end_time)); + } + message.labels = Object.entries(object.labels ?? {}).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + if (value !== undefined) { + acc[key] = String(value); + } + return acc; + }, {}); + message.metricValueSets = object.metric_value_sets?.map(e => MetricValueSet.fromAmino(e)) || []; + message.logEntries = object.log_entries?.map(e => LogEntry.fromAmino(e)) || []; + if (object.importance !== undefined && object.importance !== null) { + message.importance = object.importance; + } + message.extensions = object.extensions?.map(e => Any.fromAmino(e)) || []; + return message; + }, + toAmino(message: Operation): OperationAmino { + const obj: any = {}; + obj.operation_id = message.operationId === "" ? undefined : message.operationId; + obj.operation_name = message.operationName === "" ? undefined : message.operationName; + obj.consumer_id = message.consumerId === "" ? undefined : message.consumerId; + obj.start_time = message.startTime ? Timestamp.toAmino(toTimestamp(message.startTime)) : undefined; + obj.end_time = message.endTime ? Timestamp.toAmino(toTimestamp(message.endTime)) : undefined; + obj.labels = {}; + if (message.labels) { + Object.entries(message.labels).forEach(([k, v]) => { + obj.labels[k] = v; + }); + } + if (message.metricValueSets) { + obj.metric_value_sets = message.metricValueSets.map(e => e ? MetricValueSet.toAmino(e) : undefined); + } else { + obj.metric_value_sets = message.metricValueSets; + } + if (message.logEntries) { + obj.log_entries = message.logEntries.map(e => e ? LogEntry.toAmino(e) : undefined); + } else { + obj.log_entries = message.logEntries; + } + obj.importance = message.importance === 0 ? undefined : message.importance; + if (message.extensions) { + obj.extensions = message.extensions.map(e => e ? Any.toAmino(e) : undefined); + } else { + obj.extensions = message.extensions; + } + return obj; + }, + fromAminoMsg(object: OperationAminoMsg): Operation { + return Operation.fromAmino(object.value); + }, + fromProtoMsg(message: OperationProtoMsg): Operation { + return Operation.decode(message.value); + }, + toProto(message: Operation): Uint8Array { + return Operation.encode(message).finish(); + }, + toProtoMsg(message: Operation): OperationProtoMsg { + return { + typeUrl: "/google.api.servicecontrol.v1.Operation", + value: Operation.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/api/servicecontrol/v1/quota_controller.ts b/__fixtures__/v-next/outputicjsdeps/google/api/servicecontrol/v1/quota_controller.ts new file mode 100644 index 0000000000..70b2364f03 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/api/servicecontrol/v1/quota_controller.ts @@ -0,0 +1,1106 @@ +import { MetricValueSet, MetricValueSetSDKType } from "./metric_value.js"; +import { Status, StatusSDKType } from "../../../rpc/status.js"; +import { BinaryReader, BinaryWriter } from "../../../../binary.js"; +import { isSet, DeepPartial, isObject } from "../../../../helpers.js"; +import { JsonSafe } from "../../../../json-safe.js"; +export const protobufPackage = "google.api.servicecontrol.v1"; +/** Supported quota modes. */ +export enum QuotaOperation_QuotaMode { + /** UNSPECIFIED - Guard against implicit default. Must not be used. */ + UNSPECIFIED = 0, + /** + * NORMAL - For AllocateQuota request, allocates quota for the amount specified in + * the service configuration or specified using the quota metrics. If the + * amount is higher than the available quota, allocation error will be + * returned and no quota will be allocated. + * If multiple quotas are part of the request, and one fails, none of the + * quotas are allocated or released. + */ + NORMAL = 1, + /** + * BEST_EFFORT - The operation allocates quota for the amount specified in the service + * configuration or specified using the quota metrics. If the amount is + * higher than the available quota, request does not fail but all available + * quota will be allocated. + * For rate quota, BEST_EFFORT will continue to deduct from other groups + * even if one does not have enough quota. For allocation, it will find the + * minimum available amount across all groups and deduct that amount from + * all the affected groups. + */ + BEST_EFFORT = 2, + /** + * CHECK_ONLY - For AllocateQuota request, only checks if there is enough quota + * available and does not change the available quota. No lock is placed on + * the available quota either. + */ + CHECK_ONLY = 3, + /** + * QUERY_ONLY - Unimplemented. When used in AllocateQuotaRequest, this returns the + * effective quota limit(s) in the response, and no quota check will be + * performed. Not supported for other requests, and even for + * AllocateQuotaRequest, this is currently supported only for allowlisted + * services. + */ + QUERY_ONLY = 4, + /** + * ADJUST_ONLY - The operation allocates quota for the amount specified in the service + * configuration or specified using the quota metrics. If the requested + * amount is higher than the available quota, request does not fail and + * remaining quota would become negative (going over the limit). + * Not supported for Rate Quota. + */ + ADJUST_ONLY = 5, + UNRECOGNIZED = -1, +} +export const QuotaOperation_QuotaModeSDKType = QuotaOperation_QuotaMode; +export function quotaOperation_QuotaModeFromJSON(object: any): QuotaOperation_QuotaMode { + switch (object) { + case 0: + case "UNSPECIFIED": + return QuotaOperation_QuotaMode.UNSPECIFIED; + case 1: + case "NORMAL": + return QuotaOperation_QuotaMode.NORMAL; + case 2: + case "BEST_EFFORT": + return QuotaOperation_QuotaMode.BEST_EFFORT; + case 3: + case "CHECK_ONLY": + return QuotaOperation_QuotaMode.CHECK_ONLY; + case 4: + case "QUERY_ONLY": + return QuotaOperation_QuotaMode.QUERY_ONLY; + case 5: + case "ADJUST_ONLY": + return QuotaOperation_QuotaMode.ADJUST_ONLY; + case -1: + case "UNRECOGNIZED": + default: + return QuotaOperation_QuotaMode.UNRECOGNIZED; + } +} +export function quotaOperation_QuotaModeToJSON(object: QuotaOperation_QuotaMode): string { + switch (object) { + case QuotaOperation_QuotaMode.UNSPECIFIED: + return "UNSPECIFIED"; + case QuotaOperation_QuotaMode.NORMAL: + return "NORMAL"; + case QuotaOperation_QuotaMode.BEST_EFFORT: + return "BEST_EFFORT"; + case QuotaOperation_QuotaMode.CHECK_ONLY: + return "CHECK_ONLY"; + case QuotaOperation_QuotaMode.QUERY_ONLY: + return "QUERY_ONLY"; + case QuotaOperation_QuotaMode.ADJUST_ONLY: + return "ADJUST_ONLY"; + case QuotaOperation_QuotaMode.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** + * Error codes related to project config validations are deprecated since the + * quota controller methods do not perform these validations. Instead services + * have to call the Check method, without quota_properties field, to perform + * these validations before calling the quota controller methods. These + * methods check only for project deletion to be wipe out compliant. + */ +export enum QuotaError_Code { + /** UNSPECIFIED - This is never used. */ + UNSPECIFIED = 0, + /** + * RESOURCE_EXHAUSTED - Quota allocation failed. + * Same as [google.rpc.Code.RESOURCE_EXHAUSTED][google.rpc.Code.RESOURCE_EXHAUSTED]. + */ + RESOURCE_EXHAUSTED = 8, + /** + * BILLING_NOT_ACTIVE - Consumer cannot access the service because the service requires active + * billing. + */ + BILLING_NOT_ACTIVE = 107, + /** PROJECT_DELETED - Consumer's project has been marked as deleted (soft deletion). */ + PROJECT_DELETED = 108, + /** API_KEY_INVALID - Specified API key is invalid. */ + API_KEY_INVALID = 105, + /** API_KEY_EXPIRED - Specified API Key has expired. */ + API_KEY_EXPIRED = 112, + UNRECOGNIZED = -1, +} +export const QuotaError_CodeSDKType = QuotaError_Code; +export function quotaError_CodeFromJSON(object: any): QuotaError_Code { + switch (object) { + case 0: + case "UNSPECIFIED": + return QuotaError_Code.UNSPECIFIED; + case 8: + case "RESOURCE_EXHAUSTED": + return QuotaError_Code.RESOURCE_EXHAUSTED; + case 107: + case "BILLING_NOT_ACTIVE": + return QuotaError_Code.BILLING_NOT_ACTIVE; + case 108: + case "PROJECT_DELETED": + return QuotaError_Code.PROJECT_DELETED; + case 105: + case "API_KEY_INVALID": + return QuotaError_Code.API_KEY_INVALID; + case 112: + case "API_KEY_EXPIRED": + return QuotaError_Code.API_KEY_EXPIRED; + case -1: + case "UNRECOGNIZED": + default: + return QuotaError_Code.UNRECOGNIZED; + } +} +export function quotaError_CodeToJSON(object: QuotaError_Code): string { + switch (object) { + case QuotaError_Code.UNSPECIFIED: + return "UNSPECIFIED"; + case QuotaError_Code.RESOURCE_EXHAUSTED: + return "RESOURCE_EXHAUSTED"; + case QuotaError_Code.BILLING_NOT_ACTIVE: + return "BILLING_NOT_ACTIVE"; + case QuotaError_Code.PROJECT_DELETED: + return "PROJECT_DELETED"; + case QuotaError_Code.API_KEY_INVALID: + return "API_KEY_INVALID"; + case QuotaError_Code.API_KEY_EXPIRED: + return "API_KEY_EXPIRED"; + case QuotaError_Code.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** Request message for the AllocateQuota method. */ +export interface AllocateQuotaRequest { + /** + * Name of the service as specified in the service configuration. For example, + * `"pubsub.googleapis.com"`. + * + * See [google.api.Service][google.api.Service] for the definition of a service name. + */ + serviceName: string; + /** Operation that describes the quota allocation. */ + allocateOperation?: QuotaOperation; + /** + * Specifies which version of service configuration should be used to process + * the request. If unspecified or no matching version can be found, the latest + * one will be used. + */ + serviceConfigId: string; +} +export interface AllocateQuotaRequestProtoMsg { + typeUrl: "/google.api.servicecontrol.v1.AllocateQuotaRequest"; + value: Uint8Array; +} +/** Request message for the AllocateQuota method. */ +export interface AllocateQuotaRequestSDKType { + service_name: string; + allocate_operation?: QuotaOperationSDKType; + service_config_id: string; +} +export interface QuotaOperation_LabelsEntry { + key: string; + value: string; +} +export interface QuotaOperation_LabelsEntryProtoMsg { + typeUrl: string; + value: Uint8Array; +} +export interface QuotaOperation_LabelsEntrySDKType { + key: string; + value: string; +} +/** Represents information regarding a quota operation. */ +export interface QuotaOperation { + /** + * Identity of the operation. This is expected to be unique within the scope + * of the service that generated the operation, and guarantees idempotency in + * case of retries. + * + * In order to ensure best performance and latency in the Quota backends, + * operation_ids are optimally associated with time, so that related + * operations can be accessed fast in storage. For this reason, the + * recommended token for services that intend to operate at a high QPS is + * Unix time in nanos + UUID + */ + operationId: string; + /** + * Fully qualified name of the API method for which this quota operation is + * requested. This name is used for matching quota rules or metric rules and + * billing status rules defined in service configuration. + * + * This field should not be set if any of the following is true: + * (1) the quota operation is performed on non-API resources. + * (2) quota_metrics is set because the caller is doing quota override. + * + * + * Example of an RPC method name: + * google.example.library.v1.LibraryService.CreateShelf + */ + methodName: string; + /** + * Identity of the consumer for whom this quota operation is being performed. + * + * This can be in one of the following formats: + * project:, + * project_number:, + * api_key:. + */ + consumerId: string; + /** Labels describing the operation. */ + labels: { + [key: string]: string; + }; + /** + * Represents information about this operation. Each MetricValueSet + * corresponds to a metric defined in the service configuration. + * The data type used in the MetricValueSet must agree with + * the data type specified in the metric definition. + * + * Within a single operation, it is not allowed to have more than one + * MetricValue instances that have the same metric names and identical + * label value combinations. If a request has such duplicated MetricValue + * instances, the entire request is rejected with + * an invalid argument error. + * + * This field is mutually exclusive with method_name. + */ + quotaMetrics: MetricValueSet[]; + /** Quota mode for this operation. */ + quotaMode: QuotaOperation_QuotaMode; +} +export interface QuotaOperationProtoMsg { + typeUrl: "/google.api.servicecontrol.v1.QuotaOperation"; + value: Uint8Array; +} +/** Represents information regarding a quota operation. */ +export interface QuotaOperationSDKType { + operation_id: string; + method_name: string; + consumer_id: string; + labels: { + [key: string]: string; + }; + quota_metrics: MetricValueSetSDKType[]; + quota_mode: QuotaOperation_QuotaMode; +} +/** Response message for the AllocateQuota method. */ +export interface AllocateQuotaResponse { + /** + * The same operation_id value used in the AllocateQuotaRequest. Used for + * logging and diagnostics purposes. + */ + operationId: string; + /** Indicates the decision of the allocate. */ + allocateErrors: QuotaError[]; + /** + * Quota metrics to indicate the result of allocation. Depending on the + * request, one or more of the following metrics will be included: + * + * 1. Per quota group or per quota metric incremental usage will be specified + * using the following delta metric : + * "serviceruntime.googleapis.com/api/consumer/quota_used_count" + * + * 2. The quota limit reached condition will be specified using the following + * boolean metric : + * "serviceruntime.googleapis.com/quota/exceeded" + */ + quotaMetrics: MetricValueSet[]; + /** ID of the actual config used to process the request. */ + serviceConfigId: string; +} +export interface AllocateQuotaResponseProtoMsg { + typeUrl: "/google.api.servicecontrol.v1.AllocateQuotaResponse"; + value: Uint8Array; +} +/** Response message for the AllocateQuota method. */ +export interface AllocateQuotaResponseSDKType { + operation_id: string; + allocate_errors: QuotaErrorSDKType[]; + quota_metrics: MetricValueSetSDKType[]; + service_config_id: string; +} +/** Represents error information for [QuotaOperation][google.api.servicecontrol.v1.QuotaOperation]. */ +export interface QuotaError { + /** Error code. */ + code: QuotaError_Code; + /** + * Subject to whom this error applies. See the specific enum for more details + * on this field. For example, "clientip:" or + * "project:". + */ + subject: string; + /** Free-form text that provides details on the cause of the error. */ + description: string; + /** + * Contains additional information about the quota error. + * If available, `status.code` will be non zero. + */ + status?: Status; +} +export interface QuotaErrorProtoMsg { + typeUrl: "/google.api.servicecontrol.v1.QuotaError"; + value: Uint8Array; +} +/** Represents error information for [QuotaOperation][google.api.servicecontrol.v1.QuotaOperation]. */ +export interface QuotaErrorSDKType { + code: QuotaError_Code; + subject: string; + description: string; + status?: StatusSDKType; +} +function createBaseAllocateQuotaRequest(): AllocateQuotaRequest { + return { + serviceName: "", + allocateOperation: undefined, + serviceConfigId: "" + }; +} +export const AllocateQuotaRequest = { + typeUrl: "/google.api.servicecontrol.v1.AllocateQuotaRequest", + encode(message: AllocateQuotaRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.serviceName !== undefined) { + writer.uint32(10).string(message.serviceName); + } + if (message.allocateOperation !== undefined) { + QuotaOperation.encode(message.allocateOperation, writer.uint32(18).fork()).ldelim(); + } + if (message.serviceConfigId !== undefined) { + writer.uint32(34).string(message.serviceConfigId); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): AllocateQuotaRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseAllocateQuotaRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.serviceName = reader.string(); + break; + case 2: + message.allocateOperation = QuotaOperation.decode(reader, reader.uint32()); + break; + case 4: + message.serviceConfigId = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): AllocateQuotaRequest { + const obj = createBaseAllocateQuotaRequest(); + if (isSet(object.serviceName)) obj.serviceName = String(object.serviceName); + if (isSet(object.allocateOperation)) obj.allocateOperation = QuotaOperation.fromJSON(object.allocateOperation); + if (isSet(object.serviceConfigId)) obj.serviceConfigId = String(object.serviceConfigId); + return obj; + }, + toJSON(message: AllocateQuotaRequest): JsonSafe { + const obj: any = {}; + message.serviceName !== undefined && (obj.serviceName = message.serviceName); + message.allocateOperation !== undefined && (obj.allocateOperation = message.allocateOperation ? QuotaOperation.toJSON(message.allocateOperation) : undefined); + message.serviceConfigId !== undefined && (obj.serviceConfigId = message.serviceConfigId); + return obj; + }, + fromPartial(object: DeepPartial): AllocateQuotaRequest { + const message = createBaseAllocateQuotaRequest(); + message.serviceName = object.serviceName ?? ""; + if (object.allocateOperation !== undefined && object.allocateOperation !== null) { + message.allocateOperation = QuotaOperation.fromPartial(object.allocateOperation); + } + message.serviceConfigId = object.serviceConfigId ?? ""; + return message; + }, + fromSDK(object: AllocateQuotaRequestSDKType): AllocateQuotaRequest { + return { + serviceName: object?.service_name, + allocateOperation: object.allocate_operation ? QuotaOperation.fromSDK(object.allocate_operation) : undefined, + serviceConfigId: object?.service_config_id + }; + }, + fromSDKJSON(object: any): AllocateQuotaRequestSDKType { + return { + service_name: isSet(object.service_name) ? String(object.service_name) : "", + allocate_operation: isSet(object.allocate_operation) ? QuotaOperation.fromSDKJSON(object.allocate_operation) : undefined, + service_config_id: isSet(object.service_config_id) ? String(object.service_config_id) : "" + }; + }, + toSDK(message: AllocateQuotaRequest): AllocateQuotaRequestSDKType { + const obj: any = {}; + obj.service_name = message.serviceName; + message.allocateOperation !== undefined && (obj.allocate_operation = message.allocateOperation ? QuotaOperation.toSDK(message.allocateOperation) : undefined); + obj.service_config_id = message.serviceConfigId; + return obj; + }, + fromAmino(object: AllocateQuotaRequestAmino): AllocateQuotaRequest { + const message = createBaseAllocateQuotaRequest(); + if (object.service_name !== undefined && object.service_name !== null) { + message.serviceName = object.service_name; + } + if (object.allocate_operation !== undefined && object.allocate_operation !== null) { + message.allocateOperation = QuotaOperation.fromAmino(object.allocate_operation); + } + if (object.service_config_id !== undefined && object.service_config_id !== null) { + message.serviceConfigId = object.service_config_id; + } + return message; + }, + toAmino(message: AllocateQuotaRequest): AllocateQuotaRequestAmino { + const obj: any = {}; + obj.service_name = message.serviceName === "" ? undefined : message.serviceName; + obj.allocate_operation = message.allocateOperation ? QuotaOperation.toAmino(message.allocateOperation) : undefined; + obj.service_config_id = message.serviceConfigId === "" ? undefined : message.serviceConfigId; + return obj; + }, + fromAminoMsg(object: AllocateQuotaRequestAminoMsg): AllocateQuotaRequest { + return AllocateQuotaRequest.fromAmino(object.value); + }, + fromProtoMsg(message: AllocateQuotaRequestProtoMsg): AllocateQuotaRequest { + return AllocateQuotaRequest.decode(message.value); + }, + toProto(message: AllocateQuotaRequest): Uint8Array { + return AllocateQuotaRequest.encode(message).finish(); + }, + toProtoMsg(message: AllocateQuotaRequest): AllocateQuotaRequestProtoMsg { + return { + typeUrl: "/google.api.servicecontrol.v1.AllocateQuotaRequest", + value: AllocateQuotaRequest.encode(message).finish() + }; + } +}; +function createBaseQuotaOperation_LabelsEntry(): QuotaOperation_LabelsEntry { + return { + key: "", + value: "" + }; +} +export const QuotaOperation_LabelsEntry = { + encode(message: QuotaOperation_LabelsEntry, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.key !== undefined) { + writer.uint32(10).string(message.key); + } + if (message.value !== undefined) { + writer.uint32(18).string(message.value); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QuotaOperation_LabelsEntry { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQuotaOperation_LabelsEntry(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.string(); + break; + case 2: + message.value = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QuotaOperation_LabelsEntry { + const obj = createBaseQuotaOperation_LabelsEntry(); + if (isSet(object.key)) obj.key = String(object.key); + if (isSet(object.value)) obj.value = String(object.value); + return obj; + }, + toJSON(message: QuotaOperation_LabelsEntry): JsonSafe { + const obj: any = {}; + message.key !== undefined && (obj.key = message.key); + message.value !== undefined && (obj.value = message.value); + return obj; + }, + fromPartial(object: DeepPartial): QuotaOperation_LabelsEntry { + const message = createBaseQuotaOperation_LabelsEntry(); + message.key = object.key ?? ""; + message.value = object.value ?? ""; + return message; + }, + fromSDK(object: QuotaOperation_LabelsEntrySDKType): QuotaOperation_LabelsEntry { + return { + key: object?.key, + value: object?.value + }; + }, + fromSDKJSON(object: any): QuotaOperation_LabelsEntrySDKType { + return { + key: isSet(object.key) ? String(object.key) : "", + value: isSet(object.value) ? String(object.value) : "" + }; + }, + toSDK(message: QuotaOperation_LabelsEntry): QuotaOperation_LabelsEntrySDKType { + const obj: any = {}; + obj.key = message.key; + obj.value = message.value; + return obj; + }, + fromAmino(object: QuotaOperation_LabelsEntryAmino): QuotaOperation_LabelsEntry { + const message = createBaseQuotaOperation_LabelsEntry(); + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } + if (object.value !== undefined && object.value !== null) { + message.value = object.value; + } + return message; + }, + toAmino(message: QuotaOperation_LabelsEntry): QuotaOperation_LabelsEntryAmino { + const obj: any = {}; + obj.key = message.key === "" ? undefined : message.key; + obj.value = message.value === "" ? undefined : message.value; + return obj; + }, + fromAminoMsg(object: QuotaOperation_LabelsEntryAminoMsg): QuotaOperation_LabelsEntry { + return QuotaOperation_LabelsEntry.fromAmino(object.value); + }, + fromProtoMsg(message: QuotaOperation_LabelsEntryProtoMsg): QuotaOperation_LabelsEntry { + return QuotaOperation_LabelsEntry.decode(message.value); + }, + toProto(message: QuotaOperation_LabelsEntry): Uint8Array { + return QuotaOperation_LabelsEntry.encode(message).finish(); + } +}; +function createBaseQuotaOperation(): QuotaOperation { + return { + operationId: "", + methodName: "", + consumerId: "", + labels: {}, + quotaMetrics: [], + quotaMode: 0 + }; +} +export const QuotaOperation = { + typeUrl: "/google.api.servicecontrol.v1.QuotaOperation", + encode(message: QuotaOperation, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.operationId !== undefined) { + writer.uint32(10).string(message.operationId); + } + if (message.methodName !== undefined) { + writer.uint32(18).string(message.methodName); + } + if (message.consumerId !== undefined) { + writer.uint32(26).string(message.consumerId); + } + Object.entries(message.labels).forEach(([key, value]) => { + QuotaOperation_LabelsEntry.encode({ + key: (key as any), + value + }, writer.uint32(34).fork()).ldelim(); + }); + for (const v of message.quotaMetrics) { + MetricValueSet.encode(v!, writer.uint32(42).fork()).ldelim(); + } + if (message.quotaMode !== 0) { + writer.uint32(48).int32(message.quotaMode); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QuotaOperation { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQuotaOperation(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.operationId = reader.string(); + break; + case 2: + message.methodName = reader.string(); + break; + case 3: + message.consumerId = reader.string(); + break; + case 4: + const entry4 = QuotaOperation_LabelsEntry.decode(reader, reader.uint32()); + if (entry4.value !== undefined) { + message.labels[entry4.key] = entry4.value; + } + break; + case 5: + message.quotaMetrics.push(MetricValueSet.decode(reader, reader.uint32())); + break; + case 6: + message.quotaMode = (reader.int32() as any); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QuotaOperation { + const obj = createBaseQuotaOperation(); + if (isSet(object.operationId)) obj.operationId = String(object.operationId); + if (isSet(object.methodName)) obj.methodName = String(object.methodName); + if (isSet(object.consumerId)) obj.consumerId = String(object.consumerId); + if (isObject(object.labels)) obj.labels = Object.entries(object.labels).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + acc[key] = String(value); + return acc; + }, {}); + if (Array.isArray(object?.quotaMetrics)) obj.quotaMetrics = object.quotaMetrics.map((e: any) => MetricValueSet.fromJSON(e)); + if (isSet(object.quotaMode)) obj.quotaMode = quotaOperation_QuotaModeFromJSON(object.quotaMode); + return obj; + }, + toJSON(message: QuotaOperation): JsonSafe { + const obj: any = {}; + message.operationId !== undefined && (obj.operationId = message.operationId); + message.methodName !== undefined && (obj.methodName = message.methodName); + message.consumerId !== undefined && (obj.consumerId = message.consumerId); + obj.labels = {}; + if (message.labels) { + Object.entries(message.labels).forEach(([k, v]) => { + obj.labels[k] = v; + }); + } + if (message.quotaMetrics) { + obj.quotaMetrics = message.quotaMetrics.map(e => e ? MetricValueSet.toJSON(e) : undefined); + } else { + obj.quotaMetrics = []; + } + message.quotaMode !== undefined && (obj.quotaMode = quotaOperation_QuotaModeToJSON(message.quotaMode)); + return obj; + }, + fromPartial(object: DeepPartial): QuotaOperation { + const message = createBaseQuotaOperation(); + message.operationId = object.operationId ?? ""; + message.methodName = object.methodName ?? ""; + message.consumerId = object.consumerId ?? ""; + message.labels = Object.entries(object.labels ?? {}).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + if (value !== undefined) { + acc[key] = String(value); + } + return acc; + }, {}); + message.quotaMetrics = object.quotaMetrics?.map(e => MetricValueSet.fromPartial(e)) || []; + message.quotaMode = object.quotaMode ?? 0; + return message; + }, + fromSDK(object: QuotaOperationSDKType): QuotaOperation { + return { + operationId: object?.operation_id, + methodName: object?.method_name, + consumerId: object?.consumer_id, + labels: isObject(object.labels) ? Object.entries(object.labels).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + acc[key] = String(value); + return acc; + }, {}) : {}, + quotaMetrics: Array.isArray(object?.quota_metrics) ? object.quota_metrics.map((e: any) => MetricValueSet.fromSDK(e)) : [], + quotaMode: isSet(object.quota_mode) ? quotaOperation_QuotaModeFromJSON(object.quota_mode) : -1 + }; + }, + fromSDKJSON(object: any): QuotaOperationSDKType { + return { + operation_id: isSet(object.operation_id) ? String(object.operation_id) : "", + method_name: isSet(object.method_name) ? String(object.method_name) : "", + consumer_id: isSet(object.consumer_id) ? String(object.consumer_id) : "", + labels: isObject(object.labels) ? Object.entries(object.labels).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + acc[key] = String(value); + return acc; + }, {}) : {}, + quota_metrics: Array.isArray(object?.quota_metrics) ? object.quota_metrics.map((e: any) => MetricValueSet.fromSDKJSON(e)) : [], + quota_mode: isSet(object.quota_mode) ? quotaOperation_QuotaModeFromJSON(object.quota_mode) : -1 + }; + }, + toSDK(message: QuotaOperation): QuotaOperationSDKType { + const obj: any = {}; + obj.operation_id = message.operationId; + obj.method_name = message.methodName; + obj.consumer_id = message.consumerId; + obj.labels = {}; + if (message.labels) { + Object.entries(message.labels).forEach(([k, v]) => { + obj.labels[k] = v; + }); + } + if (message.quotaMetrics) { + obj.quota_metrics = message.quotaMetrics.map(e => e ? MetricValueSet.toSDK(e) : undefined); + } else { + obj.quota_metrics = []; + } + message.quotaMode !== undefined && (obj.quota_mode = quotaOperation_QuotaModeToJSON(message.quotaMode)); + return obj; + }, + fromAmino(object: QuotaOperationAmino): QuotaOperation { + const message = createBaseQuotaOperation(); + if (object.operation_id !== undefined && object.operation_id !== null) { + message.operationId = object.operation_id; + } + if (object.method_name !== undefined && object.method_name !== null) { + message.methodName = object.method_name; + } + if (object.consumer_id !== undefined && object.consumer_id !== null) { + message.consumerId = object.consumer_id; + } + message.labels = Object.entries(object.labels ?? {}).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + if (value !== undefined) { + acc[key] = String(value); + } + return acc; + }, {}); + message.quotaMetrics = object.quota_metrics?.map(e => MetricValueSet.fromAmino(e)) || []; + if (object.quota_mode !== undefined && object.quota_mode !== null) { + message.quotaMode = object.quota_mode; + } + return message; + }, + toAmino(message: QuotaOperation): QuotaOperationAmino { + const obj: any = {}; + obj.operation_id = message.operationId === "" ? undefined : message.operationId; + obj.method_name = message.methodName === "" ? undefined : message.methodName; + obj.consumer_id = message.consumerId === "" ? undefined : message.consumerId; + obj.labels = {}; + if (message.labels) { + Object.entries(message.labels).forEach(([k, v]) => { + obj.labels[k] = v; + }); + } + if (message.quotaMetrics) { + obj.quota_metrics = message.quotaMetrics.map(e => e ? MetricValueSet.toAmino(e) : undefined); + } else { + obj.quota_metrics = message.quotaMetrics; + } + obj.quota_mode = message.quotaMode === 0 ? undefined : message.quotaMode; + return obj; + }, + fromAminoMsg(object: QuotaOperationAminoMsg): QuotaOperation { + return QuotaOperation.fromAmino(object.value); + }, + fromProtoMsg(message: QuotaOperationProtoMsg): QuotaOperation { + return QuotaOperation.decode(message.value); + }, + toProto(message: QuotaOperation): Uint8Array { + return QuotaOperation.encode(message).finish(); + }, + toProtoMsg(message: QuotaOperation): QuotaOperationProtoMsg { + return { + typeUrl: "/google.api.servicecontrol.v1.QuotaOperation", + value: QuotaOperation.encode(message).finish() + }; + } +}; +function createBaseAllocateQuotaResponse(): AllocateQuotaResponse { + return { + operationId: "", + allocateErrors: [], + quotaMetrics: [], + serviceConfigId: "" + }; +} +export const AllocateQuotaResponse = { + typeUrl: "/google.api.servicecontrol.v1.AllocateQuotaResponse", + encode(message: AllocateQuotaResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.operationId !== undefined) { + writer.uint32(10).string(message.operationId); + } + for (const v of message.allocateErrors) { + QuotaError.encode(v!, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.quotaMetrics) { + MetricValueSet.encode(v!, writer.uint32(26).fork()).ldelim(); + } + if (message.serviceConfigId !== undefined) { + writer.uint32(34).string(message.serviceConfigId); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): AllocateQuotaResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseAllocateQuotaResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.operationId = reader.string(); + break; + case 2: + message.allocateErrors.push(QuotaError.decode(reader, reader.uint32())); + break; + case 3: + message.quotaMetrics.push(MetricValueSet.decode(reader, reader.uint32())); + break; + case 4: + message.serviceConfigId = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): AllocateQuotaResponse { + const obj = createBaseAllocateQuotaResponse(); + if (isSet(object.operationId)) obj.operationId = String(object.operationId); + if (Array.isArray(object?.allocateErrors)) obj.allocateErrors = object.allocateErrors.map((e: any) => QuotaError.fromJSON(e)); + if (Array.isArray(object?.quotaMetrics)) obj.quotaMetrics = object.quotaMetrics.map((e: any) => MetricValueSet.fromJSON(e)); + if (isSet(object.serviceConfigId)) obj.serviceConfigId = String(object.serviceConfigId); + return obj; + }, + toJSON(message: AllocateQuotaResponse): JsonSafe { + const obj: any = {}; + message.operationId !== undefined && (obj.operationId = message.operationId); + if (message.allocateErrors) { + obj.allocateErrors = message.allocateErrors.map(e => e ? QuotaError.toJSON(e) : undefined); + } else { + obj.allocateErrors = []; + } + if (message.quotaMetrics) { + obj.quotaMetrics = message.quotaMetrics.map(e => e ? MetricValueSet.toJSON(e) : undefined); + } else { + obj.quotaMetrics = []; + } + message.serviceConfigId !== undefined && (obj.serviceConfigId = message.serviceConfigId); + return obj; + }, + fromPartial(object: DeepPartial): AllocateQuotaResponse { + const message = createBaseAllocateQuotaResponse(); + message.operationId = object.operationId ?? ""; + message.allocateErrors = object.allocateErrors?.map(e => QuotaError.fromPartial(e)) || []; + message.quotaMetrics = object.quotaMetrics?.map(e => MetricValueSet.fromPartial(e)) || []; + message.serviceConfigId = object.serviceConfigId ?? ""; + return message; + }, + fromSDK(object: AllocateQuotaResponseSDKType): AllocateQuotaResponse { + return { + operationId: object?.operation_id, + allocateErrors: Array.isArray(object?.allocate_errors) ? object.allocate_errors.map((e: any) => QuotaError.fromSDK(e)) : [], + quotaMetrics: Array.isArray(object?.quota_metrics) ? object.quota_metrics.map((e: any) => MetricValueSet.fromSDK(e)) : [], + serviceConfigId: object?.service_config_id + }; + }, + fromSDKJSON(object: any): AllocateQuotaResponseSDKType { + return { + operation_id: isSet(object.operation_id) ? String(object.operation_id) : "", + allocate_errors: Array.isArray(object?.allocate_errors) ? object.allocate_errors.map((e: any) => QuotaError.fromSDKJSON(e)) : [], + quota_metrics: Array.isArray(object?.quota_metrics) ? object.quota_metrics.map((e: any) => MetricValueSet.fromSDKJSON(e)) : [], + service_config_id: isSet(object.service_config_id) ? String(object.service_config_id) : "" + }; + }, + toSDK(message: AllocateQuotaResponse): AllocateQuotaResponseSDKType { + const obj: any = {}; + obj.operation_id = message.operationId; + if (message.allocateErrors) { + obj.allocate_errors = message.allocateErrors.map(e => e ? QuotaError.toSDK(e) : undefined); + } else { + obj.allocate_errors = []; + } + if (message.quotaMetrics) { + obj.quota_metrics = message.quotaMetrics.map(e => e ? MetricValueSet.toSDK(e) : undefined); + } else { + obj.quota_metrics = []; + } + obj.service_config_id = message.serviceConfigId; + return obj; + }, + fromAmino(object: AllocateQuotaResponseAmino): AllocateQuotaResponse { + const message = createBaseAllocateQuotaResponse(); + if (object.operation_id !== undefined && object.operation_id !== null) { + message.operationId = object.operation_id; + } + message.allocateErrors = object.allocate_errors?.map(e => QuotaError.fromAmino(e)) || []; + message.quotaMetrics = object.quota_metrics?.map(e => MetricValueSet.fromAmino(e)) || []; + if (object.service_config_id !== undefined && object.service_config_id !== null) { + message.serviceConfigId = object.service_config_id; + } + return message; + }, + toAmino(message: AllocateQuotaResponse): AllocateQuotaResponseAmino { + const obj: any = {}; + obj.operation_id = message.operationId === "" ? undefined : message.operationId; + if (message.allocateErrors) { + obj.allocate_errors = message.allocateErrors.map(e => e ? QuotaError.toAmino(e) : undefined); + } else { + obj.allocate_errors = message.allocateErrors; + } + if (message.quotaMetrics) { + obj.quota_metrics = message.quotaMetrics.map(e => e ? MetricValueSet.toAmino(e) : undefined); + } else { + obj.quota_metrics = message.quotaMetrics; + } + obj.service_config_id = message.serviceConfigId === "" ? undefined : message.serviceConfigId; + return obj; + }, + fromAminoMsg(object: AllocateQuotaResponseAminoMsg): AllocateQuotaResponse { + return AllocateQuotaResponse.fromAmino(object.value); + }, + fromProtoMsg(message: AllocateQuotaResponseProtoMsg): AllocateQuotaResponse { + return AllocateQuotaResponse.decode(message.value); + }, + toProto(message: AllocateQuotaResponse): Uint8Array { + return AllocateQuotaResponse.encode(message).finish(); + }, + toProtoMsg(message: AllocateQuotaResponse): AllocateQuotaResponseProtoMsg { + return { + typeUrl: "/google.api.servicecontrol.v1.AllocateQuotaResponse", + value: AllocateQuotaResponse.encode(message).finish() + }; + } +}; +function createBaseQuotaError(): QuotaError { + return { + code: 0, + subject: "", + description: "", + status: undefined + }; +} +export const QuotaError = { + typeUrl: "/google.api.servicecontrol.v1.QuotaError", + encode(message: QuotaError, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.code !== 0) { + writer.uint32(8).int32(message.code); + } + if (message.subject !== undefined) { + writer.uint32(18).string(message.subject); + } + if (message.description !== undefined) { + writer.uint32(26).string(message.description); + } + if (message.status !== undefined) { + Status.encode(message.status, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QuotaError { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQuotaError(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.code = (reader.int32() as any); + break; + case 2: + message.subject = reader.string(); + break; + case 3: + message.description = reader.string(); + break; + case 4: + message.status = Status.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QuotaError { + const obj = createBaseQuotaError(); + if (isSet(object.code)) obj.code = quotaError_CodeFromJSON(object.code); + if (isSet(object.subject)) obj.subject = String(object.subject); + if (isSet(object.description)) obj.description = String(object.description); + if (isSet(object.status)) obj.status = Status.fromJSON(object.status); + return obj; + }, + toJSON(message: QuotaError): JsonSafe { + const obj: any = {}; + message.code !== undefined && (obj.code = quotaError_CodeToJSON(message.code)); + message.subject !== undefined && (obj.subject = message.subject); + message.description !== undefined && (obj.description = message.description); + message.status !== undefined && (obj.status = message.status ? Status.toJSON(message.status) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): QuotaError { + const message = createBaseQuotaError(); + message.code = object.code ?? 0; + message.subject = object.subject ?? ""; + message.description = object.description ?? ""; + if (object.status !== undefined && object.status !== null) { + message.status = Status.fromPartial(object.status); + } + return message; + }, + fromSDK(object: QuotaErrorSDKType): QuotaError { + return { + code: isSet(object.code) ? quotaError_CodeFromJSON(object.code) : -1, + subject: object?.subject, + description: object?.description, + status: object.status ? Status.fromSDK(object.status) : undefined + }; + }, + fromSDKJSON(object: any): QuotaErrorSDKType { + return { + code: isSet(object.code) ? quotaError_CodeFromJSON(object.code) : -1, + subject: isSet(object.subject) ? String(object.subject) : "", + description: isSet(object.description) ? String(object.description) : "", + status: isSet(object.status) ? Status.fromSDKJSON(object.status) : undefined + }; + }, + toSDK(message: QuotaError): QuotaErrorSDKType { + const obj: any = {}; + message.code !== undefined && (obj.code = quotaError_CodeToJSON(message.code)); + obj.subject = message.subject; + obj.description = message.description; + message.status !== undefined && (obj.status = message.status ? Status.toSDK(message.status) : undefined); + return obj; + }, + fromAmino(object: QuotaErrorAmino): QuotaError { + const message = createBaseQuotaError(); + if (object.code !== undefined && object.code !== null) { + message.code = object.code; + } + if (object.subject !== undefined && object.subject !== null) { + message.subject = object.subject; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } + if (object.status !== undefined && object.status !== null) { + message.status = Status.fromAmino(object.status); + } + return message; + }, + toAmino(message: QuotaError): QuotaErrorAmino { + const obj: any = {}; + obj.code = message.code === 0 ? undefined : message.code; + obj.subject = message.subject === "" ? undefined : message.subject; + obj.description = message.description === "" ? undefined : message.description; + obj.status = message.status ? Status.toAmino(message.status) : undefined; + return obj; + }, + fromAminoMsg(object: QuotaErrorAminoMsg): QuotaError { + return QuotaError.fromAmino(object.value); + }, + fromProtoMsg(message: QuotaErrorProtoMsg): QuotaError { + return QuotaError.decode(message.value); + }, + toProto(message: QuotaError): Uint8Array { + return QuotaError.encode(message).finish(); + }, + toProtoMsg(message: QuotaError): QuotaErrorProtoMsg { + return { + typeUrl: "/google.api.servicecontrol.v1.QuotaError", + value: QuotaError.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/api/servicecontrol/v1/service_controller.ts b/__fixtures__/v-next/outputicjsdeps/google/api/servicecontrol/v1/service_controller.ts new file mode 100644 index 0000000000..8acacf66a6 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/api/servicecontrol/v1/service_controller.ts @@ -0,0 +1,1201 @@ +import { Operation, OperationSDKType } from "./operation.js"; +import { CheckError, CheckErrorSDKType } from "./check_error.js"; +import { Status, StatusSDKType } from "../../../rpc/status.js"; +import { BinaryReader, BinaryWriter } from "../../../../binary.js"; +import { isSet, DeepPartial } from "../../../../helpers.js"; +import { JsonSafe } from "../../../../json-safe.js"; +export const protobufPackage = "google.api.servicecontrol.v1"; +/** + * The type of the consumer as defined in + * [Google Resource Manager](https://cloud.google.com/resource-manager/). + */ +export enum CheckResponse_ConsumerInfo_ConsumerType { + /** CONSUMER_TYPE_UNSPECIFIED - This is never used. */ + CONSUMER_TYPE_UNSPECIFIED = 0, + /** PROJECT - The consumer is a Google Cloud Project. */ + PROJECT = 1, + /** FOLDER - The consumer is a Google Cloud Folder. */ + FOLDER = 2, + /** ORGANIZATION - The consumer is a Google Cloud Organization. */ + ORGANIZATION = 3, + /** + * SERVICE_SPECIFIC - Service-specific resource container which is defined by the service + * producer to offer their users the ability to manage service control + * functionalities at a finer level of granularity than the PROJECT. + */ + SERVICE_SPECIFIC = 4, + UNRECOGNIZED = -1, +} +export const CheckResponse_ConsumerInfo_ConsumerTypeSDKType = CheckResponse_ConsumerInfo_ConsumerType; +export function checkResponse_ConsumerInfo_ConsumerTypeFromJSON(object: any): CheckResponse_ConsumerInfo_ConsumerType { + switch (object) { + case 0: + case "CONSUMER_TYPE_UNSPECIFIED": + return CheckResponse_ConsumerInfo_ConsumerType.CONSUMER_TYPE_UNSPECIFIED; + case 1: + case "PROJECT": + return CheckResponse_ConsumerInfo_ConsumerType.PROJECT; + case 2: + case "FOLDER": + return CheckResponse_ConsumerInfo_ConsumerType.FOLDER; + case 3: + case "ORGANIZATION": + return CheckResponse_ConsumerInfo_ConsumerType.ORGANIZATION; + case 4: + case "SERVICE_SPECIFIC": + return CheckResponse_ConsumerInfo_ConsumerType.SERVICE_SPECIFIC; + case -1: + case "UNRECOGNIZED": + default: + return CheckResponse_ConsumerInfo_ConsumerType.UNRECOGNIZED; + } +} +export function checkResponse_ConsumerInfo_ConsumerTypeToJSON(object: CheckResponse_ConsumerInfo_ConsumerType): string { + switch (object) { + case CheckResponse_ConsumerInfo_ConsumerType.CONSUMER_TYPE_UNSPECIFIED: + return "CONSUMER_TYPE_UNSPECIFIED"; + case CheckResponse_ConsumerInfo_ConsumerType.PROJECT: + return "PROJECT"; + case CheckResponse_ConsumerInfo_ConsumerType.FOLDER: + return "FOLDER"; + case CheckResponse_ConsumerInfo_ConsumerType.ORGANIZATION: + return "ORGANIZATION"; + case CheckResponse_ConsumerInfo_ConsumerType.SERVICE_SPECIFIC: + return "SERVICE_SPECIFIC"; + case CheckResponse_ConsumerInfo_ConsumerType.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** Request message for the Check method. */ +export interface CheckRequest { + /** + * The service name as specified in its service configuration. For example, + * `"pubsub.googleapis.com"`. + * + * See + * [google.api.Service](https://cloud.google.com/service-management/reference/rpc/google.api#google.api.Service) + * for the definition of a service name. + */ + serviceName: string; + /** The operation to be checked. */ + operation?: Operation; + /** + * Specifies which version of service configuration should be used to process + * the request. + * + * If unspecified or no matching version can be found, the + * latest one will be used. + */ + serviceConfigId: string; +} +export interface CheckRequestProtoMsg { + typeUrl: "/google.api.servicecontrol.v1.CheckRequest"; + value: Uint8Array; +} +/** Request message for the Check method. */ +export interface CheckRequestSDKType { + service_name: string; + operation?: OperationSDKType; + service_config_id: string; +} +/** Response message for the Check method. */ +export interface CheckResponse { + /** + * The same operation_id value used in the + * [CheckRequest][google.api.servicecontrol.v1.CheckRequest]. Used for logging + * and diagnostics purposes. + */ + operationId: string; + /** + * Indicate the decision of the check. + * + * If no check errors are present, the service should process the operation. + * Otherwise the service should use the list of errors to determine the + * appropriate action. + */ + checkErrors: CheckError[]; + /** The actual config id used to process the request. */ + serviceConfigId: string; + /** The current service rollout id used to process the request. */ + serviceRolloutId: string; + /** Feedback data returned from the server during processing a Check request. */ + checkInfo?: CheckResponse_CheckInfo; +} +export interface CheckResponseProtoMsg { + typeUrl: "/google.api.servicecontrol.v1.CheckResponse"; + value: Uint8Array; +} +/** Response message for the Check method. */ +export interface CheckResponseSDKType { + operation_id: string; + check_errors: CheckErrorSDKType[]; + service_config_id: string; + service_rollout_id: string; + check_info?: CheckResponse_CheckInfoSDKType; +} +/** Contains additional information about the check operation. */ +export interface CheckResponse_CheckInfo { + /** + * A list of fields and label keys that are ignored by the server. + * The client doesn't need to send them for following requests to improve + * performance and allow better aggregation. + */ + unusedArguments: string[]; + /** Consumer info of this check. */ + consumerInfo?: CheckResponse_ConsumerInfo; +} +export interface CheckResponse_CheckInfoProtoMsg { + typeUrl: "/google.api.servicecontrol.v1.CheckInfo"; + value: Uint8Array; +} +/** Contains additional information about the check operation. */ +export interface CheckResponse_CheckInfoSDKType { + unused_arguments: string[]; + consumer_info?: CheckResponse_ConsumerInfoSDKType; +} +/** `ConsumerInfo` provides information about the consumer. */ +export interface CheckResponse_ConsumerInfo { + /** + * The Google cloud project number, e.g. 1234567890. A value of 0 indicates + * no project number is found. + * + * NOTE: This field is deprecated after we support flexible consumer + * id. New code should not depend on this field anymore. + */ + projectNumber: bigint; + /** + * The type of the consumer which should have been defined in + * [Google Resource Manager](https://cloud.google.com/resource-manager/). + */ + type: CheckResponse_ConsumerInfo_ConsumerType; + /** + * The consumer identity number, can be Google cloud project number, folder + * number or organization number e.g. 1234567890. A value of 0 indicates no + * consumer number is found. + */ + consumerNumber: bigint; +} +export interface CheckResponse_ConsumerInfoProtoMsg { + typeUrl: "/google.api.servicecontrol.v1.ConsumerInfo"; + value: Uint8Array; +} +/** `ConsumerInfo` provides information about the consumer. */ +export interface CheckResponse_ConsumerInfoSDKType { + project_number: bigint; + type: CheckResponse_ConsumerInfo_ConsumerType; + consumer_number: bigint; +} +/** Request message for the Report method. */ +export interface ReportRequest { + /** + * The service name as specified in its service configuration. For example, + * `"pubsub.googleapis.com"`. + * + * See + * [google.api.Service](https://cloud.google.com/service-management/reference/rpc/google.api#google.api.Service) + * for the definition of a service name. + */ + serviceName: string; + /** + * Operations to be reported. + * + * Typically the service should report one operation per request. + * Putting multiple operations into a single request is allowed, but should + * be used only when multiple operations are natually available at the time + * of the report. + * + * There is no limit on the number of operations in the same ReportRequest, + * however the ReportRequest size should be no larger than 1MB. See + * [ReportResponse.report_errors][google.api.servicecontrol.v1.ReportResponse.report_errors] + * for partial failure behavior. + */ + operations: Operation[]; + /** + * Specifies which version of service config should be used to process the + * request. + * + * If unspecified or no matching version can be found, the + * latest one will be used. + */ + serviceConfigId: string; +} +export interface ReportRequestProtoMsg { + typeUrl: "/google.api.servicecontrol.v1.ReportRequest"; + value: Uint8Array; +} +/** Request message for the Report method. */ +export interface ReportRequestSDKType { + service_name: string; + operations: OperationSDKType[]; + service_config_id: string; +} +/** Response message for the Report method. */ +export interface ReportResponse { + /** + * Partial failures, one for each `Operation` in the request that failed + * processing. There are three possible combinations of the RPC status: + * + * 1. The combination of a successful RPC status and an empty `report_errors` + * list indicates a complete success where all `Operations` in the + * request are processed successfully. + * 2. The combination of a successful RPC status and a non-empty + * `report_errors` list indicates a partial success where some + * `Operations` in the request succeeded. Each + * `Operation` that failed processing has a corresponding item + * in this list. + * 3. A failed RPC status indicates a general non-deterministic failure. + * When this happens, it's impossible to know which of the + * 'Operations' in the request succeeded or failed. + */ + reportErrors: ReportResponse_ReportError[]; + /** The actual config id used to process the request. */ + serviceConfigId: string; + /** The current service rollout id used to process the request. */ + serviceRolloutId: string; +} +export interface ReportResponseProtoMsg { + typeUrl: "/google.api.servicecontrol.v1.ReportResponse"; + value: Uint8Array; +} +/** Response message for the Report method. */ +export interface ReportResponseSDKType { + report_errors: ReportResponse_ReportErrorSDKType[]; + service_config_id: string; + service_rollout_id: string; +} +/** + * Represents the processing error of one + * [Operation][google.api.servicecontrol.v1.Operation] in the request. + */ +export interface ReportResponse_ReportError { + /** + * The + * [Operation.operation_id][google.api.servicecontrol.v1.Operation.operation_id] + * value from the request. + */ + operationId: string; + /** + * Details of the error when processing the + * [Operation][google.api.servicecontrol.v1.Operation]. + */ + status?: Status; +} +export interface ReportResponse_ReportErrorProtoMsg { + typeUrl: "/google.api.servicecontrol.v1.ReportError"; + value: Uint8Array; +} +/** + * Represents the processing error of one + * [Operation][google.api.servicecontrol.v1.Operation] in the request. + */ +export interface ReportResponse_ReportErrorSDKType { + operation_id: string; + status?: StatusSDKType; +} +function createBaseCheckRequest(): CheckRequest { + return { + serviceName: "", + operation: undefined, + serviceConfigId: "" + }; +} +export const CheckRequest = { + typeUrl: "/google.api.servicecontrol.v1.CheckRequest", + encode(message: CheckRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.serviceName !== undefined) { + writer.uint32(10).string(message.serviceName); + } + if (message.operation !== undefined) { + Operation.encode(message.operation, writer.uint32(18).fork()).ldelim(); + } + if (message.serviceConfigId !== undefined) { + writer.uint32(34).string(message.serviceConfigId); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): CheckRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCheckRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.serviceName = reader.string(); + break; + case 2: + message.operation = Operation.decode(reader, reader.uint32()); + break; + case 4: + message.serviceConfigId = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): CheckRequest { + const obj = createBaseCheckRequest(); + if (isSet(object.serviceName)) obj.serviceName = String(object.serviceName); + if (isSet(object.operation)) obj.operation = Operation.fromJSON(object.operation); + if (isSet(object.serviceConfigId)) obj.serviceConfigId = String(object.serviceConfigId); + return obj; + }, + toJSON(message: CheckRequest): JsonSafe { + const obj: any = {}; + message.serviceName !== undefined && (obj.serviceName = message.serviceName); + message.operation !== undefined && (obj.operation = message.operation ? Operation.toJSON(message.operation) : undefined); + message.serviceConfigId !== undefined && (obj.serviceConfigId = message.serviceConfigId); + return obj; + }, + fromPartial(object: DeepPartial): CheckRequest { + const message = createBaseCheckRequest(); + message.serviceName = object.serviceName ?? ""; + if (object.operation !== undefined && object.operation !== null) { + message.operation = Operation.fromPartial(object.operation); + } + message.serviceConfigId = object.serviceConfigId ?? ""; + return message; + }, + fromSDK(object: CheckRequestSDKType): CheckRequest { + return { + serviceName: object?.service_name, + operation: object.operation ? Operation.fromSDK(object.operation) : undefined, + serviceConfigId: object?.service_config_id + }; + }, + fromSDKJSON(object: any): CheckRequestSDKType { + return { + service_name: isSet(object.service_name) ? String(object.service_name) : "", + operation: isSet(object.operation) ? Operation.fromSDKJSON(object.operation) : undefined, + service_config_id: isSet(object.service_config_id) ? String(object.service_config_id) : "" + }; + }, + toSDK(message: CheckRequest): CheckRequestSDKType { + const obj: any = {}; + obj.service_name = message.serviceName; + message.operation !== undefined && (obj.operation = message.operation ? Operation.toSDK(message.operation) : undefined); + obj.service_config_id = message.serviceConfigId; + return obj; + }, + fromAmino(object: CheckRequestAmino): CheckRequest { + const message = createBaseCheckRequest(); + if (object.service_name !== undefined && object.service_name !== null) { + message.serviceName = object.service_name; + } + if (object.operation !== undefined && object.operation !== null) { + message.operation = Operation.fromAmino(object.operation); + } + if (object.service_config_id !== undefined && object.service_config_id !== null) { + message.serviceConfigId = object.service_config_id; + } + return message; + }, + toAmino(message: CheckRequest): CheckRequestAmino { + const obj: any = {}; + obj.service_name = message.serviceName === "" ? undefined : message.serviceName; + obj.operation = message.operation ? Operation.toAmino(message.operation) : undefined; + obj.service_config_id = message.serviceConfigId === "" ? undefined : message.serviceConfigId; + return obj; + }, + fromAminoMsg(object: CheckRequestAminoMsg): CheckRequest { + return CheckRequest.fromAmino(object.value); + }, + fromProtoMsg(message: CheckRequestProtoMsg): CheckRequest { + return CheckRequest.decode(message.value); + }, + toProto(message: CheckRequest): Uint8Array { + return CheckRequest.encode(message).finish(); + }, + toProtoMsg(message: CheckRequest): CheckRequestProtoMsg { + return { + typeUrl: "/google.api.servicecontrol.v1.CheckRequest", + value: CheckRequest.encode(message).finish() + }; + } +}; +function createBaseCheckResponse(): CheckResponse { + return { + operationId: "", + checkErrors: [], + serviceConfigId: "", + serviceRolloutId: "", + checkInfo: undefined + }; +} +export const CheckResponse = { + typeUrl: "/google.api.servicecontrol.v1.CheckResponse", + encode(message: CheckResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.operationId !== undefined) { + writer.uint32(10).string(message.operationId); + } + for (const v of message.checkErrors) { + CheckError.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.serviceConfigId !== undefined) { + writer.uint32(42).string(message.serviceConfigId); + } + if (message.serviceRolloutId !== undefined) { + writer.uint32(90).string(message.serviceRolloutId); + } + if (message.checkInfo !== undefined) { + CheckResponse_CheckInfo.encode(message.checkInfo, writer.uint32(50).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): CheckResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCheckResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.operationId = reader.string(); + break; + case 2: + message.checkErrors.push(CheckError.decode(reader, reader.uint32())); + break; + case 5: + message.serviceConfigId = reader.string(); + break; + case 11: + message.serviceRolloutId = reader.string(); + break; + case 6: + message.checkInfo = CheckResponse_CheckInfo.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): CheckResponse { + const obj = createBaseCheckResponse(); + if (isSet(object.operationId)) obj.operationId = String(object.operationId); + if (Array.isArray(object?.checkErrors)) obj.checkErrors = object.checkErrors.map((e: any) => CheckError.fromJSON(e)); + if (isSet(object.serviceConfigId)) obj.serviceConfigId = String(object.serviceConfigId); + if (isSet(object.serviceRolloutId)) obj.serviceRolloutId = String(object.serviceRolloutId); + if (isSet(object.checkInfo)) obj.checkInfo = CheckResponse_CheckInfo.fromJSON(object.checkInfo); + return obj; + }, + toJSON(message: CheckResponse): JsonSafe { + const obj: any = {}; + message.operationId !== undefined && (obj.operationId = message.operationId); + if (message.checkErrors) { + obj.checkErrors = message.checkErrors.map(e => e ? CheckError.toJSON(e) : undefined); + } else { + obj.checkErrors = []; + } + message.serviceConfigId !== undefined && (obj.serviceConfigId = message.serviceConfigId); + message.serviceRolloutId !== undefined && (obj.serviceRolloutId = message.serviceRolloutId); + message.checkInfo !== undefined && (obj.checkInfo = message.checkInfo ? CheckResponse_CheckInfo.toJSON(message.checkInfo) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): CheckResponse { + const message = createBaseCheckResponse(); + message.operationId = object.operationId ?? ""; + message.checkErrors = object.checkErrors?.map(e => CheckError.fromPartial(e)) || []; + message.serviceConfigId = object.serviceConfigId ?? ""; + message.serviceRolloutId = object.serviceRolloutId ?? ""; + if (object.checkInfo !== undefined && object.checkInfo !== null) { + message.checkInfo = CheckResponse_CheckInfo.fromPartial(object.checkInfo); + } + return message; + }, + fromSDK(object: CheckResponseSDKType): CheckResponse { + return { + operationId: object?.operation_id, + checkErrors: Array.isArray(object?.check_errors) ? object.check_errors.map((e: any) => CheckError.fromSDK(e)) : [], + serviceConfigId: object?.service_config_id, + serviceRolloutId: object?.service_rollout_id, + checkInfo: object.check_info ? CheckResponse_CheckInfo.fromSDK(object.check_info) : undefined + }; + }, + fromSDKJSON(object: any): CheckResponseSDKType { + return { + operation_id: isSet(object.operation_id) ? String(object.operation_id) : "", + check_errors: Array.isArray(object?.check_errors) ? object.check_errors.map((e: any) => CheckError.fromSDKJSON(e)) : [], + service_config_id: isSet(object.service_config_id) ? String(object.service_config_id) : "", + service_rollout_id: isSet(object.service_rollout_id) ? String(object.service_rollout_id) : "", + check_info: isSet(object.check_info) ? CheckResponse_CheckInfo.fromSDKJSON(object.check_info) : undefined + }; + }, + toSDK(message: CheckResponse): CheckResponseSDKType { + const obj: any = {}; + obj.operation_id = message.operationId; + if (message.checkErrors) { + obj.check_errors = message.checkErrors.map(e => e ? CheckError.toSDK(e) : undefined); + } else { + obj.check_errors = []; + } + obj.service_config_id = message.serviceConfigId; + obj.service_rollout_id = message.serviceRolloutId; + message.checkInfo !== undefined && (obj.check_info = message.checkInfo ? CheckResponse_CheckInfo.toSDK(message.checkInfo) : undefined); + return obj; + }, + fromAmino(object: CheckResponseAmino): CheckResponse { + const message = createBaseCheckResponse(); + if (object.operation_id !== undefined && object.operation_id !== null) { + message.operationId = object.operation_id; + } + message.checkErrors = object.check_errors?.map(e => CheckError.fromAmino(e)) || []; + if (object.service_config_id !== undefined && object.service_config_id !== null) { + message.serviceConfigId = object.service_config_id; + } + if (object.service_rollout_id !== undefined && object.service_rollout_id !== null) { + message.serviceRolloutId = object.service_rollout_id; + } + if (object.check_info !== undefined && object.check_info !== null) { + message.checkInfo = CheckResponse_CheckInfo.fromAmino(object.check_info); + } + return message; + }, + toAmino(message: CheckResponse): CheckResponseAmino { + const obj: any = {}; + obj.operation_id = message.operationId === "" ? undefined : message.operationId; + if (message.checkErrors) { + obj.check_errors = message.checkErrors.map(e => e ? CheckError.toAmino(e) : undefined); + } else { + obj.check_errors = message.checkErrors; + } + obj.service_config_id = message.serviceConfigId === "" ? undefined : message.serviceConfigId; + obj.service_rollout_id = message.serviceRolloutId === "" ? undefined : message.serviceRolloutId; + obj.check_info = message.checkInfo ? CheckResponse_CheckInfo.toAmino(message.checkInfo) : undefined; + return obj; + }, + fromAminoMsg(object: CheckResponseAminoMsg): CheckResponse { + return CheckResponse.fromAmino(object.value); + }, + fromProtoMsg(message: CheckResponseProtoMsg): CheckResponse { + return CheckResponse.decode(message.value); + }, + toProto(message: CheckResponse): Uint8Array { + return CheckResponse.encode(message).finish(); + }, + toProtoMsg(message: CheckResponse): CheckResponseProtoMsg { + return { + typeUrl: "/google.api.servicecontrol.v1.CheckResponse", + value: CheckResponse.encode(message).finish() + }; + } +}; +function createBaseCheckResponse_CheckInfo(): CheckResponse_CheckInfo { + return { + unusedArguments: [], + consumerInfo: undefined + }; +} +export const CheckResponse_CheckInfo = { + typeUrl: "/google.api.servicecontrol.v1.CheckInfo", + encode(message: CheckResponse_CheckInfo, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.unusedArguments) { + writer.uint32(10).string(v!); + } + if (message.consumerInfo !== undefined) { + CheckResponse_ConsumerInfo.encode(message.consumerInfo, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): CheckResponse_CheckInfo { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCheckResponse_CheckInfo(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.unusedArguments.push(reader.string()); + break; + case 2: + message.consumerInfo = CheckResponse_ConsumerInfo.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): CheckResponse_CheckInfo { + const obj = createBaseCheckResponse_CheckInfo(); + if (Array.isArray(object?.unusedArguments)) obj.unusedArguments = object.unusedArguments.map((e: any) => String(e)); + if (isSet(object.consumerInfo)) obj.consumerInfo = CheckResponse_ConsumerInfo.fromJSON(object.consumerInfo); + return obj; + }, + toJSON(message: CheckResponse_CheckInfo): JsonSafe { + const obj: any = {}; + if (message.unusedArguments) { + obj.unusedArguments = message.unusedArguments.map(e => e); + } else { + obj.unusedArguments = []; + } + message.consumerInfo !== undefined && (obj.consumerInfo = message.consumerInfo ? CheckResponse_ConsumerInfo.toJSON(message.consumerInfo) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): CheckResponse_CheckInfo { + const message = createBaseCheckResponse_CheckInfo(); + message.unusedArguments = object.unusedArguments?.map(e => e) || []; + if (object.consumerInfo !== undefined && object.consumerInfo !== null) { + message.consumerInfo = CheckResponse_ConsumerInfo.fromPartial(object.consumerInfo); + } + return message; + }, + fromSDK(object: CheckResponse_CheckInfoSDKType): CheckResponse_CheckInfo { + return { + unusedArguments: Array.isArray(object?.unused_arguments) ? object.unused_arguments.map((e: any) => e) : [], + consumerInfo: object.consumer_info ? CheckResponse_ConsumerInfo.fromSDK(object.consumer_info) : undefined + }; + }, + fromSDKJSON(object: any): CheckResponse_CheckInfoSDKType { + return { + unused_arguments: Array.isArray(object?.unused_arguments) ? object.unused_arguments.map((e: any) => String(e)) : [], + consumer_info: isSet(object.consumer_info) ? CheckResponse_ConsumerInfo.fromSDKJSON(object.consumer_info) : undefined + }; + }, + toSDK(message: CheckResponse_CheckInfo): CheckResponse_CheckInfoSDKType { + const obj: any = {}; + if (message.unusedArguments) { + obj.unused_arguments = message.unusedArguments.map(e => e); + } else { + obj.unused_arguments = []; + } + message.consumerInfo !== undefined && (obj.consumer_info = message.consumerInfo ? CheckResponse_ConsumerInfo.toSDK(message.consumerInfo) : undefined); + return obj; + }, + fromAmino(object: CheckResponse_CheckInfoAmino): CheckResponse_CheckInfo { + const message = createBaseCheckResponse_CheckInfo(); + message.unusedArguments = object.unused_arguments?.map(e => e) || []; + if (object.consumer_info !== undefined && object.consumer_info !== null) { + message.consumerInfo = CheckResponse_ConsumerInfo.fromAmino(object.consumer_info); + } + return message; + }, + toAmino(message: CheckResponse_CheckInfo): CheckResponse_CheckInfoAmino { + const obj: any = {}; + if (message.unusedArguments) { + obj.unused_arguments = message.unusedArguments.map(e => e); + } else { + obj.unused_arguments = message.unusedArguments; + } + obj.consumer_info = message.consumerInfo ? CheckResponse_ConsumerInfo.toAmino(message.consumerInfo) : undefined; + return obj; + }, + fromAminoMsg(object: CheckResponse_CheckInfoAminoMsg): CheckResponse_CheckInfo { + return CheckResponse_CheckInfo.fromAmino(object.value); + }, + fromProtoMsg(message: CheckResponse_CheckInfoProtoMsg): CheckResponse_CheckInfo { + return CheckResponse_CheckInfo.decode(message.value); + }, + toProto(message: CheckResponse_CheckInfo): Uint8Array { + return CheckResponse_CheckInfo.encode(message).finish(); + }, + toProtoMsg(message: CheckResponse_CheckInfo): CheckResponse_CheckInfoProtoMsg { + return { + typeUrl: "/google.api.servicecontrol.v1.CheckInfo", + value: CheckResponse_CheckInfo.encode(message).finish() + }; + } +}; +function createBaseCheckResponse_ConsumerInfo(): CheckResponse_ConsumerInfo { + return { + projectNumber: BigInt(0), + type: 0, + consumerNumber: BigInt(0) + }; +} +export const CheckResponse_ConsumerInfo = { + typeUrl: "/google.api.servicecontrol.v1.ConsumerInfo", + encode(message: CheckResponse_ConsumerInfo, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.projectNumber !== undefined) { + writer.uint32(8).int64(message.projectNumber); + } + if (message.type !== 0) { + writer.uint32(16).int32(message.type); + } + if (message.consumerNumber !== undefined) { + writer.uint32(24).int64(message.consumerNumber); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): CheckResponse_ConsumerInfo { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCheckResponse_ConsumerInfo(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.projectNumber = reader.int64(); + break; + case 2: + message.type = (reader.int32() as any); + break; + case 3: + message.consumerNumber = reader.int64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): CheckResponse_ConsumerInfo { + const obj = createBaseCheckResponse_ConsumerInfo(); + if (isSet(object.projectNumber)) obj.projectNumber = BigInt(object.projectNumber.toString()); + if (isSet(object.type)) obj.type = checkResponse_ConsumerInfo_ConsumerTypeFromJSON(object.type); + if (isSet(object.consumerNumber)) obj.consumerNumber = BigInt(object.consumerNumber.toString()); + return obj; + }, + toJSON(message: CheckResponse_ConsumerInfo): JsonSafe { + const obj: any = {}; + message.projectNumber !== undefined && (obj.projectNumber = (message.projectNumber || BigInt(0)).toString()); + message.type !== undefined && (obj.type = checkResponse_ConsumerInfo_ConsumerTypeToJSON(message.type)); + message.consumerNumber !== undefined && (obj.consumerNumber = (message.consumerNumber || BigInt(0)).toString()); + return obj; + }, + fromPartial(object: DeepPartial): CheckResponse_ConsumerInfo { + const message = createBaseCheckResponse_ConsumerInfo(); + if (object.projectNumber !== undefined && object.projectNumber !== null) { + message.projectNumber = BigInt(object.projectNumber.toString()); + } + message.type = object.type ?? 0; + if (object.consumerNumber !== undefined && object.consumerNumber !== null) { + message.consumerNumber = BigInt(object.consumerNumber.toString()); + } + return message; + }, + fromSDK(object: CheckResponse_ConsumerInfoSDKType): CheckResponse_ConsumerInfo { + return { + projectNumber: object?.project_number, + type: isSet(object.type) ? checkResponse_ConsumerInfo_ConsumerTypeFromJSON(object.type) : -1, + consumerNumber: object?.consumer_number + }; + }, + fromSDKJSON(object: any): CheckResponse_ConsumerInfoSDKType { + return { + project_number: isSet(object.project_number) ? BigInt(object.project_number.toString()) : BigInt(0), + type: isSet(object.type) ? checkResponse_ConsumerInfo_ConsumerTypeFromJSON(object.type) : -1, + consumer_number: isSet(object.consumer_number) ? BigInt(object.consumer_number.toString()) : BigInt(0) + }; + }, + toSDK(message: CheckResponse_ConsumerInfo): CheckResponse_ConsumerInfoSDKType { + const obj: any = {}; + obj.project_number = message.projectNumber; + message.type !== undefined && (obj.type = checkResponse_ConsumerInfo_ConsumerTypeToJSON(message.type)); + obj.consumer_number = message.consumerNumber; + return obj; + }, + fromAmino(object: CheckResponse_ConsumerInfoAmino): CheckResponse_ConsumerInfo { + const message = createBaseCheckResponse_ConsumerInfo(); + if (object.project_number !== undefined && object.project_number !== null) { + message.projectNumber = BigInt(object.project_number); + } + if (object.type !== undefined && object.type !== null) { + message.type = object.type; + } + if (object.consumer_number !== undefined && object.consumer_number !== null) { + message.consumerNumber = BigInt(object.consumer_number); + } + return message; + }, + toAmino(message: CheckResponse_ConsumerInfo): CheckResponse_ConsumerInfoAmino { + const obj: any = {}; + obj.project_number = message.projectNumber !== BigInt(0) ? message.projectNumber?.toString() : undefined; + obj.type = message.type === 0 ? undefined : message.type; + obj.consumer_number = message.consumerNumber !== BigInt(0) ? message.consumerNumber?.toString() : undefined; + return obj; + }, + fromAminoMsg(object: CheckResponse_ConsumerInfoAminoMsg): CheckResponse_ConsumerInfo { + return CheckResponse_ConsumerInfo.fromAmino(object.value); + }, + fromProtoMsg(message: CheckResponse_ConsumerInfoProtoMsg): CheckResponse_ConsumerInfo { + return CheckResponse_ConsumerInfo.decode(message.value); + }, + toProto(message: CheckResponse_ConsumerInfo): Uint8Array { + return CheckResponse_ConsumerInfo.encode(message).finish(); + }, + toProtoMsg(message: CheckResponse_ConsumerInfo): CheckResponse_ConsumerInfoProtoMsg { + return { + typeUrl: "/google.api.servicecontrol.v1.ConsumerInfo", + value: CheckResponse_ConsumerInfo.encode(message).finish() + }; + } +}; +function createBaseReportRequest(): ReportRequest { + return { + serviceName: "", + operations: [], + serviceConfigId: "" + }; +} +export const ReportRequest = { + typeUrl: "/google.api.servicecontrol.v1.ReportRequest", + encode(message: ReportRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.serviceName !== undefined) { + writer.uint32(10).string(message.serviceName); + } + for (const v of message.operations) { + Operation.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.serviceConfigId !== undefined) { + writer.uint32(26).string(message.serviceConfigId); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ReportRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseReportRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.serviceName = reader.string(); + break; + case 2: + message.operations.push(Operation.decode(reader, reader.uint32())); + break; + case 3: + message.serviceConfigId = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ReportRequest { + const obj = createBaseReportRequest(); + if (isSet(object.serviceName)) obj.serviceName = String(object.serviceName); + if (Array.isArray(object?.operations)) obj.operations = object.operations.map((e: any) => Operation.fromJSON(e)); + if (isSet(object.serviceConfigId)) obj.serviceConfigId = String(object.serviceConfigId); + return obj; + }, + toJSON(message: ReportRequest): JsonSafe { + const obj: any = {}; + message.serviceName !== undefined && (obj.serviceName = message.serviceName); + if (message.operations) { + obj.operations = message.operations.map(e => e ? Operation.toJSON(e) : undefined); + } else { + obj.operations = []; + } + message.serviceConfigId !== undefined && (obj.serviceConfigId = message.serviceConfigId); + return obj; + }, + fromPartial(object: DeepPartial): ReportRequest { + const message = createBaseReportRequest(); + message.serviceName = object.serviceName ?? ""; + message.operations = object.operations?.map(e => Operation.fromPartial(e)) || []; + message.serviceConfigId = object.serviceConfigId ?? ""; + return message; + }, + fromSDK(object: ReportRequestSDKType): ReportRequest { + return { + serviceName: object?.service_name, + operations: Array.isArray(object?.operations) ? object.operations.map((e: any) => Operation.fromSDK(e)) : [], + serviceConfigId: object?.service_config_id + }; + }, + fromSDKJSON(object: any): ReportRequestSDKType { + return { + service_name: isSet(object.service_name) ? String(object.service_name) : "", + operations: Array.isArray(object?.operations) ? object.operations.map((e: any) => Operation.fromSDKJSON(e)) : [], + service_config_id: isSet(object.service_config_id) ? String(object.service_config_id) : "" + }; + }, + toSDK(message: ReportRequest): ReportRequestSDKType { + const obj: any = {}; + obj.service_name = message.serviceName; + if (message.operations) { + obj.operations = message.operations.map(e => e ? Operation.toSDK(e) : undefined); + } else { + obj.operations = []; + } + obj.service_config_id = message.serviceConfigId; + return obj; + }, + fromAmino(object: ReportRequestAmino): ReportRequest { + const message = createBaseReportRequest(); + if (object.service_name !== undefined && object.service_name !== null) { + message.serviceName = object.service_name; + } + message.operations = object.operations?.map(e => Operation.fromAmino(e)) || []; + if (object.service_config_id !== undefined && object.service_config_id !== null) { + message.serviceConfigId = object.service_config_id; + } + return message; + }, + toAmino(message: ReportRequest): ReportRequestAmino { + const obj: any = {}; + obj.service_name = message.serviceName === "" ? undefined : message.serviceName; + if (message.operations) { + obj.operations = message.operations.map(e => e ? Operation.toAmino(e) : undefined); + } else { + obj.operations = message.operations; + } + obj.service_config_id = message.serviceConfigId === "" ? undefined : message.serviceConfigId; + return obj; + }, + fromAminoMsg(object: ReportRequestAminoMsg): ReportRequest { + return ReportRequest.fromAmino(object.value); + }, + fromProtoMsg(message: ReportRequestProtoMsg): ReportRequest { + return ReportRequest.decode(message.value); + }, + toProto(message: ReportRequest): Uint8Array { + return ReportRequest.encode(message).finish(); + }, + toProtoMsg(message: ReportRequest): ReportRequestProtoMsg { + return { + typeUrl: "/google.api.servicecontrol.v1.ReportRequest", + value: ReportRequest.encode(message).finish() + }; + } +}; +function createBaseReportResponse(): ReportResponse { + return { + reportErrors: [], + serviceConfigId: "", + serviceRolloutId: "" + }; +} +export const ReportResponse = { + typeUrl: "/google.api.servicecontrol.v1.ReportResponse", + encode(message: ReportResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.reportErrors) { + ReportResponse_ReportError.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.serviceConfigId !== undefined) { + writer.uint32(18).string(message.serviceConfigId); + } + if (message.serviceRolloutId !== undefined) { + writer.uint32(34).string(message.serviceRolloutId); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ReportResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseReportResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.reportErrors.push(ReportResponse_ReportError.decode(reader, reader.uint32())); + break; + case 2: + message.serviceConfigId = reader.string(); + break; + case 4: + message.serviceRolloutId = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ReportResponse { + const obj = createBaseReportResponse(); + if (Array.isArray(object?.reportErrors)) obj.reportErrors = object.reportErrors.map((e: any) => ReportResponse_ReportError.fromJSON(e)); + if (isSet(object.serviceConfigId)) obj.serviceConfigId = String(object.serviceConfigId); + if (isSet(object.serviceRolloutId)) obj.serviceRolloutId = String(object.serviceRolloutId); + return obj; + }, + toJSON(message: ReportResponse): JsonSafe { + const obj: any = {}; + if (message.reportErrors) { + obj.reportErrors = message.reportErrors.map(e => e ? ReportResponse_ReportError.toJSON(e) : undefined); + } else { + obj.reportErrors = []; + } + message.serviceConfigId !== undefined && (obj.serviceConfigId = message.serviceConfigId); + message.serviceRolloutId !== undefined && (obj.serviceRolloutId = message.serviceRolloutId); + return obj; + }, + fromPartial(object: DeepPartial): ReportResponse { + const message = createBaseReportResponse(); + message.reportErrors = object.reportErrors?.map(e => ReportResponse_ReportError.fromPartial(e)) || []; + message.serviceConfigId = object.serviceConfigId ?? ""; + message.serviceRolloutId = object.serviceRolloutId ?? ""; + return message; + }, + fromSDK(object: ReportResponseSDKType): ReportResponse { + return { + reportErrors: Array.isArray(object?.report_errors) ? object.report_errors.map((e: any) => ReportResponse_ReportError.fromSDK(e)) : [], + serviceConfigId: object?.service_config_id, + serviceRolloutId: object?.service_rollout_id + }; + }, + fromSDKJSON(object: any): ReportResponseSDKType { + return { + report_errors: Array.isArray(object?.report_errors) ? object.report_errors.map((e: any) => ReportResponse_ReportError.fromSDKJSON(e)) : [], + service_config_id: isSet(object.service_config_id) ? String(object.service_config_id) : "", + service_rollout_id: isSet(object.service_rollout_id) ? String(object.service_rollout_id) : "" + }; + }, + toSDK(message: ReportResponse): ReportResponseSDKType { + const obj: any = {}; + if (message.reportErrors) { + obj.report_errors = message.reportErrors.map(e => e ? ReportResponse_ReportError.toSDK(e) : undefined); + } else { + obj.report_errors = []; + } + obj.service_config_id = message.serviceConfigId; + obj.service_rollout_id = message.serviceRolloutId; + return obj; + }, + fromAmino(object: ReportResponseAmino): ReportResponse { + const message = createBaseReportResponse(); + message.reportErrors = object.report_errors?.map(e => ReportResponse_ReportError.fromAmino(e)) || []; + if (object.service_config_id !== undefined && object.service_config_id !== null) { + message.serviceConfigId = object.service_config_id; + } + if (object.service_rollout_id !== undefined && object.service_rollout_id !== null) { + message.serviceRolloutId = object.service_rollout_id; + } + return message; + }, + toAmino(message: ReportResponse): ReportResponseAmino { + const obj: any = {}; + if (message.reportErrors) { + obj.report_errors = message.reportErrors.map(e => e ? ReportResponse_ReportError.toAmino(e) : undefined); + } else { + obj.report_errors = message.reportErrors; + } + obj.service_config_id = message.serviceConfigId === "" ? undefined : message.serviceConfigId; + obj.service_rollout_id = message.serviceRolloutId === "" ? undefined : message.serviceRolloutId; + return obj; + }, + fromAminoMsg(object: ReportResponseAminoMsg): ReportResponse { + return ReportResponse.fromAmino(object.value); + }, + fromProtoMsg(message: ReportResponseProtoMsg): ReportResponse { + return ReportResponse.decode(message.value); + }, + toProto(message: ReportResponse): Uint8Array { + return ReportResponse.encode(message).finish(); + }, + toProtoMsg(message: ReportResponse): ReportResponseProtoMsg { + return { + typeUrl: "/google.api.servicecontrol.v1.ReportResponse", + value: ReportResponse.encode(message).finish() + }; + } +}; +function createBaseReportResponse_ReportError(): ReportResponse_ReportError { + return { + operationId: "", + status: undefined + }; +} +export const ReportResponse_ReportError = { + typeUrl: "/google.api.servicecontrol.v1.ReportError", + encode(message: ReportResponse_ReportError, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.operationId !== undefined) { + writer.uint32(10).string(message.operationId); + } + if (message.status !== undefined) { + Status.encode(message.status, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ReportResponse_ReportError { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseReportResponse_ReportError(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.operationId = reader.string(); + break; + case 2: + message.status = Status.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ReportResponse_ReportError { + const obj = createBaseReportResponse_ReportError(); + if (isSet(object.operationId)) obj.operationId = String(object.operationId); + if (isSet(object.status)) obj.status = Status.fromJSON(object.status); + return obj; + }, + toJSON(message: ReportResponse_ReportError): JsonSafe { + const obj: any = {}; + message.operationId !== undefined && (obj.operationId = message.operationId); + message.status !== undefined && (obj.status = message.status ? Status.toJSON(message.status) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): ReportResponse_ReportError { + const message = createBaseReportResponse_ReportError(); + message.operationId = object.operationId ?? ""; + if (object.status !== undefined && object.status !== null) { + message.status = Status.fromPartial(object.status); + } + return message; + }, + fromSDK(object: ReportResponse_ReportErrorSDKType): ReportResponse_ReportError { + return { + operationId: object?.operation_id, + status: object.status ? Status.fromSDK(object.status) : undefined + }; + }, + fromSDKJSON(object: any): ReportResponse_ReportErrorSDKType { + return { + operation_id: isSet(object.operation_id) ? String(object.operation_id) : "", + status: isSet(object.status) ? Status.fromSDKJSON(object.status) : undefined + }; + }, + toSDK(message: ReportResponse_ReportError): ReportResponse_ReportErrorSDKType { + const obj: any = {}; + obj.operation_id = message.operationId; + message.status !== undefined && (obj.status = message.status ? Status.toSDK(message.status) : undefined); + return obj; + }, + fromAmino(object: ReportResponse_ReportErrorAmino): ReportResponse_ReportError { + const message = createBaseReportResponse_ReportError(); + if (object.operation_id !== undefined && object.operation_id !== null) { + message.operationId = object.operation_id; + } + if (object.status !== undefined && object.status !== null) { + message.status = Status.fromAmino(object.status); + } + return message; + }, + toAmino(message: ReportResponse_ReportError): ReportResponse_ReportErrorAmino { + const obj: any = {}; + obj.operation_id = message.operationId === "" ? undefined : message.operationId; + obj.status = message.status ? Status.toAmino(message.status) : undefined; + return obj; + }, + fromAminoMsg(object: ReportResponse_ReportErrorAminoMsg): ReportResponse_ReportError { + return ReportResponse_ReportError.fromAmino(object.value); + }, + fromProtoMsg(message: ReportResponse_ReportErrorProtoMsg): ReportResponse_ReportError { + return ReportResponse_ReportError.decode(message.value); + }, + toProto(message: ReportResponse_ReportError): Uint8Array { + return ReportResponse_ReportError.encode(message).finish(); + }, + toProtoMsg(message: ReportResponse_ReportError): ReportResponse_ReportErrorProtoMsg { + return { + typeUrl: "/google.api.servicecontrol.v1.ReportError", + value: ReportResponse_ReportError.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/api/servicecontrol/v2/service_controller.ts b/__fixtures__/v-next/outputicjsdeps/google/api/servicecontrol/v2/service_controller.ts new file mode 100644 index 0000000000..b629773762 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/api/servicecontrol/v2/service_controller.ts @@ -0,0 +1,944 @@ +import { AttributeContext, AttributeContextSDKType } from "../../../rpc/context/attribute_context.js"; +import { Status, StatusSDKType } from "../../../rpc/status.js"; +import { BinaryReader, BinaryWriter } from "../../../../binary.js"; +import { isSet, DeepPartial, isObject } from "../../../../helpers.js"; +import { JsonSafe } from "../../../../json-safe.js"; +export const protobufPackage = "google.api.servicecontrol.v2"; +/** Request message for the Check method. */ +export interface CheckRequest { + /** + * The service name as specified in its service configuration. For example, + * `"pubsub.googleapis.com"`. + * + * See + * [google.api.Service](https://cloud.google.com/service-management/reference/rpc/google.api#google.api.Service) + * for the definition of a service name. + */ + serviceName: string; + /** + * Specifies the version of the service configuration that should be used to + * process the request. Must not be empty. Set this field to 'latest' to + * specify using the latest configuration. + */ + serviceConfigId: string; + /** Describes attributes about the operation being executed by the service. */ + attributes?: AttributeContext; + /** Describes the resources and the policies applied to each resource. */ + resources: ResourceInfo[]; + /** Optional. Contains a comma-separated list of flags. */ + flags: string; +} +export interface CheckRequestProtoMsg { + typeUrl: "/google.api.servicecontrol.v2.CheckRequest"; + value: Uint8Array; +} +/** Request message for the Check method. */ +export interface CheckRequestSDKType { + service_name: string; + service_config_id: string; + attributes?: AttributeContextSDKType; + resources: ResourceInfoSDKType[]; + flags: string; +} +/** Describes a resource referenced in the request. */ +export interface ResourceInfo { + /** The name of the resource referenced in the request. */ + name: string; + /** The resource type in the format of "{service}/{kind}". */ + type: string; + /** + * The resource permission needed for this request. + * The format must be "{service}/{plural}.{verb}". + */ + permission: string; + /** + * Optional. The identifier of the container of this resource. For Google + * Cloud APIs, the resource container must be one of the following formats: + * - `projects/` + * - `folders/` + * - `organizations/` + * For the policy enforcement on the container level (VPCSC and Location + * Policy check), this field takes precedence on the container extracted from + * name when presents. + */ + container: string; + /** + * Optional. The location of the resource. The value must be a valid zone, + * region or multiregion. For example: "europe-west4" or + * "northamerica-northeast1-a" + */ + location: string; +} +export interface ResourceInfoProtoMsg { + typeUrl: "/google.api.servicecontrol.v2.ResourceInfo"; + value: Uint8Array; +} +/** Describes a resource referenced in the request. */ +export interface ResourceInfoSDKType { + name: string; + type: string; + permission: string; + container: string; + location: string; +} +export interface CheckResponse_HeadersEntry { + key: string; + value: string; +} +export interface CheckResponse_HeadersEntryProtoMsg { + typeUrl: string; + value: Uint8Array; +} +export interface CheckResponse_HeadersEntrySDKType { + key: string; + value: string; +} +/** Response message for the Check method. */ +export interface CheckResponse { + /** + * Operation is allowed when this field is not set. Any non-'OK' status + * indicates a denial; [google.rpc.Status.details][google.rpc.Status.details] + * would contain additional details about the denial. + */ + status?: Status; + /** Returns a set of request contexts generated from the `CheckRequest`. */ + headers: { + [key: string]: string; + }; +} +export interface CheckResponseProtoMsg { + typeUrl: "/google.api.servicecontrol.v2.CheckResponse"; + value: Uint8Array; +} +/** Response message for the Check method. */ +export interface CheckResponseSDKType { + status?: StatusSDKType; + headers: { + [key: string]: string; + }; +} +/** Request message for the Report method. */ +export interface ReportRequest { + /** + * The service name as specified in its service configuration. For example, + * `"pubsub.googleapis.com"`. + * + * See + * [google.api.Service](https://cloud.google.com/service-management/reference/rpc/google.api#google.api.Service) + * for the definition of a service name. + */ + serviceName: string; + /** + * Specifies the version of the service configuration that should be used to + * process the request. Must not be empty. Set this field to 'latest' to + * specify using the latest configuration. + */ + serviceConfigId: string; + /** + * Describes the list of operations to be reported. Each operation is + * represented as an AttributeContext, and contains all attributes around an + * API access. + */ + operations: AttributeContext[]; +} +export interface ReportRequestProtoMsg { + typeUrl: "/google.api.servicecontrol.v2.ReportRequest"; + value: Uint8Array; +} +/** Request message for the Report method. */ +export interface ReportRequestSDKType { + service_name: string; + service_config_id: string; + operations: AttributeContextSDKType[]; +} +/** + * Response message for the Report method. + * If the request contains any invalid data, the server returns an RPC error. + */ +export interface ReportResponse {} +export interface ReportResponseProtoMsg { + typeUrl: "/google.api.servicecontrol.v2.ReportResponse"; + value: Uint8Array; +} +/** + * Response message for the Report method. + * If the request contains any invalid data, the server returns an RPC error. + */ +export interface ReportResponseSDKType {} +function createBaseCheckRequest(): CheckRequest { + return { + serviceName: "", + serviceConfigId: "", + attributes: undefined, + resources: [], + flags: "" + }; +} +export const CheckRequest = { + typeUrl: "/google.api.servicecontrol.v2.CheckRequest", + encode(message: CheckRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.serviceName !== undefined) { + writer.uint32(10).string(message.serviceName); + } + if (message.serviceConfigId !== undefined) { + writer.uint32(18).string(message.serviceConfigId); + } + if (message.attributes !== undefined) { + AttributeContext.encode(message.attributes, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.resources) { + ResourceInfo.encode(v!, writer.uint32(34).fork()).ldelim(); + } + if (message.flags !== undefined) { + writer.uint32(42).string(message.flags); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): CheckRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCheckRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.serviceName = reader.string(); + break; + case 2: + message.serviceConfigId = reader.string(); + break; + case 3: + message.attributes = AttributeContext.decode(reader, reader.uint32()); + break; + case 4: + message.resources.push(ResourceInfo.decode(reader, reader.uint32())); + break; + case 5: + message.flags = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): CheckRequest { + const obj = createBaseCheckRequest(); + if (isSet(object.serviceName)) obj.serviceName = String(object.serviceName); + if (isSet(object.serviceConfigId)) obj.serviceConfigId = String(object.serviceConfigId); + if (isSet(object.attributes)) obj.attributes = AttributeContext.fromJSON(object.attributes); + if (Array.isArray(object?.resources)) obj.resources = object.resources.map((e: any) => ResourceInfo.fromJSON(e)); + if (isSet(object.flags)) obj.flags = String(object.flags); + return obj; + }, + toJSON(message: CheckRequest): JsonSafe { + const obj: any = {}; + message.serviceName !== undefined && (obj.serviceName = message.serviceName); + message.serviceConfigId !== undefined && (obj.serviceConfigId = message.serviceConfigId); + message.attributes !== undefined && (obj.attributes = message.attributes ? AttributeContext.toJSON(message.attributes) : undefined); + if (message.resources) { + obj.resources = message.resources.map(e => e ? ResourceInfo.toJSON(e) : undefined); + } else { + obj.resources = []; + } + message.flags !== undefined && (obj.flags = message.flags); + return obj; + }, + fromPartial(object: DeepPartial): CheckRequest { + const message = createBaseCheckRequest(); + message.serviceName = object.serviceName ?? ""; + message.serviceConfigId = object.serviceConfigId ?? ""; + if (object.attributes !== undefined && object.attributes !== null) { + message.attributes = AttributeContext.fromPartial(object.attributes); + } + message.resources = object.resources?.map(e => ResourceInfo.fromPartial(e)) || []; + message.flags = object.flags ?? ""; + return message; + }, + fromSDK(object: CheckRequestSDKType): CheckRequest { + return { + serviceName: object?.service_name, + serviceConfigId: object?.service_config_id, + attributes: object.attributes ? AttributeContext.fromSDK(object.attributes) : undefined, + resources: Array.isArray(object?.resources) ? object.resources.map((e: any) => ResourceInfo.fromSDK(e)) : [], + flags: object?.flags + }; + }, + fromSDKJSON(object: any): CheckRequestSDKType { + return { + service_name: isSet(object.service_name) ? String(object.service_name) : "", + service_config_id: isSet(object.service_config_id) ? String(object.service_config_id) : "", + attributes: isSet(object.attributes) ? AttributeContext.fromSDKJSON(object.attributes) : undefined, + resources: Array.isArray(object?.resources) ? object.resources.map((e: any) => ResourceInfo.fromSDKJSON(e)) : [], + flags: isSet(object.flags) ? String(object.flags) : "" + }; + }, + toSDK(message: CheckRequest): CheckRequestSDKType { + const obj: any = {}; + obj.service_name = message.serviceName; + obj.service_config_id = message.serviceConfigId; + message.attributes !== undefined && (obj.attributes = message.attributes ? AttributeContext.toSDK(message.attributes) : undefined); + if (message.resources) { + obj.resources = message.resources.map(e => e ? ResourceInfo.toSDK(e) : undefined); + } else { + obj.resources = []; + } + obj.flags = message.flags; + return obj; + }, + fromAmino(object: CheckRequestAmino): CheckRequest { + const message = createBaseCheckRequest(); + if (object.service_name !== undefined && object.service_name !== null) { + message.serviceName = object.service_name; + } + if (object.service_config_id !== undefined && object.service_config_id !== null) { + message.serviceConfigId = object.service_config_id; + } + if (object.attributes !== undefined && object.attributes !== null) { + message.attributes = AttributeContext.fromAmino(object.attributes); + } + message.resources = object.resources?.map(e => ResourceInfo.fromAmino(e)) || []; + if (object.flags !== undefined && object.flags !== null) { + message.flags = object.flags; + } + return message; + }, + toAmino(message: CheckRequest): CheckRequestAmino { + const obj: any = {}; + obj.service_name = message.serviceName === "" ? undefined : message.serviceName; + obj.service_config_id = message.serviceConfigId === "" ? undefined : message.serviceConfigId; + obj.attributes = message.attributes ? AttributeContext.toAmino(message.attributes) : undefined; + if (message.resources) { + obj.resources = message.resources.map(e => e ? ResourceInfo.toAmino(e) : undefined); + } else { + obj.resources = message.resources; + } + obj.flags = message.flags === "" ? undefined : message.flags; + return obj; + }, + fromAminoMsg(object: CheckRequestAminoMsg): CheckRequest { + return CheckRequest.fromAmino(object.value); + }, + fromProtoMsg(message: CheckRequestProtoMsg): CheckRequest { + return CheckRequest.decode(message.value); + }, + toProto(message: CheckRequest): Uint8Array { + return CheckRequest.encode(message).finish(); + }, + toProtoMsg(message: CheckRequest): CheckRequestProtoMsg { + return { + typeUrl: "/google.api.servicecontrol.v2.CheckRequest", + value: CheckRequest.encode(message).finish() + }; + } +}; +function createBaseResourceInfo(): ResourceInfo { + return { + name: "", + type: "", + permission: "", + container: "", + location: "" + }; +} +export const ResourceInfo = { + typeUrl: "/google.api.servicecontrol.v2.ResourceInfo", + encode(message: ResourceInfo, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + if (message.type !== undefined) { + writer.uint32(18).string(message.type); + } + if (message.permission !== undefined) { + writer.uint32(26).string(message.permission); + } + if (message.container !== undefined) { + writer.uint32(34).string(message.container); + } + if (message.location !== undefined) { + writer.uint32(42).string(message.location); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ResourceInfo { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseResourceInfo(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.type = reader.string(); + break; + case 3: + message.permission = reader.string(); + break; + case 4: + message.container = reader.string(); + break; + case 5: + message.location = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ResourceInfo { + const obj = createBaseResourceInfo(); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.type)) obj.type = String(object.type); + if (isSet(object.permission)) obj.permission = String(object.permission); + if (isSet(object.container)) obj.container = String(object.container); + if (isSet(object.location)) obj.location = String(object.location); + return obj; + }, + toJSON(message: ResourceInfo): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.type !== undefined && (obj.type = message.type); + message.permission !== undefined && (obj.permission = message.permission); + message.container !== undefined && (obj.container = message.container); + message.location !== undefined && (obj.location = message.location); + return obj; + }, + fromPartial(object: DeepPartial): ResourceInfo { + const message = createBaseResourceInfo(); + message.name = object.name ?? ""; + message.type = object.type ?? ""; + message.permission = object.permission ?? ""; + message.container = object.container ?? ""; + message.location = object.location ?? ""; + return message; + }, + fromSDK(object: ResourceInfoSDKType): ResourceInfo { + return { + name: object?.name, + type: object?.type, + permission: object?.permission, + container: object?.container, + location: object?.location + }; + }, + fromSDKJSON(object: any): ResourceInfoSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + type: isSet(object.type) ? String(object.type) : "", + permission: isSet(object.permission) ? String(object.permission) : "", + container: isSet(object.container) ? String(object.container) : "", + location: isSet(object.location) ? String(object.location) : "" + }; + }, + toSDK(message: ResourceInfo): ResourceInfoSDKType { + const obj: any = {}; + obj.name = message.name; + obj.type = message.type; + obj.permission = message.permission; + obj.container = message.container; + obj.location = message.location; + return obj; + }, + fromAmino(object: ResourceInfoAmino): ResourceInfo { + const message = createBaseResourceInfo(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + if (object.type !== undefined && object.type !== null) { + message.type = object.type; + } + if (object.permission !== undefined && object.permission !== null) { + message.permission = object.permission; + } + if (object.container !== undefined && object.container !== null) { + message.container = object.container; + } + if (object.location !== undefined && object.location !== null) { + message.location = object.location; + } + return message; + }, + toAmino(message: ResourceInfo): ResourceInfoAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + obj.type = message.type === "" ? undefined : message.type; + obj.permission = message.permission === "" ? undefined : message.permission; + obj.container = message.container === "" ? undefined : message.container; + obj.location = message.location === "" ? undefined : message.location; + return obj; + }, + fromAminoMsg(object: ResourceInfoAminoMsg): ResourceInfo { + return ResourceInfo.fromAmino(object.value); + }, + fromProtoMsg(message: ResourceInfoProtoMsg): ResourceInfo { + return ResourceInfo.decode(message.value); + }, + toProto(message: ResourceInfo): Uint8Array { + return ResourceInfo.encode(message).finish(); + }, + toProtoMsg(message: ResourceInfo): ResourceInfoProtoMsg { + return { + typeUrl: "/google.api.servicecontrol.v2.ResourceInfo", + value: ResourceInfo.encode(message).finish() + }; + } +}; +function createBaseCheckResponse_HeadersEntry(): CheckResponse_HeadersEntry { + return { + key: "", + value: "" + }; +} +export const CheckResponse_HeadersEntry = { + encode(message: CheckResponse_HeadersEntry, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.key !== undefined) { + writer.uint32(10).string(message.key); + } + if (message.value !== undefined) { + writer.uint32(18).string(message.value); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): CheckResponse_HeadersEntry { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCheckResponse_HeadersEntry(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.string(); + break; + case 2: + message.value = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): CheckResponse_HeadersEntry { + const obj = createBaseCheckResponse_HeadersEntry(); + if (isSet(object.key)) obj.key = String(object.key); + if (isSet(object.value)) obj.value = String(object.value); + return obj; + }, + toJSON(message: CheckResponse_HeadersEntry): JsonSafe { + const obj: any = {}; + message.key !== undefined && (obj.key = message.key); + message.value !== undefined && (obj.value = message.value); + return obj; + }, + fromPartial(object: DeepPartial): CheckResponse_HeadersEntry { + const message = createBaseCheckResponse_HeadersEntry(); + message.key = object.key ?? ""; + message.value = object.value ?? ""; + return message; + }, + fromSDK(object: CheckResponse_HeadersEntrySDKType): CheckResponse_HeadersEntry { + return { + key: object?.key, + value: object?.value + }; + }, + fromSDKJSON(object: any): CheckResponse_HeadersEntrySDKType { + return { + key: isSet(object.key) ? String(object.key) : "", + value: isSet(object.value) ? String(object.value) : "" + }; + }, + toSDK(message: CheckResponse_HeadersEntry): CheckResponse_HeadersEntrySDKType { + const obj: any = {}; + obj.key = message.key; + obj.value = message.value; + return obj; + }, + fromAmino(object: CheckResponse_HeadersEntryAmino): CheckResponse_HeadersEntry { + const message = createBaseCheckResponse_HeadersEntry(); + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } + if (object.value !== undefined && object.value !== null) { + message.value = object.value; + } + return message; + }, + toAmino(message: CheckResponse_HeadersEntry): CheckResponse_HeadersEntryAmino { + const obj: any = {}; + obj.key = message.key === "" ? undefined : message.key; + obj.value = message.value === "" ? undefined : message.value; + return obj; + }, + fromAminoMsg(object: CheckResponse_HeadersEntryAminoMsg): CheckResponse_HeadersEntry { + return CheckResponse_HeadersEntry.fromAmino(object.value); + }, + fromProtoMsg(message: CheckResponse_HeadersEntryProtoMsg): CheckResponse_HeadersEntry { + return CheckResponse_HeadersEntry.decode(message.value); + }, + toProto(message: CheckResponse_HeadersEntry): Uint8Array { + return CheckResponse_HeadersEntry.encode(message).finish(); + } +}; +function createBaseCheckResponse(): CheckResponse { + return { + status: undefined, + headers: {} + }; +} +export const CheckResponse = { + typeUrl: "/google.api.servicecontrol.v2.CheckResponse", + encode(message: CheckResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.status !== undefined) { + Status.encode(message.status, writer.uint32(10).fork()).ldelim(); + } + Object.entries(message.headers).forEach(([key, value]) => { + CheckResponse_HeadersEntry.encode({ + key: (key as any), + value + }, writer.uint32(18).fork()).ldelim(); + }); + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): CheckResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCheckResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.status = Status.decode(reader, reader.uint32()); + break; + case 2: + const entry2 = CheckResponse_HeadersEntry.decode(reader, reader.uint32()); + if (entry2.value !== undefined) { + message.headers[entry2.key] = entry2.value; + } + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): CheckResponse { + const obj = createBaseCheckResponse(); + if (isSet(object.status)) obj.status = Status.fromJSON(object.status); + if (isObject(object.headers)) obj.headers = Object.entries(object.headers).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + acc[key] = String(value); + return acc; + }, {}); + return obj; + }, + toJSON(message: CheckResponse): JsonSafe { + const obj: any = {}; + message.status !== undefined && (obj.status = message.status ? Status.toJSON(message.status) : undefined); + obj.headers = {}; + if (message.headers) { + Object.entries(message.headers).forEach(([k, v]) => { + obj.headers[k] = v; + }); + } + return obj; + }, + fromPartial(object: DeepPartial): CheckResponse { + const message = createBaseCheckResponse(); + if (object.status !== undefined && object.status !== null) { + message.status = Status.fromPartial(object.status); + } + message.headers = Object.entries(object.headers ?? {}).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + if (value !== undefined) { + acc[key] = String(value); + } + return acc; + }, {}); + return message; + }, + fromSDK(object: CheckResponseSDKType): CheckResponse { + return { + status: object.status ? Status.fromSDK(object.status) : undefined, + headers: isObject(object.headers) ? Object.entries(object.headers).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + acc[key] = String(value); + return acc; + }, {}) : {} + }; + }, + fromSDKJSON(object: any): CheckResponseSDKType { + return { + status: isSet(object.status) ? Status.fromSDKJSON(object.status) : undefined, + headers: isObject(object.headers) ? Object.entries(object.headers).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + acc[key] = String(value); + return acc; + }, {}) : {} + }; + }, + toSDK(message: CheckResponse): CheckResponseSDKType { + const obj: any = {}; + message.status !== undefined && (obj.status = message.status ? Status.toSDK(message.status) : undefined); + obj.headers = {}; + if (message.headers) { + Object.entries(message.headers).forEach(([k, v]) => { + obj.headers[k] = v; + }); + } + return obj; + }, + fromAmino(object: CheckResponseAmino): CheckResponse { + const message = createBaseCheckResponse(); + if (object.status !== undefined && object.status !== null) { + message.status = Status.fromAmino(object.status); + } + message.headers = Object.entries(object.headers ?? {}).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + if (value !== undefined) { + acc[key] = String(value); + } + return acc; + }, {}); + return message; + }, + toAmino(message: CheckResponse): CheckResponseAmino { + const obj: any = {}; + obj.status = message.status ? Status.toAmino(message.status) : undefined; + obj.headers = {}; + if (message.headers) { + Object.entries(message.headers).forEach(([k, v]) => { + obj.headers[k] = v; + }); + } + return obj; + }, + fromAminoMsg(object: CheckResponseAminoMsg): CheckResponse { + return CheckResponse.fromAmino(object.value); + }, + fromProtoMsg(message: CheckResponseProtoMsg): CheckResponse { + return CheckResponse.decode(message.value); + }, + toProto(message: CheckResponse): Uint8Array { + return CheckResponse.encode(message).finish(); + }, + toProtoMsg(message: CheckResponse): CheckResponseProtoMsg { + return { + typeUrl: "/google.api.servicecontrol.v2.CheckResponse", + value: CheckResponse.encode(message).finish() + }; + } +}; +function createBaseReportRequest(): ReportRequest { + return { + serviceName: "", + serviceConfigId: "", + operations: [] + }; +} +export const ReportRequest = { + typeUrl: "/google.api.servicecontrol.v2.ReportRequest", + encode(message: ReportRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.serviceName !== undefined) { + writer.uint32(10).string(message.serviceName); + } + if (message.serviceConfigId !== undefined) { + writer.uint32(18).string(message.serviceConfigId); + } + for (const v of message.operations) { + AttributeContext.encode(v!, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ReportRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseReportRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.serviceName = reader.string(); + break; + case 2: + message.serviceConfigId = reader.string(); + break; + case 3: + message.operations.push(AttributeContext.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ReportRequest { + const obj = createBaseReportRequest(); + if (isSet(object.serviceName)) obj.serviceName = String(object.serviceName); + if (isSet(object.serviceConfigId)) obj.serviceConfigId = String(object.serviceConfigId); + if (Array.isArray(object?.operations)) obj.operations = object.operations.map((e: any) => AttributeContext.fromJSON(e)); + return obj; + }, + toJSON(message: ReportRequest): JsonSafe { + const obj: any = {}; + message.serviceName !== undefined && (obj.serviceName = message.serviceName); + message.serviceConfigId !== undefined && (obj.serviceConfigId = message.serviceConfigId); + if (message.operations) { + obj.operations = message.operations.map(e => e ? AttributeContext.toJSON(e) : undefined); + } else { + obj.operations = []; + } + return obj; + }, + fromPartial(object: DeepPartial): ReportRequest { + const message = createBaseReportRequest(); + message.serviceName = object.serviceName ?? ""; + message.serviceConfigId = object.serviceConfigId ?? ""; + message.operations = object.operations?.map(e => AttributeContext.fromPartial(e)) || []; + return message; + }, + fromSDK(object: ReportRequestSDKType): ReportRequest { + return { + serviceName: object?.service_name, + serviceConfigId: object?.service_config_id, + operations: Array.isArray(object?.operations) ? object.operations.map((e: any) => AttributeContext.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): ReportRequestSDKType { + return { + service_name: isSet(object.service_name) ? String(object.service_name) : "", + service_config_id: isSet(object.service_config_id) ? String(object.service_config_id) : "", + operations: Array.isArray(object?.operations) ? object.operations.map((e: any) => AttributeContext.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: ReportRequest): ReportRequestSDKType { + const obj: any = {}; + obj.service_name = message.serviceName; + obj.service_config_id = message.serviceConfigId; + if (message.operations) { + obj.operations = message.operations.map(e => e ? AttributeContext.toSDK(e) : undefined); + } else { + obj.operations = []; + } + return obj; + }, + fromAmino(object: ReportRequestAmino): ReportRequest { + const message = createBaseReportRequest(); + if (object.service_name !== undefined && object.service_name !== null) { + message.serviceName = object.service_name; + } + if (object.service_config_id !== undefined && object.service_config_id !== null) { + message.serviceConfigId = object.service_config_id; + } + message.operations = object.operations?.map(e => AttributeContext.fromAmino(e)) || []; + return message; + }, + toAmino(message: ReportRequest): ReportRequestAmino { + const obj: any = {}; + obj.service_name = message.serviceName === "" ? undefined : message.serviceName; + obj.service_config_id = message.serviceConfigId === "" ? undefined : message.serviceConfigId; + if (message.operations) { + obj.operations = message.operations.map(e => e ? AttributeContext.toAmino(e) : undefined); + } else { + obj.operations = message.operations; + } + return obj; + }, + fromAminoMsg(object: ReportRequestAminoMsg): ReportRequest { + return ReportRequest.fromAmino(object.value); + }, + fromProtoMsg(message: ReportRequestProtoMsg): ReportRequest { + return ReportRequest.decode(message.value); + }, + toProto(message: ReportRequest): Uint8Array { + return ReportRequest.encode(message).finish(); + }, + toProtoMsg(message: ReportRequest): ReportRequestProtoMsg { + return { + typeUrl: "/google.api.servicecontrol.v2.ReportRequest", + value: ReportRequest.encode(message).finish() + }; + } +}; +function createBaseReportResponse(): ReportResponse { + return {}; +} +export const ReportResponse = { + typeUrl: "/google.api.servicecontrol.v2.ReportResponse", + encode(_: ReportResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ReportResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseReportResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): ReportResponse { + const obj = createBaseReportResponse(); + return obj; + }, + toJSON(_: ReportResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): ReportResponse { + const message = createBaseReportResponse(); + return message; + }, + fromSDK(_: ReportResponseSDKType): ReportResponse { + return {}; + }, + fromSDKJSON(_: any): ReportResponseSDKType { + return {}; + }, + toSDK(_: ReportResponse): ReportResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: ReportResponseAmino): ReportResponse { + const message = createBaseReportResponse(); + return message; + }, + toAmino(_: ReportResponse): ReportResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: ReportResponseAminoMsg): ReportResponse { + return ReportResponse.fromAmino(object.value); + }, + fromProtoMsg(message: ReportResponseProtoMsg): ReportResponse { + return ReportResponse.decode(message.value); + }, + toProto(message: ReportResponse): Uint8Array { + return ReportResponse.encode(message).finish(); + }, + toProtoMsg(message: ReportResponse): ReportResponseProtoMsg { + return { + typeUrl: "/google.api.servicecontrol.v2.ReportResponse", + value: ReportResponse.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/api/servicemanagement/v1/resources.ts b/__fixtures__/v-next/outputicjsdeps/google/api/servicemanagement/v1/resources.ts new file mode 100644 index 0000000000..17594c42ac --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/api/servicemanagement/v1/resources.ts @@ -0,0 +1,2010 @@ +import { Timestamp, TimestampSDKType } from "../../../protobuf/timestamp.js"; +import { ConfigChange, ConfigChangeSDKType } from "../../config_change.js"; +import { BinaryReader, BinaryWriter } from "../../../../binary.js"; +import { isSet, DeepPartial, toTimestamp, fromTimestamp, bytesFromBase64, base64FromBytes, isObject } from "../../../../helpers.js"; +import { JsonSafe } from "../../../../json-safe.js"; +export const protobufPackage = "google.api.servicemanagement.v1"; +/** Code describes the status of the operation (or one of its steps). */ +export enum OperationMetadata_Status { + /** STATUS_UNSPECIFIED - Unspecifed code. */ + STATUS_UNSPECIFIED = 0, + /** DONE - The operation or step has completed without errors. */ + DONE = 1, + /** NOT_STARTED - The operation or step has not started yet. */ + NOT_STARTED = 2, + /** IN_PROGRESS - The operation or step is in progress. */ + IN_PROGRESS = 3, + /** + * FAILED - The operation or step has completed with errors. If the operation is + * rollbackable, the rollback completed with errors too. + */ + FAILED = 4, + /** CANCELLED - The operation or step has completed with cancellation. */ + CANCELLED = 5, + UNRECOGNIZED = -1, +} +export const OperationMetadata_StatusSDKType = OperationMetadata_Status; +export function operationMetadata_StatusFromJSON(object: any): OperationMetadata_Status { + switch (object) { + case 0: + case "STATUS_UNSPECIFIED": + return OperationMetadata_Status.STATUS_UNSPECIFIED; + case 1: + case "DONE": + return OperationMetadata_Status.DONE; + case 2: + case "NOT_STARTED": + return OperationMetadata_Status.NOT_STARTED; + case 3: + case "IN_PROGRESS": + return OperationMetadata_Status.IN_PROGRESS; + case 4: + case "FAILED": + return OperationMetadata_Status.FAILED; + case 5: + case "CANCELLED": + return OperationMetadata_Status.CANCELLED; + case -1: + case "UNRECOGNIZED": + default: + return OperationMetadata_Status.UNRECOGNIZED; + } +} +export function operationMetadata_StatusToJSON(object: OperationMetadata_Status): string { + switch (object) { + case OperationMetadata_Status.STATUS_UNSPECIFIED: + return "STATUS_UNSPECIFIED"; + case OperationMetadata_Status.DONE: + return "DONE"; + case OperationMetadata_Status.NOT_STARTED: + return "NOT_STARTED"; + case OperationMetadata_Status.IN_PROGRESS: + return "IN_PROGRESS"; + case OperationMetadata_Status.FAILED: + return "FAILED"; + case OperationMetadata_Status.CANCELLED: + return "CANCELLED"; + case OperationMetadata_Status.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** The kind of diagnostic information possible. */ +export enum Diagnostic_Kind { + /** WARNING - Warnings and errors */ + WARNING = 0, + /** ERROR - Only errors */ + ERROR = 1, + UNRECOGNIZED = -1, +} +export const Diagnostic_KindSDKType = Diagnostic_Kind; +export function diagnostic_KindFromJSON(object: any): Diagnostic_Kind { + switch (object) { + case 0: + case "WARNING": + return Diagnostic_Kind.WARNING; + case 1: + case "ERROR": + return Diagnostic_Kind.ERROR; + case -1: + case "UNRECOGNIZED": + default: + return Diagnostic_Kind.UNRECOGNIZED; + } +} +export function diagnostic_KindToJSON(object: Diagnostic_Kind): string { + switch (object) { + case Diagnostic_Kind.WARNING: + return "WARNING"; + case Diagnostic_Kind.ERROR: + return "ERROR"; + case Diagnostic_Kind.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +export enum ConfigFile_FileType { + /** FILE_TYPE_UNSPECIFIED - Unknown file type. */ + FILE_TYPE_UNSPECIFIED = 0, + /** SERVICE_CONFIG_YAML - YAML-specification of service. */ + SERVICE_CONFIG_YAML = 1, + /** OPEN_API_JSON - OpenAPI specification, serialized in JSON. */ + OPEN_API_JSON = 2, + /** OPEN_API_YAML - OpenAPI specification, serialized in YAML. */ + OPEN_API_YAML = 3, + /** + * FILE_DESCRIPTOR_SET_PROTO - FileDescriptorSet, generated by protoc. + * + * To generate, use protoc with imports and source info included. + * For an example test.proto file, the following command would put the value + * in a new file named out.pb. + * + * $protoc --include_imports --include_source_info test.proto -o out.pb + */ + FILE_DESCRIPTOR_SET_PROTO = 4, + /** + * PROTO_FILE - Uncompiled Proto file. Used for storage and display purposes only, + * currently server-side compilation is not supported. Should match the + * inputs to 'protoc' command used to generated FILE_DESCRIPTOR_SET_PROTO. A + * file of this type can only be included if at least one file of type + * FILE_DESCRIPTOR_SET_PROTO is included. + */ + PROTO_FILE = 6, + UNRECOGNIZED = -1, +} +export const ConfigFile_FileTypeSDKType = ConfigFile_FileType; +export function configFile_FileTypeFromJSON(object: any): ConfigFile_FileType { + switch (object) { + case 0: + case "FILE_TYPE_UNSPECIFIED": + return ConfigFile_FileType.FILE_TYPE_UNSPECIFIED; + case 1: + case "SERVICE_CONFIG_YAML": + return ConfigFile_FileType.SERVICE_CONFIG_YAML; + case 2: + case "OPEN_API_JSON": + return ConfigFile_FileType.OPEN_API_JSON; + case 3: + case "OPEN_API_YAML": + return ConfigFile_FileType.OPEN_API_YAML; + case 4: + case "FILE_DESCRIPTOR_SET_PROTO": + return ConfigFile_FileType.FILE_DESCRIPTOR_SET_PROTO; + case 6: + case "PROTO_FILE": + return ConfigFile_FileType.PROTO_FILE; + case -1: + case "UNRECOGNIZED": + default: + return ConfigFile_FileType.UNRECOGNIZED; + } +} +export function configFile_FileTypeToJSON(object: ConfigFile_FileType): string { + switch (object) { + case ConfigFile_FileType.FILE_TYPE_UNSPECIFIED: + return "FILE_TYPE_UNSPECIFIED"; + case ConfigFile_FileType.SERVICE_CONFIG_YAML: + return "SERVICE_CONFIG_YAML"; + case ConfigFile_FileType.OPEN_API_JSON: + return "OPEN_API_JSON"; + case ConfigFile_FileType.OPEN_API_YAML: + return "OPEN_API_YAML"; + case ConfigFile_FileType.FILE_DESCRIPTOR_SET_PROTO: + return "FILE_DESCRIPTOR_SET_PROTO"; + case ConfigFile_FileType.PROTO_FILE: + return "PROTO_FILE"; + case ConfigFile_FileType.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** Status of a Rollout. */ +export enum Rollout_RolloutStatus { + /** ROLLOUT_STATUS_UNSPECIFIED - No status specified. */ + ROLLOUT_STATUS_UNSPECIFIED = 0, + /** IN_PROGRESS - The Rollout is in progress. */ + IN_PROGRESS = 1, + /** SUCCESS - The Rollout has completed successfully. */ + SUCCESS = 2, + /** + * CANCELLED - The Rollout has been cancelled. This can happen if you have overlapping + * Rollout pushes, and the previous ones will be cancelled. + */ + CANCELLED = 3, + /** FAILED - The Rollout has failed and the rollback attempt has failed too. */ + FAILED = 4, + /** PENDING - The Rollout has not started yet and is pending for execution. */ + PENDING = 5, + /** + * FAILED_ROLLED_BACK - The Rollout has failed and rolled back to the previous successful + * Rollout. + */ + FAILED_ROLLED_BACK = 6, + UNRECOGNIZED = -1, +} +export const Rollout_RolloutStatusSDKType = Rollout_RolloutStatus; +export function rollout_RolloutStatusFromJSON(object: any): Rollout_RolloutStatus { + switch (object) { + case 0: + case "ROLLOUT_STATUS_UNSPECIFIED": + return Rollout_RolloutStatus.ROLLOUT_STATUS_UNSPECIFIED; + case 1: + case "IN_PROGRESS": + return Rollout_RolloutStatus.IN_PROGRESS; + case 2: + case "SUCCESS": + return Rollout_RolloutStatus.SUCCESS; + case 3: + case "CANCELLED": + return Rollout_RolloutStatus.CANCELLED; + case 4: + case "FAILED": + return Rollout_RolloutStatus.FAILED; + case 5: + case "PENDING": + return Rollout_RolloutStatus.PENDING; + case 6: + case "FAILED_ROLLED_BACK": + return Rollout_RolloutStatus.FAILED_ROLLED_BACK; + case -1: + case "UNRECOGNIZED": + default: + return Rollout_RolloutStatus.UNRECOGNIZED; + } +} +export function rollout_RolloutStatusToJSON(object: Rollout_RolloutStatus): string { + switch (object) { + case Rollout_RolloutStatus.ROLLOUT_STATUS_UNSPECIFIED: + return "ROLLOUT_STATUS_UNSPECIFIED"; + case Rollout_RolloutStatus.IN_PROGRESS: + return "IN_PROGRESS"; + case Rollout_RolloutStatus.SUCCESS: + return "SUCCESS"; + case Rollout_RolloutStatus.CANCELLED: + return "CANCELLED"; + case Rollout_RolloutStatus.FAILED: + return "FAILED"; + case Rollout_RolloutStatus.PENDING: + return "PENDING"; + case Rollout_RolloutStatus.FAILED_ROLLED_BACK: + return "FAILED_ROLLED_BACK"; + case Rollout_RolloutStatus.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** + * The full representation of a Service that is managed by + * Google Service Management. + */ +export interface ManagedService { + /** + * The name of the service. See the [overview](/service-management/overview) + * for naming requirements. + */ + serviceName: string; + /** ID of the project that produces and owns this service. */ + producerProjectId: string; +} +export interface ManagedServiceProtoMsg { + typeUrl: "/google.api.servicemanagement.v1.ManagedService"; + value: Uint8Array; +} +/** + * The full representation of a Service that is managed by + * Google Service Management. + */ +export interface ManagedServiceSDKType { + service_name: string; + producer_project_id: string; +} +/** The metadata associated with a long running operation resource. */ +export interface OperationMetadata { + /** + * The full name of the resources that this operation is directly + * associated with. + */ + resourceNames: string[]; + /** Detailed status information for each step. The order is undetermined. */ + steps: OperationMetadata_Step[]; + /** Percentage of completion of this operation, ranging from 0 to 100. */ + progressPercentage: number; + /** The start time of the operation. */ + startTime?: Date; +} +export interface OperationMetadataProtoMsg { + typeUrl: "/google.api.servicemanagement.v1.OperationMetadata"; + value: Uint8Array; +} +/** The metadata associated with a long running operation resource. */ +export interface OperationMetadataSDKType { + resource_names: string[]; + steps: OperationMetadata_StepSDKType[]; + progress_percentage: number; + start_time?: Date; +} +/** Represents the status of one operation step. */ +export interface OperationMetadata_Step { + /** The short description of the step. */ + description: string; + /** The status code. */ + status: OperationMetadata_Status; +} +export interface OperationMetadata_StepProtoMsg { + typeUrl: "/google.api.servicemanagement.v1.Step"; + value: Uint8Array; +} +/** Represents the status of one operation step. */ +export interface OperationMetadata_StepSDKType { + description: string; + status: OperationMetadata_Status; +} +/** Represents a diagnostic message (error or warning) */ +export interface Diagnostic { + /** File name and line number of the error or warning. */ + location: string; + /** The kind of diagnostic information provided. */ + kind: Diagnostic_Kind; + /** Message describing the error or warning. */ + message: string; +} +export interface DiagnosticProtoMsg { + typeUrl: "/google.api.servicemanagement.v1.Diagnostic"; + value: Uint8Array; +} +/** Represents a diagnostic message (error or warning) */ +export interface DiagnosticSDKType { + location: string; + kind: Diagnostic_Kind; + message: string; +} +/** + * Represents a source file which is used to generate the service configuration + * defined by `google.api.Service`. + */ +export interface ConfigSource { + /** + * A unique ID for a specific instance of this message, typically assigned + * by the client for tracking purpose. If empty, the server may choose to + * generate one instead. + */ + id: string; + /** + * Set of source configuration files that are used to generate a service + * configuration (`google.api.Service`). + */ + files: ConfigFile[]; +} +export interface ConfigSourceProtoMsg { + typeUrl: "/google.api.servicemanagement.v1.ConfigSource"; + value: Uint8Array; +} +/** + * Represents a source file which is used to generate the service configuration + * defined by `google.api.Service`. + */ +export interface ConfigSourceSDKType { + id: string; + files: ConfigFileSDKType[]; +} +/** Generic specification of a source configuration file */ +export interface ConfigFile { + /** The file name of the configuration file (full or relative path). */ + filePath: string; + /** The bytes that constitute the file. */ + fileContents: Uint8Array; + /** The type of configuration file this represents. */ + fileType: ConfigFile_FileType; +} +export interface ConfigFileProtoMsg { + typeUrl: "/google.api.servicemanagement.v1.ConfigFile"; + value: Uint8Array; +} +/** Generic specification of a source configuration file */ +export interface ConfigFileSDKType { + file_path: string; + file_contents: Uint8Array; + file_type: ConfigFile_FileType; +} +/** Represents a service configuration with its name and id. */ +export interface ConfigRef { + /** + * Resource name of a service config. It must have the following + * format: "services/{service name}/configs/{config id}". + */ + name: string; +} +export interface ConfigRefProtoMsg { + typeUrl: "/google.api.servicemanagement.v1.ConfigRef"; + value: Uint8Array; +} +/** Represents a service configuration with its name and id. */ +export interface ConfigRefSDKType { + name: string; +} +/** + * Change report associated with a particular service configuration. + * + * It contains a list of ConfigChanges based on the comparison between + * two service configurations. + */ +export interface ChangeReport { + /** + * List of changes between two service configurations. + * The changes will be alphabetically sorted based on the identifier + * of each change. + * A ConfigChange identifier is a dot separated path to the configuration. + * Example: visibility.rules[selector='LibraryService.CreateBook'].restriction + */ + configChanges: ConfigChange[]; +} +export interface ChangeReportProtoMsg { + typeUrl: "/google.api.servicemanagement.v1.ChangeReport"; + value: Uint8Array; +} +/** + * Change report associated with a particular service configuration. + * + * It contains a list of ConfigChanges based on the comparison between + * two service configurations. + */ +export interface ChangeReportSDKType { + config_changes: ConfigChangeSDKType[]; +} +/** + * A rollout resource that defines how service configuration versions are pushed + * to control plane systems. Typically, you create a new version of the + * service config, and then create a Rollout to push the service config. + */ +export interface Rollout { + /** + * Optional. Unique identifier of this Rollout. Must be no longer than 63 characters + * and only lower case letters, digits, '.', '_' and '-' are allowed. + * + * If not specified by client, the server will generate one. The generated id + * will have the form of , where "date" is the create + * date in ISO 8601 format. "revision number" is a monotonically increasing + * positive number that is reset every day for each service. + * An example of the generated rollout_id is '2016-02-16r1' + */ + rolloutId: string; + /** Creation time of the rollout. Readonly. */ + createTime?: Date; + /** The user who created the Rollout. Readonly. */ + createdBy: string; + /** + * The status of this rollout. Readonly. In case of a failed rollout, + * the system will automatically rollback to the current Rollout + * version. Readonly. + */ + status: Rollout_RolloutStatus; + /** + * Google Service Control selects service configurations based on + * traffic percentage. + */ + trafficPercentStrategy?: Rollout_TrafficPercentStrategy; + /** + * The strategy associated with a rollout to delete a `ManagedService`. + * Readonly. + */ + deleteServiceStrategy?: Rollout_DeleteServiceStrategy; + /** The name of the service associated with this Rollout. */ + serviceName: string; +} +export interface RolloutProtoMsg { + typeUrl: "/google.api.servicemanagement.v1.Rollout"; + value: Uint8Array; +} +/** + * A rollout resource that defines how service configuration versions are pushed + * to control plane systems. Typically, you create a new version of the + * service config, and then create a Rollout to push the service config. + */ +export interface RolloutSDKType { + rollout_id: string; + create_time?: Date; + created_by: string; + status: Rollout_RolloutStatus; + traffic_percent_strategy?: Rollout_TrafficPercentStrategySDKType; + delete_service_strategy?: Rollout_DeleteServiceStrategySDKType; + service_name: string; +} +export interface Rollout_TrafficPercentStrategy_PercentagesEntry { + key: string; + value: number; +} +export interface Rollout_TrafficPercentStrategy_PercentagesEntryProtoMsg { + typeUrl: string; + value: Uint8Array; +} +export interface Rollout_TrafficPercentStrategy_PercentagesEntrySDKType { + key: string; + value: number; +} +/** + * Strategy that specifies how clients of Google Service Controller want to + * send traffic to use different config versions. This is generally + * used by API proxy to split traffic based on your configured percentage for + * each config version. + * + * One example of how to gradually rollout a new service configuration using + * this + * strategy: + * Day 1 + * + * Rollout { + * id: "example.googleapis.com/rollout_20160206" + * traffic_percent_strategy { + * percentages: { + * "example.googleapis.com/20160201": 70.00 + * "example.googleapis.com/20160206": 30.00 + * } + * } + * } + * + * Day 2 + * + * Rollout { + * id: "example.googleapis.com/rollout_20160207" + * traffic_percent_strategy: { + * percentages: { + * "example.googleapis.com/20160206": 100.00 + * } + * } + * } + */ +export interface Rollout_TrafficPercentStrategy { + /** + * Maps service configuration IDs to their corresponding traffic percentage. + * Key is the service configuration ID, Value is the traffic percentage + * which must be greater than 0.0 and the sum must equal to 100.0. + */ + percentages: { + [key: string]: number; + }; +} +export interface Rollout_TrafficPercentStrategyProtoMsg { + typeUrl: "/google.api.servicemanagement.v1.TrafficPercentStrategy"; + value: Uint8Array; +} +/** + * Strategy that specifies how clients of Google Service Controller want to + * send traffic to use different config versions. This is generally + * used by API proxy to split traffic based on your configured percentage for + * each config version. + * + * One example of how to gradually rollout a new service configuration using + * this + * strategy: + * Day 1 + * + * Rollout { + * id: "example.googleapis.com/rollout_20160206" + * traffic_percent_strategy { + * percentages: { + * "example.googleapis.com/20160201": 70.00 + * "example.googleapis.com/20160206": 30.00 + * } + * } + * } + * + * Day 2 + * + * Rollout { + * id: "example.googleapis.com/rollout_20160207" + * traffic_percent_strategy: { + * percentages: { + * "example.googleapis.com/20160206": 100.00 + * } + * } + * } + */ +export interface Rollout_TrafficPercentStrategySDKType { + percentages: { + [key: string]: number; + }; +} +/** + * Strategy used to delete a service. This strategy is a placeholder only + * used by the system generated rollout to delete a service. + */ +export interface Rollout_DeleteServiceStrategy {} +export interface Rollout_DeleteServiceStrategyProtoMsg { + typeUrl: "/google.api.servicemanagement.v1.DeleteServiceStrategy"; + value: Uint8Array; +} +/** + * Strategy used to delete a service. This strategy is a placeholder only + * used by the system generated rollout to delete a service. + */ +export interface Rollout_DeleteServiceStrategySDKType {} +function createBaseManagedService(): ManagedService { + return { + serviceName: "", + producerProjectId: "" + }; +} +export const ManagedService = { + typeUrl: "/google.api.servicemanagement.v1.ManagedService", + encode(message: ManagedService, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.serviceName !== undefined) { + writer.uint32(18).string(message.serviceName); + } + if (message.producerProjectId !== undefined) { + writer.uint32(26).string(message.producerProjectId); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ManagedService { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseManagedService(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.serviceName = reader.string(); + break; + case 3: + message.producerProjectId = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ManagedService { + const obj = createBaseManagedService(); + if (isSet(object.serviceName)) obj.serviceName = String(object.serviceName); + if (isSet(object.producerProjectId)) obj.producerProjectId = String(object.producerProjectId); + return obj; + }, + toJSON(message: ManagedService): JsonSafe { + const obj: any = {}; + message.serviceName !== undefined && (obj.serviceName = message.serviceName); + message.producerProjectId !== undefined && (obj.producerProjectId = message.producerProjectId); + return obj; + }, + fromPartial(object: DeepPartial): ManagedService { + const message = createBaseManagedService(); + message.serviceName = object.serviceName ?? ""; + message.producerProjectId = object.producerProjectId ?? ""; + return message; + }, + fromSDK(object: ManagedServiceSDKType): ManagedService { + return { + serviceName: object?.service_name, + producerProjectId: object?.producer_project_id + }; + }, + fromSDKJSON(object: any): ManagedServiceSDKType { + return { + service_name: isSet(object.service_name) ? String(object.service_name) : "", + producer_project_id: isSet(object.producer_project_id) ? String(object.producer_project_id) : "" + }; + }, + toSDK(message: ManagedService): ManagedServiceSDKType { + const obj: any = {}; + obj.service_name = message.serviceName; + obj.producer_project_id = message.producerProjectId; + return obj; + }, + fromAmino(object: ManagedServiceAmino): ManagedService { + const message = createBaseManagedService(); + if (object.service_name !== undefined && object.service_name !== null) { + message.serviceName = object.service_name; + } + if (object.producer_project_id !== undefined && object.producer_project_id !== null) { + message.producerProjectId = object.producer_project_id; + } + return message; + }, + toAmino(message: ManagedService): ManagedServiceAmino { + const obj: any = {}; + obj.service_name = message.serviceName === "" ? undefined : message.serviceName; + obj.producer_project_id = message.producerProjectId === "" ? undefined : message.producerProjectId; + return obj; + }, + fromAminoMsg(object: ManagedServiceAminoMsg): ManagedService { + return ManagedService.fromAmino(object.value); + }, + fromProtoMsg(message: ManagedServiceProtoMsg): ManagedService { + return ManagedService.decode(message.value); + }, + toProto(message: ManagedService): Uint8Array { + return ManagedService.encode(message).finish(); + }, + toProtoMsg(message: ManagedService): ManagedServiceProtoMsg { + return { + typeUrl: "/google.api.servicemanagement.v1.ManagedService", + value: ManagedService.encode(message).finish() + }; + } +}; +function createBaseOperationMetadata(): OperationMetadata { + return { + resourceNames: [], + steps: [], + progressPercentage: 0, + startTime: undefined + }; +} +export const OperationMetadata = { + typeUrl: "/google.api.servicemanagement.v1.OperationMetadata", + encode(message: OperationMetadata, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.resourceNames) { + writer.uint32(10).string(v!); + } + for (const v of message.steps) { + OperationMetadata_Step.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.progressPercentage !== undefined) { + writer.uint32(24).int32(message.progressPercentage); + } + if (message.startTime !== undefined) { + Timestamp.encode(toTimestamp(message.startTime), writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): OperationMetadata { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseOperationMetadata(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.resourceNames.push(reader.string()); + break; + case 2: + message.steps.push(OperationMetadata_Step.decode(reader, reader.uint32())); + break; + case 3: + message.progressPercentage = reader.int32(); + break; + case 4: + message.startTime = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): OperationMetadata { + const obj = createBaseOperationMetadata(); + if (Array.isArray(object?.resourceNames)) obj.resourceNames = object.resourceNames.map((e: any) => String(e)); + if (Array.isArray(object?.steps)) obj.steps = object.steps.map((e: any) => OperationMetadata_Step.fromJSON(e)); + if (isSet(object.progressPercentage)) obj.progressPercentage = Number(object.progressPercentage); + if (isSet(object.startTime)) obj.startTime = new Date(object.startTime); + return obj; + }, + toJSON(message: OperationMetadata): JsonSafe { + const obj: any = {}; + if (message.resourceNames) { + obj.resourceNames = message.resourceNames.map(e => e); + } else { + obj.resourceNames = []; + } + if (message.steps) { + obj.steps = message.steps.map(e => e ? OperationMetadata_Step.toJSON(e) : undefined); + } else { + obj.steps = []; + } + message.progressPercentage !== undefined && (obj.progressPercentage = Math.round(message.progressPercentage)); + message.startTime !== undefined && (obj.startTime = message.startTime.toISOString()); + return obj; + }, + fromPartial(object: DeepPartial): OperationMetadata { + const message = createBaseOperationMetadata(); + message.resourceNames = object.resourceNames?.map(e => e) || []; + message.steps = object.steps?.map(e => OperationMetadata_Step.fromPartial(e)) || []; + message.progressPercentage = object.progressPercentage ?? 0; + message.startTime = object.startTime ?? undefined; + return message; + }, + fromSDK(object: OperationMetadataSDKType): OperationMetadata { + return { + resourceNames: Array.isArray(object?.resource_names) ? object.resource_names.map((e: any) => e) : [], + steps: Array.isArray(object?.steps) ? object.steps.map((e: any) => OperationMetadata_Step.fromSDK(e)) : [], + progressPercentage: object?.progress_percentage, + startTime: object.start_time ?? undefined + }; + }, + fromSDKJSON(object: any): OperationMetadataSDKType { + return { + resource_names: Array.isArray(object?.resource_names) ? object.resource_names.map((e: any) => String(e)) : [], + steps: Array.isArray(object?.steps) ? object.steps.map((e: any) => OperationMetadata_Step.fromSDKJSON(e)) : [], + progress_percentage: isSet(object.progress_percentage) ? Number(object.progress_percentage) : 0, + start_time: isSet(object.start_time) ? new Date(object.start_time) : undefined + }; + }, + toSDK(message: OperationMetadata): OperationMetadataSDKType { + const obj: any = {}; + if (message.resourceNames) { + obj.resource_names = message.resourceNames.map(e => e); + } else { + obj.resource_names = []; + } + if (message.steps) { + obj.steps = message.steps.map(e => e ? OperationMetadata_Step.toSDK(e) : undefined); + } else { + obj.steps = []; + } + obj.progress_percentage = message.progressPercentage; + message.startTime !== undefined && (obj.start_time = message.startTime ?? undefined); + return obj; + }, + fromAmino(object: OperationMetadataAmino): OperationMetadata { + const message = createBaseOperationMetadata(); + message.resourceNames = object.resource_names?.map(e => e) || []; + message.steps = object.steps?.map(e => OperationMetadata_Step.fromAmino(e)) || []; + if (object.progress_percentage !== undefined && object.progress_percentage !== null) { + message.progressPercentage = object.progress_percentage; + } + if (object.start_time !== undefined && object.start_time !== null) { + message.startTime = fromTimestamp(Timestamp.fromAmino(object.start_time)); + } + return message; + }, + toAmino(message: OperationMetadata): OperationMetadataAmino { + const obj: any = {}; + if (message.resourceNames) { + obj.resource_names = message.resourceNames.map(e => e); + } else { + obj.resource_names = message.resourceNames; + } + if (message.steps) { + obj.steps = message.steps.map(e => e ? OperationMetadata_Step.toAmino(e) : undefined); + } else { + obj.steps = message.steps; + } + obj.progress_percentage = message.progressPercentage === 0 ? undefined : message.progressPercentage; + obj.start_time = message.startTime ? Timestamp.toAmino(toTimestamp(message.startTime)) : undefined; + return obj; + }, + fromAminoMsg(object: OperationMetadataAminoMsg): OperationMetadata { + return OperationMetadata.fromAmino(object.value); + }, + fromProtoMsg(message: OperationMetadataProtoMsg): OperationMetadata { + return OperationMetadata.decode(message.value); + }, + toProto(message: OperationMetadata): Uint8Array { + return OperationMetadata.encode(message).finish(); + }, + toProtoMsg(message: OperationMetadata): OperationMetadataProtoMsg { + return { + typeUrl: "/google.api.servicemanagement.v1.OperationMetadata", + value: OperationMetadata.encode(message).finish() + }; + } +}; +function createBaseOperationMetadata_Step(): OperationMetadata_Step { + return { + description: "", + status: 0 + }; +} +export const OperationMetadata_Step = { + typeUrl: "/google.api.servicemanagement.v1.Step", + encode(message: OperationMetadata_Step, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.description !== undefined) { + writer.uint32(18).string(message.description); + } + if (message.status !== 0) { + writer.uint32(32).int32(message.status); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): OperationMetadata_Step { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseOperationMetadata_Step(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.description = reader.string(); + break; + case 4: + message.status = (reader.int32() as any); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): OperationMetadata_Step { + const obj = createBaseOperationMetadata_Step(); + if (isSet(object.description)) obj.description = String(object.description); + if (isSet(object.status)) obj.status = operationMetadata_StatusFromJSON(object.status); + return obj; + }, + toJSON(message: OperationMetadata_Step): JsonSafe { + const obj: any = {}; + message.description !== undefined && (obj.description = message.description); + message.status !== undefined && (obj.status = operationMetadata_StatusToJSON(message.status)); + return obj; + }, + fromPartial(object: DeepPartial): OperationMetadata_Step { + const message = createBaseOperationMetadata_Step(); + message.description = object.description ?? ""; + message.status = object.status ?? 0; + return message; + }, + fromSDK(object: OperationMetadata_StepSDKType): OperationMetadata_Step { + return { + description: object?.description, + status: isSet(object.status) ? operationMetadata_StatusFromJSON(object.status) : -1 + }; + }, + fromSDKJSON(object: any): OperationMetadata_StepSDKType { + return { + description: isSet(object.description) ? String(object.description) : "", + status: isSet(object.status) ? operationMetadata_StatusFromJSON(object.status) : -1 + }; + }, + toSDK(message: OperationMetadata_Step): OperationMetadata_StepSDKType { + const obj: any = {}; + obj.description = message.description; + message.status !== undefined && (obj.status = operationMetadata_StatusToJSON(message.status)); + return obj; + }, + fromAmino(object: OperationMetadata_StepAmino): OperationMetadata_Step { + const message = createBaseOperationMetadata_Step(); + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } + if (object.status !== undefined && object.status !== null) { + message.status = object.status; + } + return message; + }, + toAmino(message: OperationMetadata_Step): OperationMetadata_StepAmino { + const obj: any = {}; + obj.description = message.description === "" ? undefined : message.description; + obj.status = message.status === 0 ? undefined : message.status; + return obj; + }, + fromAminoMsg(object: OperationMetadata_StepAminoMsg): OperationMetadata_Step { + return OperationMetadata_Step.fromAmino(object.value); + }, + fromProtoMsg(message: OperationMetadata_StepProtoMsg): OperationMetadata_Step { + return OperationMetadata_Step.decode(message.value); + }, + toProto(message: OperationMetadata_Step): Uint8Array { + return OperationMetadata_Step.encode(message).finish(); + }, + toProtoMsg(message: OperationMetadata_Step): OperationMetadata_StepProtoMsg { + return { + typeUrl: "/google.api.servicemanagement.v1.Step", + value: OperationMetadata_Step.encode(message).finish() + }; + } +}; +function createBaseDiagnostic(): Diagnostic { + return { + location: "", + kind: 0, + message: "" + }; +} +export const Diagnostic = { + typeUrl: "/google.api.servicemanagement.v1.Diagnostic", + encode(message: Diagnostic, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.location !== undefined) { + writer.uint32(10).string(message.location); + } + if (message.kind !== 0) { + writer.uint32(16).int32(message.kind); + } + if (message.message !== undefined) { + writer.uint32(26).string(message.message); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Diagnostic { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDiagnostic(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.location = reader.string(); + break; + case 2: + message.kind = (reader.int32() as any); + break; + case 3: + message.message = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Diagnostic { + const obj = createBaseDiagnostic(); + if (isSet(object.location)) obj.location = String(object.location); + if (isSet(object.kind)) obj.kind = diagnostic_KindFromJSON(object.kind); + if (isSet(object.message)) obj.message = String(object.message); + return obj; + }, + toJSON(message: Diagnostic): JsonSafe { + const obj: any = {}; + message.location !== undefined && (obj.location = message.location); + message.kind !== undefined && (obj.kind = diagnostic_KindToJSON(message.kind)); + message.message !== undefined && (obj.message = message.message); + return obj; + }, + fromPartial(object: DeepPartial): Diagnostic { + const message = createBaseDiagnostic(); + message.location = object.location ?? ""; + message.kind = object.kind ?? 0; + message.message = object.message ?? ""; + return message; + }, + fromSDK(object: DiagnosticSDKType): Diagnostic { + return { + location: object?.location, + kind: isSet(object.kind) ? diagnostic_KindFromJSON(object.kind) : -1, + message: object?.message + }; + }, + fromSDKJSON(object: any): DiagnosticSDKType { + return { + location: isSet(object.location) ? String(object.location) : "", + kind: isSet(object.kind) ? diagnostic_KindFromJSON(object.kind) : -1, + message: isSet(object.message) ? String(object.message) : "" + }; + }, + toSDK(message: Diagnostic): DiagnosticSDKType { + const obj: any = {}; + obj.location = message.location; + message.kind !== undefined && (obj.kind = diagnostic_KindToJSON(message.kind)); + obj.message = message.message; + return obj; + }, + fromAmino(object: DiagnosticAmino): Diagnostic { + const message = createBaseDiagnostic(); + if (object.location !== undefined && object.location !== null) { + message.location = object.location; + } + if (object.kind !== undefined && object.kind !== null) { + message.kind = object.kind; + } + if (object.message !== undefined && object.message !== null) { + message.message = object.message; + } + return message; + }, + toAmino(message: Diagnostic): DiagnosticAmino { + const obj: any = {}; + obj.location = message.location === "" ? undefined : message.location; + obj.kind = message.kind === 0 ? undefined : message.kind; + obj.message = message.message === "" ? undefined : message.message; + return obj; + }, + fromAminoMsg(object: DiagnosticAminoMsg): Diagnostic { + return Diagnostic.fromAmino(object.value); + }, + fromProtoMsg(message: DiagnosticProtoMsg): Diagnostic { + return Diagnostic.decode(message.value); + }, + toProto(message: Diagnostic): Uint8Array { + return Diagnostic.encode(message).finish(); + }, + toProtoMsg(message: Diagnostic): DiagnosticProtoMsg { + return { + typeUrl: "/google.api.servicemanagement.v1.Diagnostic", + value: Diagnostic.encode(message).finish() + }; + } +}; +function createBaseConfigSource(): ConfigSource { + return { + id: "", + files: [] + }; +} +export const ConfigSource = { + typeUrl: "/google.api.servicemanagement.v1.ConfigSource", + encode(message: ConfigSource, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.id !== undefined) { + writer.uint32(42).string(message.id); + } + for (const v of message.files) { + ConfigFile.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ConfigSource { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseConfigSource(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 5: + message.id = reader.string(); + break; + case 2: + message.files.push(ConfigFile.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ConfigSource { + const obj = createBaseConfigSource(); + if (isSet(object.id)) obj.id = String(object.id); + if (Array.isArray(object?.files)) obj.files = object.files.map((e: any) => ConfigFile.fromJSON(e)); + return obj; + }, + toJSON(message: ConfigSource): JsonSafe { + const obj: any = {}; + message.id !== undefined && (obj.id = message.id); + if (message.files) { + obj.files = message.files.map(e => e ? ConfigFile.toJSON(e) : undefined); + } else { + obj.files = []; + } + return obj; + }, + fromPartial(object: DeepPartial): ConfigSource { + const message = createBaseConfigSource(); + message.id = object.id ?? ""; + message.files = object.files?.map(e => ConfigFile.fromPartial(e)) || []; + return message; + }, + fromSDK(object: ConfigSourceSDKType): ConfigSource { + return { + id: object?.id, + files: Array.isArray(object?.files) ? object.files.map((e: any) => ConfigFile.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): ConfigSourceSDKType { + return { + id: isSet(object.id) ? String(object.id) : "", + files: Array.isArray(object?.files) ? object.files.map((e: any) => ConfigFile.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: ConfigSource): ConfigSourceSDKType { + const obj: any = {}; + obj.id = message.id; + if (message.files) { + obj.files = message.files.map(e => e ? ConfigFile.toSDK(e) : undefined); + } else { + obj.files = []; + } + return obj; + }, + fromAmino(object: ConfigSourceAmino): ConfigSource { + const message = createBaseConfigSource(); + if (object.id !== undefined && object.id !== null) { + message.id = object.id; + } + message.files = object.files?.map(e => ConfigFile.fromAmino(e)) || []; + return message; + }, + toAmino(message: ConfigSource): ConfigSourceAmino { + const obj: any = {}; + obj.id = message.id === "" ? undefined : message.id; + if (message.files) { + obj.files = message.files.map(e => e ? ConfigFile.toAmino(e) : undefined); + } else { + obj.files = message.files; + } + return obj; + }, + fromAminoMsg(object: ConfigSourceAminoMsg): ConfigSource { + return ConfigSource.fromAmino(object.value); + }, + fromProtoMsg(message: ConfigSourceProtoMsg): ConfigSource { + return ConfigSource.decode(message.value); + }, + toProto(message: ConfigSource): Uint8Array { + return ConfigSource.encode(message).finish(); + }, + toProtoMsg(message: ConfigSource): ConfigSourceProtoMsg { + return { + typeUrl: "/google.api.servicemanagement.v1.ConfigSource", + value: ConfigSource.encode(message).finish() + }; + } +}; +function createBaseConfigFile(): ConfigFile { + return { + filePath: "", + fileContents: new Uint8Array(), + fileType: 0 + }; +} +export const ConfigFile = { + typeUrl: "/google.api.servicemanagement.v1.ConfigFile", + encode(message: ConfigFile, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.filePath !== undefined) { + writer.uint32(10).string(message.filePath); + } + if (message.fileContents.length !== 0) { + writer.uint32(26).bytes(message.fileContents); + } + if (message.fileType !== 0) { + writer.uint32(32).int32(message.fileType); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ConfigFile { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseConfigFile(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.filePath = reader.string(); + break; + case 3: + message.fileContents = reader.bytes(); + break; + case 4: + message.fileType = (reader.int32() as any); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ConfigFile { + const obj = createBaseConfigFile(); + if (isSet(object.filePath)) obj.filePath = String(object.filePath); + if (isSet(object.fileContents)) obj.fileContents = bytesFromBase64(object.fileContents); + if (isSet(object.fileType)) obj.fileType = configFile_FileTypeFromJSON(object.fileType); + return obj; + }, + toJSON(message: ConfigFile): JsonSafe { + const obj: any = {}; + message.filePath !== undefined && (obj.filePath = message.filePath); + message.fileContents !== undefined && (obj.fileContents = base64FromBytes(message.fileContents !== undefined ? message.fileContents : new Uint8Array())); + message.fileType !== undefined && (obj.fileType = configFile_FileTypeToJSON(message.fileType)); + return obj; + }, + fromPartial(object: DeepPartial): ConfigFile { + const message = createBaseConfigFile(); + message.filePath = object.filePath ?? ""; + message.fileContents = object.fileContents ?? new Uint8Array(); + message.fileType = object.fileType ?? 0; + return message; + }, + fromSDK(object: ConfigFileSDKType): ConfigFile { + return { + filePath: object?.file_path, + fileContents: object?.file_contents, + fileType: isSet(object.file_type) ? configFile_FileTypeFromJSON(object.file_type) : -1 + }; + }, + fromSDKJSON(object: any): ConfigFileSDKType { + return { + file_path: isSet(object.file_path) ? String(object.file_path) : "", + file_contents: isSet(object.file_contents) ? bytesFromBase64(object.file_contents) : new Uint8Array(), + file_type: isSet(object.file_type) ? configFile_FileTypeFromJSON(object.file_type) : -1 + }; + }, + toSDK(message: ConfigFile): ConfigFileSDKType { + const obj: any = {}; + obj.file_path = message.filePath; + obj.file_contents = message.fileContents; + message.fileType !== undefined && (obj.file_type = configFile_FileTypeToJSON(message.fileType)); + return obj; + }, + fromAmino(object: ConfigFileAmino): ConfigFile { + const message = createBaseConfigFile(); + if (object.file_path !== undefined && object.file_path !== null) { + message.filePath = object.file_path; + } + if (object.file_contents !== undefined && object.file_contents !== null) { + message.fileContents = bytesFromBase64(object.file_contents); + } + if (object.file_type !== undefined && object.file_type !== null) { + message.fileType = object.file_type; + } + return message; + }, + toAmino(message: ConfigFile): ConfigFileAmino { + const obj: any = {}; + obj.file_path = message.filePath === "" ? undefined : message.filePath; + obj.file_contents = message.fileContents ? base64FromBytes(message.fileContents) : undefined; + obj.file_type = message.fileType === 0 ? undefined : message.fileType; + return obj; + }, + fromAminoMsg(object: ConfigFileAminoMsg): ConfigFile { + return ConfigFile.fromAmino(object.value); + }, + fromProtoMsg(message: ConfigFileProtoMsg): ConfigFile { + return ConfigFile.decode(message.value); + }, + toProto(message: ConfigFile): Uint8Array { + return ConfigFile.encode(message).finish(); + }, + toProtoMsg(message: ConfigFile): ConfigFileProtoMsg { + return { + typeUrl: "/google.api.servicemanagement.v1.ConfigFile", + value: ConfigFile.encode(message).finish() + }; + } +}; +function createBaseConfigRef(): ConfigRef { + return { + name: "" + }; +} +export const ConfigRef = { + typeUrl: "/google.api.servicemanagement.v1.ConfigRef", + encode(message: ConfigRef, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ConfigRef { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseConfigRef(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ConfigRef { + const obj = createBaseConfigRef(); + if (isSet(object.name)) obj.name = String(object.name); + return obj; + }, + toJSON(message: ConfigRef): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + return obj; + }, + fromPartial(object: DeepPartial): ConfigRef { + const message = createBaseConfigRef(); + message.name = object.name ?? ""; + return message; + }, + fromSDK(object: ConfigRefSDKType): ConfigRef { + return { + name: object?.name + }; + }, + fromSDKJSON(object: any): ConfigRefSDKType { + return { + name: isSet(object.name) ? String(object.name) : "" + }; + }, + toSDK(message: ConfigRef): ConfigRefSDKType { + const obj: any = {}; + obj.name = message.name; + return obj; + }, + fromAmino(object: ConfigRefAmino): ConfigRef { + const message = createBaseConfigRef(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + return message; + }, + toAmino(message: ConfigRef): ConfigRefAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + return obj; + }, + fromAminoMsg(object: ConfigRefAminoMsg): ConfigRef { + return ConfigRef.fromAmino(object.value); + }, + fromProtoMsg(message: ConfigRefProtoMsg): ConfigRef { + return ConfigRef.decode(message.value); + }, + toProto(message: ConfigRef): Uint8Array { + return ConfigRef.encode(message).finish(); + }, + toProtoMsg(message: ConfigRef): ConfigRefProtoMsg { + return { + typeUrl: "/google.api.servicemanagement.v1.ConfigRef", + value: ConfigRef.encode(message).finish() + }; + } +}; +function createBaseChangeReport(): ChangeReport { + return { + configChanges: [] + }; +} +export const ChangeReport = { + typeUrl: "/google.api.servicemanagement.v1.ChangeReport", + encode(message: ChangeReport, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.configChanges) { + ConfigChange.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ChangeReport { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseChangeReport(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.configChanges.push(ConfigChange.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ChangeReport { + const obj = createBaseChangeReport(); + if (Array.isArray(object?.configChanges)) obj.configChanges = object.configChanges.map((e: any) => ConfigChange.fromJSON(e)); + return obj; + }, + toJSON(message: ChangeReport): JsonSafe { + const obj: any = {}; + if (message.configChanges) { + obj.configChanges = message.configChanges.map(e => e ? ConfigChange.toJSON(e) : undefined); + } else { + obj.configChanges = []; + } + return obj; + }, + fromPartial(object: DeepPartial): ChangeReport { + const message = createBaseChangeReport(); + message.configChanges = object.configChanges?.map(e => ConfigChange.fromPartial(e)) || []; + return message; + }, + fromSDK(object: ChangeReportSDKType): ChangeReport { + return { + configChanges: Array.isArray(object?.config_changes) ? object.config_changes.map((e: any) => ConfigChange.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): ChangeReportSDKType { + return { + config_changes: Array.isArray(object?.config_changes) ? object.config_changes.map((e: any) => ConfigChange.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: ChangeReport): ChangeReportSDKType { + const obj: any = {}; + if (message.configChanges) { + obj.config_changes = message.configChanges.map(e => e ? ConfigChange.toSDK(e) : undefined); + } else { + obj.config_changes = []; + } + return obj; + }, + fromAmino(object: ChangeReportAmino): ChangeReport { + const message = createBaseChangeReport(); + message.configChanges = object.config_changes?.map(e => ConfigChange.fromAmino(e)) || []; + return message; + }, + toAmino(message: ChangeReport): ChangeReportAmino { + const obj: any = {}; + if (message.configChanges) { + obj.config_changes = message.configChanges.map(e => e ? ConfigChange.toAmino(e) : undefined); + } else { + obj.config_changes = message.configChanges; + } + return obj; + }, + fromAminoMsg(object: ChangeReportAminoMsg): ChangeReport { + return ChangeReport.fromAmino(object.value); + }, + fromProtoMsg(message: ChangeReportProtoMsg): ChangeReport { + return ChangeReport.decode(message.value); + }, + toProto(message: ChangeReport): Uint8Array { + return ChangeReport.encode(message).finish(); + }, + toProtoMsg(message: ChangeReport): ChangeReportProtoMsg { + return { + typeUrl: "/google.api.servicemanagement.v1.ChangeReport", + value: ChangeReport.encode(message).finish() + }; + } +}; +function createBaseRollout(): Rollout { + return { + rolloutId: "", + createTime: undefined, + createdBy: "", + status: 0, + trafficPercentStrategy: undefined, + deleteServiceStrategy: undefined, + serviceName: "" + }; +} +export const Rollout = { + typeUrl: "/google.api.servicemanagement.v1.Rollout", + encode(message: Rollout, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.rolloutId !== undefined) { + writer.uint32(10).string(message.rolloutId); + } + if (message.createTime !== undefined) { + Timestamp.encode(toTimestamp(message.createTime), writer.uint32(18).fork()).ldelim(); + } + if (message.createdBy !== undefined) { + writer.uint32(26).string(message.createdBy); + } + if (message.status !== 0) { + writer.uint32(32).int32(message.status); + } + if (message.trafficPercentStrategy !== undefined) { + Rollout_TrafficPercentStrategy.encode(message.trafficPercentStrategy, writer.uint32(42).fork()).ldelim(); + } + if (message.deleteServiceStrategy !== undefined) { + Rollout_DeleteServiceStrategy.encode(message.deleteServiceStrategy, writer.uint32(1602).fork()).ldelim(); + } + if (message.serviceName !== undefined) { + writer.uint32(66).string(message.serviceName); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Rollout { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseRollout(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.rolloutId = reader.string(); + break; + case 2: + message.createTime = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + break; + case 3: + message.createdBy = reader.string(); + break; + case 4: + message.status = (reader.int32() as any); + break; + case 5: + message.trafficPercentStrategy = Rollout_TrafficPercentStrategy.decode(reader, reader.uint32()); + break; + case 200: + message.deleteServiceStrategy = Rollout_DeleteServiceStrategy.decode(reader, reader.uint32()); + break; + case 8: + message.serviceName = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Rollout { + const obj = createBaseRollout(); + if (isSet(object.rolloutId)) obj.rolloutId = String(object.rolloutId); + if (isSet(object.createTime)) obj.createTime = new Date(object.createTime); + if (isSet(object.createdBy)) obj.createdBy = String(object.createdBy); + if (isSet(object.status)) obj.status = rollout_RolloutStatusFromJSON(object.status); + if (isSet(object.trafficPercentStrategy)) obj.trafficPercentStrategy = Rollout_TrafficPercentStrategy.fromJSON(object.trafficPercentStrategy); + if (isSet(object.deleteServiceStrategy)) obj.deleteServiceStrategy = Rollout_DeleteServiceStrategy.fromJSON(object.deleteServiceStrategy); + if (isSet(object.serviceName)) obj.serviceName = String(object.serviceName); + return obj; + }, + toJSON(message: Rollout): JsonSafe { + const obj: any = {}; + message.rolloutId !== undefined && (obj.rolloutId = message.rolloutId); + message.createTime !== undefined && (obj.createTime = message.createTime.toISOString()); + message.createdBy !== undefined && (obj.createdBy = message.createdBy); + message.status !== undefined && (obj.status = rollout_RolloutStatusToJSON(message.status)); + message.trafficPercentStrategy !== undefined && (obj.trafficPercentStrategy = message.trafficPercentStrategy ? Rollout_TrafficPercentStrategy.toJSON(message.trafficPercentStrategy) : undefined); + message.deleteServiceStrategy !== undefined && (obj.deleteServiceStrategy = message.deleteServiceStrategy ? Rollout_DeleteServiceStrategy.toJSON(message.deleteServiceStrategy) : undefined); + message.serviceName !== undefined && (obj.serviceName = message.serviceName); + return obj; + }, + fromPartial(object: DeepPartial): Rollout { + const message = createBaseRollout(); + message.rolloutId = object.rolloutId ?? ""; + message.createTime = object.createTime ?? undefined; + message.createdBy = object.createdBy ?? ""; + message.status = object.status ?? 0; + if (object.trafficPercentStrategy !== undefined && object.trafficPercentStrategy !== null) { + message.trafficPercentStrategy = Rollout_TrafficPercentStrategy.fromPartial(object.trafficPercentStrategy); + } + if (object.deleteServiceStrategy !== undefined && object.deleteServiceStrategy !== null) { + message.deleteServiceStrategy = Rollout_DeleteServiceStrategy.fromPartial(object.deleteServiceStrategy); + } + message.serviceName = object.serviceName ?? ""; + return message; + }, + fromSDK(object: RolloutSDKType): Rollout { + return { + rolloutId: object?.rollout_id, + createTime: object.create_time ?? undefined, + createdBy: object?.created_by, + status: isSet(object.status) ? rollout_RolloutStatusFromJSON(object.status) : -1, + trafficPercentStrategy: object.traffic_percent_strategy ? Rollout_TrafficPercentStrategy.fromSDK(object.traffic_percent_strategy) : undefined, + deleteServiceStrategy: object.delete_service_strategy ? Rollout_DeleteServiceStrategy.fromSDK(object.delete_service_strategy) : undefined, + serviceName: object?.service_name + }; + }, + fromSDKJSON(object: any): RolloutSDKType { + return { + rollout_id: isSet(object.rollout_id) ? String(object.rollout_id) : "", + create_time: isSet(object.create_time) ? new Date(object.create_time) : undefined, + created_by: isSet(object.created_by) ? String(object.created_by) : "", + status: isSet(object.status) ? rollout_RolloutStatusFromJSON(object.status) : -1, + traffic_percent_strategy: isSet(object.traffic_percent_strategy) ? Rollout_TrafficPercentStrategy.fromSDKJSON(object.traffic_percent_strategy) : undefined, + delete_service_strategy: isSet(object.delete_service_strategy) ? Rollout_DeleteServiceStrategy.fromSDKJSON(object.delete_service_strategy) : undefined, + service_name: isSet(object.service_name) ? String(object.service_name) : "" + }; + }, + toSDK(message: Rollout): RolloutSDKType { + const obj: any = {}; + obj.rollout_id = message.rolloutId; + message.createTime !== undefined && (obj.create_time = message.createTime ?? undefined); + obj.created_by = message.createdBy; + message.status !== undefined && (obj.status = rollout_RolloutStatusToJSON(message.status)); + message.trafficPercentStrategy !== undefined && (obj.traffic_percent_strategy = message.trafficPercentStrategy ? Rollout_TrafficPercentStrategy.toSDK(message.trafficPercentStrategy) : undefined); + message.deleteServiceStrategy !== undefined && (obj.delete_service_strategy = message.deleteServiceStrategy ? Rollout_DeleteServiceStrategy.toSDK(message.deleteServiceStrategy) : undefined); + obj.service_name = message.serviceName; + return obj; + }, + fromAmino(object: RolloutAmino): Rollout { + const message = createBaseRollout(); + if (object.rollout_id !== undefined && object.rollout_id !== null) { + message.rolloutId = object.rollout_id; + } + if (object.create_time !== undefined && object.create_time !== null) { + message.createTime = fromTimestamp(Timestamp.fromAmino(object.create_time)); + } + if (object.created_by !== undefined && object.created_by !== null) { + message.createdBy = object.created_by; + } + if (object.status !== undefined && object.status !== null) { + message.status = object.status; + } + if (object.traffic_percent_strategy !== undefined && object.traffic_percent_strategy !== null) { + message.trafficPercentStrategy = Rollout_TrafficPercentStrategy.fromAmino(object.traffic_percent_strategy); + } + if (object.delete_service_strategy !== undefined && object.delete_service_strategy !== null) { + message.deleteServiceStrategy = Rollout_DeleteServiceStrategy.fromAmino(object.delete_service_strategy); + } + if (object.service_name !== undefined && object.service_name !== null) { + message.serviceName = object.service_name; + } + return message; + }, + toAmino(message: Rollout): RolloutAmino { + const obj: any = {}; + obj.rollout_id = message.rolloutId === "" ? undefined : message.rolloutId; + obj.create_time = message.createTime ? Timestamp.toAmino(toTimestamp(message.createTime)) : undefined; + obj.created_by = message.createdBy === "" ? undefined : message.createdBy; + obj.status = message.status === 0 ? undefined : message.status; + obj.traffic_percent_strategy = message.trafficPercentStrategy ? Rollout_TrafficPercentStrategy.toAmino(message.trafficPercentStrategy) : undefined; + obj.delete_service_strategy = message.deleteServiceStrategy ? Rollout_DeleteServiceStrategy.toAmino(message.deleteServiceStrategy) : undefined; + obj.service_name = message.serviceName === "" ? undefined : message.serviceName; + return obj; + }, + fromAminoMsg(object: RolloutAminoMsg): Rollout { + return Rollout.fromAmino(object.value); + }, + fromProtoMsg(message: RolloutProtoMsg): Rollout { + return Rollout.decode(message.value); + }, + toProto(message: Rollout): Uint8Array { + return Rollout.encode(message).finish(); + }, + toProtoMsg(message: Rollout): RolloutProtoMsg { + return { + typeUrl: "/google.api.servicemanagement.v1.Rollout", + value: Rollout.encode(message).finish() + }; + } +}; +function createBaseRollout_TrafficPercentStrategy_PercentagesEntry(): Rollout_TrafficPercentStrategy_PercentagesEntry { + return { + key: "", + value: 0 + }; +} +export const Rollout_TrafficPercentStrategy_PercentagesEntry = { + encode(message: Rollout_TrafficPercentStrategy_PercentagesEntry, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.key !== undefined) { + writer.uint32(10).string(message.key); + } + if (message.value !== undefined) { + writer.uint32(17).double(message.value); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Rollout_TrafficPercentStrategy_PercentagesEntry { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseRollout_TrafficPercentStrategy_PercentagesEntry(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.string(); + break; + case 2: + message.value = reader.double(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Rollout_TrafficPercentStrategy_PercentagesEntry { + const obj = createBaseRollout_TrafficPercentStrategy_PercentagesEntry(); + if (isSet(object.key)) obj.key = String(object.key); + if (isSet(object.value)) obj.value = Number(object.value); + return obj; + }, + toJSON(message: Rollout_TrafficPercentStrategy_PercentagesEntry): JsonSafe { + const obj: any = {}; + message.key !== undefined && (obj.key = message.key); + message.value !== undefined && (obj.value = message.value); + return obj; + }, + fromPartial(object: DeepPartial): Rollout_TrafficPercentStrategy_PercentagesEntry { + const message = createBaseRollout_TrafficPercentStrategy_PercentagesEntry(); + message.key = object.key ?? ""; + message.value = object.value ?? 0; + return message; + }, + fromSDK(object: Rollout_TrafficPercentStrategy_PercentagesEntrySDKType): Rollout_TrafficPercentStrategy_PercentagesEntry { + return { + key: object?.key, + value: object?.value + }; + }, + fromSDKJSON(object: any): Rollout_TrafficPercentStrategy_PercentagesEntrySDKType { + return { + key: isSet(object.key) ? String(object.key) : "", + value: isSet(object.value) ? Number(object.value) : 0 + }; + }, + toSDK(message: Rollout_TrafficPercentStrategy_PercentagesEntry): Rollout_TrafficPercentStrategy_PercentagesEntrySDKType { + const obj: any = {}; + obj.key = message.key; + obj.value = message.value; + return obj; + }, + fromAmino(object: Rollout_TrafficPercentStrategy_PercentagesEntryAmino): Rollout_TrafficPercentStrategy_PercentagesEntry { + const message = createBaseRollout_TrafficPercentStrategy_PercentagesEntry(); + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } + if (object.value !== undefined && object.value !== null) { + message.value = object.value; + } + return message; + }, + toAmino(message: Rollout_TrafficPercentStrategy_PercentagesEntry): Rollout_TrafficPercentStrategy_PercentagesEntryAmino { + const obj: any = {}; + obj.key = message.key === "" ? undefined : message.key; + obj.value = message.value === 0 ? undefined : message.value; + return obj; + }, + fromAminoMsg(object: Rollout_TrafficPercentStrategy_PercentagesEntryAminoMsg): Rollout_TrafficPercentStrategy_PercentagesEntry { + return Rollout_TrafficPercentStrategy_PercentagesEntry.fromAmino(object.value); + }, + fromProtoMsg(message: Rollout_TrafficPercentStrategy_PercentagesEntryProtoMsg): Rollout_TrafficPercentStrategy_PercentagesEntry { + return Rollout_TrafficPercentStrategy_PercentagesEntry.decode(message.value); + }, + toProto(message: Rollout_TrafficPercentStrategy_PercentagesEntry): Uint8Array { + return Rollout_TrafficPercentStrategy_PercentagesEntry.encode(message).finish(); + } +}; +function createBaseRollout_TrafficPercentStrategy(): Rollout_TrafficPercentStrategy { + return { + percentages: {} + }; +} +export const Rollout_TrafficPercentStrategy = { + typeUrl: "/google.api.servicemanagement.v1.TrafficPercentStrategy", + encode(message: Rollout_TrafficPercentStrategy, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + Object.entries(message.percentages).forEach(([key, value]) => { + Rollout_TrafficPercentStrategy_PercentagesEntry.encode({ + key: (key as any), + value + }, writer.uint32(9).fork()).ldelim(); + }); + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Rollout_TrafficPercentStrategy { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseRollout_TrafficPercentStrategy(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + const entry1 = Rollout_TrafficPercentStrategy_PercentagesEntry.decode(reader, reader.uint32()); + if (entry1.value !== undefined) { + message.percentages[entry1.key] = entry1.value; + } + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Rollout_TrafficPercentStrategy { + const obj = createBaseRollout_TrafficPercentStrategy(); + if (isObject(object.percentages)) obj.percentages = Object.entries(object.percentages).reduce<{ + [key: string]: double; + }>((acc, [key, value]) => { + acc[key] = double.fromJSON(value); + return acc; + }, {}); + return obj; + }, + toJSON(message: Rollout_TrafficPercentStrategy): JsonSafe { + const obj: any = {}; + obj.percentages = {}; + if (message.percentages) { + Object.entries(message.percentages).forEach(([k, v]) => { + obj.percentages[k] = double.toJSON(v); + }); + } + return obj; + }, + fromPartial(object: DeepPartial): Rollout_TrafficPercentStrategy { + const message = createBaseRollout_TrafficPercentStrategy(); + message.percentages = Object.entries(object.percentages ?? {}).reduce<{ + [key: string]: double; + }>((acc, [key, value]) => { + if (value !== undefined) { + acc[key] = double.fromPartial(value); + } + return acc; + }, {}); + return message; + }, + fromSDK(object: Rollout_TrafficPercentStrategySDKType): Rollout_TrafficPercentStrategy { + return { + percentages: isObject(object.percentages) ? Object.entries(object.percentages).reduce<{ + [key: string]: double; + }>((acc, [key, value]) => { + acc[key] = double.fromSDK(value); + return acc; + }, {}) : {} + }; + }, + fromSDKJSON(object: any): Rollout_TrafficPercentStrategySDKType { + return { + percentages: isObject(object.percentages) ? Object.entries(object.percentages).reduce<{ + [key: string]: double; + }>((acc, [key, value]) => { + acc[key] = double.fromSDKJSON(value); + return acc; + }, {}) : {} + }; + }, + toSDK(message: Rollout_TrafficPercentStrategy): Rollout_TrafficPercentStrategySDKType { + const obj: any = {}; + obj.percentages = {}; + if (message.percentages) { + Object.entries(message.percentages).forEach(([k, v]) => { + obj.percentages[k] = double.toSDK(v); + }); + } + return obj; + }, + fromAmino(object: Rollout_TrafficPercentStrategyAmino): Rollout_TrafficPercentStrategy { + const message = createBaseRollout_TrafficPercentStrategy(); + message.percentages = Object.entries(object.percentages ?? {}).reduce<{ + [key: string]: double; + }>((acc, [key, value]) => { + if (value !== undefined) { + acc[key] = double.fromAmino(value); + } + return acc; + }, {}); + return message; + }, + toAmino(message: Rollout_TrafficPercentStrategy): Rollout_TrafficPercentStrategyAmino { + const obj: any = {}; + obj.percentages = {}; + if (message.percentages) { + Object.entries(message.percentages).forEach(([k, v]) => { + obj.percentages[k] = double.toAmino(v); + }); + } + return obj; + }, + fromAminoMsg(object: Rollout_TrafficPercentStrategyAminoMsg): Rollout_TrafficPercentStrategy { + return Rollout_TrafficPercentStrategy.fromAmino(object.value); + }, + fromProtoMsg(message: Rollout_TrafficPercentStrategyProtoMsg): Rollout_TrafficPercentStrategy { + return Rollout_TrafficPercentStrategy.decode(message.value); + }, + toProto(message: Rollout_TrafficPercentStrategy): Uint8Array { + return Rollout_TrafficPercentStrategy.encode(message).finish(); + }, + toProtoMsg(message: Rollout_TrafficPercentStrategy): Rollout_TrafficPercentStrategyProtoMsg { + return { + typeUrl: "/google.api.servicemanagement.v1.TrafficPercentStrategy", + value: Rollout_TrafficPercentStrategy.encode(message).finish() + }; + } +}; +function createBaseRollout_DeleteServiceStrategy(): Rollout_DeleteServiceStrategy { + return {}; +} +export const Rollout_DeleteServiceStrategy = { + typeUrl: "/google.api.servicemanagement.v1.DeleteServiceStrategy", + encode(_: Rollout_DeleteServiceStrategy, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Rollout_DeleteServiceStrategy { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseRollout_DeleteServiceStrategy(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): Rollout_DeleteServiceStrategy { + const obj = createBaseRollout_DeleteServiceStrategy(); + return obj; + }, + toJSON(_: Rollout_DeleteServiceStrategy): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): Rollout_DeleteServiceStrategy { + const message = createBaseRollout_DeleteServiceStrategy(); + return message; + }, + fromSDK(_: Rollout_DeleteServiceStrategySDKType): Rollout_DeleteServiceStrategy { + return {}; + }, + fromSDKJSON(_: any): Rollout_DeleteServiceStrategySDKType { + return {}; + }, + toSDK(_: Rollout_DeleteServiceStrategy): Rollout_DeleteServiceStrategySDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: Rollout_DeleteServiceStrategyAmino): Rollout_DeleteServiceStrategy { + const message = createBaseRollout_DeleteServiceStrategy(); + return message; + }, + toAmino(_: Rollout_DeleteServiceStrategy): Rollout_DeleteServiceStrategyAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: Rollout_DeleteServiceStrategyAminoMsg): Rollout_DeleteServiceStrategy { + return Rollout_DeleteServiceStrategy.fromAmino(object.value); + }, + fromProtoMsg(message: Rollout_DeleteServiceStrategyProtoMsg): Rollout_DeleteServiceStrategy { + return Rollout_DeleteServiceStrategy.decode(message.value); + }, + toProto(message: Rollout_DeleteServiceStrategy): Uint8Array { + return Rollout_DeleteServiceStrategy.encode(message).finish(); + }, + toProtoMsg(message: Rollout_DeleteServiceStrategy): Rollout_DeleteServiceStrategyProtoMsg { + return { + typeUrl: "/google.api.servicemanagement.v1.DeleteServiceStrategy", + value: Rollout_DeleteServiceStrategy.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/api/servicemanagement/v1/servicemanager.ts b/__fixtures__/v-next/outputicjsdeps/google/api/servicemanagement/v1/servicemanager.ts new file mode 100644 index 0000000000..357688baca --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/api/servicemanagement/v1/servicemanager.ts @@ -0,0 +1,2560 @@ +import { ManagedService, ManagedServiceSDKType, ConfigSource, ConfigSourceSDKType, Rollout, RolloutSDKType, ChangeReport, ChangeReportSDKType, Diagnostic, DiagnosticSDKType } from "./resources.js"; +import { Service, ServiceSDKType } from "../../service.js"; +import { Any, AnySDKType } from "../../../protobuf/any.js"; +import { BinaryReader, BinaryWriter } from "../../../../binary.js"; +import { isSet, DeepPartial } from "../../../../helpers.js"; +import { JsonSafe } from "../../../../json-safe.js"; +export const protobufPackage = "google.api.servicemanagement.v1"; +export enum GetServiceConfigRequest_ConfigView { + /** BASIC - Server response includes all fields except SourceInfo. */ + BASIC = 0, + /** + * FULL - Server response includes all fields including SourceInfo. + * SourceFiles are of type 'google.api.servicemanagement.v1.ConfigFile' + * and are only available for configs created using the + * SubmitConfigSource method. + */ + FULL = 1, + UNRECOGNIZED = -1, +} +export const GetServiceConfigRequest_ConfigViewSDKType = GetServiceConfigRequest_ConfigView; +export function getServiceConfigRequest_ConfigViewFromJSON(object: any): GetServiceConfigRequest_ConfigView { + switch (object) { + case 0: + case "BASIC": + return GetServiceConfigRequest_ConfigView.BASIC; + case 1: + case "FULL": + return GetServiceConfigRequest_ConfigView.FULL; + case -1: + case "UNRECOGNIZED": + default: + return GetServiceConfigRequest_ConfigView.UNRECOGNIZED; + } +} +export function getServiceConfigRequest_ConfigViewToJSON(object: GetServiceConfigRequest_ConfigView): string { + switch (object) { + case GetServiceConfigRequest_ConfigView.BASIC: + return "BASIC"; + case GetServiceConfigRequest_ConfigView.FULL: + return "FULL"; + case GetServiceConfigRequest_ConfigView.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** Request message for `ListServices` method. */ +export interface ListServicesRequest { + /** Include services produced by the specified project. */ + producerProjectId: string; + /** + * The max number of items to include in the response list. Page size is 50 + * if not specified. Maximum value is 100. + */ + pageSize: number; + /** + * Token identifying which result to start with; returned by a previous list + * call. + */ + pageToken: string; + /** + * Include services consumed by the specified consumer. + * + * The Google Service Management implementation accepts the following + * forms: + * - project: + */ + /** @deprecated */ + consumerId: string; +} +export interface ListServicesRequestProtoMsg { + typeUrl: "/google.api.servicemanagement.v1.ListServicesRequest"; + value: Uint8Array; +} +/** Request message for `ListServices` method. */ +export interface ListServicesRequestSDKType { + producer_project_id: string; + page_size: number; + page_token: string; + /** @deprecated */ + consumer_id: string; +} +/** Response message for `ListServices` method. */ +export interface ListServicesResponse { + /** The returned services will only have the name field set. */ + services: ManagedService[]; + /** Token that can be passed to `ListServices` to resume a paginated query. */ + nextPageToken: string; +} +export interface ListServicesResponseProtoMsg { + typeUrl: "/google.api.servicemanagement.v1.ListServicesResponse"; + value: Uint8Array; +} +/** Response message for `ListServices` method. */ +export interface ListServicesResponseSDKType { + services: ManagedServiceSDKType[]; + next_page_token: string; +} +/** Request message for `GetService` method. */ +export interface GetServiceRequest { + /** + * Required. The name of the service. See the `ServiceManager` overview for naming + * requirements. For example: `example.googleapis.com`. + */ + serviceName: string; +} +export interface GetServiceRequestProtoMsg { + typeUrl: "/google.api.servicemanagement.v1.GetServiceRequest"; + value: Uint8Array; +} +/** Request message for `GetService` method. */ +export interface GetServiceRequestSDKType { + service_name: string; +} +/** Request message for CreateService method. */ +export interface CreateServiceRequest { + /** Required. Initial values for the service resource. */ + service?: ManagedService; +} +export interface CreateServiceRequestProtoMsg { + typeUrl: "/google.api.servicemanagement.v1.CreateServiceRequest"; + value: Uint8Array; +} +/** Request message for CreateService method. */ +export interface CreateServiceRequestSDKType { + service?: ManagedServiceSDKType; +} +/** Request message for DeleteService method. */ +export interface DeleteServiceRequest { + /** + * Required. The name of the service. See the [overview](/service-management/overview) + * for naming requirements. For example: `example.googleapis.com`. + */ + serviceName: string; +} +export interface DeleteServiceRequestProtoMsg { + typeUrl: "/google.api.servicemanagement.v1.DeleteServiceRequest"; + value: Uint8Array; +} +/** Request message for DeleteService method. */ +export interface DeleteServiceRequestSDKType { + service_name: string; +} +/** Request message for UndeleteService method. */ +export interface UndeleteServiceRequest { + /** + * Required. The name of the service. See the [overview](/service-management/overview) + * for naming requirements. For example: `example.googleapis.com`. + */ + serviceName: string; +} +export interface UndeleteServiceRequestProtoMsg { + typeUrl: "/google.api.servicemanagement.v1.UndeleteServiceRequest"; + value: Uint8Array; +} +/** Request message for UndeleteService method. */ +export interface UndeleteServiceRequestSDKType { + service_name: string; +} +/** Response message for UndeleteService method. */ +export interface UndeleteServiceResponse { + /** Revived service resource. */ + service?: ManagedService; +} +export interface UndeleteServiceResponseProtoMsg { + typeUrl: "/google.api.servicemanagement.v1.UndeleteServiceResponse"; + value: Uint8Array; +} +/** Response message for UndeleteService method. */ +export interface UndeleteServiceResponseSDKType { + service?: ManagedServiceSDKType; +} +/** Request message for GetServiceConfig method. */ +export interface GetServiceConfigRequest { + /** + * Required. The name of the service. See the [overview](/service-management/overview) + * for naming requirements. For example: `example.googleapis.com`. + */ + serviceName: string; + /** + * Required. The id of the service configuration resource. + * + * This field must be specified for the server to return all fields, including + * `SourceInfo`. + */ + configId: string; + /** + * Specifies which parts of the Service Config should be returned in the + * response. + */ + view: GetServiceConfigRequest_ConfigView; +} +export interface GetServiceConfigRequestProtoMsg { + typeUrl: "/google.api.servicemanagement.v1.GetServiceConfigRequest"; + value: Uint8Array; +} +/** Request message for GetServiceConfig method. */ +export interface GetServiceConfigRequestSDKType { + service_name: string; + config_id: string; + view: GetServiceConfigRequest_ConfigView; +} +/** Request message for ListServiceConfigs method. */ +export interface ListServiceConfigsRequest { + /** + * Required. The name of the service. See the [overview](/service-management/overview) + * for naming requirements. For example: `example.googleapis.com`. + */ + serviceName: string; + /** The token of the page to retrieve. */ + pageToken: string; + /** + * The max number of items to include in the response list. Page size is 50 + * if not specified. Maximum value is 100. + */ + pageSize: number; +} +export interface ListServiceConfigsRequestProtoMsg { + typeUrl: "/google.api.servicemanagement.v1.ListServiceConfigsRequest"; + value: Uint8Array; +} +/** Request message for ListServiceConfigs method. */ +export interface ListServiceConfigsRequestSDKType { + service_name: string; + page_token: string; + page_size: number; +} +/** Response message for ListServiceConfigs method. */ +export interface ListServiceConfigsResponse { + /** The list of service configuration resources. */ + serviceConfigs: Service[]; + /** The token of the next page of results. */ + nextPageToken: string; +} +export interface ListServiceConfigsResponseProtoMsg { + typeUrl: "/google.api.servicemanagement.v1.ListServiceConfigsResponse"; + value: Uint8Array; +} +/** Response message for ListServiceConfigs method. */ +export interface ListServiceConfigsResponseSDKType { + service_configs: ServiceSDKType[]; + next_page_token: string; +} +/** Request message for CreateServiceConfig method. */ +export interface CreateServiceConfigRequest { + /** + * Required. The name of the service. See the [overview](/service-management/overview) + * for naming requirements. For example: `example.googleapis.com`. + */ + serviceName: string; + /** Required. The service configuration resource. */ + serviceConfig?: Service; +} +export interface CreateServiceConfigRequestProtoMsg { + typeUrl: "/google.api.servicemanagement.v1.CreateServiceConfigRequest"; + value: Uint8Array; +} +/** Request message for CreateServiceConfig method. */ +export interface CreateServiceConfigRequestSDKType { + service_name: string; + service_config?: ServiceSDKType; +} +/** Request message for SubmitConfigSource method. */ +export interface SubmitConfigSourceRequest { + /** + * Required. The name of the service. See the [overview](/service-management/overview) + * for naming requirements. For example: `example.googleapis.com`. + */ + serviceName: string; + /** Required. The source configuration for the service. */ + configSource?: ConfigSource; + /** + * Optional. If set, this will result in the generation of a + * `google.api.Service` configuration based on the `ConfigSource` provided, + * but the generated config and the sources will NOT be persisted. + */ + validateOnly: boolean; +} +export interface SubmitConfigSourceRequestProtoMsg { + typeUrl: "/google.api.servicemanagement.v1.SubmitConfigSourceRequest"; + value: Uint8Array; +} +/** Request message for SubmitConfigSource method. */ +export interface SubmitConfigSourceRequestSDKType { + service_name: string; + config_source?: ConfigSourceSDKType; + validate_only: boolean; +} +/** Response message for SubmitConfigSource method. */ +export interface SubmitConfigSourceResponse { + /** The generated service configuration. */ + serviceConfig?: Service; +} +export interface SubmitConfigSourceResponseProtoMsg { + typeUrl: "/google.api.servicemanagement.v1.SubmitConfigSourceResponse"; + value: Uint8Array; +} +/** Response message for SubmitConfigSource method. */ +export interface SubmitConfigSourceResponseSDKType { + service_config?: ServiceSDKType; +} +/** Request message for 'CreateServiceRollout' */ +export interface CreateServiceRolloutRequest { + /** + * Required. The name of the service. See the [overview](/service-management/overview) + * for naming requirements. For example: `example.googleapis.com`. + */ + serviceName: string; + /** Required. The rollout resource. The `service_name` field is output only. */ + rollout?: Rollout; +} +export interface CreateServiceRolloutRequestProtoMsg { + typeUrl: "/google.api.servicemanagement.v1.CreateServiceRolloutRequest"; + value: Uint8Array; +} +/** Request message for 'CreateServiceRollout' */ +export interface CreateServiceRolloutRequestSDKType { + service_name: string; + rollout?: RolloutSDKType; +} +/** Request message for 'ListServiceRollouts' */ +export interface ListServiceRolloutsRequest { + /** + * Required. The name of the service. See the [overview](/service-management/overview) + * for naming requirements. For example: `example.googleapis.com`. + */ + serviceName: string; + /** The token of the page to retrieve. */ + pageToken: string; + /** + * The max number of items to include in the response list. Page size is 50 + * if not specified. Maximum value is 100. + */ + pageSize: number; + /** + * Required. Use `filter` to return subset of rollouts. + * The following filters are supported: + * -- To limit the results to only those in + * [status](google.api.servicemanagement.v1.RolloutStatus) 'SUCCESS', + * use filter='status=SUCCESS' + * -- To limit the results to those in + * [status](google.api.servicemanagement.v1.RolloutStatus) 'CANCELLED' + * or 'FAILED', use filter='status=CANCELLED OR status=FAILED' + */ + filter: string; +} +export interface ListServiceRolloutsRequestProtoMsg { + typeUrl: "/google.api.servicemanagement.v1.ListServiceRolloutsRequest"; + value: Uint8Array; +} +/** Request message for 'ListServiceRollouts' */ +export interface ListServiceRolloutsRequestSDKType { + service_name: string; + page_token: string; + page_size: number; + filter: string; +} +/** Response message for ListServiceRollouts method. */ +export interface ListServiceRolloutsResponse { + /** The list of rollout resources. */ + rollouts: Rollout[]; + /** The token of the next page of results. */ + nextPageToken: string; +} +export interface ListServiceRolloutsResponseProtoMsg { + typeUrl: "/google.api.servicemanagement.v1.ListServiceRolloutsResponse"; + value: Uint8Array; +} +/** Response message for ListServiceRollouts method. */ +export interface ListServiceRolloutsResponseSDKType { + rollouts: RolloutSDKType[]; + next_page_token: string; +} +/** Request message for GetServiceRollout method. */ +export interface GetServiceRolloutRequest { + /** + * Required. The name of the service. See the [overview](/service-management/overview) + * for naming requirements. For example: `example.googleapis.com`. + */ + serviceName: string; + /** Required. The id of the rollout resource. */ + rolloutId: string; +} +export interface GetServiceRolloutRequestProtoMsg { + typeUrl: "/google.api.servicemanagement.v1.GetServiceRolloutRequest"; + value: Uint8Array; +} +/** Request message for GetServiceRollout method. */ +export interface GetServiceRolloutRequestSDKType { + service_name: string; + rollout_id: string; +} +/** Request message for GenerateConfigReport method. */ +export interface GenerateConfigReportRequest { + /** + * Required. Service configuration for which we want to generate the report. + * For this version of API, the supported types are + * [google.api.servicemanagement.v1.ConfigRef][google.api.servicemanagement.v1.ConfigRef], + * [google.api.servicemanagement.v1.ConfigSource][google.api.servicemanagement.v1.ConfigSource], + * and [google.api.Service][google.api.Service] + */ + newConfig?: Any; + /** + * Optional. Service configuration against which the comparison will be done. + * For this version of API, the supported types are + * [google.api.servicemanagement.v1.ConfigRef][google.api.servicemanagement.v1.ConfigRef], + * [google.api.servicemanagement.v1.ConfigSource][google.api.servicemanagement.v1.ConfigSource], + * and [google.api.Service][google.api.Service] + */ + oldConfig?: Any; +} +export interface GenerateConfigReportRequestProtoMsg { + typeUrl: "/google.api.servicemanagement.v1.GenerateConfigReportRequest"; + value: Uint8Array; +} +/** Request message for GenerateConfigReport method. */ +export interface GenerateConfigReportRequestSDKType { + new_config?: AnySDKType; + old_config?: AnySDKType; +} +/** Response message for GenerateConfigReport method. */ +export interface GenerateConfigReportResponse { + /** Name of the service this report belongs to. */ + serviceName: string; + /** ID of the service configuration this report belongs to. */ + id: string; + /** + * list of ChangeReport, each corresponding to comparison between two + * service configurations. + */ + changeReports: ChangeReport[]; + /** + * Errors / Linter warnings associated with the service definition this + * report + * belongs to. + */ + diagnostics: Diagnostic[]; +} +export interface GenerateConfigReportResponseProtoMsg { + typeUrl: "/google.api.servicemanagement.v1.GenerateConfigReportResponse"; + value: Uint8Array; +} +/** Response message for GenerateConfigReport method. */ +export interface GenerateConfigReportResponseSDKType { + service_name: string; + id: string; + change_reports: ChangeReportSDKType[]; + diagnostics: DiagnosticSDKType[]; +} +function createBaseListServicesRequest(): ListServicesRequest { + return { + producerProjectId: "", + pageSize: 0, + pageToken: "", + consumerId: "" + }; +} +export const ListServicesRequest = { + typeUrl: "/google.api.servicemanagement.v1.ListServicesRequest", + encode(message: ListServicesRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.producerProjectId !== undefined) { + writer.uint32(10).string(message.producerProjectId); + } + if (message.pageSize !== undefined) { + writer.uint32(40).int32(message.pageSize); + } + if (message.pageToken !== undefined) { + writer.uint32(50).string(message.pageToken); + } + if (message.consumerId !== undefined) { + writer.uint32(58).string(message.consumerId); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ListServicesRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseListServicesRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.producerProjectId = reader.string(); + break; + case 5: + message.pageSize = reader.int32(); + break; + case 6: + message.pageToken = reader.string(); + break; + case 7: + message.consumerId = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ListServicesRequest { + const obj = createBaseListServicesRequest(); + if (isSet(object.producerProjectId)) obj.producerProjectId = String(object.producerProjectId); + if (isSet(object.pageSize)) obj.pageSize = Number(object.pageSize); + if (isSet(object.pageToken)) obj.pageToken = String(object.pageToken); + if (isSet(object.consumerId)) obj.consumerId = String(object.consumerId); + return obj; + }, + toJSON(message: ListServicesRequest): JsonSafe { + const obj: any = {}; + message.producerProjectId !== undefined && (obj.producerProjectId = message.producerProjectId); + message.pageSize !== undefined && (obj.pageSize = Math.round(message.pageSize)); + message.pageToken !== undefined && (obj.pageToken = message.pageToken); + message.consumerId !== undefined && (obj.consumerId = message.consumerId); + return obj; + }, + fromPartial(object: DeepPartial): ListServicesRequest { + const message = createBaseListServicesRequest(); + message.producerProjectId = object.producerProjectId ?? ""; + message.pageSize = object.pageSize ?? 0; + message.pageToken = object.pageToken ?? ""; + message.consumerId = object.consumerId ?? ""; + return message; + }, + fromSDK(object: ListServicesRequestSDKType): ListServicesRequest { + return { + producerProjectId: object?.producer_project_id, + pageSize: object?.page_size, + pageToken: object?.page_token, + consumerId: object?.consumer_id + }; + }, + fromSDKJSON(object: any): ListServicesRequestSDKType { + return { + producer_project_id: isSet(object.producer_project_id) ? String(object.producer_project_id) : "", + page_size: isSet(object.page_size) ? Number(object.page_size) : 0, + page_token: isSet(object.page_token) ? String(object.page_token) : "", + consumer_id: isSet(object.consumer_id) ? String(object.consumer_id) : "" + }; + }, + toSDK(message: ListServicesRequest): ListServicesRequestSDKType { + const obj: any = {}; + obj.producer_project_id = message.producerProjectId; + obj.page_size = message.pageSize; + obj.page_token = message.pageToken; + obj.consumer_id = message.consumerId; + return obj; + }, + fromAmino(object: ListServicesRequestAmino): ListServicesRequest { + const message = createBaseListServicesRequest(); + if (object.producer_project_id !== undefined && object.producer_project_id !== null) { + message.producerProjectId = object.producer_project_id; + } + if (object.page_size !== undefined && object.page_size !== null) { + message.pageSize = object.page_size; + } + if (object.page_token !== undefined && object.page_token !== null) { + message.pageToken = object.page_token; + } + if (object.consumer_id !== undefined && object.consumer_id !== null) { + message.consumerId = object.consumer_id; + } + return message; + }, + toAmino(message: ListServicesRequest): ListServicesRequestAmino { + const obj: any = {}; + obj.producer_project_id = message.producerProjectId === "" ? undefined : message.producerProjectId; + obj.page_size = message.pageSize === 0 ? undefined : message.pageSize; + obj.page_token = message.pageToken === "" ? undefined : message.pageToken; + obj.consumer_id = message.consumerId === "" ? undefined : message.consumerId; + return obj; + }, + fromAminoMsg(object: ListServicesRequestAminoMsg): ListServicesRequest { + return ListServicesRequest.fromAmino(object.value); + }, + fromProtoMsg(message: ListServicesRequestProtoMsg): ListServicesRequest { + return ListServicesRequest.decode(message.value); + }, + toProto(message: ListServicesRequest): Uint8Array { + return ListServicesRequest.encode(message).finish(); + }, + toProtoMsg(message: ListServicesRequest): ListServicesRequestProtoMsg { + return { + typeUrl: "/google.api.servicemanagement.v1.ListServicesRequest", + value: ListServicesRequest.encode(message).finish() + }; + } +}; +function createBaseListServicesResponse(): ListServicesResponse { + return { + services: [], + nextPageToken: "" + }; +} +export const ListServicesResponse = { + typeUrl: "/google.api.servicemanagement.v1.ListServicesResponse", + encode(message: ListServicesResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.services) { + ManagedService.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.nextPageToken !== undefined) { + writer.uint32(18).string(message.nextPageToken); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ListServicesResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseListServicesResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.services.push(ManagedService.decode(reader, reader.uint32())); + break; + case 2: + message.nextPageToken = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ListServicesResponse { + const obj = createBaseListServicesResponse(); + if (Array.isArray(object?.services)) obj.services = object.services.map((e: any) => ManagedService.fromJSON(e)); + if (isSet(object.nextPageToken)) obj.nextPageToken = String(object.nextPageToken); + return obj; + }, + toJSON(message: ListServicesResponse): JsonSafe { + const obj: any = {}; + if (message.services) { + obj.services = message.services.map(e => e ? ManagedService.toJSON(e) : undefined); + } else { + obj.services = []; + } + message.nextPageToken !== undefined && (obj.nextPageToken = message.nextPageToken); + return obj; + }, + fromPartial(object: DeepPartial): ListServicesResponse { + const message = createBaseListServicesResponse(); + message.services = object.services?.map(e => ManagedService.fromPartial(e)) || []; + message.nextPageToken = object.nextPageToken ?? ""; + return message; + }, + fromSDK(object: ListServicesResponseSDKType): ListServicesResponse { + return { + services: Array.isArray(object?.services) ? object.services.map((e: any) => ManagedService.fromSDK(e)) : [], + nextPageToken: object?.next_page_token + }; + }, + fromSDKJSON(object: any): ListServicesResponseSDKType { + return { + services: Array.isArray(object?.services) ? object.services.map((e: any) => ManagedService.fromSDKJSON(e)) : [], + next_page_token: isSet(object.next_page_token) ? String(object.next_page_token) : "" + }; + }, + toSDK(message: ListServicesResponse): ListServicesResponseSDKType { + const obj: any = {}; + if (message.services) { + obj.services = message.services.map(e => e ? ManagedService.toSDK(e) : undefined); + } else { + obj.services = []; + } + obj.next_page_token = message.nextPageToken; + return obj; + }, + fromAmino(object: ListServicesResponseAmino): ListServicesResponse { + const message = createBaseListServicesResponse(); + message.services = object.services?.map(e => ManagedService.fromAmino(e)) || []; + if (object.next_page_token !== undefined && object.next_page_token !== null) { + message.nextPageToken = object.next_page_token; + } + return message; + }, + toAmino(message: ListServicesResponse): ListServicesResponseAmino { + const obj: any = {}; + if (message.services) { + obj.services = message.services.map(e => e ? ManagedService.toAmino(e) : undefined); + } else { + obj.services = message.services; + } + obj.next_page_token = message.nextPageToken === "" ? undefined : message.nextPageToken; + return obj; + }, + fromAminoMsg(object: ListServicesResponseAminoMsg): ListServicesResponse { + return ListServicesResponse.fromAmino(object.value); + }, + fromProtoMsg(message: ListServicesResponseProtoMsg): ListServicesResponse { + return ListServicesResponse.decode(message.value); + }, + toProto(message: ListServicesResponse): Uint8Array { + return ListServicesResponse.encode(message).finish(); + }, + toProtoMsg(message: ListServicesResponse): ListServicesResponseProtoMsg { + return { + typeUrl: "/google.api.servicemanagement.v1.ListServicesResponse", + value: ListServicesResponse.encode(message).finish() + }; + } +}; +function createBaseGetServiceRequest(): GetServiceRequest { + return { + serviceName: "" + }; +} +export const GetServiceRequest = { + typeUrl: "/google.api.servicemanagement.v1.GetServiceRequest", + encode(message: GetServiceRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.serviceName !== undefined) { + writer.uint32(10).string(message.serviceName); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GetServiceRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGetServiceRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.serviceName = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GetServiceRequest { + const obj = createBaseGetServiceRequest(); + if (isSet(object.serviceName)) obj.serviceName = String(object.serviceName); + return obj; + }, + toJSON(message: GetServiceRequest): JsonSafe { + const obj: any = {}; + message.serviceName !== undefined && (obj.serviceName = message.serviceName); + return obj; + }, + fromPartial(object: DeepPartial): GetServiceRequest { + const message = createBaseGetServiceRequest(); + message.serviceName = object.serviceName ?? ""; + return message; + }, + fromSDK(object: GetServiceRequestSDKType): GetServiceRequest { + return { + serviceName: object?.service_name + }; + }, + fromSDKJSON(object: any): GetServiceRequestSDKType { + return { + service_name: isSet(object.service_name) ? String(object.service_name) : "" + }; + }, + toSDK(message: GetServiceRequest): GetServiceRequestSDKType { + const obj: any = {}; + obj.service_name = message.serviceName; + return obj; + }, + fromAmino(object: GetServiceRequestAmino): GetServiceRequest { + const message = createBaseGetServiceRequest(); + if (object.service_name !== undefined && object.service_name !== null) { + message.serviceName = object.service_name; + } + return message; + }, + toAmino(message: GetServiceRequest): GetServiceRequestAmino { + const obj: any = {}; + obj.service_name = message.serviceName === "" ? undefined : message.serviceName; + return obj; + }, + fromAminoMsg(object: GetServiceRequestAminoMsg): GetServiceRequest { + return GetServiceRequest.fromAmino(object.value); + }, + fromProtoMsg(message: GetServiceRequestProtoMsg): GetServiceRequest { + return GetServiceRequest.decode(message.value); + }, + toProto(message: GetServiceRequest): Uint8Array { + return GetServiceRequest.encode(message).finish(); + }, + toProtoMsg(message: GetServiceRequest): GetServiceRequestProtoMsg { + return { + typeUrl: "/google.api.servicemanagement.v1.GetServiceRequest", + value: GetServiceRequest.encode(message).finish() + }; + } +}; +function createBaseCreateServiceRequest(): CreateServiceRequest { + return { + service: undefined + }; +} +export const CreateServiceRequest = { + typeUrl: "/google.api.servicemanagement.v1.CreateServiceRequest", + encode(message: CreateServiceRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.service !== undefined) { + ManagedService.encode(message.service, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): CreateServiceRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCreateServiceRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.service = ManagedService.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): CreateServiceRequest { + const obj = createBaseCreateServiceRequest(); + if (isSet(object.service)) obj.service = ManagedService.fromJSON(object.service); + return obj; + }, + toJSON(message: CreateServiceRequest): JsonSafe { + const obj: any = {}; + message.service !== undefined && (obj.service = message.service ? ManagedService.toJSON(message.service) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): CreateServiceRequest { + const message = createBaseCreateServiceRequest(); + if (object.service !== undefined && object.service !== null) { + message.service = ManagedService.fromPartial(object.service); + } + return message; + }, + fromSDK(object: CreateServiceRequestSDKType): CreateServiceRequest { + return { + service: object.service ? ManagedService.fromSDK(object.service) : undefined + }; + }, + fromSDKJSON(object: any): CreateServiceRequestSDKType { + return { + service: isSet(object.service) ? ManagedService.fromSDKJSON(object.service) : undefined + }; + }, + toSDK(message: CreateServiceRequest): CreateServiceRequestSDKType { + const obj: any = {}; + message.service !== undefined && (obj.service = message.service ? ManagedService.toSDK(message.service) : undefined); + return obj; + }, + fromAmino(object: CreateServiceRequestAmino): CreateServiceRequest { + const message = createBaseCreateServiceRequest(); + if (object.service !== undefined && object.service !== null) { + message.service = ManagedService.fromAmino(object.service); + } + return message; + }, + toAmino(message: CreateServiceRequest): CreateServiceRequestAmino { + const obj: any = {}; + obj.service = message.service ? ManagedService.toAmino(message.service) : undefined; + return obj; + }, + fromAminoMsg(object: CreateServiceRequestAminoMsg): CreateServiceRequest { + return CreateServiceRequest.fromAmino(object.value); + }, + fromProtoMsg(message: CreateServiceRequestProtoMsg): CreateServiceRequest { + return CreateServiceRequest.decode(message.value); + }, + toProto(message: CreateServiceRequest): Uint8Array { + return CreateServiceRequest.encode(message).finish(); + }, + toProtoMsg(message: CreateServiceRequest): CreateServiceRequestProtoMsg { + return { + typeUrl: "/google.api.servicemanagement.v1.CreateServiceRequest", + value: CreateServiceRequest.encode(message).finish() + }; + } +}; +function createBaseDeleteServiceRequest(): DeleteServiceRequest { + return { + serviceName: "" + }; +} +export const DeleteServiceRequest = { + typeUrl: "/google.api.servicemanagement.v1.DeleteServiceRequest", + encode(message: DeleteServiceRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.serviceName !== undefined) { + writer.uint32(10).string(message.serviceName); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): DeleteServiceRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDeleteServiceRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.serviceName = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): DeleteServiceRequest { + const obj = createBaseDeleteServiceRequest(); + if (isSet(object.serviceName)) obj.serviceName = String(object.serviceName); + return obj; + }, + toJSON(message: DeleteServiceRequest): JsonSafe { + const obj: any = {}; + message.serviceName !== undefined && (obj.serviceName = message.serviceName); + return obj; + }, + fromPartial(object: DeepPartial): DeleteServiceRequest { + const message = createBaseDeleteServiceRequest(); + message.serviceName = object.serviceName ?? ""; + return message; + }, + fromSDK(object: DeleteServiceRequestSDKType): DeleteServiceRequest { + return { + serviceName: object?.service_name + }; + }, + fromSDKJSON(object: any): DeleteServiceRequestSDKType { + return { + service_name: isSet(object.service_name) ? String(object.service_name) : "" + }; + }, + toSDK(message: DeleteServiceRequest): DeleteServiceRequestSDKType { + const obj: any = {}; + obj.service_name = message.serviceName; + return obj; + }, + fromAmino(object: DeleteServiceRequestAmino): DeleteServiceRequest { + const message = createBaseDeleteServiceRequest(); + if (object.service_name !== undefined && object.service_name !== null) { + message.serviceName = object.service_name; + } + return message; + }, + toAmino(message: DeleteServiceRequest): DeleteServiceRequestAmino { + const obj: any = {}; + obj.service_name = message.serviceName === "" ? undefined : message.serviceName; + return obj; + }, + fromAminoMsg(object: DeleteServiceRequestAminoMsg): DeleteServiceRequest { + return DeleteServiceRequest.fromAmino(object.value); + }, + fromProtoMsg(message: DeleteServiceRequestProtoMsg): DeleteServiceRequest { + return DeleteServiceRequest.decode(message.value); + }, + toProto(message: DeleteServiceRequest): Uint8Array { + return DeleteServiceRequest.encode(message).finish(); + }, + toProtoMsg(message: DeleteServiceRequest): DeleteServiceRequestProtoMsg { + return { + typeUrl: "/google.api.servicemanagement.v1.DeleteServiceRequest", + value: DeleteServiceRequest.encode(message).finish() + }; + } +}; +function createBaseUndeleteServiceRequest(): UndeleteServiceRequest { + return { + serviceName: "" + }; +} +export const UndeleteServiceRequest = { + typeUrl: "/google.api.servicemanagement.v1.UndeleteServiceRequest", + encode(message: UndeleteServiceRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.serviceName !== undefined) { + writer.uint32(10).string(message.serviceName); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): UndeleteServiceRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseUndeleteServiceRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.serviceName = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): UndeleteServiceRequest { + const obj = createBaseUndeleteServiceRequest(); + if (isSet(object.serviceName)) obj.serviceName = String(object.serviceName); + return obj; + }, + toJSON(message: UndeleteServiceRequest): JsonSafe { + const obj: any = {}; + message.serviceName !== undefined && (obj.serviceName = message.serviceName); + return obj; + }, + fromPartial(object: DeepPartial): UndeleteServiceRequest { + const message = createBaseUndeleteServiceRequest(); + message.serviceName = object.serviceName ?? ""; + return message; + }, + fromSDK(object: UndeleteServiceRequestSDKType): UndeleteServiceRequest { + return { + serviceName: object?.service_name + }; + }, + fromSDKJSON(object: any): UndeleteServiceRequestSDKType { + return { + service_name: isSet(object.service_name) ? String(object.service_name) : "" + }; + }, + toSDK(message: UndeleteServiceRequest): UndeleteServiceRequestSDKType { + const obj: any = {}; + obj.service_name = message.serviceName; + return obj; + }, + fromAmino(object: UndeleteServiceRequestAmino): UndeleteServiceRequest { + const message = createBaseUndeleteServiceRequest(); + if (object.service_name !== undefined && object.service_name !== null) { + message.serviceName = object.service_name; + } + return message; + }, + toAmino(message: UndeleteServiceRequest): UndeleteServiceRequestAmino { + const obj: any = {}; + obj.service_name = message.serviceName === "" ? undefined : message.serviceName; + return obj; + }, + fromAminoMsg(object: UndeleteServiceRequestAminoMsg): UndeleteServiceRequest { + return UndeleteServiceRequest.fromAmino(object.value); + }, + fromProtoMsg(message: UndeleteServiceRequestProtoMsg): UndeleteServiceRequest { + return UndeleteServiceRequest.decode(message.value); + }, + toProto(message: UndeleteServiceRequest): Uint8Array { + return UndeleteServiceRequest.encode(message).finish(); + }, + toProtoMsg(message: UndeleteServiceRequest): UndeleteServiceRequestProtoMsg { + return { + typeUrl: "/google.api.servicemanagement.v1.UndeleteServiceRequest", + value: UndeleteServiceRequest.encode(message).finish() + }; + } +}; +function createBaseUndeleteServiceResponse(): UndeleteServiceResponse { + return { + service: undefined + }; +} +export const UndeleteServiceResponse = { + typeUrl: "/google.api.servicemanagement.v1.UndeleteServiceResponse", + encode(message: UndeleteServiceResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.service !== undefined) { + ManagedService.encode(message.service, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): UndeleteServiceResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseUndeleteServiceResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.service = ManagedService.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): UndeleteServiceResponse { + const obj = createBaseUndeleteServiceResponse(); + if (isSet(object.service)) obj.service = ManagedService.fromJSON(object.service); + return obj; + }, + toJSON(message: UndeleteServiceResponse): JsonSafe { + const obj: any = {}; + message.service !== undefined && (obj.service = message.service ? ManagedService.toJSON(message.service) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): UndeleteServiceResponse { + const message = createBaseUndeleteServiceResponse(); + if (object.service !== undefined && object.service !== null) { + message.service = ManagedService.fromPartial(object.service); + } + return message; + }, + fromSDK(object: UndeleteServiceResponseSDKType): UndeleteServiceResponse { + return { + service: object.service ? ManagedService.fromSDK(object.service) : undefined + }; + }, + fromSDKJSON(object: any): UndeleteServiceResponseSDKType { + return { + service: isSet(object.service) ? ManagedService.fromSDKJSON(object.service) : undefined + }; + }, + toSDK(message: UndeleteServiceResponse): UndeleteServiceResponseSDKType { + const obj: any = {}; + message.service !== undefined && (obj.service = message.service ? ManagedService.toSDK(message.service) : undefined); + return obj; + }, + fromAmino(object: UndeleteServiceResponseAmino): UndeleteServiceResponse { + const message = createBaseUndeleteServiceResponse(); + if (object.service !== undefined && object.service !== null) { + message.service = ManagedService.fromAmino(object.service); + } + return message; + }, + toAmino(message: UndeleteServiceResponse): UndeleteServiceResponseAmino { + const obj: any = {}; + obj.service = message.service ? ManagedService.toAmino(message.service) : undefined; + return obj; + }, + fromAminoMsg(object: UndeleteServiceResponseAminoMsg): UndeleteServiceResponse { + return UndeleteServiceResponse.fromAmino(object.value); + }, + fromProtoMsg(message: UndeleteServiceResponseProtoMsg): UndeleteServiceResponse { + return UndeleteServiceResponse.decode(message.value); + }, + toProto(message: UndeleteServiceResponse): Uint8Array { + return UndeleteServiceResponse.encode(message).finish(); + }, + toProtoMsg(message: UndeleteServiceResponse): UndeleteServiceResponseProtoMsg { + return { + typeUrl: "/google.api.servicemanagement.v1.UndeleteServiceResponse", + value: UndeleteServiceResponse.encode(message).finish() + }; + } +}; +function createBaseGetServiceConfigRequest(): GetServiceConfigRequest { + return { + serviceName: "", + configId: "", + view: 0 + }; +} +export const GetServiceConfigRequest = { + typeUrl: "/google.api.servicemanagement.v1.GetServiceConfigRequest", + encode(message: GetServiceConfigRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.serviceName !== undefined) { + writer.uint32(10).string(message.serviceName); + } + if (message.configId !== undefined) { + writer.uint32(18).string(message.configId); + } + if (message.view !== 0) { + writer.uint32(24).int32(message.view); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GetServiceConfigRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGetServiceConfigRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.serviceName = reader.string(); + break; + case 2: + message.configId = reader.string(); + break; + case 3: + message.view = (reader.int32() as any); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GetServiceConfigRequest { + const obj = createBaseGetServiceConfigRequest(); + if (isSet(object.serviceName)) obj.serviceName = String(object.serviceName); + if (isSet(object.configId)) obj.configId = String(object.configId); + if (isSet(object.view)) obj.view = getServiceConfigRequest_ConfigViewFromJSON(object.view); + return obj; + }, + toJSON(message: GetServiceConfigRequest): JsonSafe { + const obj: any = {}; + message.serviceName !== undefined && (obj.serviceName = message.serviceName); + message.configId !== undefined && (obj.configId = message.configId); + message.view !== undefined && (obj.view = getServiceConfigRequest_ConfigViewToJSON(message.view)); + return obj; + }, + fromPartial(object: DeepPartial): GetServiceConfigRequest { + const message = createBaseGetServiceConfigRequest(); + message.serviceName = object.serviceName ?? ""; + message.configId = object.configId ?? ""; + message.view = object.view ?? 0; + return message; + }, + fromSDK(object: GetServiceConfigRequestSDKType): GetServiceConfigRequest { + return { + serviceName: object?.service_name, + configId: object?.config_id, + view: isSet(object.view) ? getServiceConfigRequest_ConfigViewFromJSON(object.view) : -1 + }; + }, + fromSDKJSON(object: any): GetServiceConfigRequestSDKType { + return { + service_name: isSet(object.service_name) ? String(object.service_name) : "", + config_id: isSet(object.config_id) ? String(object.config_id) : "", + view: isSet(object.view) ? getServiceConfigRequest_ConfigViewFromJSON(object.view) : -1 + }; + }, + toSDK(message: GetServiceConfigRequest): GetServiceConfigRequestSDKType { + const obj: any = {}; + obj.service_name = message.serviceName; + obj.config_id = message.configId; + message.view !== undefined && (obj.view = getServiceConfigRequest_ConfigViewToJSON(message.view)); + return obj; + }, + fromAmino(object: GetServiceConfigRequestAmino): GetServiceConfigRequest { + const message = createBaseGetServiceConfigRequest(); + if (object.service_name !== undefined && object.service_name !== null) { + message.serviceName = object.service_name; + } + if (object.config_id !== undefined && object.config_id !== null) { + message.configId = object.config_id; + } + if (object.view !== undefined && object.view !== null) { + message.view = object.view; + } + return message; + }, + toAmino(message: GetServiceConfigRequest): GetServiceConfigRequestAmino { + const obj: any = {}; + obj.service_name = message.serviceName === "" ? undefined : message.serviceName; + obj.config_id = message.configId === "" ? undefined : message.configId; + obj.view = message.view === 0 ? undefined : message.view; + return obj; + }, + fromAminoMsg(object: GetServiceConfigRequestAminoMsg): GetServiceConfigRequest { + return GetServiceConfigRequest.fromAmino(object.value); + }, + fromProtoMsg(message: GetServiceConfigRequestProtoMsg): GetServiceConfigRequest { + return GetServiceConfigRequest.decode(message.value); + }, + toProto(message: GetServiceConfigRequest): Uint8Array { + return GetServiceConfigRequest.encode(message).finish(); + }, + toProtoMsg(message: GetServiceConfigRequest): GetServiceConfigRequestProtoMsg { + return { + typeUrl: "/google.api.servicemanagement.v1.GetServiceConfigRequest", + value: GetServiceConfigRequest.encode(message).finish() + }; + } +}; +function createBaseListServiceConfigsRequest(): ListServiceConfigsRequest { + return { + serviceName: "", + pageToken: "", + pageSize: 0 + }; +} +export const ListServiceConfigsRequest = { + typeUrl: "/google.api.servicemanagement.v1.ListServiceConfigsRequest", + encode(message: ListServiceConfigsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.serviceName !== undefined) { + writer.uint32(10).string(message.serviceName); + } + if (message.pageToken !== undefined) { + writer.uint32(18).string(message.pageToken); + } + if (message.pageSize !== undefined) { + writer.uint32(24).int32(message.pageSize); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ListServiceConfigsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseListServiceConfigsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.serviceName = reader.string(); + break; + case 2: + message.pageToken = reader.string(); + break; + case 3: + message.pageSize = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ListServiceConfigsRequest { + const obj = createBaseListServiceConfigsRequest(); + if (isSet(object.serviceName)) obj.serviceName = String(object.serviceName); + if (isSet(object.pageToken)) obj.pageToken = String(object.pageToken); + if (isSet(object.pageSize)) obj.pageSize = Number(object.pageSize); + return obj; + }, + toJSON(message: ListServiceConfigsRequest): JsonSafe { + const obj: any = {}; + message.serviceName !== undefined && (obj.serviceName = message.serviceName); + message.pageToken !== undefined && (obj.pageToken = message.pageToken); + message.pageSize !== undefined && (obj.pageSize = Math.round(message.pageSize)); + return obj; + }, + fromPartial(object: DeepPartial): ListServiceConfigsRequest { + const message = createBaseListServiceConfigsRequest(); + message.serviceName = object.serviceName ?? ""; + message.pageToken = object.pageToken ?? ""; + message.pageSize = object.pageSize ?? 0; + return message; + }, + fromSDK(object: ListServiceConfigsRequestSDKType): ListServiceConfigsRequest { + return { + serviceName: object?.service_name, + pageToken: object?.page_token, + pageSize: object?.page_size + }; + }, + fromSDKJSON(object: any): ListServiceConfigsRequestSDKType { + return { + service_name: isSet(object.service_name) ? String(object.service_name) : "", + page_token: isSet(object.page_token) ? String(object.page_token) : "", + page_size: isSet(object.page_size) ? Number(object.page_size) : 0 + }; + }, + toSDK(message: ListServiceConfigsRequest): ListServiceConfigsRequestSDKType { + const obj: any = {}; + obj.service_name = message.serviceName; + obj.page_token = message.pageToken; + obj.page_size = message.pageSize; + return obj; + }, + fromAmino(object: ListServiceConfigsRequestAmino): ListServiceConfigsRequest { + const message = createBaseListServiceConfigsRequest(); + if (object.service_name !== undefined && object.service_name !== null) { + message.serviceName = object.service_name; + } + if (object.page_token !== undefined && object.page_token !== null) { + message.pageToken = object.page_token; + } + if (object.page_size !== undefined && object.page_size !== null) { + message.pageSize = object.page_size; + } + return message; + }, + toAmino(message: ListServiceConfigsRequest): ListServiceConfigsRequestAmino { + const obj: any = {}; + obj.service_name = message.serviceName === "" ? undefined : message.serviceName; + obj.page_token = message.pageToken === "" ? undefined : message.pageToken; + obj.page_size = message.pageSize === 0 ? undefined : message.pageSize; + return obj; + }, + fromAminoMsg(object: ListServiceConfigsRequestAminoMsg): ListServiceConfigsRequest { + return ListServiceConfigsRequest.fromAmino(object.value); + }, + fromProtoMsg(message: ListServiceConfigsRequestProtoMsg): ListServiceConfigsRequest { + return ListServiceConfigsRequest.decode(message.value); + }, + toProto(message: ListServiceConfigsRequest): Uint8Array { + return ListServiceConfigsRequest.encode(message).finish(); + }, + toProtoMsg(message: ListServiceConfigsRequest): ListServiceConfigsRequestProtoMsg { + return { + typeUrl: "/google.api.servicemanagement.v1.ListServiceConfigsRequest", + value: ListServiceConfigsRequest.encode(message).finish() + }; + } +}; +function createBaseListServiceConfigsResponse(): ListServiceConfigsResponse { + return { + serviceConfigs: [], + nextPageToken: "" + }; +} +export const ListServiceConfigsResponse = { + typeUrl: "/google.api.servicemanagement.v1.ListServiceConfigsResponse", + encode(message: ListServiceConfigsResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.serviceConfigs) { + Service.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.nextPageToken !== undefined) { + writer.uint32(18).string(message.nextPageToken); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ListServiceConfigsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseListServiceConfigsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.serviceConfigs.push(Service.decode(reader, reader.uint32())); + break; + case 2: + message.nextPageToken = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ListServiceConfigsResponse { + const obj = createBaseListServiceConfigsResponse(); + if (Array.isArray(object?.serviceConfigs)) obj.serviceConfigs = object.serviceConfigs.map((e: any) => Service.fromJSON(e)); + if (isSet(object.nextPageToken)) obj.nextPageToken = String(object.nextPageToken); + return obj; + }, + toJSON(message: ListServiceConfigsResponse): JsonSafe { + const obj: any = {}; + if (message.serviceConfigs) { + obj.serviceConfigs = message.serviceConfigs.map(e => e ? Service.toJSON(e) : undefined); + } else { + obj.serviceConfigs = []; + } + message.nextPageToken !== undefined && (obj.nextPageToken = message.nextPageToken); + return obj; + }, + fromPartial(object: DeepPartial): ListServiceConfigsResponse { + const message = createBaseListServiceConfigsResponse(); + message.serviceConfigs = object.serviceConfigs?.map(e => Service.fromPartial(e)) || []; + message.nextPageToken = object.nextPageToken ?? ""; + return message; + }, + fromSDK(object: ListServiceConfigsResponseSDKType): ListServiceConfigsResponse { + return { + serviceConfigs: Array.isArray(object?.service_configs) ? object.service_configs.map((e: any) => Service.fromSDK(e)) : [], + nextPageToken: object?.next_page_token + }; + }, + fromSDKJSON(object: any): ListServiceConfigsResponseSDKType { + return { + service_configs: Array.isArray(object?.service_configs) ? object.service_configs.map((e: any) => Service.fromSDKJSON(e)) : [], + next_page_token: isSet(object.next_page_token) ? String(object.next_page_token) : "" + }; + }, + toSDK(message: ListServiceConfigsResponse): ListServiceConfigsResponseSDKType { + const obj: any = {}; + if (message.serviceConfigs) { + obj.service_configs = message.serviceConfigs.map(e => e ? Service.toSDK(e) : undefined); + } else { + obj.service_configs = []; + } + obj.next_page_token = message.nextPageToken; + return obj; + }, + fromAmino(object: ListServiceConfigsResponseAmino): ListServiceConfigsResponse { + const message = createBaseListServiceConfigsResponse(); + message.serviceConfigs = object.service_configs?.map(e => Service.fromAmino(e)) || []; + if (object.next_page_token !== undefined && object.next_page_token !== null) { + message.nextPageToken = object.next_page_token; + } + return message; + }, + toAmino(message: ListServiceConfigsResponse): ListServiceConfigsResponseAmino { + const obj: any = {}; + if (message.serviceConfigs) { + obj.service_configs = message.serviceConfigs.map(e => e ? Service.toAmino(e) : undefined); + } else { + obj.service_configs = message.serviceConfigs; + } + obj.next_page_token = message.nextPageToken === "" ? undefined : message.nextPageToken; + return obj; + }, + fromAminoMsg(object: ListServiceConfigsResponseAminoMsg): ListServiceConfigsResponse { + return ListServiceConfigsResponse.fromAmino(object.value); + }, + fromProtoMsg(message: ListServiceConfigsResponseProtoMsg): ListServiceConfigsResponse { + return ListServiceConfigsResponse.decode(message.value); + }, + toProto(message: ListServiceConfigsResponse): Uint8Array { + return ListServiceConfigsResponse.encode(message).finish(); + }, + toProtoMsg(message: ListServiceConfigsResponse): ListServiceConfigsResponseProtoMsg { + return { + typeUrl: "/google.api.servicemanagement.v1.ListServiceConfigsResponse", + value: ListServiceConfigsResponse.encode(message).finish() + }; + } +}; +function createBaseCreateServiceConfigRequest(): CreateServiceConfigRequest { + return { + serviceName: "", + serviceConfig: undefined + }; +} +export const CreateServiceConfigRequest = { + typeUrl: "/google.api.servicemanagement.v1.CreateServiceConfigRequest", + encode(message: CreateServiceConfigRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.serviceName !== undefined) { + writer.uint32(10).string(message.serviceName); + } + if (message.serviceConfig !== undefined) { + Service.encode(message.serviceConfig, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): CreateServiceConfigRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCreateServiceConfigRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.serviceName = reader.string(); + break; + case 2: + message.serviceConfig = Service.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): CreateServiceConfigRequest { + const obj = createBaseCreateServiceConfigRequest(); + if (isSet(object.serviceName)) obj.serviceName = String(object.serviceName); + if (isSet(object.serviceConfig)) obj.serviceConfig = Service.fromJSON(object.serviceConfig); + return obj; + }, + toJSON(message: CreateServiceConfigRequest): JsonSafe { + const obj: any = {}; + message.serviceName !== undefined && (obj.serviceName = message.serviceName); + message.serviceConfig !== undefined && (obj.serviceConfig = message.serviceConfig ? Service.toJSON(message.serviceConfig) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): CreateServiceConfigRequest { + const message = createBaseCreateServiceConfigRequest(); + message.serviceName = object.serviceName ?? ""; + if (object.serviceConfig !== undefined && object.serviceConfig !== null) { + message.serviceConfig = Service.fromPartial(object.serviceConfig); + } + return message; + }, + fromSDK(object: CreateServiceConfigRequestSDKType): CreateServiceConfigRequest { + return { + serviceName: object?.service_name, + serviceConfig: object.service_config ? Service.fromSDK(object.service_config) : undefined + }; + }, + fromSDKJSON(object: any): CreateServiceConfigRequestSDKType { + return { + service_name: isSet(object.service_name) ? String(object.service_name) : "", + service_config: isSet(object.service_config) ? Service.fromSDKJSON(object.service_config) : undefined + }; + }, + toSDK(message: CreateServiceConfigRequest): CreateServiceConfigRequestSDKType { + const obj: any = {}; + obj.service_name = message.serviceName; + message.serviceConfig !== undefined && (obj.service_config = message.serviceConfig ? Service.toSDK(message.serviceConfig) : undefined); + return obj; + }, + fromAmino(object: CreateServiceConfigRequestAmino): CreateServiceConfigRequest { + const message = createBaseCreateServiceConfigRequest(); + if (object.service_name !== undefined && object.service_name !== null) { + message.serviceName = object.service_name; + } + if (object.service_config !== undefined && object.service_config !== null) { + message.serviceConfig = Service.fromAmino(object.service_config); + } + return message; + }, + toAmino(message: CreateServiceConfigRequest): CreateServiceConfigRequestAmino { + const obj: any = {}; + obj.service_name = message.serviceName === "" ? undefined : message.serviceName; + obj.service_config = message.serviceConfig ? Service.toAmino(message.serviceConfig) : undefined; + return obj; + }, + fromAminoMsg(object: CreateServiceConfigRequestAminoMsg): CreateServiceConfigRequest { + return CreateServiceConfigRequest.fromAmino(object.value); + }, + fromProtoMsg(message: CreateServiceConfigRequestProtoMsg): CreateServiceConfigRequest { + return CreateServiceConfigRequest.decode(message.value); + }, + toProto(message: CreateServiceConfigRequest): Uint8Array { + return CreateServiceConfigRequest.encode(message).finish(); + }, + toProtoMsg(message: CreateServiceConfigRequest): CreateServiceConfigRequestProtoMsg { + return { + typeUrl: "/google.api.servicemanagement.v1.CreateServiceConfigRequest", + value: CreateServiceConfigRequest.encode(message).finish() + }; + } +}; +function createBaseSubmitConfigSourceRequest(): SubmitConfigSourceRequest { + return { + serviceName: "", + configSource: undefined, + validateOnly: false + }; +} +export const SubmitConfigSourceRequest = { + typeUrl: "/google.api.servicemanagement.v1.SubmitConfigSourceRequest", + encode(message: SubmitConfigSourceRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.serviceName !== undefined) { + writer.uint32(10).string(message.serviceName); + } + if (message.configSource !== undefined) { + ConfigSource.encode(message.configSource, writer.uint32(18).fork()).ldelim(); + } + if (message.validateOnly !== undefined) { + writer.uint32(24).bool(message.validateOnly); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): SubmitConfigSourceRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseSubmitConfigSourceRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.serviceName = reader.string(); + break; + case 2: + message.configSource = ConfigSource.decode(reader, reader.uint32()); + break; + case 3: + message.validateOnly = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): SubmitConfigSourceRequest { + const obj = createBaseSubmitConfigSourceRequest(); + if (isSet(object.serviceName)) obj.serviceName = String(object.serviceName); + if (isSet(object.configSource)) obj.configSource = ConfigSource.fromJSON(object.configSource); + if (isSet(object.validateOnly)) obj.validateOnly = Boolean(object.validateOnly); + return obj; + }, + toJSON(message: SubmitConfigSourceRequest): JsonSafe { + const obj: any = {}; + message.serviceName !== undefined && (obj.serviceName = message.serviceName); + message.configSource !== undefined && (obj.configSource = message.configSource ? ConfigSource.toJSON(message.configSource) : undefined); + message.validateOnly !== undefined && (obj.validateOnly = message.validateOnly); + return obj; + }, + fromPartial(object: DeepPartial): SubmitConfigSourceRequest { + const message = createBaseSubmitConfigSourceRequest(); + message.serviceName = object.serviceName ?? ""; + if (object.configSource !== undefined && object.configSource !== null) { + message.configSource = ConfigSource.fromPartial(object.configSource); + } + message.validateOnly = object.validateOnly ?? false; + return message; + }, + fromSDK(object: SubmitConfigSourceRequestSDKType): SubmitConfigSourceRequest { + return { + serviceName: object?.service_name, + configSource: object.config_source ? ConfigSource.fromSDK(object.config_source) : undefined, + validateOnly: object?.validate_only + }; + }, + fromSDKJSON(object: any): SubmitConfigSourceRequestSDKType { + return { + service_name: isSet(object.service_name) ? String(object.service_name) : "", + config_source: isSet(object.config_source) ? ConfigSource.fromSDKJSON(object.config_source) : undefined, + validate_only: isSet(object.validate_only) ? Boolean(object.validate_only) : false + }; + }, + toSDK(message: SubmitConfigSourceRequest): SubmitConfigSourceRequestSDKType { + const obj: any = {}; + obj.service_name = message.serviceName; + message.configSource !== undefined && (obj.config_source = message.configSource ? ConfigSource.toSDK(message.configSource) : undefined); + obj.validate_only = message.validateOnly; + return obj; + }, + fromAmino(object: SubmitConfigSourceRequestAmino): SubmitConfigSourceRequest { + const message = createBaseSubmitConfigSourceRequest(); + if (object.service_name !== undefined && object.service_name !== null) { + message.serviceName = object.service_name; + } + if (object.config_source !== undefined && object.config_source !== null) { + message.configSource = ConfigSource.fromAmino(object.config_source); + } + if (object.validate_only !== undefined && object.validate_only !== null) { + message.validateOnly = object.validate_only; + } + return message; + }, + toAmino(message: SubmitConfigSourceRequest): SubmitConfigSourceRequestAmino { + const obj: any = {}; + obj.service_name = message.serviceName === "" ? undefined : message.serviceName; + obj.config_source = message.configSource ? ConfigSource.toAmino(message.configSource) : undefined; + obj.validate_only = message.validateOnly === false ? undefined : message.validateOnly; + return obj; + }, + fromAminoMsg(object: SubmitConfigSourceRequestAminoMsg): SubmitConfigSourceRequest { + return SubmitConfigSourceRequest.fromAmino(object.value); + }, + fromProtoMsg(message: SubmitConfigSourceRequestProtoMsg): SubmitConfigSourceRequest { + return SubmitConfigSourceRequest.decode(message.value); + }, + toProto(message: SubmitConfigSourceRequest): Uint8Array { + return SubmitConfigSourceRequest.encode(message).finish(); + }, + toProtoMsg(message: SubmitConfigSourceRequest): SubmitConfigSourceRequestProtoMsg { + return { + typeUrl: "/google.api.servicemanagement.v1.SubmitConfigSourceRequest", + value: SubmitConfigSourceRequest.encode(message).finish() + }; + } +}; +function createBaseSubmitConfigSourceResponse(): SubmitConfigSourceResponse { + return { + serviceConfig: undefined + }; +} +export const SubmitConfigSourceResponse = { + typeUrl: "/google.api.servicemanagement.v1.SubmitConfigSourceResponse", + encode(message: SubmitConfigSourceResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.serviceConfig !== undefined) { + Service.encode(message.serviceConfig, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): SubmitConfigSourceResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseSubmitConfigSourceResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.serviceConfig = Service.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): SubmitConfigSourceResponse { + const obj = createBaseSubmitConfigSourceResponse(); + if (isSet(object.serviceConfig)) obj.serviceConfig = Service.fromJSON(object.serviceConfig); + return obj; + }, + toJSON(message: SubmitConfigSourceResponse): JsonSafe { + const obj: any = {}; + message.serviceConfig !== undefined && (obj.serviceConfig = message.serviceConfig ? Service.toJSON(message.serviceConfig) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): SubmitConfigSourceResponse { + const message = createBaseSubmitConfigSourceResponse(); + if (object.serviceConfig !== undefined && object.serviceConfig !== null) { + message.serviceConfig = Service.fromPartial(object.serviceConfig); + } + return message; + }, + fromSDK(object: SubmitConfigSourceResponseSDKType): SubmitConfigSourceResponse { + return { + serviceConfig: object.service_config ? Service.fromSDK(object.service_config) : undefined + }; + }, + fromSDKJSON(object: any): SubmitConfigSourceResponseSDKType { + return { + service_config: isSet(object.service_config) ? Service.fromSDKJSON(object.service_config) : undefined + }; + }, + toSDK(message: SubmitConfigSourceResponse): SubmitConfigSourceResponseSDKType { + const obj: any = {}; + message.serviceConfig !== undefined && (obj.service_config = message.serviceConfig ? Service.toSDK(message.serviceConfig) : undefined); + return obj; + }, + fromAmino(object: SubmitConfigSourceResponseAmino): SubmitConfigSourceResponse { + const message = createBaseSubmitConfigSourceResponse(); + if (object.service_config !== undefined && object.service_config !== null) { + message.serviceConfig = Service.fromAmino(object.service_config); + } + return message; + }, + toAmino(message: SubmitConfigSourceResponse): SubmitConfigSourceResponseAmino { + const obj: any = {}; + obj.service_config = message.serviceConfig ? Service.toAmino(message.serviceConfig) : undefined; + return obj; + }, + fromAminoMsg(object: SubmitConfigSourceResponseAminoMsg): SubmitConfigSourceResponse { + return SubmitConfigSourceResponse.fromAmino(object.value); + }, + fromProtoMsg(message: SubmitConfigSourceResponseProtoMsg): SubmitConfigSourceResponse { + return SubmitConfigSourceResponse.decode(message.value); + }, + toProto(message: SubmitConfigSourceResponse): Uint8Array { + return SubmitConfigSourceResponse.encode(message).finish(); + }, + toProtoMsg(message: SubmitConfigSourceResponse): SubmitConfigSourceResponseProtoMsg { + return { + typeUrl: "/google.api.servicemanagement.v1.SubmitConfigSourceResponse", + value: SubmitConfigSourceResponse.encode(message).finish() + }; + } +}; +function createBaseCreateServiceRolloutRequest(): CreateServiceRolloutRequest { + return { + serviceName: "", + rollout: undefined + }; +} +export const CreateServiceRolloutRequest = { + typeUrl: "/google.api.servicemanagement.v1.CreateServiceRolloutRequest", + encode(message: CreateServiceRolloutRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.serviceName !== undefined) { + writer.uint32(10).string(message.serviceName); + } + if (message.rollout !== undefined) { + Rollout.encode(message.rollout, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): CreateServiceRolloutRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCreateServiceRolloutRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.serviceName = reader.string(); + break; + case 2: + message.rollout = Rollout.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): CreateServiceRolloutRequest { + const obj = createBaseCreateServiceRolloutRequest(); + if (isSet(object.serviceName)) obj.serviceName = String(object.serviceName); + if (isSet(object.rollout)) obj.rollout = Rollout.fromJSON(object.rollout); + return obj; + }, + toJSON(message: CreateServiceRolloutRequest): JsonSafe { + const obj: any = {}; + message.serviceName !== undefined && (obj.serviceName = message.serviceName); + message.rollout !== undefined && (obj.rollout = message.rollout ? Rollout.toJSON(message.rollout) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): CreateServiceRolloutRequest { + const message = createBaseCreateServiceRolloutRequest(); + message.serviceName = object.serviceName ?? ""; + if (object.rollout !== undefined && object.rollout !== null) { + message.rollout = Rollout.fromPartial(object.rollout); + } + return message; + }, + fromSDK(object: CreateServiceRolloutRequestSDKType): CreateServiceRolloutRequest { + return { + serviceName: object?.service_name, + rollout: object.rollout ? Rollout.fromSDK(object.rollout) : undefined + }; + }, + fromSDKJSON(object: any): CreateServiceRolloutRequestSDKType { + return { + service_name: isSet(object.service_name) ? String(object.service_name) : "", + rollout: isSet(object.rollout) ? Rollout.fromSDKJSON(object.rollout) : undefined + }; + }, + toSDK(message: CreateServiceRolloutRequest): CreateServiceRolloutRequestSDKType { + const obj: any = {}; + obj.service_name = message.serviceName; + message.rollout !== undefined && (obj.rollout = message.rollout ? Rollout.toSDK(message.rollout) : undefined); + return obj; + }, + fromAmino(object: CreateServiceRolloutRequestAmino): CreateServiceRolloutRequest { + const message = createBaseCreateServiceRolloutRequest(); + if (object.service_name !== undefined && object.service_name !== null) { + message.serviceName = object.service_name; + } + if (object.rollout !== undefined && object.rollout !== null) { + message.rollout = Rollout.fromAmino(object.rollout); + } + return message; + }, + toAmino(message: CreateServiceRolloutRequest): CreateServiceRolloutRequestAmino { + const obj: any = {}; + obj.service_name = message.serviceName === "" ? undefined : message.serviceName; + obj.rollout = message.rollout ? Rollout.toAmino(message.rollout) : undefined; + return obj; + }, + fromAminoMsg(object: CreateServiceRolloutRequestAminoMsg): CreateServiceRolloutRequest { + return CreateServiceRolloutRequest.fromAmino(object.value); + }, + fromProtoMsg(message: CreateServiceRolloutRequestProtoMsg): CreateServiceRolloutRequest { + return CreateServiceRolloutRequest.decode(message.value); + }, + toProto(message: CreateServiceRolloutRequest): Uint8Array { + return CreateServiceRolloutRequest.encode(message).finish(); + }, + toProtoMsg(message: CreateServiceRolloutRequest): CreateServiceRolloutRequestProtoMsg { + return { + typeUrl: "/google.api.servicemanagement.v1.CreateServiceRolloutRequest", + value: CreateServiceRolloutRequest.encode(message).finish() + }; + } +}; +function createBaseListServiceRolloutsRequest(): ListServiceRolloutsRequest { + return { + serviceName: "", + pageToken: "", + pageSize: 0, + filter: "" + }; +} +export const ListServiceRolloutsRequest = { + typeUrl: "/google.api.servicemanagement.v1.ListServiceRolloutsRequest", + encode(message: ListServiceRolloutsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.serviceName !== undefined) { + writer.uint32(10).string(message.serviceName); + } + if (message.pageToken !== undefined) { + writer.uint32(18).string(message.pageToken); + } + if (message.pageSize !== undefined) { + writer.uint32(24).int32(message.pageSize); + } + if (message.filter !== undefined) { + writer.uint32(34).string(message.filter); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ListServiceRolloutsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseListServiceRolloutsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.serviceName = reader.string(); + break; + case 2: + message.pageToken = reader.string(); + break; + case 3: + message.pageSize = reader.int32(); + break; + case 4: + message.filter = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ListServiceRolloutsRequest { + const obj = createBaseListServiceRolloutsRequest(); + if (isSet(object.serviceName)) obj.serviceName = String(object.serviceName); + if (isSet(object.pageToken)) obj.pageToken = String(object.pageToken); + if (isSet(object.pageSize)) obj.pageSize = Number(object.pageSize); + if (isSet(object.filter)) obj.filter = String(object.filter); + return obj; + }, + toJSON(message: ListServiceRolloutsRequest): JsonSafe { + const obj: any = {}; + message.serviceName !== undefined && (obj.serviceName = message.serviceName); + message.pageToken !== undefined && (obj.pageToken = message.pageToken); + message.pageSize !== undefined && (obj.pageSize = Math.round(message.pageSize)); + message.filter !== undefined && (obj.filter = message.filter); + return obj; + }, + fromPartial(object: DeepPartial): ListServiceRolloutsRequest { + const message = createBaseListServiceRolloutsRequest(); + message.serviceName = object.serviceName ?? ""; + message.pageToken = object.pageToken ?? ""; + message.pageSize = object.pageSize ?? 0; + message.filter = object.filter ?? ""; + return message; + }, + fromSDK(object: ListServiceRolloutsRequestSDKType): ListServiceRolloutsRequest { + return { + serviceName: object?.service_name, + pageToken: object?.page_token, + pageSize: object?.page_size, + filter: object?.filter + }; + }, + fromSDKJSON(object: any): ListServiceRolloutsRequestSDKType { + return { + service_name: isSet(object.service_name) ? String(object.service_name) : "", + page_token: isSet(object.page_token) ? String(object.page_token) : "", + page_size: isSet(object.page_size) ? Number(object.page_size) : 0, + filter: isSet(object.filter) ? String(object.filter) : "" + }; + }, + toSDK(message: ListServiceRolloutsRequest): ListServiceRolloutsRequestSDKType { + const obj: any = {}; + obj.service_name = message.serviceName; + obj.page_token = message.pageToken; + obj.page_size = message.pageSize; + obj.filter = message.filter; + return obj; + }, + fromAmino(object: ListServiceRolloutsRequestAmino): ListServiceRolloutsRequest { + const message = createBaseListServiceRolloutsRequest(); + if (object.service_name !== undefined && object.service_name !== null) { + message.serviceName = object.service_name; + } + if (object.page_token !== undefined && object.page_token !== null) { + message.pageToken = object.page_token; + } + if (object.page_size !== undefined && object.page_size !== null) { + message.pageSize = object.page_size; + } + if (object.filter !== undefined && object.filter !== null) { + message.filter = object.filter; + } + return message; + }, + toAmino(message: ListServiceRolloutsRequest): ListServiceRolloutsRequestAmino { + const obj: any = {}; + obj.service_name = message.serviceName === "" ? undefined : message.serviceName; + obj.page_token = message.pageToken === "" ? undefined : message.pageToken; + obj.page_size = message.pageSize === 0 ? undefined : message.pageSize; + obj.filter = message.filter === "" ? undefined : message.filter; + return obj; + }, + fromAminoMsg(object: ListServiceRolloutsRequestAminoMsg): ListServiceRolloutsRequest { + return ListServiceRolloutsRequest.fromAmino(object.value); + }, + fromProtoMsg(message: ListServiceRolloutsRequestProtoMsg): ListServiceRolloutsRequest { + return ListServiceRolloutsRequest.decode(message.value); + }, + toProto(message: ListServiceRolloutsRequest): Uint8Array { + return ListServiceRolloutsRequest.encode(message).finish(); + }, + toProtoMsg(message: ListServiceRolloutsRequest): ListServiceRolloutsRequestProtoMsg { + return { + typeUrl: "/google.api.servicemanagement.v1.ListServiceRolloutsRequest", + value: ListServiceRolloutsRequest.encode(message).finish() + }; + } +}; +function createBaseListServiceRolloutsResponse(): ListServiceRolloutsResponse { + return { + rollouts: [], + nextPageToken: "" + }; +} +export const ListServiceRolloutsResponse = { + typeUrl: "/google.api.servicemanagement.v1.ListServiceRolloutsResponse", + encode(message: ListServiceRolloutsResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.rollouts) { + Rollout.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.nextPageToken !== undefined) { + writer.uint32(18).string(message.nextPageToken); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ListServiceRolloutsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseListServiceRolloutsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.rollouts.push(Rollout.decode(reader, reader.uint32())); + break; + case 2: + message.nextPageToken = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ListServiceRolloutsResponse { + const obj = createBaseListServiceRolloutsResponse(); + if (Array.isArray(object?.rollouts)) obj.rollouts = object.rollouts.map((e: any) => Rollout.fromJSON(e)); + if (isSet(object.nextPageToken)) obj.nextPageToken = String(object.nextPageToken); + return obj; + }, + toJSON(message: ListServiceRolloutsResponse): JsonSafe { + const obj: any = {}; + if (message.rollouts) { + obj.rollouts = message.rollouts.map(e => e ? Rollout.toJSON(e) : undefined); + } else { + obj.rollouts = []; + } + message.nextPageToken !== undefined && (obj.nextPageToken = message.nextPageToken); + return obj; + }, + fromPartial(object: DeepPartial): ListServiceRolloutsResponse { + const message = createBaseListServiceRolloutsResponse(); + message.rollouts = object.rollouts?.map(e => Rollout.fromPartial(e)) || []; + message.nextPageToken = object.nextPageToken ?? ""; + return message; + }, + fromSDK(object: ListServiceRolloutsResponseSDKType): ListServiceRolloutsResponse { + return { + rollouts: Array.isArray(object?.rollouts) ? object.rollouts.map((e: any) => Rollout.fromSDK(e)) : [], + nextPageToken: object?.next_page_token + }; + }, + fromSDKJSON(object: any): ListServiceRolloutsResponseSDKType { + return { + rollouts: Array.isArray(object?.rollouts) ? object.rollouts.map((e: any) => Rollout.fromSDKJSON(e)) : [], + next_page_token: isSet(object.next_page_token) ? String(object.next_page_token) : "" + }; + }, + toSDK(message: ListServiceRolloutsResponse): ListServiceRolloutsResponseSDKType { + const obj: any = {}; + if (message.rollouts) { + obj.rollouts = message.rollouts.map(e => e ? Rollout.toSDK(e) : undefined); + } else { + obj.rollouts = []; + } + obj.next_page_token = message.nextPageToken; + return obj; + }, + fromAmino(object: ListServiceRolloutsResponseAmino): ListServiceRolloutsResponse { + const message = createBaseListServiceRolloutsResponse(); + message.rollouts = object.rollouts?.map(e => Rollout.fromAmino(e)) || []; + if (object.next_page_token !== undefined && object.next_page_token !== null) { + message.nextPageToken = object.next_page_token; + } + return message; + }, + toAmino(message: ListServiceRolloutsResponse): ListServiceRolloutsResponseAmino { + const obj: any = {}; + if (message.rollouts) { + obj.rollouts = message.rollouts.map(e => e ? Rollout.toAmino(e) : undefined); + } else { + obj.rollouts = message.rollouts; + } + obj.next_page_token = message.nextPageToken === "" ? undefined : message.nextPageToken; + return obj; + }, + fromAminoMsg(object: ListServiceRolloutsResponseAminoMsg): ListServiceRolloutsResponse { + return ListServiceRolloutsResponse.fromAmino(object.value); + }, + fromProtoMsg(message: ListServiceRolloutsResponseProtoMsg): ListServiceRolloutsResponse { + return ListServiceRolloutsResponse.decode(message.value); + }, + toProto(message: ListServiceRolloutsResponse): Uint8Array { + return ListServiceRolloutsResponse.encode(message).finish(); + }, + toProtoMsg(message: ListServiceRolloutsResponse): ListServiceRolloutsResponseProtoMsg { + return { + typeUrl: "/google.api.servicemanagement.v1.ListServiceRolloutsResponse", + value: ListServiceRolloutsResponse.encode(message).finish() + }; + } +}; +function createBaseGetServiceRolloutRequest(): GetServiceRolloutRequest { + return { + serviceName: "", + rolloutId: "" + }; +} +export const GetServiceRolloutRequest = { + typeUrl: "/google.api.servicemanagement.v1.GetServiceRolloutRequest", + encode(message: GetServiceRolloutRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.serviceName !== undefined) { + writer.uint32(10).string(message.serviceName); + } + if (message.rolloutId !== undefined) { + writer.uint32(18).string(message.rolloutId); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GetServiceRolloutRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGetServiceRolloutRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.serviceName = reader.string(); + break; + case 2: + message.rolloutId = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GetServiceRolloutRequest { + const obj = createBaseGetServiceRolloutRequest(); + if (isSet(object.serviceName)) obj.serviceName = String(object.serviceName); + if (isSet(object.rolloutId)) obj.rolloutId = String(object.rolloutId); + return obj; + }, + toJSON(message: GetServiceRolloutRequest): JsonSafe { + const obj: any = {}; + message.serviceName !== undefined && (obj.serviceName = message.serviceName); + message.rolloutId !== undefined && (obj.rolloutId = message.rolloutId); + return obj; + }, + fromPartial(object: DeepPartial): GetServiceRolloutRequest { + const message = createBaseGetServiceRolloutRequest(); + message.serviceName = object.serviceName ?? ""; + message.rolloutId = object.rolloutId ?? ""; + return message; + }, + fromSDK(object: GetServiceRolloutRequestSDKType): GetServiceRolloutRequest { + return { + serviceName: object?.service_name, + rolloutId: object?.rollout_id + }; + }, + fromSDKJSON(object: any): GetServiceRolloutRequestSDKType { + return { + service_name: isSet(object.service_name) ? String(object.service_name) : "", + rollout_id: isSet(object.rollout_id) ? String(object.rollout_id) : "" + }; + }, + toSDK(message: GetServiceRolloutRequest): GetServiceRolloutRequestSDKType { + const obj: any = {}; + obj.service_name = message.serviceName; + obj.rollout_id = message.rolloutId; + return obj; + }, + fromAmino(object: GetServiceRolloutRequestAmino): GetServiceRolloutRequest { + const message = createBaseGetServiceRolloutRequest(); + if (object.service_name !== undefined && object.service_name !== null) { + message.serviceName = object.service_name; + } + if (object.rollout_id !== undefined && object.rollout_id !== null) { + message.rolloutId = object.rollout_id; + } + return message; + }, + toAmino(message: GetServiceRolloutRequest): GetServiceRolloutRequestAmino { + const obj: any = {}; + obj.service_name = message.serviceName === "" ? undefined : message.serviceName; + obj.rollout_id = message.rolloutId === "" ? undefined : message.rolloutId; + return obj; + }, + fromAminoMsg(object: GetServiceRolloutRequestAminoMsg): GetServiceRolloutRequest { + return GetServiceRolloutRequest.fromAmino(object.value); + }, + fromProtoMsg(message: GetServiceRolloutRequestProtoMsg): GetServiceRolloutRequest { + return GetServiceRolloutRequest.decode(message.value); + }, + toProto(message: GetServiceRolloutRequest): Uint8Array { + return GetServiceRolloutRequest.encode(message).finish(); + }, + toProtoMsg(message: GetServiceRolloutRequest): GetServiceRolloutRequestProtoMsg { + return { + typeUrl: "/google.api.servicemanagement.v1.GetServiceRolloutRequest", + value: GetServiceRolloutRequest.encode(message).finish() + }; + } +}; +function createBaseGenerateConfigReportRequest(): GenerateConfigReportRequest { + return { + newConfig: undefined, + oldConfig: undefined + }; +} +export const GenerateConfigReportRequest = { + typeUrl: "/google.api.servicemanagement.v1.GenerateConfigReportRequest", + encode(message: GenerateConfigReportRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.newConfig !== undefined) { + Any.encode(message.newConfig, writer.uint32(10).fork()).ldelim(); + } + if (message.oldConfig !== undefined) { + Any.encode(message.oldConfig, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GenerateConfigReportRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGenerateConfigReportRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.newConfig = Any.decode(reader, reader.uint32()); + break; + case 2: + message.oldConfig = Any.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GenerateConfigReportRequest { + const obj = createBaseGenerateConfigReportRequest(); + if (isSet(object.newConfig)) obj.newConfig = Any.fromJSON(object.newConfig); + if (isSet(object.oldConfig)) obj.oldConfig = Any.fromJSON(object.oldConfig); + return obj; + }, + toJSON(message: GenerateConfigReportRequest): JsonSafe { + const obj: any = {}; + message.newConfig !== undefined && (obj.newConfig = message.newConfig ? Any.toJSON(message.newConfig) : undefined); + message.oldConfig !== undefined && (obj.oldConfig = message.oldConfig ? Any.toJSON(message.oldConfig) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): GenerateConfigReportRequest { + const message = createBaseGenerateConfigReportRequest(); + if (object.newConfig !== undefined && object.newConfig !== null) { + message.newConfig = Any.fromPartial(object.newConfig); + } + if (object.oldConfig !== undefined && object.oldConfig !== null) { + message.oldConfig = Any.fromPartial(object.oldConfig); + } + return message; + }, + fromSDK(object: GenerateConfigReportRequestSDKType): GenerateConfigReportRequest { + return { + newConfig: object.new_config ? Any.fromSDK(object.new_config) : undefined, + oldConfig: object.old_config ? Any.fromSDK(object.old_config) : undefined + }; + }, + fromSDKJSON(object: any): GenerateConfigReportRequestSDKType { + return { + new_config: isSet(object.new_config) ? Any.fromSDKJSON(object.new_config) : undefined, + old_config: isSet(object.old_config) ? Any.fromSDKJSON(object.old_config) : undefined + }; + }, + toSDK(message: GenerateConfigReportRequest): GenerateConfigReportRequestSDKType { + const obj: any = {}; + message.newConfig !== undefined && (obj.new_config = message.newConfig ? Any.toSDK(message.newConfig) : undefined); + message.oldConfig !== undefined && (obj.old_config = message.oldConfig ? Any.toSDK(message.oldConfig) : undefined); + return obj; + }, + fromAmino(object: GenerateConfigReportRequestAmino): GenerateConfigReportRequest { + const message = createBaseGenerateConfigReportRequest(); + if (object.new_config !== undefined && object.new_config !== null) { + message.newConfig = Any.fromAmino(object.new_config); + } + if (object.old_config !== undefined && object.old_config !== null) { + message.oldConfig = Any.fromAmino(object.old_config); + } + return message; + }, + toAmino(message: GenerateConfigReportRequest): GenerateConfigReportRequestAmino { + const obj: any = {}; + obj.new_config = message.newConfig ? Any.toAmino(message.newConfig) : undefined; + obj.old_config = message.oldConfig ? Any.toAmino(message.oldConfig) : undefined; + return obj; + }, + fromAminoMsg(object: GenerateConfigReportRequestAminoMsg): GenerateConfigReportRequest { + return GenerateConfigReportRequest.fromAmino(object.value); + }, + fromProtoMsg(message: GenerateConfigReportRequestProtoMsg): GenerateConfigReportRequest { + return GenerateConfigReportRequest.decode(message.value); + }, + toProto(message: GenerateConfigReportRequest): Uint8Array { + return GenerateConfigReportRequest.encode(message).finish(); + }, + toProtoMsg(message: GenerateConfigReportRequest): GenerateConfigReportRequestProtoMsg { + return { + typeUrl: "/google.api.servicemanagement.v1.GenerateConfigReportRequest", + value: GenerateConfigReportRequest.encode(message).finish() + }; + } +}; +function createBaseGenerateConfigReportResponse(): GenerateConfigReportResponse { + return { + serviceName: "", + id: "", + changeReports: [], + diagnostics: [] + }; +} +export const GenerateConfigReportResponse = { + typeUrl: "/google.api.servicemanagement.v1.GenerateConfigReportResponse", + encode(message: GenerateConfigReportResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.serviceName !== undefined) { + writer.uint32(10).string(message.serviceName); + } + if (message.id !== undefined) { + writer.uint32(18).string(message.id); + } + for (const v of message.changeReports) { + ChangeReport.encode(v!, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.diagnostics) { + Diagnostic.encode(v!, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GenerateConfigReportResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGenerateConfigReportResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.serviceName = reader.string(); + break; + case 2: + message.id = reader.string(); + break; + case 3: + message.changeReports.push(ChangeReport.decode(reader, reader.uint32())); + break; + case 4: + message.diagnostics.push(Diagnostic.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GenerateConfigReportResponse { + const obj = createBaseGenerateConfigReportResponse(); + if (isSet(object.serviceName)) obj.serviceName = String(object.serviceName); + if (isSet(object.id)) obj.id = String(object.id); + if (Array.isArray(object?.changeReports)) obj.changeReports = object.changeReports.map((e: any) => ChangeReport.fromJSON(e)); + if (Array.isArray(object?.diagnostics)) obj.diagnostics = object.diagnostics.map((e: any) => Diagnostic.fromJSON(e)); + return obj; + }, + toJSON(message: GenerateConfigReportResponse): JsonSafe { + const obj: any = {}; + message.serviceName !== undefined && (obj.serviceName = message.serviceName); + message.id !== undefined && (obj.id = message.id); + if (message.changeReports) { + obj.changeReports = message.changeReports.map(e => e ? ChangeReport.toJSON(e) : undefined); + } else { + obj.changeReports = []; + } + if (message.diagnostics) { + obj.diagnostics = message.diagnostics.map(e => e ? Diagnostic.toJSON(e) : undefined); + } else { + obj.diagnostics = []; + } + return obj; + }, + fromPartial(object: DeepPartial): GenerateConfigReportResponse { + const message = createBaseGenerateConfigReportResponse(); + message.serviceName = object.serviceName ?? ""; + message.id = object.id ?? ""; + message.changeReports = object.changeReports?.map(e => ChangeReport.fromPartial(e)) || []; + message.diagnostics = object.diagnostics?.map(e => Diagnostic.fromPartial(e)) || []; + return message; + }, + fromSDK(object: GenerateConfigReportResponseSDKType): GenerateConfigReportResponse { + return { + serviceName: object?.service_name, + id: object?.id, + changeReports: Array.isArray(object?.change_reports) ? object.change_reports.map((e: any) => ChangeReport.fromSDK(e)) : [], + diagnostics: Array.isArray(object?.diagnostics) ? object.diagnostics.map((e: any) => Diagnostic.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): GenerateConfigReportResponseSDKType { + return { + service_name: isSet(object.service_name) ? String(object.service_name) : "", + id: isSet(object.id) ? String(object.id) : "", + change_reports: Array.isArray(object?.change_reports) ? object.change_reports.map((e: any) => ChangeReport.fromSDKJSON(e)) : [], + diagnostics: Array.isArray(object?.diagnostics) ? object.diagnostics.map((e: any) => Diagnostic.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: GenerateConfigReportResponse): GenerateConfigReportResponseSDKType { + const obj: any = {}; + obj.service_name = message.serviceName; + obj.id = message.id; + if (message.changeReports) { + obj.change_reports = message.changeReports.map(e => e ? ChangeReport.toSDK(e) : undefined); + } else { + obj.change_reports = []; + } + if (message.diagnostics) { + obj.diagnostics = message.diagnostics.map(e => e ? Diagnostic.toSDK(e) : undefined); + } else { + obj.diagnostics = []; + } + return obj; + }, + fromAmino(object: GenerateConfigReportResponseAmino): GenerateConfigReportResponse { + const message = createBaseGenerateConfigReportResponse(); + if (object.service_name !== undefined && object.service_name !== null) { + message.serviceName = object.service_name; + } + if (object.id !== undefined && object.id !== null) { + message.id = object.id; + } + message.changeReports = object.change_reports?.map(e => ChangeReport.fromAmino(e)) || []; + message.diagnostics = object.diagnostics?.map(e => Diagnostic.fromAmino(e)) || []; + return message; + }, + toAmino(message: GenerateConfigReportResponse): GenerateConfigReportResponseAmino { + const obj: any = {}; + obj.service_name = message.serviceName === "" ? undefined : message.serviceName; + obj.id = message.id === "" ? undefined : message.id; + if (message.changeReports) { + obj.change_reports = message.changeReports.map(e => e ? ChangeReport.toAmino(e) : undefined); + } else { + obj.change_reports = message.changeReports; + } + if (message.diagnostics) { + obj.diagnostics = message.diagnostics.map(e => e ? Diagnostic.toAmino(e) : undefined); + } else { + obj.diagnostics = message.diagnostics; + } + return obj; + }, + fromAminoMsg(object: GenerateConfigReportResponseAminoMsg): GenerateConfigReportResponse { + return GenerateConfigReportResponse.fromAmino(object.value); + }, + fromProtoMsg(message: GenerateConfigReportResponseProtoMsg): GenerateConfigReportResponse { + return GenerateConfigReportResponse.decode(message.value); + }, + toProto(message: GenerateConfigReportResponse): Uint8Array { + return GenerateConfigReportResponse.encode(message).finish(); + }, + toProtoMsg(message: GenerateConfigReportResponse): GenerateConfigReportResponseProtoMsg { + return { + typeUrl: "/google.api.servicemanagement.v1.GenerateConfigReportResponse", + value: GenerateConfigReportResponse.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/api/serviceusage/v1/resources.ts b/__fixtures__/v-next/outputicjsdeps/google/api/serviceusage/v1/resources.ts new file mode 100644 index 0000000000..e6cdfb7531 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/api/serviceusage/v1/resources.ts @@ -0,0 +1,693 @@ +import { Api, ApiSDKType } from "../../../protobuf/api.js"; +import { Documentation, DocumentationSDKType } from "../../documentation.js"; +import { Quota, QuotaSDKType } from "../../quota.js"; +import { Authentication, AuthenticationSDKType } from "../../auth.js"; +import { Usage, UsageSDKType } from "../../usage.js"; +import { Endpoint, EndpointSDKType } from "../../endpoint.js"; +import { MonitoredResourceDescriptor, MonitoredResourceDescriptorSDKType } from "../../monitored_resource.js"; +import { Monitoring, MonitoringSDKType } from "../../monitoring.js"; +import { BinaryReader, BinaryWriter } from "../../../../binary.js"; +import { isSet, DeepPartial } from "../../../../helpers.js"; +import { JsonSafe } from "../../../../json-safe.js"; +export const protobufPackage = "google.api.serviceusage.v1"; +/** Whether or not a service has been enabled for use by a consumer. */ +export enum State { + /** + * STATE_UNSPECIFIED - The default value, which indicates that the enabled state of the service + * is unspecified or not meaningful. Currently, all consumers other than + * projects (such as folders and organizations) are always in this state. + */ + STATE_UNSPECIFIED = 0, + /** + * DISABLED - The service cannot be used by this consumer. It has either been explicitly + * disabled, or has never been enabled. + */ + DISABLED = 1, + /** ENABLED - The service has been explicitly enabled for use by this consumer. */ + ENABLED = 2, + UNRECOGNIZED = -1, +} +export const StateSDKType = State; +export function stateFromJSON(object: any): State { + switch (object) { + case 0: + case "STATE_UNSPECIFIED": + return State.STATE_UNSPECIFIED; + case 1: + case "DISABLED": + return State.DISABLED; + case 2: + case "ENABLED": + return State.ENABLED; + case -1: + case "UNRECOGNIZED": + default: + return State.UNRECOGNIZED; + } +} +export function stateToJSON(object: State): string { + switch (object) { + case State.STATE_UNSPECIFIED: + return "STATE_UNSPECIFIED"; + case State.DISABLED: + return "DISABLED"; + case State.ENABLED: + return "ENABLED"; + case State.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** A service that is available for use by the consumer. */ +export interface Service { + /** + * The resource name of the consumer and service. + * + * A valid name would be: + * - projects/123/services/serviceusage.googleapis.com + */ + name: string; + /** + * The resource name of the consumer. + * + * A valid name would be: + * - projects/123 + */ + parent: string; + /** + * The service configuration of the available service. + * Some fields may be filtered out of the configuration in responses to + * the `ListServices` method. These fields are present only in responses to + * the `GetService` method. + */ + config?: ServiceConfig; + /** Whether or not the service has been enabled for use by the consumer. */ + state: State; +} +export interface ServiceProtoMsg { + typeUrl: "/google.api.serviceusage.v1.Service"; + value: Uint8Array; +} +/** A service that is available for use by the consumer. */ +export interface ServiceSDKType { + name: string; + parent: string; + config?: ServiceConfigSDKType; + state: State; +} +/** The configuration of the service. */ +export interface ServiceConfig { + /** + * The DNS address at which this service is available. + * + * An example DNS address would be: + * `calendar.googleapis.com`. + */ + name: string; + /** The product title for this service. */ + title: string; + /** + * A list of API interfaces exported by this service. Contains only the names, + * versions, and method names of the interfaces. + */ + apis: Api[]; + /** + * Additional API documentation. Contains only the summary and the + * documentation URL. + */ + documentation?: Documentation; + /** Quota configuration. */ + quota?: Quota; + /** Auth configuration. Contains only the OAuth rules. */ + authentication?: Authentication; + /** Configuration controlling usage of this service. */ + usage?: Usage; + /** + * Configuration for network endpoints. Contains only the names and aliases + * of the endpoints. + */ + endpoints: Endpoint[]; + /** + * Defines the monitored resources used by this service. This is required + * by the [Service.monitoring][google.api.Service.monitoring] and [Service.logging][google.api.Service.logging] configurations. + */ + monitoredResources: MonitoredResourceDescriptor[]; + /** + * Monitoring configuration. + * This should not include the 'producer_destinations' field. + */ + monitoring?: Monitoring; +} +export interface ServiceConfigProtoMsg { + typeUrl: "/google.api.serviceusage.v1.ServiceConfig"; + value: Uint8Array; +} +/** The configuration of the service. */ +export interface ServiceConfigSDKType { + name: string; + title: string; + apis: ApiSDKType[]; + documentation?: DocumentationSDKType; + quota?: QuotaSDKType; + authentication?: AuthenticationSDKType; + usage?: UsageSDKType; + endpoints: EndpointSDKType[]; + monitored_resources: MonitoredResourceDescriptorSDKType[]; + monitoring?: MonitoringSDKType; +} +/** The operation metadata returned for the batchend services operation. */ +export interface OperationMetadata { + /** + * The full name of the resources that this operation is directly + * associated with. + */ + resourceNames: string[]; +} +export interface OperationMetadataProtoMsg { + typeUrl: "/google.api.serviceusage.v1.OperationMetadata"; + value: Uint8Array; +} +/** The operation metadata returned for the batchend services operation. */ +export interface OperationMetadataSDKType { + resource_names: string[]; +} +function createBaseService(): Service { + return { + name: "", + parent: "", + config: undefined, + state: 0 + }; +} +export const Service = { + typeUrl: "/google.api.serviceusage.v1.Service", + encode(message: Service, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + if (message.parent !== undefined) { + writer.uint32(42).string(message.parent); + } + if (message.config !== undefined) { + ServiceConfig.encode(message.config, writer.uint32(18).fork()).ldelim(); + } + if (message.state !== 0) { + writer.uint32(32).int32(message.state); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Service { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseService(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 5: + message.parent = reader.string(); + break; + case 2: + message.config = ServiceConfig.decode(reader, reader.uint32()); + break; + case 4: + message.state = (reader.int32() as any); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Service { + const obj = createBaseService(); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.parent)) obj.parent = String(object.parent); + if (isSet(object.config)) obj.config = ServiceConfig.fromJSON(object.config); + if (isSet(object.state)) obj.state = stateFromJSON(object.state); + return obj; + }, + toJSON(message: Service): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.parent !== undefined && (obj.parent = message.parent); + message.config !== undefined && (obj.config = message.config ? ServiceConfig.toJSON(message.config) : undefined); + message.state !== undefined && (obj.state = stateToJSON(message.state)); + return obj; + }, + fromPartial(object: DeepPartial): Service { + const message = createBaseService(); + message.name = object.name ?? ""; + message.parent = object.parent ?? ""; + if (object.config !== undefined && object.config !== null) { + message.config = ServiceConfig.fromPartial(object.config); + } + message.state = object.state ?? 0; + return message; + }, + fromSDK(object: ServiceSDKType): Service { + return { + name: object?.name, + parent: object?.parent, + config: object.config ? ServiceConfig.fromSDK(object.config) : undefined, + state: isSet(object.state) ? stateFromJSON(object.state) : -1 + }; + }, + fromSDKJSON(object: any): ServiceSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + parent: isSet(object.parent) ? String(object.parent) : "", + config: isSet(object.config) ? ServiceConfig.fromSDKJSON(object.config) : undefined, + state: isSet(object.state) ? stateFromJSON(object.state) : -1 + }; + }, + toSDK(message: Service): ServiceSDKType { + const obj: any = {}; + obj.name = message.name; + obj.parent = message.parent; + message.config !== undefined && (obj.config = message.config ? ServiceConfig.toSDK(message.config) : undefined); + message.state !== undefined && (obj.state = stateToJSON(message.state)); + return obj; + }, + fromAmino(object: ServiceAmino): Service { + const message = createBaseService(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + if (object.parent !== undefined && object.parent !== null) { + message.parent = object.parent; + } + if (object.config !== undefined && object.config !== null) { + message.config = ServiceConfig.fromAmino(object.config); + } + if (object.state !== undefined && object.state !== null) { + message.state = object.state; + } + return message; + }, + toAmino(message: Service): ServiceAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + obj.parent = message.parent === "" ? undefined : message.parent; + obj.config = message.config ? ServiceConfig.toAmino(message.config) : undefined; + obj.state = message.state === 0 ? undefined : message.state; + return obj; + }, + fromAminoMsg(object: ServiceAminoMsg): Service { + return Service.fromAmino(object.value); + }, + fromProtoMsg(message: ServiceProtoMsg): Service { + return Service.decode(message.value); + }, + toProto(message: Service): Uint8Array { + return Service.encode(message).finish(); + }, + toProtoMsg(message: Service): ServiceProtoMsg { + return { + typeUrl: "/google.api.serviceusage.v1.Service", + value: Service.encode(message).finish() + }; + } +}; +function createBaseServiceConfig(): ServiceConfig { + return { + name: "", + title: "", + apis: [], + documentation: undefined, + quota: undefined, + authentication: undefined, + usage: undefined, + endpoints: [], + monitoredResources: [], + monitoring: undefined + }; +} +export const ServiceConfig = { + typeUrl: "/google.api.serviceusage.v1.ServiceConfig", + encode(message: ServiceConfig, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + if (message.title !== undefined) { + writer.uint32(18).string(message.title); + } + for (const v of message.apis) { + Api.encode(v!, writer.uint32(26).fork()).ldelim(); + } + if (message.documentation !== undefined) { + Documentation.encode(message.documentation, writer.uint32(50).fork()).ldelim(); + } + if (message.quota !== undefined) { + Quota.encode(message.quota, writer.uint32(82).fork()).ldelim(); + } + if (message.authentication !== undefined) { + Authentication.encode(message.authentication, writer.uint32(90).fork()).ldelim(); + } + if (message.usage !== undefined) { + Usage.encode(message.usage, writer.uint32(122).fork()).ldelim(); + } + for (const v of message.endpoints) { + Endpoint.encode(v!, writer.uint32(146).fork()).ldelim(); + } + for (const v of message.monitoredResources) { + MonitoredResourceDescriptor.encode(v!, writer.uint32(202).fork()).ldelim(); + } + if (message.monitoring !== undefined) { + Monitoring.encode(message.monitoring, writer.uint32(226).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ServiceConfig { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseServiceConfig(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.title = reader.string(); + break; + case 3: + message.apis.push(Api.decode(reader, reader.uint32())); + break; + case 6: + message.documentation = Documentation.decode(reader, reader.uint32()); + break; + case 10: + message.quota = Quota.decode(reader, reader.uint32()); + break; + case 11: + message.authentication = Authentication.decode(reader, reader.uint32()); + break; + case 15: + message.usage = Usage.decode(reader, reader.uint32()); + break; + case 18: + message.endpoints.push(Endpoint.decode(reader, reader.uint32())); + break; + case 25: + message.monitoredResources.push(MonitoredResourceDescriptor.decode(reader, reader.uint32())); + break; + case 28: + message.monitoring = Monitoring.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ServiceConfig { + const obj = createBaseServiceConfig(); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.title)) obj.title = String(object.title); + if (Array.isArray(object?.apis)) obj.apis = object.apis.map((e: any) => Api.fromJSON(e)); + if (isSet(object.documentation)) obj.documentation = Documentation.fromJSON(object.documentation); + if (isSet(object.quota)) obj.quota = Quota.fromJSON(object.quota); + if (isSet(object.authentication)) obj.authentication = Authentication.fromJSON(object.authentication); + if (isSet(object.usage)) obj.usage = Usage.fromJSON(object.usage); + if (Array.isArray(object?.endpoints)) obj.endpoints = object.endpoints.map((e: any) => Endpoint.fromJSON(e)); + if (Array.isArray(object?.monitoredResources)) obj.monitoredResources = object.monitoredResources.map((e: any) => MonitoredResourceDescriptor.fromJSON(e)); + if (isSet(object.monitoring)) obj.monitoring = Monitoring.fromJSON(object.monitoring); + return obj; + }, + toJSON(message: ServiceConfig): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.title !== undefined && (obj.title = message.title); + if (message.apis) { + obj.apis = message.apis.map(e => e ? Api.toJSON(e) : undefined); + } else { + obj.apis = []; + } + message.documentation !== undefined && (obj.documentation = message.documentation ? Documentation.toJSON(message.documentation) : undefined); + message.quota !== undefined && (obj.quota = message.quota ? Quota.toJSON(message.quota) : undefined); + message.authentication !== undefined && (obj.authentication = message.authentication ? Authentication.toJSON(message.authentication) : undefined); + message.usage !== undefined && (obj.usage = message.usage ? Usage.toJSON(message.usage) : undefined); + if (message.endpoints) { + obj.endpoints = message.endpoints.map(e => e ? Endpoint.toJSON(e) : undefined); + } else { + obj.endpoints = []; + } + if (message.monitoredResources) { + obj.monitoredResources = message.monitoredResources.map(e => e ? MonitoredResourceDescriptor.toJSON(e) : undefined); + } else { + obj.monitoredResources = []; + } + message.monitoring !== undefined && (obj.monitoring = message.monitoring ? Monitoring.toJSON(message.monitoring) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): ServiceConfig { + const message = createBaseServiceConfig(); + message.name = object.name ?? ""; + message.title = object.title ?? ""; + message.apis = object.apis?.map(e => Api.fromPartial(e)) || []; + if (object.documentation !== undefined && object.documentation !== null) { + message.documentation = Documentation.fromPartial(object.documentation); + } + if (object.quota !== undefined && object.quota !== null) { + message.quota = Quota.fromPartial(object.quota); + } + if (object.authentication !== undefined && object.authentication !== null) { + message.authentication = Authentication.fromPartial(object.authentication); + } + if (object.usage !== undefined && object.usage !== null) { + message.usage = Usage.fromPartial(object.usage); + } + message.endpoints = object.endpoints?.map(e => Endpoint.fromPartial(e)) || []; + message.monitoredResources = object.monitoredResources?.map(e => MonitoredResourceDescriptor.fromPartial(e)) || []; + if (object.monitoring !== undefined && object.monitoring !== null) { + message.monitoring = Monitoring.fromPartial(object.monitoring); + } + return message; + }, + fromSDK(object: ServiceConfigSDKType): ServiceConfig { + return { + name: object?.name, + title: object?.title, + apis: Array.isArray(object?.apis) ? object.apis.map((e: any) => Api.fromSDK(e)) : [], + documentation: object.documentation ? Documentation.fromSDK(object.documentation) : undefined, + quota: object.quota ? Quota.fromSDK(object.quota) : undefined, + authentication: object.authentication ? Authentication.fromSDK(object.authentication) : undefined, + usage: object.usage ? Usage.fromSDK(object.usage) : undefined, + endpoints: Array.isArray(object?.endpoints) ? object.endpoints.map((e: any) => Endpoint.fromSDK(e)) : [], + monitoredResources: Array.isArray(object?.monitored_resources) ? object.monitored_resources.map((e: any) => MonitoredResourceDescriptor.fromSDK(e)) : [], + monitoring: object.monitoring ? Monitoring.fromSDK(object.monitoring) : undefined + }; + }, + fromSDKJSON(object: any): ServiceConfigSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + title: isSet(object.title) ? String(object.title) : "", + apis: Array.isArray(object?.apis) ? object.apis.map((e: any) => Api.fromSDKJSON(e)) : [], + documentation: isSet(object.documentation) ? Documentation.fromSDKJSON(object.documentation) : undefined, + quota: isSet(object.quota) ? Quota.fromSDKJSON(object.quota) : undefined, + authentication: isSet(object.authentication) ? Authentication.fromSDKJSON(object.authentication) : undefined, + usage: isSet(object.usage) ? Usage.fromSDKJSON(object.usage) : undefined, + endpoints: Array.isArray(object?.endpoints) ? object.endpoints.map((e: any) => Endpoint.fromSDKJSON(e)) : [], + monitored_resources: Array.isArray(object?.monitored_resources) ? object.monitored_resources.map((e: any) => MonitoredResourceDescriptor.fromSDKJSON(e)) : [], + monitoring: isSet(object.monitoring) ? Monitoring.fromSDKJSON(object.monitoring) : undefined + }; + }, + toSDK(message: ServiceConfig): ServiceConfigSDKType { + const obj: any = {}; + obj.name = message.name; + obj.title = message.title; + if (message.apis) { + obj.apis = message.apis.map(e => e ? Api.toSDK(e) : undefined); + } else { + obj.apis = []; + } + message.documentation !== undefined && (obj.documentation = message.documentation ? Documentation.toSDK(message.documentation) : undefined); + message.quota !== undefined && (obj.quota = message.quota ? Quota.toSDK(message.quota) : undefined); + message.authentication !== undefined && (obj.authentication = message.authentication ? Authentication.toSDK(message.authentication) : undefined); + message.usage !== undefined && (obj.usage = message.usage ? Usage.toSDK(message.usage) : undefined); + if (message.endpoints) { + obj.endpoints = message.endpoints.map(e => e ? Endpoint.toSDK(e) : undefined); + } else { + obj.endpoints = []; + } + if (message.monitoredResources) { + obj.monitored_resources = message.monitoredResources.map(e => e ? MonitoredResourceDescriptor.toSDK(e) : undefined); + } else { + obj.monitored_resources = []; + } + message.monitoring !== undefined && (obj.monitoring = message.monitoring ? Monitoring.toSDK(message.monitoring) : undefined); + return obj; + }, + fromAmino(object: ServiceConfigAmino): ServiceConfig { + const message = createBaseServiceConfig(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + if (object.title !== undefined && object.title !== null) { + message.title = object.title; + } + message.apis = object.apis?.map(e => Api.fromAmino(e)) || []; + if (object.documentation !== undefined && object.documentation !== null) { + message.documentation = Documentation.fromAmino(object.documentation); + } + if (object.quota !== undefined && object.quota !== null) { + message.quota = Quota.fromAmino(object.quota); + } + if (object.authentication !== undefined && object.authentication !== null) { + message.authentication = Authentication.fromAmino(object.authentication); + } + if (object.usage !== undefined && object.usage !== null) { + message.usage = Usage.fromAmino(object.usage); + } + message.endpoints = object.endpoints?.map(e => Endpoint.fromAmino(e)) || []; + message.monitoredResources = object.monitored_resources?.map(e => MonitoredResourceDescriptor.fromAmino(e)) || []; + if (object.monitoring !== undefined && object.monitoring !== null) { + message.monitoring = Monitoring.fromAmino(object.monitoring); + } + return message; + }, + toAmino(message: ServiceConfig): ServiceConfigAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + obj.title = message.title === "" ? undefined : message.title; + if (message.apis) { + obj.apis = message.apis.map(e => e ? Api.toAmino(e) : undefined); + } else { + obj.apis = message.apis; + } + obj.documentation = message.documentation ? Documentation.toAmino(message.documentation) : undefined; + obj.quota = message.quota ? Quota.toAmino(message.quota) : undefined; + obj.authentication = message.authentication ? Authentication.toAmino(message.authentication) : undefined; + obj.usage = message.usage ? Usage.toAmino(message.usage) : undefined; + if (message.endpoints) { + obj.endpoints = message.endpoints.map(e => e ? Endpoint.toAmino(e) : undefined); + } else { + obj.endpoints = message.endpoints; + } + if (message.monitoredResources) { + obj.monitored_resources = message.monitoredResources.map(e => e ? MonitoredResourceDescriptor.toAmino(e) : undefined); + } else { + obj.monitored_resources = message.monitoredResources; + } + obj.monitoring = message.monitoring ? Monitoring.toAmino(message.monitoring) : undefined; + return obj; + }, + fromAminoMsg(object: ServiceConfigAminoMsg): ServiceConfig { + return ServiceConfig.fromAmino(object.value); + }, + fromProtoMsg(message: ServiceConfigProtoMsg): ServiceConfig { + return ServiceConfig.decode(message.value); + }, + toProto(message: ServiceConfig): Uint8Array { + return ServiceConfig.encode(message).finish(); + }, + toProtoMsg(message: ServiceConfig): ServiceConfigProtoMsg { + return { + typeUrl: "/google.api.serviceusage.v1.ServiceConfig", + value: ServiceConfig.encode(message).finish() + }; + } +}; +function createBaseOperationMetadata(): OperationMetadata { + return { + resourceNames: [] + }; +} +export const OperationMetadata = { + typeUrl: "/google.api.serviceusage.v1.OperationMetadata", + encode(message: OperationMetadata, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.resourceNames) { + writer.uint32(18).string(v!); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): OperationMetadata { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseOperationMetadata(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.resourceNames.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): OperationMetadata { + const obj = createBaseOperationMetadata(); + if (Array.isArray(object?.resourceNames)) obj.resourceNames = object.resourceNames.map((e: any) => String(e)); + return obj; + }, + toJSON(message: OperationMetadata): JsonSafe { + const obj: any = {}; + if (message.resourceNames) { + obj.resourceNames = message.resourceNames.map(e => e); + } else { + obj.resourceNames = []; + } + return obj; + }, + fromPartial(object: DeepPartial): OperationMetadata { + const message = createBaseOperationMetadata(); + message.resourceNames = object.resourceNames?.map(e => e) || []; + return message; + }, + fromSDK(object: OperationMetadataSDKType): OperationMetadata { + return { + resourceNames: Array.isArray(object?.resource_names) ? object.resource_names.map((e: any) => e) : [] + }; + }, + fromSDKJSON(object: any): OperationMetadataSDKType { + return { + resource_names: Array.isArray(object?.resource_names) ? object.resource_names.map((e: any) => String(e)) : [] + }; + }, + toSDK(message: OperationMetadata): OperationMetadataSDKType { + const obj: any = {}; + if (message.resourceNames) { + obj.resource_names = message.resourceNames.map(e => e); + } else { + obj.resource_names = []; + } + return obj; + }, + fromAmino(object: OperationMetadataAmino): OperationMetadata { + const message = createBaseOperationMetadata(); + message.resourceNames = object.resource_names?.map(e => e) || []; + return message; + }, + toAmino(message: OperationMetadata): OperationMetadataAmino { + const obj: any = {}; + if (message.resourceNames) { + obj.resource_names = message.resourceNames.map(e => e); + } else { + obj.resource_names = message.resourceNames; + } + return obj; + }, + fromAminoMsg(object: OperationMetadataAminoMsg): OperationMetadata { + return OperationMetadata.fromAmino(object.value); + }, + fromProtoMsg(message: OperationMetadataProtoMsg): OperationMetadata { + return OperationMetadata.decode(message.value); + }, + toProto(message: OperationMetadata): Uint8Array { + return OperationMetadata.encode(message).finish(); + }, + toProtoMsg(message: OperationMetadata): OperationMetadataProtoMsg { + return { + typeUrl: "/google.api.serviceusage.v1.OperationMetadata", + value: OperationMetadata.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/api/serviceusage/v1/serviceusage.ts b/__fixtures__/v-next/outputicjsdeps/google/api/serviceusage/v1/serviceusage.ts new file mode 100644 index 0000000000..cdc8a3d1da --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/api/serviceusage/v1/serviceusage.ts @@ -0,0 +1,1638 @@ +import { Service, ServiceSDKType } from "./resources.js"; +import { BinaryReader, BinaryWriter } from "../../../../binary.js"; +import { isSet, DeepPartial } from "../../../../helpers.js"; +import { JsonSafe } from "../../../../json-safe.js"; +export const protobufPackage = "google.api.serviceusage.v1"; +/** + * Enum to determine if service usage should be checked when disabling a + * service. + */ +export enum DisableServiceRequest_CheckIfServiceHasUsage { + /** CHECK_IF_SERVICE_HAS_USAGE_UNSPECIFIED - When unset, the default behavior is used, which is SKIP. */ + CHECK_IF_SERVICE_HAS_USAGE_UNSPECIFIED = 0, + /** SKIP - If set, skip checking service usage when disabling a service. */ + SKIP = 1, + /** + * CHECK - If set, service usage is checked when disabling the service. If a + * service, or its dependents, has usage in the last 30 days, the request + * returns a FAILED_PRECONDITION error. + */ + CHECK = 2, + UNRECOGNIZED = -1, +} +export const DisableServiceRequest_CheckIfServiceHasUsageSDKType = DisableServiceRequest_CheckIfServiceHasUsage; +export function disableServiceRequest_CheckIfServiceHasUsageFromJSON(object: any): DisableServiceRequest_CheckIfServiceHasUsage { + switch (object) { + case 0: + case "CHECK_IF_SERVICE_HAS_USAGE_UNSPECIFIED": + return DisableServiceRequest_CheckIfServiceHasUsage.CHECK_IF_SERVICE_HAS_USAGE_UNSPECIFIED; + case 1: + case "SKIP": + return DisableServiceRequest_CheckIfServiceHasUsage.SKIP; + case 2: + case "CHECK": + return DisableServiceRequest_CheckIfServiceHasUsage.CHECK; + case -1: + case "UNRECOGNIZED": + default: + return DisableServiceRequest_CheckIfServiceHasUsage.UNRECOGNIZED; + } +} +export function disableServiceRequest_CheckIfServiceHasUsageToJSON(object: DisableServiceRequest_CheckIfServiceHasUsage): string { + switch (object) { + case DisableServiceRequest_CheckIfServiceHasUsage.CHECK_IF_SERVICE_HAS_USAGE_UNSPECIFIED: + return "CHECK_IF_SERVICE_HAS_USAGE_UNSPECIFIED"; + case DisableServiceRequest_CheckIfServiceHasUsage.SKIP: + return "SKIP"; + case DisableServiceRequest_CheckIfServiceHasUsage.CHECK: + return "CHECK"; + case DisableServiceRequest_CheckIfServiceHasUsage.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** Request message for the `EnableService` method. */ +export interface EnableServiceRequest { + /** + * Name of the consumer and service to enable the service on. + * + * The `EnableService` and `DisableService` methods currently only support + * projects. + * + * Enabling a service requires that the service is public or is shared with + * the user enabling the service. + * + * An example name would be: + * `projects/123/services/serviceusage.googleapis.com` where `123` is the + * project number. + */ + name: string; +} +export interface EnableServiceRequestProtoMsg { + typeUrl: "/google.api.serviceusage.v1.EnableServiceRequest"; + value: Uint8Array; +} +/** Request message for the `EnableService` method. */ +export interface EnableServiceRequestSDKType { + name: string; +} +/** + * Response message for the `EnableService` method. + * This response message is assigned to the `response` field of the returned + * Operation when that operation is done. + */ +export interface EnableServiceResponse { + /** The new state of the service after enabling. */ + service?: Service; +} +export interface EnableServiceResponseProtoMsg { + typeUrl: "/google.api.serviceusage.v1.EnableServiceResponse"; + value: Uint8Array; +} +/** + * Response message for the `EnableService` method. + * This response message is assigned to the `response` field of the returned + * Operation when that operation is done. + */ +export interface EnableServiceResponseSDKType { + service?: ServiceSDKType; +} +/** Request message for the `DisableService` method. */ +export interface DisableServiceRequest { + /** + * Name of the consumer and service to disable the service on. + * + * The enable and disable methods currently only support projects. + * + * An example name would be: + * `projects/123/services/serviceusage.googleapis.com` where `123` is the + * project number. + */ + name: string; + /** + * Indicates if services that are enabled and which depend on this service + * should also be disabled. If not set, an error will be generated if any + * enabled services depend on the service to be disabled. When set, the + * service, and any enabled services that depend on it, will be disabled + * together. + */ + disableDependentServices: boolean; + /** Defines the behavior for checking service usage when disabling a service. */ + checkIfServiceHasUsage: DisableServiceRequest_CheckIfServiceHasUsage; +} +export interface DisableServiceRequestProtoMsg { + typeUrl: "/google.api.serviceusage.v1.DisableServiceRequest"; + value: Uint8Array; +} +/** Request message for the `DisableService` method. */ +export interface DisableServiceRequestSDKType { + name: string; + disable_dependent_services: boolean; + check_if_service_has_usage: DisableServiceRequest_CheckIfServiceHasUsage; +} +/** + * Response message for the `DisableService` method. + * This response message is assigned to the `response` field of the returned + * Operation when that operation is done. + */ +export interface DisableServiceResponse { + /** The new state of the service after disabling. */ + service?: Service; +} +export interface DisableServiceResponseProtoMsg { + typeUrl: "/google.api.serviceusage.v1.DisableServiceResponse"; + value: Uint8Array; +} +/** + * Response message for the `DisableService` method. + * This response message is assigned to the `response` field of the returned + * Operation when that operation is done. + */ +export interface DisableServiceResponseSDKType { + service?: ServiceSDKType; +} +/** Request message for the `GetService` method. */ +export interface GetServiceRequest { + /** + * Name of the consumer and service to get the `ConsumerState` for. + * + * An example name would be: + * `projects/123/services/serviceusage.googleapis.com` where `123` is the + * project number. + */ + name: string; +} +export interface GetServiceRequestProtoMsg { + typeUrl: "/google.api.serviceusage.v1.GetServiceRequest"; + value: Uint8Array; +} +/** Request message for the `GetService` method. */ +export interface GetServiceRequestSDKType { + name: string; +} +/** Request message for the `ListServices` method. */ +export interface ListServicesRequest { + /** + * Parent to search for services on. + * + * An example name would be: + * `projects/123` where `123` is the project number. + */ + parent: string; + /** + * Requested size of the next page of data. + * Requested page size cannot exceed 200. + * If not set, the default page size is 50. + */ + pageSize: number; + /** + * Token identifying which result to start with, which is returned by a + * previous list call. + */ + pageToken: string; + /** + * Only list services that conform to the given filter. + * The allowed filter strings are `state:ENABLED` and `state:DISABLED`. + */ + filter: string; +} +export interface ListServicesRequestProtoMsg { + typeUrl: "/google.api.serviceusage.v1.ListServicesRequest"; + value: Uint8Array; +} +/** Request message for the `ListServices` method. */ +export interface ListServicesRequestSDKType { + parent: string; + page_size: number; + page_token: string; + filter: string; +} +/** Response message for the `ListServices` method. */ +export interface ListServicesResponse { + /** The available services for the requested project. */ + services: Service[]; + /** + * Token that can be passed to `ListServices` to resume a paginated + * query. + */ + nextPageToken: string; +} +export interface ListServicesResponseProtoMsg { + typeUrl: "/google.api.serviceusage.v1.ListServicesResponse"; + value: Uint8Array; +} +/** Response message for the `ListServices` method. */ +export interface ListServicesResponseSDKType { + services: ServiceSDKType[]; + next_page_token: string; +} +/** Request message for the `BatchEnableServices` method. */ +export interface BatchEnableServicesRequest { + /** + * Parent to enable services on. + * + * An example name would be: + * `projects/123` where `123` is the project number. + * + * The `BatchEnableServices` method currently only supports projects. + */ + parent: string; + /** + * The identifiers of the services to enable on the project. + * + * A valid identifier would be: + * serviceusage.googleapis.com + * + * Enabling services requires that each service is public or is shared with + * the user enabling the service. + * + * A single request can enable a maximum of 20 services at a time. If more + * than 20 services are specified, the request will fail, and no state changes + * will occur. + */ + serviceIds: string[]; +} +export interface BatchEnableServicesRequestProtoMsg { + typeUrl: "/google.api.serviceusage.v1.BatchEnableServicesRequest"; + value: Uint8Array; +} +/** Request message for the `BatchEnableServices` method. */ +export interface BatchEnableServicesRequestSDKType { + parent: string; + service_ids: string[]; +} +/** + * Response message for the `BatchEnableServices` method. + * This response message is assigned to the `response` field of the returned + * Operation when that operation is done. + */ +export interface BatchEnableServicesResponse { + /** The new state of the services after enabling. */ + services: Service[]; + /** + * If allow_partial_success is true, and one or more services could not be + * enabled, this field contains the details about each failure. + */ + failures: BatchEnableServicesResponse_EnableFailure[]; +} +export interface BatchEnableServicesResponseProtoMsg { + typeUrl: "/google.api.serviceusage.v1.BatchEnableServicesResponse"; + value: Uint8Array; +} +/** + * Response message for the `BatchEnableServices` method. + * This response message is assigned to the `response` field of the returned + * Operation when that operation is done. + */ +export interface BatchEnableServicesResponseSDKType { + services: ServiceSDKType[]; + failures: BatchEnableServicesResponse_EnableFailureSDKType[]; +} +/** Provides error messages for the failing services. */ +export interface BatchEnableServicesResponse_EnableFailure { + /** The service id of a service that could not be enabled. */ + serviceId: string; + /** An error message describing why the service could not be enabled. */ + errorMessage: string; +} +export interface BatchEnableServicesResponse_EnableFailureProtoMsg { + typeUrl: "/google.api.serviceusage.v1.EnableFailure"; + value: Uint8Array; +} +/** Provides error messages for the failing services. */ +export interface BatchEnableServicesResponse_EnableFailureSDKType { + service_id: string; + error_message: string; +} +/** Request message for the `BatchGetServices` method. */ +export interface BatchGetServicesRequest { + /** + * Parent to retrieve services from. + * If this is set, the parent of all of the services specified in `names` must + * match this field. An example name would be: `projects/123` where `123` is + * the project number. The `BatchGetServices` method currently only supports + * projects. + */ + parent: string; + /** + * Names of the services to retrieve. + * + * An example name would be: + * `projects/123/services/serviceusage.googleapis.com` where `123` is the + * project number. + * A single request can get a maximum of 30 services at a time. + */ + names: string[]; +} +export interface BatchGetServicesRequestProtoMsg { + typeUrl: "/google.api.serviceusage.v1.BatchGetServicesRequest"; + value: Uint8Array; +} +/** Request message for the `BatchGetServices` method. */ +export interface BatchGetServicesRequestSDKType { + parent: string; + names: string[]; +} +/** Response message for the `BatchGetServices` method. */ +export interface BatchGetServicesResponse { + /** The requested Service states. */ + services: Service[]; +} +export interface BatchGetServicesResponseProtoMsg { + typeUrl: "/google.api.serviceusage.v1.BatchGetServicesResponse"; + value: Uint8Array; +} +/** Response message for the `BatchGetServices` method. */ +export interface BatchGetServicesResponseSDKType { + services: ServiceSDKType[]; +} +function createBaseEnableServiceRequest(): EnableServiceRequest { + return { + name: "" + }; +} +export const EnableServiceRequest = { + typeUrl: "/google.api.serviceusage.v1.EnableServiceRequest", + encode(message: EnableServiceRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): EnableServiceRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseEnableServiceRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): EnableServiceRequest { + const obj = createBaseEnableServiceRequest(); + if (isSet(object.name)) obj.name = String(object.name); + return obj; + }, + toJSON(message: EnableServiceRequest): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + return obj; + }, + fromPartial(object: DeepPartial): EnableServiceRequest { + const message = createBaseEnableServiceRequest(); + message.name = object.name ?? ""; + return message; + }, + fromSDK(object: EnableServiceRequestSDKType): EnableServiceRequest { + return { + name: object?.name + }; + }, + fromSDKJSON(object: any): EnableServiceRequestSDKType { + return { + name: isSet(object.name) ? String(object.name) : "" + }; + }, + toSDK(message: EnableServiceRequest): EnableServiceRequestSDKType { + const obj: any = {}; + obj.name = message.name; + return obj; + }, + fromAmino(object: EnableServiceRequestAmino): EnableServiceRequest { + const message = createBaseEnableServiceRequest(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + return message; + }, + toAmino(message: EnableServiceRequest): EnableServiceRequestAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + return obj; + }, + fromAminoMsg(object: EnableServiceRequestAminoMsg): EnableServiceRequest { + return EnableServiceRequest.fromAmino(object.value); + }, + fromProtoMsg(message: EnableServiceRequestProtoMsg): EnableServiceRequest { + return EnableServiceRequest.decode(message.value); + }, + toProto(message: EnableServiceRequest): Uint8Array { + return EnableServiceRequest.encode(message).finish(); + }, + toProtoMsg(message: EnableServiceRequest): EnableServiceRequestProtoMsg { + return { + typeUrl: "/google.api.serviceusage.v1.EnableServiceRequest", + value: EnableServiceRequest.encode(message).finish() + }; + } +}; +function createBaseEnableServiceResponse(): EnableServiceResponse { + return { + service: undefined + }; +} +export const EnableServiceResponse = { + typeUrl: "/google.api.serviceusage.v1.EnableServiceResponse", + encode(message: EnableServiceResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.service !== undefined) { + Service.encode(message.service, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): EnableServiceResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseEnableServiceResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.service = Service.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): EnableServiceResponse { + const obj = createBaseEnableServiceResponse(); + if (isSet(object.service)) obj.service = Service.fromJSON(object.service); + return obj; + }, + toJSON(message: EnableServiceResponse): JsonSafe { + const obj: any = {}; + message.service !== undefined && (obj.service = message.service ? Service.toJSON(message.service) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): EnableServiceResponse { + const message = createBaseEnableServiceResponse(); + if (object.service !== undefined && object.service !== null) { + message.service = Service.fromPartial(object.service); + } + return message; + }, + fromSDK(object: EnableServiceResponseSDKType): EnableServiceResponse { + return { + service: object.service ? Service.fromSDK(object.service) : undefined + }; + }, + fromSDKJSON(object: any): EnableServiceResponseSDKType { + return { + service: isSet(object.service) ? Service.fromSDKJSON(object.service) : undefined + }; + }, + toSDK(message: EnableServiceResponse): EnableServiceResponseSDKType { + const obj: any = {}; + message.service !== undefined && (obj.service = message.service ? Service.toSDK(message.service) : undefined); + return obj; + }, + fromAmino(object: EnableServiceResponseAmino): EnableServiceResponse { + const message = createBaseEnableServiceResponse(); + if (object.service !== undefined && object.service !== null) { + message.service = Service.fromAmino(object.service); + } + return message; + }, + toAmino(message: EnableServiceResponse): EnableServiceResponseAmino { + const obj: any = {}; + obj.service = message.service ? Service.toAmino(message.service) : undefined; + return obj; + }, + fromAminoMsg(object: EnableServiceResponseAminoMsg): EnableServiceResponse { + return EnableServiceResponse.fromAmino(object.value); + }, + fromProtoMsg(message: EnableServiceResponseProtoMsg): EnableServiceResponse { + return EnableServiceResponse.decode(message.value); + }, + toProto(message: EnableServiceResponse): Uint8Array { + return EnableServiceResponse.encode(message).finish(); + }, + toProtoMsg(message: EnableServiceResponse): EnableServiceResponseProtoMsg { + return { + typeUrl: "/google.api.serviceusage.v1.EnableServiceResponse", + value: EnableServiceResponse.encode(message).finish() + }; + } +}; +function createBaseDisableServiceRequest(): DisableServiceRequest { + return { + name: "", + disableDependentServices: false, + checkIfServiceHasUsage: 0 + }; +} +export const DisableServiceRequest = { + typeUrl: "/google.api.serviceusage.v1.DisableServiceRequest", + encode(message: DisableServiceRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + if (message.disableDependentServices !== undefined) { + writer.uint32(16).bool(message.disableDependentServices); + } + if (message.checkIfServiceHasUsage !== 0) { + writer.uint32(24).int32(message.checkIfServiceHasUsage); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): DisableServiceRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDisableServiceRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.disableDependentServices = reader.bool(); + break; + case 3: + message.checkIfServiceHasUsage = (reader.int32() as any); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): DisableServiceRequest { + const obj = createBaseDisableServiceRequest(); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.disableDependentServices)) obj.disableDependentServices = Boolean(object.disableDependentServices); + if (isSet(object.checkIfServiceHasUsage)) obj.checkIfServiceHasUsage = disableServiceRequest_CheckIfServiceHasUsageFromJSON(object.checkIfServiceHasUsage); + return obj; + }, + toJSON(message: DisableServiceRequest): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.disableDependentServices !== undefined && (obj.disableDependentServices = message.disableDependentServices); + message.checkIfServiceHasUsage !== undefined && (obj.checkIfServiceHasUsage = disableServiceRequest_CheckIfServiceHasUsageToJSON(message.checkIfServiceHasUsage)); + return obj; + }, + fromPartial(object: DeepPartial): DisableServiceRequest { + const message = createBaseDisableServiceRequest(); + message.name = object.name ?? ""; + message.disableDependentServices = object.disableDependentServices ?? false; + message.checkIfServiceHasUsage = object.checkIfServiceHasUsage ?? 0; + return message; + }, + fromSDK(object: DisableServiceRequestSDKType): DisableServiceRequest { + return { + name: object?.name, + disableDependentServices: object?.disable_dependent_services, + checkIfServiceHasUsage: isSet(object.check_if_service_has_usage) ? disableServiceRequest_CheckIfServiceHasUsageFromJSON(object.check_if_service_has_usage) : -1 + }; + }, + fromSDKJSON(object: any): DisableServiceRequestSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + disable_dependent_services: isSet(object.disable_dependent_services) ? Boolean(object.disable_dependent_services) : false, + check_if_service_has_usage: isSet(object.check_if_service_has_usage) ? disableServiceRequest_CheckIfServiceHasUsageFromJSON(object.check_if_service_has_usage) : -1 + }; + }, + toSDK(message: DisableServiceRequest): DisableServiceRequestSDKType { + const obj: any = {}; + obj.name = message.name; + obj.disable_dependent_services = message.disableDependentServices; + message.checkIfServiceHasUsage !== undefined && (obj.check_if_service_has_usage = disableServiceRequest_CheckIfServiceHasUsageToJSON(message.checkIfServiceHasUsage)); + return obj; + }, + fromAmino(object: DisableServiceRequestAmino): DisableServiceRequest { + const message = createBaseDisableServiceRequest(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + if (object.disable_dependent_services !== undefined && object.disable_dependent_services !== null) { + message.disableDependentServices = object.disable_dependent_services; + } + if (object.check_if_service_has_usage !== undefined && object.check_if_service_has_usage !== null) { + message.checkIfServiceHasUsage = object.check_if_service_has_usage; + } + return message; + }, + toAmino(message: DisableServiceRequest): DisableServiceRequestAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + obj.disable_dependent_services = message.disableDependentServices === false ? undefined : message.disableDependentServices; + obj.check_if_service_has_usage = message.checkIfServiceHasUsage === 0 ? undefined : message.checkIfServiceHasUsage; + return obj; + }, + fromAminoMsg(object: DisableServiceRequestAminoMsg): DisableServiceRequest { + return DisableServiceRequest.fromAmino(object.value); + }, + fromProtoMsg(message: DisableServiceRequestProtoMsg): DisableServiceRequest { + return DisableServiceRequest.decode(message.value); + }, + toProto(message: DisableServiceRequest): Uint8Array { + return DisableServiceRequest.encode(message).finish(); + }, + toProtoMsg(message: DisableServiceRequest): DisableServiceRequestProtoMsg { + return { + typeUrl: "/google.api.serviceusage.v1.DisableServiceRequest", + value: DisableServiceRequest.encode(message).finish() + }; + } +}; +function createBaseDisableServiceResponse(): DisableServiceResponse { + return { + service: undefined + }; +} +export const DisableServiceResponse = { + typeUrl: "/google.api.serviceusage.v1.DisableServiceResponse", + encode(message: DisableServiceResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.service !== undefined) { + Service.encode(message.service, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): DisableServiceResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDisableServiceResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.service = Service.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): DisableServiceResponse { + const obj = createBaseDisableServiceResponse(); + if (isSet(object.service)) obj.service = Service.fromJSON(object.service); + return obj; + }, + toJSON(message: DisableServiceResponse): JsonSafe { + const obj: any = {}; + message.service !== undefined && (obj.service = message.service ? Service.toJSON(message.service) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): DisableServiceResponse { + const message = createBaseDisableServiceResponse(); + if (object.service !== undefined && object.service !== null) { + message.service = Service.fromPartial(object.service); + } + return message; + }, + fromSDK(object: DisableServiceResponseSDKType): DisableServiceResponse { + return { + service: object.service ? Service.fromSDK(object.service) : undefined + }; + }, + fromSDKJSON(object: any): DisableServiceResponseSDKType { + return { + service: isSet(object.service) ? Service.fromSDKJSON(object.service) : undefined + }; + }, + toSDK(message: DisableServiceResponse): DisableServiceResponseSDKType { + const obj: any = {}; + message.service !== undefined && (obj.service = message.service ? Service.toSDK(message.service) : undefined); + return obj; + }, + fromAmino(object: DisableServiceResponseAmino): DisableServiceResponse { + const message = createBaseDisableServiceResponse(); + if (object.service !== undefined && object.service !== null) { + message.service = Service.fromAmino(object.service); + } + return message; + }, + toAmino(message: DisableServiceResponse): DisableServiceResponseAmino { + const obj: any = {}; + obj.service = message.service ? Service.toAmino(message.service) : undefined; + return obj; + }, + fromAminoMsg(object: DisableServiceResponseAminoMsg): DisableServiceResponse { + return DisableServiceResponse.fromAmino(object.value); + }, + fromProtoMsg(message: DisableServiceResponseProtoMsg): DisableServiceResponse { + return DisableServiceResponse.decode(message.value); + }, + toProto(message: DisableServiceResponse): Uint8Array { + return DisableServiceResponse.encode(message).finish(); + }, + toProtoMsg(message: DisableServiceResponse): DisableServiceResponseProtoMsg { + return { + typeUrl: "/google.api.serviceusage.v1.DisableServiceResponse", + value: DisableServiceResponse.encode(message).finish() + }; + } +}; +function createBaseGetServiceRequest(): GetServiceRequest { + return { + name: "" + }; +} +export const GetServiceRequest = { + typeUrl: "/google.api.serviceusage.v1.GetServiceRequest", + encode(message: GetServiceRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GetServiceRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGetServiceRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GetServiceRequest { + const obj = createBaseGetServiceRequest(); + if (isSet(object.name)) obj.name = String(object.name); + return obj; + }, + toJSON(message: GetServiceRequest): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + return obj; + }, + fromPartial(object: DeepPartial): GetServiceRequest { + const message = createBaseGetServiceRequest(); + message.name = object.name ?? ""; + return message; + }, + fromSDK(object: GetServiceRequestSDKType): GetServiceRequest { + return { + name: object?.name + }; + }, + fromSDKJSON(object: any): GetServiceRequestSDKType { + return { + name: isSet(object.name) ? String(object.name) : "" + }; + }, + toSDK(message: GetServiceRequest): GetServiceRequestSDKType { + const obj: any = {}; + obj.name = message.name; + return obj; + }, + fromAmino(object: GetServiceRequestAmino): GetServiceRequest { + const message = createBaseGetServiceRequest(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + return message; + }, + toAmino(message: GetServiceRequest): GetServiceRequestAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + return obj; + }, + fromAminoMsg(object: GetServiceRequestAminoMsg): GetServiceRequest { + return GetServiceRequest.fromAmino(object.value); + }, + fromProtoMsg(message: GetServiceRequestProtoMsg): GetServiceRequest { + return GetServiceRequest.decode(message.value); + }, + toProto(message: GetServiceRequest): Uint8Array { + return GetServiceRequest.encode(message).finish(); + }, + toProtoMsg(message: GetServiceRequest): GetServiceRequestProtoMsg { + return { + typeUrl: "/google.api.serviceusage.v1.GetServiceRequest", + value: GetServiceRequest.encode(message).finish() + }; + } +}; +function createBaseListServicesRequest(): ListServicesRequest { + return { + parent: "", + pageSize: 0, + pageToken: "", + filter: "" + }; +} +export const ListServicesRequest = { + typeUrl: "/google.api.serviceusage.v1.ListServicesRequest", + encode(message: ListServicesRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.parent !== undefined) { + writer.uint32(10).string(message.parent); + } + if (message.pageSize !== undefined) { + writer.uint32(16).int32(message.pageSize); + } + if (message.pageToken !== undefined) { + writer.uint32(26).string(message.pageToken); + } + if (message.filter !== undefined) { + writer.uint32(34).string(message.filter); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ListServicesRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseListServicesRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.parent = reader.string(); + break; + case 2: + message.pageSize = reader.int32(); + break; + case 3: + message.pageToken = reader.string(); + break; + case 4: + message.filter = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ListServicesRequest { + const obj = createBaseListServicesRequest(); + if (isSet(object.parent)) obj.parent = String(object.parent); + if (isSet(object.pageSize)) obj.pageSize = Number(object.pageSize); + if (isSet(object.pageToken)) obj.pageToken = String(object.pageToken); + if (isSet(object.filter)) obj.filter = String(object.filter); + return obj; + }, + toJSON(message: ListServicesRequest): JsonSafe { + const obj: any = {}; + message.parent !== undefined && (obj.parent = message.parent); + message.pageSize !== undefined && (obj.pageSize = Math.round(message.pageSize)); + message.pageToken !== undefined && (obj.pageToken = message.pageToken); + message.filter !== undefined && (obj.filter = message.filter); + return obj; + }, + fromPartial(object: DeepPartial): ListServicesRequest { + const message = createBaseListServicesRequest(); + message.parent = object.parent ?? ""; + message.pageSize = object.pageSize ?? 0; + message.pageToken = object.pageToken ?? ""; + message.filter = object.filter ?? ""; + return message; + }, + fromSDK(object: ListServicesRequestSDKType): ListServicesRequest { + return { + parent: object?.parent, + pageSize: object?.page_size, + pageToken: object?.page_token, + filter: object?.filter + }; + }, + fromSDKJSON(object: any): ListServicesRequestSDKType { + return { + parent: isSet(object.parent) ? String(object.parent) : "", + page_size: isSet(object.page_size) ? Number(object.page_size) : 0, + page_token: isSet(object.page_token) ? String(object.page_token) : "", + filter: isSet(object.filter) ? String(object.filter) : "" + }; + }, + toSDK(message: ListServicesRequest): ListServicesRequestSDKType { + const obj: any = {}; + obj.parent = message.parent; + obj.page_size = message.pageSize; + obj.page_token = message.pageToken; + obj.filter = message.filter; + return obj; + }, + fromAmino(object: ListServicesRequestAmino): ListServicesRequest { + const message = createBaseListServicesRequest(); + if (object.parent !== undefined && object.parent !== null) { + message.parent = object.parent; + } + if (object.page_size !== undefined && object.page_size !== null) { + message.pageSize = object.page_size; + } + if (object.page_token !== undefined && object.page_token !== null) { + message.pageToken = object.page_token; + } + if (object.filter !== undefined && object.filter !== null) { + message.filter = object.filter; + } + return message; + }, + toAmino(message: ListServicesRequest): ListServicesRequestAmino { + const obj: any = {}; + obj.parent = message.parent === "" ? undefined : message.parent; + obj.page_size = message.pageSize === 0 ? undefined : message.pageSize; + obj.page_token = message.pageToken === "" ? undefined : message.pageToken; + obj.filter = message.filter === "" ? undefined : message.filter; + return obj; + }, + fromAminoMsg(object: ListServicesRequestAminoMsg): ListServicesRequest { + return ListServicesRequest.fromAmino(object.value); + }, + fromProtoMsg(message: ListServicesRequestProtoMsg): ListServicesRequest { + return ListServicesRequest.decode(message.value); + }, + toProto(message: ListServicesRequest): Uint8Array { + return ListServicesRequest.encode(message).finish(); + }, + toProtoMsg(message: ListServicesRequest): ListServicesRequestProtoMsg { + return { + typeUrl: "/google.api.serviceusage.v1.ListServicesRequest", + value: ListServicesRequest.encode(message).finish() + }; + } +}; +function createBaseListServicesResponse(): ListServicesResponse { + return { + services: [], + nextPageToken: "" + }; +} +export const ListServicesResponse = { + typeUrl: "/google.api.serviceusage.v1.ListServicesResponse", + encode(message: ListServicesResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.services) { + Service.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.nextPageToken !== undefined) { + writer.uint32(18).string(message.nextPageToken); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ListServicesResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseListServicesResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.services.push(Service.decode(reader, reader.uint32())); + break; + case 2: + message.nextPageToken = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ListServicesResponse { + const obj = createBaseListServicesResponse(); + if (Array.isArray(object?.services)) obj.services = object.services.map((e: any) => Service.fromJSON(e)); + if (isSet(object.nextPageToken)) obj.nextPageToken = String(object.nextPageToken); + return obj; + }, + toJSON(message: ListServicesResponse): JsonSafe { + const obj: any = {}; + if (message.services) { + obj.services = message.services.map(e => e ? Service.toJSON(e) : undefined); + } else { + obj.services = []; + } + message.nextPageToken !== undefined && (obj.nextPageToken = message.nextPageToken); + return obj; + }, + fromPartial(object: DeepPartial): ListServicesResponse { + const message = createBaseListServicesResponse(); + message.services = object.services?.map(e => Service.fromPartial(e)) || []; + message.nextPageToken = object.nextPageToken ?? ""; + return message; + }, + fromSDK(object: ListServicesResponseSDKType): ListServicesResponse { + return { + services: Array.isArray(object?.services) ? object.services.map((e: any) => Service.fromSDK(e)) : [], + nextPageToken: object?.next_page_token + }; + }, + fromSDKJSON(object: any): ListServicesResponseSDKType { + return { + services: Array.isArray(object?.services) ? object.services.map((e: any) => Service.fromSDKJSON(e)) : [], + next_page_token: isSet(object.next_page_token) ? String(object.next_page_token) : "" + }; + }, + toSDK(message: ListServicesResponse): ListServicesResponseSDKType { + const obj: any = {}; + if (message.services) { + obj.services = message.services.map(e => e ? Service.toSDK(e) : undefined); + } else { + obj.services = []; + } + obj.next_page_token = message.nextPageToken; + return obj; + }, + fromAmino(object: ListServicesResponseAmino): ListServicesResponse { + const message = createBaseListServicesResponse(); + message.services = object.services?.map(e => Service.fromAmino(e)) || []; + if (object.next_page_token !== undefined && object.next_page_token !== null) { + message.nextPageToken = object.next_page_token; + } + return message; + }, + toAmino(message: ListServicesResponse): ListServicesResponseAmino { + const obj: any = {}; + if (message.services) { + obj.services = message.services.map(e => e ? Service.toAmino(e) : undefined); + } else { + obj.services = message.services; + } + obj.next_page_token = message.nextPageToken === "" ? undefined : message.nextPageToken; + return obj; + }, + fromAminoMsg(object: ListServicesResponseAminoMsg): ListServicesResponse { + return ListServicesResponse.fromAmino(object.value); + }, + fromProtoMsg(message: ListServicesResponseProtoMsg): ListServicesResponse { + return ListServicesResponse.decode(message.value); + }, + toProto(message: ListServicesResponse): Uint8Array { + return ListServicesResponse.encode(message).finish(); + }, + toProtoMsg(message: ListServicesResponse): ListServicesResponseProtoMsg { + return { + typeUrl: "/google.api.serviceusage.v1.ListServicesResponse", + value: ListServicesResponse.encode(message).finish() + }; + } +}; +function createBaseBatchEnableServicesRequest(): BatchEnableServicesRequest { + return { + parent: "", + serviceIds: [] + }; +} +export const BatchEnableServicesRequest = { + typeUrl: "/google.api.serviceusage.v1.BatchEnableServicesRequest", + encode(message: BatchEnableServicesRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.parent !== undefined) { + writer.uint32(10).string(message.parent); + } + for (const v of message.serviceIds) { + writer.uint32(18).string(v!); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): BatchEnableServicesRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseBatchEnableServicesRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.parent = reader.string(); + break; + case 2: + message.serviceIds.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): BatchEnableServicesRequest { + const obj = createBaseBatchEnableServicesRequest(); + if (isSet(object.parent)) obj.parent = String(object.parent); + if (Array.isArray(object?.serviceIds)) obj.serviceIds = object.serviceIds.map((e: any) => String(e)); + return obj; + }, + toJSON(message: BatchEnableServicesRequest): JsonSafe { + const obj: any = {}; + message.parent !== undefined && (obj.parent = message.parent); + if (message.serviceIds) { + obj.serviceIds = message.serviceIds.map(e => e); + } else { + obj.serviceIds = []; + } + return obj; + }, + fromPartial(object: DeepPartial): BatchEnableServicesRequest { + const message = createBaseBatchEnableServicesRequest(); + message.parent = object.parent ?? ""; + message.serviceIds = object.serviceIds?.map(e => e) || []; + return message; + }, + fromSDK(object: BatchEnableServicesRequestSDKType): BatchEnableServicesRequest { + return { + parent: object?.parent, + serviceIds: Array.isArray(object?.service_ids) ? object.service_ids.map((e: any) => e) : [] + }; + }, + fromSDKJSON(object: any): BatchEnableServicesRequestSDKType { + return { + parent: isSet(object.parent) ? String(object.parent) : "", + service_ids: Array.isArray(object?.service_ids) ? object.service_ids.map((e: any) => String(e)) : [] + }; + }, + toSDK(message: BatchEnableServicesRequest): BatchEnableServicesRequestSDKType { + const obj: any = {}; + obj.parent = message.parent; + if (message.serviceIds) { + obj.service_ids = message.serviceIds.map(e => e); + } else { + obj.service_ids = []; + } + return obj; + }, + fromAmino(object: BatchEnableServicesRequestAmino): BatchEnableServicesRequest { + const message = createBaseBatchEnableServicesRequest(); + if (object.parent !== undefined && object.parent !== null) { + message.parent = object.parent; + } + message.serviceIds = object.service_ids?.map(e => e) || []; + return message; + }, + toAmino(message: BatchEnableServicesRequest): BatchEnableServicesRequestAmino { + const obj: any = {}; + obj.parent = message.parent === "" ? undefined : message.parent; + if (message.serviceIds) { + obj.service_ids = message.serviceIds.map(e => e); + } else { + obj.service_ids = message.serviceIds; + } + return obj; + }, + fromAminoMsg(object: BatchEnableServicesRequestAminoMsg): BatchEnableServicesRequest { + return BatchEnableServicesRequest.fromAmino(object.value); + }, + fromProtoMsg(message: BatchEnableServicesRequestProtoMsg): BatchEnableServicesRequest { + return BatchEnableServicesRequest.decode(message.value); + }, + toProto(message: BatchEnableServicesRequest): Uint8Array { + return BatchEnableServicesRequest.encode(message).finish(); + }, + toProtoMsg(message: BatchEnableServicesRequest): BatchEnableServicesRequestProtoMsg { + return { + typeUrl: "/google.api.serviceusage.v1.BatchEnableServicesRequest", + value: BatchEnableServicesRequest.encode(message).finish() + }; + } +}; +function createBaseBatchEnableServicesResponse(): BatchEnableServicesResponse { + return { + services: [], + failures: [] + }; +} +export const BatchEnableServicesResponse = { + typeUrl: "/google.api.serviceusage.v1.BatchEnableServicesResponse", + encode(message: BatchEnableServicesResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.services) { + Service.encode(v!, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.failures) { + BatchEnableServicesResponse_EnableFailure.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): BatchEnableServicesResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseBatchEnableServicesResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.services.push(Service.decode(reader, reader.uint32())); + break; + case 2: + message.failures.push(BatchEnableServicesResponse_EnableFailure.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): BatchEnableServicesResponse { + const obj = createBaseBatchEnableServicesResponse(); + if (Array.isArray(object?.services)) obj.services = object.services.map((e: any) => Service.fromJSON(e)); + if (Array.isArray(object?.failures)) obj.failures = object.failures.map((e: any) => BatchEnableServicesResponse_EnableFailure.fromJSON(e)); + return obj; + }, + toJSON(message: BatchEnableServicesResponse): JsonSafe { + const obj: any = {}; + if (message.services) { + obj.services = message.services.map(e => e ? Service.toJSON(e) : undefined); + } else { + obj.services = []; + } + if (message.failures) { + obj.failures = message.failures.map(e => e ? BatchEnableServicesResponse_EnableFailure.toJSON(e) : undefined); + } else { + obj.failures = []; + } + return obj; + }, + fromPartial(object: DeepPartial): BatchEnableServicesResponse { + const message = createBaseBatchEnableServicesResponse(); + message.services = object.services?.map(e => Service.fromPartial(e)) || []; + message.failures = object.failures?.map(e => BatchEnableServicesResponse_EnableFailure.fromPartial(e)) || []; + return message; + }, + fromSDK(object: BatchEnableServicesResponseSDKType): BatchEnableServicesResponse { + return { + services: Array.isArray(object?.services) ? object.services.map((e: any) => Service.fromSDK(e)) : [], + failures: Array.isArray(object?.failures) ? object.failures.map((e: any) => BatchEnableServicesResponse_EnableFailure.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): BatchEnableServicesResponseSDKType { + return { + services: Array.isArray(object?.services) ? object.services.map((e: any) => Service.fromSDKJSON(e)) : [], + failures: Array.isArray(object?.failures) ? object.failures.map((e: any) => BatchEnableServicesResponse_EnableFailure.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: BatchEnableServicesResponse): BatchEnableServicesResponseSDKType { + const obj: any = {}; + if (message.services) { + obj.services = message.services.map(e => e ? Service.toSDK(e) : undefined); + } else { + obj.services = []; + } + if (message.failures) { + obj.failures = message.failures.map(e => e ? BatchEnableServicesResponse_EnableFailure.toSDK(e) : undefined); + } else { + obj.failures = []; + } + return obj; + }, + fromAmino(object: BatchEnableServicesResponseAmino): BatchEnableServicesResponse { + const message = createBaseBatchEnableServicesResponse(); + message.services = object.services?.map(e => Service.fromAmino(e)) || []; + message.failures = object.failures?.map(e => BatchEnableServicesResponse_EnableFailure.fromAmino(e)) || []; + return message; + }, + toAmino(message: BatchEnableServicesResponse): BatchEnableServicesResponseAmino { + const obj: any = {}; + if (message.services) { + obj.services = message.services.map(e => e ? Service.toAmino(e) : undefined); + } else { + obj.services = message.services; + } + if (message.failures) { + obj.failures = message.failures.map(e => e ? BatchEnableServicesResponse_EnableFailure.toAmino(e) : undefined); + } else { + obj.failures = message.failures; + } + return obj; + }, + fromAminoMsg(object: BatchEnableServicesResponseAminoMsg): BatchEnableServicesResponse { + return BatchEnableServicesResponse.fromAmino(object.value); + }, + fromProtoMsg(message: BatchEnableServicesResponseProtoMsg): BatchEnableServicesResponse { + return BatchEnableServicesResponse.decode(message.value); + }, + toProto(message: BatchEnableServicesResponse): Uint8Array { + return BatchEnableServicesResponse.encode(message).finish(); + }, + toProtoMsg(message: BatchEnableServicesResponse): BatchEnableServicesResponseProtoMsg { + return { + typeUrl: "/google.api.serviceusage.v1.BatchEnableServicesResponse", + value: BatchEnableServicesResponse.encode(message).finish() + }; + } +}; +function createBaseBatchEnableServicesResponse_EnableFailure(): BatchEnableServicesResponse_EnableFailure { + return { + serviceId: "", + errorMessage: "" + }; +} +export const BatchEnableServicesResponse_EnableFailure = { + typeUrl: "/google.api.serviceusage.v1.EnableFailure", + encode(message: BatchEnableServicesResponse_EnableFailure, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.serviceId !== undefined) { + writer.uint32(10).string(message.serviceId); + } + if (message.errorMessage !== undefined) { + writer.uint32(18).string(message.errorMessage); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): BatchEnableServicesResponse_EnableFailure { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseBatchEnableServicesResponse_EnableFailure(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.serviceId = reader.string(); + break; + case 2: + message.errorMessage = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): BatchEnableServicesResponse_EnableFailure { + const obj = createBaseBatchEnableServicesResponse_EnableFailure(); + if (isSet(object.serviceId)) obj.serviceId = String(object.serviceId); + if (isSet(object.errorMessage)) obj.errorMessage = String(object.errorMessage); + return obj; + }, + toJSON(message: BatchEnableServicesResponse_EnableFailure): JsonSafe { + const obj: any = {}; + message.serviceId !== undefined && (obj.serviceId = message.serviceId); + message.errorMessage !== undefined && (obj.errorMessage = message.errorMessage); + return obj; + }, + fromPartial(object: DeepPartial): BatchEnableServicesResponse_EnableFailure { + const message = createBaseBatchEnableServicesResponse_EnableFailure(); + message.serviceId = object.serviceId ?? ""; + message.errorMessage = object.errorMessage ?? ""; + return message; + }, + fromSDK(object: BatchEnableServicesResponse_EnableFailureSDKType): BatchEnableServicesResponse_EnableFailure { + return { + serviceId: object?.service_id, + errorMessage: object?.error_message + }; + }, + fromSDKJSON(object: any): BatchEnableServicesResponse_EnableFailureSDKType { + return { + service_id: isSet(object.service_id) ? String(object.service_id) : "", + error_message: isSet(object.error_message) ? String(object.error_message) : "" + }; + }, + toSDK(message: BatchEnableServicesResponse_EnableFailure): BatchEnableServicesResponse_EnableFailureSDKType { + const obj: any = {}; + obj.service_id = message.serviceId; + obj.error_message = message.errorMessage; + return obj; + }, + fromAmino(object: BatchEnableServicesResponse_EnableFailureAmino): BatchEnableServicesResponse_EnableFailure { + const message = createBaseBatchEnableServicesResponse_EnableFailure(); + if (object.service_id !== undefined && object.service_id !== null) { + message.serviceId = object.service_id; + } + if (object.error_message !== undefined && object.error_message !== null) { + message.errorMessage = object.error_message; + } + return message; + }, + toAmino(message: BatchEnableServicesResponse_EnableFailure): BatchEnableServicesResponse_EnableFailureAmino { + const obj: any = {}; + obj.service_id = message.serviceId === "" ? undefined : message.serviceId; + obj.error_message = message.errorMessage === "" ? undefined : message.errorMessage; + return obj; + }, + fromAminoMsg(object: BatchEnableServicesResponse_EnableFailureAminoMsg): BatchEnableServicesResponse_EnableFailure { + return BatchEnableServicesResponse_EnableFailure.fromAmino(object.value); + }, + fromProtoMsg(message: BatchEnableServicesResponse_EnableFailureProtoMsg): BatchEnableServicesResponse_EnableFailure { + return BatchEnableServicesResponse_EnableFailure.decode(message.value); + }, + toProto(message: BatchEnableServicesResponse_EnableFailure): Uint8Array { + return BatchEnableServicesResponse_EnableFailure.encode(message).finish(); + }, + toProtoMsg(message: BatchEnableServicesResponse_EnableFailure): BatchEnableServicesResponse_EnableFailureProtoMsg { + return { + typeUrl: "/google.api.serviceusage.v1.EnableFailure", + value: BatchEnableServicesResponse_EnableFailure.encode(message).finish() + }; + } +}; +function createBaseBatchGetServicesRequest(): BatchGetServicesRequest { + return { + parent: "", + names: [] + }; +} +export const BatchGetServicesRequest = { + typeUrl: "/google.api.serviceusage.v1.BatchGetServicesRequest", + encode(message: BatchGetServicesRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.parent !== undefined) { + writer.uint32(10).string(message.parent); + } + for (const v of message.names) { + writer.uint32(18).string(v!); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): BatchGetServicesRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseBatchGetServicesRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.parent = reader.string(); + break; + case 2: + message.names.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): BatchGetServicesRequest { + const obj = createBaseBatchGetServicesRequest(); + if (isSet(object.parent)) obj.parent = String(object.parent); + if (Array.isArray(object?.names)) obj.names = object.names.map((e: any) => String(e)); + return obj; + }, + toJSON(message: BatchGetServicesRequest): JsonSafe { + const obj: any = {}; + message.parent !== undefined && (obj.parent = message.parent); + if (message.names) { + obj.names = message.names.map(e => e); + } else { + obj.names = []; + } + return obj; + }, + fromPartial(object: DeepPartial): BatchGetServicesRequest { + const message = createBaseBatchGetServicesRequest(); + message.parent = object.parent ?? ""; + message.names = object.names?.map(e => e) || []; + return message; + }, + fromSDK(object: BatchGetServicesRequestSDKType): BatchGetServicesRequest { + return { + parent: object?.parent, + names: Array.isArray(object?.names) ? object.names.map((e: any) => e) : [] + }; + }, + fromSDKJSON(object: any): BatchGetServicesRequestSDKType { + return { + parent: isSet(object.parent) ? String(object.parent) : "", + names: Array.isArray(object?.names) ? object.names.map((e: any) => String(e)) : [] + }; + }, + toSDK(message: BatchGetServicesRequest): BatchGetServicesRequestSDKType { + const obj: any = {}; + obj.parent = message.parent; + if (message.names) { + obj.names = message.names.map(e => e); + } else { + obj.names = []; + } + return obj; + }, + fromAmino(object: BatchGetServicesRequestAmino): BatchGetServicesRequest { + const message = createBaseBatchGetServicesRequest(); + if (object.parent !== undefined && object.parent !== null) { + message.parent = object.parent; + } + message.names = object.names?.map(e => e) || []; + return message; + }, + toAmino(message: BatchGetServicesRequest): BatchGetServicesRequestAmino { + const obj: any = {}; + obj.parent = message.parent === "" ? undefined : message.parent; + if (message.names) { + obj.names = message.names.map(e => e); + } else { + obj.names = message.names; + } + return obj; + }, + fromAminoMsg(object: BatchGetServicesRequestAminoMsg): BatchGetServicesRequest { + return BatchGetServicesRequest.fromAmino(object.value); + }, + fromProtoMsg(message: BatchGetServicesRequestProtoMsg): BatchGetServicesRequest { + return BatchGetServicesRequest.decode(message.value); + }, + toProto(message: BatchGetServicesRequest): Uint8Array { + return BatchGetServicesRequest.encode(message).finish(); + }, + toProtoMsg(message: BatchGetServicesRequest): BatchGetServicesRequestProtoMsg { + return { + typeUrl: "/google.api.serviceusage.v1.BatchGetServicesRequest", + value: BatchGetServicesRequest.encode(message).finish() + }; + } +}; +function createBaseBatchGetServicesResponse(): BatchGetServicesResponse { + return { + services: [] + }; +} +export const BatchGetServicesResponse = { + typeUrl: "/google.api.serviceusage.v1.BatchGetServicesResponse", + encode(message: BatchGetServicesResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.services) { + Service.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): BatchGetServicesResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseBatchGetServicesResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.services.push(Service.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): BatchGetServicesResponse { + const obj = createBaseBatchGetServicesResponse(); + if (Array.isArray(object?.services)) obj.services = object.services.map((e: any) => Service.fromJSON(e)); + return obj; + }, + toJSON(message: BatchGetServicesResponse): JsonSafe { + const obj: any = {}; + if (message.services) { + obj.services = message.services.map(e => e ? Service.toJSON(e) : undefined); + } else { + obj.services = []; + } + return obj; + }, + fromPartial(object: DeepPartial): BatchGetServicesResponse { + const message = createBaseBatchGetServicesResponse(); + message.services = object.services?.map(e => Service.fromPartial(e)) || []; + return message; + }, + fromSDK(object: BatchGetServicesResponseSDKType): BatchGetServicesResponse { + return { + services: Array.isArray(object?.services) ? object.services.map((e: any) => Service.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): BatchGetServicesResponseSDKType { + return { + services: Array.isArray(object?.services) ? object.services.map((e: any) => Service.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: BatchGetServicesResponse): BatchGetServicesResponseSDKType { + const obj: any = {}; + if (message.services) { + obj.services = message.services.map(e => e ? Service.toSDK(e) : undefined); + } else { + obj.services = []; + } + return obj; + }, + fromAmino(object: BatchGetServicesResponseAmino): BatchGetServicesResponse { + const message = createBaseBatchGetServicesResponse(); + message.services = object.services?.map(e => Service.fromAmino(e)) || []; + return message; + }, + toAmino(message: BatchGetServicesResponse): BatchGetServicesResponseAmino { + const obj: any = {}; + if (message.services) { + obj.services = message.services.map(e => e ? Service.toAmino(e) : undefined); + } else { + obj.services = message.services; + } + return obj; + }, + fromAminoMsg(object: BatchGetServicesResponseAminoMsg): BatchGetServicesResponse { + return BatchGetServicesResponse.fromAmino(object.value); + }, + fromProtoMsg(message: BatchGetServicesResponseProtoMsg): BatchGetServicesResponse { + return BatchGetServicesResponse.decode(message.value); + }, + toProto(message: BatchGetServicesResponse): Uint8Array { + return BatchGetServicesResponse.encode(message).finish(); + }, + toProtoMsg(message: BatchGetServicesResponse): BatchGetServicesResponseProtoMsg { + return { + typeUrl: "/google.api.serviceusage.v1.BatchGetServicesResponse", + value: BatchGetServicesResponse.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/api/serviceusage/v1beta1/resources.ts b/__fixtures__/v-next/outputicjsdeps/google/api/serviceusage/v1beta1/resources.ts new file mode 100644 index 0000000000..165d71ab35 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/api/serviceusage/v1beta1/resources.ts @@ -0,0 +1,2737 @@ +import { Api, ApiSDKType } from "../../../protobuf/api.js"; +import { Documentation, DocumentationSDKType } from "../../documentation.js"; +import { Quota, QuotaSDKType } from "../../quota.js"; +import { Authentication, AuthenticationSDKType } from "../../auth.js"; +import { Usage, UsageSDKType } from "../../usage.js"; +import { Endpoint, EndpointSDKType } from "../../endpoint.js"; +import { MonitoredResourceDescriptor, MonitoredResourceDescriptorSDKType } from "../../monitored_resource.js"; +import { Monitoring, MonitoringSDKType } from "../../monitoring.js"; +import { BinaryReader, BinaryWriter } from "../../../../binary.js"; +import { isSet, DeepPartial, isObject } from "../../../../helpers.js"; +import { JsonSafe } from "../../../../json-safe.js"; +export const protobufPackage = "google.api.serviceusage.v1beta1"; +/** Whether or not a service has been enabled for use by a consumer. */ +export enum State { + /** + * STATE_UNSPECIFIED - The default value, which indicates that the enabled state of the service + * is unspecified or not meaningful. Currently, all consumers other than + * projects (such as folders and organizations) are always in this state. + */ + STATE_UNSPECIFIED = 0, + /** + * DISABLED - The service cannot be used by this consumer. It has either been explicitly + * disabled, or has never been enabled. + */ + DISABLED = 1, + /** ENABLED - The service has been explicitly enabled for use by this consumer. */ + ENABLED = 2, + UNRECOGNIZED = -1, +} +export const StateSDKType = State; +export function stateFromJSON(object: any): State { + switch (object) { + case 0: + case "STATE_UNSPECIFIED": + return State.STATE_UNSPECIFIED; + case 1: + case "DISABLED": + return State.DISABLED; + case 2: + case "ENABLED": + return State.ENABLED; + case -1: + case "UNRECOGNIZED": + default: + return State.UNRECOGNIZED; + } +} +export function stateToJSON(object: State): string { + switch (object) { + case State.STATE_UNSPECIFIED: + return "STATE_UNSPECIFIED"; + case State.DISABLED: + return "DISABLED"; + case State.ENABLED: + return "ENABLED"; + case State.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** + * Selected view of quota. Can be used to request more detailed quota + * information when retrieving quota metrics and limits. + */ +export enum QuotaView { + /** + * QUOTA_VIEW_UNSPECIFIED - No quota view specified. Requests that do not specify a quota view will + * typically default to the BASIC view. + */ + QUOTA_VIEW_UNSPECIFIED = 0, + /** BASIC - Only buckets with overrides are shown in the response. */ + BASIC = 1, + /** + * FULL - Include per-location buckets even if they do not have overrides. + * When the view is FULL, and a limit has regional or zonal quota, the limit + * will include buckets for all regions or zones that could support + * overrides, even if none are currently present. In some cases this will + * cause the response to become very large; callers that do not need this + * extra information should use the BASIC view instead. + */ + FULL = 2, + UNRECOGNIZED = -1, +} +export const QuotaViewSDKType = QuotaView; +export function quotaViewFromJSON(object: any): QuotaView { + switch (object) { + case 0: + case "QUOTA_VIEW_UNSPECIFIED": + return QuotaView.QUOTA_VIEW_UNSPECIFIED; + case 1: + case "BASIC": + return QuotaView.BASIC; + case 2: + case "FULL": + return QuotaView.FULL; + case -1: + case "UNRECOGNIZED": + default: + return QuotaView.UNRECOGNIZED; + } +} +export function quotaViewToJSON(object: QuotaView): string { + switch (object) { + case QuotaView.QUOTA_VIEW_UNSPECIFIED: + return "QUOTA_VIEW_UNSPECIFIED"; + case QuotaView.BASIC: + return "BASIC"; + case QuotaView.FULL: + return "FULL"; + case QuotaView.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** Enumerations of quota safety checks. */ +export enum QuotaSafetyCheck { + /** QUOTA_SAFETY_CHECK_UNSPECIFIED - Unspecified quota safety check. */ + QUOTA_SAFETY_CHECK_UNSPECIFIED = 0, + /** + * LIMIT_DECREASE_BELOW_USAGE - Validates that a quota mutation would not cause the consumer's effective + * limit to be lower than the consumer's quota usage. + */ + LIMIT_DECREASE_BELOW_USAGE = 1, + /** + * LIMIT_DECREASE_PERCENTAGE_TOO_HIGH - Validates that a quota mutation would not cause the consumer's effective + * limit to decrease by more than 10 percent. + */ + LIMIT_DECREASE_PERCENTAGE_TOO_HIGH = 2, + UNRECOGNIZED = -1, +} +export const QuotaSafetyCheckSDKType = QuotaSafetyCheck; +export function quotaSafetyCheckFromJSON(object: any): QuotaSafetyCheck { + switch (object) { + case 0: + case "QUOTA_SAFETY_CHECK_UNSPECIFIED": + return QuotaSafetyCheck.QUOTA_SAFETY_CHECK_UNSPECIFIED; + case 1: + case "LIMIT_DECREASE_BELOW_USAGE": + return QuotaSafetyCheck.LIMIT_DECREASE_BELOW_USAGE; + case 2: + case "LIMIT_DECREASE_PERCENTAGE_TOO_HIGH": + return QuotaSafetyCheck.LIMIT_DECREASE_PERCENTAGE_TOO_HIGH; + case -1: + case "UNRECOGNIZED": + default: + return QuotaSafetyCheck.UNRECOGNIZED; + } +} +export function quotaSafetyCheckToJSON(object: QuotaSafetyCheck): string { + switch (object) { + case QuotaSafetyCheck.QUOTA_SAFETY_CHECK_UNSPECIFIED: + return "QUOTA_SAFETY_CHECK_UNSPECIFIED"; + case QuotaSafetyCheck.LIMIT_DECREASE_BELOW_USAGE: + return "LIMIT_DECREASE_BELOW_USAGE"; + case QuotaSafetyCheck.LIMIT_DECREASE_PERCENTAGE_TOO_HIGH: + return "LIMIT_DECREASE_PERCENTAGE_TOO_HIGH"; + case QuotaSafetyCheck.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** A service that is available for use by the consumer. */ +export interface Service { + /** + * The resource name of the consumer and service. + * + * A valid name would be: + * - `projects/123/services/serviceusage.googleapis.com` + */ + name: string; + /** + * The resource name of the consumer. + * + * A valid name would be: + * - `projects/123` + */ + parent: string; + /** + * The service configuration of the available service. + * Some fields may be filtered out of the configuration in responses to + * the `ListServices` method. These fields are present only in responses to + * the `GetService` method. + */ + config?: ServiceConfig; + /** Whether or not the service has been enabled for use by the consumer. */ + state: State; +} +export interface ServiceProtoMsg { + typeUrl: "/google.api.serviceusage.v1beta1.Service"; + value: Uint8Array; +} +/** A service that is available for use by the consumer. */ +export interface ServiceSDKType { + name: string; + parent: string; + config?: ServiceConfigSDKType; + state: State; +} +/** The configuration of the service. */ +export interface ServiceConfig { + /** + * The DNS address at which this service is available. + * + * An example DNS address would be: + * `calendar.googleapis.com`. + */ + name: string; + /** The product title for this service. */ + title: string; + /** + * A list of API interfaces exported by this service. Contains only the names, + * versions, and method names of the interfaces. + */ + apis: Api[]; + /** + * Additional API documentation. Contains only the summary and the + * documentation URL. + */ + documentation?: Documentation; + /** Quota configuration. */ + quota?: Quota; + /** Auth configuration. Contains only the OAuth rules. */ + authentication?: Authentication; + /** Configuration controlling usage of this service. */ + usage?: Usage; + /** + * Configuration for network endpoints. Contains only the names and aliases + * of the endpoints. + */ + endpoints: Endpoint[]; + /** + * Defines the monitored resources used by this service. This is required + * by the [Service.monitoring][google.api.Service.monitoring] and [Service.logging][google.api.Service.logging] configurations. + */ + monitoredResources: MonitoredResourceDescriptor[]; + /** + * Monitoring configuration. + * This should not include the 'producer_destinations' field. + */ + monitoring?: Monitoring; +} +export interface ServiceConfigProtoMsg { + typeUrl: "/google.api.serviceusage.v1beta1.ServiceConfig"; + value: Uint8Array; +} +/** The configuration of the service. */ +export interface ServiceConfigSDKType { + name: string; + title: string; + apis: ApiSDKType[]; + documentation?: DocumentationSDKType; + quota?: QuotaSDKType; + authentication?: AuthenticationSDKType; + usage?: UsageSDKType; + endpoints: EndpointSDKType[]; + monitored_resources: MonitoredResourceDescriptorSDKType[]; + monitoring?: MonitoringSDKType; +} +/** The operation metadata returned for the batchend services operation. */ +export interface OperationMetadata { + /** + * The full name of the resources that this operation is directly + * associated with. + */ + resourceNames: string[]; +} +export interface OperationMetadataProtoMsg { + typeUrl: "/google.api.serviceusage.v1beta1.OperationMetadata"; + value: Uint8Array; +} +/** The operation metadata returned for the batchend services operation. */ +export interface OperationMetadataSDKType { + resource_names: string[]; +} +/** Consumer quota settings for a quota metric. */ +export interface ConsumerQuotaMetric { + /** + * The resource name of the quota settings on this metric for this consumer. + * + * An example name would be: + * `projects/123/services/compute.googleapis.com/consumerQuotaMetrics/compute.googleapis.com%2Fcpus` + * + * The resource name is intended to be opaque and should not be parsed for + * its component strings, since its representation could change in the future. + */ + name: string; + /** + * The name of the metric. + * + * An example name would be: + * `compute.googleapis.com/cpus` + */ + metric: string; + /** + * The display name of the metric. + * + * An example name would be: + * `CPUs` + */ + displayName: string; + /** The consumer quota for each quota limit defined on the metric. */ + consumerQuotaLimits: ConsumerQuotaLimit[]; + /** + * The quota limits targeting the descendant containers of the + * consumer in request. + * + * If the consumer in request is of type `organizations` + * or `folders`, the field will list per-project limits in the metric; if the + * consumer in request is of type `project`, the field will be empty. + * + * The `quota_buckets` field of each descendant consumer quota limit will not + * be populated. + */ + descendantConsumerQuotaLimits: ConsumerQuotaLimit[]; + /** The units in which the metric value is reported. */ + unit: string; +} +export interface ConsumerQuotaMetricProtoMsg { + typeUrl: "/google.api.serviceusage.v1beta1.ConsumerQuotaMetric"; + value: Uint8Array; +} +/** Consumer quota settings for a quota metric. */ +export interface ConsumerQuotaMetricSDKType { + name: string; + metric: string; + display_name: string; + consumer_quota_limits: ConsumerQuotaLimitSDKType[]; + descendant_consumer_quota_limits: ConsumerQuotaLimitSDKType[]; + unit: string; +} +/** Consumer quota settings for a quota limit. */ +export interface ConsumerQuotaLimit { + /** + * The resource name of the quota limit. + * + * An example name would be: + * `projects/123/services/compute.googleapis.com/consumerQuotaMetrics/compute.googleapis.com%2Fcpus/limits/%2Fproject%2Fregion` + * + * The resource name is intended to be opaque and should not be parsed for + * its component strings, since its representation could change in the future. + */ + name: string; + /** + * The name of the parent metric of this limit. + * + * An example name would be: + * `compute.googleapis.com/cpus` + */ + metric: string; + /** + * The limit unit. + * + * An example unit would be + * `1/{project}/{region}` + * Note that `{project}` and `{region}` are not placeholders in this example; + * the literal characters `{` and `}` occur in the string. + */ + unit: string; + /** Whether this limit is precise or imprecise. */ + isPrecise: boolean; + /** Whether admin overrides are allowed on this limit */ + allowsAdminOverrides: boolean; + /** + * Summary of the enforced quota buckets, organized by quota dimension, + * ordered from least specific to most specific (for example, the global + * default bucket, with no quota dimensions, will always appear first). + */ + quotaBuckets: QuotaBucket[]; +} +export interface ConsumerQuotaLimitProtoMsg { + typeUrl: "/google.api.serviceusage.v1beta1.ConsumerQuotaLimit"; + value: Uint8Array; +} +/** Consumer quota settings for a quota limit. */ +export interface ConsumerQuotaLimitSDKType { + name: string; + metric: string; + unit: string; + is_precise: boolean; + allows_admin_overrides: boolean; + quota_buckets: QuotaBucketSDKType[]; +} +export interface QuotaBucket_DimensionsEntry { + key: string; + value: string; +} +export interface QuotaBucket_DimensionsEntryProtoMsg { + typeUrl: string; + value: Uint8Array; +} +export interface QuotaBucket_DimensionsEntrySDKType { + key: string; + value: string; +} +/** A quota bucket is a quota provisioning unit for a specific set of dimensions. */ +export interface QuotaBucket { + /** + * The effective limit of this quota bucket. Equal to default_limit if there + * are no overrides. + */ + effectiveLimit: bigint; + /** + * The default limit of this quota bucket, as specified by the service + * configuration. + */ + defaultLimit: bigint; + /** Producer override on this quota bucket. */ + producerOverride?: QuotaOverride; + /** Consumer override on this quota bucket. */ + consumerOverride?: QuotaOverride; + /** Admin override on this quota bucket. */ + adminOverride?: QuotaOverride; + /** + * The dimensions of this quota bucket. + * + * If this map is empty, this is the global bucket, which is the default quota + * value applied to all requests that do not have a more specific override. + * + * If this map is nonempty, the default limit, effective limit, and quota + * overrides apply only to requests that have the dimensions given in the map. + * + * For example, if the map has key `region` and value `us-east-1`, then the + * specified effective limit is only effective in that region, and the + * specified overrides apply only in that region. + */ + dimensions: { + [key: string]: string; + }; +} +export interface QuotaBucketProtoMsg { + typeUrl: "/google.api.serviceusage.v1beta1.QuotaBucket"; + value: Uint8Array; +} +/** A quota bucket is a quota provisioning unit for a specific set of dimensions. */ +export interface QuotaBucketSDKType { + effective_limit: bigint; + default_limit: bigint; + producer_override?: QuotaOverrideSDKType; + consumer_override?: QuotaOverrideSDKType; + admin_override?: QuotaOverrideSDKType; + dimensions: { + [key: string]: string; + }; +} +export interface QuotaOverride_DimensionsEntry { + key: string; + value: string; +} +export interface QuotaOverride_DimensionsEntryProtoMsg { + typeUrl: string; + value: Uint8Array; +} +export interface QuotaOverride_DimensionsEntrySDKType { + key: string; + value: string; +} +/** A quota override */ +export interface QuotaOverride { + /** + * The resource name of the override. + * This name is generated by the server when the override is created. + * + * Example names would be: + * `projects/123/services/compute.googleapis.com/consumerQuotaMetrics/compute.googleapis.com%2Fcpus/limits/%2Fproject%2Fregion/adminOverrides/4a3f2c1d` + * `projects/123/services/compute.googleapis.com/consumerQuotaMetrics/compute.googleapis.com%2Fcpus/limits/%2Fproject%2Fregion/consumerOverrides/4a3f2c1d` + * + * The resource name is intended to be opaque and should not be parsed for + * its component strings, since its representation could change in the future. + */ + name: string; + /** + * The overriding quota limit value. + * Can be any nonnegative integer, or -1 (unlimited quota). + */ + overrideValue: bigint; + /** + * If this map is nonempty, then this override applies only to specific values + * for dimensions defined in the limit unit. + * + * For example, an override on a limit with the unit `1/{project}/{region}` + * could contain an entry with the key `region` and the value `us-east-1`; + * the override is only applied to quota consumed in that region. + * + * This map has the following restrictions: + * + * * Keys that are not defined in the limit's unit are not valid keys. + * Any string appearing in `{brackets}` in the unit (besides `{project}` + * or + * `{user}`) is a defined key. + * * `project` is not a valid key; the project is already specified in + * the parent resource name. + * * `user` is not a valid key; the API does not support quota overrides + * that apply only to a specific user. + * * If `region` appears as a key, its value must be a valid Cloud region. + * * If `zone` appears as a key, its value must be a valid Cloud zone. + * * If any valid key other than `region` or `zone` appears in the map, then + * all valid keys other than `region` or `zone` must also appear in the + * map. + */ + dimensions: { + [key: string]: string; + }; + /** + * The name of the metric to which this override applies. + * + * An example name would be: + * `compute.googleapis.com/cpus` + */ + metric: string; + /** + * The limit unit of the limit to which this override applies. + * + * An example unit would be: + * `1/{project}/{region}` + * Note that `{project}` and `{region}` are not placeholders in this example; + * the literal characters `{` and `}` occur in the string. + */ + unit: string; + /** + * The resource name of the ancestor that requested the override. For example: + * `organizations/12345` or `folders/67890`. + * Used by admin overrides only. + */ + adminOverrideAncestor: string; +} +export interface QuotaOverrideProtoMsg { + typeUrl: "/google.api.serviceusage.v1beta1.QuotaOverride"; + value: Uint8Array; +} +/** A quota override */ +export interface QuotaOverrideSDKType { + name: string; + override_value: bigint; + dimensions: { + [key: string]: string; + }; + metric: string; + unit: string; + admin_override_ancestor: string; +} +/** Import data embedded in the request message */ +export interface OverrideInlineSource { + /** + * The overrides to create. + * Each override must have a value for 'metric' and 'unit', to specify + * which metric and which limit the override should be applied to. + * The 'name' field of the override does not need to be set; it is ignored. + */ + overrides: QuotaOverride[]; +} +export interface OverrideInlineSourceProtoMsg { + typeUrl: "/google.api.serviceusage.v1beta1.OverrideInlineSource"; + value: Uint8Array; +} +/** Import data embedded in the request message */ +export interface OverrideInlineSourceSDKType { + overrides: QuotaOverrideSDKType[]; +} +export interface AdminQuotaPolicy_DimensionsEntry { + key: string; + value: string; +} +export interface AdminQuotaPolicy_DimensionsEntryProtoMsg { + typeUrl: string; + value: Uint8Array; +} +export interface AdminQuotaPolicy_DimensionsEntrySDKType { + key: string; + value: string; +} +/** Quota policy created by quota administrator. */ +export interface AdminQuotaPolicy { + /** + * The resource name of the policy. + * This name is generated by the server when the policy is created. + * + * Example names would be: + * `organizations/123/services/compute.googleapis.com/consumerQuotaMetrics/compute.googleapis.com%2Fcpus/limits/%2Fproject%2Fregion/adminQuotaPolicies/4a3f2c1d` + */ + name: string; + /** + * The quota policy value. + * Can be any nonnegative integer, or -1 (unlimited quota). + */ + policyValue: bigint; + /** + * If this map is nonempty, then this policy applies only to specific values + * for dimensions defined in the limit unit. + * + * For example, an policy on a limit with the unit `1/{project}/{region}` + * could contain an entry with the key `region` and the value `us-east-1`; + * the policy is only applied to quota consumed in that region. + * + * This map has the following restrictions: + * + * * If `region` appears as a key, its value must be a valid Cloud region. + * * If `zone` appears as a key, its value must be a valid Cloud zone. + * * Keys other than `region` or `zone` are not valid. + */ + dimensions: { + [key: string]: string; + }; + /** + * The name of the metric to which this policy applies. + * + * An example name would be: + * `compute.googleapis.com/cpus` + */ + metric: string; + /** + * The limit unit of the limit to which this policy applies. + * + * An example unit would be: + * `1/{project}/{region}` + * Note that `{project}` and `{region}` are not placeholders in this example; + * the literal characters `{` and `}` occur in the string. + */ + unit: string; + /** + * The cloud resource container at which the quota policy is created. The + * format is `{container_type}/{container_number}` + */ + container: string; +} +export interface AdminQuotaPolicyProtoMsg { + typeUrl: "/google.api.serviceusage.v1beta1.AdminQuotaPolicy"; + value: Uint8Array; +} +/** Quota policy created by quota administrator. */ +export interface AdminQuotaPolicySDKType { + name: string; + policy_value: bigint; + dimensions: { + [key: string]: string; + }; + metric: string; + unit: string; + container: string; +} +/** + * Service identity for a service. This is the identity that service producer + * should use to access consumer resources. + */ +export interface ServiceIdentity { + /** + * The email address of the service account that a service producer would use + * to access consumer resources. + */ + email: string; + /** + * The unique and stable id of the service account. + * https://cloud.google.com/iam/reference/rest/v1/projects.serviceAccounts#ServiceAccount + */ + uniqueId: string; +} +export interface ServiceIdentityProtoMsg { + typeUrl: "/google.api.serviceusage.v1beta1.ServiceIdentity"; + value: Uint8Array; +} +/** + * Service identity for a service. This is the identity that service producer + * should use to access consumer resources. + */ +export interface ServiceIdentitySDKType { + email: string; + unique_id: string; +} +function createBaseService(): Service { + return { + name: "", + parent: "", + config: undefined, + state: 0 + }; +} +export const Service = { + typeUrl: "/google.api.serviceusage.v1beta1.Service", + encode(message: Service, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + if (message.parent !== undefined) { + writer.uint32(42).string(message.parent); + } + if (message.config !== undefined) { + ServiceConfig.encode(message.config, writer.uint32(18).fork()).ldelim(); + } + if (message.state !== 0) { + writer.uint32(32).int32(message.state); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Service { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseService(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 5: + message.parent = reader.string(); + break; + case 2: + message.config = ServiceConfig.decode(reader, reader.uint32()); + break; + case 4: + message.state = (reader.int32() as any); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Service { + const obj = createBaseService(); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.parent)) obj.parent = String(object.parent); + if (isSet(object.config)) obj.config = ServiceConfig.fromJSON(object.config); + if (isSet(object.state)) obj.state = stateFromJSON(object.state); + return obj; + }, + toJSON(message: Service): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.parent !== undefined && (obj.parent = message.parent); + message.config !== undefined && (obj.config = message.config ? ServiceConfig.toJSON(message.config) : undefined); + message.state !== undefined && (obj.state = stateToJSON(message.state)); + return obj; + }, + fromPartial(object: DeepPartial): Service { + const message = createBaseService(); + message.name = object.name ?? ""; + message.parent = object.parent ?? ""; + if (object.config !== undefined && object.config !== null) { + message.config = ServiceConfig.fromPartial(object.config); + } + message.state = object.state ?? 0; + return message; + }, + fromSDK(object: ServiceSDKType): Service { + return { + name: object?.name, + parent: object?.parent, + config: object.config ? ServiceConfig.fromSDK(object.config) : undefined, + state: isSet(object.state) ? stateFromJSON(object.state) : -1 + }; + }, + fromSDKJSON(object: any): ServiceSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + parent: isSet(object.parent) ? String(object.parent) : "", + config: isSet(object.config) ? ServiceConfig.fromSDKJSON(object.config) : undefined, + state: isSet(object.state) ? stateFromJSON(object.state) : -1 + }; + }, + toSDK(message: Service): ServiceSDKType { + const obj: any = {}; + obj.name = message.name; + obj.parent = message.parent; + message.config !== undefined && (obj.config = message.config ? ServiceConfig.toSDK(message.config) : undefined); + message.state !== undefined && (obj.state = stateToJSON(message.state)); + return obj; + }, + fromAmino(object: ServiceAmino): Service { + const message = createBaseService(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + if (object.parent !== undefined && object.parent !== null) { + message.parent = object.parent; + } + if (object.config !== undefined && object.config !== null) { + message.config = ServiceConfig.fromAmino(object.config); + } + if (object.state !== undefined && object.state !== null) { + message.state = object.state; + } + return message; + }, + toAmino(message: Service): ServiceAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + obj.parent = message.parent === "" ? undefined : message.parent; + obj.config = message.config ? ServiceConfig.toAmino(message.config) : undefined; + obj.state = message.state === 0 ? undefined : message.state; + return obj; + }, + fromAminoMsg(object: ServiceAminoMsg): Service { + return Service.fromAmino(object.value); + }, + fromProtoMsg(message: ServiceProtoMsg): Service { + return Service.decode(message.value); + }, + toProto(message: Service): Uint8Array { + return Service.encode(message).finish(); + }, + toProtoMsg(message: Service): ServiceProtoMsg { + return { + typeUrl: "/google.api.serviceusage.v1beta1.Service", + value: Service.encode(message).finish() + }; + } +}; +function createBaseServiceConfig(): ServiceConfig { + return { + name: "", + title: "", + apis: [], + documentation: undefined, + quota: undefined, + authentication: undefined, + usage: undefined, + endpoints: [], + monitoredResources: [], + monitoring: undefined + }; +} +export const ServiceConfig = { + typeUrl: "/google.api.serviceusage.v1beta1.ServiceConfig", + encode(message: ServiceConfig, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + if (message.title !== undefined) { + writer.uint32(18).string(message.title); + } + for (const v of message.apis) { + Api.encode(v!, writer.uint32(26).fork()).ldelim(); + } + if (message.documentation !== undefined) { + Documentation.encode(message.documentation, writer.uint32(50).fork()).ldelim(); + } + if (message.quota !== undefined) { + Quota.encode(message.quota, writer.uint32(82).fork()).ldelim(); + } + if (message.authentication !== undefined) { + Authentication.encode(message.authentication, writer.uint32(90).fork()).ldelim(); + } + if (message.usage !== undefined) { + Usage.encode(message.usage, writer.uint32(122).fork()).ldelim(); + } + for (const v of message.endpoints) { + Endpoint.encode(v!, writer.uint32(146).fork()).ldelim(); + } + for (const v of message.monitoredResources) { + MonitoredResourceDescriptor.encode(v!, writer.uint32(202).fork()).ldelim(); + } + if (message.monitoring !== undefined) { + Monitoring.encode(message.monitoring, writer.uint32(226).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ServiceConfig { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseServiceConfig(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.title = reader.string(); + break; + case 3: + message.apis.push(Api.decode(reader, reader.uint32())); + break; + case 6: + message.documentation = Documentation.decode(reader, reader.uint32()); + break; + case 10: + message.quota = Quota.decode(reader, reader.uint32()); + break; + case 11: + message.authentication = Authentication.decode(reader, reader.uint32()); + break; + case 15: + message.usage = Usage.decode(reader, reader.uint32()); + break; + case 18: + message.endpoints.push(Endpoint.decode(reader, reader.uint32())); + break; + case 25: + message.monitoredResources.push(MonitoredResourceDescriptor.decode(reader, reader.uint32())); + break; + case 28: + message.monitoring = Monitoring.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ServiceConfig { + const obj = createBaseServiceConfig(); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.title)) obj.title = String(object.title); + if (Array.isArray(object?.apis)) obj.apis = object.apis.map((e: any) => Api.fromJSON(e)); + if (isSet(object.documentation)) obj.documentation = Documentation.fromJSON(object.documentation); + if (isSet(object.quota)) obj.quota = Quota.fromJSON(object.quota); + if (isSet(object.authentication)) obj.authentication = Authentication.fromJSON(object.authentication); + if (isSet(object.usage)) obj.usage = Usage.fromJSON(object.usage); + if (Array.isArray(object?.endpoints)) obj.endpoints = object.endpoints.map((e: any) => Endpoint.fromJSON(e)); + if (Array.isArray(object?.monitoredResources)) obj.monitoredResources = object.monitoredResources.map((e: any) => MonitoredResourceDescriptor.fromJSON(e)); + if (isSet(object.monitoring)) obj.monitoring = Monitoring.fromJSON(object.monitoring); + return obj; + }, + toJSON(message: ServiceConfig): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.title !== undefined && (obj.title = message.title); + if (message.apis) { + obj.apis = message.apis.map(e => e ? Api.toJSON(e) : undefined); + } else { + obj.apis = []; + } + message.documentation !== undefined && (obj.documentation = message.documentation ? Documentation.toJSON(message.documentation) : undefined); + message.quota !== undefined && (obj.quota = message.quota ? Quota.toJSON(message.quota) : undefined); + message.authentication !== undefined && (obj.authentication = message.authentication ? Authentication.toJSON(message.authentication) : undefined); + message.usage !== undefined && (obj.usage = message.usage ? Usage.toJSON(message.usage) : undefined); + if (message.endpoints) { + obj.endpoints = message.endpoints.map(e => e ? Endpoint.toJSON(e) : undefined); + } else { + obj.endpoints = []; + } + if (message.monitoredResources) { + obj.monitoredResources = message.monitoredResources.map(e => e ? MonitoredResourceDescriptor.toJSON(e) : undefined); + } else { + obj.monitoredResources = []; + } + message.monitoring !== undefined && (obj.monitoring = message.monitoring ? Monitoring.toJSON(message.monitoring) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): ServiceConfig { + const message = createBaseServiceConfig(); + message.name = object.name ?? ""; + message.title = object.title ?? ""; + message.apis = object.apis?.map(e => Api.fromPartial(e)) || []; + if (object.documentation !== undefined && object.documentation !== null) { + message.documentation = Documentation.fromPartial(object.documentation); + } + if (object.quota !== undefined && object.quota !== null) { + message.quota = Quota.fromPartial(object.quota); + } + if (object.authentication !== undefined && object.authentication !== null) { + message.authentication = Authentication.fromPartial(object.authentication); + } + if (object.usage !== undefined && object.usage !== null) { + message.usage = Usage.fromPartial(object.usage); + } + message.endpoints = object.endpoints?.map(e => Endpoint.fromPartial(e)) || []; + message.monitoredResources = object.monitoredResources?.map(e => MonitoredResourceDescriptor.fromPartial(e)) || []; + if (object.monitoring !== undefined && object.monitoring !== null) { + message.monitoring = Monitoring.fromPartial(object.monitoring); + } + return message; + }, + fromSDK(object: ServiceConfigSDKType): ServiceConfig { + return { + name: object?.name, + title: object?.title, + apis: Array.isArray(object?.apis) ? object.apis.map((e: any) => Api.fromSDK(e)) : [], + documentation: object.documentation ? Documentation.fromSDK(object.documentation) : undefined, + quota: object.quota ? Quota.fromSDK(object.quota) : undefined, + authentication: object.authentication ? Authentication.fromSDK(object.authentication) : undefined, + usage: object.usage ? Usage.fromSDK(object.usage) : undefined, + endpoints: Array.isArray(object?.endpoints) ? object.endpoints.map((e: any) => Endpoint.fromSDK(e)) : [], + monitoredResources: Array.isArray(object?.monitored_resources) ? object.monitored_resources.map((e: any) => MonitoredResourceDescriptor.fromSDK(e)) : [], + monitoring: object.monitoring ? Monitoring.fromSDK(object.monitoring) : undefined + }; + }, + fromSDKJSON(object: any): ServiceConfigSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + title: isSet(object.title) ? String(object.title) : "", + apis: Array.isArray(object?.apis) ? object.apis.map((e: any) => Api.fromSDKJSON(e)) : [], + documentation: isSet(object.documentation) ? Documentation.fromSDKJSON(object.documentation) : undefined, + quota: isSet(object.quota) ? Quota.fromSDKJSON(object.quota) : undefined, + authentication: isSet(object.authentication) ? Authentication.fromSDKJSON(object.authentication) : undefined, + usage: isSet(object.usage) ? Usage.fromSDKJSON(object.usage) : undefined, + endpoints: Array.isArray(object?.endpoints) ? object.endpoints.map((e: any) => Endpoint.fromSDKJSON(e)) : [], + monitored_resources: Array.isArray(object?.monitored_resources) ? object.monitored_resources.map((e: any) => MonitoredResourceDescriptor.fromSDKJSON(e)) : [], + monitoring: isSet(object.monitoring) ? Monitoring.fromSDKJSON(object.monitoring) : undefined + }; + }, + toSDK(message: ServiceConfig): ServiceConfigSDKType { + const obj: any = {}; + obj.name = message.name; + obj.title = message.title; + if (message.apis) { + obj.apis = message.apis.map(e => e ? Api.toSDK(e) : undefined); + } else { + obj.apis = []; + } + message.documentation !== undefined && (obj.documentation = message.documentation ? Documentation.toSDK(message.documentation) : undefined); + message.quota !== undefined && (obj.quota = message.quota ? Quota.toSDK(message.quota) : undefined); + message.authentication !== undefined && (obj.authentication = message.authentication ? Authentication.toSDK(message.authentication) : undefined); + message.usage !== undefined && (obj.usage = message.usage ? Usage.toSDK(message.usage) : undefined); + if (message.endpoints) { + obj.endpoints = message.endpoints.map(e => e ? Endpoint.toSDK(e) : undefined); + } else { + obj.endpoints = []; + } + if (message.monitoredResources) { + obj.monitored_resources = message.monitoredResources.map(e => e ? MonitoredResourceDescriptor.toSDK(e) : undefined); + } else { + obj.monitored_resources = []; + } + message.monitoring !== undefined && (obj.monitoring = message.monitoring ? Monitoring.toSDK(message.monitoring) : undefined); + return obj; + }, + fromAmino(object: ServiceConfigAmino): ServiceConfig { + const message = createBaseServiceConfig(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + if (object.title !== undefined && object.title !== null) { + message.title = object.title; + } + message.apis = object.apis?.map(e => Api.fromAmino(e)) || []; + if (object.documentation !== undefined && object.documentation !== null) { + message.documentation = Documentation.fromAmino(object.documentation); + } + if (object.quota !== undefined && object.quota !== null) { + message.quota = Quota.fromAmino(object.quota); + } + if (object.authentication !== undefined && object.authentication !== null) { + message.authentication = Authentication.fromAmino(object.authentication); + } + if (object.usage !== undefined && object.usage !== null) { + message.usage = Usage.fromAmino(object.usage); + } + message.endpoints = object.endpoints?.map(e => Endpoint.fromAmino(e)) || []; + message.monitoredResources = object.monitored_resources?.map(e => MonitoredResourceDescriptor.fromAmino(e)) || []; + if (object.monitoring !== undefined && object.monitoring !== null) { + message.monitoring = Monitoring.fromAmino(object.monitoring); + } + return message; + }, + toAmino(message: ServiceConfig): ServiceConfigAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + obj.title = message.title === "" ? undefined : message.title; + if (message.apis) { + obj.apis = message.apis.map(e => e ? Api.toAmino(e) : undefined); + } else { + obj.apis = message.apis; + } + obj.documentation = message.documentation ? Documentation.toAmino(message.documentation) : undefined; + obj.quota = message.quota ? Quota.toAmino(message.quota) : undefined; + obj.authentication = message.authentication ? Authentication.toAmino(message.authentication) : undefined; + obj.usage = message.usage ? Usage.toAmino(message.usage) : undefined; + if (message.endpoints) { + obj.endpoints = message.endpoints.map(e => e ? Endpoint.toAmino(e) : undefined); + } else { + obj.endpoints = message.endpoints; + } + if (message.monitoredResources) { + obj.monitored_resources = message.monitoredResources.map(e => e ? MonitoredResourceDescriptor.toAmino(e) : undefined); + } else { + obj.monitored_resources = message.monitoredResources; + } + obj.monitoring = message.monitoring ? Monitoring.toAmino(message.monitoring) : undefined; + return obj; + }, + fromAminoMsg(object: ServiceConfigAminoMsg): ServiceConfig { + return ServiceConfig.fromAmino(object.value); + }, + fromProtoMsg(message: ServiceConfigProtoMsg): ServiceConfig { + return ServiceConfig.decode(message.value); + }, + toProto(message: ServiceConfig): Uint8Array { + return ServiceConfig.encode(message).finish(); + }, + toProtoMsg(message: ServiceConfig): ServiceConfigProtoMsg { + return { + typeUrl: "/google.api.serviceusage.v1beta1.ServiceConfig", + value: ServiceConfig.encode(message).finish() + }; + } +}; +function createBaseOperationMetadata(): OperationMetadata { + return { + resourceNames: [] + }; +} +export const OperationMetadata = { + typeUrl: "/google.api.serviceusage.v1beta1.OperationMetadata", + encode(message: OperationMetadata, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.resourceNames) { + writer.uint32(18).string(v!); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): OperationMetadata { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseOperationMetadata(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.resourceNames.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): OperationMetadata { + const obj = createBaseOperationMetadata(); + if (Array.isArray(object?.resourceNames)) obj.resourceNames = object.resourceNames.map((e: any) => String(e)); + return obj; + }, + toJSON(message: OperationMetadata): JsonSafe { + const obj: any = {}; + if (message.resourceNames) { + obj.resourceNames = message.resourceNames.map(e => e); + } else { + obj.resourceNames = []; + } + return obj; + }, + fromPartial(object: DeepPartial): OperationMetadata { + const message = createBaseOperationMetadata(); + message.resourceNames = object.resourceNames?.map(e => e) || []; + return message; + }, + fromSDK(object: OperationMetadataSDKType): OperationMetadata { + return { + resourceNames: Array.isArray(object?.resource_names) ? object.resource_names.map((e: any) => e) : [] + }; + }, + fromSDKJSON(object: any): OperationMetadataSDKType { + return { + resource_names: Array.isArray(object?.resource_names) ? object.resource_names.map((e: any) => String(e)) : [] + }; + }, + toSDK(message: OperationMetadata): OperationMetadataSDKType { + const obj: any = {}; + if (message.resourceNames) { + obj.resource_names = message.resourceNames.map(e => e); + } else { + obj.resource_names = []; + } + return obj; + }, + fromAmino(object: OperationMetadataAmino): OperationMetadata { + const message = createBaseOperationMetadata(); + message.resourceNames = object.resource_names?.map(e => e) || []; + return message; + }, + toAmino(message: OperationMetadata): OperationMetadataAmino { + const obj: any = {}; + if (message.resourceNames) { + obj.resource_names = message.resourceNames.map(e => e); + } else { + obj.resource_names = message.resourceNames; + } + return obj; + }, + fromAminoMsg(object: OperationMetadataAminoMsg): OperationMetadata { + return OperationMetadata.fromAmino(object.value); + }, + fromProtoMsg(message: OperationMetadataProtoMsg): OperationMetadata { + return OperationMetadata.decode(message.value); + }, + toProto(message: OperationMetadata): Uint8Array { + return OperationMetadata.encode(message).finish(); + }, + toProtoMsg(message: OperationMetadata): OperationMetadataProtoMsg { + return { + typeUrl: "/google.api.serviceusage.v1beta1.OperationMetadata", + value: OperationMetadata.encode(message).finish() + }; + } +}; +function createBaseConsumerQuotaMetric(): ConsumerQuotaMetric { + return { + name: "", + metric: "", + displayName: "", + consumerQuotaLimits: [], + descendantConsumerQuotaLimits: [], + unit: "" + }; +} +export const ConsumerQuotaMetric = { + typeUrl: "/google.api.serviceusage.v1beta1.ConsumerQuotaMetric", + encode(message: ConsumerQuotaMetric, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + if (message.metric !== undefined) { + writer.uint32(34).string(message.metric); + } + if (message.displayName !== undefined) { + writer.uint32(18).string(message.displayName); + } + for (const v of message.consumerQuotaLimits) { + ConsumerQuotaLimit.encode(v!, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.descendantConsumerQuotaLimits) { + ConsumerQuotaLimit.encode(v!, writer.uint32(50).fork()).ldelim(); + } + if (message.unit !== undefined) { + writer.uint32(42).string(message.unit); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ConsumerQuotaMetric { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseConsumerQuotaMetric(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 4: + message.metric = reader.string(); + break; + case 2: + message.displayName = reader.string(); + break; + case 3: + message.consumerQuotaLimits.push(ConsumerQuotaLimit.decode(reader, reader.uint32())); + break; + case 6: + message.descendantConsumerQuotaLimits.push(ConsumerQuotaLimit.decode(reader, reader.uint32())); + break; + case 5: + message.unit = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ConsumerQuotaMetric { + const obj = createBaseConsumerQuotaMetric(); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.metric)) obj.metric = String(object.metric); + if (isSet(object.displayName)) obj.displayName = String(object.displayName); + if (Array.isArray(object?.consumerQuotaLimits)) obj.consumerQuotaLimits = object.consumerQuotaLimits.map((e: any) => ConsumerQuotaLimit.fromJSON(e)); + if (Array.isArray(object?.descendantConsumerQuotaLimits)) obj.descendantConsumerQuotaLimits = object.descendantConsumerQuotaLimits.map((e: any) => ConsumerQuotaLimit.fromJSON(e)); + if (isSet(object.unit)) obj.unit = String(object.unit); + return obj; + }, + toJSON(message: ConsumerQuotaMetric): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.metric !== undefined && (obj.metric = message.metric); + message.displayName !== undefined && (obj.displayName = message.displayName); + if (message.consumerQuotaLimits) { + obj.consumerQuotaLimits = message.consumerQuotaLimits.map(e => e ? ConsumerQuotaLimit.toJSON(e) : undefined); + } else { + obj.consumerQuotaLimits = []; + } + if (message.descendantConsumerQuotaLimits) { + obj.descendantConsumerQuotaLimits = message.descendantConsumerQuotaLimits.map(e => e ? ConsumerQuotaLimit.toJSON(e) : undefined); + } else { + obj.descendantConsumerQuotaLimits = []; + } + message.unit !== undefined && (obj.unit = message.unit); + return obj; + }, + fromPartial(object: DeepPartial): ConsumerQuotaMetric { + const message = createBaseConsumerQuotaMetric(); + message.name = object.name ?? ""; + message.metric = object.metric ?? ""; + message.displayName = object.displayName ?? ""; + message.consumerQuotaLimits = object.consumerQuotaLimits?.map(e => ConsumerQuotaLimit.fromPartial(e)) || []; + message.descendantConsumerQuotaLimits = object.descendantConsumerQuotaLimits?.map(e => ConsumerQuotaLimit.fromPartial(e)) || []; + message.unit = object.unit ?? ""; + return message; + }, + fromSDK(object: ConsumerQuotaMetricSDKType): ConsumerQuotaMetric { + return { + name: object?.name, + metric: object?.metric, + displayName: object?.display_name, + consumerQuotaLimits: Array.isArray(object?.consumer_quota_limits) ? object.consumer_quota_limits.map((e: any) => ConsumerQuotaLimit.fromSDK(e)) : [], + descendantConsumerQuotaLimits: Array.isArray(object?.descendant_consumer_quota_limits) ? object.descendant_consumer_quota_limits.map((e: any) => ConsumerQuotaLimit.fromSDK(e)) : [], + unit: object?.unit + }; + }, + fromSDKJSON(object: any): ConsumerQuotaMetricSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + metric: isSet(object.metric) ? String(object.metric) : "", + display_name: isSet(object.display_name) ? String(object.display_name) : "", + consumer_quota_limits: Array.isArray(object?.consumer_quota_limits) ? object.consumer_quota_limits.map((e: any) => ConsumerQuotaLimit.fromSDKJSON(e)) : [], + descendant_consumer_quota_limits: Array.isArray(object?.descendant_consumer_quota_limits) ? object.descendant_consumer_quota_limits.map((e: any) => ConsumerQuotaLimit.fromSDKJSON(e)) : [], + unit: isSet(object.unit) ? String(object.unit) : "" + }; + }, + toSDK(message: ConsumerQuotaMetric): ConsumerQuotaMetricSDKType { + const obj: any = {}; + obj.name = message.name; + obj.metric = message.metric; + obj.display_name = message.displayName; + if (message.consumerQuotaLimits) { + obj.consumer_quota_limits = message.consumerQuotaLimits.map(e => e ? ConsumerQuotaLimit.toSDK(e) : undefined); + } else { + obj.consumer_quota_limits = []; + } + if (message.descendantConsumerQuotaLimits) { + obj.descendant_consumer_quota_limits = message.descendantConsumerQuotaLimits.map(e => e ? ConsumerQuotaLimit.toSDK(e) : undefined); + } else { + obj.descendant_consumer_quota_limits = []; + } + obj.unit = message.unit; + return obj; + }, + fromAmino(object: ConsumerQuotaMetricAmino): ConsumerQuotaMetric { + const message = createBaseConsumerQuotaMetric(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + if (object.metric !== undefined && object.metric !== null) { + message.metric = object.metric; + } + if (object.display_name !== undefined && object.display_name !== null) { + message.displayName = object.display_name; + } + message.consumerQuotaLimits = object.consumer_quota_limits?.map(e => ConsumerQuotaLimit.fromAmino(e)) || []; + message.descendantConsumerQuotaLimits = object.descendant_consumer_quota_limits?.map(e => ConsumerQuotaLimit.fromAmino(e)) || []; + if (object.unit !== undefined && object.unit !== null) { + message.unit = object.unit; + } + return message; + }, + toAmino(message: ConsumerQuotaMetric): ConsumerQuotaMetricAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + obj.metric = message.metric === "" ? undefined : message.metric; + obj.display_name = message.displayName === "" ? undefined : message.displayName; + if (message.consumerQuotaLimits) { + obj.consumer_quota_limits = message.consumerQuotaLimits.map(e => e ? ConsumerQuotaLimit.toAmino(e) : undefined); + } else { + obj.consumer_quota_limits = message.consumerQuotaLimits; + } + if (message.descendantConsumerQuotaLimits) { + obj.descendant_consumer_quota_limits = message.descendantConsumerQuotaLimits.map(e => e ? ConsumerQuotaLimit.toAmino(e) : undefined); + } else { + obj.descendant_consumer_quota_limits = message.descendantConsumerQuotaLimits; + } + obj.unit = message.unit === "" ? undefined : message.unit; + return obj; + }, + fromAminoMsg(object: ConsumerQuotaMetricAminoMsg): ConsumerQuotaMetric { + return ConsumerQuotaMetric.fromAmino(object.value); + }, + fromProtoMsg(message: ConsumerQuotaMetricProtoMsg): ConsumerQuotaMetric { + return ConsumerQuotaMetric.decode(message.value); + }, + toProto(message: ConsumerQuotaMetric): Uint8Array { + return ConsumerQuotaMetric.encode(message).finish(); + }, + toProtoMsg(message: ConsumerQuotaMetric): ConsumerQuotaMetricProtoMsg { + return { + typeUrl: "/google.api.serviceusage.v1beta1.ConsumerQuotaMetric", + value: ConsumerQuotaMetric.encode(message).finish() + }; + } +}; +function createBaseConsumerQuotaLimit(): ConsumerQuotaLimit { + return { + name: "", + metric: "", + unit: "", + isPrecise: false, + allowsAdminOverrides: false, + quotaBuckets: [] + }; +} +export const ConsumerQuotaLimit = { + typeUrl: "/google.api.serviceusage.v1beta1.ConsumerQuotaLimit", + encode(message: ConsumerQuotaLimit, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + if (message.metric !== undefined) { + writer.uint32(66).string(message.metric); + } + if (message.unit !== undefined) { + writer.uint32(18).string(message.unit); + } + if (message.isPrecise !== undefined) { + writer.uint32(24).bool(message.isPrecise); + } + if (message.allowsAdminOverrides !== undefined) { + writer.uint32(56).bool(message.allowsAdminOverrides); + } + for (const v of message.quotaBuckets) { + QuotaBucket.encode(v!, writer.uint32(74).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ConsumerQuotaLimit { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseConsumerQuotaLimit(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 8: + message.metric = reader.string(); + break; + case 2: + message.unit = reader.string(); + break; + case 3: + message.isPrecise = reader.bool(); + break; + case 7: + message.allowsAdminOverrides = reader.bool(); + break; + case 9: + message.quotaBuckets.push(QuotaBucket.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ConsumerQuotaLimit { + const obj = createBaseConsumerQuotaLimit(); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.metric)) obj.metric = String(object.metric); + if (isSet(object.unit)) obj.unit = String(object.unit); + if (isSet(object.isPrecise)) obj.isPrecise = Boolean(object.isPrecise); + if (isSet(object.allowsAdminOverrides)) obj.allowsAdminOverrides = Boolean(object.allowsAdminOverrides); + if (Array.isArray(object?.quotaBuckets)) obj.quotaBuckets = object.quotaBuckets.map((e: any) => QuotaBucket.fromJSON(e)); + return obj; + }, + toJSON(message: ConsumerQuotaLimit): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.metric !== undefined && (obj.metric = message.metric); + message.unit !== undefined && (obj.unit = message.unit); + message.isPrecise !== undefined && (obj.isPrecise = message.isPrecise); + message.allowsAdminOverrides !== undefined && (obj.allowsAdminOverrides = message.allowsAdminOverrides); + if (message.quotaBuckets) { + obj.quotaBuckets = message.quotaBuckets.map(e => e ? QuotaBucket.toJSON(e) : undefined); + } else { + obj.quotaBuckets = []; + } + return obj; + }, + fromPartial(object: DeepPartial): ConsumerQuotaLimit { + const message = createBaseConsumerQuotaLimit(); + message.name = object.name ?? ""; + message.metric = object.metric ?? ""; + message.unit = object.unit ?? ""; + message.isPrecise = object.isPrecise ?? false; + message.allowsAdminOverrides = object.allowsAdminOverrides ?? false; + message.quotaBuckets = object.quotaBuckets?.map(e => QuotaBucket.fromPartial(e)) || []; + return message; + }, + fromSDK(object: ConsumerQuotaLimitSDKType): ConsumerQuotaLimit { + return { + name: object?.name, + metric: object?.metric, + unit: object?.unit, + isPrecise: object?.is_precise, + allowsAdminOverrides: object?.allows_admin_overrides, + quotaBuckets: Array.isArray(object?.quota_buckets) ? object.quota_buckets.map((e: any) => QuotaBucket.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): ConsumerQuotaLimitSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + metric: isSet(object.metric) ? String(object.metric) : "", + unit: isSet(object.unit) ? String(object.unit) : "", + is_precise: isSet(object.is_precise) ? Boolean(object.is_precise) : false, + allows_admin_overrides: isSet(object.allows_admin_overrides) ? Boolean(object.allows_admin_overrides) : false, + quota_buckets: Array.isArray(object?.quota_buckets) ? object.quota_buckets.map((e: any) => QuotaBucket.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: ConsumerQuotaLimit): ConsumerQuotaLimitSDKType { + const obj: any = {}; + obj.name = message.name; + obj.metric = message.metric; + obj.unit = message.unit; + obj.is_precise = message.isPrecise; + obj.allows_admin_overrides = message.allowsAdminOverrides; + if (message.quotaBuckets) { + obj.quota_buckets = message.quotaBuckets.map(e => e ? QuotaBucket.toSDK(e) : undefined); + } else { + obj.quota_buckets = []; + } + return obj; + }, + fromAmino(object: ConsumerQuotaLimitAmino): ConsumerQuotaLimit { + const message = createBaseConsumerQuotaLimit(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + if (object.metric !== undefined && object.metric !== null) { + message.metric = object.metric; + } + if (object.unit !== undefined && object.unit !== null) { + message.unit = object.unit; + } + if (object.is_precise !== undefined && object.is_precise !== null) { + message.isPrecise = object.is_precise; + } + if (object.allows_admin_overrides !== undefined && object.allows_admin_overrides !== null) { + message.allowsAdminOverrides = object.allows_admin_overrides; + } + message.quotaBuckets = object.quota_buckets?.map(e => QuotaBucket.fromAmino(e)) || []; + return message; + }, + toAmino(message: ConsumerQuotaLimit): ConsumerQuotaLimitAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + obj.metric = message.metric === "" ? undefined : message.metric; + obj.unit = message.unit === "" ? undefined : message.unit; + obj.is_precise = message.isPrecise === false ? undefined : message.isPrecise; + obj.allows_admin_overrides = message.allowsAdminOverrides === false ? undefined : message.allowsAdminOverrides; + if (message.quotaBuckets) { + obj.quota_buckets = message.quotaBuckets.map(e => e ? QuotaBucket.toAmino(e) : undefined); + } else { + obj.quota_buckets = message.quotaBuckets; + } + return obj; + }, + fromAminoMsg(object: ConsumerQuotaLimitAminoMsg): ConsumerQuotaLimit { + return ConsumerQuotaLimit.fromAmino(object.value); + }, + fromProtoMsg(message: ConsumerQuotaLimitProtoMsg): ConsumerQuotaLimit { + return ConsumerQuotaLimit.decode(message.value); + }, + toProto(message: ConsumerQuotaLimit): Uint8Array { + return ConsumerQuotaLimit.encode(message).finish(); + }, + toProtoMsg(message: ConsumerQuotaLimit): ConsumerQuotaLimitProtoMsg { + return { + typeUrl: "/google.api.serviceusage.v1beta1.ConsumerQuotaLimit", + value: ConsumerQuotaLimit.encode(message).finish() + }; + } +}; +function createBaseQuotaBucket_DimensionsEntry(): QuotaBucket_DimensionsEntry { + return { + key: "", + value: "" + }; +} +export const QuotaBucket_DimensionsEntry = { + encode(message: QuotaBucket_DimensionsEntry, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.key !== undefined) { + writer.uint32(10).string(message.key); + } + if (message.value !== undefined) { + writer.uint32(18).string(message.value); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QuotaBucket_DimensionsEntry { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQuotaBucket_DimensionsEntry(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.string(); + break; + case 2: + message.value = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QuotaBucket_DimensionsEntry { + const obj = createBaseQuotaBucket_DimensionsEntry(); + if (isSet(object.key)) obj.key = String(object.key); + if (isSet(object.value)) obj.value = String(object.value); + return obj; + }, + toJSON(message: QuotaBucket_DimensionsEntry): JsonSafe { + const obj: any = {}; + message.key !== undefined && (obj.key = message.key); + message.value !== undefined && (obj.value = message.value); + return obj; + }, + fromPartial(object: DeepPartial): QuotaBucket_DimensionsEntry { + const message = createBaseQuotaBucket_DimensionsEntry(); + message.key = object.key ?? ""; + message.value = object.value ?? ""; + return message; + }, + fromSDK(object: QuotaBucket_DimensionsEntrySDKType): QuotaBucket_DimensionsEntry { + return { + key: object?.key, + value: object?.value + }; + }, + fromSDKJSON(object: any): QuotaBucket_DimensionsEntrySDKType { + return { + key: isSet(object.key) ? String(object.key) : "", + value: isSet(object.value) ? String(object.value) : "" + }; + }, + toSDK(message: QuotaBucket_DimensionsEntry): QuotaBucket_DimensionsEntrySDKType { + const obj: any = {}; + obj.key = message.key; + obj.value = message.value; + return obj; + }, + fromAmino(object: QuotaBucket_DimensionsEntryAmino): QuotaBucket_DimensionsEntry { + const message = createBaseQuotaBucket_DimensionsEntry(); + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } + if (object.value !== undefined && object.value !== null) { + message.value = object.value; + } + return message; + }, + toAmino(message: QuotaBucket_DimensionsEntry): QuotaBucket_DimensionsEntryAmino { + const obj: any = {}; + obj.key = message.key === "" ? undefined : message.key; + obj.value = message.value === "" ? undefined : message.value; + return obj; + }, + fromAminoMsg(object: QuotaBucket_DimensionsEntryAminoMsg): QuotaBucket_DimensionsEntry { + return QuotaBucket_DimensionsEntry.fromAmino(object.value); + }, + fromProtoMsg(message: QuotaBucket_DimensionsEntryProtoMsg): QuotaBucket_DimensionsEntry { + return QuotaBucket_DimensionsEntry.decode(message.value); + }, + toProto(message: QuotaBucket_DimensionsEntry): Uint8Array { + return QuotaBucket_DimensionsEntry.encode(message).finish(); + } +}; +function createBaseQuotaBucket(): QuotaBucket { + return { + effectiveLimit: BigInt(0), + defaultLimit: BigInt(0), + producerOverride: undefined, + consumerOverride: undefined, + adminOverride: undefined, + dimensions: {} + }; +} +export const QuotaBucket = { + typeUrl: "/google.api.serviceusage.v1beta1.QuotaBucket", + encode(message: QuotaBucket, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.effectiveLimit !== undefined) { + writer.uint32(8).int64(message.effectiveLimit); + } + if (message.defaultLimit !== undefined) { + writer.uint32(16).int64(message.defaultLimit); + } + if (message.producerOverride !== undefined) { + QuotaOverride.encode(message.producerOverride, writer.uint32(26).fork()).ldelim(); + } + if (message.consumerOverride !== undefined) { + QuotaOverride.encode(message.consumerOverride, writer.uint32(34).fork()).ldelim(); + } + if (message.adminOverride !== undefined) { + QuotaOverride.encode(message.adminOverride, writer.uint32(42).fork()).ldelim(); + } + Object.entries(message.dimensions).forEach(([key, value]) => { + QuotaBucket_DimensionsEntry.encode({ + key: (key as any), + value + }, writer.uint32(50).fork()).ldelim(); + }); + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QuotaBucket { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQuotaBucket(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.effectiveLimit = reader.int64(); + break; + case 2: + message.defaultLimit = reader.int64(); + break; + case 3: + message.producerOverride = QuotaOverride.decode(reader, reader.uint32()); + break; + case 4: + message.consumerOverride = QuotaOverride.decode(reader, reader.uint32()); + break; + case 5: + message.adminOverride = QuotaOverride.decode(reader, reader.uint32()); + break; + case 6: + const entry6 = QuotaBucket_DimensionsEntry.decode(reader, reader.uint32()); + if (entry6.value !== undefined) { + message.dimensions[entry6.key] = entry6.value; + } + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QuotaBucket { + const obj = createBaseQuotaBucket(); + if (isSet(object.effectiveLimit)) obj.effectiveLimit = BigInt(object.effectiveLimit.toString()); + if (isSet(object.defaultLimit)) obj.defaultLimit = BigInt(object.defaultLimit.toString()); + if (isSet(object.producerOverride)) obj.producerOverride = QuotaOverride.fromJSON(object.producerOverride); + if (isSet(object.consumerOverride)) obj.consumerOverride = QuotaOverride.fromJSON(object.consumerOverride); + if (isSet(object.adminOverride)) obj.adminOverride = QuotaOverride.fromJSON(object.adminOverride); + if (isObject(object.dimensions)) obj.dimensions = Object.entries(object.dimensions).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + acc[key] = String(value); + return acc; + }, {}); + return obj; + }, + toJSON(message: QuotaBucket): JsonSafe { + const obj: any = {}; + message.effectiveLimit !== undefined && (obj.effectiveLimit = (message.effectiveLimit || BigInt(0)).toString()); + message.defaultLimit !== undefined && (obj.defaultLimit = (message.defaultLimit || BigInt(0)).toString()); + message.producerOverride !== undefined && (obj.producerOverride = message.producerOverride ? QuotaOverride.toJSON(message.producerOverride) : undefined); + message.consumerOverride !== undefined && (obj.consumerOverride = message.consumerOverride ? QuotaOverride.toJSON(message.consumerOverride) : undefined); + message.adminOverride !== undefined && (obj.adminOverride = message.adminOverride ? QuotaOverride.toJSON(message.adminOverride) : undefined); + obj.dimensions = {}; + if (message.dimensions) { + Object.entries(message.dimensions).forEach(([k, v]) => { + obj.dimensions[k] = v; + }); + } + return obj; + }, + fromPartial(object: DeepPartial): QuotaBucket { + const message = createBaseQuotaBucket(); + if (object.effectiveLimit !== undefined && object.effectiveLimit !== null) { + message.effectiveLimit = BigInt(object.effectiveLimit.toString()); + } + if (object.defaultLimit !== undefined && object.defaultLimit !== null) { + message.defaultLimit = BigInt(object.defaultLimit.toString()); + } + if (object.producerOverride !== undefined && object.producerOverride !== null) { + message.producerOverride = QuotaOverride.fromPartial(object.producerOverride); + } + if (object.consumerOverride !== undefined && object.consumerOverride !== null) { + message.consumerOverride = QuotaOverride.fromPartial(object.consumerOverride); + } + if (object.adminOverride !== undefined && object.adminOverride !== null) { + message.adminOverride = QuotaOverride.fromPartial(object.adminOverride); + } + message.dimensions = Object.entries(object.dimensions ?? {}).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + if (value !== undefined) { + acc[key] = String(value); + } + return acc; + }, {}); + return message; + }, + fromSDK(object: QuotaBucketSDKType): QuotaBucket { + return { + effectiveLimit: object?.effective_limit, + defaultLimit: object?.default_limit, + producerOverride: object.producer_override ? QuotaOverride.fromSDK(object.producer_override) : undefined, + consumerOverride: object.consumer_override ? QuotaOverride.fromSDK(object.consumer_override) : undefined, + adminOverride: object.admin_override ? QuotaOverride.fromSDK(object.admin_override) : undefined, + dimensions: isObject(object.dimensions) ? Object.entries(object.dimensions).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + acc[key] = String(value); + return acc; + }, {}) : {} + }; + }, + fromSDKJSON(object: any): QuotaBucketSDKType { + return { + effective_limit: isSet(object.effective_limit) ? BigInt(object.effective_limit.toString()) : BigInt(0), + default_limit: isSet(object.default_limit) ? BigInt(object.default_limit.toString()) : BigInt(0), + producer_override: isSet(object.producer_override) ? QuotaOverride.fromSDKJSON(object.producer_override) : undefined, + consumer_override: isSet(object.consumer_override) ? QuotaOverride.fromSDKJSON(object.consumer_override) : undefined, + admin_override: isSet(object.admin_override) ? QuotaOverride.fromSDKJSON(object.admin_override) : undefined, + dimensions: isObject(object.dimensions) ? Object.entries(object.dimensions).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + acc[key] = String(value); + return acc; + }, {}) : {} + }; + }, + toSDK(message: QuotaBucket): QuotaBucketSDKType { + const obj: any = {}; + obj.effective_limit = message.effectiveLimit; + obj.default_limit = message.defaultLimit; + message.producerOverride !== undefined && (obj.producer_override = message.producerOverride ? QuotaOverride.toSDK(message.producerOverride) : undefined); + message.consumerOverride !== undefined && (obj.consumer_override = message.consumerOverride ? QuotaOverride.toSDK(message.consumerOverride) : undefined); + message.adminOverride !== undefined && (obj.admin_override = message.adminOverride ? QuotaOverride.toSDK(message.adminOverride) : undefined); + obj.dimensions = {}; + if (message.dimensions) { + Object.entries(message.dimensions).forEach(([k, v]) => { + obj.dimensions[k] = v; + }); + } + return obj; + }, + fromAmino(object: QuotaBucketAmino): QuotaBucket { + const message = createBaseQuotaBucket(); + if (object.effective_limit !== undefined && object.effective_limit !== null) { + message.effectiveLimit = BigInt(object.effective_limit); + } + if (object.default_limit !== undefined && object.default_limit !== null) { + message.defaultLimit = BigInt(object.default_limit); + } + if (object.producer_override !== undefined && object.producer_override !== null) { + message.producerOverride = QuotaOverride.fromAmino(object.producer_override); + } + if (object.consumer_override !== undefined && object.consumer_override !== null) { + message.consumerOverride = QuotaOverride.fromAmino(object.consumer_override); + } + if (object.admin_override !== undefined && object.admin_override !== null) { + message.adminOverride = QuotaOverride.fromAmino(object.admin_override); + } + message.dimensions = Object.entries(object.dimensions ?? {}).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + if (value !== undefined) { + acc[key] = String(value); + } + return acc; + }, {}); + return message; + }, + toAmino(message: QuotaBucket): QuotaBucketAmino { + const obj: any = {}; + obj.effective_limit = message.effectiveLimit !== BigInt(0) ? message.effectiveLimit?.toString() : undefined; + obj.default_limit = message.defaultLimit !== BigInt(0) ? message.defaultLimit?.toString() : undefined; + obj.producer_override = message.producerOverride ? QuotaOverride.toAmino(message.producerOverride) : undefined; + obj.consumer_override = message.consumerOverride ? QuotaOverride.toAmino(message.consumerOverride) : undefined; + obj.admin_override = message.adminOverride ? QuotaOverride.toAmino(message.adminOverride) : undefined; + obj.dimensions = {}; + if (message.dimensions) { + Object.entries(message.dimensions).forEach(([k, v]) => { + obj.dimensions[k] = v; + }); + } + return obj; + }, + fromAminoMsg(object: QuotaBucketAminoMsg): QuotaBucket { + return QuotaBucket.fromAmino(object.value); + }, + fromProtoMsg(message: QuotaBucketProtoMsg): QuotaBucket { + return QuotaBucket.decode(message.value); + }, + toProto(message: QuotaBucket): Uint8Array { + return QuotaBucket.encode(message).finish(); + }, + toProtoMsg(message: QuotaBucket): QuotaBucketProtoMsg { + return { + typeUrl: "/google.api.serviceusage.v1beta1.QuotaBucket", + value: QuotaBucket.encode(message).finish() + }; + } +}; +function createBaseQuotaOverride_DimensionsEntry(): QuotaOverride_DimensionsEntry { + return { + key: "", + value: "" + }; +} +export const QuotaOverride_DimensionsEntry = { + encode(message: QuotaOverride_DimensionsEntry, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.key !== undefined) { + writer.uint32(10).string(message.key); + } + if (message.value !== undefined) { + writer.uint32(18).string(message.value); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QuotaOverride_DimensionsEntry { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQuotaOverride_DimensionsEntry(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.string(); + break; + case 2: + message.value = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QuotaOverride_DimensionsEntry { + const obj = createBaseQuotaOverride_DimensionsEntry(); + if (isSet(object.key)) obj.key = String(object.key); + if (isSet(object.value)) obj.value = String(object.value); + return obj; + }, + toJSON(message: QuotaOverride_DimensionsEntry): JsonSafe { + const obj: any = {}; + message.key !== undefined && (obj.key = message.key); + message.value !== undefined && (obj.value = message.value); + return obj; + }, + fromPartial(object: DeepPartial): QuotaOverride_DimensionsEntry { + const message = createBaseQuotaOverride_DimensionsEntry(); + message.key = object.key ?? ""; + message.value = object.value ?? ""; + return message; + }, + fromSDK(object: QuotaOverride_DimensionsEntrySDKType): QuotaOverride_DimensionsEntry { + return { + key: object?.key, + value: object?.value + }; + }, + fromSDKJSON(object: any): QuotaOverride_DimensionsEntrySDKType { + return { + key: isSet(object.key) ? String(object.key) : "", + value: isSet(object.value) ? String(object.value) : "" + }; + }, + toSDK(message: QuotaOverride_DimensionsEntry): QuotaOverride_DimensionsEntrySDKType { + const obj: any = {}; + obj.key = message.key; + obj.value = message.value; + return obj; + }, + fromAmino(object: QuotaOverride_DimensionsEntryAmino): QuotaOverride_DimensionsEntry { + const message = createBaseQuotaOverride_DimensionsEntry(); + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } + if (object.value !== undefined && object.value !== null) { + message.value = object.value; + } + return message; + }, + toAmino(message: QuotaOverride_DimensionsEntry): QuotaOverride_DimensionsEntryAmino { + const obj: any = {}; + obj.key = message.key === "" ? undefined : message.key; + obj.value = message.value === "" ? undefined : message.value; + return obj; + }, + fromAminoMsg(object: QuotaOverride_DimensionsEntryAminoMsg): QuotaOverride_DimensionsEntry { + return QuotaOverride_DimensionsEntry.fromAmino(object.value); + }, + fromProtoMsg(message: QuotaOverride_DimensionsEntryProtoMsg): QuotaOverride_DimensionsEntry { + return QuotaOverride_DimensionsEntry.decode(message.value); + }, + toProto(message: QuotaOverride_DimensionsEntry): Uint8Array { + return QuotaOverride_DimensionsEntry.encode(message).finish(); + } +}; +function createBaseQuotaOverride(): QuotaOverride { + return { + name: "", + overrideValue: BigInt(0), + dimensions: {}, + metric: "", + unit: "", + adminOverrideAncestor: "" + }; +} +export const QuotaOverride = { + typeUrl: "/google.api.serviceusage.v1beta1.QuotaOverride", + encode(message: QuotaOverride, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + if (message.overrideValue !== undefined) { + writer.uint32(16).int64(message.overrideValue); + } + Object.entries(message.dimensions).forEach(([key, value]) => { + QuotaOverride_DimensionsEntry.encode({ + key: (key as any), + value + }, writer.uint32(26).fork()).ldelim(); + }); + if (message.metric !== undefined) { + writer.uint32(34).string(message.metric); + } + if (message.unit !== undefined) { + writer.uint32(42).string(message.unit); + } + if (message.adminOverrideAncestor !== undefined) { + writer.uint32(50).string(message.adminOverrideAncestor); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): QuotaOverride { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQuotaOverride(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.overrideValue = reader.int64(); + break; + case 3: + const entry3 = QuotaOverride_DimensionsEntry.decode(reader, reader.uint32()); + if (entry3.value !== undefined) { + message.dimensions[entry3.key] = entry3.value; + } + break; + case 4: + message.metric = reader.string(); + break; + case 5: + message.unit = reader.string(); + break; + case 6: + message.adminOverrideAncestor = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): QuotaOverride { + const obj = createBaseQuotaOverride(); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.overrideValue)) obj.overrideValue = BigInt(object.overrideValue.toString()); + if (isObject(object.dimensions)) obj.dimensions = Object.entries(object.dimensions).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + acc[key] = String(value); + return acc; + }, {}); + if (isSet(object.metric)) obj.metric = String(object.metric); + if (isSet(object.unit)) obj.unit = String(object.unit); + if (isSet(object.adminOverrideAncestor)) obj.adminOverrideAncestor = String(object.adminOverrideAncestor); + return obj; + }, + toJSON(message: QuotaOverride): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.overrideValue !== undefined && (obj.overrideValue = (message.overrideValue || BigInt(0)).toString()); + obj.dimensions = {}; + if (message.dimensions) { + Object.entries(message.dimensions).forEach(([k, v]) => { + obj.dimensions[k] = v; + }); + } + message.metric !== undefined && (obj.metric = message.metric); + message.unit !== undefined && (obj.unit = message.unit); + message.adminOverrideAncestor !== undefined && (obj.adminOverrideAncestor = message.adminOverrideAncestor); + return obj; + }, + fromPartial(object: DeepPartial): QuotaOverride { + const message = createBaseQuotaOverride(); + message.name = object.name ?? ""; + if (object.overrideValue !== undefined && object.overrideValue !== null) { + message.overrideValue = BigInt(object.overrideValue.toString()); + } + message.dimensions = Object.entries(object.dimensions ?? {}).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + if (value !== undefined) { + acc[key] = String(value); + } + return acc; + }, {}); + message.metric = object.metric ?? ""; + message.unit = object.unit ?? ""; + message.adminOverrideAncestor = object.adminOverrideAncestor ?? ""; + return message; + }, + fromSDK(object: QuotaOverrideSDKType): QuotaOverride { + return { + name: object?.name, + overrideValue: object?.override_value, + dimensions: isObject(object.dimensions) ? Object.entries(object.dimensions).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + acc[key] = String(value); + return acc; + }, {}) : {}, + metric: object?.metric, + unit: object?.unit, + adminOverrideAncestor: object?.admin_override_ancestor + }; + }, + fromSDKJSON(object: any): QuotaOverrideSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + override_value: isSet(object.override_value) ? BigInt(object.override_value.toString()) : BigInt(0), + dimensions: isObject(object.dimensions) ? Object.entries(object.dimensions).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + acc[key] = String(value); + return acc; + }, {}) : {}, + metric: isSet(object.metric) ? String(object.metric) : "", + unit: isSet(object.unit) ? String(object.unit) : "", + admin_override_ancestor: isSet(object.admin_override_ancestor) ? String(object.admin_override_ancestor) : "" + }; + }, + toSDK(message: QuotaOverride): QuotaOverrideSDKType { + const obj: any = {}; + obj.name = message.name; + obj.override_value = message.overrideValue; + obj.dimensions = {}; + if (message.dimensions) { + Object.entries(message.dimensions).forEach(([k, v]) => { + obj.dimensions[k] = v; + }); + } + obj.metric = message.metric; + obj.unit = message.unit; + obj.admin_override_ancestor = message.adminOverrideAncestor; + return obj; + }, + fromAmino(object: QuotaOverrideAmino): QuotaOverride { + const message = createBaseQuotaOverride(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + if (object.override_value !== undefined && object.override_value !== null) { + message.overrideValue = BigInt(object.override_value); + } + message.dimensions = Object.entries(object.dimensions ?? {}).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + if (value !== undefined) { + acc[key] = String(value); + } + return acc; + }, {}); + if (object.metric !== undefined && object.metric !== null) { + message.metric = object.metric; + } + if (object.unit !== undefined && object.unit !== null) { + message.unit = object.unit; + } + if (object.admin_override_ancestor !== undefined && object.admin_override_ancestor !== null) { + message.adminOverrideAncestor = object.admin_override_ancestor; + } + return message; + }, + toAmino(message: QuotaOverride): QuotaOverrideAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + obj.override_value = message.overrideValue !== BigInt(0) ? message.overrideValue?.toString() : undefined; + obj.dimensions = {}; + if (message.dimensions) { + Object.entries(message.dimensions).forEach(([k, v]) => { + obj.dimensions[k] = v; + }); + } + obj.metric = message.metric === "" ? undefined : message.metric; + obj.unit = message.unit === "" ? undefined : message.unit; + obj.admin_override_ancestor = message.adminOverrideAncestor === "" ? undefined : message.adminOverrideAncestor; + return obj; + }, + fromAminoMsg(object: QuotaOverrideAminoMsg): QuotaOverride { + return QuotaOverride.fromAmino(object.value); + }, + fromProtoMsg(message: QuotaOverrideProtoMsg): QuotaOverride { + return QuotaOverride.decode(message.value); + }, + toProto(message: QuotaOverride): Uint8Array { + return QuotaOverride.encode(message).finish(); + }, + toProtoMsg(message: QuotaOverride): QuotaOverrideProtoMsg { + return { + typeUrl: "/google.api.serviceusage.v1beta1.QuotaOverride", + value: QuotaOverride.encode(message).finish() + }; + } +}; +function createBaseOverrideInlineSource(): OverrideInlineSource { + return { + overrides: [] + }; +} +export const OverrideInlineSource = { + typeUrl: "/google.api.serviceusage.v1beta1.OverrideInlineSource", + encode(message: OverrideInlineSource, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.overrides) { + QuotaOverride.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): OverrideInlineSource { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseOverrideInlineSource(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.overrides.push(QuotaOverride.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): OverrideInlineSource { + const obj = createBaseOverrideInlineSource(); + if (Array.isArray(object?.overrides)) obj.overrides = object.overrides.map((e: any) => QuotaOverride.fromJSON(e)); + return obj; + }, + toJSON(message: OverrideInlineSource): JsonSafe { + const obj: any = {}; + if (message.overrides) { + obj.overrides = message.overrides.map(e => e ? QuotaOverride.toJSON(e) : undefined); + } else { + obj.overrides = []; + } + return obj; + }, + fromPartial(object: DeepPartial): OverrideInlineSource { + const message = createBaseOverrideInlineSource(); + message.overrides = object.overrides?.map(e => QuotaOverride.fromPartial(e)) || []; + return message; + }, + fromSDK(object: OverrideInlineSourceSDKType): OverrideInlineSource { + return { + overrides: Array.isArray(object?.overrides) ? object.overrides.map((e: any) => QuotaOverride.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): OverrideInlineSourceSDKType { + return { + overrides: Array.isArray(object?.overrides) ? object.overrides.map((e: any) => QuotaOverride.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: OverrideInlineSource): OverrideInlineSourceSDKType { + const obj: any = {}; + if (message.overrides) { + obj.overrides = message.overrides.map(e => e ? QuotaOverride.toSDK(e) : undefined); + } else { + obj.overrides = []; + } + return obj; + }, + fromAmino(object: OverrideInlineSourceAmino): OverrideInlineSource { + const message = createBaseOverrideInlineSource(); + message.overrides = object.overrides?.map(e => QuotaOverride.fromAmino(e)) || []; + return message; + }, + toAmino(message: OverrideInlineSource): OverrideInlineSourceAmino { + const obj: any = {}; + if (message.overrides) { + obj.overrides = message.overrides.map(e => e ? QuotaOverride.toAmino(e) : undefined); + } else { + obj.overrides = message.overrides; + } + return obj; + }, + fromAminoMsg(object: OverrideInlineSourceAminoMsg): OverrideInlineSource { + return OverrideInlineSource.fromAmino(object.value); + }, + fromProtoMsg(message: OverrideInlineSourceProtoMsg): OverrideInlineSource { + return OverrideInlineSource.decode(message.value); + }, + toProto(message: OverrideInlineSource): Uint8Array { + return OverrideInlineSource.encode(message).finish(); + }, + toProtoMsg(message: OverrideInlineSource): OverrideInlineSourceProtoMsg { + return { + typeUrl: "/google.api.serviceusage.v1beta1.OverrideInlineSource", + value: OverrideInlineSource.encode(message).finish() + }; + } +}; +function createBaseAdminQuotaPolicy_DimensionsEntry(): AdminQuotaPolicy_DimensionsEntry { + return { + key: "", + value: "" + }; +} +export const AdminQuotaPolicy_DimensionsEntry = { + encode(message: AdminQuotaPolicy_DimensionsEntry, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.key !== undefined) { + writer.uint32(10).string(message.key); + } + if (message.value !== undefined) { + writer.uint32(18).string(message.value); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): AdminQuotaPolicy_DimensionsEntry { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseAdminQuotaPolicy_DimensionsEntry(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.string(); + break; + case 2: + message.value = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): AdminQuotaPolicy_DimensionsEntry { + const obj = createBaseAdminQuotaPolicy_DimensionsEntry(); + if (isSet(object.key)) obj.key = String(object.key); + if (isSet(object.value)) obj.value = String(object.value); + return obj; + }, + toJSON(message: AdminQuotaPolicy_DimensionsEntry): JsonSafe { + const obj: any = {}; + message.key !== undefined && (obj.key = message.key); + message.value !== undefined && (obj.value = message.value); + return obj; + }, + fromPartial(object: DeepPartial): AdminQuotaPolicy_DimensionsEntry { + const message = createBaseAdminQuotaPolicy_DimensionsEntry(); + message.key = object.key ?? ""; + message.value = object.value ?? ""; + return message; + }, + fromSDK(object: AdminQuotaPolicy_DimensionsEntrySDKType): AdminQuotaPolicy_DimensionsEntry { + return { + key: object?.key, + value: object?.value + }; + }, + fromSDKJSON(object: any): AdminQuotaPolicy_DimensionsEntrySDKType { + return { + key: isSet(object.key) ? String(object.key) : "", + value: isSet(object.value) ? String(object.value) : "" + }; + }, + toSDK(message: AdminQuotaPolicy_DimensionsEntry): AdminQuotaPolicy_DimensionsEntrySDKType { + const obj: any = {}; + obj.key = message.key; + obj.value = message.value; + return obj; + }, + fromAmino(object: AdminQuotaPolicy_DimensionsEntryAmino): AdminQuotaPolicy_DimensionsEntry { + const message = createBaseAdminQuotaPolicy_DimensionsEntry(); + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } + if (object.value !== undefined && object.value !== null) { + message.value = object.value; + } + return message; + }, + toAmino(message: AdminQuotaPolicy_DimensionsEntry): AdminQuotaPolicy_DimensionsEntryAmino { + const obj: any = {}; + obj.key = message.key === "" ? undefined : message.key; + obj.value = message.value === "" ? undefined : message.value; + return obj; + }, + fromAminoMsg(object: AdminQuotaPolicy_DimensionsEntryAminoMsg): AdminQuotaPolicy_DimensionsEntry { + return AdminQuotaPolicy_DimensionsEntry.fromAmino(object.value); + }, + fromProtoMsg(message: AdminQuotaPolicy_DimensionsEntryProtoMsg): AdminQuotaPolicy_DimensionsEntry { + return AdminQuotaPolicy_DimensionsEntry.decode(message.value); + }, + toProto(message: AdminQuotaPolicy_DimensionsEntry): Uint8Array { + return AdminQuotaPolicy_DimensionsEntry.encode(message).finish(); + } +}; +function createBaseAdminQuotaPolicy(): AdminQuotaPolicy { + return { + name: "", + policyValue: BigInt(0), + dimensions: {}, + metric: "", + unit: "", + container: "" + }; +} +export const AdminQuotaPolicy = { + typeUrl: "/google.api.serviceusage.v1beta1.AdminQuotaPolicy", + encode(message: AdminQuotaPolicy, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + if (message.policyValue !== undefined) { + writer.uint32(16).int64(message.policyValue); + } + Object.entries(message.dimensions).forEach(([key, value]) => { + AdminQuotaPolicy_DimensionsEntry.encode({ + key: (key as any), + value + }, writer.uint32(26).fork()).ldelim(); + }); + if (message.metric !== undefined) { + writer.uint32(34).string(message.metric); + } + if (message.unit !== undefined) { + writer.uint32(42).string(message.unit); + } + if (message.container !== undefined) { + writer.uint32(50).string(message.container); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): AdminQuotaPolicy { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseAdminQuotaPolicy(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.policyValue = reader.int64(); + break; + case 3: + const entry3 = AdminQuotaPolicy_DimensionsEntry.decode(reader, reader.uint32()); + if (entry3.value !== undefined) { + message.dimensions[entry3.key] = entry3.value; + } + break; + case 4: + message.metric = reader.string(); + break; + case 5: + message.unit = reader.string(); + break; + case 6: + message.container = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): AdminQuotaPolicy { + const obj = createBaseAdminQuotaPolicy(); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.policyValue)) obj.policyValue = BigInt(object.policyValue.toString()); + if (isObject(object.dimensions)) obj.dimensions = Object.entries(object.dimensions).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + acc[key] = String(value); + return acc; + }, {}); + if (isSet(object.metric)) obj.metric = String(object.metric); + if (isSet(object.unit)) obj.unit = String(object.unit); + if (isSet(object.container)) obj.container = String(object.container); + return obj; + }, + toJSON(message: AdminQuotaPolicy): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.policyValue !== undefined && (obj.policyValue = (message.policyValue || BigInt(0)).toString()); + obj.dimensions = {}; + if (message.dimensions) { + Object.entries(message.dimensions).forEach(([k, v]) => { + obj.dimensions[k] = v; + }); + } + message.metric !== undefined && (obj.metric = message.metric); + message.unit !== undefined && (obj.unit = message.unit); + message.container !== undefined && (obj.container = message.container); + return obj; + }, + fromPartial(object: DeepPartial): AdminQuotaPolicy { + const message = createBaseAdminQuotaPolicy(); + message.name = object.name ?? ""; + if (object.policyValue !== undefined && object.policyValue !== null) { + message.policyValue = BigInt(object.policyValue.toString()); + } + message.dimensions = Object.entries(object.dimensions ?? {}).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + if (value !== undefined) { + acc[key] = String(value); + } + return acc; + }, {}); + message.metric = object.metric ?? ""; + message.unit = object.unit ?? ""; + message.container = object.container ?? ""; + return message; + }, + fromSDK(object: AdminQuotaPolicySDKType): AdminQuotaPolicy { + return { + name: object?.name, + policyValue: object?.policy_value, + dimensions: isObject(object.dimensions) ? Object.entries(object.dimensions).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + acc[key] = String(value); + return acc; + }, {}) : {}, + metric: object?.metric, + unit: object?.unit, + container: object?.container + }; + }, + fromSDKJSON(object: any): AdminQuotaPolicySDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + policy_value: isSet(object.policy_value) ? BigInt(object.policy_value.toString()) : BigInt(0), + dimensions: isObject(object.dimensions) ? Object.entries(object.dimensions).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + acc[key] = String(value); + return acc; + }, {}) : {}, + metric: isSet(object.metric) ? String(object.metric) : "", + unit: isSet(object.unit) ? String(object.unit) : "", + container: isSet(object.container) ? String(object.container) : "" + }; + }, + toSDK(message: AdminQuotaPolicy): AdminQuotaPolicySDKType { + const obj: any = {}; + obj.name = message.name; + obj.policy_value = message.policyValue; + obj.dimensions = {}; + if (message.dimensions) { + Object.entries(message.dimensions).forEach(([k, v]) => { + obj.dimensions[k] = v; + }); + } + obj.metric = message.metric; + obj.unit = message.unit; + obj.container = message.container; + return obj; + }, + fromAmino(object: AdminQuotaPolicyAmino): AdminQuotaPolicy { + const message = createBaseAdminQuotaPolicy(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + if (object.policy_value !== undefined && object.policy_value !== null) { + message.policyValue = BigInt(object.policy_value); + } + message.dimensions = Object.entries(object.dimensions ?? {}).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + if (value !== undefined) { + acc[key] = String(value); + } + return acc; + }, {}); + if (object.metric !== undefined && object.metric !== null) { + message.metric = object.metric; + } + if (object.unit !== undefined && object.unit !== null) { + message.unit = object.unit; + } + if (object.container !== undefined && object.container !== null) { + message.container = object.container; + } + return message; + }, + toAmino(message: AdminQuotaPolicy): AdminQuotaPolicyAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + obj.policy_value = message.policyValue !== BigInt(0) ? message.policyValue?.toString() : undefined; + obj.dimensions = {}; + if (message.dimensions) { + Object.entries(message.dimensions).forEach(([k, v]) => { + obj.dimensions[k] = v; + }); + } + obj.metric = message.metric === "" ? undefined : message.metric; + obj.unit = message.unit === "" ? undefined : message.unit; + obj.container = message.container === "" ? undefined : message.container; + return obj; + }, + fromAminoMsg(object: AdminQuotaPolicyAminoMsg): AdminQuotaPolicy { + return AdminQuotaPolicy.fromAmino(object.value); + }, + fromProtoMsg(message: AdminQuotaPolicyProtoMsg): AdminQuotaPolicy { + return AdminQuotaPolicy.decode(message.value); + }, + toProto(message: AdminQuotaPolicy): Uint8Array { + return AdminQuotaPolicy.encode(message).finish(); + }, + toProtoMsg(message: AdminQuotaPolicy): AdminQuotaPolicyProtoMsg { + return { + typeUrl: "/google.api.serviceusage.v1beta1.AdminQuotaPolicy", + value: AdminQuotaPolicy.encode(message).finish() + }; + } +}; +function createBaseServiceIdentity(): ServiceIdentity { + return { + email: "", + uniqueId: "" + }; +} +export const ServiceIdentity = { + typeUrl: "/google.api.serviceusage.v1beta1.ServiceIdentity", + encode(message: ServiceIdentity, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.email !== undefined) { + writer.uint32(10).string(message.email); + } + if (message.uniqueId !== undefined) { + writer.uint32(18).string(message.uniqueId); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ServiceIdentity { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseServiceIdentity(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.email = reader.string(); + break; + case 2: + message.uniqueId = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ServiceIdentity { + const obj = createBaseServiceIdentity(); + if (isSet(object.email)) obj.email = String(object.email); + if (isSet(object.uniqueId)) obj.uniqueId = String(object.uniqueId); + return obj; + }, + toJSON(message: ServiceIdentity): JsonSafe { + const obj: any = {}; + message.email !== undefined && (obj.email = message.email); + message.uniqueId !== undefined && (obj.uniqueId = message.uniqueId); + return obj; + }, + fromPartial(object: DeepPartial): ServiceIdentity { + const message = createBaseServiceIdentity(); + message.email = object.email ?? ""; + message.uniqueId = object.uniqueId ?? ""; + return message; + }, + fromSDK(object: ServiceIdentitySDKType): ServiceIdentity { + return { + email: object?.email, + uniqueId: object?.unique_id + }; + }, + fromSDKJSON(object: any): ServiceIdentitySDKType { + return { + email: isSet(object.email) ? String(object.email) : "", + unique_id: isSet(object.unique_id) ? String(object.unique_id) : "" + }; + }, + toSDK(message: ServiceIdentity): ServiceIdentitySDKType { + const obj: any = {}; + obj.email = message.email; + obj.unique_id = message.uniqueId; + return obj; + }, + fromAmino(object: ServiceIdentityAmino): ServiceIdentity { + const message = createBaseServiceIdentity(); + if (object.email !== undefined && object.email !== null) { + message.email = object.email; + } + if (object.unique_id !== undefined && object.unique_id !== null) { + message.uniqueId = object.unique_id; + } + return message; + }, + toAmino(message: ServiceIdentity): ServiceIdentityAmino { + const obj: any = {}; + obj.email = message.email === "" ? undefined : message.email; + obj.unique_id = message.uniqueId === "" ? undefined : message.uniqueId; + return obj; + }, + fromAminoMsg(object: ServiceIdentityAminoMsg): ServiceIdentity { + return ServiceIdentity.fromAmino(object.value); + }, + fromProtoMsg(message: ServiceIdentityProtoMsg): ServiceIdentity { + return ServiceIdentity.decode(message.value); + }, + toProto(message: ServiceIdentity): Uint8Array { + return ServiceIdentity.encode(message).finish(); + }, + toProtoMsg(message: ServiceIdentity): ServiceIdentityProtoMsg { + return { + typeUrl: "/google.api.serviceusage.v1beta1.ServiceIdentity", + value: ServiceIdentity.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/api/serviceusage/v1beta1/serviceusage.ts b/__fixtures__/v-next/outputicjsdeps/google/api/serviceusage/v1beta1/serviceusage.ts new file mode 100644 index 0000000000..6003cb233d --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/api/serviceusage/v1beta1/serviceusage.ts @@ -0,0 +1,4915 @@ +import { QuotaView, QuotaViewSDKType, QuotaOverride, QuotaOverrideSDKType, QuotaSafetyCheck, QuotaSafetyCheckSDKType, OverrideInlineSource, OverrideInlineSourceSDKType, Service, ServiceSDKType, ConsumerQuotaMetric, ConsumerQuotaMetricSDKType, AdminQuotaPolicy, AdminQuotaPolicySDKType, ServiceIdentity, ServiceIdentitySDKType, quotaViewFromJSON, quotaViewToJSON, quotaSafetyCheckFromJSON, quotaSafetyCheckToJSON } from "./resources.js"; +import { FieldMask, FieldMaskSDKType } from "../../../protobuf/field_mask.js"; +import { BinaryReader, BinaryWriter } from "../../../../binary.js"; +import { isSet, DeepPartial } from "../../../../helpers.js"; +import { JsonSafe } from "../../../../json-safe.js"; +export const protobufPackage = "google.api.serviceusage.v1beta1"; +/** Enum for service identity state. */ +export enum GetServiceIdentityResponse_IdentityState { + /** + * IDENTITY_STATE_UNSPECIFIED - Default service identity state. This value is used if the state is + * omitted. + */ + IDENTITY_STATE_UNSPECIFIED = 0, + /** ACTIVE - Service identity has been created and can be used. */ + ACTIVE = 1, + UNRECOGNIZED = -1, +} +export const GetServiceIdentityResponse_IdentityStateSDKType = GetServiceIdentityResponse_IdentityState; +export function getServiceIdentityResponse_IdentityStateFromJSON(object: any): GetServiceIdentityResponse_IdentityState { + switch (object) { + case 0: + case "IDENTITY_STATE_UNSPECIFIED": + return GetServiceIdentityResponse_IdentityState.IDENTITY_STATE_UNSPECIFIED; + case 1: + case "ACTIVE": + return GetServiceIdentityResponse_IdentityState.ACTIVE; + case -1: + case "UNRECOGNIZED": + default: + return GetServiceIdentityResponse_IdentityState.UNRECOGNIZED; + } +} +export function getServiceIdentityResponse_IdentityStateToJSON(object: GetServiceIdentityResponse_IdentityState): string { + switch (object) { + case GetServiceIdentityResponse_IdentityState.IDENTITY_STATE_UNSPECIFIED: + return "IDENTITY_STATE_UNSPECIFIED"; + case GetServiceIdentityResponse_IdentityState.ACTIVE: + return "ACTIVE"; + case GetServiceIdentityResponse_IdentityState.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** Request message for the `EnableService` method. */ +export interface EnableServiceRequest { + /** + * Name of the consumer and service to enable the service on. + * + * The `EnableService` and `DisableService` methods currently only support + * projects. + * + * Enabling a service requires that the service is public or is shared with + * the user enabling the service. + * + * An example name would be: + * `projects/123/services/serviceusage.googleapis.com` + * where `123` is the project number (not project ID). + */ + name: string; +} +export interface EnableServiceRequestProtoMsg { + typeUrl: "/google.api.serviceusage.v1beta1.EnableServiceRequest"; + value: Uint8Array; +} +/** Request message for the `EnableService` method. */ +export interface EnableServiceRequestSDKType { + name: string; +} +/** Request message for the `DisableService` method. */ +export interface DisableServiceRequest { + /** + * Name of the consumer and service to disable the service on. + * + * The enable and disable methods currently only support projects. + * + * An example name would be: + * `projects/123/services/serviceusage.googleapis.com` + * where `123` is the project number (not project ID). + */ + name: string; +} +export interface DisableServiceRequestProtoMsg { + typeUrl: "/google.api.serviceusage.v1beta1.DisableServiceRequest"; + value: Uint8Array; +} +/** Request message for the `DisableService` method. */ +export interface DisableServiceRequestSDKType { + name: string; +} +/** Request message for the `GetService` method. */ +export interface GetServiceRequest { + /** + * Name of the consumer and service to get the `ConsumerState` for. + * + * An example name would be: + * `projects/123/services/serviceusage.googleapis.com` + * where `123` is the project number (not project ID). + */ + name: string; +} +export interface GetServiceRequestProtoMsg { + typeUrl: "/google.api.serviceusage.v1beta1.GetServiceRequest"; + value: Uint8Array; +} +/** Request message for the `GetService` method. */ +export interface GetServiceRequestSDKType { + name: string; +} +/** Request message for the `ListServices` method. */ +export interface ListServicesRequest { + /** + * Parent to search for services on. + * + * An example name would be: + * `projects/123` + * where `123` is the project number (not project ID). + */ + parent: string; + /** + * Requested size of the next page of data. + * Requested page size cannot exceed 200. + * If not set, the default page size is 50. + */ + pageSize: number; + /** + * Token identifying which result to start with, which is returned by a + * previous list call. + */ + pageToken: string; + /** + * Only list services that conform to the given filter. + * The allowed filter strings are `state:ENABLED` and `state:DISABLED`. + */ + filter: string; +} +export interface ListServicesRequestProtoMsg { + typeUrl: "/google.api.serviceusage.v1beta1.ListServicesRequest"; + value: Uint8Array; +} +/** Request message for the `ListServices` method. */ +export interface ListServicesRequestSDKType { + parent: string; + page_size: number; + page_token: string; + filter: string; +} +/** Response message for the `ListServices` method. */ +export interface ListServicesResponse { + /** The available services for the requested project. */ + services: Service[]; + /** + * Token that can be passed to `ListServices` to resume a paginated + * query. + */ + nextPageToken: string; +} +export interface ListServicesResponseProtoMsg { + typeUrl: "/google.api.serviceusage.v1beta1.ListServicesResponse"; + value: Uint8Array; +} +/** Response message for the `ListServices` method. */ +export interface ListServicesResponseSDKType { + services: ServiceSDKType[]; + next_page_token: string; +} +/** Request message for the `BatchEnableServices` method. */ +export interface BatchEnableServicesRequest { + /** + * Parent to enable services on. + * + * An example name would be: + * `projects/123` + * where `123` is the project number (not project ID). + * + * The `BatchEnableServices` method currently only supports projects. + */ + parent: string; + /** + * The identifiers of the services to enable on the project. + * + * A valid identifier would be: + * serviceusage.googleapis.com + * + * Enabling services requires that each service is public or is shared with + * the user enabling the service. + * + * Two or more services must be specified. To enable a single service, + * use the `EnableService` method instead. + * + * A single request can enable a maximum of 20 services at a time. If more + * than 20 services are specified, the request will fail, and no state changes + * will occur. + */ + serviceIds: string[]; +} +export interface BatchEnableServicesRequestProtoMsg { + typeUrl: "/google.api.serviceusage.v1beta1.BatchEnableServicesRequest"; + value: Uint8Array; +} +/** Request message for the `BatchEnableServices` method. */ +export interface BatchEnableServicesRequestSDKType { + parent: string; + service_ids: string[]; +} +/** Request message for ListConsumerQuotaMetrics */ +export interface ListConsumerQuotaMetricsRequest { + /** + * Parent of the quotas resource. + * + * Some example names would be: + * `projects/123/services/serviceconsumermanagement.googleapis.com` + * `folders/345/services/serviceconsumermanagement.googleapis.com` + * `organizations/456/services/serviceconsumermanagement.googleapis.com` + */ + parent: string; + /** Requested size of the next page of data. */ + pageSize: number; + /** + * Token identifying which result to start with; returned by a previous list + * call. + */ + pageToken: string; + /** Specifies the level of detail for quota information in the response. */ + view: QuotaView; +} +export interface ListConsumerQuotaMetricsRequestProtoMsg { + typeUrl: "/google.api.serviceusage.v1beta1.ListConsumerQuotaMetricsRequest"; + value: Uint8Array; +} +/** Request message for ListConsumerQuotaMetrics */ +export interface ListConsumerQuotaMetricsRequestSDKType { + parent: string; + page_size: number; + page_token: string; + view: QuotaView; +} +/** Response message for ListConsumerQuotaMetrics */ +export interface ListConsumerQuotaMetricsResponse { + /** Quota settings for the consumer, organized by quota metric. */ + metrics: ConsumerQuotaMetric[]; + /** + * Token identifying which result to start with; returned by a previous list + * call. + */ + nextPageToken: string; +} +export interface ListConsumerQuotaMetricsResponseProtoMsg { + typeUrl: "/google.api.serviceusage.v1beta1.ListConsumerQuotaMetricsResponse"; + value: Uint8Array; +} +/** Response message for ListConsumerQuotaMetrics */ +export interface ListConsumerQuotaMetricsResponseSDKType { + metrics: ConsumerQuotaMetricSDKType[]; + next_page_token: string; +} +/** Request message for GetConsumerQuotaMetric */ +export interface GetConsumerQuotaMetricRequest { + /** + * The resource name of the quota limit. + * + * An example name would be: + * `projects/123/services/serviceusage.googleapis.com/quotas/metrics/serviceusage.googleapis.com%2Fmutate_requests` + */ + name: string; + /** Specifies the level of detail for quota information in the response. */ + view: QuotaView; +} +export interface GetConsumerQuotaMetricRequestProtoMsg { + typeUrl: "/google.api.serviceusage.v1beta1.GetConsumerQuotaMetricRequest"; + value: Uint8Array; +} +/** Request message for GetConsumerQuotaMetric */ +export interface GetConsumerQuotaMetricRequestSDKType { + name: string; + view: QuotaView; +} +/** Request message for GetConsumerQuotaLimit */ +export interface GetConsumerQuotaLimitRequest { + /** + * The resource name of the quota limit. + * + * Use the quota limit resource name returned by previous + * ListConsumerQuotaMetrics and GetConsumerQuotaMetric API calls. + */ + name: string; + /** Specifies the level of detail for quota information in the response. */ + view: QuotaView; +} +export interface GetConsumerQuotaLimitRequestProtoMsg { + typeUrl: "/google.api.serviceusage.v1beta1.GetConsumerQuotaLimitRequest"; + value: Uint8Array; +} +/** Request message for GetConsumerQuotaLimit */ +export interface GetConsumerQuotaLimitRequestSDKType { + name: string; + view: QuotaView; +} +/** Request message for CreateAdminOverride. */ +export interface CreateAdminOverrideRequest { + /** + * The resource name of the parent quota limit, returned by a + * ListConsumerQuotaMetrics or GetConsumerQuotaMetric call. + * + * An example name would be: + * `projects/123/services/compute.googleapis.com/consumerQuotaMetrics/compute.googleapis.com%2Fcpus/limits/%2Fproject%2Fregion` + */ + parent: string; + /** The admin override to create. */ + override?: QuotaOverride; + /** + * Whether to force the creation of the quota override. + * Setting the force parameter to 'true' ignores all quota safety checks that + * would fail the request. QuotaSafetyCheck lists all such validations. + */ + force: boolean; + /** + * The list of quota safety checks to ignore before the override mutation. + * Unlike 'force' field that ignores all the quota safety checks, the + * 'force_only' field ignores only the specified checks; other checks are + * still enforced. The 'force' and 'force_only' fields cannot both be set. + */ + forceOnly: QuotaSafetyCheck[]; +} +export interface CreateAdminOverrideRequestProtoMsg { + typeUrl: "/google.api.serviceusage.v1beta1.CreateAdminOverrideRequest"; + value: Uint8Array; +} +/** Request message for CreateAdminOverride. */ +export interface CreateAdminOverrideRequestSDKType { + parent: string; + override?: QuotaOverrideSDKType; + force: boolean; + force_only: QuotaSafetyCheck[]; +} +/** Request message for UpdateAdminOverride. */ +export interface UpdateAdminOverrideRequest { + /** + * The resource name of the override to update. + * + * An example name would be: + * `projects/123/services/compute.googleapis.com/consumerQuotaMetrics/compute.googleapis.com%2Fcpus/limits/%2Fproject%2Fregion/adminOverrides/4a3f2c1d` + */ + name: string; + /** + * The new override. + * Only the override_value is updated; all other fields are ignored. + */ + override?: QuotaOverride; + /** + * Whether to force the update of the quota override. + * Setting the force parameter to 'true' ignores all quota safety checks that + * would fail the request. QuotaSafetyCheck lists all such validations. + */ + force: boolean; + /** + * Update only the specified fields of the override. + * If unset, all fields will be updated. + */ + updateMask?: FieldMask; + /** + * The list of quota safety checks to ignore before the override mutation. + * Unlike 'force' field that ignores all the quota safety checks, the + * 'force_only' field ignores only the specified checks; other checks are + * still enforced. The 'force' and 'force_only' fields cannot both be set. + */ + forceOnly: QuotaSafetyCheck[]; +} +export interface UpdateAdminOverrideRequestProtoMsg { + typeUrl: "/google.api.serviceusage.v1beta1.UpdateAdminOverrideRequest"; + value: Uint8Array; +} +/** Request message for UpdateAdminOverride. */ +export interface UpdateAdminOverrideRequestSDKType { + name: string; + override?: QuotaOverrideSDKType; + force: boolean; + update_mask?: FieldMaskSDKType; + force_only: QuotaSafetyCheck[]; +} +/** Request message for DeleteAdminOverride. */ +export interface DeleteAdminOverrideRequest { + /** + * The resource name of the override to delete. + * + * An example name would be: + * `projects/123/services/compute.googleapis.com/consumerQuotaMetrics/compute.googleapis.com%2Fcpus/limits/%2Fproject%2Fregion/adminOverrides/4a3f2c1d` + */ + name: string; + /** + * Whether to force the deletion of the quota override. + * Setting the force parameter to 'true' ignores all quota safety checks that + * would fail the request. QuotaSafetyCheck lists all such validations. + */ + force: boolean; + /** + * The list of quota safety checks to ignore before the override mutation. + * Unlike 'force' field that ignores all the quota safety checks, the + * 'force_only' field ignores only the specified checks; other checks are + * still enforced. The 'force' and 'force_only' fields cannot both be set. + */ + forceOnly: QuotaSafetyCheck[]; +} +export interface DeleteAdminOverrideRequestProtoMsg { + typeUrl: "/google.api.serviceusage.v1beta1.DeleteAdminOverrideRequest"; + value: Uint8Array; +} +/** Request message for DeleteAdminOverride. */ +export interface DeleteAdminOverrideRequestSDKType { + name: string; + force: boolean; + force_only: QuotaSafetyCheck[]; +} +/** Request message for ListAdminOverrides */ +export interface ListAdminOverridesRequest { + /** + * The resource name of the parent quota limit, returned by a + * ListConsumerQuotaMetrics or GetConsumerQuotaMetric call. + * + * An example name would be: + * `projects/123/services/compute.googleapis.com/consumerQuotaMetrics/compute.googleapis.com%2Fcpus/limits/%2Fproject%2Fregion` + */ + parent: string; + /** Requested size of the next page of data. */ + pageSize: number; + /** + * Token identifying which result to start with; returned by a previous list + * call. + */ + pageToken: string; +} +export interface ListAdminOverridesRequestProtoMsg { + typeUrl: "/google.api.serviceusage.v1beta1.ListAdminOverridesRequest"; + value: Uint8Array; +} +/** Request message for ListAdminOverrides */ +export interface ListAdminOverridesRequestSDKType { + parent: string; + page_size: number; + page_token: string; +} +/** Response message for ListAdminOverrides. */ +export interface ListAdminOverridesResponse { + /** Admin overrides on this limit. */ + overrides: QuotaOverride[]; + /** + * Token identifying which result to start with; returned by a previous list + * call. + */ + nextPageToken: string; +} +export interface ListAdminOverridesResponseProtoMsg { + typeUrl: "/google.api.serviceusage.v1beta1.ListAdminOverridesResponse"; + value: Uint8Array; +} +/** Response message for ListAdminOverrides. */ +export interface ListAdminOverridesResponseSDKType { + overrides: QuotaOverrideSDKType[]; + next_page_token: string; +} +/** Response message for BatchCreateAdminOverrides */ +export interface BatchCreateAdminOverridesResponse { + /** The overrides that were created. */ + overrides: QuotaOverride[]; +} +export interface BatchCreateAdminOverridesResponseProtoMsg { + typeUrl: "/google.api.serviceusage.v1beta1.BatchCreateAdminOverridesResponse"; + value: Uint8Array; +} +/** Response message for BatchCreateAdminOverrides */ +export interface BatchCreateAdminOverridesResponseSDKType { + overrides: QuotaOverrideSDKType[]; +} +/** Request message for ImportAdminOverrides */ +export interface ImportAdminOverridesRequest { + /** + * The resource name of the consumer. + * + * An example name would be: + * `projects/123/services/compute.googleapis.com` + */ + parent: string; + /** The import data is specified in the request message itself */ + inlineSource?: OverrideInlineSource; + /** + * Whether to force the creation of the quota overrides. + * Setting the force parameter to 'true' ignores all quota safety checks that + * would fail the request. QuotaSafetyCheck lists all such validations. + */ + force: boolean; + /** + * The list of quota safety checks to ignore before the override mutation. + * Unlike 'force' field that ignores all the quota safety checks, the + * 'force_only' field ignores only the specified checks; other checks are + * still enforced. The 'force' and 'force_only' fields cannot both be set. + */ + forceOnly: QuotaSafetyCheck[]; +} +export interface ImportAdminOverridesRequestProtoMsg { + typeUrl: "/google.api.serviceusage.v1beta1.ImportAdminOverridesRequest"; + value: Uint8Array; +} +/** Request message for ImportAdminOverrides */ +export interface ImportAdminOverridesRequestSDKType { + parent: string; + inline_source?: OverrideInlineSourceSDKType; + force: boolean; + force_only: QuotaSafetyCheck[]; +} +/** Response message for ImportAdminOverrides */ +export interface ImportAdminOverridesResponse { + /** The overrides that were created from the imported data. */ + overrides: QuotaOverride[]; +} +export interface ImportAdminOverridesResponseProtoMsg { + typeUrl: "/google.api.serviceusage.v1beta1.ImportAdminOverridesResponse"; + value: Uint8Array; +} +/** Response message for ImportAdminOverrides */ +export interface ImportAdminOverridesResponseSDKType { + overrides: QuotaOverrideSDKType[]; +} +/** + * Metadata message that provides information such as progress, + * partial failures, and similar information on each GetOperation call + * of LRO returned by ImportAdminOverrides. + */ +export interface ImportAdminOverridesMetadata {} +export interface ImportAdminOverridesMetadataProtoMsg { + typeUrl: "/google.api.serviceusage.v1beta1.ImportAdminOverridesMetadata"; + value: Uint8Array; +} +/** + * Metadata message that provides information such as progress, + * partial failures, and similar information on each GetOperation call + * of LRO returned by ImportAdminOverrides. + */ +export interface ImportAdminOverridesMetadataSDKType {} +/** Request message for CreateConsumerOverride. */ +export interface CreateConsumerOverrideRequest { + /** + * The resource name of the parent quota limit, returned by a + * ListConsumerQuotaMetrics or GetConsumerQuotaMetric call. + * + * An example name would be: + * `projects/123/services/compute.googleapis.com/consumerQuotaMetrics/compute.googleapis.com%2Fcpus/limits/%2Fproject%2Fregion` + */ + parent: string; + /** The override to create. */ + override?: QuotaOverride; + /** + * Whether to force the creation of the quota override. + * Setting the force parameter to 'true' ignores all quota safety checks that + * would fail the request. QuotaSafetyCheck lists all such validations. + */ + force: boolean; + /** + * The list of quota safety checks to ignore before the override mutation. + * Unlike 'force' field that ignores all the quota safety checks, the + * 'force_only' field ignores only the specified checks; other checks are + * still enforced. The 'force' and 'force_only' fields cannot both be set. + */ + forceOnly: QuotaSafetyCheck[]; +} +export interface CreateConsumerOverrideRequestProtoMsg { + typeUrl: "/google.api.serviceusage.v1beta1.CreateConsumerOverrideRequest"; + value: Uint8Array; +} +/** Request message for CreateConsumerOverride. */ +export interface CreateConsumerOverrideRequestSDKType { + parent: string; + override?: QuotaOverrideSDKType; + force: boolean; + force_only: QuotaSafetyCheck[]; +} +/** Request message for UpdateConsumerOverride. */ +export interface UpdateConsumerOverrideRequest { + /** + * The resource name of the override to update. + * + * An example name would be: + * `projects/123/services/compute.googleapis.com/consumerQuotaMetrics/compute.googleapis.com%2Fcpus/limits/%2Fproject%2Fregion/consumerOverrides/4a3f2c1d` + */ + name: string; + /** + * The new override. + * Only the override_value is updated; all other fields are ignored. + */ + override?: QuotaOverride; + /** + * Whether to force the update of the quota override. + * Setting the force parameter to 'true' ignores all quota safety checks that + * would fail the request. QuotaSafetyCheck lists all such validations. + */ + force: boolean; + /** + * Update only the specified fields of the override. + * If unset, all fields will be updated. + */ + updateMask?: FieldMask; + /** + * The list of quota safety checks to ignore before the override mutation. + * Unlike 'force' field that ignores all the quota safety checks, the + * 'force_only' field ignores only the specified checks; other checks are + * still enforced. The 'force' and 'force_only' fields cannot both be set. + */ + forceOnly: QuotaSafetyCheck[]; +} +export interface UpdateConsumerOverrideRequestProtoMsg { + typeUrl: "/google.api.serviceusage.v1beta1.UpdateConsumerOverrideRequest"; + value: Uint8Array; +} +/** Request message for UpdateConsumerOverride. */ +export interface UpdateConsumerOverrideRequestSDKType { + name: string; + override?: QuotaOverrideSDKType; + force: boolean; + update_mask?: FieldMaskSDKType; + force_only: QuotaSafetyCheck[]; +} +/** Request message for DeleteConsumerOverride. */ +export interface DeleteConsumerOverrideRequest { + /** + * The resource name of the override to delete. + * + * An example name would be: + * `projects/123/services/compute.googleapis.com/consumerQuotaMetrics/compute.googleapis.com%2Fcpus/limits/%2Fproject%2Fregion/consumerOverrides/4a3f2c1d` + */ + name: string; + /** + * Whether to force the deletion of the quota override. + * Setting the force parameter to 'true' ignores all quota safety checks that + * would fail the request. QuotaSafetyCheck lists all such validations. + */ + force: boolean; + /** + * The list of quota safety checks to ignore before the override mutation. + * Unlike 'force' field that ignores all the quota safety checks, the + * 'force_only' field ignores only the specified checks; other checks are + * still enforced. The 'force' and 'force_only' fields cannot both be set. + */ + forceOnly: QuotaSafetyCheck[]; +} +export interface DeleteConsumerOverrideRequestProtoMsg { + typeUrl: "/google.api.serviceusage.v1beta1.DeleteConsumerOverrideRequest"; + value: Uint8Array; +} +/** Request message for DeleteConsumerOverride. */ +export interface DeleteConsumerOverrideRequestSDKType { + name: string; + force: boolean; + force_only: QuotaSafetyCheck[]; +} +/** Request message for ListConsumerOverrides */ +export interface ListConsumerOverridesRequest { + /** + * The resource name of the parent quota limit, returned by a + * ListConsumerQuotaMetrics or GetConsumerQuotaMetric call. + * + * An example name would be: + * `projects/123/services/compute.googleapis.com/consumerQuotaMetrics/compute.googleapis.com%2Fcpus/limits/%2Fproject%2Fregion` + */ + parent: string; + /** Requested size of the next page of data. */ + pageSize: number; + /** + * Token identifying which result to start with; returned by a previous list + * call. + */ + pageToken: string; +} +export interface ListConsumerOverridesRequestProtoMsg { + typeUrl: "/google.api.serviceusage.v1beta1.ListConsumerOverridesRequest"; + value: Uint8Array; +} +/** Request message for ListConsumerOverrides */ +export interface ListConsumerOverridesRequestSDKType { + parent: string; + page_size: number; + page_token: string; +} +/** Response message for ListConsumerOverrides. */ +export interface ListConsumerOverridesResponse { + /** Consumer overrides on this limit. */ + overrides: QuotaOverride[]; + /** + * Token identifying which result to start with; returned by a previous list + * call. + */ + nextPageToken: string; +} +export interface ListConsumerOverridesResponseProtoMsg { + typeUrl: "/google.api.serviceusage.v1beta1.ListConsumerOverridesResponse"; + value: Uint8Array; +} +/** Response message for ListConsumerOverrides. */ +export interface ListConsumerOverridesResponseSDKType { + overrides: QuotaOverrideSDKType[]; + next_page_token: string; +} +/** Response message for BatchCreateConsumerOverrides */ +export interface BatchCreateConsumerOverridesResponse { + /** The overrides that were created. */ + overrides: QuotaOverride[]; +} +export interface BatchCreateConsumerOverridesResponseProtoMsg { + typeUrl: "/google.api.serviceusage.v1beta1.BatchCreateConsumerOverridesResponse"; + value: Uint8Array; +} +/** Response message for BatchCreateConsumerOverrides */ +export interface BatchCreateConsumerOverridesResponseSDKType { + overrides: QuotaOverrideSDKType[]; +} +/** Request message for ImportConsumerOverrides */ +export interface ImportConsumerOverridesRequest { + /** + * The resource name of the consumer. + * + * An example name would be: + * `projects/123/services/compute.googleapis.com` + */ + parent: string; + /** The import data is specified in the request message itself */ + inlineSource?: OverrideInlineSource; + /** + * Whether to force the creation of the quota overrides. + * Setting the force parameter to 'true' ignores all quota safety checks that + * would fail the request. QuotaSafetyCheck lists all such validations. + */ + force: boolean; + /** + * The list of quota safety checks to ignore before the override mutation. + * Unlike 'force' field that ignores all the quota safety checks, the + * 'force_only' field ignores only the specified checks; other checks are + * still enforced. The 'force' and 'force_only' fields cannot both be set. + */ + forceOnly: QuotaSafetyCheck[]; +} +export interface ImportConsumerOverridesRequestProtoMsg { + typeUrl: "/google.api.serviceusage.v1beta1.ImportConsumerOverridesRequest"; + value: Uint8Array; +} +/** Request message for ImportConsumerOverrides */ +export interface ImportConsumerOverridesRequestSDKType { + parent: string; + inline_source?: OverrideInlineSourceSDKType; + force: boolean; + force_only: QuotaSafetyCheck[]; +} +/** Response message for ImportConsumerOverrides */ +export interface ImportConsumerOverridesResponse { + /** The overrides that were created from the imported data. */ + overrides: QuotaOverride[]; +} +export interface ImportConsumerOverridesResponseProtoMsg { + typeUrl: "/google.api.serviceusage.v1beta1.ImportConsumerOverridesResponse"; + value: Uint8Array; +} +/** Response message for ImportConsumerOverrides */ +export interface ImportConsumerOverridesResponseSDKType { + overrides: QuotaOverrideSDKType[]; +} +/** + * Metadata message that provides information such as progress, + * partial failures, and similar information on each GetOperation call + * of LRO returned by ImportConsumerOverrides. + */ +export interface ImportConsumerOverridesMetadata {} +export interface ImportConsumerOverridesMetadataProtoMsg { + typeUrl: "/google.api.serviceusage.v1beta1.ImportConsumerOverridesMetadata"; + value: Uint8Array; +} +/** + * Metadata message that provides information such as progress, + * partial failures, and similar information on each GetOperation call + * of LRO returned by ImportConsumerOverrides. + */ +export interface ImportConsumerOverridesMetadataSDKType {} +/** Response message for ImportAdminQuotaPolicies */ +export interface ImportAdminQuotaPoliciesResponse { + /** The policies that were created from the imported data. */ + policies: AdminQuotaPolicy[]; +} +export interface ImportAdminQuotaPoliciesResponseProtoMsg { + typeUrl: "/google.api.serviceusage.v1beta1.ImportAdminQuotaPoliciesResponse"; + value: Uint8Array; +} +/** Response message for ImportAdminQuotaPolicies */ +export interface ImportAdminQuotaPoliciesResponseSDKType { + policies: AdminQuotaPolicySDKType[]; +} +/** + * Metadata message that provides information such as progress, + * partial failures, and similar information on each GetOperation call + * of LRO returned by ImportAdminQuotaPolicies. + */ +export interface ImportAdminQuotaPoliciesMetadata {} +export interface ImportAdminQuotaPoliciesMetadataProtoMsg { + typeUrl: "/google.api.serviceusage.v1beta1.ImportAdminQuotaPoliciesMetadata"; + value: Uint8Array; +} +/** + * Metadata message that provides information such as progress, + * partial failures, and similar information on each GetOperation call + * of LRO returned by ImportAdminQuotaPolicies. + */ +export interface ImportAdminQuotaPoliciesMetadataSDKType {} +/** + * Metadata message that provides information such as progress, + * partial failures, and similar information on each GetOperation call + * of LRO returned by CreateAdminQuotaPolicy. + */ +export interface CreateAdminQuotaPolicyMetadata {} +export interface CreateAdminQuotaPolicyMetadataProtoMsg { + typeUrl: "/google.api.serviceusage.v1beta1.CreateAdminQuotaPolicyMetadata"; + value: Uint8Array; +} +/** + * Metadata message that provides information such as progress, + * partial failures, and similar information on each GetOperation call + * of LRO returned by CreateAdminQuotaPolicy. + */ +export interface CreateAdminQuotaPolicyMetadataSDKType {} +/** + * Metadata message that provides information such as progress, + * partial failures, and similar information on each GetOperation call + * of LRO returned by UpdateAdminQuotaPolicy. + */ +export interface UpdateAdminQuotaPolicyMetadata {} +export interface UpdateAdminQuotaPolicyMetadataProtoMsg { + typeUrl: "/google.api.serviceusage.v1beta1.UpdateAdminQuotaPolicyMetadata"; + value: Uint8Array; +} +/** + * Metadata message that provides information such as progress, + * partial failures, and similar information on each GetOperation call + * of LRO returned by UpdateAdminQuotaPolicy. + */ +export interface UpdateAdminQuotaPolicyMetadataSDKType {} +/** + * Metadata message that provides information such as progress, + * partial failures, and similar information on each GetOperation call + * of LRO returned by DeleteAdminQuotaPolicy. + */ +export interface DeleteAdminQuotaPolicyMetadata {} +export interface DeleteAdminQuotaPolicyMetadataProtoMsg { + typeUrl: "/google.api.serviceusage.v1beta1.DeleteAdminQuotaPolicyMetadata"; + value: Uint8Array; +} +/** + * Metadata message that provides information such as progress, + * partial failures, and similar information on each GetOperation call + * of LRO returned by DeleteAdminQuotaPolicy. + */ +export interface DeleteAdminQuotaPolicyMetadataSDKType {} +/** Request message for generating service identity. */ +export interface GenerateServiceIdentityRequest { + /** + * Name of the consumer and service to generate an identity for. + * + * The `GenerateServiceIdentity` methods currently only support projects. + * + * An example name would be: + * `projects/123/services/example.googleapis.com` where `123` is the + * project number. + */ + parent: string; +} +export interface GenerateServiceIdentityRequestProtoMsg { + typeUrl: "/google.api.serviceusage.v1beta1.GenerateServiceIdentityRequest"; + value: Uint8Array; +} +/** Request message for generating service identity. */ +export interface GenerateServiceIdentityRequestSDKType { + parent: string; +} +/** Response message for getting service identity. */ +export interface GetServiceIdentityResponse { + /** + * Service identity that service producer can use to access consumer + * resources. If exists is true, it contains email and unique_id. If exists is + * false, it contains pre-constructed email and empty unique_id. + */ + identity?: ServiceIdentity; + /** Service identity state. */ + state: GetServiceIdentityResponse_IdentityState; +} +export interface GetServiceIdentityResponseProtoMsg { + typeUrl: "/google.api.serviceusage.v1beta1.GetServiceIdentityResponse"; + value: Uint8Array; +} +/** Response message for getting service identity. */ +export interface GetServiceIdentityResponseSDKType { + identity?: ServiceIdentitySDKType; + state: GetServiceIdentityResponse_IdentityState; +} +/** Metadata for the `GetServiceIdentity` method. */ +export interface GetServiceIdentityMetadata {} +export interface GetServiceIdentityMetadataProtoMsg { + typeUrl: "/google.api.serviceusage.v1beta1.GetServiceIdentityMetadata"; + value: Uint8Array; +} +/** Metadata for the `GetServiceIdentity` method. */ +export interface GetServiceIdentityMetadataSDKType {} +function createBaseEnableServiceRequest(): EnableServiceRequest { + return { + name: "" + }; +} +export const EnableServiceRequest = { + typeUrl: "/google.api.serviceusage.v1beta1.EnableServiceRequest", + encode(message: EnableServiceRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): EnableServiceRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseEnableServiceRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): EnableServiceRequest { + const obj = createBaseEnableServiceRequest(); + if (isSet(object.name)) obj.name = String(object.name); + return obj; + }, + toJSON(message: EnableServiceRequest): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + return obj; + }, + fromPartial(object: DeepPartial): EnableServiceRequest { + const message = createBaseEnableServiceRequest(); + message.name = object.name ?? ""; + return message; + }, + fromSDK(object: EnableServiceRequestSDKType): EnableServiceRequest { + return { + name: object?.name + }; + }, + fromSDKJSON(object: any): EnableServiceRequestSDKType { + return { + name: isSet(object.name) ? String(object.name) : "" + }; + }, + toSDK(message: EnableServiceRequest): EnableServiceRequestSDKType { + const obj: any = {}; + obj.name = message.name; + return obj; + }, + fromAmino(object: EnableServiceRequestAmino): EnableServiceRequest { + const message = createBaseEnableServiceRequest(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + return message; + }, + toAmino(message: EnableServiceRequest): EnableServiceRequestAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + return obj; + }, + fromAminoMsg(object: EnableServiceRequestAminoMsg): EnableServiceRequest { + return EnableServiceRequest.fromAmino(object.value); + }, + fromProtoMsg(message: EnableServiceRequestProtoMsg): EnableServiceRequest { + return EnableServiceRequest.decode(message.value); + }, + toProto(message: EnableServiceRequest): Uint8Array { + return EnableServiceRequest.encode(message).finish(); + }, + toProtoMsg(message: EnableServiceRequest): EnableServiceRequestProtoMsg { + return { + typeUrl: "/google.api.serviceusage.v1beta1.EnableServiceRequest", + value: EnableServiceRequest.encode(message).finish() + }; + } +}; +function createBaseDisableServiceRequest(): DisableServiceRequest { + return { + name: "" + }; +} +export const DisableServiceRequest = { + typeUrl: "/google.api.serviceusage.v1beta1.DisableServiceRequest", + encode(message: DisableServiceRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): DisableServiceRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDisableServiceRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): DisableServiceRequest { + const obj = createBaseDisableServiceRequest(); + if (isSet(object.name)) obj.name = String(object.name); + return obj; + }, + toJSON(message: DisableServiceRequest): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + return obj; + }, + fromPartial(object: DeepPartial): DisableServiceRequest { + const message = createBaseDisableServiceRequest(); + message.name = object.name ?? ""; + return message; + }, + fromSDK(object: DisableServiceRequestSDKType): DisableServiceRequest { + return { + name: object?.name + }; + }, + fromSDKJSON(object: any): DisableServiceRequestSDKType { + return { + name: isSet(object.name) ? String(object.name) : "" + }; + }, + toSDK(message: DisableServiceRequest): DisableServiceRequestSDKType { + const obj: any = {}; + obj.name = message.name; + return obj; + }, + fromAmino(object: DisableServiceRequestAmino): DisableServiceRequest { + const message = createBaseDisableServiceRequest(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + return message; + }, + toAmino(message: DisableServiceRequest): DisableServiceRequestAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + return obj; + }, + fromAminoMsg(object: DisableServiceRequestAminoMsg): DisableServiceRequest { + return DisableServiceRequest.fromAmino(object.value); + }, + fromProtoMsg(message: DisableServiceRequestProtoMsg): DisableServiceRequest { + return DisableServiceRequest.decode(message.value); + }, + toProto(message: DisableServiceRequest): Uint8Array { + return DisableServiceRequest.encode(message).finish(); + }, + toProtoMsg(message: DisableServiceRequest): DisableServiceRequestProtoMsg { + return { + typeUrl: "/google.api.serviceusage.v1beta1.DisableServiceRequest", + value: DisableServiceRequest.encode(message).finish() + }; + } +}; +function createBaseGetServiceRequest(): GetServiceRequest { + return { + name: "" + }; +} +export const GetServiceRequest = { + typeUrl: "/google.api.serviceusage.v1beta1.GetServiceRequest", + encode(message: GetServiceRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GetServiceRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGetServiceRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GetServiceRequest { + const obj = createBaseGetServiceRequest(); + if (isSet(object.name)) obj.name = String(object.name); + return obj; + }, + toJSON(message: GetServiceRequest): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + return obj; + }, + fromPartial(object: DeepPartial): GetServiceRequest { + const message = createBaseGetServiceRequest(); + message.name = object.name ?? ""; + return message; + }, + fromSDK(object: GetServiceRequestSDKType): GetServiceRequest { + return { + name: object?.name + }; + }, + fromSDKJSON(object: any): GetServiceRequestSDKType { + return { + name: isSet(object.name) ? String(object.name) : "" + }; + }, + toSDK(message: GetServiceRequest): GetServiceRequestSDKType { + const obj: any = {}; + obj.name = message.name; + return obj; + }, + fromAmino(object: GetServiceRequestAmino): GetServiceRequest { + const message = createBaseGetServiceRequest(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + return message; + }, + toAmino(message: GetServiceRequest): GetServiceRequestAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + return obj; + }, + fromAminoMsg(object: GetServiceRequestAminoMsg): GetServiceRequest { + return GetServiceRequest.fromAmino(object.value); + }, + fromProtoMsg(message: GetServiceRequestProtoMsg): GetServiceRequest { + return GetServiceRequest.decode(message.value); + }, + toProto(message: GetServiceRequest): Uint8Array { + return GetServiceRequest.encode(message).finish(); + }, + toProtoMsg(message: GetServiceRequest): GetServiceRequestProtoMsg { + return { + typeUrl: "/google.api.serviceusage.v1beta1.GetServiceRequest", + value: GetServiceRequest.encode(message).finish() + }; + } +}; +function createBaseListServicesRequest(): ListServicesRequest { + return { + parent: "", + pageSize: 0, + pageToken: "", + filter: "" + }; +} +export const ListServicesRequest = { + typeUrl: "/google.api.serviceusage.v1beta1.ListServicesRequest", + encode(message: ListServicesRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.parent !== undefined) { + writer.uint32(10).string(message.parent); + } + if (message.pageSize !== undefined) { + writer.uint32(16).int32(message.pageSize); + } + if (message.pageToken !== undefined) { + writer.uint32(26).string(message.pageToken); + } + if (message.filter !== undefined) { + writer.uint32(34).string(message.filter); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ListServicesRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseListServicesRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.parent = reader.string(); + break; + case 2: + message.pageSize = reader.int32(); + break; + case 3: + message.pageToken = reader.string(); + break; + case 4: + message.filter = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ListServicesRequest { + const obj = createBaseListServicesRequest(); + if (isSet(object.parent)) obj.parent = String(object.parent); + if (isSet(object.pageSize)) obj.pageSize = Number(object.pageSize); + if (isSet(object.pageToken)) obj.pageToken = String(object.pageToken); + if (isSet(object.filter)) obj.filter = String(object.filter); + return obj; + }, + toJSON(message: ListServicesRequest): JsonSafe { + const obj: any = {}; + message.parent !== undefined && (obj.parent = message.parent); + message.pageSize !== undefined && (obj.pageSize = Math.round(message.pageSize)); + message.pageToken !== undefined && (obj.pageToken = message.pageToken); + message.filter !== undefined && (obj.filter = message.filter); + return obj; + }, + fromPartial(object: DeepPartial): ListServicesRequest { + const message = createBaseListServicesRequest(); + message.parent = object.parent ?? ""; + message.pageSize = object.pageSize ?? 0; + message.pageToken = object.pageToken ?? ""; + message.filter = object.filter ?? ""; + return message; + }, + fromSDK(object: ListServicesRequestSDKType): ListServicesRequest { + return { + parent: object?.parent, + pageSize: object?.page_size, + pageToken: object?.page_token, + filter: object?.filter + }; + }, + fromSDKJSON(object: any): ListServicesRequestSDKType { + return { + parent: isSet(object.parent) ? String(object.parent) : "", + page_size: isSet(object.page_size) ? Number(object.page_size) : 0, + page_token: isSet(object.page_token) ? String(object.page_token) : "", + filter: isSet(object.filter) ? String(object.filter) : "" + }; + }, + toSDK(message: ListServicesRequest): ListServicesRequestSDKType { + const obj: any = {}; + obj.parent = message.parent; + obj.page_size = message.pageSize; + obj.page_token = message.pageToken; + obj.filter = message.filter; + return obj; + }, + fromAmino(object: ListServicesRequestAmino): ListServicesRequest { + const message = createBaseListServicesRequest(); + if (object.parent !== undefined && object.parent !== null) { + message.parent = object.parent; + } + if (object.page_size !== undefined && object.page_size !== null) { + message.pageSize = object.page_size; + } + if (object.page_token !== undefined && object.page_token !== null) { + message.pageToken = object.page_token; + } + if (object.filter !== undefined && object.filter !== null) { + message.filter = object.filter; + } + return message; + }, + toAmino(message: ListServicesRequest): ListServicesRequestAmino { + const obj: any = {}; + obj.parent = message.parent === "" ? undefined : message.parent; + obj.page_size = message.pageSize === 0 ? undefined : message.pageSize; + obj.page_token = message.pageToken === "" ? undefined : message.pageToken; + obj.filter = message.filter === "" ? undefined : message.filter; + return obj; + }, + fromAminoMsg(object: ListServicesRequestAminoMsg): ListServicesRequest { + return ListServicesRequest.fromAmino(object.value); + }, + fromProtoMsg(message: ListServicesRequestProtoMsg): ListServicesRequest { + return ListServicesRequest.decode(message.value); + }, + toProto(message: ListServicesRequest): Uint8Array { + return ListServicesRequest.encode(message).finish(); + }, + toProtoMsg(message: ListServicesRequest): ListServicesRequestProtoMsg { + return { + typeUrl: "/google.api.serviceusage.v1beta1.ListServicesRequest", + value: ListServicesRequest.encode(message).finish() + }; + } +}; +function createBaseListServicesResponse(): ListServicesResponse { + return { + services: [], + nextPageToken: "" + }; +} +export const ListServicesResponse = { + typeUrl: "/google.api.serviceusage.v1beta1.ListServicesResponse", + encode(message: ListServicesResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.services) { + Service.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.nextPageToken !== undefined) { + writer.uint32(18).string(message.nextPageToken); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ListServicesResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseListServicesResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.services.push(Service.decode(reader, reader.uint32())); + break; + case 2: + message.nextPageToken = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ListServicesResponse { + const obj = createBaseListServicesResponse(); + if (Array.isArray(object?.services)) obj.services = object.services.map((e: any) => Service.fromJSON(e)); + if (isSet(object.nextPageToken)) obj.nextPageToken = String(object.nextPageToken); + return obj; + }, + toJSON(message: ListServicesResponse): JsonSafe { + const obj: any = {}; + if (message.services) { + obj.services = message.services.map(e => e ? Service.toJSON(e) : undefined); + } else { + obj.services = []; + } + message.nextPageToken !== undefined && (obj.nextPageToken = message.nextPageToken); + return obj; + }, + fromPartial(object: DeepPartial): ListServicesResponse { + const message = createBaseListServicesResponse(); + message.services = object.services?.map(e => Service.fromPartial(e)) || []; + message.nextPageToken = object.nextPageToken ?? ""; + return message; + }, + fromSDK(object: ListServicesResponseSDKType): ListServicesResponse { + return { + services: Array.isArray(object?.services) ? object.services.map((e: any) => Service.fromSDK(e)) : [], + nextPageToken: object?.next_page_token + }; + }, + fromSDKJSON(object: any): ListServicesResponseSDKType { + return { + services: Array.isArray(object?.services) ? object.services.map((e: any) => Service.fromSDKJSON(e)) : [], + next_page_token: isSet(object.next_page_token) ? String(object.next_page_token) : "" + }; + }, + toSDK(message: ListServicesResponse): ListServicesResponseSDKType { + const obj: any = {}; + if (message.services) { + obj.services = message.services.map(e => e ? Service.toSDK(e) : undefined); + } else { + obj.services = []; + } + obj.next_page_token = message.nextPageToken; + return obj; + }, + fromAmino(object: ListServicesResponseAmino): ListServicesResponse { + const message = createBaseListServicesResponse(); + message.services = object.services?.map(e => Service.fromAmino(e)) || []; + if (object.next_page_token !== undefined && object.next_page_token !== null) { + message.nextPageToken = object.next_page_token; + } + return message; + }, + toAmino(message: ListServicesResponse): ListServicesResponseAmino { + const obj: any = {}; + if (message.services) { + obj.services = message.services.map(e => e ? Service.toAmino(e) : undefined); + } else { + obj.services = message.services; + } + obj.next_page_token = message.nextPageToken === "" ? undefined : message.nextPageToken; + return obj; + }, + fromAminoMsg(object: ListServicesResponseAminoMsg): ListServicesResponse { + return ListServicesResponse.fromAmino(object.value); + }, + fromProtoMsg(message: ListServicesResponseProtoMsg): ListServicesResponse { + return ListServicesResponse.decode(message.value); + }, + toProto(message: ListServicesResponse): Uint8Array { + return ListServicesResponse.encode(message).finish(); + }, + toProtoMsg(message: ListServicesResponse): ListServicesResponseProtoMsg { + return { + typeUrl: "/google.api.serviceusage.v1beta1.ListServicesResponse", + value: ListServicesResponse.encode(message).finish() + }; + } +}; +function createBaseBatchEnableServicesRequest(): BatchEnableServicesRequest { + return { + parent: "", + serviceIds: [] + }; +} +export const BatchEnableServicesRequest = { + typeUrl: "/google.api.serviceusage.v1beta1.BatchEnableServicesRequest", + encode(message: BatchEnableServicesRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.parent !== undefined) { + writer.uint32(10).string(message.parent); + } + for (const v of message.serviceIds) { + writer.uint32(18).string(v!); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): BatchEnableServicesRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseBatchEnableServicesRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.parent = reader.string(); + break; + case 2: + message.serviceIds.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): BatchEnableServicesRequest { + const obj = createBaseBatchEnableServicesRequest(); + if (isSet(object.parent)) obj.parent = String(object.parent); + if (Array.isArray(object?.serviceIds)) obj.serviceIds = object.serviceIds.map((e: any) => String(e)); + return obj; + }, + toJSON(message: BatchEnableServicesRequest): JsonSafe { + const obj: any = {}; + message.parent !== undefined && (obj.parent = message.parent); + if (message.serviceIds) { + obj.serviceIds = message.serviceIds.map(e => e); + } else { + obj.serviceIds = []; + } + return obj; + }, + fromPartial(object: DeepPartial): BatchEnableServicesRequest { + const message = createBaseBatchEnableServicesRequest(); + message.parent = object.parent ?? ""; + message.serviceIds = object.serviceIds?.map(e => e) || []; + return message; + }, + fromSDK(object: BatchEnableServicesRequestSDKType): BatchEnableServicesRequest { + return { + parent: object?.parent, + serviceIds: Array.isArray(object?.service_ids) ? object.service_ids.map((e: any) => e) : [] + }; + }, + fromSDKJSON(object: any): BatchEnableServicesRequestSDKType { + return { + parent: isSet(object.parent) ? String(object.parent) : "", + service_ids: Array.isArray(object?.service_ids) ? object.service_ids.map((e: any) => String(e)) : [] + }; + }, + toSDK(message: BatchEnableServicesRequest): BatchEnableServicesRequestSDKType { + const obj: any = {}; + obj.parent = message.parent; + if (message.serviceIds) { + obj.service_ids = message.serviceIds.map(e => e); + } else { + obj.service_ids = []; + } + return obj; + }, + fromAmino(object: BatchEnableServicesRequestAmino): BatchEnableServicesRequest { + const message = createBaseBatchEnableServicesRequest(); + if (object.parent !== undefined && object.parent !== null) { + message.parent = object.parent; + } + message.serviceIds = object.service_ids?.map(e => e) || []; + return message; + }, + toAmino(message: BatchEnableServicesRequest): BatchEnableServicesRequestAmino { + const obj: any = {}; + obj.parent = message.parent === "" ? undefined : message.parent; + if (message.serviceIds) { + obj.service_ids = message.serviceIds.map(e => e); + } else { + obj.service_ids = message.serviceIds; + } + return obj; + }, + fromAminoMsg(object: BatchEnableServicesRequestAminoMsg): BatchEnableServicesRequest { + return BatchEnableServicesRequest.fromAmino(object.value); + }, + fromProtoMsg(message: BatchEnableServicesRequestProtoMsg): BatchEnableServicesRequest { + return BatchEnableServicesRequest.decode(message.value); + }, + toProto(message: BatchEnableServicesRequest): Uint8Array { + return BatchEnableServicesRequest.encode(message).finish(); + }, + toProtoMsg(message: BatchEnableServicesRequest): BatchEnableServicesRequestProtoMsg { + return { + typeUrl: "/google.api.serviceusage.v1beta1.BatchEnableServicesRequest", + value: BatchEnableServicesRequest.encode(message).finish() + }; + } +}; +function createBaseListConsumerQuotaMetricsRequest(): ListConsumerQuotaMetricsRequest { + return { + parent: "", + pageSize: 0, + pageToken: "", + view: 0 + }; +} +export const ListConsumerQuotaMetricsRequest = { + typeUrl: "/google.api.serviceusage.v1beta1.ListConsumerQuotaMetricsRequest", + encode(message: ListConsumerQuotaMetricsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.parent !== undefined) { + writer.uint32(10).string(message.parent); + } + if (message.pageSize !== undefined) { + writer.uint32(16).int32(message.pageSize); + } + if (message.pageToken !== undefined) { + writer.uint32(26).string(message.pageToken); + } + if (message.view !== 0) { + writer.uint32(32).int32(message.view); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ListConsumerQuotaMetricsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseListConsumerQuotaMetricsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.parent = reader.string(); + break; + case 2: + message.pageSize = reader.int32(); + break; + case 3: + message.pageToken = reader.string(); + break; + case 4: + message.view = (reader.int32() as any); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ListConsumerQuotaMetricsRequest { + const obj = createBaseListConsumerQuotaMetricsRequest(); + if (isSet(object.parent)) obj.parent = String(object.parent); + if (isSet(object.pageSize)) obj.pageSize = Number(object.pageSize); + if (isSet(object.pageToken)) obj.pageToken = String(object.pageToken); + if (isSet(object.view)) obj.view = quotaViewFromJSON(object.view); + return obj; + }, + toJSON(message: ListConsumerQuotaMetricsRequest): JsonSafe { + const obj: any = {}; + message.parent !== undefined && (obj.parent = message.parent); + message.pageSize !== undefined && (obj.pageSize = Math.round(message.pageSize)); + message.pageToken !== undefined && (obj.pageToken = message.pageToken); + message.view !== undefined && (obj.view = quotaViewToJSON(message.view)); + return obj; + }, + fromPartial(object: DeepPartial): ListConsumerQuotaMetricsRequest { + const message = createBaseListConsumerQuotaMetricsRequest(); + message.parent = object.parent ?? ""; + message.pageSize = object.pageSize ?? 0; + message.pageToken = object.pageToken ?? ""; + message.view = object.view ?? 0; + return message; + }, + fromSDK(object: ListConsumerQuotaMetricsRequestSDKType): ListConsumerQuotaMetricsRequest { + return { + parent: object?.parent, + pageSize: object?.page_size, + pageToken: object?.page_token, + view: isSet(object.view) ? quotaViewFromJSON(object.view) : -1 + }; + }, + fromSDKJSON(object: any): ListConsumerQuotaMetricsRequestSDKType { + return { + parent: isSet(object.parent) ? String(object.parent) : "", + page_size: isSet(object.page_size) ? Number(object.page_size) : 0, + page_token: isSet(object.page_token) ? String(object.page_token) : "", + view: isSet(object.view) ? quotaViewFromJSON(object.view) : -1 + }; + }, + toSDK(message: ListConsumerQuotaMetricsRequest): ListConsumerQuotaMetricsRequestSDKType { + const obj: any = {}; + obj.parent = message.parent; + obj.page_size = message.pageSize; + obj.page_token = message.pageToken; + message.view !== undefined && (obj.view = quotaViewToJSON(message.view)); + return obj; + }, + fromAmino(object: ListConsumerQuotaMetricsRequestAmino): ListConsumerQuotaMetricsRequest { + const message = createBaseListConsumerQuotaMetricsRequest(); + if (object.parent !== undefined && object.parent !== null) { + message.parent = object.parent; + } + if (object.page_size !== undefined && object.page_size !== null) { + message.pageSize = object.page_size; + } + if (object.page_token !== undefined && object.page_token !== null) { + message.pageToken = object.page_token; + } + if (object.view !== undefined && object.view !== null) { + message.view = object.view; + } + return message; + }, + toAmino(message: ListConsumerQuotaMetricsRequest): ListConsumerQuotaMetricsRequestAmino { + const obj: any = {}; + obj.parent = message.parent === "" ? undefined : message.parent; + obj.page_size = message.pageSize === 0 ? undefined : message.pageSize; + obj.page_token = message.pageToken === "" ? undefined : message.pageToken; + obj.view = message.view === 0 ? undefined : message.view; + return obj; + }, + fromAminoMsg(object: ListConsumerQuotaMetricsRequestAminoMsg): ListConsumerQuotaMetricsRequest { + return ListConsumerQuotaMetricsRequest.fromAmino(object.value); + }, + fromProtoMsg(message: ListConsumerQuotaMetricsRequestProtoMsg): ListConsumerQuotaMetricsRequest { + return ListConsumerQuotaMetricsRequest.decode(message.value); + }, + toProto(message: ListConsumerQuotaMetricsRequest): Uint8Array { + return ListConsumerQuotaMetricsRequest.encode(message).finish(); + }, + toProtoMsg(message: ListConsumerQuotaMetricsRequest): ListConsumerQuotaMetricsRequestProtoMsg { + return { + typeUrl: "/google.api.serviceusage.v1beta1.ListConsumerQuotaMetricsRequest", + value: ListConsumerQuotaMetricsRequest.encode(message).finish() + }; + } +}; +function createBaseListConsumerQuotaMetricsResponse(): ListConsumerQuotaMetricsResponse { + return { + metrics: [], + nextPageToken: "" + }; +} +export const ListConsumerQuotaMetricsResponse = { + typeUrl: "/google.api.serviceusage.v1beta1.ListConsumerQuotaMetricsResponse", + encode(message: ListConsumerQuotaMetricsResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.metrics) { + ConsumerQuotaMetric.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.nextPageToken !== undefined) { + writer.uint32(18).string(message.nextPageToken); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ListConsumerQuotaMetricsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseListConsumerQuotaMetricsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.metrics.push(ConsumerQuotaMetric.decode(reader, reader.uint32())); + break; + case 2: + message.nextPageToken = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ListConsumerQuotaMetricsResponse { + const obj = createBaseListConsumerQuotaMetricsResponse(); + if (Array.isArray(object?.metrics)) obj.metrics = object.metrics.map((e: any) => ConsumerQuotaMetric.fromJSON(e)); + if (isSet(object.nextPageToken)) obj.nextPageToken = String(object.nextPageToken); + return obj; + }, + toJSON(message: ListConsumerQuotaMetricsResponse): JsonSafe { + const obj: any = {}; + if (message.metrics) { + obj.metrics = message.metrics.map(e => e ? ConsumerQuotaMetric.toJSON(e) : undefined); + } else { + obj.metrics = []; + } + message.nextPageToken !== undefined && (obj.nextPageToken = message.nextPageToken); + return obj; + }, + fromPartial(object: DeepPartial): ListConsumerQuotaMetricsResponse { + const message = createBaseListConsumerQuotaMetricsResponse(); + message.metrics = object.metrics?.map(e => ConsumerQuotaMetric.fromPartial(e)) || []; + message.nextPageToken = object.nextPageToken ?? ""; + return message; + }, + fromSDK(object: ListConsumerQuotaMetricsResponseSDKType): ListConsumerQuotaMetricsResponse { + return { + metrics: Array.isArray(object?.metrics) ? object.metrics.map((e: any) => ConsumerQuotaMetric.fromSDK(e)) : [], + nextPageToken: object?.next_page_token + }; + }, + fromSDKJSON(object: any): ListConsumerQuotaMetricsResponseSDKType { + return { + metrics: Array.isArray(object?.metrics) ? object.metrics.map((e: any) => ConsumerQuotaMetric.fromSDKJSON(e)) : [], + next_page_token: isSet(object.next_page_token) ? String(object.next_page_token) : "" + }; + }, + toSDK(message: ListConsumerQuotaMetricsResponse): ListConsumerQuotaMetricsResponseSDKType { + const obj: any = {}; + if (message.metrics) { + obj.metrics = message.metrics.map(e => e ? ConsumerQuotaMetric.toSDK(e) : undefined); + } else { + obj.metrics = []; + } + obj.next_page_token = message.nextPageToken; + return obj; + }, + fromAmino(object: ListConsumerQuotaMetricsResponseAmino): ListConsumerQuotaMetricsResponse { + const message = createBaseListConsumerQuotaMetricsResponse(); + message.metrics = object.metrics?.map(e => ConsumerQuotaMetric.fromAmino(e)) || []; + if (object.next_page_token !== undefined && object.next_page_token !== null) { + message.nextPageToken = object.next_page_token; + } + return message; + }, + toAmino(message: ListConsumerQuotaMetricsResponse): ListConsumerQuotaMetricsResponseAmino { + const obj: any = {}; + if (message.metrics) { + obj.metrics = message.metrics.map(e => e ? ConsumerQuotaMetric.toAmino(e) : undefined); + } else { + obj.metrics = message.metrics; + } + obj.next_page_token = message.nextPageToken === "" ? undefined : message.nextPageToken; + return obj; + }, + fromAminoMsg(object: ListConsumerQuotaMetricsResponseAminoMsg): ListConsumerQuotaMetricsResponse { + return ListConsumerQuotaMetricsResponse.fromAmino(object.value); + }, + fromProtoMsg(message: ListConsumerQuotaMetricsResponseProtoMsg): ListConsumerQuotaMetricsResponse { + return ListConsumerQuotaMetricsResponse.decode(message.value); + }, + toProto(message: ListConsumerQuotaMetricsResponse): Uint8Array { + return ListConsumerQuotaMetricsResponse.encode(message).finish(); + }, + toProtoMsg(message: ListConsumerQuotaMetricsResponse): ListConsumerQuotaMetricsResponseProtoMsg { + return { + typeUrl: "/google.api.serviceusage.v1beta1.ListConsumerQuotaMetricsResponse", + value: ListConsumerQuotaMetricsResponse.encode(message).finish() + }; + } +}; +function createBaseGetConsumerQuotaMetricRequest(): GetConsumerQuotaMetricRequest { + return { + name: "", + view: 0 + }; +} +export const GetConsumerQuotaMetricRequest = { + typeUrl: "/google.api.serviceusage.v1beta1.GetConsumerQuotaMetricRequest", + encode(message: GetConsumerQuotaMetricRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + if (message.view !== 0) { + writer.uint32(16).int32(message.view); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GetConsumerQuotaMetricRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGetConsumerQuotaMetricRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.view = (reader.int32() as any); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GetConsumerQuotaMetricRequest { + const obj = createBaseGetConsumerQuotaMetricRequest(); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.view)) obj.view = quotaViewFromJSON(object.view); + return obj; + }, + toJSON(message: GetConsumerQuotaMetricRequest): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.view !== undefined && (obj.view = quotaViewToJSON(message.view)); + return obj; + }, + fromPartial(object: DeepPartial): GetConsumerQuotaMetricRequest { + const message = createBaseGetConsumerQuotaMetricRequest(); + message.name = object.name ?? ""; + message.view = object.view ?? 0; + return message; + }, + fromSDK(object: GetConsumerQuotaMetricRequestSDKType): GetConsumerQuotaMetricRequest { + return { + name: object?.name, + view: isSet(object.view) ? quotaViewFromJSON(object.view) : -1 + }; + }, + fromSDKJSON(object: any): GetConsumerQuotaMetricRequestSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + view: isSet(object.view) ? quotaViewFromJSON(object.view) : -1 + }; + }, + toSDK(message: GetConsumerQuotaMetricRequest): GetConsumerQuotaMetricRequestSDKType { + const obj: any = {}; + obj.name = message.name; + message.view !== undefined && (obj.view = quotaViewToJSON(message.view)); + return obj; + }, + fromAmino(object: GetConsumerQuotaMetricRequestAmino): GetConsumerQuotaMetricRequest { + const message = createBaseGetConsumerQuotaMetricRequest(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + if (object.view !== undefined && object.view !== null) { + message.view = object.view; + } + return message; + }, + toAmino(message: GetConsumerQuotaMetricRequest): GetConsumerQuotaMetricRequestAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + obj.view = message.view === 0 ? undefined : message.view; + return obj; + }, + fromAminoMsg(object: GetConsumerQuotaMetricRequestAminoMsg): GetConsumerQuotaMetricRequest { + return GetConsumerQuotaMetricRequest.fromAmino(object.value); + }, + fromProtoMsg(message: GetConsumerQuotaMetricRequestProtoMsg): GetConsumerQuotaMetricRequest { + return GetConsumerQuotaMetricRequest.decode(message.value); + }, + toProto(message: GetConsumerQuotaMetricRequest): Uint8Array { + return GetConsumerQuotaMetricRequest.encode(message).finish(); + }, + toProtoMsg(message: GetConsumerQuotaMetricRequest): GetConsumerQuotaMetricRequestProtoMsg { + return { + typeUrl: "/google.api.serviceusage.v1beta1.GetConsumerQuotaMetricRequest", + value: GetConsumerQuotaMetricRequest.encode(message).finish() + }; + } +}; +function createBaseGetConsumerQuotaLimitRequest(): GetConsumerQuotaLimitRequest { + return { + name: "", + view: 0 + }; +} +export const GetConsumerQuotaLimitRequest = { + typeUrl: "/google.api.serviceusage.v1beta1.GetConsumerQuotaLimitRequest", + encode(message: GetConsumerQuotaLimitRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + if (message.view !== 0) { + writer.uint32(16).int32(message.view); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GetConsumerQuotaLimitRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGetConsumerQuotaLimitRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.view = (reader.int32() as any); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GetConsumerQuotaLimitRequest { + const obj = createBaseGetConsumerQuotaLimitRequest(); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.view)) obj.view = quotaViewFromJSON(object.view); + return obj; + }, + toJSON(message: GetConsumerQuotaLimitRequest): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.view !== undefined && (obj.view = quotaViewToJSON(message.view)); + return obj; + }, + fromPartial(object: DeepPartial): GetConsumerQuotaLimitRequest { + const message = createBaseGetConsumerQuotaLimitRequest(); + message.name = object.name ?? ""; + message.view = object.view ?? 0; + return message; + }, + fromSDK(object: GetConsumerQuotaLimitRequestSDKType): GetConsumerQuotaLimitRequest { + return { + name: object?.name, + view: isSet(object.view) ? quotaViewFromJSON(object.view) : -1 + }; + }, + fromSDKJSON(object: any): GetConsumerQuotaLimitRequestSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + view: isSet(object.view) ? quotaViewFromJSON(object.view) : -1 + }; + }, + toSDK(message: GetConsumerQuotaLimitRequest): GetConsumerQuotaLimitRequestSDKType { + const obj: any = {}; + obj.name = message.name; + message.view !== undefined && (obj.view = quotaViewToJSON(message.view)); + return obj; + }, + fromAmino(object: GetConsumerQuotaLimitRequestAmino): GetConsumerQuotaLimitRequest { + const message = createBaseGetConsumerQuotaLimitRequest(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + if (object.view !== undefined && object.view !== null) { + message.view = object.view; + } + return message; + }, + toAmino(message: GetConsumerQuotaLimitRequest): GetConsumerQuotaLimitRequestAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + obj.view = message.view === 0 ? undefined : message.view; + return obj; + }, + fromAminoMsg(object: GetConsumerQuotaLimitRequestAminoMsg): GetConsumerQuotaLimitRequest { + return GetConsumerQuotaLimitRequest.fromAmino(object.value); + }, + fromProtoMsg(message: GetConsumerQuotaLimitRequestProtoMsg): GetConsumerQuotaLimitRequest { + return GetConsumerQuotaLimitRequest.decode(message.value); + }, + toProto(message: GetConsumerQuotaLimitRequest): Uint8Array { + return GetConsumerQuotaLimitRequest.encode(message).finish(); + }, + toProtoMsg(message: GetConsumerQuotaLimitRequest): GetConsumerQuotaLimitRequestProtoMsg { + return { + typeUrl: "/google.api.serviceusage.v1beta1.GetConsumerQuotaLimitRequest", + value: GetConsumerQuotaLimitRequest.encode(message).finish() + }; + } +}; +function createBaseCreateAdminOverrideRequest(): CreateAdminOverrideRequest { + return { + parent: "", + override: undefined, + force: false, + forceOnly: [] + }; +} +export const CreateAdminOverrideRequest = { + typeUrl: "/google.api.serviceusage.v1beta1.CreateAdminOverrideRequest", + encode(message: CreateAdminOverrideRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.parent !== undefined) { + writer.uint32(10).string(message.parent); + } + if (message.override !== undefined) { + QuotaOverride.encode(message.override, writer.uint32(18).fork()).ldelim(); + } + if (message.force !== undefined) { + writer.uint32(24).bool(message.force); + } + writer.uint32(34).fork(); + for (const v of message.forceOnly) { + writer.int32(v); + } + writer.ldelim(); + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): CreateAdminOverrideRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCreateAdminOverrideRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.parent = reader.string(); + break; + case 2: + message.override = QuotaOverride.decode(reader, reader.uint32()); + break; + case 3: + message.force = reader.bool(); + break; + case 4: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.forceOnly.push((reader.int32() as any)); + } + } else { + message.forceOnly.push((reader.int32() as any)); + } + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): CreateAdminOverrideRequest { + const obj = createBaseCreateAdminOverrideRequest(); + if (isSet(object.parent)) obj.parent = String(object.parent); + if (isSet(object.override)) obj.override = QuotaOverride.fromJSON(object.override); + if (isSet(object.force)) obj.force = Boolean(object.force); + if (Array.isArray(object?.forceOnly)) obj.forceOnly = object.forceOnly.map((e: any) => quotaSafetyCheckFromJSON(e)); + return obj; + }, + toJSON(message: CreateAdminOverrideRequest): JsonSafe { + const obj: any = {}; + message.parent !== undefined && (obj.parent = message.parent); + message.override !== undefined && (obj.override = message.override ? QuotaOverride.toJSON(message.override) : undefined); + message.force !== undefined && (obj.force = message.force); + if (message.forceOnly) { + obj.forceOnly = message.forceOnly.map(e => quotaSafetyCheckToJSON(e)); + } else { + obj.forceOnly = []; + } + return obj; + }, + fromPartial(object: DeepPartial): CreateAdminOverrideRequest { + const message = createBaseCreateAdminOverrideRequest(); + message.parent = object.parent ?? ""; + if (object.override !== undefined && object.override !== null) { + message.override = QuotaOverride.fromPartial(object.override); + } + message.force = object.force ?? false; + message.forceOnly = object.forceOnly?.map(e => e) || []; + return message; + }, + fromSDK(object: CreateAdminOverrideRequestSDKType): CreateAdminOverrideRequest { + return { + parent: object?.parent, + override: object.override ? QuotaOverride.fromSDK(object.override) : undefined, + force: object?.force, + forceOnly: Array.isArray(object?.force_only) ? object.force_only.map((e: any) => quotaSafetyCheckFromJSON(e)) : [] + }; + }, + fromSDKJSON(object: any): CreateAdminOverrideRequestSDKType { + return { + parent: isSet(object.parent) ? String(object.parent) : "", + override: isSet(object.override) ? QuotaOverride.fromSDKJSON(object.override) : undefined, + force: isSet(object.force) ? Boolean(object.force) : false, + force_only: Array.isArray(object?.force_only) ? object.force_only.map((e: any) => quotaSafetyCheckFromJSON(e)) : [] + }; + }, + toSDK(message: CreateAdminOverrideRequest): CreateAdminOverrideRequestSDKType { + const obj: any = {}; + obj.parent = message.parent; + message.override !== undefined && (obj.override = message.override ? QuotaOverride.toSDK(message.override) : undefined); + obj.force = message.force; + if (message.forceOnly) { + obj.force_only = message.forceOnly.map(e => quotaSafetyCheckToJSON(e)); + } else { + obj.force_only = []; + } + return obj; + }, + fromAmino(object: CreateAdminOverrideRequestAmino): CreateAdminOverrideRequest { + const message = createBaseCreateAdminOverrideRequest(); + if (object.parent !== undefined && object.parent !== null) { + message.parent = object.parent; + } + if (object.override !== undefined && object.override !== null) { + message.override = QuotaOverride.fromAmino(object.override); + } + if (object.force !== undefined && object.force !== null) { + message.force = object.force; + } + message.forceOnly = object.force_only?.map(e => e) || []; + return message; + }, + toAmino(message: CreateAdminOverrideRequest): CreateAdminOverrideRequestAmino { + const obj: any = {}; + obj.parent = message.parent === "" ? undefined : message.parent; + obj.override = message.override ? QuotaOverride.toAmino(message.override) : undefined; + obj.force = message.force === false ? undefined : message.force; + if (message.forceOnly) { + obj.force_only = message.forceOnly.map(e => e); + } else { + obj.force_only = message.forceOnly; + } + return obj; + }, + fromAminoMsg(object: CreateAdminOverrideRequestAminoMsg): CreateAdminOverrideRequest { + return CreateAdminOverrideRequest.fromAmino(object.value); + }, + fromProtoMsg(message: CreateAdminOverrideRequestProtoMsg): CreateAdminOverrideRequest { + return CreateAdminOverrideRequest.decode(message.value); + }, + toProto(message: CreateAdminOverrideRequest): Uint8Array { + return CreateAdminOverrideRequest.encode(message).finish(); + }, + toProtoMsg(message: CreateAdminOverrideRequest): CreateAdminOverrideRequestProtoMsg { + return { + typeUrl: "/google.api.serviceusage.v1beta1.CreateAdminOverrideRequest", + value: CreateAdminOverrideRequest.encode(message).finish() + }; + } +}; +function createBaseUpdateAdminOverrideRequest(): UpdateAdminOverrideRequest { + return { + name: "", + override: undefined, + force: false, + updateMask: undefined, + forceOnly: [] + }; +} +export const UpdateAdminOverrideRequest = { + typeUrl: "/google.api.serviceusage.v1beta1.UpdateAdminOverrideRequest", + encode(message: UpdateAdminOverrideRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + if (message.override !== undefined) { + QuotaOverride.encode(message.override, writer.uint32(18).fork()).ldelim(); + } + if (message.force !== undefined) { + writer.uint32(24).bool(message.force); + } + if (message.updateMask !== undefined) { + FieldMask.encode(message.updateMask, writer.uint32(34).fork()).ldelim(); + } + writer.uint32(42).fork(); + for (const v of message.forceOnly) { + writer.int32(v); + } + writer.ldelim(); + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): UpdateAdminOverrideRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseUpdateAdminOverrideRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.override = QuotaOverride.decode(reader, reader.uint32()); + break; + case 3: + message.force = reader.bool(); + break; + case 4: + message.updateMask = FieldMask.decode(reader, reader.uint32()); + break; + case 5: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.forceOnly.push((reader.int32() as any)); + } + } else { + message.forceOnly.push((reader.int32() as any)); + } + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): UpdateAdminOverrideRequest { + const obj = createBaseUpdateAdminOverrideRequest(); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.override)) obj.override = QuotaOverride.fromJSON(object.override); + if (isSet(object.force)) obj.force = Boolean(object.force); + if (isSet(object.updateMask)) obj.updateMask = FieldMask.fromJSON(object.updateMask); + if (Array.isArray(object?.forceOnly)) obj.forceOnly = object.forceOnly.map((e: any) => quotaSafetyCheckFromJSON(e)); + return obj; + }, + toJSON(message: UpdateAdminOverrideRequest): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.override !== undefined && (obj.override = message.override ? QuotaOverride.toJSON(message.override) : undefined); + message.force !== undefined && (obj.force = message.force); + message.updateMask !== undefined && (obj.updateMask = message.updateMask ? FieldMask.toJSON(message.updateMask) : undefined); + if (message.forceOnly) { + obj.forceOnly = message.forceOnly.map(e => quotaSafetyCheckToJSON(e)); + } else { + obj.forceOnly = []; + } + return obj; + }, + fromPartial(object: DeepPartial): UpdateAdminOverrideRequest { + const message = createBaseUpdateAdminOverrideRequest(); + message.name = object.name ?? ""; + if (object.override !== undefined && object.override !== null) { + message.override = QuotaOverride.fromPartial(object.override); + } + message.force = object.force ?? false; + if (object.updateMask !== undefined && object.updateMask !== null) { + message.updateMask = FieldMask.fromPartial(object.updateMask); + } + message.forceOnly = object.forceOnly?.map(e => e) || []; + return message; + }, + fromSDK(object: UpdateAdminOverrideRequestSDKType): UpdateAdminOverrideRequest { + return { + name: object?.name, + override: object.override ? QuotaOverride.fromSDK(object.override) : undefined, + force: object?.force, + updateMask: object.update_mask ? FieldMask.fromSDK(object.update_mask) : undefined, + forceOnly: Array.isArray(object?.force_only) ? object.force_only.map((e: any) => quotaSafetyCheckFromJSON(e)) : [] + }; + }, + fromSDKJSON(object: any): UpdateAdminOverrideRequestSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + override: isSet(object.override) ? QuotaOverride.fromSDKJSON(object.override) : undefined, + force: isSet(object.force) ? Boolean(object.force) : false, + update_mask: isSet(object.update_mask) ? FieldMask.fromSDKJSON(object.update_mask) : undefined, + force_only: Array.isArray(object?.force_only) ? object.force_only.map((e: any) => quotaSafetyCheckFromJSON(e)) : [] + }; + }, + toSDK(message: UpdateAdminOverrideRequest): UpdateAdminOverrideRequestSDKType { + const obj: any = {}; + obj.name = message.name; + message.override !== undefined && (obj.override = message.override ? QuotaOverride.toSDK(message.override) : undefined); + obj.force = message.force; + message.updateMask !== undefined && (obj.update_mask = message.updateMask ? FieldMask.toSDK(message.updateMask) : undefined); + if (message.forceOnly) { + obj.force_only = message.forceOnly.map(e => quotaSafetyCheckToJSON(e)); + } else { + obj.force_only = []; + } + return obj; + }, + fromAmino(object: UpdateAdminOverrideRequestAmino): UpdateAdminOverrideRequest { + const message = createBaseUpdateAdminOverrideRequest(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + if (object.override !== undefined && object.override !== null) { + message.override = QuotaOverride.fromAmino(object.override); + } + if (object.force !== undefined && object.force !== null) { + message.force = object.force; + } + if (object.update_mask !== undefined && object.update_mask !== null) { + message.updateMask = FieldMask.fromAmino(object.update_mask); + } + message.forceOnly = object.force_only?.map(e => e) || []; + return message; + }, + toAmino(message: UpdateAdminOverrideRequest): UpdateAdminOverrideRequestAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + obj.override = message.override ? QuotaOverride.toAmino(message.override) : undefined; + obj.force = message.force === false ? undefined : message.force; + obj.update_mask = message.updateMask ? FieldMask.toAmino(message.updateMask) : undefined; + if (message.forceOnly) { + obj.force_only = message.forceOnly.map(e => e); + } else { + obj.force_only = message.forceOnly; + } + return obj; + }, + fromAminoMsg(object: UpdateAdminOverrideRequestAminoMsg): UpdateAdminOverrideRequest { + return UpdateAdminOverrideRequest.fromAmino(object.value); + }, + fromProtoMsg(message: UpdateAdminOverrideRequestProtoMsg): UpdateAdminOverrideRequest { + return UpdateAdminOverrideRequest.decode(message.value); + }, + toProto(message: UpdateAdminOverrideRequest): Uint8Array { + return UpdateAdminOverrideRequest.encode(message).finish(); + }, + toProtoMsg(message: UpdateAdminOverrideRequest): UpdateAdminOverrideRequestProtoMsg { + return { + typeUrl: "/google.api.serviceusage.v1beta1.UpdateAdminOverrideRequest", + value: UpdateAdminOverrideRequest.encode(message).finish() + }; + } +}; +function createBaseDeleteAdminOverrideRequest(): DeleteAdminOverrideRequest { + return { + name: "", + force: false, + forceOnly: [] + }; +} +export const DeleteAdminOverrideRequest = { + typeUrl: "/google.api.serviceusage.v1beta1.DeleteAdminOverrideRequest", + encode(message: DeleteAdminOverrideRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + if (message.force !== undefined) { + writer.uint32(16).bool(message.force); + } + writer.uint32(26).fork(); + for (const v of message.forceOnly) { + writer.int32(v); + } + writer.ldelim(); + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): DeleteAdminOverrideRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDeleteAdminOverrideRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.force = reader.bool(); + break; + case 3: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.forceOnly.push((reader.int32() as any)); + } + } else { + message.forceOnly.push((reader.int32() as any)); + } + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): DeleteAdminOverrideRequest { + const obj = createBaseDeleteAdminOverrideRequest(); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.force)) obj.force = Boolean(object.force); + if (Array.isArray(object?.forceOnly)) obj.forceOnly = object.forceOnly.map((e: any) => quotaSafetyCheckFromJSON(e)); + return obj; + }, + toJSON(message: DeleteAdminOverrideRequest): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.force !== undefined && (obj.force = message.force); + if (message.forceOnly) { + obj.forceOnly = message.forceOnly.map(e => quotaSafetyCheckToJSON(e)); + } else { + obj.forceOnly = []; + } + return obj; + }, + fromPartial(object: DeepPartial): DeleteAdminOverrideRequest { + const message = createBaseDeleteAdminOverrideRequest(); + message.name = object.name ?? ""; + message.force = object.force ?? false; + message.forceOnly = object.forceOnly?.map(e => e) || []; + return message; + }, + fromSDK(object: DeleteAdminOverrideRequestSDKType): DeleteAdminOverrideRequest { + return { + name: object?.name, + force: object?.force, + forceOnly: Array.isArray(object?.force_only) ? object.force_only.map((e: any) => quotaSafetyCheckFromJSON(e)) : [] + }; + }, + fromSDKJSON(object: any): DeleteAdminOverrideRequestSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + force: isSet(object.force) ? Boolean(object.force) : false, + force_only: Array.isArray(object?.force_only) ? object.force_only.map((e: any) => quotaSafetyCheckFromJSON(e)) : [] + }; + }, + toSDK(message: DeleteAdminOverrideRequest): DeleteAdminOverrideRequestSDKType { + const obj: any = {}; + obj.name = message.name; + obj.force = message.force; + if (message.forceOnly) { + obj.force_only = message.forceOnly.map(e => quotaSafetyCheckToJSON(e)); + } else { + obj.force_only = []; + } + return obj; + }, + fromAmino(object: DeleteAdminOverrideRequestAmino): DeleteAdminOverrideRequest { + const message = createBaseDeleteAdminOverrideRequest(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + if (object.force !== undefined && object.force !== null) { + message.force = object.force; + } + message.forceOnly = object.force_only?.map(e => e) || []; + return message; + }, + toAmino(message: DeleteAdminOverrideRequest): DeleteAdminOverrideRequestAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + obj.force = message.force === false ? undefined : message.force; + if (message.forceOnly) { + obj.force_only = message.forceOnly.map(e => e); + } else { + obj.force_only = message.forceOnly; + } + return obj; + }, + fromAminoMsg(object: DeleteAdminOverrideRequestAminoMsg): DeleteAdminOverrideRequest { + return DeleteAdminOverrideRequest.fromAmino(object.value); + }, + fromProtoMsg(message: DeleteAdminOverrideRequestProtoMsg): DeleteAdminOverrideRequest { + return DeleteAdminOverrideRequest.decode(message.value); + }, + toProto(message: DeleteAdminOverrideRequest): Uint8Array { + return DeleteAdminOverrideRequest.encode(message).finish(); + }, + toProtoMsg(message: DeleteAdminOverrideRequest): DeleteAdminOverrideRequestProtoMsg { + return { + typeUrl: "/google.api.serviceusage.v1beta1.DeleteAdminOverrideRequest", + value: DeleteAdminOverrideRequest.encode(message).finish() + }; + } +}; +function createBaseListAdminOverridesRequest(): ListAdminOverridesRequest { + return { + parent: "", + pageSize: 0, + pageToken: "" + }; +} +export const ListAdminOverridesRequest = { + typeUrl: "/google.api.serviceusage.v1beta1.ListAdminOverridesRequest", + encode(message: ListAdminOverridesRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.parent !== undefined) { + writer.uint32(10).string(message.parent); + } + if (message.pageSize !== undefined) { + writer.uint32(16).int32(message.pageSize); + } + if (message.pageToken !== undefined) { + writer.uint32(26).string(message.pageToken); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ListAdminOverridesRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseListAdminOverridesRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.parent = reader.string(); + break; + case 2: + message.pageSize = reader.int32(); + break; + case 3: + message.pageToken = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ListAdminOverridesRequest { + const obj = createBaseListAdminOverridesRequest(); + if (isSet(object.parent)) obj.parent = String(object.parent); + if (isSet(object.pageSize)) obj.pageSize = Number(object.pageSize); + if (isSet(object.pageToken)) obj.pageToken = String(object.pageToken); + return obj; + }, + toJSON(message: ListAdminOverridesRequest): JsonSafe { + const obj: any = {}; + message.parent !== undefined && (obj.parent = message.parent); + message.pageSize !== undefined && (obj.pageSize = Math.round(message.pageSize)); + message.pageToken !== undefined && (obj.pageToken = message.pageToken); + return obj; + }, + fromPartial(object: DeepPartial): ListAdminOverridesRequest { + const message = createBaseListAdminOverridesRequest(); + message.parent = object.parent ?? ""; + message.pageSize = object.pageSize ?? 0; + message.pageToken = object.pageToken ?? ""; + return message; + }, + fromSDK(object: ListAdminOverridesRequestSDKType): ListAdminOverridesRequest { + return { + parent: object?.parent, + pageSize: object?.page_size, + pageToken: object?.page_token + }; + }, + fromSDKJSON(object: any): ListAdminOverridesRequestSDKType { + return { + parent: isSet(object.parent) ? String(object.parent) : "", + page_size: isSet(object.page_size) ? Number(object.page_size) : 0, + page_token: isSet(object.page_token) ? String(object.page_token) : "" + }; + }, + toSDK(message: ListAdminOverridesRequest): ListAdminOverridesRequestSDKType { + const obj: any = {}; + obj.parent = message.parent; + obj.page_size = message.pageSize; + obj.page_token = message.pageToken; + return obj; + }, + fromAmino(object: ListAdminOverridesRequestAmino): ListAdminOverridesRequest { + const message = createBaseListAdminOverridesRequest(); + if (object.parent !== undefined && object.parent !== null) { + message.parent = object.parent; + } + if (object.page_size !== undefined && object.page_size !== null) { + message.pageSize = object.page_size; + } + if (object.page_token !== undefined && object.page_token !== null) { + message.pageToken = object.page_token; + } + return message; + }, + toAmino(message: ListAdminOverridesRequest): ListAdminOverridesRequestAmino { + const obj: any = {}; + obj.parent = message.parent === "" ? undefined : message.parent; + obj.page_size = message.pageSize === 0 ? undefined : message.pageSize; + obj.page_token = message.pageToken === "" ? undefined : message.pageToken; + return obj; + }, + fromAminoMsg(object: ListAdminOverridesRequestAminoMsg): ListAdminOverridesRequest { + return ListAdminOverridesRequest.fromAmino(object.value); + }, + fromProtoMsg(message: ListAdminOverridesRequestProtoMsg): ListAdminOverridesRequest { + return ListAdminOverridesRequest.decode(message.value); + }, + toProto(message: ListAdminOverridesRequest): Uint8Array { + return ListAdminOverridesRequest.encode(message).finish(); + }, + toProtoMsg(message: ListAdminOverridesRequest): ListAdminOverridesRequestProtoMsg { + return { + typeUrl: "/google.api.serviceusage.v1beta1.ListAdminOverridesRequest", + value: ListAdminOverridesRequest.encode(message).finish() + }; + } +}; +function createBaseListAdminOverridesResponse(): ListAdminOverridesResponse { + return { + overrides: [], + nextPageToken: "" + }; +} +export const ListAdminOverridesResponse = { + typeUrl: "/google.api.serviceusage.v1beta1.ListAdminOverridesResponse", + encode(message: ListAdminOverridesResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.overrides) { + QuotaOverride.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.nextPageToken !== undefined) { + writer.uint32(18).string(message.nextPageToken); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ListAdminOverridesResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseListAdminOverridesResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.overrides.push(QuotaOverride.decode(reader, reader.uint32())); + break; + case 2: + message.nextPageToken = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ListAdminOverridesResponse { + const obj = createBaseListAdminOverridesResponse(); + if (Array.isArray(object?.overrides)) obj.overrides = object.overrides.map((e: any) => QuotaOverride.fromJSON(e)); + if (isSet(object.nextPageToken)) obj.nextPageToken = String(object.nextPageToken); + return obj; + }, + toJSON(message: ListAdminOverridesResponse): JsonSafe { + const obj: any = {}; + if (message.overrides) { + obj.overrides = message.overrides.map(e => e ? QuotaOverride.toJSON(e) : undefined); + } else { + obj.overrides = []; + } + message.nextPageToken !== undefined && (obj.nextPageToken = message.nextPageToken); + return obj; + }, + fromPartial(object: DeepPartial): ListAdminOverridesResponse { + const message = createBaseListAdminOverridesResponse(); + message.overrides = object.overrides?.map(e => QuotaOverride.fromPartial(e)) || []; + message.nextPageToken = object.nextPageToken ?? ""; + return message; + }, + fromSDK(object: ListAdminOverridesResponseSDKType): ListAdminOverridesResponse { + return { + overrides: Array.isArray(object?.overrides) ? object.overrides.map((e: any) => QuotaOverride.fromSDK(e)) : [], + nextPageToken: object?.next_page_token + }; + }, + fromSDKJSON(object: any): ListAdminOverridesResponseSDKType { + return { + overrides: Array.isArray(object?.overrides) ? object.overrides.map((e: any) => QuotaOverride.fromSDKJSON(e)) : [], + next_page_token: isSet(object.next_page_token) ? String(object.next_page_token) : "" + }; + }, + toSDK(message: ListAdminOverridesResponse): ListAdminOverridesResponseSDKType { + const obj: any = {}; + if (message.overrides) { + obj.overrides = message.overrides.map(e => e ? QuotaOverride.toSDK(e) : undefined); + } else { + obj.overrides = []; + } + obj.next_page_token = message.nextPageToken; + return obj; + }, + fromAmino(object: ListAdminOverridesResponseAmino): ListAdminOverridesResponse { + const message = createBaseListAdminOverridesResponse(); + message.overrides = object.overrides?.map(e => QuotaOverride.fromAmino(e)) || []; + if (object.next_page_token !== undefined && object.next_page_token !== null) { + message.nextPageToken = object.next_page_token; + } + return message; + }, + toAmino(message: ListAdminOverridesResponse): ListAdminOverridesResponseAmino { + const obj: any = {}; + if (message.overrides) { + obj.overrides = message.overrides.map(e => e ? QuotaOverride.toAmino(e) : undefined); + } else { + obj.overrides = message.overrides; + } + obj.next_page_token = message.nextPageToken === "" ? undefined : message.nextPageToken; + return obj; + }, + fromAminoMsg(object: ListAdminOverridesResponseAminoMsg): ListAdminOverridesResponse { + return ListAdminOverridesResponse.fromAmino(object.value); + }, + fromProtoMsg(message: ListAdminOverridesResponseProtoMsg): ListAdminOverridesResponse { + return ListAdminOverridesResponse.decode(message.value); + }, + toProto(message: ListAdminOverridesResponse): Uint8Array { + return ListAdminOverridesResponse.encode(message).finish(); + }, + toProtoMsg(message: ListAdminOverridesResponse): ListAdminOverridesResponseProtoMsg { + return { + typeUrl: "/google.api.serviceusage.v1beta1.ListAdminOverridesResponse", + value: ListAdminOverridesResponse.encode(message).finish() + }; + } +}; +function createBaseBatchCreateAdminOverridesResponse(): BatchCreateAdminOverridesResponse { + return { + overrides: [] + }; +} +export const BatchCreateAdminOverridesResponse = { + typeUrl: "/google.api.serviceusage.v1beta1.BatchCreateAdminOverridesResponse", + encode(message: BatchCreateAdminOverridesResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.overrides) { + QuotaOverride.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): BatchCreateAdminOverridesResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseBatchCreateAdminOverridesResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.overrides.push(QuotaOverride.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): BatchCreateAdminOverridesResponse { + const obj = createBaseBatchCreateAdminOverridesResponse(); + if (Array.isArray(object?.overrides)) obj.overrides = object.overrides.map((e: any) => QuotaOverride.fromJSON(e)); + return obj; + }, + toJSON(message: BatchCreateAdminOverridesResponse): JsonSafe { + const obj: any = {}; + if (message.overrides) { + obj.overrides = message.overrides.map(e => e ? QuotaOverride.toJSON(e) : undefined); + } else { + obj.overrides = []; + } + return obj; + }, + fromPartial(object: DeepPartial): BatchCreateAdminOverridesResponse { + const message = createBaseBatchCreateAdminOverridesResponse(); + message.overrides = object.overrides?.map(e => QuotaOverride.fromPartial(e)) || []; + return message; + }, + fromSDK(object: BatchCreateAdminOverridesResponseSDKType): BatchCreateAdminOverridesResponse { + return { + overrides: Array.isArray(object?.overrides) ? object.overrides.map((e: any) => QuotaOverride.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): BatchCreateAdminOverridesResponseSDKType { + return { + overrides: Array.isArray(object?.overrides) ? object.overrides.map((e: any) => QuotaOverride.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: BatchCreateAdminOverridesResponse): BatchCreateAdminOverridesResponseSDKType { + const obj: any = {}; + if (message.overrides) { + obj.overrides = message.overrides.map(e => e ? QuotaOverride.toSDK(e) : undefined); + } else { + obj.overrides = []; + } + return obj; + }, + fromAmino(object: BatchCreateAdminOverridesResponseAmino): BatchCreateAdminOverridesResponse { + const message = createBaseBatchCreateAdminOverridesResponse(); + message.overrides = object.overrides?.map(e => QuotaOverride.fromAmino(e)) || []; + return message; + }, + toAmino(message: BatchCreateAdminOverridesResponse): BatchCreateAdminOverridesResponseAmino { + const obj: any = {}; + if (message.overrides) { + obj.overrides = message.overrides.map(e => e ? QuotaOverride.toAmino(e) : undefined); + } else { + obj.overrides = message.overrides; + } + return obj; + }, + fromAminoMsg(object: BatchCreateAdminOverridesResponseAminoMsg): BatchCreateAdminOverridesResponse { + return BatchCreateAdminOverridesResponse.fromAmino(object.value); + }, + fromProtoMsg(message: BatchCreateAdminOverridesResponseProtoMsg): BatchCreateAdminOverridesResponse { + return BatchCreateAdminOverridesResponse.decode(message.value); + }, + toProto(message: BatchCreateAdminOverridesResponse): Uint8Array { + return BatchCreateAdminOverridesResponse.encode(message).finish(); + }, + toProtoMsg(message: BatchCreateAdminOverridesResponse): BatchCreateAdminOverridesResponseProtoMsg { + return { + typeUrl: "/google.api.serviceusage.v1beta1.BatchCreateAdminOverridesResponse", + value: BatchCreateAdminOverridesResponse.encode(message).finish() + }; + } +}; +function createBaseImportAdminOverridesRequest(): ImportAdminOverridesRequest { + return { + parent: "", + inlineSource: undefined, + force: false, + forceOnly: [] + }; +} +export const ImportAdminOverridesRequest = { + typeUrl: "/google.api.serviceusage.v1beta1.ImportAdminOverridesRequest", + encode(message: ImportAdminOverridesRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.parent !== undefined) { + writer.uint32(10).string(message.parent); + } + if (message.inlineSource !== undefined) { + OverrideInlineSource.encode(message.inlineSource, writer.uint32(18).fork()).ldelim(); + } + if (message.force !== undefined) { + writer.uint32(24).bool(message.force); + } + writer.uint32(34).fork(); + for (const v of message.forceOnly) { + writer.int32(v); + } + writer.ldelim(); + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ImportAdminOverridesRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseImportAdminOverridesRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.parent = reader.string(); + break; + case 2: + message.inlineSource = OverrideInlineSource.decode(reader, reader.uint32()); + break; + case 3: + message.force = reader.bool(); + break; + case 4: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.forceOnly.push((reader.int32() as any)); + } + } else { + message.forceOnly.push((reader.int32() as any)); + } + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ImportAdminOverridesRequest { + const obj = createBaseImportAdminOverridesRequest(); + if (isSet(object.parent)) obj.parent = String(object.parent); + if (isSet(object.inlineSource)) obj.inlineSource = OverrideInlineSource.fromJSON(object.inlineSource); + if (isSet(object.force)) obj.force = Boolean(object.force); + if (Array.isArray(object?.forceOnly)) obj.forceOnly = object.forceOnly.map((e: any) => quotaSafetyCheckFromJSON(e)); + return obj; + }, + toJSON(message: ImportAdminOverridesRequest): JsonSafe { + const obj: any = {}; + message.parent !== undefined && (obj.parent = message.parent); + message.inlineSource !== undefined && (obj.inlineSource = message.inlineSource ? OverrideInlineSource.toJSON(message.inlineSource) : undefined); + message.force !== undefined && (obj.force = message.force); + if (message.forceOnly) { + obj.forceOnly = message.forceOnly.map(e => quotaSafetyCheckToJSON(e)); + } else { + obj.forceOnly = []; + } + return obj; + }, + fromPartial(object: DeepPartial): ImportAdminOverridesRequest { + const message = createBaseImportAdminOverridesRequest(); + message.parent = object.parent ?? ""; + if (object.inlineSource !== undefined && object.inlineSource !== null) { + message.inlineSource = OverrideInlineSource.fromPartial(object.inlineSource); + } + message.force = object.force ?? false; + message.forceOnly = object.forceOnly?.map(e => e) || []; + return message; + }, + fromSDK(object: ImportAdminOverridesRequestSDKType): ImportAdminOverridesRequest { + return { + parent: object?.parent, + inlineSource: object.inline_source ? OverrideInlineSource.fromSDK(object.inline_source) : undefined, + force: object?.force, + forceOnly: Array.isArray(object?.force_only) ? object.force_only.map((e: any) => quotaSafetyCheckFromJSON(e)) : [] + }; + }, + fromSDKJSON(object: any): ImportAdminOverridesRequestSDKType { + return { + parent: isSet(object.parent) ? String(object.parent) : "", + inline_source: isSet(object.inline_source) ? OverrideInlineSource.fromSDKJSON(object.inline_source) : undefined, + force: isSet(object.force) ? Boolean(object.force) : false, + force_only: Array.isArray(object?.force_only) ? object.force_only.map((e: any) => quotaSafetyCheckFromJSON(e)) : [] + }; + }, + toSDK(message: ImportAdminOverridesRequest): ImportAdminOverridesRequestSDKType { + const obj: any = {}; + obj.parent = message.parent; + message.inlineSource !== undefined && (obj.inline_source = message.inlineSource ? OverrideInlineSource.toSDK(message.inlineSource) : undefined); + obj.force = message.force; + if (message.forceOnly) { + obj.force_only = message.forceOnly.map(e => quotaSafetyCheckToJSON(e)); + } else { + obj.force_only = []; + } + return obj; + }, + fromAmino(object: ImportAdminOverridesRequestAmino): ImportAdminOverridesRequest { + const message = createBaseImportAdminOverridesRequest(); + if (object.parent !== undefined && object.parent !== null) { + message.parent = object.parent; + } + if (object.inline_source !== undefined && object.inline_source !== null) { + message.inlineSource = OverrideInlineSource.fromAmino(object.inline_source); + } + if (object.force !== undefined && object.force !== null) { + message.force = object.force; + } + message.forceOnly = object.force_only?.map(e => e) || []; + return message; + }, + toAmino(message: ImportAdminOverridesRequest): ImportAdminOverridesRequestAmino { + const obj: any = {}; + obj.parent = message.parent === "" ? undefined : message.parent; + obj.inline_source = message.inlineSource ? OverrideInlineSource.toAmino(message.inlineSource) : undefined; + obj.force = message.force === false ? undefined : message.force; + if (message.forceOnly) { + obj.force_only = message.forceOnly.map(e => e); + } else { + obj.force_only = message.forceOnly; + } + return obj; + }, + fromAminoMsg(object: ImportAdminOverridesRequestAminoMsg): ImportAdminOverridesRequest { + return ImportAdminOverridesRequest.fromAmino(object.value); + }, + fromProtoMsg(message: ImportAdminOverridesRequestProtoMsg): ImportAdminOverridesRequest { + return ImportAdminOverridesRequest.decode(message.value); + }, + toProto(message: ImportAdminOverridesRequest): Uint8Array { + return ImportAdminOverridesRequest.encode(message).finish(); + }, + toProtoMsg(message: ImportAdminOverridesRequest): ImportAdminOverridesRequestProtoMsg { + return { + typeUrl: "/google.api.serviceusage.v1beta1.ImportAdminOverridesRequest", + value: ImportAdminOverridesRequest.encode(message).finish() + }; + } +}; +function createBaseImportAdminOverridesResponse(): ImportAdminOverridesResponse { + return { + overrides: [] + }; +} +export const ImportAdminOverridesResponse = { + typeUrl: "/google.api.serviceusage.v1beta1.ImportAdminOverridesResponse", + encode(message: ImportAdminOverridesResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.overrides) { + QuotaOverride.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ImportAdminOverridesResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseImportAdminOverridesResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.overrides.push(QuotaOverride.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ImportAdminOverridesResponse { + const obj = createBaseImportAdminOverridesResponse(); + if (Array.isArray(object?.overrides)) obj.overrides = object.overrides.map((e: any) => QuotaOverride.fromJSON(e)); + return obj; + }, + toJSON(message: ImportAdminOverridesResponse): JsonSafe { + const obj: any = {}; + if (message.overrides) { + obj.overrides = message.overrides.map(e => e ? QuotaOverride.toJSON(e) : undefined); + } else { + obj.overrides = []; + } + return obj; + }, + fromPartial(object: DeepPartial): ImportAdminOverridesResponse { + const message = createBaseImportAdminOverridesResponse(); + message.overrides = object.overrides?.map(e => QuotaOverride.fromPartial(e)) || []; + return message; + }, + fromSDK(object: ImportAdminOverridesResponseSDKType): ImportAdminOverridesResponse { + return { + overrides: Array.isArray(object?.overrides) ? object.overrides.map((e: any) => QuotaOverride.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): ImportAdminOverridesResponseSDKType { + return { + overrides: Array.isArray(object?.overrides) ? object.overrides.map((e: any) => QuotaOverride.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: ImportAdminOverridesResponse): ImportAdminOverridesResponseSDKType { + const obj: any = {}; + if (message.overrides) { + obj.overrides = message.overrides.map(e => e ? QuotaOverride.toSDK(e) : undefined); + } else { + obj.overrides = []; + } + return obj; + }, + fromAmino(object: ImportAdminOverridesResponseAmino): ImportAdminOverridesResponse { + const message = createBaseImportAdminOverridesResponse(); + message.overrides = object.overrides?.map(e => QuotaOverride.fromAmino(e)) || []; + return message; + }, + toAmino(message: ImportAdminOverridesResponse): ImportAdminOverridesResponseAmino { + const obj: any = {}; + if (message.overrides) { + obj.overrides = message.overrides.map(e => e ? QuotaOverride.toAmino(e) : undefined); + } else { + obj.overrides = message.overrides; + } + return obj; + }, + fromAminoMsg(object: ImportAdminOverridesResponseAminoMsg): ImportAdminOverridesResponse { + return ImportAdminOverridesResponse.fromAmino(object.value); + }, + fromProtoMsg(message: ImportAdminOverridesResponseProtoMsg): ImportAdminOverridesResponse { + return ImportAdminOverridesResponse.decode(message.value); + }, + toProto(message: ImportAdminOverridesResponse): Uint8Array { + return ImportAdminOverridesResponse.encode(message).finish(); + }, + toProtoMsg(message: ImportAdminOverridesResponse): ImportAdminOverridesResponseProtoMsg { + return { + typeUrl: "/google.api.serviceusage.v1beta1.ImportAdminOverridesResponse", + value: ImportAdminOverridesResponse.encode(message).finish() + }; + } +}; +function createBaseImportAdminOverridesMetadata(): ImportAdminOverridesMetadata { + return {}; +} +export const ImportAdminOverridesMetadata = { + typeUrl: "/google.api.serviceusage.v1beta1.ImportAdminOverridesMetadata", + encode(_: ImportAdminOverridesMetadata, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ImportAdminOverridesMetadata { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseImportAdminOverridesMetadata(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): ImportAdminOverridesMetadata { + const obj = createBaseImportAdminOverridesMetadata(); + return obj; + }, + toJSON(_: ImportAdminOverridesMetadata): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): ImportAdminOverridesMetadata { + const message = createBaseImportAdminOverridesMetadata(); + return message; + }, + fromSDK(_: ImportAdminOverridesMetadataSDKType): ImportAdminOverridesMetadata { + return {}; + }, + fromSDKJSON(_: any): ImportAdminOverridesMetadataSDKType { + return {}; + }, + toSDK(_: ImportAdminOverridesMetadata): ImportAdminOverridesMetadataSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: ImportAdminOverridesMetadataAmino): ImportAdminOverridesMetadata { + const message = createBaseImportAdminOverridesMetadata(); + return message; + }, + toAmino(_: ImportAdminOverridesMetadata): ImportAdminOverridesMetadataAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: ImportAdminOverridesMetadataAminoMsg): ImportAdminOverridesMetadata { + return ImportAdminOverridesMetadata.fromAmino(object.value); + }, + fromProtoMsg(message: ImportAdminOverridesMetadataProtoMsg): ImportAdminOverridesMetadata { + return ImportAdminOverridesMetadata.decode(message.value); + }, + toProto(message: ImportAdminOverridesMetadata): Uint8Array { + return ImportAdminOverridesMetadata.encode(message).finish(); + }, + toProtoMsg(message: ImportAdminOverridesMetadata): ImportAdminOverridesMetadataProtoMsg { + return { + typeUrl: "/google.api.serviceusage.v1beta1.ImportAdminOverridesMetadata", + value: ImportAdminOverridesMetadata.encode(message).finish() + }; + } +}; +function createBaseCreateConsumerOverrideRequest(): CreateConsumerOverrideRequest { + return { + parent: "", + override: undefined, + force: false, + forceOnly: [] + }; +} +export const CreateConsumerOverrideRequest = { + typeUrl: "/google.api.serviceusage.v1beta1.CreateConsumerOverrideRequest", + encode(message: CreateConsumerOverrideRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.parent !== undefined) { + writer.uint32(10).string(message.parent); + } + if (message.override !== undefined) { + QuotaOverride.encode(message.override, writer.uint32(18).fork()).ldelim(); + } + if (message.force !== undefined) { + writer.uint32(24).bool(message.force); + } + writer.uint32(34).fork(); + for (const v of message.forceOnly) { + writer.int32(v); + } + writer.ldelim(); + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): CreateConsumerOverrideRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCreateConsumerOverrideRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.parent = reader.string(); + break; + case 2: + message.override = QuotaOverride.decode(reader, reader.uint32()); + break; + case 3: + message.force = reader.bool(); + break; + case 4: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.forceOnly.push((reader.int32() as any)); + } + } else { + message.forceOnly.push((reader.int32() as any)); + } + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): CreateConsumerOverrideRequest { + const obj = createBaseCreateConsumerOverrideRequest(); + if (isSet(object.parent)) obj.parent = String(object.parent); + if (isSet(object.override)) obj.override = QuotaOverride.fromJSON(object.override); + if (isSet(object.force)) obj.force = Boolean(object.force); + if (Array.isArray(object?.forceOnly)) obj.forceOnly = object.forceOnly.map((e: any) => quotaSafetyCheckFromJSON(e)); + return obj; + }, + toJSON(message: CreateConsumerOverrideRequest): JsonSafe { + const obj: any = {}; + message.parent !== undefined && (obj.parent = message.parent); + message.override !== undefined && (obj.override = message.override ? QuotaOverride.toJSON(message.override) : undefined); + message.force !== undefined && (obj.force = message.force); + if (message.forceOnly) { + obj.forceOnly = message.forceOnly.map(e => quotaSafetyCheckToJSON(e)); + } else { + obj.forceOnly = []; + } + return obj; + }, + fromPartial(object: DeepPartial): CreateConsumerOverrideRequest { + const message = createBaseCreateConsumerOverrideRequest(); + message.parent = object.parent ?? ""; + if (object.override !== undefined && object.override !== null) { + message.override = QuotaOverride.fromPartial(object.override); + } + message.force = object.force ?? false; + message.forceOnly = object.forceOnly?.map(e => e) || []; + return message; + }, + fromSDK(object: CreateConsumerOverrideRequestSDKType): CreateConsumerOverrideRequest { + return { + parent: object?.parent, + override: object.override ? QuotaOverride.fromSDK(object.override) : undefined, + force: object?.force, + forceOnly: Array.isArray(object?.force_only) ? object.force_only.map((e: any) => quotaSafetyCheckFromJSON(e)) : [] + }; + }, + fromSDKJSON(object: any): CreateConsumerOverrideRequestSDKType { + return { + parent: isSet(object.parent) ? String(object.parent) : "", + override: isSet(object.override) ? QuotaOverride.fromSDKJSON(object.override) : undefined, + force: isSet(object.force) ? Boolean(object.force) : false, + force_only: Array.isArray(object?.force_only) ? object.force_only.map((e: any) => quotaSafetyCheckFromJSON(e)) : [] + }; + }, + toSDK(message: CreateConsumerOverrideRequest): CreateConsumerOverrideRequestSDKType { + const obj: any = {}; + obj.parent = message.parent; + message.override !== undefined && (obj.override = message.override ? QuotaOverride.toSDK(message.override) : undefined); + obj.force = message.force; + if (message.forceOnly) { + obj.force_only = message.forceOnly.map(e => quotaSafetyCheckToJSON(e)); + } else { + obj.force_only = []; + } + return obj; + }, + fromAmino(object: CreateConsumerOverrideRequestAmino): CreateConsumerOverrideRequest { + const message = createBaseCreateConsumerOverrideRequest(); + if (object.parent !== undefined && object.parent !== null) { + message.parent = object.parent; + } + if (object.override !== undefined && object.override !== null) { + message.override = QuotaOverride.fromAmino(object.override); + } + if (object.force !== undefined && object.force !== null) { + message.force = object.force; + } + message.forceOnly = object.force_only?.map(e => e) || []; + return message; + }, + toAmino(message: CreateConsumerOverrideRequest): CreateConsumerOverrideRequestAmino { + const obj: any = {}; + obj.parent = message.parent === "" ? undefined : message.parent; + obj.override = message.override ? QuotaOverride.toAmino(message.override) : undefined; + obj.force = message.force === false ? undefined : message.force; + if (message.forceOnly) { + obj.force_only = message.forceOnly.map(e => e); + } else { + obj.force_only = message.forceOnly; + } + return obj; + }, + fromAminoMsg(object: CreateConsumerOverrideRequestAminoMsg): CreateConsumerOverrideRequest { + return CreateConsumerOverrideRequest.fromAmino(object.value); + }, + fromProtoMsg(message: CreateConsumerOverrideRequestProtoMsg): CreateConsumerOverrideRequest { + return CreateConsumerOverrideRequest.decode(message.value); + }, + toProto(message: CreateConsumerOverrideRequest): Uint8Array { + return CreateConsumerOverrideRequest.encode(message).finish(); + }, + toProtoMsg(message: CreateConsumerOverrideRequest): CreateConsumerOverrideRequestProtoMsg { + return { + typeUrl: "/google.api.serviceusage.v1beta1.CreateConsumerOverrideRequest", + value: CreateConsumerOverrideRequest.encode(message).finish() + }; + } +}; +function createBaseUpdateConsumerOverrideRequest(): UpdateConsumerOverrideRequest { + return { + name: "", + override: undefined, + force: false, + updateMask: undefined, + forceOnly: [] + }; +} +export const UpdateConsumerOverrideRequest = { + typeUrl: "/google.api.serviceusage.v1beta1.UpdateConsumerOverrideRequest", + encode(message: UpdateConsumerOverrideRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + if (message.override !== undefined) { + QuotaOverride.encode(message.override, writer.uint32(18).fork()).ldelim(); + } + if (message.force !== undefined) { + writer.uint32(24).bool(message.force); + } + if (message.updateMask !== undefined) { + FieldMask.encode(message.updateMask, writer.uint32(34).fork()).ldelim(); + } + writer.uint32(42).fork(); + for (const v of message.forceOnly) { + writer.int32(v); + } + writer.ldelim(); + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): UpdateConsumerOverrideRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseUpdateConsumerOverrideRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.override = QuotaOverride.decode(reader, reader.uint32()); + break; + case 3: + message.force = reader.bool(); + break; + case 4: + message.updateMask = FieldMask.decode(reader, reader.uint32()); + break; + case 5: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.forceOnly.push((reader.int32() as any)); + } + } else { + message.forceOnly.push((reader.int32() as any)); + } + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): UpdateConsumerOverrideRequest { + const obj = createBaseUpdateConsumerOverrideRequest(); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.override)) obj.override = QuotaOverride.fromJSON(object.override); + if (isSet(object.force)) obj.force = Boolean(object.force); + if (isSet(object.updateMask)) obj.updateMask = FieldMask.fromJSON(object.updateMask); + if (Array.isArray(object?.forceOnly)) obj.forceOnly = object.forceOnly.map((e: any) => quotaSafetyCheckFromJSON(e)); + return obj; + }, + toJSON(message: UpdateConsumerOverrideRequest): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.override !== undefined && (obj.override = message.override ? QuotaOverride.toJSON(message.override) : undefined); + message.force !== undefined && (obj.force = message.force); + message.updateMask !== undefined && (obj.updateMask = message.updateMask ? FieldMask.toJSON(message.updateMask) : undefined); + if (message.forceOnly) { + obj.forceOnly = message.forceOnly.map(e => quotaSafetyCheckToJSON(e)); + } else { + obj.forceOnly = []; + } + return obj; + }, + fromPartial(object: DeepPartial): UpdateConsumerOverrideRequest { + const message = createBaseUpdateConsumerOverrideRequest(); + message.name = object.name ?? ""; + if (object.override !== undefined && object.override !== null) { + message.override = QuotaOverride.fromPartial(object.override); + } + message.force = object.force ?? false; + if (object.updateMask !== undefined && object.updateMask !== null) { + message.updateMask = FieldMask.fromPartial(object.updateMask); + } + message.forceOnly = object.forceOnly?.map(e => e) || []; + return message; + }, + fromSDK(object: UpdateConsumerOverrideRequestSDKType): UpdateConsumerOverrideRequest { + return { + name: object?.name, + override: object.override ? QuotaOverride.fromSDK(object.override) : undefined, + force: object?.force, + updateMask: object.update_mask ? FieldMask.fromSDK(object.update_mask) : undefined, + forceOnly: Array.isArray(object?.force_only) ? object.force_only.map((e: any) => quotaSafetyCheckFromJSON(e)) : [] + }; + }, + fromSDKJSON(object: any): UpdateConsumerOverrideRequestSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + override: isSet(object.override) ? QuotaOverride.fromSDKJSON(object.override) : undefined, + force: isSet(object.force) ? Boolean(object.force) : false, + update_mask: isSet(object.update_mask) ? FieldMask.fromSDKJSON(object.update_mask) : undefined, + force_only: Array.isArray(object?.force_only) ? object.force_only.map((e: any) => quotaSafetyCheckFromJSON(e)) : [] + }; + }, + toSDK(message: UpdateConsumerOverrideRequest): UpdateConsumerOverrideRequestSDKType { + const obj: any = {}; + obj.name = message.name; + message.override !== undefined && (obj.override = message.override ? QuotaOverride.toSDK(message.override) : undefined); + obj.force = message.force; + message.updateMask !== undefined && (obj.update_mask = message.updateMask ? FieldMask.toSDK(message.updateMask) : undefined); + if (message.forceOnly) { + obj.force_only = message.forceOnly.map(e => quotaSafetyCheckToJSON(e)); + } else { + obj.force_only = []; + } + return obj; + }, + fromAmino(object: UpdateConsumerOverrideRequestAmino): UpdateConsumerOverrideRequest { + const message = createBaseUpdateConsumerOverrideRequest(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + if (object.override !== undefined && object.override !== null) { + message.override = QuotaOverride.fromAmino(object.override); + } + if (object.force !== undefined && object.force !== null) { + message.force = object.force; + } + if (object.update_mask !== undefined && object.update_mask !== null) { + message.updateMask = FieldMask.fromAmino(object.update_mask); + } + message.forceOnly = object.force_only?.map(e => e) || []; + return message; + }, + toAmino(message: UpdateConsumerOverrideRequest): UpdateConsumerOverrideRequestAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + obj.override = message.override ? QuotaOverride.toAmino(message.override) : undefined; + obj.force = message.force === false ? undefined : message.force; + obj.update_mask = message.updateMask ? FieldMask.toAmino(message.updateMask) : undefined; + if (message.forceOnly) { + obj.force_only = message.forceOnly.map(e => e); + } else { + obj.force_only = message.forceOnly; + } + return obj; + }, + fromAminoMsg(object: UpdateConsumerOverrideRequestAminoMsg): UpdateConsumerOverrideRequest { + return UpdateConsumerOverrideRequest.fromAmino(object.value); + }, + fromProtoMsg(message: UpdateConsumerOverrideRequestProtoMsg): UpdateConsumerOverrideRequest { + return UpdateConsumerOverrideRequest.decode(message.value); + }, + toProto(message: UpdateConsumerOverrideRequest): Uint8Array { + return UpdateConsumerOverrideRequest.encode(message).finish(); + }, + toProtoMsg(message: UpdateConsumerOverrideRequest): UpdateConsumerOverrideRequestProtoMsg { + return { + typeUrl: "/google.api.serviceusage.v1beta1.UpdateConsumerOverrideRequest", + value: UpdateConsumerOverrideRequest.encode(message).finish() + }; + } +}; +function createBaseDeleteConsumerOverrideRequest(): DeleteConsumerOverrideRequest { + return { + name: "", + force: false, + forceOnly: [] + }; +} +export const DeleteConsumerOverrideRequest = { + typeUrl: "/google.api.serviceusage.v1beta1.DeleteConsumerOverrideRequest", + encode(message: DeleteConsumerOverrideRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + if (message.force !== undefined) { + writer.uint32(16).bool(message.force); + } + writer.uint32(26).fork(); + for (const v of message.forceOnly) { + writer.int32(v); + } + writer.ldelim(); + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): DeleteConsumerOverrideRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDeleteConsumerOverrideRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.force = reader.bool(); + break; + case 3: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.forceOnly.push((reader.int32() as any)); + } + } else { + message.forceOnly.push((reader.int32() as any)); + } + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): DeleteConsumerOverrideRequest { + const obj = createBaseDeleteConsumerOverrideRequest(); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.force)) obj.force = Boolean(object.force); + if (Array.isArray(object?.forceOnly)) obj.forceOnly = object.forceOnly.map((e: any) => quotaSafetyCheckFromJSON(e)); + return obj; + }, + toJSON(message: DeleteConsumerOverrideRequest): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.force !== undefined && (obj.force = message.force); + if (message.forceOnly) { + obj.forceOnly = message.forceOnly.map(e => quotaSafetyCheckToJSON(e)); + } else { + obj.forceOnly = []; + } + return obj; + }, + fromPartial(object: DeepPartial): DeleteConsumerOverrideRequest { + const message = createBaseDeleteConsumerOverrideRequest(); + message.name = object.name ?? ""; + message.force = object.force ?? false; + message.forceOnly = object.forceOnly?.map(e => e) || []; + return message; + }, + fromSDK(object: DeleteConsumerOverrideRequestSDKType): DeleteConsumerOverrideRequest { + return { + name: object?.name, + force: object?.force, + forceOnly: Array.isArray(object?.force_only) ? object.force_only.map((e: any) => quotaSafetyCheckFromJSON(e)) : [] + }; + }, + fromSDKJSON(object: any): DeleteConsumerOverrideRequestSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + force: isSet(object.force) ? Boolean(object.force) : false, + force_only: Array.isArray(object?.force_only) ? object.force_only.map((e: any) => quotaSafetyCheckFromJSON(e)) : [] + }; + }, + toSDK(message: DeleteConsumerOverrideRequest): DeleteConsumerOverrideRequestSDKType { + const obj: any = {}; + obj.name = message.name; + obj.force = message.force; + if (message.forceOnly) { + obj.force_only = message.forceOnly.map(e => quotaSafetyCheckToJSON(e)); + } else { + obj.force_only = []; + } + return obj; + }, + fromAmino(object: DeleteConsumerOverrideRequestAmino): DeleteConsumerOverrideRequest { + const message = createBaseDeleteConsumerOverrideRequest(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + if (object.force !== undefined && object.force !== null) { + message.force = object.force; + } + message.forceOnly = object.force_only?.map(e => e) || []; + return message; + }, + toAmino(message: DeleteConsumerOverrideRequest): DeleteConsumerOverrideRequestAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + obj.force = message.force === false ? undefined : message.force; + if (message.forceOnly) { + obj.force_only = message.forceOnly.map(e => e); + } else { + obj.force_only = message.forceOnly; + } + return obj; + }, + fromAminoMsg(object: DeleteConsumerOverrideRequestAminoMsg): DeleteConsumerOverrideRequest { + return DeleteConsumerOverrideRequest.fromAmino(object.value); + }, + fromProtoMsg(message: DeleteConsumerOverrideRequestProtoMsg): DeleteConsumerOverrideRequest { + return DeleteConsumerOverrideRequest.decode(message.value); + }, + toProto(message: DeleteConsumerOverrideRequest): Uint8Array { + return DeleteConsumerOverrideRequest.encode(message).finish(); + }, + toProtoMsg(message: DeleteConsumerOverrideRequest): DeleteConsumerOverrideRequestProtoMsg { + return { + typeUrl: "/google.api.serviceusage.v1beta1.DeleteConsumerOverrideRequest", + value: DeleteConsumerOverrideRequest.encode(message).finish() + }; + } +}; +function createBaseListConsumerOverridesRequest(): ListConsumerOverridesRequest { + return { + parent: "", + pageSize: 0, + pageToken: "" + }; +} +export const ListConsumerOverridesRequest = { + typeUrl: "/google.api.serviceusage.v1beta1.ListConsumerOverridesRequest", + encode(message: ListConsumerOverridesRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.parent !== undefined) { + writer.uint32(10).string(message.parent); + } + if (message.pageSize !== undefined) { + writer.uint32(16).int32(message.pageSize); + } + if (message.pageToken !== undefined) { + writer.uint32(26).string(message.pageToken); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ListConsumerOverridesRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseListConsumerOverridesRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.parent = reader.string(); + break; + case 2: + message.pageSize = reader.int32(); + break; + case 3: + message.pageToken = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ListConsumerOverridesRequest { + const obj = createBaseListConsumerOverridesRequest(); + if (isSet(object.parent)) obj.parent = String(object.parent); + if (isSet(object.pageSize)) obj.pageSize = Number(object.pageSize); + if (isSet(object.pageToken)) obj.pageToken = String(object.pageToken); + return obj; + }, + toJSON(message: ListConsumerOverridesRequest): JsonSafe { + const obj: any = {}; + message.parent !== undefined && (obj.parent = message.parent); + message.pageSize !== undefined && (obj.pageSize = Math.round(message.pageSize)); + message.pageToken !== undefined && (obj.pageToken = message.pageToken); + return obj; + }, + fromPartial(object: DeepPartial): ListConsumerOverridesRequest { + const message = createBaseListConsumerOverridesRequest(); + message.parent = object.parent ?? ""; + message.pageSize = object.pageSize ?? 0; + message.pageToken = object.pageToken ?? ""; + return message; + }, + fromSDK(object: ListConsumerOverridesRequestSDKType): ListConsumerOverridesRequest { + return { + parent: object?.parent, + pageSize: object?.page_size, + pageToken: object?.page_token + }; + }, + fromSDKJSON(object: any): ListConsumerOverridesRequestSDKType { + return { + parent: isSet(object.parent) ? String(object.parent) : "", + page_size: isSet(object.page_size) ? Number(object.page_size) : 0, + page_token: isSet(object.page_token) ? String(object.page_token) : "" + }; + }, + toSDK(message: ListConsumerOverridesRequest): ListConsumerOverridesRequestSDKType { + const obj: any = {}; + obj.parent = message.parent; + obj.page_size = message.pageSize; + obj.page_token = message.pageToken; + return obj; + }, + fromAmino(object: ListConsumerOverridesRequestAmino): ListConsumerOverridesRequest { + const message = createBaseListConsumerOverridesRequest(); + if (object.parent !== undefined && object.parent !== null) { + message.parent = object.parent; + } + if (object.page_size !== undefined && object.page_size !== null) { + message.pageSize = object.page_size; + } + if (object.page_token !== undefined && object.page_token !== null) { + message.pageToken = object.page_token; + } + return message; + }, + toAmino(message: ListConsumerOverridesRequest): ListConsumerOverridesRequestAmino { + const obj: any = {}; + obj.parent = message.parent === "" ? undefined : message.parent; + obj.page_size = message.pageSize === 0 ? undefined : message.pageSize; + obj.page_token = message.pageToken === "" ? undefined : message.pageToken; + return obj; + }, + fromAminoMsg(object: ListConsumerOverridesRequestAminoMsg): ListConsumerOverridesRequest { + return ListConsumerOverridesRequest.fromAmino(object.value); + }, + fromProtoMsg(message: ListConsumerOverridesRequestProtoMsg): ListConsumerOverridesRequest { + return ListConsumerOverridesRequest.decode(message.value); + }, + toProto(message: ListConsumerOverridesRequest): Uint8Array { + return ListConsumerOverridesRequest.encode(message).finish(); + }, + toProtoMsg(message: ListConsumerOverridesRequest): ListConsumerOverridesRequestProtoMsg { + return { + typeUrl: "/google.api.serviceusage.v1beta1.ListConsumerOverridesRequest", + value: ListConsumerOverridesRequest.encode(message).finish() + }; + } +}; +function createBaseListConsumerOverridesResponse(): ListConsumerOverridesResponse { + return { + overrides: [], + nextPageToken: "" + }; +} +export const ListConsumerOverridesResponse = { + typeUrl: "/google.api.serviceusage.v1beta1.ListConsumerOverridesResponse", + encode(message: ListConsumerOverridesResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.overrides) { + QuotaOverride.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.nextPageToken !== undefined) { + writer.uint32(18).string(message.nextPageToken); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ListConsumerOverridesResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseListConsumerOverridesResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.overrides.push(QuotaOverride.decode(reader, reader.uint32())); + break; + case 2: + message.nextPageToken = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ListConsumerOverridesResponse { + const obj = createBaseListConsumerOverridesResponse(); + if (Array.isArray(object?.overrides)) obj.overrides = object.overrides.map((e: any) => QuotaOverride.fromJSON(e)); + if (isSet(object.nextPageToken)) obj.nextPageToken = String(object.nextPageToken); + return obj; + }, + toJSON(message: ListConsumerOverridesResponse): JsonSafe { + const obj: any = {}; + if (message.overrides) { + obj.overrides = message.overrides.map(e => e ? QuotaOverride.toJSON(e) : undefined); + } else { + obj.overrides = []; + } + message.nextPageToken !== undefined && (obj.nextPageToken = message.nextPageToken); + return obj; + }, + fromPartial(object: DeepPartial): ListConsumerOverridesResponse { + const message = createBaseListConsumerOverridesResponse(); + message.overrides = object.overrides?.map(e => QuotaOverride.fromPartial(e)) || []; + message.nextPageToken = object.nextPageToken ?? ""; + return message; + }, + fromSDK(object: ListConsumerOverridesResponseSDKType): ListConsumerOverridesResponse { + return { + overrides: Array.isArray(object?.overrides) ? object.overrides.map((e: any) => QuotaOverride.fromSDK(e)) : [], + nextPageToken: object?.next_page_token + }; + }, + fromSDKJSON(object: any): ListConsumerOverridesResponseSDKType { + return { + overrides: Array.isArray(object?.overrides) ? object.overrides.map((e: any) => QuotaOverride.fromSDKJSON(e)) : [], + next_page_token: isSet(object.next_page_token) ? String(object.next_page_token) : "" + }; + }, + toSDK(message: ListConsumerOverridesResponse): ListConsumerOverridesResponseSDKType { + const obj: any = {}; + if (message.overrides) { + obj.overrides = message.overrides.map(e => e ? QuotaOverride.toSDK(e) : undefined); + } else { + obj.overrides = []; + } + obj.next_page_token = message.nextPageToken; + return obj; + }, + fromAmino(object: ListConsumerOverridesResponseAmino): ListConsumerOverridesResponse { + const message = createBaseListConsumerOverridesResponse(); + message.overrides = object.overrides?.map(e => QuotaOverride.fromAmino(e)) || []; + if (object.next_page_token !== undefined && object.next_page_token !== null) { + message.nextPageToken = object.next_page_token; + } + return message; + }, + toAmino(message: ListConsumerOverridesResponse): ListConsumerOverridesResponseAmino { + const obj: any = {}; + if (message.overrides) { + obj.overrides = message.overrides.map(e => e ? QuotaOverride.toAmino(e) : undefined); + } else { + obj.overrides = message.overrides; + } + obj.next_page_token = message.nextPageToken === "" ? undefined : message.nextPageToken; + return obj; + }, + fromAminoMsg(object: ListConsumerOverridesResponseAminoMsg): ListConsumerOverridesResponse { + return ListConsumerOverridesResponse.fromAmino(object.value); + }, + fromProtoMsg(message: ListConsumerOverridesResponseProtoMsg): ListConsumerOverridesResponse { + return ListConsumerOverridesResponse.decode(message.value); + }, + toProto(message: ListConsumerOverridesResponse): Uint8Array { + return ListConsumerOverridesResponse.encode(message).finish(); + }, + toProtoMsg(message: ListConsumerOverridesResponse): ListConsumerOverridesResponseProtoMsg { + return { + typeUrl: "/google.api.serviceusage.v1beta1.ListConsumerOverridesResponse", + value: ListConsumerOverridesResponse.encode(message).finish() + }; + } +}; +function createBaseBatchCreateConsumerOverridesResponse(): BatchCreateConsumerOverridesResponse { + return { + overrides: [] + }; +} +export const BatchCreateConsumerOverridesResponse = { + typeUrl: "/google.api.serviceusage.v1beta1.BatchCreateConsumerOverridesResponse", + encode(message: BatchCreateConsumerOverridesResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.overrides) { + QuotaOverride.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): BatchCreateConsumerOverridesResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseBatchCreateConsumerOverridesResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.overrides.push(QuotaOverride.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): BatchCreateConsumerOverridesResponse { + const obj = createBaseBatchCreateConsumerOverridesResponse(); + if (Array.isArray(object?.overrides)) obj.overrides = object.overrides.map((e: any) => QuotaOverride.fromJSON(e)); + return obj; + }, + toJSON(message: BatchCreateConsumerOverridesResponse): JsonSafe { + const obj: any = {}; + if (message.overrides) { + obj.overrides = message.overrides.map(e => e ? QuotaOverride.toJSON(e) : undefined); + } else { + obj.overrides = []; + } + return obj; + }, + fromPartial(object: DeepPartial): BatchCreateConsumerOverridesResponse { + const message = createBaseBatchCreateConsumerOverridesResponse(); + message.overrides = object.overrides?.map(e => QuotaOverride.fromPartial(e)) || []; + return message; + }, + fromSDK(object: BatchCreateConsumerOverridesResponseSDKType): BatchCreateConsumerOverridesResponse { + return { + overrides: Array.isArray(object?.overrides) ? object.overrides.map((e: any) => QuotaOverride.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): BatchCreateConsumerOverridesResponseSDKType { + return { + overrides: Array.isArray(object?.overrides) ? object.overrides.map((e: any) => QuotaOverride.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: BatchCreateConsumerOverridesResponse): BatchCreateConsumerOverridesResponseSDKType { + const obj: any = {}; + if (message.overrides) { + obj.overrides = message.overrides.map(e => e ? QuotaOverride.toSDK(e) : undefined); + } else { + obj.overrides = []; + } + return obj; + }, + fromAmino(object: BatchCreateConsumerOverridesResponseAmino): BatchCreateConsumerOverridesResponse { + const message = createBaseBatchCreateConsumerOverridesResponse(); + message.overrides = object.overrides?.map(e => QuotaOverride.fromAmino(e)) || []; + return message; + }, + toAmino(message: BatchCreateConsumerOverridesResponse): BatchCreateConsumerOverridesResponseAmino { + const obj: any = {}; + if (message.overrides) { + obj.overrides = message.overrides.map(e => e ? QuotaOverride.toAmino(e) : undefined); + } else { + obj.overrides = message.overrides; + } + return obj; + }, + fromAminoMsg(object: BatchCreateConsumerOverridesResponseAminoMsg): BatchCreateConsumerOverridesResponse { + return BatchCreateConsumerOverridesResponse.fromAmino(object.value); + }, + fromProtoMsg(message: BatchCreateConsumerOverridesResponseProtoMsg): BatchCreateConsumerOverridesResponse { + return BatchCreateConsumerOverridesResponse.decode(message.value); + }, + toProto(message: BatchCreateConsumerOverridesResponse): Uint8Array { + return BatchCreateConsumerOverridesResponse.encode(message).finish(); + }, + toProtoMsg(message: BatchCreateConsumerOverridesResponse): BatchCreateConsumerOverridesResponseProtoMsg { + return { + typeUrl: "/google.api.serviceusage.v1beta1.BatchCreateConsumerOverridesResponse", + value: BatchCreateConsumerOverridesResponse.encode(message).finish() + }; + } +}; +function createBaseImportConsumerOverridesRequest(): ImportConsumerOverridesRequest { + return { + parent: "", + inlineSource: undefined, + force: false, + forceOnly: [] + }; +} +export const ImportConsumerOverridesRequest = { + typeUrl: "/google.api.serviceusage.v1beta1.ImportConsumerOverridesRequest", + encode(message: ImportConsumerOverridesRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.parent !== undefined) { + writer.uint32(10).string(message.parent); + } + if (message.inlineSource !== undefined) { + OverrideInlineSource.encode(message.inlineSource, writer.uint32(18).fork()).ldelim(); + } + if (message.force !== undefined) { + writer.uint32(24).bool(message.force); + } + writer.uint32(34).fork(); + for (const v of message.forceOnly) { + writer.int32(v); + } + writer.ldelim(); + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ImportConsumerOverridesRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseImportConsumerOverridesRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.parent = reader.string(); + break; + case 2: + message.inlineSource = OverrideInlineSource.decode(reader, reader.uint32()); + break; + case 3: + message.force = reader.bool(); + break; + case 4: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.forceOnly.push((reader.int32() as any)); + } + } else { + message.forceOnly.push((reader.int32() as any)); + } + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ImportConsumerOverridesRequest { + const obj = createBaseImportConsumerOverridesRequest(); + if (isSet(object.parent)) obj.parent = String(object.parent); + if (isSet(object.inlineSource)) obj.inlineSource = OverrideInlineSource.fromJSON(object.inlineSource); + if (isSet(object.force)) obj.force = Boolean(object.force); + if (Array.isArray(object?.forceOnly)) obj.forceOnly = object.forceOnly.map((e: any) => quotaSafetyCheckFromJSON(e)); + return obj; + }, + toJSON(message: ImportConsumerOverridesRequest): JsonSafe { + const obj: any = {}; + message.parent !== undefined && (obj.parent = message.parent); + message.inlineSource !== undefined && (obj.inlineSource = message.inlineSource ? OverrideInlineSource.toJSON(message.inlineSource) : undefined); + message.force !== undefined && (obj.force = message.force); + if (message.forceOnly) { + obj.forceOnly = message.forceOnly.map(e => quotaSafetyCheckToJSON(e)); + } else { + obj.forceOnly = []; + } + return obj; + }, + fromPartial(object: DeepPartial): ImportConsumerOverridesRequest { + const message = createBaseImportConsumerOverridesRequest(); + message.parent = object.parent ?? ""; + if (object.inlineSource !== undefined && object.inlineSource !== null) { + message.inlineSource = OverrideInlineSource.fromPartial(object.inlineSource); + } + message.force = object.force ?? false; + message.forceOnly = object.forceOnly?.map(e => e) || []; + return message; + }, + fromSDK(object: ImportConsumerOverridesRequestSDKType): ImportConsumerOverridesRequest { + return { + parent: object?.parent, + inlineSource: object.inline_source ? OverrideInlineSource.fromSDK(object.inline_source) : undefined, + force: object?.force, + forceOnly: Array.isArray(object?.force_only) ? object.force_only.map((e: any) => quotaSafetyCheckFromJSON(e)) : [] + }; + }, + fromSDKJSON(object: any): ImportConsumerOverridesRequestSDKType { + return { + parent: isSet(object.parent) ? String(object.parent) : "", + inline_source: isSet(object.inline_source) ? OverrideInlineSource.fromSDKJSON(object.inline_source) : undefined, + force: isSet(object.force) ? Boolean(object.force) : false, + force_only: Array.isArray(object?.force_only) ? object.force_only.map((e: any) => quotaSafetyCheckFromJSON(e)) : [] + }; + }, + toSDK(message: ImportConsumerOverridesRequest): ImportConsumerOverridesRequestSDKType { + const obj: any = {}; + obj.parent = message.parent; + message.inlineSource !== undefined && (obj.inline_source = message.inlineSource ? OverrideInlineSource.toSDK(message.inlineSource) : undefined); + obj.force = message.force; + if (message.forceOnly) { + obj.force_only = message.forceOnly.map(e => quotaSafetyCheckToJSON(e)); + } else { + obj.force_only = []; + } + return obj; + }, + fromAmino(object: ImportConsumerOverridesRequestAmino): ImportConsumerOverridesRequest { + const message = createBaseImportConsumerOverridesRequest(); + if (object.parent !== undefined && object.parent !== null) { + message.parent = object.parent; + } + if (object.inline_source !== undefined && object.inline_source !== null) { + message.inlineSource = OverrideInlineSource.fromAmino(object.inline_source); + } + if (object.force !== undefined && object.force !== null) { + message.force = object.force; + } + message.forceOnly = object.force_only?.map(e => e) || []; + return message; + }, + toAmino(message: ImportConsumerOverridesRequest): ImportConsumerOverridesRequestAmino { + const obj: any = {}; + obj.parent = message.parent === "" ? undefined : message.parent; + obj.inline_source = message.inlineSource ? OverrideInlineSource.toAmino(message.inlineSource) : undefined; + obj.force = message.force === false ? undefined : message.force; + if (message.forceOnly) { + obj.force_only = message.forceOnly.map(e => e); + } else { + obj.force_only = message.forceOnly; + } + return obj; + }, + fromAminoMsg(object: ImportConsumerOverridesRequestAminoMsg): ImportConsumerOverridesRequest { + return ImportConsumerOverridesRequest.fromAmino(object.value); + }, + fromProtoMsg(message: ImportConsumerOverridesRequestProtoMsg): ImportConsumerOverridesRequest { + return ImportConsumerOverridesRequest.decode(message.value); + }, + toProto(message: ImportConsumerOverridesRequest): Uint8Array { + return ImportConsumerOverridesRequest.encode(message).finish(); + }, + toProtoMsg(message: ImportConsumerOverridesRequest): ImportConsumerOverridesRequestProtoMsg { + return { + typeUrl: "/google.api.serviceusage.v1beta1.ImportConsumerOverridesRequest", + value: ImportConsumerOverridesRequest.encode(message).finish() + }; + } +}; +function createBaseImportConsumerOverridesResponse(): ImportConsumerOverridesResponse { + return { + overrides: [] + }; +} +export const ImportConsumerOverridesResponse = { + typeUrl: "/google.api.serviceusage.v1beta1.ImportConsumerOverridesResponse", + encode(message: ImportConsumerOverridesResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.overrides) { + QuotaOverride.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ImportConsumerOverridesResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseImportConsumerOverridesResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.overrides.push(QuotaOverride.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ImportConsumerOverridesResponse { + const obj = createBaseImportConsumerOverridesResponse(); + if (Array.isArray(object?.overrides)) obj.overrides = object.overrides.map((e: any) => QuotaOverride.fromJSON(e)); + return obj; + }, + toJSON(message: ImportConsumerOverridesResponse): JsonSafe { + const obj: any = {}; + if (message.overrides) { + obj.overrides = message.overrides.map(e => e ? QuotaOverride.toJSON(e) : undefined); + } else { + obj.overrides = []; + } + return obj; + }, + fromPartial(object: DeepPartial): ImportConsumerOverridesResponse { + const message = createBaseImportConsumerOverridesResponse(); + message.overrides = object.overrides?.map(e => QuotaOverride.fromPartial(e)) || []; + return message; + }, + fromSDK(object: ImportConsumerOverridesResponseSDKType): ImportConsumerOverridesResponse { + return { + overrides: Array.isArray(object?.overrides) ? object.overrides.map((e: any) => QuotaOverride.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): ImportConsumerOverridesResponseSDKType { + return { + overrides: Array.isArray(object?.overrides) ? object.overrides.map((e: any) => QuotaOverride.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: ImportConsumerOverridesResponse): ImportConsumerOverridesResponseSDKType { + const obj: any = {}; + if (message.overrides) { + obj.overrides = message.overrides.map(e => e ? QuotaOverride.toSDK(e) : undefined); + } else { + obj.overrides = []; + } + return obj; + }, + fromAmino(object: ImportConsumerOverridesResponseAmino): ImportConsumerOverridesResponse { + const message = createBaseImportConsumerOverridesResponse(); + message.overrides = object.overrides?.map(e => QuotaOverride.fromAmino(e)) || []; + return message; + }, + toAmino(message: ImportConsumerOverridesResponse): ImportConsumerOverridesResponseAmino { + const obj: any = {}; + if (message.overrides) { + obj.overrides = message.overrides.map(e => e ? QuotaOverride.toAmino(e) : undefined); + } else { + obj.overrides = message.overrides; + } + return obj; + }, + fromAminoMsg(object: ImportConsumerOverridesResponseAminoMsg): ImportConsumerOverridesResponse { + return ImportConsumerOverridesResponse.fromAmino(object.value); + }, + fromProtoMsg(message: ImportConsumerOverridesResponseProtoMsg): ImportConsumerOverridesResponse { + return ImportConsumerOverridesResponse.decode(message.value); + }, + toProto(message: ImportConsumerOverridesResponse): Uint8Array { + return ImportConsumerOverridesResponse.encode(message).finish(); + }, + toProtoMsg(message: ImportConsumerOverridesResponse): ImportConsumerOverridesResponseProtoMsg { + return { + typeUrl: "/google.api.serviceusage.v1beta1.ImportConsumerOverridesResponse", + value: ImportConsumerOverridesResponse.encode(message).finish() + }; + } +}; +function createBaseImportConsumerOverridesMetadata(): ImportConsumerOverridesMetadata { + return {}; +} +export const ImportConsumerOverridesMetadata = { + typeUrl: "/google.api.serviceusage.v1beta1.ImportConsumerOverridesMetadata", + encode(_: ImportConsumerOverridesMetadata, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ImportConsumerOverridesMetadata { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseImportConsumerOverridesMetadata(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): ImportConsumerOverridesMetadata { + const obj = createBaseImportConsumerOverridesMetadata(); + return obj; + }, + toJSON(_: ImportConsumerOverridesMetadata): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): ImportConsumerOverridesMetadata { + const message = createBaseImportConsumerOverridesMetadata(); + return message; + }, + fromSDK(_: ImportConsumerOverridesMetadataSDKType): ImportConsumerOverridesMetadata { + return {}; + }, + fromSDKJSON(_: any): ImportConsumerOverridesMetadataSDKType { + return {}; + }, + toSDK(_: ImportConsumerOverridesMetadata): ImportConsumerOverridesMetadataSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: ImportConsumerOverridesMetadataAmino): ImportConsumerOverridesMetadata { + const message = createBaseImportConsumerOverridesMetadata(); + return message; + }, + toAmino(_: ImportConsumerOverridesMetadata): ImportConsumerOverridesMetadataAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: ImportConsumerOverridesMetadataAminoMsg): ImportConsumerOverridesMetadata { + return ImportConsumerOverridesMetadata.fromAmino(object.value); + }, + fromProtoMsg(message: ImportConsumerOverridesMetadataProtoMsg): ImportConsumerOverridesMetadata { + return ImportConsumerOverridesMetadata.decode(message.value); + }, + toProto(message: ImportConsumerOverridesMetadata): Uint8Array { + return ImportConsumerOverridesMetadata.encode(message).finish(); + }, + toProtoMsg(message: ImportConsumerOverridesMetadata): ImportConsumerOverridesMetadataProtoMsg { + return { + typeUrl: "/google.api.serviceusage.v1beta1.ImportConsumerOverridesMetadata", + value: ImportConsumerOverridesMetadata.encode(message).finish() + }; + } +}; +function createBaseImportAdminQuotaPoliciesResponse(): ImportAdminQuotaPoliciesResponse { + return { + policies: [] + }; +} +export const ImportAdminQuotaPoliciesResponse = { + typeUrl: "/google.api.serviceusage.v1beta1.ImportAdminQuotaPoliciesResponse", + encode(message: ImportAdminQuotaPoliciesResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.policies) { + AdminQuotaPolicy.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ImportAdminQuotaPoliciesResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseImportAdminQuotaPoliciesResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.policies.push(AdminQuotaPolicy.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ImportAdminQuotaPoliciesResponse { + const obj = createBaseImportAdminQuotaPoliciesResponse(); + if (Array.isArray(object?.policies)) obj.policies = object.policies.map((e: any) => AdminQuotaPolicy.fromJSON(e)); + return obj; + }, + toJSON(message: ImportAdminQuotaPoliciesResponse): JsonSafe { + const obj: any = {}; + if (message.policies) { + obj.policies = message.policies.map(e => e ? AdminQuotaPolicy.toJSON(e) : undefined); + } else { + obj.policies = []; + } + return obj; + }, + fromPartial(object: DeepPartial): ImportAdminQuotaPoliciesResponse { + const message = createBaseImportAdminQuotaPoliciesResponse(); + message.policies = object.policies?.map(e => AdminQuotaPolicy.fromPartial(e)) || []; + return message; + }, + fromSDK(object: ImportAdminQuotaPoliciesResponseSDKType): ImportAdminQuotaPoliciesResponse { + return { + policies: Array.isArray(object?.policies) ? object.policies.map((e: any) => AdminQuotaPolicy.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): ImportAdminQuotaPoliciesResponseSDKType { + return { + policies: Array.isArray(object?.policies) ? object.policies.map((e: any) => AdminQuotaPolicy.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: ImportAdminQuotaPoliciesResponse): ImportAdminQuotaPoliciesResponseSDKType { + const obj: any = {}; + if (message.policies) { + obj.policies = message.policies.map(e => e ? AdminQuotaPolicy.toSDK(e) : undefined); + } else { + obj.policies = []; + } + return obj; + }, + fromAmino(object: ImportAdminQuotaPoliciesResponseAmino): ImportAdminQuotaPoliciesResponse { + const message = createBaseImportAdminQuotaPoliciesResponse(); + message.policies = object.policies?.map(e => AdminQuotaPolicy.fromAmino(e)) || []; + return message; + }, + toAmino(message: ImportAdminQuotaPoliciesResponse): ImportAdminQuotaPoliciesResponseAmino { + const obj: any = {}; + if (message.policies) { + obj.policies = message.policies.map(e => e ? AdminQuotaPolicy.toAmino(e) : undefined); + } else { + obj.policies = message.policies; + } + return obj; + }, + fromAminoMsg(object: ImportAdminQuotaPoliciesResponseAminoMsg): ImportAdminQuotaPoliciesResponse { + return ImportAdminQuotaPoliciesResponse.fromAmino(object.value); + }, + fromProtoMsg(message: ImportAdminQuotaPoliciesResponseProtoMsg): ImportAdminQuotaPoliciesResponse { + return ImportAdminQuotaPoliciesResponse.decode(message.value); + }, + toProto(message: ImportAdminQuotaPoliciesResponse): Uint8Array { + return ImportAdminQuotaPoliciesResponse.encode(message).finish(); + }, + toProtoMsg(message: ImportAdminQuotaPoliciesResponse): ImportAdminQuotaPoliciesResponseProtoMsg { + return { + typeUrl: "/google.api.serviceusage.v1beta1.ImportAdminQuotaPoliciesResponse", + value: ImportAdminQuotaPoliciesResponse.encode(message).finish() + }; + } +}; +function createBaseImportAdminQuotaPoliciesMetadata(): ImportAdminQuotaPoliciesMetadata { + return {}; +} +export const ImportAdminQuotaPoliciesMetadata = { + typeUrl: "/google.api.serviceusage.v1beta1.ImportAdminQuotaPoliciesMetadata", + encode(_: ImportAdminQuotaPoliciesMetadata, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ImportAdminQuotaPoliciesMetadata { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseImportAdminQuotaPoliciesMetadata(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): ImportAdminQuotaPoliciesMetadata { + const obj = createBaseImportAdminQuotaPoliciesMetadata(); + return obj; + }, + toJSON(_: ImportAdminQuotaPoliciesMetadata): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): ImportAdminQuotaPoliciesMetadata { + const message = createBaseImportAdminQuotaPoliciesMetadata(); + return message; + }, + fromSDK(_: ImportAdminQuotaPoliciesMetadataSDKType): ImportAdminQuotaPoliciesMetadata { + return {}; + }, + fromSDKJSON(_: any): ImportAdminQuotaPoliciesMetadataSDKType { + return {}; + }, + toSDK(_: ImportAdminQuotaPoliciesMetadata): ImportAdminQuotaPoliciesMetadataSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: ImportAdminQuotaPoliciesMetadataAmino): ImportAdminQuotaPoliciesMetadata { + const message = createBaseImportAdminQuotaPoliciesMetadata(); + return message; + }, + toAmino(_: ImportAdminQuotaPoliciesMetadata): ImportAdminQuotaPoliciesMetadataAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: ImportAdminQuotaPoliciesMetadataAminoMsg): ImportAdminQuotaPoliciesMetadata { + return ImportAdminQuotaPoliciesMetadata.fromAmino(object.value); + }, + fromProtoMsg(message: ImportAdminQuotaPoliciesMetadataProtoMsg): ImportAdminQuotaPoliciesMetadata { + return ImportAdminQuotaPoliciesMetadata.decode(message.value); + }, + toProto(message: ImportAdminQuotaPoliciesMetadata): Uint8Array { + return ImportAdminQuotaPoliciesMetadata.encode(message).finish(); + }, + toProtoMsg(message: ImportAdminQuotaPoliciesMetadata): ImportAdminQuotaPoliciesMetadataProtoMsg { + return { + typeUrl: "/google.api.serviceusage.v1beta1.ImportAdminQuotaPoliciesMetadata", + value: ImportAdminQuotaPoliciesMetadata.encode(message).finish() + }; + } +}; +function createBaseCreateAdminQuotaPolicyMetadata(): CreateAdminQuotaPolicyMetadata { + return {}; +} +export const CreateAdminQuotaPolicyMetadata = { + typeUrl: "/google.api.serviceusage.v1beta1.CreateAdminQuotaPolicyMetadata", + encode(_: CreateAdminQuotaPolicyMetadata, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): CreateAdminQuotaPolicyMetadata { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCreateAdminQuotaPolicyMetadata(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): CreateAdminQuotaPolicyMetadata { + const obj = createBaseCreateAdminQuotaPolicyMetadata(); + return obj; + }, + toJSON(_: CreateAdminQuotaPolicyMetadata): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): CreateAdminQuotaPolicyMetadata { + const message = createBaseCreateAdminQuotaPolicyMetadata(); + return message; + }, + fromSDK(_: CreateAdminQuotaPolicyMetadataSDKType): CreateAdminQuotaPolicyMetadata { + return {}; + }, + fromSDKJSON(_: any): CreateAdminQuotaPolicyMetadataSDKType { + return {}; + }, + toSDK(_: CreateAdminQuotaPolicyMetadata): CreateAdminQuotaPolicyMetadataSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: CreateAdminQuotaPolicyMetadataAmino): CreateAdminQuotaPolicyMetadata { + const message = createBaseCreateAdminQuotaPolicyMetadata(); + return message; + }, + toAmino(_: CreateAdminQuotaPolicyMetadata): CreateAdminQuotaPolicyMetadataAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: CreateAdminQuotaPolicyMetadataAminoMsg): CreateAdminQuotaPolicyMetadata { + return CreateAdminQuotaPolicyMetadata.fromAmino(object.value); + }, + fromProtoMsg(message: CreateAdminQuotaPolicyMetadataProtoMsg): CreateAdminQuotaPolicyMetadata { + return CreateAdminQuotaPolicyMetadata.decode(message.value); + }, + toProto(message: CreateAdminQuotaPolicyMetadata): Uint8Array { + return CreateAdminQuotaPolicyMetadata.encode(message).finish(); + }, + toProtoMsg(message: CreateAdminQuotaPolicyMetadata): CreateAdminQuotaPolicyMetadataProtoMsg { + return { + typeUrl: "/google.api.serviceusage.v1beta1.CreateAdminQuotaPolicyMetadata", + value: CreateAdminQuotaPolicyMetadata.encode(message).finish() + }; + } +}; +function createBaseUpdateAdminQuotaPolicyMetadata(): UpdateAdminQuotaPolicyMetadata { + return {}; +} +export const UpdateAdminQuotaPolicyMetadata = { + typeUrl: "/google.api.serviceusage.v1beta1.UpdateAdminQuotaPolicyMetadata", + encode(_: UpdateAdminQuotaPolicyMetadata, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): UpdateAdminQuotaPolicyMetadata { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseUpdateAdminQuotaPolicyMetadata(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): UpdateAdminQuotaPolicyMetadata { + const obj = createBaseUpdateAdminQuotaPolicyMetadata(); + return obj; + }, + toJSON(_: UpdateAdminQuotaPolicyMetadata): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): UpdateAdminQuotaPolicyMetadata { + const message = createBaseUpdateAdminQuotaPolicyMetadata(); + return message; + }, + fromSDK(_: UpdateAdminQuotaPolicyMetadataSDKType): UpdateAdminQuotaPolicyMetadata { + return {}; + }, + fromSDKJSON(_: any): UpdateAdminQuotaPolicyMetadataSDKType { + return {}; + }, + toSDK(_: UpdateAdminQuotaPolicyMetadata): UpdateAdminQuotaPolicyMetadataSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: UpdateAdminQuotaPolicyMetadataAmino): UpdateAdminQuotaPolicyMetadata { + const message = createBaseUpdateAdminQuotaPolicyMetadata(); + return message; + }, + toAmino(_: UpdateAdminQuotaPolicyMetadata): UpdateAdminQuotaPolicyMetadataAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: UpdateAdminQuotaPolicyMetadataAminoMsg): UpdateAdminQuotaPolicyMetadata { + return UpdateAdminQuotaPolicyMetadata.fromAmino(object.value); + }, + fromProtoMsg(message: UpdateAdminQuotaPolicyMetadataProtoMsg): UpdateAdminQuotaPolicyMetadata { + return UpdateAdminQuotaPolicyMetadata.decode(message.value); + }, + toProto(message: UpdateAdminQuotaPolicyMetadata): Uint8Array { + return UpdateAdminQuotaPolicyMetadata.encode(message).finish(); + }, + toProtoMsg(message: UpdateAdminQuotaPolicyMetadata): UpdateAdminQuotaPolicyMetadataProtoMsg { + return { + typeUrl: "/google.api.serviceusage.v1beta1.UpdateAdminQuotaPolicyMetadata", + value: UpdateAdminQuotaPolicyMetadata.encode(message).finish() + }; + } +}; +function createBaseDeleteAdminQuotaPolicyMetadata(): DeleteAdminQuotaPolicyMetadata { + return {}; +} +export const DeleteAdminQuotaPolicyMetadata = { + typeUrl: "/google.api.serviceusage.v1beta1.DeleteAdminQuotaPolicyMetadata", + encode(_: DeleteAdminQuotaPolicyMetadata, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): DeleteAdminQuotaPolicyMetadata { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDeleteAdminQuotaPolicyMetadata(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): DeleteAdminQuotaPolicyMetadata { + const obj = createBaseDeleteAdminQuotaPolicyMetadata(); + return obj; + }, + toJSON(_: DeleteAdminQuotaPolicyMetadata): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): DeleteAdminQuotaPolicyMetadata { + const message = createBaseDeleteAdminQuotaPolicyMetadata(); + return message; + }, + fromSDK(_: DeleteAdminQuotaPolicyMetadataSDKType): DeleteAdminQuotaPolicyMetadata { + return {}; + }, + fromSDKJSON(_: any): DeleteAdminQuotaPolicyMetadataSDKType { + return {}; + }, + toSDK(_: DeleteAdminQuotaPolicyMetadata): DeleteAdminQuotaPolicyMetadataSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: DeleteAdminQuotaPolicyMetadataAmino): DeleteAdminQuotaPolicyMetadata { + const message = createBaseDeleteAdminQuotaPolicyMetadata(); + return message; + }, + toAmino(_: DeleteAdminQuotaPolicyMetadata): DeleteAdminQuotaPolicyMetadataAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: DeleteAdminQuotaPolicyMetadataAminoMsg): DeleteAdminQuotaPolicyMetadata { + return DeleteAdminQuotaPolicyMetadata.fromAmino(object.value); + }, + fromProtoMsg(message: DeleteAdminQuotaPolicyMetadataProtoMsg): DeleteAdminQuotaPolicyMetadata { + return DeleteAdminQuotaPolicyMetadata.decode(message.value); + }, + toProto(message: DeleteAdminQuotaPolicyMetadata): Uint8Array { + return DeleteAdminQuotaPolicyMetadata.encode(message).finish(); + }, + toProtoMsg(message: DeleteAdminQuotaPolicyMetadata): DeleteAdminQuotaPolicyMetadataProtoMsg { + return { + typeUrl: "/google.api.serviceusage.v1beta1.DeleteAdminQuotaPolicyMetadata", + value: DeleteAdminQuotaPolicyMetadata.encode(message).finish() + }; + } +}; +function createBaseGenerateServiceIdentityRequest(): GenerateServiceIdentityRequest { + return { + parent: "" + }; +} +export const GenerateServiceIdentityRequest = { + typeUrl: "/google.api.serviceusage.v1beta1.GenerateServiceIdentityRequest", + encode(message: GenerateServiceIdentityRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.parent !== undefined) { + writer.uint32(10).string(message.parent); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GenerateServiceIdentityRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGenerateServiceIdentityRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.parent = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GenerateServiceIdentityRequest { + const obj = createBaseGenerateServiceIdentityRequest(); + if (isSet(object.parent)) obj.parent = String(object.parent); + return obj; + }, + toJSON(message: GenerateServiceIdentityRequest): JsonSafe { + const obj: any = {}; + message.parent !== undefined && (obj.parent = message.parent); + return obj; + }, + fromPartial(object: DeepPartial): GenerateServiceIdentityRequest { + const message = createBaseGenerateServiceIdentityRequest(); + message.parent = object.parent ?? ""; + return message; + }, + fromSDK(object: GenerateServiceIdentityRequestSDKType): GenerateServiceIdentityRequest { + return { + parent: object?.parent + }; + }, + fromSDKJSON(object: any): GenerateServiceIdentityRequestSDKType { + return { + parent: isSet(object.parent) ? String(object.parent) : "" + }; + }, + toSDK(message: GenerateServiceIdentityRequest): GenerateServiceIdentityRequestSDKType { + const obj: any = {}; + obj.parent = message.parent; + return obj; + }, + fromAmino(object: GenerateServiceIdentityRequestAmino): GenerateServiceIdentityRequest { + const message = createBaseGenerateServiceIdentityRequest(); + if (object.parent !== undefined && object.parent !== null) { + message.parent = object.parent; + } + return message; + }, + toAmino(message: GenerateServiceIdentityRequest): GenerateServiceIdentityRequestAmino { + const obj: any = {}; + obj.parent = message.parent === "" ? undefined : message.parent; + return obj; + }, + fromAminoMsg(object: GenerateServiceIdentityRequestAminoMsg): GenerateServiceIdentityRequest { + return GenerateServiceIdentityRequest.fromAmino(object.value); + }, + fromProtoMsg(message: GenerateServiceIdentityRequestProtoMsg): GenerateServiceIdentityRequest { + return GenerateServiceIdentityRequest.decode(message.value); + }, + toProto(message: GenerateServiceIdentityRequest): Uint8Array { + return GenerateServiceIdentityRequest.encode(message).finish(); + }, + toProtoMsg(message: GenerateServiceIdentityRequest): GenerateServiceIdentityRequestProtoMsg { + return { + typeUrl: "/google.api.serviceusage.v1beta1.GenerateServiceIdentityRequest", + value: GenerateServiceIdentityRequest.encode(message).finish() + }; + } +}; +function createBaseGetServiceIdentityResponse(): GetServiceIdentityResponse { + return { + identity: undefined, + state: 0 + }; +} +export const GetServiceIdentityResponse = { + typeUrl: "/google.api.serviceusage.v1beta1.GetServiceIdentityResponse", + encode(message: GetServiceIdentityResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.identity !== undefined) { + ServiceIdentity.encode(message.identity, writer.uint32(10).fork()).ldelim(); + } + if (message.state !== 0) { + writer.uint32(16).int32(message.state); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GetServiceIdentityResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGetServiceIdentityResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.identity = ServiceIdentity.decode(reader, reader.uint32()); + break; + case 2: + message.state = (reader.int32() as any); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GetServiceIdentityResponse { + const obj = createBaseGetServiceIdentityResponse(); + if (isSet(object.identity)) obj.identity = ServiceIdentity.fromJSON(object.identity); + if (isSet(object.state)) obj.state = getServiceIdentityResponse_IdentityStateFromJSON(object.state); + return obj; + }, + toJSON(message: GetServiceIdentityResponse): JsonSafe { + const obj: any = {}; + message.identity !== undefined && (obj.identity = message.identity ? ServiceIdentity.toJSON(message.identity) : undefined); + message.state !== undefined && (obj.state = getServiceIdentityResponse_IdentityStateToJSON(message.state)); + return obj; + }, + fromPartial(object: DeepPartial): GetServiceIdentityResponse { + const message = createBaseGetServiceIdentityResponse(); + if (object.identity !== undefined && object.identity !== null) { + message.identity = ServiceIdentity.fromPartial(object.identity); + } + message.state = object.state ?? 0; + return message; + }, + fromSDK(object: GetServiceIdentityResponseSDKType): GetServiceIdentityResponse { + return { + identity: object.identity ? ServiceIdentity.fromSDK(object.identity) : undefined, + state: isSet(object.state) ? getServiceIdentityResponse_IdentityStateFromJSON(object.state) : -1 + }; + }, + fromSDKJSON(object: any): GetServiceIdentityResponseSDKType { + return { + identity: isSet(object.identity) ? ServiceIdentity.fromSDKJSON(object.identity) : undefined, + state: isSet(object.state) ? getServiceIdentityResponse_IdentityStateFromJSON(object.state) : -1 + }; + }, + toSDK(message: GetServiceIdentityResponse): GetServiceIdentityResponseSDKType { + const obj: any = {}; + message.identity !== undefined && (obj.identity = message.identity ? ServiceIdentity.toSDK(message.identity) : undefined); + message.state !== undefined && (obj.state = getServiceIdentityResponse_IdentityStateToJSON(message.state)); + return obj; + }, + fromAmino(object: GetServiceIdentityResponseAmino): GetServiceIdentityResponse { + const message = createBaseGetServiceIdentityResponse(); + if (object.identity !== undefined && object.identity !== null) { + message.identity = ServiceIdentity.fromAmino(object.identity); + } + if (object.state !== undefined && object.state !== null) { + message.state = object.state; + } + return message; + }, + toAmino(message: GetServiceIdentityResponse): GetServiceIdentityResponseAmino { + const obj: any = {}; + obj.identity = message.identity ? ServiceIdentity.toAmino(message.identity) : undefined; + obj.state = message.state === 0 ? undefined : message.state; + return obj; + }, + fromAminoMsg(object: GetServiceIdentityResponseAminoMsg): GetServiceIdentityResponse { + return GetServiceIdentityResponse.fromAmino(object.value); + }, + fromProtoMsg(message: GetServiceIdentityResponseProtoMsg): GetServiceIdentityResponse { + return GetServiceIdentityResponse.decode(message.value); + }, + toProto(message: GetServiceIdentityResponse): Uint8Array { + return GetServiceIdentityResponse.encode(message).finish(); + }, + toProtoMsg(message: GetServiceIdentityResponse): GetServiceIdentityResponseProtoMsg { + return { + typeUrl: "/google.api.serviceusage.v1beta1.GetServiceIdentityResponse", + value: GetServiceIdentityResponse.encode(message).finish() + }; + } +}; +function createBaseGetServiceIdentityMetadata(): GetServiceIdentityMetadata { + return {}; +} +export const GetServiceIdentityMetadata = { + typeUrl: "/google.api.serviceusage.v1beta1.GetServiceIdentityMetadata", + encode(_: GetServiceIdentityMetadata, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GetServiceIdentityMetadata { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGetServiceIdentityMetadata(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): GetServiceIdentityMetadata { + const obj = createBaseGetServiceIdentityMetadata(); + return obj; + }, + toJSON(_: GetServiceIdentityMetadata): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): GetServiceIdentityMetadata { + const message = createBaseGetServiceIdentityMetadata(); + return message; + }, + fromSDK(_: GetServiceIdentityMetadataSDKType): GetServiceIdentityMetadata { + return {}; + }, + fromSDKJSON(_: any): GetServiceIdentityMetadataSDKType { + return {}; + }, + toSDK(_: GetServiceIdentityMetadata): GetServiceIdentityMetadataSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: GetServiceIdentityMetadataAmino): GetServiceIdentityMetadata { + const message = createBaseGetServiceIdentityMetadata(); + return message; + }, + toAmino(_: GetServiceIdentityMetadata): GetServiceIdentityMetadataAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: GetServiceIdentityMetadataAminoMsg): GetServiceIdentityMetadata { + return GetServiceIdentityMetadata.fromAmino(object.value); + }, + fromProtoMsg(message: GetServiceIdentityMetadataProtoMsg): GetServiceIdentityMetadata { + return GetServiceIdentityMetadata.decode(message.value); + }, + toProto(message: GetServiceIdentityMetadata): Uint8Array { + return GetServiceIdentityMetadata.encode(message).finish(); + }, + toProtoMsg(message: GetServiceIdentityMetadata): GetServiceIdentityMetadataProtoMsg { + return { + typeUrl: "/google.api.serviceusage.v1beta1.GetServiceIdentityMetadata", + value: GetServiceIdentityMetadata.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/api/source_info.ts b/__fixtures__/v-next/outputicjsdeps/google/api/source_info.ts new file mode 100644 index 0000000000..9e80f57567 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/api/source_info.ts @@ -0,0 +1,116 @@ +import { Any, AnySDKType } from "../protobuf/any.js"; +import { BinaryReader, BinaryWriter } from "../../binary.js"; +import { JsonSafe } from "../../json-safe.js"; +import { DeepPartial } from "../../helpers.js"; +export const protobufPackage = "google.api"; +/** Source information used to create a Service Config */ +export interface SourceInfo { + /** All files used during config generation. */ + sourceFiles: Any[]; +} +export interface SourceInfoProtoMsg { + typeUrl: "/google.api.SourceInfo"; + value: Uint8Array; +} +/** Source information used to create a Service Config */ +export interface SourceInfoSDKType { + source_files: AnySDKType[]; +} +function createBaseSourceInfo(): SourceInfo { + return { + sourceFiles: [] + }; +} +export const SourceInfo = { + typeUrl: "/google.api.SourceInfo", + encode(message: SourceInfo, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.sourceFiles) { + Any.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): SourceInfo { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseSourceInfo(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.sourceFiles.push(Any.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): SourceInfo { + const obj = createBaseSourceInfo(); + if (Array.isArray(object?.sourceFiles)) obj.sourceFiles = object.sourceFiles.map((e: any) => Any.fromJSON(e)); + return obj; + }, + toJSON(message: SourceInfo): JsonSafe { + const obj: any = {}; + if (message.sourceFiles) { + obj.sourceFiles = message.sourceFiles.map(e => e ? Any.toJSON(e) : undefined); + } else { + obj.sourceFiles = []; + } + return obj; + }, + fromPartial(object: DeepPartial): SourceInfo { + const message = createBaseSourceInfo(); + message.sourceFiles = object.sourceFiles?.map(e => Any.fromPartial(e)) || []; + return message; + }, + fromSDK(object: SourceInfoSDKType): SourceInfo { + return { + sourceFiles: Array.isArray(object?.source_files) ? object.source_files.map((e: any) => Any.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): SourceInfoSDKType { + return { + source_files: Array.isArray(object?.source_files) ? object.source_files.map((e: any) => Any.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: SourceInfo): SourceInfoSDKType { + const obj: any = {}; + if (message.sourceFiles) { + obj.source_files = message.sourceFiles.map(e => e ? Any.toSDK(e) : undefined); + } else { + obj.source_files = []; + } + return obj; + }, + fromAmino(object: SourceInfoAmino): SourceInfo { + const message = createBaseSourceInfo(); + message.sourceFiles = object.source_files?.map(e => Any.fromAmino(e)) || []; + return message; + }, + toAmino(message: SourceInfo): SourceInfoAmino { + const obj: any = {}; + if (message.sourceFiles) { + obj.source_files = message.sourceFiles.map(e => e ? Any.toAmino(e) : undefined); + } else { + obj.source_files = message.sourceFiles; + } + return obj; + }, + fromAminoMsg(object: SourceInfoAminoMsg): SourceInfo { + return SourceInfo.fromAmino(object.value); + }, + fromProtoMsg(message: SourceInfoProtoMsg): SourceInfo { + return SourceInfo.decode(message.value); + }, + toProto(message: SourceInfo): Uint8Array { + return SourceInfo.encode(message).finish(); + }, + toProtoMsg(message: SourceInfo): SourceInfoProtoMsg { + return { + typeUrl: "/google.api.SourceInfo", + value: SourceInfo.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/api/system_parameter.ts b/__fixtures__/v-next/outputicjsdeps/google/api/system_parameter.ts new file mode 100644 index 0000000000..230e353d3b --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/api/system_parameter.ts @@ -0,0 +1,462 @@ +import { BinaryReader, BinaryWriter } from "../../binary.js"; +import { JsonSafe } from "../../json-safe.js"; +import { DeepPartial, isSet } from "../../helpers.js"; +export const protobufPackage = "google.api"; +/** + * ### System parameter configuration + * + * A system parameter is a special kind of parameter defined by the API + * system, not by an individual API. It is typically mapped to an HTTP header + * and/or a URL query parameter. This configuration specifies which methods + * change the names of the system parameters. + */ +export interface SystemParameters { + /** + * Define system parameters. + * + * The parameters defined here will override the default parameters + * implemented by the system. If this field is missing from the service + * config, default system parameters will be used. Default system parameters + * and names is implementation-dependent. + * + * Example: define api key for all methods + * + * system_parameters + * rules: + * - selector: "*" + * parameters: + * - name: api_key + * url_query_parameter: api_key + * + * + * Example: define 2 api key names for a specific method. + * + * system_parameters + * rules: + * - selector: "/ListShelves" + * parameters: + * - name: api_key + * http_header: Api-Key1 + * - name: api_key + * http_header: Api-Key2 + * + * **NOTE:** All service configuration rules follow "last one wins" order. + */ + rules: SystemParameterRule[]; +} +export interface SystemParametersProtoMsg { + typeUrl: "/google.api.SystemParameters"; + value: Uint8Array; +} +/** + * ### System parameter configuration + * + * A system parameter is a special kind of parameter defined by the API + * system, not by an individual API. It is typically mapped to an HTTP header + * and/or a URL query parameter. This configuration specifies which methods + * change the names of the system parameters. + */ +export interface SystemParametersSDKType { + rules: SystemParameterRuleSDKType[]; +} +/** + * Define a system parameter rule mapping system parameter definitions to + * methods. + */ +export interface SystemParameterRule { + /** + * Selects the methods to which this rule applies. Use '*' to indicate all + * methods in all APIs. + * + * Refer to [selector][google.api.DocumentationRule.selector] for syntax details. + */ + selector: string; + /** + * Define parameters. Multiple names may be defined for a parameter. + * For a given method call, only one of them should be used. If multiple + * names are used the behavior is implementation-dependent. + * If none of the specified names are present the behavior is + * parameter-dependent. + */ + parameters: SystemParameter[]; +} +export interface SystemParameterRuleProtoMsg { + typeUrl: "/google.api.SystemParameterRule"; + value: Uint8Array; +} +/** + * Define a system parameter rule mapping system parameter definitions to + * methods. + */ +export interface SystemParameterRuleSDKType { + selector: string; + parameters: SystemParameterSDKType[]; +} +/** + * Define a parameter's name and location. The parameter may be passed as either + * an HTTP header or a URL query parameter, and if both are passed the behavior + * is implementation-dependent. + */ +export interface SystemParameter { + /** Define the name of the parameter, such as "api_key" . It is case sensitive. */ + name: string; + /** + * Define the HTTP header name to use for the parameter. It is case + * insensitive. + */ + httpHeader: string; + /** + * Define the URL query parameter name to use for the parameter. It is case + * sensitive. + */ + urlQueryParameter: string; +} +export interface SystemParameterProtoMsg { + typeUrl: "/google.api.SystemParameter"; + value: Uint8Array; +} +/** + * Define a parameter's name and location. The parameter may be passed as either + * an HTTP header or a URL query parameter, and if both are passed the behavior + * is implementation-dependent. + */ +export interface SystemParameterSDKType { + name: string; + http_header: string; + url_query_parameter: string; +} +function createBaseSystemParameters(): SystemParameters { + return { + rules: [] + }; +} +export const SystemParameters = { + typeUrl: "/google.api.SystemParameters", + encode(message: SystemParameters, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.rules) { + SystemParameterRule.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): SystemParameters { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseSystemParameters(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.rules.push(SystemParameterRule.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): SystemParameters { + const obj = createBaseSystemParameters(); + if (Array.isArray(object?.rules)) obj.rules = object.rules.map((e: any) => SystemParameterRule.fromJSON(e)); + return obj; + }, + toJSON(message: SystemParameters): JsonSafe { + const obj: any = {}; + if (message.rules) { + obj.rules = message.rules.map(e => e ? SystemParameterRule.toJSON(e) : undefined); + } else { + obj.rules = []; + } + return obj; + }, + fromPartial(object: DeepPartial): SystemParameters { + const message = createBaseSystemParameters(); + message.rules = object.rules?.map(e => SystemParameterRule.fromPartial(e)) || []; + return message; + }, + fromSDK(object: SystemParametersSDKType): SystemParameters { + return { + rules: Array.isArray(object?.rules) ? object.rules.map((e: any) => SystemParameterRule.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): SystemParametersSDKType { + return { + rules: Array.isArray(object?.rules) ? object.rules.map((e: any) => SystemParameterRule.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: SystemParameters): SystemParametersSDKType { + const obj: any = {}; + if (message.rules) { + obj.rules = message.rules.map(e => e ? SystemParameterRule.toSDK(e) : undefined); + } else { + obj.rules = []; + } + return obj; + }, + fromAmino(object: SystemParametersAmino): SystemParameters { + const message = createBaseSystemParameters(); + message.rules = object.rules?.map(e => SystemParameterRule.fromAmino(e)) || []; + return message; + }, + toAmino(message: SystemParameters): SystemParametersAmino { + const obj: any = {}; + if (message.rules) { + obj.rules = message.rules.map(e => e ? SystemParameterRule.toAmino(e) : undefined); + } else { + obj.rules = message.rules; + } + return obj; + }, + fromAminoMsg(object: SystemParametersAminoMsg): SystemParameters { + return SystemParameters.fromAmino(object.value); + }, + fromProtoMsg(message: SystemParametersProtoMsg): SystemParameters { + return SystemParameters.decode(message.value); + }, + toProto(message: SystemParameters): Uint8Array { + return SystemParameters.encode(message).finish(); + }, + toProtoMsg(message: SystemParameters): SystemParametersProtoMsg { + return { + typeUrl: "/google.api.SystemParameters", + value: SystemParameters.encode(message).finish() + }; + } +}; +function createBaseSystemParameterRule(): SystemParameterRule { + return { + selector: "", + parameters: [] + }; +} +export const SystemParameterRule = { + typeUrl: "/google.api.SystemParameterRule", + encode(message: SystemParameterRule, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.selector !== undefined) { + writer.uint32(10).string(message.selector); + } + for (const v of message.parameters) { + SystemParameter.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): SystemParameterRule { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseSystemParameterRule(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.selector = reader.string(); + break; + case 2: + message.parameters.push(SystemParameter.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): SystemParameterRule { + const obj = createBaseSystemParameterRule(); + if (isSet(object.selector)) obj.selector = String(object.selector); + if (Array.isArray(object?.parameters)) obj.parameters = object.parameters.map((e: any) => SystemParameter.fromJSON(e)); + return obj; + }, + toJSON(message: SystemParameterRule): JsonSafe { + const obj: any = {}; + message.selector !== undefined && (obj.selector = message.selector); + if (message.parameters) { + obj.parameters = message.parameters.map(e => e ? SystemParameter.toJSON(e) : undefined); + } else { + obj.parameters = []; + } + return obj; + }, + fromPartial(object: DeepPartial): SystemParameterRule { + const message = createBaseSystemParameterRule(); + message.selector = object.selector ?? ""; + message.parameters = object.parameters?.map(e => SystemParameter.fromPartial(e)) || []; + return message; + }, + fromSDK(object: SystemParameterRuleSDKType): SystemParameterRule { + return { + selector: object?.selector, + parameters: Array.isArray(object?.parameters) ? object.parameters.map((e: any) => SystemParameter.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): SystemParameterRuleSDKType { + return { + selector: isSet(object.selector) ? String(object.selector) : "", + parameters: Array.isArray(object?.parameters) ? object.parameters.map((e: any) => SystemParameter.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: SystemParameterRule): SystemParameterRuleSDKType { + const obj: any = {}; + obj.selector = message.selector; + if (message.parameters) { + obj.parameters = message.parameters.map(e => e ? SystemParameter.toSDK(e) : undefined); + } else { + obj.parameters = []; + } + return obj; + }, + fromAmino(object: SystemParameterRuleAmino): SystemParameterRule { + const message = createBaseSystemParameterRule(); + if (object.selector !== undefined && object.selector !== null) { + message.selector = object.selector; + } + message.parameters = object.parameters?.map(e => SystemParameter.fromAmino(e)) || []; + return message; + }, + toAmino(message: SystemParameterRule): SystemParameterRuleAmino { + const obj: any = {}; + obj.selector = message.selector === "" ? undefined : message.selector; + if (message.parameters) { + obj.parameters = message.parameters.map(e => e ? SystemParameter.toAmino(e) : undefined); + } else { + obj.parameters = message.parameters; + } + return obj; + }, + fromAminoMsg(object: SystemParameterRuleAminoMsg): SystemParameterRule { + return SystemParameterRule.fromAmino(object.value); + }, + fromProtoMsg(message: SystemParameterRuleProtoMsg): SystemParameterRule { + return SystemParameterRule.decode(message.value); + }, + toProto(message: SystemParameterRule): Uint8Array { + return SystemParameterRule.encode(message).finish(); + }, + toProtoMsg(message: SystemParameterRule): SystemParameterRuleProtoMsg { + return { + typeUrl: "/google.api.SystemParameterRule", + value: SystemParameterRule.encode(message).finish() + }; + } +}; +function createBaseSystemParameter(): SystemParameter { + return { + name: "", + httpHeader: "", + urlQueryParameter: "" + }; +} +export const SystemParameter = { + typeUrl: "/google.api.SystemParameter", + encode(message: SystemParameter, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + if (message.httpHeader !== undefined) { + writer.uint32(18).string(message.httpHeader); + } + if (message.urlQueryParameter !== undefined) { + writer.uint32(26).string(message.urlQueryParameter); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): SystemParameter { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseSystemParameter(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.httpHeader = reader.string(); + break; + case 3: + message.urlQueryParameter = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): SystemParameter { + const obj = createBaseSystemParameter(); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.httpHeader)) obj.httpHeader = String(object.httpHeader); + if (isSet(object.urlQueryParameter)) obj.urlQueryParameter = String(object.urlQueryParameter); + return obj; + }, + toJSON(message: SystemParameter): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.httpHeader !== undefined && (obj.httpHeader = message.httpHeader); + message.urlQueryParameter !== undefined && (obj.urlQueryParameter = message.urlQueryParameter); + return obj; + }, + fromPartial(object: DeepPartial): SystemParameter { + const message = createBaseSystemParameter(); + message.name = object.name ?? ""; + message.httpHeader = object.httpHeader ?? ""; + message.urlQueryParameter = object.urlQueryParameter ?? ""; + return message; + }, + fromSDK(object: SystemParameterSDKType): SystemParameter { + return { + name: object?.name, + httpHeader: object?.http_header, + urlQueryParameter: object?.url_query_parameter + }; + }, + fromSDKJSON(object: any): SystemParameterSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + http_header: isSet(object.http_header) ? String(object.http_header) : "", + url_query_parameter: isSet(object.url_query_parameter) ? String(object.url_query_parameter) : "" + }; + }, + toSDK(message: SystemParameter): SystemParameterSDKType { + const obj: any = {}; + obj.name = message.name; + obj.http_header = message.httpHeader; + obj.url_query_parameter = message.urlQueryParameter; + return obj; + }, + fromAmino(object: SystemParameterAmino): SystemParameter { + const message = createBaseSystemParameter(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + if (object.http_header !== undefined && object.http_header !== null) { + message.httpHeader = object.http_header; + } + if (object.url_query_parameter !== undefined && object.url_query_parameter !== null) { + message.urlQueryParameter = object.url_query_parameter; + } + return message; + }, + toAmino(message: SystemParameter): SystemParameterAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + obj.http_header = message.httpHeader === "" ? undefined : message.httpHeader; + obj.url_query_parameter = message.urlQueryParameter === "" ? undefined : message.urlQueryParameter; + return obj; + }, + fromAminoMsg(object: SystemParameterAminoMsg): SystemParameter { + return SystemParameter.fromAmino(object.value); + }, + fromProtoMsg(message: SystemParameterProtoMsg): SystemParameter { + return SystemParameter.decode(message.value); + }, + toProto(message: SystemParameter): Uint8Array { + return SystemParameter.encode(message).finish(); + }, + toProtoMsg(message: SystemParameter): SystemParameterProtoMsg { + return { + typeUrl: "/google.api.SystemParameter", + value: SystemParameter.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/api/usage.ts b/__fixtures__/v-next/outputicjsdeps/google/api/usage.ts new file mode 100644 index 0000000000..b4a9d63a75 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/api/usage.ts @@ -0,0 +1,394 @@ +import { BinaryReader, BinaryWriter } from "../../binary.js"; +import { isSet, DeepPartial } from "../../helpers.js"; +import { JsonSafe } from "../../json-safe.js"; +export const protobufPackage = "google.api"; +/** Configuration controlling usage of a service. */ +export interface Usage { + /** + * Requirements that must be satisfied before a consumer project can use the + * service. Each requirement is of the form /; + * for example 'serviceusage.googleapis.com/billing-enabled'. + * + * For Google APIs, a Terms of Service requirement must be included here. + * Google Cloud APIs must include "serviceusage.googleapis.com/tos/cloud". + * Other Google APIs should include + * "serviceusage.googleapis.com/tos/universal". Additional ToS can be + * included based on the business needs. + */ + requirements: string[]; + /** + * A list of usage rules that apply to individual API methods. + * + * **NOTE:** All service configuration rules follow "last one wins" order. + */ + rules: UsageRule[]; + /** + * The full resource name of a channel used for sending notifications to the + * service producer. + * + * Google Service Management currently only supports + * [Google Cloud Pub/Sub](https://cloud.google.com/pubsub) as a notification + * channel. To use Google Cloud Pub/Sub as the channel, this must be the name + * of a Cloud Pub/Sub topic that uses the Cloud Pub/Sub topic name format + * documented in https://cloud.google.com/pubsub/docs/overview. + */ + producerNotificationChannel: string; +} +export interface UsageProtoMsg { + typeUrl: "/google.api.Usage"; + value: Uint8Array; +} +/** Configuration controlling usage of a service. */ +export interface UsageSDKType { + requirements: string[]; + rules: UsageRuleSDKType[]; + producer_notification_channel: string; +} +/** + * Usage configuration rules for the service. + * + * NOTE: Under development. + * + * + * Use this rule to configure unregistered calls for the service. Unregistered + * calls are calls that do not contain consumer project identity. + * (Example: calls that do not contain an API key). + * By default, API methods do not allow unregistered calls, and each method call + * must be identified by a consumer project identity. Use this rule to + * allow/disallow unregistered calls. + * + * Example of an API that wants to allow unregistered calls for entire service. + * + * usage: + * rules: + * - selector: "*" + * allow_unregistered_calls: true + * + * Example of a method that wants to allow unregistered calls. + * + * usage: + * rules: + * - selector: "google.example.library.v1.LibraryService.CreateBook" + * allow_unregistered_calls: true + */ +export interface UsageRule { + /** + * Selects the methods to which this rule applies. Use '*' to indicate all + * methods in all APIs. + * + * Refer to [selector][google.api.DocumentationRule.selector] for syntax details. + */ + selector: string; + /** + * If true, the selected method allows unregistered calls, e.g. calls + * that don't identify any user or application. + */ + allowUnregisteredCalls: boolean; + /** + * If true, the selected method should skip service control and the control + * plane features, such as quota and billing, will not be available. + * This flag is used by Google Cloud Endpoints to bypass checks for internal + * methods, such as service health check methods. + */ + skipServiceControl: boolean; +} +export interface UsageRuleProtoMsg { + typeUrl: "/google.api.UsageRule"; + value: Uint8Array; +} +/** + * Usage configuration rules for the service. + * + * NOTE: Under development. + * + * + * Use this rule to configure unregistered calls for the service. Unregistered + * calls are calls that do not contain consumer project identity. + * (Example: calls that do not contain an API key). + * By default, API methods do not allow unregistered calls, and each method call + * must be identified by a consumer project identity. Use this rule to + * allow/disallow unregistered calls. + * + * Example of an API that wants to allow unregistered calls for entire service. + * + * usage: + * rules: + * - selector: "*" + * allow_unregistered_calls: true + * + * Example of a method that wants to allow unregistered calls. + * + * usage: + * rules: + * - selector: "google.example.library.v1.LibraryService.CreateBook" + * allow_unregistered_calls: true + */ +export interface UsageRuleSDKType { + selector: string; + allow_unregistered_calls: boolean; + skip_service_control: boolean; +} +function createBaseUsage(): Usage { + return { + requirements: [], + rules: [], + producerNotificationChannel: "" + }; +} +export const Usage = { + typeUrl: "/google.api.Usage", + encode(message: Usage, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.requirements) { + writer.uint32(10).string(v!); + } + for (const v of message.rules) { + UsageRule.encode(v!, writer.uint32(50).fork()).ldelim(); + } + if (message.producerNotificationChannel !== undefined) { + writer.uint32(58).string(message.producerNotificationChannel); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Usage { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseUsage(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.requirements.push(reader.string()); + break; + case 6: + message.rules.push(UsageRule.decode(reader, reader.uint32())); + break; + case 7: + message.producerNotificationChannel = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Usage { + const obj = createBaseUsage(); + if (Array.isArray(object?.requirements)) obj.requirements = object.requirements.map((e: any) => String(e)); + if (Array.isArray(object?.rules)) obj.rules = object.rules.map((e: any) => UsageRule.fromJSON(e)); + if (isSet(object.producerNotificationChannel)) obj.producerNotificationChannel = String(object.producerNotificationChannel); + return obj; + }, + toJSON(message: Usage): JsonSafe { + const obj: any = {}; + if (message.requirements) { + obj.requirements = message.requirements.map(e => e); + } else { + obj.requirements = []; + } + if (message.rules) { + obj.rules = message.rules.map(e => e ? UsageRule.toJSON(e) : undefined); + } else { + obj.rules = []; + } + message.producerNotificationChannel !== undefined && (obj.producerNotificationChannel = message.producerNotificationChannel); + return obj; + }, + fromPartial(object: DeepPartial): Usage { + const message = createBaseUsage(); + message.requirements = object.requirements?.map(e => e) || []; + message.rules = object.rules?.map(e => UsageRule.fromPartial(e)) || []; + message.producerNotificationChannel = object.producerNotificationChannel ?? ""; + return message; + }, + fromSDK(object: UsageSDKType): Usage { + return { + requirements: Array.isArray(object?.requirements) ? object.requirements.map((e: any) => e) : [], + rules: Array.isArray(object?.rules) ? object.rules.map((e: any) => UsageRule.fromSDK(e)) : [], + producerNotificationChannel: object?.producer_notification_channel + }; + }, + fromSDKJSON(object: any): UsageSDKType { + return { + requirements: Array.isArray(object?.requirements) ? object.requirements.map((e: any) => String(e)) : [], + rules: Array.isArray(object?.rules) ? object.rules.map((e: any) => UsageRule.fromSDKJSON(e)) : [], + producer_notification_channel: isSet(object.producer_notification_channel) ? String(object.producer_notification_channel) : "" + }; + }, + toSDK(message: Usage): UsageSDKType { + const obj: any = {}; + if (message.requirements) { + obj.requirements = message.requirements.map(e => e); + } else { + obj.requirements = []; + } + if (message.rules) { + obj.rules = message.rules.map(e => e ? UsageRule.toSDK(e) : undefined); + } else { + obj.rules = []; + } + obj.producer_notification_channel = message.producerNotificationChannel; + return obj; + }, + fromAmino(object: UsageAmino): Usage { + const message = createBaseUsage(); + message.requirements = object.requirements?.map(e => e) || []; + message.rules = object.rules?.map(e => UsageRule.fromAmino(e)) || []; + if (object.producer_notification_channel !== undefined && object.producer_notification_channel !== null) { + message.producerNotificationChannel = object.producer_notification_channel; + } + return message; + }, + toAmino(message: Usage): UsageAmino { + const obj: any = {}; + if (message.requirements) { + obj.requirements = message.requirements.map(e => e); + } else { + obj.requirements = message.requirements; + } + if (message.rules) { + obj.rules = message.rules.map(e => e ? UsageRule.toAmino(e) : undefined); + } else { + obj.rules = message.rules; + } + obj.producer_notification_channel = message.producerNotificationChannel === "" ? undefined : message.producerNotificationChannel; + return obj; + }, + fromAminoMsg(object: UsageAminoMsg): Usage { + return Usage.fromAmino(object.value); + }, + fromProtoMsg(message: UsageProtoMsg): Usage { + return Usage.decode(message.value); + }, + toProto(message: Usage): Uint8Array { + return Usage.encode(message).finish(); + }, + toProtoMsg(message: Usage): UsageProtoMsg { + return { + typeUrl: "/google.api.Usage", + value: Usage.encode(message).finish() + }; + } +}; +function createBaseUsageRule(): UsageRule { + return { + selector: "", + allowUnregisteredCalls: false, + skipServiceControl: false + }; +} +export const UsageRule = { + typeUrl: "/google.api.UsageRule", + encode(message: UsageRule, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.selector !== undefined) { + writer.uint32(10).string(message.selector); + } + if (message.allowUnregisteredCalls !== undefined) { + writer.uint32(16).bool(message.allowUnregisteredCalls); + } + if (message.skipServiceControl !== undefined) { + writer.uint32(24).bool(message.skipServiceControl); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): UsageRule { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseUsageRule(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.selector = reader.string(); + break; + case 2: + message.allowUnregisteredCalls = reader.bool(); + break; + case 3: + message.skipServiceControl = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): UsageRule { + const obj = createBaseUsageRule(); + if (isSet(object.selector)) obj.selector = String(object.selector); + if (isSet(object.allowUnregisteredCalls)) obj.allowUnregisteredCalls = Boolean(object.allowUnregisteredCalls); + if (isSet(object.skipServiceControl)) obj.skipServiceControl = Boolean(object.skipServiceControl); + return obj; + }, + toJSON(message: UsageRule): JsonSafe { + const obj: any = {}; + message.selector !== undefined && (obj.selector = message.selector); + message.allowUnregisteredCalls !== undefined && (obj.allowUnregisteredCalls = message.allowUnregisteredCalls); + message.skipServiceControl !== undefined && (obj.skipServiceControl = message.skipServiceControl); + return obj; + }, + fromPartial(object: DeepPartial): UsageRule { + const message = createBaseUsageRule(); + message.selector = object.selector ?? ""; + message.allowUnregisteredCalls = object.allowUnregisteredCalls ?? false; + message.skipServiceControl = object.skipServiceControl ?? false; + return message; + }, + fromSDK(object: UsageRuleSDKType): UsageRule { + return { + selector: object?.selector, + allowUnregisteredCalls: object?.allow_unregistered_calls, + skipServiceControl: object?.skip_service_control + }; + }, + fromSDKJSON(object: any): UsageRuleSDKType { + return { + selector: isSet(object.selector) ? String(object.selector) : "", + allow_unregistered_calls: isSet(object.allow_unregistered_calls) ? Boolean(object.allow_unregistered_calls) : false, + skip_service_control: isSet(object.skip_service_control) ? Boolean(object.skip_service_control) : false + }; + }, + toSDK(message: UsageRule): UsageRuleSDKType { + const obj: any = {}; + obj.selector = message.selector; + obj.allow_unregistered_calls = message.allowUnregisteredCalls; + obj.skip_service_control = message.skipServiceControl; + return obj; + }, + fromAmino(object: UsageRuleAmino): UsageRule { + const message = createBaseUsageRule(); + if (object.selector !== undefined && object.selector !== null) { + message.selector = object.selector; + } + if (object.allow_unregistered_calls !== undefined && object.allow_unregistered_calls !== null) { + message.allowUnregisteredCalls = object.allow_unregistered_calls; + } + if (object.skip_service_control !== undefined && object.skip_service_control !== null) { + message.skipServiceControl = object.skip_service_control; + } + return message; + }, + toAmino(message: UsageRule): UsageRuleAmino { + const obj: any = {}; + obj.selector = message.selector === "" ? undefined : message.selector; + obj.allow_unregistered_calls = message.allowUnregisteredCalls === false ? undefined : message.allowUnregisteredCalls; + obj.skip_service_control = message.skipServiceControl === false ? undefined : message.skipServiceControl; + return obj; + }, + fromAminoMsg(object: UsageRuleAminoMsg): UsageRule { + return UsageRule.fromAmino(object.value); + }, + fromProtoMsg(message: UsageRuleProtoMsg): UsageRule { + return UsageRule.decode(message.value); + }, + toProto(message: UsageRule): Uint8Array { + return UsageRule.encode(message).finish(); + }, + toProtoMsg(message: UsageRule): UsageRuleProtoMsg { + return { + typeUrl: "/google.api.UsageRule", + value: UsageRule.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/api/visibility.ts b/__fixtures__/v-next/outputicjsdeps/google/api/visibility.ts new file mode 100644 index 0000000000..10ddd8230b --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/api/visibility.ts @@ -0,0 +1,312 @@ +import { BinaryReader, BinaryWriter } from "../../binary.js"; +import { JsonSafe } from "../../json-safe.js"; +import { DeepPartial, isSet } from "../../helpers.js"; +export const protobufPackage = "google.api"; +/** + * `Visibility` defines restrictions for the visibility of service + * elements. Restrictions are specified using visibility labels + * (e.g., PREVIEW) that are elsewhere linked to users and projects. + * + * Users and projects can have access to more than one visibility label. The + * effective visibility for multiple labels is the union of each label's + * elements, plus any unrestricted elements. + * + * If an element and its parents have no restrictions, visibility is + * unconditionally granted. + * + * Example: + * + * visibility: + * rules: + * - selector: google.calendar.Calendar.EnhancedSearch + * restriction: PREVIEW + * - selector: google.calendar.Calendar.Delegate + * restriction: INTERNAL + * + * Here, all methods are publicly visible except for the restricted methods + * EnhancedSearch and Delegate. + */ +export interface Visibility { + /** + * A list of visibility rules that apply to individual API elements. + * + * **NOTE:** All service configuration rules follow "last one wins" order. + */ + rules: VisibilityRule[]; +} +export interface VisibilityProtoMsg { + typeUrl: "/google.api.Visibility"; + value: Uint8Array; +} +/** + * `Visibility` defines restrictions for the visibility of service + * elements. Restrictions are specified using visibility labels + * (e.g., PREVIEW) that are elsewhere linked to users and projects. + * + * Users and projects can have access to more than one visibility label. The + * effective visibility for multiple labels is the union of each label's + * elements, plus any unrestricted elements. + * + * If an element and its parents have no restrictions, visibility is + * unconditionally granted. + * + * Example: + * + * visibility: + * rules: + * - selector: google.calendar.Calendar.EnhancedSearch + * restriction: PREVIEW + * - selector: google.calendar.Calendar.Delegate + * restriction: INTERNAL + * + * Here, all methods are publicly visible except for the restricted methods + * EnhancedSearch and Delegate. + */ +export interface VisibilitySDKType { + rules: VisibilityRuleSDKType[]; +} +/** + * A visibility rule provides visibility configuration for an individual API + * element. + */ +export interface VisibilityRule { + /** + * Selects methods, messages, fields, enums, etc. to which this rule applies. + * + * Refer to [selector][google.api.DocumentationRule.selector] for syntax details. + */ + selector: string; + /** + * A comma-separated list of visibility labels that apply to the `selector`. + * Any of the listed labels can be used to grant the visibility. + * + * If a rule has multiple labels, removing one of the labels but not all of + * them can break clients. + * + * Example: + * + * visibility: + * rules: + * - selector: google.calendar.Calendar.EnhancedSearch + * restriction: INTERNAL, PREVIEW + * + * Removing INTERNAL from this restriction will break clients that rely on + * this method and only had access to it through INTERNAL. + */ + restriction: string; +} +export interface VisibilityRuleProtoMsg { + typeUrl: "/google.api.VisibilityRule"; + value: Uint8Array; +} +/** + * A visibility rule provides visibility configuration for an individual API + * element. + */ +export interface VisibilityRuleSDKType { + selector: string; + restriction: string; +} +function createBaseVisibility(): Visibility { + return { + rules: [] + }; +} +export const Visibility = { + typeUrl: "/google.api.Visibility", + encode(message: Visibility, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.rules) { + VisibilityRule.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Visibility { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseVisibility(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.rules.push(VisibilityRule.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Visibility { + const obj = createBaseVisibility(); + if (Array.isArray(object?.rules)) obj.rules = object.rules.map((e: any) => VisibilityRule.fromJSON(e)); + return obj; + }, + toJSON(message: Visibility): JsonSafe { + const obj: any = {}; + if (message.rules) { + obj.rules = message.rules.map(e => e ? VisibilityRule.toJSON(e) : undefined); + } else { + obj.rules = []; + } + return obj; + }, + fromPartial(object: DeepPartial): Visibility { + const message = createBaseVisibility(); + message.rules = object.rules?.map(e => VisibilityRule.fromPartial(e)) || []; + return message; + }, + fromSDK(object: VisibilitySDKType): Visibility { + return { + rules: Array.isArray(object?.rules) ? object.rules.map((e: any) => VisibilityRule.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): VisibilitySDKType { + return { + rules: Array.isArray(object?.rules) ? object.rules.map((e: any) => VisibilityRule.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: Visibility): VisibilitySDKType { + const obj: any = {}; + if (message.rules) { + obj.rules = message.rules.map(e => e ? VisibilityRule.toSDK(e) : undefined); + } else { + obj.rules = []; + } + return obj; + }, + fromAmino(object: VisibilityAmino): Visibility { + const message = createBaseVisibility(); + message.rules = object.rules?.map(e => VisibilityRule.fromAmino(e)) || []; + return message; + }, + toAmino(message: Visibility): VisibilityAmino { + const obj: any = {}; + if (message.rules) { + obj.rules = message.rules.map(e => e ? VisibilityRule.toAmino(e) : undefined); + } else { + obj.rules = message.rules; + } + return obj; + }, + fromAminoMsg(object: VisibilityAminoMsg): Visibility { + return Visibility.fromAmino(object.value); + }, + fromProtoMsg(message: VisibilityProtoMsg): Visibility { + return Visibility.decode(message.value); + }, + toProto(message: Visibility): Uint8Array { + return Visibility.encode(message).finish(); + }, + toProtoMsg(message: Visibility): VisibilityProtoMsg { + return { + typeUrl: "/google.api.Visibility", + value: Visibility.encode(message).finish() + }; + } +}; +function createBaseVisibilityRule(): VisibilityRule { + return { + selector: "", + restriction: "" + }; +} +export const VisibilityRule = { + typeUrl: "/google.api.VisibilityRule", + encode(message: VisibilityRule, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.selector !== undefined) { + writer.uint32(10).string(message.selector); + } + if (message.restriction !== undefined) { + writer.uint32(18).string(message.restriction); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): VisibilityRule { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseVisibilityRule(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.selector = reader.string(); + break; + case 2: + message.restriction = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): VisibilityRule { + const obj = createBaseVisibilityRule(); + if (isSet(object.selector)) obj.selector = String(object.selector); + if (isSet(object.restriction)) obj.restriction = String(object.restriction); + return obj; + }, + toJSON(message: VisibilityRule): JsonSafe { + const obj: any = {}; + message.selector !== undefined && (obj.selector = message.selector); + message.restriction !== undefined && (obj.restriction = message.restriction); + return obj; + }, + fromPartial(object: DeepPartial): VisibilityRule { + const message = createBaseVisibilityRule(); + message.selector = object.selector ?? ""; + message.restriction = object.restriction ?? ""; + return message; + }, + fromSDK(object: VisibilityRuleSDKType): VisibilityRule { + return { + selector: object?.selector, + restriction: object?.restriction + }; + }, + fromSDKJSON(object: any): VisibilityRuleSDKType { + return { + selector: isSet(object.selector) ? String(object.selector) : "", + restriction: isSet(object.restriction) ? String(object.restriction) : "" + }; + }, + toSDK(message: VisibilityRule): VisibilityRuleSDKType { + const obj: any = {}; + obj.selector = message.selector; + obj.restriction = message.restriction; + return obj; + }, + fromAmino(object: VisibilityRuleAmino): VisibilityRule { + const message = createBaseVisibilityRule(); + if (object.selector !== undefined && object.selector !== null) { + message.selector = object.selector; + } + if (object.restriction !== undefined && object.restriction !== null) { + message.restriction = object.restriction; + } + return message; + }, + toAmino(message: VisibilityRule): VisibilityRuleAmino { + const obj: any = {}; + obj.selector = message.selector === "" ? undefined : message.selector; + obj.restriction = message.restriction === "" ? undefined : message.restriction; + return obj; + }, + fromAminoMsg(object: VisibilityRuleAminoMsg): VisibilityRule { + return VisibilityRule.fromAmino(object.value); + }, + fromProtoMsg(message: VisibilityRuleProtoMsg): VisibilityRule { + return VisibilityRule.decode(message.value); + }, + toProto(message: VisibilityRule): Uint8Array { + return VisibilityRule.encode(message).finish(); + }, + toProtoMsg(message: VisibilityRule): VisibilityRuleProtoMsg { + return { + typeUrl: "/google.api.VisibilityRule", + value: VisibilityRule.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/bundle.ts b/__fixtures__/v-next/outputicjsdeps/google/bundle.ts new file mode 100644 index 0000000000..1d59dbeed3 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/bundle.ts @@ -0,0 +1,120 @@ +import * as _178 from "./api/annotations.js"; +import * as _179 from "./api/auth.js"; +import * as _180 from "./api/backend.js"; +import * as _181 from "./api/billing.js"; +import * as _182 from "./api/client.js"; +import * as _183 from "./api/config_change.js"; +import * as _184 from "./api/consumer.js"; +import * as _185 from "./api/context.js"; +import * as _186 from "./api/control.js"; +import * as _187 from "./api/distribution.js"; +import * as _188 from "./api/documentation.js"; +import * as _189 from "./api/endpoint.js"; +import * as _190 from "./api/error_reason.js"; +import * as _191 from "./api/field_behavior.js"; +import * as _192 from "./api/http.js"; +import * as _193 from "./api/httpbody.js"; +import * as _194 from "./api/label.js"; +import * as _195 from "./api/launch_stage.js"; +import * as _196 from "./api/log.js"; +import * as _197 from "./api/logging.js"; +import * as _198 from "./api/metric.js"; +import * as _199 from "./api/monitored_resource.js"; +import * as _200 from "./api/monitoring.js"; +import * as _201 from "./api/quota.js"; +import * as _202 from "./api/resource.js"; +import * as _203 from "./api/routing.js"; +import * as _204 from "./api/service.js"; +import * as _205 from "./api/source_info.js"; +import * as _206 from "./api/system_parameter.js"; +import * as _207 from "./api/usage.js"; +import * as _208 from "./api/visibility.js"; +import * as _209 from "./logging/type/http_request.js"; +import * as _210 from "./logging/type/log_severity.js"; +import * as _211 from "./logging/v2/log_entry.js"; +import * as _212 from "./logging/v2/logging_config.js"; +import * as _213 from "./logging/v2/logging_metrics.js"; +import * as _214 from "./logging/v2/logging.js"; +import * as _215 from "./longrunning/operations.js"; +import * as _216 from "./protobuf/any.js"; +import * as _217 from "./protobuf/api.js"; +import * as _218 from "./protobuf/descriptor.js"; +import * as _219 from "./protobuf/duration.js"; +import * as _220 from "./protobuf/empty.js"; +import * as _221 from "./protobuf/field_mask.js"; +import * as _222 from "./protobuf/source_context.js"; +import * as _223 from "./protobuf/struct.js"; +import * as _224 from "./protobuf/timestamp.js"; +import * as _225 from "./protobuf/type.js"; +import * as _226 from "./protobuf/wrappers.js"; +import * as _227 from "./rpc/code.js"; +import * as _228 from "./rpc/error_details.js"; +import * as _229 from "./rpc/status.js"; +export namespace google { + export const api = { + ..._178, + ..._179, + ..._180, + ..._181, + ..._182, + ..._183, + ..._184, + ..._185, + ..._186, + ..._187, + ..._188, + ..._189, + ..._190, + ..._191, + ..._192, + ..._193, + ..._194, + ..._195, + ..._196, + ..._197, + ..._198, + ..._199, + ..._200, + ..._201, + ..._202, + ..._203, + ..._204, + ..._205, + ..._206, + ..._207, + ..._208 + }; + export namespace logging { + export const type = { + ..._209, + ..._210 + }; + export const v2 = { + ..._211, + ..._212, + ..._213, + ..._214 + }; + } + export const longrunning = { + ..._215 + }; + export const protobuf = { + ..._216, + ..._217, + ..._218, + ..._219, + ..._220, + ..._221, + ..._222, + ..._223, + ..._224, + ..._225, + ..._226 + }; + export const rpc = { + ..._227, + ..._228, + ..._229 + }; +} \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/logging/type/http_request.ts b/__fixtures__/v-next/outputicjsdeps/google/logging/type/http_request.ts new file mode 100644 index 0000000000..7e80dedf30 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/logging/type/http_request.ts @@ -0,0 +1,444 @@ +import { Duration, DurationSDKType } from "../../protobuf/duration.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "google.logging.type"; +/** + * A common proto for logging HTTP requests. Only contains semantics + * defined by the HTTP specification. Product-specific logging + * information MUST be defined in a separate message. + */ +export interface HttpRequest { + /** The request method. Examples: `"GET"`, `"HEAD"`, `"PUT"`, `"POST"`. */ + requestMethod: string; + /** + * The scheme (http, https), the host name, the path and the query + * portion of the URL that was requested. + * Example: `"http://example.com/some/info?color=red"`. + */ + requestUrl: string; + /** + * The size of the HTTP request message in bytes, including the request + * headers and the request body. + */ + requestSize: bigint; + /** + * The response code indicating the status of response. + * Examples: 200, 404. + */ + status: number; + /** + * The size of the HTTP response message sent back to the client, in bytes, + * including the response headers and the response body. + */ + responseSize: bigint; + /** + * The user agent sent by the client. Example: + * `"Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; Q312461; .NET + * CLR 1.0.3705)"`. + */ + userAgent: string; + /** + * The IP address (IPv4 or IPv6) of the client that issued the HTTP + * request. This field can include port information. Examples: + * `"192.168.1.1"`, `"10.0.0.1:80"`, `"FE80::0202:B3FF:FE1E:8329"`. + */ + remoteIp: string; + /** + * The IP address (IPv4 or IPv6) of the origin server that the request was + * sent to. This field can include port information. Examples: + * `"192.168.1.1"`, `"10.0.0.1:80"`, `"FE80::0202:B3FF:FE1E:8329"`. + */ + serverIp: string; + /** + * The referer URL of the request, as defined in + * [HTTP/1.1 Header Field + * Definitions](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). + */ + referer: string; + /** + * The request processing latency on the server, from the time the request was + * received until the response was sent. + */ + latency?: Duration; + /** Whether or not a cache lookup was attempted. */ + cacheLookup: boolean; + /** + * Whether or not an entity was served from cache + * (with or without validation). + */ + cacheHit: boolean; + /** + * Whether or not the response was validated with the origin server before + * being served from cache. This field is only meaningful if `cache_hit` is + * True. + */ + cacheValidatedWithOriginServer: boolean; + /** + * The number of HTTP response bytes inserted into cache. Set only when a + * cache fill was attempted. + */ + cacheFillBytes: bigint; + /** Protocol used for the request. Examples: "HTTP/1.1", "HTTP/2", "websocket" */ + protocol: string; +} +export interface HttpRequestProtoMsg { + typeUrl: "/google.logging.type.HttpRequest"; + value: Uint8Array; +} +/** + * A common proto for logging HTTP requests. Only contains semantics + * defined by the HTTP specification. Product-specific logging + * information MUST be defined in a separate message. + */ +export interface HttpRequestSDKType { + request_method: string; + request_url: string; + request_size: bigint; + status: number; + response_size: bigint; + user_agent: string; + remote_ip: string; + server_ip: string; + referer: string; + latency?: DurationSDKType; + cache_lookup: boolean; + cache_hit: boolean; + cache_validated_with_origin_server: boolean; + cache_fill_bytes: bigint; + protocol: string; +} +function createBaseHttpRequest(): HttpRequest { + return { + requestMethod: "", + requestUrl: "", + requestSize: BigInt(0), + status: 0, + responseSize: BigInt(0), + userAgent: "", + remoteIp: "", + serverIp: "", + referer: "", + latency: undefined, + cacheLookup: false, + cacheHit: false, + cacheValidatedWithOriginServer: false, + cacheFillBytes: BigInt(0), + protocol: "" + }; +} +export const HttpRequest = { + typeUrl: "/google.logging.type.HttpRequest", + encode(message: HttpRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.requestMethod !== undefined) { + writer.uint32(10).string(message.requestMethod); + } + if (message.requestUrl !== undefined) { + writer.uint32(18).string(message.requestUrl); + } + if (message.requestSize !== undefined) { + writer.uint32(24).int64(message.requestSize); + } + if (message.status !== undefined) { + writer.uint32(32).int32(message.status); + } + if (message.responseSize !== undefined) { + writer.uint32(40).int64(message.responseSize); + } + if (message.userAgent !== undefined) { + writer.uint32(50).string(message.userAgent); + } + if (message.remoteIp !== undefined) { + writer.uint32(58).string(message.remoteIp); + } + if (message.serverIp !== undefined) { + writer.uint32(106).string(message.serverIp); + } + if (message.referer !== undefined) { + writer.uint32(66).string(message.referer); + } + if (message.latency !== undefined) { + Duration.encode(message.latency, writer.uint32(114).fork()).ldelim(); + } + if (message.cacheLookup !== undefined) { + writer.uint32(88).bool(message.cacheLookup); + } + if (message.cacheHit !== undefined) { + writer.uint32(72).bool(message.cacheHit); + } + if (message.cacheValidatedWithOriginServer !== undefined) { + writer.uint32(80).bool(message.cacheValidatedWithOriginServer); + } + if (message.cacheFillBytes !== undefined) { + writer.uint32(96).int64(message.cacheFillBytes); + } + if (message.protocol !== undefined) { + writer.uint32(122).string(message.protocol); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): HttpRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseHttpRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.requestMethod = reader.string(); + break; + case 2: + message.requestUrl = reader.string(); + break; + case 3: + message.requestSize = reader.int64(); + break; + case 4: + message.status = reader.int32(); + break; + case 5: + message.responseSize = reader.int64(); + break; + case 6: + message.userAgent = reader.string(); + break; + case 7: + message.remoteIp = reader.string(); + break; + case 13: + message.serverIp = reader.string(); + break; + case 8: + message.referer = reader.string(); + break; + case 14: + message.latency = Duration.decode(reader, reader.uint32()); + break; + case 11: + message.cacheLookup = reader.bool(); + break; + case 9: + message.cacheHit = reader.bool(); + break; + case 10: + message.cacheValidatedWithOriginServer = reader.bool(); + break; + case 12: + message.cacheFillBytes = reader.int64(); + break; + case 15: + message.protocol = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): HttpRequest { + const obj = createBaseHttpRequest(); + if (isSet(object.requestMethod)) obj.requestMethod = String(object.requestMethod); + if (isSet(object.requestUrl)) obj.requestUrl = String(object.requestUrl); + if (isSet(object.requestSize)) obj.requestSize = BigInt(object.requestSize.toString()); + if (isSet(object.status)) obj.status = Number(object.status); + if (isSet(object.responseSize)) obj.responseSize = BigInt(object.responseSize.toString()); + if (isSet(object.userAgent)) obj.userAgent = String(object.userAgent); + if (isSet(object.remoteIp)) obj.remoteIp = String(object.remoteIp); + if (isSet(object.serverIp)) obj.serverIp = String(object.serverIp); + if (isSet(object.referer)) obj.referer = String(object.referer); + if (isSet(object.latency)) obj.latency = Duration.fromJSON(object.latency); + if (isSet(object.cacheLookup)) obj.cacheLookup = Boolean(object.cacheLookup); + if (isSet(object.cacheHit)) obj.cacheHit = Boolean(object.cacheHit); + if (isSet(object.cacheValidatedWithOriginServer)) obj.cacheValidatedWithOriginServer = Boolean(object.cacheValidatedWithOriginServer); + if (isSet(object.cacheFillBytes)) obj.cacheFillBytes = BigInt(object.cacheFillBytes.toString()); + if (isSet(object.protocol)) obj.protocol = String(object.protocol); + return obj; + }, + toJSON(message: HttpRequest): JsonSafe { + const obj: any = {}; + message.requestMethod !== undefined && (obj.requestMethod = message.requestMethod); + message.requestUrl !== undefined && (obj.requestUrl = message.requestUrl); + message.requestSize !== undefined && (obj.requestSize = (message.requestSize || BigInt(0)).toString()); + message.status !== undefined && (obj.status = Math.round(message.status)); + message.responseSize !== undefined && (obj.responseSize = (message.responseSize || BigInt(0)).toString()); + message.userAgent !== undefined && (obj.userAgent = message.userAgent); + message.remoteIp !== undefined && (obj.remoteIp = message.remoteIp); + message.serverIp !== undefined && (obj.serverIp = message.serverIp); + message.referer !== undefined && (obj.referer = message.referer); + message.latency !== undefined && (obj.latency = message.latency ? Duration.toJSON(message.latency) : undefined); + message.cacheLookup !== undefined && (obj.cacheLookup = message.cacheLookup); + message.cacheHit !== undefined && (obj.cacheHit = message.cacheHit); + message.cacheValidatedWithOriginServer !== undefined && (obj.cacheValidatedWithOriginServer = message.cacheValidatedWithOriginServer); + message.cacheFillBytes !== undefined && (obj.cacheFillBytes = (message.cacheFillBytes || BigInt(0)).toString()); + message.protocol !== undefined && (obj.protocol = message.protocol); + return obj; + }, + fromPartial(object: DeepPartial): HttpRequest { + const message = createBaseHttpRequest(); + message.requestMethod = object.requestMethod ?? ""; + message.requestUrl = object.requestUrl ?? ""; + if (object.requestSize !== undefined && object.requestSize !== null) { + message.requestSize = BigInt(object.requestSize.toString()); + } + message.status = object.status ?? 0; + if (object.responseSize !== undefined && object.responseSize !== null) { + message.responseSize = BigInt(object.responseSize.toString()); + } + message.userAgent = object.userAgent ?? ""; + message.remoteIp = object.remoteIp ?? ""; + message.serverIp = object.serverIp ?? ""; + message.referer = object.referer ?? ""; + if (object.latency !== undefined && object.latency !== null) { + message.latency = Duration.fromPartial(object.latency); + } + message.cacheLookup = object.cacheLookup ?? false; + message.cacheHit = object.cacheHit ?? false; + message.cacheValidatedWithOriginServer = object.cacheValidatedWithOriginServer ?? false; + if (object.cacheFillBytes !== undefined && object.cacheFillBytes !== null) { + message.cacheFillBytes = BigInt(object.cacheFillBytes.toString()); + } + message.protocol = object.protocol ?? ""; + return message; + }, + fromSDK(object: HttpRequestSDKType): HttpRequest { + return { + requestMethod: object?.request_method, + requestUrl: object?.request_url, + requestSize: object?.request_size, + status: object?.status, + responseSize: object?.response_size, + userAgent: object?.user_agent, + remoteIp: object?.remote_ip, + serverIp: object?.server_ip, + referer: object?.referer, + latency: object.latency ? Duration.fromSDK(object.latency) : undefined, + cacheLookup: object?.cache_lookup, + cacheHit: object?.cache_hit, + cacheValidatedWithOriginServer: object?.cache_validated_with_origin_server, + cacheFillBytes: object?.cache_fill_bytes, + protocol: object?.protocol + }; + }, + fromSDKJSON(object: any): HttpRequestSDKType { + return { + request_method: isSet(object.request_method) ? String(object.request_method) : "", + request_url: isSet(object.request_url) ? String(object.request_url) : "", + request_size: isSet(object.request_size) ? BigInt(object.request_size.toString()) : BigInt(0), + status: isSet(object.status) ? Number(object.status) : 0, + response_size: isSet(object.response_size) ? BigInt(object.response_size.toString()) : BigInt(0), + user_agent: isSet(object.user_agent) ? String(object.user_agent) : "", + remote_ip: isSet(object.remote_ip) ? String(object.remote_ip) : "", + server_ip: isSet(object.server_ip) ? String(object.server_ip) : "", + referer: isSet(object.referer) ? String(object.referer) : "", + latency: isSet(object.latency) ? Duration.fromSDKJSON(object.latency) : undefined, + cache_lookup: isSet(object.cache_lookup) ? Boolean(object.cache_lookup) : false, + cache_hit: isSet(object.cache_hit) ? Boolean(object.cache_hit) : false, + cache_validated_with_origin_server: isSet(object.cache_validated_with_origin_server) ? Boolean(object.cache_validated_with_origin_server) : false, + cache_fill_bytes: isSet(object.cache_fill_bytes) ? BigInt(object.cache_fill_bytes.toString()) : BigInt(0), + protocol: isSet(object.protocol) ? String(object.protocol) : "" + }; + }, + toSDK(message: HttpRequest): HttpRequestSDKType { + const obj: any = {}; + obj.request_method = message.requestMethod; + obj.request_url = message.requestUrl; + obj.request_size = message.requestSize; + obj.status = message.status; + obj.response_size = message.responseSize; + obj.user_agent = message.userAgent; + obj.remote_ip = message.remoteIp; + obj.server_ip = message.serverIp; + obj.referer = message.referer; + message.latency !== undefined && (obj.latency = message.latency ? Duration.toSDK(message.latency) : undefined); + obj.cache_lookup = message.cacheLookup; + obj.cache_hit = message.cacheHit; + obj.cache_validated_with_origin_server = message.cacheValidatedWithOriginServer; + obj.cache_fill_bytes = message.cacheFillBytes; + obj.protocol = message.protocol; + return obj; + }, + fromAmino(object: HttpRequestAmino): HttpRequest { + const message = createBaseHttpRequest(); + if (object.request_method !== undefined && object.request_method !== null) { + message.requestMethod = object.request_method; + } + if (object.request_url !== undefined && object.request_url !== null) { + message.requestUrl = object.request_url; + } + if (object.request_size !== undefined && object.request_size !== null) { + message.requestSize = BigInt(object.request_size); + } + if (object.status !== undefined && object.status !== null) { + message.status = object.status; + } + if (object.response_size !== undefined && object.response_size !== null) { + message.responseSize = BigInt(object.response_size); + } + if (object.user_agent !== undefined && object.user_agent !== null) { + message.userAgent = object.user_agent; + } + if (object.remote_ip !== undefined && object.remote_ip !== null) { + message.remoteIp = object.remote_ip; + } + if (object.server_ip !== undefined && object.server_ip !== null) { + message.serverIp = object.server_ip; + } + if (object.referer !== undefined && object.referer !== null) { + message.referer = object.referer; + } + if (object.latency !== undefined && object.latency !== null) { + message.latency = Duration.fromAmino(object.latency); + } + if (object.cache_lookup !== undefined && object.cache_lookup !== null) { + message.cacheLookup = object.cache_lookup; + } + if (object.cache_hit !== undefined && object.cache_hit !== null) { + message.cacheHit = object.cache_hit; + } + if (object.cache_validated_with_origin_server !== undefined && object.cache_validated_with_origin_server !== null) { + message.cacheValidatedWithOriginServer = object.cache_validated_with_origin_server; + } + if (object.cache_fill_bytes !== undefined && object.cache_fill_bytes !== null) { + message.cacheFillBytes = BigInt(object.cache_fill_bytes); + } + if (object.protocol !== undefined && object.protocol !== null) { + message.protocol = object.protocol; + } + return message; + }, + toAmino(message: HttpRequest): HttpRequestAmino { + const obj: any = {}; + obj.request_method = message.requestMethod === "" ? undefined : message.requestMethod; + obj.request_url = message.requestUrl === "" ? undefined : message.requestUrl; + obj.request_size = message.requestSize !== BigInt(0) ? message.requestSize?.toString() : undefined; + obj.status = message.status === 0 ? undefined : message.status; + obj.response_size = message.responseSize !== BigInt(0) ? message.responseSize?.toString() : undefined; + obj.user_agent = message.userAgent === "" ? undefined : message.userAgent; + obj.remote_ip = message.remoteIp === "" ? undefined : message.remoteIp; + obj.server_ip = message.serverIp === "" ? undefined : message.serverIp; + obj.referer = message.referer === "" ? undefined : message.referer; + obj.latency = message.latency ? Duration.toAmino(message.latency) : undefined; + obj.cache_lookup = message.cacheLookup === false ? undefined : message.cacheLookup; + obj.cache_hit = message.cacheHit === false ? undefined : message.cacheHit; + obj.cache_validated_with_origin_server = message.cacheValidatedWithOriginServer === false ? undefined : message.cacheValidatedWithOriginServer; + obj.cache_fill_bytes = message.cacheFillBytes !== BigInt(0) ? message.cacheFillBytes?.toString() : undefined; + obj.protocol = message.protocol === "" ? undefined : message.protocol; + return obj; + }, + fromAminoMsg(object: HttpRequestAminoMsg): HttpRequest { + return HttpRequest.fromAmino(object.value); + }, + fromProtoMsg(message: HttpRequestProtoMsg): HttpRequest { + return HttpRequest.decode(message.value); + }, + toProto(message: HttpRequest): Uint8Array { + return HttpRequest.encode(message).finish(); + }, + toProtoMsg(message: HttpRequest): HttpRequestProtoMsg { + return { + typeUrl: "/google.logging.type.HttpRequest", + value: HttpRequest.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/logging/type/log_severity.ts b/__fixtures__/v-next/outputicjsdeps/google/logging/type/log_severity.ts new file mode 100644 index 0000000000..17fae166c6 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/logging/type/log_severity.ts @@ -0,0 +1,103 @@ +export const protobufPackage = "google.logging.type"; +/** + * The severity of the event described in a log entry, expressed as one of the + * standard severity levels listed below. For your reference, the levels are + * assigned the listed numeric values. The effect of using numeric values other + * than those listed is undefined. + * + * You can filter for log entries by severity. For example, the following + * filter expression will match log entries with severities `INFO`, `NOTICE`, + * and `WARNING`: + * + * severity > DEBUG AND severity <= WARNING + * + * If you are writing log entries, you should map other severity encodings to + * one of these standard levels. For example, you might map all of Java's FINE, + * FINER, and FINEST levels to `LogSeverity.DEBUG`. You can preserve the + * original severity level in the log entry payload if you wish. + */ +export enum LogSeverity { + /** DEFAULT - (0) The log entry has no assigned severity level. */ + DEFAULT = 0, + /** DEBUG - (100) Debug or trace information. */ + DEBUG = 100, + /** INFO - (200) Routine information, such as ongoing status or performance. */ + INFO = 200, + /** + * NOTICE - (300) Normal but significant events, such as start up, shut down, or + * a configuration change. + */ + NOTICE = 300, + /** WARNING - (400) Warning events might cause problems. */ + WARNING = 400, + /** ERROR - (500) Error events are likely to cause problems. */ + ERROR = 500, + /** CRITICAL - (600) Critical events cause more severe problems or outages. */ + CRITICAL = 600, + /** ALERT - (700) A person must take an action immediately. */ + ALERT = 700, + /** EMERGENCY - (800) One or more systems are unusable. */ + EMERGENCY = 800, + UNRECOGNIZED = -1, +} +export const LogSeveritySDKType = LogSeverity; +export function logSeverityFromJSON(object: any): LogSeverity { + switch (object) { + case 0: + case "DEFAULT": + return LogSeverity.DEFAULT; + case 100: + case "DEBUG": + return LogSeverity.DEBUG; + case 200: + case "INFO": + return LogSeverity.INFO; + case 300: + case "NOTICE": + return LogSeverity.NOTICE; + case 400: + case "WARNING": + return LogSeverity.WARNING; + case 500: + case "ERROR": + return LogSeverity.ERROR; + case 600: + case "CRITICAL": + return LogSeverity.CRITICAL; + case 700: + case "ALERT": + return LogSeverity.ALERT; + case 800: + case "EMERGENCY": + return LogSeverity.EMERGENCY; + case -1: + case "UNRECOGNIZED": + default: + return LogSeverity.UNRECOGNIZED; + } +} +export function logSeverityToJSON(object: LogSeverity): string { + switch (object) { + case LogSeverity.DEFAULT: + return "DEFAULT"; + case LogSeverity.DEBUG: + return "DEBUG"; + case LogSeverity.INFO: + return "INFO"; + case LogSeverity.NOTICE: + return "NOTICE"; + case LogSeverity.WARNING: + return "WARNING"; + case LogSeverity.ERROR: + return "ERROR"; + case LogSeverity.CRITICAL: + return "CRITICAL"; + case LogSeverity.ALERT: + return "ALERT"; + case LogSeverity.EMERGENCY: + return "EMERGENCY"; + case LogSeverity.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/logging/v2/log_entry.ts b/__fixtures__/v-next/outputicjsdeps/google/logging/v2/log_entry.ts new file mode 100644 index 0000000000..ce7a3a0f3d --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/logging/v2/log_entry.ts @@ -0,0 +1,1209 @@ +import { MonitoredResource, MonitoredResourceSDKType } from "../../api/monitored_resource.js"; +import { Any, AnySDKType } from "../../protobuf/any.js"; +import { Struct, StructSDKType } from "../../protobuf/struct.js"; +import { Timestamp, TimestampSDKType } from "../../protobuf/timestamp.js"; +import { LogSeverity, LogSeveritySDKType, logSeverityFromJSON, logSeverityToJSON } from "../type/log_severity.js"; +import { HttpRequest, HttpRequestSDKType } from "../type/http_request.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial, toTimestamp, fromTimestamp, isObject } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "google.logging.v2"; +export interface LogEntry_LabelsEntry { + key: string; + value: string; +} +export interface LogEntry_LabelsEntryProtoMsg { + typeUrl: string; + value: Uint8Array; +} +export interface LogEntry_LabelsEntrySDKType { + key: string; + value: string; +} +/** An individual entry in a log. */ +export interface LogEntry { + /** + * Required. The resource name of the log to which this log entry belongs: + * + * "projects/[PROJECT_ID]/logs/[LOG_ID]" + * "organizations/[ORGANIZATION_ID]/logs/[LOG_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]/logs/[LOG_ID]" + * "folders/[FOLDER_ID]/logs/[LOG_ID]" + * + * A project number may be used in place of PROJECT_ID. The project number is + * translated to its corresponding PROJECT_ID internally and the `log_name` + * field will contain PROJECT_ID in queries and exports. + * + * `[LOG_ID]` must be URL-encoded within `log_name`. Example: + * `"organizations/1234567890/logs/cloudresourcemanager.googleapis.com%2Factivity"`. + * + * `[LOG_ID]` must be less than 512 characters long and can only include the + * following characters: upper and lower case alphanumeric characters, + * forward-slash, underscore, hyphen, and period. + * + * For backward compatibility, if `log_name` begins with a forward-slash, such + * as `/projects/...`, then the log entry is ingested as usual, but the + * forward-slash is removed. Listing the log entry will not show the leading + * slash and filtering for a log name with a leading slash will never return + * any results. + */ + logName: string; + /** + * Required. The monitored resource that produced this log entry. + * + * Example: a log entry that reports a database error would be associated with + * the monitored resource designating the particular database that reported + * the error. + */ + resource?: MonitoredResource; + /** + * The log entry payload, represented as a protocol buffer. Some Google + * Cloud Platform services use this field for their log entry payloads. + * + * The following protocol buffer types are supported; user-defined types + * are not supported: + * + * "type.googleapis.com/google.cloud.audit.AuditLog" + * "type.googleapis.com/google.appengine.logging.v1.RequestLog" + */ + protoPayload?: Any; + /** The log entry payload, represented as a Unicode string (UTF-8). */ + textPayload?: string; + /** + * The log entry payload, represented as a structure that is + * expressed as a JSON object. + */ + jsonPayload?: Struct; + /** + * Optional. The time the event described by the log entry occurred. This time is used + * to compute the log entry's age and to enforce the logs retention period. + * If this field is omitted in a new log entry, then Logging assigns it the + * current time. Timestamps have nanosecond accuracy, but trailing zeros in + * the fractional seconds might be omitted when the timestamp is displayed. + * + * Incoming log entries must have timestamps that don't exceed the + * [logs retention + * period](https://cloud.google.com/logging/quotas#logs_retention_periods) in + * the past, and that don't exceed 24 hours in the future. Log entries outside + * those time boundaries aren't ingested by Logging. + */ + timestamp?: Date; + /** Output only. The time the log entry was received by Logging. */ + receiveTimestamp?: Date; + /** Optional. The severity of the log entry. The default value is `LogSeverity.DEFAULT`. */ + severity: LogSeverity; + /** + * Optional. A unique identifier for the log entry. If you provide a value, then + * Logging considers other log entries in the same project, with the same + * `timestamp`, and with the same `insert_id` to be duplicates which are + * removed in a single query result. However, there are no guarantees of + * de-duplication in the export of logs. + * + * If the `insert_id` is omitted when writing a log entry, the Logging API + * assigns its own unique identifier in this field. + * + * In queries, the `insert_id` is also used to order log entries that have + * the same `log_name` and `timestamp` values. + */ + insertId: string; + /** + * Optional. Information about the HTTP request associated with this log entry, if + * applicable. + */ + httpRequest?: HttpRequest; + /** + * Optional. A map of key, value pairs that provides additional information about the + * log entry. The labels can be user-defined or system-defined. + * + * User-defined labels are arbitrary key, value pairs that you can use to + * classify logs. + * + * System-defined labels are defined by GCP services for platform logs. + * They have two components - a service namespace component and the + * attribute name. For example: `compute.googleapis.com/resource_name`. + * + * Cloud Logging truncates label keys that exceed 512 B and label + * values that exceed 64 KB upon their associated log entry being + * written. The truncation is indicated by an ellipsis at the + * end of the character string. + */ + labels: { + [key: string]: string; + }; + /** + * Optional. Information about an operation associated with the log entry, if + * applicable. + */ + operation?: LogEntryOperation; + /** + * Optional. Resource name of the trace associated with the log entry, if any. If it + * contains a relative resource name, the name is assumed to be relative to + * `//tracing.googleapis.com`. Example: + * `projects/my-projectid/traces/06796866738c859f2f19b7cfb3214824` + */ + trace: string; + /** + * Optional. The span ID within the trace associated with the log entry. + * + * For Trace spans, this is the same format that the Trace API v2 uses: a + * 16-character hexadecimal encoding of an 8-byte array, such as + * `000000000000004a`. + */ + spanId: string; + /** + * Optional. The sampling decision of the trace associated with the log entry. + * + * True means that the trace resource name in the `trace` field was sampled + * for storage in a trace backend. False means that the trace was not sampled + * for storage when this log entry was written, or the sampling decision was + * unknown at the time. A non-sampled `trace` value is still useful as a + * request correlation identifier. The default is False. + */ + traceSampled: boolean; + /** Optional. Source code location information associated with the log entry, if any. */ + sourceLocation?: LogEntrySourceLocation; + /** + * Optional. Information indicating this LogEntry is part of a sequence of multiple log + * entries split from a single LogEntry. + */ + split?: LogSplit; +} +export interface LogEntryProtoMsg { + typeUrl: "/google.logging.v2.LogEntry"; + value: Uint8Array; +} +/** An individual entry in a log. */ +export interface LogEntrySDKType { + log_name: string; + resource?: MonitoredResourceSDKType; + proto_payload?: AnySDKType; + text_payload?: string; + json_payload?: StructSDKType; + timestamp?: Date; + receive_timestamp?: Date; + severity: LogSeverity; + insert_id: string; + http_request?: HttpRequestSDKType; + labels: { + [key: string]: string; + }; + operation?: LogEntryOperationSDKType; + trace: string; + span_id: string; + trace_sampled: boolean; + source_location?: LogEntrySourceLocationSDKType; + split?: LogSplitSDKType; +} +/** + * Additional information about a potentially long-running operation with which + * a log entry is associated. + */ +export interface LogEntryOperation { + /** + * Optional. An arbitrary operation identifier. Log entries with the same + * identifier are assumed to be part of the same operation. + */ + id: string; + /** + * Optional. An arbitrary producer identifier. The combination of `id` and + * `producer` must be globally unique. Examples for `producer`: + * `"MyDivision.MyBigCompany.com"`, `"github.com/MyProject/MyApplication"`. + */ + producer: string; + /** Optional. Set this to True if this is the first log entry in the operation. */ + first: boolean; + /** Optional. Set this to True if this is the last log entry in the operation. */ + last: boolean; +} +export interface LogEntryOperationProtoMsg { + typeUrl: "/google.logging.v2.LogEntryOperation"; + value: Uint8Array; +} +/** + * Additional information about a potentially long-running operation with which + * a log entry is associated. + */ +export interface LogEntryOperationSDKType { + id: string; + producer: string; + first: boolean; + last: boolean; +} +/** + * Additional information about the source code location that produced the log + * entry. + */ +export interface LogEntrySourceLocation { + /** + * Optional. Source file name. Depending on the runtime environment, this + * might be a simple name or a fully-qualified name. + */ + file: string; + /** + * Optional. Line within the source file. 1-based; 0 indicates no line number + * available. + */ + line: bigint; + /** + * Optional. Human-readable name of the function or method being invoked, with + * optional context such as the class or package name. This information may be + * used in contexts such as the logs viewer, where a file and line number are + * less meaningful. The format can vary by language. For example: + * `qual.if.ied.Class.method` (Java), `dir/package.func` (Go), `function` + * (Python). + */ + function: string; +} +export interface LogEntrySourceLocationProtoMsg { + typeUrl: "/google.logging.v2.LogEntrySourceLocation"; + value: Uint8Array; +} +/** + * Additional information about the source code location that produced the log + * entry. + */ +export interface LogEntrySourceLocationSDKType { + file: string; + line: bigint; + function: string; +} +/** + * Additional information used to correlate multiple log entries. Used when a + * single LogEntry would exceed the Google Cloud Logging size limit and is + * split across multiple log entries. + */ +export interface LogSplit { + /** + * A globally unique identifier for all log entries in a sequence of split log + * entries. All log entries with the same |LogSplit.uid| are assumed to be + * part of the same sequence of split log entries. + */ + uid: string; + /** + * The index of this LogEntry in the sequence of split log entries. Log + * entries are given |index| values 0, 1, ..., n-1 for a sequence of n log + * entries. + */ + index: number; + /** The total number of log entries that the original LogEntry was split into. */ + totalSplits: number; +} +export interface LogSplitProtoMsg { + typeUrl: "/google.logging.v2.LogSplit"; + value: Uint8Array; +} +/** + * Additional information used to correlate multiple log entries. Used when a + * single LogEntry would exceed the Google Cloud Logging size limit and is + * split across multiple log entries. + */ +export interface LogSplitSDKType { + uid: string; + index: number; + total_splits: number; +} +function createBaseLogEntry_LabelsEntry(): LogEntry_LabelsEntry { + return { + key: "", + value: "" + }; +} +export const LogEntry_LabelsEntry = { + encode(message: LogEntry_LabelsEntry, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.key !== undefined) { + writer.uint32(10).string(message.key); + } + if (message.value !== undefined) { + writer.uint32(18).string(message.value); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): LogEntry_LabelsEntry { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseLogEntry_LabelsEntry(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.string(); + break; + case 2: + message.value = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): LogEntry_LabelsEntry { + const obj = createBaseLogEntry_LabelsEntry(); + if (isSet(object.key)) obj.key = String(object.key); + if (isSet(object.value)) obj.value = String(object.value); + return obj; + }, + toJSON(message: LogEntry_LabelsEntry): JsonSafe { + const obj: any = {}; + message.key !== undefined && (obj.key = message.key); + message.value !== undefined && (obj.value = message.value); + return obj; + }, + fromPartial(object: DeepPartial): LogEntry_LabelsEntry { + const message = createBaseLogEntry_LabelsEntry(); + message.key = object.key ?? ""; + message.value = object.value ?? ""; + return message; + }, + fromSDK(object: LogEntry_LabelsEntrySDKType): LogEntry_LabelsEntry { + return { + key: object?.key, + value: object?.value + }; + }, + fromSDKJSON(object: any): LogEntry_LabelsEntrySDKType { + return { + key: isSet(object.key) ? String(object.key) : "", + value: isSet(object.value) ? String(object.value) : "" + }; + }, + toSDK(message: LogEntry_LabelsEntry): LogEntry_LabelsEntrySDKType { + const obj: any = {}; + obj.key = message.key; + obj.value = message.value; + return obj; + }, + fromAmino(object: LogEntry_LabelsEntryAmino): LogEntry_LabelsEntry { + const message = createBaseLogEntry_LabelsEntry(); + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } + if (object.value !== undefined && object.value !== null) { + message.value = object.value; + } + return message; + }, + toAmino(message: LogEntry_LabelsEntry): LogEntry_LabelsEntryAmino { + const obj: any = {}; + obj.key = message.key === "" ? undefined : message.key; + obj.value = message.value === "" ? undefined : message.value; + return obj; + }, + fromAminoMsg(object: LogEntry_LabelsEntryAminoMsg): LogEntry_LabelsEntry { + return LogEntry_LabelsEntry.fromAmino(object.value); + }, + fromProtoMsg(message: LogEntry_LabelsEntryProtoMsg): LogEntry_LabelsEntry { + return LogEntry_LabelsEntry.decode(message.value); + }, + toProto(message: LogEntry_LabelsEntry): Uint8Array { + return LogEntry_LabelsEntry.encode(message).finish(); + } +}; +function createBaseLogEntry(): LogEntry { + return { + logName: "", + resource: undefined, + protoPayload: undefined, + textPayload: undefined, + jsonPayload: undefined, + timestamp: undefined, + receiveTimestamp: undefined, + severity: 0, + insertId: "", + httpRequest: undefined, + labels: {}, + operation: undefined, + trace: "", + spanId: "", + traceSampled: false, + sourceLocation: undefined, + split: undefined + }; +} +export const LogEntry = { + typeUrl: "/google.logging.v2.LogEntry", + encode(message: LogEntry, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.logName !== undefined) { + writer.uint32(98).string(message.logName); + } + if (message.resource !== undefined) { + MonitoredResource.encode(message.resource, writer.uint32(66).fork()).ldelim(); + } + if (message.protoPayload !== undefined) { + Any.encode(message.protoPayload, writer.uint32(18).fork()).ldelim(); + } + if (message.textPayload !== undefined) { + writer.uint32(26).string(message.textPayload); + } + if (message.jsonPayload !== undefined) { + Struct.encode(message.jsonPayload, writer.uint32(50).fork()).ldelim(); + } + if (message.timestamp !== undefined) { + Timestamp.encode(toTimestamp(message.timestamp), writer.uint32(74).fork()).ldelim(); + } + if (message.receiveTimestamp !== undefined) { + Timestamp.encode(toTimestamp(message.receiveTimestamp), writer.uint32(194).fork()).ldelim(); + } + if (message.severity !== 0) { + writer.uint32(80).int32(message.severity); + } + if (message.insertId !== undefined) { + writer.uint32(34).string(message.insertId); + } + if (message.httpRequest !== undefined) { + HttpRequest.encode(message.httpRequest, writer.uint32(58).fork()).ldelim(); + } + Object.entries(message.labels).forEach(([key, value]) => { + LogEntry_LabelsEntry.encode({ + key: (key as any), + value + }, writer.uint32(90).fork()).ldelim(); + }); + if (message.operation !== undefined) { + LogEntryOperation.encode(message.operation, writer.uint32(122).fork()).ldelim(); + } + if (message.trace !== undefined) { + writer.uint32(178).string(message.trace); + } + if (message.spanId !== undefined) { + writer.uint32(218).string(message.spanId); + } + if (message.traceSampled !== undefined) { + writer.uint32(240).bool(message.traceSampled); + } + if (message.sourceLocation !== undefined) { + LogEntrySourceLocation.encode(message.sourceLocation, writer.uint32(186).fork()).ldelim(); + } + if (message.split !== undefined) { + LogSplit.encode(message.split, writer.uint32(282).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): LogEntry { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseLogEntry(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 12: + message.logName = reader.string(); + break; + case 8: + message.resource = MonitoredResource.decode(reader, reader.uint32()); + break; + case 2: + message.protoPayload = Any.decode(reader, reader.uint32()); + break; + case 3: + message.textPayload = reader.string(); + break; + case 6: + message.jsonPayload = Struct.decode(reader, reader.uint32()); + break; + case 9: + message.timestamp = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + break; + case 24: + message.receiveTimestamp = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + break; + case 10: + message.severity = (reader.int32() as any); + break; + case 4: + message.insertId = reader.string(); + break; + case 7: + message.httpRequest = HttpRequest.decode(reader, reader.uint32()); + break; + case 11: + const entry11 = LogEntry_LabelsEntry.decode(reader, reader.uint32()); + if (entry11.value !== undefined) { + message.labels[entry11.key] = entry11.value; + } + break; + case 15: + message.operation = LogEntryOperation.decode(reader, reader.uint32()); + break; + case 22: + message.trace = reader.string(); + break; + case 27: + message.spanId = reader.string(); + break; + case 30: + message.traceSampled = reader.bool(); + break; + case 23: + message.sourceLocation = LogEntrySourceLocation.decode(reader, reader.uint32()); + break; + case 35: + message.split = LogSplit.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): LogEntry { + const obj = createBaseLogEntry(); + if (isSet(object.logName)) obj.logName = String(object.logName); + if (isSet(object.resource)) obj.resource = MonitoredResource.fromJSON(object.resource); + if (isSet(object.protoPayload)) obj.protoPayload = Any.fromJSON(object.protoPayload); + if (isSet(object.textPayload)) obj.textPayload = String(object.textPayload); + if (isSet(object.jsonPayload)) obj.jsonPayload = Struct.fromJSON(object.jsonPayload); + if (isSet(object.timestamp)) obj.timestamp = new Date(object.timestamp); + if (isSet(object.receiveTimestamp)) obj.receiveTimestamp = new Date(object.receiveTimestamp); + if (isSet(object.severity)) obj.severity = logSeverityFromJSON(object.severity); + if (isSet(object.insertId)) obj.insertId = String(object.insertId); + if (isSet(object.httpRequest)) obj.httpRequest = HttpRequest.fromJSON(object.httpRequest); + if (isObject(object.labels)) obj.labels = Object.entries(object.labels).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + acc[key] = String(value); + return acc; + }, {}); + if (isSet(object.operation)) obj.operation = LogEntryOperation.fromJSON(object.operation); + if (isSet(object.trace)) obj.trace = String(object.trace); + if (isSet(object.spanId)) obj.spanId = String(object.spanId); + if (isSet(object.traceSampled)) obj.traceSampled = Boolean(object.traceSampled); + if (isSet(object.sourceLocation)) obj.sourceLocation = LogEntrySourceLocation.fromJSON(object.sourceLocation); + if (isSet(object.split)) obj.split = LogSplit.fromJSON(object.split); + return obj; + }, + toJSON(message: LogEntry): JsonSafe { + const obj: any = {}; + message.logName !== undefined && (obj.logName = message.logName); + message.resource !== undefined && (obj.resource = message.resource ? MonitoredResource.toJSON(message.resource) : undefined); + message.protoPayload !== undefined && (obj.protoPayload = message.protoPayload ? Any.toJSON(message.protoPayload) : undefined); + message.textPayload !== undefined && (obj.textPayload = message.textPayload); + message.jsonPayload !== undefined && (obj.jsonPayload = message.jsonPayload ? Struct.toJSON(message.jsonPayload) : undefined); + message.timestamp !== undefined && (obj.timestamp = message.timestamp.toISOString()); + message.receiveTimestamp !== undefined && (obj.receiveTimestamp = message.receiveTimestamp.toISOString()); + message.severity !== undefined && (obj.severity = logSeverityToJSON(message.severity)); + message.insertId !== undefined && (obj.insertId = message.insertId); + message.httpRequest !== undefined && (obj.httpRequest = message.httpRequest ? HttpRequest.toJSON(message.httpRequest) : undefined); + obj.labels = {}; + if (message.labels) { + Object.entries(message.labels).forEach(([k, v]) => { + obj.labels[k] = v; + }); + } + message.operation !== undefined && (obj.operation = message.operation ? LogEntryOperation.toJSON(message.operation) : undefined); + message.trace !== undefined && (obj.trace = message.trace); + message.spanId !== undefined && (obj.spanId = message.spanId); + message.traceSampled !== undefined && (obj.traceSampled = message.traceSampled); + message.sourceLocation !== undefined && (obj.sourceLocation = message.sourceLocation ? LogEntrySourceLocation.toJSON(message.sourceLocation) : undefined); + message.split !== undefined && (obj.split = message.split ? LogSplit.toJSON(message.split) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): LogEntry { + const message = createBaseLogEntry(); + message.logName = object.logName ?? ""; + if (object.resource !== undefined && object.resource !== null) { + message.resource = MonitoredResource.fromPartial(object.resource); + } + if (object.protoPayload !== undefined && object.protoPayload !== null) { + message.protoPayload = Any.fromPartial(object.protoPayload); + } + message.textPayload = object.textPayload ?? undefined; + if (object.jsonPayload !== undefined && object.jsonPayload !== null) { + message.jsonPayload = Struct.fromPartial(object.jsonPayload); + } + message.timestamp = object.timestamp ?? undefined; + message.receiveTimestamp = object.receiveTimestamp ?? undefined; + message.severity = object.severity ?? 0; + message.insertId = object.insertId ?? ""; + if (object.httpRequest !== undefined && object.httpRequest !== null) { + message.httpRequest = HttpRequest.fromPartial(object.httpRequest); + } + message.labels = Object.entries(object.labels ?? {}).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + if (value !== undefined) { + acc[key] = String(value); + } + return acc; + }, {}); + if (object.operation !== undefined && object.operation !== null) { + message.operation = LogEntryOperation.fromPartial(object.operation); + } + message.trace = object.trace ?? ""; + message.spanId = object.spanId ?? ""; + message.traceSampled = object.traceSampled ?? false; + if (object.sourceLocation !== undefined && object.sourceLocation !== null) { + message.sourceLocation = LogEntrySourceLocation.fromPartial(object.sourceLocation); + } + if (object.split !== undefined && object.split !== null) { + message.split = LogSplit.fromPartial(object.split); + } + return message; + }, + fromSDK(object: LogEntrySDKType): LogEntry { + return { + logName: object?.log_name, + resource: object.resource ? MonitoredResource.fromSDK(object.resource) : undefined, + protoPayload: object.proto_payload ? Any.fromSDK(object.proto_payload) : undefined, + textPayload: object?.text_payload, + jsonPayload: object.json_payload ? Struct.fromSDK(object.json_payload) : undefined, + timestamp: object.timestamp ?? undefined, + receiveTimestamp: object.receive_timestamp ?? undefined, + severity: isSet(object.severity) ? logSeverityFromJSON(object.severity) : -1, + insertId: object?.insert_id, + httpRequest: object.http_request ? HttpRequest.fromSDK(object.http_request) : undefined, + labels: isObject(object.labels) ? Object.entries(object.labels).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + acc[key] = String(value); + return acc; + }, {}) : {}, + operation: object.operation ? LogEntryOperation.fromSDK(object.operation) : undefined, + trace: object?.trace, + spanId: object?.span_id, + traceSampled: object?.trace_sampled, + sourceLocation: object.source_location ? LogEntrySourceLocation.fromSDK(object.source_location) : undefined, + split: object.split ? LogSplit.fromSDK(object.split) : undefined + }; + }, + fromSDKJSON(object: any): LogEntrySDKType { + return { + log_name: isSet(object.log_name) ? String(object.log_name) : "", + resource: isSet(object.resource) ? MonitoredResource.fromSDKJSON(object.resource) : undefined, + proto_payload: isSet(object.proto_payload) ? Any.fromSDKJSON(object.proto_payload) : undefined, + text_payload: isSet(object.text_payload) ? String(object.text_payload) : undefined, + json_payload: isSet(object.json_payload) ? Struct.fromSDKJSON(object.json_payload) : undefined, + timestamp: isSet(object.timestamp) ? new Date(object.timestamp) : undefined, + receive_timestamp: isSet(object.receive_timestamp) ? new Date(object.receive_timestamp) : undefined, + severity: isSet(object.severity) ? logSeverityFromJSON(object.severity) : -1, + insert_id: isSet(object.insert_id) ? String(object.insert_id) : "", + http_request: isSet(object.http_request) ? HttpRequest.fromSDKJSON(object.http_request) : undefined, + labels: isObject(object.labels) ? Object.entries(object.labels).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + acc[key] = String(value); + return acc; + }, {}) : {}, + operation: isSet(object.operation) ? LogEntryOperation.fromSDKJSON(object.operation) : undefined, + trace: isSet(object.trace) ? String(object.trace) : "", + span_id: isSet(object.span_id) ? String(object.span_id) : "", + trace_sampled: isSet(object.trace_sampled) ? Boolean(object.trace_sampled) : false, + source_location: isSet(object.source_location) ? LogEntrySourceLocation.fromSDKJSON(object.source_location) : undefined, + split: isSet(object.split) ? LogSplit.fromSDKJSON(object.split) : undefined + }; + }, + toSDK(message: LogEntry): LogEntrySDKType { + const obj: any = {}; + obj.log_name = message.logName; + message.resource !== undefined && (obj.resource = message.resource ? MonitoredResource.toSDK(message.resource) : undefined); + message.protoPayload !== undefined && (obj.proto_payload = message.protoPayload ? Any.toSDK(message.protoPayload) : undefined); + obj.text_payload = message.textPayload; + message.jsonPayload !== undefined && (obj.json_payload = message.jsonPayload ? Struct.toSDK(message.jsonPayload) : undefined); + message.timestamp !== undefined && (obj.timestamp = message.timestamp ?? undefined); + message.receiveTimestamp !== undefined && (obj.receive_timestamp = message.receiveTimestamp ?? undefined); + message.severity !== undefined && (obj.severity = logSeverityToJSON(message.severity)); + obj.insert_id = message.insertId; + message.httpRequest !== undefined && (obj.http_request = message.httpRequest ? HttpRequest.toSDK(message.httpRequest) : undefined); + obj.labels = {}; + if (message.labels) { + Object.entries(message.labels).forEach(([k, v]) => { + obj.labels[k] = v; + }); + } + message.operation !== undefined && (obj.operation = message.operation ? LogEntryOperation.toSDK(message.operation) : undefined); + obj.trace = message.trace; + obj.span_id = message.spanId; + obj.trace_sampled = message.traceSampled; + message.sourceLocation !== undefined && (obj.source_location = message.sourceLocation ? LogEntrySourceLocation.toSDK(message.sourceLocation) : undefined); + message.split !== undefined && (obj.split = message.split ? LogSplit.toSDK(message.split) : undefined); + return obj; + }, + fromAmino(object: LogEntryAmino): LogEntry { + const message = createBaseLogEntry(); + if (object.log_name !== undefined && object.log_name !== null) { + message.logName = object.log_name; + } + if (object.resource !== undefined && object.resource !== null) { + message.resource = MonitoredResource.fromAmino(object.resource); + } + if (object.proto_payload !== undefined && object.proto_payload !== null) { + message.protoPayload = Any.fromAmino(object.proto_payload); + } + if (object.text_payload !== undefined && object.text_payload !== null) { + message.textPayload = object.text_payload; + } + if (object.json_payload !== undefined && object.json_payload !== null) { + message.jsonPayload = Struct.fromAmino(object.json_payload); + } + if (object.timestamp !== undefined && object.timestamp !== null) { + message.timestamp = fromTimestamp(Timestamp.fromAmino(object.timestamp)); + } + if (object.receive_timestamp !== undefined && object.receive_timestamp !== null) { + message.receiveTimestamp = fromTimestamp(Timestamp.fromAmino(object.receive_timestamp)); + } + if (object.severity !== undefined && object.severity !== null) { + message.severity = object.severity; + } + if (object.insert_id !== undefined && object.insert_id !== null) { + message.insertId = object.insert_id; + } + if (object.http_request !== undefined && object.http_request !== null) { + message.httpRequest = HttpRequest.fromAmino(object.http_request); + } + message.labels = Object.entries(object.labels ?? {}).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + if (value !== undefined) { + acc[key] = String(value); + } + return acc; + }, {}); + if (object.operation !== undefined && object.operation !== null) { + message.operation = LogEntryOperation.fromAmino(object.operation); + } + if (object.trace !== undefined && object.trace !== null) { + message.trace = object.trace; + } + if (object.span_id !== undefined && object.span_id !== null) { + message.spanId = object.span_id; + } + if (object.trace_sampled !== undefined && object.trace_sampled !== null) { + message.traceSampled = object.trace_sampled; + } + if (object.source_location !== undefined && object.source_location !== null) { + message.sourceLocation = LogEntrySourceLocation.fromAmino(object.source_location); + } + if (object.split !== undefined && object.split !== null) { + message.split = LogSplit.fromAmino(object.split); + } + return message; + }, + toAmino(message: LogEntry): LogEntryAmino { + const obj: any = {}; + obj.log_name = message.logName === "" ? undefined : message.logName; + obj.resource = message.resource ? MonitoredResource.toAmino(message.resource) : undefined; + obj.proto_payload = message.protoPayload ? Any.toAmino(message.protoPayload) : undefined; + obj.text_payload = message.textPayload === null ? undefined : message.textPayload; + obj.json_payload = message.jsonPayload ? Struct.toAmino(message.jsonPayload) : undefined; + obj.timestamp = message.timestamp ? Timestamp.toAmino(toTimestamp(message.timestamp)) : undefined; + obj.receive_timestamp = message.receiveTimestamp ? Timestamp.toAmino(toTimestamp(message.receiveTimestamp)) : undefined; + obj.severity = message.severity === 0 ? undefined : message.severity; + obj.insert_id = message.insertId === "" ? undefined : message.insertId; + obj.http_request = message.httpRequest ? HttpRequest.toAmino(message.httpRequest) : undefined; + obj.labels = {}; + if (message.labels) { + Object.entries(message.labels).forEach(([k, v]) => { + obj.labels[k] = v; + }); + } + obj.operation = message.operation ? LogEntryOperation.toAmino(message.operation) : undefined; + obj.trace = message.trace === "" ? undefined : message.trace; + obj.span_id = message.spanId === "" ? undefined : message.spanId; + obj.trace_sampled = message.traceSampled === false ? undefined : message.traceSampled; + obj.source_location = message.sourceLocation ? LogEntrySourceLocation.toAmino(message.sourceLocation) : undefined; + obj.split = message.split ? LogSplit.toAmino(message.split) : undefined; + return obj; + }, + fromAminoMsg(object: LogEntryAminoMsg): LogEntry { + return LogEntry.fromAmino(object.value); + }, + fromProtoMsg(message: LogEntryProtoMsg): LogEntry { + return LogEntry.decode(message.value); + }, + toProto(message: LogEntry): Uint8Array { + return LogEntry.encode(message).finish(); + }, + toProtoMsg(message: LogEntry): LogEntryProtoMsg { + return { + typeUrl: "/google.logging.v2.LogEntry", + value: LogEntry.encode(message).finish() + }; + } +}; +function createBaseLogEntryOperation(): LogEntryOperation { + return { + id: "", + producer: "", + first: false, + last: false + }; +} +export const LogEntryOperation = { + typeUrl: "/google.logging.v2.LogEntryOperation", + encode(message: LogEntryOperation, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.id !== undefined) { + writer.uint32(10).string(message.id); + } + if (message.producer !== undefined) { + writer.uint32(18).string(message.producer); + } + if (message.first !== undefined) { + writer.uint32(24).bool(message.first); + } + if (message.last !== undefined) { + writer.uint32(32).bool(message.last); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): LogEntryOperation { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseLogEntryOperation(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.id = reader.string(); + break; + case 2: + message.producer = reader.string(); + break; + case 3: + message.first = reader.bool(); + break; + case 4: + message.last = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): LogEntryOperation { + const obj = createBaseLogEntryOperation(); + if (isSet(object.id)) obj.id = String(object.id); + if (isSet(object.producer)) obj.producer = String(object.producer); + if (isSet(object.first)) obj.first = Boolean(object.first); + if (isSet(object.last)) obj.last = Boolean(object.last); + return obj; + }, + toJSON(message: LogEntryOperation): JsonSafe { + const obj: any = {}; + message.id !== undefined && (obj.id = message.id); + message.producer !== undefined && (obj.producer = message.producer); + message.first !== undefined && (obj.first = message.first); + message.last !== undefined && (obj.last = message.last); + return obj; + }, + fromPartial(object: DeepPartial): LogEntryOperation { + const message = createBaseLogEntryOperation(); + message.id = object.id ?? ""; + message.producer = object.producer ?? ""; + message.first = object.first ?? false; + message.last = object.last ?? false; + return message; + }, + fromSDK(object: LogEntryOperationSDKType): LogEntryOperation { + return { + id: object?.id, + producer: object?.producer, + first: object?.first, + last: object?.last + }; + }, + fromSDKJSON(object: any): LogEntryOperationSDKType { + return { + id: isSet(object.id) ? String(object.id) : "", + producer: isSet(object.producer) ? String(object.producer) : "", + first: isSet(object.first) ? Boolean(object.first) : false, + last: isSet(object.last) ? Boolean(object.last) : false + }; + }, + toSDK(message: LogEntryOperation): LogEntryOperationSDKType { + const obj: any = {}; + obj.id = message.id; + obj.producer = message.producer; + obj.first = message.first; + obj.last = message.last; + return obj; + }, + fromAmino(object: LogEntryOperationAmino): LogEntryOperation { + const message = createBaseLogEntryOperation(); + if (object.id !== undefined && object.id !== null) { + message.id = object.id; + } + if (object.producer !== undefined && object.producer !== null) { + message.producer = object.producer; + } + if (object.first !== undefined && object.first !== null) { + message.first = object.first; + } + if (object.last !== undefined && object.last !== null) { + message.last = object.last; + } + return message; + }, + toAmino(message: LogEntryOperation): LogEntryOperationAmino { + const obj: any = {}; + obj.id = message.id === "" ? undefined : message.id; + obj.producer = message.producer === "" ? undefined : message.producer; + obj.first = message.first === false ? undefined : message.first; + obj.last = message.last === false ? undefined : message.last; + return obj; + }, + fromAminoMsg(object: LogEntryOperationAminoMsg): LogEntryOperation { + return LogEntryOperation.fromAmino(object.value); + }, + fromProtoMsg(message: LogEntryOperationProtoMsg): LogEntryOperation { + return LogEntryOperation.decode(message.value); + }, + toProto(message: LogEntryOperation): Uint8Array { + return LogEntryOperation.encode(message).finish(); + }, + toProtoMsg(message: LogEntryOperation): LogEntryOperationProtoMsg { + return { + typeUrl: "/google.logging.v2.LogEntryOperation", + value: LogEntryOperation.encode(message).finish() + }; + } +}; +function createBaseLogEntrySourceLocation(): LogEntrySourceLocation { + return { + file: "", + line: BigInt(0), + function: "" + }; +} +export const LogEntrySourceLocation = { + typeUrl: "/google.logging.v2.LogEntrySourceLocation", + encode(message: LogEntrySourceLocation, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.file !== undefined) { + writer.uint32(10).string(message.file); + } + if (message.line !== undefined) { + writer.uint32(16).int64(message.line); + } + if (message.function !== undefined) { + writer.uint32(26).string(message.function); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): LogEntrySourceLocation { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseLogEntrySourceLocation(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.file = reader.string(); + break; + case 2: + message.line = reader.int64(); + break; + case 3: + message.function = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): LogEntrySourceLocation { + const obj = createBaseLogEntrySourceLocation(); + if (isSet(object.file)) obj.file = String(object.file); + if (isSet(object.line)) obj.line = BigInt(object.line.toString()); + if (isSet(object.function)) obj.function = String(object.function); + return obj; + }, + toJSON(message: LogEntrySourceLocation): JsonSafe { + const obj: any = {}; + message.file !== undefined && (obj.file = message.file); + message.line !== undefined && (obj.line = (message.line || BigInt(0)).toString()); + message.function !== undefined && (obj.function = message.function); + return obj; + }, + fromPartial(object: DeepPartial): LogEntrySourceLocation { + const message = createBaseLogEntrySourceLocation(); + message.file = object.file ?? ""; + if (object.line !== undefined && object.line !== null) { + message.line = BigInt(object.line.toString()); + } + message.function = object.function ?? ""; + return message; + }, + fromSDK(object: LogEntrySourceLocationSDKType): LogEntrySourceLocation { + return { + file: object?.file, + line: object?.line, + function: object?.function + }; + }, + fromSDKJSON(object: any): LogEntrySourceLocationSDKType { + return { + file: isSet(object.file) ? String(object.file) : "", + line: isSet(object.line) ? BigInt(object.line.toString()) : BigInt(0), + function: isSet(object.function) ? String(object.function) : "" + }; + }, + toSDK(message: LogEntrySourceLocation): LogEntrySourceLocationSDKType { + const obj: any = {}; + obj.file = message.file; + obj.line = message.line; + obj.function = message.function; + return obj; + }, + fromAmino(object: LogEntrySourceLocationAmino): LogEntrySourceLocation { + const message = createBaseLogEntrySourceLocation(); + if (object.file !== undefined && object.file !== null) { + message.file = object.file; + } + if (object.line !== undefined && object.line !== null) { + message.line = BigInt(object.line); + } + if (object.function !== undefined && object.function !== null) { + message.function = object.function; + } + return message; + }, + toAmino(message: LogEntrySourceLocation): LogEntrySourceLocationAmino { + const obj: any = {}; + obj.file = message.file === "" ? undefined : message.file; + obj.line = message.line !== BigInt(0) ? message.line?.toString() : undefined; + obj.function = message.function === "" ? undefined : message.function; + return obj; + }, + fromAminoMsg(object: LogEntrySourceLocationAminoMsg): LogEntrySourceLocation { + return LogEntrySourceLocation.fromAmino(object.value); + }, + fromProtoMsg(message: LogEntrySourceLocationProtoMsg): LogEntrySourceLocation { + return LogEntrySourceLocation.decode(message.value); + }, + toProto(message: LogEntrySourceLocation): Uint8Array { + return LogEntrySourceLocation.encode(message).finish(); + }, + toProtoMsg(message: LogEntrySourceLocation): LogEntrySourceLocationProtoMsg { + return { + typeUrl: "/google.logging.v2.LogEntrySourceLocation", + value: LogEntrySourceLocation.encode(message).finish() + }; + } +}; +function createBaseLogSplit(): LogSplit { + return { + uid: "", + index: 0, + totalSplits: 0 + }; +} +export const LogSplit = { + typeUrl: "/google.logging.v2.LogSplit", + encode(message: LogSplit, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.uid !== undefined) { + writer.uint32(10).string(message.uid); + } + if (message.index !== undefined) { + writer.uint32(16).int32(message.index); + } + if (message.totalSplits !== undefined) { + writer.uint32(24).int32(message.totalSplits); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): LogSplit { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseLogSplit(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.uid = reader.string(); + break; + case 2: + message.index = reader.int32(); + break; + case 3: + message.totalSplits = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): LogSplit { + const obj = createBaseLogSplit(); + if (isSet(object.uid)) obj.uid = String(object.uid); + if (isSet(object.index)) obj.index = Number(object.index); + if (isSet(object.totalSplits)) obj.totalSplits = Number(object.totalSplits); + return obj; + }, + toJSON(message: LogSplit): JsonSafe { + const obj: any = {}; + message.uid !== undefined && (obj.uid = message.uid); + message.index !== undefined && (obj.index = Math.round(message.index)); + message.totalSplits !== undefined && (obj.totalSplits = Math.round(message.totalSplits)); + return obj; + }, + fromPartial(object: DeepPartial): LogSplit { + const message = createBaseLogSplit(); + message.uid = object.uid ?? ""; + message.index = object.index ?? 0; + message.totalSplits = object.totalSplits ?? 0; + return message; + }, + fromSDK(object: LogSplitSDKType): LogSplit { + return { + uid: object?.uid, + index: object?.index, + totalSplits: object?.total_splits + }; + }, + fromSDKJSON(object: any): LogSplitSDKType { + return { + uid: isSet(object.uid) ? String(object.uid) : "", + index: isSet(object.index) ? Number(object.index) : 0, + total_splits: isSet(object.total_splits) ? Number(object.total_splits) : 0 + }; + }, + toSDK(message: LogSplit): LogSplitSDKType { + const obj: any = {}; + obj.uid = message.uid; + obj.index = message.index; + obj.total_splits = message.totalSplits; + return obj; + }, + fromAmino(object: LogSplitAmino): LogSplit { + const message = createBaseLogSplit(); + if (object.uid !== undefined && object.uid !== null) { + message.uid = object.uid; + } + if (object.index !== undefined && object.index !== null) { + message.index = object.index; + } + if (object.total_splits !== undefined && object.total_splits !== null) { + message.totalSplits = object.total_splits; + } + return message; + }, + toAmino(message: LogSplit): LogSplitAmino { + const obj: any = {}; + obj.uid = message.uid === "" ? undefined : message.uid; + obj.index = message.index === 0 ? undefined : message.index; + obj.total_splits = message.totalSplits === 0 ? undefined : message.totalSplits; + return obj; + }, + fromAminoMsg(object: LogSplitAminoMsg): LogSplit { + return LogSplit.fromAmino(object.value); + }, + fromProtoMsg(message: LogSplitProtoMsg): LogSplit { + return LogSplit.decode(message.value); + }, + toProto(message: LogSplit): Uint8Array { + return LogSplit.encode(message).finish(); + }, + toProtoMsg(message: LogSplit): LogSplitProtoMsg { + return { + typeUrl: "/google.logging.v2.LogSplit", + value: LogSplit.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/logging/v2/logging.ts b/__fixtures__/v-next/outputicjsdeps/google/logging/v2/logging.ts new file mode 100644 index 0000000000..6d1a6be44d --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/logging/v2/logging.ts @@ -0,0 +1,2398 @@ +import { MonitoredResource, MonitoredResourceSDKType, MonitoredResourceDescriptor, MonitoredResourceDescriptorSDKType } from "../../api/monitored_resource.js"; +import { LogEntry, LogEntrySDKType } from "./log_entry.js"; +import { Duration, DurationSDKType } from "../../protobuf/duration.js"; +import { Status, StatusSDKType } from "../../rpc/status.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial, isObject } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "google.logging.v2"; +/** An indicator of why entries were omitted. */ +export enum TailLogEntriesResponse_SuppressionInfo_Reason { + /** REASON_UNSPECIFIED - Unexpected default. */ + REASON_UNSPECIFIED = 0, + /** + * RATE_LIMIT - Indicates suppression occurred due to relevant entries being + * received in excess of rate limits. For quotas and limits, see + * [Logging API quotas and + * limits](https://cloud.google.com/logging/quotas#api-limits). + */ + RATE_LIMIT = 1, + /** + * NOT_CONSUMED - Indicates suppression occurred due to the client not consuming + * responses quickly enough. + */ + NOT_CONSUMED = 2, + UNRECOGNIZED = -1, +} +export const TailLogEntriesResponse_SuppressionInfo_ReasonSDKType = TailLogEntriesResponse_SuppressionInfo_Reason; +export function tailLogEntriesResponse_SuppressionInfo_ReasonFromJSON(object: any): TailLogEntriesResponse_SuppressionInfo_Reason { + switch (object) { + case 0: + case "REASON_UNSPECIFIED": + return TailLogEntriesResponse_SuppressionInfo_Reason.REASON_UNSPECIFIED; + case 1: + case "RATE_LIMIT": + return TailLogEntriesResponse_SuppressionInfo_Reason.RATE_LIMIT; + case 2: + case "NOT_CONSUMED": + return TailLogEntriesResponse_SuppressionInfo_Reason.NOT_CONSUMED; + case -1: + case "UNRECOGNIZED": + default: + return TailLogEntriesResponse_SuppressionInfo_Reason.UNRECOGNIZED; + } +} +export function tailLogEntriesResponse_SuppressionInfo_ReasonToJSON(object: TailLogEntriesResponse_SuppressionInfo_Reason): string { + switch (object) { + case TailLogEntriesResponse_SuppressionInfo_Reason.REASON_UNSPECIFIED: + return "REASON_UNSPECIFIED"; + case TailLogEntriesResponse_SuppressionInfo_Reason.RATE_LIMIT: + return "RATE_LIMIT"; + case TailLogEntriesResponse_SuppressionInfo_Reason.NOT_CONSUMED: + return "NOT_CONSUMED"; + case TailLogEntriesResponse_SuppressionInfo_Reason.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** The parameters to DeleteLog. */ +export interface DeleteLogRequest { + /** + * Required. The resource name of the log to delete: + * + * * `projects/[PROJECT_ID]/logs/[LOG_ID]` + * * `organizations/[ORGANIZATION_ID]/logs/[LOG_ID]` + * * `billingAccounts/[BILLING_ACCOUNT_ID]/logs/[LOG_ID]` + * * `folders/[FOLDER_ID]/logs/[LOG_ID]` + * + * `[LOG_ID]` must be URL-encoded. For example, + * `"projects/my-project-id/logs/syslog"`, + * `"organizations/123/logs/cloudaudit.googleapis.com%2Factivity"`. + * + * For more information about log names, see + * [LogEntry][google.logging.v2.LogEntry]. + */ + logName: string; +} +export interface DeleteLogRequestProtoMsg { + typeUrl: "/google.logging.v2.DeleteLogRequest"; + value: Uint8Array; +} +/** The parameters to DeleteLog. */ +export interface DeleteLogRequestSDKType { + log_name: string; +} +export interface WriteLogEntriesRequest_LabelsEntry { + key: string; + value: string; +} +export interface WriteLogEntriesRequest_LabelsEntryProtoMsg { + typeUrl: string; + value: Uint8Array; +} +export interface WriteLogEntriesRequest_LabelsEntrySDKType { + key: string; + value: string; +} +/** The parameters to WriteLogEntries. */ +export interface WriteLogEntriesRequest { + /** + * Optional. A default log resource name that is assigned to all log entries + * in `entries` that do not specify a value for `log_name`: + * + * * `projects/[PROJECT_ID]/logs/[LOG_ID]` + * * `organizations/[ORGANIZATION_ID]/logs/[LOG_ID]` + * * `billingAccounts/[BILLING_ACCOUNT_ID]/logs/[LOG_ID]` + * * `folders/[FOLDER_ID]/logs/[LOG_ID]` + * + * `[LOG_ID]` must be URL-encoded. For example: + * + * "projects/my-project-id/logs/syslog" + * "organizations/123/logs/cloudaudit.googleapis.com%2Factivity" + * + * The permission `logging.logEntries.create` is needed on each project, + * organization, billing account, or folder that is receiving new log + * entries, whether the resource is specified in `logName` or in an + * individual log entry. + */ + logName: string; + /** + * Optional. A default monitored resource object that is assigned to all log + * entries in `entries` that do not specify a value for `resource`. Example: + * + * { "type": "gce_instance", + * "labels": { + * "zone": "us-central1-a", "instance_id": "00000000000000000000" }} + * + * See [LogEntry][google.logging.v2.LogEntry]. + */ + resource?: MonitoredResource; + /** + * Optional. Default labels that are added to the `labels` field of all log + * entries in `entries`. If a log entry already has a label with the same key + * as a label in this parameter, then the log entry's label is not changed. + * See [LogEntry][google.logging.v2.LogEntry]. + */ + labels: { + [key: string]: string; + }; + /** + * Required. The log entries to send to Logging. The order of log + * entries in this list does not matter. Values supplied in this method's + * `log_name`, `resource`, and `labels` fields are copied into those log + * entries in this list that do not include values for their corresponding + * fields. For more information, see the + * [LogEntry][google.logging.v2.LogEntry] type. + * + * If the `timestamp` or `insert_id` fields are missing in log entries, then + * this method supplies the current time or a unique identifier, respectively. + * The supplied values are chosen so that, among the log entries that did not + * supply their own values, the entries earlier in the list will sort before + * the entries later in the list. See the `entries.list` method. + * + * Log entries with timestamps that are more than the + * [logs retention period](https://cloud.google.com/logging/quotas) in + * the past or more than 24 hours in the future will not be available when + * calling `entries.list`. However, those log entries can still be [exported + * with + * LogSinks](https://cloud.google.com/logging/docs/api/tasks/exporting-logs). + * + * To improve throughput and to avoid exceeding the + * [quota limit](https://cloud.google.com/logging/quotas) for calls to + * `entries.write`, you should try to include several log entries in this + * list, rather than calling this method for each individual log entry. + */ + entries: LogEntry[]; + /** + * Optional. Whether valid entries should be written even if some other + * entries fail due to INVALID_ARGUMENT or PERMISSION_DENIED errors. If any + * entry is not written, then the response status is the error associated + * with one of the failed entries and the response includes error details + * keyed by the entries' zero-based index in the `entries.write` method. + */ + partialSuccess: boolean; + /** + * Optional. If true, the request should expect normal response, but the + * entries won't be persisted nor exported. Useful for checking whether the + * logging API endpoints are working properly before sending valuable data. + */ + dryRun: boolean; +} +export interface WriteLogEntriesRequestProtoMsg { + typeUrl: "/google.logging.v2.WriteLogEntriesRequest"; + value: Uint8Array; +} +/** The parameters to WriteLogEntries. */ +export interface WriteLogEntriesRequestSDKType { + log_name: string; + resource?: MonitoredResourceSDKType; + labels: { + [key: string]: string; + }; + entries: LogEntrySDKType[]; + partial_success: boolean; + dry_run: boolean; +} +/** Result returned from WriteLogEntries. */ +export interface WriteLogEntriesResponse {} +export interface WriteLogEntriesResponseProtoMsg { + typeUrl: "/google.logging.v2.WriteLogEntriesResponse"; + value: Uint8Array; +} +/** Result returned from WriteLogEntries. */ +export interface WriteLogEntriesResponseSDKType {} +export interface WriteLogEntriesPartialErrors_LogEntryErrorsEntry { + key: number; + value?: Status; +} +export interface WriteLogEntriesPartialErrors_LogEntryErrorsEntryProtoMsg { + typeUrl: string; + value: Uint8Array; +} +export interface WriteLogEntriesPartialErrors_LogEntryErrorsEntrySDKType { + key: number; + value?: StatusSDKType; +} +/** Error details for WriteLogEntries with partial success. */ +export interface WriteLogEntriesPartialErrors { + /** + * When `WriteLogEntriesRequest.partial_success` is true, records the error + * status for entries that were not written due to a permanent error, keyed + * by the entry's zero-based index in `WriteLogEntriesRequest.entries`. + * + * Failed requests for which no entries are written will not include + * per-entry errors. + */ + logEntryErrors: { + [key: number]: Status; + }; +} +export interface WriteLogEntriesPartialErrorsProtoMsg { + typeUrl: "/google.logging.v2.WriteLogEntriesPartialErrors"; + value: Uint8Array; +} +/** Error details for WriteLogEntries with partial success. */ +export interface WriteLogEntriesPartialErrorsSDKType { + log_entry_errors: { + [key: number]: StatusSDKType; + }; +} +/** The parameters to `ListLogEntries`. */ +export interface ListLogEntriesRequest { + /** + * Required. Names of one or more parent resources from which to + * retrieve log entries: + * + * * `projects/[PROJECT_ID]` + * * `organizations/[ORGANIZATION_ID]` + * * `billingAccounts/[BILLING_ACCOUNT_ID]` + * * `folders/[FOLDER_ID]` + * + * May alternatively be one or more views: + * + * * `projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]` + * * `organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]` + * * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]` + * * `folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]` + * + * Projects listed in the `project_ids` field are added to this list. + */ + resourceNames: string[]; + /** + * Optional. A filter that chooses which log entries to return. See [Advanced + * Logs Queries](https://cloud.google.com/logging/docs/view/advanced-queries). + * Only log entries that match the filter are returned. An empty filter + * matches all log entries in the resources listed in `resource_names`. + * Referencing a parent resource that is not listed in `resource_names` will + * cause the filter to return no results. The maximum length of the filter is + * 20000 characters. + */ + filter: string; + /** + * Optional. How the results should be sorted. Presently, the only permitted + * values are `"timestamp asc"` (default) and `"timestamp desc"`. The first + * option returns entries in order of increasing values of + * `LogEntry.timestamp` (oldest first), and the second option returns entries + * in order of decreasing timestamps (newest first). Entries with equal + * timestamps are returned in order of their `insert_id` values. + */ + orderBy: string; + /** + * Optional. The maximum number of results to return from this request. Default is 50. + * If the value is negative or exceeds 1000, the request is rejected. The + * presence of `next_page_token` in the response indicates that more results + * might be available. + */ + pageSize: number; + /** + * Optional. If present, then retrieve the next batch of results from the + * preceding call to this method. `page_token` must be the value of + * `next_page_token` from the previous response. The values of other method + * parameters should be identical to those in the previous call. + */ + pageToken: string; +} +export interface ListLogEntriesRequestProtoMsg { + typeUrl: "/google.logging.v2.ListLogEntriesRequest"; + value: Uint8Array; +} +/** The parameters to `ListLogEntries`. */ +export interface ListLogEntriesRequestSDKType { + resource_names: string[]; + filter: string; + order_by: string; + page_size: number; + page_token: string; +} +/** Result returned from `ListLogEntries`. */ +export interface ListLogEntriesResponse { + /** + * A list of log entries. If `entries` is empty, `nextPageToken` may still be + * returned, indicating that more entries may exist. See `nextPageToken` for + * more information. + */ + entries: LogEntry[]; + /** + * If there might be more results than those appearing in this response, then + * `nextPageToken` is included. To get the next set of results, call this + * method again using the value of `nextPageToken` as `pageToken`. + * + * If a value for `next_page_token` appears and the `entries` field is empty, + * it means that the search found no log entries so far but it did not have + * time to search all the possible log entries. Retry the method with this + * value for `page_token` to continue the search. Alternatively, consider + * speeding up the search by changing your filter to specify a single log name + * or resource type, or to narrow the time range of the search. + */ + nextPageToken: string; +} +export interface ListLogEntriesResponseProtoMsg { + typeUrl: "/google.logging.v2.ListLogEntriesResponse"; + value: Uint8Array; +} +/** Result returned from `ListLogEntries`. */ +export interface ListLogEntriesResponseSDKType { + entries: LogEntrySDKType[]; + next_page_token: string; +} +/** The parameters to ListMonitoredResourceDescriptors */ +export interface ListMonitoredResourceDescriptorsRequest { + /** + * Optional. The maximum number of results to return from this request. + * Non-positive values are ignored. The presence of `nextPageToken` in the + * response indicates that more results might be available. + */ + pageSize: number; + /** + * Optional. If present, then retrieve the next batch of results from the + * preceding call to this method. `pageToken` must be the value of + * `nextPageToken` from the previous response. The values of other method + * parameters should be identical to those in the previous call. + */ + pageToken: string; +} +export interface ListMonitoredResourceDescriptorsRequestProtoMsg { + typeUrl: "/google.logging.v2.ListMonitoredResourceDescriptorsRequest"; + value: Uint8Array; +} +/** The parameters to ListMonitoredResourceDescriptors */ +export interface ListMonitoredResourceDescriptorsRequestSDKType { + page_size: number; + page_token: string; +} +/** Result returned from ListMonitoredResourceDescriptors. */ +export interface ListMonitoredResourceDescriptorsResponse { + /** A list of resource descriptors. */ + resourceDescriptors: MonitoredResourceDescriptor[]; + /** + * If there might be more results than those appearing in this response, then + * `nextPageToken` is included. To get the next set of results, call this + * method again using the value of `nextPageToken` as `pageToken`. + */ + nextPageToken: string; +} +export interface ListMonitoredResourceDescriptorsResponseProtoMsg { + typeUrl: "/google.logging.v2.ListMonitoredResourceDescriptorsResponse"; + value: Uint8Array; +} +/** Result returned from ListMonitoredResourceDescriptors. */ +export interface ListMonitoredResourceDescriptorsResponseSDKType { + resource_descriptors: MonitoredResourceDescriptorSDKType[]; + next_page_token: string; +} +/** The parameters to ListLogs. */ +export interface ListLogsRequest { + /** + * Required. The resource name that owns the logs: + * + * * `projects/[PROJECT_ID]` + * * `organizations/[ORGANIZATION_ID]` + * * `billingAccounts/[BILLING_ACCOUNT_ID]` + * * `folders/[FOLDER_ID]` + */ + parent: string; + /** + * Optional. The maximum number of results to return from this request. + * Non-positive values are ignored. The presence of `nextPageToken` in the + * response indicates that more results might be available. + */ + pageSize: number; + /** + * Optional. If present, then retrieve the next batch of results from the + * preceding call to this method. `pageToken` must be the value of + * `nextPageToken` from the previous response. The values of other method + * parameters should be identical to those in the previous call. + */ + pageToken: string; + /** + * Optional. The resource name that owns the logs: + * + * * `projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]` + * * `organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]` + * * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]` + * * `folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]` + * + * To support legacy queries, it could also be: + * + * * `projects/[PROJECT_ID]` + * * `organizations/[ORGANIZATION_ID]` + * * `billingAccounts/[BILLING_ACCOUNT_ID]` + * * `folders/[FOLDER_ID]` + */ + resourceNames: string[]; +} +export interface ListLogsRequestProtoMsg { + typeUrl: "/google.logging.v2.ListLogsRequest"; + value: Uint8Array; +} +/** The parameters to ListLogs. */ +export interface ListLogsRequestSDKType { + parent: string; + page_size: number; + page_token: string; + resource_names: string[]; +} +/** Result returned from ListLogs. */ +export interface ListLogsResponse { + /** + * A list of log names. For example, + * `"projects/my-project/logs/syslog"` or + * `"organizations/123/logs/cloudresourcemanager.googleapis.com%2Factivity"`. + */ + logNames: string[]; + /** + * If there might be more results than those appearing in this response, then + * `nextPageToken` is included. To get the next set of results, call this + * method again using the value of `nextPageToken` as `pageToken`. + */ + nextPageToken: string; +} +export interface ListLogsResponseProtoMsg { + typeUrl: "/google.logging.v2.ListLogsResponse"; + value: Uint8Array; +} +/** Result returned from ListLogs. */ +export interface ListLogsResponseSDKType { + log_names: string[]; + next_page_token: string; +} +/** The parameters to `TailLogEntries`. */ +export interface TailLogEntriesRequest { + /** + * Required. Name of a parent resource from which to retrieve log entries: + * + * * `projects/[PROJECT_ID]` + * * `organizations/[ORGANIZATION_ID]` + * * `billingAccounts/[BILLING_ACCOUNT_ID]` + * * `folders/[FOLDER_ID]` + * + * May alternatively be one or more views: + * + * * `projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]` + * * `organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]` + * * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]` + * * `folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]` + */ + resourceNames: string[]; + /** + * Optional. A filter that chooses which log entries to return. See [Advanced + * Logs Filters](https://cloud.google.com/logging/docs/view/advanced_filters). + * Only log entries that match the filter are returned. An empty filter + * matches all log entries in the resources listed in `resource_names`. + * Referencing a parent resource that is not in `resource_names` will cause + * the filter to return no results. The maximum length of the filter is 20000 + * characters. + */ + filter: string; + /** + * Optional. The amount of time to buffer log entries at the server before + * being returned to prevent out of order results due to late arriving log + * entries. Valid values are between 0-60000 milliseconds. Defaults to 2000 + * milliseconds. + */ + bufferWindow?: Duration; +} +export interface TailLogEntriesRequestProtoMsg { + typeUrl: "/google.logging.v2.TailLogEntriesRequest"; + value: Uint8Array; +} +/** The parameters to `TailLogEntries`. */ +export interface TailLogEntriesRequestSDKType { + resource_names: string[]; + filter: string; + buffer_window?: DurationSDKType; +} +/** Result returned from `TailLogEntries`. */ +export interface TailLogEntriesResponse { + /** + * A list of log entries. Each response in the stream will order entries with + * increasing values of `LogEntry.timestamp`. Ordering is not guaranteed + * between separate responses. + */ + entries: LogEntry[]; + /** + * If entries that otherwise would have been included in the session were not + * sent back to the client, counts of relevant entries omitted from the + * session with the reason that they were not included. There will be at most + * one of each reason per response. The counts represent the number of + * suppressed entries since the last streamed response. + */ + suppressionInfo: TailLogEntriesResponse_SuppressionInfo[]; +} +export interface TailLogEntriesResponseProtoMsg { + typeUrl: "/google.logging.v2.TailLogEntriesResponse"; + value: Uint8Array; +} +/** Result returned from `TailLogEntries`. */ +export interface TailLogEntriesResponseSDKType { + entries: LogEntrySDKType[]; + suppression_info: TailLogEntriesResponse_SuppressionInfoSDKType[]; +} +/** Information about entries that were omitted from the session. */ +export interface TailLogEntriesResponse_SuppressionInfo { + /** The reason that entries were omitted from the session. */ + reason: TailLogEntriesResponse_SuppressionInfo_Reason; + /** A lower bound on the count of entries omitted due to `reason`. */ + suppressedCount: number; +} +export interface TailLogEntriesResponse_SuppressionInfoProtoMsg { + typeUrl: "/google.logging.v2.SuppressionInfo"; + value: Uint8Array; +} +/** Information about entries that were omitted from the session. */ +export interface TailLogEntriesResponse_SuppressionInfoSDKType { + reason: TailLogEntriesResponse_SuppressionInfo_Reason; + suppressed_count: number; +} +function createBaseDeleteLogRequest(): DeleteLogRequest { + return { + logName: "" + }; +} +export const DeleteLogRequest = { + typeUrl: "/google.logging.v2.DeleteLogRequest", + encode(message: DeleteLogRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.logName !== undefined) { + writer.uint32(10).string(message.logName); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): DeleteLogRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDeleteLogRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.logName = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): DeleteLogRequest { + const obj = createBaseDeleteLogRequest(); + if (isSet(object.logName)) obj.logName = String(object.logName); + return obj; + }, + toJSON(message: DeleteLogRequest): JsonSafe { + const obj: any = {}; + message.logName !== undefined && (obj.logName = message.logName); + return obj; + }, + fromPartial(object: DeepPartial): DeleteLogRequest { + const message = createBaseDeleteLogRequest(); + message.logName = object.logName ?? ""; + return message; + }, + fromSDK(object: DeleteLogRequestSDKType): DeleteLogRequest { + return { + logName: object?.log_name + }; + }, + fromSDKJSON(object: any): DeleteLogRequestSDKType { + return { + log_name: isSet(object.log_name) ? String(object.log_name) : "" + }; + }, + toSDK(message: DeleteLogRequest): DeleteLogRequestSDKType { + const obj: any = {}; + obj.log_name = message.logName; + return obj; + }, + fromAmino(object: DeleteLogRequestAmino): DeleteLogRequest { + const message = createBaseDeleteLogRequest(); + if (object.log_name !== undefined && object.log_name !== null) { + message.logName = object.log_name; + } + return message; + }, + toAmino(message: DeleteLogRequest): DeleteLogRequestAmino { + const obj: any = {}; + obj.log_name = message.logName === "" ? undefined : message.logName; + return obj; + }, + fromAminoMsg(object: DeleteLogRequestAminoMsg): DeleteLogRequest { + return DeleteLogRequest.fromAmino(object.value); + }, + fromProtoMsg(message: DeleteLogRequestProtoMsg): DeleteLogRequest { + return DeleteLogRequest.decode(message.value); + }, + toProto(message: DeleteLogRequest): Uint8Array { + return DeleteLogRequest.encode(message).finish(); + }, + toProtoMsg(message: DeleteLogRequest): DeleteLogRequestProtoMsg { + return { + typeUrl: "/google.logging.v2.DeleteLogRequest", + value: DeleteLogRequest.encode(message).finish() + }; + } +}; +function createBaseWriteLogEntriesRequest_LabelsEntry(): WriteLogEntriesRequest_LabelsEntry { + return { + key: "", + value: "" + }; +} +export const WriteLogEntriesRequest_LabelsEntry = { + encode(message: WriteLogEntriesRequest_LabelsEntry, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.key !== undefined) { + writer.uint32(10).string(message.key); + } + if (message.value !== undefined) { + writer.uint32(18).string(message.value); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): WriteLogEntriesRequest_LabelsEntry { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseWriteLogEntriesRequest_LabelsEntry(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.string(); + break; + case 2: + message.value = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): WriteLogEntriesRequest_LabelsEntry { + const obj = createBaseWriteLogEntriesRequest_LabelsEntry(); + if (isSet(object.key)) obj.key = String(object.key); + if (isSet(object.value)) obj.value = String(object.value); + return obj; + }, + toJSON(message: WriteLogEntriesRequest_LabelsEntry): JsonSafe { + const obj: any = {}; + message.key !== undefined && (obj.key = message.key); + message.value !== undefined && (obj.value = message.value); + return obj; + }, + fromPartial(object: DeepPartial): WriteLogEntriesRequest_LabelsEntry { + const message = createBaseWriteLogEntriesRequest_LabelsEntry(); + message.key = object.key ?? ""; + message.value = object.value ?? ""; + return message; + }, + fromSDK(object: WriteLogEntriesRequest_LabelsEntrySDKType): WriteLogEntriesRequest_LabelsEntry { + return { + key: object?.key, + value: object?.value + }; + }, + fromSDKJSON(object: any): WriteLogEntriesRequest_LabelsEntrySDKType { + return { + key: isSet(object.key) ? String(object.key) : "", + value: isSet(object.value) ? String(object.value) : "" + }; + }, + toSDK(message: WriteLogEntriesRequest_LabelsEntry): WriteLogEntriesRequest_LabelsEntrySDKType { + const obj: any = {}; + obj.key = message.key; + obj.value = message.value; + return obj; + }, + fromAmino(object: WriteLogEntriesRequest_LabelsEntryAmino): WriteLogEntriesRequest_LabelsEntry { + const message = createBaseWriteLogEntriesRequest_LabelsEntry(); + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } + if (object.value !== undefined && object.value !== null) { + message.value = object.value; + } + return message; + }, + toAmino(message: WriteLogEntriesRequest_LabelsEntry): WriteLogEntriesRequest_LabelsEntryAmino { + const obj: any = {}; + obj.key = message.key === "" ? undefined : message.key; + obj.value = message.value === "" ? undefined : message.value; + return obj; + }, + fromAminoMsg(object: WriteLogEntriesRequest_LabelsEntryAminoMsg): WriteLogEntriesRequest_LabelsEntry { + return WriteLogEntriesRequest_LabelsEntry.fromAmino(object.value); + }, + fromProtoMsg(message: WriteLogEntriesRequest_LabelsEntryProtoMsg): WriteLogEntriesRequest_LabelsEntry { + return WriteLogEntriesRequest_LabelsEntry.decode(message.value); + }, + toProto(message: WriteLogEntriesRequest_LabelsEntry): Uint8Array { + return WriteLogEntriesRequest_LabelsEntry.encode(message).finish(); + } +}; +function createBaseWriteLogEntriesRequest(): WriteLogEntriesRequest { + return { + logName: "", + resource: undefined, + labels: {}, + entries: [], + partialSuccess: false, + dryRun: false + }; +} +export const WriteLogEntriesRequest = { + typeUrl: "/google.logging.v2.WriteLogEntriesRequest", + encode(message: WriteLogEntriesRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.logName !== undefined) { + writer.uint32(10).string(message.logName); + } + if (message.resource !== undefined) { + MonitoredResource.encode(message.resource, writer.uint32(18).fork()).ldelim(); + } + Object.entries(message.labels).forEach(([key, value]) => { + WriteLogEntriesRequest_LabelsEntry.encode({ + key: (key as any), + value + }, writer.uint32(26).fork()).ldelim(); + }); + for (const v of message.entries) { + LogEntry.encode(v!, writer.uint32(34).fork()).ldelim(); + } + if (message.partialSuccess !== undefined) { + writer.uint32(40).bool(message.partialSuccess); + } + if (message.dryRun !== undefined) { + writer.uint32(48).bool(message.dryRun); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): WriteLogEntriesRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseWriteLogEntriesRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.logName = reader.string(); + break; + case 2: + message.resource = MonitoredResource.decode(reader, reader.uint32()); + break; + case 3: + const entry3 = WriteLogEntriesRequest_LabelsEntry.decode(reader, reader.uint32()); + if (entry3.value !== undefined) { + message.labels[entry3.key] = entry3.value; + } + break; + case 4: + message.entries.push(LogEntry.decode(reader, reader.uint32())); + break; + case 5: + message.partialSuccess = reader.bool(); + break; + case 6: + message.dryRun = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): WriteLogEntriesRequest { + const obj = createBaseWriteLogEntriesRequest(); + if (isSet(object.logName)) obj.logName = String(object.logName); + if (isSet(object.resource)) obj.resource = MonitoredResource.fromJSON(object.resource); + if (isObject(object.labels)) obj.labels = Object.entries(object.labels).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + acc[key] = String(value); + return acc; + }, {}); + if (Array.isArray(object?.entries)) obj.entries = object.entries.map((e: any) => LogEntry.fromJSON(e)); + if (isSet(object.partialSuccess)) obj.partialSuccess = Boolean(object.partialSuccess); + if (isSet(object.dryRun)) obj.dryRun = Boolean(object.dryRun); + return obj; + }, + toJSON(message: WriteLogEntriesRequest): JsonSafe { + const obj: any = {}; + message.logName !== undefined && (obj.logName = message.logName); + message.resource !== undefined && (obj.resource = message.resource ? MonitoredResource.toJSON(message.resource) : undefined); + obj.labels = {}; + if (message.labels) { + Object.entries(message.labels).forEach(([k, v]) => { + obj.labels[k] = v; + }); + } + if (message.entries) { + obj.entries = message.entries.map(e => e ? LogEntry.toJSON(e) : undefined); + } else { + obj.entries = []; + } + message.partialSuccess !== undefined && (obj.partialSuccess = message.partialSuccess); + message.dryRun !== undefined && (obj.dryRun = message.dryRun); + return obj; + }, + fromPartial(object: DeepPartial): WriteLogEntriesRequest { + const message = createBaseWriteLogEntriesRequest(); + message.logName = object.logName ?? ""; + if (object.resource !== undefined && object.resource !== null) { + message.resource = MonitoredResource.fromPartial(object.resource); + } + message.labels = Object.entries(object.labels ?? {}).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + if (value !== undefined) { + acc[key] = String(value); + } + return acc; + }, {}); + message.entries = object.entries?.map(e => LogEntry.fromPartial(e)) || []; + message.partialSuccess = object.partialSuccess ?? false; + message.dryRun = object.dryRun ?? false; + return message; + }, + fromSDK(object: WriteLogEntriesRequestSDKType): WriteLogEntriesRequest { + return { + logName: object?.log_name, + resource: object.resource ? MonitoredResource.fromSDK(object.resource) : undefined, + labels: isObject(object.labels) ? Object.entries(object.labels).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + acc[key] = String(value); + return acc; + }, {}) : {}, + entries: Array.isArray(object?.entries) ? object.entries.map((e: any) => LogEntry.fromSDK(e)) : [], + partialSuccess: object?.partial_success, + dryRun: object?.dry_run + }; + }, + fromSDKJSON(object: any): WriteLogEntriesRequestSDKType { + return { + log_name: isSet(object.log_name) ? String(object.log_name) : "", + resource: isSet(object.resource) ? MonitoredResource.fromSDKJSON(object.resource) : undefined, + labels: isObject(object.labels) ? Object.entries(object.labels).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + acc[key] = String(value); + return acc; + }, {}) : {}, + entries: Array.isArray(object?.entries) ? object.entries.map((e: any) => LogEntry.fromSDKJSON(e)) : [], + partial_success: isSet(object.partial_success) ? Boolean(object.partial_success) : false, + dry_run: isSet(object.dry_run) ? Boolean(object.dry_run) : false + }; + }, + toSDK(message: WriteLogEntriesRequest): WriteLogEntriesRequestSDKType { + const obj: any = {}; + obj.log_name = message.logName; + message.resource !== undefined && (obj.resource = message.resource ? MonitoredResource.toSDK(message.resource) : undefined); + obj.labels = {}; + if (message.labels) { + Object.entries(message.labels).forEach(([k, v]) => { + obj.labels[k] = v; + }); + } + if (message.entries) { + obj.entries = message.entries.map(e => e ? LogEntry.toSDK(e) : undefined); + } else { + obj.entries = []; + } + obj.partial_success = message.partialSuccess; + obj.dry_run = message.dryRun; + return obj; + }, + fromAmino(object: WriteLogEntriesRequestAmino): WriteLogEntriesRequest { + const message = createBaseWriteLogEntriesRequest(); + if (object.log_name !== undefined && object.log_name !== null) { + message.logName = object.log_name; + } + if (object.resource !== undefined && object.resource !== null) { + message.resource = MonitoredResource.fromAmino(object.resource); + } + message.labels = Object.entries(object.labels ?? {}).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + if (value !== undefined) { + acc[key] = String(value); + } + return acc; + }, {}); + message.entries = object.entries?.map(e => LogEntry.fromAmino(e)) || []; + if (object.partial_success !== undefined && object.partial_success !== null) { + message.partialSuccess = object.partial_success; + } + if (object.dry_run !== undefined && object.dry_run !== null) { + message.dryRun = object.dry_run; + } + return message; + }, + toAmino(message: WriteLogEntriesRequest): WriteLogEntriesRequestAmino { + const obj: any = {}; + obj.log_name = message.logName === "" ? undefined : message.logName; + obj.resource = message.resource ? MonitoredResource.toAmino(message.resource) : undefined; + obj.labels = {}; + if (message.labels) { + Object.entries(message.labels).forEach(([k, v]) => { + obj.labels[k] = v; + }); + } + if (message.entries) { + obj.entries = message.entries.map(e => e ? LogEntry.toAmino(e) : undefined); + } else { + obj.entries = message.entries; + } + obj.partial_success = message.partialSuccess === false ? undefined : message.partialSuccess; + obj.dry_run = message.dryRun === false ? undefined : message.dryRun; + return obj; + }, + fromAminoMsg(object: WriteLogEntriesRequestAminoMsg): WriteLogEntriesRequest { + return WriteLogEntriesRequest.fromAmino(object.value); + }, + fromProtoMsg(message: WriteLogEntriesRequestProtoMsg): WriteLogEntriesRequest { + return WriteLogEntriesRequest.decode(message.value); + }, + toProto(message: WriteLogEntriesRequest): Uint8Array { + return WriteLogEntriesRequest.encode(message).finish(); + }, + toProtoMsg(message: WriteLogEntriesRequest): WriteLogEntriesRequestProtoMsg { + return { + typeUrl: "/google.logging.v2.WriteLogEntriesRequest", + value: WriteLogEntriesRequest.encode(message).finish() + }; + } +}; +function createBaseWriteLogEntriesResponse(): WriteLogEntriesResponse { + return {}; +} +export const WriteLogEntriesResponse = { + typeUrl: "/google.logging.v2.WriteLogEntriesResponse", + encode(_: WriteLogEntriesResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): WriteLogEntriesResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseWriteLogEntriesResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): WriteLogEntriesResponse { + const obj = createBaseWriteLogEntriesResponse(); + return obj; + }, + toJSON(_: WriteLogEntriesResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): WriteLogEntriesResponse { + const message = createBaseWriteLogEntriesResponse(); + return message; + }, + fromSDK(_: WriteLogEntriesResponseSDKType): WriteLogEntriesResponse { + return {}; + }, + fromSDKJSON(_: any): WriteLogEntriesResponseSDKType { + return {}; + }, + toSDK(_: WriteLogEntriesResponse): WriteLogEntriesResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: WriteLogEntriesResponseAmino): WriteLogEntriesResponse { + const message = createBaseWriteLogEntriesResponse(); + return message; + }, + toAmino(_: WriteLogEntriesResponse): WriteLogEntriesResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: WriteLogEntriesResponseAminoMsg): WriteLogEntriesResponse { + return WriteLogEntriesResponse.fromAmino(object.value); + }, + fromProtoMsg(message: WriteLogEntriesResponseProtoMsg): WriteLogEntriesResponse { + return WriteLogEntriesResponse.decode(message.value); + }, + toProto(message: WriteLogEntriesResponse): Uint8Array { + return WriteLogEntriesResponse.encode(message).finish(); + }, + toProtoMsg(message: WriteLogEntriesResponse): WriteLogEntriesResponseProtoMsg { + return { + typeUrl: "/google.logging.v2.WriteLogEntriesResponse", + value: WriteLogEntriesResponse.encode(message).finish() + }; + } +}; +function createBaseWriteLogEntriesPartialErrors_LogEntryErrorsEntry(): WriteLogEntriesPartialErrors_LogEntryErrorsEntry { + return { + key: 0, + value: undefined + }; +} +export const WriteLogEntriesPartialErrors_LogEntryErrorsEntry = { + encode(message: WriteLogEntriesPartialErrors_LogEntryErrorsEntry, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.key !== undefined) { + writer.uint32(8).int32(message.key); + } + if (message.value !== undefined) { + Status.encode(message.value, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): WriteLogEntriesPartialErrors_LogEntryErrorsEntry { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseWriteLogEntriesPartialErrors_LogEntryErrorsEntry(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.int32(); + break; + case 2: + message.value = Status.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): WriteLogEntriesPartialErrors_LogEntryErrorsEntry { + const obj = createBaseWriteLogEntriesPartialErrors_LogEntryErrorsEntry(); + if (isSet(object.key)) obj.key = Number(object.key); + if (isSet(object.value)) obj.value = Status.fromJSON(object.value); + return obj; + }, + toJSON(message: WriteLogEntriesPartialErrors_LogEntryErrorsEntry): JsonSafe { + const obj: any = {}; + message.key !== undefined && (obj.key = Math.round(message.key)); + message.value !== undefined && (obj.value = message.value ? Status.toJSON(message.value) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): WriteLogEntriesPartialErrors_LogEntryErrorsEntry { + const message = createBaseWriteLogEntriesPartialErrors_LogEntryErrorsEntry(); + message.key = object.key ?? 0; + if (object.value !== undefined && object.value !== null) { + message.value = Status.fromPartial(object.value); + } + return message; + }, + fromSDK(object: WriteLogEntriesPartialErrors_LogEntryErrorsEntrySDKType): WriteLogEntriesPartialErrors_LogEntryErrorsEntry { + return { + key: object?.key, + value: object.value ? Status.fromSDK(object.value) : undefined + }; + }, + fromSDKJSON(object: any): WriteLogEntriesPartialErrors_LogEntryErrorsEntrySDKType { + return { + key: isSet(object.key) ? Number(object.key) : 0, + value: isSet(object.value) ? Status.fromSDKJSON(object.value) : undefined + }; + }, + toSDK(message: WriteLogEntriesPartialErrors_LogEntryErrorsEntry): WriteLogEntriesPartialErrors_LogEntryErrorsEntrySDKType { + const obj: any = {}; + obj.key = message.key; + message.value !== undefined && (obj.value = message.value ? Status.toSDK(message.value) : undefined); + return obj; + }, + fromAmino(object: WriteLogEntriesPartialErrors_LogEntryErrorsEntryAmino): WriteLogEntriesPartialErrors_LogEntryErrorsEntry { + const message = createBaseWriteLogEntriesPartialErrors_LogEntryErrorsEntry(); + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } + if (object.value !== undefined && object.value !== null) { + message.value = Status.fromAmino(object.value); + } + return message; + }, + toAmino(message: WriteLogEntriesPartialErrors_LogEntryErrorsEntry): WriteLogEntriesPartialErrors_LogEntryErrorsEntryAmino { + const obj: any = {}; + obj.key = message.key === 0 ? undefined : message.key; + obj.value = message.value ? Status.toAmino(message.value) : undefined; + return obj; + }, + fromAminoMsg(object: WriteLogEntriesPartialErrors_LogEntryErrorsEntryAminoMsg): WriteLogEntriesPartialErrors_LogEntryErrorsEntry { + return WriteLogEntriesPartialErrors_LogEntryErrorsEntry.fromAmino(object.value); + }, + fromProtoMsg(message: WriteLogEntriesPartialErrors_LogEntryErrorsEntryProtoMsg): WriteLogEntriesPartialErrors_LogEntryErrorsEntry { + return WriteLogEntriesPartialErrors_LogEntryErrorsEntry.decode(message.value); + }, + toProto(message: WriteLogEntriesPartialErrors_LogEntryErrorsEntry): Uint8Array { + return WriteLogEntriesPartialErrors_LogEntryErrorsEntry.encode(message).finish(); + } +}; +function createBaseWriteLogEntriesPartialErrors(): WriteLogEntriesPartialErrors { + return { + logEntryErrors: {} + }; +} +export const WriteLogEntriesPartialErrors = { + typeUrl: "/google.logging.v2.WriteLogEntriesPartialErrors", + encode(message: WriteLogEntriesPartialErrors, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + Object.entries(message.logEntryErrors).forEach(([key, value]) => { + WriteLogEntriesPartialErrors_LogEntryErrorsEntry.encode({ + key: (key as any), + value + }, writer.uint32(10).fork()).ldelim(); + }); + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): WriteLogEntriesPartialErrors { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseWriteLogEntriesPartialErrors(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + const entry1 = WriteLogEntriesPartialErrors_LogEntryErrorsEntry.decode(reader, reader.uint32()); + if (entry1.value !== undefined) { + message.logEntryErrors[entry1.key] = entry1.value; + } + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): WriteLogEntriesPartialErrors { + const obj = createBaseWriteLogEntriesPartialErrors(); + if (isObject(object.logEntryErrors)) obj.logEntryErrors = Object.entries(object.logEntryErrors).reduce<{ + [key: number]: Status; + }>((acc, [key, value]) => { + acc[Number(key)] = Status.fromJSON(value); + return acc; + }, {}); + return obj; + }, + toJSON(message: WriteLogEntriesPartialErrors): JsonSafe { + const obj: any = {}; + obj.logEntryErrors = {}; + if (message.logEntryErrors) { + Object.entries(message.logEntryErrors).forEach(([k, v]) => { + obj.logEntryErrors[k] = Status.toJSON(v); + }); + } + return obj; + }, + fromPartial(object: DeepPartial): WriteLogEntriesPartialErrors { + const message = createBaseWriteLogEntriesPartialErrors(); + message.logEntryErrors = Object.entries(object.logEntryErrors ?? {}).reduce<{ + [key: number]: Status; + }>((acc, [key, value]) => { + if (value !== undefined) { + acc[Number(key)] = Status.fromPartial(value); + } + return acc; + }, {}); + return message; + }, + fromSDK(object: WriteLogEntriesPartialErrorsSDKType): WriteLogEntriesPartialErrors { + return { + logEntryErrors: isObject(object.log_entry_errors) ? Object.entries(object.log_entry_errors).reduce<{ + [key: number]: Status; + }>((acc, [key, value]) => { + acc[Number(key)] = Status.fromSDK(value); + return acc; + }, {}) : {} + }; + }, + fromSDKJSON(object: any): WriteLogEntriesPartialErrorsSDKType { + return { + log_entry_errors: isObject(object.log_entry_errors) ? Object.entries(object.log_entry_errors).reduce<{ + [key: number]: Status; + }>((acc, [key, value]) => { + acc[Number(key)] = Status.fromSDKJSON(value); + return acc; + }, {}) : {} + }; + }, + toSDK(message: WriteLogEntriesPartialErrors): WriteLogEntriesPartialErrorsSDKType { + const obj: any = {}; + obj.log_entry_errors = {}; + if (message.logEntryErrors) { + Object.entries(message.logEntryErrors).forEach(([k, v]) => { + obj.log_entry_errors[k] = Status.toSDK(v); + }); + } + return obj; + }, + fromAmino(object: WriteLogEntriesPartialErrorsAmino): WriteLogEntriesPartialErrors { + const message = createBaseWriteLogEntriesPartialErrors(); + message.logEntryErrors = Object.entries(object.log_entry_errors ?? {}).reduce<{ + [key: number]: Status; + }>((acc, [key, value]) => { + if (value !== undefined) { + acc[Number(key)] = Status.fromAmino(value); + } + return acc; + }, {}); + return message; + }, + toAmino(message: WriteLogEntriesPartialErrors): WriteLogEntriesPartialErrorsAmino { + const obj: any = {}; + obj.log_entry_errors = {}; + if (message.logEntryErrors) { + Object.entries(message.logEntryErrors).forEach(([k, v]) => { + obj.log_entry_errors[k] = Status.toAmino(v); + }); + } + return obj; + }, + fromAminoMsg(object: WriteLogEntriesPartialErrorsAminoMsg): WriteLogEntriesPartialErrors { + return WriteLogEntriesPartialErrors.fromAmino(object.value); + }, + fromProtoMsg(message: WriteLogEntriesPartialErrorsProtoMsg): WriteLogEntriesPartialErrors { + return WriteLogEntriesPartialErrors.decode(message.value); + }, + toProto(message: WriteLogEntriesPartialErrors): Uint8Array { + return WriteLogEntriesPartialErrors.encode(message).finish(); + }, + toProtoMsg(message: WriteLogEntriesPartialErrors): WriteLogEntriesPartialErrorsProtoMsg { + return { + typeUrl: "/google.logging.v2.WriteLogEntriesPartialErrors", + value: WriteLogEntriesPartialErrors.encode(message).finish() + }; + } +}; +function createBaseListLogEntriesRequest(): ListLogEntriesRequest { + return { + resourceNames: [], + filter: "", + orderBy: "", + pageSize: 0, + pageToken: "" + }; +} +export const ListLogEntriesRequest = { + typeUrl: "/google.logging.v2.ListLogEntriesRequest", + encode(message: ListLogEntriesRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.resourceNames) { + writer.uint32(66).string(v!); + } + if (message.filter !== undefined) { + writer.uint32(18).string(message.filter); + } + if (message.orderBy !== undefined) { + writer.uint32(26).string(message.orderBy); + } + if (message.pageSize !== undefined) { + writer.uint32(32).int32(message.pageSize); + } + if (message.pageToken !== undefined) { + writer.uint32(42).string(message.pageToken); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ListLogEntriesRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseListLogEntriesRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 8: + message.resourceNames.push(reader.string()); + break; + case 2: + message.filter = reader.string(); + break; + case 3: + message.orderBy = reader.string(); + break; + case 4: + message.pageSize = reader.int32(); + break; + case 5: + message.pageToken = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ListLogEntriesRequest { + const obj = createBaseListLogEntriesRequest(); + if (Array.isArray(object?.resourceNames)) obj.resourceNames = object.resourceNames.map((e: any) => String(e)); + if (isSet(object.filter)) obj.filter = String(object.filter); + if (isSet(object.orderBy)) obj.orderBy = String(object.orderBy); + if (isSet(object.pageSize)) obj.pageSize = Number(object.pageSize); + if (isSet(object.pageToken)) obj.pageToken = String(object.pageToken); + return obj; + }, + toJSON(message: ListLogEntriesRequest): JsonSafe { + const obj: any = {}; + if (message.resourceNames) { + obj.resourceNames = message.resourceNames.map(e => e); + } else { + obj.resourceNames = []; + } + message.filter !== undefined && (obj.filter = message.filter); + message.orderBy !== undefined && (obj.orderBy = message.orderBy); + message.pageSize !== undefined && (obj.pageSize = Math.round(message.pageSize)); + message.pageToken !== undefined && (obj.pageToken = message.pageToken); + return obj; + }, + fromPartial(object: DeepPartial): ListLogEntriesRequest { + const message = createBaseListLogEntriesRequest(); + message.resourceNames = object.resourceNames?.map(e => e) || []; + message.filter = object.filter ?? ""; + message.orderBy = object.orderBy ?? ""; + message.pageSize = object.pageSize ?? 0; + message.pageToken = object.pageToken ?? ""; + return message; + }, + fromSDK(object: ListLogEntriesRequestSDKType): ListLogEntriesRequest { + return { + resourceNames: Array.isArray(object?.resource_names) ? object.resource_names.map((e: any) => e) : [], + filter: object?.filter, + orderBy: object?.order_by, + pageSize: object?.page_size, + pageToken: object?.page_token + }; + }, + fromSDKJSON(object: any): ListLogEntriesRequestSDKType { + return { + resource_names: Array.isArray(object?.resource_names) ? object.resource_names.map((e: any) => String(e)) : [], + filter: isSet(object.filter) ? String(object.filter) : "", + order_by: isSet(object.order_by) ? String(object.order_by) : "", + page_size: isSet(object.page_size) ? Number(object.page_size) : 0, + page_token: isSet(object.page_token) ? String(object.page_token) : "" + }; + }, + toSDK(message: ListLogEntriesRequest): ListLogEntriesRequestSDKType { + const obj: any = {}; + if (message.resourceNames) { + obj.resource_names = message.resourceNames.map(e => e); + } else { + obj.resource_names = []; + } + obj.filter = message.filter; + obj.order_by = message.orderBy; + obj.page_size = message.pageSize; + obj.page_token = message.pageToken; + return obj; + }, + fromAmino(object: ListLogEntriesRequestAmino): ListLogEntriesRequest { + const message = createBaseListLogEntriesRequest(); + message.resourceNames = object.resource_names?.map(e => e) || []; + if (object.filter !== undefined && object.filter !== null) { + message.filter = object.filter; + } + if (object.order_by !== undefined && object.order_by !== null) { + message.orderBy = object.order_by; + } + if (object.page_size !== undefined && object.page_size !== null) { + message.pageSize = object.page_size; + } + if (object.page_token !== undefined && object.page_token !== null) { + message.pageToken = object.page_token; + } + return message; + }, + toAmino(message: ListLogEntriesRequest): ListLogEntriesRequestAmino { + const obj: any = {}; + if (message.resourceNames) { + obj.resource_names = message.resourceNames.map(e => e); + } else { + obj.resource_names = message.resourceNames; + } + obj.filter = message.filter === "" ? undefined : message.filter; + obj.order_by = message.orderBy === "" ? undefined : message.orderBy; + obj.page_size = message.pageSize === 0 ? undefined : message.pageSize; + obj.page_token = message.pageToken === "" ? undefined : message.pageToken; + return obj; + }, + fromAminoMsg(object: ListLogEntriesRequestAminoMsg): ListLogEntriesRequest { + return ListLogEntriesRequest.fromAmino(object.value); + }, + fromProtoMsg(message: ListLogEntriesRequestProtoMsg): ListLogEntriesRequest { + return ListLogEntriesRequest.decode(message.value); + }, + toProto(message: ListLogEntriesRequest): Uint8Array { + return ListLogEntriesRequest.encode(message).finish(); + }, + toProtoMsg(message: ListLogEntriesRequest): ListLogEntriesRequestProtoMsg { + return { + typeUrl: "/google.logging.v2.ListLogEntriesRequest", + value: ListLogEntriesRequest.encode(message).finish() + }; + } +}; +function createBaseListLogEntriesResponse(): ListLogEntriesResponse { + return { + entries: [], + nextPageToken: "" + }; +} +export const ListLogEntriesResponse = { + typeUrl: "/google.logging.v2.ListLogEntriesResponse", + encode(message: ListLogEntriesResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.entries) { + LogEntry.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.nextPageToken !== undefined) { + writer.uint32(18).string(message.nextPageToken); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ListLogEntriesResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseListLogEntriesResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.entries.push(LogEntry.decode(reader, reader.uint32())); + break; + case 2: + message.nextPageToken = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ListLogEntriesResponse { + const obj = createBaseListLogEntriesResponse(); + if (Array.isArray(object?.entries)) obj.entries = object.entries.map((e: any) => LogEntry.fromJSON(e)); + if (isSet(object.nextPageToken)) obj.nextPageToken = String(object.nextPageToken); + return obj; + }, + toJSON(message: ListLogEntriesResponse): JsonSafe { + const obj: any = {}; + if (message.entries) { + obj.entries = message.entries.map(e => e ? LogEntry.toJSON(e) : undefined); + } else { + obj.entries = []; + } + message.nextPageToken !== undefined && (obj.nextPageToken = message.nextPageToken); + return obj; + }, + fromPartial(object: DeepPartial): ListLogEntriesResponse { + const message = createBaseListLogEntriesResponse(); + message.entries = object.entries?.map(e => LogEntry.fromPartial(e)) || []; + message.nextPageToken = object.nextPageToken ?? ""; + return message; + }, + fromSDK(object: ListLogEntriesResponseSDKType): ListLogEntriesResponse { + return { + entries: Array.isArray(object?.entries) ? object.entries.map((e: any) => LogEntry.fromSDK(e)) : [], + nextPageToken: object?.next_page_token + }; + }, + fromSDKJSON(object: any): ListLogEntriesResponseSDKType { + return { + entries: Array.isArray(object?.entries) ? object.entries.map((e: any) => LogEntry.fromSDKJSON(e)) : [], + next_page_token: isSet(object.next_page_token) ? String(object.next_page_token) : "" + }; + }, + toSDK(message: ListLogEntriesResponse): ListLogEntriesResponseSDKType { + const obj: any = {}; + if (message.entries) { + obj.entries = message.entries.map(e => e ? LogEntry.toSDK(e) : undefined); + } else { + obj.entries = []; + } + obj.next_page_token = message.nextPageToken; + return obj; + }, + fromAmino(object: ListLogEntriesResponseAmino): ListLogEntriesResponse { + const message = createBaseListLogEntriesResponse(); + message.entries = object.entries?.map(e => LogEntry.fromAmino(e)) || []; + if (object.next_page_token !== undefined && object.next_page_token !== null) { + message.nextPageToken = object.next_page_token; + } + return message; + }, + toAmino(message: ListLogEntriesResponse): ListLogEntriesResponseAmino { + const obj: any = {}; + if (message.entries) { + obj.entries = message.entries.map(e => e ? LogEntry.toAmino(e) : undefined); + } else { + obj.entries = message.entries; + } + obj.next_page_token = message.nextPageToken === "" ? undefined : message.nextPageToken; + return obj; + }, + fromAminoMsg(object: ListLogEntriesResponseAminoMsg): ListLogEntriesResponse { + return ListLogEntriesResponse.fromAmino(object.value); + }, + fromProtoMsg(message: ListLogEntriesResponseProtoMsg): ListLogEntriesResponse { + return ListLogEntriesResponse.decode(message.value); + }, + toProto(message: ListLogEntriesResponse): Uint8Array { + return ListLogEntriesResponse.encode(message).finish(); + }, + toProtoMsg(message: ListLogEntriesResponse): ListLogEntriesResponseProtoMsg { + return { + typeUrl: "/google.logging.v2.ListLogEntriesResponse", + value: ListLogEntriesResponse.encode(message).finish() + }; + } +}; +function createBaseListMonitoredResourceDescriptorsRequest(): ListMonitoredResourceDescriptorsRequest { + return { + pageSize: 0, + pageToken: "" + }; +} +export const ListMonitoredResourceDescriptorsRequest = { + typeUrl: "/google.logging.v2.ListMonitoredResourceDescriptorsRequest", + encode(message: ListMonitoredResourceDescriptorsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.pageSize !== undefined) { + writer.uint32(8).int32(message.pageSize); + } + if (message.pageToken !== undefined) { + writer.uint32(18).string(message.pageToken); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ListMonitoredResourceDescriptorsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseListMonitoredResourceDescriptorsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.pageSize = reader.int32(); + break; + case 2: + message.pageToken = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ListMonitoredResourceDescriptorsRequest { + const obj = createBaseListMonitoredResourceDescriptorsRequest(); + if (isSet(object.pageSize)) obj.pageSize = Number(object.pageSize); + if (isSet(object.pageToken)) obj.pageToken = String(object.pageToken); + return obj; + }, + toJSON(message: ListMonitoredResourceDescriptorsRequest): JsonSafe { + const obj: any = {}; + message.pageSize !== undefined && (obj.pageSize = Math.round(message.pageSize)); + message.pageToken !== undefined && (obj.pageToken = message.pageToken); + return obj; + }, + fromPartial(object: DeepPartial): ListMonitoredResourceDescriptorsRequest { + const message = createBaseListMonitoredResourceDescriptorsRequest(); + message.pageSize = object.pageSize ?? 0; + message.pageToken = object.pageToken ?? ""; + return message; + }, + fromSDK(object: ListMonitoredResourceDescriptorsRequestSDKType): ListMonitoredResourceDescriptorsRequest { + return { + pageSize: object?.page_size, + pageToken: object?.page_token + }; + }, + fromSDKJSON(object: any): ListMonitoredResourceDescriptorsRequestSDKType { + return { + page_size: isSet(object.page_size) ? Number(object.page_size) : 0, + page_token: isSet(object.page_token) ? String(object.page_token) : "" + }; + }, + toSDK(message: ListMonitoredResourceDescriptorsRequest): ListMonitoredResourceDescriptorsRequestSDKType { + const obj: any = {}; + obj.page_size = message.pageSize; + obj.page_token = message.pageToken; + return obj; + }, + fromAmino(object: ListMonitoredResourceDescriptorsRequestAmino): ListMonitoredResourceDescriptorsRequest { + const message = createBaseListMonitoredResourceDescriptorsRequest(); + if (object.page_size !== undefined && object.page_size !== null) { + message.pageSize = object.page_size; + } + if (object.page_token !== undefined && object.page_token !== null) { + message.pageToken = object.page_token; + } + return message; + }, + toAmino(message: ListMonitoredResourceDescriptorsRequest): ListMonitoredResourceDescriptorsRequestAmino { + const obj: any = {}; + obj.page_size = message.pageSize === 0 ? undefined : message.pageSize; + obj.page_token = message.pageToken === "" ? undefined : message.pageToken; + return obj; + }, + fromAminoMsg(object: ListMonitoredResourceDescriptorsRequestAminoMsg): ListMonitoredResourceDescriptorsRequest { + return ListMonitoredResourceDescriptorsRequest.fromAmino(object.value); + }, + fromProtoMsg(message: ListMonitoredResourceDescriptorsRequestProtoMsg): ListMonitoredResourceDescriptorsRequest { + return ListMonitoredResourceDescriptorsRequest.decode(message.value); + }, + toProto(message: ListMonitoredResourceDescriptorsRequest): Uint8Array { + return ListMonitoredResourceDescriptorsRequest.encode(message).finish(); + }, + toProtoMsg(message: ListMonitoredResourceDescriptorsRequest): ListMonitoredResourceDescriptorsRequestProtoMsg { + return { + typeUrl: "/google.logging.v2.ListMonitoredResourceDescriptorsRequest", + value: ListMonitoredResourceDescriptorsRequest.encode(message).finish() + }; + } +}; +function createBaseListMonitoredResourceDescriptorsResponse(): ListMonitoredResourceDescriptorsResponse { + return { + resourceDescriptors: [], + nextPageToken: "" + }; +} +export const ListMonitoredResourceDescriptorsResponse = { + typeUrl: "/google.logging.v2.ListMonitoredResourceDescriptorsResponse", + encode(message: ListMonitoredResourceDescriptorsResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.resourceDescriptors) { + MonitoredResourceDescriptor.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.nextPageToken !== undefined) { + writer.uint32(18).string(message.nextPageToken); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ListMonitoredResourceDescriptorsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseListMonitoredResourceDescriptorsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.resourceDescriptors.push(MonitoredResourceDescriptor.decode(reader, reader.uint32())); + break; + case 2: + message.nextPageToken = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ListMonitoredResourceDescriptorsResponse { + const obj = createBaseListMonitoredResourceDescriptorsResponse(); + if (Array.isArray(object?.resourceDescriptors)) obj.resourceDescriptors = object.resourceDescriptors.map((e: any) => MonitoredResourceDescriptor.fromJSON(e)); + if (isSet(object.nextPageToken)) obj.nextPageToken = String(object.nextPageToken); + return obj; + }, + toJSON(message: ListMonitoredResourceDescriptorsResponse): JsonSafe { + const obj: any = {}; + if (message.resourceDescriptors) { + obj.resourceDescriptors = message.resourceDescriptors.map(e => e ? MonitoredResourceDescriptor.toJSON(e) : undefined); + } else { + obj.resourceDescriptors = []; + } + message.nextPageToken !== undefined && (obj.nextPageToken = message.nextPageToken); + return obj; + }, + fromPartial(object: DeepPartial): ListMonitoredResourceDescriptorsResponse { + const message = createBaseListMonitoredResourceDescriptorsResponse(); + message.resourceDescriptors = object.resourceDescriptors?.map(e => MonitoredResourceDescriptor.fromPartial(e)) || []; + message.nextPageToken = object.nextPageToken ?? ""; + return message; + }, + fromSDK(object: ListMonitoredResourceDescriptorsResponseSDKType): ListMonitoredResourceDescriptorsResponse { + return { + resourceDescriptors: Array.isArray(object?.resource_descriptors) ? object.resource_descriptors.map((e: any) => MonitoredResourceDescriptor.fromSDK(e)) : [], + nextPageToken: object?.next_page_token + }; + }, + fromSDKJSON(object: any): ListMonitoredResourceDescriptorsResponseSDKType { + return { + resource_descriptors: Array.isArray(object?.resource_descriptors) ? object.resource_descriptors.map((e: any) => MonitoredResourceDescriptor.fromSDKJSON(e)) : [], + next_page_token: isSet(object.next_page_token) ? String(object.next_page_token) : "" + }; + }, + toSDK(message: ListMonitoredResourceDescriptorsResponse): ListMonitoredResourceDescriptorsResponseSDKType { + const obj: any = {}; + if (message.resourceDescriptors) { + obj.resource_descriptors = message.resourceDescriptors.map(e => e ? MonitoredResourceDescriptor.toSDK(e) : undefined); + } else { + obj.resource_descriptors = []; + } + obj.next_page_token = message.nextPageToken; + return obj; + }, + fromAmino(object: ListMonitoredResourceDescriptorsResponseAmino): ListMonitoredResourceDescriptorsResponse { + const message = createBaseListMonitoredResourceDescriptorsResponse(); + message.resourceDescriptors = object.resource_descriptors?.map(e => MonitoredResourceDescriptor.fromAmino(e)) || []; + if (object.next_page_token !== undefined && object.next_page_token !== null) { + message.nextPageToken = object.next_page_token; + } + return message; + }, + toAmino(message: ListMonitoredResourceDescriptorsResponse): ListMonitoredResourceDescriptorsResponseAmino { + const obj: any = {}; + if (message.resourceDescriptors) { + obj.resource_descriptors = message.resourceDescriptors.map(e => e ? MonitoredResourceDescriptor.toAmino(e) : undefined); + } else { + obj.resource_descriptors = message.resourceDescriptors; + } + obj.next_page_token = message.nextPageToken === "" ? undefined : message.nextPageToken; + return obj; + }, + fromAminoMsg(object: ListMonitoredResourceDescriptorsResponseAminoMsg): ListMonitoredResourceDescriptorsResponse { + return ListMonitoredResourceDescriptorsResponse.fromAmino(object.value); + }, + fromProtoMsg(message: ListMonitoredResourceDescriptorsResponseProtoMsg): ListMonitoredResourceDescriptorsResponse { + return ListMonitoredResourceDescriptorsResponse.decode(message.value); + }, + toProto(message: ListMonitoredResourceDescriptorsResponse): Uint8Array { + return ListMonitoredResourceDescriptorsResponse.encode(message).finish(); + }, + toProtoMsg(message: ListMonitoredResourceDescriptorsResponse): ListMonitoredResourceDescriptorsResponseProtoMsg { + return { + typeUrl: "/google.logging.v2.ListMonitoredResourceDescriptorsResponse", + value: ListMonitoredResourceDescriptorsResponse.encode(message).finish() + }; + } +}; +function createBaseListLogsRequest(): ListLogsRequest { + return { + parent: "", + pageSize: 0, + pageToken: "", + resourceNames: [] + }; +} +export const ListLogsRequest = { + typeUrl: "/google.logging.v2.ListLogsRequest", + encode(message: ListLogsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.parent !== undefined) { + writer.uint32(10).string(message.parent); + } + if (message.pageSize !== undefined) { + writer.uint32(16).int32(message.pageSize); + } + if (message.pageToken !== undefined) { + writer.uint32(26).string(message.pageToken); + } + for (const v of message.resourceNames) { + writer.uint32(66).string(v!); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ListLogsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseListLogsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.parent = reader.string(); + break; + case 2: + message.pageSize = reader.int32(); + break; + case 3: + message.pageToken = reader.string(); + break; + case 8: + message.resourceNames.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ListLogsRequest { + const obj = createBaseListLogsRequest(); + if (isSet(object.parent)) obj.parent = String(object.parent); + if (isSet(object.pageSize)) obj.pageSize = Number(object.pageSize); + if (isSet(object.pageToken)) obj.pageToken = String(object.pageToken); + if (Array.isArray(object?.resourceNames)) obj.resourceNames = object.resourceNames.map((e: any) => String(e)); + return obj; + }, + toJSON(message: ListLogsRequest): JsonSafe { + const obj: any = {}; + message.parent !== undefined && (obj.parent = message.parent); + message.pageSize !== undefined && (obj.pageSize = Math.round(message.pageSize)); + message.pageToken !== undefined && (obj.pageToken = message.pageToken); + if (message.resourceNames) { + obj.resourceNames = message.resourceNames.map(e => e); + } else { + obj.resourceNames = []; + } + return obj; + }, + fromPartial(object: DeepPartial): ListLogsRequest { + const message = createBaseListLogsRequest(); + message.parent = object.parent ?? ""; + message.pageSize = object.pageSize ?? 0; + message.pageToken = object.pageToken ?? ""; + message.resourceNames = object.resourceNames?.map(e => e) || []; + return message; + }, + fromSDK(object: ListLogsRequestSDKType): ListLogsRequest { + return { + parent: object?.parent, + pageSize: object?.page_size, + pageToken: object?.page_token, + resourceNames: Array.isArray(object?.resource_names) ? object.resource_names.map((e: any) => e) : [] + }; + }, + fromSDKJSON(object: any): ListLogsRequestSDKType { + return { + parent: isSet(object.parent) ? String(object.parent) : "", + page_size: isSet(object.page_size) ? Number(object.page_size) : 0, + page_token: isSet(object.page_token) ? String(object.page_token) : "", + resource_names: Array.isArray(object?.resource_names) ? object.resource_names.map((e: any) => String(e)) : [] + }; + }, + toSDK(message: ListLogsRequest): ListLogsRequestSDKType { + const obj: any = {}; + obj.parent = message.parent; + obj.page_size = message.pageSize; + obj.page_token = message.pageToken; + if (message.resourceNames) { + obj.resource_names = message.resourceNames.map(e => e); + } else { + obj.resource_names = []; + } + return obj; + }, + fromAmino(object: ListLogsRequestAmino): ListLogsRequest { + const message = createBaseListLogsRequest(); + if (object.parent !== undefined && object.parent !== null) { + message.parent = object.parent; + } + if (object.page_size !== undefined && object.page_size !== null) { + message.pageSize = object.page_size; + } + if (object.page_token !== undefined && object.page_token !== null) { + message.pageToken = object.page_token; + } + message.resourceNames = object.resource_names?.map(e => e) || []; + return message; + }, + toAmino(message: ListLogsRequest): ListLogsRequestAmino { + const obj: any = {}; + obj.parent = message.parent === "" ? undefined : message.parent; + obj.page_size = message.pageSize === 0 ? undefined : message.pageSize; + obj.page_token = message.pageToken === "" ? undefined : message.pageToken; + if (message.resourceNames) { + obj.resource_names = message.resourceNames.map(e => e); + } else { + obj.resource_names = message.resourceNames; + } + return obj; + }, + fromAminoMsg(object: ListLogsRequestAminoMsg): ListLogsRequest { + return ListLogsRequest.fromAmino(object.value); + }, + fromProtoMsg(message: ListLogsRequestProtoMsg): ListLogsRequest { + return ListLogsRequest.decode(message.value); + }, + toProto(message: ListLogsRequest): Uint8Array { + return ListLogsRequest.encode(message).finish(); + }, + toProtoMsg(message: ListLogsRequest): ListLogsRequestProtoMsg { + return { + typeUrl: "/google.logging.v2.ListLogsRequest", + value: ListLogsRequest.encode(message).finish() + }; + } +}; +function createBaseListLogsResponse(): ListLogsResponse { + return { + logNames: [], + nextPageToken: "" + }; +} +export const ListLogsResponse = { + typeUrl: "/google.logging.v2.ListLogsResponse", + encode(message: ListLogsResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.logNames) { + writer.uint32(26).string(v!); + } + if (message.nextPageToken !== undefined) { + writer.uint32(18).string(message.nextPageToken); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ListLogsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseListLogsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 3: + message.logNames.push(reader.string()); + break; + case 2: + message.nextPageToken = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ListLogsResponse { + const obj = createBaseListLogsResponse(); + if (Array.isArray(object?.logNames)) obj.logNames = object.logNames.map((e: any) => String(e)); + if (isSet(object.nextPageToken)) obj.nextPageToken = String(object.nextPageToken); + return obj; + }, + toJSON(message: ListLogsResponse): JsonSafe { + const obj: any = {}; + if (message.logNames) { + obj.logNames = message.logNames.map(e => e); + } else { + obj.logNames = []; + } + message.nextPageToken !== undefined && (obj.nextPageToken = message.nextPageToken); + return obj; + }, + fromPartial(object: DeepPartial): ListLogsResponse { + const message = createBaseListLogsResponse(); + message.logNames = object.logNames?.map(e => e) || []; + message.nextPageToken = object.nextPageToken ?? ""; + return message; + }, + fromSDK(object: ListLogsResponseSDKType): ListLogsResponse { + return { + logNames: Array.isArray(object?.log_names) ? object.log_names.map((e: any) => e) : [], + nextPageToken: object?.next_page_token + }; + }, + fromSDKJSON(object: any): ListLogsResponseSDKType { + return { + log_names: Array.isArray(object?.log_names) ? object.log_names.map((e: any) => String(e)) : [], + next_page_token: isSet(object.next_page_token) ? String(object.next_page_token) : "" + }; + }, + toSDK(message: ListLogsResponse): ListLogsResponseSDKType { + const obj: any = {}; + if (message.logNames) { + obj.log_names = message.logNames.map(e => e); + } else { + obj.log_names = []; + } + obj.next_page_token = message.nextPageToken; + return obj; + }, + fromAmino(object: ListLogsResponseAmino): ListLogsResponse { + const message = createBaseListLogsResponse(); + message.logNames = object.log_names?.map(e => e) || []; + if (object.next_page_token !== undefined && object.next_page_token !== null) { + message.nextPageToken = object.next_page_token; + } + return message; + }, + toAmino(message: ListLogsResponse): ListLogsResponseAmino { + const obj: any = {}; + if (message.logNames) { + obj.log_names = message.logNames.map(e => e); + } else { + obj.log_names = message.logNames; + } + obj.next_page_token = message.nextPageToken === "" ? undefined : message.nextPageToken; + return obj; + }, + fromAminoMsg(object: ListLogsResponseAminoMsg): ListLogsResponse { + return ListLogsResponse.fromAmino(object.value); + }, + fromProtoMsg(message: ListLogsResponseProtoMsg): ListLogsResponse { + return ListLogsResponse.decode(message.value); + }, + toProto(message: ListLogsResponse): Uint8Array { + return ListLogsResponse.encode(message).finish(); + }, + toProtoMsg(message: ListLogsResponse): ListLogsResponseProtoMsg { + return { + typeUrl: "/google.logging.v2.ListLogsResponse", + value: ListLogsResponse.encode(message).finish() + }; + } +}; +function createBaseTailLogEntriesRequest(): TailLogEntriesRequest { + return { + resourceNames: [], + filter: "", + bufferWindow: undefined + }; +} +export const TailLogEntriesRequest = { + typeUrl: "/google.logging.v2.TailLogEntriesRequest", + encode(message: TailLogEntriesRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.resourceNames) { + writer.uint32(10).string(v!); + } + if (message.filter !== undefined) { + writer.uint32(18).string(message.filter); + } + if (message.bufferWindow !== undefined) { + Duration.encode(message.bufferWindow, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): TailLogEntriesRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseTailLogEntriesRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.resourceNames.push(reader.string()); + break; + case 2: + message.filter = reader.string(); + break; + case 3: + message.bufferWindow = Duration.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): TailLogEntriesRequest { + const obj = createBaseTailLogEntriesRequest(); + if (Array.isArray(object?.resourceNames)) obj.resourceNames = object.resourceNames.map((e: any) => String(e)); + if (isSet(object.filter)) obj.filter = String(object.filter); + if (isSet(object.bufferWindow)) obj.bufferWindow = Duration.fromJSON(object.bufferWindow); + return obj; + }, + toJSON(message: TailLogEntriesRequest): JsonSafe { + const obj: any = {}; + if (message.resourceNames) { + obj.resourceNames = message.resourceNames.map(e => e); + } else { + obj.resourceNames = []; + } + message.filter !== undefined && (obj.filter = message.filter); + message.bufferWindow !== undefined && (obj.bufferWindow = message.bufferWindow ? Duration.toJSON(message.bufferWindow) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): TailLogEntriesRequest { + const message = createBaseTailLogEntriesRequest(); + message.resourceNames = object.resourceNames?.map(e => e) || []; + message.filter = object.filter ?? ""; + if (object.bufferWindow !== undefined && object.bufferWindow !== null) { + message.bufferWindow = Duration.fromPartial(object.bufferWindow); + } + return message; + }, + fromSDK(object: TailLogEntriesRequestSDKType): TailLogEntriesRequest { + return { + resourceNames: Array.isArray(object?.resource_names) ? object.resource_names.map((e: any) => e) : [], + filter: object?.filter, + bufferWindow: object.buffer_window ? Duration.fromSDK(object.buffer_window) : undefined + }; + }, + fromSDKJSON(object: any): TailLogEntriesRequestSDKType { + return { + resource_names: Array.isArray(object?.resource_names) ? object.resource_names.map((e: any) => String(e)) : [], + filter: isSet(object.filter) ? String(object.filter) : "", + buffer_window: isSet(object.buffer_window) ? Duration.fromSDKJSON(object.buffer_window) : undefined + }; + }, + toSDK(message: TailLogEntriesRequest): TailLogEntriesRequestSDKType { + const obj: any = {}; + if (message.resourceNames) { + obj.resource_names = message.resourceNames.map(e => e); + } else { + obj.resource_names = []; + } + obj.filter = message.filter; + message.bufferWindow !== undefined && (obj.buffer_window = message.bufferWindow ? Duration.toSDK(message.bufferWindow) : undefined); + return obj; + }, + fromAmino(object: TailLogEntriesRequestAmino): TailLogEntriesRequest { + const message = createBaseTailLogEntriesRequest(); + message.resourceNames = object.resource_names?.map(e => e) || []; + if (object.filter !== undefined && object.filter !== null) { + message.filter = object.filter; + } + if (object.buffer_window !== undefined && object.buffer_window !== null) { + message.bufferWindow = Duration.fromAmino(object.buffer_window); + } + return message; + }, + toAmino(message: TailLogEntriesRequest): TailLogEntriesRequestAmino { + const obj: any = {}; + if (message.resourceNames) { + obj.resource_names = message.resourceNames.map(e => e); + } else { + obj.resource_names = message.resourceNames; + } + obj.filter = message.filter === "" ? undefined : message.filter; + obj.buffer_window = message.bufferWindow ? Duration.toAmino(message.bufferWindow) : undefined; + return obj; + }, + fromAminoMsg(object: TailLogEntriesRequestAminoMsg): TailLogEntriesRequest { + return TailLogEntriesRequest.fromAmino(object.value); + }, + fromProtoMsg(message: TailLogEntriesRequestProtoMsg): TailLogEntriesRequest { + return TailLogEntriesRequest.decode(message.value); + }, + toProto(message: TailLogEntriesRequest): Uint8Array { + return TailLogEntriesRequest.encode(message).finish(); + }, + toProtoMsg(message: TailLogEntriesRequest): TailLogEntriesRequestProtoMsg { + return { + typeUrl: "/google.logging.v2.TailLogEntriesRequest", + value: TailLogEntriesRequest.encode(message).finish() + }; + } +}; +function createBaseTailLogEntriesResponse(): TailLogEntriesResponse { + return { + entries: [], + suppressionInfo: [] + }; +} +export const TailLogEntriesResponse = { + typeUrl: "/google.logging.v2.TailLogEntriesResponse", + encode(message: TailLogEntriesResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.entries) { + LogEntry.encode(v!, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.suppressionInfo) { + TailLogEntriesResponse_SuppressionInfo.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): TailLogEntriesResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseTailLogEntriesResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.entries.push(LogEntry.decode(reader, reader.uint32())); + break; + case 2: + message.suppressionInfo.push(TailLogEntriesResponse_SuppressionInfo.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): TailLogEntriesResponse { + const obj = createBaseTailLogEntriesResponse(); + if (Array.isArray(object?.entries)) obj.entries = object.entries.map((e: any) => LogEntry.fromJSON(e)); + if (Array.isArray(object?.suppressionInfo)) obj.suppressionInfo = object.suppressionInfo.map((e: any) => TailLogEntriesResponse_SuppressionInfo.fromJSON(e)); + return obj; + }, + toJSON(message: TailLogEntriesResponse): JsonSafe { + const obj: any = {}; + if (message.entries) { + obj.entries = message.entries.map(e => e ? LogEntry.toJSON(e) : undefined); + } else { + obj.entries = []; + } + if (message.suppressionInfo) { + obj.suppressionInfo = message.suppressionInfo.map(e => e ? TailLogEntriesResponse_SuppressionInfo.toJSON(e) : undefined); + } else { + obj.suppressionInfo = []; + } + return obj; + }, + fromPartial(object: DeepPartial): TailLogEntriesResponse { + const message = createBaseTailLogEntriesResponse(); + message.entries = object.entries?.map(e => LogEntry.fromPartial(e)) || []; + message.suppressionInfo = object.suppressionInfo?.map(e => TailLogEntriesResponse_SuppressionInfo.fromPartial(e)) || []; + return message; + }, + fromSDK(object: TailLogEntriesResponseSDKType): TailLogEntriesResponse { + return { + entries: Array.isArray(object?.entries) ? object.entries.map((e: any) => LogEntry.fromSDK(e)) : [], + suppressionInfo: Array.isArray(object?.suppression_info) ? object.suppression_info.map((e: any) => TailLogEntriesResponse_SuppressionInfo.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): TailLogEntriesResponseSDKType { + return { + entries: Array.isArray(object?.entries) ? object.entries.map((e: any) => LogEntry.fromSDKJSON(e)) : [], + suppression_info: Array.isArray(object?.suppression_info) ? object.suppression_info.map((e: any) => TailLogEntriesResponse_SuppressionInfo.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: TailLogEntriesResponse): TailLogEntriesResponseSDKType { + const obj: any = {}; + if (message.entries) { + obj.entries = message.entries.map(e => e ? LogEntry.toSDK(e) : undefined); + } else { + obj.entries = []; + } + if (message.suppressionInfo) { + obj.suppression_info = message.suppressionInfo.map(e => e ? TailLogEntriesResponse_SuppressionInfo.toSDK(e) : undefined); + } else { + obj.suppression_info = []; + } + return obj; + }, + fromAmino(object: TailLogEntriesResponseAmino): TailLogEntriesResponse { + const message = createBaseTailLogEntriesResponse(); + message.entries = object.entries?.map(e => LogEntry.fromAmino(e)) || []; + message.suppressionInfo = object.suppression_info?.map(e => TailLogEntriesResponse_SuppressionInfo.fromAmino(e)) || []; + return message; + }, + toAmino(message: TailLogEntriesResponse): TailLogEntriesResponseAmino { + const obj: any = {}; + if (message.entries) { + obj.entries = message.entries.map(e => e ? LogEntry.toAmino(e) : undefined); + } else { + obj.entries = message.entries; + } + if (message.suppressionInfo) { + obj.suppression_info = message.suppressionInfo.map(e => e ? TailLogEntriesResponse_SuppressionInfo.toAmino(e) : undefined); + } else { + obj.suppression_info = message.suppressionInfo; + } + return obj; + }, + fromAminoMsg(object: TailLogEntriesResponseAminoMsg): TailLogEntriesResponse { + return TailLogEntriesResponse.fromAmino(object.value); + }, + fromProtoMsg(message: TailLogEntriesResponseProtoMsg): TailLogEntriesResponse { + return TailLogEntriesResponse.decode(message.value); + }, + toProto(message: TailLogEntriesResponse): Uint8Array { + return TailLogEntriesResponse.encode(message).finish(); + }, + toProtoMsg(message: TailLogEntriesResponse): TailLogEntriesResponseProtoMsg { + return { + typeUrl: "/google.logging.v2.TailLogEntriesResponse", + value: TailLogEntriesResponse.encode(message).finish() + }; + } +}; +function createBaseTailLogEntriesResponse_SuppressionInfo(): TailLogEntriesResponse_SuppressionInfo { + return { + reason: 0, + suppressedCount: 0 + }; +} +export const TailLogEntriesResponse_SuppressionInfo = { + typeUrl: "/google.logging.v2.SuppressionInfo", + encode(message: TailLogEntriesResponse_SuppressionInfo, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.reason !== 0) { + writer.uint32(8).int32(message.reason); + } + if (message.suppressedCount !== undefined) { + writer.uint32(16).int32(message.suppressedCount); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): TailLogEntriesResponse_SuppressionInfo { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseTailLogEntriesResponse_SuppressionInfo(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.reason = (reader.int32() as any); + break; + case 2: + message.suppressedCount = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): TailLogEntriesResponse_SuppressionInfo { + const obj = createBaseTailLogEntriesResponse_SuppressionInfo(); + if (isSet(object.reason)) obj.reason = tailLogEntriesResponse_SuppressionInfo_ReasonFromJSON(object.reason); + if (isSet(object.suppressedCount)) obj.suppressedCount = Number(object.suppressedCount); + return obj; + }, + toJSON(message: TailLogEntriesResponse_SuppressionInfo): JsonSafe { + const obj: any = {}; + message.reason !== undefined && (obj.reason = tailLogEntriesResponse_SuppressionInfo_ReasonToJSON(message.reason)); + message.suppressedCount !== undefined && (obj.suppressedCount = Math.round(message.suppressedCount)); + return obj; + }, + fromPartial(object: DeepPartial): TailLogEntriesResponse_SuppressionInfo { + const message = createBaseTailLogEntriesResponse_SuppressionInfo(); + message.reason = object.reason ?? 0; + message.suppressedCount = object.suppressedCount ?? 0; + return message; + }, + fromSDK(object: TailLogEntriesResponse_SuppressionInfoSDKType): TailLogEntriesResponse_SuppressionInfo { + return { + reason: isSet(object.reason) ? tailLogEntriesResponse_SuppressionInfo_ReasonFromJSON(object.reason) : -1, + suppressedCount: object?.suppressed_count + }; + }, + fromSDKJSON(object: any): TailLogEntriesResponse_SuppressionInfoSDKType { + return { + reason: isSet(object.reason) ? tailLogEntriesResponse_SuppressionInfo_ReasonFromJSON(object.reason) : -1, + suppressed_count: isSet(object.suppressed_count) ? Number(object.suppressed_count) : 0 + }; + }, + toSDK(message: TailLogEntriesResponse_SuppressionInfo): TailLogEntriesResponse_SuppressionInfoSDKType { + const obj: any = {}; + message.reason !== undefined && (obj.reason = tailLogEntriesResponse_SuppressionInfo_ReasonToJSON(message.reason)); + obj.suppressed_count = message.suppressedCount; + return obj; + }, + fromAmino(object: TailLogEntriesResponse_SuppressionInfoAmino): TailLogEntriesResponse_SuppressionInfo { + const message = createBaseTailLogEntriesResponse_SuppressionInfo(); + if (object.reason !== undefined && object.reason !== null) { + message.reason = object.reason; + } + if (object.suppressed_count !== undefined && object.suppressed_count !== null) { + message.suppressedCount = object.suppressed_count; + } + return message; + }, + toAmino(message: TailLogEntriesResponse_SuppressionInfo): TailLogEntriesResponse_SuppressionInfoAmino { + const obj: any = {}; + obj.reason = message.reason === 0 ? undefined : message.reason; + obj.suppressed_count = message.suppressedCount === 0 ? undefined : message.suppressedCount; + return obj; + }, + fromAminoMsg(object: TailLogEntriesResponse_SuppressionInfoAminoMsg): TailLogEntriesResponse_SuppressionInfo { + return TailLogEntriesResponse_SuppressionInfo.fromAmino(object.value); + }, + fromProtoMsg(message: TailLogEntriesResponse_SuppressionInfoProtoMsg): TailLogEntriesResponse_SuppressionInfo { + return TailLogEntriesResponse_SuppressionInfo.decode(message.value); + }, + toProto(message: TailLogEntriesResponse_SuppressionInfo): Uint8Array { + return TailLogEntriesResponse_SuppressionInfo.encode(message).finish(); + }, + toProtoMsg(message: TailLogEntriesResponse_SuppressionInfo): TailLogEntriesResponse_SuppressionInfoProtoMsg { + return { + typeUrl: "/google.logging.v2.SuppressionInfo", + value: TailLogEntriesResponse_SuppressionInfo.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/logging/v2/logging_config.ts b/__fixtures__/v-next/outputicjsdeps/google/logging/v2/logging_config.ts new file mode 100644 index 0000000000..99b27c9942 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/logging/v2/logging_config.ts @@ -0,0 +1,6551 @@ +import { FieldMask, FieldMaskSDKType } from "../../protobuf/field_mask.js"; +import { Timestamp, TimestampSDKType } from "../../protobuf/timestamp.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { toTimestamp, fromTimestamp, isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "google.logging.v2"; +/** Deprecated. This is unused. */ +export enum LogSink_VersionFormat { + /** VERSION_FORMAT_UNSPECIFIED - An unspecified format version that will default to V2. */ + VERSION_FORMAT_UNSPECIFIED = 0, + /** V2 - `LogEntry` version 2 format. */ + V2 = 1, + /** V1 - `LogEntry` version 1 format. */ + V1 = 2, + UNRECOGNIZED = -1, +} +export const LogSink_VersionFormatSDKType = LogSink_VersionFormat; +export function logSink_VersionFormatFromJSON(object: any): LogSink_VersionFormat { + switch (object) { + case 0: + case "VERSION_FORMAT_UNSPECIFIED": + return LogSink_VersionFormat.VERSION_FORMAT_UNSPECIFIED; + case 1: + case "V2": + return LogSink_VersionFormat.V2; + case 2: + case "V1": + return LogSink_VersionFormat.V1; + case -1: + case "UNRECOGNIZED": + default: + return LogSink_VersionFormat.UNRECOGNIZED; + } +} +export function logSink_VersionFormatToJSON(object: LogSink_VersionFormat): string { + switch (object) { + case LogSink_VersionFormat.VERSION_FORMAT_UNSPECIFIED: + return "VERSION_FORMAT_UNSPECIFIED"; + case LogSink_VersionFormat.V2: + return "V2"; + case LogSink_VersionFormat.V1: + return "V1"; + case LogSink_VersionFormat.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** LogBucket lifecycle states. */ +export enum LifecycleState { + /** + * LIFECYCLE_STATE_UNSPECIFIED - Unspecified state. This is only used/useful for distinguishing unset + * values. + */ + LIFECYCLE_STATE_UNSPECIFIED = 0, + /** ACTIVE - The normal and active state. */ + ACTIVE = 1, + /** + * DELETE_REQUESTED - The resource has been marked for deletion by the user. For some resources + * (e.g. buckets), this can be reversed by an un-delete operation. + */ + DELETE_REQUESTED = 2, + UNRECOGNIZED = -1, +} +export const LifecycleStateSDKType = LifecycleState; +export function lifecycleStateFromJSON(object: any): LifecycleState { + switch (object) { + case 0: + case "LIFECYCLE_STATE_UNSPECIFIED": + return LifecycleState.LIFECYCLE_STATE_UNSPECIFIED; + case 1: + case "ACTIVE": + return LifecycleState.ACTIVE; + case 2: + case "DELETE_REQUESTED": + return LifecycleState.DELETE_REQUESTED; + case -1: + case "UNRECOGNIZED": + default: + return LifecycleState.UNRECOGNIZED; + } +} +export function lifecycleStateToJSON(object: LifecycleState): string { + switch (object) { + case LifecycleState.LIFECYCLE_STATE_UNSPECIFIED: + return "LIFECYCLE_STATE_UNSPECIFIED"; + case LifecycleState.ACTIVE: + return "ACTIVE"; + case LifecycleState.DELETE_REQUESTED: + return "DELETE_REQUESTED"; + case LifecycleState.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** + * List of different operation states. + * High level state of the operation. This is used to report the job's + * current state to the user. Once a long running operation is created, + * the current state of the operation can be queried even before the + * operation is finished and the final result is available. + */ +export enum OperationState { + /** OPERATION_STATE_UNSPECIFIED - Should not be used. */ + OPERATION_STATE_UNSPECIFIED = 0, + /** OPERATION_STATE_SCHEDULED - The operation is scheduled. */ + OPERATION_STATE_SCHEDULED = 1, + /** OPERATION_STATE_WAITING_FOR_PERMISSIONS - Waiting for necessary permissions. */ + OPERATION_STATE_WAITING_FOR_PERMISSIONS = 2, + /** OPERATION_STATE_RUNNING - The operation is running. */ + OPERATION_STATE_RUNNING = 3, + /** OPERATION_STATE_SUCCEEDED - The operation was completed successfully. */ + OPERATION_STATE_SUCCEEDED = 4, + /** OPERATION_STATE_FAILED - The operation failed. */ + OPERATION_STATE_FAILED = 5, + /** OPERATION_STATE_CANCELLED - The operation was cancelled by the user. */ + OPERATION_STATE_CANCELLED = 6, + UNRECOGNIZED = -1, +} +export const OperationStateSDKType = OperationState; +export function operationStateFromJSON(object: any): OperationState { + switch (object) { + case 0: + case "OPERATION_STATE_UNSPECIFIED": + return OperationState.OPERATION_STATE_UNSPECIFIED; + case 1: + case "OPERATION_STATE_SCHEDULED": + return OperationState.OPERATION_STATE_SCHEDULED; + case 2: + case "OPERATION_STATE_WAITING_FOR_PERMISSIONS": + return OperationState.OPERATION_STATE_WAITING_FOR_PERMISSIONS; + case 3: + case "OPERATION_STATE_RUNNING": + return OperationState.OPERATION_STATE_RUNNING; + case 4: + case "OPERATION_STATE_SUCCEEDED": + return OperationState.OPERATION_STATE_SUCCEEDED; + case 5: + case "OPERATION_STATE_FAILED": + return OperationState.OPERATION_STATE_FAILED; + case 6: + case "OPERATION_STATE_CANCELLED": + return OperationState.OPERATION_STATE_CANCELLED; + case -1: + case "UNRECOGNIZED": + default: + return OperationState.UNRECOGNIZED; + } +} +export function operationStateToJSON(object: OperationState): string { + switch (object) { + case OperationState.OPERATION_STATE_UNSPECIFIED: + return "OPERATION_STATE_UNSPECIFIED"; + case OperationState.OPERATION_STATE_SCHEDULED: + return "OPERATION_STATE_SCHEDULED"; + case OperationState.OPERATION_STATE_WAITING_FOR_PERMISSIONS: + return "OPERATION_STATE_WAITING_FOR_PERMISSIONS"; + case OperationState.OPERATION_STATE_RUNNING: + return "OPERATION_STATE_RUNNING"; + case OperationState.OPERATION_STATE_SUCCEEDED: + return "OPERATION_STATE_SUCCEEDED"; + case OperationState.OPERATION_STATE_FAILED: + return "OPERATION_STATE_FAILED"; + case OperationState.OPERATION_STATE_CANCELLED: + return "OPERATION_STATE_CANCELLED"; + case OperationState.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** Describes a repository in which log entries are stored. */ +export interface LogBucket { + /** + * Output only. The resource name of the bucket. + * + * For example: + * + * `projects/my-project/locations/global/buckets/my-bucket` + * + * For a list of supported locations, see [Supported + * Regions](https://cloud.google.com/logging/docs/region-support) + * + * For the location of `global` it is unspecified where log entries are + * actually stored. + * + * After a bucket has been created, the location cannot be changed. + */ + name: string; + /** Describes this bucket. */ + description: string; + /** + * Output only. The creation timestamp of the bucket. This is not set for any of the + * default buckets. + */ + createTime?: Date; + /** Output only. The last update timestamp of the bucket. */ + updateTime?: Date; + /** + * Logs will be retained by default for this amount of time, after which they + * will automatically be deleted. The minimum retention period is 1 day. If + * this value is set to zero at bucket creation time, the default time of 30 + * days will be used. + */ + retentionDays: number; + /** + * Whether the bucket is locked. + * + * The retention period on a locked bucket cannot be changed. Locked buckets + * may only be deleted if they are empty. + */ + locked: boolean; + /** Output only. The bucket lifecycle state. */ + lifecycleState: LifecycleState; + /** + * Log entry field paths that are denied access in this bucket. + * + * The following fields and their children are eligible: `textPayload`, + * `jsonPayload`, `protoPayload`, `httpRequest`, `labels`, `sourceLocation`. + * + * Restricting a repeated field will restrict all values. Adding a parent will + * block all child fields. (e.g. `foo.bar` will block `foo.bar.baz`) + */ + restrictedFields: string[]; + /** + * The CMEK settings of the log bucket. If present, new log entries written to + * this log bucket are encrypted using the CMEK key provided in this + * configuration. If a log bucket has CMEK settings, the CMEK settings cannot + * be disabled later by updating the log bucket. Changing the KMS key is + * allowed. + */ + cmekSettings?: CmekSettings; +} +export interface LogBucketProtoMsg { + typeUrl: "/google.logging.v2.LogBucket"; + value: Uint8Array; +} +/** Describes a repository in which log entries are stored. */ +export interface LogBucketSDKType { + name: string; + description: string; + create_time?: Date; + update_time?: Date; + retention_days: number; + locked: boolean; + lifecycle_state: LifecycleState; + restricted_fields: string[]; + cmek_settings?: CmekSettingsSDKType; +} +/** Describes a view over log entries in a bucket. */ +export interface LogView { + /** + * The resource name of the view. + * + * For example: + * + * `projects/my-project/locations/global/buckets/my-bucket/views/my-view` + */ + name: string; + /** Describes this view. */ + description: string; + /** Output only. The creation timestamp of the view. */ + createTime?: Date; + /** Output only. The last update timestamp of the view. */ + updateTime?: Date; + /** + * Filter that restricts which log entries in a bucket are visible in this + * view. + * + * Filters are restricted to be a logical AND of ==/!= of any of the + * following: + * + * - originating project/folder/organization/billing account. + * - resource type + * - log id + * + * For example: + * + * SOURCE("projects/myproject") AND resource.type = "gce_instance" + * AND LOG_ID("stdout") + */ + filter: string; +} +export interface LogViewProtoMsg { + typeUrl: "/google.logging.v2.LogView"; + value: Uint8Array; +} +/** Describes a view over log entries in a bucket. */ +export interface LogViewSDKType { + name: string; + description: string; + create_time?: Date; + update_time?: Date; + filter: string; +} +/** + * Describes a sink used to export log entries to one of the following + * destinations in any project: a Cloud Storage bucket, a BigQuery dataset, a + * Pub/Sub topic or a Cloud Logging log bucket. A logs filter controls which log + * entries are exported. The sink must be created within a project, + * organization, billing account, or folder. + */ +export interface LogSink { + /** + * Required. The client-assigned sink identifier, unique within the project. + * + * For example: `"my-syslog-errors-to-pubsub"`. Sink identifiers are limited + * to 100 characters and can include only the following characters: upper and + * lower-case alphanumeric characters, underscores, hyphens, and periods. + * First character has to be alphanumeric. + */ + name: string; + /** + * Required. The export destination: + * + * "storage.googleapis.com/[GCS_BUCKET]" + * "bigquery.googleapis.com/projects/[PROJECT_ID]/datasets/[DATASET]" + * "pubsub.googleapis.com/projects/[PROJECT_ID]/topics/[TOPIC_ID]" + * + * The sink's `writer_identity`, set when the sink is created, must have + * permission to write to the destination or else the log entries are not + * exported. For more information, see + * [Exporting Logs with + * Sinks](https://cloud.google.com/logging/docs/api/tasks/exporting-logs). + */ + destination: string; + /** + * Optional. An [advanced logs + * filter](https://cloud.google.com/logging/docs/view/advanced-queries). The + * only exported log entries are those that are in the resource owning the + * sink and that match the filter. + * + * For example: + * + * `logName="projects/[PROJECT_ID]/logs/[LOG_ID]" AND severity>=ERROR` + */ + filter: string; + /** + * Optional. A description of this sink. + * + * The maximum length of the description is 8000 characters. + */ + description: string; + /** + * Optional. If set to true, then this sink is disabled and it does not export any log + * entries. + */ + disabled: boolean; + /** + * Optional. Log entries that match any of these exclusion filters will not be exported. + * + * If a log entry is matched by both `filter` and one of `exclusion_filters` + * it will not be exported. + */ + exclusions: LogExclusion[]; + /** Deprecated. This field is unused. */ + /** @deprecated */ + outputVersionFormat: LogSink_VersionFormat; + /** + * Output only. An IAM identity—a service account or group—under which Cloud + * Logging writes the exported log entries to the sink's destination. This + * field is set by + * [sinks.create][google.logging.v2.ConfigServiceV2.CreateSink] and + * [sinks.update][google.logging.v2.ConfigServiceV2.UpdateSink] based on the + * value of `unique_writer_identity` in those methods. + * + * Until you grant this identity write-access to the destination, log entry + * exports from this sink will fail. For more information, see [Granting + * Access for a + * Resource](https://cloud.google.com/iam/docs/granting-roles-to-service-accounts#granting_access_to_a_service_account_for_a_resource). + * Consult the destination service's documentation to determine the + * appropriate IAM roles to assign to the identity. + * + * Sinks that have a destination that is a log bucket in the same project as + * the sink do not have a writer_identity and no additional permissions are + * required. + */ + writerIdentity: string; + /** + * Optional. This field applies only to sinks owned by organizations and folders. If the + * field is false, the default, only the logs owned by the sink's parent + * resource are available for export. If the field is true, then log entries + * from all the projects, folders, and billing accounts contained in the + * sink's parent resource are also available for export. Whether a particular + * log entry from the children is exported depends on the sink's filter + * expression. + * + * For example, if this field is true, then the filter + * `resource.type=gce_instance` would export all Compute Engine VM instance + * log entries from all projects in the sink's parent. + * + * To only export entries from certain child projects, filter on the project + * part of the log name: + * + * logName:("projects/test-project1/" OR "projects/test-project2/") AND + * resource.type=gce_instance + */ + includeChildren: boolean; + /** Optional. Options that affect sinks exporting data to BigQuery. */ + bigqueryOptions?: BigQueryOptions; + /** + * Output only. The creation timestamp of the sink. + * + * This field may not be present for older sinks. + */ + createTime?: Date; + /** + * Output only. The last update timestamp of the sink. + * + * This field may not be present for older sinks. + */ + updateTime?: Date; +} +export interface LogSinkProtoMsg { + typeUrl: "/google.logging.v2.LogSink"; + value: Uint8Array; +} +/** + * Describes a sink used to export log entries to one of the following + * destinations in any project: a Cloud Storage bucket, a BigQuery dataset, a + * Pub/Sub topic or a Cloud Logging log bucket. A logs filter controls which log + * entries are exported. The sink must be created within a project, + * organization, billing account, or folder. + */ +export interface LogSinkSDKType { + name: string; + destination: string; + filter: string; + description: string; + disabled: boolean; + exclusions: LogExclusionSDKType[]; + /** @deprecated */ + output_version_format: LogSink_VersionFormat; + writer_identity: string; + include_children: boolean; + bigquery_options?: BigQueryOptionsSDKType; + create_time?: Date; + update_time?: Date; +} +/** Options that change functionality of a sink exporting data to BigQuery. */ +export interface BigQueryOptions { + /** + * Optional. Whether to use [BigQuery's partition + * tables](https://cloud.google.com/bigquery/docs/partitioned-tables). By + * default, Cloud Logging creates dated tables based on the log entries' + * timestamps, e.g. syslog_20170523. With partitioned tables the date suffix + * is no longer present and [special query + * syntax](https://cloud.google.com/bigquery/docs/querying-partitioned-tables) + * has to be used instead. In both cases, tables are sharded based on UTC + * timezone. + */ + usePartitionedTables: boolean; + /** + * Output only. True if new timestamp column based partitioning is in use, false if legacy + * ingestion-time partitioning is in use. + * + * All new sinks will have this field set true and will use timestamp column + * based partitioning. If use_partitioned_tables is false, this value has no + * meaning and will be false. Legacy sinks using partitioned tables will have + * this field set to false. + */ + usesTimestampColumnPartitioning: boolean; +} +export interface BigQueryOptionsProtoMsg { + typeUrl: "/google.logging.v2.BigQueryOptions"; + value: Uint8Array; +} +/** Options that change functionality of a sink exporting data to BigQuery. */ +export interface BigQueryOptionsSDKType { + use_partitioned_tables: boolean; + uses_timestamp_column_partitioning: boolean; +} +/** The parameters to `ListBuckets`. */ +export interface ListBucketsRequest { + /** + * Required. The parent resource whose buckets are to be listed: + * + * "projects/[PROJECT_ID]/locations/[LOCATION_ID]" + * "organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]" + * "folders/[FOLDER_ID]/locations/[LOCATION_ID]" + * + * Note: The locations portion of the resource must be specified, but + * supplying the character `-` in place of [LOCATION_ID] will return all + * buckets. + */ + parent: string; + /** + * Optional. If present, then retrieve the next batch of results from the preceding call + * to this method. `pageToken` must be the value of `nextPageToken` from the + * previous response. The values of other method parameters should be + * identical to those in the previous call. + */ + pageToken: string; + /** + * Optional. The maximum number of results to return from this request. Non-positive + * values are ignored. The presence of `nextPageToken` in the response + * indicates that more results might be available. + */ + pageSize: number; +} +export interface ListBucketsRequestProtoMsg { + typeUrl: "/google.logging.v2.ListBucketsRequest"; + value: Uint8Array; +} +/** The parameters to `ListBuckets`. */ +export interface ListBucketsRequestSDKType { + parent: string; + page_token: string; + page_size: number; +} +/** The response from ListBuckets. */ +export interface ListBucketsResponse { + /** A list of buckets. */ + buckets: LogBucket[]; + /** + * If there might be more results than appear in this response, then + * `nextPageToken` is included. To get the next set of results, call the same + * method again using the value of `nextPageToken` as `pageToken`. + */ + nextPageToken: string; +} +export interface ListBucketsResponseProtoMsg { + typeUrl: "/google.logging.v2.ListBucketsResponse"; + value: Uint8Array; +} +/** The response from ListBuckets. */ +export interface ListBucketsResponseSDKType { + buckets: LogBucketSDKType[]; + next_page_token: string; +} +/** The parameters to `CreateBucket`. */ +export interface CreateBucketRequest { + /** + * Required. The resource in which to create the log bucket: + * + * "projects/[PROJECT_ID]/locations/[LOCATION_ID]" + * + * For example: + * + * `"projects/my-project/locations/global"` + */ + parent: string; + /** + * Required. A client-assigned identifier such as `"my-bucket"`. Identifiers are limited + * to 100 characters and can include only letters, digits, underscores, + * hyphens, and periods. + */ + bucketId: string; + /** + * Required. The new bucket. The region specified in the new bucket must be compliant + * with any Location Restriction Org Policy. The name field in the bucket is + * ignored. + */ + bucket?: LogBucket; +} +export interface CreateBucketRequestProtoMsg { + typeUrl: "/google.logging.v2.CreateBucketRequest"; + value: Uint8Array; +} +/** The parameters to `CreateBucket`. */ +export interface CreateBucketRequestSDKType { + parent: string; + bucket_id: string; + bucket?: LogBucketSDKType; +} +/** The parameters to `UpdateBucket`. */ +export interface UpdateBucketRequest { + /** + * Required. The full resource name of the bucket to update. + * + * "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" + * "organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" + * "folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" + * + * For example: + * + * `"projects/my-project/locations/global/buckets/my-bucket"` + */ + name: string; + /** Required. The updated bucket. */ + bucket?: LogBucket; + /** + * Required. Field mask that specifies the fields in `bucket` that need an update. A + * bucket field will be overwritten if, and only if, it is in the update mask. + * `name` and output only fields cannot be updated. + * + * For a detailed `FieldMask` definition, see: + * https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.FieldMask + * + * For example: `updateMask=retention_days` + */ + updateMask?: FieldMask; +} +export interface UpdateBucketRequestProtoMsg { + typeUrl: "/google.logging.v2.UpdateBucketRequest"; + value: Uint8Array; +} +/** The parameters to `UpdateBucket`. */ +export interface UpdateBucketRequestSDKType { + name: string; + bucket?: LogBucketSDKType; + update_mask?: FieldMaskSDKType; +} +/** The parameters to `GetBucket`. */ +export interface GetBucketRequest { + /** + * Required. The resource name of the bucket: + * + * "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" + * "organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" + * "folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" + * + * For example: + * + * `"projects/my-project/locations/global/buckets/my-bucket"` + */ + name: string; +} +export interface GetBucketRequestProtoMsg { + typeUrl: "/google.logging.v2.GetBucketRequest"; + value: Uint8Array; +} +/** The parameters to `GetBucket`. */ +export interface GetBucketRequestSDKType { + name: string; +} +/** The parameters to `DeleteBucket`. */ +export interface DeleteBucketRequest { + /** + * Required. The full resource name of the bucket to delete. + * + * "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" + * "organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" + * "folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" + * + * For example: + * + * `"projects/my-project/locations/global/buckets/my-bucket"` + */ + name: string; +} +export interface DeleteBucketRequestProtoMsg { + typeUrl: "/google.logging.v2.DeleteBucketRequest"; + value: Uint8Array; +} +/** The parameters to `DeleteBucket`. */ +export interface DeleteBucketRequestSDKType { + name: string; +} +/** The parameters to `UndeleteBucket`. */ +export interface UndeleteBucketRequest { + /** + * Required. The full resource name of the bucket to undelete. + * + * "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" + * "organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" + * "folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" + * + * For example: + * + * `"projects/my-project/locations/global/buckets/my-bucket"` + */ + name: string; +} +export interface UndeleteBucketRequestProtoMsg { + typeUrl: "/google.logging.v2.UndeleteBucketRequest"; + value: Uint8Array; +} +/** The parameters to `UndeleteBucket`. */ +export interface UndeleteBucketRequestSDKType { + name: string; +} +/** The parameters to `ListViews`. */ +export interface ListViewsRequest { + /** + * Required. The bucket whose views are to be listed: + * + * "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" + */ + parent: string; + /** + * Optional. If present, then retrieve the next batch of results from the preceding call + * to this method. `pageToken` must be the value of `nextPageToken` from the + * previous response. The values of other method parameters should be + * identical to those in the previous call. + */ + pageToken: string; + /** + * Optional. The maximum number of results to return from this request. + * + * Non-positive values are ignored. The presence of `nextPageToken` in the + * response indicates that more results might be available. + */ + pageSize: number; +} +export interface ListViewsRequestProtoMsg { + typeUrl: "/google.logging.v2.ListViewsRequest"; + value: Uint8Array; +} +/** The parameters to `ListViews`. */ +export interface ListViewsRequestSDKType { + parent: string; + page_token: string; + page_size: number; +} +/** The response from ListViews. */ +export interface ListViewsResponse { + /** A list of views. */ + views: LogView[]; + /** + * If there might be more results than appear in this response, then + * `nextPageToken` is included. To get the next set of results, call the same + * method again using the value of `nextPageToken` as `pageToken`. + */ + nextPageToken: string; +} +export interface ListViewsResponseProtoMsg { + typeUrl: "/google.logging.v2.ListViewsResponse"; + value: Uint8Array; +} +/** The response from ListViews. */ +export interface ListViewsResponseSDKType { + views: LogViewSDKType[]; + next_page_token: string; +} +/** The parameters to `CreateView`. */ +export interface CreateViewRequest { + /** + * Required. The bucket in which to create the view + * + * `"projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]"` + * + * For example: + * + * `"projects/my-project/locations/global/buckets/my-bucket"` + */ + parent: string; + /** Required. The id to use for this view. */ + viewId: string; + /** Required. The new view. */ + view?: LogView; +} +export interface CreateViewRequestProtoMsg { + typeUrl: "/google.logging.v2.CreateViewRequest"; + value: Uint8Array; +} +/** The parameters to `CreateView`. */ +export interface CreateViewRequestSDKType { + parent: string; + view_id: string; + view?: LogViewSDKType; +} +/** The parameters to `UpdateView`. */ +export interface UpdateViewRequest { + /** + * Required. The full resource name of the view to update + * + * "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]" + * + * For example: + * + * `"projects/my-project/locations/global/buckets/my-bucket/views/my-view"` + */ + name: string; + /** Required. The updated view. */ + view?: LogView; + /** + * Optional. Field mask that specifies the fields in `view` that need + * an update. A field will be overwritten if, and only if, it is + * in the update mask. `name` and output only fields cannot be updated. + * + * For a detailed `FieldMask` definition, see + * https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.FieldMask + * + * For example: `updateMask=filter` + */ + updateMask?: FieldMask; +} +export interface UpdateViewRequestProtoMsg { + typeUrl: "/google.logging.v2.UpdateViewRequest"; + value: Uint8Array; +} +/** The parameters to `UpdateView`. */ +export interface UpdateViewRequestSDKType { + name: string; + view?: LogViewSDKType; + update_mask?: FieldMaskSDKType; +} +/** The parameters to `GetView`. */ +export interface GetViewRequest { + /** + * Required. The resource name of the policy: + * + * "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]" + * + * For example: + * + * `"projects/my-project/locations/global/buckets/my-bucket/views/my-view"` + */ + name: string; +} +export interface GetViewRequestProtoMsg { + typeUrl: "/google.logging.v2.GetViewRequest"; + value: Uint8Array; +} +/** The parameters to `GetView`. */ +export interface GetViewRequestSDKType { + name: string; +} +/** The parameters to `DeleteView`. */ +export interface DeleteViewRequest { + /** + * Required. The full resource name of the view to delete: + * + * "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]" + * + * For example: + * + * `"projects/my-project/locations/global/buckets/my-bucket/views/my-view"` + */ + name: string; +} +export interface DeleteViewRequestProtoMsg { + typeUrl: "/google.logging.v2.DeleteViewRequest"; + value: Uint8Array; +} +/** The parameters to `DeleteView`. */ +export interface DeleteViewRequestSDKType { + name: string; +} +/** The parameters to `ListSinks`. */ +export interface ListSinksRequest { + /** + * Required. The parent resource whose sinks are to be listed: + * + * "projects/[PROJECT_ID]" + * "organizations/[ORGANIZATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]" + * "folders/[FOLDER_ID]" + */ + parent: string; + /** + * Optional. If present, then retrieve the next batch of results from the + * preceding call to this method. `pageToken` must be the value of + * `nextPageToken` from the previous response. The values of other method + * parameters should be identical to those in the previous call. + */ + pageToken: string; + /** + * Optional. The maximum number of results to return from this request. + * Non-positive values are ignored. The presence of `nextPageToken` in the + * response indicates that more results might be available. + */ + pageSize: number; +} +export interface ListSinksRequestProtoMsg { + typeUrl: "/google.logging.v2.ListSinksRequest"; + value: Uint8Array; +} +/** The parameters to `ListSinks`. */ +export interface ListSinksRequestSDKType { + parent: string; + page_token: string; + page_size: number; +} +/** Result returned from `ListSinks`. */ +export interface ListSinksResponse { + /** A list of sinks. */ + sinks: LogSink[]; + /** + * If there might be more results than appear in this response, then + * `nextPageToken` is included. To get the next set of results, call the same + * method again using the value of `nextPageToken` as `pageToken`. + */ + nextPageToken: string; +} +export interface ListSinksResponseProtoMsg { + typeUrl: "/google.logging.v2.ListSinksResponse"; + value: Uint8Array; +} +/** Result returned from `ListSinks`. */ +export interface ListSinksResponseSDKType { + sinks: LogSinkSDKType[]; + next_page_token: string; +} +/** The parameters to `GetSink`. */ +export interface GetSinkRequest { + /** + * Required. The resource name of the sink: + * + * "projects/[PROJECT_ID]/sinks/[SINK_ID]" + * "organizations/[ORGANIZATION_ID]/sinks/[SINK_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]/sinks/[SINK_ID]" + * "folders/[FOLDER_ID]/sinks/[SINK_ID]" + * + * For example: + * + * `"projects/my-project/sinks/my-sink"` + */ + sinkName: string; +} +export interface GetSinkRequestProtoMsg { + typeUrl: "/google.logging.v2.GetSinkRequest"; + value: Uint8Array; +} +/** The parameters to `GetSink`. */ +export interface GetSinkRequestSDKType { + sink_name: string; +} +/** The parameters to `CreateSink`. */ +export interface CreateSinkRequest { + /** + * Required. The resource in which to create the sink: + * + * "projects/[PROJECT_ID]" + * "organizations/[ORGANIZATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]" + * "folders/[FOLDER_ID]" + * + * For examples: + * + * `"projects/my-project"` + * `"organizations/123456789"` + */ + parent: string; + /** + * Required. The new sink, whose `name` parameter is a sink identifier that + * is not already in use. + */ + sink?: LogSink; + /** + * Optional. Determines the kind of IAM identity returned as `writer_identity` + * in the new sink. If this value is omitted or set to false, and if the + * sink's parent is a project, then the value returned as `writer_identity` is + * the same group or service account used by Cloud Logging before the addition + * of writer identities to this API. The sink's destination must be in the + * same project as the sink itself. + * + * If this field is set to true, or if the sink is owned by a non-project + * resource such as an organization, then the value of `writer_identity` will + * be a unique service account used only for exports from the new sink. For + * more information, see `writer_identity` in [LogSink][google.logging.v2.LogSink]. + */ + uniqueWriterIdentity: boolean; +} +export interface CreateSinkRequestProtoMsg { + typeUrl: "/google.logging.v2.CreateSinkRequest"; + value: Uint8Array; +} +/** The parameters to `CreateSink`. */ +export interface CreateSinkRequestSDKType { + parent: string; + sink?: LogSinkSDKType; + unique_writer_identity: boolean; +} +/** The parameters to `UpdateSink`. */ +export interface UpdateSinkRequest { + /** + * Required. The full resource name of the sink to update, including the parent + * resource and the sink identifier: + * + * "projects/[PROJECT_ID]/sinks/[SINK_ID]" + * "organizations/[ORGANIZATION_ID]/sinks/[SINK_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]/sinks/[SINK_ID]" + * "folders/[FOLDER_ID]/sinks/[SINK_ID]" + * + * For example: + * + * `"projects/my-project/sinks/my-sink"` + */ + sinkName: string; + /** + * Required. The updated sink, whose name is the same identifier that appears as part + * of `sink_name`. + */ + sink?: LogSink; + /** + * Optional. See [sinks.create][google.logging.v2.ConfigServiceV2.CreateSink] + * for a description of this field. When updating a sink, the effect of this + * field on the value of `writer_identity` in the updated sink depends on both + * the old and new values of this field: + * + * + If the old and new values of this field are both false or both true, + * then there is no change to the sink's `writer_identity`. + * + If the old value is false and the new value is true, then + * `writer_identity` is changed to a unique service account. + * + It is an error if the old value is true and the new value is + * set to false or defaulted to false. + */ + uniqueWriterIdentity: boolean; + /** + * Optional. Field mask that specifies the fields in `sink` that need + * an update. A sink field will be overwritten if, and only if, it is + * in the update mask. `name` and output only fields cannot be updated. + * + * An empty `updateMask` is temporarily treated as using the following mask + * for backwards compatibility purposes: + * + * `destination,filter,includeChildren` + * + * At some point in the future, behavior will be removed and specifying an + * empty `updateMask` will be an error. + * + * For a detailed `FieldMask` definition, see + * https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.FieldMask + * + * For example: `updateMask=filter` + */ + updateMask?: FieldMask; +} +export interface UpdateSinkRequestProtoMsg { + typeUrl: "/google.logging.v2.UpdateSinkRequest"; + value: Uint8Array; +} +/** The parameters to `UpdateSink`. */ +export interface UpdateSinkRequestSDKType { + sink_name: string; + sink?: LogSinkSDKType; + unique_writer_identity: boolean; + update_mask?: FieldMaskSDKType; +} +/** The parameters to `DeleteSink`. */ +export interface DeleteSinkRequest { + /** + * Required. The full resource name of the sink to delete, including the parent + * resource and the sink identifier: + * + * "projects/[PROJECT_ID]/sinks/[SINK_ID]" + * "organizations/[ORGANIZATION_ID]/sinks/[SINK_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]/sinks/[SINK_ID]" + * "folders/[FOLDER_ID]/sinks/[SINK_ID]" + * + * For example: + * + * `"projects/my-project/sinks/my-sink"` + */ + sinkName: string; +} +export interface DeleteSinkRequestProtoMsg { + typeUrl: "/google.logging.v2.DeleteSinkRequest"; + value: Uint8Array; +} +/** The parameters to `DeleteSink`. */ +export interface DeleteSinkRequestSDKType { + sink_name: string; +} +/** + * Specifies a set of log entries that are filtered out by a sink. If + * your Google Cloud resource receives a large volume of log entries, you can + * use exclusions to reduce your chargeable logs. Note that exclusions on + * organization-level and folder-level sinks don't apply to child resources. + * Note also that you cannot modify the _Required sink or exclude logs from it. + */ +export interface LogExclusion { + /** + * Required. A client-assigned identifier, such as `"load-balancer-exclusion"`. + * Identifiers are limited to 100 characters and can include only letters, + * digits, underscores, hyphens, and periods. First character has to be + * alphanumeric. + */ + name: string; + /** Optional. A description of this exclusion. */ + description: string; + /** + * Required. An [advanced logs + * filter](https://cloud.google.com/logging/docs/view/advanced-queries) that + * matches the log entries to be excluded. By using the [sample + * function](https://cloud.google.com/logging/docs/view/advanced-queries#sample), + * you can exclude less than 100% of the matching log entries. + * + * For example, the following query matches 99% of low-severity log entries + * from Google Cloud Storage buckets: + * + * `resource.type=gcs_bucket severity>> 3) { + case 1: + message.name = reader.string(); + break; + case 3: + message.description = reader.string(); + break; + case 4: + message.createTime = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + break; + case 5: + message.updateTime = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + break; + case 11: + message.retentionDays = reader.int32(); + break; + case 9: + message.locked = reader.bool(); + break; + case 12: + message.lifecycleState = (reader.int32() as any); + break; + case 15: + message.restrictedFields.push(reader.string()); + break; + case 19: + message.cmekSettings = CmekSettings.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): LogBucket { + const obj = createBaseLogBucket(); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.description)) obj.description = String(object.description); + if (isSet(object.createTime)) obj.createTime = new Date(object.createTime); + if (isSet(object.updateTime)) obj.updateTime = new Date(object.updateTime); + if (isSet(object.retentionDays)) obj.retentionDays = Number(object.retentionDays); + if (isSet(object.locked)) obj.locked = Boolean(object.locked); + if (isSet(object.lifecycleState)) obj.lifecycleState = lifecycleStateFromJSON(object.lifecycleState); + if (Array.isArray(object?.restrictedFields)) obj.restrictedFields = object.restrictedFields.map((e: any) => String(e)); + if (isSet(object.cmekSettings)) obj.cmekSettings = CmekSettings.fromJSON(object.cmekSettings); + return obj; + }, + toJSON(message: LogBucket): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.description !== undefined && (obj.description = message.description); + message.createTime !== undefined && (obj.createTime = message.createTime.toISOString()); + message.updateTime !== undefined && (obj.updateTime = message.updateTime.toISOString()); + message.retentionDays !== undefined && (obj.retentionDays = Math.round(message.retentionDays)); + message.locked !== undefined && (obj.locked = message.locked); + message.lifecycleState !== undefined && (obj.lifecycleState = lifecycleStateToJSON(message.lifecycleState)); + if (message.restrictedFields) { + obj.restrictedFields = message.restrictedFields.map(e => e); + } else { + obj.restrictedFields = []; + } + message.cmekSettings !== undefined && (obj.cmekSettings = message.cmekSettings ? CmekSettings.toJSON(message.cmekSettings) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): LogBucket { + const message = createBaseLogBucket(); + message.name = object.name ?? ""; + message.description = object.description ?? ""; + message.createTime = object.createTime ?? undefined; + message.updateTime = object.updateTime ?? undefined; + message.retentionDays = object.retentionDays ?? 0; + message.locked = object.locked ?? false; + message.lifecycleState = object.lifecycleState ?? 0; + message.restrictedFields = object.restrictedFields?.map(e => e) || []; + if (object.cmekSettings !== undefined && object.cmekSettings !== null) { + message.cmekSettings = CmekSettings.fromPartial(object.cmekSettings); + } + return message; + }, + fromSDK(object: LogBucketSDKType): LogBucket { + return { + name: object?.name, + description: object?.description, + createTime: object.create_time ?? undefined, + updateTime: object.update_time ?? undefined, + retentionDays: object?.retention_days, + locked: object?.locked, + lifecycleState: isSet(object.lifecycle_state) ? lifecycleStateFromJSON(object.lifecycle_state) : -1, + restrictedFields: Array.isArray(object?.restricted_fields) ? object.restricted_fields.map((e: any) => e) : [], + cmekSettings: object.cmek_settings ? CmekSettings.fromSDK(object.cmek_settings) : undefined + }; + }, + fromSDKJSON(object: any): LogBucketSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + description: isSet(object.description) ? String(object.description) : "", + create_time: isSet(object.create_time) ? new Date(object.create_time) : undefined, + update_time: isSet(object.update_time) ? new Date(object.update_time) : undefined, + retention_days: isSet(object.retention_days) ? Number(object.retention_days) : 0, + locked: isSet(object.locked) ? Boolean(object.locked) : false, + lifecycle_state: isSet(object.lifecycle_state) ? lifecycleStateFromJSON(object.lifecycle_state) : -1, + restricted_fields: Array.isArray(object?.restricted_fields) ? object.restricted_fields.map((e: any) => String(e)) : [], + cmek_settings: isSet(object.cmek_settings) ? CmekSettings.fromSDKJSON(object.cmek_settings) : undefined + }; + }, + toSDK(message: LogBucket): LogBucketSDKType { + const obj: any = {}; + obj.name = message.name; + obj.description = message.description; + message.createTime !== undefined && (obj.create_time = message.createTime ?? undefined); + message.updateTime !== undefined && (obj.update_time = message.updateTime ?? undefined); + obj.retention_days = message.retentionDays; + obj.locked = message.locked; + message.lifecycleState !== undefined && (obj.lifecycle_state = lifecycleStateToJSON(message.lifecycleState)); + if (message.restrictedFields) { + obj.restricted_fields = message.restrictedFields.map(e => e); + } else { + obj.restricted_fields = []; + } + message.cmekSettings !== undefined && (obj.cmek_settings = message.cmekSettings ? CmekSettings.toSDK(message.cmekSettings) : undefined); + return obj; + }, + fromAmino(object: LogBucketAmino): LogBucket { + const message = createBaseLogBucket(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } + if (object.create_time !== undefined && object.create_time !== null) { + message.createTime = fromTimestamp(Timestamp.fromAmino(object.create_time)); + } + if (object.update_time !== undefined && object.update_time !== null) { + message.updateTime = fromTimestamp(Timestamp.fromAmino(object.update_time)); + } + if (object.retention_days !== undefined && object.retention_days !== null) { + message.retentionDays = object.retention_days; + } + if (object.locked !== undefined && object.locked !== null) { + message.locked = object.locked; + } + if (object.lifecycle_state !== undefined && object.lifecycle_state !== null) { + message.lifecycleState = object.lifecycle_state; + } + message.restrictedFields = object.restricted_fields?.map(e => e) || []; + if (object.cmek_settings !== undefined && object.cmek_settings !== null) { + message.cmekSettings = CmekSettings.fromAmino(object.cmek_settings); + } + return message; + }, + toAmino(message: LogBucket): LogBucketAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + obj.description = message.description === "" ? undefined : message.description; + obj.create_time = message.createTime ? Timestamp.toAmino(toTimestamp(message.createTime)) : undefined; + obj.update_time = message.updateTime ? Timestamp.toAmino(toTimestamp(message.updateTime)) : undefined; + obj.retention_days = message.retentionDays === 0 ? undefined : message.retentionDays; + obj.locked = message.locked === false ? undefined : message.locked; + obj.lifecycle_state = message.lifecycleState === 0 ? undefined : message.lifecycleState; + if (message.restrictedFields) { + obj.restricted_fields = message.restrictedFields.map(e => e); + } else { + obj.restricted_fields = message.restrictedFields; + } + obj.cmek_settings = message.cmekSettings ? CmekSettings.toAmino(message.cmekSettings) : undefined; + return obj; + }, + fromAminoMsg(object: LogBucketAminoMsg): LogBucket { + return LogBucket.fromAmino(object.value); + }, + fromProtoMsg(message: LogBucketProtoMsg): LogBucket { + return LogBucket.decode(message.value); + }, + toProto(message: LogBucket): Uint8Array { + return LogBucket.encode(message).finish(); + }, + toProtoMsg(message: LogBucket): LogBucketProtoMsg { + return { + typeUrl: "/google.logging.v2.LogBucket", + value: LogBucket.encode(message).finish() + }; + } +}; +function createBaseLogView(): LogView { + return { + name: "", + description: "", + createTime: undefined, + updateTime: undefined, + filter: "" + }; +} +export const LogView = { + typeUrl: "/google.logging.v2.LogView", + encode(message: LogView, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + if (message.description !== undefined) { + writer.uint32(26).string(message.description); + } + if (message.createTime !== undefined) { + Timestamp.encode(toTimestamp(message.createTime), writer.uint32(34).fork()).ldelim(); + } + if (message.updateTime !== undefined) { + Timestamp.encode(toTimestamp(message.updateTime), writer.uint32(42).fork()).ldelim(); + } + if (message.filter !== undefined) { + writer.uint32(58).string(message.filter); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): LogView { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseLogView(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 3: + message.description = reader.string(); + break; + case 4: + message.createTime = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + break; + case 5: + message.updateTime = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + break; + case 7: + message.filter = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): LogView { + const obj = createBaseLogView(); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.description)) obj.description = String(object.description); + if (isSet(object.createTime)) obj.createTime = new Date(object.createTime); + if (isSet(object.updateTime)) obj.updateTime = new Date(object.updateTime); + if (isSet(object.filter)) obj.filter = String(object.filter); + return obj; + }, + toJSON(message: LogView): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.description !== undefined && (obj.description = message.description); + message.createTime !== undefined && (obj.createTime = message.createTime.toISOString()); + message.updateTime !== undefined && (obj.updateTime = message.updateTime.toISOString()); + message.filter !== undefined && (obj.filter = message.filter); + return obj; + }, + fromPartial(object: DeepPartial): LogView { + const message = createBaseLogView(); + message.name = object.name ?? ""; + message.description = object.description ?? ""; + message.createTime = object.createTime ?? undefined; + message.updateTime = object.updateTime ?? undefined; + message.filter = object.filter ?? ""; + return message; + }, + fromSDK(object: LogViewSDKType): LogView { + return { + name: object?.name, + description: object?.description, + createTime: object.create_time ?? undefined, + updateTime: object.update_time ?? undefined, + filter: object?.filter + }; + }, + fromSDKJSON(object: any): LogViewSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + description: isSet(object.description) ? String(object.description) : "", + create_time: isSet(object.create_time) ? new Date(object.create_time) : undefined, + update_time: isSet(object.update_time) ? new Date(object.update_time) : undefined, + filter: isSet(object.filter) ? String(object.filter) : "" + }; + }, + toSDK(message: LogView): LogViewSDKType { + const obj: any = {}; + obj.name = message.name; + obj.description = message.description; + message.createTime !== undefined && (obj.create_time = message.createTime ?? undefined); + message.updateTime !== undefined && (obj.update_time = message.updateTime ?? undefined); + obj.filter = message.filter; + return obj; + }, + fromAmino(object: LogViewAmino): LogView { + const message = createBaseLogView(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } + if (object.create_time !== undefined && object.create_time !== null) { + message.createTime = fromTimestamp(Timestamp.fromAmino(object.create_time)); + } + if (object.update_time !== undefined && object.update_time !== null) { + message.updateTime = fromTimestamp(Timestamp.fromAmino(object.update_time)); + } + if (object.filter !== undefined && object.filter !== null) { + message.filter = object.filter; + } + return message; + }, + toAmino(message: LogView): LogViewAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + obj.description = message.description === "" ? undefined : message.description; + obj.create_time = message.createTime ? Timestamp.toAmino(toTimestamp(message.createTime)) : undefined; + obj.update_time = message.updateTime ? Timestamp.toAmino(toTimestamp(message.updateTime)) : undefined; + obj.filter = message.filter === "" ? undefined : message.filter; + return obj; + }, + fromAminoMsg(object: LogViewAminoMsg): LogView { + return LogView.fromAmino(object.value); + }, + fromProtoMsg(message: LogViewProtoMsg): LogView { + return LogView.decode(message.value); + }, + toProto(message: LogView): Uint8Array { + return LogView.encode(message).finish(); + }, + toProtoMsg(message: LogView): LogViewProtoMsg { + return { + typeUrl: "/google.logging.v2.LogView", + value: LogView.encode(message).finish() + }; + } +}; +function createBaseLogSink(): LogSink { + return { + name: "", + destination: "", + filter: "", + description: "", + disabled: false, + exclusions: [], + outputVersionFormat: 0, + writerIdentity: "", + includeChildren: false, + bigqueryOptions: undefined, + createTime: undefined, + updateTime: undefined + }; +} +export const LogSink = { + typeUrl: "/google.logging.v2.LogSink", + encode(message: LogSink, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + if (message.destination !== undefined) { + writer.uint32(26).string(message.destination); + } + if (message.filter !== undefined) { + writer.uint32(42).string(message.filter); + } + if (message.description !== undefined) { + writer.uint32(146).string(message.description); + } + if (message.disabled !== undefined) { + writer.uint32(152).bool(message.disabled); + } + for (const v of message.exclusions) { + LogExclusion.encode(v!, writer.uint32(130).fork()).ldelim(); + } + if (message.outputVersionFormat !== 0) { + writer.uint32(48).int32(message.outputVersionFormat); + } + if (message.writerIdentity !== undefined) { + writer.uint32(66).string(message.writerIdentity); + } + if (message.includeChildren !== undefined) { + writer.uint32(72).bool(message.includeChildren); + } + if (message.bigqueryOptions !== undefined) { + BigQueryOptions.encode(message.bigqueryOptions, writer.uint32(98).fork()).ldelim(); + } + if (message.createTime !== undefined) { + Timestamp.encode(toTimestamp(message.createTime), writer.uint32(106).fork()).ldelim(); + } + if (message.updateTime !== undefined) { + Timestamp.encode(toTimestamp(message.updateTime), writer.uint32(114).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): LogSink { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseLogSink(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 3: + message.destination = reader.string(); + break; + case 5: + message.filter = reader.string(); + break; + case 18: + message.description = reader.string(); + break; + case 19: + message.disabled = reader.bool(); + break; + case 16: + message.exclusions.push(LogExclusion.decode(reader, reader.uint32())); + break; + case 6: + message.outputVersionFormat = (reader.int32() as any); + break; + case 8: + message.writerIdentity = reader.string(); + break; + case 9: + message.includeChildren = reader.bool(); + break; + case 12: + message.bigqueryOptions = BigQueryOptions.decode(reader, reader.uint32()); + break; + case 13: + message.createTime = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + break; + case 14: + message.updateTime = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): LogSink { + const obj = createBaseLogSink(); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.destination)) obj.destination = String(object.destination); + if (isSet(object.filter)) obj.filter = String(object.filter); + if (isSet(object.description)) obj.description = String(object.description); + if (isSet(object.disabled)) obj.disabled = Boolean(object.disabled); + if (Array.isArray(object?.exclusions)) obj.exclusions = object.exclusions.map((e: any) => LogExclusion.fromJSON(e)); + if (isSet(object.outputVersionFormat)) obj.outputVersionFormat = logSink_VersionFormatFromJSON(object.outputVersionFormat); + if (isSet(object.writerIdentity)) obj.writerIdentity = String(object.writerIdentity); + if (isSet(object.includeChildren)) obj.includeChildren = Boolean(object.includeChildren); + if (isSet(object.bigqueryOptions)) obj.bigqueryOptions = BigQueryOptions.fromJSON(object.bigqueryOptions); + if (isSet(object.createTime)) obj.createTime = new Date(object.createTime); + if (isSet(object.updateTime)) obj.updateTime = new Date(object.updateTime); + return obj; + }, + toJSON(message: LogSink): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.destination !== undefined && (obj.destination = message.destination); + message.filter !== undefined && (obj.filter = message.filter); + message.description !== undefined && (obj.description = message.description); + message.disabled !== undefined && (obj.disabled = message.disabled); + if (message.exclusions) { + obj.exclusions = message.exclusions.map(e => e ? LogExclusion.toJSON(e) : undefined); + } else { + obj.exclusions = []; + } + message.outputVersionFormat !== undefined && (obj.outputVersionFormat = logSink_VersionFormatToJSON(message.outputVersionFormat)); + message.writerIdentity !== undefined && (obj.writerIdentity = message.writerIdentity); + message.includeChildren !== undefined && (obj.includeChildren = message.includeChildren); + message.bigqueryOptions !== undefined && (obj.bigqueryOptions = message.bigqueryOptions ? BigQueryOptions.toJSON(message.bigqueryOptions) : undefined); + message.createTime !== undefined && (obj.createTime = message.createTime.toISOString()); + message.updateTime !== undefined && (obj.updateTime = message.updateTime.toISOString()); + return obj; + }, + fromPartial(object: DeepPartial): LogSink { + const message = createBaseLogSink(); + message.name = object.name ?? ""; + message.destination = object.destination ?? ""; + message.filter = object.filter ?? ""; + message.description = object.description ?? ""; + message.disabled = object.disabled ?? false; + message.exclusions = object.exclusions?.map(e => LogExclusion.fromPartial(e)) || []; + message.outputVersionFormat = object.outputVersionFormat ?? 0; + message.writerIdentity = object.writerIdentity ?? ""; + message.includeChildren = object.includeChildren ?? false; + if (object.bigqueryOptions !== undefined && object.bigqueryOptions !== null) { + message.bigqueryOptions = BigQueryOptions.fromPartial(object.bigqueryOptions); + } + message.createTime = object.createTime ?? undefined; + message.updateTime = object.updateTime ?? undefined; + return message; + }, + fromSDK(object: LogSinkSDKType): LogSink { + return { + name: object?.name, + destination: object?.destination, + filter: object?.filter, + description: object?.description, + disabled: object?.disabled, + exclusions: Array.isArray(object?.exclusions) ? object.exclusions.map((e: any) => LogExclusion.fromSDK(e)) : [], + outputVersionFormat: isSet(object.output_version_format) ? logSink_VersionFormatFromJSON(object.output_version_format) : -1, + writerIdentity: object?.writer_identity, + includeChildren: object?.include_children, + bigqueryOptions: object.bigquery_options ? BigQueryOptions.fromSDK(object.bigquery_options) : undefined, + createTime: object.create_time ?? undefined, + updateTime: object.update_time ?? undefined + }; + }, + fromSDKJSON(object: any): LogSinkSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + destination: isSet(object.destination) ? String(object.destination) : "", + filter: isSet(object.filter) ? String(object.filter) : "", + description: isSet(object.description) ? String(object.description) : "", + disabled: isSet(object.disabled) ? Boolean(object.disabled) : false, + exclusions: Array.isArray(object?.exclusions) ? object.exclusions.map((e: any) => LogExclusion.fromSDKJSON(e)) : [], + output_version_format: isSet(object.output_version_format) ? logSink_VersionFormatFromJSON(object.output_version_format) : -1, + writer_identity: isSet(object.writer_identity) ? String(object.writer_identity) : "", + include_children: isSet(object.include_children) ? Boolean(object.include_children) : false, + bigquery_options: isSet(object.bigquery_options) ? BigQueryOptions.fromSDKJSON(object.bigquery_options) : undefined, + create_time: isSet(object.create_time) ? new Date(object.create_time) : undefined, + update_time: isSet(object.update_time) ? new Date(object.update_time) : undefined + }; + }, + toSDK(message: LogSink): LogSinkSDKType { + const obj: any = {}; + obj.name = message.name; + obj.destination = message.destination; + obj.filter = message.filter; + obj.description = message.description; + obj.disabled = message.disabled; + if (message.exclusions) { + obj.exclusions = message.exclusions.map(e => e ? LogExclusion.toSDK(e) : undefined); + } else { + obj.exclusions = []; + } + message.outputVersionFormat !== undefined && (obj.output_version_format = logSink_VersionFormatToJSON(message.outputVersionFormat)); + obj.writer_identity = message.writerIdentity; + obj.include_children = message.includeChildren; + message.bigqueryOptions !== undefined && (obj.bigquery_options = message.bigqueryOptions ? BigQueryOptions.toSDK(message.bigqueryOptions) : undefined); + message.createTime !== undefined && (obj.create_time = message.createTime ?? undefined); + message.updateTime !== undefined && (obj.update_time = message.updateTime ?? undefined); + return obj; + }, + fromAmino(object: LogSinkAmino): LogSink { + const message = createBaseLogSink(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + if (object.destination !== undefined && object.destination !== null) { + message.destination = object.destination; + } + if (object.filter !== undefined && object.filter !== null) { + message.filter = object.filter; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } + if (object.disabled !== undefined && object.disabled !== null) { + message.disabled = object.disabled; + } + message.exclusions = object.exclusions?.map(e => LogExclusion.fromAmino(e)) || []; + if (object.output_version_format !== undefined && object.output_version_format !== null) { + message.outputVersionFormat = object.output_version_format; + } + if (object.writer_identity !== undefined && object.writer_identity !== null) { + message.writerIdentity = object.writer_identity; + } + if (object.include_children !== undefined && object.include_children !== null) { + message.includeChildren = object.include_children; + } + if (object.bigquery_options !== undefined && object.bigquery_options !== null) { + message.bigqueryOptions = BigQueryOptions.fromAmino(object.bigquery_options); + } + if (object.create_time !== undefined && object.create_time !== null) { + message.createTime = fromTimestamp(Timestamp.fromAmino(object.create_time)); + } + if (object.update_time !== undefined && object.update_time !== null) { + message.updateTime = fromTimestamp(Timestamp.fromAmino(object.update_time)); + } + return message; + }, + toAmino(message: LogSink): LogSinkAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + obj.destination = message.destination === "" ? undefined : message.destination; + obj.filter = message.filter === "" ? undefined : message.filter; + obj.description = message.description === "" ? undefined : message.description; + obj.disabled = message.disabled === false ? undefined : message.disabled; + if (message.exclusions) { + obj.exclusions = message.exclusions.map(e => e ? LogExclusion.toAmino(e) : undefined); + } else { + obj.exclusions = message.exclusions; + } + obj.output_version_format = message.outputVersionFormat === 0 ? undefined : message.outputVersionFormat; + obj.writer_identity = message.writerIdentity === "" ? undefined : message.writerIdentity; + obj.include_children = message.includeChildren === false ? undefined : message.includeChildren; + obj.bigquery_options = message.bigqueryOptions ? BigQueryOptions.toAmino(message.bigqueryOptions) : undefined; + obj.create_time = message.createTime ? Timestamp.toAmino(toTimestamp(message.createTime)) : undefined; + obj.update_time = message.updateTime ? Timestamp.toAmino(toTimestamp(message.updateTime)) : undefined; + return obj; + }, + fromAminoMsg(object: LogSinkAminoMsg): LogSink { + return LogSink.fromAmino(object.value); + }, + fromProtoMsg(message: LogSinkProtoMsg): LogSink { + return LogSink.decode(message.value); + }, + toProto(message: LogSink): Uint8Array { + return LogSink.encode(message).finish(); + }, + toProtoMsg(message: LogSink): LogSinkProtoMsg { + return { + typeUrl: "/google.logging.v2.LogSink", + value: LogSink.encode(message).finish() + }; + } +}; +function createBaseBigQueryOptions(): BigQueryOptions { + return { + usePartitionedTables: false, + usesTimestampColumnPartitioning: false + }; +} +export const BigQueryOptions = { + typeUrl: "/google.logging.v2.BigQueryOptions", + encode(message: BigQueryOptions, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.usePartitionedTables !== undefined) { + writer.uint32(8).bool(message.usePartitionedTables); + } + if (message.usesTimestampColumnPartitioning !== undefined) { + writer.uint32(24).bool(message.usesTimestampColumnPartitioning); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): BigQueryOptions { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseBigQueryOptions(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.usePartitionedTables = reader.bool(); + break; + case 3: + message.usesTimestampColumnPartitioning = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): BigQueryOptions { + const obj = createBaseBigQueryOptions(); + if (isSet(object.usePartitionedTables)) obj.usePartitionedTables = Boolean(object.usePartitionedTables); + if (isSet(object.usesTimestampColumnPartitioning)) obj.usesTimestampColumnPartitioning = Boolean(object.usesTimestampColumnPartitioning); + return obj; + }, + toJSON(message: BigQueryOptions): JsonSafe { + const obj: any = {}; + message.usePartitionedTables !== undefined && (obj.usePartitionedTables = message.usePartitionedTables); + message.usesTimestampColumnPartitioning !== undefined && (obj.usesTimestampColumnPartitioning = message.usesTimestampColumnPartitioning); + return obj; + }, + fromPartial(object: DeepPartial): BigQueryOptions { + const message = createBaseBigQueryOptions(); + message.usePartitionedTables = object.usePartitionedTables ?? false; + message.usesTimestampColumnPartitioning = object.usesTimestampColumnPartitioning ?? false; + return message; + }, + fromSDK(object: BigQueryOptionsSDKType): BigQueryOptions { + return { + usePartitionedTables: object?.use_partitioned_tables, + usesTimestampColumnPartitioning: object?.uses_timestamp_column_partitioning + }; + }, + fromSDKJSON(object: any): BigQueryOptionsSDKType { + return { + use_partitioned_tables: isSet(object.use_partitioned_tables) ? Boolean(object.use_partitioned_tables) : false, + uses_timestamp_column_partitioning: isSet(object.uses_timestamp_column_partitioning) ? Boolean(object.uses_timestamp_column_partitioning) : false + }; + }, + toSDK(message: BigQueryOptions): BigQueryOptionsSDKType { + const obj: any = {}; + obj.use_partitioned_tables = message.usePartitionedTables; + obj.uses_timestamp_column_partitioning = message.usesTimestampColumnPartitioning; + return obj; + }, + fromAmino(object: BigQueryOptionsAmino): BigQueryOptions { + const message = createBaseBigQueryOptions(); + if (object.use_partitioned_tables !== undefined && object.use_partitioned_tables !== null) { + message.usePartitionedTables = object.use_partitioned_tables; + } + if (object.uses_timestamp_column_partitioning !== undefined && object.uses_timestamp_column_partitioning !== null) { + message.usesTimestampColumnPartitioning = object.uses_timestamp_column_partitioning; + } + return message; + }, + toAmino(message: BigQueryOptions): BigQueryOptionsAmino { + const obj: any = {}; + obj.use_partitioned_tables = message.usePartitionedTables === false ? undefined : message.usePartitionedTables; + obj.uses_timestamp_column_partitioning = message.usesTimestampColumnPartitioning === false ? undefined : message.usesTimestampColumnPartitioning; + return obj; + }, + fromAminoMsg(object: BigQueryOptionsAminoMsg): BigQueryOptions { + return BigQueryOptions.fromAmino(object.value); + }, + fromProtoMsg(message: BigQueryOptionsProtoMsg): BigQueryOptions { + return BigQueryOptions.decode(message.value); + }, + toProto(message: BigQueryOptions): Uint8Array { + return BigQueryOptions.encode(message).finish(); + }, + toProtoMsg(message: BigQueryOptions): BigQueryOptionsProtoMsg { + return { + typeUrl: "/google.logging.v2.BigQueryOptions", + value: BigQueryOptions.encode(message).finish() + }; + } +}; +function createBaseListBucketsRequest(): ListBucketsRequest { + return { + parent: "", + pageToken: "", + pageSize: 0 + }; +} +export const ListBucketsRequest = { + typeUrl: "/google.logging.v2.ListBucketsRequest", + encode(message: ListBucketsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.parent !== undefined) { + writer.uint32(10).string(message.parent); + } + if (message.pageToken !== undefined) { + writer.uint32(18).string(message.pageToken); + } + if (message.pageSize !== undefined) { + writer.uint32(24).int32(message.pageSize); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ListBucketsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseListBucketsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.parent = reader.string(); + break; + case 2: + message.pageToken = reader.string(); + break; + case 3: + message.pageSize = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ListBucketsRequest { + const obj = createBaseListBucketsRequest(); + if (isSet(object.parent)) obj.parent = String(object.parent); + if (isSet(object.pageToken)) obj.pageToken = String(object.pageToken); + if (isSet(object.pageSize)) obj.pageSize = Number(object.pageSize); + return obj; + }, + toJSON(message: ListBucketsRequest): JsonSafe { + const obj: any = {}; + message.parent !== undefined && (obj.parent = message.parent); + message.pageToken !== undefined && (obj.pageToken = message.pageToken); + message.pageSize !== undefined && (obj.pageSize = Math.round(message.pageSize)); + return obj; + }, + fromPartial(object: DeepPartial): ListBucketsRequest { + const message = createBaseListBucketsRequest(); + message.parent = object.parent ?? ""; + message.pageToken = object.pageToken ?? ""; + message.pageSize = object.pageSize ?? 0; + return message; + }, + fromSDK(object: ListBucketsRequestSDKType): ListBucketsRequest { + return { + parent: object?.parent, + pageToken: object?.page_token, + pageSize: object?.page_size + }; + }, + fromSDKJSON(object: any): ListBucketsRequestSDKType { + return { + parent: isSet(object.parent) ? String(object.parent) : "", + page_token: isSet(object.page_token) ? String(object.page_token) : "", + page_size: isSet(object.page_size) ? Number(object.page_size) : 0 + }; + }, + toSDK(message: ListBucketsRequest): ListBucketsRequestSDKType { + const obj: any = {}; + obj.parent = message.parent; + obj.page_token = message.pageToken; + obj.page_size = message.pageSize; + return obj; + }, + fromAmino(object: ListBucketsRequestAmino): ListBucketsRequest { + const message = createBaseListBucketsRequest(); + if (object.parent !== undefined && object.parent !== null) { + message.parent = object.parent; + } + if (object.page_token !== undefined && object.page_token !== null) { + message.pageToken = object.page_token; + } + if (object.page_size !== undefined && object.page_size !== null) { + message.pageSize = object.page_size; + } + return message; + }, + toAmino(message: ListBucketsRequest): ListBucketsRequestAmino { + const obj: any = {}; + obj.parent = message.parent === "" ? undefined : message.parent; + obj.page_token = message.pageToken === "" ? undefined : message.pageToken; + obj.page_size = message.pageSize === 0 ? undefined : message.pageSize; + return obj; + }, + fromAminoMsg(object: ListBucketsRequestAminoMsg): ListBucketsRequest { + return ListBucketsRequest.fromAmino(object.value); + }, + fromProtoMsg(message: ListBucketsRequestProtoMsg): ListBucketsRequest { + return ListBucketsRequest.decode(message.value); + }, + toProto(message: ListBucketsRequest): Uint8Array { + return ListBucketsRequest.encode(message).finish(); + }, + toProtoMsg(message: ListBucketsRequest): ListBucketsRequestProtoMsg { + return { + typeUrl: "/google.logging.v2.ListBucketsRequest", + value: ListBucketsRequest.encode(message).finish() + }; + } +}; +function createBaseListBucketsResponse(): ListBucketsResponse { + return { + buckets: [], + nextPageToken: "" + }; +} +export const ListBucketsResponse = { + typeUrl: "/google.logging.v2.ListBucketsResponse", + encode(message: ListBucketsResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.buckets) { + LogBucket.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.nextPageToken !== undefined) { + writer.uint32(18).string(message.nextPageToken); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ListBucketsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseListBucketsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.buckets.push(LogBucket.decode(reader, reader.uint32())); + break; + case 2: + message.nextPageToken = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ListBucketsResponse { + const obj = createBaseListBucketsResponse(); + if (Array.isArray(object?.buckets)) obj.buckets = object.buckets.map((e: any) => LogBucket.fromJSON(e)); + if (isSet(object.nextPageToken)) obj.nextPageToken = String(object.nextPageToken); + return obj; + }, + toJSON(message: ListBucketsResponse): JsonSafe { + const obj: any = {}; + if (message.buckets) { + obj.buckets = message.buckets.map(e => e ? LogBucket.toJSON(e) : undefined); + } else { + obj.buckets = []; + } + message.nextPageToken !== undefined && (obj.nextPageToken = message.nextPageToken); + return obj; + }, + fromPartial(object: DeepPartial): ListBucketsResponse { + const message = createBaseListBucketsResponse(); + message.buckets = object.buckets?.map(e => LogBucket.fromPartial(e)) || []; + message.nextPageToken = object.nextPageToken ?? ""; + return message; + }, + fromSDK(object: ListBucketsResponseSDKType): ListBucketsResponse { + return { + buckets: Array.isArray(object?.buckets) ? object.buckets.map((e: any) => LogBucket.fromSDK(e)) : [], + nextPageToken: object?.next_page_token + }; + }, + fromSDKJSON(object: any): ListBucketsResponseSDKType { + return { + buckets: Array.isArray(object?.buckets) ? object.buckets.map((e: any) => LogBucket.fromSDKJSON(e)) : [], + next_page_token: isSet(object.next_page_token) ? String(object.next_page_token) : "" + }; + }, + toSDK(message: ListBucketsResponse): ListBucketsResponseSDKType { + const obj: any = {}; + if (message.buckets) { + obj.buckets = message.buckets.map(e => e ? LogBucket.toSDK(e) : undefined); + } else { + obj.buckets = []; + } + obj.next_page_token = message.nextPageToken; + return obj; + }, + fromAmino(object: ListBucketsResponseAmino): ListBucketsResponse { + const message = createBaseListBucketsResponse(); + message.buckets = object.buckets?.map(e => LogBucket.fromAmino(e)) || []; + if (object.next_page_token !== undefined && object.next_page_token !== null) { + message.nextPageToken = object.next_page_token; + } + return message; + }, + toAmino(message: ListBucketsResponse): ListBucketsResponseAmino { + const obj: any = {}; + if (message.buckets) { + obj.buckets = message.buckets.map(e => e ? LogBucket.toAmino(e) : undefined); + } else { + obj.buckets = message.buckets; + } + obj.next_page_token = message.nextPageToken === "" ? undefined : message.nextPageToken; + return obj; + }, + fromAminoMsg(object: ListBucketsResponseAminoMsg): ListBucketsResponse { + return ListBucketsResponse.fromAmino(object.value); + }, + fromProtoMsg(message: ListBucketsResponseProtoMsg): ListBucketsResponse { + return ListBucketsResponse.decode(message.value); + }, + toProto(message: ListBucketsResponse): Uint8Array { + return ListBucketsResponse.encode(message).finish(); + }, + toProtoMsg(message: ListBucketsResponse): ListBucketsResponseProtoMsg { + return { + typeUrl: "/google.logging.v2.ListBucketsResponse", + value: ListBucketsResponse.encode(message).finish() + }; + } +}; +function createBaseCreateBucketRequest(): CreateBucketRequest { + return { + parent: "", + bucketId: "", + bucket: undefined + }; +} +export const CreateBucketRequest = { + typeUrl: "/google.logging.v2.CreateBucketRequest", + encode(message: CreateBucketRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.parent !== undefined) { + writer.uint32(10).string(message.parent); + } + if (message.bucketId !== undefined) { + writer.uint32(18).string(message.bucketId); + } + if (message.bucket !== undefined) { + LogBucket.encode(message.bucket, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): CreateBucketRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCreateBucketRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.parent = reader.string(); + break; + case 2: + message.bucketId = reader.string(); + break; + case 3: + message.bucket = LogBucket.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): CreateBucketRequest { + const obj = createBaseCreateBucketRequest(); + if (isSet(object.parent)) obj.parent = String(object.parent); + if (isSet(object.bucketId)) obj.bucketId = String(object.bucketId); + if (isSet(object.bucket)) obj.bucket = LogBucket.fromJSON(object.bucket); + return obj; + }, + toJSON(message: CreateBucketRequest): JsonSafe { + const obj: any = {}; + message.parent !== undefined && (obj.parent = message.parent); + message.bucketId !== undefined && (obj.bucketId = message.bucketId); + message.bucket !== undefined && (obj.bucket = message.bucket ? LogBucket.toJSON(message.bucket) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): CreateBucketRequest { + const message = createBaseCreateBucketRequest(); + message.parent = object.parent ?? ""; + message.bucketId = object.bucketId ?? ""; + if (object.bucket !== undefined && object.bucket !== null) { + message.bucket = LogBucket.fromPartial(object.bucket); + } + return message; + }, + fromSDK(object: CreateBucketRequestSDKType): CreateBucketRequest { + return { + parent: object?.parent, + bucketId: object?.bucket_id, + bucket: object.bucket ? LogBucket.fromSDK(object.bucket) : undefined + }; + }, + fromSDKJSON(object: any): CreateBucketRequestSDKType { + return { + parent: isSet(object.parent) ? String(object.parent) : "", + bucket_id: isSet(object.bucket_id) ? String(object.bucket_id) : "", + bucket: isSet(object.bucket) ? LogBucket.fromSDKJSON(object.bucket) : undefined + }; + }, + toSDK(message: CreateBucketRequest): CreateBucketRequestSDKType { + const obj: any = {}; + obj.parent = message.parent; + obj.bucket_id = message.bucketId; + message.bucket !== undefined && (obj.bucket = message.bucket ? LogBucket.toSDK(message.bucket) : undefined); + return obj; + }, + fromAmino(object: CreateBucketRequestAmino): CreateBucketRequest { + const message = createBaseCreateBucketRequest(); + if (object.parent !== undefined && object.parent !== null) { + message.parent = object.parent; + } + if (object.bucket_id !== undefined && object.bucket_id !== null) { + message.bucketId = object.bucket_id; + } + if (object.bucket !== undefined && object.bucket !== null) { + message.bucket = LogBucket.fromAmino(object.bucket); + } + return message; + }, + toAmino(message: CreateBucketRequest): CreateBucketRequestAmino { + const obj: any = {}; + obj.parent = message.parent === "" ? undefined : message.parent; + obj.bucket_id = message.bucketId === "" ? undefined : message.bucketId; + obj.bucket = message.bucket ? LogBucket.toAmino(message.bucket) : undefined; + return obj; + }, + fromAminoMsg(object: CreateBucketRequestAminoMsg): CreateBucketRequest { + return CreateBucketRequest.fromAmino(object.value); + }, + fromProtoMsg(message: CreateBucketRequestProtoMsg): CreateBucketRequest { + return CreateBucketRequest.decode(message.value); + }, + toProto(message: CreateBucketRequest): Uint8Array { + return CreateBucketRequest.encode(message).finish(); + }, + toProtoMsg(message: CreateBucketRequest): CreateBucketRequestProtoMsg { + return { + typeUrl: "/google.logging.v2.CreateBucketRequest", + value: CreateBucketRequest.encode(message).finish() + }; + } +}; +function createBaseUpdateBucketRequest(): UpdateBucketRequest { + return { + name: "", + bucket: undefined, + updateMask: undefined + }; +} +export const UpdateBucketRequest = { + typeUrl: "/google.logging.v2.UpdateBucketRequest", + encode(message: UpdateBucketRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + if (message.bucket !== undefined) { + LogBucket.encode(message.bucket, writer.uint32(18).fork()).ldelim(); + } + if (message.updateMask !== undefined) { + FieldMask.encode(message.updateMask, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): UpdateBucketRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseUpdateBucketRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.bucket = LogBucket.decode(reader, reader.uint32()); + break; + case 4: + message.updateMask = FieldMask.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): UpdateBucketRequest { + const obj = createBaseUpdateBucketRequest(); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.bucket)) obj.bucket = LogBucket.fromJSON(object.bucket); + if (isSet(object.updateMask)) obj.updateMask = FieldMask.fromJSON(object.updateMask); + return obj; + }, + toJSON(message: UpdateBucketRequest): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.bucket !== undefined && (obj.bucket = message.bucket ? LogBucket.toJSON(message.bucket) : undefined); + message.updateMask !== undefined && (obj.updateMask = message.updateMask ? FieldMask.toJSON(message.updateMask) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): UpdateBucketRequest { + const message = createBaseUpdateBucketRequest(); + message.name = object.name ?? ""; + if (object.bucket !== undefined && object.bucket !== null) { + message.bucket = LogBucket.fromPartial(object.bucket); + } + if (object.updateMask !== undefined && object.updateMask !== null) { + message.updateMask = FieldMask.fromPartial(object.updateMask); + } + return message; + }, + fromSDK(object: UpdateBucketRequestSDKType): UpdateBucketRequest { + return { + name: object?.name, + bucket: object.bucket ? LogBucket.fromSDK(object.bucket) : undefined, + updateMask: object.update_mask ? FieldMask.fromSDK(object.update_mask) : undefined + }; + }, + fromSDKJSON(object: any): UpdateBucketRequestSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + bucket: isSet(object.bucket) ? LogBucket.fromSDKJSON(object.bucket) : undefined, + update_mask: isSet(object.update_mask) ? FieldMask.fromSDKJSON(object.update_mask) : undefined + }; + }, + toSDK(message: UpdateBucketRequest): UpdateBucketRequestSDKType { + const obj: any = {}; + obj.name = message.name; + message.bucket !== undefined && (obj.bucket = message.bucket ? LogBucket.toSDK(message.bucket) : undefined); + message.updateMask !== undefined && (obj.update_mask = message.updateMask ? FieldMask.toSDK(message.updateMask) : undefined); + return obj; + }, + fromAmino(object: UpdateBucketRequestAmino): UpdateBucketRequest { + const message = createBaseUpdateBucketRequest(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + if (object.bucket !== undefined && object.bucket !== null) { + message.bucket = LogBucket.fromAmino(object.bucket); + } + if (object.update_mask !== undefined && object.update_mask !== null) { + message.updateMask = FieldMask.fromAmino(object.update_mask); + } + return message; + }, + toAmino(message: UpdateBucketRequest): UpdateBucketRequestAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + obj.bucket = message.bucket ? LogBucket.toAmino(message.bucket) : undefined; + obj.update_mask = message.updateMask ? FieldMask.toAmino(message.updateMask) : undefined; + return obj; + }, + fromAminoMsg(object: UpdateBucketRequestAminoMsg): UpdateBucketRequest { + return UpdateBucketRequest.fromAmino(object.value); + }, + fromProtoMsg(message: UpdateBucketRequestProtoMsg): UpdateBucketRequest { + return UpdateBucketRequest.decode(message.value); + }, + toProto(message: UpdateBucketRequest): Uint8Array { + return UpdateBucketRequest.encode(message).finish(); + }, + toProtoMsg(message: UpdateBucketRequest): UpdateBucketRequestProtoMsg { + return { + typeUrl: "/google.logging.v2.UpdateBucketRequest", + value: UpdateBucketRequest.encode(message).finish() + }; + } +}; +function createBaseGetBucketRequest(): GetBucketRequest { + return { + name: "" + }; +} +export const GetBucketRequest = { + typeUrl: "/google.logging.v2.GetBucketRequest", + encode(message: GetBucketRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GetBucketRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGetBucketRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GetBucketRequest { + const obj = createBaseGetBucketRequest(); + if (isSet(object.name)) obj.name = String(object.name); + return obj; + }, + toJSON(message: GetBucketRequest): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + return obj; + }, + fromPartial(object: DeepPartial): GetBucketRequest { + const message = createBaseGetBucketRequest(); + message.name = object.name ?? ""; + return message; + }, + fromSDK(object: GetBucketRequestSDKType): GetBucketRequest { + return { + name: object?.name + }; + }, + fromSDKJSON(object: any): GetBucketRequestSDKType { + return { + name: isSet(object.name) ? String(object.name) : "" + }; + }, + toSDK(message: GetBucketRequest): GetBucketRequestSDKType { + const obj: any = {}; + obj.name = message.name; + return obj; + }, + fromAmino(object: GetBucketRequestAmino): GetBucketRequest { + const message = createBaseGetBucketRequest(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + return message; + }, + toAmino(message: GetBucketRequest): GetBucketRequestAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + return obj; + }, + fromAminoMsg(object: GetBucketRequestAminoMsg): GetBucketRequest { + return GetBucketRequest.fromAmino(object.value); + }, + fromProtoMsg(message: GetBucketRequestProtoMsg): GetBucketRequest { + return GetBucketRequest.decode(message.value); + }, + toProto(message: GetBucketRequest): Uint8Array { + return GetBucketRequest.encode(message).finish(); + }, + toProtoMsg(message: GetBucketRequest): GetBucketRequestProtoMsg { + return { + typeUrl: "/google.logging.v2.GetBucketRequest", + value: GetBucketRequest.encode(message).finish() + }; + } +}; +function createBaseDeleteBucketRequest(): DeleteBucketRequest { + return { + name: "" + }; +} +export const DeleteBucketRequest = { + typeUrl: "/google.logging.v2.DeleteBucketRequest", + encode(message: DeleteBucketRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): DeleteBucketRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDeleteBucketRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): DeleteBucketRequest { + const obj = createBaseDeleteBucketRequest(); + if (isSet(object.name)) obj.name = String(object.name); + return obj; + }, + toJSON(message: DeleteBucketRequest): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + return obj; + }, + fromPartial(object: DeepPartial): DeleteBucketRequest { + const message = createBaseDeleteBucketRequest(); + message.name = object.name ?? ""; + return message; + }, + fromSDK(object: DeleteBucketRequestSDKType): DeleteBucketRequest { + return { + name: object?.name + }; + }, + fromSDKJSON(object: any): DeleteBucketRequestSDKType { + return { + name: isSet(object.name) ? String(object.name) : "" + }; + }, + toSDK(message: DeleteBucketRequest): DeleteBucketRequestSDKType { + const obj: any = {}; + obj.name = message.name; + return obj; + }, + fromAmino(object: DeleteBucketRequestAmino): DeleteBucketRequest { + const message = createBaseDeleteBucketRequest(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + return message; + }, + toAmino(message: DeleteBucketRequest): DeleteBucketRequestAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + return obj; + }, + fromAminoMsg(object: DeleteBucketRequestAminoMsg): DeleteBucketRequest { + return DeleteBucketRequest.fromAmino(object.value); + }, + fromProtoMsg(message: DeleteBucketRequestProtoMsg): DeleteBucketRequest { + return DeleteBucketRequest.decode(message.value); + }, + toProto(message: DeleteBucketRequest): Uint8Array { + return DeleteBucketRequest.encode(message).finish(); + }, + toProtoMsg(message: DeleteBucketRequest): DeleteBucketRequestProtoMsg { + return { + typeUrl: "/google.logging.v2.DeleteBucketRequest", + value: DeleteBucketRequest.encode(message).finish() + }; + } +}; +function createBaseUndeleteBucketRequest(): UndeleteBucketRequest { + return { + name: "" + }; +} +export const UndeleteBucketRequest = { + typeUrl: "/google.logging.v2.UndeleteBucketRequest", + encode(message: UndeleteBucketRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): UndeleteBucketRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseUndeleteBucketRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): UndeleteBucketRequest { + const obj = createBaseUndeleteBucketRequest(); + if (isSet(object.name)) obj.name = String(object.name); + return obj; + }, + toJSON(message: UndeleteBucketRequest): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + return obj; + }, + fromPartial(object: DeepPartial): UndeleteBucketRequest { + const message = createBaseUndeleteBucketRequest(); + message.name = object.name ?? ""; + return message; + }, + fromSDK(object: UndeleteBucketRequestSDKType): UndeleteBucketRequest { + return { + name: object?.name + }; + }, + fromSDKJSON(object: any): UndeleteBucketRequestSDKType { + return { + name: isSet(object.name) ? String(object.name) : "" + }; + }, + toSDK(message: UndeleteBucketRequest): UndeleteBucketRequestSDKType { + const obj: any = {}; + obj.name = message.name; + return obj; + }, + fromAmino(object: UndeleteBucketRequestAmino): UndeleteBucketRequest { + const message = createBaseUndeleteBucketRequest(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + return message; + }, + toAmino(message: UndeleteBucketRequest): UndeleteBucketRequestAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + return obj; + }, + fromAminoMsg(object: UndeleteBucketRequestAminoMsg): UndeleteBucketRequest { + return UndeleteBucketRequest.fromAmino(object.value); + }, + fromProtoMsg(message: UndeleteBucketRequestProtoMsg): UndeleteBucketRequest { + return UndeleteBucketRequest.decode(message.value); + }, + toProto(message: UndeleteBucketRequest): Uint8Array { + return UndeleteBucketRequest.encode(message).finish(); + }, + toProtoMsg(message: UndeleteBucketRequest): UndeleteBucketRequestProtoMsg { + return { + typeUrl: "/google.logging.v2.UndeleteBucketRequest", + value: UndeleteBucketRequest.encode(message).finish() + }; + } +}; +function createBaseListViewsRequest(): ListViewsRequest { + return { + parent: "", + pageToken: "", + pageSize: 0 + }; +} +export const ListViewsRequest = { + typeUrl: "/google.logging.v2.ListViewsRequest", + encode(message: ListViewsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.parent !== undefined) { + writer.uint32(10).string(message.parent); + } + if (message.pageToken !== undefined) { + writer.uint32(18).string(message.pageToken); + } + if (message.pageSize !== undefined) { + writer.uint32(24).int32(message.pageSize); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ListViewsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseListViewsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.parent = reader.string(); + break; + case 2: + message.pageToken = reader.string(); + break; + case 3: + message.pageSize = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ListViewsRequest { + const obj = createBaseListViewsRequest(); + if (isSet(object.parent)) obj.parent = String(object.parent); + if (isSet(object.pageToken)) obj.pageToken = String(object.pageToken); + if (isSet(object.pageSize)) obj.pageSize = Number(object.pageSize); + return obj; + }, + toJSON(message: ListViewsRequest): JsonSafe { + const obj: any = {}; + message.parent !== undefined && (obj.parent = message.parent); + message.pageToken !== undefined && (obj.pageToken = message.pageToken); + message.pageSize !== undefined && (obj.pageSize = Math.round(message.pageSize)); + return obj; + }, + fromPartial(object: DeepPartial): ListViewsRequest { + const message = createBaseListViewsRequest(); + message.parent = object.parent ?? ""; + message.pageToken = object.pageToken ?? ""; + message.pageSize = object.pageSize ?? 0; + return message; + }, + fromSDK(object: ListViewsRequestSDKType): ListViewsRequest { + return { + parent: object?.parent, + pageToken: object?.page_token, + pageSize: object?.page_size + }; + }, + fromSDKJSON(object: any): ListViewsRequestSDKType { + return { + parent: isSet(object.parent) ? String(object.parent) : "", + page_token: isSet(object.page_token) ? String(object.page_token) : "", + page_size: isSet(object.page_size) ? Number(object.page_size) : 0 + }; + }, + toSDK(message: ListViewsRequest): ListViewsRequestSDKType { + const obj: any = {}; + obj.parent = message.parent; + obj.page_token = message.pageToken; + obj.page_size = message.pageSize; + return obj; + }, + fromAmino(object: ListViewsRequestAmino): ListViewsRequest { + const message = createBaseListViewsRequest(); + if (object.parent !== undefined && object.parent !== null) { + message.parent = object.parent; + } + if (object.page_token !== undefined && object.page_token !== null) { + message.pageToken = object.page_token; + } + if (object.page_size !== undefined && object.page_size !== null) { + message.pageSize = object.page_size; + } + return message; + }, + toAmino(message: ListViewsRequest): ListViewsRequestAmino { + const obj: any = {}; + obj.parent = message.parent === "" ? undefined : message.parent; + obj.page_token = message.pageToken === "" ? undefined : message.pageToken; + obj.page_size = message.pageSize === 0 ? undefined : message.pageSize; + return obj; + }, + fromAminoMsg(object: ListViewsRequestAminoMsg): ListViewsRequest { + return ListViewsRequest.fromAmino(object.value); + }, + fromProtoMsg(message: ListViewsRequestProtoMsg): ListViewsRequest { + return ListViewsRequest.decode(message.value); + }, + toProto(message: ListViewsRequest): Uint8Array { + return ListViewsRequest.encode(message).finish(); + }, + toProtoMsg(message: ListViewsRequest): ListViewsRequestProtoMsg { + return { + typeUrl: "/google.logging.v2.ListViewsRequest", + value: ListViewsRequest.encode(message).finish() + }; + } +}; +function createBaseListViewsResponse(): ListViewsResponse { + return { + views: [], + nextPageToken: "" + }; +} +export const ListViewsResponse = { + typeUrl: "/google.logging.v2.ListViewsResponse", + encode(message: ListViewsResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.views) { + LogView.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.nextPageToken !== undefined) { + writer.uint32(18).string(message.nextPageToken); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ListViewsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseListViewsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.views.push(LogView.decode(reader, reader.uint32())); + break; + case 2: + message.nextPageToken = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ListViewsResponse { + const obj = createBaseListViewsResponse(); + if (Array.isArray(object?.views)) obj.views = object.views.map((e: any) => LogView.fromJSON(e)); + if (isSet(object.nextPageToken)) obj.nextPageToken = String(object.nextPageToken); + return obj; + }, + toJSON(message: ListViewsResponse): JsonSafe { + const obj: any = {}; + if (message.views) { + obj.views = message.views.map(e => e ? LogView.toJSON(e) : undefined); + } else { + obj.views = []; + } + message.nextPageToken !== undefined && (obj.nextPageToken = message.nextPageToken); + return obj; + }, + fromPartial(object: DeepPartial): ListViewsResponse { + const message = createBaseListViewsResponse(); + message.views = object.views?.map(e => LogView.fromPartial(e)) || []; + message.nextPageToken = object.nextPageToken ?? ""; + return message; + }, + fromSDK(object: ListViewsResponseSDKType): ListViewsResponse { + return { + views: Array.isArray(object?.views) ? object.views.map((e: any) => LogView.fromSDK(e)) : [], + nextPageToken: object?.next_page_token + }; + }, + fromSDKJSON(object: any): ListViewsResponseSDKType { + return { + views: Array.isArray(object?.views) ? object.views.map((e: any) => LogView.fromSDKJSON(e)) : [], + next_page_token: isSet(object.next_page_token) ? String(object.next_page_token) : "" + }; + }, + toSDK(message: ListViewsResponse): ListViewsResponseSDKType { + const obj: any = {}; + if (message.views) { + obj.views = message.views.map(e => e ? LogView.toSDK(e) : undefined); + } else { + obj.views = []; + } + obj.next_page_token = message.nextPageToken; + return obj; + }, + fromAmino(object: ListViewsResponseAmino): ListViewsResponse { + const message = createBaseListViewsResponse(); + message.views = object.views?.map(e => LogView.fromAmino(e)) || []; + if (object.next_page_token !== undefined && object.next_page_token !== null) { + message.nextPageToken = object.next_page_token; + } + return message; + }, + toAmino(message: ListViewsResponse): ListViewsResponseAmino { + const obj: any = {}; + if (message.views) { + obj.views = message.views.map(e => e ? LogView.toAmino(e) : undefined); + } else { + obj.views = message.views; + } + obj.next_page_token = message.nextPageToken === "" ? undefined : message.nextPageToken; + return obj; + }, + fromAminoMsg(object: ListViewsResponseAminoMsg): ListViewsResponse { + return ListViewsResponse.fromAmino(object.value); + }, + fromProtoMsg(message: ListViewsResponseProtoMsg): ListViewsResponse { + return ListViewsResponse.decode(message.value); + }, + toProto(message: ListViewsResponse): Uint8Array { + return ListViewsResponse.encode(message).finish(); + }, + toProtoMsg(message: ListViewsResponse): ListViewsResponseProtoMsg { + return { + typeUrl: "/google.logging.v2.ListViewsResponse", + value: ListViewsResponse.encode(message).finish() + }; + } +}; +function createBaseCreateViewRequest(): CreateViewRequest { + return { + parent: "", + viewId: "", + view: undefined + }; +} +export const CreateViewRequest = { + typeUrl: "/google.logging.v2.CreateViewRequest", + encode(message: CreateViewRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.parent !== undefined) { + writer.uint32(10).string(message.parent); + } + if (message.viewId !== undefined) { + writer.uint32(18).string(message.viewId); + } + if (message.view !== undefined) { + LogView.encode(message.view, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): CreateViewRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCreateViewRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.parent = reader.string(); + break; + case 2: + message.viewId = reader.string(); + break; + case 3: + message.view = LogView.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): CreateViewRequest { + const obj = createBaseCreateViewRequest(); + if (isSet(object.parent)) obj.parent = String(object.parent); + if (isSet(object.viewId)) obj.viewId = String(object.viewId); + if (isSet(object.view)) obj.view = LogView.fromJSON(object.view); + return obj; + }, + toJSON(message: CreateViewRequest): JsonSafe { + const obj: any = {}; + message.parent !== undefined && (obj.parent = message.parent); + message.viewId !== undefined && (obj.viewId = message.viewId); + message.view !== undefined && (obj.view = message.view ? LogView.toJSON(message.view) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): CreateViewRequest { + const message = createBaseCreateViewRequest(); + message.parent = object.parent ?? ""; + message.viewId = object.viewId ?? ""; + if (object.view !== undefined && object.view !== null) { + message.view = LogView.fromPartial(object.view); + } + return message; + }, + fromSDK(object: CreateViewRequestSDKType): CreateViewRequest { + return { + parent: object?.parent, + viewId: object?.view_id, + view: object.view ? LogView.fromSDK(object.view) : undefined + }; + }, + fromSDKJSON(object: any): CreateViewRequestSDKType { + return { + parent: isSet(object.parent) ? String(object.parent) : "", + view_id: isSet(object.view_id) ? String(object.view_id) : "", + view: isSet(object.view) ? LogView.fromSDKJSON(object.view) : undefined + }; + }, + toSDK(message: CreateViewRequest): CreateViewRequestSDKType { + const obj: any = {}; + obj.parent = message.parent; + obj.view_id = message.viewId; + message.view !== undefined && (obj.view = message.view ? LogView.toSDK(message.view) : undefined); + return obj; + }, + fromAmino(object: CreateViewRequestAmino): CreateViewRequest { + const message = createBaseCreateViewRequest(); + if (object.parent !== undefined && object.parent !== null) { + message.parent = object.parent; + } + if (object.view_id !== undefined && object.view_id !== null) { + message.viewId = object.view_id; + } + if (object.view !== undefined && object.view !== null) { + message.view = LogView.fromAmino(object.view); + } + return message; + }, + toAmino(message: CreateViewRequest): CreateViewRequestAmino { + const obj: any = {}; + obj.parent = message.parent === "" ? undefined : message.parent; + obj.view_id = message.viewId === "" ? undefined : message.viewId; + obj.view = message.view ? LogView.toAmino(message.view) : undefined; + return obj; + }, + fromAminoMsg(object: CreateViewRequestAminoMsg): CreateViewRequest { + return CreateViewRequest.fromAmino(object.value); + }, + fromProtoMsg(message: CreateViewRequestProtoMsg): CreateViewRequest { + return CreateViewRequest.decode(message.value); + }, + toProto(message: CreateViewRequest): Uint8Array { + return CreateViewRequest.encode(message).finish(); + }, + toProtoMsg(message: CreateViewRequest): CreateViewRequestProtoMsg { + return { + typeUrl: "/google.logging.v2.CreateViewRequest", + value: CreateViewRequest.encode(message).finish() + }; + } +}; +function createBaseUpdateViewRequest(): UpdateViewRequest { + return { + name: "", + view: undefined, + updateMask: undefined + }; +} +export const UpdateViewRequest = { + typeUrl: "/google.logging.v2.UpdateViewRequest", + encode(message: UpdateViewRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + if (message.view !== undefined) { + LogView.encode(message.view, writer.uint32(18).fork()).ldelim(); + } + if (message.updateMask !== undefined) { + FieldMask.encode(message.updateMask, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): UpdateViewRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseUpdateViewRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.view = LogView.decode(reader, reader.uint32()); + break; + case 4: + message.updateMask = FieldMask.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): UpdateViewRequest { + const obj = createBaseUpdateViewRequest(); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.view)) obj.view = LogView.fromJSON(object.view); + if (isSet(object.updateMask)) obj.updateMask = FieldMask.fromJSON(object.updateMask); + return obj; + }, + toJSON(message: UpdateViewRequest): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.view !== undefined && (obj.view = message.view ? LogView.toJSON(message.view) : undefined); + message.updateMask !== undefined && (obj.updateMask = message.updateMask ? FieldMask.toJSON(message.updateMask) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): UpdateViewRequest { + const message = createBaseUpdateViewRequest(); + message.name = object.name ?? ""; + if (object.view !== undefined && object.view !== null) { + message.view = LogView.fromPartial(object.view); + } + if (object.updateMask !== undefined && object.updateMask !== null) { + message.updateMask = FieldMask.fromPartial(object.updateMask); + } + return message; + }, + fromSDK(object: UpdateViewRequestSDKType): UpdateViewRequest { + return { + name: object?.name, + view: object.view ? LogView.fromSDK(object.view) : undefined, + updateMask: object.update_mask ? FieldMask.fromSDK(object.update_mask) : undefined + }; + }, + fromSDKJSON(object: any): UpdateViewRequestSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + view: isSet(object.view) ? LogView.fromSDKJSON(object.view) : undefined, + update_mask: isSet(object.update_mask) ? FieldMask.fromSDKJSON(object.update_mask) : undefined + }; + }, + toSDK(message: UpdateViewRequest): UpdateViewRequestSDKType { + const obj: any = {}; + obj.name = message.name; + message.view !== undefined && (obj.view = message.view ? LogView.toSDK(message.view) : undefined); + message.updateMask !== undefined && (obj.update_mask = message.updateMask ? FieldMask.toSDK(message.updateMask) : undefined); + return obj; + }, + fromAmino(object: UpdateViewRequestAmino): UpdateViewRequest { + const message = createBaseUpdateViewRequest(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + if (object.view !== undefined && object.view !== null) { + message.view = LogView.fromAmino(object.view); + } + if (object.update_mask !== undefined && object.update_mask !== null) { + message.updateMask = FieldMask.fromAmino(object.update_mask); + } + return message; + }, + toAmino(message: UpdateViewRequest): UpdateViewRequestAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + obj.view = message.view ? LogView.toAmino(message.view) : undefined; + obj.update_mask = message.updateMask ? FieldMask.toAmino(message.updateMask) : undefined; + return obj; + }, + fromAminoMsg(object: UpdateViewRequestAminoMsg): UpdateViewRequest { + return UpdateViewRequest.fromAmino(object.value); + }, + fromProtoMsg(message: UpdateViewRequestProtoMsg): UpdateViewRequest { + return UpdateViewRequest.decode(message.value); + }, + toProto(message: UpdateViewRequest): Uint8Array { + return UpdateViewRequest.encode(message).finish(); + }, + toProtoMsg(message: UpdateViewRequest): UpdateViewRequestProtoMsg { + return { + typeUrl: "/google.logging.v2.UpdateViewRequest", + value: UpdateViewRequest.encode(message).finish() + }; + } +}; +function createBaseGetViewRequest(): GetViewRequest { + return { + name: "" + }; +} +export const GetViewRequest = { + typeUrl: "/google.logging.v2.GetViewRequest", + encode(message: GetViewRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GetViewRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGetViewRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GetViewRequest { + const obj = createBaseGetViewRequest(); + if (isSet(object.name)) obj.name = String(object.name); + return obj; + }, + toJSON(message: GetViewRequest): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + return obj; + }, + fromPartial(object: DeepPartial): GetViewRequest { + const message = createBaseGetViewRequest(); + message.name = object.name ?? ""; + return message; + }, + fromSDK(object: GetViewRequestSDKType): GetViewRequest { + return { + name: object?.name + }; + }, + fromSDKJSON(object: any): GetViewRequestSDKType { + return { + name: isSet(object.name) ? String(object.name) : "" + }; + }, + toSDK(message: GetViewRequest): GetViewRequestSDKType { + const obj: any = {}; + obj.name = message.name; + return obj; + }, + fromAmino(object: GetViewRequestAmino): GetViewRequest { + const message = createBaseGetViewRequest(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + return message; + }, + toAmino(message: GetViewRequest): GetViewRequestAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + return obj; + }, + fromAminoMsg(object: GetViewRequestAminoMsg): GetViewRequest { + return GetViewRequest.fromAmino(object.value); + }, + fromProtoMsg(message: GetViewRequestProtoMsg): GetViewRequest { + return GetViewRequest.decode(message.value); + }, + toProto(message: GetViewRequest): Uint8Array { + return GetViewRequest.encode(message).finish(); + }, + toProtoMsg(message: GetViewRequest): GetViewRequestProtoMsg { + return { + typeUrl: "/google.logging.v2.GetViewRequest", + value: GetViewRequest.encode(message).finish() + }; + } +}; +function createBaseDeleteViewRequest(): DeleteViewRequest { + return { + name: "" + }; +} +export const DeleteViewRequest = { + typeUrl: "/google.logging.v2.DeleteViewRequest", + encode(message: DeleteViewRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): DeleteViewRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDeleteViewRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): DeleteViewRequest { + const obj = createBaseDeleteViewRequest(); + if (isSet(object.name)) obj.name = String(object.name); + return obj; + }, + toJSON(message: DeleteViewRequest): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + return obj; + }, + fromPartial(object: DeepPartial): DeleteViewRequest { + const message = createBaseDeleteViewRequest(); + message.name = object.name ?? ""; + return message; + }, + fromSDK(object: DeleteViewRequestSDKType): DeleteViewRequest { + return { + name: object?.name + }; + }, + fromSDKJSON(object: any): DeleteViewRequestSDKType { + return { + name: isSet(object.name) ? String(object.name) : "" + }; + }, + toSDK(message: DeleteViewRequest): DeleteViewRequestSDKType { + const obj: any = {}; + obj.name = message.name; + return obj; + }, + fromAmino(object: DeleteViewRequestAmino): DeleteViewRequest { + const message = createBaseDeleteViewRequest(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + return message; + }, + toAmino(message: DeleteViewRequest): DeleteViewRequestAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + return obj; + }, + fromAminoMsg(object: DeleteViewRequestAminoMsg): DeleteViewRequest { + return DeleteViewRequest.fromAmino(object.value); + }, + fromProtoMsg(message: DeleteViewRequestProtoMsg): DeleteViewRequest { + return DeleteViewRequest.decode(message.value); + }, + toProto(message: DeleteViewRequest): Uint8Array { + return DeleteViewRequest.encode(message).finish(); + }, + toProtoMsg(message: DeleteViewRequest): DeleteViewRequestProtoMsg { + return { + typeUrl: "/google.logging.v2.DeleteViewRequest", + value: DeleteViewRequest.encode(message).finish() + }; + } +}; +function createBaseListSinksRequest(): ListSinksRequest { + return { + parent: "", + pageToken: "", + pageSize: 0 + }; +} +export const ListSinksRequest = { + typeUrl: "/google.logging.v2.ListSinksRequest", + encode(message: ListSinksRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.parent !== undefined) { + writer.uint32(10).string(message.parent); + } + if (message.pageToken !== undefined) { + writer.uint32(18).string(message.pageToken); + } + if (message.pageSize !== undefined) { + writer.uint32(24).int32(message.pageSize); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ListSinksRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseListSinksRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.parent = reader.string(); + break; + case 2: + message.pageToken = reader.string(); + break; + case 3: + message.pageSize = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ListSinksRequest { + const obj = createBaseListSinksRequest(); + if (isSet(object.parent)) obj.parent = String(object.parent); + if (isSet(object.pageToken)) obj.pageToken = String(object.pageToken); + if (isSet(object.pageSize)) obj.pageSize = Number(object.pageSize); + return obj; + }, + toJSON(message: ListSinksRequest): JsonSafe { + const obj: any = {}; + message.parent !== undefined && (obj.parent = message.parent); + message.pageToken !== undefined && (obj.pageToken = message.pageToken); + message.pageSize !== undefined && (obj.pageSize = Math.round(message.pageSize)); + return obj; + }, + fromPartial(object: DeepPartial): ListSinksRequest { + const message = createBaseListSinksRequest(); + message.parent = object.parent ?? ""; + message.pageToken = object.pageToken ?? ""; + message.pageSize = object.pageSize ?? 0; + return message; + }, + fromSDK(object: ListSinksRequestSDKType): ListSinksRequest { + return { + parent: object?.parent, + pageToken: object?.page_token, + pageSize: object?.page_size + }; + }, + fromSDKJSON(object: any): ListSinksRequestSDKType { + return { + parent: isSet(object.parent) ? String(object.parent) : "", + page_token: isSet(object.page_token) ? String(object.page_token) : "", + page_size: isSet(object.page_size) ? Number(object.page_size) : 0 + }; + }, + toSDK(message: ListSinksRequest): ListSinksRequestSDKType { + const obj: any = {}; + obj.parent = message.parent; + obj.page_token = message.pageToken; + obj.page_size = message.pageSize; + return obj; + }, + fromAmino(object: ListSinksRequestAmino): ListSinksRequest { + const message = createBaseListSinksRequest(); + if (object.parent !== undefined && object.parent !== null) { + message.parent = object.parent; + } + if (object.page_token !== undefined && object.page_token !== null) { + message.pageToken = object.page_token; + } + if (object.page_size !== undefined && object.page_size !== null) { + message.pageSize = object.page_size; + } + return message; + }, + toAmino(message: ListSinksRequest): ListSinksRequestAmino { + const obj: any = {}; + obj.parent = message.parent === "" ? undefined : message.parent; + obj.page_token = message.pageToken === "" ? undefined : message.pageToken; + obj.page_size = message.pageSize === 0 ? undefined : message.pageSize; + return obj; + }, + fromAminoMsg(object: ListSinksRequestAminoMsg): ListSinksRequest { + return ListSinksRequest.fromAmino(object.value); + }, + fromProtoMsg(message: ListSinksRequestProtoMsg): ListSinksRequest { + return ListSinksRequest.decode(message.value); + }, + toProto(message: ListSinksRequest): Uint8Array { + return ListSinksRequest.encode(message).finish(); + }, + toProtoMsg(message: ListSinksRequest): ListSinksRequestProtoMsg { + return { + typeUrl: "/google.logging.v2.ListSinksRequest", + value: ListSinksRequest.encode(message).finish() + }; + } +}; +function createBaseListSinksResponse(): ListSinksResponse { + return { + sinks: [], + nextPageToken: "" + }; +} +export const ListSinksResponse = { + typeUrl: "/google.logging.v2.ListSinksResponse", + encode(message: ListSinksResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.sinks) { + LogSink.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.nextPageToken !== undefined) { + writer.uint32(18).string(message.nextPageToken); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ListSinksResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseListSinksResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.sinks.push(LogSink.decode(reader, reader.uint32())); + break; + case 2: + message.nextPageToken = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ListSinksResponse { + const obj = createBaseListSinksResponse(); + if (Array.isArray(object?.sinks)) obj.sinks = object.sinks.map((e: any) => LogSink.fromJSON(e)); + if (isSet(object.nextPageToken)) obj.nextPageToken = String(object.nextPageToken); + return obj; + }, + toJSON(message: ListSinksResponse): JsonSafe { + const obj: any = {}; + if (message.sinks) { + obj.sinks = message.sinks.map(e => e ? LogSink.toJSON(e) : undefined); + } else { + obj.sinks = []; + } + message.nextPageToken !== undefined && (obj.nextPageToken = message.nextPageToken); + return obj; + }, + fromPartial(object: DeepPartial): ListSinksResponse { + const message = createBaseListSinksResponse(); + message.sinks = object.sinks?.map(e => LogSink.fromPartial(e)) || []; + message.nextPageToken = object.nextPageToken ?? ""; + return message; + }, + fromSDK(object: ListSinksResponseSDKType): ListSinksResponse { + return { + sinks: Array.isArray(object?.sinks) ? object.sinks.map((e: any) => LogSink.fromSDK(e)) : [], + nextPageToken: object?.next_page_token + }; + }, + fromSDKJSON(object: any): ListSinksResponseSDKType { + return { + sinks: Array.isArray(object?.sinks) ? object.sinks.map((e: any) => LogSink.fromSDKJSON(e)) : [], + next_page_token: isSet(object.next_page_token) ? String(object.next_page_token) : "" + }; + }, + toSDK(message: ListSinksResponse): ListSinksResponseSDKType { + const obj: any = {}; + if (message.sinks) { + obj.sinks = message.sinks.map(e => e ? LogSink.toSDK(e) : undefined); + } else { + obj.sinks = []; + } + obj.next_page_token = message.nextPageToken; + return obj; + }, + fromAmino(object: ListSinksResponseAmino): ListSinksResponse { + const message = createBaseListSinksResponse(); + message.sinks = object.sinks?.map(e => LogSink.fromAmino(e)) || []; + if (object.next_page_token !== undefined && object.next_page_token !== null) { + message.nextPageToken = object.next_page_token; + } + return message; + }, + toAmino(message: ListSinksResponse): ListSinksResponseAmino { + const obj: any = {}; + if (message.sinks) { + obj.sinks = message.sinks.map(e => e ? LogSink.toAmino(e) : undefined); + } else { + obj.sinks = message.sinks; + } + obj.next_page_token = message.nextPageToken === "" ? undefined : message.nextPageToken; + return obj; + }, + fromAminoMsg(object: ListSinksResponseAminoMsg): ListSinksResponse { + return ListSinksResponse.fromAmino(object.value); + }, + fromProtoMsg(message: ListSinksResponseProtoMsg): ListSinksResponse { + return ListSinksResponse.decode(message.value); + }, + toProto(message: ListSinksResponse): Uint8Array { + return ListSinksResponse.encode(message).finish(); + }, + toProtoMsg(message: ListSinksResponse): ListSinksResponseProtoMsg { + return { + typeUrl: "/google.logging.v2.ListSinksResponse", + value: ListSinksResponse.encode(message).finish() + }; + } +}; +function createBaseGetSinkRequest(): GetSinkRequest { + return { + sinkName: "" + }; +} +export const GetSinkRequest = { + typeUrl: "/google.logging.v2.GetSinkRequest", + encode(message: GetSinkRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.sinkName !== undefined) { + writer.uint32(10).string(message.sinkName); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GetSinkRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGetSinkRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.sinkName = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GetSinkRequest { + const obj = createBaseGetSinkRequest(); + if (isSet(object.sinkName)) obj.sinkName = String(object.sinkName); + return obj; + }, + toJSON(message: GetSinkRequest): JsonSafe { + const obj: any = {}; + message.sinkName !== undefined && (obj.sinkName = message.sinkName); + return obj; + }, + fromPartial(object: DeepPartial): GetSinkRequest { + const message = createBaseGetSinkRequest(); + message.sinkName = object.sinkName ?? ""; + return message; + }, + fromSDK(object: GetSinkRequestSDKType): GetSinkRequest { + return { + sinkName: object?.sink_name + }; + }, + fromSDKJSON(object: any): GetSinkRequestSDKType { + return { + sink_name: isSet(object.sink_name) ? String(object.sink_name) : "" + }; + }, + toSDK(message: GetSinkRequest): GetSinkRequestSDKType { + const obj: any = {}; + obj.sink_name = message.sinkName; + return obj; + }, + fromAmino(object: GetSinkRequestAmino): GetSinkRequest { + const message = createBaseGetSinkRequest(); + if (object.sink_name !== undefined && object.sink_name !== null) { + message.sinkName = object.sink_name; + } + return message; + }, + toAmino(message: GetSinkRequest): GetSinkRequestAmino { + const obj: any = {}; + obj.sink_name = message.sinkName === "" ? undefined : message.sinkName; + return obj; + }, + fromAminoMsg(object: GetSinkRequestAminoMsg): GetSinkRequest { + return GetSinkRequest.fromAmino(object.value); + }, + fromProtoMsg(message: GetSinkRequestProtoMsg): GetSinkRequest { + return GetSinkRequest.decode(message.value); + }, + toProto(message: GetSinkRequest): Uint8Array { + return GetSinkRequest.encode(message).finish(); + }, + toProtoMsg(message: GetSinkRequest): GetSinkRequestProtoMsg { + return { + typeUrl: "/google.logging.v2.GetSinkRequest", + value: GetSinkRequest.encode(message).finish() + }; + } +}; +function createBaseCreateSinkRequest(): CreateSinkRequest { + return { + parent: "", + sink: undefined, + uniqueWriterIdentity: false + }; +} +export const CreateSinkRequest = { + typeUrl: "/google.logging.v2.CreateSinkRequest", + encode(message: CreateSinkRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.parent !== undefined) { + writer.uint32(10).string(message.parent); + } + if (message.sink !== undefined) { + LogSink.encode(message.sink, writer.uint32(18).fork()).ldelim(); + } + if (message.uniqueWriterIdentity !== undefined) { + writer.uint32(24).bool(message.uniqueWriterIdentity); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): CreateSinkRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCreateSinkRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.parent = reader.string(); + break; + case 2: + message.sink = LogSink.decode(reader, reader.uint32()); + break; + case 3: + message.uniqueWriterIdentity = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): CreateSinkRequest { + const obj = createBaseCreateSinkRequest(); + if (isSet(object.parent)) obj.parent = String(object.parent); + if (isSet(object.sink)) obj.sink = LogSink.fromJSON(object.sink); + if (isSet(object.uniqueWriterIdentity)) obj.uniqueWriterIdentity = Boolean(object.uniqueWriterIdentity); + return obj; + }, + toJSON(message: CreateSinkRequest): JsonSafe { + const obj: any = {}; + message.parent !== undefined && (obj.parent = message.parent); + message.sink !== undefined && (obj.sink = message.sink ? LogSink.toJSON(message.sink) : undefined); + message.uniqueWriterIdentity !== undefined && (obj.uniqueWriterIdentity = message.uniqueWriterIdentity); + return obj; + }, + fromPartial(object: DeepPartial): CreateSinkRequest { + const message = createBaseCreateSinkRequest(); + message.parent = object.parent ?? ""; + if (object.sink !== undefined && object.sink !== null) { + message.sink = LogSink.fromPartial(object.sink); + } + message.uniqueWriterIdentity = object.uniqueWriterIdentity ?? false; + return message; + }, + fromSDK(object: CreateSinkRequestSDKType): CreateSinkRequest { + return { + parent: object?.parent, + sink: object.sink ? LogSink.fromSDK(object.sink) : undefined, + uniqueWriterIdentity: object?.unique_writer_identity + }; + }, + fromSDKJSON(object: any): CreateSinkRequestSDKType { + return { + parent: isSet(object.parent) ? String(object.parent) : "", + sink: isSet(object.sink) ? LogSink.fromSDKJSON(object.sink) : undefined, + unique_writer_identity: isSet(object.unique_writer_identity) ? Boolean(object.unique_writer_identity) : false + }; + }, + toSDK(message: CreateSinkRequest): CreateSinkRequestSDKType { + const obj: any = {}; + obj.parent = message.parent; + message.sink !== undefined && (obj.sink = message.sink ? LogSink.toSDK(message.sink) : undefined); + obj.unique_writer_identity = message.uniqueWriterIdentity; + return obj; + }, + fromAmino(object: CreateSinkRequestAmino): CreateSinkRequest { + const message = createBaseCreateSinkRequest(); + if (object.parent !== undefined && object.parent !== null) { + message.parent = object.parent; + } + if (object.sink !== undefined && object.sink !== null) { + message.sink = LogSink.fromAmino(object.sink); + } + if (object.unique_writer_identity !== undefined && object.unique_writer_identity !== null) { + message.uniqueWriterIdentity = object.unique_writer_identity; + } + return message; + }, + toAmino(message: CreateSinkRequest): CreateSinkRequestAmino { + const obj: any = {}; + obj.parent = message.parent === "" ? undefined : message.parent; + obj.sink = message.sink ? LogSink.toAmino(message.sink) : undefined; + obj.unique_writer_identity = message.uniqueWriterIdentity === false ? undefined : message.uniqueWriterIdentity; + return obj; + }, + fromAminoMsg(object: CreateSinkRequestAminoMsg): CreateSinkRequest { + return CreateSinkRequest.fromAmino(object.value); + }, + fromProtoMsg(message: CreateSinkRequestProtoMsg): CreateSinkRequest { + return CreateSinkRequest.decode(message.value); + }, + toProto(message: CreateSinkRequest): Uint8Array { + return CreateSinkRequest.encode(message).finish(); + }, + toProtoMsg(message: CreateSinkRequest): CreateSinkRequestProtoMsg { + return { + typeUrl: "/google.logging.v2.CreateSinkRequest", + value: CreateSinkRequest.encode(message).finish() + }; + } +}; +function createBaseUpdateSinkRequest(): UpdateSinkRequest { + return { + sinkName: "", + sink: undefined, + uniqueWriterIdentity: false, + updateMask: undefined + }; +} +export const UpdateSinkRequest = { + typeUrl: "/google.logging.v2.UpdateSinkRequest", + encode(message: UpdateSinkRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.sinkName !== undefined) { + writer.uint32(10).string(message.sinkName); + } + if (message.sink !== undefined) { + LogSink.encode(message.sink, writer.uint32(18).fork()).ldelim(); + } + if (message.uniqueWriterIdentity !== undefined) { + writer.uint32(24).bool(message.uniqueWriterIdentity); + } + if (message.updateMask !== undefined) { + FieldMask.encode(message.updateMask, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): UpdateSinkRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseUpdateSinkRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.sinkName = reader.string(); + break; + case 2: + message.sink = LogSink.decode(reader, reader.uint32()); + break; + case 3: + message.uniqueWriterIdentity = reader.bool(); + break; + case 4: + message.updateMask = FieldMask.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): UpdateSinkRequest { + const obj = createBaseUpdateSinkRequest(); + if (isSet(object.sinkName)) obj.sinkName = String(object.sinkName); + if (isSet(object.sink)) obj.sink = LogSink.fromJSON(object.sink); + if (isSet(object.uniqueWriterIdentity)) obj.uniqueWriterIdentity = Boolean(object.uniqueWriterIdentity); + if (isSet(object.updateMask)) obj.updateMask = FieldMask.fromJSON(object.updateMask); + return obj; + }, + toJSON(message: UpdateSinkRequest): JsonSafe { + const obj: any = {}; + message.sinkName !== undefined && (obj.sinkName = message.sinkName); + message.sink !== undefined && (obj.sink = message.sink ? LogSink.toJSON(message.sink) : undefined); + message.uniqueWriterIdentity !== undefined && (obj.uniqueWriterIdentity = message.uniqueWriterIdentity); + message.updateMask !== undefined && (obj.updateMask = message.updateMask ? FieldMask.toJSON(message.updateMask) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): UpdateSinkRequest { + const message = createBaseUpdateSinkRequest(); + message.sinkName = object.sinkName ?? ""; + if (object.sink !== undefined && object.sink !== null) { + message.sink = LogSink.fromPartial(object.sink); + } + message.uniqueWriterIdentity = object.uniqueWriterIdentity ?? false; + if (object.updateMask !== undefined && object.updateMask !== null) { + message.updateMask = FieldMask.fromPartial(object.updateMask); + } + return message; + }, + fromSDK(object: UpdateSinkRequestSDKType): UpdateSinkRequest { + return { + sinkName: object?.sink_name, + sink: object.sink ? LogSink.fromSDK(object.sink) : undefined, + uniqueWriterIdentity: object?.unique_writer_identity, + updateMask: object.update_mask ? FieldMask.fromSDK(object.update_mask) : undefined + }; + }, + fromSDKJSON(object: any): UpdateSinkRequestSDKType { + return { + sink_name: isSet(object.sink_name) ? String(object.sink_name) : "", + sink: isSet(object.sink) ? LogSink.fromSDKJSON(object.sink) : undefined, + unique_writer_identity: isSet(object.unique_writer_identity) ? Boolean(object.unique_writer_identity) : false, + update_mask: isSet(object.update_mask) ? FieldMask.fromSDKJSON(object.update_mask) : undefined + }; + }, + toSDK(message: UpdateSinkRequest): UpdateSinkRequestSDKType { + const obj: any = {}; + obj.sink_name = message.sinkName; + message.sink !== undefined && (obj.sink = message.sink ? LogSink.toSDK(message.sink) : undefined); + obj.unique_writer_identity = message.uniqueWriterIdentity; + message.updateMask !== undefined && (obj.update_mask = message.updateMask ? FieldMask.toSDK(message.updateMask) : undefined); + return obj; + }, + fromAmino(object: UpdateSinkRequestAmino): UpdateSinkRequest { + const message = createBaseUpdateSinkRequest(); + if (object.sink_name !== undefined && object.sink_name !== null) { + message.sinkName = object.sink_name; + } + if (object.sink !== undefined && object.sink !== null) { + message.sink = LogSink.fromAmino(object.sink); + } + if (object.unique_writer_identity !== undefined && object.unique_writer_identity !== null) { + message.uniqueWriterIdentity = object.unique_writer_identity; + } + if (object.update_mask !== undefined && object.update_mask !== null) { + message.updateMask = FieldMask.fromAmino(object.update_mask); + } + return message; + }, + toAmino(message: UpdateSinkRequest): UpdateSinkRequestAmino { + const obj: any = {}; + obj.sink_name = message.sinkName === "" ? undefined : message.sinkName; + obj.sink = message.sink ? LogSink.toAmino(message.sink) : undefined; + obj.unique_writer_identity = message.uniqueWriterIdentity === false ? undefined : message.uniqueWriterIdentity; + obj.update_mask = message.updateMask ? FieldMask.toAmino(message.updateMask) : undefined; + return obj; + }, + fromAminoMsg(object: UpdateSinkRequestAminoMsg): UpdateSinkRequest { + return UpdateSinkRequest.fromAmino(object.value); + }, + fromProtoMsg(message: UpdateSinkRequestProtoMsg): UpdateSinkRequest { + return UpdateSinkRequest.decode(message.value); + }, + toProto(message: UpdateSinkRequest): Uint8Array { + return UpdateSinkRequest.encode(message).finish(); + }, + toProtoMsg(message: UpdateSinkRequest): UpdateSinkRequestProtoMsg { + return { + typeUrl: "/google.logging.v2.UpdateSinkRequest", + value: UpdateSinkRequest.encode(message).finish() + }; + } +}; +function createBaseDeleteSinkRequest(): DeleteSinkRequest { + return { + sinkName: "" + }; +} +export const DeleteSinkRequest = { + typeUrl: "/google.logging.v2.DeleteSinkRequest", + encode(message: DeleteSinkRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.sinkName !== undefined) { + writer.uint32(10).string(message.sinkName); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): DeleteSinkRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDeleteSinkRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.sinkName = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): DeleteSinkRequest { + const obj = createBaseDeleteSinkRequest(); + if (isSet(object.sinkName)) obj.sinkName = String(object.sinkName); + return obj; + }, + toJSON(message: DeleteSinkRequest): JsonSafe { + const obj: any = {}; + message.sinkName !== undefined && (obj.sinkName = message.sinkName); + return obj; + }, + fromPartial(object: DeepPartial): DeleteSinkRequest { + const message = createBaseDeleteSinkRequest(); + message.sinkName = object.sinkName ?? ""; + return message; + }, + fromSDK(object: DeleteSinkRequestSDKType): DeleteSinkRequest { + return { + sinkName: object?.sink_name + }; + }, + fromSDKJSON(object: any): DeleteSinkRequestSDKType { + return { + sink_name: isSet(object.sink_name) ? String(object.sink_name) : "" + }; + }, + toSDK(message: DeleteSinkRequest): DeleteSinkRequestSDKType { + const obj: any = {}; + obj.sink_name = message.sinkName; + return obj; + }, + fromAmino(object: DeleteSinkRequestAmino): DeleteSinkRequest { + const message = createBaseDeleteSinkRequest(); + if (object.sink_name !== undefined && object.sink_name !== null) { + message.sinkName = object.sink_name; + } + return message; + }, + toAmino(message: DeleteSinkRequest): DeleteSinkRequestAmino { + const obj: any = {}; + obj.sink_name = message.sinkName === "" ? undefined : message.sinkName; + return obj; + }, + fromAminoMsg(object: DeleteSinkRequestAminoMsg): DeleteSinkRequest { + return DeleteSinkRequest.fromAmino(object.value); + }, + fromProtoMsg(message: DeleteSinkRequestProtoMsg): DeleteSinkRequest { + return DeleteSinkRequest.decode(message.value); + }, + toProto(message: DeleteSinkRequest): Uint8Array { + return DeleteSinkRequest.encode(message).finish(); + }, + toProtoMsg(message: DeleteSinkRequest): DeleteSinkRequestProtoMsg { + return { + typeUrl: "/google.logging.v2.DeleteSinkRequest", + value: DeleteSinkRequest.encode(message).finish() + }; + } +}; +function createBaseLogExclusion(): LogExclusion { + return { + name: "", + description: "", + filter: "", + disabled: false, + createTime: undefined, + updateTime: undefined + }; +} +export const LogExclusion = { + typeUrl: "/google.logging.v2.LogExclusion", + encode(message: LogExclusion, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + if (message.description !== undefined) { + writer.uint32(18).string(message.description); + } + if (message.filter !== undefined) { + writer.uint32(26).string(message.filter); + } + if (message.disabled !== undefined) { + writer.uint32(32).bool(message.disabled); + } + if (message.createTime !== undefined) { + Timestamp.encode(toTimestamp(message.createTime), writer.uint32(42).fork()).ldelim(); + } + if (message.updateTime !== undefined) { + Timestamp.encode(toTimestamp(message.updateTime), writer.uint32(50).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): LogExclusion { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseLogExclusion(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.description = reader.string(); + break; + case 3: + message.filter = reader.string(); + break; + case 4: + message.disabled = reader.bool(); + break; + case 5: + message.createTime = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + break; + case 6: + message.updateTime = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): LogExclusion { + const obj = createBaseLogExclusion(); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.description)) obj.description = String(object.description); + if (isSet(object.filter)) obj.filter = String(object.filter); + if (isSet(object.disabled)) obj.disabled = Boolean(object.disabled); + if (isSet(object.createTime)) obj.createTime = new Date(object.createTime); + if (isSet(object.updateTime)) obj.updateTime = new Date(object.updateTime); + return obj; + }, + toJSON(message: LogExclusion): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.description !== undefined && (obj.description = message.description); + message.filter !== undefined && (obj.filter = message.filter); + message.disabled !== undefined && (obj.disabled = message.disabled); + message.createTime !== undefined && (obj.createTime = message.createTime.toISOString()); + message.updateTime !== undefined && (obj.updateTime = message.updateTime.toISOString()); + return obj; + }, + fromPartial(object: DeepPartial): LogExclusion { + const message = createBaseLogExclusion(); + message.name = object.name ?? ""; + message.description = object.description ?? ""; + message.filter = object.filter ?? ""; + message.disabled = object.disabled ?? false; + message.createTime = object.createTime ?? undefined; + message.updateTime = object.updateTime ?? undefined; + return message; + }, + fromSDK(object: LogExclusionSDKType): LogExclusion { + return { + name: object?.name, + description: object?.description, + filter: object?.filter, + disabled: object?.disabled, + createTime: object.create_time ?? undefined, + updateTime: object.update_time ?? undefined + }; + }, + fromSDKJSON(object: any): LogExclusionSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + description: isSet(object.description) ? String(object.description) : "", + filter: isSet(object.filter) ? String(object.filter) : "", + disabled: isSet(object.disabled) ? Boolean(object.disabled) : false, + create_time: isSet(object.create_time) ? new Date(object.create_time) : undefined, + update_time: isSet(object.update_time) ? new Date(object.update_time) : undefined + }; + }, + toSDK(message: LogExclusion): LogExclusionSDKType { + const obj: any = {}; + obj.name = message.name; + obj.description = message.description; + obj.filter = message.filter; + obj.disabled = message.disabled; + message.createTime !== undefined && (obj.create_time = message.createTime ?? undefined); + message.updateTime !== undefined && (obj.update_time = message.updateTime ?? undefined); + return obj; + }, + fromAmino(object: LogExclusionAmino): LogExclusion { + const message = createBaseLogExclusion(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } + if (object.filter !== undefined && object.filter !== null) { + message.filter = object.filter; + } + if (object.disabled !== undefined && object.disabled !== null) { + message.disabled = object.disabled; + } + if (object.create_time !== undefined && object.create_time !== null) { + message.createTime = fromTimestamp(Timestamp.fromAmino(object.create_time)); + } + if (object.update_time !== undefined && object.update_time !== null) { + message.updateTime = fromTimestamp(Timestamp.fromAmino(object.update_time)); + } + return message; + }, + toAmino(message: LogExclusion): LogExclusionAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + obj.description = message.description === "" ? undefined : message.description; + obj.filter = message.filter === "" ? undefined : message.filter; + obj.disabled = message.disabled === false ? undefined : message.disabled; + obj.create_time = message.createTime ? Timestamp.toAmino(toTimestamp(message.createTime)) : undefined; + obj.update_time = message.updateTime ? Timestamp.toAmino(toTimestamp(message.updateTime)) : undefined; + return obj; + }, + fromAminoMsg(object: LogExclusionAminoMsg): LogExclusion { + return LogExclusion.fromAmino(object.value); + }, + fromProtoMsg(message: LogExclusionProtoMsg): LogExclusion { + return LogExclusion.decode(message.value); + }, + toProto(message: LogExclusion): Uint8Array { + return LogExclusion.encode(message).finish(); + }, + toProtoMsg(message: LogExclusion): LogExclusionProtoMsg { + return { + typeUrl: "/google.logging.v2.LogExclusion", + value: LogExclusion.encode(message).finish() + }; + } +}; +function createBaseListExclusionsRequest(): ListExclusionsRequest { + return { + parent: "", + pageToken: "", + pageSize: 0 + }; +} +export const ListExclusionsRequest = { + typeUrl: "/google.logging.v2.ListExclusionsRequest", + encode(message: ListExclusionsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.parent !== undefined) { + writer.uint32(10).string(message.parent); + } + if (message.pageToken !== undefined) { + writer.uint32(18).string(message.pageToken); + } + if (message.pageSize !== undefined) { + writer.uint32(24).int32(message.pageSize); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ListExclusionsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseListExclusionsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.parent = reader.string(); + break; + case 2: + message.pageToken = reader.string(); + break; + case 3: + message.pageSize = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ListExclusionsRequest { + const obj = createBaseListExclusionsRequest(); + if (isSet(object.parent)) obj.parent = String(object.parent); + if (isSet(object.pageToken)) obj.pageToken = String(object.pageToken); + if (isSet(object.pageSize)) obj.pageSize = Number(object.pageSize); + return obj; + }, + toJSON(message: ListExclusionsRequest): JsonSafe { + const obj: any = {}; + message.parent !== undefined && (obj.parent = message.parent); + message.pageToken !== undefined && (obj.pageToken = message.pageToken); + message.pageSize !== undefined && (obj.pageSize = Math.round(message.pageSize)); + return obj; + }, + fromPartial(object: DeepPartial): ListExclusionsRequest { + const message = createBaseListExclusionsRequest(); + message.parent = object.parent ?? ""; + message.pageToken = object.pageToken ?? ""; + message.pageSize = object.pageSize ?? 0; + return message; + }, + fromSDK(object: ListExclusionsRequestSDKType): ListExclusionsRequest { + return { + parent: object?.parent, + pageToken: object?.page_token, + pageSize: object?.page_size + }; + }, + fromSDKJSON(object: any): ListExclusionsRequestSDKType { + return { + parent: isSet(object.parent) ? String(object.parent) : "", + page_token: isSet(object.page_token) ? String(object.page_token) : "", + page_size: isSet(object.page_size) ? Number(object.page_size) : 0 + }; + }, + toSDK(message: ListExclusionsRequest): ListExclusionsRequestSDKType { + const obj: any = {}; + obj.parent = message.parent; + obj.page_token = message.pageToken; + obj.page_size = message.pageSize; + return obj; + }, + fromAmino(object: ListExclusionsRequestAmino): ListExclusionsRequest { + const message = createBaseListExclusionsRequest(); + if (object.parent !== undefined && object.parent !== null) { + message.parent = object.parent; + } + if (object.page_token !== undefined && object.page_token !== null) { + message.pageToken = object.page_token; + } + if (object.page_size !== undefined && object.page_size !== null) { + message.pageSize = object.page_size; + } + return message; + }, + toAmino(message: ListExclusionsRequest): ListExclusionsRequestAmino { + const obj: any = {}; + obj.parent = message.parent === "" ? undefined : message.parent; + obj.page_token = message.pageToken === "" ? undefined : message.pageToken; + obj.page_size = message.pageSize === 0 ? undefined : message.pageSize; + return obj; + }, + fromAminoMsg(object: ListExclusionsRequestAminoMsg): ListExclusionsRequest { + return ListExclusionsRequest.fromAmino(object.value); + }, + fromProtoMsg(message: ListExclusionsRequestProtoMsg): ListExclusionsRequest { + return ListExclusionsRequest.decode(message.value); + }, + toProto(message: ListExclusionsRequest): Uint8Array { + return ListExclusionsRequest.encode(message).finish(); + }, + toProtoMsg(message: ListExclusionsRequest): ListExclusionsRequestProtoMsg { + return { + typeUrl: "/google.logging.v2.ListExclusionsRequest", + value: ListExclusionsRequest.encode(message).finish() + }; + } +}; +function createBaseListExclusionsResponse(): ListExclusionsResponse { + return { + exclusions: [], + nextPageToken: "" + }; +} +export const ListExclusionsResponse = { + typeUrl: "/google.logging.v2.ListExclusionsResponse", + encode(message: ListExclusionsResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.exclusions) { + LogExclusion.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.nextPageToken !== undefined) { + writer.uint32(18).string(message.nextPageToken); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ListExclusionsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseListExclusionsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.exclusions.push(LogExclusion.decode(reader, reader.uint32())); + break; + case 2: + message.nextPageToken = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ListExclusionsResponse { + const obj = createBaseListExclusionsResponse(); + if (Array.isArray(object?.exclusions)) obj.exclusions = object.exclusions.map((e: any) => LogExclusion.fromJSON(e)); + if (isSet(object.nextPageToken)) obj.nextPageToken = String(object.nextPageToken); + return obj; + }, + toJSON(message: ListExclusionsResponse): JsonSafe { + const obj: any = {}; + if (message.exclusions) { + obj.exclusions = message.exclusions.map(e => e ? LogExclusion.toJSON(e) : undefined); + } else { + obj.exclusions = []; + } + message.nextPageToken !== undefined && (obj.nextPageToken = message.nextPageToken); + return obj; + }, + fromPartial(object: DeepPartial): ListExclusionsResponse { + const message = createBaseListExclusionsResponse(); + message.exclusions = object.exclusions?.map(e => LogExclusion.fromPartial(e)) || []; + message.nextPageToken = object.nextPageToken ?? ""; + return message; + }, + fromSDK(object: ListExclusionsResponseSDKType): ListExclusionsResponse { + return { + exclusions: Array.isArray(object?.exclusions) ? object.exclusions.map((e: any) => LogExclusion.fromSDK(e)) : [], + nextPageToken: object?.next_page_token + }; + }, + fromSDKJSON(object: any): ListExclusionsResponseSDKType { + return { + exclusions: Array.isArray(object?.exclusions) ? object.exclusions.map((e: any) => LogExclusion.fromSDKJSON(e)) : [], + next_page_token: isSet(object.next_page_token) ? String(object.next_page_token) : "" + }; + }, + toSDK(message: ListExclusionsResponse): ListExclusionsResponseSDKType { + const obj: any = {}; + if (message.exclusions) { + obj.exclusions = message.exclusions.map(e => e ? LogExclusion.toSDK(e) : undefined); + } else { + obj.exclusions = []; + } + obj.next_page_token = message.nextPageToken; + return obj; + }, + fromAmino(object: ListExclusionsResponseAmino): ListExclusionsResponse { + const message = createBaseListExclusionsResponse(); + message.exclusions = object.exclusions?.map(e => LogExclusion.fromAmino(e)) || []; + if (object.next_page_token !== undefined && object.next_page_token !== null) { + message.nextPageToken = object.next_page_token; + } + return message; + }, + toAmino(message: ListExclusionsResponse): ListExclusionsResponseAmino { + const obj: any = {}; + if (message.exclusions) { + obj.exclusions = message.exclusions.map(e => e ? LogExclusion.toAmino(e) : undefined); + } else { + obj.exclusions = message.exclusions; + } + obj.next_page_token = message.nextPageToken === "" ? undefined : message.nextPageToken; + return obj; + }, + fromAminoMsg(object: ListExclusionsResponseAminoMsg): ListExclusionsResponse { + return ListExclusionsResponse.fromAmino(object.value); + }, + fromProtoMsg(message: ListExclusionsResponseProtoMsg): ListExclusionsResponse { + return ListExclusionsResponse.decode(message.value); + }, + toProto(message: ListExclusionsResponse): Uint8Array { + return ListExclusionsResponse.encode(message).finish(); + }, + toProtoMsg(message: ListExclusionsResponse): ListExclusionsResponseProtoMsg { + return { + typeUrl: "/google.logging.v2.ListExclusionsResponse", + value: ListExclusionsResponse.encode(message).finish() + }; + } +}; +function createBaseGetExclusionRequest(): GetExclusionRequest { + return { + name: "" + }; +} +export const GetExclusionRequest = { + typeUrl: "/google.logging.v2.GetExclusionRequest", + encode(message: GetExclusionRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GetExclusionRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGetExclusionRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GetExclusionRequest { + const obj = createBaseGetExclusionRequest(); + if (isSet(object.name)) obj.name = String(object.name); + return obj; + }, + toJSON(message: GetExclusionRequest): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + return obj; + }, + fromPartial(object: DeepPartial): GetExclusionRequest { + const message = createBaseGetExclusionRequest(); + message.name = object.name ?? ""; + return message; + }, + fromSDK(object: GetExclusionRequestSDKType): GetExclusionRequest { + return { + name: object?.name + }; + }, + fromSDKJSON(object: any): GetExclusionRequestSDKType { + return { + name: isSet(object.name) ? String(object.name) : "" + }; + }, + toSDK(message: GetExclusionRequest): GetExclusionRequestSDKType { + const obj: any = {}; + obj.name = message.name; + return obj; + }, + fromAmino(object: GetExclusionRequestAmino): GetExclusionRequest { + const message = createBaseGetExclusionRequest(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + return message; + }, + toAmino(message: GetExclusionRequest): GetExclusionRequestAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + return obj; + }, + fromAminoMsg(object: GetExclusionRequestAminoMsg): GetExclusionRequest { + return GetExclusionRequest.fromAmino(object.value); + }, + fromProtoMsg(message: GetExclusionRequestProtoMsg): GetExclusionRequest { + return GetExclusionRequest.decode(message.value); + }, + toProto(message: GetExclusionRequest): Uint8Array { + return GetExclusionRequest.encode(message).finish(); + }, + toProtoMsg(message: GetExclusionRequest): GetExclusionRequestProtoMsg { + return { + typeUrl: "/google.logging.v2.GetExclusionRequest", + value: GetExclusionRequest.encode(message).finish() + }; + } +}; +function createBaseCreateExclusionRequest(): CreateExclusionRequest { + return { + parent: "", + exclusion: undefined + }; +} +export const CreateExclusionRequest = { + typeUrl: "/google.logging.v2.CreateExclusionRequest", + encode(message: CreateExclusionRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.parent !== undefined) { + writer.uint32(10).string(message.parent); + } + if (message.exclusion !== undefined) { + LogExclusion.encode(message.exclusion, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): CreateExclusionRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCreateExclusionRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.parent = reader.string(); + break; + case 2: + message.exclusion = LogExclusion.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): CreateExclusionRequest { + const obj = createBaseCreateExclusionRequest(); + if (isSet(object.parent)) obj.parent = String(object.parent); + if (isSet(object.exclusion)) obj.exclusion = LogExclusion.fromJSON(object.exclusion); + return obj; + }, + toJSON(message: CreateExclusionRequest): JsonSafe { + const obj: any = {}; + message.parent !== undefined && (obj.parent = message.parent); + message.exclusion !== undefined && (obj.exclusion = message.exclusion ? LogExclusion.toJSON(message.exclusion) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): CreateExclusionRequest { + const message = createBaseCreateExclusionRequest(); + message.parent = object.parent ?? ""; + if (object.exclusion !== undefined && object.exclusion !== null) { + message.exclusion = LogExclusion.fromPartial(object.exclusion); + } + return message; + }, + fromSDK(object: CreateExclusionRequestSDKType): CreateExclusionRequest { + return { + parent: object?.parent, + exclusion: object.exclusion ? LogExclusion.fromSDK(object.exclusion) : undefined + }; + }, + fromSDKJSON(object: any): CreateExclusionRequestSDKType { + return { + parent: isSet(object.parent) ? String(object.parent) : "", + exclusion: isSet(object.exclusion) ? LogExclusion.fromSDKJSON(object.exclusion) : undefined + }; + }, + toSDK(message: CreateExclusionRequest): CreateExclusionRequestSDKType { + const obj: any = {}; + obj.parent = message.parent; + message.exclusion !== undefined && (obj.exclusion = message.exclusion ? LogExclusion.toSDK(message.exclusion) : undefined); + return obj; + }, + fromAmino(object: CreateExclusionRequestAmino): CreateExclusionRequest { + const message = createBaseCreateExclusionRequest(); + if (object.parent !== undefined && object.parent !== null) { + message.parent = object.parent; + } + if (object.exclusion !== undefined && object.exclusion !== null) { + message.exclusion = LogExclusion.fromAmino(object.exclusion); + } + return message; + }, + toAmino(message: CreateExclusionRequest): CreateExclusionRequestAmino { + const obj: any = {}; + obj.parent = message.parent === "" ? undefined : message.parent; + obj.exclusion = message.exclusion ? LogExclusion.toAmino(message.exclusion) : undefined; + return obj; + }, + fromAminoMsg(object: CreateExclusionRequestAminoMsg): CreateExclusionRequest { + return CreateExclusionRequest.fromAmino(object.value); + }, + fromProtoMsg(message: CreateExclusionRequestProtoMsg): CreateExclusionRequest { + return CreateExclusionRequest.decode(message.value); + }, + toProto(message: CreateExclusionRequest): Uint8Array { + return CreateExclusionRequest.encode(message).finish(); + }, + toProtoMsg(message: CreateExclusionRequest): CreateExclusionRequestProtoMsg { + return { + typeUrl: "/google.logging.v2.CreateExclusionRequest", + value: CreateExclusionRequest.encode(message).finish() + }; + } +}; +function createBaseUpdateExclusionRequest(): UpdateExclusionRequest { + return { + name: "", + exclusion: undefined, + updateMask: undefined + }; +} +export const UpdateExclusionRequest = { + typeUrl: "/google.logging.v2.UpdateExclusionRequest", + encode(message: UpdateExclusionRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + if (message.exclusion !== undefined) { + LogExclusion.encode(message.exclusion, writer.uint32(18).fork()).ldelim(); + } + if (message.updateMask !== undefined) { + FieldMask.encode(message.updateMask, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): UpdateExclusionRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseUpdateExclusionRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.exclusion = LogExclusion.decode(reader, reader.uint32()); + break; + case 3: + message.updateMask = FieldMask.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): UpdateExclusionRequest { + const obj = createBaseUpdateExclusionRequest(); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.exclusion)) obj.exclusion = LogExclusion.fromJSON(object.exclusion); + if (isSet(object.updateMask)) obj.updateMask = FieldMask.fromJSON(object.updateMask); + return obj; + }, + toJSON(message: UpdateExclusionRequest): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.exclusion !== undefined && (obj.exclusion = message.exclusion ? LogExclusion.toJSON(message.exclusion) : undefined); + message.updateMask !== undefined && (obj.updateMask = message.updateMask ? FieldMask.toJSON(message.updateMask) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): UpdateExclusionRequest { + const message = createBaseUpdateExclusionRequest(); + message.name = object.name ?? ""; + if (object.exclusion !== undefined && object.exclusion !== null) { + message.exclusion = LogExclusion.fromPartial(object.exclusion); + } + if (object.updateMask !== undefined && object.updateMask !== null) { + message.updateMask = FieldMask.fromPartial(object.updateMask); + } + return message; + }, + fromSDK(object: UpdateExclusionRequestSDKType): UpdateExclusionRequest { + return { + name: object?.name, + exclusion: object.exclusion ? LogExclusion.fromSDK(object.exclusion) : undefined, + updateMask: object.update_mask ? FieldMask.fromSDK(object.update_mask) : undefined + }; + }, + fromSDKJSON(object: any): UpdateExclusionRequestSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + exclusion: isSet(object.exclusion) ? LogExclusion.fromSDKJSON(object.exclusion) : undefined, + update_mask: isSet(object.update_mask) ? FieldMask.fromSDKJSON(object.update_mask) : undefined + }; + }, + toSDK(message: UpdateExclusionRequest): UpdateExclusionRequestSDKType { + const obj: any = {}; + obj.name = message.name; + message.exclusion !== undefined && (obj.exclusion = message.exclusion ? LogExclusion.toSDK(message.exclusion) : undefined); + message.updateMask !== undefined && (obj.update_mask = message.updateMask ? FieldMask.toSDK(message.updateMask) : undefined); + return obj; + }, + fromAmino(object: UpdateExclusionRequestAmino): UpdateExclusionRequest { + const message = createBaseUpdateExclusionRequest(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + if (object.exclusion !== undefined && object.exclusion !== null) { + message.exclusion = LogExclusion.fromAmino(object.exclusion); + } + if (object.update_mask !== undefined && object.update_mask !== null) { + message.updateMask = FieldMask.fromAmino(object.update_mask); + } + return message; + }, + toAmino(message: UpdateExclusionRequest): UpdateExclusionRequestAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + obj.exclusion = message.exclusion ? LogExclusion.toAmino(message.exclusion) : undefined; + obj.update_mask = message.updateMask ? FieldMask.toAmino(message.updateMask) : undefined; + return obj; + }, + fromAminoMsg(object: UpdateExclusionRequestAminoMsg): UpdateExclusionRequest { + return UpdateExclusionRequest.fromAmino(object.value); + }, + fromProtoMsg(message: UpdateExclusionRequestProtoMsg): UpdateExclusionRequest { + return UpdateExclusionRequest.decode(message.value); + }, + toProto(message: UpdateExclusionRequest): Uint8Array { + return UpdateExclusionRequest.encode(message).finish(); + }, + toProtoMsg(message: UpdateExclusionRequest): UpdateExclusionRequestProtoMsg { + return { + typeUrl: "/google.logging.v2.UpdateExclusionRequest", + value: UpdateExclusionRequest.encode(message).finish() + }; + } +}; +function createBaseDeleteExclusionRequest(): DeleteExclusionRequest { + return { + name: "" + }; +} +export const DeleteExclusionRequest = { + typeUrl: "/google.logging.v2.DeleteExclusionRequest", + encode(message: DeleteExclusionRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): DeleteExclusionRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDeleteExclusionRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): DeleteExclusionRequest { + const obj = createBaseDeleteExclusionRequest(); + if (isSet(object.name)) obj.name = String(object.name); + return obj; + }, + toJSON(message: DeleteExclusionRequest): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + return obj; + }, + fromPartial(object: DeepPartial): DeleteExclusionRequest { + const message = createBaseDeleteExclusionRequest(); + message.name = object.name ?? ""; + return message; + }, + fromSDK(object: DeleteExclusionRequestSDKType): DeleteExclusionRequest { + return { + name: object?.name + }; + }, + fromSDKJSON(object: any): DeleteExclusionRequestSDKType { + return { + name: isSet(object.name) ? String(object.name) : "" + }; + }, + toSDK(message: DeleteExclusionRequest): DeleteExclusionRequestSDKType { + const obj: any = {}; + obj.name = message.name; + return obj; + }, + fromAmino(object: DeleteExclusionRequestAmino): DeleteExclusionRequest { + const message = createBaseDeleteExclusionRequest(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + return message; + }, + toAmino(message: DeleteExclusionRequest): DeleteExclusionRequestAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + return obj; + }, + fromAminoMsg(object: DeleteExclusionRequestAminoMsg): DeleteExclusionRequest { + return DeleteExclusionRequest.fromAmino(object.value); + }, + fromProtoMsg(message: DeleteExclusionRequestProtoMsg): DeleteExclusionRequest { + return DeleteExclusionRequest.decode(message.value); + }, + toProto(message: DeleteExclusionRequest): Uint8Array { + return DeleteExclusionRequest.encode(message).finish(); + }, + toProtoMsg(message: DeleteExclusionRequest): DeleteExclusionRequestProtoMsg { + return { + typeUrl: "/google.logging.v2.DeleteExclusionRequest", + value: DeleteExclusionRequest.encode(message).finish() + }; + } +}; +function createBaseGetCmekSettingsRequest(): GetCmekSettingsRequest { + return { + name: "" + }; +} +export const GetCmekSettingsRequest = { + typeUrl: "/google.logging.v2.GetCmekSettingsRequest", + encode(message: GetCmekSettingsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GetCmekSettingsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGetCmekSettingsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GetCmekSettingsRequest { + const obj = createBaseGetCmekSettingsRequest(); + if (isSet(object.name)) obj.name = String(object.name); + return obj; + }, + toJSON(message: GetCmekSettingsRequest): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + return obj; + }, + fromPartial(object: DeepPartial): GetCmekSettingsRequest { + const message = createBaseGetCmekSettingsRequest(); + message.name = object.name ?? ""; + return message; + }, + fromSDK(object: GetCmekSettingsRequestSDKType): GetCmekSettingsRequest { + return { + name: object?.name + }; + }, + fromSDKJSON(object: any): GetCmekSettingsRequestSDKType { + return { + name: isSet(object.name) ? String(object.name) : "" + }; + }, + toSDK(message: GetCmekSettingsRequest): GetCmekSettingsRequestSDKType { + const obj: any = {}; + obj.name = message.name; + return obj; + }, + fromAmino(object: GetCmekSettingsRequestAmino): GetCmekSettingsRequest { + const message = createBaseGetCmekSettingsRequest(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + return message; + }, + toAmino(message: GetCmekSettingsRequest): GetCmekSettingsRequestAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + return obj; + }, + fromAminoMsg(object: GetCmekSettingsRequestAminoMsg): GetCmekSettingsRequest { + return GetCmekSettingsRequest.fromAmino(object.value); + }, + fromProtoMsg(message: GetCmekSettingsRequestProtoMsg): GetCmekSettingsRequest { + return GetCmekSettingsRequest.decode(message.value); + }, + toProto(message: GetCmekSettingsRequest): Uint8Array { + return GetCmekSettingsRequest.encode(message).finish(); + }, + toProtoMsg(message: GetCmekSettingsRequest): GetCmekSettingsRequestProtoMsg { + return { + typeUrl: "/google.logging.v2.GetCmekSettingsRequest", + value: GetCmekSettingsRequest.encode(message).finish() + }; + } +}; +function createBaseUpdateCmekSettingsRequest(): UpdateCmekSettingsRequest { + return { + name: "", + cmekSettings: undefined, + updateMask: undefined + }; +} +export const UpdateCmekSettingsRequest = { + typeUrl: "/google.logging.v2.UpdateCmekSettingsRequest", + encode(message: UpdateCmekSettingsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + if (message.cmekSettings !== undefined) { + CmekSettings.encode(message.cmekSettings, writer.uint32(18).fork()).ldelim(); + } + if (message.updateMask !== undefined) { + FieldMask.encode(message.updateMask, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): UpdateCmekSettingsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseUpdateCmekSettingsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.cmekSettings = CmekSettings.decode(reader, reader.uint32()); + break; + case 3: + message.updateMask = FieldMask.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): UpdateCmekSettingsRequest { + const obj = createBaseUpdateCmekSettingsRequest(); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.cmekSettings)) obj.cmekSettings = CmekSettings.fromJSON(object.cmekSettings); + if (isSet(object.updateMask)) obj.updateMask = FieldMask.fromJSON(object.updateMask); + return obj; + }, + toJSON(message: UpdateCmekSettingsRequest): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.cmekSettings !== undefined && (obj.cmekSettings = message.cmekSettings ? CmekSettings.toJSON(message.cmekSettings) : undefined); + message.updateMask !== undefined && (obj.updateMask = message.updateMask ? FieldMask.toJSON(message.updateMask) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): UpdateCmekSettingsRequest { + const message = createBaseUpdateCmekSettingsRequest(); + message.name = object.name ?? ""; + if (object.cmekSettings !== undefined && object.cmekSettings !== null) { + message.cmekSettings = CmekSettings.fromPartial(object.cmekSettings); + } + if (object.updateMask !== undefined && object.updateMask !== null) { + message.updateMask = FieldMask.fromPartial(object.updateMask); + } + return message; + }, + fromSDK(object: UpdateCmekSettingsRequestSDKType): UpdateCmekSettingsRequest { + return { + name: object?.name, + cmekSettings: object.cmek_settings ? CmekSettings.fromSDK(object.cmek_settings) : undefined, + updateMask: object.update_mask ? FieldMask.fromSDK(object.update_mask) : undefined + }; + }, + fromSDKJSON(object: any): UpdateCmekSettingsRequestSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + cmek_settings: isSet(object.cmek_settings) ? CmekSettings.fromSDKJSON(object.cmek_settings) : undefined, + update_mask: isSet(object.update_mask) ? FieldMask.fromSDKJSON(object.update_mask) : undefined + }; + }, + toSDK(message: UpdateCmekSettingsRequest): UpdateCmekSettingsRequestSDKType { + const obj: any = {}; + obj.name = message.name; + message.cmekSettings !== undefined && (obj.cmek_settings = message.cmekSettings ? CmekSettings.toSDK(message.cmekSettings) : undefined); + message.updateMask !== undefined && (obj.update_mask = message.updateMask ? FieldMask.toSDK(message.updateMask) : undefined); + return obj; + }, + fromAmino(object: UpdateCmekSettingsRequestAmino): UpdateCmekSettingsRequest { + const message = createBaseUpdateCmekSettingsRequest(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + if (object.cmek_settings !== undefined && object.cmek_settings !== null) { + message.cmekSettings = CmekSettings.fromAmino(object.cmek_settings); + } + if (object.update_mask !== undefined && object.update_mask !== null) { + message.updateMask = FieldMask.fromAmino(object.update_mask); + } + return message; + }, + toAmino(message: UpdateCmekSettingsRequest): UpdateCmekSettingsRequestAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + obj.cmek_settings = message.cmekSettings ? CmekSettings.toAmino(message.cmekSettings) : undefined; + obj.update_mask = message.updateMask ? FieldMask.toAmino(message.updateMask) : undefined; + return obj; + }, + fromAminoMsg(object: UpdateCmekSettingsRequestAminoMsg): UpdateCmekSettingsRequest { + return UpdateCmekSettingsRequest.fromAmino(object.value); + }, + fromProtoMsg(message: UpdateCmekSettingsRequestProtoMsg): UpdateCmekSettingsRequest { + return UpdateCmekSettingsRequest.decode(message.value); + }, + toProto(message: UpdateCmekSettingsRequest): Uint8Array { + return UpdateCmekSettingsRequest.encode(message).finish(); + }, + toProtoMsg(message: UpdateCmekSettingsRequest): UpdateCmekSettingsRequestProtoMsg { + return { + typeUrl: "/google.logging.v2.UpdateCmekSettingsRequest", + value: UpdateCmekSettingsRequest.encode(message).finish() + }; + } +}; +function createBaseCmekSettings(): CmekSettings { + return { + name: "", + kmsKeyName: "", + serviceAccountId: "" + }; +} +export const CmekSettings = { + typeUrl: "/google.logging.v2.CmekSettings", + encode(message: CmekSettings, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + if (message.kmsKeyName !== undefined) { + writer.uint32(18).string(message.kmsKeyName); + } + if (message.serviceAccountId !== undefined) { + writer.uint32(26).string(message.serviceAccountId); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): CmekSettings { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCmekSettings(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.kmsKeyName = reader.string(); + break; + case 3: + message.serviceAccountId = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): CmekSettings { + const obj = createBaseCmekSettings(); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.kmsKeyName)) obj.kmsKeyName = String(object.kmsKeyName); + if (isSet(object.serviceAccountId)) obj.serviceAccountId = String(object.serviceAccountId); + return obj; + }, + toJSON(message: CmekSettings): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.kmsKeyName !== undefined && (obj.kmsKeyName = message.kmsKeyName); + message.serviceAccountId !== undefined && (obj.serviceAccountId = message.serviceAccountId); + return obj; + }, + fromPartial(object: DeepPartial): CmekSettings { + const message = createBaseCmekSettings(); + message.name = object.name ?? ""; + message.kmsKeyName = object.kmsKeyName ?? ""; + message.serviceAccountId = object.serviceAccountId ?? ""; + return message; + }, + fromSDK(object: CmekSettingsSDKType): CmekSettings { + return { + name: object?.name, + kmsKeyName: object?.kms_key_name, + serviceAccountId: object?.service_account_id + }; + }, + fromSDKJSON(object: any): CmekSettingsSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + kms_key_name: isSet(object.kms_key_name) ? String(object.kms_key_name) : "", + service_account_id: isSet(object.service_account_id) ? String(object.service_account_id) : "" + }; + }, + toSDK(message: CmekSettings): CmekSettingsSDKType { + const obj: any = {}; + obj.name = message.name; + obj.kms_key_name = message.kmsKeyName; + obj.service_account_id = message.serviceAccountId; + return obj; + }, + fromAmino(object: CmekSettingsAmino): CmekSettings { + const message = createBaseCmekSettings(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + if (object.kms_key_name !== undefined && object.kms_key_name !== null) { + message.kmsKeyName = object.kms_key_name; + } + if (object.service_account_id !== undefined && object.service_account_id !== null) { + message.serviceAccountId = object.service_account_id; + } + return message; + }, + toAmino(message: CmekSettings): CmekSettingsAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + obj.kms_key_name = message.kmsKeyName === "" ? undefined : message.kmsKeyName; + obj.service_account_id = message.serviceAccountId === "" ? undefined : message.serviceAccountId; + return obj; + }, + fromAminoMsg(object: CmekSettingsAminoMsg): CmekSettings { + return CmekSettings.fromAmino(object.value); + }, + fromProtoMsg(message: CmekSettingsProtoMsg): CmekSettings { + return CmekSettings.decode(message.value); + }, + toProto(message: CmekSettings): Uint8Array { + return CmekSettings.encode(message).finish(); + }, + toProtoMsg(message: CmekSettings): CmekSettingsProtoMsg { + return { + typeUrl: "/google.logging.v2.CmekSettings", + value: CmekSettings.encode(message).finish() + }; + } +}; +function createBaseGetSettingsRequest(): GetSettingsRequest { + return { + name: "" + }; +} +export const GetSettingsRequest = { + typeUrl: "/google.logging.v2.GetSettingsRequest", + encode(message: GetSettingsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GetSettingsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGetSettingsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GetSettingsRequest { + const obj = createBaseGetSettingsRequest(); + if (isSet(object.name)) obj.name = String(object.name); + return obj; + }, + toJSON(message: GetSettingsRequest): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + return obj; + }, + fromPartial(object: DeepPartial): GetSettingsRequest { + const message = createBaseGetSettingsRequest(); + message.name = object.name ?? ""; + return message; + }, + fromSDK(object: GetSettingsRequestSDKType): GetSettingsRequest { + return { + name: object?.name + }; + }, + fromSDKJSON(object: any): GetSettingsRequestSDKType { + return { + name: isSet(object.name) ? String(object.name) : "" + }; + }, + toSDK(message: GetSettingsRequest): GetSettingsRequestSDKType { + const obj: any = {}; + obj.name = message.name; + return obj; + }, + fromAmino(object: GetSettingsRequestAmino): GetSettingsRequest { + const message = createBaseGetSettingsRequest(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + return message; + }, + toAmino(message: GetSettingsRequest): GetSettingsRequestAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + return obj; + }, + fromAminoMsg(object: GetSettingsRequestAminoMsg): GetSettingsRequest { + return GetSettingsRequest.fromAmino(object.value); + }, + fromProtoMsg(message: GetSettingsRequestProtoMsg): GetSettingsRequest { + return GetSettingsRequest.decode(message.value); + }, + toProto(message: GetSettingsRequest): Uint8Array { + return GetSettingsRequest.encode(message).finish(); + }, + toProtoMsg(message: GetSettingsRequest): GetSettingsRequestProtoMsg { + return { + typeUrl: "/google.logging.v2.GetSettingsRequest", + value: GetSettingsRequest.encode(message).finish() + }; + } +}; +function createBaseUpdateSettingsRequest(): UpdateSettingsRequest { + return { + name: "", + settings: undefined, + updateMask: undefined + }; +} +export const UpdateSettingsRequest = { + typeUrl: "/google.logging.v2.UpdateSettingsRequest", + encode(message: UpdateSettingsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + if (message.settings !== undefined) { + Settings.encode(message.settings, writer.uint32(18).fork()).ldelim(); + } + if (message.updateMask !== undefined) { + FieldMask.encode(message.updateMask, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): UpdateSettingsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseUpdateSettingsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.settings = Settings.decode(reader, reader.uint32()); + break; + case 3: + message.updateMask = FieldMask.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): UpdateSettingsRequest { + const obj = createBaseUpdateSettingsRequest(); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.settings)) obj.settings = Settings.fromJSON(object.settings); + if (isSet(object.updateMask)) obj.updateMask = FieldMask.fromJSON(object.updateMask); + return obj; + }, + toJSON(message: UpdateSettingsRequest): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.settings !== undefined && (obj.settings = message.settings ? Settings.toJSON(message.settings) : undefined); + message.updateMask !== undefined && (obj.updateMask = message.updateMask ? FieldMask.toJSON(message.updateMask) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): UpdateSettingsRequest { + const message = createBaseUpdateSettingsRequest(); + message.name = object.name ?? ""; + if (object.settings !== undefined && object.settings !== null) { + message.settings = Settings.fromPartial(object.settings); + } + if (object.updateMask !== undefined && object.updateMask !== null) { + message.updateMask = FieldMask.fromPartial(object.updateMask); + } + return message; + }, + fromSDK(object: UpdateSettingsRequestSDKType): UpdateSettingsRequest { + return { + name: object?.name, + settings: object.settings ? Settings.fromSDK(object.settings) : undefined, + updateMask: object.update_mask ? FieldMask.fromSDK(object.update_mask) : undefined + }; + }, + fromSDKJSON(object: any): UpdateSettingsRequestSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + settings: isSet(object.settings) ? Settings.fromSDKJSON(object.settings) : undefined, + update_mask: isSet(object.update_mask) ? FieldMask.fromSDKJSON(object.update_mask) : undefined + }; + }, + toSDK(message: UpdateSettingsRequest): UpdateSettingsRequestSDKType { + const obj: any = {}; + obj.name = message.name; + message.settings !== undefined && (obj.settings = message.settings ? Settings.toSDK(message.settings) : undefined); + message.updateMask !== undefined && (obj.update_mask = message.updateMask ? FieldMask.toSDK(message.updateMask) : undefined); + return obj; + }, + fromAmino(object: UpdateSettingsRequestAmino): UpdateSettingsRequest { + const message = createBaseUpdateSettingsRequest(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + if (object.settings !== undefined && object.settings !== null) { + message.settings = Settings.fromAmino(object.settings); + } + if (object.update_mask !== undefined && object.update_mask !== null) { + message.updateMask = FieldMask.fromAmino(object.update_mask); + } + return message; + }, + toAmino(message: UpdateSettingsRequest): UpdateSettingsRequestAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + obj.settings = message.settings ? Settings.toAmino(message.settings) : undefined; + obj.update_mask = message.updateMask ? FieldMask.toAmino(message.updateMask) : undefined; + return obj; + }, + fromAminoMsg(object: UpdateSettingsRequestAminoMsg): UpdateSettingsRequest { + return UpdateSettingsRequest.fromAmino(object.value); + }, + fromProtoMsg(message: UpdateSettingsRequestProtoMsg): UpdateSettingsRequest { + return UpdateSettingsRequest.decode(message.value); + }, + toProto(message: UpdateSettingsRequest): Uint8Array { + return UpdateSettingsRequest.encode(message).finish(); + }, + toProtoMsg(message: UpdateSettingsRequest): UpdateSettingsRequestProtoMsg { + return { + typeUrl: "/google.logging.v2.UpdateSettingsRequest", + value: UpdateSettingsRequest.encode(message).finish() + }; + } +}; +function createBaseSettings(): Settings { + return { + name: "", + kmsKeyName: "", + kmsServiceAccountId: "", + storageLocation: "", + disableDefaultSink: false + }; +} +export const Settings = { + typeUrl: "/google.logging.v2.Settings", + encode(message: Settings, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + if (message.kmsKeyName !== undefined) { + writer.uint32(18).string(message.kmsKeyName); + } + if (message.kmsServiceAccountId !== undefined) { + writer.uint32(26).string(message.kmsServiceAccountId); + } + if (message.storageLocation !== undefined) { + writer.uint32(34).string(message.storageLocation); + } + if (message.disableDefaultSink !== undefined) { + writer.uint32(40).bool(message.disableDefaultSink); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Settings { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseSettings(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.kmsKeyName = reader.string(); + break; + case 3: + message.kmsServiceAccountId = reader.string(); + break; + case 4: + message.storageLocation = reader.string(); + break; + case 5: + message.disableDefaultSink = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Settings { + const obj = createBaseSettings(); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.kmsKeyName)) obj.kmsKeyName = String(object.kmsKeyName); + if (isSet(object.kmsServiceAccountId)) obj.kmsServiceAccountId = String(object.kmsServiceAccountId); + if (isSet(object.storageLocation)) obj.storageLocation = String(object.storageLocation); + if (isSet(object.disableDefaultSink)) obj.disableDefaultSink = Boolean(object.disableDefaultSink); + return obj; + }, + toJSON(message: Settings): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.kmsKeyName !== undefined && (obj.kmsKeyName = message.kmsKeyName); + message.kmsServiceAccountId !== undefined && (obj.kmsServiceAccountId = message.kmsServiceAccountId); + message.storageLocation !== undefined && (obj.storageLocation = message.storageLocation); + message.disableDefaultSink !== undefined && (obj.disableDefaultSink = message.disableDefaultSink); + return obj; + }, + fromPartial(object: DeepPartial): Settings { + const message = createBaseSettings(); + message.name = object.name ?? ""; + message.kmsKeyName = object.kmsKeyName ?? ""; + message.kmsServiceAccountId = object.kmsServiceAccountId ?? ""; + message.storageLocation = object.storageLocation ?? ""; + message.disableDefaultSink = object.disableDefaultSink ?? false; + return message; + }, + fromSDK(object: SettingsSDKType): Settings { + return { + name: object?.name, + kmsKeyName: object?.kms_key_name, + kmsServiceAccountId: object?.kms_service_account_id, + storageLocation: object?.storage_location, + disableDefaultSink: object?.disable_default_sink + }; + }, + fromSDKJSON(object: any): SettingsSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + kms_key_name: isSet(object.kms_key_name) ? String(object.kms_key_name) : "", + kms_service_account_id: isSet(object.kms_service_account_id) ? String(object.kms_service_account_id) : "", + storage_location: isSet(object.storage_location) ? String(object.storage_location) : "", + disable_default_sink: isSet(object.disable_default_sink) ? Boolean(object.disable_default_sink) : false + }; + }, + toSDK(message: Settings): SettingsSDKType { + const obj: any = {}; + obj.name = message.name; + obj.kms_key_name = message.kmsKeyName; + obj.kms_service_account_id = message.kmsServiceAccountId; + obj.storage_location = message.storageLocation; + obj.disable_default_sink = message.disableDefaultSink; + return obj; + }, + fromAmino(object: SettingsAmino): Settings { + const message = createBaseSettings(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + if (object.kms_key_name !== undefined && object.kms_key_name !== null) { + message.kmsKeyName = object.kms_key_name; + } + if (object.kms_service_account_id !== undefined && object.kms_service_account_id !== null) { + message.kmsServiceAccountId = object.kms_service_account_id; + } + if (object.storage_location !== undefined && object.storage_location !== null) { + message.storageLocation = object.storage_location; + } + if (object.disable_default_sink !== undefined && object.disable_default_sink !== null) { + message.disableDefaultSink = object.disable_default_sink; + } + return message; + }, + toAmino(message: Settings): SettingsAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + obj.kms_key_name = message.kmsKeyName === "" ? undefined : message.kmsKeyName; + obj.kms_service_account_id = message.kmsServiceAccountId === "" ? undefined : message.kmsServiceAccountId; + obj.storage_location = message.storageLocation === "" ? undefined : message.storageLocation; + obj.disable_default_sink = message.disableDefaultSink === false ? undefined : message.disableDefaultSink; + return obj; + }, + fromAminoMsg(object: SettingsAminoMsg): Settings { + return Settings.fromAmino(object.value); + }, + fromProtoMsg(message: SettingsProtoMsg): Settings { + return Settings.decode(message.value); + }, + toProto(message: Settings): Uint8Array { + return Settings.encode(message).finish(); + }, + toProtoMsg(message: Settings): SettingsProtoMsg { + return { + typeUrl: "/google.logging.v2.Settings", + value: Settings.encode(message).finish() + }; + } +}; +function createBaseCopyLogEntriesRequest(): CopyLogEntriesRequest { + return { + name: "", + filter: "", + destination: "" + }; +} +export const CopyLogEntriesRequest = { + typeUrl: "/google.logging.v2.CopyLogEntriesRequest", + encode(message: CopyLogEntriesRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + if (message.filter !== undefined) { + writer.uint32(26).string(message.filter); + } + if (message.destination !== undefined) { + writer.uint32(34).string(message.destination); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): CopyLogEntriesRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCopyLogEntriesRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 3: + message.filter = reader.string(); + break; + case 4: + message.destination = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): CopyLogEntriesRequest { + const obj = createBaseCopyLogEntriesRequest(); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.filter)) obj.filter = String(object.filter); + if (isSet(object.destination)) obj.destination = String(object.destination); + return obj; + }, + toJSON(message: CopyLogEntriesRequest): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.filter !== undefined && (obj.filter = message.filter); + message.destination !== undefined && (obj.destination = message.destination); + return obj; + }, + fromPartial(object: DeepPartial): CopyLogEntriesRequest { + const message = createBaseCopyLogEntriesRequest(); + message.name = object.name ?? ""; + message.filter = object.filter ?? ""; + message.destination = object.destination ?? ""; + return message; + }, + fromSDK(object: CopyLogEntriesRequestSDKType): CopyLogEntriesRequest { + return { + name: object?.name, + filter: object?.filter, + destination: object?.destination + }; + }, + fromSDKJSON(object: any): CopyLogEntriesRequestSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + filter: isSet(object.filter) ? String(object.filter) : "", + destination: isSet(object.destination) ? String(object.destination) : "" + }; + }, + toSDK(message: CopyLogEntriesRequest): CopyLogEntriesRequestSDKType { + const obj: any = {}; + obj.name = message.name; + obj.filter = message.filter; + obj.destination = message.destination; + return obj; + }, + fromAmino(object: CopyLogEntriesRequestAmino): CopyLogEntriesRequest { + const message = createBaseCopyLogEntriesRequest(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + if (object.filter !== undefined && object.filter !== null) { + message.filter = object.filter; + } + if (object.destination !== undefined && object.destination !== null) { + message.destination = object.destination; + } + return message; + }, + toAmino(message: CopyLogEntriesRequest): CopyLogEntriesRequestAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + obj.filter = message.filter === "" ? undefined : message.filter; + obj.destination = message.destination === "" ? undefined : message.destination; + return obj; + }, + fromAminoMsg(object: CopyLogEntriesRequestAminoMsg): CopyLogEntriesRequest { + return CopyLogEntriesRequest.fromAmino(object.value); + }, + fromProtoMsg(message: CopyLogEntriesRequestProtoMsg): CopyLogEntriesRequest { + return CopyLogEntriesRequest.decode(message.value); + }, + toProto(message: CopyLogEntriesRequest): Uint8Array { + return CopyLogEntriesRequest.encode(message).finish(); + }, + toProtoMsg(message: CopyLogEntriesRequest): CopyLogEntriesRequestProtoMsg { + return { + typeUrl: "/google.logging.v2.CopyLogEntriesRequest", + value: CopyLogEntriesRequest.encode(message).finish() + }; + } +}; +function createBaseCopyLogEntriesMetadata(): CopyLogEntriesMetadata { + return { + startTime: undefined, + endTime: undefined, + state: 0, + cancellationRequested: false, + request: undefined, + progress: 0, + writerIdentity: "" + }; +} +export const CopyLogEntriesMetadata = { + typeUrl: "/google.logging.v2.CopyLogEntriesMetadata", + encode(message: CopyLogEntriesMetadata, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.startTime !== undefined) { + Timestamp.encode(toTimestamp(message.startTime), writer.uint32(10).fork()).ldelim(); + } + if (message.endTime !== undefined) { + Timestamp.encode(toTimestamp(message.endTime), writer.uint32(18).fork()).ldelim(); + } + if (message.state !== 0) { + writer.uint32(24).int32(message.state); + } + if (message.cancellationRequested !== undefined) { + writer.uint32(32).bool(message.cancellationRequested); + } + if (message.request !== undefined) { + CopyLogEntriesRequest.encode(message.request, writer.uint32(42).fork()).ldelim(); + } + if (message.progress !== undefined) { + writer.uint32(48).int32(message.progress); + } + if (message.writerIdentity !== undefined) { + writer.uint32(58).string(message.writerIdentity); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): CopyLogEntriesMetadata { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCopyLogEntriesMetadata(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.startTime = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + break; + case 2: + message.endTime = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + break; + case 3: + message.state = (reader.int32() as any); + break; + case 4: + message.cancellationRequested = reader.bool(); + break; + case 5: + message.request = CopyLogEntriesRequest.decode(reader, reader.uint32()); + break; + case 6: + message.progress = reader.int32(); + break; + case 7: + message.writerIdentity = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): CopyLogEntriesMetadata { + const obj = createBaseCopyLogEntriesMetadata(); + if (isSet(object.startTime)) obj.startTime = new Date(object.startTime); + if (isSet(object.endTime)) obj.endTime = new Date(object.endTime); + if (isSet(object.state)) obj.state = operationStateFromJSON(object.state); + if (isSet(object.cancellationRequested)) obj.cancellationRequested = Boolean(object.cancellationRequested); + if (isSet(object.request)) obj.request = CopyLogEntriesRequest.fromJSON(object.request); + if (isSet(object.progress)) obj.progress = Number(object.progress); + if (isSet(object.writerIdentity)) obj.writerIdentity = String(object.writerIdentity); + return obj; + }, + toJSON(message: CopyLogEntriesMetadata): JsonSafe { + const obj: any = {}; + message.startTime !== undefined && (obj.startTime = message.startTime.toISOString()); + message.endTime !== undefined && (obj.endTime = message.endTime.toISOString()); + message.state !== undefined && (obj.state = operationStateToJSON(message.state)); + message.cancellationRequested !== undefined && (obj.cancellationRequested = message.cancellationRequested); + message.request !== undefined && (obj.request = message.request ? CopyLogEntriesRequest.toJSON(message.request) : undefined); + message.progress !== undefined && (obj.progress = Math.round(message.progress)); + message.writerIdentity !== undefined && (obj.writerIdentity = message.writerIdentity); + return obj; + }, + fromPartial(object: DeepPartial): CopyLogEntriesMetadata { + const message = createBaseCopyLogEntriesMetadata(); + message.startTime = object.startTime ?? undefined; + message.endTime = object.endTime ?? undefined; + message.state = object.state ?? 0; + message.cancellationRequested = object.cancellationRequested ?? false; + if (object.request !== undefined && object.request !== null) { + message.request = CopyLogEntriesRequest.fromPartial(object.request); + } + message.progress = object.progress ?? 0; + message.writerIdentity = object.writerIdentity ?? ""; + return message; + }, + fromSDK(object: CopyLogEntriesMetadataSDKType): CopyLogEntriesMetadata { + return { + startTime: object.start_time ?? undefined, + endTime: object.end_time ?? undefined, + state: isSet(object.state) ? operationStateFromJSON(object.state) : -1, + cancellationRequested: object?.cancellation_requested, + request: object.request ? CopyLogEntriesRequest.fromSDK(object.request) : undefined, + progress: object?.progress, + writerIdentity: object?.writer_identity + }; + }, + fromSDKJSON(object: any): CopyLogEntriesMetadataSDKType { + return { + start_time: isSet(object.start_time) ? new Date(object.start_time) : undefined, + end_time: isSet(object.end_time) ? new Date(object.end_time) : undefined, + state: isSet(object.state) ? operationStateFromJSON(object.state) : -1, + cancellation_requested: isSet(object.cancellation_requested) ? Boolean(object.cancellation_requested) : false, + request: isSet(object.request) ? CopyLogEntriesRequest.fromSDKJSON(object.request) : undefined, + progress: isSet(object.progress) ? Number(object.progress) : 0, + writer_identity: isSet(object.writer_identity) ? String(object.writer_identity) : "" + }; + }, + toSDK(message: CopyLogEntriesMetadata): CopyLogEntriesMetadataSDKType { + const obj: any = {}; + message.startTime !== undefined && (obj.start_time = message.startTime ?? undefined); + message.endTime !== undefined && (obj.end_time = message.endTime ?? undefined); + message.state !== undefined && (obj.state = operationStateToJSON(message.state)); + obj.cancellation_requested = message.cancellationRequested; + message.request !== undefined && (obj.request = message.request ? CopyLogEntriesRequest.toSDK(message.request) : undefined); + obj.progress = message.progress; + obj.writer_identity = message.writerIdentity; + return obj; + }, + fromAmino(object: CopyLogEntriesMetadataAmino): CopyLogEntriesMetadata { + const message = createBaseCopyLogEntriesMetadata(); + if (object.start_time !== undefined && object.start_time !== null) { + message.startTime = fromTimestamp(Timestamp.fromAmino(object.start_time)); + } + if (object.end_time !== undefined && object.end_time !== null) { + message.endTime = fromTimestamp(Timestamp.fromAmino(object.end_time)); + } + if (object.state !== undefined && object.state !== null) { + message.state = object.state; + } + if (object.cancellation_requested !== undefined && object.cancellation_requested !== null) { + message.cancellationRequested = object.cancellation_requested; + } + if (object.request !== undefined && object.request !== null) { + message.request = CopyLogEntriesRequest.fromAmino(object.request); + } + if (object.progress !== undefined && object.progress !== null) { + message.progress = object.progress; + } + if (object.writer_identity !== undefined && object.writer_identity !== null) { + message.writerIdentity = object.writer_identity; + } + return message; + }, + toAmino(message: CopyLogEntriesMetadata): CopyLogEntriesMetadataAmino { + const obj: any = {}; + obj.start_time = message.startTime ? Timestamp.toAmino(toTimestamp(message.startTime)) : undefined; + obj.end_time = message.endTime ? Timestamp.toAmino(toTimestamp(message.endTime)) : undefined; + obj.state = message.state === 0 ? undefined : message.state; + obj.cancellation_requested = message.cancellationRequested === false ? undefined : message.cancellationRequested; + obj.request = message.request ? CopyLogEntriesRequest.toAmino(message.request) : undefined; + obj.progress = message.progress === 0 ? undefined : message.progress; + obj.writer_identity = message.writerIdentity === "" ? undefined : message.writerIdentity; + return obj; + }, + fromAminoMsg(object: CopyLogEntriesMetadataAminoMsg): CopyLogEntriesMetadata { + return CopyLogEntriesMetadata.fromAmino(object.value); + }, + fromProtoMsg(message: CopyLogEntriesMetadataProtoMsg): CopyLogEntriesMetadata { + return CopyLogEntriesMetadata.decode(message.value); + }, + toProto(message: CopyLogEntriesMetadata): Uint8Array { + return CopyLogEntriesMetadata.encode(message).finish(); + }, + toProtoMsg(message: CopyLogEntriesMetadata): CopyLogEntriesMetadataProtoMsg { + return { + typeUrl: "/google.logging.v2.CopyLogEntriesMetadata", + value: CopyLogEntriesMetadata.encode(message).finish() + }; + } +}; +function createBaseCopyLogEntriesResponse(): CopyLogEntriesResponse { + return { + logEntriesCopiedCount: BigInt(0) + }; +} +export const CopyLogEntriesResponse = { + typeUrl: "/google.logging.v2.CopyLogEntriesResponse", + encode(message: CopyLogEntriesResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.logEntriesCopiedCount !== undefined) { + writer.uint32(8).int64(message.logEntriesCopiedCount); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): CopyLogEntriesResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCopyLogEntriesResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.logEntriesCopiedCount = reader.int64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): CopyLogEntriesResponse { + const obj = createBaseCopyLogEntriesResponse(); + if (isSet(object.logEntriesCopiedCount)) obj.logEntriesCopiedCount = BigInt(object.logEntriesCopiedCount.toString()); + return obj; + }, + toJSON(message: CopyLogEntriesResponse): JsonSafe { + const obj: any = {}; + message.logEntriesCopiedCount !== undefined && (obj.logEntriesCopiedCount = (message.logEntriesCopiedCount || BigInt(0)).toString()); + return obj; + }, + fromPartial(object: DeepPartial): CopyLogEntriesResponse { + const message = createBaseCopyLogEntriesResponse(); + if (object.logEntriesCopiedCount !== undefined && object.logEntriesCopiedCount !== null) { + message.logEntriesCopiedCount = BigInt(object.logEntriesCopiedCount.toString()); + } + return message; + }, + fromSDK(object: CopyLogEntriesResponseSDKType): CopyLogEntriesResponse { + return { + logEntriesCopiedCount: object?.log_entries_copied_count + }; + }, + fromSDKJSON(object: any): CopyLogEntriesResponseSDKType { + return { + log_entries_copied_count: isSet(object.log_entries_copied_count) ? BigInt(object.log_entries_copied_count.toString()) : BigInt(0) + }; + }, + toSDK(message: CopyLogEntriesResponse): CopyLogEntriesResponseSDKType { + const obj: any = {}; + obj.log_entries_copied_count = message.logEntriesCopiedCount; + return obj; + }, + fromAmino(object: CopyLogEntriesResponseAmino): CopyLogEntriesResponse { + const message = createBaseCopyLogEntriesResponse(); + if (object.log_entries_copied_count !== undefined && object.log_entries_copied_count !== null) { + message.logEntriesCopiedCount = BigInt(object.log_entries_copied_count); + } + return message; + }, + toAmino(message: CopyLogEntriesResponse): CopyLogEntriesResponseAmino { + const obj: any = {}; + obj.log_entries_copied_count = message.logEntriesCopiedCount !== BigInt(0) ? message.logEntriesCopiedCount?.toString() : undefined; + return obj; + }, + fromAminoMsg(object: CopyLogEntriesResponseAminoMsg): CopyLogEntriesResponse { + return CopyLogEntriesResponse.fromAmino(object.value); + }, + fromProtoMsg(message: CopyLogEntriesResponseProtoMsg): CopyLogEntriesResponse { + return CopyLogEntriesResponse.decode(message.value); + }, + toProto(message: CopyLogEntriesResponse): Uint8Array { + return CopyLogEntriesResponse.encode(message).finish(); + }, + toProtoMsg(message: CopyLogEntriesResponse): CopyLogEntriesResponseProtoMsg { + return { + typeUrl: "/google.logging.v2.CopyLogEntriesResponse", + value: CopyLogEntriesResponse.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/logging/v2/logging_metrics.ts b/__fixtures__/v-next/outputicjsdeps/google/logging/v2/logging_metrics.ts new file mode 100644 index 0000000000..d963191aba --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/logging/v2/logging_metrics.ts @@ -0,0 +1,1388 @@ +import { MetricDescriptor, MetricDescriptorSDKType } from "../../api/metric.js"; +import { Distribution_BucketOptions, Distribution_BucketOptionsSDKType } from "../../api/distribution.js"; +import { Timestamp, TimestampSDKType } from "../../protobuf/timestamp.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial, toTimestamp, fromTimestamp, isObject } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "google.logging.v2"; +/** Logging API version. */ +export enum LogMetric_ApiVersion { + /** V2 - Logging API v2. */ + V2 = 0, + /** V1 - Logging API v1. */ + V1 = 1, + UNRECOGNIZED = -1, +} +export const LogMetric_ApiVersionSDKType = LogMetric_ApiVersion; +export function logMetric_ApiVersionFromJSON(object: any): LogMetric_ApiVersion { + switch (object) { + case 0: + case "V2": + return LogMetric_ApiVersion.V2; + case 1: + case "V1": + return LogMetric_ApiVersion.V1; + case -1: + case "UNRECOGNIZED": + default: + return LogMetric_ApiVersion.UNRECOGNIZED; + } +} +export function logMetric_ApiVersionToJSON(object: LogMetric_ApiVersion): string { + switch (object) { + case LogMetric_ApiVersion.V2: + return "V2"; + case LogMetric_ApiVersion.V1: + return "V1"; + case LogMetric_ApiVersion.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +export interface LogMetric_LabelExtractorsEntry { + key: string; + value: string; +} +export interface LogMetric_LabelExtractorsEntryProtoMsg { + typeUrl: string; + value: Uint8Array; +} +export interface LogMetric_LabelExtractorsEntrySDKType { + key: string; + value: string; +} +/** + * Describes a logs-based metric. The value of the metric is the number of log + * entries that match a logs filter in a given time interval. + * + * Logs-based metrics can also be used to extract values from logs and create a + * distribution of the values. The distribution records the statistics of the + * extracted values along with an optional histogram of the values as specified + * by the bucket options. + */ +export interface LogMetric { + /** + * Required. The client-assigned metric identifier. + * Examples: `"error_count"`, `"nginx/requests"`. + * + * Metric identifiers are limited to 100 characters and can include only the + * following characters: `A-Z`, `a-z`, `0-9`, and the special characters + * `_-.,+!*',()%/`. The forward-slash character (`/`) denotes a hierarchy of + * name pieces, and it cannot be the first character of the name. + * + * This field is the `[METRIC_ID]` part of a metric resource name in the + * format "projects/[PROJECT_ID]/metrics/[METRIC_ID]". Example: If the + * resource name of a metric is + * `"projects/my-project/metrics/nginx%2Frequests"`, this field's value is + * `"nginx/requests"`. + */ + name: string; + /** + * Optional. A description of this metric, which is used in documentation. + * The maximum length of the description is 8000 characters. + */ + description: string; + /** + * Required. An [advanced logs + * filter](https://cloud.google.com/logging/docs/view/advanced_filters) which + * is used to match log entries. Example: + * + * "resource.type=gae_app AND severity>=ERROR" + * + * The maximum length of the filter is 20000 characters. + */ + filter: string; + /** + * Optional. If set to True, then this metric is disabled and it does not + * generate any points. + */ + disabled: boolean; + /** + * Optional. The metric descriptor associated with the logs-based metric. + * If unspecified, it uses a default metric descriptor with a DELTA metric + * kind, INT64 value type, with no labels and a unit of "1". Such a metric + * counts the number of log entries matching the `filter` expression. + * + * The `name`, `type`, and `description` fields in the `metric_descriptor` + * are output only, and is constructed using the `name` and `description` + * field in the LogMetric. + * + * To create a logs-based metric that records a distribution of log values, a + * DELTA metric kind with a DISTRIBUTION value type must be used along with + * a `value_extractor` expression in the LogMetric. + * + * Each label in the metric descriptor must have a matching label + * name as the key and an extractor expression as the value in the + * `label_extractors` map. + * + * The `metric_kind` and `value_type` fields in the `metric_descriptor` cannot + * be updated once initially configured. New labels can be added in the + * `metric_descriptor`, but existing labels cannot be modified except for + * their description. + */ + metricDescriptor?: MetricDescriptor; + /** + * Optional. A `value_extractor` is required when using a distribution + * logs-based metric to extract the values to record from a log entry. + * Two functions are supported for value extraction: `EXTRACT(field)` or + * `REGEXP_EXTRACT(field, regex)`. The argument are: + * 1. field: The name of the log entry field from which the value is to be + * extracted. + * 2. regex: A regular expression using the Google RE2 syntax + * (https://github.com/google/re2/wiki/Syntax) with a single capture + * group to extract data from the specified log entry field. The value + * of the field is converted to a string before applying the regex. + * It is an error to specify a regex that does not include exactly one + * capture group. + * + * The result of the extraction must be convertible to a double type, as the + * distribution always records double values. If either the extraction or + * the conversion to double fails, then those values are not recorded in the + * distribution. + * + * Example: `REGEXP_EXTRACT(jsonPayload.request, ".*quantity=(\d+).*")` + */ + valueExtractor: string; + /** + * Optional. A map from a label key string to an extractor expression which is + * used to extract data from a log entry field and assign as the label value. + * Each label key specified in the LabelDescriptor must have an associated + * extractor expression in this map. The syntax of the extractor expression + * is the same as for the `value_extractor` field. + * + * The extracted value is converted to the type defined in the label + * descriptor. If the either the extraction or the type conversion fails, + * the label will have a default value. The default value for a string + * label is an empty string, for an integer label its 0, and for a boolean + * label its `false`. + * + * Note that there are upper bounds on the maximum number of labels and the + * number of active time series that are allowed in a project. + */ + labelExtractors: { + [key: string]: string; + }; + /** + * Optional. The `bucket_options` are required when the logs-based metric is + * using a DISTRIBUTION value type and it describes the bucket boundaries + * used to create a histogram of the extracted values. + */ + bucketOptions?: Distribution_BucketOptions; + /** + * Output only. The creation timestamp of the metric. + * + * This field may not be present for older metrics. + */ + createTime?: Date; + /** + * Output only. The last update timestamp of the metric. + * + * This field may not be present for older metrics. + */ + updateTime?: Date; + /** + * Deprecated. The API version that created or updated this metric. + * The v2 format is used by default and cannot be changed. + */ + /** @deprecated */ + version: LogMetric_ApiVersion; +} +export interface LogMetricProtoMsg { + typeUrl: "/google.logging.v2.LogMetric"; + value: Uint8Array; +} +/** + * Describes a logs-based metric. The value of the metric is the number of log + * entries that match a logs filter in a given time interval. + * + * Logs-based metrics can also be used to extract values from logs and create a + * distribution of the values. The distribution records the statistics of the + * extracted values along with an optional histogram of the values as specified + * by the bucket options. + */ +export interface LogMetricSDKType { + name: string; + description: string; + filter: string; + disabled: boolean; + metric_descriptor?: MetricDescriptorSDKType; + value_extractor: string; + label_extractors: { + [key: string]: string; + }; + bucket_options?: Distribution_BucketOptionsSDKType; + create_time?: Date; + update_time?: Date; + /** @deprecated */ + version: LogMetric_ApiVersion; +} +/** The parameters to ListLogMetrics. */ +export interface ListLogMetricsRequest { + /** + * Required. The name of the project containing the metrics: + * + * "projects/[PROJECT_ID]" + */ + parent: string; + /** + * Optional. If present, then retrieve the next batch of results from the + * preceding call to this method. `pageToken` must be the value of + * `nextPageToken` from the previous response. The values of other method + * parameters should be identical to those in the previous call. + */ + pageToken: string; + /** + * Optional. The maximum number of results to return from this request. + * Non-positive values are ignored. The presence of `nextPageToken` in the + * response indicates that more results might be available. + */ + pageSize: number; +} +export interface ListLogMetricsRequestProtoMsg { + typeUrl: "/google.logging.v2.ListLogMetricsRequest"; + value: Uint8Array; +} +/** The parameters to ListLogMetrics. */ +export interface ListLogMetricsRequestSDKType { + parent: string; + page_token: string; + page_size: number; +} +/** Result returned from ListLogMetrics. */ +export interface ListLogMetricsResponse { + /** A list of logs-based metrics. */ + metrics: LogMetric[]; + /** + * If there might be more results than appear in this response, then + * `nextPageToken` is included. To get the next set of results, call this + * method again using the value of `nextPageToken` as `pageToken`. + */ + nextPageToken: string; +} +export interface ListLogMetricsResponseProtoMsg { + typeUrl: "/google.logging.v2.ListLogMetricsResponse"; + value: Uint8Array; +} +/** Result returned from ListLogMetrics. */ +export interface ListLogMetricsResponseSDKType { + metrics: LogMetricSDKType[]; + next_page_token: string; +} +/** The parameters to GetLogMetric. */ +export interface GetLogMetricRequest { + /** + * Required. The resource name of the desired metric: + * + * "projects/[PROJECT_ID]/metrics/[METRIC_ID]" + */ + metricName: string; +} +export interface GetLogMetricRequestProtoMsg { + typeUrl: "/google.logging.v2.GetLogMetricRequest"; + value: Uint8Array; +} +/** The parameters to GetLogMetric. */ +export interface GetLogMetricRequestSDKType { + metric_name: string; +} +/** The parameters to CreateLogMetric. */ +export interface CreateLogMetricRequest { + /** + * Required. The resource name of the project in which to create the metric: + * + * "projects/[PROJECT_ID]" + * + * The new metric must be provided in the request. + */ + parent: string; + /** + * Required. The new logs-based metric, which must not have an identifier that + * already exists. + */ + metric?: LogMetric; +} +export interface CreateLogMetricRequestProtoMsg { + typeUrl: "/google.logging.v2.CreateLogMetricRequest"; + value: Uint8Array; +} +/** The parameters to CreateLogMetric. */ +export interface CreateLogMetricRequestSDKType { + parent: string; + metric?: LogMetricSDKType; +} +/** The parameters to UpdateLogMetric. */ +export interface UpdateLogMetricRequest { + /** + * Required. The resource name of the metric to update: + * + * "projects/[PROJECT_ID]/metrics/[METRIC_ID]" + * + * The updated metric must be provided in the request and it's + * `name` field must be the same as `[METRIC_ID]` If the metric + * does not exist in `[PROJECT_ID]`, then a new metric is created. + */ + metricName: string; + /** Required. The updated metric. */ + metric?: LogMetric; +} +export interface UpdateLogMetricRequestProtoMsg { + typeUrl: "/google.logging.v2.UpdateLogMetricRequest"; + value: Uint8Array; +} +/** The parameters to UpdateLogMetric. */ +export interface UpdateLogMetricRequestSDKType { + metric_name: string; + metric?: LogMetricSDKType; +} +/** The parameters to DeleteLogMetric. */ +export interface DeleteLogMetricRequest { + /** + * Required. The resource name of the metric to delete: + * + * "projects/[PROJECT_ID]/metrics/[METRIC_ID]" + */ + metricName: string; +} +export interface DeleteLogMetricRequestProtoMsg { + typeUrl: "/google.logging.v2.DeleteLogMetricRequest"; + value: Uint8Array; +} +/** The parameters to DeleteLogMetric. */ +export interface DeleteLogMetricRequestSDKType { + metric_name: string; +} +function createBaseLogMetric_LabelExtractorsEntry(): LogMetric_LabelExtractorsEntry { + return { + key: "", + value: "" + }; +} +export const LogMetric_LabelExtractorsEntry = { + encode(message: LogMetric_LabelExtractorsEntry, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.key !== undefined) { + writer.uint32(10).string(message.key); + } + if (message.value !== undefined) { + writer.uint32(18).string(message.value); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): LogMetric_LabelExtractorsEntry { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseLogMetric_LabelExtractorsEntry(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.string(); + break; + case 2: + message.value = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): LogMetric_LabelExtractorsEntry { + const obj = createBaseLogMetric_LabelExtractorsEntry(); + if (isSet(object.key)) obj.key = String(object.key); + if (isSet(object.value)) obj.value = String(object.value); + return obj; + }, + toJSON(message: LogMetric_LabelExtractorsEntry): JsonSafe { + const obj: any = {}; + message.key !== undefined && (obj.key = message.key); + message.value !== undefined && (obj.value = message.value); + return obj; + }, + fromPartial(object: DeepPartial): LogMetric_LabelExtractorsEntry { + const message = createBaseLogMetric_LabelExtractorsEntry(); + message.key = object.key ?? ""; + message.value = object.value ?? ""; + return message; + }, + fromSDK(object: LogMetric_LabelExtractorsEntrySDKType): LogMetric_LabelExtractorsEntry { + return { + key: object?.key, + value: object?.value + }; + }, + fromSDKJSON(object: any): LogMetric_LabelExtractorsEntrySDKType { + return { + key: isSet(object.key) ? String(object.key) : "", + value: isSet(object.value) ? String(object.value) : "" + }; + }, + toSDK(message: LogMetric_LabelExtractorsEntry): LogMetric_LabelExtractorsEntrySDKType { + const obj: any = {}; + obj.key = message.key; + obj.value = message.value; + return obj; + }, + fromAmino(object: LogMetric_LabelExtractorsEntryAmino): LogMetric_LabelExtractorsEntry { + const message = createBaseLogMetric_LabelExtractorsEntry(); + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } + if (object.value !== undefined && object.value !== null) { + message.value = object.value; + } + return message; + }, + toAmino(message: LogMetric_LabelExtractorsEntry): LogMetric_LabelExtractorsEntryAmino { + const obj: any = {}; + obj.key = message.key === "" ? undefined : message.key; + obj.value = message.value === "" ? undefined : message.value; + return obj; + }, + fromAminoMsg(object: LogMetric_LabelExtractorsEntryAminoMsg): LogMetric_LabelExtractorsEntry { + return LogMetric_LabelExtractorsEntry.fromAmino(object.value); + }, + fromProtoMsg(message: LogMetric_LabelExtractorsEntryProtoMsg): LogMetric_LabelExtractorsEntry { + return LogMetric_LabelExtractorsEntry.decode(message.value); + }, + toProto(message: LogMetric_LabelExtractorsEntry): Uint8Array { + return LogMetric_LabelExtractorsEntry.encode(message).finish(); + } +}; +function createBaseLogMetric(): LogMetric { + return { + name: "", + description: "", + filter: "", + disabled: false, + metricDescriptor: undefined, + valueExtractor: "", + labelExtractors: {}, + bucketOptions: undefined, + createTime: undefined, + updateTime: undefined, + version: 0 + }; +} +export const LogMetric = { + typeUrl: "/google.logging.v2.LogMetric", + encode(message: LogMetric, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + if (message.description !== undefined) { + writer.uint32(18).string(message.description); + } + if (message.filter !== undefined) { + writer.uint32(26).string(message.filter); + } + if (message.disabled !== undefined) { + writer.uint32(96).bool(message.disabled); + } + if (message.metricDescriptor !== undefined) { + MetricDescriptor.encode(message.metricDescriptor, writer.uint32(42).fork()).ldelim(); + } + if (message.valueExtractor !== undefined) { + writer.uint32(50).string(message.valueExtractor); + } + Object.entries(message.labelExtractors).forEach(([key, value]) => { + LogMetric_LabelExtractorsEntry.encode({ + key: (key as any), + value + }, writer.uint32(58).fork()).ldelim(); + }); + if (message.bucketOptions !== undefined) { + Distribution_BucketOptions.encode(message.bucketOptions, writer.uint32(66).fork()).ldelim(); + } + if (message.createTime !== undefined) { + Timestamp.encode(toTimestamp(message.createTime), writer.uint32(74).fork()).ldelim(); + } + if (message.updateTime !== undefined) { + Timestamp.encode(toTimestamp(message.updateTime), writer.uint32(82).fork()).ldelim(); + } + if (message.version !== 0) { + writer.uint32(32).int32(message.version); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): LogMetric { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseLogMetric(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.description = reader.string(); + break; + case 3: + message.filter = reader.string(); + break; + case 12: + message.disabled = reader.bool(); + break; + case 5: + message.metricDescriptor = MetricDescriptor.decode(reader, reader.uint32()); + break; + case 6: + message.valueExtractor = reader.string(); + break; + case 7: + const entry7 = LogMetric_LabelExtractorsEntry.decode(reader, reader.uint32()); + if (entry7.value !== undefined) { + message.labelExtractors[entry7.key] = entry7.value; + } + break; + case 8: + message.bucketOptions = Distribution_BucketOptions.decode(reader, reader.uint32()); + break; + case 9: + message.createTime = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + break; + case 10: + message.updateTime = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + break; + case 4: + message.version = (reader.int32() as any); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): LogMetric { + const obj = createBaseLogMetric(); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.description)) obj.description = String(object.description); + if (isSet(object.filter)) obj.filter = String(object.filter); + if (isSet(object.disabled)) obj.disabled = Boolean(object.disabled); + if (isSet(object.metricDescriptor)) obj.metricDescriptor = MetricDescriptor.fromJSON(object.metricDescriptor); + if (isSet(object.valueExtractor)) obj.valueExtractor = String(object.valueExtractor); + if (isObject(object.labelExtractors)) obj.labelExtractors = Object.entries(object.labelExtractors).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + acc[key] = String(value); + return acc; + }, {}); + if (isSet(object.bucketOptions)) obj.bucketOptions = Distribution_BucketOptions.fromJSON(object.bucketOptions); + if (isSet(object.createTime)) obj.createTime = new Date(object.createTime); + if (isSet(object.updateTime)) obj.updateTime = new Date(object.updateTime); + if (isSet(object.version)) obj.version = logMetric_ApiVersionFromJSON(object.version); + return obj; + }, + toJSON(message: LogMetric): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.description !== undefined && (obj.description = message.description); + message.filter !== undefined && (obj.filter = message.filter); + message.disabled !== undefined && (obj.disabled = message.disabled); + message.metricDescriptor !== undefined && (obj.metricDescriptor = message.metricDescriptor ? MetricDescriptor.toJSON(message.metricDescriptor) : undefined); + message.valueExtractor !== undefined && (obj.valueExtractor = message.valueExtractor); + obj.labelExtractors = {}; + if (message.labelExtractors) { + Object.entries(message.labelExtractors).forEach(([k, v]) => { + obj.labelExtractors[k] = v; + }); + } + message.bucketOptions !== undefined && (obj.bucketOptions = message.bucketOptions ? Distribution_BucketOptions.toJSON(message.bucketOptions) : undefined); + message.createTime !== undefined && (obj.createTime = message.createTime.toISOString()); + message.updateTime !== undefined && (obj.updateTime = message.updateTime.toISOString()); + message.version !== undefined && (obj.version = logMetric_ApiVersionToJSON(message.version)); + return obj; + }, + fromPartial(object: DeepPartial): LogMetric { + const message = createBaseLogMetric(); + message.name = object.name ?? ""; + message.description = object.description ?? ""; + message.filter = object.filter ?? ""; + message.disabled = object.disabled ?? false; + if (object.metricDescriptor !== undefined && object.metricDescriptor !== null) { + message.metricDescriptor = MetricDescriptor.fromPartial(object.metricDescriptor); + } + message.valueExtractor = object.valueExtractor ?? ""; + message.labelExtractors = Object.entries(object.labelExtractors ?? {}).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + if (value !== undefined) { + acc[key] = String(value); + } + return acc; + }, {}); + if (object.bucketOptions !== undefined && object.bucketOptions !== null) { + message.bucketOptions = Distribution_BucketOptions.fromPartial(object.bucketOptions); + } + message.createTime = object.createTime ?? undefined; + message.updateTime = object.updateTime ?? undefined; + message.version = object.version ?? 0; + return message; + }, + fromSDK(object: LogMetricSDKType): LogMetric { + return { + name: object?.name, + description: object?.description, + filter: object?.filter, + disabled: object?.disabled, + metricDescriptor: object.metric_descriptor ? MetricDescriptor.fromSDK(object.metric_descriptor) : undefined, + valueExtractor: object?.value_extractor, + labelExtractors: isObject(object.label_extractors) ? Object.entries(object.label_extractors).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + acc[key] = String(value); + return acc; + }, {}) : {}, + bucketOptions: object.bucket_options ? Distribution_BucketOptions.fromSDK(object.bucket_options) : undefined, + createTime: object.create_time ?? undefined, + updateTime: object.update_time ?? undefined, + version: isSet(object.version) ? logMetric_ApiVersionFromJSON(object.version) : -1 + }; + }, + fromSDKJSON(object: any): LogMetricSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + description: isSet(object.description) ? String(object.description) : "", + filter: isSet(object.filter) ? String(object.filter) : "", + disabled: isSet(object.disabled) ? Boolean(object.disabled) : false, + metric_descriptor: isSet(object.metric_descriptor) ? MetricDescriptor.fromSDKJSON(object.metric_descriptor) : undefined, + value_extractor: isSet(object.value_extractor) ? String(object.value_extractor) : "", + label_extractors: isObject(object.label_extractors) ? Object.entries(object.label_extractors).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + acc[key] = String(value); + return acc; + }, {}) : {}, + bucket_options: isSet(object.bucket_options) ? Distribution_BucketOptions.fromSDKJSON(object.bucket_options) : undefined, + create_time: isSet(object.create_time) ? new Date(object.create_time) : undefined, + update_time: isSet(object.update_time) ? new Date(object.update_time) : undefined, + version: isSet(object.version) ? logMetric_ApiVersionFromJSON(object.version) : -1 + }; + }, + toSDK(message: LogMetric): LogMetricSDKType { + const obj: any = {}; + obj.name = message.name; + obj.description = message.description; + obj.filter = message.filter; + obj.disabled = message.disabled; + message.metricDescriptor !== undefined && (obj.metric_descriptor = message.metricDescriptor ? MetricDescriptor.toSDK(message.metricDescriptor) : undefined); + obj.value_extractor = message.valueExtractor; + obj.label_extractors = {}; + if (message.labelExtractors) { + Object.entries(message.labelExtractors).forEach(([k, v]) => { + obj.label_extractors[k] = v; + }); + } + message.bucketOptions !== undefined && (obj.bucket_options = message.bucketOptions ? Distribution_BucketOptions.toSDK(message.bucketOptions) : undefined); + message.createTime !== undefined && (obj.create_time = message.createTime ?? undefined); + message.updateTime !== undefined && (obj.update_time = message.updateTime ?? undefined); + message.version !== undefined && (obj.version = logMetric_ApiVersionToJSON(message.version)); + return obj; + }, + fromAmino(object: LogMetricAmino): LogMetric { + const message = createBaseLogMetric(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } + if (object.filter !== undefined && object.filter !== null) { + message.filter = object.filter; + } + if (object.disabled !== undefined && object.disabled !== null) { + message.disabled = object.disabled; + } + if (object.metric_descriptor !== undefined && object.metric_descriptor !== null) { + message.metricDescriptor = MetricDescriptor.fromAmino(object.metric_descriptor); + } + if (object.value_extractor !== undefined && object.value_extractor !== null) { + message.valueExtractor = object.value_extractor; + } + message.labelExtractors = Object.entries(object.label_extractors ?? {}).reduce<{ + [key: string]: string; + }>((acc, [key, value]) => { + if (value !== undefined) { + acc[key] = String(value); + } + return acc; + }, {}); + if (object.bucket_options !== undefined && object.bucket_options !== null) { + message.bucketOptions = Distribution_BucketOptions.fromAmino(object.bucket_options); + } + if (object.create_time !== undefined && object.create_time !== null) { + message.createTime = fromTimestamp(Timestamp.fromAmino(object.create_time)); + } + if (object.update_time !== undefined && object.update_time !== null) { + message.updateTime = fromTimestamp(Timestamp.fromAmino(object.update_time)); + } + if (object.version !== undefined && object.version !== null) { + message.version = object.version; + } + return message; + }, + toAmino(message: LogMetric): LogMetricAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + obj.description = message.description === "" ? undefined : message.description; + obj.filter = message.filter === "" ? undefined : message.filter; + obj.disabled = message.disabled === false ? undefined : message.disabled; + obj.metric_descriptor = message.metricDescriptor ? MetricDescriptor.toAmino(message.metricDescriptor) : undefined; + obj.value_extractor = message.valueExtractor === "" ? undefined : message.valueExtractor; + obj.label_extractors = {}; + if (message.labelExtractors) { + Object.entries(message.labelExtractors).forEach(([k, v]) => { + obj.label_extractors[k] = v; + }); + } + obj.bucket_options = message.bucketOptions ? Distribution_BucketOptions.toAmino(message.bucketOptions) : undefined; + obj.create_time = message.createTime ? Timestamp.toAmino(toTimestamp(message.createTime)) : undefined; + obj.update_time = message.updateTime ? Timestamp.toAmino(toTimestamp(message.updateTime)) : undefined; + obj.version = message.version === 0 ? undefined : message.version; + return obj; + }, + fromAminoMsg(object: LogMetricAminoMsg): LogMetric { + return LogMetric.fromAmino(object.value); + }, + fromProtoMsg(message: LogMetricProtoMsg): LogMetric { + return LogMetric.decode(message.value); + }, + toProto(message: LogMetric): Uint8Array { + return LogMetric.encode(message).finish(); + }, + toProtoMsg(message: LogMetric): LogMetricProtoMsg { + return { + typeUrl: "/google.logging.v2.LogMetric", + value: LogMetric.encode(message).finish() + }; + } +}; +function createBaseListLogMetricsRequest(): ListLogMetricsRequest { + return { + parent: "", + pageToken: "", + pageSize: 0 + }; +} +export const ListLogMetricsRequest = { + typeUrl: "/google.logging.v2.ListLogMetricsRequest", + encode(message: ListLogMetricsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.parent !== undefined) { + writer.uint32(10).string(message.parent); + } + if (message.pageToken !== undefined) { + writer.uint32(18).string(message.pageToken); + } + if (message.pageSize !== undefined) { + writer.uint32(24).int32(message.pageSize); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ListLogMetricsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseListLogMetricsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.parent = reader.string(); + break; + case 2: + message.pageToken = reader.string(); + break; + case 3: + message.pageSize = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ListLogMetricsRequest { + const obj = createBaseListLogMetricsRequest(); + if (isSet(object.parent)) obj.parent = String(object.parent); + if (isSet(object.pageToken)) obj.pageToken = String(object.pageToken); + if (isSet(object.pageSize)) obj.pageSize = Number(object.pageSize); + return obj; + }, + toJSON(message: ListLogMetricsRequest): JsonSafe { + const obj: any = {}; + message.parent !== undefined && (obj.parent = message.parent); + message.pageToken !== undefined && (obj.pageToken = message.pageToken); + message.pageSize !== undefined && (obj.pageSize = Math.round(message.pageSize)); + return obj; + }, + fromPartial(object: DeepPartial): ListLogMetricsRequest { + const message = createBaseListLogMetricsRequest(); + message.parent = object.parent ?? ""; + message.pageToken = object.pageToken ?? ""; + message.pageSize = object.pageSize ?? 0; + return message; + }, + fromSDK(object: ListLogMetricsRequestSDKType): ListLogMetricsRequest { + return { + parent: object?.parent, + pageToken: object?.page_token, + pageSize: object?.page_size + }; + }, + fromSDKJSON(object: any): ListLogMetricsRequestSDKType { + return { + parent: isSet(object.parent) ? String(object.parent) : "", + page_token: isSet(object.page_token) ? String(object.page_token) : "", + page_size: isSet(object.page_size) ? Number(object.page_size) : 0 + }; + }, + toSDK(message: ListLogMetricsRequest): ListLogMetricsRequestSDKType { + const obj: any = {}; + obj.parent = message.parent; + obj.page_token = message.pageToken; + obj.page_size = message.pageSize; + return obj; + }, + fromAmino(object: ListLogMetricsRequestAmino): ListLogMetricsRequest { + const message = createBaseListLogMetricsRequest(); + if (object.parent !== undefined && object.parent !== null) { + message.parent = object.parent; + } + if (object.page_token !== undefined && object.page_token !== null) { + message.pageToken = object.page_token; + } + if (object.page_size !== undefined && object.page_size !== null) { + message.pageSize = object.page_size; + } + return message; + }, + toAmino(message: ListLogMetricsRequest): ListLogMetricsRequestAmino { + const obj: any = {}; + obj.parent = message.parent === "" ? undefined : message.parent; + obj.page_token = message.pageToken === "" ? undefined : message.pageToken; + obj.page_size = message.pageSize === 0 ? undefined : message.pageSize; + return obj; + }, + fromAminoMsg(object: ListLogMetricsRequestAminoMsg): ListLogMetricsRequest { + return ListLogMetricsRequest.fromAmino(object.value); + }, + fromProtoMsg(message: ListLogMetricsRequestProtoMsg): ListLogMetricsRequest { + return ListLogMetricsRequest.decode(message.value); + }, + toProto(message: ListLogMetricsRequest): Uint8Array { + return ListLogMetricsRequest.encode(message).finish(); + }, + toProtoMsg(message: ListLogMetricsRequest): ListLogMetricsRequestProtoMsg { + return { + typeUrl: "/google.logging.v2.ListLogMetricsRequest", + value: ListLogMetricsRequest.encode(message).finish() + }; + } +}; +function createBaseListLogMetricsResponse(): ListLogMetricsResponse { + return { + metrics: [], + nextPageToken: "" + }; +} +export const ListLogMetricsResponse = { + typeUrl: "/google.logging.v2.ListLogMetricsResponse", + encode(message: ListLogMetricsResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.metrics) { + LogMetric.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.nextPageToken !== undefined) { + writer.uint32(18).string(message.nextPageToken); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ListLogMetricsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseListLogMetricsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.metrics.push(LogMetric.decode(reader, reader.uint32())); + break; + case 2: + message.nextPageToken = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ListLogMetricsResponse { + const obj = createBaseListLogMetricsResponse(); + if (Array.isArray(object?.metrics)) obj.metrics = object.metrics.map((e: any) => LogMetric.fromJSON(e)); + if (isSet(object.nextPageToken)) obj.nextPageToken = String(object.nextPageToken); + return obj; + }, + toJSON(message: ListLogMetricsResponse): JsonSafe { + const obj: any = {}; + if (message.metrics) { + obj.metrics = message.metrics.map(e => e ? LogMetric.toJSON(e) : undefined); + } else { + obj.metrics = []; + } + message.nextPageToken !== undefined && (obj.nextPageToken = message.nextPageToken); + return obj; + }, + fromPartial(object: DeepPartial): ListLogMetricsResponse { + const message = createBaseListLogMetricsResponse(); + message.metrics = object.metrics?.map(e => LogMetric.fromPartial(e)) || []; + message.nextPageToken = object.nextPageToken ?? ""; + return message; + }, + fromSDK(object: ListLogMetricsResponseSDKType): ListLogMetricsResponse { + return { + metrics: Array.isArray(object?.metrics) ? object.metrics.map((e: any) => LogMetric.fromSDK(e)) : [], + nextPageToken: object?.next_page_token + }; + }, + fromSDKJSON(object: any): ListLogMetricsResponseSDKType { + return { + metrics: Array.isArray(object?.metrics) ? object.metrics.map((e: any) => LogMetric.fromSDKJSON(e)) : [], + next_page_token: isSet(object.next_page_token) ? String(object.next_page_token) : "" + }; + }, + toSDK(message: ListLogMetricsResponse): ListLogMetricsResponseSDKType { + const obj: any = {}; + if (message.metrics) { + obj.metrics = message.metrics.map(e => e ? LogMetric.toSDK(e) : undefined); + } else { + obj.metrics = []; + } + obj.next_page_token = message.nextPageToken; + return obj; + }, + fromAmino(object: ListLogMetricsResponseAmino): ListLogMetricsResponse { + const message = createBaseListLogMetricsResponse(); + message.metrics = object.metrics?.map(e => LogMetric.fromAmino(e)) || []; + if (object.next_page_token !== undefined && object.next_page_token !== null) { + message.nextPageToken = object.next_page_token; + } + return message; + }, + toAmino(message: ListLogMetricsResponse): ListLogMetricsResponseAmino { + const obj: any = {}; + if (message.metrics) { + obj.metrics = message.metrics.map(e => e ? LogMetric.toAmino(e) : undefined); + } else { + obj.metrics = message.metrics; + } + obj.next_page_token = message.nextPageToken === "" ? undefined : message.nextPageToken; + return obj; + }, + fromAminoMsg(object: ListLogMetricsResponseAminoMsg): ListLogMetricsResponse { + return ListLogMetricsResponse.fromAmino(object.value); + }, + fromProtoMsg(message: ListLogMetricsResponseProtoMsg): ListLogMetricsResponse { + return ListLogMetricsResponse.decode(message.value); + }, + toProto(message: ListLogMetricsResponse): Uint8Array { + return ListLogMetricsResponse.encode(message).finish(); + }, + toProtoMsg(message: ListLogMetricsResponse): ListLogMetricsResponseProtoMsg { + return { + typeUrl: "/google.logging.v2.ListLogMetricsResponse", + value: ListLogMetricsResponse.encode(message).finish() + }; + } +}; +function createBaseGetLogMetricRequest(): GetLogMetricRequest { + return { + metricName: "" + }; +} +export const GetLogMetricRequest = { + typeUrl: "/google.logging.v2.GetLogMetricRequest", + encode(message: GetLogMetricRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.metricName !== undefined) { + writer.uint32(10).string(message.metricName); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GetLogMetricRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGetLogMetricRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.metricName = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GetLogMetricRequest { + const obj = createBaseGetLogMetricRequest(); + if (isSet(object.metricName)) obj.metricName = String(object.metricName); + return obj; + }, + toJSON(message: GetLogMetricRequest): JsonSafe { + const obj: any = {}; + message.metricName !== undefined && (obj.metricName = message.metricName); + return obj; + }, + fromPartial(object: DeepPartial): GetLogMetricRequest { + const message = createBaseGetLogMetricRequest(); + message.metricName = object.metricName ?? ""; + return message; + }, + fromSDK(object: GetLogMetricRequestSDKType): GetLogMetricRequest { + return { + metricName: object?.metric_name + }; + }, + fromSDKJSON(object: any): GetLogMetricRequestSDKType { + return { + metric_name: isSet(object.metric_name) ? String(object.metric_name) : "" + }; + }, + toSDK(message: GetLogMetricRequest): GetLogMetricRequestSDKType { + const obj: any = {}; + obj.metric_name = message.metricName; + return obj; + }, + fromAmino(object: GetLogMetricRequestAmino): GetLogMetricRequest { + const message = createBaseGetLogMetricRequest(); + if (object.metric_name !== undefined && object.metric_name !== null) { + message.metricName = object.metric_name; + } + return message; + }, + toAmino(message: GetLogMetricRequest): GetLogMetricRequestAmino { + const obj: any = {}; + obj.metric_name = message.metricName === "" ? undefined : message.metricName; + return obj; + }, + fromAminoMsg(object: GetLogMetricRequestAminoMsg): GetLogMetricRequest { + return GetLogMetricRequest.fromAmino(object.value); + }, + fromProtoMsg(message: GetLogMetricRequestProtoMsg): GetLogMetricRequest { + return GetLogMetricRequest.decode(message.value); + }, + toProto(message: GetLogMetricRequest): Uint8Array { + return GetLogMetricRequest.encode(message).finish(); + }, + toProtoMsg(message: GetLogMetricRequest): GetLogMetricRequestProtoMsg { + return { + typeUrl: "/google.logging.v2.GetLogMetricRequest", + value: GetLogMetricRequest.encode(message).finish() + }; + } +}; +function createBaseCreateLogMetricRequest(): CreateLogMetricRequest { + return { + parent: "", + metric: undefined + }; +} +export const CreateLogMetricRequest = { + typeUrl: "/google.logging.v2.CreateLogMetricRequest", + encode(message: CreateLogMetricRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.parent !== undefined) { + writer.uint32(10).string(message.parent); + } + if (message.metric !== undefined) { + LogMetric.encode(message.metric, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): CreateLogMetricRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCreateLogMetricRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.parent = reader.string(); + break; + case 2: + message.metric = LogMetric.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): CreateLogMetricRequest { + const obj = createBaseCreateLogMetricRequest(); + if (isSet(object.parent)) obj.parent = String(object.parent); + if (isSet(object.metric)) obj.metric = LogMetric.fromJSON(object.metric); + return obj; + }, + toJSON(message: CreateLogMetricRequest): JsonSafe { + const obj: any = {}; + message.parent !== undefined && (obj.parent = message.parent); + message.metric !== undefined && (obj.metric = message.metric ? LogMetric.toJSON(message.metric) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): CreateLogMetricRequest { + const message = createBaseCreateLogMetricRequest(); + message.parent = object.parent ?? ""; + if (object.metric !== undefined && object.metric !== null) { + message.metric = LogMetric.fromPartial(object.metric); + } + return message; + }, + fromSDK(object: CreateLogMetricRequestSDKType): CreateLogMetricRequest { + return { + parent: object?.parent, + metric: object.metric ? LogMetric.fromSDK(object.metric) : undefined + }; + }, + fromSDKJSON(object: any): CreateLogMetricRequestSDKType { + return { + parent: isSet(object.parent) ? String(object.parent) : "", + metric: isSet(object.metric) ? LogMetric.fromSDKJSON(object.metric) : undefined + }; + }, + toSDK(message: CreateLogMetricRequest): CreateLogMetricRequestSDKType { + const obj: any = {}; + obj.parent = message.parent; + message.metric !== undefined && (obj.metric = message.metric ? LogMetric.toSDK(message.metric) : undefined); + return obj; + }, + fromAmino(object: CreateLogMetricRequestAmino): CreateLogMetricRequest { + const message = createBaseCreateLogMetricRequest(); + if (object.parent !== undefined && object.parent !== null) { + message.parent = object.parent; + } + if (object.metric !== undefined && object.metric !== null) { + message.metric = LogMetric.fromAmino(object.metric); + } + return message; + }, + toAmino(message: CreateLogMetricRequest): CreateLogMetricRequestAmino { + const obj: any = {}; + obj.parent = message.parent === "" ? undefined : message.parent; + obj.metric = message.metric ? LogMetric.toAmino(message.metric) : undefined; + return obj; + }, + fromAminoMsg(object: CreateLogMetricRequestAminoMsg): CreateLogMetricRequest { + return CreateLogMetricRequest.fromAmino(object.value); + }, + fromProtoMsg(message: CreateLogMetricRequestProtoMsg): CreateLogMetricRequest { + return CreateLogMetricRequest.decode(message.value); + }, + toProto(message: CreateLogMetricRequest): Uint8Array { + return CreateLogMetricRequest.encode(message).finish(); + }, + toProtoMsg(message: CreateLogMetricRequest): CreateLogMetricRequestProtoMsg { + return { + typeUrl: "/google.logging.v2.CreateLogMetricRequest", + value: CreateLogMetricRequest.encode(message).finish() + }; + } +}; +function createBaseUpdateLogMetricRequest(): UpdateLogMetricRequest { + return { + metricName: "", + metric: undefined + }; +} +export const UpdateLogMetricRequest = { + typeUrl: "/google.logging.v2.UpdateLogMetricRequest", + encode(message: UpdateLogMetricRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.metricName !== undefined) { + writer.uint32(10).string(message.metricName); + } + if (message.metric !== undefined) { + LogMetric.encode(message.metric, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): UpdateLogMetricRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseUpdateLogMetricRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.metricName = reader.string(); + break; + case 2: + message.metric = LogMetric.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): UpdateLogMetricRequest { + const obj = createBaseUpdateLogMetricRequest(); + if (isSet(object.metricName)) obj.metricName = String(object.metricName); + if (isSet(object.metric)) obj.metric = LogMetric.fromJSON(object.metric); + return obj; + }, + toJSON(message: UpdateLogMetricRequest): JsonSafe { + const obj: any = {}; + message.metricName !== undefined && (obj.metricName = message.metricName); + message.metric !== undefined && (obj.metric = message.metric ? LogMetric.toJSON(message.metric) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): UpdateLogMetricRequest { + const message = createBaseUpdateLogMetricRequest(); + message.metricName = object.metricName ?? ""; + if (object.metric !== undefined && object.metric !== null) { + message.metric = LogMetric.fromPartial(object.metric); + } + return message; + }, + fromSDK(object: UpdateLogMetricRequestSDKType): UpdateLogMetricRequest { + return { + metricName: object?.metric_name, + metric: object.metric ? LogMetric.fromSDK(object.metric) : undefined + }; + }, + fromSDKJSON(object: any): UpdateLogMetricRequestSDKType { + return { + metric_name: isSet(object.metric_name) ? String(object.metric_name) : "", + metric: isSet(object.metric) ? LogMetric.fromSDKJSON(object.metric) : undefined + }; + }, + toSDK(message: UpdateLogMetricRequest): UpdateLogMetricRequestSDKType { + const obj: any = {}; + obj.metric_name = message.metricName; + message.metric !== undefined && (obj.metric = message.metric ? LogMetric.toSDK(message.metric) : undefined); + return obj; + }, + fromAmino(object: UpdateLogMetricRequestAmino): UpdateLogMetricRequest { + const message = createBaseUpdateLogMetricRequest(); + if (object.metric_name !== undefined && object.metric_name !== null) { + message.metricName = object.metric_name; + } + if (object.metric !== undefined && object.metric !== null) { + message.metric = LogMetric.fromAmino(object.metric); + } + return message; + }, + toAmino(message: UpdateLogMetricRequest): UpdateLogMetricRequestAmino { + const obj: any = {}; + obj.metric_name = message.metricName === "" ? undefined : message.metricName; + obj.metric = message.metric ? LogMetric.toAmino(message.metric) : undefined; + return obj; + }, + fromAminoMsg(object: UpdateLogMetricRequestAminoMsg): UpdateLogMetricRequest { + return UpdateLogMetricRequest.fromAmino(object.value); + }, + fromProtoMsg(message: UpdateLogMetricRequestProtoMsg): UpdateLogMetricRequest { + return UpdateLogMetricRequest.decode(message.value); + }, + toProto(message: UpdateLogMetricRequest): Uint8Array { + return UpdateLogMetricRequest.encode(message).finish(); + }, + toProtoMsg(message: UpdateLogMetricRequest): UpdateLogMetricRequestProtoMsg { + return { + typeUrl: "/google.logging.v2.UpdateLogMetricRequest", + value: UpdateLogMetricRequest.encode(message).finish() + }; + } +}; +function createBaseDeleteLogMetricRequest(): DeleteLogMetricRequest { + return { + metricName: "" + }; +} +export const DeleteLogMetricRequest = { + typeUrl: "/google.logging.v2.DeleteLogMetricRequest", + encode(message: DeleteLogMetricRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.metricName !== undefined) { + writer.uint32(10).string(message.metricName); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): DeleteLogMetricRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDeleteLogMetricRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.metricName = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): DeleteLogMetricRequest { + const obj = createBaseDeleteLogMetricRequest(); + if (isSet(object.metricName)) obj.metricName = String(object.metricName); + return obj; + }, + toJSON(message: DeleteLogMetricRequest): JsonSafe { + const obj: any = {}; + message.metricName !== undefined && (obj.metricName = message.metricName); + return obj; + }, + fromPartial(object: DeepPartial): DeleteLogMetricRequest { + const message = createBaseDeleteLogMetricRequest(); + message.metricName = object.metricName ?? ""; + return message; + }, + fromSDK(object: DeleteLogMetricRequestSDKType): DeleteLogMetricRequest { + return { + metricName: object?.metric_name + }; + }, + fromSDKJSON(object: any): DeleteLogMetricRequestSDKType { + return { + metric_name: isSet(object.metric_name) ? String(object.metric_name) : "" + }; + }, + toSDK(message: DeleteLogMetricRequest): DeleteLogMetricRequestSDKType { + const obj: any = {}; + obj.metric_name = message.metricName; + return obj; + }, + fromAmino(object: DeleteLogMetricRequestAmino): DeleteLogMetricRequest { + const message = createBaseDeleteLogMetricRequest(); + if (object.metric_name !== undefined && object.metric_name !== null) { + message.metricName = object.metric_name; + } + return message; + }, + toAmino(message: DeleteLogMetricRequest): DeleteLogMetricRequestAmino { + const obj: any = {}; + obj.metric_name = message.metricName === "" ? undefined : message.metricName; + return obj; + }, + fromAminoMsg(object: DeleteLogMetricRequestAminoMsg): DeleteLogMetricRequest { + return DeleteLogMetricRequest.fromAmino(object.value); + }, + fromProtoMsg(message: DeleteLogMetricRequestProtoMsg): DeleteLogMetricRequest { + return DeleteLogMetricRequest.decode(message.value); + }, + toProto(message: DeleteLogMetricRequest): Uint8Array { + return DeleteLogMetricRequest.encode(message).finish(); + }, + toProtoMsg(message: DeleteLogMetricRequest): DeleteLogMetricRequestProtoMsg { + return { + typeUrl: "/google.logging.v2.DeleteLogMetricRequest", + value: DeleteLogMetricRequest.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/longrunning/operations.ts b/__fixtures__/v-next/outputicjsdeps/google/longrunning/operations.ts new file mode 100644 index 0000000000..a096efd145 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/longrunning/operations.ts @@ -0,0 +1,1106 @@ +import { Duration, DurationSDKType } from "../protobuf/duration.js"; +import { Any, AnySDKType } from "../protobuf/any.js"; +import { Status, StatusSDKType } from "../rpc/status.js"; +import { BinaryReader, BinaryWriter } from "../../binary.js"; +import { isSet, DeepPartial } from "../../helpers.js"; +import { JsonSafe } from "../../json-safe.js"; +export const protobufPackage = "google.longrunning"; +/** + * This resource represents a long-running operation that is the result of a + * network API call. + */ +export interface Operation { + /** + * The server-assigned name, which is only unique within the same service that + * originally returns it. If you use the default HTTP mapping, the + * `name` should be a resource name ending with `operations/{unique_id}`. + */ + name: string; + /** + * Service-specific metadata associated with the operation. It typically + * contains progress information and common metadata such as create time. + * Some services might not provide such metadata. Any method that returns a + * long-running operation should document the metadata type, if any. + */ + metadata?: Any; + /** + * If the value is `false`, it means the operation is still in progress. + * If `true`, the operation is completed, and either `error` or `response` is + * available. + */ + done: boolean; + /** The error result of the operation in case of failure or cancellation. */ + error?: Status; + /** + * The normal response of the operation in case of success. If the original + * method returns no data on success, such as `Delete`, the response is + * `google.protobuf.Empty`. If the original method is standard + * `Get`/`Create`/`Update`, the response should be the resource. For other + * methods, the response should have the type `XxxResponse`, where `Xxx` + * is the original method name. For example, if the original method name + * is `TakeSnapshot()`, the inferred response type is + * `TakeSnapshotResponse`. + */ + response?: Any; +} +export interface OperationProtoMsg { + typeUrl: "/google.longrunning.Operation"; + value: Uint8Array; +} +/** + * This resource represents a long-running operation that is the result of a + * network API call. + */ +export interface OperationSDKType { + name: string; + metadata?: AnySDKType; + done: boolean; + error?: StatusSDKType; + response?: AnySDKType; +} +/** The request message for [Operations.GetOperation][google.longrunning.Operations.GetOperation]. */ +export interface GetOperationRequest { + /** The name of the operation resource. */ + name: string; +} +export interface GetOperationRequestProtoMsg { + typeUrl: "/google.longrunning.GetOperationRequest"; + value: Uint8Array; +} +/** The request message for [Operations.GetOperation][google.longrunning.Operations.GetOperation]. */ +export interface GetOperationRequestSDKType { + name: string; +} +/** The request message for [Operations.ListOperations][google.longrunning.Operations.ListOperations]. */ +export interface ListOperationsRequest { + /** The name of the operation's parent resource. */ + name: string; + /** The standard list filter. */ + filter: string; + /** The standard list page size. */ + pageSize: number; + /** The standard list page token. */ + pageToken: string; +} +export interface ListOperationsRequestProtoMsg { + typeUrl: "/google.longrunning.ListOperationsRequest"; + value: Uint8Array; +} +/** The request message for [Operations.ListOperations][google.longrunning.Operations.ListOperations]. */ +export interface ListOperationsRequestSDKType { + name: string; + filter: string; + page_size: number; + page_token: string; +} +/** The response message for [Operations.ListOperations][google.longrunning.Operations.ListOperations]. */ +export interface ListOperationsResponse { + /** A list of operations that matches the specified filter in the request. */ + operations: Operation[]; + /** The standard List next-page token. */ + nextPageToken: string; +} +export interface ListOperationsResponseProtoMsg { + typeUrl: "/google.longrunning.ListOperationsResponse"; + value: Uint8Array; +} +/** The response message for [Operations.ListOperations][google.longrunning.Operations.ListOperations]. */ +export interface ListOperationsResponseSDKType { + operations: OperationSDKType[]; + next_page_token: string; +} +/** The request message for [Operations.CancelOperation][google.longrunning.Operations.CancelOperation]. */ +export interface CancelOperationRequest { + /** The name of the operation resource to be cancelled. */ + name: string; +} +export interface CancelOperationRequestProtoMsg { + typeUrl: "/google.longrunning.CancelOperationRequest"; + value: Uint8Array; +} +/** The request message for [Operations.CancelOperation][google.longrunning.Operations.CancelOperation]. */ +export interface CancelOperationRequestSDKType { + name: string; +} +/** The request message for [Operations.DeleteOperation][google.longrunning.Operations.DeleteOperation]. */ +export interface DeleteOperationRequest { + /** The name of the operation resource to be deleted. */ + name: string; +} +export interface DeleteOperationRequestProtoMsg { + typeUrl: "/google.longrunning.DeleteOperationRequest"; + value: Uint8Array; +} +/** The request message for [Operations.DeleteOperation][google.longrunning.Operations.DeleteOperation]. */ +export interface DeleteOperationRequestSDKType { + name: string; +} +/** The request message for [Operations.WaitOperation][google.longrunning.Operations.WaitOperation]. */ +export interface WaitOperationRequest { + /** The name of the operation resource to wait on. */ + name: string; + /** + * The maximum duration to wait before timing out. If left blank, the wait + * will be at most the time permitted by the underlying HTTP/RPC protocol. + * If RPC context deadline is also specified, the shorter one will be used. + */ + timeout?: Duration; +} +export interface WaitOperationRequestProtoMsg { + typeUrl: "/google.longrunning.WaitOperationRequest"; + value: Uint8Array; +} +/** The request message for [Operations.WaitOperation][google.longrunning.Operations.WaitOperation]. */ +export interface WaitOperationRequestSDKType { + name: string; + timeout?: DurationSDKType; +} +/** + * A message representing the message types used by a long-running operation. + * + * Example: + * + * rpc LongRunningRecognize(LongRunningRecognizeRequest) + * returns (google.longrunning.Operation) { + * option (google.longrunning.operation_info) = { + * response_type: "LongRunningRecognizeResponse" + * metadata_type: "LongRunningRecognizeMetadata" + * }; + * } + */ +export interface OperationInfo { + /** + * Required. The message name of the primary return type for this + * long-running operation. + * This type will be used to deserialize the LRO's response. + * + * If the response is in a different package from the rpc, a fully-qualified + * message name must be used (e.g. `google.protobuf.Struct`). + * + * Note: Altering this value constitutes a breaking change. + */ + responseType: string; + /** + * Required. The message name of the metadata type for this long-running + * operation. + * + * If the response is in a different package from the rpc, a fully-qualified + * message name must be used (e.g. `google.protobuf.Struct`). + * + * Note: Altering this value constitutes a breaking change. + */ + metadataType: string; +} +export interface OperationInfoProtoMsg { + typeUrl: "/google.longrunning.OperationInfo"; + value: Uint8Array; +} +/** + * A message representing the message types used by a long-running operation. + * + * Example: + * + * rpc LongRunningRecognize(LongRunningRecognizeRequest) + * returns (google.longrunning.Operation) { + * option (google.longrunning.operation_info) = { + * response_type: "LongRunningRecognizeResponse" + * metadata_type: "LongRunningRecognizeMetadata" + * }; + * } + */ +export interface OperationInfoSDKType { + response_type: string; + metadata_type: string; +} +function createBaseOperation(): Operation { + return { + name: "", + metadata: undefined, + done: false, + error: undefined, + response: undefined + }; +} +export const Operation = { + typeUrl: "/google.longrunning.Operation", + encode(message: Operation, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + if (message.metadata !== undefined) { + Any.encode(message.metadata, writer.uint32(18).fork()).ldelim(); + } + if (message.done !== undefined) { + writer.uint32(24).bool(message.done); + } + if (message.error !== undefined) { + Status.encode(message.error, writer.uint32(34).fork()).ldelim(); + } + if (message.response !== undefined) { + Any.encode(message.response, writer.uint32(42).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Operation { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseOperation(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.metadata = Any.decode(reader, reader.uint32()); + break; + case 3: + message.done = reader.bool(); + break; + case 4: + message.error = Status.decode(reader, reader.uint32()); + break; + case 5: + message.response = Any.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Operation { + const obj = createBaseOperation(); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.metadata)) obj.metadata = Any.fromJSON(object.metadata); + if (isSet(object.done)) obj.done = Boolean(object.done); + if (isSet(object.error)) obj.error = Status.fromJSON(object.error); + if (isSet(object.response)) obj.response = Any.fromJSON(object.response); + return obj; + }, + toJSON(message: Operation): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.metadata !== undefined && (obj.metadata = message.metadata ? Any.toJSON(message.metadata) : undefined); + message.done !== undefined && (obj.done = message.done); + message.error !== undefined && (obj.error = message.error ? Status.toJSON(message.error) : undefined); + message.response !== undefined && (obj.response = message.response ? Any.toJSON(message.response) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): Operation { + const message = createBaseOperation(); + message.name = object.name ?? ""; + if (object.metadata !== undefined && object.metadata !== null) { + message.metadata = Any.fromPartial(object.metadata); + } + message.done = object.done ?? false; + if (object.error !== undefined && object.error !== null) { + message.error = Status.fromPartial(object.error); + } + if (object.response !== undefined && object.response !== null) { + message.response = Any.fromPartial(object.response); + } + return message; + }, + fromSDK(object: OperationSDKType): Operation { + return { + name: object?.name, + metadata: object.metadata ? Any.fromSDK(object.metadata) : undefined, + done: object?.done, + error: object.error ? Status.fromSDK(object.error) : undefined, + response: object.response ? Any.fromSDK(object.response) : undefined + }; + }, + fromSDKJSON(object: any): OperationSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + metadata: isSet(object.metadata) ? Any.fromSDKJSON(object.metadata) : undefined, + done: isSet(object.done) ? Boolean(object.done) : false, + error: isSet(object.error) ? Status.fromSDKJSON(object.error) : undefined, + response: isSet(object.response) ? Any.fromSDKJSON(object.response) : undefined + }; + }, + toSDK(message: Operation): OperationSDKType { + const obj: any = {}; + obj.name = message.name; + message.metadata !== undefined && (obj.metadata = message.metadata ? Any.toSDK(message.metadata) : undefined); + obj.done = message.done; + message.error !== undefined && (obj.error = message.error ? Status.toSDK(message.error) : undefined); + message.response !== undefined && (obj.response = message.response ? Any.toSDK(message.response) : undefined); + return obj; + }, + fromAmino(object: OperationAmino): Operation { + const message = createBaseOperation(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + if (object.metadata !== undefined && object.metadata !== null) { + message.metadata = Any.fromAmino(object.metadata); + } + if (object.done !== undefined && object.done !== null) { + message.done = object.done; + } + if (object.error !== undefined && object.error !== null) { + message.error = Status.fromAmino(object.error); + } + if (object.response !== undefined && object.response !== null) { + message.response = Any.fromAmino(object.response); + } + return message; + }, + toAmino(message: Operation): OperationAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + obj.metadata = message.metadata ? Any.toAmino(message.metadata) : undefined; + obj.done = message.done === false ? undefined : message.done; + obj.error = message.error ? Status.toAmino(message.error) : undefined; + obj.response = message.response ? Any.toAmino(message.response) : undefined; + return obj; + }, + fromAminoMsg(object: OperationAminoMsg): Operation { + return Operation.fromAmino(object.value); + }, + fromProtoMsg(message: OperationProtoMsg): Operation { + return Operation.decode(message.value); + }, + toProto(message: Operation): Uint8Array { + return Operation.encode(message).finish(); + }, + toProtoMsg(message: Operation): OperationProtoMsg { + return { + typeUrl: "/google.longrunning.Operation", + value: Operation.encode(message).finish() + }; + } +}; +function createBaseGetOperationRequest(): GetOperationRequest { + return { + name: "" + }; +} +export const GetOperationRequest = { + typeUrl: "/google.longrunning.GetOperationRequest", + encode(message: GetOperationRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GetOperationRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGetOperationRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GetOperationRequest { + const obj = createBaseGetOperationRequest(); + if (isSet(object.name)) obj.name = String(object.name); + return obj; + }, + toJSON(message: GetOperationRequest): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + return obj; + }, + fromPartial(object: DeepPartial): GetOperationRequest { + const message = createBaseGetOperationRequest(); + message.name = object.name ?? ""; + return message; + }, + fromSDK(object: GetOperationRequestSDKType): GetOperationRequest { + return { + name: object?.name + }; + }, + fromSDKJSON(object: any): GetOperationRequestSDKType { + return { + name: isSet(object.name) ? String(object.name) : "" + }; + }, + toSDK(message: GetOperationRequest): GetOperationRequestSDKType { + const obj: any = {}; + obj.name = message.name; + return obj; + }, + fromAmino(object: GetOperationRequestAmino): GetOperationRequest { + const message = createBaseGetOperationRequest(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + return message; + }, + toAmino(message: GetOperationRequest): GetOperationRequestAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + return obj; + }, + fromAminoMsg(object: GetOperationRequestAminoMsg): GetOperationRequest { + return GetOperationRequest.fromAmino(object.value); + }, + fromProtoMsg(message: GetOperationRequestProtoMsg): GetOperationRequest { + return GetOperationRequest.decode(message.value); + }, + toProto(message: GetOperationRequest): Uint8Array { + return GetOperationRequest.encode(message).finish(); + }, + toProtoMsg(message: GetOperationRequest): GetOperationRequestProtoMsg { + return { + typeUrl: "/google.longrunning.GetOperationRequest", + value: GetOperationRequest.encode(message).finish() + }; + } +}; +function createBaseListOperationsRequest(): ListOperationsRequest { + return { + name: "", + filter: "", + pageSize: 0, + pageToken: "" + }; +} +export const ListOperationsRequest = { + typeUrl: "/google.longrunning.ListOperationsRequest", + encode(message: ListOperationsRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(34).string(message.name); + } + if (message.filter !== undefined) { + writer.uint32(10).string(message.filter); + } + if (message.pageSize !== undefined) { + writer.uint32(16).int32(message.pageSize); + } + if (message.pageToken !== undefined) { + writer.uint32(26).string(message.pageToken); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ListOperationsRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseListOperationsRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 4: + message.name = reader.string(); + break; + case 1: + message.filter = reader.string(); + break; + case 2: + message.pageSize = reader.int32(); + break; + case 3: + message.pageToken = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ListOperationsRequest { + const obj = createBaseListOperationsRequest(); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.filter)) obj.filter = String(object.filter); + if (isSet(object.pageSize)) obj.pageSize = Number(object.pageSize); + if (isSet(object.pageToken)) obj.pageToken = String(object.pageToken); + return obj; + }, + toJSON(message: ListOperationsRequest): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.filter !== undefined && (obj.filter = message.filter); + message.pageSize !== undefined && (obj.pageSize = Math.round(message.pageSize)); + message.pageToken !== undefined && (obj.pageToken = message.pageToken); + return obj; + }, + fromPartial(object: DeepPartial): ListOperationsRequest { + const message = createBaseListOperationsRequest(); + message.name = object.name ?? ""; + message.filter = object.filter ?? ""; + message.pageSize = object.pageSize ?? 0; + message.pageToken = object.pageToken ?? ""; + return message; + }, + fromSDK(object: ListOperationsRequestSDKType): ListOperationsRequest { + return { + name: object?.name, + filter: object?.filter, + pageSize: object?.page_size, + pageToken: object?.page_token + }; + }, + fromSDKJSON(object: any): ListOperationsRequestSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + filter: isSet(object.filter) ? String(object.filter) : "", + page_size: isSet(object.page_size) ? Number(object.page_size) : 0, + page_token: isSet(object.page_token) ? String(object.page_token) : "" + }; + }, + toSDK(message: ListOperationsRequest): ListOperationsRequestSDKType { + const obj: any = {}; + obj.name = message.name; + obj.filter = message.filter; + obj.page_size = message.pageSize; + obj.page_token = message.pageToken; + return obj; + }, + fromAmino(object: ListOperationsRequestAmino): ListOperationsRequest { + const message = createBaseListOperationsRequest(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + if (object.filter !== undefined && object.filter !== null) { + message.filter = object.filter; + } + if (object.page_size !== undefined && object.page_size !== null) { + message.pageSize = object.page_size; + } + if (object.page_token !== undefined && object.page_token !== null) { + message.pageToken = object.page_token; + } + return message; + }, + toAmino(message: ListOperationsRequest): ListOperationsRequestAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + obj.filter = message.filter === "" ? undefined : message.filter; + obj.page_size = message.pageSize === 0 ? undefined : message.pageSize; + obj.page_token = message.pageToken === "" ? undefined : message.pageToken; + return obj; + }, + fromAminoMsg(object: ListOperationsRequestAminoMsg): ListOperationsRequest { + return ListOperationsRequest.fromAmino(object.value); + }, + fromProtoMsg(message: ListOperationsRequestProtoMsg): ListOperationsRequest { + return ListOperationsRequest.decode(message.value); + }, + toProto(message: ListOperationsRequest): Uint8Array { + return ListOperationsRequest.encode(message).finish(); + }, + toProtoMsg(message: ListOperationsRequest): ListOperationsRequestProtoMsg { + return { + typeUrl: "/google.longrunning.ListOperationsRequest", + value: ListOperationsRequest.encode(message).finish() + }; + } +}; +function createBaseListOperationsResponse(): ListOperationsResponse { + return { + operations: [], + nextPageToken: "" + }; +} +export const ListOperationsResponse = { + typeUrl: "/google.longrunning.ListOperationsResponse", + encode(message: ListOperationsResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.operations) { + Operation.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.nextPageToken !== undefined) { + writer.uint32(18).string(message.nextPageToken); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ListOperationsResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseListOperationsResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.operations.push(Operation.decode(reader, reader.uint32())); + break; + case 2: + message.nextPageToken = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ListOperationsResponse { + const obj = createBaseListOperationsResponse(); + if (Array.isArray(object?.operations)) obj.operations = object.operations.map((e: any) => Operation.fromJSON(e)); + if (isSet(object.nextPageToken)) obj.nextPageToken = String(object.nextPageToken); + return obj; + }, + toJSON(message: ListOperationsResponse): JsonSafe { + const obj: any = {}; + if (message.operations) { + obj.operations = message.operations.map(e => e ? Operation.toJSON(e) : undefined); + } else { + obj.operations = []; + } + message.nextPageToken !== undefined && (obj.nextPageToken = message.nextPageToken); + return obj; + }, + fromPartial(object: DeepPartial): ListOperationsResponse { + const message = createBaseListOperationsResponse(); + message.operations = object.operations?.map(e => Operation.fromPartial(e)) || []; + message.nextPageToken = object.nextPageToken ?? ""; + return message; + }, + fromSDK(object: ListOperationsResponseSDKType): ListOperationsResponse { + return { + operations: Array.isArray(object?.operations) ? object.operations.map((e: any) => Operation.fromSDK(e)) : [], + nextPageToken: object?.next_page_token + }; + }, + fromSDKJSON(object: any): ListOperationsResponseSDKType { + return { + operations: Array.isArray(object?.operations) ? object.operations.map((e: any) => Operation.fromSDKJSON(e)) : [], + next_page_token: isSet(object.next_page_token) ? String(object.next_page_token) : "" + }; + }, + toSDK(message: ListOperationsResponse): ListOperationsResponseSDKType { + const obj: any = {}; + if (message.operations) { + obj.operations = message.operations.map(e => e ? Operation.toSDK(e) : undefined); + } else { + obj.operations = []; + } + obj.next_page_token = message.nextPageToken; + return obj; + }, + fromAmino(object: ListOperationsResponseAmino): ListOperationsResponse { + const message = createBaseListOperationsResponse(); + message.operations = object.operations?.map(e => Operation.fromAmino(e)) || []; + if (object.next_page_token !== undefined && object.next_page_token !== null) { + message.nextPageToken = object.next_page_token; + } + return message; + }, + toAmino(message: ListOperationsResponse): ListOperationsResponseAmino { + const obj: any = {}; + if (message.operations) { + obj.operations = message.operations.map(e => e ? Operation.toAmino(e) : undefined); + } else { + obj.operations = message.operations; + } + obj.next_page_token = message.nextPageToken === "" ? undefined : message.nextPageToken; + return obj; + }, + fromAminoMsg(object: ListOperationsResponseAminoMsg): ListOperationsResponse { + return ListOperationsResponse.fromAmino(object.value); + }, + fromProtoMsg(message: ListOperationsResponseProtoMsg): ListOperationsResponse { + return ListOperationsResponse.decode(message.value); + }, + toProto(message: ListOperationsResponse): Uint8Array { + return ListOperationsResponse.encode(message).finish(); + }, + toProtoMsg(message: ListOperationsResponse): ListOperationsResponseProtoMsg { + return { + typeUrl: "/google.longrunning.ListOperationsResponse", + value: ListOperationsResponse.encode(message).finish() + }; + } +}; +function createBaseCancelOperationRequest(): CancelOperationRequest { + return { + name: "" + }; +} +export const CancelOperationRequest = { + typeUrl: "/google.longrunning.CancelOperationRequest", + encode(message: CancelOperationRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): CancelOperationRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCancelOperationRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): CancelOperationRequest { + const obj = createBaseCancelOperationRequest(); + if (isSet(object.name)) obj.name = String(object.name); + return obj; + }, + toJSON(message: CancelOperationRequest): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + return obj; + }, + fromPartial(object: DeepPartial): CancelOperationRequest { + const message = createBaseCancelOperationRequest(); + message.name = object.name ?? ""; + return message; + }, + fromSDK(object: CancelOperationRequestSDKType): CancelOperationRequest { + return { + name: object?.name + }; + }, + fromSDKJSON(object: any): CancelOperationRequestSDKType { + return { + name: isSet(object.name) ? String(object.name) : "" + }; + }, + toSDK(message: CancelOperationRequest): CancelOperationRequestSDKType { + const obj: any = {}; + obj.name = message.name; + return obj; + }, + fromAmino(object: CancelOperationRequestAmino): CancelOperationRequest { + const message = createBaseCancelOperationRequest(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + return message; + }, + toAmino(message: CancelOperationRequest): CancelOperationRequestAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + return obj; + }, + fromAminoMsg(object: CancelOperationRequestAminoMsg): CancelOperationRequest { + return CancelOperationRequest.fromAmino(object.value); + }, + fromProtoMsg(message: CancelOperationRequestProtoMsg): CancelOperationRequest { + return CancelOperationRequest.decode(message.value); + }, + toProto(message: CancelOperationRequest): Uint8Array { + return CancelOperationRequest.encode(message).finish(); + }, + toProtoMsg(message: CancelOperationRequest): CancelOperationRequestProtoMsg { + return { + typeUrl: "/google.longrunning.CancelOperationRequest", + value: CancelOperationRequest.encode(message).finish() + }; + } +}; +function createBaseDeleteOperationRequest(): DeleteOperationRequest { + return { + name: "" + }; +} +export const DeleteOperationRequest = { + typeUrl: "/google.longrunning.DeleteOperationRequest", + encode(message: DeleteOperationRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): DeleteOperationRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDeleteOperationRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): DeleteOperationRequest { + const obj = createBaseDeleteOperationRequest(); + if (isSet(object.name)) obj.name = String(object.name); + return obj; + }, + toJSON(message: DeleteOperationRequest): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + return obj; + }, + fromPartial(object: DeepPartial): DeleteOperationRequest { + const message = createBaseDeleteOperationRequest(); + message.name = object.name ?? ""; + return message; + }, + fromSDK(object: DeleteOperationRequestSDKType): DeleteOperationRequest { + return { + name: object?.name + }; + }, + fromSDKJSON(object: any): DeleteOperationRequestSDKType { + return { + name: isSet(object.name) ? String(object.name) : "" + }; + }, + toSDK(message: DeleteOperationRequest): DeleteOperationRequestSDKType { + const obj: any = {}; + obj.name = message.name; + return obj; + }, + fromAmino(object: DeleteOperationRequestAmino): DeleteOperationRequest { + const message = createBaseDeleteOperationRequest(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + return message; + }, + toAmino(message: DeleteOperationRequest): DeleteOperationRequestAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + return obj; + }, + fromAminoMsg(object: DeleteOperationRequestAminoMsg): DeleteOperationRequest { + return DeleteOperationRequest.fromAmino(object.value); + }, + fromProtoMsg(message: DeleteOperationRequestProtoMsg): DeleteOperationRequest { + return DeleteOperationRequest.decode(message.value); + }, + toProto(message: DeleteOperationRequest): Uint8Array { + return DeleteOperationRequest.encode(message).finish(); + }, + toProtoMsg(message: DeleteOperationRequest): DeleteOperationRequestProtoMsg { + return { + typeUrl: "/google.longrunning.DeleteOperationRequest", + value: DeleteOperationRequest.encode(message).finish() + }; + } +}; +function createBaseWaitOperationRequest(): WaitOperationRequest { + return { + name: "", + timeout: undefined + }; +} +export const WaitOperationRequest = { + typeUrl: "/google.longrunning.WaitOperationRequest", + encode(message: WaitOperationRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + if (message.timeout !== undefined) { + Duration.encode(message.timeout, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): WaitOperationRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseWaitOperationRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.timeout = Duration.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): WaitOperationRequest { + const obj = createBaseWaitOperationRequest(); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.timeout)) obj.timeout = Duration.fromJSON(object.timeout); + return obj; + }, + toJSON(message: WaitOperationRequest): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.timeout !== undefined && (obj.timeout = message.timeout ? Duration.toJSON(message.timeout) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): WaitOperationRequest { + const message = createBaseWaitOperationRequest(); + message.name = object.name ?? ""; + if (object.timeout !== undefined && object.timeout !== null) { + message.timeout = Duration.fromPartial(object.timeout); + } + return message; + }, + fromSDK(object: WaitOperationRequestSDKType): WaitOperationRequest { + return { + name: object?.name, + timeout: object.timeout ? Duration.fromSDK(object.timeout) : undefined + }; + }, + fromSDKJSON(object: any): WaitOperationRequestSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + timeout: isSet(object.timeout) ? Duration.fromSDKJSON(object.timeout) : undefined + }; + }, + toSDK(message: WaitOperationRequest): WaitOperationRequestSDKType { + const obj: any = {}; + obj.name = message.name; + message.timeout !== undefined && (obj.timeout = message.timeout ? Duration.toSDK(message.timeout) : undefined); + return obj; + }, + fromAmino(object: WaitOperationRequestAmino): WaitOperationRequest { + const message = createBaseWaitOperationRequest(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + if (object.timeout !== undefined && object.timeout !== null) { + message.timeout = Duration.fromAmino(object.timeout); + } + return message; + }, + toAmino(message: WaitOperationRequest): WaitOperationRequestAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + obj.timeout = message.timeout ? Duration.toAmino(message.timeout) : undefined; + return obj; + }, + fromAminoMsg(object: WaitOperationRequestAminoMsg): WaitOperationRequest { + return WaitOperationRequest.fromAmino(object.value); + }, + fromProtoMsg(message: WaitOperationRequestProtoMsg): WaitOperationRequest { + return WaitOperationRequest.decode(message.value); + }, + toProto(message: WaitOperationRequest): Uint8Array { + return WaitOperationRequest.encode(message).finish(); + }, + toProtoMsg(message: WaitOperationRequest): WaitOperationRequestProtoMsg { + return { + typeUrl: "/google.longrunning.WaitOperationRequest", + value: WaitOperationRequest.encode(message).finish() + }; + } +}; +function createBaseOperationInfo(): OperationInfo { + return { + responseType: "", + metadataType: "" + }; +} +export const OperationInfo = { + typeUrl: "/google.longrunning.OperationInfo", + encode(message: OperationInfo, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.responseType !== undefined) { + writer.uint32(10).string(message.responseType); + } + if (message.metadataType !== undefined) { + writer.uint32(18).string(message.metadataType); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): OperationInfo { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseOperationInfo(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.responseType = reader.string(); + break; + case 2: + message.metadataType = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): OperationInfo { + const obj = createBaseOperationInfo(); + if (isSet(object.responseType)) obj.responseType = String(object.responseType); + if (isSet(object.metadataType)) obj.metadataType = String(object.metadataType); + return obj; + }, + toJSON(message: OperationInfo): JsonSafe { + const obj: any = {}; + message.responseType !== undefined && (obj.responseType = message.responseType); + message.metadataType !== undefined && (obj.metadataType = message.metadataType); + return obj; + }, + fromPartial(object: DeepPartial): OperationInfo { + const message = createBaseOperationInfo(); + message.responseType = object.responseType ?? ""; + message.metadataType = object.metadataType ?? ""; + return message; + }, + fromSDK(object: OperationInfoSDKType): OperationInfo { + return { + responseType: object?.response_type, + metadataType: object?.metadata_type + }; + }, + fromSDKJSON(object: any): OperationInfoSDKType { + return { + response_type: isSet(object.response_type) ? String(object.response_type) : "", + metadata_type: isSet(object.metadata_type) ? String(object.metadata_type) : "" + }; + }, + toSDK(message: OperationInfo): OperationInfoSDKType { + const obj: any = {}; + obj.response_type = message.responseType; + obj.metadata_type = message.metadataType; + return obj; + }, + fromAmino(object: OperationInfoAmino): OperationInfo { + const message = createBaseOperationInfo(); + if (object.response_type !== undefined && object.response_type !== null) { + message.responseType = object.response_type; + } + if (object.metadata_type !== undefined && object.metadata_type !== null) { + message.metadataType = object.metadata_type; + } + return message; + }, + toAmino(message: OperationInfo): OperationInfoAmino { + const obj: any = {}; + obj.response_type = message.responseType === "" ? undefined : message.responseType; + obj.metadata_type = message.metadataType === "" ? undefined : message.metadataType; + return obj; + }, + fromAminoMsg(object: OperationInfoAminoMsg): OperationInfo { + return OperationInfo.fromAmino(object.value); + }, + fromProtoMsg(message: OperationInfoProtoMsg): OperationInfo { + return OperationInfo.decode(message.value); + }, + toProto(message: OperationInfo): Uint8Array { + return OperationInfo.encode(message).finish(); + }, + toProtoMsg(message: OperationInfo): OperationInfoProtoMsg { + return { + typeUrl: "/google.longrunning.OperationInfo", + value: OperationInfo.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/protobuf/any.ts b/__fixtures__/v-next/outputicjsdeps/google/protobuf/any.ts new file mode 100644 index 0000000000..1a705eea55 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/protobuf/any.ts @@ -0,0 +1,312 @@ +import { BinaryReader, BinaryWriter } from "../../binary.js"; +import { isSet, bytesFromBase64, base64FromBytes, DeepPartial } from "../../helpers.js"; +import { JsonSafe } from "../../json-safe.js"; +export const protobufPackage = "google.protobuf"; +/** + * `Any` contains an arbitrary serialized protocol buffer message along with a + * URL that describes the type of the serialized message. + * + * Protobuf library provides support to pack/unpack Any values in the form + * of utility functions or additional generated methods of the Any type. + * + * Example 1: Pack and unpack a message in C++. + * + * Foo foo = ...; + * Any any; + * any.PackFrom(foo); + * ... + * if (any.UnpackTo(&foo)) { + * ... + * } + * + * Example 2: Pack and unpack a message in Java. + * + * Foo foo = ...; + * Any any = Any.pack(foo); + * ... + * if (any.is(Foo.class)) { + * foo = any.unpack(Foo.class); + * } + * + * Example 3: Pack and unpack a message in Python. + * + * foo = Foo(...) + * any = Any() + * any.Pack(foo) + * ... + * if any.Is(Foo.DESCRIPTOR): + * any.Unpack(foo) + * ... + * + * Example 4: Pack and unpack a message in Go + * + * foo := &pb.Foo{...} + * any, err := ptypes.MarshalAny(foo) + * ... + * foo := &pb.Foo{} + * if err := ptypes.UnmarshalAny(any, foo); err != nil { + * ... + * } + * + * The pack methods provided by protobuf library will by default use + * 'type.googleapis.com/full.type.name' as the type URL and the unpack + * methods only use the fully qualified type name after the last '/' + * in the type URL, for example "foo.bar.com/x/y.z" will yield type + * name "y.z". + * + * + * JSON + * ==== + * The JSON representation of an `Any` value uses the regular + * representation of the deserialized, embedded message, with an + * additional field `@type` which contains the type URL. Example: + * + * package google.profile; + * message Person { + * string first_name = 1; + * string last_name = 2; + * } + * + * { + * "@type": "type.googleapis.com/google.profile.Person", + * "firstName": , + * "lastName": + * } + * + * If the embedded message type is well-known and has a custom JSON + * representation, that representation will be embedded adding a field + * `value` which holds the custom JSON in addition to the `@type` + * field. Example (for message [google.protobuf.Duration][]): + * + * { + * "@type": "type.googleapis.com/google.protobuf.Duration", + * "value": "1.212s" + * } + */ +export interface Any { + $typeUrl?: "/google.protobuf.Any" | string; + /** + * A URL/resource name that uniquely identifies the type of the serialized + * protocol buffer message. This string must contain at least + * one "/" character. The last segment of the URL's path must represent + * the fully qualified name of the type (as in + * `path/google.protobuf.Duration`). The name should be in a canonical form + * (e.g., leading "." is not accepted). + * + * In practice, teams usually precompile into the binary all types that they + * expect it to use in the context of Any. However, for URLs which use the + * scheme `http`, `https`, or no scheme, one can optionally set up a type + * server that maps type URLs to message definitions as follows: + * + * * If no scheme is provided, `https` is assumed. + * * An HTTP GET on the URL must yield a [google.protobuf.Type][] + * value in binary format, or produce an error. + * * Applications are allowed to cache lookup results based on the + * URL, or have them precompiled into a binary to avoid any + * lookup. Therefore, binary compatibility needs to be preserved + * on changes to types. (Use versioned type names to manage + * breaking changes.) + * + * Note: this functionality is not currently available in the official + * protobuf release, and it is not used for type URLs beginning with + * type.googleapis.com. + * + * Schemes other than `http`, `https` (or the empty scheme) might be + * used with implementation specific semantics. + */ + typeUrl: string; + /** Must be a valid serialized protocol buffer of the above specified type. */ + value: Uint8Array; +} +export interface AnyProtoMsg { + typeUrl: "/google.protobuf.Any"; + value: Uint8Array; +} +/** + * `Any` contains an arbitrary serialized protocol buffer message along with a + * URL that describes the type of the serialized message. + * + * Protobuf library provides support to pack/unpack Any values in the form + * of utility functions or additional generated methods of the Any type. + * + * Example 1: Pack and unpack a message in C++. + * + * Foo foo = ...; + * Any any; + * any.PackFrom(foo); + * ... + * if (any.UnpackTo(&foo)) { + * ... + * } + * + * Example 2: Pack and unpack a message in Java. + * + * Foo foo = ...; + * Any any = Any.pack(foo); + * ... + * if (any.is(Foo.class)) { + * foo = any.unpack(Foo.class); + * } + * + * Example 3: Pack and unpack a message in Python. + * + * foo = Foo(...) + * any = Any() + * any.Pack(foo) + * ... + * if any.Is(Foo.DESCRIPTOR): + * any.Unpack(foo) + * ... + * + * Example 4: Pack and unpack a message in Go + * + * foo := &pb.Foo{...} + * any, err := ptypes.MarshalAny(foo) + * ... + * foo := &pb.Foo{} + * if err := ptypes.UnmarshalAny(any, foo); err != nil { + * ... + * } + * + * The pack methods provided by protobuf library will by default use + * 'type.googleapis.com/full.type.name' as the type URL and the unpack + * methods only use the fully qualified type name after the last '/' + * in the type URL, for example "foo.bar.com/x/y.z" will yield type + * name "y.z". + * + * + * JSON + * ==== + * The JSON representation of an `Any` value uses the regular + * representation of the deserialized, embedded message, with an + * additional field `@type` which contains the type URL. Example: + * + * package google.profile; + * message Person { + * string first_name = 1; + * string last_name = 2; + * } + * + * { + * "@type": "type.googleapis.com/google.profile.Person", + * "firstName": , + * "lastName": + * } + * + * If the embedded message type is well-known and has a custom JSON + * representation, that representation will be embedded adding a field + * `value` which holds the custom JSON in addition to the `@type` + * field. Example (for message [google.protobuf.Duration][]): + * + * { + * "@type": "type.googleapis.com/google.protobuf.Duration", + * "value": "1.212s" + * } + */ +export interface AnySDKType { + $typeUrl?: "/google.protobuf.Any" | string; + type_url: string; + value: Uint8Array; +} +function createBaseAny(): Any { + return { + $typeUrl: "/google.protobuf.Any", + typeUrl: "", + value: new Uint8Array() + }; +} +export const Any = { + typeUrl: "/google.protobuf.Any", + encode(message: Any, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.typeUrl !== undefined) { + writer.uint32(10).string(message.typeUrl); + } + if (message.value.length !== 0) { + writer.uint32(18).bytes(message.value); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Any { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseAny(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.typeUrl = reader.string(); + break; + case 2: + message.value = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Any { + const obj = createBaseAny(); + if (isSet(object.typeUrl)) obj.typeUrl = String(object.typeUrl); + if (isSet(object.value)) obj.value = bytesFromBase64(object.value); + return obj; + }, + toJSON(message: Any): JsonSafe { + const obj: any = {}; + message.typeUrl !== undefined && (obj.typeUrl = message.typeUrl); + message.value !== undefined && (obj.value = base64FromBytes(message.value !== undefined ? message.value : new Uint8Array())); + return obj; + }, + fromPartial(object: DeepPartial): Any { + const message = createBaseAny(); + message.typeUrl = object.typeUrl ?? ""; + message.value = object.value ?? new Uint8Array(); + return message; + }, + fromSDK(object: AnySDKType): Any { + return { + typeUrl: object?.type_url, + value: object?.value + }; + }, + fromSDKJSON(object: any): AnySDKType { + return { + type_url: isSet(object.type_url) ? String(object.type_url) : "", + value: isSet(object.value) ? bytesFromBase64(object.value) : new Uint8Array() + }; + }, + toSDK(message: Any): AnySDKType { + const obj: any = {}; + obj.type_url = message.typeUrl; + obj.value = message.value; + return obj; + }, + fromAmino(object: AnyAmino): Any { + return { + typeUrl: object.type, + value: object.value + }; + }, + toAmino(message: Any): AnyAmino { + const obj: any = {}; + obj.type = message.typeUrl; + obj.value = message.value; + return obj; + }, + fromAminoMsg(object: AnyAminoMsg): Any { + return Any.fromAmino(object.value); + }, + fromProtoMsg(message: AnyProtoMsg): Any { + return Any.decode(message.value); + }, + toProto(message: Any): Uint8Array { + return Any.encode(message).finish(); + }, + toProtoMsg(message: Any): AnyProtoMsg { + return { + typeUrl: "/google.protobuf.Any", + value: Any.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/protobuf/api.ts b/__fixtures__/v-next/outputicjsdeps/google/protobuf/api.ts new file mode 100644 index 0000000000..359d83e8cc --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/protobuf/api.ts @@ -0,0 +1,818 @@ +import { Option, OptionSDKType, Syntax, SyntaxSDKType, syntaxFromJSON, syntaxToJSON } from "./type.js"; +import { SourceContext, SourceContextSDKType } from "./source_context.js"; +import { BinaryReader, BinaryWriter } from "../../binary.js"; +import { isSet, DeepPartial } from "../../helpers.js"; +import { JsonSafe } from "../../json-safe.js"; +export const protobufPackage = "google.protobuf"; +/** + * Api is a light-weight descriptor for an API Interface. + * + * Interfaces are also described as "protocol buffer services" in some contexts, + * such as by the "service" keyword in a .proto file, but they are different + * from API Services, which represent a concrete implementation of an interface + * as opposed to simply a description of methods and bindings. They are also + * sometimes simply referred to as "APIs" in other contexts, such as the name of + * this message itself. See https://cloud.google.com/apis/design/glossary for + * detailed terminology. + */ +export interface Api { + /** + * The fully qualified name of this interface, including package name + * followed by the interface's simple name. + */ + name: string; + /** The methods of this interface, in unspecified order. */ + methods: Method[]; + /** Any metadata attached to the interface. */ + options: Option[]; + /** + * A version string for this interface. If specified, must have the form + * `major-version.minor-version`, as in `1.10`. If the minor version is + * omitted, it defaults to zero. If the entire version field is empty, the + * major version is derived from the package name, as outlined below. If the + * field is not empty, the version in the package name will be verified to be + * consistent with what is provided here. + * + * The versioning schema uses [semantic + * versioning](http://semver.org) where the major version number + * indicates a breaking change and the minor version an additive, + * non-breaking change. Both version numbers are signals to users + * what to expect from different versions, and should be carefully + * chosen based on the product plan. + * + * The major version is also reflected in the package name of the + * interface, which must end in `v`, as in + * `google.feature.v1`. For major versions 0 and 1, the suffix can + * be omitted. Zero major versions must only be used for + * experimental, non-GA interfaces. + */ + version: string; + /** + * Source context for the protocol buffer service represented by this + * message. + */ + sourceContext?: SourceContext; + /** Included interfaces. See [Mixin][]. */ + mixins: Mixin[]; + /** The source syntax of the service. */ + syntax: Syntax; +} +export interface ApiProtoMsg { + typeUrl: "/google.protobuf.Api"; + value: Uint8Array; +} +/** + * Api is a light-weight descriptor for an API Interface. + * + * Interfaces are also described as "protocol buffer services" in some contexts, + * such as by the "service" keyword in a .proto file, but they are different + * from API Services, which represent a concrete implementation of an interface + * as opposed to simply a description of methods and bindings. They are also + * sometimes simply referred to as "APIs" in other contexts, such as the name of + * this message itself. See https://cloud.google.com/apis/design/glossary for + * detailed terminology. + */ +export interface ApiSDKType { + name: string; + methods: MethodSDKType[]; + options: OptionSDKType[]; + version: string; + source_context?: SourceContextSDKType; + mixins: MixinSDKType[]; + syntax: Syntax; +} +/** Method represents a method of an API interface. */ +export interface Method { + /** The simple name of this method. */ + name: string; + /** A URL of the input message type. */ + requestTypeUrl: string; + /** If true, the request is streamed. */ + requestStreaming: boolean; + /** The URL of the output message type. */ + responseTypeUrl: string; + /** If true, the response is streamed. */ + responseStreaming: boolean; + /** Any metadata attached to the method. */ + options: Option[]; + /** The source syntax of this method. */ + syntax: Syntax; +} +export interface MethodProtoMsg { + typeUrl: "/google.protobuf.Method"; + value: Uint8Array; +} +/** Method represents a method of an API interface. */ +export interface MethodSDKType { + name: string; + request_type_url: string; + request_streaming: boolean; + response_type_url: string; + response_streaming: boolean; + options: OptionSDKType[]; + syntax: Syntax; +} +/** + * Declares an API Interface to be included in this interface. The including + * interface must redeclare all the methods from the included interface, but + * documentation and options are inherited as follows: + * + * - If after comment and whitespace stripping, the documentation + * string of the redeclared method is empty, it will be inherited + * from the original method. + * + * - Each annotation belonging to the service config (http, + * visibility) which is not set in the redeclared method will be + * inherited. + * + * - If an http annotation is inherited, the path pattern will be + * modified as follows. Any version prefix will be replaced by the + * version of the including interface plus the [root][] path if + * specified. + * + * Example of a simple mixin: + * + * package google.acl.v1; + * service AccessControl { + * // Get the underlying ACL object. + * rpc GetAcl(GetAclRequest) returns (Acl) { + * option (google.api.http).get = "/v1/{resource=**}:getAcl"; + * } + * } + * + * package google.storage.v2; + * service Storage { + * rpc GetAcl(GetAclRequest) returns (Acl); + * + * // Get a data record. + * rpc GetData(GetDataRequest) returns (Data) { + * option (google.api.http).get = "/v2/{resource=**}"; + * } + * } + * + * Example of a mixin configuration: + * + * apis: + * - name: google.storage.v2.Storage + * mixins: + * - name: google.acl.v1.AccessControl + * + * The mixin construct implies that all methods in `AccessControl` are + * also declared with same name and request/response types in + * `Storage`. A documentation generator or annotation processor will + * see the effective `Storage.GetAcl` method after inherting + * documentation and annotations as follows: + * + * service Storage { + * // Get the underlying ACL object. + * rpc GetAcl(GetAclRequest) returns (Acl) { + * option (google.api.http).get = "/v2/{resource=**}:getAcl"; + * } + * ... + * } + * + * Note how the version in the path pattern changed from `v1` to `v2`. + * + * If the `root` field in the mixin is specified, it should be a + * relative path under which inherited HTTP paths are placed. Example: + * + * apis: + * - name: google.storage.v2.Storage + * mixins: + * - name: google.acl.v1.AccessControl + * root: acls + * + * This implies the following inherited HTTP annotation: + * + * service Storage { + * // Get the underlying ACL object. + * rpc GetAcl(GetAclRequest) returns (Acl) { + * option (google.api.http).get = "/v2/acls/{resource=**}:getAcl"; + * } + * ... + * } + */ +export interface Mixin { + /** The fully qualified name of the interface which is included. */ + name: string; + /** + * If non-empty specifies a path under which inherited HTTP paths + * are rooted. + */ + root: string; +} +export interface MixinProtoMsg { + typeUrl: "/google.protobuf.Mixin"; + value: Uint8Array; +} +/** + * Declares an API Interface to be included in this interface. The including + * interface must redeclare all the methods from the included interface, but + * documentation and options are inherited as follows: + * + * - If after comment and whitespace stripping, the documentation + * string of the redeclared method is empty, it will be inherited + * from the original method. + * + * - Each annotation belonging to the service config (http, + * visibility) which is not set in the redeclared method will be + * inherited. + * + * - If an http annotation is inherited, the path pattern will be + * modified as follows. Any version prefix will be replaced by the + * version of the including interface plus the [root][] path if + * specified. + * + * Example of a simple mixin: + * + * package google.acl.v1; + * service AccessControl { + * // Get the underlying ACL object. + * rpc GetAcl(GetAclRequest) returns (Acl) { + * option (google.api.http).get = "/v1/{resource=**}:getAcl"; + * } + * } + * + * package google.storage.v2; + * service Storage { + * rpc GetAcl(GetAclRequest) returns (Acl); + * + * // Get a data record. + * rpc GetData(GetDataRequest) returns (Data) { + * option (google.api.http).get = "/v2/{resource=**}"; + * } + * } + * + * Example of a mixin configuration: + * + * apis: + * - name: google.storage.v2.Storage + * mixins: + * - name: google.acl.v1.AccessControl + * + * The mixin construct implies that all methods in `AccessControl` are + * also declared with same name and request/response types in + * `Storage`. A documentation generator or annotation processor will + * see the effective `Storage.GetAcl` method after inherting + * documentation and annotations as follows: + * + * service Storage { + * // Get the underlying ACL object. + * rpc GetAcl(GetAclRequest) returns (Acl) { + * option (google.api.http).get = "/v2/{resource=**}:getAcl"; + * } + * ... + * } + * + * Note how the version in the path pattern changed from `v1` to `v2`. + * + * If the `root` field in the mixin is specified, it should be a + * relative path under which inherited HTTP paths are placed. Example: + * + * apis: + * - name: google.storage.v2.Storage + * mixins: + * - name: google.acl.v1.AccessControl + * root: acls + * + * This implies the following inherited HTTP annotation: + * + * service Storage { + * // Get the underlying ACL object. + * rpc GetAcl(GetAclRequest) returns (Acl) { + * option (google.api.http).get = "/v2/acls/{resource=**}:getAcl"; + * } + * ... + * } + */ +export interface MixinSDKType { + name: string; + root: string; +} +function createBaseApi(): Api { + return { + name: "", + methods: [], + options: [], + version: "", + sourceContext: undefined, + mixins: [], + syntax: 0 + }; +} +export const Api = { + typeUrl: "/google.protobuf.Api", + encode(message: Api, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + for (const v of message.methods) { + Method.encode(v!, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.options) { + Option.encode(v!, writer.uint32(26).fork()).ldelim(); + } + if (message.version !== undefined) { + writer.uint32(34).string(message.version); + } + if (message.sourceContext !== undefined) { + SourceContext.encode(message.sourceContext, writer.uint32(42).fork()).ldelim(); + } + for (const v of message.mixins) { + Mixin.encode(v!, writer.uint32(50).fork()).ldelim(); + } + if (message.syntax !== 0) { + writer.uint32(56).int32(message.syntax); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Api { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseApi(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.methods.push(Method.decode(reader, reader.uint32())); + break; + case 3: + message.options.push(Option.decode(reader, reader.uint32())); + break; + case 4: + message.version = reader.string(); + break; + case 5: + message.sourceContext = SourceContext.decode(reader, reader.uint32()); + break; + case 6: + message.mixins.push(Mixin.decode(reader, reader.uint32())); + break; + case 7: + message.syntax = (reader.int32() as any); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Api { + const obj = createBaseApi(); + if (isSet(object.name)) obj.name = String(object.name); + if (Array.isArray(object?.methods)) obj.methods = object.methods.map((e: any) => Method.fromJSON(e)); + if (Array.isArray(object?.options)) obj.options = object.options.map((e: any) => Option.fromJSON(e)); + if (isSet(object.version)) obj.version = String(object.version); + if (isSet(object.sourceContext)) obj.sourceContext = SourceContext.fromJSON(object.sourceContext); + if (Array.isArray(object?.mixins)) obj.mixins = object.mixins.map((e: any) => Mixin.fromJSON(e)); + if (isSet(object.syntax)) obj.syntax = syntaxFromJSON(object.syntax); + return obj; + }, + toJSON(message: Api): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.methods) { + obj.methods = message.methods.map(e => e ? Method.toJSON(e) : undefined); + } else { + obj.methods = []; + } + if (message.options) { + obj.options = message.options.map(e => e ? Option.toJSON(e) : undefined); + } else { + obj.options = []; + } + message.version !== undefined && (obj.version = message.version); + message.sourceContext !== undefined && (obj.sourceContext = message.sourceContext ? SourceContext.toJSON(message.sourceContext) : undefined); + if (message.mixins) { + obj.mixins = message.mixins.map(e => e ? Mixin.toJSON(e) : undefined); + } else { + obj.mixins = []; + } + message.syntax !== undefined && (obj.syntax = syntaxToJSON(message.syntax)); + return obj; + }, + fromPartial(object: DeepPartial): Api { + const message = createBaseApi(); + message.name = object.name ?? ""; + message.methods = object.methods?.map(e => Method.fromPartial(e)) || []; + message.options = object.options?.map(e => Option.fromPartial(e)) || []; + message.version = object.version ?? ""; + if (object.sourceContext !== undefined && object.sourceContext !== null) { + message.sourceContext = SourceContext.fromPartial(object.sourceContext); + } + message.mixins = object.mixins?.map(e => Mixin.fromPartial(e)) || []; + message.syntax = object.syntax ?? 0; + return message; + }, + fromSDK(object: ApiSDKType): Api { + return { + name: object?.name, + methods: Array.isArray(object?.methods) ? object.methods.map((e: any) => Method.fromSDK(e)) : [], + options: Array.isArray(object?.options) ? object.options.map((e: any) => Option.fromSDK(e)) : [], + version: object?.version, + sourceContext: object.source_context ? SourceContext.fromSDK(object.source_context) : undefined, + mixins: Array.isArray(object?.mixins) ? object.mixins.map((e: any) => Mixin.fromSDK(e)) : [], + syntax: isSet(object.syntax) ? syntaxFromJSON(object.syntax) : -1 + }; + }, + fromSDKJSON(object: any): ApiSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + methods: Array.isArray(object?.methods) ? object.methods.map((e: any) => Method.fromSDKJSON(e)) : [], + options: Array.isArray(object?.options) ? object.options.map((e: any) => Option.fromSDKJSON(e)) : [], + version: isSet(object.version) ? String(object.version) : "", + source_context: isSet(object.source_context) ? SourceContext.fromSDKJSON(object.source_context) : undefined, + mixins: Array.isArray(object?.mixins) ? object.mixins.map((e: any) => Mixin.fromSDKJSON(e)) : [], + syntax: isSet(object.syntax) ? syntaxFromJSON(object.syntax) : -1 + }; + }, + toSDK(message: Api): ApiSDKType { + const obj: any = {}; + obj.name = message.name; + if (message.methods) { + obj.methods = message.methods.map(e => e ? Method.toSDK(e) : undefined); + } else { + obj.methods = []; + } + if (message.options) { + obj.options = message.options.map(e => e ? Option.toSDK(e) : undefined); + } else { + obj.options = []; + } + obj.version = message.version; + message.sourceContext !== undefined && (obj.source_context = message.sourceContext ? SourceContext.toSDK(message.sourceContext) : undefined); + if (message.mixins) { + obj.mixins = message.mixins.map(e => e ? Mixin.toSDK(e) : undefined); + } else { + obj.mixins = []; + } + message.syntax !== undefined && (obj.syntax = syntaxToJSON(message.syntax)); + return obj; + }, + fromAmino(object: ApiAmino): Api { + const message = createBaseApi(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + message.methods = object.methods?.map(e => Method.fromAmino(e)) || []; + message.options = object.options?.map(e => Option.fromAmino(e)) || []; + if (object.version !== undefined && object.version !== null) { + message.version = object.version; + } + if (object.source_context !== undefined && object.source_context !== null) { + message.sourceContext = SourceContext.fromAmino(object.source_context); + } + message.mixins = object.mixins?.map(e => Mixin.fromAmino(e)) || []; + if (object.syntax !== undefined && object.syntax !== null) { + message.syntax = object.syntax; + } + return message; + }, + toAmino(message: Api): ApiAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + if (message.methods) { + obj.methods = message.methods.map(e => e ? Method.toAmino(e) : undefined); + } else { + obj.methods = message.methods; + } + if (message.options) { + obj.options = message.options.map(e => e ? Option.toAmino(e) : undefined); + } else { + obj.options = message.options; + } + obj.version = message.version === "" ? undefined : message.version; + obj.source_context = message.sourceContext ? SourceContext.toAmino(message.sourceContext) : undefined; + if (message.mixins) { + obj.mixins = message.mixins.map(e => e ? Mixin.toAmino(e) : undefined); + } else { + obj.mixins = message.mixins; + } + obj.syntax = message.syntax === 0 ? undefined : message.syntax; + return obj; + }, + fromAminoMsg(object: ApiAminoMsg): Api { + return Api.fromAmino(object.value); + }, + fromProtoMsg(message: ApiProtoMsg): Api { + return Api.decode(message.value); + }, + toProto(message: Api): Uint8Array { + return Api.encode(message).finish(); + }, + toProtoMsg(message: Api): ApiProtoMsg { + return { + typeUrl: "/google.protobuf.Api", + value: Api.encode(message).finish() + }; + } +}; +function createBaseMethod(): Method { + return { + name: "", + requestTypeUrl: "", + requestStreaming: false, + responseTypeUrl: "", + responseStreaming: false, + options: [], + syntax: 0 + }; +} +export const Method = { + typeUrl: "/google.protobuf.Method", + encode(message: Method, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + if (message.requestTypeUrl !== undefined) { + writer.uint32(18).string(message.requestTypeUrl); + } + if (message.requestStreaming !== undefined) { + writer.uint32(24).bool(message.requestStreaming); + } + if (message.responseTypeUrl !== undefined) { + writer.uint32(34).string(message.responseTypeUrl); + } + if (message.responseStreaming !== undefined) { + writer.uint32(40).bool(message.responseStreaming); + } + for (const v of message.options) { + Option.encode(v!, writer.uint32(50).fork()).ldelim(); + } + if (message.syntax !== 0) { + writer.uint32(56).int32(message.syntax); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Method { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMethod(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.requestTypeUrl = reader.string(); + break; + case 3: + message.requestStreaming = reader.bool(); + break; + case 4: + message.responseTypeUrl = reader.string(); + break; + case 5: + message.responseStreaming = reader.bool(); + break; + case 6: + message.options.push(Option.decode(reader, reader.uint32())); + break; + case 7: + message.syntax = (reader.int32() as any); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Method { + const obj = createBaseMethod(); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.requestTypeUrl)) obj.requestTypeUrl = String(object.requestTypeUrl); + if (isSet(object.requestStreaming)) obj.requestStreaming = Boolean(object.requestStreaming); + if (isSet(object.responseTypeUrl)) obj.responseTypeUrl = String(object.responseTypeUrl); + if (isSet(object.responseStreaming)) obj.responseStreaming = Boolean(object.responseStreaming); + if (Array.isArray(object?.options)) obj.options = object.options.map((e: any) => Option.fromJSON(e)); + if (isSet(object.syntax)) obj.syntax = syntaxFromJSON(object.syntax); + return obj; + }, + toJSON(message: Method): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.requestTypeUrl !== undefined && (obj.requestTypeUrl = message.requestTypeUrl); + message.requestStreaming !== undefined && (obj.requestStreaming = message.requestStreaming); + message.responseTypeUrl !== undefined && (obj.responseTypeUrl = message.responseTypeUrl); + message.responseStreaming !== undefined && (obj.responseStreaming = message.responseStreaming); + if (message.options) { + obj.options = message.options.map(e => e ? Option.toJSON(e) : undefined); + } else { + obj.options = []; + } + message.syntax !== undefined && (obj.syntax = syntaxToJSON(message.syntax)); + return obj; + }, + fromPartial(object: DeepPartial): Method { + const message = createBaseMethod(); + message.name = object.name ?? ""; + message.requestTypeUrl = object.requestTypeUrl ?? ""; + message.requestStreaming = object.requestStreaming ?? false; + message.responseTypeUrl = object.responseTypeUrl ?? ""; + message.responseStreaming = object.responseStreaming ?? false; + message.options = object.options?.map(e => Option.fromPartial(e)) || []; + message.syntax = object.syntax ?? 0; + return message; + }, + fromSDK(object: MethodSDKType): Method { + return { + name: object?.name, + requestTypeUrl: object?.request_type_url, + requestStreaming: object?.request_streaming, + responseTypeUrl: object?.response_type_url, + responseStreaming: object?.response_streaming, + options: Array.isArray(object?.options) ? object.options.map((e: any) => Option.fromSDK(e)) : [], + syntax: isSet(object.syntax) ? syntaxFromJSON(object.syntax) : -1 + }; + }, + fromSDKJSON(object: any): MethodSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + request_type_url: isSet(object.request_type_url) ? String(object.request_type_url) : "", + request_streaming: isSet(object.request_streaming) ? Boolean(object.request_streaming) : false, + response_type_url: isSet(object.response_type_url) ? String(object.response_type_url) : "", + response_streaming: isSet(object.response_streaming) ? Boolean(object.response_streaming) : false, + options: Array.isArray(object?.options) ? object.options.map((e: any) => Option.fromSDKJSON(e)) : [], + syntax: isSet(object.syntax) ? syntaxFromJSON(object.syntax) : -1 + }; + }, + toSDK(message: Method): MethodSDKType { + const obj: any = {}; + obj.name = message.name; + obj.request_type_url = message.requestTypeUrl; + obj.request_streaming = message.requestStreaming; + obj.response_type_url = message.responseTypeUrl; + obj.response_streaming = message.responseStreaming; + if (message.options) { + obj.options = message.options.map(e => e ? Option.toSDK(e) : undefined); + } else { + obj.options = []; + } + message.syntax !== undefined && (obj.syntax = syntaxToJSON(message.syntax)); + return obj; + }, + fromAmino(object: MethodAmino): Method { + const message = createBaseMethod(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + if (object.request_type_url !== undefined && object.request_type_url !== null) { + message.requestTypeUrl = object.request_type_url; + } + if (object.request_streaming !== undefined && object.request_streaming !== null) { + message.requestStreaming = object.request_streaming; + } + if (object.response_type_url !== undefined && object.response_type_url !== null) { + message.responseTypeUrl = object.response_type_url; + } + if (object.response_streaming !== undefined && object.response_streaming !== null) { + message.responseStreaming = object.response_streaming; + } + message.options = object.options?.map(e => Option.fromAmino(e)) || []; + if (object.syntax !== undefined && object.syntax !== null) { + message.syntax = object.syntax; + } + return message; + }, + toAmino(message: Method): MethodAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + obj.request_type_url = message.requestTypeUrl === "" ? undefined : message.requestTypeUrl; + obj.request_streaming = message.requestStreaming === false ? undefined : message.requestStreaming; + obj.response_type_url = message.responseTypeUrl === "" ? undefined : message.responseTypeUrl; + obj.response_streaming = message.responseStreaming === false ? undefined : message.responseStreaming; + if (message.options) { + obj.options = message.options.map(e => e ? Option.toAmino(e) : undefined); + } else { + obj.options = message.options; + } + obj.syntax = message.syntax === 0 ? undefined : message.syntax; + return obj; + }, + fromAminoMsg(object: MethodAminoMsg): Method { + return Method.fromAmino(object.value); + }, + fromProtoMsg(message: MethodProtoMsg): Method { + return Method.decode(message.value); + }, + toProto(message: Method): Uint8Array { + return Method.encode(message).finish(); + }, + toProtoMsg(message: Method): MethodProtoMsg { + return { + typeUrl: "/google.protobuf.Method", + value: Method.encode(message).finish() + }; + } +}; +function createBaseMixin(): Mixin { + return { + name: "", + root: "" + }; +} +export const Mixin = { + typeUrl: "/google.protobuf.Mixin", + encode(message: Mixin, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + if (message.root !== undefined) { + writer.uint32(18).string(message.root); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Mixin { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMixin(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.root = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Mixin { + const obj = createBaseMixin(); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.root)) obj.root = String(object.root); + return obj; + }, + toJSON(message: Mixin): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.root !== undefined && (obj.root = message.root); + return obj; + }, + fromPartial(object: DeepPartial): Mixin { + const message = createBaseMixin(); + message.name = object.name ?? ""; + message.root = object.root ?? ""; + return message; + }, + fromSDK(object: MixinSDKType): Mixin { + return { + name: object?.name, + root: object?.root + }; + }, + fromSDKJSON(object: any): MixinSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + root: isSet(object.root) ? String(object.root) : "" + }; + }, + toSDK(message: Mixin): MixinSDKType { + const obj: any = {}; + obj.name = message.name; + obj.root = message.root; + return obj; + }, + fromAmino(object: MixinAmino): Mixin { + const message = createBaseMixin(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + if (object.root !== undefined && object.root !== null) { + message.root = object.root; + } + return message; + }, + toAmino(message: Mixin): MixinAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + obj.root = message.root === "" ? undefined : message.root; + return obj; + }, + fromAminoMsg(object: MixinAminoMsg): Mixin { + return Mixin.fromAmino(object.value); + }, + fromProtoMsg(message: MixinProtoMsg): Mixin { + return Mixin.decode(message.value); + }, + toProto(message: Mixin): Uint8Array { + return Mixin.encode(message).finish(); + }, + toProtoMsg(message: Mixin): MixinProtoMsg { + return { + typeUrl: "/google.protobuf.Mixin", + value: Mixin.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/protobuf/compiler/plugin.ts b/__fixtures__/v-next/outputicjsdeps/google/protobuf/compiler/plugin.ts new file mode 100644 index 0000000000..d057e41456 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/protobuf/compiler/plugin.ts @@ -0,0 +1,698 @@ +import { FileDescriptorProto, FileDescriptorProtoSDKType } from "../descriptor.js"; +import { BinaryReader, BinaryWriter } from "../../../binary.js"; +import { isSet, DeepPartial } from "../../../helpers.js"; +import { JsonSafe } from "../../../json-safe.js"; +export const protobufPackage = "google.protobuf.compiler"; +/** The version number of protocol compiler. */ +export interface Version { + major: number; + minor: number; + patch: number; + /** + * A suffix for alpha, beta or rc release, e.g., "alpha-1", "rc2". It should + * be empty for mainline stable releases. + */ + suffix: string; +} +export interface VersionProtoMsg { + typeUrl: "/google.protobuf.compiler.Version"; + value: Uint8Array; +} +/** The version number of protocol compiler. */ +export interface VersionSDKType { + major: number; + minor: number; + patch: number; + suffix: string; +} +/** An encoded CodeGeneratorRequest is written to the plugin's stdin. */ +export interface CodeGeneratorRequest { + /** + * The .proto files that were explicitly listed on the command-line. The + * code generator should generate code only for these files. Each file's + * descriptor will be included in proto_file, below. + */ + fileToGenerate: string[]; + /** The generator parameter passed on the command-line. */ + parameter: string; + /** + * FileDescriptorProtos for all files in files_to_generate and everything + * they import. The files will appear in topological order, so each file + * appears before any file that imports it. + * + * protoc guarantees that all proto_files will be written after + * the fields above, even though this is not technically guaranteed by the + * protobuf wire format. This theoretically could allow a plugin to stream + * in the FileDescriptorProtos and handle them one by one rather than read + * the entire set into memory at once. However, as of this writing, this + * is not similarly optimized on protoc's end -- it will store all fields in + * memory at once before sending them to the plugin. + * + * Type names of fields and extensions in the FileDescriptorProto are always + * fully qualified. + */ + protoFile: FileDescriptorProto[]; + /** The version number of protocol compiler. */ + compilerVersion?: Version; +} +export interface CodeGeneratorRequestProtoMsg { + typeUrl: "/google.protobuf.compiler.CodeGeneratorRequest"; + value: Uint8Array; +} +/** An encoded CodeGeneratorRequest is written to the plugin's stdin. */ +export interface CodeGeneratorRequestSDKType { + file_to_generate: string[]; + parameter: string; + proto_file: FileDescriptorProtoSDKType[]; + compiler_version?: VersionSDKType; +} +/** The plugin writes an encoded CodeGeneratorResponse to stdout. */ +export interface CodeGeneratorResponse { + /** + * Error message. If non-empty, code generation failed. The plugin process + * should exit with status code zero even if it reports an error in this way. + * + * This should be used to indicate errors in .proto files which prevent the + * code generator from generating correct code. Errors which indicate a + * problem in protoc itself -- such as the input CodeGeneratorRequest being + * unparseable -- should be reported by writing a message to stderr and + * exiting with a non-zero status code. + */ + error: string; + file: CodeGeneratorResponse_File[]; +} +export interface CodeGeneratorResponseProtoMsg { + typeUrl: "/google.protobuf.compiler.CodeGeneratorResponse"; + value: Uint8Array; +} +/** The plugin writes an encoded CodeGeneratorResponse to stdout. */ +export interface CodeGeneratorResponseSDKType { + error: string; + file: CodeGeneratorResponse_FileSDKType[]; +} +/** Represents a single generated file. */ +export interface CodeGeneratorResponse_File { + /** + * The file name, relative to the output directory. The name must not + * contain "." or ".." components and must be relative, not be absolute (so, + * the file cannot lie outside the output directory). "/" must be used as + * the path separator, not "\". + * + * If the name is omitted, the content will be appended to the previous + * file. This allows the generator to break large files into small chunks, + * and allows the generated text to be streamed back to protoc so that large + * files need not reside completely in memory at one time. Note that as of + * this writing protoc does not optimize for this -- it will read the entire + * CodeGeneratorResponse before writing files to disk. + */ + name: string; + /** + * If non-empty, indicates that the named file should already exist, and the + * content here is to be inserted into that file at a defined insertion + * point. This feature allows a code generator to extend the output + * produced by another code generator. The original generator may provide + * insertion points by placing special annotations in the file that look + * like: + * @@protoc_insertion_point(NAME) + * The annotation can have arbitrary text before and after it on the line, + * which allows it to be placed in a comment. NAME should be replaced with + * an identifier naming the point -- this is what other generators will use + * as the insertion_point. Code inserted at this point will be placed + * immediately above the line containing the insertion point (thus multiple + * insertions to the same point will come out in the order they were added). + * The double-@ is intended to make it unlikely that the generated code + * could contain things that look like insertion points by accident. + * + * For example, the C++ code generator places the following line in the + * .pb.h files that it generates: + * // @@protoc_insertion_point(namespace_scope) + * This line appears within the scope of the file's package namespace, but + * outside of any particular class. Another plugin can then specify the + * insertion_point "namespace_scope" to generate additional classes or + * other declarations that should be placed in this scope. + * + * Note that if the line containing the insertion point begins with + * whitespace, the same whitespace will be added to every line of the + * inserted text. This is useful for languages like Python, where + * indentation matters. In these languages, the insertion point comment + * should be indented the same amount as any inserted code will need to be + * in order to work correctly in that context. + * + * The code generator that generates the initial file and the one which + * inserts into it must both run as part of a single invocation of protoc. + * Code generators are executed in the order in which they appear on the + * command line. + * + * If |insertion_point| is present, |name| must also be present. + */ + insertionPoint: string; + /** The file contents. */ + content: string; +} +export interface CodeGeneratorResponse_FileProtoMsg { + typeUrl: "/google.protobuf.compiler.File"; + value: Uint8Array; +} +/** Represents a single generated file. */ +export interface CodeGeneratorResponse_FileSDKType { + name: string; + insertion_point: string; + content: string; +} +function createBaseVersion(): Version { + return { + major: 0, + minor: 0, + patch: 0, + suffix: "" + }; +} +export const Version = { + typeUrl: "/google.protobuf.compiler.Version", + encode(message: Version, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.major !== undefined) { + writer.uint32(8).int32(message.major); + } + if (message.minor !== undefined) { + writer.uint32(16).int32(message.minor); + } + if (message.patch !== undefined) { + writer.uint32(24).int32(message.patch); + } + if (message.suffix !== undefined) { + writer.uint32(34).string(message.suffix); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Version { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseVersion(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.major = reader.int32(); + break; + case 2: + message.minor = reader.int32(); + break; + case 3: + message.patch = reader.int32(); + break; + case 4: + message.suffix = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Version { + const obj = createBaseVersion(); + if (isSet(object.major)) obj.major = Number(object.major); + if (isSet(object.minor)) obj.minor = Number(object.minor); + if (isSet(object.patch)) obj.patch = Number(object.patch); + if (isSet(object.suffix)) obj.suffix = String(object.suffix); + return obj; + }, + toJSON(message: Version): JsonSafe { + const obj: any = {}; + message.major !== undefined && (obj.major = Math.round(message.major)); + message.minor !== undefined && (obj.minor = Math.round(message.minor)); + message.patch !== undefined && (obj.patch = Math.round(message.patch)); + message.suffix !== undefined && (obj.suffix = message.suffix); + return obj; + }, + fromPartial(object: DeepPartial): Version { + const message = createBaseVersion(); + message.major = object.major ?? 0; + message.minor = object.minor ?? 0; + message.patch = object.patch ?? 0; + message.suffix = object.suffix ?? ""; + return message; + }, + fromSDK(object: VersionSDKType): Version { + return { + major: object?.major, + minor: object?.minor, + patch: object?.patch, + suffix: object?.suffix + }; + }, + fromSDKJSON(object: any): VersionSDKType { + return { + major: isSet(object.major) ? Number(object.major) : 0, + minor: isSet(object.minor) ? Number(object.minor) : 0, + patch: isSet(object.patch) ? Number(object.patch) : 0, + suffix: isSet(object.suffix) ? String(object.suffix) : "" + }; + }, + toSDK(message: Version): VersionSDKType { + const obj: any = {}; + obj.major = message.major; + obj.minor = message.minor; + obj.patch = message.patch; + obj.suffix = message.suffix; + return obj; + }, + fromAmino(object: VersionAmino): Version { + const message = createBaseVersion(); + if (object.major !== undefined && object.major !== null) { + message.major = object.major; + } + if (object.minor !== undefined && object.minor !== null) { + message.minor = object.minor; + } + if (object.patch !== undefined && object.patch !== null) { + message.patch = object.patch; + } + if (object.suffix !== undefined && object.suffix !== null) { + message.suffix = object.suffix; + } + return message; + }, + toAmino(message: Version): VersionAmino { + const obj: any = {}; + obj.major = message.major === 0 ? undefined : message.major; + obj.minor = message.minor === 0 ? undefined : message.minor; + obj.patch = message.patch === 0 ? undefined : message.patch; + obj.suffix = message.suffix === "" ? undefined : message.suffix; + return obj; + }, + fromAminoMsg(object: VersionAminoMsg): Version { + return Version.fromAmino(object.value); + }, + fromProtoMsg(message: VersionProtoMsg): Version { + return Version.decode(message.value); + }, + toProto(message: Version): Uint8Array { + return Version.encode(message).finish(); + }, + toProtoMsg(message: Version): VersionProtoMsg { + return { + typeUrl: "/google.protobuf.compiler.Version", + value: Version.encode(message).finish() + }; + } +}; +function createBaseCodeGeneratorRequest(): CodeGeneratorRequest { + return { + fileToGenerate: [], + parameter: "", + protoFile: [], + compilerVersion: undefined + }; +} +export const CodeGeneratorRequest = { + typeUrl: "/google.protobuf.compiler.CodeGeneratorRequest", + encode(message: CodeGeneratorRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.fileToGenerate) { + writer.uint32(10).string(v!); + } + if (message.parameter !== undefined) { + writer.uint32(18).string(message.parameter); + } + for (const v of message.protoFile) { + FileDescriptorProto.encode(v!, writer.uint32(122).fork()).ldelim(); + } + if (message.compilerVersion !== undefined) { + Version.encode(message.compilerVersion, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): CodeGeneratorRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCodeGeneratorRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.fileToGenerate.push(reader.string()); + break; + case 2: + message.parameter = reader.string(); + break; + case 15: + message.protoFile.push(FileDescriptorProto.decode(reader, reader.uint32())); + break; + case 3: + message.compilerVersion = Version.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): CodeGeneratorRequest { + const obj = createBaseCodeGeneratorRequest(); + if (Array.isArray(object?.fileToGenerate)) obj.fileToGenerate = object.fileToGenerate.map((e: any) => String(e)); + if (isSet(object.parameter)) obj.parameter = String(object.parameter); + if (Array.isArray(object?.protoFile)) obj.protoFile = object.protoFile.map((e: any) => FileDescriptorProto.fromJSON(e)); + if (isSet(object.compilerVersion)) obj.compilerVersion = Version.fromJSON(object.compilerVersion); + return obj; + }, + toJSON(message: CodeGeneratorRequest): JsonSafe { + const obj: any = {}; + if (message.fileToGenerate) { + obj.fileToGenerate = message.fileToGenerate.map(e => e); + } else { + obj.fileToGenerate = []; + } + message.parameter !== undefined && (obj.parameter = message.parameter); + if (message.protoFile) { + obj.protoFile = message.protoFile.map(e => e ? FileDescriptorProto.toJSON(e) : undefined); + } else { + obj.protoFile = []; + } + message.compilerVersion !== undefined && (obj.compilerVersion = message.compilerVersion ? Version.toJSON(message.compilerVersion) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): CodeGeneratorRequest { + const message = createBaseCodeGeneratorRequest(); + message.fileToGenerate = object.fileToGenerate?.map(e => e) || []; + message.parameter = object.parameter ?? ""; + message.protoFile = object.protoFile?.map(e => FileDescriptorProto.fromPartial(e)) || []; + if (object.compilerVersion !== undefined && object.compilerVersion !== null) { + message.compilerVersion = Version.fromPartial(object.compilerVersion); + } + return message; + }, + fromSDK(object: CodeGeneratorRequestSDKType): CodeGeneratorRequest { + return { + fileToGenerate: Array.isArray(object?.file_to_generate) ? object.file_to_generate.map((e: any) => e) : [], + parameter: object?.parameter, + protoFile: Array.isArray(object?.proto_file) ? object.proto_file.map((e: any) => FileDescriptorProto.fromSDK(e)) : [], + compilerVersion: object.compiler_version ? Version.fromSDK(object.compiler_version) : undefined + }; + }, + fromSDKJSON(object: any): CodeGeneratorRequestSDKType { + return { + file_to_generate: Array.isArray(object?.file_to_generate) ? object.file_to_generate.map((e: any) => String(e)) : [], + parameter: isSet(object.parameter) ? String(object.parameter) : "", + proto_file: Array.isArray(object?.proto_file) ? object.proto_file.map((e: any) => FileDescriptorProto.fromSDKJSON(e)) : [], + compiler_version: isSet(object.compiler_version) ? Version.fromSDKJSON(object.compiler_version) : undefined + }; + }, + toSDK(message: CodeGeneratorRequest): CodeGeneratorRequestSDKType { + const obj: any = {}; + if (message.fileToGenerate) { + obj.file_to_generate = message.fileToGenerate.map(e => e); + } else { + obj.file_to_generate = []; + } + obj.parameter = message.parameter; + if (message.protoFile) { + obj.proto_file = message.protoFile.map(e => e ? FileDescriptorProto.toSDK(e) : undefined); + } else { + obj.proto_file = []; + } + message.compilerVersion !== undefined && (obj.compiler_version = message.compilerVersion ? Version.toSDK(message.compilerVersion) : undefined); + return obj; + }, + fromAmino(object: CodeGeneratorRequestAmino): CodeGeneratorRequest { + const message = createBaseCodeGeneratorRequest(); + message.fileToGenerate = object.file_to_generate?.map(e => e) || []; + if (object.parameter !== undefined && object.parameter !== null) { + message.parameter = object.parameter; + } + message.protoFile = object.proto_file?.map(e => FileDescriptorProto.fromAmino(e)) || []; + if (object.compiler_version !== undefined && object.compiler_version !== null) { + message.compilerVersion = Version.fromAmino(object.compiler_version); + } + return message; + }, + toAmino(message: CodeGeneratorRequest): CodeGeneratorRequestAmino { + const obj: any = {}; + if (message.fileToGenerate) { + obj.file_to_generate = message.fileToGenerate.map(e => e); + } else { + obj.file_to_generate = message.fileToGenerate; + } + obj.parameter = message.parameter === "" ? undefined : message.parameter; + if (message.protoFile) { + obj.proto_file = message.protoFile.map(e => e ? FileDescriptorProto.toAmino(e) : undefined); + } else { + obj.proto_file = message.protoFile; + } + obj.compiler_version = message.compilerVersion ? Version.toAmino(message.compilerVersion) : undefined; + return obj; + }, + fromAminoMsg(object: CodeGeneratorRequestAminoMsg): CodeGeneratorRequest { + return CodeGeneratorRequest.fromAmino(object.value); + }, + fromProtoMsg(message: CodeGeneratorRequestProtoMsg): CodeGeneratorRequest { + return CodeGeneratorRequest.decode(message.value); + }, + toProto(message: CodeGeneratorRequest): Uint8Array { + return CodeGeneratorRequest.encode(message).finish(); + }, + toProtoMsg(message: CodeGeneratorRequest): CodeGeneratorRequestProtoMsg { + return { + typeUrl: "/google.protobuf.compiler.CodeGeneratorRequest", + value: CodeGeneratorRequest.encode(message).finish() + }; + } +}; +function createBaseCodeGeneratorResponse(): CodeGeneratorResponse { + return { + error: "", + file: [] + }; +} +export const CodeGeneratorResponse = { + typeUrl: "/google.protobuf.compiler.CodeGeneratorResponse", + encode(message: CodeGeneratorResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.error !== undefined) { + writer.uint32(10).string(message.error); + } + for (const v of message.file) { + CodeGeneratorResponse_File.encode(v!, writer.uint32(122).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): CodeGeneratorResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCodeGeneratorResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.error = reader.string(); + break; + case 15: + message.file.push(CodeGeneratorResponse_File.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): CodeGeneratorResponse { + const obj = createBaseCodeGeneratorResponse(); + if (isSet(object.error)) obj.error = String(object.error); + if (Array.isArray(object?.file)) obj.file = object.file.map((e: any) => CodeGeneratorResponse_File.fromJSON(e)); + return obj; + }, + toJSON(message: CodeGeneratorResponse): JsonSafe { + const obj: any = {}; + message.error !== undefined && (obj.error = message.error); + if (message.file) { + obj.file = message.file.map(e => e ? CodeGeneratorResponse_File.toJSON(e) : undefined); + } else { + obj.file = []; + } + return obj; + }, + fromPartial(object: DeepPartial): CodeGeneratorResponse { + const message = createBaseCodeGeneratorResponse(); + message.error = object.error ?? ""; + message.file = object.file?.map(e => CodeGeneratorResponse_File.fromPartial(e)) || []; + return message; + }, + fromSDK(object: CodeGeneratorResponseSDKType): CodeGeneratorResponse { + return { + error: object?.error, + file: Array.isArray(object?.file) ? object.file.map((e: any) => CodeGeneratorResponse_File.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): CodeGeneratorResponseSDKType { + return { + error: isSet(object.error) ? String(object.error) : "", + file: Array.isArray(object?.file) ? object.file.map((e: any) => CodeGeneratorResponse_File.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: CodeGeneratorResponse): CodeGeneratorResponseSDKType { + const obj: any = {}; + obj.error = message.error; + if (message.file) { + obj.file = message.file.map(e => e ? CodeGeneratorResponse_File.toSDK(e) : undefined); + } else { + obj.file = []; + } + return obj; + }, + fromAmino(object: CodeGeneratorResponseAmino): CodeGeneratorResponse { + const message = createBaseCodeGeneratorResponse(); + if (object.error !== undefined && object.error !== null) { + message.error = object.error; + } + message.file = object.file?.map(e => CodeGeneratorResponse_File.fromAmino(e)) || []; + return message; + }, + toAmino(message: CodeGeneratorResponse): CodeGeneratorResponseAmino { + const obj: any = {}; + obj.error = message.error === "" ? undefined : message.error; + if (message.file) { + obj.file = message.file.map(e => e ? CodeGeneratorResponse_File.toAmino(e) : undefined); + } else { + obj.file = message.file; + } + return obj; + }, + fromAminoMsg(object: CodeGeneratorResponseAminoMsg): CodeGeneratorResponse { + return CodeGeneratorResponse.fromAmino(object.value); + }, + fromProtoMsg(message: CodeGeneratorResponseProtoMsg): CodeGeneratorResponse { + return CodeGeneratorResponse.decode(message.value); + }, + toProto(message: CodeGeneratorResponse): Uint8Array { + return CodeGeneratorResponse.encode(message).finish(); + }, + toProtoMsg(message: CodeGeneratorResponse): CodeGeneratorResponseProtoMsg { + return { + typeUrl: "/google.protobuf.compiler.CodeGeneratorResponse", + value: CodeGeneratorResponse.encode(message).finish() + }; + } +}; +function createBaseCodeGeneratorResponse_File(): CodeGeneratorResponse_File { + return { + name: "", + insertionPoint: "", + content: "" + }; +} +export const CodeGeneratorResponse_File = { + typeUrl: "/google.protobuf.compiler.File", + encode(message: CodeGeneratorResponse_File, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + if (message.insertionPoint !== undefined) { + writer.uint32(18).string(message.insertionPoint); + } + if (message.content !== undefined) { + writer.uint32(122).string(message.content); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): CodeGeneratorResponse_File { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCodeGeneratorResponse_File(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.insertionPoint = reader.string(); + break; + case 15: + message.content = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): CodeGeneratorResponse_File { + const obj = createBaseCodeGeneratorResponse_File(); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.insertionPoint)) obj.insertionPoint = String(object.insertionPoint); + if (isSet(object.content)) obj.content = String(object.content); + return obj; + }, + toJSON(message: CodeGeneratorResponse_File): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.insertionPoint !== undefined && (obj.insertionPoint = message.insertionPoint); + message.content !== undefined && (obj.content = message.content); + return obj; + }, + fromPartial(object: DeepPartial): CodeGeneratorResponse_File { + const message = createBaseCodeGeneratorResponse_File(); + message.name = object.name ?? ""; + message.insertionPoint = object.insertionPoint ?? ""; + message.content = object.content ?? ""; + return message; + }, + fromSDK(object: CodeGeneratorResponse_FileSDKType): CodeGeneratorResponse_File { + return { + name: object?.name, + insertionPoint: object?.insertion_point, + content: object?.content + }; + }, + fromSDKJSON(object: any): CodeGeneratorResponse_FileSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + insertion_point: isSet(object.insertion_point) ? String(object.insertion_point) : "", + content: isSet(object.content) ? String(object.content) : "" + }; + }, + toSDK(message: CodeGeneratorResponse_File): CodeGeneratorResponse_FileSDKType { + const obj: any = {}; + obj.name = message.name; + obj.insertion_point = message.insertionPoint; + obj.content = message.content; + return obj; + }, + fromAmino(object: CodeGeneratorResponse_FileAmino): CodeGeneratorResponse_File { + const message = createBaseCodeGeneratorResponse_File(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + if (object.insertion_point !== undefined && object.insertion_point !== null) { + message.insertionPoint = object.insertion_point; + } + if (object.content !== undefined && object.content !== null) { + message.content = object.content; + } + return message; + }, + toAmino(message: CodeGeneratorResponse_File): CodeGeneratorResponse_FileAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + obj.insertion_point = message.insertionPoint === "" ? undefined : message.insertionPoint; + obj.content = message.content === "" ? undefined : message.content; + return obj; + }, + fromAminoMsg(object: CodeGeneratorResponse_FileAminoMsg): CodeGeneratorResponse_File { + return CodeGeneratorResponse_File.fromAmino(object.value); + }, + fromProtoMsg(message: CodeGeneratorResponse_FileProtoMsg): CodeGeneratorResponse_File { + return CodeGeneratorResponse_File.decode(message.value); + }, + toProto(message: CodeGeneratorResponse_File): Uint8Array { + return CodeGeneratorResponse_File.encode(message).finish(); + }, + toProtoMsg(message: CodeGeneratorResponse_File): CodeGeneratorResponse_FileProtoMsg { + return { + typeUrl: "/google.protobuf.compiler.File", + value: CodeGeneratorResponse_File.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/protobuf/descriptor.ts b/__fixtures__/v-next/outputicjsdeps/google/protobuf/descriptor.ts new file mode 100644 index 0000000000..91fbd835f5 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/protobuf/descriptor.ts @@ -0,0 +1,5842 @@ +import { BinaryReader, BinaryWriter } from "../../binary.js"; +import { JsonSafe } from "../../json-safe.js"; +import { DeepPartial, isSet, bytesFromBase64, base64FromBytes } from "../../helpers.js"; +export const protobufPackage = "google.protobuf"; +export enum FieldDescriptorProto_Type { + /** + * TYPE_DOUBLE - 0 is reserved for errors. + * Order is weird for historical reasons. + */ + TYPE_DOUBLE = 1, + TYPE_FLOAT = 2, + /** + * TYPE_INT64 - Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if + * negative values are likely. + */ + TYPE_INT64 = 3, + TYPE_UINT64 = 4, + /** + * TYPE_INT32 - Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if + * negative values are likely. + */ + TYPE_INT32 = 5, + TYPE_FIXED64 = 6, + TYPE_FIXED32 = 7, + TYPE_BOOL = 8, + TYPE_STRING = 9, + /** + * TYPE_GROUP - Tag-delimited aggregate. + * Group type is deprecated and not supported in proto3. However, Proto3 + * implementations should still be able to parse the group wire format and + * treat group fields as unknown fields. + */ + TYPE_GROUP = 10, + /** TYPE_MESSAGE - Length-delimited aggregate. */ + TYPE_MESSAGE = 11, + /** TYPE_BYTES - New in version 2. */ + TYPE_BYTES = 12, + TYPE_UINT32 = 13, + TYPE_ENUM = 14, + TYPE_SFIXED32 = 15, + TYPE_SFIXED64 = 16, + /** TYPE_SINT32 - Uses ZigZag encoding. */ + TYPE_SINT32 = 17, + /** TYPE_SINT64 - Uses ZigZag encoding. */ + TYPE_SINT64 = 18, + UNRECOGNIZED = -1, +} +export const FieldDescriptorProto_TypeSDKType = FieldDescriptorProto_Type; +export function fieldDescriptorProto_TypeFromJSON(object: any): FieldDescriptorProto_Type { + switch (object) { + case 1: + case "TYPE_DOUBLE": + return FieldDescriptorProto_Type.TYPE_DOUBLE; + case 2: + case "TYPE_FLOAT": + return FieldDescriptorProto_Type.TYPE_FLOAT; + case 3: + case "TYPE_INT64": + return FieldDescriptorProto_Type.TYPE_INT64; + case 4: + case "TYPE_UINT64": + return FieldDescriptorProto_Type.TYPE_UINT64; + case 5: + case "TYPE_INT32": + return FieldDescriptorProto_Type.TYPE_INT32; + case 6: + case "TYPE_FIXED64": + return FieldDescriptorProto_Type.TYPE_FIXED64; + case 7: + case "TYPE_FIXED32": + return FieldDescriptorProto_Type.TYPE_FIXED32; + case 8: + case "TYPE_BOOL": + return FieldDescriptorProto_Type.TYPE_BOOL; + case 9: + case "TYPE_STRING": + return FieldDescriptorProto_Type.TYPE_STRING; + case 10: + case "TYPE_GROUP": + return FieldDescriptorProto_Type.TYPE_GROUP; + case 11: + case "TYPE_MESSAGE": + return FieldDescriptorProto_Type.TYPE_MESSAGE; + case 12: + case "TYPE_BYTES": + return FieldDescriptorProto_Type.TYPE_BYTES; + case 13: + case "TYPE_UINT32": + return FieldDescriptorProto_Type.TYPE_UINT32; + case 14: + case "TYPE_ENUM": + return FieldDescriptorProto_Type.TYPE_ENUM; + case 15: + case "TYPE_SFIXED32": + return FieldDescriptorProto_Type.TYPE_SFIXED32; + case 16: + case "TYPE_SFIXED64": + return FieldDescriptorProto_Type.TYPE_SFIXED64; + case 17: + case "TYPE_SINT32": + return FieldDescriptorProto_Type.TYPE_SINT32; + case 18: + case "TYPE_SINT64": + return FieldDescriptorProto_Type.TYPE_SINT64; + case -1: + case "UNRECOGNIZED": + default: + return FieldDescriptorProto_Type.UNRECOGNIZED; + } +} +export function fieldDescriptorProto_TypeToJSON(object: FieldDescriptorProto_Type): string { + switch (object) { + case FieldDescriptorProto_Type.TYPE_DOUBLE: + return "TYPE_DOUBLE"; + case FieldDescriptorProto_Type.TYPE_FLOAT: + return "TYPE_FLOAT"; + case FieldDescriptorProto_Type.TYPE_INT64: + return "TYPE_INT64"; + case FieldDescriptorProto_Type.TYPE_UINT64: + return "TYPE_UINT64"; + case FieldDescriptorProto_Type.TYPE_INT32: + return "TYPE_INT32"; + case FieldDescriptorProto_Type.TYPE_FIXED64: + return "TYPE_FIXED64"; + case FieldDescriptorProto_Type.TYPE_FIXED32: + return "TYPE_FIXED32"; + case FieldDescriptorProto_Type.TYPE_BOOL: + return "TYPE_BOOL"; + case FieldDescriptorProto_Type.TYPE_STRING: + return "TYPE_STRING"; + case FieldDescriptorProto_Type.TYPE_GROUP: + return "TYPE_GROUP"; + case FieldDescriptorProto_Type.TYPE_MESSAGE: + return "TYPE_MESSAGE"; + case FieldDescriptorProto_Type.TYPE_BYTES: + return "TYPE_BYTES"; + case FieldDescriptorProto_Type.TYPE_UINT32: + return "TYPE_UINT32"; + case FieldDescriptorProto_Type.TYPE_ENUM: + return "TYPE_ENUM"; + case FieldDescriptorProto_Type.TYPE_SFIXED32: + return "TYPE_SFIXED32"; + case FieldDescriptorProto_Type.TYPE_SFIXED64: + return "TYPE_SFIXED64"; + case FieldDescriptorProto_Type.TYPE_SINT32: + return "TYPE_SINT32"; + case FieldDescriptorProto_Type.TYPE_SINT64: + return "TYPE_SINT64"; + case FieldDescriptorProto_Type.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +export enum FieldDescriptorProto_Label { + /** LABEL_OPTIONAL - 0 is reserved for errors */ + LABEL_OPTIONAL = 1, + LABEL_REQUIRED = 2, + LABEL_REPEATED = 3, + UNRECOGNIZED = -1, +} +export const FieldDescriptorProto_LabelSDKType = FieldDescriptorProto_Label; +export function fieldDescriptorProto_LabelFromJSON(object: any): FieldDescriptorProto_Label { + switch (object) { + case 1: + case "LABEL_OPTIONAL": + return FieldDescriptorProto_Label.LABEL_OPTIONAL; + case 2: + case "LABEL_REQUIRED": + return FieldDescriptorProto_Label.LABEL_REQUIRED; + case 3: + case "LABEL_REPEATED": + return FieldDescriptorProto_Label.LABEL_REPEATED; + case -1: + case "UNRECOGNIZED": + default: + return FieldDescriptorProto_Label.UNRECOGNIZED; + } +} +export function fieldDescriptorProto_LabelToJSON(object: FieldDescriptorProto_Label): string { + switch (object) { + case FieldDescriptorProto_Label.LABEL_OPTIONAL: + return "LABEL_OPTIONAL"; + case FieldDescriptorProto_Label.LABEL_REQUIRED: + return "LABEL_REQUIRED"; + case FieldDescriptorProto_Label.LABEL_REPEATED: + return "LABEL_REPEATED"; + case FieldDescriptorProto_Label.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** Generated classes can be optimized for speed or code size. */ +export enum FileOptions_OptimizeMode { + /** SPEED - Generate complete code for parsing, serialization, */ + SPEED = 1, + /** CODE_SIZE - etc. */ + CODE_SIZE = 2, + /** LITE_RUNTIME - Generate code using MessageLite and the lite runtime. */ + LITE_RUNTIME = 3, + UNRECOGNIZED = -1, +} +export const FileOptions_OptimizeModeSDKType = FileOptions_OptimizeMode; +export function fileOptions_OptimizeModeFromJSON(object: any): FileOptions_OptimizeMode { + switch (object) { + case 1: + case "SPEED": + return FileOptions_OptimizeMode.SPEED; + case 2: + case "CODE_SIZE": + return FileOptions_OptimizeMode.CODE_SIZE; + case 3: + case "LITE_RUNTIME": + return FileOptions_OptimizeMode.LITE_RUNTIME; + case -1: + case "UNRECOGNIZED": + default: + return FileOptions_OptimizeMode.UNRECOGNIZED; + } +} +export function fileOptions_OptimizeModeToJSON(object: FileOptions_OptimizeMode): string { + switch (object) { + case FileOptions_OptimizeMode.SPEED: + return "SPEED"; + case FileOptions_OptimizeMode.CODE_SIZE: + return "CODE_SIZE"; + case FileOptions_OptimizeMode.LITE_RUNTIME: + return "LITE_RUNTIME"; + case FileOptions_OptimizeMode.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +export enum FieldOptions_CType { + /** STRING - Default mode. */ + STRING = 0, + CORD = 1, + STRING_PIECE = 2, + UNRECOGNIZED = -1, +} +export const FieldOptions_CTypeSDKType = FieldOptions_CType; +export function fieldOptions_CTypeFromJSON(object: any): FieldOptions_CType { + switch (object) { + case 0: + case "STRING": + return FieldOptions_CType.STRING; + case 1: + case "CORD": + return FieldOptions_CType.CORD; + case 2: + case "STRING_PIECE": + return FieldOptions_CType.STRING_PIECE; + case -1: + case "UNRECOGNIZED": + default: + return FieldOptions_CType.UNRECOGNIZED; + } +} +export function fieldOptions_CTypeToJSON(object: FieldOptions_CType): string { + switch (object) { + case FieldOptions_CType.STRING: + return "STRING"; + case FieldOptions_CType.CORD: + return "CORD"; + case FieldOptions_CType.STRING_PIECE: + return "STRING_PIECE"; + case FieldOptions_CType.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +export enum FieldOptions_JSType { + /** JS_NORMAL - Use the default type. */ + JS_NORMAL = 0, + /** JS_STRING - Use JavaScript strings. */ + JS_STRING = 1, + /** JS_NUMBER - Use JavaScript numbers. */ + JS_NUMBER = 2, + UNRECOGNIZED = -1, +} +export const FieldOptions_JSTypeSDKType = FieldOptions_JSType; +export function fieldOptions_JSTypeFromJSON(object: any): FieldOptions_JSType { + switch (object) { + case 0: + case "JS_NORMAL": + return FieldOptions_JSType.JS_NORMAL; + case 1: + case "JS_STRING": + return FieldOptions_JSType.JS_STRING; + case 2: + case "JS_NUMBER": + return FieldOptions_JSType.JS_NUMBER; + case -1: + case "UNRECOGNIZED": + default: + return FieldOptions_JSType.UNRECOGNIZED; + } +} +export function fieldOptions_JSTypeToJSON(object: FieldOptions_JSType): string { + switch (object) { + case FieldOptions_JSType.JS_NORMAL: + return "JS_NORMAL"; + case FieldOptions_JSType.JS_STRING: + return "JS_STRING"; + case FieldOptions_JSType.JS_NUMBER: + return "JS_NUMBER"; + case FieldOptions_JSType.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** + * Is this method side-effect-free (or safe in HTTP parlance), or idempotent, + * or neither? HTTP based RPC implementation may choose GET verb for safe + * methods, and PUT verb for idempotent methods instead of the default POST. + */ +export enum MethodOptions_IdempotencyLevel { + IDEMPOTENCY_UNKNOWN = 0, + /** NO_SIDE_EFFECTS - implies idempotent */ + NO_SIDE_EFFECTS = 1, + /** IDEMPOTENT - idempotent, but may have side effects */ + IDEMPOTENT = 2, + UNRECOGNIZED = -1, +} +export const MethodOptions_IdempotencyLevelSDKType = MethodOptions_IdempotencyLevel; +export function methodOptions_IdempotencyLevelFromJSON(object: any): MethodOptions_IdempotencyLevel { + switch (object) { + case 0: + case "IDEMPOTENCY_UNKNOWN": + return MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN; + case 1: + case "NO_SIDE_EFFECTS": + return MethodOptions_IdempotencyLevel.NO_SIDE_EFFECTS; + case 2: + case "IDEMPOTENT": + return MethodOptions_IdempotencyLevel.IDEMPOTENT; + case -1: + case "UNRECOGNIZED": + default: + return MethodOptions_IdempotencyLevel.UNRECOGNIZED; + } +} +export function methodOptions_IdempotencyLevelToJSON(object: MethodOptions_IdempotencyLevel): string { + switch (object) { + case MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN: + return "IDEMPOTENCY_UNKNOWN"; + case MethodOptions_IdempotencyLevel.NO_SIDE_EFFECTS: + return "NO_SIDE_EFFECTS"; + case MethodOptions_IdempotencyLevel.IDEMPOTENT: + return "IDEMPOTENT"; + case MethodOptions_IdempotencyLevel.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** + * The protocol compiler can output a FileDescriptorSet containing the .proto + * files it parses. + */ +export interface FileDescriptorSet { + file: FileDescriptorProto[]; +} +export interface FileDescriptorSetProtoMsg { + typeUrl: "/google.protobuf.FileDescriptorSet"; + value: Uint8Array; +} +/** + * The protocol compiler can output a FileDescriptorSet containing the .proto + * files it parses. + */ +export interface FileDescriptorSetSDKType { + file: FileDescriptorProtoSDKType[]; +} +/** Describes a complete .proto file. */ +export interface FileDescriptorProto { + /** file name, relative to root of source tree */ + name: string; + /** e.g. "foo", "foo.bar", etc. */ + package: string; + /** Names of files imported by this file. */ + dependency: string[]; + /** Indexes of the public imported files in the dependency list above. */ + publicDependency: number[]; + /** + * Indexes of the weak imported files in the dependency list. + * For Google-internal migration only. Do not use. + */ + weakDependency: number[]; + /** All top-level definitions in this file. */ + messageType: DescriptorProto[]; + enumType: EnumDescriptorProto[]; + service: ServiceDescriptorProto[]; + extension: FieldDescriptorProto[]; + options?: FileOptions; + /** + * This field contains optional information about the original source code. + * You may safely remove this entire field without harming runtime + * functionality of the descriptors -- the information is needed only by + * development tools. + */ + sourceCodeInfo?: SourceCodeInfo; + /** + * The syntax of the proto file. + * The supported values are "proto2" and "proto3". + */ + syntax: string; +} +export interface FileDescriptorProtoProtoMsg { + typeUrl: "/google.protobuf.FileDescriptorProto"; + value: Uint8Array; +} +/** Describes a complete .proto file. */ +export interface FileDescriptorProtoSDKType { + name: string; + package: string; + dependency: string[]; + public_dependency: number[]; + weak_dependency: number[]; + message_type: DescriptorProtoSDKType[]; + enum_type: EnumDescriptorProtoSDKType[]; + service: ServiceDescriptorProtoSDKType[]; + extension: FieldDescriptorProtoSDKType[]; + options?: FileOptionsSDKType; + source_code_info?: SourceCodeInfoSDKType; + syntax: string; +} +/** Describes a message type. */ +export interface DescriptorProto { + name: string; + field: FieldDescriptorProto[]; + extension: FieldDescriptorProto[]; + nestedType: DescriptorProto[]; + enumType: EnumDescriptorProto[]; + extensionRange: DescriptorProto_ExtensionRange[]; + oneofDecl: OneofDescriptorProto[]; + options?: MessageOptions; + reservedRange: DescriptorProto_ReservedRange[]; + /** + * Reserved field names, which may not be used by fields in the same message. + * A given name may only be reserved once. + */ + reservedName: string[]; +} +export interface DescriptorProtoProtoMsg { + typeUrl: "/google.protobuf.DescriptorProto"; + value: Uint8Array; +} +/** Describes a message type. */ +export interface DescriptorProtoSDKType { + name: string; + field: FieldDescriptorProtoSDKType[]; + extension: FieldDescriptorProtoSDKType[]; + nested_type: DescriptorProtoSDKType[]; + enum_type: EnumDescriptorProtoSDKType[]; + extension_range: DescriptorProto_ExtensionRangeSDKType[]; + oneof_decl: OneofDescriptorProtoSDKType[]; + options?: MessageOptionsSDKType; + reserved_range: DescriptorProto_ReservedRangeSDKType[]; + reserved_name: string[]; +} +export interface DescriptorProto_ExtensionRange { + /** Inclusive. */ + start: number; + /** Exclusive. */ + end: number; + options?: ExtensionRangeOptions; +} +export interface DescriptorProto_ExtensionRangeProtoMsg { + typeUrl: "/google.protobuf.ExtensionRange"; + value: Uint8Array; +} +export interface DescriptorProto_ExtensionRangeSDKType { + start: number; + end: number; + options?: ExtensionRangeOptionsSDKType; +} +/** + * Range of reserved tag numbers. Reserved tag numbers may not be used by + * fields or extension ranges in the same message. Reserved ranges may + * not overlap. + */ +export interface DescriptorProto_ReservedRange { + /** Inclusive. */ + start: number; + /** Exclusive. */ + end: number; +} +export interface DescriptorProto_ReservedRangeProtoMsg { + typeUrl: "/google.protobuf.ReservedRange"; + value: Uint8Array; +} +/** + * Range of reserved tag numbers. Reserved tag numbers may not be used by + * fields or extension ranges in the same message. Reserved ranges may + * not overlap. + */ +export interface DescriptorProto_ReservedRangeSDKType { + start: number; + end: number; +} +export interface ExtensionRangeOptions { + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} +export interface ExtensionRangeOptionsProtoMsg { + typeUrl: "/google.protobuf.ExtensionRangeOptions"; + value: Uint8Array; +} +export interface ExtensionRangeOptionsSDKType { + uninterpreted_option: UninterpretedOptionSDKType[]; +} +/** Describes a field within a message. */ +export interface FieldDescriptorProto { + name: string; + number: number; + label: FieldDescriptorProto_Label; + /** + * If type_name is set, this need not be set. If both this and type_name + * are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP. + */ + type: FieldDescriptorProto_Type; + /** + * For message and enum types, this is the name of the type. If the name + * starts with a '.', it is fully-qualified. Otherwise, C++-like scoping + * rules are used to find the type (i.e. first the nested types within this + * message are searched, then within the parent, on up to the root + * namespace). + */ + typeName: string; + /** + * For extensions, this is the name of the type being extended. It is + * resolved in the same manner as type_name. + */ + extendee: string; + /** + * For numeric types, contains the original text representation of the value. + * For booleans, "true" or "false". + * For strings, contains the default text contents (not escaped in any way). + * For bytes, contains the C escaped value. All bytes >= 128 are escaped. + * TODO(kenton): Base-64 encode? + */ + defaultValue: string; + /** + * If set, gives the index of a oneof in the containing type's oneof_decl + * list. This field is a member of that oneof. + */ + oneofIndex: number; + /** + * JSON name of this field. The value is set by protocol compiler. If the + * user has set a "json_name" option on this field, that option's value + * will be used. Otherwise, it's deduced from the field's name by converting + * it to camelCase. + */ + jsonName: string; + options?: FieldOptions; +} +export interface FieldDescriptorProtoProtoMsg { + typeUrl: "/google.protobuf.FieldDescriptorProto"; + value: Uint8Array; +} +/** Describes a field within a message. */ +export interface FieldDescriptorProtoSDKType { + name: string; + number: number; + label: FieldDescriptorProto_Label; + type: FieldDescriptorProto_Type; + type_name: string; + extendee: string; + default_value: string; + oneof_index: number; + json_name: string; + options?: FieldOptionsSDKType; +} +/** Describes a oneof. */ +export interface OneofDescriptorProto { + name: string; + options?: OneofOptions; +} +export interface OneofDescriptorProtoProtoMsg { + typeUrl: "/google.protobuf.OneofDescriptorProto"; + value: Uint8Array; +} +/** Describes a oneof. */ +export interface OneofDescriptorProtoSDKType { + name: string; + options?: OneofOptionsSDKType; +} +/** Describes an enum type. */ +export interface EnumDescriptorProto { + name: string; + value: EnumValueDescriptorProto[]; + options?: EnumOptions; + /** + * Range of reserved numeric values. Reserved numeric values may not be used + * by enum values in the same enum declaration. Reserved ranges may not + * overlap. + */ + reservedRange: EnumDescriptorProto_EnumReservedRange[]; + /** + * Reserved enum value names, which may not be reused. A given name may only + * be reserved once. + */ + reservedName: string[]; +} +export interface EnumDescriptorProtoProtoMsg { + typeUrl: "/google.protobuf.EnumDescriptorProto"; + value: Uint8Array; +} +/** Describes an enum type. */ +export interface EnumDescriptorProtoSDKType { + name: string; + value: EnumValueDescriptorProtoSDKType[]; + options?: EnumOptionsSDKType; + reserved_range: EnumDescriptorProto_EnumReservedRangeSDKType[]; + reserved_name: string[]; +} +/** + * Range of reserved numeric values. Reserved values may not be used by + * entries in the same enum. Reserved ranges may not overlap. + * + * Note that this is distinct from DescriptorProto.ReservedRange in that it + * is inclusive such that it can appropriately represent the entire int32 + * domain. + */ +export interface EnumDescriptorProto_EnumReservedRange { + /** Inclusive. */ + start: number; + /** Inclusive. */ + end: number; +} +export interface EnumDescriptorProto_EnumReservedRangeProtoMsg { + typeUrl: "/google.protobuf.EnumReservedRange"; + value: Uint8Array; +} +/** + * Range of reserved numeric values. Reserved values may not be used by + * entries in the same enum. Reserved ranges may not overlap. + * + * Note that this is distinct from DescriptorProto.ReservedRange in that it + * is inclusive such that it can appropriately represent the entire int32 + * domain. + */ +export interface EnumDescriptorProto_EnumReservedRangeSDKType { + start: number; + end: number; +} +/** Describes a value within an enum. */ +export interface EnumValueDescriptorProto { + name: string; + number: number; + options?: EnumValueOptions; +} +export interface EnumValueDescriptorProtoProtoMsg { + typeUrl: "/google.protobuf.EnumValueDescriptorProto"; + value: Uint8Array; +} +/** Describes a value within an enum. */ +export interface EnumValueDescriptorProtoSDKType { + name: string; + number: number; + options?: EnumValueOptionsSDKType; +} +/** Describes a service. */ +export interface ServiceDescriptorProto { + name: string; + method: MethodDescriptorProto[]; + options?: ServiceOptions; +} +export interface ServiceDescriptorProtoProtoMsg { + typeUrl: "/google.protobuf.ServiceDescriptorProto"; + value: Uint8Array; +} +/** Describes a service. */ +export interface ServiceDescriptorProtoSDKType { + name: string; + method: MethodDescriptorProtoSDKType[]; + options?: ServiceOptionsSDKType; +} +/** Describes a method of a service. */ +export interface MethodDescriptorProto { + name: string; + /** + * Input and output type names. These are resolved in the same way as + * FieldDescriptorProto.type_name, but must refer to a message type. + */ + inputType: string; + outputType: string; + options?: MethodOptions; + /** Identifies if client streams multiple client messages */ + clientStreaming: boolean; + /** Identifies if server streams multiple server messages */ + serverStreaming: boolean; +} +export interface MethodDescriptorProtoProtoMsg { + typeUrl: "/google.protobuf.MethodDescriptorProto"; + value: Uint8Array; +} +/** Describes a method of a service. */ +export interface MethodDescriptorProtoSDKType { + name: string; + input_type: string; + output_type: string; + options?: MethodOptionsSDKType; + client_streaming: boolean; + server_streaming: boolean; +} +export interface FileOptions { + /** + * Sets the Java package where classes generated from this .proto will be + * placed. By default, the proto package is used, but this is often + * inappropriate because proto packages do not normally start with backwards + * domain names. + */ + javaPackage: string; + /** + * If set, all the classes from the .proto file are wrapped in a single + * outer class with the given name. This applies to both Proto1 + * (equivalent to the old "--one_java_file" option) and Proto2 (where + * a .proto always translates to a single class, but you may want to + * explicitly choose the class name). + */ + javaOuterClassname: string; + /** + * If set true, then the Java code generator will generate a separate .java + * file for each top-level message, enum, and service defined in the .proto + * file. Thus, these types will *not* be nested inside the outer class + * named by java_outer_classname. However, the outer class will still be + * generated to contain the file's getDescriptor() method as well as any + * top-level extensions defined in the file. + */ + javaMultipleFiles: boolean; + /** This option does nothing. */ + /** @deprecated */ + javaGenerateEqualsAndHash: boolean; + /** + * If set true, then the Java2 code generator will generate code that + * throws an exception whenever an attempt is made to assign a non-UTF-8 + * byte sequence to a string field. + * Message reflection will do the same. + * However, an extension field still accepts non-UTF-8 byte sequences. + * This option has no effect on when used with the lite runtime. + */ + javaStringCheckUtf8: boolean; + optimizeFor: FileOptions_OptimizeMode; + /** + * Sets the Go package where structs generated from this .proto will be + * placed. If omitted, the Go package will be derived from the following: + * - The basename of the package import path, if provided. + * - Otherwise, the package statement in the .proto file, if present. + * - Otherwise, the basename of the .proto file, without extension. + */ + goPackage: string; + /** + * Should generic services be generated in each language? "Generic" services + * are not specific to any particular RPC system. They are generated by the + * main code generators in each language (without additional plugins). + * Generic services were the only kind of service generation supported by + * early versions of google.protobuf. + * + * Generic services are now considered deprecated in favor of using plugins + * that generate code specific to your particular RPC system. Therefore, + * these default to false. Old code which depends on generic services should + * explicitly set them to true. + */ + ccGenericServices: boolean; + javaGenericServices: boolean; + pyGenericServices: boolean; + phpGenericServices: boolean; + /** + * Is this file deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for everything in the file, or it will be completely ignored; in the very + * least, this is a formalization for deprecating files. + */ + deprecated: boolean; + /** + * Enables the use of arenas for the proto messages in this file. This applies + * only to generated classes for C++. + */ + ccEnableArenas: boolean; + /** + * Sets the objective c class prefix which is prepended to all objective c + * generated classes from this .proto. There is no default. + */ + objcClassPrefix: string; + /** Namespace for generated classes; defaults to the package. */ + csharpNamespace: string; + /** + * By default Swift generators will take the proto package and CamelCase it + * replacing '.' with underscore and use that to prefix the types/symbols + * defined. When this options is provided, they will use this value instead + * to prefix the types/symbols defined. + */ + swiftPrefix: string; + /** + * Sets the php class prefix which is prepended to all php generated classes + * from this .proto. Default is empty. + */ + phpClassPrefix: string; + /** + * Use this option to change the namespace of php generated classes. Default + * is empty. When this option is empty, the package name will be used for + * determining the namespace. + */ + phpNamespace: string; + /** + * Use this option to change the namespace of php generated metadata classes. + * Default is empty. When this option is empty, the proto file name will be + * used for determining the namespace. + */ + phpMetadataNamespace: string; + /** + * Use this option to change the package of ruby generated classes. Default + * is empty. When this option is not set, the package name will be used for + * determining the ruby package. + */ + rubyPackage: string; + /** + * The parser stores options it doesn't recognize here. + * See the documentation for the "Options" section above. + */ + uninterpretedOption: UninterpretedOption[]; +} +export interface FileOptionsProtoMsg { + typeUrl: "/google.protobuf.FileOptions"; + value: Uint8Array; +} +export interface FileOptionsSDKType { + java_package: string; + java_outer_classname: string; + java_multiple_files: boolean; + /** @deprecated */ + java_generate_equals_and_hash: boolean; + java_string_check_utf8: boolean; + optimize_for: FileOptions_OptimizeMode; + go_package: string; + cc_generic_services: boolean; + java_generic_services: boolean; + py_generic_services: boolean; + php_generic_services: boolean; + deprecated: boolean; + cc_enable_arenas: boolean; + objc_class_prefix: string; + csharp_namespace: string; + swift_prefix: string; + php_class_prefix: string; + php_namespace: string; + php_metadata_namespace: string; + ruby_package: string; + uninterpreted_option: UninterpretedOptionSDKType[]; +} +export interface MessageOptions { + /** + * Set true to use the old proto1 MessageSet wire format for extensions. + * This is provided for backwards-compatibility with the MessageSet wire + * format. You should not use this for any other reason: It's less + * efficient, has fewer features, and is more complicated. + * + * The message must be defined exactly as follows: + * message Foo { + * option message_set_wire_format = true; + * extensions 4 to max; + * } + * Note that the message cannot have any defined fields; MessageSets only + * have extensions. + * + * All extensions of your type must be singular messages; e.g. they cannot + * be int32s, enums, or repeated messages. + * + * Because this is an option, the above two restrictions are not enforced by + * the protocol compiler. + */ + messageSetWireFormat: boolean; + /** + * Disables the generation of the standard "descriptor()" accessor, which can + * conflict with a field of the same name. This is meant to make migration + * from proto1 easier; new code should avoid fields named "descriptor". + */ + noStandardDescriptorAccessor: boolean; + /** + * Is this message deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the message, or it will be completely ignored; in the very least, + * this is a formalization for deprecating messages. + */ + deprecated: boolean; + /** + * Whether the message is an automatically generated map entry type for the + * maps field. + * + * For maps fields: + * map map_field = 1; + * The parsed descriptor looks like: + * message MapFieldEntry { + * option map_entry = true; + * optional KeyType key = 1; + * optional ValueType value = 2; + * } + * repeated MapFieldEntry map_field = 1; + * + * Implementations may choose not to generate the map_entry=true message, but + * use a native map in the target language to hold the keys and values. + * The reflection APIs in such implementations still need to work as + * if the field is a repeated message field. + * + * NOTE: Do not set the option in .proto files. Always use the maps syntax + * instead. The option should only be implicitly set by the proto compiler + * parser. + */ + mapEntry: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} +export interface MessageOptionsProtoMsg { + typeUrl: "/google.protobuf.MessageOptions"; + value: Uint8Array; +} +export interface MessageOptionsSDKType { + message_set_wire_format: boolean; + no_standard_descriptor_accessor: boolean; + deprecated: boolean; + map_entry: boolean; + uninterpreted_option: UninterpretedOptionSDKType[]; +} +export interface FieldOptions { + /** + * The ctype option instructs the C++ code generator to use a different + * representation of the field than it normally would. See the specific + * options below. This option is not yet implemented in the open source + * release -- sorry, we'll try to include it in a future version! + */ + ctype: FieldOptions_CType; + /** + * The packed option can be enabled for repeated primitive fields to enable + * a more efficient representation on the wire. Rather than repeatedly + * writing the tag and type for each element, the entire array is encoded as + * a single length-delimited blob. In proto3, only explicit setting it to + * false will avoid using packed encoding. + */ + packed: boolean; + /** + * The jstype option determines the JavaScript type used for values of the + * field. The option is permitted only for 64 bit integral and fixed types + * (int64, uint64, sint64, fixed64, sfixed64). A field with jstype JS_STRING + * is represented as JavaScript string, which avoids loss of precision that + * can happen when a large value is converted to a floating point JavaScript. + * Specifying JS_NUMBER for the jstype causes the generated JavaScript code to + * use the JavaScript "number" type. The behavior of the default option + * JS_NORMAL is implementation dependent. + * + * This option is an enum to permit additional types to be added, e.g. + * goog.math.Integer. + */ + jstype: FieldOptions_JSType; + /** + * Should this field be parsed lazily? Lazy applies only to message-type + * fields. It means that when the outer message is initially parsed, the + * inner message's contents will not be parsed but instead stored in encoded + * form. The inner message will actually be parsed when it is first accessed. + * + * This is only a hint. Implementations are free to choose whether to use + * eager or lazy parsing regardless of the value of this option. However, + * setting this option true suggests that the protocol author believes that + * using lazy parsing on this field is worth the additional bookkeeping + * overhead typically needed to implement it. + * + * This option does not affect the public interface of any generated code; + * all method signatures remain the same. Furthermore, thread-safety of the + * interface is not affected by this option; const methods remain safe to + * call from multiple threads concurrently, while non-const methods continue + * to require exclusive access. + * + * + * Note that implementations may choose not to check required fields within + * a lazy sub-message. That is, calling IsInitialized() on the outer message + * may return true even if the inner message has missing required fields. + * This is necessary because otherwise the inner message would have to be + * parsed in order to perform the check, defeating the purpose of lazy + * parsing. An implementation which chooses not to check required fields + * must be consistent about it. That is, for any particular sub-message, the + * implementation must either *always* check its required fields, or *never* + * check its required fields, regardless of whether or not the message has + * been parsed. + */ + lazy: boolean; + /** + * Is this field deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for accessors, or it will be completely ignored; in the very least, this + * is a formalization for deprecating fields. + */ + deprecated: boolean; + /** For Google-internal migration only. Do not use. */ + weak: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} +export interface FieldOptionsProtoMsg { + typeUrl: "/google.protobuf.FieldOptions"; + value: Uint8Array; +} +export interface FieldOptionsSDKType { + ctype: FieldOptions_CType; + packed: boolean; + jstype: FieldOptions_JSType; + lazy: boolean; + deprecated: boolean; + weak: boolean; + uninterpreted_option: UninterpretedOptionSDKType[]; +} +export interface OneofOptions { + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} +export interface OneofOptionsProtoMsg { + typeUrl: "/google.protobuf.OneofOptions"; + value: Uint8Array; +} +export interface OneofOptionsSDKType { + uninterpreted_option: UninterpretedOptionSDKType[]; +} +export interface EnumOptions { + /** + * Set this option to true to allow mapping different tag names to the same + * value. + */ + allowAlias: boolean; + /** + * Is this enum deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum, or it will be completely ignored; in the very least, this + * is a formalization for deprecating enums. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} +export interface EnumOptionsProtoMsg { + typeUrl: "/google.protobuf.EnumOptions"; + value: Uint8Array; +} +export interface EnumOptionsSDKType { + allow_alias: boolean; + deprecated: boolean; + uninterpreted_option: UninterpretedOptionSDKType[]; +} +export interface EnumValueOptions { + /** + * Is this enum value deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum value, or it will be completely ignored; in the very least, + * this is a formalization for deprecating enum values. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} +export interface EnumValueOptionsProtoMsg { + typeUrl: "/google.protobuf.EnumValueOptions"; + value: Uint8Array; +} +export interface EnumValueOptionsSDKType { + deprecated: boolean; + uninterpreted_option: UninterpretedOptionSDKType[]; +} +export interface ServiceOptions { + /** + * Is this service deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the service, or it will be completely ignored; in the very least, + * this is a formalization for deprecating services. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} +export interface ServiceOptionsProtoMsg { + typeUrl: "/google.protobuf.ServiceOptions"; + value: Uint8Array; +} +export interface ServiceOptionsSDKType { + deprecated: boolean; + uninterpreted_option: UninterpretedOptionSDKType[]; +} +export interface MethodOptions { + /** + * Is this method deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the method, or it will be completely ignored; in the very least, + * this is a formalization for deprecating methods. + */ + deprecated: boolean; + idempotencyLevel: MethodOptions_IdempotencyLevel; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} +export interface MethodOptionsProtoMsg { + typeUrl: "/google.protobuf.MethodOptions"; + value: Uint8Array; +} +export interface MethodOptionsSDKType { + deprecated: boolean; + idempotency_level: MethodOptions_IdempotencyLevel; + uninterpreted_option: UninterpretedOptionSDKType[]; +} +/** + * A message representing a option the parser does not recognize. This only + * appears in options protos created by the compiler::Parser class. + * DescriptorPool resolves these when building Descriptor objects. Therefore, + * options protos in descriptor objects (e.g. returned by Descriptor::options(), + * or produced by Descriptor::CopyTo()) will never have UninterpretedOptions + * in them. + */ +export interface UninterpretedOption { + name: UninterpretedOption_NamePart[]; + /** + * The value of the uninterpreted option, in whatever type the tokenizer + * identified it as during parsing. Exactly one of these should be set. + */ + identifierValue: string; + positiveIntValue: bigint; + negativeIntValue: bigint; + doubleValue: number; + stringValue: Uint8Array; + aggregateValue: string; +} +export interface UninterpretedOptionProtoMsg { + typeUrl: "/google.protobuf.UninterpretedOption"; + value: Uint8Array; +} +/** + * A message representing a option the parser does not recognize. This only + * appears in options protos created by the compiler::Parser class. + * DescriptorPool resolves these when building Descriptor objects. Therefore, + * options protos in descriptor objects (e.g. returned by Descriptor::options(), + * or produced by Descriptor::CopyTo()) will never have UninterpretedOptions + * in them. + */ +export interface UninterpretedOptionSDKType { + name: UninterpretedOption_NamePartSDKType[]; + identifier_value: string; + positive_int_value: bigint; + negative_int_value: bigint; + double_value: number; + string_value: Uint8Array; + aggregate_value: string; +} +/** + * The name of the uninterpreted option. Each string represents a segment in + * a dot-separated name. is_extension is true iff a segment represents an + * extension (denoted with parentheses in options specs in .proto files). + * E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents + * "foo.(bar.baz).qux". + */ +export interface UninterpretedOption_NamePart { + namePart: string; + isExtension: boolean; +} +export interface UninterpretedOption_NamePartProtoMsg { + typeUrl: "/google.protobuf.NamePart"; + value: Uint8Array; +} +/** + * The name of the uninterpreted option. Each string represents a segment in + * a dot-separated name. is_extension is true iff a segment represents an + * extension (denoted with parentheses in options specs in .proto files). + * E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents + * "foo.(bar.baz).qux". + */ +export interface UninterpretedOption_NamePartSDKType { + name_part: string; + is_extension: boolean; +} +/** + * Encapsulates information about the original source file from which a + * FileDescriptorProto was generated. + */ +export interface SourceCodeInfo { + /** + * A Location identifies a piece of source code in a .proto file which + * corresponds to a particular definition. This information is intended + * to be useful to IDEs, code indexers, documentation generators, and similar + * tools. + * + * For example, say we have a file like: + * message Foo { + * optional string foo = 1; + * } + * Let's look at just the field definition: + * optional string foo = 1; + * ^ ^^ ^^ ^ ^^^ + * a bc de f ghi + * We have the following locations: + * span path represents + * [a,i) [ 4, 0, 2, 0 ] The whole field definition. + * [a,b) [ 4, 0, 2, 0, 4 ] The label (optional). + * [c,d) [ 4, 0, 2, 0, 5 ] The type (string). + * [e,f) [ 4, 0, 2, 0, 1 ] The name (foo). + * [g,h) [ 4, 0, 2, 0, 3 ] The number (1). + * + * Notes: + * - A location may refer to a repeated field itself (i.e. not to any + * particular index within it). This is used whenever a set of elements are + * logically enclosed in a single code segment. For example, an entire + * extend block (possibly containing multiple extension definitions) will + * have an outer location whose path refers to the "extensions" repeated + * field without an index. + * - Multiple locations may have the same path. This happens when a single + * logical declaration is spread out across multiple places. The most + * obvious example is the "extend" block again -- there may be multiple + * extend blocks in the same scope, each of which will have the same path. + * - A location's span is not always a subset of its parent's span. For + * example, the "extendee" of an extension declaration appears at the + * beginning of the "extend" block and is shared by all extensions within + * the block. + * - Just because a location's span is a subset of some other location's span + * does not mean that it is a descendant. For example, a "group" defines + * both a type and a field in a single declaration. Thus, the locations + * corresponding to the type and field and their components will overlap. + * - Code which tries to interpret locations should probably be designed to + * ignore those that it doesn't understand, as more types of locations could + * be recorded in the future. + */ + location: SourceCodeInfo_Location[]; +} +export interface SourceCodeInfoProtoMsg { + typeUrl: "/google.protobuf.SourceCodeInfo"; + value: Uint8Array; +} +/** + * Encapsulates information about the original source file from which a + * FileDescriptorProto was generated. + */ +export interface SourceCodeInfoSDKType { + location: SourceCodeInfo_LocationSDKType[]; +} +export interface SourceCodeInfo_Location { + /** + * Identifies which part of the FileDescriptorProto was defined at this + * location. + * + * Each element is a field number or an index. They form a path from + * the root FileDescriptorProto to the place where the definition. For + * example, this path: + * [ 4, 3, 2, 7, 1 ] + * refers to: + * file.message_type(3) // 4, 3 + * .field(7) // 2, 7 + * .name() // 1 + * This is because FileDescriptorProto.message_type has field number 4: + * repeated DescriptorProto message_type = 4; + * and DescriptorProto.field has field number 2: + * repeated FieldDescriptorProto field = 2; + * and FieldDescriptorProto.name has field number 1: + * optional string name = 1; + * + * Thus, the above path gives the location of a field name. If we removed + * the last element: + * [ 4, 3, 2, 7 ] + * this path refers to the whole field declaration (from the beginning + * of the label to the terminating semicolon). + */ + path: number[]; + /** + * Always has exactly three or four elements: start line, start column, + * end line (optional, otherwise assumed same as start line), end column. + * These are packed into a single field for efficiency. Note that line + * and column numbers are zero-based -- typically you will want to add + * 1 to each before displaying to a user. + */ + span: number[]; + /** + * If this SourceCodeInfo represents a complete declaration, these are any + * comments appearing before and after the declaration which appear to be + * attached to the declaration. + * + * A series of line comments appearing on consecutive lines, with no other + * tokens appearing on those lines, will be treated as a single comment. + * + * leading_detached_comments will keep paragraphs of comments that appear + * before (but not connected to) the current element. Each paragraph, + * separated by empty lines, will be one comment element in the repeated + * field. + * + * Only the comment content is provided; comment markers (e.g. //) are + * stripped out. For block comments, leading whitespace and an asterisk + * will be stripped from the beginning of each line other than the first. + * Newlines are included in the output. + * + * Examples: + * + * optional int32 foo = 1; // Comment attached to foo. + * // Comment attached to bar. + * optional int32 bar = 2; + * + * optional string baz = 3; + * // Comment attached to baz. + * // Another line attached to baz. + * + * // Comment attached to qux. + * // + * // Another line attached to qux. + * optional double qux = 4; + * + * // Detached comment for corge. This is not leading or trailing comments + * // to qux or corge because there are blank lines separating it from + * // both. + * + * // Detached comment for corge paragraph 2. + * + * optional string corge = 5; + * /* Block comment attached + * * to corge. Leading asterisks + * * will be removed. *\/ + * /* Block comment attached to + * * grault. *\/ + * optional int32 grault = 6; + * + * // ignored detached comments. + */ + leadingComments: string; + trailingComments: string; + leadingDetachedComments: string[]; +} +export interface SourceCodeInfo_LocationProtoMsg { + typeUrl: "/google.protobuf.Location"; + value: Uint8Array; +} +export interface SourceCodeInfo_LocationSDKType { + path: number[]; + span: number[]; + leading_comments: string; + trailing_comments: string; + leading_detached_comments: string[]; +} +/** + * Describes the relationship between generated code and its original source + * file. A GeneratedCodeInfo message is associated with only one generated + * source file, but may contain references to different source .proto files. + */ +export interface GeneratedCodeInfo { + /** + * An Annotation connects some span of text in generated code to an element + * of its generating .proto file. + */ + annotation: GeneratedCodeInfo_Annotation[]; +} +export interface GeneratedCodeInfoProtoMsg { + typeUrl: "/google.protobuf.GeneratedCodeInfo"; + value: Uint8Array; +} +/** + * Describes the relationship between generated code and its original source + * file. A GeneratedCodeInfo message is associated with only one generated + * source file, but may contain references to different source .proto files. + */ +export interface GeneratedCodeInfoSDKType { + annotation: GeneratedCodeInfo_AnnotationSDKType[]; +} +export interface GeneratedCodeInfo_Annotation { + /** + * Identifies the element in the original source .proto file. This field + * is formatted the same as SourceCodeInfo.Location.path. + */ + path: number[]; + /** Identifies the filesystem path to the original source .proto. */ + sourceFile: string; + /** + * Identifies the starting offset in bytes in the generated code + * that relates to the identified object. + */ + begin: number; + /** + * Identifies the ending offset in bytes in the generated code that + * relates to the identified offset. The end offset should be one past + * the last relevant byte (so the length of the text = end - begin). + */ + end: number; +} +export interface GeneratedCodeInfo_AnnotationProtoMsg { + typeUrl: "/google.protobuf.Annotation"; + value: Uint8Array; +} +export interface GeneratedCodeInfo_AnnotationSDKType { + path: number[]; + source_file: string; + begin: number; + end: number; +} +function createBaseFileDescriptorSet(): FileDescriptorSet { + return { + file: [] + }; +} +export const FileDescriptorSet = { + typeUrl: "/google.protobuf.FileDescriptorSet", + encode(message: FileDescriptorSet, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.file) { + FileDescriptorProto.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): FileDescriptorSet { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseFileDescriptorSet(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.file.push(FileDescriptorProto.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): FileDescriptorSet { + const obj = createBaseFileDescriptorSet(); + if (Array.isArray(object?.file)) obj.file = object.file.map((e: any) => FileDescriptorProto.fromJSON(e)); + return obj; + }, + toJSON(message: FileDescriptorSet): JsonSafe { + const obj: any = {}; + if (message.file) { + obj.file = message.file.map(e => e ? FileDescriptorProto.toJSON(e) : undefined); + } else { + obj.file = []; + } + return obj; + }, + fromPartial(object: DeepPartial): FileDescriptorSet { + const message = createBaseFileDescriptorSet(); + message.file = object.file?.map(e => FileDescriptorProto.fromPartial(e)) || []; + return message; + }, + fromSDK(object: FileDescriptorSetSDKType): FileDescriptorSet { + return { + file: Array.isArray(object?.file) ? object.file.map((e: any) => FileDescriptorProto.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): FileDescriptorSetSDKType { + return { + file: Array.isArray(object?.file) ? object.file.map((e: any) => FileDescriptorProto.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: FileDescriptorSet): FileDescriptorSetSDKType { + const obj: any = {}; + if (message.file) { + obj.file = message.file.map(e => e ? FileDescriptorProto.toSDK(e) : undefined); + } else { + obj.file = []; + } + return obj; + }, + fromAmino(object: FileDescriptorSetAmino): FileDescriptorSet { + const message = createBaseFileDescriptorSet(); + message.file = object.file?.map(e => FileDescriptorProto.fromAmino(e)) || []; + return message; + }, + toAmino(message: FileDescriptorSet): FileDescriptorSetAmino { + const obj: any = {}; + if (message.file) { + obj.file = message.file.map(e => e ? FileDescriptorProto.toAmino(e) : undefined); + } else { + obj.file = message.file; + } + return obj; + }, + fromAminoMsg(object: FileDescriptorSetAminoMsg): FileDescriptorSet { + return FileDescriptorSet.fromAmino(object.value); + }, + fromProtoMsg(message: FileDescriptorSetProtoMsg): FileDescriptorSet { + return FileDescriptorSet.decode(message.value); + }, + toProto(message: FileDescriptorSet): Uint8Array { + return FileDescriptorSet.encode(message).finish(); + }, + toProtoMsg(message: FileDescriptorSet): FileDescriptorSetProtoMsg { + return { + typeUrl: "/google.protobuf.FileDescriptorSet", + value: FileDescriptorSet.encode(message).finish() + }; + } +}; +function createBaseFileDescriptorProto(): FileDescriptorProto { + return { + name: "", + package: "", + dependency: [], + publicDependency: [], + weakDependency: [], + messageType: [], + enumType: [], + service: [], + extension: [], + options: undefined, + sourceCodeInfo: undefined, + syntax: "" + }; +} +export const FileDescriptorProto = { + typeUrl: "/google.protobuf.FileDescriptorProto", + encode(message: FileDescriptorProto, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + if (message.package !== undefined) { + writer.uint32(18).string(message.package); + } + for (const v of message.dependency) { + writer.uint32(26).string(v!); + } + writer.uint32(82).fork(); + for (const v of message.publicDependency) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(90).fork(); + for (const v of message.weakDependency) { + writer.int32(v); + } + writer.ldelim(); + for (const v of message.messageType) { + DescriptorProto.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.enumType) { + EnumDescriptorProto.encode(v!, writer.uint32(42).fork()).ldelim(); + } + for (const v of message.service) { + ServiceDescriptorProto.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.extension) { + FieldDescriptorProto.encode(v!, writer.uint32(58).fork()).ldelim(); + } + if (message.options !== undefined) { + FileOptions.encode(message.options, writer.uint32(66).fork()).ldelim(); + } + if (message.sourceCodeInfo !== undefined) { + SourceCodeInfo.encode(message.sourceCodeInfo, writer.uint32(74).fork()).ldelim(); + } + if (message.syntax !== undefined) { + writer.uint32(98).string(message.syntax); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): FileDescriptorProto { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseFileDescriptorProto(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.package = reader.string(); + break; + case 3: + message.dependency.push(reader.string()); + break; + case 10: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.publicDependency.push(reader.int32()); + } + } else { + message.publicDependency.push(reader.int32()); + } + break; + case 11: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.weakDependency.push(reader.int32()); + } + } else { + message.weakDependency.push(reader.int32()); + } + break; + case 4: + message.messageType.push(DescriptorProto.decode(reader, reader.uint32())); + break; + case 5: + message.enumType.push(EnumDescriptorProto.decode(reader, reader.uint32())); + break; + case 6: + message.service.push(ServiceDescriptorProto.decode(reader, reader.uint32())); + break; + case 7: + message.extension.push(FieldDescriptorProto.decode(reader, reader.uint32())); + break; + case 8: + message.options = FileOptions.decode(reader, reader.uint32()); + break; + case 9: + message.sourceCodeInfo = SourceCodeInfo.decode(reader, reader.uint32()); + break; + case 12: + message.syntax = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): FileDescriptorProto { + const obj = createBaseFileDescriptorProto(); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.package)) obj.package = String(object.package); + if (Array.isArray(object?.dependency)) obj.dependency = object.dependency.map((e: any) => String(e)); + if (Array.isArray(object?.publicDependency)) obj.publicDependency = object.publicDependency.map((e: any) => Number(e)); + if (Array.isArray(object?.weakDependency)) obj.weakDependency = object.weakDependency.map((e: any) => Number(e)); + if (Array.isArray(object?.messageType)) obj.messageType = object.messageType.map((e: any) => DescriptorProto.fromJSON(e)); + if (Array.isArray(object?.enumType)) obj.enumType = object.enumType.map((e: any) => EnumDescriptorProto.fromJSON(e)); + if (Array.isArray(object?.service)) obj.service = object.service.map((e: any) => ServiceDescriptorProto.fromJSON(e)); + if (Array.isArray(object?.extension)) obj.extension = object.extension.map((e: any) => FieldDescriptorProto.fromJSON(e)); + if (isSet(object.options)) obj.options = FileOptions.fromJSON(object.options); + if (isSet(object.sourceCodeInfo)) obj.sourceCodeInfo = SourceCodeInfo.fromJSON(object.sourceCodeInfo); + if (isSet(object.syntax)) obj.syntax = String(object.syntax); + return obj; + }, + toJSON(message: FileDescriptorProto): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.package !== undefined && (obj.package = message.package); + if (message.dependency) { + obj.dependency = message.dependency.map(e => e); + } else { + obj.dependency = []; + } + if (message.publicDependency) { + obj.publicDependency = message.publicDependency.map(e => Math.round(e)); + } else { + obj.publicDependency = []; + } + if (message.weakDependency) { + obj.weakDependency = message.weakDependency.map(e => Math.round(e)); + } else { + obj.weakDependency = []; + } + if (message.messageType) { + obj.messageType = message.messageType.map(e => e ? DescriptorProto.toJSON(e) : undefined); + } else { + obj.messageType = []; + } + if (message.enumType) { + obj.enumType = message.enumType.map(e => e ? EnumDescriptorProto.toJSON(e) : undefined); + } else { + obj.enumType = []; + } + if (message.service) { + obj.service = message.service.map(e => e ? ServiceDescriptorProto.toJSON(e) : undefined); + } else { + obj.service = []; + } + if (message.extension) { + obj.extension = message.extension.map(e => e ? FieldDescriptorProto.toJSON(e) : undefined); + } else { + obj.extension = []; + } + message.options !== undefined && (obj.options = message.options ? FileOptions.toJSON(message.options) : undefined); + message.sourceCodeInfo !== undefined && (obj.sourceCodeInfo = message.sourceCodeInfo ? SourceCodeInfo.toJSON(message.sourceCodeInfo) : undefined); + message.syntax !== undefined && (obj.syntax = message.syntax); + return obj; + }, + fromPartial(object: DeepPartial): FileDescriptorProto { + const message = createBaseFileDescriptorProto(); + message.name = object.name ?? ""; + message.package = object.package ?? ""; + message.dependency = object.dependency?.map(e => e) || []; + message.publicDependency = object.publicDependency?.map(e => e) || []; + message.weakDependency = object.weakDependency?.map(e => e) || []; + message.messageType = object.messageType?.map(e => DescriptorProto.fromPartial(e)) || []; + message.enumType = object.enumType?.map(e => EnumDescriptorProto.fromPartial(e)) || []; + message.service = object.service?.map(e => ServiceDescriptorProto.fromPartial(e)) || []; + message.extension = object.extension?.map(e => FieldDescriptorProto.fromPartial(e)) || []; + if (object.options !== undefined && object.options !== null) { + message.options = FileOptions.fromPartial(object.options); + } + if (object.sourceCodeInfo !== undefined && object.sourceCodeInfo !== null) { + message.sourceCodeInfo = SourceCodeInfo.fromPartial(object.sourceCodeInfo); + } + message.syntax = object.syntax ?? ""; + return message; + }, + fromSDK(object: FileDescriptorProtoSDKType): FileDescriptorProto { + return { + name: object?.name, + package: object?.package, + dependency: Array.isArray(object?.dependency) ? object.dependency.map((e: any) => e) : [], + publicDependency: Array.isArray(object?.public_dependency) ? object.public_dependency.map((e: any) => e) : [], + weakDependency: Array.isArray(object?.weak_dependency) ? object.weak_dependency.map((e: any) => e) : [], + messageType: Array.isArray(object?.message_type) ? object.message_type.map((e: any) => DescriptorProto.fromSDK(e)) : [], + enumType: Array.isArray(object?.enum_type) ? object.enum_type.map((e: any) => EnumDescriptorProto.fromSDK(e)) : [], + service: Array.isArray(object?.service) ? object.service.map((e: any) => ServiceDescriptorProto.fromSDK(e)) : [], + extension: Array.isArray(object?.extension) ? object.extension.map((e: any) => FieldDescriptorProto.fromSDK(e)) : [], + options: object.options ? FileOptions.fromSDK(object.options) : undefined, + sourceCodeInfo: object.source_code_info ? SourceCodeInfo.fromSDK(object.source_code_info) : undefined, + syntax: object?.syntax + }; + }, + fromSDKJSON(object: any): FileDescriptorProtoSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + package: isSet(object.package) ? String(object.package) : "", + dependency: Array.isArray(object?.dependency) ? object.dependency.map((e: any) => String(e)) : [], + public_dependency: Array.isArray(object?.public_dependency) ? object.public_dependency.map((e: any) => Number(e)) : [], + weak_dependency: Array.isArray(object?.weak_dependency) ? object.weak_dependency.map((e: any) => Number(e)) : [], + message_type: Array.isArray(object?.message_type) ? object.message_type.map((e: any) => DescriptorProto.fromSDKJSON(e)) : [], + enum_type: Array.isArray(object?.enum_type) ? object.enum_type.map((e: any) => EnumDescriptorProto.fromSDKJSON(e)) : [], + service: Array.isArray(object?.service) ? object.service.map((e: any) => ServiceDescriptorProto.fromSDKJSON(e)) : [], + extension: Array.isArray(object?.extension) ? object.extension.map((e: any) => FieldDescriptorProto.fromSDKJSON(e)) : [], + options: isSet(object.options) ? FileOptions.fromSDKJSON(object.options) : undefined, + source_code_info: isSet(object.source_code_info) ? SourceCodeInfo.fromSDKJSON(object.source_code_info) : undefined, + syntax: isSet(object.syntax) ? String(object.syntax) : "" + }; + }, + toSDK(message: FileDescriptorProto): FileDescriptorProtoSDKType { + const obj: any = {}; + obj.name = message.name; + obj.package = message.package; + if (message.dependency) { + obj.dependency = message.dependency.map(e => e); + } else { + obj.dependency = []; + } + if (message.publicDependency) { + obj.public_dependency = message.publicDependency.map(e => e); + } else { + obj.public_dependency = []; + } + if (message.weakDependency) { + obj.weak_dependency = message.weakDependency.map(e => e); + } else { + obj.weak_dependency = []; + } + if (message.messageType) { + obj.message_type = message.messageType.map(e => e ? DescriptorProto.toSDK(e) : undefined); + } else { + obj.message_type = []; + } + if (message.enumType) { + obj.enum_type = message.enumType.map(e => e ? EnumDescriptorProto.toSDK(e) : undefined); + } else { + obj.enum_type = []; + } + if (message.service) { + obj.service = message.service.map(e => e ? ServiceDescriptorProto.toSDK(e) : undefined); + } else { + obj.service = []; + } + if (message.extension) { + obj.extension = message.extension.map(e => e ? FieldDescriptorProto.toSDK(e) : undefined); + } else { + obj.extension = []; + } + message.options !== undefined && (obj.options = message.options ? FileOptions.toSDK(message.options) : undefined); + message.sourceCodeInfo !== undefined && (obj.source_code_info = message.sourceCodeInfo ? SourceCodeInfo.toSDK(message.sourceCodeInfo) : undefined); + obj.syntax = message.syntax; + return obj; + }, + fromAmino(object: FileDescriptorProtoAmino): FileDescriptorProto { + const message = createBaseFileDescriptorProto(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + if (object.package !== undefined && object.package !== null) { + message.package = object.package; + } + message.dependency = object.dependency?.map(e => e) || []; + message.publicDependency = object.public_dependency?.map(e => e) || []; + message.weakDependency = object.weak_dependency?.map(e => e) || []; + message.messageType = object.message_type?.map(e => DescriptorProto.fromAmino(e)) || []; + message.enumType = object.enum_type?.map(e => EnumDescriptorProto.fromAmino(e)) || []; + message.service = object.service?.map(e => ServiceDescriptorProto.fromAmino(e)) || []; + message.extension = object.extension?.map(e => FieldDescriptorProto.fromAmino(e)) || []; + if (object.options !== undefined && object.options !== null) { + message.options = FileOptions.fromAmino(object.options); + } + if (object.source_code_info !== undefined && object.source_code_info !== null) { + message.sourceCodeInfo = SourceCodeInfo.fromAmino(object.source_code_info); + } + if (object.syntax !== undefined && object.syntax !== null) { + message.syntax = object.syntax; + } + return message; + }, + toAmino(message: FileDescriptorProto): FileDescriptorProtoAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + obj.package = message.package === "" ? undefined : message.package; + if (message.dependency) { + obj.dependency = message.dependency.map(e => e); + } else { + obj.dependency = message.dependency; + } + if (message.publicDependency) { + obj.public_dependency = message.publicDependency.map(e => e); + } else { + obj.public_dependency = message.publicDependency; + } + if (message.weakDependency) { + obj.weak_dependency = message.weakDependency.map(e => e); + } else { + obj.weak_dependency = message.weakDependency; + } + if (message.messageType) { + obj.message_type = message.messageType.map(e => e ? DescriptorProto.toAmino(e) : undefined); + } else { + obj.message_type = message.messageType; + } + if (message.enumType) { + obj.enum_type = message.enumType.map(e => e ? EnumDescriptorProto.toAmino(e) : undefined); + } else { + obj.enum_type = message.enumType; + } + if (message.service) { + obj.service = message.service.map(e => e ? ServiceDescriptorProto.toAmino(e) : undefined); + } else { + obj.service = message.service; + } + if (message.extension) { + obj.extension = message.extension.map(e => e ? FieldDescriptorProto.toAmino(e) : undefined); + } else { + obj.extension = message.extension; + } + obj.options = message.options ? FileOptions.toAmino(message.options) : undefined; + obj.source_code_info = message.sourceCodeInfo ? SourceCodeInfo.toAmino(message.sourceCodeInfo) : undefined; + obj.syntax = message.syntax === "" ? undefined : message.syntax; + return obj; + }, + fromAminoMsg(object: FileDescriptorProtoAminoMsg): FileDescriptorProto { + return FileDescriptorProto.fromAmino(object.value); + }, + fromProtoMsg(message: FileDescriptorProtoProtoMsg): FileDescriptorProto { + return FileDescriptorProto.decode(message.value); + }, + toProto(message: FileDescriptorProto): Uint8Array { + return FileDescriptorProto.encode(message).finish(); + }, + toProtoMsg(message: FileDescriptorProto): FileDescriptorProtoProtoMsg { + return { + typeUrl: "/google.protobuf.FileDescriptorProto", + value: FileDescriptorProto.encode(message).finish() + }; + } +}; +function createBaseDescriptorProto(): DescriptorProto { + return { + name: "", + field: [], + extension: [], + nestedType: [], + enumType: [], + extensionRange: [], + oneofDecl: [], + options: undefined, + reservedRange: [], + reservedName: [] + }; +} +export const DescriptorProto = { + typeUrl: "/google.protobuf.DescriptorProto", + encode(message: DescriptorProto, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + for (const v of message.field) { + FieldDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.extension) { + FieldDescriptorProto.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.nestedType) { + DescriptorProto.encode(v!, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.enumType) { + EnumDescriptorProto.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.extensionRange) { + DescriptorProto_ExtensionRange.encode(v!, writer.uint32(42).fork()).ldelim(); + } + for (const v of message.oneofDecl) { + OneofDescriptorProto.encode(v!, writer.uint32(66).fork()).ldelim(); + } + if (message.options !== undefined) { + MessageOptions.encode(message.options, writer.uint32(58).fork()).ldelim(); + } + for (const v of message.reservedRange) { + DescriptorProto_ReservedRange.encode(v!, writer.uint32(74).fork()).ldelim(); + } + for (const v of message.reservedName) { + writer.uint32(82).string(v!); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): DescriptorProto { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDescriptorProto(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.field.push(FieldDescriptorProto.decode(reader, reader.uint32())); + break; + case 6: + message.extension.push(FieldDescriptorProto.decode(reader, reader.uint32())); + break; + case 3: + message.nestedType.push(DescriptorProto.decode(reader, reader.uint32())); + break; + case 4: + message.enumType.push(EnumDescriptorProto.decode(reader, reader.uint32())); + break; + case 5: + message.extensionRange.push(DescriptorProto_ExtensionRange.decode(reader, reader.uint32())); + break; + case 8: + message.oneofDecl.push(OneofDescriptorProto.decode(reader, reader.uint32())); + break; + case 7: + message.options = MessageOptions.decode(reader, reader.uint32()); + break; + case 9: + message.reservedRange.push(DescriptorProto_ReservedRange.decode(reader, reader.uint32())); + break; + case 10: + message.reservedName.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): DescriptorProto { + const obj = createBaseDescriptorProto(); + if (isSet(object.name)) obj.name = String(object.name); + if (Array.isArray(object?.field)) obj.field = object.field.map((e: any) => FieldDescriptorProto.fromJSON(e)); + if (Array.isArray(object?.extension)) obj.extension = object.extension.map((e: any) => FieldDescriptorProto.fromJSON(e)); + if (Array.isArray(object?.nestedType)) obj.nestedType = object.nestedType.map((e: any) => DescriptorProto.fromJSON(e)); + if (Array.isArray(object?.enumType)) obj.enumType = object.enumType.map((e: any) => EnumDescriptorProto.fromJSON(e)); + if (Array.isArray(object?.extensionRange)) obj.extensionRange = object.extensionRange.map((e: any) => DescriptorProto_ExtensionRange.fromJSON(e)); + if (Array.isArray(object?.oneofDecl)) obj.oneofDecl = object.oneofDecl.map((e: any) => OneofDescriptorProto.fromJSON(e)); + if (isSet(object.options)) obj.options = MessageOptions.fromJSON(object.options); + if (Array.isArray(object?.reservedRange)) obj.reservedRange = object.reservedRange.map((e: any) => DescriptorProto_ReservedRange.fromJSON(e)); + if (Array.isArray(object?.reservedName)) obj.reservedName = object.reservedName.map((e: any) => String(e)); + return obj; + }, + toJSON(message: DescriptorProto): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.field) { + obj.field = message.field.map(e => e ? FieldDescriptorProto.toJSON(e) : undefined); + } else { + obj.field = []; + } + if (message.extension) { + obj.extension = message.extension.map(e => e ? FieldDescriptorProto.toJSON(e) : undefined); + } else { + obj.extension = []; + } + if (message.nestedType) { + obj.nestedType = message.nestedType.map(e => e ? DescriptorProto.toJSON(e) : undefined); + } else { + obj.nestedType = []; + } + if (message.enumType) { + obj.enumType = message.enumType.map(e => e ? EnumDescriptorProto.toJSON(e) : undefined); + } else { + obj.enumType = []; + } + if (message.extensionRange) { + obj.extensionRange = message.extensionRange.map(e => e ? DescriptorProto_ExtensionRange.toJSON(e) : undefined); + } else { + obj.extensionRange = []; + } + if (message.oneofDecl) { + obj.oneofDecl = message.oneofDecl.map(e => e ? OneofDescriptorProto.toJSON(e) : undefined); + } else { + obj.oneofDecl = []; + } + message.options !== undefined && (obj.options = message.options ? MessageOptions.toJSON(message.options) : undefined); + if (message.reservedRange) { + obj.reservedRange = message.reservedRange.map(e => e ? DescriptorProto_ReservedRange.toJSON(e) : undefined); + } else { + obj.reservedRange = []; + } + if (message.reservedName) { + obj.reservedName = message.reservedName.map(e => e); + } else { + obj.reservedName = []; + } + return obj; + }, + fromPartial(object: DeepPartial): DescriptorProto { + const message = createBaseDescriptorProto(); + message.name = object.name ?? ""; + message.field = object.field?.map(e => FieldDescriptorProto.fromPartial(e)) || []; + message.extension = object.extension?.map(e => FieldDescriptorProto.fromPartial(e)) || []; + message.nestedType = object.nestedType?.map(e => DescriptorProto.fromPartial(e)) || []; + message.enumType = object.enumType?.map(e => EnumDescriptorProto.fromPartial(e)) || []; + message.extensionRange = object.extensionRange?.map(e => DescriptorProto_ExtensionRange.fromPartial(e)) || []; + message.oneofDecl = object.oneofDecl?.map(e => OneofDescriptorProto.fromPartial(e)) || []; + if (object.options !== undefined && object.options !== null) { + message.options = MessageOptions.fromPartial(object.options); + } + message.reservedRange = object.reservedRange?.map(e => DescriptorProto_ReservedRange.fromPartial(e)) || []; + message.reservedName = object.reservedName?.map(e => e) || []; + return message; + }, + fromSDK(object: DescriptorProtoSDKType): DescriptorProto { + return { + name: object?.name, + field: Array.isArray(object?.field) ? object.field.map((e: any) => FieldDescriptorProto.fromSDK(e)) : [], + extension: Array.isArray(object?.extension) ? object.extension.map((e: any) => FieldDescriptorProto.fromSDK(e)) : [], + nestedType: Array.isArray(object?.nested_type) ? object.nested_type.map((e: any) => DescriptorProto.fromSDK(e)) : [], + enumType: Array.isArray(object?.enum_type) ? object.enum_type.map((e: any) => EnumDescriptorProto.fromSDK(e)) : [], + extensionRange: Array.isArray(object?.extension_range) ? object.extension_range.map((e: any) => DescriptorProto_ExtensionRange.fromSDK(e)) : [], + oneofDecl: Array.isArray(object?.oneof_decl) ? object.oneof_decl.map((e: any) => OneofDescriptorProto.fromSDK(e)) : [], + options: object.options ? MessageOptions.fromSDK(object.options) : undefined, + reservedRange: Array.isArray(object?.reserved_range) ? object.reserved_range.map((e: any) => DescriptorProto_ReservedRange.fromSDK(e)) : [], + reservedName: Array.isArray(object?.reserved_name) ? object.reserved_name.map((e: any) => e) : [] + }; + }, + fromSDKJSON(object: any): DescriptorProtoSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + field: Array.isArray(object?.field) ? object.field.map((e: any) => FieldDescriptorProto.fromSDKJSON(e)) : [], + extension: Array.isArray(object?.extension) ? object.extension.map((e: any) => FieldDescriptorProto.fromSDKJSON(e)) : [], + nested_type: Array.isArray(object?.nested_type) ? object.nested_type.map((e: any) => DescriptorProto.fromSDKJSON(e)) : [], + enum_type: Array.isArray(object?.enum_type) ? object.enum_type.map((e: any) => EnumDescriptorProto.fromSDKJSON(e)) : [], + extension_range: Array.isArray(object?.extension_range) ? object.extension_range.map((e: any) => DescriptorProto_ExtensionRange.fromSDKJSON(e)) : [], + oneof_decl: Array.isArray(object?.oneof_decl) ? object.oneof_decl.map((e: any) => OneofDescriptorProto.fromSDKJSON(e)) : [], + options: isSet(object.options) ? MessageOptions.fromSDKJSON(object.options) : undefined, + reserved_range: Array.isArray(object?.reserved_range) ? object.reserved_range.map((e: any) => DescriptorProto_ReservedRange.fromSDKJSON(e)) : [], + reserved_name: Array.isArray(object?.reserved_name) ? object.reserved_name.map((e: any) => String(e)) : [] + }; + }, + toSDK(message: DescriptorProto): DescriptorProtoSDKType { + const obj: any = {}; + obj.name = message.name; + if (message.field) { + obj.field = message.field.map(e => e ? FieldDescriptorProto.toSDK(e) : undefined); + } else { + obj.field = []; + } + if (message.extension) { + obj.extension = message.extension.map(e => e ? FieldDescriptorProto.toSDK(e) : undefined); + } else { + obj.extension = []; + } + if (message.nestedType) { + obj.nested_type = message.nestedType.map(e => e ? DescriptorProto.toSDK(e) : undefined); + } else { + obj.nested_type = []; + } + if (message.enumType) { + obj.enum_type = message.enumType.map(e => e ? EnumDescriptorProto.toSDK(e) : undefined); + } else { + obj.enum_type = []; + } + if (message.extensionRange) { + obj.extension_range = message.extensionRange.map(e => e ? DescriptorProto_ExtensionRange.toSDK(e) : undefined); + } else { + obj.extension_range = []; + } + if (message.oneofDecl) { + obj.oneof_decl = message.oneofDecl.map(e => e ? OneofDescriptorProto.toSDK(e) : undefined); + } else { + obj.oneof_decl = []; + } + message.options !== undefined && (obj.options = message.options ? MessageOptions.toSDK(message.options) : undefined); + if (message.reservedRange) { + obj.reserved_range = message.reservedRange.map(e => e ? DescriptorProto_ReservedRange.toSDK(e) : undefined); + } else { + obj.reserved_range = []; + } + if (message.reservedName) { + obj.reserved_name = message.reservedName.map(e => e); + } else { + obj.reserved_name = []; + } + return obj; + }, + fromAmino(object: DescriptorProtoAmino): DescriptorProto { + const message = createBaseDescriptorProto(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + message.field = object.field?.map(e => FieldDescriptorProto.fromAmino(e)) || []; + message.extension = object.extension?.map(e => FieldDescriptorProto.fromAmino(e)) || []; + message.nestedType = object.nested_type?.map(e => DescriptorProto.fromAmino(e)) || []; + message.enumType = object.enum_type?.map(e => EnumDescriptorProto.fromAmino(e)) || []; + message.extensionRange = object.extension_range?.map(e => DescriptorProto_ExtensionRange.fromAmino(e)) || []; + message.oneofDecl = object.oneof_decl?.map(e => OneofDescriptorProto.fromAmino(e)) || []; + if (object.options !== undefined && object.options !== null) { + message.options = MessageOptions.fromAmino(object.options); + } + message.reservedRange = object.reserved_range?.map(e => DescriptorProto_ReservedRange.fromAmino(e)) || []; + message.reservedName = object.reserved_name?.map(e => e) || []; + return message; + }, + toAmino(message: DescriptorProto): DescriptorProtoAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + if (message.field) { + obj.field = message.field.map(e => e ? FieldDescriptorProto.toAmino(e) : undefined); + } else { + obj.field = message.field; + } + if (message.extension) { + obj.extension = message.extension.map(e => e ? FieldDescriptorProto.toAmino(e) : undefined); + } else { + obj.extension = message.extension; + } + if (message.nestedType) { + obj.nested_type = message.nestedType.map(e => e ? DescriptorProto.toAmino(e) : undefined); + } else { + obj.nested_type = message.nestedType; + } + if (message.enumType) { + obj.enum_type = message.enumType.map(e => e ? EnumDescriptorProto.toAmino(e) : undefined); + } else { + obj.enum_type = message.enumType; + } + if (message.extensionRange) { + obj.extension_range = message.extensionRange.map(e => e ? DescriptorProto_ExtensionRange.toAmino(e) : undefined); + } else { + obj.extension_range = message.extensionRange; + } + if (message.oneofDecl) { + obj.oneof_decl = message.oneofDecl.map(e => e ? OneofDescriptorProto.toAmino(e) : undefined); + } else { + obj.oneof_decl = message.oneofDecl; + } + obj.options = message.options ? MessageOptions.toAmino(message.options) : undefined; + if (message.reservedRange) { + obj.reserved_range = message.reservedRange.map(e => e ? DescriptorProto_ReservedRange.toAmino(e) : undefined); + } else { + obj.reserved_range = message.reservedRange; + } + if (message.reservedName) { + obj.reserved_name = message.reservedName.map(e => e); + } else { + obj.reserved_name = message.reservedName; + } + return obj; + }, + fromAminoMsg(object: DescriptorProtoAminoMsg): DescriptorProto { + return DescriptorProto.fromAmino(object.value); + }, + fromProtoMsg(message: DescriptorProtoProtoMsg): DescriptorProto { + return DescriptorProto.decode(message.value); + }, + toProto(message: DescriptorProto): Uint8Array { + return DescriptorProto.encode(message).finish(); + }, + toProtoMsg(message: DescriptorProto): DescriptorProtoProtoMsg { + return { + typeUrl: "/google.protobuf.DescriptorProto", + value: DescriptorProto.encode(message).finish() + }; + } +}; +function createBaseDescriptorProto_ExtensionRange(): DescriptorProto_ExtensionRange { + return { + start: 0, + end: 0, + options: undefined + }; +} +export const DescriptorProto_ExtensionRange = { + typeUrl: "/google.protobuf.ExtensionRange", + encode(message: DescriptorProto_ExtensionRange, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.start !== undefined) { + writer.uint32(8).int32(message.start); + } + if (message.end !== undefined) { + writer.uint32(16).int32(message.end); + } + if (message.options !== undefined) { + ExtensionRangeOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): DescriptorProto_ExtensionRange { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDescriptorProto_ExtensionRange(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + case 3: + message.options = ExtensionRangeOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): DescriptorProto_ExtensionRange { + const obj = createBaseDescriptorProto_ExtensionRange(); + if (isSet(object.start)) obj.start = Number(object.start); + if (isSet(object.end)) obj.end = Number(object.end); + if (isSet(object.options)) obj.options = ExtensionRangeOptions.fromJSON(object.options); + return obj; + }, + toJSON(message: DescriptorProto_ExtensionRange): JsonSafe { + const obj: any = {}; + message.start !== undefined && (obj.start = Math.round(message.start)); + message.end !== undefined && (obj.end = Math.round(message.end)); + message.options !== undefined && (obj.options = message.options ? ExtensionRangeOptions.toJSON(message.options) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): DescriptorProto_ExtensionRange { + const message = createBaseDescriptorProto_ExtensionRange(); + message.start = object.start ?? 0; + message.end = object.end ?? 0; + if (object.options !== undefined && object.options !== null) { + message.options = ExtensionRangeOptions.fromPartial(object.options); + } + return message; + }, + fromSDK(object: DescriptorProto_ExtensionRangeSDKType): DescriptorProto_ExtensionRange { + return { + start: object?.start, + end: object?.end, + options: object.options ? ExtensionRangeOptions.fromSDK(object.options) : undefined + }; + }, + fromSDKJSON(object: any): DescriptorProto_ExtensionRangeSDKType { + return { + start: isSet(object.start) ? Number(object.start) : 0, + end: isSet(object.end) ? Number(object.end) : 0, + options: isSet(object.options) ? ExtensionRangeOptions.fromSDKJSON(object.options) : undefined + }; + }, + toSDK(message: DescriptorProto_ExtensionRange): DescriptorProto_ExtensionRangeSDKType { + const obj: any = {}; + obj.start = message.start; + obj.end = message.end; + message.options !== undefined && (obj.options = message.options ? ExtensionRangeOptions.toSDK(message.options) : undefined); + return obj; + }, + fromAmino(object: DescriptorProto_ExtensionRangeAmino): DescriptorProto_ExtensionRange { + const message = createBaseDescriptorProto_ExtensionRange(); + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } + if (object.options !== undefined && object.options !== null) { + message.options = ExtensionRangeOptions.fromAmino(object.options); + } + return message; + }, + toAmino(message: DescriptorProto_ExtensionRange): DescriptorProto_ExtensionRangeAmino { + const obj: any = {}; + obj.start = message.start === 0 ? undefined : message.start; + obj.end = message.end === 0 ? undefined : message.end; + obj.options = message.options ? ExtensionRangeOptions.toAmino(message.options) : undefined; + return obj; + }, + fromAminoMsg(object: DescriptorProto_ExtensionRangeAminoMsg): DescriptorProto_ExtensionRange { + return DescriptorProto_ExtensionRange.fromAmino(object.value); + }, + fromProtoMsg(message: DescriptorProto_ExtensionRangeProtoMsg): DescriptorProto_ExtensionRange { + return DescriptorProto_ExtensionRange.decode(message.value); + }, + toProto(message: DescriptorProto_ExtensionRange): Uint8Array { + return DescriptorProto_ExtensionRange.encode(message).finish(); + }, + toProtoMsg(message: DescriptorProto_ExtensionRange): DescriptorProto_ExtensionRangeProtoMsg { + return { + typeUrl: "/google.protobuf.ExtensionRange", + value: DescriptorProto_ExtensionRange.encode(message).finish() + }; + } +}; +function createBaseDescriptorProto_ReservedRange(): DescriptorProto_ReservedRange { + return { + start: 0, + end: 0 + }; +} +export const DescriptorProto_ReservedRange = { + typeUrl: "/google.protobuf.ReservedRange", + encode(message: DescriptorProto_ReservedRange, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.start !== undefined) { + writer.uint32(8).int32(message.start); + } + if (message.end !== undefined) { + writer.uint32(16).int32(message.end); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): DescriptorProto_ReservedRange { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDescriptorProto_ReservedRange(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): DescriptorProto_ReservedRange { + const obj = createBaseDescriptorProto_ReservedRange(); + if (isSet(object.start)) obj.start = Number(object.start); + if (isSet(object.end)) obj.end = Number(object.end); + return obj; + }, + toJSON(message: DescriptorProto_ReservedRange): JsonSafe { + const obj: any = {}; + message.start !== undefined && (obj.start = Math.round(message.start)); + message.end !== undefined && (obj.end = Math.round(message.end)); + return obj; + }, + fromPartial(object: DeepPartial): DescriptorProto_ReservedRange { + const message = createBaseDescriptorProto_ReservedRange(); + message.start = object.start ?? 0; + message.end = object.end ?? 0; + return message; + }, + fromSDK(object: DescriptorProto_ReservedRangeSDKType): DescriptorProto_ReservedRange { + return { + start: object?.start, + end: object?.end + }; + }, + fromSDKJSON(object: any): DescriptorProto_ReservedRangeSDKType { + return { + start: isSet(object.start) ? Number(object.start) : 0, + end: isSet(object.end) ? Number(object.end) : 0 + }; + }, + toSDK(message: DescriptorProto_ReservedRange): DescriptorProto_ReservedRangeSDKType { + const obj: any = {}; + obj.start = message.start; + obj.end = message.end; + return obj; + }, + fromAmino(object: DescriptorProto_ReservedRangeAmino): DescriptorProto_ReservedRange { + const message = createBaseDescriptorProto_ReservedRange(); + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } + return message; + }, + toAmino(message: DescriptorProto_ReservedRange): DescriptorProto_ReservedRangeAmino { + const obj: any = {}; + obj.start = message.start === 0 ? undefined : message.start; + obj.end = message.end === 0 ? undefined : message.end; + return obj; + }, + fromAminoMsg(object: DescriptorProto_ReservedRangeAminoMsg): DescriptorProto_ReservedRange { + return DescriptorProto_ReservedRange.fromAmino(object.value); + }, + fromProtoMsg(message: DescriptorProto_ReservedRangeProtoMsg): DescriptorProto_ReservedRange { + return DescriptorProto_ReservedRange.decode(message.value); + }, + toProto(message: DescriptorProto_ReservedRange): Uint8Array { + return DescriptorProto_ReservedRange.encode(message).finish(); + }, + toProtoMsg(message: DescriptorProto_ReservedRange): DescriptorProto_ReservedRangeProtoMsg { + return { + typeUrl: "/google.protobuf.ReservedRange", + value: DescriptorProto_ReservedRange.encode(message).finish() + }; + } +}; +function createBaseExtensionRangeOptions(): ExtensionRangeOptions { + return { + uninterpretedOption: [] + }; +} +export const ExtensionRangeOptions = { + typeUrl: "/google.protobuf.ExtensionRangeOptions", + encode(message: ExtensionRangeOptions, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ExtensionRangeOptions { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseExtensionRangeOptions(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 999: + message.uninterpretedOption.push(UninterpretedOption.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ExtensionRangeOptions { + const obj = createBaseExtensionRangeOptions(); + if (Array.isArray(object?.uninterpretedOption)) obj.uninterpretedOption = object.uninterpretedOption.map((e: any) => UninterpretedOption.fromJSON(e)); + return obj; + }, + toJSON(message: ExtensionRangeOptions): JsonSafe { + const obj: any = {}; + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map(e => e ? UninterpretedOption.toJSON(e) : undefined); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + fromPartial(object: DeepPartial): ExtensionRangeOptions { + const message = createBaseExtensionRangeOptions(); + message.uninterpretedOption = object.uninterpretedOption?.map(e => UninterpretedOption.fromPartial(e)) || []; + return message; + }, + fromSDK(object: ExtensionRangeOptionsSDKType): ExtensionRangeOptions { + return { + uninterpretedOption: Array.isArray(object?.uninterpreted_option) ? object.uninterpreted_option.map((e: any) => UninterpretedOption.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): ExtensionRangeOptionsSDKType { + return { + uninterpreted_option: Array.isArray(object?.uninterpreted_option) ? object.uninterpreted_option.map((e: any) => UninterpretedOption.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: ExtensionRangeOptions): ExtensionRangeOptionsSDKType { + const obj: any = {}; + if (message.uninterpretedOption) { + obj.uninterpreted_option = message.uninterpretedOption.map(e => e ? UninterpretedOption.toSDK(e) : undefined); + } else { + obj.uninterpreted_option = []; + } + return obj; + }, + fromAmino(object: ExtensionRangeOptionsAmino): ExtensionRangeOptions { + const message = createBaseExtensionRangeOptions(); + message.uninterpretedOption = object.uninterpreted_option?.map(e => UninterpretedOption.fromAmino(e)) || []; + return message; + }, + toAmino(message: ExtensionRangeOptions): ExtensionRangeOptionsAmino { + const obj: any = {}; + if (message.uninterpretedOption) { + obj.uninterpreted_option = message.uninterpretedOption.map(e => e ? UninterpretedOption.toAmino(e) : undefined); + } else { + obj.uninterpreted_option = message.uninterpretedOption; + } + return obj; + }, + fromAminoMsg(object: ExtensionRangeOptionsAminoMsg): ExtensionRangeOptions { + return ExtensionRangeOptions.fromAmino(object.value); + }, + fromProtoMsg(message: ExtensionRangeOptionsProtoMsg): ExtensionRangeOptions { + return ExtensionRangeOptions.decode(message.value); + }, + toProto(message: ExtensionRangeOptions): Uint8Array { + return ExtensionRangeOptions.encode(message).finish(); + }, + toProtoMsg(message: ExtensionRangeOptions): ExtensionRangeOptionsProtoMsg { + return { + typeUrl: "/google.protobuf.ExtensionRangeOptions", + value: ExtensionRangeOptions.encode(message).finish() + }; + } +}; +function createBaseFieldDescriptorProto(): FieldDescriptorProto { + return { + name: "", + number: 0, + label: 1, + type: 1, + typeName: "", + extendee: "", + defaultValue: "", + oneofIndex: 0, + jsonName: "", + options: undefined + }; +} +export const FieldDescriptorProto = { + typeUrl: "/google.protobuf.FieldDescriptorProto", + encode(message: FieldDescriptorProto, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + if (message.number !== undefined) { + writer.uint32(24).int32(message.number); + } + if (message.label !== 1) { + writer.uint32(32).int32(message.label); + } + if (message.type !== 1) { + writer.uint32(40).int32(message.type); + } + if (message.typeName !== undefined) { + writer.uint32(50).string(message.typeName); + } + if (message.extendee !== undefined) { + writer.uint32(18).string(message.extendee); + } + if (message.defaultValue !== undefined) { + writer.uint32(58).string(message.defaultValue); + } + if (message.oneofIndex !== undefined) { + writer.uint32(72).int32(message.oneofIndex); + } + if (message.jsonName !== undefined) { + writer.uint32(82).string(message.jsonName); + } + if (message.options !== undefined) { + FieldOptions.encode(message.options, writer.uint32(66).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): FieldDescriptorProto { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseFieldDescriptorProto(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 3: + message.number = reader.int32(); + break; + case 4: + message.label = (reader.int32() as any); + break; + case 5: + message.type = (reader.int32() as any); + break; + case 6: + message.typeName = reader.string(); + break; + case 2: + message.extendee = reader.string(); + break; + case 7: + message.defaultValue = reader.string(); + break; + case 9: + message.oneofIndex = reader.int32(); + break; + case 10: + message.jsonName = reader.string(); + break; + case 8: + message.options = FieldOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): FieldDescriptorProto { + const obj = createBaseFieldDescriptorProto(); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.number)) obj.number = Number(object.number); + if (isSet(object.label)) obj.label = fieldDescriptorProto_LabelFromJSON(object.label); + if (isSet(object.type)) obj.type = fieldDescriptorProto_TypeFromJSON(object.type); + if (isSet(object.typeName)) obj.typeName = String(object.typeName); + if (isSet(object.extendee)) obj.extendee = String(object.extendee); + if (isSet(object.defaultValue)) obj.defaultValue = String(object.defaultValue); + if (isSet(object.oneofIndex)) obj.oneofIndex = Number(object.oneofIndex); + if (isSet(object.jsonName)) obj.jsonName = String(object.jsonName); + if (isSet(object.options)) obj.options = FieldOptions.fromJSON(object.options); + return obj; + }, + toJSON(message: FieldDescriptorProto): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.number !== undefined && (obj.number = Math.round(message.number)); + message.label !== undefined && (obj.label = fieldDescriptorProto_LabelToJSON(message.label)); + message.type !== undefined && (obj.type = fieldDescriptorProto_TypeToJSON(message.type)); + message.typeName !== undefined && (obj.typeName = message.typeName); + message.extendee !== undefined && (obj.extendee = message.extendee); + message.defaultValue !== undefined && (obj.defaultValue = message.defaultValue); + message.oneofIndex !== undefined && (obj.oneofIndex = Math.round(message.oneofIndex)); + message.jsonName !== undefined && (obj.jsonName = message.jsonName); + message.options !== undefined && (obj.options = message.options ? FieldOptions.toJSON(message.options) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): FieldDescriptorProto { + const message = createBaseFieldDescriptorProto(); + message.name = object.name ?? ""; + message.number = object.number ?? 0; + message.label = object.label ?? 1; + message.type = object.type ?? 1; + message.typeName = object.typeName ?? ""; + message.extendee = object.extendee ?? ""; + message.defaultValue = object.defaultValue ?? ""; + message.oneofIndex = object.oneofIndex ?? 0; + message.jsonName = object.jsonName ?? ""; + if (object.options !== undefined && object.options !== null) { + message.options = FieldOptions.fromPartial(object.options); + } + return message; + }, + fromSDK(object: FieldDescriptorProtoSDKType): FieldDescriptorProto { + return { + name: object?.name, + number: object?.number, + label: isSet(object.label) ? fieldDescriptorProto_LabelFromJSON(object.label) : -1, + type: isSet(object.type) ? fieldDescriptorProto_TypeFromJSON(object.type) : -1, + typeName: object?.type_name, + extendee: object?.extendee, + defaultValue: object?.default_value, + oneofIndex: object?.oneof_index, + jsonName: object?.json_name, + options: object.options ? FieldOptions.fromSDK(object.options) : undefined + }; + }, + fromSDKJSON(object: any): FieldDescriptorProtoSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + number: isSet(object.number) ? Number(object.number) : 0, + label: isSet(object.label) ? fieldDescriptorProto_LabelFromJSON(object.label) : -1, + type: isSet(object.type) ? fieldDescriptorProto_TypeFromJSON(object.type) : -1, + type_name: isSet(object.type_name) ? String(object.type_name) : "", + extendee: isSet(object.extendee) ? String(object.extendee) : "", + default_value: isSet(object.default_value) ? String(object.default_value) : "", + oneof_index: isSet(object.oneof_index) ? Number(object.oneof_index) : 0, + json_name: isSet(object.json_name) ? String(object.json_name) : "", + options: isSet(object.options) ? FieldOptions.fromSDKJSON(object.options) : undefined + }; + }, + toSDK(message: FieldDescriptorProto): FieldDescriptorProtoSDKType { + const obj: any = {}; + obj.name = message.name; + obj.number = message.number; + message.label !== undefined && (obj.label = fieldDescriptorProto_LabelToJSON(message.label)); + message.type !== undefined && (obj.type = fieldDescriptorProto_TypeToJSON(message.type)); + obj.type_name = message.typeName; + obj.extendee = message.extendee; + obj.default_value = message.defaultValue; + obj.oneof_index = message.oneofIndex; + obj.json_name = message.jsonName; + message.options !== undefined && (obj.options = message.options ? FieldOptions.toSDK(message.options) : undefined); + return obj; + }, + fromAmino(object: FieldDescriptorProtoAmino): FieldDescriptorProto { + const message = createBaseFieldDescriptorProto(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + if (object.number !== undefined && object.number !== null) { + message.number = object.number; + } + if (object.label !== undefined && object.label !== null) { + message.label = object.label; + } + if (object.type !== undefined && object.type !== null) { + message.type = object.type; + } + if (object.type_name !== undefined && object.type_name !== null) { + message.typeName = object.type_name; + } + if (object.extendee !== undefined && object.extendee !== null) { + message.extendee = object.extendee; + } + if (object.default_value !== undefined && object.default_value !== null) { + message.defaultValue = object.default_value; + } + if (object.oneof_index !== undefined && object.oneof_index !== null) { + message.oneofIndex = object.oneof_index; + } + if (object.json_name !== undefined && object.json_name !== null) { + message.jsonName = object.json_name; + } + if (object.options !== undefined && object.options !== null) { + message.options = FieldOptions.fromAmino(object.options); + } + return message; + }, + toAmino(message: FieldDescriptorProto): FieldDescriptorProtoAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + obj.number = message.number === 0 ? undefined : message.number; + obj.label = message.label === 1 ? undefined : message.label; + obj.type = message.type === 1 ? undefined : message.type; + obj.type_name = message.typeName === "" ? undefined : message.typeName; + obj.extendee = message.extendee === "" ? undefined : message.extendee; + obj.default_value = message.defaultValue === "" ? undefined : message.defaultValue; + obj.oneof_index = message.oneofIndex === 0 ? undefined : message.oneofIndex; + obj.json_name = message.jsonName === "" ? undefined : message.jsonName; + obj.options = message.options ? FieldOptions.toAmino(message.options) : undefined; + return obj; + }, + fromAminoMsg(object: FieldDescriptorProtoAminoMsg): FieldDescriptorProto { + return FieldDescriptorProto.fromAmino(object.value); + }, + fromProtoMsg(message: FieldDescriptorProtoProtoMsg): FieldDescriptorProto { + return FieldDescriptorProto.decode(message.value); + }, + toProto(message: FieldDescriptorProto): Uint8Array { + return FieldDescriptorProto.encode(message).finish(); + }, + toProtoMsg(message: FieldDescriptorProto): FieldDescriptorProtoProtoMsg { + return { + typeUrl: "/google.protobuf.FieldDescriptorProto", + value: FieldDescriptorProto.encode(message).finish() + }; + } +}; +function createBaseOneofDescriptorProto(): OneofDescriptorProto { + return { + name: "", + options: undefined + }; +} +export const OneofDescriptorProto = { + typeUrl: "/google.protobuf.OneofDescriptorProto", + encode(message: OneofDescriptorProto, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + if (message.options !== undefined) { + OneofOptions.encode(message.options, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): OneofDescriptorProto { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseOneofDescriptorProto(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.options = OneofOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): OneofDescriptorProto { + const obj = createBaseOneofDescriptorProto(); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.options)) obj.options = OneofOptions.fromJSON(object.options); + return obj; + }, + toJSON(message: OneofDescriptorProto): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.options !== undefined && (obj.options = message.options ? OneofOptions.toJSON(message.options) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): OneofDescriptorProto { + const message = createBaseOneofDescriptorProto(); + message.name = object.name ?? ""; + if (object.options !== undefined && object.options !== null) { + message.options = OneofOptions.fromPartial(object.options); + } + return message; + }, + fromSDK(object: OneofDescriptorProtoSDKType): OneofDescriptorProto { + return { + name: object?.name, + options: object.options ? OneofOptions.fromSDK(object.options) : undefined + }; + }, + fromSDKJSON(object: any): OneofDescriptorProtoSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + options: isSet(object.options) ? OneofOptions.fromSDKJSON(object.options) : undefined + }; + }, + toSDK(message: OneofDescriptorProto): OneofDescriptorProtoSDKType { + const obj: any = {}; + obj.name = message.name; + message.options !== undefined && (obj.options = message.options ? OneofOptions.toSDK(message.options) : undefined); + return obj; + }, + fromAmino(object: OneofDescriptorProtoAmino): OneofDescriptorProto { + const message = createBaseOneofDescriptorProto(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + if (object.options !== undefined && object.options !== null) { + message.options = OneofOptions.fromAmino(object.options); + } + return message; + }, + toAmino(message: OneofDescriptorProto): OneofDescriptorProtoAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + obj.options = message.options ? OneofOptions.toAmino(message.options) : undefined; + return obj; + }, + fromAminoMsg(object: OneofDescriptorProtoAminoMsg): OneofDescriptorProto { + return OneofDescriptorProto.fromAmino(object.value); + }, + fromProtoMsg(message: OneofDescriptorProtoProtoMsg): OneofDescriptorProto { + return OneofDescriptorProto.decode(message.value); + }, + toProto(message: OneofDescriptorProto): Uint8Array { + return OneofDescriptorProto.encode(message).finish(); + }, + toProtoMsg(message: OneofDescriptorProto): OneofDescriptorProtoProtoMsg { + return { + typeUrl: "/google.protobuf.OneofDescriptorProto", + value: OneofDescriptorProto.encode(message).finish() + }; + } +}; +function createBaseEnumDescriptorProto(): EnumDescriptorProto { + return { + name: "", + value: [], + options: undefined, + reservedRange: [], + reservedName: [] + }; +} +export const EnumDescriptorProto = { + typeUrl: "/google.protobuf.EnumDescriptorProto", + encode(message: EnumDescriptorProto, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + for (const v of message.value) { + EnumValueDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.options !== undefined) { + EnumOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.reservedRange) { + EnumDescriptorProto_EnumReservedRange.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.reservedName) { + writer.uint32(42).string(v!); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): EnumDescriptorProto { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseEnumDescriptorProto(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.value.push(EnumValueDescriptorProto.decode(reader, reader.uint32())); + break; + case 3: + message.options = EnumOptions.decode(reader, reader.uint32()); + break; + case 4: + message.reservedRange.push(EnumDescriptorProto_EnumReservedRange.decode(reader, reader.uint32())); + break; + case 5: + message.reservedName.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): EnumDescriptorProto { + const obj = createBaseEnumDescriptorProto(); + if (isSet(object.name)) obj.name = String(object.name); + if (Array.isArray(object?.value)) obj.value = object.value.map((e: any) => EnumValueDescriptorProto.fromJSON(e)); + if (isSet(object.options)) obj.options = EnumOptions.fromJSON(object.options); + if (Array.isArray(object?.reservedRange)) obj.reservedRange = object.reservedRange.map((e: any) => EnumDescriptorProto_EnumReservedRange.fromJSON(e)); + if (Array.isArray(object?.reservedName)) obj.reservedName = object.reservedName.map((e: any) => String(e)); + return obj; + }, + toJSON(message: EnumDescriptorProto): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.value) { + obj.value = message.value.map(e => e ? EnumValueDescriptorProto.toJSON(e) : undefined); + } else { + obj.value = []; + } + message.options !== undefined && (obj.options = message.options ? EnumOptions.toJSON(message.options) : undefined); + if (message.reservedRange) { + obj.reservedRange = message.reservedRange.map(e => e ? EnumDescriptorProto_EnumReservedRange.toJSON(e) : undefined); + } else { + obj.reservedRange = []; + } + if (message.reservedName) { + obj.reservedName = message.reservedName.map(e => e); + } else { + obj.reservedName = []; + } + return obj; + }, + fromPartial(object: DeepPartial): EnumDescriptorProto { + const message = createBaseEnumDescriptorProto(); + message.name = object.name ?? ""; + message.value = object.value?.map(e => EnumValueDescriptorProto.fromPartial(e)) || []; + if (object.options !== undefined && object.options !== null) { + message.options = EnumOptions.fromPartial(object.options); + } + message.reservedRange = object.reservedRange?.map(e => EnumDescriptorProto_EnumReservedRange.fromPartial(e)) || []; + message.reservedName = object.reservedName?.map(e => e) || []; + return message; + }, + fromSDK(object: EnumDescriptorProtoSDKType): EnumDescriptorProto { + return { + name: object?.name, + value: Array.isArray(object?.value) ? object.value.map((e: any) => EnumValueDescriptorProto.fromSDK(e)) : [], + options: object.options ? EnumOptions.fromSDK(object.options) : undefined, + reservedRange: Array.isArray(object?.reserved_range) ? object.reserved_range.map((e: any) => EnumDescriptorProto_EnumReservedRange.fromSDK(e)) : [], + reservedName: Array.isArray(object?.reserved_name) ? object.reserved_name.map((e: any) => e) : [] + }; + }, + fromSDKJSON(object: any): EnumDescriptorProtoSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + value: Array.isArray(object?.value) ? object.value.map((e: any) => EnumValueDescriptorProto.fromSDKJSON(e)) : [], + options: isSet(object.options) ? EnumOptions.fromSDKJSON(object.options) : undefined, + reserved_range: Array.isArray(object?.reserved_range) ? object.reserved_range.map((e: any) => EnumDescriptorProto_EnumReservedRange.fromSDKJSON(e)) : [], + reserved_name: Array.isArray(object?.reserved_name) ? object.reserved_name.map((e: any) => String(e)) : [] + }; + }, + toSDK(message: EnumDescriptorProto): EnumDescriptorProtoSDKType { + const obj: any = {}; + obj.name = message.name; + if (message.value) { + obj.value = message.value.map(e => e ? EnumValueDescriptorProto.toSDK(e) : undefined); + } else { + obj.value = []; + } + message.options !== undefined && (obj.options = message.options ? EnumOptions.toSDK(message.options) : undefined); + if (message.reservedRange) { + obj.reserved_range = message.reservedRange.map(e => e ? EnumDescriptorProto_EnumReservedRange.toSDK(e) : undefined); + } else { + obj.reserved_range = []; + } + if (message.reservedName) { + obj.reserved_name = message.reservedName.map(e => e); + } else { + obj.reserved_name = []; + } + return obj; + }, + fromAmino(object: EnumDescriptorProtoAmino): EnumDescriptorProto { + const message = createBaseEnumDescriptorProto(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + message.value = object.value?.map(e => EnumValueDescriptorProto.fromAmino(e)) || []; + if (object.options !== undefined && object.options !== null) { + message.options = EnumOptions.fromAmino(object.options); + } + message.reservedRange = object.reserved_range?.map(e => EnumDescriptorProto_EnumReservedRange.fromAmino(e)) || []; + message.reservedName = object.reserved_name?.map(e => e) || []; + return message; + }, + toAmino(message: EnumDescriptorProto): EnumDescriptorProtoAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + if (message.value) { + obj.value = message.value.map(e => e ? EnumValueDescriptorProto.toAmino(e) : undefined); + } else { + obj.value = message.value; + } + obj.options = message.options ? EnumOptions.toAmino(message.options) : undefined; + if (message.reservedRange) { + obj.reserved_range = message.reservedRange.map(e => e ? EnumDescriptorProto_EnumReservedRange.toAmino(e) : undefined); + } else { + obj.reserved_range = message.reservedRange; + } + if (message.reservedName) { + obj.reserved_name = message.reservedName.map(e => e); + } else { + obj.reserved_name = message.reservedName; + } + return obj; + }, + fromAminoMsg(object: EnumDescriptorProtoAminoMsg): EnumDescriptorProto { + return EnumDescriptorProto.fromAmino(object.value); + }, + fromProtoMsg(message: EnumDescriptorProtoProtoMsg): EnumDescriptorProto { + return EnumDescriptorProto.decode(message.value); + }, + toProto(message: EnumDescriptorProto): Uint8Array { + return EnumDescriptorProto.encode(message).finish(); + }, + toProtoMsg(message: EnumDescriptorProto): EnumDescriptorProtoProtoMsg { + return { + typeUrl: "/google.protobuf.EnumDescriptorProto", + value: EnumDescriptorProto.encode(message).finish() + }; + } +}; +function createBaseEnumDescriptorProto_EnumReservedRange(): EnumDescriptorProto_EnumReservedRange { + return { + start: 0, + end: 0 + }; +} +export const EnumDescriptorProto_EnumReservedRange = { + typeUrl: "/google.protobuf.EnumReservedRange", + encode(message: EnumDescriptorProto_EnumReservedRange, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.start !== undefined) { + writer.uint32(8).int32(message.start); + } + if (message.end !== undefined) { + writer.uint32(16).int32(message.end); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): EnumDescriptorProto_EnumReservedRange { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseEnumDescriptorProto_EnumReservedRange(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): EnumDescriptorProto_EnumReservedRange { + const obj = createBaseEnumDescriptorProto_EnumReservedRange(); + if (isSet(object.start)) obj.start = Number(object.start); + if (isSet(object.end)) obj.end = Number(object.end); + return obj; + }, + toJSON(message: EnumDescriptorProto_EnumReservedRange): JsonSafe { + const obj: any = {}; + message.start !== undefined && (obj.start = Math.round(message.start)); + message.end !== undefined && (obj.end = Math.round(message.end)); + return obj; + }, + fromPartial(object: DeepPartial): EnumDescriptorProto_EnumReservedRange { + const message = createBaseEnumDescriptorProto_EnumReservedRange(); + message.start = object.start ?? 0; + message.end = object.end ?? 0; + return message; + }, + fromSDK(object: EnumDescriptorProto_EnumReservedRangeSDKType): EnumDescriptorProto_EnumReservedRange { + return { + start: object?.start, + end: object?.end + }; + }, + fromSDKJSON(object: any): EnumDescriptorProto_EnumReservedRangeSDKType { + return { + start: isSet(object.start) ? Number(object.start) : 0, + end: isSet(object.end) ? Number(object.end) : 0 + }; + }, + toSDK(message: EnumDescriptorProto_EnumReservedRange): EnumDescriptorProto_EnumReservedRangeSDKType { + const obj: any = {}; + obj.start = message.start; + obj.end = message.end; + return obj; + }, + fromAmino(object: EnumDescriptorProto_EnumReservedRangeAmino): EnumDescriptorProto_EnumReservedRange { + const message = createBaseEnumDescriptorProto_EnumReservedRange(); + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } + return message; + }, + toAmino(message: EnumDescriptorProto_EnumReservedRange): EnumDescriptorProto_EnumReservedRangeAmino { + const obj: any = {}; + obj.start = message.start === 0 ? undefined : message.start; + obj.end = message.end === 0 ? undefined : message.end; + return obj; + }, + fromAminoMsg(object: EnumDescriptorProto_EnumReservedRangeAminoMsg): EnumDescriptorProto_EnumReservedRange { + return EnumDescriptorProto_EnumReservedRange.fromAmino(object.value); + }, + fromProtoMsg(message: EnumDescriptorProto_EnumReservedRangeProtoMsg): EnumDescriptorProto_EnumReservedRange { + return EnumDescriptorProto_EnumReservedRange.decode(message.value); + }, + toProto(message: EnumDescriptorProto_EnumReservedRange): Uint8Array { + return EnumDescriptorProto_EnumReservedRange.encode(message).finish(); + }, + toProtoMsg(message: EnumDescriptorProto_EnumReservedRange): EnumDescriptorProto_EnumReservedRangeProtoMsg { + return { + typeUrl: "/google.protobuf.EnumReservedRange", + value: EnumDescriptorProto_EnumReservedRange.encode(message).finish() + }; + } +}; +function createBaseEnumValueDescriptorProto(): EnumValueDescriptorProto { + return { + name: "", + number: 0, + options: undefined + }; +} +export const EnumValueDescriptorProto = { + typeUrl: "/google.protobuf.EnumValueDescriptorProto", + encode(message: EnumValueDescriptorProto, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + if (message.number !== undefined) { + writer.uint32(16).int32(message.number); + } + if (message.options !== undefined) { + EnumValueOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): EnumValueDescriptorProto { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseEnumValueDescriptorProto(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.number = reader.int32(); + break; + case 3: + message.options = EnumValueOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): EnumValueDescriptorProto { + const obj = createBaseEnumValueDescriptorProto(); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.number)) obj.number = Number(object.number); + if (isSet(object.options)) obj.options = EnumValueOptions.fromJSON(object.options); + return obj; + }, + toJSON(message: EnumValueDescriptorProto): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.number !== undefined && (obj.number = Math.round(message.number)); + message.options !== undefined && (obj.options = message.options ? EnumValueOptions.toJSON(message.options) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): EnumValueDescriptorProto { + const message = createBaseEnumValueDescriptorProto(); + message.name = object.name ?? ""; + message.number = object.number ?? 0; + if (object.options !== undefined && object.options !== null) { + message.options = EnumValueOptions.fromPartial(object.options); + } + return message; + }, + fromSDK(object: EnumValueDescriptorProtoSDKType): EnumValueDescriptorProto { + return { + name: object?.name, + number: object?.number, + options: object.options ? EnumValueOptions.fromSDK(object.options) : undefined + }; + }, + fromSDKJSON(object: any): EnumValueDescriptorProtoSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + number: isSet(object.number) ? Number(object.number) : 0, + options: isSet(object.options) ? EnumValueOptions.fromSDKJSON(object.options) : undefined + }; + }, + toSDK(message: EnumValueDescriptorProto): EnumValueDescriptorProtoSDKType { + const obj: any = {}; + obj.name = message.name; + obj.number = message.number; + message.options !== undefined && (obj.options = message.options ? EnumValueOptions.toSDK(message.options) : undefined); + return obj; + }, + fromAmino(object: EnumValueDescriptorProtoAmino): EnumValueDescriptorProto { + const message = createBaseEnumValueDescriptorProto(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + if (object.number !== undefined && object.number !== null) { + message.number = object.number; + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumValueOptions.fromAmino(object.options); + } + return message; + }, + toAmino(message: EnumValueDescriptorProto): EnumValueDescriptorProtoAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + obj.number = message.number === 0 ? undefined : message.number; + obj.options = message.options ? EnumValueOptions.toAmino(message.options) : undefined; + return obj; + }, + fromAminoMsg(object: EnumValueDescriptorProtoAminoMsg): EnumValueDescriptorProto { + return EnumValueDescriptorProto.fromAmino(object.value); + }, + fromProtoMsg(message: EnumValueDescriptorProtoProtoMsg): EnumValueDescriptorProto { + return EnumValueDescriptorProto.decode(message.value); + }, + toProto(message: EnumValueDescriptorProto): Uint8Array { + return EnumValueDescriptorProto.encode(message).finish(); + }, + toProtoMsg(message: EnumValueDescriptorProto): EnumValueDescriptorProtoProtoMsg { + return { + typeUrl: "/google.protobuf.EnumValueDescriptorProto", + value: EnumValueDescriptorProto.encode(message).finish() + }; + } +}; +function createBaseServiceDescriptorProto(): ServiceDescriptorProto { + return { + name: "", + method: [], + options: undefined + }; +} +export const ServiceDescriptorProto = { + typeUrl: "/google.protobuf.ServiceDescriptorProto", + encode(message: ServiceDescriptorProto, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + for (const v of message.method) { + MethodDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.options !== undefined) { + ServiceOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ServiceDescriptorProto { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseServiceDescriptorProto(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.method.push(MethodDescriptorProto.decode(reader, reader.uint32())); + break; + case 3: + message.options = ServiceOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ServiceDescriptorProto { + const obj = createBaseServiceDescriptorProto(); + if (isSet(object.name)) obj.name = String(object.name); + if (Array.isArray(object?.method)) obj.method = object.method.map((e: any) => MethodDescriptorProto.fromJSON(e)); + if (isSet(object.options)) obj.options = ServiceOptions.fromJSON(object.options); + return obj; + }, + toJSON(message: ServiceDescriptorProto): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.method) { + obj.method = message.method.map(e => e ? MethodDescriptorProto.toJSON(e) : undefined); + } else { + obj.method = []; + } + message.options !== undefined && (obj.options = message.options ? ServiceOptions.toJSON(message.options) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): ServiceDescriptorProto { + const message = createBaseServiceDescriptorProto(); + message.name = object.name ?? ""; + message.method = object.method?.map(e => MethodDescriptorProto.fromPartial(e)) || []; + if (object.options !== undefined && object.options !== null) { + message.options = ServiceOptions.fromPartial(object.options); + } + return message; + }, + fromSDK(object: ServiceDescriptorProtoSDKType): ServiceDescriptorProto { + return { + name: object?.name, + method: Array.isArray(object?.method) ? object.method.map((e: any) => MethodDescriptorProto.fromSDK(e)) : [], + options: object.options ? ServiceOptions.fromSDK(object.options) : undefined + }; + }, + fromSDKJSON(object: any): ServiceDescriptorProtoSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + method: Array.isArray(object?.method) ? object.method.map((e: any) => MethodDescriptorProto.fromSDKJSON(e)) : [], + options: isSet(object.options) ? ServiceOptions.fromSDKJSON(object.options) : undefined + }; + }, + toSDK(message: ServiceDescriptorProto): ServiceDescriptorProtoSDKType { + const obj: any = {}; + obj.name = message.name; + if (message.method) { + obj.method = message.method.map(e => e ? MethodDescriptorProto.toSDK(e) : undefined); + } else { + obj.method = []; + } + message.options !== undefined && (obj.options = message.options ? ServiceOptions.toSDK(message.options) : undefined); + return obj; + }, + fromAmino(object: ServiceDescriptorProtoAmino): ServiceDescriptorProto { + const message = createBaseServiceDescriptorProto(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + message.method = object.method?.map(e => MethodDescriptorProto.fromAmino(e)) || []; + if (object.options !== undefined && object.options !== null) { + message.options = ServiceOptions.fromAmino(object.options); + } + return message; + }, + toAmino(message: ServiceDescriptorProto): ServiceDescriptorProtoAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + if (message.method) { + obj.method = message.method.map(e => e ? MethodDescriptorProto.toAmino(e) : undefined); + } else { + obj.method = message.method; + } + obj.options = message.options ? ServiceOptions.toAmino(message.options) : undefined; + return obj; + }, + fromAminoMsg(object: ServiceDescriptorProtoAminoMsg): ServiceDescriptorProto { + return ServiceDescriptorProto.fromAmino(object.value); + }, + fromProtoMsg(message: ServiceDescriptorProtoProtoMsg): ServiceDescriptorProto { + return ServiceDescriptorProto.decode(message.value); + }, + toProto(message: ServiceDescriptorProto): Uint8Array { + return ServiceDescriptorProto.encode(message).finish(); + }, + toProtoMsg(message: ServiceDescriptorProto): ServiceDescriptorProtoProtoMsg { + return { + typeUrl: "/google.protobuf.ServiceDescriptorProto", + value: ServiceDescriptorProto.encode(message).finish() + }; + } +}; +function createBaseMethodDescriptorProto(): MethodDescriptorProto { + return { + name: "", + inputType: "", + outputType: "", + options: undefined, + clientStreaming: false, + serverStreaming: false + }; +} +export const MethodDescriptorProto = { + typeUrl: "/google.protobuf.MethodDescriptorProto", + encode(message: MethodDescriptorProto, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + if (message.inputType !== undefined) { + writer.uint32(18).string(message.inputType); + } + if (message.outputType !== undefined) { + writer.uint32(26).string(message.outputType); + } + if (message.options !== undefined) { + MethodOptions.encode(message.options, writer.uint32(34).fork()).ldelim(); + } + if (message.clientStreaming !== undefined) { + writer.uint32(40).bool(message.clientStreaming); + } + if (message.serverStreaming !== undefined) { + writer.uint32(48).bool(message.serverStreaming); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MethodDescriptorProto { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMethodDescriptorProto(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.inputType = reader.string(); + break; + case 3: + message.outputType = reader.string(); + break; + case 4: + message.options = MethodOptions.decode(reader, reader.uint32()); + break; + case 5: + message.clientStreaming = reader.bool(); + break; + case 6: + message.serverStreaming = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MethodDescriptorProto { + const obj = createBaseMethodDescriptorProto(); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.inputType)) obj.inputType = String(object.inputType); + if (isSet(object.outputType)) obj.outputType = String(object.outputType); + if (isSet(object.options)) obj.options = MethodOptions.fromJSON(object.options); + if (isSet(object.clientStreaming)) obj.clientStreaming = Boolean(object.clientStreaming); + if (isSet(object.serverStreaming)) obj.serverStreaming = Boolean(object.serverStreaming); + return obj; + }, + toJSON(message: MethodDescriptorProto): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.inputType !== undefined && (obj.inputType = message.inputType); + message.outputType !== undefined && (obj.outputType = message.outputType); + message.options !== undefined && (obj.options = message.options ? MethodOptions.toJSON(message.options) : undefined); + message.clientStreaming !== undefined && (obj.clientStreaming = message.clientStreaming); + message.serverStreaming !== undefined && (obj.serverStreaming = message.serverStreaming); + return obj; + }, + fromPartial(object: DeepPartial): MethodDescriptorProto { + const message = createBaseMethodDescriptorProto(); + message.name = object.name ?? ""; + message.inputType = object.inputType ?? ""; + message.outputType = object.outputType ?? ""; + if (object.options !== undefined && object.options !== null) { + message.options = MethodOptions.fromPartial(object.options); + } + message.clientStreaming = object.clientStreaming ?? false; + message.serverStreaming = object.serverStreaming ?? false; + return message; + }, + fromSDK(object: MethodDescriptorProtoSDKType): MethodDescriptorProto { + return { + name: object?.name, + inputType: object?.input_type, + outputType: object?.output_type, + options: object.options ? MethodOptions.fromSDK(object.options) : undefined, + clientStreaming: object?.client_streaming, + serverStreaming: object?.server_streaming + }; + }, + fromSDKJSON(object: any): MethodDescriptorProtoSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + input_type: isSet(object.input_type) ? String(object.input_type) : "", + output_type: isSet(object.output_type) ? String(object.output_type) : "", + options: isSet(object.options) ? MethodOptions.fromSDKJSON(object.options) : undefined, + client_streaming: isSet(object.client_streaming) ? Boolean(object.client_streaming) : false, + server_streaming: isSet(object.server_streaming) ? Boolean(object.server_streaming) : false + }; + }, + toSDK(message: MethodDescriptorProto): MethodDescriptorProtoSDKType { + const obj: any = {}; + obj.name = message.name; + obj.input_type = message.inputType; + obj.output_type = message.outputType; + message.options !== undefined && (obj.options = message.options ? MethodOptions.toSDK(message.options) : undefined); + obj.client_streaming = message.clientStreaming; + obj.server_streaming = message.serverStreaming; + return obj; + }, + fromAmino(object: MethodDescriptorProtoAmino): MethodDescriptorProto { + const message = createBaseMethodDescriptorProto(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + if (object.input_type !== undefined && object.input_type !== null) { + message.inputType = object.input_type; + } + if (object.output_type !== undefined && object.output_type !== null) { + message.outputType = object.output_type; + } + if (object.options !== undefined && object.options !== null) { + message.options = MethodOptions.fromAmino(object.options); + } + if (object.client_streaming !== undefined && object.client_streaming !== null) { + message.clientStreaming = object.client_streaming; + } + if (object.server_streaming !== undefined && object.server_streaming !== null) { + message.serverStreaming = object.server_streaming; + } + return message; + }, + toAmino(message: MethodDescriptorProto): MethodDescriptorProtoAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + obj.input_type = message.inputType === "" ? undefined : message.inputType; + obj.output_type = message.outputType === "" ? undefined : message.outputType; + obj.options = message.options ? MethodOptions.toAmino(message.options) : undefined; + obj.client_streaming = message.clientStreaming === false ? undefined : message.clientStreaming; + obj.server_streaming = message.serverStreaming === false ? undefined : message.serverStreaming; + return obj; + }, + fromAminoMsg(object: MethodDescriptorProtoAminoMsg): MethodDescriptorProto { + return MethodDescriptorProto.fromAmino(object.value); + }, + fromProtoMsg(message: MethodDescriptorProtoProtoMsg): MethodDescriptorProto { + return MethodDescriptorProto.decode(message.value); + }, + toProto(message: MethodDescriptorProto): Uint8Array { + return MethodDescriptorProto.encode(message).finish(); + }, + toProtoMsg(message: MethodDescriptorProto): MethodDescriptorProtoProtoMsg { + return { + typeUrl: "/google.protobuf.MethodDescriptorProto", + value: MethodDescriptorProto.encode(message).finish() + }; + } +}; +function createBaseFileOptions(): FileOptions { + return { + javaPackage: "", + javaOuterClassname: "", + javaMultipleFiles: false, + javaGenerateEqualsAndHash: false, + javaStringCheckUtf8: false, + optimizeFor: 1, + goPackage: "", + ccGenericServices: false, + javaGenericServices: false, + pyGenericServices: false, + phpGenericServices: false, + deprecated: false, + ccEnableArenas: false, + objcClassPrefix: "", + csharpNamespace: "", + swiftPrefix: "", + phpClassPrefix: "", + phpNamespace: "", + phpMetadataNamespace: "", + rubyPackage: "", + uninterpretedOption: [] + }; +} +export const FileOptions = { + typeUrl: "/google.protobuf.FileOptions", + encode(message: FileOptions, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.javaPackage !== undefined) { + writer.uint32(10).string(message.javaPackage); + } + if (message.javaOuterClassname !== undefined) { + writer.uint32(66).string(message.javaOuterClassname); + } + if (message.javaMultipleFiles !== undefined) { + writer.uint32(80).bool(message.javaMultipleFiles); + } + if (message.javaGenerateEqualsAndHash !== undefined) { + writer.uint32(160).bool(message.javaGenerateEqualsAndHash); + } + if (message.javaStringCheckUtf8 !== undefined) { + writer.uint32(216).bool(message.javaStringCheckUtf8); + } + if (message.optimizeFor !== 1) { + writer.uint32(72).int32(message.optimizeFor); + } + if (message.goPackage !== undefined) { + writer.uint32(90).string(message.goPackage); + } + if (message.ccGenericServices !== undefined) { + writer.uint32(128).bool(message.ccGenericServices); + } + if (message.javaGenericServices !== undefined) { + writer.uint32(136).bool(message.javaGenericServices); + } + if (message.pyGenericServices !== undefined) { + writer.uint32(144).bool(message.pyGenericServices); + } + if (message.phpGenericServices !== undefined) { + writer.uint32(336).bool(message.phpGenericServices); + } + if (message.deprecated !== undefined) { + writer.uint32(184).bool(message.deprecated); + } + if (message.ccEnableArenas !== undefined) { + writer.uint32(248).bool(message.ccEnableArenas); + } + if (message.objcClassPrefix !== undefined) { + writer.uint32(290).string(message.objcClassPrefix); + } + if (message.csharpNamespace !== undefined) { + writer.uint32(298).string(message.csharpNamespace); + } + if (message.swiftPrefix !== undefined) { + writer.uint32(314).string(message.swiftPrefix); + } + if (message.phpClassPrefix !== undefined) { + writer.uint32(322).string(message.phpClassPrefix); + } + if (message.phpNamespace !== undefined) { + writer.uint32(330).string(message.phpNamespace); + } + if (message.phpMetadataNamespace !== undefined) { + writer.uint32(354).string(message.phpMetadataNamespace); + } + if (message.rubyPackage !== undefined) { + writer.uint32(362).string(message.rubyPackage); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): FileOptions { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseFileOptions(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.javaPackage = reader.string(); + break; + case 8: + message.javaOuterClassname = reader.string(); + break; + case 10: + message.javaMultipleFiles = reader.bool(); + break; + case 20: + message.javaGenerateEqualsAndHash = reader.bool(); + break; + case 27: + message.javaStringCheckUtf8 = reader.bool(); + break; + case 9: + message.optimizeFor = (reader.int32() as any); + break; + case 11: + message.goPackage = reader.string(); + break; + case 16: + message.ccGenericServices = reader.bool(); + break; + case 17: + message.javaGenericServices = reader.bool(); + break; + case 18: + message.pyGenericServices = reader.bool(); + break; + case 42: + message.phpGenericServices = reader.bool(); + break; + case 23: + message.deprecated = reader.bool(); + break; + case 31: + message.ccEnableArenas = reader.bool(); + break; + case 36: + message.objcClassPrefix = reader.string(); + break; + case 37: + message.csharpNamespace = reader.string(); + break; + case 39: + message.swiftPrefix = reader.string(); + break; + case 40: + message.phpClassPrefix = reader.string(); + break; + case 41: + message.phpNamespace = reader.string(); + break; + case 44: + message.phpMetadataNamespace = reader.string(); + break; + case 45: + message.rubyPackage = reader.string(); + break; + case 999: + message.uninterpretedOption.push(UninterpretedOption.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): FileOptions { + const obj = createBaseFileOptions(); + if (isSet(object.javaPackage)) obj.javaPackage = String(object.javaPackage); + if (isSet(object.javaOuterClassname)) obj.javaOuterClassname = String(object.javaOuterClassname); + if (isSet(object.javaMultipleFiles)) obj.javaMultipleFiles = Boolean(object.javaMultipleFiles); + if (isSet(object.javaGenerateEqualsAndHash)) obj.javaGenerateEqualsAndHash = Boolean(object.javaGenerateEqualsAndHash); + if (isSet(object.javaStringCheckUtf8)) obj.javaStringCheckUtf8 = Boolean(object.javaStringCheckUtf8); + if (isSet(object.optimizeFor)) obj.optimizeFor = fileOptions_OptimizeModeFromJSON(object.optimizeFor); + if (isSet(object.goPackage)) obj.goPackage = String(object.goPackage); + if (isSet(object.ccGenericServices)) obj.ccGenericServices = Boolean(object.ccGenericServices); + if (isSet(object.javaGenericServices)) obj.javaGenericServices = Boolean(object.javaGenericServices); + if (isSet(object.pyGenericServices)) obj.pyGenericServices = Boolean(object.pyGenericServices); + if (isSet(object.phpGenericServices)) obj.phpGenericServices = Boolean(object.phpGenericServices); + if (isSet(object.deprecated)) obj.deprecated = Boolean(object.deprecated); + if (isSet(object.ccEnableArenas)) obj.ccEnableArenas = Boolean(object.ccEnableArenas); + if (isSet(object.objcClassPrefix)) obj.objcClassPrefix = String(object.objcClassPrefix); + if (isSet(object.csharpNamespace)) obj.csharpNamespace = String(object.csharpNamespace); + if (isSet(object.swiftPrefix)) obj.swiftPrefix = String(object.swiftPrefix); + if (isSet(object.phpClassPrefix)) obj.phpClassPrefix = String(object.phpClassPrefix); + if (isSet(object.phpNamespace)) obj.phpNamespace = String(object.phpNamespace); + if (isSet(object.phpMetadataNamespace)) obj.phpMetadataNamespace = String(object.phpMetadataNamespace); + if (isSet(object.rubyPackage)) obj.rubyPackage = String(object.rubyPackage); + if (Array.isArray(object?.uninterpretedOption)) obj.uninterpretedOption = object.uninterpretedOption.map((e: any) => UninterpretedOption.fromJSON(e)); + return obj; + }, + toJSON(message: FileOptions): JsonSafe { + const obj: any = {}; + message.javaPackage !== undefined && (obj.javaPackage = message.javaPackage); + message.javaOuterClassname !== undefined && (obj.javaOuterClassname = message.javaOuterClassname); + message.javaMultipleFiles !== undefined && (obj.javaMultipleFiles = message.javaMultipleFiles); + message.javaGenerateEqualsAndHash !== undefined && (obj.javaGenerateEqualsAndHash = message.javaGenerateEqualsAndHash); + message.javaStringCheckUtf8 !== undefined && (obj.javaStringCheckUtf8 = message.javaStringCheckUtf8); + message.optimizeFor !== undefined && (obj.optimizeFor = fileOptions_OptimizeModeToJSON(message.optimizeFor)); + message.goPackage !== undefined && (obj.goPackage = message.goPackage); + message.ccGenericServices !== undefined && (obj.ccGenericServices = message.ccGenericServices); + message.javaGenericServices !== undefined && (obj.javaGenericServices = message.javaGenericServices); + message.pyGenericServices !== undefined && (obj.pyGenericServices = message.pyGenericServices); + message.phpGenericServices !== undefined && (obj.phpGenericServices = message.phpGenericServices); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.ccEnableArenas !== undefined && (obj.ccEnableArenas = message.ccEnableArenas); + message.objcClassPrefix !== undefined && (obj.objcClassPrefix = message.objcClassPrefix); + message.csharpNamespace !== undefined && (obj.csharpNamespace = message.csharpNamespace); + message.swiftPrefix !== undefined && (obj.swiftPrefix = message.swiftPrefix); + message.phpClassPrefix !== undefined && (obj.phpClassPrefix = message.phpClassPrefix); + message.phpNamespace !== undefined && (obj.phpNamespace = message.phpNamespace); + message.phpMetadataNamespace !== undefined && (obj.phpMetadataNamespace = message.phpMetadataNamespace); + message.rubyPackage !== undefined && (obj.rubyPackage = message.rubyPackage); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map(e => e ? UninterpretedOption.toJSON(e) : undefined); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + fromPartial(object: DeepPartial): FileOptions { + const message = createBaseFileOptions(); + message.javaPackage = object.javaPackage ?? ""; + message.javaOuterClassname = object.javaOuterClassname ?? ""; + message.javaMultipleFiles = object.javaMultipleFiles ?? false; + message.javaGenerateEqualsAndHash = object.javaGenerateEqualsAndHash ?? false; + message.javaStringCheckUtf8 = object.javaStringCheckUtf8 ?? false; + message.optimizeFor = object.optimizeFor ?? 1; + message.goPackage = object.goPackage ?? ""; + message.ccGenericServices = object.ccGenericServices ?? false; + message.javaGenericServices = object.javaGenericServices ?? false; + message.pyGenericServices = object.pyGenericServices ?? false; + message.phpGenericServices = object.phpGenericServices ?? false; + message.deprecated = object.deprecated ?? false; + message.ccEnableArenas = object.ccEnableArenas ?? false; + message.objcClassPrefix = object.objcClassPrefix ?? ""; + message.csharpNamespace = object.csharpNamespace ?? ""; + message.swiftPrefix = object.swiftPrefix ?? ""; + message.phpClassPrefix = object.phpClassPrefix ?? ""; + message.phpNamespace = object.phpNamespace ?? ""; + message.phpMetadataNamespace = object.phpMetadataNamespace ?? ""; + message.rubyPackage = object.rubyPackage ?? ""; + message.uninterpretedOption = object.uninterpretedOption?.map(e => UninterpretedOption.fromPartial(e)) || []; + return message; + }, + fromSDK(object: FileOptionsSDKType): FileOptions { + return { + javaPackage: object?.java_package, + javaOuterClassname: object?.java_outer_classname, + javaMultipleFiles: object?.java_multiple_files, + javaGenerateEqualsAndHash: object?.java_generate_equals_and_hash, + javaStringCheckUtf8: object?.java_string_check_utf8, + optimizeFor: isSet(object.optimize_for) ? fileOptions_OptimizeModeFromJSON(object.optimize_for) : -1, + goPackage: object?.go_package, + ccGenericServices: object?.cc_generic_services, + javaGenericServices: object?.java_generic_services, + pyGenericServices: object?.py_generic_services, + phpGenericServices: object?.php_generic_services, + deprecated: object?.deprecated, + ccEnableArenas: object?.cc_enable_arenas, + objcClassPrefix: object?.objc_class_prefix, + csharpNamespace: object?.csharp_namespace, + swiftPrefix: object?.swift_prefix, + phpClassPrefix: object?.php_class_prefix, + phpNamespace: object?.php_namespace, + phpMetadataNamespace: object?.php_metadata_namespace, + rubyPackage: object?.ruby_package, + uninterpretedOption: Array.isArray(object?.uninterpreted_option) ? object.uninterpreted_option.map((e: any) => UninterpretedOption.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): FileOptionsSDKType { + return { + java_package: isSet(object.java_package) ? String(object.java_package) : "", + java_outer_classname: isSet(object.java_outer_classname) ? String(object.java_outer_classname) : "", + java_multiple_files: isSet(object.java_multiple_files) ? Boolean(object.java_multiple_files) : false, + java_generate_equals_and_hash: isSet(object.java_generate_equals_and_hash) ? Boolean(object.java_generate_equals_and_hash) : false, + java_string_check_utf8: isSet(object.java_string_check_utf8) ? Boolean(object.java_string_check_utf8) : false, + optimize_for: isSet(object.optimize_for) ? fileOptions_OptimizeModeFromJSON(object.optimize_for) : -1, + go_package: isSet(object.go_package) ? String(object.go_package) : "", + cc_generic_services: isSet(object.cc_generic_services) ? Boolean(object.cc_generic_services) : false, + java_generic_services: isSet(object.java_generic_services) ? Boolean(object.java_generic_services) : false, + py_generic_services: isSet(object.py_generic_services) ? Boolean(object.py_generic_services) : false, + php_generic_services: isSet(object.php_generic_services) ? Boolean(object.php_generic_services) : false, + deprecated: isSet(object.deprecated) ? Boolean(object.deprecated) : false, + cc_enable_arenas: isSet(object.cc_enable_arenas) ? Boolean(object.cc_enable_arenas) : false, + objc_class_prefix: isSet(object.objc_class_prefix) ? String(object.objc_class_prefix) : "", + csharp_namespace: isSet(object.csharp_namespace) ? String(object.csharp_namespace) : "", + swift_prefix: isSet(object.swift_prefix) ? String(object.swift_prefix) : "", + php_class_prefix: isSet(object.php_class_prefix) ? String(object.php_class_prefix) : "", + php_namespace: isSet(object.php_namespace) ? String(object.php_namespace) : "", + php_metadata_namespace: isSet(object.php_metadata_namespace) ? String(object.php_metadata_namespace) : "", + ruby_package: isSet(object.ruby_package) ? String(object.ruby_package) : "", + uninterpreted_option: Array.isArray(object?.uninterpreted_option) ? object.uninterpreted_option.map((e: any) => UninterpretedOption.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: FileOptions): FileOptionsSDKType { + const obj: any = {}; + obj.java_package = message.javaPackage; + obj.java_outer_classname = message.javaOuterClassname; + obj.java_multiple_files = message.javaMultipleFiles; + obj.java_generate_equals_and_hash = message.javaGenerateEqualsAndHash; + obj.java_string_check_utf8 = message.javaStringCheckUtf8; + message.optimizeFor !== undefined && (obj.optimize_for = fileOptions_OptimizeModeToJSON(message.optimizeFor)); + obj.go_package = message.goPackage; + obj.cc_generic_services = message.ccGenericServices; + obj.java_generic_services = message.javaGenericServices; + obj.py_generic_services = message.pyGenericServices; + obj.php_generic_services = message.phpGenericServices; + obj.deprecated = message.deprecated; + obj.cc_enable_arenas = message.ccEnableArenas; + obj.objc_class_prefix = message.objcClassPrefix; + obj.csharp_namespace = message.csharpNamespace; + obj.swift_prefix = message.swiftPrefix; + obj.php_class_prefix = message.phpClassPrefix; + obj.php_namespace = message.phpNamespace; + obj.php_metadata_namespace = message.phpMetadataNamespace; + obj.ruby_package = message.rubyPackage; + if (message.uninterpretedOption) { + obj.uninterpreted_option = message.uninterpretedOption.map(e => e ? UninterpretedOption.toSDK(e) : undefined); + } else { + obj.uninterpreted_option = []; + } + return obj; + }, + fromAmino(object: FileOptionsAmino): FileOptions { + const message = createBaseFileOptions(); + if (object.java_package !== undefined && object.java_package !== null) { + message.javaPackage = object.java_package; + } + if (object.java_outer_classname !== undefined && object.java_outer_classname !== null) { + message.javaOuterClassname = object.java_outer_classname; + } + if (object.java_multiple_files !== undefined && object.java_multiple_files !== null) { + message.javaMultipleFiles = object.java_multiple_files; + } + if (object.java_generate_equals_and_hash !== undefined && object.java_generate_equals_and_hash !== null) { + message.javaGenerateEqualsAndHash = object.java_generate_equals_and_hash; + } + if (object.java_string_check_utf8 !== undefined && object.java_string_check_utf8 !== null) { + message.javaStringCheckUtf8 = object.java_string_check_utf8; + } + if (object.optimize_for !== undefined && object.optimize_for !== null) { + message.optimizeFor = object.optimize_for; + } + if (object.go_package !== undefined && object.go_package !== null) { + message.goPackage = object.go_package; + } + if (object.cc_generic_services !== undefined && object.cc_generic_services !== null) { + message.ccGenericServices = object.cc_generic_services; + } + if (object.java_generic_services !== undefined && object.java_generic_services !== null) { + message.javaGenericServices = object.java_generic_services; + } + if (object.py_generic_services !== undefined && object.py_generic_services !== null) { + message.pyGenericServices = object.py_generic_services; + } + if (object.php_generic_services !== undefined && object.php_generic_services !== null) { + message.phpGenericServices = object.php_generic_services; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } + if (object.cc_enable_arenas !== undefined && object.cc_enable_arenas !== null) { + message.ccEnableArenas = object.cc_enable_arenas; + } + if (object.objc_class_prefix !== undefined && object.objc_class_prefix !== null) { + message.objcClassPrefix = object.objc_class_prefix; + } + if (object.csharp_namespace !== undefined && object.csharp_namespace !== null) { + message.csharpNamespace = object.csharp_namespace; + } + if (object.swift_prefix !== undefined && object.swift_prefix !== null) { + message.swiftPrefix = object.swift_prefix; + } + if (object.php_class_prefix !== undefined && object.php_class_prefix !== null) { + message.phpClassPrefix = object.php_class_prefix; + } + if (object.php_namespace !== undefined && object.php_namespace !== null) { + message.phpNamespace = object.php_namespace; + } + if (object.php_metadata_namespace !== undefined && object.php_metadata_namespace !== null) { + message.phpMetadataNamespace = object.php_metadata_namespace; + } + if (object.ruby_package !== undefined && object.ruby_package !== null) { + message.rubyPackage = object.ruby_package; + } + message.uninterpretedOption = object.uninterpreted_option?.map(e => UninterpretedOption.fromAmino(e)) || []; + return message; + }, + toAmino(message: FileOptions): FileOptionsAmino { + const obj: any = {}; + obj.java_package = message.javaPackage === "" ? undefined : message.javaPackage; + obj.java_outer_classname = message.javaOuterClassname === "" ? undefined : message.javaOuterClassname; + obj.java_multiple_files = message.javaMultipleFiles === false ? undefined : message.javaMultipleFiles; + obj.java_generate_equals_and_hash = message.javaGenerateEqualsAndHash === false ? undefined : message.javaGenerateEqualsAndHash; + obj.java_string_check_utf8 = message.javaStringCheckUtf8 === false ? undefined : message.javaStringCheckUtf8; + obj.optimize_for = message.optimizeFor === 1 ? undefined : message.optimizeFor; + obj.go_package = message.goPackage === "" ? undefined : message.goPackage; + obj.cc_generic_services = message.ccGenericServices === false ? undefined : message.ccGenericServices; + obj.java_generic_services = message.javaGenericServices === false ? undefined : message.javaGenericServices; + obj.py_generic_services = message.pyGenericServices === false ? undefined : message.pyGenericServices; + obj.php_generic_services = message.phpGenericServices === false ? undefined : message.phpGenericServices; + obj.deprecated = message.deprecated === false ? undefined : message.deprecated; + obj.cc_enable_arenas = message.ccEnableArenas === false ? undefined : message.ccEnableArenas; + obj.objc_class_prefix = message.objcClassPrefix === "" ? undefined : message.objcClassPrefix; + obj.csharp_namespace = message.csharpNamespace === "" ? undefined : message.csharpNamespace; + obj.swift_prefix = message.swiftPrefix === "" ? undefined : message.swiftPrefix; + obj.php_class_prefix = message.phpClassPrefix === "" ? undefined : message.phpClassPrefix; + obj.php_namespace = message.phpNamespace === "" ? undefined : message.phpNamespace; + obj.php_metadata_namespace = message.phpMetadataNamespace === "" ? undefined : message.phpMetadataNamespace; + obj.ruby_package = message.rubyPackage === "" ? undefined : message.rubyPackage; + if (message.uninterpretedOption) { + obj.uninterpreted_option = message.uninterpretedOption.map(e => e ? UninterpretedOption.toAmino(e) : undefined); + } else { + obj.uninterpreted_option = message.uninterpretedOption; + } + return obj; + }, + fromAminoMsg(object: FileOptionsAminoMsg): FileOptions { + return FileOptions.fromAmino(object.value); + }, + fromProtoMsg(message: FileOptionsProtoMsg): FileOptions { + return FileOptions.decode(message.value); + }, + toProto(message: FileOptions): Uint8Array { + return FileOptions.encode(message).finish(); + }, + toProtoMsg(message: FileOptions): FileOptionsProtoMsg { + return { + typeUrl: "/google.protobuf.FileOptions", + value: FileOptions.encode(message).finish() + }; + } +}; +function createBaseMessageOptions(): MessageOptions { + return { + messageSetWireFormat: false, + noStandardDescriptorAccessor: false, + deprecated: false, + mapEntry: false, + uninterpretedOption: [] + }; +} +export const MessageOptions = { + typeUrl: "/google.protobuf.MessageOptions", + encode(message: MessageOptions, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.messageSetWireFormat !== undefined) { + writer.uint32(8).bool(message.messageSetWireFormat); + } + if (message.noStandardDescriptorAccessor !== undefined) { + writer.uint32(16).bool(message.noStandardDescriptorAccessor); + } + if (message.deprecated !== undefined) { + writer.uint32(24).bool(message.deprecated); + } + if (message.mapEntry !== undefined) { + writer.uint32(56).bool(message.mapEntry); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MessageOptions { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMessageOptions(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.messageSetWireFormat = reader.bool(); + break; + case 2: + message.noStandardDescriptorAccessor = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 7: + message.mapEntry = reader.bool(); + break; + case 999: + message.uninterpretedOption.push(UninterpretedOption.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MessageOptions { + const obj = createBaseMessageOptions(); + if (isSet(object.messageSetWireFormat)) obj.messageSetWireFormat = Boolean(object.messageSetWireFormat); + if (isSet(object.noStandardDescriptorAccessor)) obj.noStandardDescriptorAccessor = Boolean(object.noStandardDescriptorAccessor); + if (isSet(object.deprecated)) obj.deprecated = Boolean(object.deprecated); + if (isSet(object.mapEntry)) obj.mapEntry = Boolean(object.mapEntry); + if (Array.isArray(object?.uninterpretedOption)) obj.uninterpretedOption = object.uninterpretedOption.map((e: any) => UninterpretedOption.fromJSON(e)); + return obj; + }, + toJSON(message: MessageOptions): JsonSafe { + const obj: any = {}; + message.messageSetWireFormat !== undefined && (obj.messageSetWireFormat = message.messageSetWireFormat); + message.noStandardDescriptorAccessor !== undefined && (obj.noStandardDescriptorAccessor = message.noStandardDescriptorAccessor); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.mapEntry !== undefined && (obj.mapEntry = message.mapEntry); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map(e => e ? UninterpretedOption.toJSON(e) : undefined); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + fromPartial(object: DeepPartial): MessageOptions { + const message = createBaseMessageOptions(); + message.messageSetWireFormat = object.messageSetWireFormat ?? false; + message.noStandardDescriptorAccessor = object.noStandardDescriptorAccessor ?? false; + message.deprecated = object.deprecated ?? false; + message.mapEntry = object.mapEntry ?? false; + message.uninterpretedOption = object.uninterpretedOption?.map(e => UninterpretedOption.fromPartial(e)) || []; + return message; + }, + fromSDK(object: MessageOptionsSDKType): MessageOptions { + return { + messageSetWireFormat: object?.message_set_wire_format, + noStandardDescriptorAccessor: object?.no_standard_descriptor_accessor, + deprecated: object?.deprecated, + mapEntry: object?.map_entry, + uninterpretedOption: Array.isArray(object?.uninterpreted_option) ? object.uninterpreted_option.map((e: any) => UninterpretedOption.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): MessageOptionsSDKType { + return { + message_set_wire_format: isSet(object.message_set_wire_format) ? Boolean(object.message_set_wire_format) : false, + no_standard_descriptor_accessor: isSet(object.no_standard_descriptor_accessor) ? Boolean(object.no_standard_descriptor_accessor) : false, + deprecated: isSet(object.deprecated) ? Boolean(object.deprecated) : false, + map_entry: isSet(object.map_entry) ? Boolean(object.map_entry) : false, + uninterpreted_option: Array.isArray(object?.uninterpreted_option) ? object.uninterpreted_option.map((e: any) => UninterpretedOption.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: MessageOptions): MessageOptionsSDKType { + const obj: any = {}; + obj.message_set_wire_format = message.messageSetWireFormat; + obj.no_standard_descriptor_accessor = message.noStandardDescriptorAccessor; + obj.deprecated = message.deprecated; + obj.map_entry = message.mapEntry; + if (message.uninterpretedOption) { + obj.uninterpreted_option = message.uninterpretedOption.map(e => e ? UninterpretedOption.toSDK(e) : undefined); + } else { + obj.uninterpreted_option = []; + } + return obj; + }, + fromAmino(object: MessageOptionsAmino): MessageOptions { + const message = createBaseMessageOptions(); + if (object.message_set_wire_format !== undefined && object.message_set_wire_format !== null) { + message.messageSetWireFormat = object.message_set_wire_format; + } + if (object.no_standard_descriptor_accessor !== undefined && object.no_standard_descriptor_accessor !== null) { + message.noStandardDescriptorAccessor = object.no_standard_descriptor_accessor; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } + if (object.map_entry !== undefined && object.map_entry !== null) { + message.mapEntry = object.map_entry; + } + message.uninterpretedOption = object.uninterpreted_option?.map(e => UninterpretedOption.fromAmino(e)) || []; + return message; + }, + toAmino(message: MessageOptions): MessageOptionsAmino { + const obj: any = {}; + obj.message_set_wire_format = message.messageSetWireFormat === false ? undefined : message.messageSetWireFormat; + obj.no_standard_descriptor_accessor = message.noStandardDescriptorAccessor === false ? undefined : message.noStandardDescriptorAccessor; + obj.deprecated = message.deprecated === false ? undefined : message.deprecated; + obj.map_entry = message.mapEntry === false ? undefined : message.mapEntry; + if (message.uninterpretedOption) { + obj.uninterpreted_option = message.uninterpretedOption.map(e => e ? UninterpretedOption.toAmino(e) : undefined); + } else { + obj.uninterpreted_option = message.uninterpretedOption; + } + return obj; + }, + fromAminoMsg(object: MessageOptionsAminoMsg): MessageOptions { + return MessageOptions.fromAmino(object.value); + }, + fromProtoMsg(message: MessageOptionsProtoMsg): MessageOptions { + return MessageOptions.decode(message.value); + }, + toProto(message: MessageOptions): Uint8Array { + return MessageOptions.encode(message).finish(); + }, + toProtoMsg(message: MessageOptions): MessageOptionsProtoMsg { + return { + typeUrl: "/google.protobuf.MessageOptions", + value: MessageOptions.encode(message).finish() + }; + } +}; +function createBaseFieldOptions(): FieldOptions { + return { + ctype: 1, + packed: false, + jstype: 1, + lazy: false, + deprecated: false, + weak: false, + uninterpretedOption: [] + }; +} +export const FieldOptions = { + typeUrl: "/google.protobuf.FieldOptions", + encode(message: FieldOptions, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.ctype !== 1) { + writer.uint32(8).int32(message.ctype); + } + if (message.packed !== undefined) { + writer.uint32(16).bool(message.packed); + } + if (message.jstype !== 1) { + writer.uint32(48).int32(message.jstype); + } + if (message.lazy !== undefined) { + writer.uint32(40).bool(message.lazy); + } + if (message.deprecated !== undefined) { + writer.uint32(24).bool(message.deprecated); + } + if (message.weak !== undefined) { + writer.uint32(80).bool(message.weak); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): FieldOptions { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseFieldOptions(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.ctype = (reader.int32() as any); + break; + case 2: + message.packed = reader.bool(); + break; + case 6: + message.jstype = (reader.int32() as any); + break; + case 5: + message.lazy = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 10: + message.weak = reader.bool(); + break; + case 999: + message.uninterpretedOption.push(UninterpretedOption.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): FieldOptions { + const obj = createBaseFieldOptions(); + if (isSet(object.ctype)) obj.ctype = fieldOptions_CTypeFromJSON(object.ctype); + if (isSet(object.packed)) obj.packed = Boolean(object.packed); + if (isSet(object.jstype)) obj.jstype = fieldOptions_JSTypeFromJSON(object.jstype); + if (isSet(object.lazy)) obj.lazy = Boolean(object.lazy); + if (isSet(object.deprecated)) obj.deprecated = Boolean(object.deprecated); + if (isSet(object.weak)) obj.weak = Boolean(object.weak); + if (Array.isArray(object?.uninterpretedOption)) obj.uninterpretedOption = object.uninterpretedOption.map((e: any) => UninterpretedOption.fromJSON(e)); + return obj; + }, + toJSON(message: FieldOptions): JsonSafe { + const obj: any = {}; + message.ctype !== undefined && (obj.ctype = fieldOptions_CTypeToJSON(message.ctype)); + message.packed !== undefined && (obj.packed = message.packed); + message.jstype !== undefined && (obj.jstype = fieldOptions_JSTypeToJSON(message.jstype)); + message.lazy !== undefined && (obj.lazy = message.lazy); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.weak !== undefined && (obj.weak = message.weak); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map(e => e ? UninterpretedOption.toJSON(e) : undefined); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + fromPartial(object: DeepPartial): FieldOptions { + const message = createBaseFieldOptions(); + message.ctype = object.ctype ?? 1; + message.packed = object.packed ?? false; + message.jstype = object.jstype ?? 1; + message.lazy = object.lazy ?? false; + message.deprecated = object.deprecated ?? false; + message.weak = object.weak ?? false; + message.uninterpretedOption = object.uninterpretedOption?.map(e => UninterpretedOption.fromPartial(e)) || []; + return message; + }, + fromSDK(object: FieldOptionsSDKType): FieldOptions { + return { + ctype: isSet(object.ctype) ? fieldOptions_CTypeFromJSON(object.ctype) : -1, + packed: object?.packed, + jstype: isSet(object.jstype) ? fieldOptions_JSTypeFromJSON(object.jstype) : -1, + lazy: object?.lazy, + deprecated: object?.deprecated, + weak: object?.weak, + uninterpretedOption: Array.isArray(object?.uninterpreted_option) ? object.uninterpreted_option.map((e: any) => UninterpretedOption.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): FieldOptionsSDKType { + return { + ctype: isSet(object.ctype) ? fieldOptions_CTypeFromJSON(object.ctype) : -1, + packed: isSet(object.packed) ? Boolean(object.packed) : false, + jstype: isSet(object.jstype) ? fieldOptions_JSTypeFromJSON(object.jstype) : -1, + lazy: isSet(object.lazy) ? Boolean(object.lazy) : false, + deprecated: isSet(object.deprecated) ? Boolean(object.deprecated) : false, + weak: isSet(object.weak) ? Boolean(object.weak) : false, + uninterpreted_option: Array.isArray(object?.uninterpreted_option) ? object.uninterpreted_option.map((e: any) => UninterpretedOption.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: FieldOptions): FieldOptionsSDKType { + const obj: any = {}; + message.ctype !== undefined && (obj.ctype = fieldOptions_CTypeToJSON(message.ctype)); + obj.packed = message.packed; + message.jstype !== undefined && (obj.jstype = fieldOptions_JSTypeToJSON(message.jstype)); + obj.lazy = message.lazy; + obj.deprecated = message.deprecated; + obj.weak = message.weak; + if (message.uninterpretedOption) { + obj.uninterpreted_option = message.uninterpretedOption.map(e => e ? UninterpretedOption.toSDK(e) : undefined); + } else { + obj.uninterpreted_option = []; + } + return obj; + }, + fromAmino(object: FieldOptionsAmino): FieldOptions { + const message = createBaseFieldOptions(); + if (object.ctype !== undefined && object.ctype !== null) { + message.ctype = object.ctype; + } + if (object.packed !== undefined && object.packed !== null) { + message.packed = object.packed; + } + if (object.jstype !== undefined && object.jstype !== null) { + message.jstype = object.jstype; + } + if (object.lazy !== undefined && object.lazy !== null) { + message.lazy = object.lazy; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } + if (object.weak !== undefined && object.weak !== null) { + message.weak = object.weak; + } + message.uninterpretedOption = object.uninterpreted_option?.map(e => UninterpretedOption.fromAmino(e)) || []; + return message; + }, + toAmino(message: FieldOptions): FieldOptionsAmino { + const obj: any = {}; + obj.ctype = message.ctype === 1 ? undefined : message.ctype; + obj.packed = message.packed === false ? undefined : message.packed; + obj.jstype = message.jstype === 1 ? undefined : message.jstype; + obj.lazy = message.lazy === false ? undefined : message.lazy; + obj.deprecated = message.deprecated === false ? undefined : message.deprecated; + obj.weak = message.weak === false ? undefined : message.weak; + if (message.uninterpretedOption) { + obj.uninterpreted_option = message.uninterpretedOption.map(e => e ? UninterpretedOption.toAmino(e) : undefined); + } else { + obj.uninterpreted_option = message.uninterpretedOption; + } + return obj; + }, + fromAminoMsg(object: FieldOptionsAminoMsg): FieldOptions { + return FieldOptions.fromAmino(object.value); + }, + fromProtoMsg(message: FieldOptionsProtoMsg): FieldOptions { + return FieldOptions.decode(message.value); + }, + toProto(message: FieldOptions): Uint8Array { + return FieldOptions.encode(message).finish(); + }, + toProtoMsg(message: FieldOptions): FieldOptionsProtoMsg { + return { + typeUrl: "/google.protobuf.FieldOptions", + value: FieldOptions.encode(message).finish() + }; + } +}; +function createBaseOneofOptions(): OneofOptions { + return { + uninterpretedOption: [] + }; +} +export const OneofOptions = { + typeUrl: "/google.protobuf.OneofOptions", + encode(message: OneofOptions, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): OneofOptions { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseOneofOptions(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 999: + message.uninterpretedOption.push(UninterpretedOption.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): OneofOptions { + const obj = createBaseOneofOptions(); + if (Array.isArray(object?.uninterpretedOption)) obj.uninterpretedOption = object.uninterpretedOption.map((e: any) => UninterpretedOption.fromJSON(e)); + return obj; + }, + toJSON(message: OneofOptions): JsonSafe { + const obj: any = {}; + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map(e => e ? UninterpretedOption.toJSON(e) : undefined); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + fromPartial(object: DeepPartial): OneofOptions { + const message = createBaseOneofOptions(); + message.uninterpretedOption = object.uninterpretedOption?.map(e => UninterpretedOption.fromPartial(e)) || []; + return message; + }, + fromSDK(object: OneofOptionsSDKType): OneofOptions { + return { + uninterpretedOption: Array.isArray(object?.uninterpreted_option) ? object.uninterpreted_option.map((e: any) => UninterpretedOption.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): OneofOptionsSDKType { + return { + uninterpreted_option: Array.isArray(object?.uninterpreted_option) ? object.uninterpreted_option.map((e: any) => UninterpretedOption.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: OneofOptions): OneofOptionsSDKType { + const obj: any = {}; + if (message.uninterpretedOption) { + obj.uninterpreted_option = message.uninterpretedOption.map(e => e ? UninterpretedOption.toSDK(e) : undefined); + } else { + obj.uninterpreted_option = []; + } + return obj; + }, + fromAmino(object: OneofOptionsAmino): OneofOptions { + const message = createBaseOneofOptions(); + message.uninterpretedOption = object.uninterpreted_option?.map(e => UninterpretedOption.fromAmino(e)) || []; + return message; + }, + toAmino(message: OneofOptions): OneofOptionsAmino { + const obj: any = {}; + if (message.uninterpretedOption) { + obj.uninterpreted_option = message.uninterpretedOption.map(e => e ? UninterpretedOption.toAmino(e) : undefined); + } else { + obj.uninterpreted_option = message.uninterpretedOption; + } + return obj; + }, + fromAminoMsg(object: OneofOptionsAminoMsg): OneofOptions { + return OneofOptions.fromAmino(object.value); + }, + fromProtoMsg(message: OneofOptionsProtoMsg): OneofOptions { + return OneofOptions.decode(message.value); + }, + toProto(message: OneofOptions): Uint8Array { + return OneofOptions.encode(message).finish(); + }, + toProtoMsg(message: OneofOptions): OneofOptionsProtoMsg { + return { + typeUrl: "/google.protobuf.OneofOptions", + value: OneofOptions.encode(message).finish() + }; + } +}; +function createBaseEnumOptions(): EnumOptions { + return { + allowAlias: false, + deprecated: false, + uninterpretedOption: [] + }; +} +export const EnumOptions = { + typeUrl: "/google.protobuf.EnumOptions", + encode(message: EnumOptions, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.allowAlias !== undefined) { + writer.uint32(16).bool(message.allowAlias); + } + if (message.deprecated !== undefined) { + writer.uint32(24).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): EnumOptions { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseEnumOptions(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.allowAlias = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push(UninterpretedOption.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): EnumOptions { + const obj = createBaseEnumOptions(); + if (isSet(object.allowAlias)) obj.allowAlias = Boolean(object.allowAlias); + if (isSet(object.deprecated)) obj.deprecated = Boolean(object.deprecated); + if (Array.isArray(object?.uninterpretedOption)) obj.uninterpretedOption = object.uninterpretedOption.map((e: any) => UninterpretedOption.fromJSON(e)); + return obj; + }, + toJSON(message: EnumOptions): JsonSafe { + const obj: any = {}; + message.allowAlias !== undefined && (obj.allowAlias = message.allowAlias); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map(e => e ? UninterpretedOption.toJSON(e) : undefined); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + fromPartial(object: DeepPartial): EnumOptions { + const message = createBaseEnumOptions(); + message.allowAlias = object.allowAlias ?? false; + message.deprecated = object.deprecated ?? false; + message.uninterpretedOption = object.uninterpretedOption?.map(e => UninterpretedOption.fromPartial(e)) || []; + return message; + }, + fromSDK(object: EnumOptionsSDKType): EnumOptions { + return { + allowAlias: object?.allow_alias, + deprecated: object?.deprecated, + uninterpretedOption: Array.isArray(object?.uninterpreted_option) ? object.uninterpreted_option.map((e: any) => UninterpretedOption.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): EnumOptionsSDKType { + return { + allow_alias: isSet(object.allow_alias) ? Boolean(object.allow_alias) : false, + deprecated: isSet(object.deprecated) ? Boolean(object.deprecated) : false, + uninterpreted_option: Array.isArray(object?.uninterpreted_option) ? object.uninterpreted_option.map((e: any) => UninterpretedOption.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: EnumOptions): EnumOptionsSDKType { + const obj: any = {}; + obj.allow_alias = message.allowAlias; + obj.deprecated = message.deprecated; + if (message.uninterpretedOption) { + obj.uninterpreted_option = message.uninterpretedOption.map(e => e ? UninterpretedOption.toSDK(e) : undefined); + } else { + obj.uninterpreted_option = []; + } + return obj; + }, + fromAmino(object: EnumOptionsAmino): EnumOptions { + const message = createBaseEnumOptions(); + if (object.allow_alias !== undefined && object.allow_alias !== null) { + message.allowAlias = object.allow_alias; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } + message.uninterpretedOption = object.uninterpreted_option?.map(e => UninterpretedOption.fromAmino(e)) || []; + return message; + }, + toAmino(message: EnumOptions): EnumOptionsAmino { + const obj: any = {}; + obj.allow_alias = message.allowAlias === false ? undefined : message.allowAlias; + obj.deprecated = message.deprecated === false ? undefined : message.deprecated; + if (message.uninterpretedOption) { + obj.uninterpreted_option = message.uninterpretedOption.map(e => e ? UninterpretedOption.toAmino(e) : undefined); + } else { + obj.uninterpreted_option = message.uninterpretedOption; + } + return obj; + }, + fromAminoMsg(object: EnumOptionsAminoMsg): EnumOptions { + return EnumOptions.fromAmino(object.value); + }, + fromProtoMsg(message: EnumOptionsProtoMsg): EnumOptions { + return EnumOptions.decode(message.value); + }, + toProto(message: EnumOptions): Uint8Array { + return EnumOptions.encode(message).finish(); + }, + toProtoMsg(message: EnumOptions): EnumOptionsProtoMsg { + return { + typeUrl: "/google.protobuf.EnumOptions", + value: EnumOptions.encode(message).finish() + }; + } +}; +function createBaseEnumValueOptions(): EnumValueOptions { + return { + deprecated: false, + uninterpretedOption: [] + }; +} +export const EnumValueOptions = { + typeUrl: "/google.protobuf.EnumValueOptions", + encode(message: EnumValueOptions, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.deprecated !== undefined) { + writer.uint32(8).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): EnumValueOptions { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseEnumValueOptions(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push(UninterpretedOption.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): EnumValueOptions { + const obj = createBaseEnumValueOptions(); + if (isSet(object.deprecated)) obj.deprecated = Boolean(object.deprecated); + if (Array.isArray(object?.uninterpretedOption)) obj.uninterpretedOption = object.uninterpretedOption.map((e: any) => UninterpretedOption.fromJSON(e)); + return obj; + }, + toJSON(message: EnumValueOptions): JsonSafe { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map(e => e ? UninterpretedOption.toJSON(e) : undefined); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + fromPartial(object: DeepPartial): EnumValueOptions { + const message = createBaseEnumValueOptions(); + message.deprecated = object.deprecated ?? false; + message.uninterpretedOption = object.uninterpretedOption?.map(e => UninterpretedOption.fromPartial(e)) || []; + return message; + }, + fromSDK(object: EnumValueOptionsSDKType): EnumValueOptions { + return { + deprecated: object?.deprecated, + uninterpretedOption: Array.isArray(object?.uninterpreted_option) ? object.uninterpreted_option.map((e: any) => UninterpretedOption.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): EnumValueOptionsSDKType { + return { + deprecated: isSet(object.deprecated) ? Boolean(object.deprecated) : false, + uninterpreted_option: Array.isArray(object?.uninterpreted_option) ? object.uninterpreted_option.map((e: any) => UninterpretedOption.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: EnumValueOptions): EnumValueOptionsSDKType { + const obj: any = {}; + obj.deprecated = message.deprecated; + if (message.uninterpretedOption) { + obj.uninterpreted_option = message.uninterpretedOption.map(e => e ? UninterpretedOption.toSDK(e) : undefined); + } else { + obj.uninterpreted_option = []; + } + return obj; + }, + fromAmino(object: EnumValueOptionsAmino): EnumValueOptions { + const message = createBaseEnumValueOptions(); + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } + message.uninterpretedOption = object.uninterpreted_option?.map(e => UninterpretedOption.fromAmino(e)) || []; + return message; + }, + toAmino(message: EnumValueOptions): EnumValueOptionsAmino { + const obj: any = {}; + obj.deprecated = message.deprecated === false ? undefined : message.deprecated; + if (message.uninterpretedOption) { + obj.uninterpreted_option = message.uninterpretedOption.map(e => e ? UninterpretedOption.toAmino(e) : undefined); + } else { + obj.uninterpreted_option = message.uninterpretedOption; + } + return obj; + }, + fromAminoMsg(object: EnumValueOptionsAminoMsg): EnumValueOptions { + return EnumValueOptions.fromAmino(object.value); + }, + fromProtoMsg(message: EnumValueOptionsProtoMsg): EnumValueOptions { + return EnumValueOptions.decode(message.value); + }, + toProto(message: EnumValueOptions): Uint8Array { + return EnumValueOptions.encode(message).finish(); + }, + toProtoMsg(message: EnumValueOptions): EnumValueOptionsProtoMsg { + return { + typeUrl: "/google.protobuf.EnumValueOptions", + value: EnumValueOptions.encode(message).finish() + }; + } +}; +function createBaseServiceOptions(): ServiceOptions { + return { + deprecated: false, + uninterpretedOption: [] + }; +} +export const ServiceOptions = { + typeUrl: "/google.protobuf.ServiceOptions", + encode(message: ServiceOptions, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.deprecated !== undefined) { + writer.uint32(264).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ServiceOptions { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseServiceOptions(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push(UninterpretedOption.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ServiceOptions { + const obj = createBaseServiceOptions(); + if (isSet(object.deprecated)) obj.deprecated = Boolean(object.deprecated); + if (Array.isArray(object?.uninterpretedOption)) obj.uninterpretedOption = object.uninterpretedOption.map((e: any) => UninterpretedOption.fromJSON(e)); + return obj; + }, + toJSON(message: ServiceOptions): JsonSafe { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map(e => e ? UninterpretedOption.toJSON(e) : undefined); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + fromPartial(object: DeepPartial): ServiceOptions { + const message = createBaseServiceOptions(); + message.deprecated = object.deprecated ?? false; + message.uninterpretedOption = object.uninterpretedOption?.map(e => UninterpretedOption.fromPartial(e)) || []; + return message; + }, + fromSDK(object: ServiceOptionsSDKType): ServiceOptions { + return { + deprecated: object?.deprecated, + uninterpretedOption: Array.isArray(object?.uninterpreted_option) ? object.uninterpreted_option.map((e: any) => UninterpretedOption.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): ServiceOptionsSDKType { + return { + deprecated: isSet(object.deprecated) ? Boolean(object.deprecated) : false, + uninterpreted_option: Array.isArray(object?.uninterpreted_option) ? object.uninterpreted_option.map((e: any) => UninterpretedOption.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: ServiceOptions): ServiceOptionsSDKType { + const obj: any = {}; + obj.deprecated = message.deprecated; + if (message.uninterpretedOption) { + obj.uninterpreted_option = message.uninterpretedOption.map(e => e ? UninterpretedOption.toSDK(e) : undefined); + } else { + obj.uninterpreted_option = []; + } + return obj; + }, + fromAmino(object: ServiceOptionsAmino): ServiceOptions { + const message = createBaseServiceOptions(); + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } + message.uninterpretedOption = object.uninterpreted_option?.map(e => UninterpretedOption.fromAmino(e)) || []; + return message; + }, + toAmino(message: ServiceOptions): ServiceOptionsAmino { + const obj: any = {}; + obj.deprecated = message.deprecated === false ? undefined : message.deprecated; + if (message.uninterpretedOption) { + obj.uninterpreted_option = message.uninterpretedOption.map(e => e ? UninterpretedOption.toAmino(e) : undefined); + } else { + obj.uninterpreted_option = message.uninterpretedOption; + } + return obj; + }, + fromAminoMsg(object: ServiceOptionsAminoMsg): ServiceOptions { + return ServiceOptions.fromAmino(object.value); + }, + fromProtoMsg(message: ServiceOptionsProtoMsg): ServiceOptions { + return ServiceOptions.decode(message.value); + }, + toProto(message: ServiceOptions): Uint8Array { + return ServiceOptions.encode(message).finish(); + }, + toProtoMsg(message: ServiceOptions): ServiceOptionsProtoMsg { + return { + typeUrl: "/google.protobuf.ServiceOptions", + value: ServiceOptions.encode(message).finish() + }; + } +}; +function createBaseMethodOptions(): MethodOptions { + return { + deprecated: false, + idempotencyLevel: 1, + uninterpretedOption: [] + }; +} +export const MethodOptions = { + typeUrl: "/google.protobuf.MethodOptions", + encode(message: MethodOptions, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.deprecated !== undefined) { + writer.uint32(264).bool(message.deprecated); + } + if (message.idempotencyLevel !== 1) { + writer.uint32(272).int32(message.idempotencyLevel); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MethodOptions { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMethodOptions(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool(); + break; + case 34: + message.idempotencyLevel = (reader.int32() as any); + break; + case 999: + message.uninterpretedOption.push(UninterpretedOption.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): MethodOptions { + const obj = createBaseMethodOptions(); + if (isSet(object.deprecated)) obj.deprecated = Boolean(object.deprecated); + if (isSet(object.idempotencyLevel)) obj.idempotencyLevel = methodOptions_IdempotencyLevelFromJSON(object.idempotencyLevel); + if (Array.isArray(object?.uninterpretedOption)) obj.uninterpretedOption = object.uninterpretedOption.map((e: any) => UninterpretedOption.fromJSON(e)); + return obj; + }, + toJSON(message: MethodOptions): JsonSafe { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.idempotencyLevel !== undefined && (obj.idempotencyLevel = methodOptions_IdempotencyLevelToJSON(message.idempotencyLevel)); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map(e => e ? UninterpretedOption.toJSON(e) : undefined); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + fromPartial(object: DeepPartial): MethodOptions { + const message = createBaseMethodOptions(); + message.deprecated = object.deprecated ?? false; + message.idempotencyLevel = object.idempotencyLevel ?? 1; + message.uninterpretedOption = object.uninterpretedOption?.map(e => UninterpretedOption.fromPartial(e)) || []; + return message; + }, + fromSDK(object: MethodOptionsSDKType): MethodOptions { + return { + deprecated: object?.deprecated, + idempotencyLevel: isSet(object.idempotency_level) ? methodOptions_IdempotencyLevelFromJSON(object.idempotency_level) : -1, + uninterpretedOption: Array.isArray(object?.uninterpreted_option) ? object.uninterpreted_option.map((e: any) => UninterpretedOption.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): MethodOptionsSDKType { + return { + deprecated: isSet(object.deprecated) ? Boolean(object.deprecated) : false, + idempotency_level: isSet(object.idempotency_level) ? methodOptions_IdempotencyLevelFromJSON(object.idempotency_level) : -1, + uninterpreted_option: Array.isArray(object?.uninterpreted_option) ? object.uninterpreted_option.map((e: any) => UninterpretedOption.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: MethodOptions): MethodOptionsSDKType { + const obj: any = {}; + obj.deprecated = message.deprecated; + message.idempotencyLevel !== undefined && (obj.idempotency_level = methodOptions_IdempotencyLevelToJSON(message.idempotencyLevel)); + if (message.uninterpretedOption) { + obj.uninterpreted_option = message.uninterpretedOption.map(e => e ? UninterpretedOption.toSDK(e) : undefined); + } else { + obj.uninterpreted_option = []; + } + return obj; + }, + fromAmino(object: MethodOptionsAmino): MethodOptions { + const message = createBaseMethodOptions(); + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } + if (object.idempotency_level !== undefined && object.idempotency_level !== null) { + message.idempotencyLevel = object.idempotency_level; + } + message.uninterpretedOption = object.uninterpreted_option?.map(e => UninterpretedOption.fromAmino(e)) || []; + return message; + }, + toAmino(message: MethodOptions): MethodOptionsAmino { + const obj: any = {}; + obj.deprecated = message.deprecated === false ? undefined : message.deprecated; + obj.idempotency_level = message.idempotencyLevel === 1 ? undefined : message.idempotencyLevel; + if (message.uninterpretedOption) { + obj.uninterpreted_option = message.uninterpretedOption.map(e => e ? UninterpretedOption.toAmino(e) : undefined); + } else { + obj.uninterpreted_option = message.uninterpretedOption; + } + return obj; + }, + fromAminoMsg(object: MethodOptionsAminoMsg): MethodOptions { + return MethodOptions.fromAmino(object.value); + }, + fromProtoMsg(message: MethodOptionsProtoMsg): MethodOptions { + return MethodOptions.decode(message.value); + }, + toProto(message: MethodOptions): Uint8Array { + return MethodOptions.encode(message).finish(); + }, + toProtoMsg(message: MethodOptions): MethodOptionsProtoMsg { + return { + typeUrl: "/google.protobuf.MethodOptions", + value: MethodOptions.encode(message).finish() + }; + } +}; +function createBaseUninterpretedOption(): UninterpretedOption { + return { + name: [], + identifierValue: "", + positiveIntValue: BigInt(0), + negativeIntValue: BigInt(0), + doubleValue: 0, + stringValue: new Uint8Array(), + aggregateValue: "" + }; +} +export const UninterpretedOption = { + typeUrl: "/google.protobuf.UninterpretedOption", + encode(message: UninterpretedOption, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.name) { + UninterpretedOption_NamePart.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.identifierValue !== undefined) { + writer.uint32(26).string(message.identifierValue); + } + if (message.positiveIntValue !== undefined) { + writer.uint32(32).uint64(message.positiveIntValue); + } + if (message.negativeIntValue !== undefined) { + writer.uint32(40).int64(message.negativeIntValue); + } + if (message.doubleValue !== undefined) { + writer.uint32(49).double(message.doubleValue); + } + if (message.stringValue.length !== 0) { + writer.uint32(58).bytes(message.stringValue); + } + if (message.aggregateValue !== undefined) { + writer.uint32(66).string(message.aggregateValue); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): UninterpretedOption { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseUninterpretedOption(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.name.push(UninterpretedOption_NamePart.decode(reader, reader.uint32())); + break; + case 3: + message.identifierValue = reader.string(); + break; + case 4: + message.positiveIntValue = reader.uint64(); + break; + case 5: + message.negativeIntValue = reader.int64(); + break; + case 6: + message.doubleValue = reader.double(); + break; + case 7: + message.stringValue = reader.bytes(); + break; + case 8: + message.aggregateValue = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): UninterpretedOption { + const obj = createBaseUninterpretedOption(); + if (Array.isArray(object?.name)) obj.name = object.name.map((e: any) => UninterpretedOption_NamePart.fromJSON(e)); + if (isSet(object.identifierValue)) obj.identifierValue = String(object.identifierValue); + if (isSet(object.positiveIntValue)) obj.positiveIntValue = BigInt(object.positiveIntValue.toString()); + if (isSet(object.negativeIntValue)) obj.negativeIntValue = BigInt(object.negativeIntValue.toString()); + if (isSet(object.doubleValue)) obj.doubleValue = Number(object.doubleValue); + if (isSet(object.stringValue)) obj.stringValue = bytesFromBase64(object.stringValue); + if (isSet(object.aggregateValue)) obj.aggregateValue = String(object.aggregateValue); + return obj; + }, + toJSON(message: UninterpretedOption): JsonSafe { + const obj: any = {}; + if (message.name) { + obj.name = message.name.map(e => e ? UninterpretedOption_NamePart.toJSON(e) : undefined); + } else { + obj.name = []; + } + message.identifierValue !== undefined && (obj.identifierValue = message.identifierValue); + message.positiveIntValue !== undefined && (obj.positiveIntValue = (message.positiveIntValue || BigInt(0)).toString()); + message.negativeIntValue !== undefined && (obj.negativeIntValue = (message.negativeIntValue || BigInt(0)).toString()); + message.doubleValue !== undefined && (obj.doubleValue = message.doubleValue); + message.stringValue !== undefined && (obj.stringValue = base64FromBytes(message.stringValue !== undefined ? message.stringValue : new Uint8Array())); + message.aggregateValue !== undefined && (obj.aggregateValue = message.aggregateValue); + return obj; + }, + fromPartial(object: DeepPartial): UninterpretedOption { + const message = createBaseUninterpretedOption(); + message.name = object.name?.map(e => UninterpretedOption_NamePart.fromPartial(e)) || []; + message.identifierValue = object.identifierValue ?? ""; + if (object.positiveIntValue !== undefined && object.positiveIntValue !== null) { + message.positiveIntValue = BigInt(object.positiveIntValue.toString()); + } + if (object.negativeIntValue !== undefined && object.negativeIntValue !== null) { + message.negativeIntValue = BigInt(object.negativeIntValue.toString()); + } + message.doubleValue = object.doubleValue ?? 0; + message.stringValue = object.stringValue ?? new Uint8Array(); + message.aggregateValue = object.aggregateValue ?? ""; + return message; + }, + fromSDK(object: UninterpretedOptionSDKType): UninterpretedOption { + return { + name: Array.isArray(object?.name) ? object.name.map((e: any) => UninterpretedOption_NamePart.fromSDK(e)) : [], + identifierValue: object?.identifier_value, + positiveIntValue: object?.positive_int_value, + negativeIntValue: object?.negative_int_value, + doubleValue: object?.double_value, + stringValue: object?.string_value, + aggregateValue: object?.aggregate_value + }; + }, + fromSDKJSON(object: any): UninterpretedOptionSDKType { + return { + name: Array.isArray(object?.name) ? object.name.map((e: any) => UninterpretedOption_NamePart.fromSDKJSON(e)) : [], + identifier_value: isSet(object.identifier_value) ? String(object.identifier_value) : "", + positive_int_value: isSet(object.positive_int_value) ? BigInt(object.positive_int_value.toString()) : BigInt(0), + negative_int_value: isSet(object.negative_int_value) ? BigInt(object.negative_int_value.toString()) : BigInt(0), + double_value: isSet(object.double_value) ? Number(object.double_value) : 0, + string_value: isSet(object.string_value) ? bytesFromBase64(object.string_value) : new Uint8Array(), + aggregate_value: isSet(object.aggregate_value) ? String(object.aggregate_value) : "" + }; + }, + toSDK(message: UninterpretedOption): UninterpretedOptionSDKType { + const obj: any = {}; + if (message.name) { + obj.name = message.name.map(e => e ? UninterpretedOption_NamePart.toSDK(e) : undefined); + } else { + obj.name = []; + } + obj.identifier_value = message.identifierValue; + obj.positive_int_value = message.positiveIntValue; + obj.negative_int_value = message.negativeIntValue; + obj.double_value = message.doubleValue; + obj.string_value = message.stringValue; + obj.aggregate_value = message.aggregateValue; + return obj; + }, + fromAmino(object: UninterpretedOptionAmino): UninterpretedOption { + const message = createBaseUninterpretedOption(); + message.name = object.name?.map(e => UninterpretedOption_NamePart.fromAmino(e)) || []; + if (object.identifier_value !== undefined && object.identifier_value !== null) { + message.identifierValue = object.identifier_value; + } + if (object.positive_int_value !== undefined && object.positive_int_value !== null) { + message.positiveIntValue = BigInt(object.positive_int_value); + } + if (object.negative_int_value !== undefined && object.negative_int_value !== null) { + message.negativeIntValue = BigInt(object.negative_int_value); + } + if (object.double_value !== undefined && object.double_value !== null) { + message.doubleValue = object.double_value; + } + if (object.string_value !== undefined && object.string_value !== null) { + message.stringValue = bytesFromBase64(object.string_value); + } + if (object.aggregate_value !== undefined && object.aggregate_value !== null) { + message.aggregateValue = object.aggregate_value; + } + return message; + }, + toAmino(message: UninterpretedOption): UninterpretedOptionAmino { + const obj: any = {}; + if (message.name) { + obj.name = message.name.map(e => e ? UninterpretedOption_NamePart.toAmino(e) : undefined); + } else { + obj.name = message.name; + } + obj.identifier_value = message.identifierValue === "" ? undefined : message.identifierValue; + obj.positive_int_value = message.positiveIntValue !== BigInt(0) ? message.positiveIntValue?.toString() : undefined; + obj.negative_int_value = message.negativeIntValue !== BigInt(0) ? message.negativeIntValue?.toString() : undefined; + obj.double_value = message.doubleValue === 0 ? undefined : message.doubleValue; + obj.string_value = message.stringValue ? base64FromBytes(message.stringValue) : undefined; + obj.aggregate_value = message.aggregateValue === "" ? undefined : message.aggregateValue; + return obj; + }, + fromAminoMsg(object: UninterpretedOptionAminoMsg): UninterpretedOption { + return UninterpretedOption.fromAmino(object.value); + }, + fromProtoMsg(message: UninterpretedOptionProtoMsg): UninterpretedOption { + return UninterpretedOption.decode(message.value); + }, + toProto(message: UninterpretedOption): Uint8Array { + return UninterpretedOption.encode(message).finish(); + }, + toProtoMsg(message: UninterpretedOption): UninterpretedOptionProtoMsg { + return { + typeUrl: "/google.protobuf.UninterpretedOption", + value: UninterpretedOption.encode(message).finish() + }; + } +}; +function createBaseUninterpretedOption_NamePart(): UninterpretedOption_NamePart { + return { + namePart: "", + isExtension: false + }; +} +export const UninterpretedOption_NamePart = { + typeUrl: "/google.protobuf.NamePart", + encode(message: UninterpretedOption_NamePart, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.namePart !== undefined) { + writer.uint32(10).string(message.namePart); + } + if (message.isExtension !== undefined) { + writer.uint32(16).bool(message.isExtension); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): UninterpretedOption_NamePart { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseUninterpretedOption_NamePart(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.namePart = reader.string(); + break; + case 2: + message.isExtension = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): UninterpretedOption_NamePart { + const obj = createBaseUninterpretedOption_NamePart(); + if (isSet(object.namePart)) obj.namePart = String(object.namePart); + if (isSet(object.isExtension)) obj.isExtension = Boolean(object.isExtension); + return obj; + }, + toJSON(message: UninterpretedOption_NamePart): JsonSafe { + const obj: any = {}; + message.namePart !== undefined && (obj.namePart = message.namePart); + message.isExtension !== undefined && (obj.isExtension = message.isExtension); + return obj; + }, + fromPartial(object: DeepPartial): UninterpretedOption_NamePart { + const message = createBaseUninterpretedOption_NamePart(); + message.namePart = object.namePart ?? ""; + message.isExtension = object.isExtension ?? false; + return message; + }, + fromSDK(object: UninterpretedOption_NamePartSDKType): UninterpretedOption_NamePart { + return { + namePart: object?.name_part, + isExtension: object?.is_extension + }; + }, + fromSDKJSON(object: any): UninterpretedOption_NamePartSDKType { + return { + name_part: isSet(object.name_part) ? String(object.name_part) : "", + is_extension: isSet(object.is_extension) ? Boolean(object.is_extension) : false + }; + }, + toSDK(message: UninterpretedOption_NamePart): UninterpretedOption_NamePartSDKType { + const obj: any = {}; + obj.name_part = message.namePart; + obj.is_extension = message.isExtension; + return obj; + }, + fromAmino(object: UninterpretedOption_NamePartAmino): UninterpretedOption_NamePart { + const message = createBaseUninterpretedOption_NamePart(); + if (object.name_part !== undefined && object.name_part !== null) { + message.namePart = object.name_part; + } + if (object.is_extension !== undefined && object.is_extension !== null) { + message.isExtension = object.is_extension; + } + return message; + }, + toAmino(message: UninterpretedOption_NamePart): UninterpretedOption_NamePartAmino { + const obj: any = {}; + obj.name_part = message.namePart === "" ? undefined : message.namePart; + obj.is_extension = message.isExtension === false ? undefined : message.isExtension; + return obj; + }, + fromAminoMsg(object: UninterpretedOption_NamePartAminoMsg): UninterpretedOption_NamePart { + return UninterpretedOption_NamePart.fromAmino(object.value); + }, + fromProtoMsg(message: UninterpretedOption_NamePartProtoMsg): UninterpretedOption_NamePart { + return UninterpretedOption_NamePart.decode(message.value); + }, + toProto(message: UninterpretedOption_NamePart): Uint8Array { + return UninterpretedOption_NamePart.encode(message).finish(); + }, + toProtoMsg(message: UninterpretedOption_NamePart): UninterpretedOption_NamePartProtoMsg { + return { + typeUrl: "/google.protobuf.NamePart", + value: UninterpretedOption_NamePart.encode(message).finish() + }; + } +}; +function createBaseSourceCodeInfo(): SourceCodeInfo { + return { + location: [] + }; +} +export const SourceCodeInfo = { + typeUrl: "/google.protobuf.SourceCodeInfo", + encode(message: SourceCodeInfo, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.location) { + SourceCodeInfo_Location.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): SourceCodeInfo { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseSourceCodeInfo(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.location.push(SourceCodeInfo_Location.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): SourceCodeInfo { + const obj = createBaseSourceCodeInfo(); + if (Array.isArray(object?.location)) obj.location = object.location.map((e: any) => SourceCodeInfo_Location.fromJSON(e)); + return obj; + }, + toJSON(message: SourceCodeInfo): JsonSafe { + const obj: any = {}; + if (message.location) { + obj.location = message.location.map(e => e ? SourceCodeInfo_Location.toJSON(e) : undefined); + } else { + obj.location = []; + } + return obj; + }, + fromPartial(object: DeepPartial): SourceCodeInfo { + const message = createBaseSourceCodeInfo(); + message.location = object.location?.map(e => SourceCodeInfo_Location.fromPartial(e)) || []; + return message; + }, + fromSDK(object: SourceCodeInfoSDKType): SourceCodeInfo { + return { + location: Array.isArray(object?.location) ? object.location.map((e: any) => SourceCodeInfo_Location.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): SourceCodeInfoSDKType { + return { + location: Array.isArray(object?.location) ? object.location.map((e: any) => SourceCodeInfo_Location.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: SourceCodeInfo): SourceCodeInfoSDKType { + const obj: any = {}; + if (message.location) { + obj.location = message.location.map(e => e ? SourceCodeInfo_Location.toSDK(e) : undefined); + } else { + obj.location = []; + } + return obj; + }, + fromAmino(object: SourceCodeInfoAmino): SourceCodeInfo { + const message = createBaseSourceCodeInfo(); + message.location = object.location?.map(e => SourceCodeInfo_Location.fromAmino(e)) || []; + return message; + }, + toAmino(message: SourceCodeInfo): SourceCodeInfoAmino { + const obj: any = {}; + if (message.location) { + obj.location = message.location.map(e => e ? SourceCodeInfo_Location.toAmino(e) : undefined); + } else { + obj.location = message.location; + } + return obj; + }, + fromAminoMsg(object: SourceCodeInfoAminoMsg): SourceCodeInfo { + return SourceCodeInfo.fromAmino(object.value); + }, + fromProtoMsg(message: SourceCodeInfoProtoMsg): SourceCodeInfo { + return SourceCodeInfo.decode(message.value); + }, + toProto(message: SourceCodeInfo): Uint8Array { + return SourceCodeInfo.encode(message).finish(); + }, + toProtoMsg(message: SourceCodeInfo): SourceCodeInfoProtoMsg { + return { + typeUrl: "/google.protobuf.SourceCodeInfo", + value: SourceCodeInfo.encode(message).finish() + }; + } +}; +function createBaseSourceCodeInfo_Location(): SourceCodeInfo_Location { + return { + path: [], + span: [], + leadingComments: "", + trailingComments: "", + leadingDetachedComments: [] + }; +} +export const SourceCodeInfo_Location = { + typeUrl: "/google.protobuf.Location", + encode(message: SourceCodeInfo_Location, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + writer.uint32(10).fork(); + for (const v of message.path) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(18).fork(); + for (const v of message.span) { + writer.int32(v); + } + writer.ldelim(); + if (message.leadingComments !== undefined) { + writer.uint32(26).string(message.leadingComments); + } + if (message.trailingComments !== undefined) { + writer.uint32(34).string(message.trailingComments); + } + for (const v of message.leadingDetachedComments) { + writer.uint32(50).string(v!); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): SourceCodeInfo_Location { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseSourceCodeInfo_Location(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.path.push(reader.int32()); + } + } else { + message.path.push(reader.int32()); + } + break; + case 2: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.span.push(reader.int32()); + } + } else { + message.span.push(reader.int32()); + } + break; + case 3: + message.leadingComments = reader.string(); + break; + case 4: + message.trailingComments = reader.string(); + break; + case 6: + message.leadingDetachedComments.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): SourceCodeInfo_Location { + const obj = createBaseSourceCodeInfo_Location(); + if (Array.isArray(object?.path)) obj.path = object.path.map((e: any) => Number(e)); + if (Array.isArray(object?.span)) obj.span = object.span.map((e: any) => Number(e)); + if (isSet(object.leadingComments)) obj.leadingComments = String(object.leadingComments); + if (isSet(object.trailingComments)) obj.trailingComments = String(object.trailingComments); + if (Array.isArray(object?.leadingDetachedComments)) obj.leadingDetachedComments = object.leadingDetachedComments.map((e: any) => String(e)); + return obj; + }, + toJSON(message: SourceCodeInfo_Location): JsonSafe { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map(e => Math.round(e)); + } else { + obj.path = []; + } + if (message.span) { + obj.span = message.span.map(e => Math.round(e)); + } else { + obj.span = []; + } + message.leadingComments !== undefined && (obj.leadingComments = message.leadingComments); + message.trailingComments !== undefined && (obj.trailingComments = message.trailingComments); + if (message.leadingDetachedComments) { + obj.leadingDetachedComments = message.leadingDetachedComments.map(e => e); + } else { + obj.leadingDetachedComments = []; + } + return obj; + }, + fromPartial(object: DeepPartial): SourceCodeInfo_Location { + const message = createBaseSourceCodeInfo_Location(); + message.path = object.path?.map(e => e) || []; + message.span = object.span?.map(e => e) || []; + message.leadingComments = object.leadingComments ?? ""; + message.trailingComments = object.trailingComments ?? ""; + message.leadingDetachedComments = object.leadingDetachedComments?.map(e => e) || []; + return message; + }, + fromSDK(object: SourceCodeInfo_LocationSDKType): SourceCodeInfo_Location { + return { + path: Array.isArray(object?.path) ? object.path.map((e: any) => e) : [], + span: Array.isArray(object?.span) ? object.span.map((e: any) => e) : [], + leadingComments: object?.leading_comments, + trailingComments: object?.trailing_comments, + leadingDetachedComments: Array.isArray(object?.leading_detached_comments) ? object.leading_detached_comments.map((e: any) => e) : [] + }; + }, + fromSDKJSON(object: any): SourceCodeInfo_LocationSDKType { + return { + path: Array.isArray(object?.path) ? object.path.map((e: any) => Number(e)) : [], + span: Array.isArray(object?.span) ? object.span.map((e: any) => Number(e)) : [], + leading_comments: isSet(object.leading_comments) ? String(object.leading_comments) : "", + trailing_comments: isSet(object.trailing_comments) ? String(object.trailing_comments) : "", + leading_detached_comments: Array.isArray(object?.leading_detached_comments) ? object.leading_detached_comments.map((e: any) => String(e)) : [] + }; + }, + toSDK(message: SourceCodeInfo_Location): SourceCodeInfo_LocationSDKType { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map(e => e); + } else { + obj.path = []; + } + if (message.span) { + obj.span = message.span.map(e => e); + } else { + obj.span = []; + } + obj.leading_comments = message.leadingComments; + obj.trailing_comments = message.trailingComments; + if (message.leadingDetachedComments) { + obj.leading_detached_comments = message.leadingDetachedComments.map(e => e); + } else { + obj.leading_detached_comments = []; + } + return obj; + }, + fromAmino(object: SourceCodeInfo_LocationAmino): SourceCodeInfo_Location { + const message = createBaseSourceCodeInfo_Location(); + message.path = object.path?.map(e => e) || []; + message.span = object.span?.map(e => e) || []; + if (object.leading_comments !== undefined && object.leading_comments !== null) { + message.leadingComments = object.leading_comments; + } + if (object.trailing_comments !== undefined && object.trailing_comments !== null) { + message.trailingComments = object.trailing_comments; + } + message.leadingDetachedComments = object.leading_detached_comments?.map(e => e) || []; + return message; + }, + toAmino(message: SourceCodeInfo_Location): SourceCodeInfo_LocationAmino { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map(e => e); + } else { + obj.path = message.path; + } + if (message.span) { + obj.span = message.span.map(e => e); + } else { + obj.span = message.span; + } + obj.leading_comments = message.leadingComments === "" ? undefined : message.leadingComments; + obj.trailing_comments = message.trailingComments === "" ? undefined : message.trailingComments; + if (message.leadingDetachedComments) { + obj.leading_detached_comments = message.leadingDetachedComments.map(e => e); + } else { + obj.leading_detached_comments = message.leadingDetachedComments; + } + return obj; + }, + fromAminoMsg(object: SourceCodeInfo_LocationAminoMsg): SourceCodeInfo_Location { + return SourceCodeInfo_Location.fromAmino(object.value); + }, + fromProtoMsg(message: SourceCodeInfo_LocationProtoMsg): SourceCodeInfo_Location { + return SourceCodeInfo_Location.decode(message.value); + }, + toProto(message: SourceCodeInfo_Location): Uint8Array { + return SourceCodeInfo_Location.encode(message).finish(); + }, + toProtoMsg(message: SourceCodeInfo_Location): SourceCodeInfo_LocationProtoMsg { + return { + typeUrl: "/google.protobuf.Location", + value: SourceCodeInfo_Location.encode(message).finish() + }; + } +}; +function createBaseGeneratedCodeInfo(): GeneratedCodeInfo { + return { + annotation: [] + }; +} +export const GeneratedCodeInfo = { + typeUrl: "/google.protobuf.GeneratedCodeInfo", + encode(message: GeneratedCodeInfo, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.annotation) { + GeneratedCodeInfo_Annotation.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GeneratedCodeInfo { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGeneratedCodeInfo(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.annotation.push(GeneratedCodeInfo_Annotation.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GeneratedCodeInfo { + const obj = createBaseGeneratedCodeInfo(); + if (Array.isArray(object?.annotation)) obj.annotation = object.annotation.map((e: any) => GeneratedCodeInfo_Annotation.fromJSON(e)); + return obj; + }, + toJSON(message: GeneratedCodeInfo): JsonSafe { + const obj: any = {}; + if (message.annotation) { + obj.annotation = message.annotation.map(e => e ? GeneratedCodeInfo_Annotation.toJSON(e) : undefined); + } else { + obj.annotation = []; + } + return obj; + }, + fromPartial(object: DeepPartial): GeneratedCodeInfo { + const message = createBaseGeneratedCodeInfo(); + message.annotation = object.annotation?.map(e => GeneratedCodeInfo_Annotation.fromPartial(e)) || []; + return message; + }, + fromSDK(object: GeneratedCodeInfoSDKType): GeneratedCodeInfo { + return { + annotation: Array.isArray(object?.annotation) ? object.annotation.map((e: any) => GeneratedCodeInfo_Annotation.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): GeneratedCodeInfoSDKType { + return { + annotation: Array.isArray(object?.annotation) ? object.annotation.map((e: any) => GeneratedCodeInfo_Annotation.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: GeneratedCodeInfo): GeneratedCodeInfoSDKType { + const obj: any = {}; + if (message.annotation) { + obj.annotation = message.annotation.map(e => e ? GeneratedCodeInfo_Annotation.toSDK(e) : undefined); + } else { + obj.annotation = []; + } + return obj; + }, + fromAmino(object: GeneratedCodeInfoAmino): GeneratedCodeInfo { + const message = createBaseGeneratedCodeInfo(); + message.annotation = object.annotation?.map(e => GeneratedCodeInfo_Annotation.fromAmino(e)) || []; + return message; + }, + toAmino(message: GeneratedCodeInfo): GeneratedCodeInfoAmino { + const obj: any = {}; + if (message.annotation) { + obj.annotation = message.annotation.map(e => e ? GeneratedCodeInfo_Annotation.toAmino(e) : undefined); + } else { + obj.annotation = message.annotation; + } + return obj; + }, + fromAminoMsg(object: GeneratedCodeInfoAminoMsg): GeneratedCodeInfo { + return GeneratedCodeInfo.fromAmino(object.value); + }, + fromProtoMsg(message: GeneratedCodeInfoProtoMsg): GeneratedCodeInfo { + return GeneratedCodeInfo.decode(message.value); + }, + toProto(message: GeneratedCodeInfo): Uint8Array { + return GeneratedCodeInfo.encode(message).finish(); + }, + toProtoMsg(message: GeneratedCodeInfo): GeneratedCodeInfoProtoMsg { + return { + typeUrl: "/google.protobuf.GeneratedCodeInfo", + value: GeneratedCodeInfo.encode(message).finish() + }; + } +}; +function createBaseGeneratedCodeInfo_Annotation(): GeneratedCodeInfo_Annotation { + return { + path: [], + sourceFile: "", + begin: 0, + end: 0 + }; +} +export const GeneratedCodeInfo_Annotation = { + typeUrl: "/google.protobuf.Annotation", + encode(message: GeneratedCodeInfo_Annotation, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + writer.uint32(10).fork(); + for (const v of message.path) { + writer.int32(v); + } + writer.ldelim(); + if (message.sourceFile !== undefined) { + writer.uint32(18).string(message.sourceFile); + } + if (message.begin !== undefined) { + writer.uint32(24).int32(message.begin); + } + if (message.end !== undefined) { + writer.uint32(32).int32(message.end); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): GeneratedCodeInfo_Annotation { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGeneratedCodeInfo_Annotation(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.path.push(reader.int32()); + } + } else { + message.path.push(reader.int32()); + } + break; + case 2: + message.sourceFile = reader.string(); + break; + case 3: + message.begin = reader.int32(); + break; + case 4: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): GeneratedCodeInfo_Annotation { + const obj = createBaseGeneratedCodeInfo_Annotation(); + if (Array.isArray(object?.path)) obj.path = object.path.map((e: any) => Number(e)); + if (isSet(object.sourceFile)) obj.sourceFile = String(object.sourceFile); + if (isSet(object.begin)) obj.begin = Number(object.begin); + if (isSet(object.end)) obj.end = Number(object.end); + return obj; + }, + toJSON(message: GeneratedCodeInfo_Annotation): JsonSafe { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map(e => Math.round(e)); + } else { + obj.path = []; + } + message.sourceFile !== undefined && (obj.sourceFile = message.sourceFile); + message.begin !== undefined && (obj.begin = Math.round(message.begin)); + message.end !== undefined && (obj.end = Math.round(message.end)); + return obj; + }, + fromPartial(object: DeepPartial): GeneratedCodeInfo_Annotation { + const message = createBaseGeneratedCodeInfo_Annotation(); + message.path = object.path?.map(e => e) || []; + message.sourceFile = object.sourceFile ?? ""; + message.begin = object.begin ?? 0; + message.end = object.end ?? 0; + return message; + }, + fromSDK(object: GeneratedCodeInfo_AnnotationSDKType): GeneratedCodeInfo_Annotation { + return { + path: Array.isArray(object?.path) ? object.path.map((e: any) => e) : [], + sourceFile: object?.source_file, + begin: object?.begin, + end: object?.end + }; + }, + fromSDKJSON(object: any): GeneratedCodeInfo_AnnotationSDKType { + return { + path: Array.isArray(object?.path) ? object.path.map((e: any) => Number(e)) : [], + source_file: isSet(object.source_file) ? String(object.source_file) : "", + begin: isSet(object.begin) ? Number(object.begin) : 0, + end: isSet(object.end) ? Number(object.end) : 0 + }; + }, + toSDK(message: GeneratedCodeInfo_Annotation): GeneratedCodeInfo_AnnotationSDKType { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map(e => e); + } else { + obj.path = []; + } + obj.source_file = message.sourceFile; + obj.begin = message.begin; + obj.end = message.end; + return obj; + }, + fromAmino(object: GeneratedCodeInfo_AnnotationAmino): GeneratedCodeInfo_Annotation { + const message = createBaseGeneratedCodeInfo_Annotation(); + message.path = object.path?.map(e => e) || []; + if (object.source_file !== undefined && object.source_file !== null) { + message.sourceFile = object.source_file; + } + if (object.begin !== undefined && object.begin !== null) { + message.begin = object.begin; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } + return message; + }, + toAmino(message: GeneratedCodeInfo_Annotation): GeneratedCodeInfo_AnnotationAmino { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map(e => e); + } else { + obj.path = message.path; + } + obj.source_file = message.sourceFile === "" ? undefined : message.sourceFile; + obj.begin = message.begin === 0 ? undefined : message.begin; + obj.end = message.end === 0 ? undefined : message.end; + return obj; + }, + fromAminoMsg(object: GeneratedCodeInfo_AnnotationAminoMsg): GeneratedCodeInfo_Annotation { + return GeneratedCodeInfo_Annotation.fromAmino(object.value); + }, + fromProtoMsg(message: GeneratedCodeInfo_AnnotationProtoMsg): GeneratedCodeInfo_Annotation { + return GeneratedCodeInfo_Annotation.decode(message.value); + }, + toProto(message: GeneratedCodeInfo_Annotation): Uint8Array { + return GeneratedCodeInfo_Annotation.encode(message).finish(); + }, + toProtoMsg(message: GeneratedCodeInfo_Annotation): GeneratedCodeInfo_AnnotationProtoMsg { + return { + typeUrl: "/google.protobuf.Annotation", + value: GeneratedCodeInfo_Annotation.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/protobuf/duration.ts b/__fixtures__/v-next/outputicjsdeps/google/protobuf/duration.ts new file mode 100644 index 0000000000..2fa45e4f46 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/protobuf/duration.ts @@ -0,0 +1,250 @@ +import { BinaryReader, BinaryWriter } from "../../binary.js"; +import { isSet, DeepPartial } from "../../helpers.js"; +import { JsonSafe } from "../../json-safe.js"; +export const protobufPackage = "google.protobuf"; +/** + * A Duration represents a signed, fixed-length span of time represented + * as a count of seconds and fractions of seconds at nanosecond + * resolution. It is independent of any calendar and concepts like "day" + * or "month". It is related to Timestamp in that the difference between + * two Timestamp values is a Duration and it can be added or subtracted + * from a Timestamp. Range is approximately +-10,000 years. + * + * # Examples + * + * Example 1: Compute Duration from two Timestamps in pseudo code. + * + * Timestamp start = ...; + * Timestamp end = ...; + * Duration duration = ...; + * + * duration.seconds = end.seconds - start.seconds; + * duration.nanos = end.nanos - start.nanos; + * + * if (duration.seconds < 0 && duration.nanos > 0) { + * duration.seconds += 1; + * duration.nanos -= 1000000000; + * } else if (durations.seconds > 0 && duration.nanos < 0) { + * duration.seconds -= 1; + * duration.nanos += 1000000000; + * } + * + * Example 2: Compute Timestamp from Timestamp + Duration in pseudo code. + * + * Timestamp start = ...; + * Duration duration = ...; + * Timestamp end = ...; + * + * end.seconds = start.seconds + duration.seconds; + * end.nanos = start.nanos + duration.nanos; + * + * if (end.nanos < 0) { + * end.seconds -= 1; + * end.nanos += 1000000000; + * } else if (end.nanos >= 1000000000) { + * end.seconds += 1; + * end.nanos -= 1000000000; + * } + * + * Example 3: Compute Duration from datetime.timedelta in Python. + * + * td = datetime.timedelta(days=3, minutes=10) + * duration = Duration() + * duration.FromTimedelta(td) + * + * # JSON Mapping + * + * In JSON format, the Duration type is encoded as a string rather than an + * object, where the string ends in the suffix "s" (indicating seconds) and + * is preceded by the number of seconds, with nanoseconds expressed as + * fractional seconds. For example, 3 seconds with 0 nanoseconds should be + * encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should + * be expressed in JSON format as "3.000000001s", and 3 seconds and 1 + * microsecond should be expressed in JSON format as "3.000001s". + */ +export interface Duration { + /** + * Signed seconds of the span of time. Must be from -315,576,000,000 + * to +315,576,000,000 inclusive. Note: these bounds are computed from: + * 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years + */ + seconds: bigint; + /** + * Signed fractions of a second at nanosecond resolution of the span + * of time. Durations less than one second are represented with a 0 + * `seconds` field and a positive or negative `nanos` field. For durations + * of one second or more, a non-zero value for the `nanos` field must be + * of the same sign as the `seconds` field. Must be from -999,999,999 + * to +999,999,999 inclusive. + */ + nanos: number; +} +export interface DurationProtoMsg { + typeUrl: "/google.protobuf.Duration"; + value: Uint8Array; +} +/** + * A Duration represents a signed, fixed-length span of time represented + * as a count of seconds and fractions of seconds at nanosecond + * resolution. It is independent of any calendar and concepts like "day" + * or "month". It is related to Timestamp in that the difference between + * two Timestamp values is a Duration and it can be added or subtracted + * from a Timestamp. Range is approximately +-10,000 years. + * + * # Examples + * + * Example 1: Compute Duration from two Timestamps in pseudo code. + * + * Timestamp start = ...; + * Timestamp end = ...; + * Duration duration = ...; + * + * duration.seconds = end.seconds - start.seconds; + * duration.nanos = end.nanos - start.nanos; + * + * if (duration.seconds < 0 && duration.nanos > 0) { + * duration.seconds += 1; + * duration.nanos -= 1000000000; + * } else if (durations.seconds > 0 && duration.nanos < 0) { + * duration.seconds -= 1; + * duration.nanos += 1000000000; + * } + * + * Example 2: Compute Timestamp from Timestamp + Duration in pseudo code. + * + * Timestamp start = ...; + * Duration duration = ...; + * Timestamp end = ...; + * + * end.seconds = start.seconds + duration.seconds; + * end.nanos = start.nanos + duration.nanos; + * + * if (end.nanos < 0) { + * end.seconds -= 1; + * end.nanos += 1000000000; + * } else if (end.nanos >= 1000000000) { + * end.seconds += 1; + * end.nanos -= 1000000000; + * } + * + * Example 3: Compute Duration from datetime.timedelta in Python. + * + * td = datetime.timedelta(days=3, minutes=10) + * duration = Duration() + * duration.FromTimedelta(td) + * + * # JSON Mapping + * + * In JSON format, the Duration type is encoded as a string rather than an + * object, where the string ends in the suffix "s" (indicating seconds) and + * is preceded by the number of seconds, with nanoseconds expressed as + * fractional seconds. For example, 3 seconds with 0 nanoseconds should be + * encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should + * be expressed in JSON format as "3.000000001s", and 3 seconds and 1 + * microsecond should be expressed in JSON format as "3.000001s". + */ +export interface DurationSDKType { + seconds: bigint; + nanos: number; +} +function createBaseDuration(): Duration { + return { + seconds: BigInt(0), + nanos: 0 + }; +} +export const Duration = { + typeUrl: "/google.protobuf.Duration", + encode(message: Duration, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.seconds !== undefined) { + writer.uint32(8).int64(message.seconds); + } + if (message.nanos !== undefined) { + writer.uint32(16).int32(message.nanos); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Duration { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDuration(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.seconds = reader.int64(); + break; + case 2: + message.nanos = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Duration { + const obj = createBaseDuration(); + if (isSet(object.seconds)) obj.seconds = BigInt(object.seconds.toString()); + if (isSet(object.nanos)) obj.nanos = Number(object.nanos); + return obj; + }, + toJSON(message: Duration): JsonSafe { + const obj: any = {}; + message.seconds !== undefined && (obj.seconds = (message.seconds || BigInt(0)).toString()); + message.nanos !== undefined && (obj.nanos = Math.round(message.nanos)); + return obj; + }, + fromPartial(object: DeepPartial): Duration { + const message = createBaseDuration(); + if (object.seconds !== undefined && object.seconds !== null) { + message.seconds = BigInt(object.seconds.toString()); + } + message.nanos = object.nanos ?? 0; + return message; + }, + fromSDK(object: DurationSDKType): Duration { + return { + seconds: object?.seconds, + nanos: object?.nanos + }; + }, + fromSDKJSON(object: any): DurationSDKType { + return { + seconds: isSet(object.seconds) ? BigInt(object.seconds.toString()) : BigInt(0), + nanos: isSet(object.nanos) ? Number(object.nanos) : 0 + }; + }, + toSDK(message: Duration): DurationSDKType { + const obj: any = {}; + obj.seconds = message.seconds; + obj.nanos = message.nanos; + return obj; + }, + fromAmino(object: DurationAmino): Duration { + const value = BigInt(object); + return { + seconds: value / BigInt("1000000000"), + nanos: Number(value % BigInt("1000000000")) + }; + }, + toAmino(message: Duration): DurationAmino { + return (message.seconds * BigInt("1000000000") + BigInt(message.nanos)).toString(); + }, + fromAminoMsg(object: DurationAminoMsg): Duration { + return Duration.fromAmino(object.value); + }, + fromProtoMsg(message: DurationProtoMsg): Duration { + return Duration.decode(message.value); + }, + toProto(message: Duration): Uint8Array { + return Duration.encode(message).finish(); + }, + toProtoMsg(message: Duration): DurationProtoMsg { + return { + typeUrl: "/google.protobuf.Duration", + value: Duration.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/protobuf/empty.ts b/__fixtures__/v-next/outputicjsdeps/google/protobuf/empty.ts new file mode 100644 index 0000000000..a7e3fcd23c --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/protobuf/empty.ts @@ -0,0 +1,100 @@ +import { BinaryReader, BinaryWriter } from "../../binary.js"; +import { JsonSafe } from "../../json-safe.js"; +import { DeepPartial } from "../../helpers.js"; +export const protobufPackage = "google.protobuf"; +/** + * A generic empty message that you can re-use to avoid defining duplicated + * empty messages in your APIs. A typical example is to use it as the request + * or the response type of an API method. For instance: + * + * service Foo { + * rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); + * } + * + * The JSON representation for `Empty` is empty JSON object `{}`. + */ +export interface Empty {} +export interface EmptyProtoMsg { + typeUrl: "/google.protobuf.Empty"; + value: Uint8Array; +} +/** + * A generic empty message that you can re-use to avoid defining duplicated + * empty messages in your APIs. A typical example is to use it as the request + * or the response type of an API method. For instance: + * + * service Foo { + * rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); + * } + * + * The JSON representation for `Empty` is empty JSON object `{}`. + */ +export interface EmptySDKType {} +function createBaseEmpty(): Empty { + return {}; +} +export const Empty = { + typeUrl: "/google.protobuf.Empty", + encode(_: Empty, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Empty { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseEmpty(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): Empty { + const obj = createBaseEmpty(); + return obj; + }, + toJSON(_: Empty): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): Empty { + const message = createBaseEmpty(); + return message; + }, + fromSDK(_: EmptySDKType): Empty { + return {}; + }, + fromSDKJSON(_: any): EmptySDKType { + return {}; + }, + toSDK(_: Empty): EmptySDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: EmptyAmino): Empty { + const message = createBaseEmpty(); + return message; + }, + toAmino(_: Empty): EmptyAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: EmptyAminoMsg): Empty { + return Empty.fromAmino(object.value); + }, + fromProtoMsg(message: EmptyProtoMsg): Empty { + return Empty.decode(message.value); + }, + toProto(message: Empty): Uint8Array { + return Empty.encode(message).finish(); + }, + toProtoMsg(message: Empty): EmptyProtoMsg { + return { + typeUrl: "/google.protobuf.Empty", + value: Empty.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/protobuf/field_mask.ts b/__fixtures__/v-next/outputicjsdeps/google/protobuf/field_mask.ts new file mode 100644 index 0000000000..f0247add07 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/protobuf/field_mask.ts @@ -0,0 +1,515 @@ +import { BinaryReader, BinaryWriter } from "../../binary.js"; +import { JsonSafe } from "../../json-safe.js"; +import { DeepPartial } from "../../helpers.js"; +export const protobufPackage = "google.protobuf"; +/** + * `FieldMask` represents a set of symbolic field paths, for example: + * + * paths: "f.a" + * paths: "f.b.d" + * + * Here `f` represents a field in some root message, `a` and `b` + * fields in the message found in `f`, and `d` a field found in the + * message in `f.b`. + * + * Field masks are used to specify a subset of fields that should be + * returned by a get operation or modified by an update operation. + * Field masks also have a custom JSON encoding (see below). + * + * # Field Masks in Projections + * + * When used in the context of a projection, a response message or + * sub-message is filtered by the API to only contain those fields as + * specified in the mask. For example, if the mask in the previous + * example is applied to a response message as follows: + * + * f { + * a : 22 + * b { + * d : 1 + * x : 2 + * } + * y : 13 + * } + * z: 8 + * + * The result will not contain specific values for fields x,y and z + * (their value will be set to the default, and omitted in proto text + * output): + * + * + * f { + * a : 22 + * b { + * d : 1 + * } + * } + * + * A repeated field is not allowed except at the last position of a + * paths string. + * + * If a FieldMask object is not present in a get operation, the + * operation applies to all fields (as if a FieldMask of all fields + * had been specified). + * + * Note that a field mask does not necessarily apply to the + * top-level response message. In case of a REST get operation, the + * field mask applies directly to the response, but in case of a REST + * list operation, the mask instead applies to each individual message + * in the returned resource list. In case of a REST custom method, + * other definitions may be used. Where the mask applies will be + * clearly documented together with its declaration in the API. In + * any case, the effect on the returned resource/resources is required + * behavior for APIs. + * + * # Field Masks in Update Operations + * + * A field mask in update operations specifies which fields of the + * targeted resource are going to be updated. The API is required + * to only change the values of the fields as specified in the mask + * and leave the others untouched. If a resource is passed in to + * describe the updated values, the API ignores the values of all + * fields not covered by the mask. + * + * If a repeated field is specified for an update operation, new values will + * be appended to the existing repeated field in the target resource. Note that + * a repeated field is only allowed in the last position of a `paths` string. + * + * If a sub-message is specified in the last position of the field mask for an + * update operation, then new value will be merged into the existing sub-message + * in the target resource. + * + * For example, given the target message: + * + * f { + * b { + * d: 1 + * x: 2 + * } + * c: [1] + * } + * + * And an update message: + * + * f { + * b { + * d: 10 + * } + * c: [2] + * } + * + * then if the field mask is: + * + * paths: ["f.b", "f.c"] + * + * then the result will be: + * + * f { + * b { + * d: 10 + * x: 2 + * } + * c: [1, 2] + * } + * + * An implementation may provide options to override this default behavior for + * repeated and message fields. + * + * In order to reset a field's value to the default, the field must + * be in the mask and set to the default value in the provided resource. + * Hence, in order to reset all fields of a resource, provide a default + * instance of the resource and set all fields in the mask, or do + * not provide a mask as described below. + * + * If a field mask is not present on update, the operation applies to + * all fields (as if a field mask of all fields has been specified). + * Note that in the presence of schema evolution, this may mean that + * fields the client does not know and has therefore not filled into + * the request will be reset to their default. If this is unwanted + * behavior, a specific service may require a client to always specify + * a field mask, producing an error if not. + * + * As with get operations, the location of the resource which + * describes the updated values in the request message depends on the + * operation kind. In any case, the effect of the field mask is + * required to be honored by the API. + * + * ## Considerations for HTTP REST + * + * The HTTP kind of an update operation which uses a field mask must + * be set to PATCH instead of PUT in order to satisfy HTTP semantics + * (PUT must only be used for full updates). + * + * # JSON Encoding of Field Masks + * + * In JSON, a field mask is encoded as a single string where paths are + * separated by a comma. Fields name in each path are converted + * to/from lower-camel naming conventions. + * + * As an example, consider the following message declarations: + * + * message Profile { + * User user = 1; + * Photo photo = 2; + * } + * message User { + * string display_name = 1; + * string address = 2; + * } + * + * In proto a field mask for `Profile` may look as such: + * + * mask { + * paths: "user.display_name" + * paths: "photo" + * } + * + * In JSON, the same mask is represented as below: + * + * { + * mask: "user.displayName,photo" + * } + * + * # Field Masks and Oneof Fields + * + * Field masks treat fields in oneofs just as regular fields. Consider the + * following message: + * + * message SampleMessage { + * oneof test_oneof { + * string name = 4; + * SubMessage sub_message = 9; + * } + * } + * + * The field mask can be: + * + * mask { + * paths: "name" + * } + * + * Or: + * + * mask { + * paths: "sub_message" + * } + * + * Note that oneof type names ("test_oneof" in this case) cannot be used in + * paths. + * + * ## Field Mask Verification + * + * The implementation of any API method which has a FieldMask type field in the + * request should verify the included field paths, and return an + * `INVALID_ARGUMENT` error if any path is duplicated or unmappable. + */ +export interface FieldMask { + /** The set of field mask paths. */ + paths: string[]; +} +export interface FieldMaskProtoMsg { + typeUrl: "/google.protobuf.FieldMask"; + value: Uint8Array; +} +/** + * `FieldMask` represents a set of symbolic field paths, for example: + * + * paths: "f.a" + * paths: "f.b.d" + * + * Here `f` represents a field in some root message, `a` and `b` + * fields in the message found in `f`, and `d` a field found in the + * message in `f.b`. + * + * Field masks are used to specify a subset of fields that should be + * returned by a get operation or modified by an update operation. + * Field masks also have a custom JSON encoding (see below). + * + * # Field Masks in Projections + * + * When used in the context of a projection, a response message or + * sub-message is filtered by the API to only contain those fields as + * specified in the mask. For example, if the mask in the previous + * example is applied to a response message as follows: + * + * f { + * a : 22 + * b { + * d : 1 + * x : 2 + * } + * y : 13 + * } + * z: 8 + * + * The result will not contain specific values for fields x,y and z + * (their value will be set to the default, and omitted in proto text + * output): + * + * + * f { + * a : 22 + * b { + * d : 1 + * } + * } + * + * A repeated field is not allowed except at the last position of a + * paths string. + * + * If a FieldMask object is not present in a get operation, the + * operation applies to all fields (as if a FieldMask of all fields + * had been specified). + * + * Note that a field mask does not necessarily apply to the + * top-level response message. In case of a REST get operation, the + * field mask applies directly to the response, but in case of a REST + * list operation, the mask instead applies to each individual message + * in the returned resource list. In case of a REST custom method, + * other definitions may be used. Where the mask applies will be + * clearly documented together with its declaration in the API. In + * any case, the effect on the returned resource/resources is required + * behavior for APIs. + * + * # Field Masks in Update Operations + * + * A field mask in update operations specifies which fields of the + * targeted resource are going to be updated. The API is required + * to only change the values of the fields as specified in the mask + * and leave the others untouched. If a resource is passed in to + * describe the updated values, the API ignores the values of all + * fields not covered by the mask. + * + * If a repeated field is specified for an update operation, new values will + * be appended to the existing repeated field in the target resource. Note that + * a repeated field is only allowed in the last position of a `paths` string. + * + * If a sub-message is specified in the last position of the field mask for an + * update operation, then new value will be merged into the existing sub-message + * in the target resource. + * + * For example, given the target message: + * + * f { + * b { + * d: 1 + * x: 2 + * } + * c: [1] + * } + * + * And an update message: + * + * f { + * b { + * d: 10 + * } + * c: [2] + * } + * + * then if the field mask is: + * + * paths: ["f.b", "f.c"] + * + * then the result will be: + * + * f { + * b { + * d: 10 + * x: 2 + * } + * c: [1, 2] + * } + * + * An implementation may provide options to override this default behavior for + * repeated and message fields. + * + * In order to reset a field's value to the default, the field must + * be in the mask and set to the default value in the provided resource. + * Hence, in order to reset all fields of a resource, provide a default + * instance of the resource and set all fields in the mask, or do + * not provide a mask as described below. + * + * If a field mask is not present on update, the operation applies to + * all fields (as if a field mask of all fields has been specified). + * Note that in the presence of schema evolution, this may mean that + * fields the client does not know and has therefore not filled into + * the request will be reset to their default. If this is unwanted + * behavior, a specific service may require a client to always specify + * a field mask, producing an error if not. + * + * As with get operations, the location of the resource which + * describes the updated values in the request message depends on the + * operation kind. In any case, the effect of the field mask is + * required to be honored by the API. + * + * ## Considerations for HTTP REST + * + * The HTTP kind of an update operation which uses a field mask must + * be set to PATCH instead of PUT in order to satisfy HTTP semantics + * (PUT must only be used for full updates). + * + * # JSON Encoding of Field Masks + * + * In JSON, a field mask is encoded as a single string where paths are + * separated by a comma. Fields name in each path are converted + * to/from lower-camel naming conventions. + * + * As an example, consider the following message declarations: + * + * message Profile { + * User user = 1; + * Photo photo = 2; + * } + * message User { + * string display_name = 1; + * string address = 2; + * } + * + * In proto a field mask for `Profile` may look as such: + * + * mask { + * paths: "user.display_name" + * paths: "photo" + * } + * + * In JSON, the same mask is represented as below: + * + * { + * mask: "user.displayName,photo" + * } + * + * # Field Masks and Oneof Fields + * + * Field masks treat fields in oneofs just as regular fields. Consider the + * following message: + * + * message SampleMessage { + * oneof test_oneof { + * string name = 4; + * SubMessage sub_message = 9; + * } + * } + * + * The field mask can be: + * + * mask { + * paths: "name" + * } + * + * Or: + * + * mask { + * paths: "sub_message" + * } + * + * Note that oneof type names ("test_oneof" in this case) cannot be used in + * paths. + * + * ## Field Mask Verification + * + * The implementation of any API method which has a FieldMask type field in the + * request should verify the included field paths, and return an + * `INVALID_ARGUMENT` error if any path is duplicated or unmappable. + */ +export interface FieldMaskSDKType { + paths: string[]; +} +function createBaseFieldMask(): FieldMask { + return { + paths: [] + }; +} +export const FieldMask = { + typeUrl: "/google.protobuf.FieldMask", + encode(message: FieldMask, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.paths) { + writer.uint32(10).string(v!); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): FieldMask { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseFieldMask(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.paths.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): FieldMask { + const obj = createBaseFieldMask(); + if (Array.isArray(object?.paths)) obj.paths = object.paths.map((e: any) => String(e)); + return obj; + }, + toJSON(message: FieldMask): JsonSafe { + const obj: any = {}; + if (message.paths) { + obj.paths = message.paths.map(e => e); + } else { + obj.paths = []; + } + return obj; + }, + fromPartial(object: DeepPartial): FieldMask { + const message = createBaseFieldMask(); + message.paths = object.paths?.map(e => e) || []; + return message; + }, + fromSDK(object: FieldMaskSDKType): FieldMask { + return { + paths: Array.isArray(object?.paths) ? object.paths.map((e: any) => e) : [] + }; + }, + fromSDKJSON(object: any): FieldMaskSDKType { + return { + paths: Array.isArray(object?.paths) ? object.paths.map((e: any) => String(e)) : [] + }; + }, + toSDK(message: FieldMask): FieldMaskSDKType { + const obj: any = {}; + if (message.paths) { + obj.paths = message.paths.map(e => e); + } else { + obj.paths = []; + } + return obj; + }, + fromAmino(object: FieldMaskAmino): FieldMask { + const message = createBaseFieldMask(); + message.paths = object.paths?.map(e => e) || []; + return message; + }, + toAmino(message: FieldMask): FieldMaskAmino { + const obj: any = {}; + if (message.paths) { + obj.paths = message.paths.map(e => e); + } else { + obj.paths = message.paths; + } + return obj; + }, + fromAminoMsg(object: FieldMaskAminoMsg): FieldMask { + return FieldMask.fromAmino(object.value); + }, + fromProtoMsg(message: FieldMaskProtoMsg): FieldMask { + return FieldMask.decode(message.value); + }, + toProto(message: FieldMask): Uint8Array { + return FieldMask.encode(message).finish(); + }, + toProtoMsg(message: FieldMask): FieldMaskProtoMsg { + return { + typeUrl: "/google.protobuf.FieldMask", + value: FieldMask.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/protobuf/source_context.ts b/__fixtures__/v-next/outputicjsdeps/google/protobuf/source_context.ts new file mode 100644 index 0000000000..b30ee947bd --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/protobuf/source_context.ts @@ -0,0 +1,114 @@ +import { BinaryReader, BinaryWriter } from "../../binary.js"; +import { isSet, DeepPartial } from "../../helpers.js"; +import { JsonSafe } from "../../json-safe.js"; +export const protobufPackage = "google.protobuf"; +/** + * `SourceContext` represents information about the source of a + * protobuf element, like the file in which it is defined. + */ +export interface SourceContext { + /** + * The path-qualified name of the .proto file that contained the associated + * protobuf element. For example: `"google/protobuf/source_context.proto"`. + */ + fileName: string; +} +export interface SourceContextProtoMsg { + typeUrl: "/google.protobuf.SourceContext"; + value: Uint8Array; +} +/** + * `SourceContext` represents information about the source of a + * protobuf element, like the file in which it is defined. + */ +export interface SourceContextSDKType { + file_name: string; +} +function createBaseSourceContext(): SourceContext { + return { + fileName: "" + }; +} +export const SourceContext = { + typeUrl: "/google.protobuf.SourceContext", + encode(message: SourceContext, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.fileName !== undefined) { + writer.uint32(10).string(message.fileName); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): SourceContext { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseSourceContext(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.fileName = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): SourceContext { + const obj = createBaseSourceContext(); + if (isSet(object.fileName)) obj.fileName = String(object.fileName); + return obj; + }, + toJSON(message: SourceContext): JsonSafe { + const obj: any = {}; + message.fileName !== undefined && (obj.fileName = message.fileName); + return obj; + }, + fromPartial(object: DeepPartial): SourceContext { + const message = createBaseSourceContext(); + message.fileName = object.fileName ?? ""; + return message; + }, + fromSDK(object: SourceContextSDKType): SourceContext { + return { + fileName: object?.file_name + }; + }, + fromSDKJSON(object: any): SourceContextSDKType { + return { + file_name: isSet(object.file_name) ? String(object.file_name) : "" + }; + }, + toSDK(message: SourceContext): SourceContextSDKType { + const obj: any = {}; + obj.file_name = message.fileName; + return obj; + }, + fromAmino(object: SourceContextAmino): SourceContext { + const message = createBaseSourceContext(); + if (object.file_name !== undefined && object.file_name !== null) { + message.fileName = object.file_name; + } + return message; + }, + toAmino(message: SourceContext): SourceContextAmino { + const obj: any = {}; + obj.file_name = message.fileName === "" ? undefined : message.fileName; + return obj; + }, + fromAminoMsg(object: SourceContextAminoMsg): SourceContext { + return SourceContext.fromAmino(object.value); + }, + fromProtoMsg(message: SourceContextProtoMsg): SourceContext { + return SourceContext.decode(message.value); + }, + toProto(message: SourceContext): Uint8Array { + return SourceContext.encode(message).finish(); + }, + toProtoMsg(message: SourceContext): SourceContextProtoMsg { + return { + typeUrl: "/google.protobuf.SourceContext", + value: SourceContext.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/protobuf/struct.ts b/__fixtures__/v-next/outputicjsdeps/google/protobuf/struct.ts new file mode 100644 index 0000000000..930dab6e07 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/protobuf/struct.ts @@ -0,0 +1,657 @@ +import { BinaryReader, BinaryWriter } from "../../binary.js"; +import { isSet, DeepPartial, isObject } from "../../helpers.js"; +import { JsonSafe } from "../../json-safe.js"; +export const protobufPackage = "google.protobuf"; +/** + * `NullValue` is a singleton enumeration to represent the null value for the + * `Value` type union. + * + * The JSON representation for `NullValue` is JSON `null`. + */ +export enum NullValue { + /** NULL_VALUE - Null value. */ + NULL_VALUE = 0, + UNRECOGNIZED = -1, +} +export const NullValueSDKType = NullValue; +export function nullValueFromJSON(object: any): NullValue { + switch (object) { + case 0: + case "NULL_VALUE": + return NullValue.NULL_VALUE; + case -1: + case "UNRECOGNIZED": + default: + return NullValue.UNRECOGNIZED; + } +} +export function nullValueToJSON(object: NullValue): string { + switch (object) { + case NullValue.NULL_VALUE: + return "NULL_VALUE"; + case NullValue.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +export interface Struct_FieldsEntry { + key: string; + value?: Value; +} +export interface Struct_FieldsEntryProtoMsg { + typeUrl: string; + value: Uint8Array; +} +export interface Struct_FieldsEntrySDKType { + key: string; + value?: ValueSDKType; +} +/** + * `Struct` represents a structured data value, consisting of fields + * which map to dynamically typed values. In some languages, `Struct` + * might be supported by a native representation. For example, in + * scripting languages like JS a struct is represented as an + * object. The details of that representation are described together + * with the proto support for the language. + * + * The JSON representation for `Struct` is JSON object. + */ +export interface Struct { + /** Unordered map of dynamically typed values. */ + fields: { + [key: string]: Value; + }; +} +export interface StructProtoMsg { + typeUrl: "/google.protobuf.Struct"; + value: Uint8Array; +} +/** + * `Struct` represents a structured data value, consisting of fields + * which map to dynamically typed values. In some languages, `Struct` + * might be supported by a native representation. For example, in + * scripting languages like JS a struct is represented as an + * object. The details of that representation are described together + * with the proto support for the language. + * + * The JSON representation for `Struct` is JSON object. + */ +export interface StructSDKType { + fields: { + [key: string]: ValueSDKType; + }; +} +/** + * `Value` represents a dynamically typed value which can be either + * null, a number, a string, a boolean, a recursive struct value, or a + * list of values. A producer of value is expected to set one of that + * variants, absence of any variant indicates an error. + * + * The JSON representation for `Value` is JSON value. + */ +export interface Value { + /** Represents a null value. */ + nullValue?: NullValue; + /** Represents a double value. */ + numberValue?: number; + /** Represents a string value. */ + stringValue?: string; + /** Represents a boolean value. */ + boolValue?: boolean; + /** Represents a structured value. */ + structValue?: Struct; + /** Represents a repeated `Value`. */ + listValue?: ListValue; +} +export interface ValueProtoMsg { + typeUrl: "/google.protobuf.Value"; + value: Uint8Array; +} +/** + * `Value` represents a dynamically typed value which can be either + * null, a number, a string, a boolean, a recursive struct value, or a + * list of values. A producer of value is expected to set one of that + * variants, absence of any variant indicates an error. + * + * The JSON representation for `Value` is JSON value. + */ +export interface ValueSDKType { + null_value?: NullValue; + number_value?: number; + string_value?: string; + bool_value?: boolean; + struct_value?: StructSDKType; + list_value?: ListValueSDKType; +} +/** + * `ListValue` is a wrapper around a repeated field of values. + * + * The JSON representation for `ListValue` is JSON array. + */ +export interface ListValue { + /** Repeated field of dynamically typed values. */ + values: Value[]; +} +export interface ListValueProtoMsg { + typeUrl: "/google.protobuf.ListValue"; + value: Uint8Array; +} +/** + * `ListValue` is a wrapper around a repeated field of values. + * + * The JSON representation for `ListValue` is JSON array. + */ +export interface ListValueSDKType { + values: ValueSDKType[]; +} +function createBaseStruct_FieldsEntry(): Struct_FieldsEntry { + return { + key: "", + value: undefined + }; +} +export const Struct_FieldsEntry = { + encode(message: Struct_FieldsEntry, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.key !== undefined) { + writer.uint32(10).string(message.key); + } + if (message.value !== undefined) { + Value.encode(message.value, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Struct_FieldsEntry { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseStruct_FieldsEntry(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.string(); + break; + case 2: + message.value = Value.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Struct_FieldsEntry { + const obj = createBaseStruct_FieldsEntry(); + if (isSet(object.key)) obj.key = String(object.key); + if (isSet(object.value)) obj.value = Value.fromJSON(object.value); + return obj; + }, + toJSON(message: Struct_FieldsEntry): JsonSafe { + const obj: any = {}; + message.key !== undefined && (obj.key = message.key); + message.value !== undefined && (obj.value = message.value ? Value.toJSON(message.value) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): Struct_FieldsEntry { + const message = createBaseStruct_FieldsEntry(); + message.key = object.key ?? ""; + if (object.value !== undefined && object.value !== null) { + message.value = Value.fromPartial(object.value); + } + return message; + }, + fromSDK(object: Struct_FieldsEntrySDKType): Struct_FieldsEntry { + return { + key: object?.key, + value: object.value ? Value.fromSDK(object.value) : undefined + }; + }, + fromSDKJSON(object: any): Struct_FieldsEntrySDKType { + return { + key: isSet(object.key) ? String(object.key) : "", + value: isSet(object.value) ? Value.fromSDKJSON(object.value) : undefined + }; + }, + toSDK(message: Struct_FieldsEntry): Struct_FieldsEntrySDKType { + const obj: any = {}; + obj.key = message.key; + message.value !== undefined && (obj.value = message.value ? Value.toSDK(message.value) : undefined); + return obj; + }, + fromAmino(object: Struct_FieldsEntryAmino): Struct_FieldsEntry { + const message = createBaseStruct_FieldsEntry(); + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } + if (object.value !== undefined && object.value !== null) { + message.value = Value.fromAmino(object.value); + } + return message; + }, + toAmino(message: Struct_FieldsEntry): Struct_FieldsEntryAmino { + const obj: any = {}; + obj.key = message.key === "" ? undefined : message.key; + obj.value = message.value ? Value.toAmino(message.value) : undefined; + return obj; + }, + fromAminoMsg(object: Struct_FieldsEntryAminoMsg): Struct_FieldsEntry { + return Struct_FieldsEntry.fromAmino(object.value); + }, + fromProtoMsg(message: Struct_FieldsEntryProtoMsg): Struct_FieldsEntry { + return Struct_FieldsEntry.decode(message.value); + }, + toProto(message: Struct_FieldsEntry): Uint8Array { + return Struct_FieldsEntry.encode(message).finish(); + } +}; +function createBaseStruct(): Struct { + return { + fields: {} + }; +} +export const Struct = { + typeUrl: "/google.protobuf.Struct", + encode(message: Struct, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + Object.entries(message.fields).forEach(([key, value]) => { + Struct_FieldsEntry.encode({ + key: (key as any), + value + }, writer.uint32(10).fork()).ldelim(); + }); + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Struct { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseStruct(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + const entry1 = Struct_FieldsEntry.decode(reader, reader.uint32()); + if (entry1.value !== undefined) { + message.fields[entry1.key] = entry1.value; + } + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Struct { + const obj = createBaseStruct(); + if (isObject(object.fields)) obj.fields = Object.entries(object.fields).reduce<{ + [key: string]: Value; + }>((acc, [key, value]) => { + acc[key] = Value.fromJSON(value); + return acc; + }, {}); + return obj; + }, + toJSON(message: Struct): JsonSafe { + const obj: any = {}; + obj.fields = {}; + if (message.fields) { + Object.entries(message.fields).forEach(([k, v]) => { + obj.fields[k] = Value.toJSON(v); + }); + } + return obj; + }, + fromPartial(object: DeepPartial): Struct { + const message = createBaseStruct(); + message.fields = Object.entries(object.fields ?? {}).reduce<{ + [key: string]: Value; + }>((acc, [key, value]) => { + if (value !== undefined) { + acc[key] = Value.fromPartial(value); + } + return acc; + }, {}); + return message; + }, + fromSDK(object: StructSDKType): Struct { + return { + fields: isObject(object.fields) ? Object.entries(object.fields).reduce<{ + [key: string]: Value; + }>((acc, [key, value]) => { + acc[key] = Value.fromSDK(value); + return acc; + }, {}) : {} + }; + }, + fromSDKJSON(object: any): StructSDKType { + return { + fields: isObject(object.fields) ? Object.entries(object.fields).reduce<{ + [key: string]: Value; + }>((acc, [key, value]) => { + acc[key] = Value.fromSDKJSON(value); + return acc; + }, {}) : {} + }; + }, + toSDK(message: Struct): StructSDKType { + const obj: any = {}; + obj.fields = {}; + if (message.fields) { + Object.entries(message.fields).forEach(([k, v]) => { + obj.fields[k] = Value.toSDK(v); + }); + } + return obj; + }, + fromAmino(object: StructAmino): Struct { + const message = createBaseStruct(); + message.fields = Object.entries(object.fields ?? {}).reduce<{ + [key: string]: Value; + }>((acc, [key, value]) => { + if (value !== undefined) { + acc[key] = Value.fromAmino(value); + } + return acc; + }, {}); + return message; + }, + toAmino(message: Struct): StructAmino { + const obj: any = {}; + obj.fields = {}; + if (message.fields) { + Object.entries(message.fields).forEach(([k, v]) => { + obj.fields[k] = Value.toAmino(v); + }); + } + return obj; + }, + fromAminoMsg(object: StructAminoMsg): Struct { + return Struct.fromAmino(object.value); + }, + fromProtoMsg(message: StructProtoMsg): Struct { + return Struct.decode(message.value); + }, + toProto(message: Struct): Uint8Array { + return Struct.encode(message).finish(); + }, + toProtoMsg(message: Struct): StructProtoMsg { + return { + typeUrl: "/google.protobuf.Struct", + value: Struct.encode(message).finish() + }; + } +}; +function createBaseValue(): Value { + return { + nullValue: undefined, + numberValue: undefined, + stringValue: undefined, + boolValue: undefined, + structValue: undefined, + listValue: undefined + }; +} +export const Value = { + typeUrl: "/google.protobuf.Value", + encode(message: Value, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.nullValue !== undefined) { + writer.uint32(8).int32(message.nullValue); + } + if (message.numberValue !== undefined) { + writer.uint32(17).double(message.numberValue); + } + if (message.stringValue !== undefined) { + writer.uint32(26).string(message.stringValue); + } + if (message.boolValue !== undefined) { + writer.uint32(32).bool(message.boolValue); + } + if (message.structValue !== undefined) { + Struct.encode(message.structValue, writer.uint32(42).fork()).ldelim(); + } + if (message.listValue !== undefined) { + ListValue.encode(message.listValue, writer.uint32(50).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Value { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseValue(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.nullValue = (reader.int32() as any); + break; + case 2: + message.numberValue = reader.double(); + break; + case 3: + message.stringValue = reader.string(); + break; + case 4: + message.boolValue = reader.bool(); + break; + case 5: + message.structValue = Struct.decode(reader, reader.uint32()); + break; + case 6: + message.listValue = ListValue.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Value { + const obj = createBaseValue(); + if (isSet(object.nullValue)) obj.nullValue = nullValueFromJSON(object.nullValue); + if (isSet(object.numberValue)) obj.numberValue = Number(object.numberValue); + if (isSet(object.stringValue)) obj.stringValue = String(object.stringValue); + if (isSet(object.boolValue)) obj.boolValue = Boolean(object.boolValue); + if (isSet(object.structValue)) obj.structValue = Struct.fromJSON(object.structValue); + if (isSet(object.listValue)) obj.listValue = ListValue.fromJSON(object.listValue); + return obj; + }, + toJSON(message: Value): JsonSafe { + const obj: any = {}; + message.nullValue !== undefined && (obj.nullValue = nullValueToJSON(message.nullValue)); + message.numberValue !== undefined && (obj.numberValue = message.numberValue); + message.stringValue !== undefined && (obj.stringValue = message.stringValue); + message.boolValue !== undefined && (obj.boolValue = message.boolValue); + message.structValue !== undefined && (obj.structValue = message.structValue ? Struct.toJSON(message.structValue) : undefined); + message.listValue !== undefined && (obj.listValue = message.listValue ? ListValue.toJSON(message.listValue) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): Value { + const message = createBaseValue(); + message.nullValue = object.nullValue ?? undefined; + message.numberValue = object.numberValue ?? undefined; + message.stringValue = object.stringValue ?? undefined; + message.boolValue = object.boolValue ?? undefined; + if (object.structValue !== undefined && object.structValue !== null) { + message.structValue = Struct.fromPartial(object.structValue); + } + if (object.listValue !== undefined && object.listValue !== null) { + message.listValue = ListValue.fromPartial(object.listValue); + } + return message; + }, + fromSDK(object: ValueSDKType): Value { + return { + nullValue: isSet(object.null_value) ? nullValueFromJSON(object.null_value) : undefined, + numberValue: object?.number_value, + stringValue: object?.string_value, + boolValue: object?.bool_value, + structValue: object.struct_value ? Struct.fromSDK(object.struct_value) : undefined, + listValue: object.list_value ? ListValue.fromSDK(object.list_value) : undefined + }; + }, + fromSDKJSON(object: any): ValueSDKType { + return { + null_value: isSet(object.null_value) ? nullValueFromJSON(object.null_value) : undefined, + number_value: isSet(object.number_value) ? Number(object.number_value) : undefined, + string_value: isSet(object.string_value) ? String(object.string_value) : undefined, + bool_value: isSet(object.bool_value) ? Boolean(object.bool_value) : undefined, + struct_value: isSet(object.struct_value) ? Struct.fromSDKJSON(object.struct_value) : undefined, + list_value: isSet(object.list_value) ? ListValue.fromSDKJSON(object.list_value) : undefined + }; + }, + toSDK(message: Value): ValueSDKType { + const obj: any = {}; + message.nullValue !== undefined && (obj.null_value = nullValueToJSON(message.nullValue)); + obj.number_value = message.numberValue; + obj.string_value = message.stringValue; + obj.bool_value = message.boolValue; + message.structValue !== undefined && (obj.struct_value = message.structValue ? Struct.toSDK(message.structValue) : undefined); + message.listValue !== undefined && (obj.list_value = message.listValue ? ListValue.toSDK(message.listValue) : undefined); + return obj; + }, + fromAmino(object: ValueAmino): Value { + const message = createBaseValue(); + if (object.null_value !== undefined && object.null_value !== null) { + message.nullValue = object.null_value; + } + if (object.number_value !== undefined && object.number_value !== null) { + message.numberValue = object.number_value; + } + if (object.string_value !== undefined && object.string_value !== null) { + message.stringValue = object.string_value; + } + if (object.bool_value !== undefined && object.bool_value !== null) { + message.boolValue = object.bool_value; + } + if (object.struct_value !== undefined && object.struct_value !== null) { + message.structValue = Struct.fromAmino(object.struct_value); + } + if (object.list_value !== undefined && object.list_value !== null) { + message.listValue = ListValue.fromAmino(object.list_value); + } + return message; + }, + toAmino(message: Value): ValueAmino { + const obj: any = {}; + obj.null_value = message.nullValue === null ? undefined : message.nullValue; + obj.number_value = message.numberValue === null ? undefined : message.numberValue; + obj.string_value = message.stringValue === null ? undefined : message.stringValue; + obj.bool_value = message.boolValue === null ? undefined : message.boolValue; + obj.struct_value = message.structValue ? Struct.toAmino(message.structValue) : undefined; + obj.list_value = message.listValue ? ListValue.toAmino(message.listValue) : undefined; + return obj; + }, + fromAminoMsg(object: ValueAminoMsg): Value { + return Value.fromAmino(object.value); + }, + fromProtoMsg(message: ValueProtoMsg): Value { + return Value.decode(message.value); + }, + toProto(message: Value): Uint8Array { + return Value.encode(message).finish(); + }, + toProtoMsg(message: Value): ValueProtoMsg { + return { + typeUrl: "/google.protobuf.Value", + value: Value.encode(message).finish() + }; + } +}; +function createBaseListValue(): ListValue { + return { + values: [] + }; +} +export const ListValue = { + typeUrl: "/google.protobuf.ListValue", + encode(message: ListValue, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + for (const v of message.values) { + Value.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): ListValue { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseListValue(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.values.push(Value.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ListValue { + const obj = createBaseListValue(); + if (Array.isArray(object?.values)) obj.values = object.values.map((e: any) => Value.fromJSON(e)); + return obj; + }, + toJSON(message: ListValue): JsonSafe { + const obj: any = {}; + if (message.values) { + obj.values = message.values.map(e => e ? Value.toJSON(e) : undefined); + } else { + obj.values = []; + } + return obj; + }, + fromPartial(object: DeepPartial): ListValue { + const message = createBaseListValue(); + message.values = object.values?.map(e => Value.fromPartial(e)) || []; + return message; + }, + fromSDK(object: ListValueSDKType): ListValue { + return { + values: Array.isArray(object?.values) ? object.values.map((e: any) => Value.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): ListValueSDKType { + return { + values: Array.isArray(object?.values) ? object.values.map((e: any) => Value.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: ListValue): ListValueSDKType { + const obj: any = {}; + if (message.values) { + obj.values = message.values.map(e => e ? Value.toSDK(e) : undefined); + } else { + obj.values = []; + } + return obj; + }, + fromAmino(object: ListValueAmino): ListValue { + const message = createBaseListValue(); + message.values = object.values?.map(e => Value.fromAmino(e)) || []; + return message; + }, + toAmino(message: ListValue): ListValueAmino { + const obj: any = {}; + if (message.values) { + obj.values = message.values.map(e => e ? Value.toAmino(e) : undefined); + } else { + obj.values = message.values; + } + return obj; + }, + fromAminoMsg(object: ListValueAminoMsg): ListValue { + return ListValue.fromAmino(object.value); + }, + fromProtoMsg(message: ListValueProtoMsg): ListValue { + return ListValue.decode(message.value); + }, + toProto(message: ListValue): Uint8Array { + return ListValue.encode(message).finish(); + }, + toProtoMsg(message: ListValue): ListValueProtoMsg { + return { + typeUrl: "/google.protobuf.ListValue", + value: ListValue.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/protobuf/timestamp.ts b/__fixtures__/v-next/outputicjsdeps/google/protobuf/timestamp.ts new file mode 100644 index 0000000000..9b0ae07ea7 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/protobuf/timestamp.ts @@ -0,0 +1,292 @@ +import { BinaryReader, BinaryWriter } from "../../binary.js"; +import { isSet, DeepPartial, fromJsonTimestamp, fromTimestamp } from "../../helpers.js"; +import { JsonSafe } from "../../json-safe.js"; +export const protobufPackage = "google.protobuf"; +/** + * A Timestamp represents a point in time independent of any time zone or local + * calendar, encoded as a count of seconds and fractions of seconds at + * nanosecond resolution. The count is relative to an epoch at UTC midnight on + * January 1, 1970, in the proleptic Gregorian calendar which extends the + * Gregorian calendar backwards to year one. + * + * All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap + * second table is needed for interpretation, using a [24-hour linear + * smear](https://developers.google.com/time/smear). + * + * The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By + * restricting to that range, we ensure that we can convert to and from [RFC + * 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings. + * + * # Examples + * + * Example 1: Compute Timestamp from POSIX `time()`. + * + * Timestamp timestamp; + * timestamp.set_seconds(time(NULL)); + * timestamp.set_nanos(0); + * + * Example 2: Compute Timestamp from POSIX `gettimeofday()`. + * + * struct timeval tv; + * gettimeofday(&tv, NULL); + * + * Timestamp timestamp; + * timestamp.set_seconds(tv.tv_sec); + * timestamp.set_nanos(tv.tv_usec * 1000); + * + * Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`. + * + * FILETIME ft; + * GetSystemTimeAsFileTime(&ft); + * UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime; + * + * // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z + * // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z. + * Timestamp timestamp; + * timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL)); + * timestamp.set_nanos((INT32) ((ticks % 10000000) * 100)); + * + * Example 4: Compute Timestamp from Java `System.currentTimeMillis()`. + * + * long millis = System.currentTimeMillis(); + * + * Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000) + * .setNanos((int) ((millis % 1000) * 1000000)).build(); + * + * + * Example 5: Compute Timestamp from current time in Python. + * + * timestamp = Timestamp() + * timestamp.GetCurrentTime() + * + * # JSON Mapping + * + * In JSON format, the Timestamp type is encoded as a string in the + * [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the + * format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z" + * where {year} is always expressed using four digits while {month}, {day}, + * {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional + * seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution), + * are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone + * is required. A proto3 JSON serializer should always use UTC (as indicated by + * "Z") when printing the Timestamp type and a proto3 JSON parser should be + * able to accept both UTC and other timezones (as indicated by an offset). + * + * For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past + * 01:30 UTC on January 15, 2017. + * + * In JavaScript, one can convert a Date object to this format using the + * standard + * [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString) + * method. In Python, a standard `datetime.datetime` object can be converted + * to this format using + * [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with + * the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use + * the Joda Time's [`ISODateTimeFormat.dateTime()`]( + * http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D + * ) to obtain a formatter capable of generating timestamps in this format. + */ +export interface Timestamp { + /** + * Represents seconds of UTC time since Unix epoch + * 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to + * 9999-12-31T23:59:59Z inclusive. + */ + seconds: bigint; + /** + * Non-negative fractions of a second at nanosecond resolution. Negative + * second values with fractions must still have non-negative nanos values + * that count forward in time. Must be from 0 to 999,999,999 + * inclusive. + */ + nanos: number; +} +export interface TimestampProtoMsg { + typeUrl: "/google.protobuf.Timestamp"; + value: Uint8Array; +} +/** + * A Timestamp represents a point in time independent of any time zone or local + * calendar, encoded as a count of seconds and fractions of seconds at + * nanosecond resolution. The count is relative to an epoch at UTC midnight on + * January 1, 1970, in the proleptic Gregorian calendar which extends the + * Gregorian calendar backwards to year one. + * + * All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap + * second table is needed for interpretation, using a [24-hour linear + * smear](https://developers.google.com/time/smear). + * + * The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By + * restricting to that range, we ensure that we can convert to and from [RFC + * 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings. + * + * # Examples + * + * Example 1: Compute Timestamp from POSIX `time()`. + * + * Timestamp timestamp; + * timestamp.set_seconds(time(NULL)); + * timestamp.set_nanos(0); + * + * Example 2: Compute Timestamp from POSIX `gettimeofday()`. + * + * struct timeval tv; + * gettimeofday(&tv, NULL); + * + * Timestamp timestamp; + * timestamp.set_seconds(tv.tv_sec); + * timestamp.set_nanos(tv.tv_usec * 1000); + * + * Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`. + * + * FILETIME ft; + * GetSystemTimeAsFileTime(&ft); + * UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime; + * + * // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z + * // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z. + * Timestamp timestamp; + * timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL)); + * timestamp.set_nanos((INT32) ((ticks % 10000000) * 100)); + * + * Example 4: Compute Timestamp from Java `System.currentTimeMillis()`. + * + * long millis = System.currentTimeMillis(); + * + * Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000) + * .setNanos((int) ((millis % 1000) * 1000000)).build(); + * + * + * Example 5: Compute Timestamp from current time in Python. + * + * timestamp = Timestamp() + * timestamp.GetCurrentTime() + * + * # JSON Mapping + * + * In JSON format, the Timestamp type is encoded as a string in the + * [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the + * format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z" + * where {year} is always expressed using four digits while {month}, {day}, + * {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional + * seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution), + * are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone + * is required. A proto3 JSON serializer should always use UTC (as indicated by + * "Z") when printing the Timestamp type and a proto3 JSON parser should be + * able to accept both UTC and other timezones (as indicated by an offset). + * + * For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past + * 01:30 UTC on January 15, 2017. + * + * In JavaScript, one can convert a Date object to this format using the + * standard + * [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString) + * method. In Python, a standard `datetime.datetime` object can be converted + * to this format using + * [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with + * the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use + * the Joda Time's [`ISODateTimeFormat.dateTime()`]( + * http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D + * ) to obtain a formatter capable of generating timestamps in this format. + */ +export interface TimestampSDKType { + seconds: bigint; + nanos: number; +} +function createBaseTimestamp(): Timestamp { + return { + seconds: BigInt(0), + nanos: 0 + }; +} +export const Timestamp = { + typeUrl: "/google.protobuf.Timestamp", + encode(message: Timestamp, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.seconds !== undefined) { + writer.uint32(8).int64(message.seconds); + } + if (message.nanos !== undefined) { + writer.uint32(16).int32(message.nanos); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Timestamp { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseTimestamp(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.seconds = reader.int64(); + break; + case 2: + message.nanos = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Timestamp { + const obj = createBaseTimestamp(); + if (isSet(object.seconds)) obj.seconds = BigInt(object.seconds.toString()); + if (isSet(object.nanos)) obj.nanos = Number(object.nanos); + return obj; + }, + toJSON(message: Timestamp): JsonSafe { + const obj: any = {}; + message.seconds !== undefined && (obj.seconds = (message.seconds || BigInt(0)).toString()); + message.nanos !== undefined && (obj.nanos = Math.round(message.nanos)); + return obj; + }, + fromPartial(object: DeepPartial): Timestamp { + const message = createBaseTimestamp(); + if (object.seconds !== undefined && object.seconds !== null) { + message.seconds = BigInt(object.seconds.toString()); + } + message.nanos = object.nanos ?? 0; + return message; + }, + fromSDK(object: TimestampSDKType): Timestamp { + return { + seconds: object?.seconds, + nanos: object?.nanos + }; + }, + fromSDKJSON(object: any): TimestampSDKType { + return { + seconds: isSet(object.seconds) ? BigInt(object.seconds.toString()) : BigInt(0), + nanos: isSet(object.nanos) ? Number(object.nanos) : 0 + }; + }, + toSDK(message: Timestamp): TimestampSDKType { + const obj: any = {}; + obj.seconds = message.seconds; + obj.nanos = message.nanos; + return obj; + }, + fromAmino(object: TimestampAmino): Timestamp { + return fromJsonTimestamp(object); + }, + toAmino(message: Timestamp): TimestampAmino { + return fromTimestamp(message).toISOString().replace(/\.\d+Z$/, "Z"); + }, + fromAminoMsg(object: TimestampAminoMsg): Timestamp { + return Timestamp.fromAmino(object.value); + }, + fromProtoMsg(message: TimestampProtoMsg): Timestamp { + return Timestamp.decode(message.value); + }, + toProto(message: Timestamp): Uint8Array { + return Timestamp.encode(message).finish(); + }, + toProtoMsg(message: Timestamp): TimestampProtoMsg { + return { + typeUrl: "/google.protobuf.Timestamp", + value: Timestamp.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/v-next/outputicjsdeps/google/protobuf/type.ts b/__fixtures__/v-next/outputicjsdeps/google/protobuf/type.ts new file mode 100644 index 0000000000..74eef8b121 --- /dev/null +++ b/__fixtures__/v-next/outputicjsdeps/google/protobuf/type.ts @@ -0,0 +1,1264 @@ +import { SourceContext, SourceContextSDKType } from "./source_context.js"; +import { Any, AnySDKType } from "./any.js"; +import { BinaryReader, BinaryWriter } from "../../binary.js"; +import { isSet, DeepPartial } from "../../helpers.js"; +import { JsonSafe } from "../../json-safe.js"; +export const protobufPackage = "google.protobuf"; +/** Basic field types. */ +export enum Field_Kind { + /** TYPE_UNKNOWN - Field type unknown. */ + TYPE_UNKNOWN = 0, + /** TYPE_DOUBLE - Field type double. */ + TYPE_DOUBLE = 1, + /** TYPE_FLOAT - Field type float. */ + TYPE_FLOAT = 2, + /** TYPE_INT64 - Field type int64. */ + TYPE_INT64 = 3, + /** TYPE_UINT64 - Field type uint64. */ + TYPE_UINT64 = 4, + /** TYPE_INT32 - Field type int32. */ + TYPE_INT32 = 5, + /** TYPE_FIXED64 - Field type fixed64. */ + TYPE_FIXED64 = 6, + /** TYPE_FIXED32 - Field type fixed32. */ + TYPE_FIXED32 = 7, + /** TYPE_BOOL - Field type bool. */ + TYPE_BOOL = 8, + /** TYPE_STRING - Field type string. */ + TYPE_STRING = 9, + /** TYPE_GROUP - Field type group. Proto2 syntax only, and deprecated. */ + TYPE_GROUP = 10, + /** TYPE_MESSAGE - Field type message. */ + TYPE_MESSAGE = 11, + /** TYPE_BYTES - Field type bytes. */ + TYPE_BYTES = 12, + /** TYPE_UINT32 - Field type uint32. */ + TYPE_UINT32 = 13, + /** TYPE_ENUM - Field type enum. */ + TYPE_ENUM = 14, + /** TYPE_SFIXED32 - Field type sfixed32. */ + TYPE_SFIXED32 = 15, + /** TYPE_SFIXED64 - Field type sfixed64. */ + TYPE_SFIXED64 = 16, + /** TYPE_SINT32 - Field type sint32. */ + TYPE_SINT32 = 17, + /** TYPE_SINT64 - Field type sint64. */ + TYPE_SINT64 = 18, + UNRECOGNIZED = -1, +} +export const Field_KindSDKType = Field_Kind; +export function field_KindFromJSON(object: any): Field_Kind { + switch (object) { + case 0: + case "TYPE_UNKNOWN": + return Field_Kind.TYPE_UNKNOWN; + case 1: + case "TYPE_DOUBLE": + return Field_Kind.TYPE_DOUBLE; + case 2: + case "TYPE_FLOAT": + return Field_Kind.TYPE_FLOAT; + case 3: + case "TYPE_INT64": + return Field_Kind.TYPE_INT64; + case 4: + case "TYPE_UINT64": + return Field_Kind.TYPE_UINT64; + case 5: + case "TYPE_INT32": + return Field_Kind.TYPE_INT32; + case 6: + case "TYPE_FIXED64": + return Field_Kind.TYPE_FIXED64; + case 7: + case "TYPE_FIXED32": + return Field_Kind.TYPE_FIXED32; + case 8: + case "TYPE_BOOL": + return Field_Kind.TYPE_BOOL; + case 9: + case "TYPE_STRING": + return Field_Kind.TYPE_STRING; + case 10: + case "TYPE_GROUP": + return Field_Kind.TYPE_GROUP; + case 11: + case "TYPE_MESSAGE": + return Field_Kind.TYPE_MESSAGE; + case 12: + case "TYPE_BYTES": + return Field_Kind.TYPE_BYTES; + case 13: + case "TYPE_UINT32": + return Field_Kind.TYPE_UINT32; + case 14: + case "TYPE_ENUM": + return Field_Kind.TYPE_ENUM; + case 15: + case "TYPE_SFIXED32": + return Field_Kind.TYPE_SFIXED32; + case 16: + case "TYPE_SFIXED64": + return Field_Kind.TYPE_SFIXED64; + case 17: + case "TYPE_SINT32": + return Field_Kind.TYPE_SINT32; + case 18: + case "TYPE_SINT64": + return Field_Kind.TYPE_SINT64; + case -1: + case "UNRECOGNIZED": + default: + return Field_Kind.UNRECOGNIZED; + } +} +export function field_KindToJSON(object: Field_Kind): string { + switch (object) { + case Field_Kind.TYPE_UNKNOWN: + return "TYPE_UNKNOWN"; + case Field_Kind.TYPE_DOUBLE: + return "TYPE_DOUBLE"; + case Field_Kind.TYPE_FLOAT: + return "TYPE_FLOAT"; + case Field_Kind.TYPE_INT64: + return "TYPE_INT64"; + case Field_Kind.TYPE_UINT64: + return "TYPE_UINT64"; + case Field_Kind.TYPE_INT32: + return "TYPE_INT32"; + case Field_Kind.TYPE_FIXED64: + return "TYPE_FIXED64"; + case Field_Kind.TYPE_FIXED32: + return "TYPE_FIXED32"; + case Field_Kind.TYPE_BOOL: + return "TYPE_BOOL"; + case Field_Kind.TYPE_STRING: + return "TYPE_STRING"; + case Field_Kind.TYPE_GROUP: + return "TYPE_GROUP"; + case Field_Kind.TYPE_MESSAGE: + return "TYPE_MESSAGE"; + case Field_Kind.TYPE_BYTES: + return "TYPE_BYTES"; + case Field_Kind.TYPE_UINT32: + return "TYPE_UINT32"; + case Field_Kind.TYPE_ENUM: + return "TYPE_ENUM"; + case Field_Kind.TYPE_SFIXED32: + return "TYPE_SFIXED32"; + case Field_Kind.TYPE_SFIXED64: + return "TYPE_SFIXED64"; + case Field_Kind.TYPE_SINT32: + return "TYPE_SINT32"; + case Field_Kind.TYPE_SINT64: + return "TYPE_SINT64"; + case Field_Kind.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** Whether a field is optional, required, or repeated. */ +export enum Field_Cardinality { + /** CARDINALITY_UNKNOWN - For fields with unknown cardinality. */ + CARDINALITY_UNKNOWN = 0, + /** CARDINALITY_OPTIONAL - For optional fields. */ + CARDINALITY_OPTIONAL = 1, + /** CARDINALITY_REQUIRED - For required fields. Proto2 syntax only. */ + CARDINALITY_REQUIRED = 2, + /** CARDINALITY_REPEATED - For repeated fields. */ + CARDINALITY_REPEATED = 3, + UNRECOGNIZED = -1, +} +export const Field_CardinalitySDKType = Field_Cardinality; +export function field_CardinalityFromJSON(object: any): Field_Cardinality { + switch (object) { + case 0: + case "CARDINALITY_UNKNOWN": + return Field_Cardinality.CARDINALITY_UNKNOWN; + case 1: + case "CARDINALITY_OPTIONAL": + return Field_Cardinality.CARDINALITY_OPTIONAL; + case 2: + case "CARDINALITY_REQUIRED": + return Field_Cardinality.CARDINALITY_REQUIRED; + case 3: + case "CARDINALITY_REPEATED": + return Field_Cardinality.CARDINALITY_REPEATED; + case -1: + case "UNRECOGNIZED": + default: + return Field_Cardinality.UNRECOGNIZED; + } +} +export function field_CardinalityToJSON(object: Field_Cardinality): string { + switch (object) { + case Field_Cardinality.CARDINALITY_UNKNOWN: + return "CARDINALITY_UNKNOWN"; + case Field_Cardinality.CARDINALITY_OPTIONAL: + return "CARDINALITY_OPTIONAL"; + case Field_Cardinality.CARDINALITY_REQUIRED: + return "CARDINALITY_REQUIRED"; + case Field_Cardinality.CARDINALITY_REPEATED: + return "CARDINALITY_REPEATED"; + case Field_Cardinality.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** The syntax in which a protocol buffer element is defined. */ +export enum Syntax { + /** SYNTAX_PROTO2 - Syntax `proto2`. */ + SYNTAX_PROTO2 = 0, + /** SYNTAX_PROTO3 - Syntax `proto3`. */ + SYNTAX_PROTO3 = 1, + UNRECOGNIZED = -1, +} +export const SyntaxSDKType = Syntax; +export function syntaxFromJSON(object: any): Syntax { + switch (object) { + case 0: + case "SYNTAX_PROTO2": + return Syntax.SYNTAX_PROTO2; + case 1: + case "SYNTAX_PROTO3": + return Syntax.SYNTAX_PROTO3; + case -1: + case "UNRECOGNIZED": + default: + return Syntax.UNRECOGNIZED; + } +} +export function syntaxToJSON(object: Syntax): string { + switch (object) { + case Syntax.SYNTAX_PROTO2: + return "SYNTAX_PROTO2"; + case Syntax.SYNTAX_PROTO3: + return "SYNTAX_PROTO3"; + case Syntax.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} +/** A protocol buffer message type. */ +export interface Type { + /** The fully qualified message name. */ + name: string; + /** The list of fields. */ + fields: Field[]; + /** The list of types appearing in `oneof` definitions in this type. */ + oneofs: string[]; + /** The protocol buffer options. */ + options: Option[]; + /** The source context. */ + sourceContext?: SourceContext; + /** The source syntax. */ + syntax: Syntax; +} +export interface TypeProtoMsg { + typeUrl: "/google.protobuf.Type"; + value: Uint8Array; +} +/** A protocol buffer message type. */ +export interface TypeSDKType { + name: string; + fields: FieldSDKType[]; + oneofs: string[]; + options: OptionSDKType[]; + source_context?: SourceContextSDKType; + syntax: Syntax; +} +/** A single field of a message type. */ +export interface Field { + /** The field type. */ + kind: Field_Kind; + /** The field cardinality. */ + cardinality: Field_Cardinality; + /** The field number. */ + number: number; + /** The field name. */ + name: string; + /** + * The field type URL, without the scheme, for message or enumeration + * types. Example: `"type.googleapis.com/google.protobuf.Timestamp"`. + */ + typeUrl: string; + /** + * The index of the field type in `Type.oneofs`, for message or enumeration + * types. The first type has index 1; zero means the type is not in the list. + */ + oneofIndex: number; + /** Whether to use alternative packed wire representation. */ + packed: boolean; + /** The protocol buffer options. */ + options: Option[]; + /** The field JSON name. */ + jsonName: string; + /** The string value of the default value of this field. Proto2 syntax only. */ + defaultValue: string; +} +export interface FieldProtoMsg { + typeUrl: "/google.protobuf.Field"; + value: Uint8Array; +} +/** A single field of a message type. */ +export interface FieldSDKType { + kind: Field_Kind; + cardinality: Field_Cardinality; + number: number; + name: string; + type_url: string; + oneof_index: number; + packed: boolean; + options: OptionSDKType[]; + json_name: string; + default_value: string; +} +/** Enum type definition. */ +export interface Enum { + /** Enum type name. */ + name: string; + /** Enum value definitions. */ + enumvalue: EnumValue[]; + /** Protocol buffer options. */ + options: Option[]; + /** The source context. */ + sourceContext?: SourceContext; + /** The source syntax. */ + syntax: Syntax; +} +export interface EnumProtoMsg { + typeUrl: "/google.protobuf.Enum"; + value: Uint8Array; +} +/** Enum type definition. */ +export interface EnumSDKType { + name: string; + enumvalue: EnumValueSDKType[]; + options: OptionSDKType[]; + source_context?: SourceContextSDKType; + syntax: Syntax; +} +/** Enum value definition. */ +export interface EnumValue { + /** Enum value name. */ + name: string; + /** Enum value number. */ + number: number; + /** Protocol buffer options. */ + options: Option[]; +} +export interface EnumValueProtoMsg { + typeUrl: "/google.protobuf.EnumValue"; + value: Uint8Array; +} +/** Enum value definition. */ +export interface EnumValueSDKType { + name: string; + number: number; + options: OptionSDKType[]; +} +/** + * A protocol buffer option, which can be attached to a message, field, + * enumeration, etc. + */ +export interface Option { + /** + * The option's name. For protobuf built-in options (options defined in + * descriptor.proto), this is the short name. For example, `"map_entry"`. + * For custom options, it should be the fully-qualified name. For example, + * `"google.api.http"`. + */ + name: string; + /** + * The option's value packed in an Any message. If the value is a primitive, + * the corresponding wrapper type defined in google/protobuf/wrappers.proto + * should be used. If the value is an enum, it should be stored as an int32 + * value using the google.protobuf.Int32Value type. + */ + value?: Any; +} +export interface OptionProtoMsg { + typeUrl: "/google.protobuf.Option"; + value: Uint8Array; +} +/** + * A protocol buffer option, which can be attached to a message, field, + * enumeration, etc. + */ +export interface OptionSDKType { + name: string; + value?: AnySDKType; +} +function createBaseType(): Type { + return { + name: "", + fields: [], + oneofs: [], + options: [], + sourceContext: undefined, + syntax: 0 + }; +} +export const Type = { + typeUrl: "/google.protobuf.Type", + encode(message: Type, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + for (const v of message.fields) { + Field.encode(v!, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.oneofs) { + writer.uint32(26).string(v!); + } + for (const v of message.options) { + Option.encode(v!, writer.uint32(34).fork()).ldelim(); + } + if (message.sourceContext !== undefined) { + SourceContext.encode(message.sourceContext, writer.uint32(42).fork()).ldelim(); + } + if (message.syntax !== 0) { + writer.uint32(48).int32(message.syntax); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Type { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseType(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.fields.push(Field.decode(reader, reader.uint32())); + break; + case 3: + message.oneofs.push(reader.string()); + break; + case 4: + message.options.push(Option.decode(reader, reader.uint32())); + break; + case 5: + message.sourceContext = SourceContext.decode(reader, reader.uint32()); + break; + case 6: + message.syntax = (reader.int32() as any); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Type { + const obj = createBaseType(); + if (isSet(object.name)) obj.name = String(object.name); + if (Array.isArray(object?.fields)) obj.fields = object.fields.map((e: any) => Field.fromJSON(e)); + if (Array.isArray(object?.oneofs)) obj.oneofs = object.oneofs.map((e: any) => String(e)); + if (Array.isArray(object?.options)) obj.options = object.options.map((e: any) => Option.fromJSON(e)); + if (isSet(object.sourceContext)) obj.sourceContext = SourceContext.fromJSON(object.sourceContext); + if (isSet(object.syntax)) obj.syntax = syntaxFromJSON(object.syntax); + return obj; + }, + toJSON(message: Type): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.fields) { + obj.fields = message.fields.map(e => e ? Field.toJSON(e) : undefined); + } else { + obj.fields = []; + } + if (message.oneofs) { + obj.oneofs = message.oneofs.map(e => e); + } else { + obj.oneofs = []; + } + if (message.options) { + obj.options = message.options.map(e => e ? Option.toJSON(e) : undefined); + } else { + obj.options = []; + } + message.sourceContext !== undefined && (obj.sourceContext = message.sourceContext ? SourceContext.toJSON(message.sourceContext) : undefined); + message.syntax !== undefined && (obj.syntax = syntaxToJSON(message.syntax)); + return obj; + }, + fromPartial(object: DeepPartial): Type { + const message = createBaseType(); + message.name = object.name ?? ""; + message.fields = object.fields?.map(e => Field.fromPartial(e)) || []; + message.oneofs = object.oneofs?.map(e => e) || []; + message.options = object.options?.map(e => Option.fromPartial(e)) || []; + if (object.sourceContext !== undefined && object.sourceContext !== null) { + message.sourceContext = SourceContext.fromPartial(object.sourceContext); + } + message.syntax = object.syntax ?? 0; + return message; + }, + fromSDK(object: TypeSDKType): Type { + return { + name: object?.name, + fields: Array.isArray(object?.fields) ? object.fields.map((e: any) => Field.fromSDK(e)) : [], + oneofs: Array.isArray(object?.oneofs) ? object.oneofs.map((e: any) => e) : [], + options: Array.isArray(object?.options) ? object.options.map((e: any) => Option.fromSDK(e)) : [], + sourceContext: object.source_context ? SourceContext.fromSDK(object.source_context) : undefined, + syntax: isSet(object.syntax) ? syntaxFromJSON(object.syntax) : -1 + }; + }, + fromSDKJSON(object: any): TypeSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + fields: Array.isArray(object?.fields) ? object.fields.map((e: any) => Field.fromSDKJSON(e)) : [], + oneofs: Array.isArray(object?.oneofs) ? object.oneofs.map((e: any) => String(e)) : [], + options: Array.isArray(object?.options) ? object.options.map((e: any) => Option.fromSDKJSON(e)) : [], + source_context: isSet(object.source_context) ? SourceContext.fromSDKJSON(object.source_context) : undefined, + syntax: isSet(object.syntax) ? syntaxFromJSON(object.syntax) : -1 + }; + }, + toSDK(message: Type): TypeSDKType { + const obj: any = {}; + obj.name = message.name; + if (message.fields) { + obj.fields = message.fields.map(e => e ? Field.toSDK(e) : undefined); + } else { + obj.fields = []; + } + if (message.oneofs) { + obj.oneofs = message.oneofs.map(e => e); + } else { + obj.oneofs = []; + } + if (message.options) { + obj.options = message.options.map(e => e ? Option.toSDK(e) : undefined); + } else { + obj.options = []; + } + message.sourceContext !== undefined && (obj.source_context = message.sourceContext ? SourceContext.toSDK(message.sourceContext) : undefined); + message.syntax !== undefined && (obj.syntax = syntaxToJSON(message.syntax)); + return obj; + }, + fromAmino(object: TypeAmino): Type { + const message = createBaseType(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + message.fields = object.fields?.map(e => Field.fromAmino(e)) || []; + message.oneofs = object.oneofs?.map(e => e) || []; + message.options = object.options?.map(e => Option.fromAmino(e)) || []; + if (object.source_context !== undefined && object.source_context !== null) { + message.sourceContext = SourceContext.fromAmino(object.source_context); + } + if (object.syntax !== undefined && object.syntax !== null) { + message.syntax = object.syntax; + } + return message; + }, + toAmino(message: Type): TypeAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + if (message.fields) { + obj.fields = message.fields.map(e => e ? Field.toAmino(e) : undefined); + } else { + obj.fields = message.fields; + } + if (message.oneofs) { + obj.oneofs = message.oneofs.map(e => e); + } else { + obj.oneofs = message.oneofs; + } + if (message.options) { + obj.options = message.options.map(e => e ? Option.toAmino(e) : undefined); + } else { + obj.options = message.options; + } + obj.source_context = message.sourceContext ? SourceContext.toAmino(message.sourceContext) : undefined; + obj.syntax = message.syntax === 0 ? undefined : message.syntax; + return obj; + }, + fromAminoMsg(object: TypeAminoMsg): Type { + return Type.fromAmino(object.value); + }, + fromProtoMsg(message: TypeProtoMsg): Type { + return Type.decode(message.value); + }, + toProto(message: Type): Uint8Array { + return Type.encode(message).finish(); + }, + toProtoMsg(message: Type): TypeProtoMsg { + return { + typeUrl: "/google.protobuf.Type", + value: Type.encode(message).finish() + }; + } +}; +function createBaseField(): Field { + return { + kind: 0, + cardinality: 0, + number: 0, + name: "", + typeUrl: "", + oneofIndex: 0, + packed: false, + options: [], + jsonName: "", + defaultValue: "" + }; +} +export const Field = { + typeUrl: "/google.protobuf.Field", + encode(message: Field, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.kind !== 0) { + writer.uint32(8).int32(message.kind); + } + if (message.cardinality !== 0) { + writer.uint32(16).int32(message.cardinality); + } + if (message.number !== undefined) { + writer.uint32(24).int32(message.number); + } + if (message.name !== undefined) { + writer.uint32(34).string(message.name); + } + if (message.typeUrl !== undefined) { + writer.uint32(50).string(message.typeUrl); + } + if (message.oneofIndex !== undefined) { + writer.uint32(56).int32(message.oneofIndex); + } + if (message.packed !== undefined) { + writer.uint32(64).bool(message.packed); + } + for (const v of message.options) { + Option.encode(v!, writer.uint32(74).fork()).ldelim(); + } + if (message.jsonName !== undefined) { + writer.uint32(82).string(message.jsonName); + } + if (message.defaultValue !== undefined) { + writer.uint32(90).string(message.defaultValue); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Field { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseField(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.kind = (reader.int32() as any); + break; + case 2: + message.cardinality = (reader.int32() as any); + break; + case 3: + message.number = reader.int32(); + break; + case 4: + message.name = reader.string(); + break; + case 6: + message.typeUrl = reader.string(); + break; + case 7: + message.oneofIndex = reader.int32(); + break; + case 8: + message.packed = reader.bool(); + break; + case 9: + message.options.push(Option.decode(reader, reader.uint32())); + break; + case 10: + message.jsonName = reader.string(); + break; + case 11: + message.defaultValue = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Field { + const obj = createBaseField(); + if (isSet(object.kind)) obj.kind = field_KindFromJSON(object.kind); + if (isSet(object.cardinality)) obj.cardinality = field_CardinalityFromJSON(object.cardinality); + if (isSet(object.number)) obj.number = Number(object.number); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.typeUrl)) obj.typeUrl = String(object.typeUrl); + if (isSet(object.oneofIndex)) obj.oneofIndex = Number(object.oneofIndex); + if (isSet(object.packed)) obj.packed = Boolean(object.packed); + if (Array.isArray(object?.options)) obj.options = object.options.map((e: any) => Option.fromJSON(e)); + if (isSet(object.jsonName)) obj.jsonName = String(object.jsonName); + if (isSet(object.defaultValue)) obj.defaultValue = String(object.defaultValue); + return obj; + }, + toJSON(message: Field): JsonSafe { + const obj: any = {}; + message.kind !== undefined && (obj.kind = field_KindToJSON(message.kind)); + message.cardinality !== undefined && (obj.cardinality = field_CardinalityToJSON(message.cardinality)); + message.number !== undefined && (obj.number = Math.round(message.number)); + message.name !== undefined && (obj.name = message.name); + message.typeUrl !== undefined && (obj.typeUrl = message.typeUrl); + message.oneofIndex !== undefined && (obj.oneofIndex = Math.round(message.oneofIndex)); + message.packed !== undefined && (obj.packed = message.packed); + if (message.options) { + obj.options = message.options.map(e => e ? Option.toJSON(e) : undefined); + } else { + obj.options = []; + } + message.jsonName !== undefined && (obj.jsonName = message.jsonName); + message.defaultValue !== undefined && (obj.defaultValue = message.defaultValue); + return obj; + }, + fromPartial(object: DeepPartial): Field { + const message = createBaseField(); + message.kind = object.kind ?? 0; + message.cardinality = object.cardinality ?? 0; + message.number = object.number ?? 0; + message.name = object.name ?? ""; + message.typeUrl = object.typeUrl ?? ""; + message.oneofIndex = object.oneofIndex ?? 0; + message.packed = object.packed ?? false; + message.options = object.options?.map(e => Option.fromPartial(e)) || []; + message.jsonName = object.jsonName ?? ""; + message.defaultValue = object.defaultValue ?? ""; + return message; + }, + fromSDK(object: FieldSDKType): Field { + return { + kind: isSet(object.kind) ? field_KindFromJSON(object.kind) : -1, + cardinality: isSet(object.cardinality) ? field_CardinalityFromJSON(object.cardinality) : -1, + number: object?.number, + name: object?.name, + typeUrl: object?.type_url, + oneofIndex: object?.oneof_index, + packed: object?.packed, + options: Array.isArray(object?.options) ? object.options.map((e: any) => Option.fromSDK(e)) : [], + jsonName: object?.json_name, + defaultValue: object?.default_value + }; + }, + fromSDKJSON(object: any): FieldSDKType { + return { + kind: isSet(object.kind) ? field_KindFromJSON(object.kind) : -1, + cardinality: isSet(object.cardinality) ? field_CardinalityFromJSON(object.cardinality) : -1, + number: isSet(object.number) ? Number(object.number) : 0, + name: isSet(object.name) ? String(object.name) : "", + type_url: isSet(object.type_url) ? String(object.type_url) : "", + oneof_index: isSet(object.oneof_index) ? Number(object.oneof_index) : 0, + packed: isSet(object.packed) ? Boolean(object.packed) : false, + options: Array.isArray(object?.options) ? object.options.map((e: any) => Option.fromSDKJSON(e)) : [], + json_name: isSet(object.json_name) ? String(object.json_name) : "", + default_value: isSet(object.default_value) ? String(object.default_value) : "" + }; + }, + toSDK(message: Field): FieldSDKType { + const obj: any = {}; + message.kind !== undefined && (obj.kind = field_KindToJSON(message.kind)); + message.cardinality !== undefined && (obj.cardinality = field_CardinalityToJSON(message.cardinality)); + obj.number = message.number; + obj.name = message.name; + obj.type_url = message.typeUrl; + obj.oneof_index = message.oneofIndex; + obj.packed = message.packed; + if (message.options) { + obj.options = message.options.map(e => e ? Option.toSDK(e) : undefined); + } else { + obj.options = []; + } + obj.json_name = message.jsonName; + obj.default_value = message.defaultValue; + return obj; + }, + fromAmino(object: FieldAmino): Field { + const message = createBaseField(); + if (object.kind !== undefined && object.kind !== null) { + message.kind = object.kind; + } + if (object.cardinality !== undefined && object.cardinality !== null) { + message.cardinality = object.cardinality; + } + if (object.number !== undefined && object.number !== null) { + message.number = object.number; + } + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + if (object.type_url !== undefined && object.type_url !== null) { + message.typeUrl = object.type_url; + } + if (object.oneof_index !== undefined && object.oneof_index !== null) { + message.oneofIndex = object.oneof_index; + } + if (object.packed !== undefined && object.packed !== null) { + message.packed = object.packed; + } + message.options = object.options?.map(e => Option.fromAmino(e)) || []; + if (object.json_name !== undefined && object.json_name !== null) { + message.jsonName = object.json_name; + } + if (object.default_value !== undefined && object.default_value !== null) { + message.defaultValue = object.default_value; + } + return message; + }, + toAmino(message: Field): FieldAmino { + const obj: any = {}; + obj.kind = message.kind === 0 ? undefined : message.kind; + obj.cardinality = message.cardinality === 0 ? undefined : message.cardinality; + obj.number = message.number === 0 ? undefined : message.number; + obj.name = message.name === "" ? undefined : message.name; + obj.type_url = message.typeUrl === "" ? undefined : message.typeUrl; + obj.oneof_index = message.oneofIndex === 0 ? undefined : message.oneofIndex; + obj.packed = message.packed === false ? undefined : message.packed; + if (message.options) { + obj.options = message.options.map(e => e ? Option.toAmino(e) : undefined); + } else { + obj.options = message.options; + } + obj.json_name = message.jsonName === "" ? undefined : message.jsonName; + obj.default_value = message.defaultValue === "" ? undefined : message.defaultValue; + return obj; + }, + fromAminoMsg(object: FieldAminoMsg): Field { + return Field.fromAmino(object.value); + }, + fromProtoMsg(message: FieldProtoMsg): Field { + return Field.decode(message.value); + }, + toProto(message: Field): Uint8Array { + return Field.encode(message).finish(); + }, + toProtoMsg(message: Field): FieldProtoMsg { + return { + typeUrl: "/google.protobuf.Field", + value: Field.encode(message).finish() + }; + } +}; +function createBaseEnum(): Enum { + return { + name: "", + enumvalue: [], + options: [], + sourceContext: undefined, + syntax: 0 + }; +} +export const Enum = { + typeUrl: "/google.protobuf.Enum", + encode(message: Enum, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + for (const v of message.enumvalue) { + EnumValue.encode(v!, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.options) { + Option.encode(v!, writer.uint32(26).fork()).ldelim(); + } + if (message.sourceContext !== undefined) { + SourceContext.encode(message.sourceContext, writer.uint32(34).fork()).ldelim(); + } + if (message.syntax !== 0) { + writer.uint32(40).int32(message.syntax); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Enum { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseEnum(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.enumvalue.push(EnumValue.decode(reader, reader.uint32())); + break; + case 3: + message.options.push(Option.decode(reader, reader.uint32())); + break; + case 4: + message.sourceContext = SourceContext.decode(reader, reader.uint32()); + break; + case 5: + message.syntax = (reader.int32() as any); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Enum { + const obj = createBaseEnum(); + if (isSet(object.name)) obj.name = String(object.name); + if (Array.isArray(object?.enumvalue)) obj.enumvalue = object.enumvalue.map((e: any) => EnumValue.fromJSON(e)); + if (Array.isArray(object?.options)) obj.options = object.options.map((e: any) => Option.fromJSON(e)); + if (isSet(object.sourceContext)) obj.sourceContext = SourceContext.fromJSON(object.sourceContext); + if (isSet(object.syntax)) obj.syntax = syntaxFromJSON(object.syntax); + return obj; + }, + toJSON(message: Enum): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.enumvalue) { + obj.enumvalue = message.enumvalue.map(e => e ? EnumValue.toJSON(e) : undefined); + } else { + obj.enumvalue = []; + } + if (message.options) { + obj.options = message.options.map(e => e ? Option.toJSON(e) : undefined); + } else { + obj.options = []; + } + message.sourceContext !== undefined && (obj.sourceContext = message.sourceContext ? SourceContext.toJSON(message.sourceContext) : undefined); + message.syntax !== undefined && (obj.syntax = syntaxToJSON(message.syntax)); + return obj; + }, + fromPartial(object: DeepPartial): Enum { + const message = createBaseEnum(); + message.name = object.name ?? ""; + message.enumvalue = object.enumvalue?.map(e => EnumValue.fromPartial(e)) || []; + message.options = object.options?.map(e => Option.fromPartial(e)) || []; + if (object.sourceContext !== undefined && object.sourceContext !== null) { + message.sourceContext = SourceContext.fromPartial(object.sourceContext); + } + message.syntax = object.syntax ?? 0; + return message; + }, + fromSDK(object: EnumSDKType): Enum { + return { + name: object?.name, + enumvalue: Array.isArray(object?.enumvalue) ? object.enumvalue.map((e: any) => EnumValue.fromSDK(e)) : [], + options: Array.isArray(object?.options) ? object.options.map((e: any) => Option.fromSDK(e)) : [], + sourceContext: object.source_context ? SourceContext.fromSDK(object.source_context) : undefined, + syntax: isSet(object.syntax) ? syntaxFromJSON(object.syntax) : -1 + }; + }, + fromSDKJSON(object: any): EnumSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + enumvalue: Array.isArray(object?.enumvalue) ? object.enumvalue.map((e: any) => EnumValue.fromSDKJSON(e)) : [], + options: Array.isArray(object?.options) ? object.options.map((e: any) => Option.fromSDKJSON(e)) : [], + source_context: isSet(object.source_context) ? SourceContext.fromSDKJSON(object.source_context) : undefined, + syntax: isSet(object.syntax) ? syntaxFromJSON(object.syntax) : -1 + }; + }, + toSDK(message: Enum): EnumSDKType { + const obj: any = {}; + obj.name = message.name; + if (message.enumvalue) { + obj.enumvalue = message.enumvalue.map(e => e ? EnumValue.toSDK(e) : undefined); + } else { + obj.enumvalue = []; + } + if (message.options) { + obj.options = message.options.map(e => e ? Option.toSDK(e) : undefined); + } else { + obj.options = []; + } + message.sourceContext !== undefined && (obj.source_context = message.sourceContext ? SourceContext.toSDK(message.sourceContext) : undefined); + message.syntax !== undefined && (obj.syntax = syntaxToJSON(message.syntax)); + return obj; + }, + fromAmino(object: EnumAmino): Enum { + const message = createBaseEnum(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + message.enumvalue = object.enumvalue?.map(e => EnumValue.fromAmino(e)) || []; + message.options = object.options?.map(e => Option.fromAmino(e)) || []; + if (object.source_context !== undefined && object.source_context !== null) { + message.sourceContext = SourceContext.fromAmino(object.source_context); + } + if (object.syntax !== undefined && object.syntax !== null) { + message.syntax = object.syntax; + } + return message; + }, + toAmino(message: Enum): EnumAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + if (message.enumvalue) { + obj.enumvalue = message.enumvalue.map(e => e ? EnumValue.toAmino(e) : undefined); + } else { + obj.enumvalue = message.enumvalue; + } + if (message.options) { + obj.options = message.options.map(e => e ? Option.toAmino(e) : undefined); + } else { + obj.options = message.options; + } + obj.source_context = message.sourceContext ? SourceContext.toAmino(message.sourceContext) : undefined; + obj.syntax = message.syntax === 0 ? undefined : message.syntax; + return obj; + }, + fromAminoMsg(object: EnumAminoMsg): Enum { + return Enum.fromAmino(object.value); + }, + fromProtoMsg(message: EnumProtoMsg): Enum { + return Enum.decode(message.value); + }, + toProto(message: Enum): Uint8Array { + return Enum.encode(message).finish(); + }, + toProtoMsg(message: Enum): EnumProtoMsg { + return { + typeUrl: "/google.protobuf.Enum", + value: Enum.encode(message).finish() + }; + } +}; +function createBaseEnumValue(): EnumValue { + return { + name: "", + number: 0, + options: [] + }; +} +export const EnumValue = { + typeUrl: "/google.protobuf.EnumValue", + encode(message: EnumValue, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + if (message.number !== undefined) { + writer.uint32(16).int32(message.number); + } + for (const v of message.options) { + Option.encode(v!, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): EnumValue { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseEnumValue(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.number = reader.int32(); + break; + case 3: + message.options.push(Option.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): EnumValue { + const obj = createBaseEnumValue(); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.number)) obj.number = Number(object.number); + if (Array.isArray(object?.options)) obj.options = object.options.map((e: any) => Option.fromJSON(e)); + return obj; + }, + toJSON(message: EnumValue): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.number !== undefined && (obj.number = Math.round(message.number)); + if (message.options) { + obj.options = message.options.map(e => e ? Option.toJSON(e) : undefined); + } else { + obj.options = []; + } + return obj; + }, + fromPartial(object: DeepPartial): EnumValue { + const message = createBaseEnumValue(); + message.name = object.name ?? ""; + message.number = object.number ?? 0; + message.options = object.options?.map(e => Option.fromPartial(e)) || []; + return message; + }, + fromSDK(object: EnumValueSDKType): EnumValue { + return { + name: object?.name, + number: object?.number, + options: Array.isArray(object?.options) ? object.options.map((e: any) => Option.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): EnumValueSDKType { + return { + name: isSet(object.name) ? String(object.name) : "", + number: isSet(object.number) ? Number(object.number) : 0, + options: Array.isArray(object?.options) ? object.options.map((e: any) => Option.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: EnumValue): EnumValueSDKType { + const obj: any = {}; + obj.name = message.name; + obj.number = message.number; + if (message.options) { + obj.options = message.options.map(e => e ? Option.toSDK(e) : undefined); + } else { + obj.options = []; + } + return obj; + }, + fromAmino(object: EnumValueAmino): EnumValue { + const message = createBaseEnumValue(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + if (object.number !== undefined && object.number !== null) { + message.number = object.number; + } + message.options = object.options?.map(e => Option.fromAmino(e)) || []; + return message; + }, + toAmino(message: EnumValue): EnumValueAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + obj.number = message.number === 0 ? undefined : message.number; + if (message.options) { + obj.options = message.options.map(e => e ? Option.toAmino(e) : undefined); + } else { + obj.options = message.options; + } + return obj; + }, + fromAminoMsg(object: EnumValueAminoMsg): EnumValue { + return EnumValue.fromAmino(object.value); + }, + fromProtoMsg(message: EnumValueProtoMsg): EnumValue { + return EnumValue.decode(message.value); + }, + toProto(message: EnumValue): Uint8Array { + return EnumValue.encode(message).finish(); + }, + toProtoMsg(message: EnumValue): EnumValueProtoMsg { + return { + typeUrl: "/google.protobuf.EnumValue", + value: EnumValue.encode(message).finish() + }; + } +}; +function createBaseOption(): Option { + return { + name: "", + value: undefined + }; +} +export const Option = { + typeUrl: "/google.protobuf.Option", + encode(message: Option, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== undefined) { + writer.uint32(10).string(message.name); + } + if (message.value !== undefined) { + Any.encode(message.value, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): Option { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseOption(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.value = Any.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): Option { + const obj = createBaseOption(); + if (isSet(object.name)) obj.name = String(object.name); + if (isSet(object.value)) obj.value = Any.fromJSON(object.value); + return obj; + }, + toJSON(message: Option): JsonSafe