From b317d1f9dfa794d73dadb124047608d9e2b38f67 Mon Sep 17 00:00:00 2001 From: j-yw <32629001+j-yw@users.noreply.github.com> Date: Sat, 14 Sep 2024 22:16:35 +0800 Subject: [PATCH] chore: bundle new fixture outputs --- __fixtures__/misc/output-base64/binary.ts | 534 ++ __fixtures__/misc/output-base64/extern.ts | 33 + .../misc/output-base64/gogoproto/bundle.ts | 4 + .../misc/output-base64/gogoproto/gogo.ts | 1 + .../google/api/expr/v1alpha1/eval.ts | 228 + .../misc/output-base64/google/bundle.ts | 20 + .../misc/output-base64/google/protobuf/any.ts | 433 ++ .../google/protobuf/descriptor.ts | 6805 +++++++++++++++++ .../output-base64/google/protobuf/duration.ts | 315 + .../google/protobuf/timestamp.ts | 381 + __fixtures__/misc/output-base64/helpers.ts | 255 + __fixtures__/misc/output-base64/index.ts | 18 + __fixtures__/misc/output-base64/json-safe.ts | 14 + .../misc/output-base64/misc/all_fields.ts | 2739 +++++++ .../misc/output-base64/misc/bundle.ts | 20 + .../misc/output-base64/misc/client.ts | 47 + .../misc/output-base64/misc/eval_request.ts | 952 +++ __fixtures__/misc/output-base64/misc/nest.ts | 214 + .../misc/output-base64/misc/rpc.tx.ts | 8 + .../misc/output-base64/misc/tx.amino.ts | 9 + .../misc/output-base64/misc/tx.registry.ts | 51 + .../misc/output-base64/misc/tx.rpc.msg.ts | 23 + __fixtures__/misc/output-base64/misc/tx.ts | 228 + __fixtures__/misc/output-base64/mobx.ts | 82 + .../misc/output-base64/pinia-endpoint.ts | 22 + .../misc/output-base64/react-query.ts | 71 + __fixtures__/misc/output-base64/utf8.ts | 148 + __fixtures__/misc/output-base64/varint.ts | 488 ++ 28 files changed, 14143 insertions(+) create mode 100644 __fixtures__/misc/output-base64/binary.ts create mode 100644 __fixtures__/misc/output-base64/extern.ts create mode 100644 __fixtures__/misc/output-base64/gogoproto/bundle.ts create mode 100644 __fixtures__/misc/output-base64/gogoproto/gogo.ts create mode 100644 __fixtures__/misc/output-base64/google/api/expr/v1alpha1/eval.ts create mode 100644 __fixtures__/misc/output-base64/google/bundle.ts create mode 100644 __fixtures__/misc/output-base64/google/protobuf/any.ts create mode 100644 __fixtures__/misc/output-base64/google/protobuf/descriptor.ts create mode 100644 __fixtures__/misc/output-base64/google/protobuf/duration.ts create mode 100644 __fixtures__/misc/output-base64/google/protobuf/timestamp.ts create mode 100644 __fixtures__/misc/output-base64/helpers.ts create mode 100644 __fixtures__/misc/output-base64/index.ts create mode 100644 __fixtures__/misc/output-base64/json-safe.ts create mode 100644 __fixtures__/misc/output-base64/misc/all_fields.ts create mode 100644 __fixtures__/misc/output-base64/misc/bundle.ts create mode 100644 __fixtures__/misc/output-base64/misc/client.ts create mode 100644 __fixtures__/misc/output-base64/misc/eval_request.ts create mode 100644 __fixtures__/misc/output-base64/misc/nest.ts create mode 100644 __fixtures__/misc/output-base64/misc/rpc.tx.ts create mode 100644 __fixtures__/misc/output-base64/misc/tx.amino.ts create mode 100644 __fixtures__/misc/output-base64/misc/tx.registry.ts create mode 100644 __fixtures__/misc/output-base64/misc/tx.rpc.msg.ts create mode 100644 __fixtures__/misc/output-base64/misc/tx.ts create mode 100644 __fixtures__/misc/output-base64/mobx.ts create mode 100644 __fixtures__/misc/output-base64/pinia-endpoint.ts create mode 100644 __fixtures__/misc/output-base64/react-query.ts create mode 100644 __fixtures__/misc/output-base64/utf8.ts create mode 100644 __fixtures__/misc/output-base64/varint.ts diff --git a/__fixtures__/misc/output-base64/binary.ts b/__fixtures__/misc/output-base64/binary.ts new file mode 100644 index 0000000000..85549bde0e --- /dev/null +++ b/__fixtures__/misc/output-base64/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"; +import { + int64ToString, + readInt32, + readUInt32, + uInt64ToString, + varint32read, + varint64read, + writeVarint32, + writeVarint64, + int64FromString, + int64Length, + writeFixed32, + writeByte, + zzDecode, + zzEncode, +} from "./varint"; + +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__/misc/output-base64/extern.ts b/__fixtures__/misc/output-base64/extern.ts new file mode 100644 index 0000000000..f60ecaf86f --- /dev/null +++ b/__fixtures__/misc/output-base64/extern.ts @@ -0,0 +1,33 @@ +/** +* 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 { Tendermint34Client, 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 tmClient = await Tendermint34Client.connect(rpcEndpoint); + //@ts-ignore + const client = new QueryClient(tmClient); + const rpc = createProtobufRpcClient(client); + _rpcClients[key] = rpc; + return rpc; +} diff --git a/__fixtures__/misc/output-base64/gogoproto/bundle.ts b/__fixtures__/misc/output-base64/gogoproto/bundle.ts new file mode 100644 index 0000000000..727e551de9 --- /dev/null +++ b/__fixtures__/misc/output-base64/gogoproto/bundle.ts @@ -0,0 +1,4 @@ +import * as _184 from "./gogo"; +export const gogoproto = { + ..._184 +}; \ No newline at end of file diff --git a/__fixtures__/misc/output-base64/gogoproto/gogo.ts b/__fixtures__/misc/output-base64/gogoproto/gogo.ts new file mode 100644 index 0000000000..693da49fc4 --- /dev/null +++ b/__fixtures__/misc/output-base64/gogoproto/gogo.ts @@ -0,0 +1 @@ +export {} \ No newline at end of file diff --git a/__fixtures__/misc/output-base64/google/api/expr/v1alpha1/eval.ts b/__fixtures__/misc/output-base64/google/api/expr/v1alpha1/eval.ts new file mode 100644 index 0000000000..d154618421 --- /dev/null +++ b/__fixtures__/misc/output-base64/google/api/expr/v1alpha1/eval.ts @@ -0,0 +1,228 @@ +import { BinaryReader, BinaryWriter } from "../../../../binary"; +import { JsonSafe } from "../../../../json-safe"; +import { DeepPartial, isSet } from "../../../../helpers"; +export const protobufPackage = "google.api.expr.v1alpha1"; +export interface ExprValue { + /** The ids of the expressions with unknown values. */ + exprs: IdRef[]; +} +export interface ExprValueProtoMsg { + typeUrl: "/google.api.expr.v1alpha1.ExprValue"; + value: Uint8Array; +} +export interface ExprValueAmino { + /** The ids of the expressions with unknown values. */ + exprs?: IdRefAmino[]; +} +export interface ExprValueAminoMsg { + type: "/google.api.expr.v1alpha1.ExprValue"; + value: ExprValueAmino; +} +export interface ExprValueSDKType { + exprs: IdRefSDKType[]; +} +export interface IdRef { + /** The expression id. */ + id: number; +} +export interface IdRefProtoMsg { + typeUrl: "/google.api.expr.v1alpha1.IdRef"; + value: Uint8Array; +} +export interface IdRefAmino { + /** The expression id. */ + id?: number; +} +export interface IdRefAminoMsg { + type: "/google.api.expr.v1alpha1.IdRef"; + value: IdRefAmino; +} +export interface IdRefSDKType { + id: number; +} +function createBaseExprValue(): ExprValue { + return { + exprs: [] + }; +} +export const ExprValue = { + typeUrl: "/google.api.expr.v1alpha1.ExprValue", + encode(message: ExprValue, 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): 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.exprs.push(IdRef.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): ExprValue { + const obj = createBaseExprValue(); + if (Array.isArray(object?.exprs)) obj.exprs = object.exprs.map((e: any) => IdRef.fromJSON(e)); + return obj; + }, + toJSON(message: ExprValue): 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): ExprValue { + const message = createBaseExprValue(); + message.exprs = object.exprs?.map(e => IdRef.fromPartial(e)) || []; + return message; + }, + fromSDK(object: ExprValueSDKType): ExprValue { + return { + exprs: Array.isArray(object?.exprs) ? object.exprs.map((e: any) => IdRef.fromSDK(e)) : [] + }; + }, + fromSDKJSON(object: any): ExprValueSDKType { + return { + exprs: Array.isArray(object?.exprs) ? object.exprs.map((e: any) => IdRef.fromSDKJSON(e)) : [] + }; + }, + toSDK(message: ExprValue): ExprValueSDKType { + const obj: any = {}; + if (message.exprs) { + obj.exprs = message.exprs.map(e => e ? IdRef.toSDK(e) : undefined); + } else { + obj.exprs = []; + } + return obj; + }, + fromAmino(object: ExprValueAmino): ExprValue { + const message = createBaseExprValue(); + message.exprs = object.exprs?.map(e => IdRef.fromAmino(e)) || []; + return message; + }, + toAmino(message: ExprValue): ExprValueAmino { + 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: 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 createBaseIdRef(): IdRef { + return { + id: 0 + }; +} +export const IdRef = { + typeUrl: "/google.api.expr.v1alpha1.IdRef", + encode(message: IdRef, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.id !== 0) { + 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.v1alpha1.IdRef", + value: IdRef.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/misc/output-base64/google/bundle.ts b/__fixtures__/misc/output-base64/google/bundle.ts new file mode 100644 index 0000000000..736c53a744 --- /dev/null +++ b/__fixtures__/misc/output-base64/google/bundle.ts @@ -0,0 +1,20 @@ +import * as _185 from "./api/expr/v1alpha1/eval"; +import * as _186 from "./protobuf/any"; +import * as _187 from "./protobuf/descriptor"; +import * as _188 from "./protobuf/duration"; +import * as _189 from "./protobuf/timestamp"; +export namespace google { + export namespace api { + export namespace expr { + export const v1alpha1 = { + ..._185 + }; + } + } + export const protobuf = { + ..._186, + ..._187, + ..._188, + ..._189 + }; +} \ No newline at end of file diff --git a/__fixtures__/misc/output-base64/google/protobuf/any.ts b/__fixtures__/misc/output-base64/google/protobuf/any.ts new file mode 100644 index 0000000000..49d4bc52c3 --- /dev/null +++ b/__fixtures__/misc/output-base64/google/protobuf/any.ts @@ -0,0 +1,433 @@ +import { BinaryReader, BinaryWriter } from "../../binary"; +import { isSet, DeepPartial } from "../../helpers"; +import { encodeBase64 as bytesFromBase64 } from "@endo/base64"; +import { decodeBase64 as base64FromBytes } from "@endo/base64"; +import { JsonSafe } from "../../json-safe"; +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 AnyAmino { + /** + * 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. + */ + type: string; + /** Must be a valid serialized protocol buffer of the above specified type. */ + value: any; +} +export interface AnyAminoMsg { + type: string; + value: AnyAmino; +} +/** + * `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 !== "") { + 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__/misc/output-base64/google/protobuf/descriptor.ts b/__fixtures__/misc/output-base64/google/protobuf/descriptor.ts new file mode 100644 index 0000000000..5a83869b14 --- /dev/null +++ b/__fixtures__/misc/output-base64/google/protobuf/descriptor.ts @@ -0,0 +1,6805 @@ +import { BinaryReader, BinaryWriter } from "../../binary"; +import { JsonSafe } from "../../json-safe"; +import { DeepPartial, isSet } from "../../helpers"; +import { encodeBase64 as bytesFromBase64 } from "@endo/base64"; +import { decodeBase64 as base64FromBytes } from "@endo/base64"; +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 const FieldDescriptorProto_TypeAmino = 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 const FieldDescriptorProto_LabelAmino = 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 const FileOptions_OptimizeModeAmino = 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 const FieldOptions_CTypeAmino = 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 const FieldOptions_JSTypeAmino = 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 const MethodOptions_IdempotencyLevelAmino = 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"; + } +} +export enum FeatureSet_Utf8Validation { + SMALLEST = -2, + UTF8_VALIDATION_UNKNOWN = 0, + VERIFY = 2, + NONE = 3, + UNRECOGNIZED = -1, +} +export const FeatureSet_Utf8ValidationSDKType = FeatureSet_Utf8Validation; +export const FeatureSet_Utf8ValidationAmino = FeatureSet_Utf8Validation; +export function featureSet_Utf8ValidationFromJSON(object: any): FeatureSet_Utf8Validation { + switch (object) { + case -2: + case "SMALLEST": + return FeatureSet_Utf8Validation.SMALLEST; + case 0: + case "UTF8_VALIDATION_UNKNOWN": + return FeatureSet_Utf8Validation.UTF8_VALIDATION_UNKNOWN; + case 2: + case "VERIFY": + return FeatureSet_Utf8Validation.VERIFY; + case 3: + case "NONE": + return FeatureSet_Utf8Validation.NONE; + case -1: + case "UNRECOGNIZED": + default: + return FeatureSet_Utf8Validation.UNRECOGNIZED; + } +} +export function featureSet_Utf8ValidationToJSON(object: FeatureSet_Utf8Validation): string { + switch (object) { + case FeatureSet_Utf8Validation.SMALLEST: + return "SMALLEST"; + case FeatureSet_Utf8Validation.UTF8_VALIDATION_UNKNOWN: + return "UTF8_VALIDATION_UNKNOWN"; + case FeatureSet_Utf8Validation.VERIFY: + return "VERIFY"; + case FeatureSet_Utf8Validation.NONE: + return "NONE"; + case FeatureSet_Utf8Validation.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 FileDescriptorSetAmino { + file?: FileDescriptorProtoAmino[]; +} +export interface FileDescriptorSetAminoMsg { + type: "/google.protobuf.FileDescriptorSet"; + value: FileDescriptorSetAmino; +} +/** + * 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 FileDescriptorProtoAmino { + /** 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. */ + public_dependency?: number[]; + /** + * Indexes of the weak imported files in the dependency list. + * For Google-internal migration only. Do not use. + */ + weak_dependency?: number[]; + /** All top-level definitions in this file. */ + message_type?: DescriptorProtoAmino[]; + enum_type?: EnumDescriptorProtoAmino[]; + service?: ServiceDescriptorProtoAmino[]; + extension?: FieldDescriptorProtoAmino[]; + options?: FileOptionsAmino; + /** + * 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. + */ + source_code_info?: SourceCodeInfoAmino; + /** + * The syntax of the proto file. + * The supported values are "proto2" and "proto3". + */ + syntax?: string; +} +export interface FileDescriptorProtoAminoMsg { + type: "/google.protobuf.FileDescriptorProto"; + value: FileDescriptorProtoAmino; +} +/** 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 DescriptorProtoAmino { + name?: string; + field?: FieldDescriptorProtoAmino[]; + extension?: FieldDescriptorProtoAmino[]; + nested_type?: DescriptorProtoAmino[]; + enum_type?: EnumDescriptorProtoAmino[]; + extension_range?: DescriptorProto_ExtensionRangeAmino[]; + oneof_decl?: OneofDescriptorProtoAmino[]; + options?: MessageOptionsAmino; + reserved_range?: DescriptorProto_ReservedRangeAmino[]; + /** + * Reserved field names, which may not be used by fields in the same message. + * A given name may only be reserved once. + */ + reserved_name?: string[]; +} +export interface DescriptorProtoAminoMsg { + type: "/google.protobuf.DescriptorProto"; + value: DescriptorProtoAmino; +} +/** 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_ExtensionRangeAmino { + /** Inclusive. */ + start?: number; + /** Exclusive. */ + end?: number; + options?: ExtensionRangeOptionsAmino; +} +export interface DescriptorProto_ExtensionRangeAminoMsg { + type: "/google.protobuf.ExtensionRange"; + value: DescriptorProto_ExtensionRangeAmino; +} +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_ReservedRangeAmino { + /** Inclusive. */ + start?: number; + /** Exclusive. */ + end?: number; +} +export interface DescriptorProto_ReservedRangeAminoMsg { + type: "/google.protobuf.ReservedRange"; + value: DescriptorProto_ReservedRangeAmino; +} +/** + * 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 ExtensionRangeOptionsAmino { + /** The parser stores options it doesn't recognize here. See above. */ + uninterpreted_option?: UninterpretedOptionAmino[]; +} +export interface ExtensionRangeOptionsAminoMsg { + type: "/google.protobuf.ExtensionRangeOptions"; + value: ExtensionRangeOptionsAmino; +} +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 FieldDescriptorProtoAmino { + 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). + */ + type_name?: 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? + */ + default_value?: 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. + */ + oneof_index?: 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. + */ + json_name?: string; + options?: FieldOptionsAmino; +} +export interface FieldDescriptorProtoAminoMsg { + type: "/google.protobuf.FieldDescriptorProto"; + value: FieldDescriptorProtoAmino; +} +/** 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 OneofDescriptorProtoAmino { + name?: string; + options?: OneofOptionsAmino; +} +export interface OneofDescriptorProtoAminoMsg { + type: "/google.protobuf.OneofDescriptorProto"; + value: OneofDescriptorProtoAmino; +} +/** 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 EnumDescriptorProtoAmino { + name?: string; + value?: EnumValueDescriptorProtoAmino[]; + options?: EnumOptionsAmino; + /** + * 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. + */ + reserved_range?: EnumDescriptorProto_EnumReservedRangeAmino[]; + /** + * Reserved enum value names, which may not be reused. A given name may only + * be reserved once. + */ + reserved_name?: string[]; +} +export interface EnumDescriptorProtoAminoMsg { + type: "/google.protobuf.EnumDescriptorProto"; + value: EnumDescriptorProtoAmino; +} +/** 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_EnumReservedRangeAmino { + /** Inclusive. */ + start?: number; + /** Inclusive. */ + end?: number; +} +export interface EnumDescriptorProto_EnumReservedRangeAminoMsg { + type: "/google.protobuf.EnumReservedRange"; + value: EnumDescriptorProto_EnumReservedRangeAmino; +} +/** + * 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 EnumValueDescriptorProtoAmino { + name?: string; + number?: number; + options?: EnumValueOptionsAmino; +} +export interface EnumValueDescriptorProtoAminoMsg { + type: "/google.protobuf.EnumValueDescriptorProto"; + value: EnumValueDescriptorProtoAmino; +} +/** 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 ServiceDescriptorProtoAmino { + name?: string; + method?: MethodDescriptorProtoAmino[]; + options?: ServiceOptionsAmino; +} +export interface ServiceDescriptorProtoAminoMsg { + type: "/google.protobuf.ServiceDescriptorProto"; + value: ServiceDescriptorProtoAmino; +} +/** 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 MethodDescriptorProtoAmino { + 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. + */ + input_type?: string; + output_type?: string; + options?: MethodOptionsAmino; + /** Identifies if client streams multiple client messages */ + client_streaming?: boolean; + /** Identifies if server streams multiple server messages */ + server_streaming?: boolean; +} +export interface MethodDescriptorProtoAminoMsg { + type: "/google.protobuf.MethodDescriptorProto"; + value: MethodDescriptorProtoAmino; +} +/** 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 FileOptionsAmino { + /** + * 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. + */ + java_package?: 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). + */ + java_outer_classname?: 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. + */ + java_multiple_files?: boolean; + /** This option does nothing. */ + /** @deprecated */ + java_generate_equals_and_hash?: 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. + */ + java_string_check_utf8?: boolean; + optimize_for?: 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. + */ + go_package?: 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. + */ + cc_generic_services?: boolean; + java_generic_services?: boolean; + py_generic_services?: boolean; + php_generic_services?: 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++. + */ + cc_enable_arenas?: boolean; + /** + * Sets the objective c class prefix which is prepended to all objective c + * generated classes from this .proto. There is no default. + */ + objc_class_prefix?: string; + /** Namespace for generated classes; defaults to the package. */ + csharp_namespace?: 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. + */ + swift_prefix?: string; + /** + * Sets the php class prefix which is prepended to all php generated classes + * from this .proto. Default is empty. + */ + php_class_prefix?: 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. + */ + php_namespace?: 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. + */ + php_metadata_namespace?: 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. + */ + ruby_package?: string; + /** + * The parser stores options it doesn't recognize here. + * See the documentation for the "Options" section above. + */ + uninterpreted_option?: UninterpretedOptionAmino[]; +} +export interface FileOptionsAminoMsg { + type: "/google.protobuf.FileOptions"; + value: FileOptionsAmino; +} +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 MessageOptionsAmino { + /** + * 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. + */ + message_set_wire_format?: 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". + */ + no_standard_descriptor_accessor?: 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. + */ + map_entry?: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpreted_option?: UninterpretedOptionAmino[]; +} +export interface MessageOptionsAminoMsg { + type: "/google.protobuf.MessageOptions"; + value: MessageOptionsAmino; +} +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 FieldOptionsAmino { + /** + * 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. */ + uninterpreted_option?: UninterpretedOptionAmino[]; +} +export interface FieldOptionsAminoMsg { + type: "/google.protobuf.FieldOptions"; + value: FieldOptionsAmino; +} +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 OneofOptionsAmino { + /** The parser stores options it doesn't recognize here. See above. */ + uninterpreted_option?: UninterpretedOptionAmino[]; +} +export interface OneofOptionsAminoMsg { + type: "/google.protobuf.OneofOptions"; + value: OneofOptionsAmino; +} +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 EnumOptionsAmino { + /** + * Set this option to true to allow mapping different tag names to the same + * value. + */ + allow_alias?: 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. */ + uninterpreted_option?: UninterpretedOptionAmino[]; +} +export interface EnumOptionsAminoMsg { + type: "/google.protobuf.EnumOptions"; + value: EnumOptionsAmino; +} +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 EnumValueOptionsAmino { + /** + * 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. */ + uninterpreted_option?: UninterpretedOptionAmino[]; +} +export interface EnumValueOptionsAminoMsg { + type: "/google.protobuf.EnumValueOptions"; + value: EnumValueOptionsAmino; +} +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 ServiceOptionsAmino { + /** + * 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. */ + uninterpreted_option?: UninterpretedOptionAmino[]; +} +export interface ServiceOptionsAminoMsg { + type: "/google.protobuf.ServiceOptions"; + value: ServiceOptionsAmino; +} +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 MethodOptionsAmino { + /** + * 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; + idempotency_level?: MethodOptions_IdempotencyLevel; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpreted_option?: UninterpretedOptionAmino[]; +} +export interface MethodOptionsAminoMsg { + type: "/google.protobuf.MethodOptions"; + value: MethodOptionsAmino; +} +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 UninterpretedOptionAmino { + name?: UninterpretedOption_NamePartAmino[]; + /** + * The value of the uninterpreted option, in whatever type the tokenizer + * identified it as during parsing. Exactly one of these should be set. + */ + identifier_value?: string; + positive_int_value?: string; + negative_int_value?: string; + double_value?: number; + string_value?: string; + aggregate_value?: string; +} +export interface UninterpretedOptionAminoMsg { + type: "/google.protobuf.UninterpretedOption"; + value: UninterpretedOptionAmino; +} +/** + * 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_NamePartAmino { + name_part?: string; + is_extension?: boolean; +} +export interface UninterpretedOption_NamePartAminoMsg { + type: "/google.protobuf.NamePart"; + value: UninterpretedOption_NamePartAmino; +} +/** + * 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 SourceCodeInfoAmino { + /** + * 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_LocationAmino[]; +} +export interface SourceCodeInfoAminoMsg { + type: "/google.protobuf.SourceCodeInfo"; + value: SourceCodeInfoAmino; +} +/** + * 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_LocationAmino { + /** + * 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. + */ + leading_comments?: string; + trailing_comments?: string; + leading_detached_comments?: string[]; +} +export interface SourceCodeInfo_LocationAminoMsg { + type: "/google.protobuf.Location"; + value: SourceCodeInfo_LocationAmino; +} +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 GeneratedCodeInfoAmino { + /** + * An Annotation connects some span of text in generated code to an element + * of its generating .proto file. + */ + annotation?: GeneratedCodeInfo_AnnotationAmino[]; +} +export interface GeneratedCodeInfoAminoMsg { + type: "/google.protobuf.GeneratedCodeInfo"; + value: GeneratedCodeInfoAmino; +} +/** + * 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_AnnotationAmino { + /** + * 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. */ + source_file?: 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_AnnotationAminoMsg { + type: "/google.protobuf.Annotation"; + value: GeneratedCodeInfo_AnnotationAmino; +} +export interface GeneratedCodeInfo_AnnotationSDKType { + path: number[]; + source_file: string; + begin: number; + end: number; +} +export interface FeatureSet { + utf8Validation: FeatureSet_Utf8Validation; +} +export interface FeatureSetProtoMsg { + typeUrl: "/google.protobuf.FeatureSet"; + value: Uint8Array; +} +export interface FeatureSetAmino { + utf8_validation?: FeatureSet_Utf8Validation; +} +export interface FeatureSetAminoMsg { + type: "/google.protobuf.FeatureSet"; + value: FeatureSetAmino; +} +export interface FeatureSetSDKType { + utf8_validation: FeatureSet_Utf8Validation; +} +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 !== "") { + writer.uint32(10).string(message.name); + } + if (message.package !== "") { + 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 !== "") { + 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 !== "") { + 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 !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + 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 !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + 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 !== "") { + writer.uint32(10).string(message.name); + } + if (message.number !== 0) { + 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 !== "") { + writer.uint32(50).string(message.typeName); + } + if (message.extendee !== "") { + writer.uint32(18).string(message.extendee); + } + if (message.defaultValue !== "") { + writer.uint32(58).string(message.defaultValue); + } + if (message.oneofIndex !== 0) { + writer.uint32(72).int32(message.oneofIndex); + } + if (message.jsonName !== "") { + 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 !== "") { + 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 !== "") { + 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 !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + 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 !== "") { + writer.uint32(10).string(message.name); + } + if (message.number !== 0) { + 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 !== "") { + 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 !== "") { + writer.uint32(10).string(message.name); + } + if (message.inputType !== "") { + writer.uint32(18).string(message.inputType); + } + if (message.outputType !== "") { + writer.uint32(26).string(message.outputType); + } + if (message.options !== undefined) { + MethodOptions.encode(message.options, writer.uint32(34).fork()).ldelim(); + } + if (message.clientStreaming === true) { + writer.uint32(40).bool(message.clientStreaming); + } + if (message.serverStreaming === true) { + 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 !== "") { + writer.uint32(10).string(message.javaPackage); + } + if (message.javaOuterClassname !== "") { + writer.uint32(66).string(message.javaOuterClassname); + } + if (message.javaMultipleFiles === true) { + writer.uint32(80).bool(message.javaMultipleFiles); + } + if (message.javaGenerateEqualsAndHash === true) { + writer.uint32(160).bool(message.javaGenerateEqualsAndHash); + } + if (message.javaStringCheckUtf8 === true) { + writer.uint32(216).bool(message.javaStringCheckUtf8); + } + if (message.optimizeFor !== 1) { + writer.uint32(72).int32(message.optimizeFor); + } + if (message.goPackage !== "") { + writer.uint32(90).string(message.goPackage); + } + if (message.ccGenericServices === true) { + writer.uint32(128).bool(message.ccGenericServices); + } + if (message.javaGenericServices === true) { + writer.uint32(136).bool(message.javaGenericServices); + } + if (message.pyGenericServices === true) { + writer.uint32(144).bool(message.pyGenericServices); + } + if (message.phpGenericServices === true) { + writer.uint32(336).bool(message.phpGenericServices); + } + if (message.deprecated === true) { + writer.uint32(184).bool(message.deprecated); + } + if (message.ccEnableArenas === true) { + writer.uint32(248).bool(message.ccEnableArenas); + } + if (message.objcClassPrefix !== "") { + writer.uint32(290).string(message.objcClassPrefix); + } + if (message.csharpNamespace !== "") { + writer.uint32(298).string(message.csharpNamespace); + } + if (message.swiftPrefix !== "") { + writer.uint32(314).string(message.swiftPrefix); + } + if (message.phpClassPrefix !== "") { + writer.uint32(322).string(message.phpClassPrefix); + } + if (message.phpNamespace !== "") { + writer.uint32(330).string(message.phpNamespace); + } + if (message.phpMetadataNamespace !== "") { + writer.uint32(354).string(message.phpMetadataNamespace); + } + if (message.rubyPackage !== "") { + 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 === true) { + writer.uint32(8).bool(message.messageSetWireFormat); + } + if (message.noStandardDescriptorAccessor === true) { + writer.uint32(16).bool(message.noStandardDescriptorAccessor); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + if (message.mapEntry === true) { + 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 === true) { + writer.uint32(16).bool(message.packed); + } + if (message.jstype !== 1) { + writer.uint32(48).int32(message.jstype); + } + if (message.lazy === true) { + writer.uint32(40).bool(message.lazy); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + if (message.weak === true) { + 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 === true) { + writer.uint32(16).bool(message.allowAlias); + } + if (message.deprecated === true) { + 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 === true) { + 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 === true) { + 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 === true) { + 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 !== "") { + writer.uint32(26).string(message.identifierValue); + } + if (message.positiveIntValue !== BigInt(0)) { + writer.uint32(32).uint64(message.positiveIntValue); + } + if (message.negativeIntValue !== BigInt(0)) { + writer.uint32(40).int64(message.negativeIntValue); + } + if (message.doubleValue !== 0) { + writer.uint32(49).double(message.doubleValue); + } + if (message.stringValue.length !== 0) { + writer.uint32(58).bytes(message.stringValue); + } + if (message.aggregateValue !== "") { + 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 !== "") { + writer.uint32(10).string(message.namePart); + } + if (message.isExtension === true) { + 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 !== "") { + writer.uint32(26).string(message.leadingComments); + } + if (message.trailingComments !== "") { + 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 !== "") { + writer.uint32(18).string(message.sourceFile); + } + if (message.begin !== 0) { + writer.uint32(24).int32(message.begin); + } + if (message.end !== 0) { + 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() + }; + } +}; +function createBaseFeatureSet(): FeatureSet { + return { + utf8Validation: 1 + }; +} +export const FeatureSet = { + typeUrl: "/google.protobuf.FeatureSet", + encode(message: FeatureSet, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.utf8Validation !== 1) { + writer.uint32(32).int32(message.utf8Validation); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): FeatureSet { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseFeatureSet(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 4: + message.utf8Validation = (reader.int32() as any); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): FeatureSet { + const obj = createBaseFeatureSet(); + if (isSet(object.utf8Validation)) obj.utf8Validation = featureSet_Utf8ValidationFromJSON(object.utf8Validation); + return obj; + }, + toJSON(message: FeatureSet): JsonSafe { + const obj: any = {}; + message.utf8Validation !== undefined && (obj.utf8Validation = featureSet_Utf8ValidationToJSON(message.utf8Validation)); + return obj; + }, + fromPartial(object: DeepPartial): FeatureSet { + const message = createBaseFeatureSet(); + message.utf8Validation = object.utf8Validation ?? 1; + return message; + }, + fromSDK(object: FeatureSetSDKType): FeatureSet { + return { + utf8Validation: isSet(object.utf8_validation) ? featureSet_Utf8ValidationFromJSON(object.utf8_validation) : -1 + }; + }, + fromSDKJSON(object: any): FeatureSetSDKType { + return { + utf8_validation: isSet(object.utf8_validation) ? featureSet_Utf8ValidationFromJSON(object.utf8_validation) : -1 + }; + }, + toSDK(message: FeatureSet): FeatureSetSDKType { + const obj: any = {}; + message.utf8Validation !== undefined && (obj.utf8_validation = featureSet_Utf8ValidationToJSON(message.utf8Validation)); + return obj; + }, + fromAmino(object: FeatureSetAmino): FeatureSet { + const message = createBaseFeatureSet(); + if (object.utf8_validation !== undefined && object.utf8_validation !== null) { + message.utf8Validation = object.utf8_validation; + } + return message; + }, + toAmino(message: FeatureSet): FeatureSetAmino { + const obj: any = {}; + obj.utf8_validation = message.utf8Validation === 1 ? undefined : message.utf8Validation; + return obj; + }, + fromAminoMsg(object: FeatureSetAminoMsg): FeatureSet { + return FeatureSet.fromAmino(object.value); + }, + fromProtoMsg(message: FeatureSetProtoMsg): FeatureSet { + return FeatureSet.decode(message.value); + }, + toProto(message: FeatureSet): Uint8Array { + return FeatureSet.encode(message).finish(); + }, + toProtoMsg(message: FeatureSet): FeatureSetProtoMsg { + return { + typeUrl: "/google.protobuf.FeatureSet", + value: FeatureSet.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/misc/output-base64/google/protobuf/duration.ts b/__fixtures__/misc/output-base64/google/protobuf/duration.ts new file mode 100644 index 0000000000..d56729d709 --- /dev/null +++ b/__fixtures__/misc/output-base64/google/protobuf/duration.ts @@ -0,0 +1,315 @@ +import { BinaryReader, BinaryWriter } from "../../binary"; +import { isSet, DeepPartial } from "../../helpers"; +import { JsonSafe } from "../../json-safe"; +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 type DurationAmino = string; +export interface DurationAminoMsg { + type: "/google.protobuf.Duration"; + value: DurationAmino; +} +/** + * 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 !== BigInt(0)) { + writer.uint32(8).int64(message.seconds); + } + if (message.nanos !== 0) { + 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__/misc/output-base64/google/protobuf/timestamp.ts b/__fixtures__/misc/output-base64/google/protobuf/timestamp.ts new file mode 100644 index 0000000000..259ef92539 --- /dev/null +++ b/__fixtures__/misc/output-base64/google/protobuf/timestamp.ts @@ -0,0 +1,381 @@ +import { BinaryReader, BinaryWriter } from "../../binary"; +import { isSet, DeepPartial, fromJsonTimestamp, fromTimestamp } from "../../helpers"; +import { JsonSafe } from "../../json-safe"; +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 type TimestampAmino = string; +export interface TimestampAminoMsg { + type: "/google.protobuf.Timestamp"; + value: TimestampAmino; +} +/** + * 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 !== BigInt(0)) { + writer.uint32(8).int64(message.seconds); + } + if (message.nanos !== 0) { + 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__/misc/output-base64/helpers.ts b/__fixtures__/misc/output-base64/helpers.ts new file mode 100644 index 0000000000..091dfcca78 --- /dev/null +++ b/__fixtures__/misc/output-base64/helpers.ts @@ -0,0 +1,255 @@ +/** +* 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. +*/ + + +declare var self: any | undefined; +declare var window: any | undefined; +declare var global: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== 'undefined') return globalThis; + if (typeof self !== 'undefined') return self; + if (typeof window !== 'undefined') return window; + if (typeof global !== 'undefined') return global; + throw 'Unable to locate global object'; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, 'base64').toString('binary')); + +export function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, 'binary').toString('base64')); + +export function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + arr.forEach((byte) => { + bin.push(String.fromCharCode(byte)); + }); + return btoa(bin.join('')); +} + +export interface AminoHeight { + readonly revision_number?: string; + readonly revision_height?: string; +} + +export function omitDefault( + input: T +): T | undefined { + if (typeof input === 'string') { + return input === '' ? undefined : input; + } + + if (typeof input === 'number') { + return input === 0 ? undefined : input; + } + + if (typeof input === "boolean"){ + return input === false ? undefined : input; + } + + if (typeof input === 'bigint') { + return input === BigInt(0) ? undefined : input; + } + + throw new Error(`Got unsupported type ${typeof input}`); +} + +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 function toDuration(duration: string): Duration { + return { + seconds: BigInt(Math.floor(parseInt(duration) / 1000000000)), + nanos: parseInt(duration) % 1000000000 + }; +} + +export function fromDuration(duration: Duration): string { + return ( + parseInt(duration.seconds.toString()) * 1000000000 + + duration.nanos + ).toString(); +} + +export function isSet(value: any): boolean { + return value !== null && value !== undefined; +} + +export function isObject(value: any): boolean { + return typeof value === 'object' && value !== null; +} + +export interface PageRequest { + key: Uint8Array; + offset: bigint; + limit: bigint; + countTotal: boolean; + reverse: boolean; +} + +export interface PageRequestParams { + 'pagination.key'?: string; + 'pagination.offset'?: string; + 'pagination.limit'?: string; + 'pagination.count_total'?: boolean; + 'pagination.reverse'?: boolean; +} + +export interface Params { + params: PageRequestParams; +} + +export const setPaginationParams = ( + options: Params, + pagination?: PageRequest +) => { + if (!pagination) { + return options; + } + + if (typeof pagination?.countTotal !== 'undefined') { + options.params['pagination.count_total'] = pagination.countTotal; + } + if (typeof pagination?.key !== 'undefined') { + // String to Uint8Array + // let uint8arr = new Uint8Array(Buffer.from(data,'base64')); + + // Uint8Array to String + options.params['pagination.key'] = Buffer.from(pagination.key).toString( + 'base64' + ); + } + if (typeof pagination?.limit !== 'undefined') { + options.params['pagination.limit'] = pagination.limit.toString(); + } + if (typeof pagination?.offset !== 'undefined') { + options.params['pagination.offset'] = pagination.offset.toString(); + } + if (typeof pagination?.reverse !== 'undefined') { + options.params['pagination.reverse'] = pagination.reverse; + } + + return options; +}; + +type Builtin = + | Date + | Function + | Uint8Array + | string + | number + | bigint + | boolean + | undefined; + +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +type KeysOfUnion = T extends T ? keyof T : never; +export type Exact = P extends Builtin + ? P + : P & { [K in keyof P]: Exact } & Record< + Exclude>, + never + >; + +export interface Rpc { + request( + service: string, + method: string, + data: Uint8Array + ): Promise; +} + +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 function toTimestamp(date: Date): Timestamp { + const seconds = numberToLong(date.getTime() / 1_000); + const nanos = (date.getTime() % 1000) * 1000000; + return { + seconds, + nanos + }; +} + +export function fromTimestamp(t: Timestamp): Date { + let millis = Number(t.seconds) * 1000; + millis += t.nanos / 1000000; + return new Date(millis); +} + +const timestampFromJSON = (object: any): Timestamp => { + return { + seconds: isSet(object.seconds) + ? BigInt(object.seconds.toString()) + : BigInt(0), + nanos: isSet(object.nanos) ? Number(object.nanos) : 0 + }; +}; + +export function fromJsonTimestamp(o: any): Timestamp { + if (o instanceof Date) { + return toTimestamp(o); + } else if (typeof o === 'string') { + return toTimestamp(new Date(o)); + } else { + return timestampFromJSON(o); + } +} + +function numberToLong(number: number) { + return BigInt(Math.trunc(number)); +} + diff --git a/__fixtures__/misc/output-base64/index.ts b/__fixtures__/misc/output-base64/index.ts new file mode 100644 index 0000000000..3757ae2467 --- /dev/null +++ b/__fixtures__/misc/output-base64/index.ts @@ -0,0 +1,18 @@ +/** + * 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. + */ + +export * from "./gogoproto/bundle"; +export * from "./google/bundle"; +export * from "./misc/bundle"; +export * from "./misc/client"; +export * from "./extern"; +export * from "./react-query"; +export * from "./mobx"; +export * from "./pinia-endpoint"; +export * from "./json-safe"; +export * from "./varint"; +export * from "./utf8"; +export * from "./binary"; \ No newline at end of file diff --git a/__fixtures__/misc/output-base64/json-safe.ts b/__fixtures__/misc/output-base64/json-safe.ts new file mode 100644 index 0000000000..c03f452e18 --- /dev/null +++ b/__fixtures__/misc/output-base64/json-safe.ts @@ -0,0 +1,14 @@ +/** +* 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. +*/ + + +export type JsonSafe = T extends Uint8Array | bigint | Date + ? string + : T extends Array + ? Array> + : T extends object + ? { [K in keyof T]: JsonSafe } + : T; diff --git a/__fixtures__/misc/output-base64/misc/all_fields.ts b/__fixtures__/misc/output-base64/misc/all_fields.ts new file mode 100644 index 0000000000..07a41e4297 --- /dev/null +++ b/__fixtures__/misc/output-base64/misc/all_fields.ts @@ -0,0 +1,2739 @@ +import { AccessConfig, AccessConfigAmino, AccessConfigSDKType, VoteOption, VoteOptionSDKType, voteOptionFromJSON, voteOptionToJSON } from "./eval_request"; +import { Any, AnyProtoMsg, AnyAmino, AnySDKType } from "../google/protobuf/any"; +import { Duration, DurationAmino, DurationSDKType } from "../google/protobuf/duration"; +import { Timestamp, TimestampAmino, TimestampSDKType } from "../google/protobuf/timestamp"; +import { BinaryReader, BinaryWriter } from "../binary"; +import { toTimestamp, fromTimestamp, isSet, DeepPartial } from "../helpers"; +import { Decimal } from "@cosmjs/math"; +import { encodeBase64 as bytesFromBase64 } from "@endo/base64"; +import { decodeBase64 as base64FromBytes } from "@endo/base64"; +import { JsonSafe } from "../json-safe"; +import { toUtf8, fromBase64, fromUtf8, toBase64 } from "@cosmjs/encoding"; +import { encodePubkey, decodePubkey } from "@cosmjs/proto-signing"; +export const protobufPackage = "misc"; +export interface EncodingTestForDontOmit { + /** scalar */ + str: string; + dOStr: string; + b: boolean; + dOB: boolean; + num: number; + dONum: number; + /** bigint */ + big: bigint; + dOBig: bigint; + /** protoType */ + proto?: AccessConfig; + dOProto: AccessConfig; + /** anyType */ + auth?: Any; + dOAuth: Any; + /** bytes */ + salt: Uint8Array; + dOSalt: Uint8Array; + /** raw bytes */ + raw: Uint8Array; + dORaw: Uint8Array; + /** wasm bytes */ + wasm: Uint8Array; + dOWasm: Uint8Array; + /** enum */ + opt: VoteOption; + dOOpt: VoteOption; + /** duration */ + period?: Duration; + dOPeriod: Duration; + /** timestamp */ + date?: Date; + dODate: Date; + /** pubkey */ + pubkey?: Any; + dOPubkey: Any; + /** array scalar */ + nums: number[]; + dONums: number[]; + /** array bigint */ + bigs: bigint[]; + dOBigs: bigint[]; + /** array bytes */ + salts: Uint8Array[]; + dOSalts: Uint8Array[]; + /** array raw bytes */ + raws: Uint8Array[]; + dORaws: Uint8Array[]; + /** array wasm bytes */ + wasms: Uint8Array[]; + dOWasms: Uint8Array[]; + /** array enum */ + opts: VoteOption[]; + dOOpts: VoteOption[]; + /** array duration */ + periods: Duration[]; + dOPeriods: Duration[]; + /** array protoType */ + protos: AccessConfig[]; + dOProtos: AccessConfig[]; + /** array anyType */ + auths: Any[]; + dOAuths: Any[]; + /** dec */ + dec: string; + dODec: string; + /** array dec */ + decs: string[]; + dODecs: string[]; +} +export interface EncodingTestForDontOmitProtoMsg { + typeUrl: "/misc.EncodingTestForDontOmit"; + value: Uint8Array; +} +export interface EncodingTestForDontOmitAmino { + /** scalar */ + str?: string; + d_o_str: string; + b?: boolean; + d_o_b: boolean; + num?: number; + d_o_num: number; + /** bigint */ + big?: string; + d_o_big: string; + /** protoType */ + proto?: AccessConfigAmino; + d_o_proto: AccessConfigAmino; + /** anyType */ + auth?: AnyAmino; + d_o_auth: AnyAmino; + /** bytes */ + salt?: string; + d_o_salt: string; + /** raw bytes */ + raw?: any; + d_o_raw: any; + /** wasm bytes */ + wasm?: string; + d_o_wasm: string; + /** enum */ + opt?: VoteOption; + d_o_opt: VoteOption; + /** duration */ + period?: DurationAmino; + d_o_period: DurationAmino; + /** timestamp */ + date?: string; + d_o_date: string; + /** pubkey */ + pubkey?: AnyAmino; + d_o_pubkey: AnyAmino; + /** array scalar */ + nums?: number[]; + d_o_nums: number[]; + /** array bigint */ + bigs?: string[]; + d_o_bigs: string[]; + /** array bytes */ + salts?: string[]; + d_o_salts: string[]; + /** array raw bytes */ + raws?: any[]; + d_o_raws: any[]; + /** array wasm bytes */ + wasms?: string[]; + d_o_wasms: string[]; + /** array enum */ + opts?: VoteOption[]; + d_o_opts: VoteOption[]; + /** array duration */ + periods?: DurationAmino[]; + d_o_periods: DurationAmino[]; + /** array protoType */ + protos?: AccessConfigAmino[]; + d_o_protos: AccessConfigAmino[]; + /** array anyType */ + auths?: AnyAmino[]; + d_o_auths: AnyAmino[]; + /** dec */ + dec?: string; + d_o_dec: string; + /** array dec */ + decs?: string[]; + d_o_decs: string[]; +} +export interface EncodingTestForDontOmitAminoMsg { + type: "/misc.EncodingTestForDontOmit"; + value: EncodingTestForDontOmitAmino; +} +export interface EncodingTestForDontOmitSDKType { + str: string; + d_o_str: string; + b: boolean; + d_o_b: boolean; + num: number; + d_o_num: number; + big: bigint; + d_o_big: bigint; + proto?: AccessConfigSDKType; + d_o_proto: AccessConfigSDKType; + auth?: AnySDKType; + d_o_auth: AnySDKType; + salt: Uint8Array; + d_o_salt: Uint8Array; + raw: Uint8Array; + d_o_raw: Uint8Array; + wasm: Uint8Array; + d_o_wasm: Uint8Array; + opt: VoteOption; + d_o_opt: VoteOption; + period?: DurationSDKType; + d_o_period: DurationSDKType; + date?: Date; + d_o_date: Date; + pubkey?: AnySDKType; + d_o_pubkey: AnySDKType; + nums: number[]; + d_o_nums: number[]; + bigs: bigint[]; + d_o_bigs: bigint[]; + salts: Uint8Array[]; + d_o_salts: Uint8Array[]; + raws: Uint8Array[]; + d_o_raws: Uint8Array[]; + wasms: Uint8Array[]; + d_o_wasms: Uint8Array[]; + opts: VoteOption[]; + d_o_opts: VoteOption[]; + periods: DurationSDKType[]; + d_o_periods: DurationSDKType[]; + protos: AccessConfigSDKType[]; + d_o_protos: AccessConfigSDKType[]; + auths: AnySDKType[]; + d_o_auths: AnySDKType[]; + dec: string; + d_o_dec: string; + decs: string[]; + d_o_decs: string[]; +} +export interface EncodingTestForOmit { + /** scalar */ + str: string; + oStr: string; + b: boolean; + oB: boolean; + num: number; + oNum: number; + /** bigint */ + big: bigint; + oBig: bigint; + /** protoType */ + proto?: AccessConfig; + oProto: AccessConfig; + /** anyType */ + auth?: Any; + oAuth: Any; + /** bytes */ + salt: Uint8Array; + oSalt: Uint8Array; + /** raw bytes */ + raw: Uint8Array; + oRaw: Uint8Array; + /** wasm bytes */ + wasm: Uint8Array; + oWasm: Uint8Array; + /** enum */ + opt: VoteOption; + oOpt: VoteOption; + /** duration */ + period?: Duration; + oPeriod: Duration; + /** timestamp */ + date?: Date; + oDate: Date; + /** pubkey */ + pubkey?: Any; + oPubkey: Any; + /** array scalar */ + nums: number[]; + oNums: number[]; + /** array bigint */ + bigs: bigint[]; + oBigs: bigint[]; + /** array bytes */ + salts: Uint8Array[]; + oSalts: Uint8Array[]; + /** array raw bytes */ + raws: Uint8Array[]; + oRaws: Uint8Array[]; + /** array wasm bytes */ + wasms: Uint8Array[]; + oWasms: Uint8Array[]; + /** array enum */ + opts: VoteOption[]; + oOpts: VoteOption[]; + /** array duration */ + periods: Duration[]; + oPeriods: Duration[]; + /** array protoType */ + protos: AccessConfig[]; + oProtos: AccessConfig[]; + /** array anyType */ + auths: Any[]; + oAuths: Any[]; + /** dec */ + dec: string; + oDec: string; + /** array dec */ + decs: string[]; + oDecs: string[]; +} +export interface EncodingTestForOmitProtoMsg { + typeUrl: "/misc.EncodingTestForOmit"; + value: Uint8Array; +} +export interface EncodingTestForOmitAmino { + /** scalar */ + str: string; + o_str?: string; + b: boolean; + o_b?: boolean; + num: number; + o_num?: number; + /** bigint */ + big: string; + o_big?: string; + /** protoType */ + proto: AccessConfigAmino; + o_proto?: AccessConfigAmino; + /** anyType */ + auth: AnyAmino; + o_auth?: AnyAmino; + /** bytes */ + salt: string; + o_salt?: string; + /** raw bytes */ + raw: any; + o_raw?: any; + /** wasm bytes */ + wasm: string; + o_wasm?: string; + /** enum */ + opt: VoteOption; + o_opt?: VoteOption; + /** duration */ + period: DurationAmino; + o_period?: DurationAmino; + /** timestamp */ + date: string; + o_date?: string; + /** pubkey */ + pubkey: AnyAmino; + o_pubkey?: AnyAmino; + /** array scalar */ + nums: number[]; + o_nums?: number[]; + /** array bigint */ + bigs: string[]; + o_bigs?: string[]; + /** array bytes */ + salts: string[]; + o_salts?: string[]; + /** array raw bytes */ + raws: any[]; + o_raws?: any[]; + /** array wasm bytes */ + wasms: string[]; + o_wasms?: string[]; + /** array enum */ + opts: VoteOption[]; + o_opts?: VoteOption[]; + /** array duration */ + periods: DurationAmino[]; + o_periods?: DurationAmino[]; + /** array protoType */ + protos: AccessConfigAmino[]; + o_protos?: AccessConfigAmino[]; + /** array anyType */ + auths: AnyAmino[]; + o_auths?: AnyAmino[]; + /** dec */ + dec: string; + o_dec?: string; + /** array dec */ + decs: string[]; + o_decs?: string[]; +} +export interface EncodingTestForOmitAminoMsg { + type: "/misc.EncodingTestForOmit"; + value: EncodingTestForOmitAmino; +} +export interface EncodingTestForOmitSDKType { + str: string; + o_str: string; + b: boolean; + o_b: boolean; + num: number; + o_num: number; + big: bigint; + o_big: bigint; + proto?: AccessConfigSDKType; + o_proto: AccessConfigSDKType; + auth?: AnySDKType; + o_auth: AnySDKType; + salt: Uint8Array; + o_salt: Uint8Array; + raw: Uint8Array; + o_raw: Uint8Array; + wasm: Uint8Array; + o_wasm: Uint8Array; + opt: VoteOption; + o_opt: VoteOption; + period?: DurationSDKType; + o_period: DurationSDKType; + date?: Date; + o_date: Date; + pubkey?: AnySDKType; + o_pubkey: AnySDKType; + nums: number[]; + o_nums: number[]; + bigs: bigint[]; + o_bigs: bigint[]; + salts: Uint8Array[]; + o_salts: Uint8Array[]; + raws: Uint8Array[]; + o_raws: Uint8Array[]; + wasms: Uint8Array[]; + o_wasms: Uint8Array[]; + opts: VoteOption[]; + o_opts: VoteOption[]; + periods: DurationSDKType[]; + o_periods: DurationSDKType[]; + protos: AccessConfigSDKType[]; + o_protos: AccessConfigSDKType[]; + auths: AnySDKType[]; + o_auths: AnySDKType[]; + dec: string; + o_dec: string; + decs: string[]; + o_decs: string[]; +} +function createBaseEncodingTestForDontOmit(): EncodingTestForDontOmit { + return { + str: "", + dOStr: "", + b: false, + dOB: false, + num: 0, + dONum: 0, + big: BigInt(0), + dOBig: BigInt(0), + proto: undefined, + dOProto: AccessConfig.fromPartial({}), + auth: undefined, + dOAuth: Any.fromPartial({}), + salt: new Uint8Array(), + dOSalt: new Uint8Array(), + raw: new Uint8Array(), + dORaw: new Uint8Array(), + wasm: new Uint8Array(), + dOWasm: new Uint8Array(), + opt: 0, + dOOpt: 0, + period: undefined, + dOPeriod: Duration.fromPartial({}), + date: undefined, + dODate: new Date(), + pubkey: undefined, + dOPubkey: Any.fromPartial({}), + nums: [], + dONums: [], + bigs: [], + dOBigs: [], + salts: [], + dOSalts: [], + raws: [], + dORaws: [], + wasms: [], + dOWasms: [], + opts: [], + dOOpts: [], + periods: [], + dOPeriods: [], + protos: [], + dOProtos: [], + auths: [], + dOAuths: [], + dec: "", + dODec: "", + decs: [], + dODecs: [] + }; +} +export const EncodingTestForDontOmit = { + typeUrl: "/misc.EncodingTestForDontOmit", + encode(message: EncodingTestForDontOmit, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.str !== "") { + writer.uint32(10).string(message.str); + } + if (message.dOStr !== "") { + writer.uint32(18).string(message.dOStr); + } + if (message.b === true) { + writer.uint32(24).bool(message.b); + } + if (message.dOB === true) { + writer.uint32(32).bool(message.dOB); + } + if (message.num !== 0) { + writer.uint32(40).int32(message.num); + } + if (message.dONum !== 0) { + writer.uint32(48).int32(message.dONum); + } + if (message.big !== BigInt(0)) { + writer.uint32(56).int64(message.big); + } + if (message.dOBig !== BigInt(0)) { + writer.uint32(64).int64(message.dOBig); + } + if (message.proto !== undefined) { + AccessConfig.encode(message.proto, writer.uint32(74).fork()).ldelim(); + } + if (message.dOProto !== undefined) { + AccessConfig.encode(message.dOProto, writer.uint32(82).fork()).ldelim(); + } + if (message.auth !== undefined) { + Any.encode(message.auth, writer.uint32(90).fork()).ldelim(); + } + if (message.dOAuth !== undefined) { + Any.encode(message.dOAuth, writer.uint32(98).fork()).ldelim(); + } + if (message.salt.length !== 0) { + writer.uint32(106).bytes(message.salt); + } + if (message.dOSalt.length !== 0) { + writer.uint32(114).bytes(message.dOSalt); + } + if (message.raw.length !== 0) { + writer.uint32(122).bytes(message.raw); + } + if (message.dORaw.length !== 0) { + writer.uint32(130).bytes(message.dORaw); + } + if (message.wasm.length !== 0) { + writer.uint32(138).bytes(message.wasm); + } + if (message.dOWasm.length !== 0) { + writer.uint32(146).bytes(message.dOWasm); + } + if (message.opt !== 0) { + writer.uint32(152).int32(message.opt); + } + if (message.dOOpt !== 0) { + writer.uint32(160).int32(message.dOOpt); + } + if (message.period !== undefined) { + Duration.encode(message.period, writer.uint32(170).fork()).ldelim(); + } + if (message.dOPeriod !== undefined) { + Duration.encode(message.dOPeriod, writer.uint32(178).fork()).ldelim(); + } + if (message.date !== undefined) { + Timestamp.encode(toTimestamp(message.date), writer.uint32(186).fork()).ldelim(); + } + if (message.dODate !== undefined) { + Timestamp.encode(toTimestamp(message.dODate), writer.uint32(194).fork()).ldelim(); + } + if (message.pubkey !== undefined) { + Any.encode(message.pubkey, writer.uint32(202).fork()).ldelim(); + } + if (message.dOPubkey !== undefined) { + Any.encode(message.dOPubkey, writer.uint32(210).fork()).ldelim(); + } + writer.uint32(218).fork(); + for (const v of message.nums) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(226).fork(); + for (const v of message.dONums) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(234).fork(); + for (const v of message.bigs) { + writer.int64(v); + } + writer.ldelim(); + writer.uint32(242).fork(); + for (const v of message.dOBigs) { + writer.int64(v); + } + writer.ldelim(); + for (const v of message.salts) { + writer.uint32(250).bytes(v!); + } + for (const v of message.dOSalts) { + writer.uint32(258).bytes(v!); + } + for (const v of message.raws) { + writer.uint32(266).bytes(v!); + } + for (const v of message.dORaws) { + writer.uint32(274).bytes(v!); + } + for (const v of message.wasms) { + writer.uint32(282).bytes(v!); + } + for (const v of message.dOWasms) { + writer.uint32(290).bytes(v!); + } + writer.uint32(298).fork(); + for (const v of message.opts) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(306).fork(); + for (const v of message.dOOpts) { + writer.int32(v); + } + writer.ldelim(); + for (const v of message.periods) { + Duration.encode(v!, writer.uint32(314).fork()).ldelim(); + } + for (const v of message.dOPeriods) { + Duration.encode(v!, writer.uint32(322).fork()).ldelim(); + } + for (const v of message.protos) { + AccessConfig.encode(v!, writer.uint32(346).fork()).ldelim(); + } + for (const v of message.dOProtos) { + AccessConfig.encode(v!, writer.uint32(354).fork()).ldelim(); + } + for (const v of message.auths) { + Any.encode(v!, writer.uint32(362).fork()).ldelim(); + } + for (const v of message.dOAuths) { + Any.encode(v!, writer.uint32(370).fork()).ldelim(); + } + if (message.dec !== "") { + writer.uint32(378).string(Decimal.fromUserInput(message.dec, 18).atomics); + } + if (message.dODec !== "") { + writer.uint32(386).string(Decimal.fromUserInput(message.dODec, 18).atomics); + } + for (const v of message.decs) { + writer.uint32(394).string(Decimal.fromUserInput(v!, 18).atomics); + } + for (const v of message.dODecs) { + writer.uint32(402).string(Decimal.fromUserInput(v!, 18).atomics); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): EncodingTestForDontOmit { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseEncodingTestForDontOmit(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.str = reader.string(); + break; + case 2: + message.dOStr = reader.string(); + break; + case 3: + message.b = reader.bool(); + break; + case 4: + message.dOB = reader.bool(); + break; + case 5: + message.num = reader.int32(); + break; + case 6: + message.dONum = reader.int32(); + break; + case 7: + message.big = reader.int64(); + break; + case 8: + message.dOBig = reader.int64(); + break; + case 9: + message.proto = AccessConfig.decode(reader, reader.uint32()); + break; + case 10: + message.dOProto = AccessConfig.decode(reader, reader.uint32()); + break; + case 11: + message.auth = Any.decode(reader, reader.uint32()); + break; + case 12: + message.dOAuth = Any.decode(reader, reader.uint32()); + break; + case 13: + message.salt = reader.bytes(); + break; + case 14: + message.dOSalt = reader.bytes(); + break; + case 15: + message.raw = reader.bytes(); + break; + case 16: + message.dORaw = reader.bytes(); + break; + case 17: + message.wasm = reader.bytes(); + break; + case 18: + message.dOWasm = reader.bytes(); + break; + case 19: + message.opt = (reader.int32() as any); + break; + case 20: + message.dOOpt = (reader.int32() as any); + break; + case 21: + message.period = Duration.decode(reader, reader.uint32()); + break; + case 22: + message.dOPeriod = Duration.decode(reader, reader.uint32()); + break; + case 23: + message.date = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + break; + case 24: + message.dODate = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + break; + case 25: + message.pubkey = Any.decode(reader, reader.uint32()); + break; + case 26: + message.dOPubkey = Any.decode(reader, reader.uint32()); + break; + case 27: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.nums.push(reader.int32()); + } + } else { + message.nums.push(reader.int32()); + } + break; + case 28: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.dONums.push(reader.int32()); + } + } else { + message.dONums.push(reader.int32()); + } + break; + case 29: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.bigs.push(reader.int64()); + } + } else { + message.bigs.push(reader.int64()); + } + break; + case 30: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.dOBigs.push(reader.int64()); + } + } else { + message.dOBigs.push(reader.int64()); + } + break; + case 31: + message.salts.push(reader.bytes()); + break; + case 32: + message.dOSalts.push(reader.bytes()); + break; + case 33: + message.raws.push(reader.bytes()); + break; + case 34: + message.dORaws.push(reader.bytes()); + break; + case 35: + message.wasms.push(reader.bytes()); + break; + case 36: + message.dOWasms.push(reader.bytes()); + break; + case 37: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.opts.push((reader.int32() as any)); + } + } else { + message.opts.push((reader.int32() as any)); + } + break; + case 38: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.dOOpts.push((reader.int32() as any)); + } + } else { + message.dOOpts.push((reader.int32() as any)); + } + break; + case 39: + message.periods.push(Duration.decode(reader, reader.uint32())); + break; + case 40: + message.dOPeriods.push(Duration.decode(reader, reader.uint32())); + break; + case 43: + message.protos.push(AccessConfig.decode(reader, reader.uint32())); + break; + case 44: + message.dOProtos.push(AccessConfig.decode(reader, reader.uint32())); + break; + case 45: + message.auths.push(Any.decode(reader, reader.uint32())); + break; + case 46: + message.dOAuths.push(Any.decode(reader, reader.uint32())); + break; + case 47: + message.dec = Decimal.fromAtomics(reader.string(), 18).toString(); + break; + case 48: + message.dODec = Decimal.fromAtomics(reader.string(), 18).toString(); + break; + case 49: + message.decs.push(Decimal.fromAtomics(reader.string(), 18).toString()); + break; + case 50: + message.dODecs.push(Decimal.fromAtomics(reader.string(), 18).toString()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): EncodingTestForDontOmit { + const obj = createBaseEncodingTestForDontOmit(); + if (isSet(object.str)) obj.str = String(object.str); + if (isSet(object.dOStr)) obj.dOStr = String(object.dOStr); + if (isSet(object.b)) obj.b = Boolean(object.b); + if (isSet(object.dOB)) obj.dOB = Boolean(object.dOB); + if (isSet(object.num)) obj.num = Number(object.num); + if (isSet(object.dONum)) obj.dONum = Number(object.dONum); + if (isSet(object.big)) obj.big = BigInt(object.big.toString()); + if (isSet(object.dOBig)) obj.dOBig = BigInt(object.dOBig.toString()); + if (isSet(object.proto)) obj.proto = AccessConfig.fromJSON(object.proto); + if (isSet(object.dOProto)) obj.dOProto = AccessConfig.fromJSON(object.dOProto); + if (isSet(object.auth)) obj.auth = Any.fromJSON(object.auth); + if (isSet(object.dOAuth)) obj.dOAuth = Any.fromJSON(object.dOAuth); + if (isSet(object.salt)) obj.salt = bytesFromBase64(object.salt); + if (isSet(object.dOSalt)) obj.dOSalt = bytesFromBase64(object.dOSalt); + if (isSet(object.raw)) obj.raw = bytesFromBase64(object.raw); + if (isSet(object.dORaw)) obj.dORaw = bytesFromBase64(object.dORaw); + if (isSet(object.wasm)) obj.wasm = bytesFromBase64(object.wasm); + if (isSet(object.dOWasm)) obj.dOWasm = bytesFromBase64(object.dOWasm); + if (isSet(object.opt)) obj.opt = voteOptionFromJSON(object.opt); + if (isSet(object.dOOpt)) obj.dOOpt = voteOptionFromJSON(object.dOOpt); + if (isSet(object.period)) obj.period = Duration.fromJSON(object.period); + if (isSet(object.dOPeriod)) obj.dOPeriod = Duration.fromJSON(object.dOPeriod); + if (isSet(object.date)) obj.date = new Date(object.date); + if (isSet(object.dODate)) obj.dODate = new Date(object.dODate); + if (isSet(object.pubkey)) obj.pubkey = Any.fromJSON(object.pubkey); + if (isSet(object.dOPubkey)) obj.dOPubkey = Any.fromJSON(object.dOPubkey); + if (Array.isArray(object?.nums)) obj.nums = object.nums.map((e: any) => Number(e)); + if (Array.isArray(object?.dONums)) obj.dONums = object.dONums.map((e: any) => Number(e)); + if (Array.isArray(object?.bigs)) obj.bigs = object.bigs.map((e: any) => BigInt(e.toString())); + if (Array.isArray(object?.dOBigs)) obj.dOBigs = object.dOBigs.map((e: any) => BigInt(e.toString())); + if (Array.isArray(object?.salts)) obj.salts = object.salts.map((e: any) => bytesFromBase64(e)); + if (Array.isArray(object?.dOSalts)) obj.dOSalts = object.dOSalts.map((e: any) => bytesFromBase64(e)); + if (Array.isArray(object?.raws)) obj.raws = object.raws.map((e: any) => bytesFromBase64(e)); + if (Array.isArray(object?.dORaws)) obj.dORaws = object.dORaws.map((e: any) => bytesFromBase64(e)); + if (Array.isArray(object?.wasms)) obj.wasms = object.wasms.map((e: any) => bytesFromBase64(e)); + if (Array.isArray(object?.dOWasms)) obj.dOWasms = object.dOWasms.map((e: any) => bytesFromBase64(e)); + if (Array.isArray(object?.opts)) obj.opts = object.opts.map((e: any) => voteOptionFromJSON(e)); + if (Array.isArray(object?.dOOpts)) obj.dOOpts = object.dOOpts.map((e: any) => voteOptionFromJSON(e)); + if (Array.isArray(object?.periods)) obj.periods = object.periods.map((e: any) => Duration.fromJSON(e)); + if (Array.isArray(object?.dOPeriods)) obj.dOPeriods = object.dOPeriods.map((e: any) => Duration.fromJSON(e)); + if (Array.isArray(object?.protos)) obj.protos = object.protos.map((e: any) => AccessConfig.fromJSON(e)); + if (Array.isArray(object?.dOProtos)) obj.dOProtos = object.dOProtos.map((e: any) => AccessConfig.fromJSON(e)); + if (Array.isArray(object?.auths)) obj.auths = object.auths.map((e: any) => Any.fromJSON(e)); + if (Array.isArray(object?.dOAuths)) obj.dOAuths = object.dOAuths.map((e: any) => Any.fromJSON(e)); + if (isSet(object.dec)) obj.dec = String(object.dec); + if (isSet(object.dODec)) obj.dODec = String(object.dODec); + if (Array.isArray(object?.decs)) obj.decs = object.decs.map((e: any) => String(e)); + if (Array.isArray(object?.dODecs)) obj.dODecs = object.dODecs.map((e: any) => String(e)); + return obj; + }, + toJSON(message: EncodingTestForDontOmit): JsonSafe { + const obj: any = {}; + message.str !== undefined && (obj.str = message.str); + message.dOStr !== undefined && (obj.dOStr = message.dOStr); + message.b !== undefined && (obj.b = message.b); + message.dOB !== undefined && (obj.dOB = message.dOB); + message.num !== undefined && (obj.num = Math.round(message.num)); + message.dONum !== undefined && (obj.dONum = Math.round(message.dONum)); + message.big !== undefined && (obj.big = (message.big || BigInt(0)).toString()); + message.dOBig !== undefined && (obj.dOBig = (message.dOBig || BigInt(0)).toString()); + message.proto !== undefined && (obj.proto = message.proto ? AccessConfig.toJSON(message.proto) : undefined); + message.dOProto !== undefined && (obj.dOProto = message.dOProto ? AccessConfig.toJSON(message.dOProto) : undefined); + message.auth !== undefined && (obj.auth = message.auth ? Any.toJSON(message.auth) : undefined); + message.dOAuth !== undefined && (obj.dOAuth = message.dOAuth ? Any.toJSON(message.dOAuth) : undefined); + message.salt !== undefined && (obj.salt = base64FromBytes(message.salt !== undefined ? message.salt : new Uint8Array())); + message.dOSalt !== undefined && (obj.dOSalt = base64FromBytes(message.dOSalt !== undefined ? message.dOSalt : new Uint8Array())); + message.raw !== undefined && (obj.raw = base64FromBytes(message.raw !== undefined ? message.raw : new Uint8Array())); + message.dORaw !== undefined && (obj.dORaw = base64FromBytes(message.dORaw !== undefined ? message.dORaw : new Uint8Array())); + message.wasm !== undefined && (obj.wasm = base64FromBytes(message.wasm !== undefined ? message.wasm : new Uint8Array())); + message.dOWasm !== undefined && (obj.dOWasm = base64FromBytes(message.dOWasm !== undefined ? message.dOWasm : new Uint8Array())); + message.opt !== undefined && (obj.opt = voteOptionToJSON(message.opt)); + message.dOOpt !== undefined && (obj.dOOpt = voteOptionToJSON(message.dOOpt)); + message.period !== undefined && (obj.period = message.period ? Duration.toJSON(message.period) : undefined); + message.dOPeriod !== undefined && (obj.dOPeriod = message.dOPeriod ? Duration.toJSON(message.dOPeriod) : undefined); + message.date !== undefined && (obj.date = message.date.toISOString()); + message.dODate !== undefined && (obj.dODate = message.dODate.toISOString()); + message.pubkey !== undefined && (obj.pubkey = message.pubkey ? Any.toJSON(message.pubkey) : undefined); + message.dOPubkey !== undefined && (obj.dOPubkey = message.dOPubkey ? Any.toJSON(message.dOPubkey) : undefined); + if (message.nums) { + obj.nums = message.nums.map(e => Math.round(e)); + } else { + obj.nums = []; + } + if (message.dONums) { + obj.dONums = message.dONums.map(e => Math.round(e)); + } else { + obj.dONums = []; + } + if (message.bigs) { + obj.bigs = message.bigs.map(e => (e || BigInt(0)).toString()); + } else { + obj.bigs = []; + } + if (message.dOBigs) { + obj.dOBigs = message.dOBigs.map(e => (e || BigInt(0)).toString()); + } else { + obj.dOBigs = []; + } + if (message.salts) { + obj.salts = message.salts.map(e => base64FromBytes(e !== undefined ? e : new Uint8Array())); + } else { + obj.salts = []; + } + if (message.dOSalts) { + obj.dOSalts = message.dOSalts.map(e => base64FromBytes(e !== undefined ? e : new Uint8Array())); + } else { + obj.dOSalts = []; + } + if (message.raws) { + obj.raws = message.raws.map(e => base64FromBytes(e !== undefined ? e : new Uint8Array())); + } else { + obj.raws = []; + } + if (message.dORaws) { + obj.dORaws = message.dORaws.map(e => base64FromBytes(e !== undefined ? e : new Uint8Array())); + } else { + obj.dORaws = []; + } + if (message.wasms) { + obj.wasms = message.wasms.map(e => base64FromBytes(e !== undefined ? e : new Uint8Array())); + } else { + obj.wasms = []; + } + if (message.dOWasms) { + obj.dOWasms = message.dOWasms.map(e => base64FromBytes(e !== undefined ? e : new Uint8Array())); + } else { + obj.dOWasms = []; + } + if (message.opts) { + obj.opts = message.opts.map(e => voteOptionToJSON(e)); + } else { + obj.opts = []; + } + if (message.dOOpts) { + obj.dOOpts = message.dOOpts.map(e => voteOptionToJSON(e)); + } else { + obj.dOOpts = []; + } + if (message.periods) { + obj.periods = message.periods.map(e => e ? Duration.toJSON(e) : undefined); + } else { + obj.periods = []; + } + if (message.dOPeriods) { + obj.dOPeriods = message.dOPeriods.map(e => e ? Duration.toJSON(e) : undefined); + } else { + obj.dOPeriods = []; + } + if (message.protos) { + obj.protos = message.protos.map(e => e ? AccessConfig.toJSON(e) : undefined); + } else { + obj.protos = []; + } + if (message.dOProtos) { + obj.dOProtos = message.dOProtos.map(e => e ? AccessConfig.toJSON(e) : undefined); + } else { + obj.dOProtos = []; + } + if (message.auths) { + obj.auths = message.auths.map(e => e ? Any.toJSON(e) : undefined); + } else { + obj.auths = []; + } + if (message.dOAuths) { + obj.dOAuths = message.dOAuths.map(e => e ? Any.toJSON(e) : undefined); + } else { + obj.dOAuths = []; + } + message.dec !== undefined && (obj.dec = message.dec); + message.dODec !== undefined && (obj.dODec = message.dODec); + if (message.decs) { + obj.decs = message.decs.map(e => e); + } else { + obj.decs = []; + } + if (message.dODecs) { + obj.dODecs = message.dODecs.map(e => e); + } else { + obj.dODecs = []; + } + return obj; + }, + fromPartial(object: DeepPartial): EncodingTestForDontOmit { + const message = createBaseEncodingTestForDontOmit(); + message.str = object.str ?? ""; + message.dOStr = object.dOStr ?? ""; + message.b = object.b ?? false; + message.dOB = object.dOB ?? false; + message.num = object.num ?? 0; + message.dONum = object.dONum ?? 0; + if (object.big !== undefined && object.big !== null) { + message.big = BigInt(object.big.toString()); + } + if (object.dOBig !== undefined && object.dOBig !== null) { + message.dOBig = BigInt(object.dOBig.toString()); + } + if (object.proto !== undefined && object.proto !== null) { + message.proto = AccessConfig.fromPartial(object.proto); + } + if (object.dOProto !== undefined && object.dOProto !== null) { + message.dOProto = AccessConfig.fromPartial(object.dOProto); + } + if (object.auth !== undefined && object.auth !== null) { + message.auth = Any.fromPartial(object.auth); + } + if (object.dOAuth !== undefined && object.dOAuth !== null) { + message.dOAuth = Any.fromPartial(object.dOAuth); + } + message.salt = object.salt ?? new Uint8Array(); + message.dOSalt = object.dOSalt ?? new Uint8Array(); + message.raw = object.raw ?? new Uint8Array(); + message.dORaw = object.dORaw ?? new Uint8Array(); + message.wasm = object.wasm ?? new Uint8Array(); + message.dOWasm = object.dOWasm ?? new Uint8Array(); + message.opt = object.opt ?? 0; + message.dOOpt = object.dOOpt ?? 0; + if (object.period !== undefined && object.period !== null) { + message.period = Duration.fromPartial(object.period); + } + if (object.dOPeriod !== undefined && object.dOPeriod !== null) { + message.dOPeriod = Duration.fromPartial(object.dOPeriod); + } + message.date = object.date ?? undefined; + message.dODate = object.dODate ?? undefined; + if (object.pubkey !== undefined && object.pubkey !== null) { + message.pubkey = Any.fromPartial(object.pubkey); + } + if (object.dOPubkey !== undefined && object.dOPubkey !== null) { + message.dOPubkey = Any.fromPartial(object.dOPubkey); + } + message.nums = object.nums?.map(e => e) || []; + message.dONums = object.dONums?.map(e => e) || []; + message.bigs = object.bigs?.map(e => BigInt(e.toString())) || []; + message.dOBigs = object.dOBigs?.map(e => BigInt(e.toString())) || []; + message.salts = object.salts?.map(e => e) || []; + message.dOSalts = object.dOSalts?.map(e => e) || []; + message.raws = object.raws?.map(e => e) || []; + message.dORaws = object.dORaws?.map(e => e) || []; + message.wasms = object.wasms?.map(e => e) || []; + message.dOWasms = object.dOWasms?.map(e => e) || []; + message.opts = object.opts?.map(e => e) || []; + message.dOOpts = object.dOOpts?.map(e => e) || []; + message.periods = object.periods?.map(e => Duration.fromPartial(e)) || []; + message.dOPeriods = object.dOPeriods?.map(e => Duration.fromPartial(e)) || []; + message.protos = object.protos?.map(e => AccessConfig.fromPartial(e)) || []; + message.dOProtos = object.dOProtos?.map(e => AccessConfig.fromPartial(e)) || []; + message.auths = object.auths?.map(e => Any.fromPartial(e)) || []; + message.dOAuths = object.dOAuths?.map(e => Any.fromPartial(e)) || []; + message.dec = object.dec ?? ""; + message.dODec = object.dODec ?? ""; + message.decs = object.decs?.map(e => e) || []; + message.dODecs = object.dODecs?.map(e => e) || []; + return message; + }, + fromSDK(object: EncodingTestForDontOmitSDKType): EncodingTestForDontOmit { + return { + str: object?.str, + dOStr: object?.d_o_str, + b: object?.b, + dOB: object?.d_o_b, + num: object?.num, + dONum: object?.d_o_num, + big: object?.big, + dOBig: object?.d_o_big, + proto: object.proto ? AccessConfig.fromSDK(object.proto) : undefined, + dOProto: object.d_o_proto ? AccessConfig.fromSDK(object.d_o_proto) : undefined, + auth: object.auth ? Any.fromSDK(object.auth) : undefined, + dOAuth: object.d_o_auth ? Any.fromSDK(object.d_o_auth) : undefined, + salt: object?.salt, + dOSalt: object?.d_o_salt, + raw: object?.raw, + dORaw: object?.d_o_raw, + wasm: object?.wasm, + dOWasm: object?.d_o_wasm, + opt: isSet(object.opt) ? voteOptionFromJSON(object.opt) : -1, + dOOpt: isSet(object.d_o_opt) ? voteOptionFromJSON(object.d_o_opt) : -1, + period: object.period ? Duration.fromSDK(object.period) : undefined, + dOPeriod: object.d_o_period ? Duration.fromSDK(object.d_o_period) : undefined, + date: object.date ?? undefined, + dODate: object.d_o_date ?? undefined, + pubkey: object.pubkey ? Any.fromSDK(object.pubkey) : undefined, + dOPubkey: object.d_o_pubkey ? Any.fromSDK(object.d_o_pubkey) : undefined, + nums: Array.isArray(object?.nums) ? object.nums.map((e: any) => e) : [], + dONums: Array.isArray(object?.d_o_nums) ? object.d_o_nums.map((e: any) => e) : [], + bigs: Array.isArray(object?.bigs) ? object.bigs.map((e: any) => e) : [], + dOBigs: Array.isArray(object?.d_o_bigs) ? object.d_o_bigs.map((e: any) => e) : [], + salts: Array.isArray(object?.salts) ? object.salts.map((e: any) => e) : [], + dOSalts: Array.isArray(object?.d_o_salts) ? object.d_o_salts.map((e: any) => e) : [], + raws: Array.isArray(object?.raws) ? object.raws.map((e: any) => e) : [], + dORaws: Array.isArray(object?.d_o_raws) ? object.d_o_raws.map((e: any) => e) : [], + wasms: Array.isArray(object?.wasms) ? object.wasms.map((e: any) => e) : [], + dOWasms: Array.isArray(object?.d_o_wasms) ? object.d_o_wasms.map((e: any) => e) : [], + opts: Array.isArray(object?.opts) ? object.opts.map((e: any) => voteOptionFromJSON(e)) : [], + dOOpts: Array.isArray(object?.d_o_opts) ? object.d_o_opts.map((e: any) => voteOptionFromJSON(e)) : [], + periods: Array.isArray(object?.periods) ? object.periods.map((e: any) => Duration.fromSDK(e)) : [], + dOPeriods: Array.isArray(object?.d_o_periods) ? object.d_o_periods.map((e: any) => Duration.fromSDK(e)) : [], + protos: Array.isArray(object?.protos) ? object.protos.map((e: any) => AccessConfig.fromSDK(e)) : [], + dOProtos: Array.isArray(object?.d_o_protos) ? object.d_o_protos.map((e: any) => AccessConfig.fromSDK(e)) : [], + auths: Array.isArray(object?.auths) ? object.auths.map((e: any) => Any.fromSDK(e)) : [], + dOAuths: Array.isArray(object?.d_o_auths) ? object.d_o_auths.map((e: any) => Any.fromSDK(e)) : [], + dec: object?.dec, + dODec: object?.d_o_dec, + decs: Array.isArray(object?.decs) ? object.decs.map((e: any) => e) : [], + dODecs: Array.isArray(object?.d_o_decs) ? object.d_o_decs.map((e: any) => e) : [] + }; + }, + fromSDKJSON(object: any): EncodingTestForDontOmitSDKType { + return { + str: isSet(object.str) ? String(object.str) : "", + d_o_str: isSet(object.d_o_str) ? String(object.d_o_str) : "", + b: isSet(object.b) ? Boolean(object.b) : false, + d_o_b: isSet(object.d_o_b) ? Boolean(object.d_o_b) : false, + num: isSet(object.num) ? Number(object.num) : 0, + d_o_num: isSet(object.d_o_num) ? Number(object.d_o_num) : 0, + big: isSet(object.big) ? BigInt(object.big.toString()) : BigInt(0), + d_o_big: isSet(object.d_o_big) ? BigInt(object.d_o_big.toString()) : BigInt(0), + proto: isSet(object.proto) ? AccessConfig.fromSDKJSON(object.proto) : undefined, + d_o_proto: isSet(object.d_o_proto) ? AccessConfig.fromSDKJSON(object.d_o_proto) : undefined, + auth: isSet(object.auth) ? Any.fromSDKJSON(object.auth) : undefined, + d_o_auth: isSet(object.d_o_auth) ? Any.fromSDKJSON(object.d_o_auth) : undefined, + salt: isSet(object.salt) ? bytesFromBase64(object.salt) : new Uint8Array(), + d_o_salt: isSet(object.d_o_salt) ? bytesFromBase64(object.d_o_salt) : new Uint8Array(), + raw: isSet(object.raw) ? bytesFromBase64(object.raw) : new Uint8Array(), + d_o_raw: isSet(object.d_o_raw) ? bytesFromBase64(object.d_o_raw) : new Uint8Array(), + wasm: isSet(object.wasm) ? bytesFromBase64(object.wasm) : new Uint8Array(), + d_o_wasm: isSet(object.d_o_wasm) ? bytesFromBase64(object.d_o_wasm) : new Uint8Array(), + opt: isSet(object.opt) ? voteOptionFromJSON(object.opt) : -1, + d_o_opt: isSet(object.d_o_opt) ? voteOptionFromJSON(object.d_o_opt) : -1, + period: isSet(object.period) ? Duration.fromSDKJSON(object.period) : undefined, + d_o_period: isSet(object.d_o_period) ? Duration.fromSDKJSON(object.d_o_period) : undefined, + date: isSet(object.date) ? new Date(object.date) : undefined, + d_o_date: isSet(object.d_o_date) ? new Date(object.d_o_date) : undefined, + pubkey: isSet(object.pubkey) ? Any.fromSDKJSON(object.pubkey) : undefined, + d_o_pubkey: isSet(object.d_o_pubkey) ? Any.fromSDKJSON(object.d_o_pubkey) : undefined, + nums: Array.isArray(object?.nums) ? object.nums.map((e: any) => Number(e)) : [], + d_o_nums: Array.isArray(object?.d_o_nums) ? object.d_o_nums.map((e: any) => Number(e)) : [], + bigs: Array.isArray(object?.bigs) ? object.bigs.map((e: any) => BigInt(e.toString())) : [], + d_o_bigs: Array.isArray(object?.d_o_bigs) ? object.d_o_bigs.map((e: any) => BigInt(e.toString())) : [], + salts: Array.isArray(object?.salts) ? object.salts.map((e: any) => bytesFromBase64(e)) : [], + d_o_salts: Array.isArray(object?.d_o_salts) ? object.d_o_salts.map((e: any) => bytesFromBase64(e)) : [], + raws: Array.isArray(object?.raws) ? object.raws.map((e: any) => bytesFromBase64(e)) : [], + d_o_raws: Array.isArray(object?.d_o_raws) ? object.d_o_raws.map((e: any) => bytesFromBase64(e)) : [], + wasms: Array.isArray(object?.wasms) ? object.wasms.map((e: any) => bytesFromBase64(e)) : [], + d_o_wasms: Array.isArray(object?.d_o_wasms) ? object.d_o_wasms.map((e: any) => bytesFromBase64(e)) : [], + opts: Array.isArray(object?.opts) ? object.opts.map((e: any) => voteOptionFromJSON(e)) : [], + d_o_opts: Array.isArray(object?.d_o_opts) ? object.d_o_opts.map((e: any) => voteOptionFromJSON(e)) : [], + periods: Array.isArray(object?.periods) ? object.periods.map((e: any) => Duration.fromSDKJSON(e)) : [], + d_o_periods: Array.isArray(object?.d_o_periods) ? object.d_o_periods.map((e: any) => Duration.fromSDKJSON(e)) : [], + protos: Array.isArray(object?.protos) ? object.protos.map((e: any) => AccessConfig.fromSDKJSON(e)) : [], + d_o_protos: Array.isArray(object?.d_o_protos) ? object.d_o_protos.map((e: any) => AccessConfig.fromSDKJSON(e)) : [], + auths: Array.isArray(object?.auths) ? object.auths.map((e: any) => Any.fromSDKJSON(e)) : [], + d_o_auths: Array.isArray(object?.d_o_auths) ? object.d_o_auths.map((e: any) => Any.fromSDKJSON(e)) : [], + dec: isSet(object.dec) ? String(object.dec) : "", + d_o_dec: isSet(object.d_o_dec) ? String(object.d_o_dec) : "", + decs: Array.isArray(object?.decs) ? object.decs.map((e: any) => String(e)) : [], + d_o_decs: Array.isArray(object?.d_o_decs) ? object.d_o_decs.map((e: any) => String(e)) : [] + }; + }, + toSDK(message: EncodingTestForDontOmit): EncodingTestForDontOmitSDKType { + const obj: any = {}; + obj.str = message.str; + obj.d_o_str = message.dOStr; + obj.b = message.b; + obj.d_o_b = message.dOB; + obj.num = message.num; + obj.d_o_num = message.dONum; + obj.big = message.big; + obj.d_o_big = message.dOBig; + message.proto !== undefined && (obj.proto = message.proto ? AccessConfig.toSDK(message.proto) : undefined); + message.dOProto !== undefined && (obj.d_o_proto = message.dOProto ? AccessConfig.toSDK(message.dOProto) : undefined); + message.auth !== undefined && (obj.auth = message.auth ? Any.toSDK(message.auth) : undefined); + message.dOAuth !== undefined && (obj.d_o_auth = message.dOAuth ? Any.toSDK(message.dOAuth) : undefined); + obj.salt = message.salt; + obj.d_o_salt = message.dOSalt; + obj.raw = message.raw; + obj.d_o_raw = message.dORaw; + obj.wasm = message.wasm; + obj.d_o_wasm = message.dOWasm; + message.opt !== undefined && (obj.opt = voteOptionToJSON(message.opt)); + message.dOOpt !== undefined && (obj.d_o_opt = voteOptionToJSON(message.dOOpt)); + message.period !== undefined && (obj.period = message.period ? Duration.toSDK(message.period) : undefined); + message.dOPeriod !== undefined && (obj.d_o_period = message.dOPeriod ? Duration.toSDK(message.dOPeriod) : undefined); + message.date !== undefined && (obj.date = message.date ?? undefined); + message.dODate !== undefined && (obj.d_o_date = message.dODate ?? undefined); + message.pubkey !== undefined && (obj.pubkey = message.pubkey ? Any.toSDK(message.pubkey) : undefined); + message.dOPubkey !== undefined && (obj.d_o_pubkey = message.dOPubkey ? Any.toSDK(message.dOPubkey) : undefined); + if (message.nums) { + obj.nums = message.nums.map(e => e); + } else { + obj.nums = []; + } + if (message.dONums) { + obj.d_o_nums = message.dONums.map(e => e); + } else { + obj.d_o_nums = []; + } + if (message.bigs) { + obj.bigs = message.bigs.map(e => e); + } else { + obj.bigs = []; + } + if (message.dOBigs) { + obj.d_o_bigs = message.dOBigs.map(e => e); + } else { + obj.d_o_bigs = []; + } + if (message.salts) { + obj.salts = message.salts.map(e => e); + } else { + obj.salts = []; + } + if (message.dOSalts) { + obj.d_o_salts = message.dOSalts.map(e => e); + } else { + obj.d_o_salts = []; + } + if (message.raws) { + obj.raws = message.raws.map(e => e); + } else { + obj.raws = []; + } + if (message.dORaws) { + obj.d_o_raws = message.dORaws.map(e => e); + } else { + obj.d_o_raws = []; + } + if (message.wasms) { + obj.wasms = message.wasms.map(e => e); + } else { + obj.wasms = []; + } + if (message.dOWasms) { + obj.d_o_wasms = message.dOWasms.map(e => e); + } else { + obj.d_o_wasms = []; + } + if (message.opts) { + obj.opts = message.opts.map(e => voteOptionToJSON(e)); + } else { + obj.opts = []; + } + if (message.dOOpts) { + obj.d_o_opts = message.dOOpts.map(e => voteOptionToJSON(e)); + } else { + obj.d_o_opts = []; + } + if (message.periods) { + obj.periods = message.periods.map(e => e ? Duration.toSDK(e) : undefined); + } else { + obj.periods = []; + } + if (message.dOPeriods) { + obj.d_o_periods = message.dOPeriods.map(e => e ? Duration.toSDK(e) : undefined); + } else { + obj.d_o_periods = []; + } + if (message.protos) { + obj.protos = message.protos.map(e => e ? AccessConfig.toSDK(e) : undefined); + } else { + obj.protos = []; + } + if (message.dOProtos) { + obj.d_o_protos = message.dOProtos.map(e => e ? AccessConfig.toSDK(e) : undefined); + } else { + obj.d_o_protos = []; + } + if (message.auths) { + obj.auths = message.auths.map(e => e ? Any.toSDK(e) : undefined); + } else { + obj.auths = []; + } + if (message.dOAuths) { + obj.d_o_auths = message.dOAuths.map(e => e ? Any.toSDK(e) : undefined); + } else { + obj.d_o_auths = []; + } + obj.dec = message.dec; + obj.d_o_dec = message.dODec; + if (message.decs) { + obj.decs = message.decs.map(e => e); + } else { + obj.decs = []; + } + if (message.dODecs) { + obj.d_o_decs = message.dODecs.map(e => e); + } else { + obj.d_o_decs = []; + } + return obj; + }, + fromAmino(object: EncodingTestForDontOmitAmino): EncodingTestForDontOmit { + const message = createBaseEncodingTestForDontOmit(); + if (object.str !== undefined && object.str !== null) { + message.str = object.str; + } + if (object.d_o_str !== undefined && object.d_o_str !== null) { + message.dOStr = object.d_o_str; + } + if (object.b !== undefined && object.b !== null) { + message.b = object.b; + } + if (object.d_o_b !== undefined && object.d_o_b !== null) { + message.dOB = object.d_o_b; + } + if (object.num !== undefined && object.num !== null) { + message.num = object.num; + } + if (object.d_o_num !== undefined && object.d_o_num !== null) { + message.dONum = object.d_o_num; + } + if (object.big !== undefined && object.big !== null) { + message.big = BigInt(object.big); + } + if (object.d_o_big !== undefined && object.d_o_big !== null) { + message.dOBig = BigInt(object.d_o_big); + } + if (object.proto !== undefined && object.proto !== null) { + message.proto = AccessConfig.fromAmino(object.proto); + } + if (object.d_o_proto !== undefined && object.d_o_proto !== null) { + message.dOProto = AccessConfig.fromAmino(object.d_o_proto); + } + if (object.auth !== undefined && object.auth !== null) { + message.auth = Any.fromAmino(object.auth); + } + if (object.d_o_auth !== undefined && object.d_o_auth !== null) { + message.dOAuth = Any.fromAmino(object.d_o_auth); + } + if (object.salt !== undefined && object.salt !== null) { + message.salt = bytesFromBase64(object.salt); + } + if (object.d_o_salt !== undefined && object.d_o_salt !== null) { + message.dOSalt = bytesFromBase64(object.d_o_salt); + } + if (object.raw !== undefined && object.raw !== null) { + message.raw = toUtf8(JSON.stringify(object.raw)); + } + if (object.d_o_raw !== undefined && object.d_o_raw !== null) { + message.dORaw = toUtf8(JSON.stringify(object.d_o_raw)); + } + if (object.wasm !== undefined && object.wasm !== null) { + message.wasm = fromBase64(object.wasm); + } + if (object.d_o_wasm !== undefined && object.d_o_wasm !== null) { + message.dOWasm = fromBase64(object.d_o_wasm); + } + if (object.opt !== undefined && object.opt !== null) { + message.opt = object.opt; + } + if (object.d_o_opt !== undefined && object.d_o_opt !== null) { + message.dOOpt = object.d_o_opt; + } + if (object.period !== undefined && object.period !== null) { + message.period = Duration.fromAmino(object.period); + } + if (object.d_o_period !== undefined && object.d_o_period !== null) { + message.dOPeriod = Duration.fromAmino(object.d_o_period); + } + if (object.date !== undefined && object.date !== null) { + message.date = fromTimestamp(Timestamp.fromAmino(object.date)); + } + if (object.d_o_date !== undefined && object.d_o_date !== null) { + message.dODate = fromTimestamp(Timestamp.fromAmino(object.d_o_date)); + } + if (object.pubkey !== undefined && object.pubkey !== null) { + message.pubkey = encodePubkey(object.pubkey); + } + if (object.d_o_pubkey !== undefined && object.d_o_pubkey !== null) { + message.dOPubkey = encodePubkey(object.d_o_pubkey); + } + message.nums = object.nums?.map(e => e) || []; + message.dONums = object.d_o_nums?.map(e => e) || []; + message.bigs = object.bigs?.map(e => BigInt(e)) || []; + message.dOBigs = object.d_o_bigs?.map(e => BigInt(e)) || []; + message.salts = object.salts?.map(e => bytesFromBase64(e)) || []; + message.dOSalts = object.d_o_salts?.map(e => bytesFromBase64(e)) || []; + message.raws = object.raws?.map(e => toUtf8(JSON.stringify(e))) || []; + message.dORaws = object.d_o_raws?.map(e => toUtf8(JSON.stringify(e))) || []; + message.wasms = object.wasms?.map(e => fromBase64(e)) || []; + message.dOWasms = object.d_o_wasms?.map(e => fromBase64(e)) || []; + message.opts = object.opts?.map(e => e) || []; + message.dOOpts = object.d_o_opts?.map(e => e) || []; + message.periods = object.periods?.map(e => Duration.fromAmino(e)) || []; + message.dOPeriods = object.d_o_periods?.map(e => Duration.fromAmino(e)) || []; + message.protos = object.protos?.map(e => AccessConfig.fromAmino(e)) || []; + message.dOProtos = object.d_o_protos?.map(e => AccessConfig.fromAmino(e)) || []; + message.auths = object.auths?.map(e => Any.fromAmino(e)) || []; + message.dOAuths = object.d_o_auths?.map(e => Any.fromAmino(e)) || []; + if (object.dec !== undefined && object.dec !== null) { + message.dec = object.dec; + } + if (object.d_o_dec !== undefined && object.d_o_dec !== null) { + message.dODec = object.d_o_dec; + } + message.decs = object.decs?.map(e => e) || []; + message.dODecs = object.d_o_decs?.map(e => e) || []; + return message; + }, + toAmino(message: EncodingTestForDontOmit): EncodingTestForDontOmitAmino { + const obj: any = {}; + obj.str = message.str === "" ? undefined : message.str; + obj.d_o_str = message.dOStr ?? ""; + obj.b = message.b === false ? undefined : message.b; + obj.d_o_b = message.dOB ?? false; + obj.num = message.num === 0 ? undefined : message.num; + obj.d_o_num = message.dONum ?? 0; + obj.big = message.big !== BigInt(0) ? (message.big?.toString)() : undefined; + obj.d_o_big = message.dOBig ? (message.dOBig?.toString)() : "0"; + obj.proto = message.proto ? AccessConfig.toAmino(message.proto) : undefined; + obj.d_o_proto = message.dOProto ? AccessConfig.toAmino(message.dOProto) : AccessConfig.toAmino(AccessConfig.fromPartial({})); + obj.auth = message.auth ? Any.toAmino(message.auth) : undefined; + obj.d_o_auth = message.dOAuth ? Any.toAmino(message.dOAuth) : Any.toAmino(Any.fromPartial({})); + obj.salt = message.salt ? base64FromBytes(message.salt) : undefined; + obj.d_o_salt = message.dOSalt ? base64FromBytes(message.dOSalt) : ""; + obj.raw = message.raw ? JSON.parse(fromUtf8(message.raw)) : undefined; + obj.d_o_raw = message.dORaw ? JSON.parse(fromUtf8(message.dORaw)) : {}; + obj.wasm = message.wasm ? toBase64(message.wasm) : undefined; + obj.d_o_wasm = message.dOWasm ? toBase64(message.dOWasm) : ""; + obj.opt = message.opt === 0 ? undefined : message.opt; + obj.d_o_opt = message.dOOpt ?? 0; + obj.period = message.period ? Duration.toAmino(message.period) : undefined; + obj.d_o_period = message.dOPeriod ? Duration.toAmino(message.dOPeriod) : Duration.toAmino(Duration.fromPartial({})); + obj.date = message.date ? Timestamp.toAmino(toTimestamp(message.date)) : undefined; + obj.d_o_date = message.dODate ? Timestamp.toAmino(toTimestamp(message.dODate)) : new Date(); + obj.pubkey = message.pubkey ? decodePubkey(message.pubkey) : undefined; + obj.d_o_pubkey = message.dOPubkey ? decodePubkey(message.dOPubkey) : Any.fromPartial({}); + if (message.nums) { + obj.nums = message.nums.map(e => e); + } else { + obj.nums = message.nums; + } + if (message.dONums) { + obj.d_o_nums = message.dONums.map(e => e); + } else { + obj.d_o_nums = message.dONums; + } + if (message.bigs) { + obj.bigs = message.bigs.map(e => e.toString()); + } else { + obj.bigs = message.bigs; + } + if (message.dOBigs) { + obj.d_o_bigs = message.dOBigs.map(e => e.toString()); + } else { + obj.d_o_bigs = message.dOBigs; + } + if (message.salts) { + obj.salts = message.salts.map(e => base64FromBytes(e)); + } else { + obj.salts = message.salts; + } + if (message.dOSalts) { + obj.d_o_salts = message.dOSalts.map(e => base64FromBytes(e)); + } else { + obj.d_o_salts = message.dOSalts; + } + if (message.raws) { + obj.raws = message.raws.map(e => JSON.parse(fromUtf8(e))); + } else { + obj.raws = message.raws; + } + if (message.dORaws) { + obj.d_o_raws = message.dORaws.map(e => JSON.parse(fromUtf8(e))); + } else { + obj.d_o_raws = message.dORaws; + } + if (message.wasms) { + obj.wasms = message.wasms.map(e => toBase64(e)); + } else { + obj.wasms = message.wasms; + } + if (message.dOWasms) { + obj.d_o_wasms = message.dOWasms.map(e => toBase64(e)); + } else { + obj.d_o_wasms = message.dOWasms; + } + if (message.opts) { + obj.opts = message.opts.map(e => e); + } else { + obj.opts = message.opts; + } + if (message.dOOpts) { + obj.d_o_opts = message.dOOpts.map(e => e); + } else { + obj.d_o_opts = message.dOOpts; + } + if (message.periods) { + obj.periods = message.periods.map(e => e ? Duration.toAmino(e) : undefined); + } else { + obj.periods = message.periods; + } + if (message.dOPeriods) { + obj.d_o_periods = message.dOPeriods.map(e => e ? Duration.toAmino(e) : undefined); + } else { + obj.d_o_periods = message.dOPeriods; + } + if (message.protos) { + obj.protos = message.protos.map(e => e ? AccessConfig.toAmino(e) : undefined); + } else { + obj.protos = message.protos; + } + if (message.dOProtos) { + obj.d_o_protos = message.dOProtos.map(e => e ? AccessConfig.toAmino(e) : undefined); + } else { + obj.d_o_protos = message.dOProtos; + } + if (message.auths) { + obj.auths = message.auths.map(e => e ? Any.toAmino(e) : undefined); + } else { + obj.auths = message.auths; + } + if (message.dOAuths) { + obj.d_o_auths = message.dOAuths.map(e => e ? Any.toAmino(e) : undefined); + } else { + obj.d_o_auths = message.dOAuths; + } + obj.dec = message.dec === "" ? undefined : message.dec; + obj.d_o_dec = message.dODec ?? ""; + if (message.decs) { + obj.decs = message.decs.map(e => e); + } else { + obj.decs = message.decs; + } + if (message.dODecs) { + obj.d_o_decs = message.dODecs.map(e => e); + } else { + obj.d_o_decs = message.dODecs; + } + return obj; + }, + fromAminoMsg(object: EncodingTestForDontOmitAminoMsg): EncodingTestForDontOmit { + return EncodingTestForDontOmit.fromAmino(object.value); + }, + fromProtoMsg(message: EncodingTestForDontOmitProtoMsg): EncodingTestForDontOmit { + return EncodingTestForDontOmit.decode(message.value); + }, + toProto(message: EncodingTestForDontOmit): Uint8Array { + return EncodingTestForDontOmit.encode(message).finish(); + }, + toProtoMsg(message: EncodingTestForDontOmit): EncodingTestForDontOmitProtoMsg { + return { + typeUrl: "/misc.EncodingTestForDontOmit", + value: EncodingTestForDontOmit.encode(message).finish() + }; + } +}; +function createBaseEncodingTestForOmit(): EncodingTestForOmit { + return { + str: "", + oStr: "", + b: false, + oB: false, + num: 0, + oNum: 0, + big: BigInt(0), + oBig: BigInt(0), + proto: undefined, + oProto: AccessConfig.fromPartial({}), + auth: undefined, + oAuth: Any.fromPartial({}), + salt: new Uint8Array(), + oSalt: new Uint8Array(), + raw: new Uint8Array(), + oRaw: new Uint8Array(), + wasm: new Uint8Array(), + oWasm: new Uint8Array(), + opt: 0, + oOpt: 0, + period: undefined, + oPeriod: Duration.fromPartial({}), + date: undefined, + oDate: new Date(), + pubkey: undefined, + oPubkey: Any.fromPartial({}), + nums: [], + oNums: [], + bigs: [], + oBigs: [], + salts: [], + oSalts: [], + raws: [], + oRaws: [], + wasms: [], + oWasms: [], + opts: [], + oOpts: [], + periods: [], + oPeriods: [], + protos: [], + oProtos: [], + auths: [], + oAuths: [], + dec: "", + oDec: "", + decs: [], + oDecs: [] + }; +} +export const EncodingTestForOmit = { + typeUrl: "/misc.EncodingTestForOmit", + encode(message: EncodingTestForOmit, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.str !== "") { + writer.uint32(10).string(message.str); + } + if (message.oStr !== "") { + writer.uint32(18).string(message.oStr); + } + if (message.b === true) { + writer.uint32(24).bool(message.b); + } + if (message.oB === true) { + writer.uint32(32).bool(message.oB); + } + if (message.num !== 0) { + writer.uint32(40).int32(message.num); + } + if (message.oNum !== 0) { + writer.uint32(48).int32(message.oNum); + } + if (message.big !== BigInt(0)) { + writer.uint32(56).int64(message.big); + } + if (message.oBig !== BigInt(0)) { + writer.uint32(64).int64(message.oBig); + } + if (message.proto !== undefined) { + AccessConfig.encode(message.proto, writer.uint32(74).fork()).ldelim(); + } + if (message.oProto !== undefined) { + AccessConfig.encode(message.oProto, writer.uint32(82).fork()).ldelim(); + } + if (message.auth !== undefined) { + Any.encode(message.auth, writer.uint32(90).fork()).ldelim(); + } + if (message.oAuth !== undefined) { + Any.encode(message.oAuth, writer.uint32(98).fork()).ldelim(); + } + if (message.salt.length !== 0) { + writer.uint32(106).bytes(message.salt); + } + if (message.oSalt.length !== 0) { + writer.uint32(114).bytes(message.oSalt); + } + if (message.raw.length !== 0) { + writer.uint32(122).bytes(message.raw); + } + if (message.oRaw.length !== 0) { + writer.uint32(130).bytes(message.oRaw); + } + if (message.wasm.length !== 0) { + writer.uint32(138).bytes(message.wasm); + } + if (message.oWasm.length !== 0) { + writer.uint32(146).bytes(message.oWasm); + } + if (message.opt !== 0) { + writer.uint32(152).int32(message.opt); + } + if (message.oOpt !== 0) { + writer.uint32(160).int32(message.oOpt); + } + if (message.period !== undefined) { + Duration.encode(message.period, writer.uint32(170).fork()).ldelim(); + } + if (message.oPeriod !== undefined) { + Duration.encode(message.oPeriod, writer.uint32(178).fork()).ldelim(); + } + if (message.date !== undefined) { + Timestamp.encode(toTimestamp(message.date), writer.uint32(186).fork()).ldelim(); + } + if (message.oDate !== undefined) { + Timestamp.encode(toTimestamp(message.oDate), writer.uint32(194).fork()).ldelim(); + } + if (message.pubkey !== undefined) { + Any.encode(message.pubkey, writer.uint32(202).fork()).ldelim(); + } + if (message.oPubkey !== undefined) { + Any.encode(message.oPubkey, writer.uint32(210).fork()).ldelim(); + } + writer.uint32(218).fork(); + for (const v of message.nums) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(226).fork(); + for (const v of message.oNums) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(234).fork(); + for (const v of message.bigs) { + writer.int64(v); + } + writer.ldelim(); + writer.uint32(242).fork(); + for (const v of message.oBigs) { + writer.int64(v); + } + writer.ldelim(); + for (const v of message.salts) { + writer.uint32(250).bytes(v!); + } + for (const v of message.oSalts) { + writer.uint32(258).bytes(v!); + } + for (const v of message.raws) { + writer.uint32(266).bytes(v!); + } + for (const v of message.oRaws) { + writer.uint32(274).bytes(v!); + } + for (const v of message.wasms) { + writer.uint32(282).bytes(v!); + } + for (const v of message.oWasms) { + writer.uint32(290).bytes(v!); + } + writer.uint32(298).fork(); + for (const v of message.opts) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(306).fork(); + for (const v of message.oOpts) { + writer.int32(v); + } + writer.ldelim(); + for (const v of message.periods) { + Duration.encode(v!, writer.uint32(314).fork()).ldelim(); + } + for (const v of message.oPeriods) { + Duration.encode(v!, writer.uint32(322).fork()).ldelim(); + } + for (const v of message.protos) { + AccessConfig.encode(v!, writer.uint32(346).fork()).ldelim(); + } + for (const v of message.oProtos) { + AccessConfig.encode(v!, writer.uint32(354).fork()).ldelim(); + } + for (const v of message.auths) { + Any.encode(v!, writer.uint32(362).fork()).ldelim(); + } + for (const v of message.oAuths) { + Any.encode(v!, writer.uint32(370).fork()).ldelim(); + } + if (message.dec !== "") { + writer.uint32(378).string(Decimal.fromUserInput(message.dec, 18).atomics); + } + if (message.oDec !== "") { + writer.uint32(386).string(Decimal.fromUserInput(message.oDec, 18).atomics); + } + for (const v of message.decs) { + writer.uint32(394).string(Decimal.fromUserInput(v!, 18).atomics); + } + for (const v of message.oDecs) { + writer.uint32(402).string(Decimal.fromUserInput(v!, 18).atomics); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): EncodingTestForOmit { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseEncodingTestForOmit(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.str = reader.string(); + break; + case 2: + message.oStr = reader.string(); + break; + case 3: + message.b = reader.bool(); + break; + case 4: + message.oB = reader.bool(); + break; + case 5: + message.num = reader.int32(); + break; + case 6: + message.oNum = reader.int32(); + break; + case 7: + message.big = reader.int64(); + break; + case 8: + message.oBig = reader.int64(); + break; + case 9: + message.proto = AccessConfig.decode(reader, reader.uint32()); + break; + case 10: + message.oProto = AccessConfig.decode(reader, reader.uint32()); + break; + case 11: + message.auth = Any.decode(reader, reader.uint32()); + break; + case 12: + message.oAuth = Any.decode(reader, reader.uint32()); + break; + case 13: + message.salt = reader.bytes(); + break; + case 14: + message.oSalt = reader.bytes(); + break; + case 15: + message.raw = reader.bytes(); + break; + case 16: + message.oRaw = reader.bytes(); + break; + case 17: + message.wasm = reader.bytes(); + break; + case 18: + message.oWasm = reader.bytes(); + break; + case 19: + message.opt = (reader.int32() as any); + break; + case 20: + message.oOpt = (reader.int32() as any); + break; + case 21: + message.period = Duration.decode(reader, reader.uint32()); + break; + case 22: + message.oPeriod = Duration.decode(reader, reader.uint32()); + break; + case 23: + message.date = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + break; + case 24: + message.oDate = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + break; + case 25: + message.pubkey = Any.decode(reader, reader.uint32()); + break; + case 26: + message.oPubkey = Any.decode(reader, reader.uint32()); + break; + case 27: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.nums.push(reader.int32()); + } + } else { + message.nums.push(reader.int32()); + } + break; + case 28: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.oNums.push(reader.int32()); + } + } else { + message.oNums.push(reader.int32()); + } + break; + case 29: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.bigs.push(reader.int64()); + } + } else { + message.bigs.push(reader.int64()); + } + break; + case 30: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.oBigs.push(reader.int64()); + } + } else { + message.oBigs.push(reader.int64()); + } + break; + case 31: + message.salts.push(reader.bytes()); + break; + case 32: + message.oSalts.push(reader.bytes()); + break; + case 33: + message.raws.push(reader.bytes()); + break; + case 34: + message.oRaws.push(reader.bytes()); + break; + case 35: + message.wasms.push(reader.bytes()); + break; + case 36: + message.oWasms.push(reader.bytes()); + break; + case 37: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.opts.push((reader.int32() as any)); + } + } else { + message.opts.push((reader.int32() as any)); + } + break; + case 38: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.oOpts.push((reader.int32() as any)); + } + } else { + message.oOpts.push((reader.int32() as any)); + } + break; + case 39: + message.periods.push(Duration.decode(reader, reader.uint32())); + break; + case 40: + message.oPeriods.push(Duration.decode(reader, reader.uint32())); + break; + case 43: + message.protos.push(AccessConfig.decode(reader, reader.uint32())); + break; + case 44: + message.oProtos.push(AccessConfig.decode(reader, reader.uint32())); + break; + case 45: + message.auths.push(Any.decode(reader, reader.uint32())); + break; + case 46: + message.oAuths.push(Any.decode(reader, reader.uint32())); + break; + case 47: + message.dec = Decimal.fromAtomics(reader.string(), 18).toString(); + break; + case 48: + message.oDec = Decimal.fromAtomics(reader.string(), 18).toString(); + break; + case 49: + message.decs.push(Decimal.fromAtomics(reader.string(), 18).toString()); + break; + case 50: + message.oDecs.push(Decimal.fromAtomics(reader.string(), 18).toString()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): EncodingTestForOmit { + const obj = createBaseEncodingTestForOmit(); + if (isSet(object.str)) obj.str = String(object.str); + if (isSet(object.oStr)) obj.oStr = String(object.oStr); + if (isSet(object.b)) obj.b = Boolean(object.b); + if (isSet(object.oB)) obj.oB = Boolean(object.oB); + if (isSet(object.num)) obj.num = Number(object.num); + if (isSet(object.oNum)) obj.oNum = Number(object.oNum); + if (isSet(object.big)) obj.big = BigInt(object.big.toString()); + if (isSet(object.oBig)) obj.oBig = BigInt(object.oBig.toString()); + if (isSet(object.proto)) obj.proto = AccessConfig.fromJSON(object.proto); + if (isSet(object.oProto)) obj.oProto = AccessConfig.fromJSON(object.oProto); + if (isSet(object.auth)) obj.auth = Any.fromJSON(object.auth); + if (isSet(object.oAuth)) obj.oAuth = Any.fromJSON(object.oAuth); + if (isSet(object.salt)) obj.salt = bytesFromBase64(object.salt); + if (isSet(object.oSalt)) obj.oSalt = bytesFromBase64(object.oSalt); + if (isSet(object.raw)) obj.raw = bytesFromBase64(object.raw); + if (isSet(object.oRaw)) obj.oRaw = bytesFromBase64(object.oRaw); + if (isSet(object.wasm)) obj.wasm = bytesFromBase64(object.wasm); + if (isSet(object.oWasm)) obj.oWasm = bytesFromBase64(object.oWasm); + if (isSet(object.opt)) obj.opt = voteOptionFromJSON(object.opt); + if (isSet(object.oOpt)) obj.oOpt = voteOptionFromJSON(object.oOpt); + if (isSet(object.period)) obj.period = Duration.fromJSON(object.period); + if (isSet(object.oPeriod)) obj.oPeriod = Duration.fromJSON(object.oPeriod); + if (isSet(object.date)) obj.date = new Date(object.date); + if (isSet(object.oDate)) obj.oDate = new Date(object.oDate); + if (isSet(object.pubkey)) obj.pubkey = Any.fromJSON(object.pubkey); + if (isSet(object.oPubkey)) obj.oPubkey = Any.fromJSON(object.oPubkey); + if (Array.isArray(object?.nums)) obj.nums = object.nums.map((e: any) => Number(e)); + if (Array.isArray(object?.oNums)) obj.oNums = object.oNums.map((e: any) => Number(e)); + if (Array.isArray(object?.bigs)) obj.bigs = object.bigs.map((e: any) => BigInt(e.toString())); + if (Array.isArray(object?.oBigs)) obj.oBigs = object.oBigs.map((e: any) => BigInt(e.toString())); + if (Array.isArray(object?.salts)) obj.salts = object.salts.map((e: any) => bytesFromBase64(e)); + if (Array.isArray(object?.oSalts)) obj.oSalts = object.oSalts.map((e: any) => bytesFromBase64(e)); + if (Array.isArray(object?.raws)) obj.raws = object.raws.map((e: any) => bytesFromBase64(e)); + if (Array.isArray(object?.oRaws)) obj.oRaws = object.oRaws.map((e: any) => bytesFromBase64(e)); + if (Array.isArray(object?.wasms)) obj.wasms = object.wasms.map((e: any) => bytesFromBase64(e)); + if (Array.isArray(object?.oWasms)) obj.oWasms = object.oWasms.map((e: any) => bytesFromBase64(e)); + if (Array.isArray(object?.opts)) obj.opts = object.opts.map((e: any) => voteOptionFromJSON(e)); + if (Array.isArray(object?.oOpts)) obj.oOpts = object.oOpts.map((e: any) => voteOptionFromJSON(e)); + if (Array.isArray(object?.periods)) obj.periods = object.periods.map((e: any) => Duration.fromJSON(e)); + if (Array.isArray(object?.oPeriods)) obj.oPeriods = object.oPeriods.map((e: any) => Duration.fromJSON(e)); + if (Array.isArray(object?.protos)) obj.protos = object.protos.map((e: any) => AccessConfig.fromJSON(e)); + if (Array.isArray(object?.oProtos)) obj.oProtos = object.oProtos.map((e: any) => AccessConfig.fromJSON(e)); + if (Array.isArray(object?.auths)) obj.auths = object.auths.map((e: any) => Any.fromJSON(e)); + if (Array.isArray(object?.oAuths)) obj.oAuths = object.oAuths.map((e: any) => Any.fromJSON(e)); + if (isSet(object.dec)) obj.dec = String(object.dec); + if (isSet(object.oDec)) obj.oDec = String(object.oDec); + if (Array.isArray(object?.decs)) obj.decs = object.decs.map((e: any) => String(e)); + if (Array.isArray(object?.oDecs)) obj.oDecs = object.oDecs.map((e: any) => String(e)); + return obj; + }, + toJSON(message: EncodingTestForOmit): JsonSafe { + const obj: any = {}; + message.str !== undefined && (obj.str = message.str); + message.oStr !== undefined && (obj.oStr = message.oStr); + message.b !== undefined && (obj.b = message.b); + message.oB !== undefined && (obj.oB = message.oB); + message.num !== undefined && (obj.num = Math.round(message.num)); + message.oNum !== undefined && (obj.oNum = Math.round(message.oNum)); + message.big !== undefined && (obj.big = (message.big || BigInt(0)).toString()); + message.oBig !== undefined && (obj.oBig = (message.oBig || BigInt(0)).toString()); + message.proto !== undefined && (obj.proto = message.proto ? AccessConfig.toJSON(message.proto) : undefined); + message.oProto !== undefined && (obj.oProto = message.oProto ? AccessConfig.toJSON(message.oProto) : undefined); + message.auth !== undefined && (obj.auth = message.auth ? Any.toJSON(message.auth) : undefined); + message.oAuth !== undefined && (obj.oAuth = message.oAuth ? Any.toJSON(message.oAuth) : undefined); + message.salt !== undefined && (obj.salt = base64FromBytes(message.salt !== undefined ? message.salt : new Uint8Array())); + message.oSalt !== undefined && (obj.oSalt = base64FromBytes(message.oSalt !== undefined ? message.oSalt : new Uint8Array())); + message.raw !== undefined && (obj.raw = base64FromBytes(message.raw !== undefined ? message.raw : new Uint8Array())); + message.oRaw !== undefined && (obj.oRaw = base64FromBytes(message.oRaw !== undefined ? message.oRaw : new Uint8Array())); + message.wasm !== undefined && (obj.wasm = base64FromBytes(message.wasm !== undefined ? message.wasm : new Uint8Array())); + message.oWasm !== undefined && (obj.oWasm = base64FromBytes(message.oWasm !== undefined ? message.oWasm : new Uint8Array())); + message.opt !== undefined && (obj.opt = voteOptionToJSON(message.opt)); + message.oOpt !== undefined && (obj.oOpt = voteOptionToJSON(message.oOpt)); + message.period !== undefined && (obj.period = message.period ? Duration.toJSON(message.period) : undefined); + message.oPeriod !== undefined && (obj.oPeriod = message.oPeriod ? Duration.toJSON(message.oPeriod) : undefined); + message.date !== undefined && (obj.date = message.date.toISOString()); + message.oDate !== undefined && (obj.oDate = message.oDate.toISOString()); + message.pubkey !== undefined && (obj.pubkey = message.pubkey ? Any.toJSON(message.pubkey) : undefined); + message.oPubkey !== undefined && (obj.oPubkey = message.oPubkey ? Any.toJSON(message.oPubkey) : undefined); + if (message.nums) { + obj.nums = message.nums.map(e => Math.round(e)); + } else { + obj.nums = []; + } + if (message.oNums) { + obj.oNums = message.oNums.map(e => Math.round(e)); + } else { + obj.oNums = []; + } + if (message.bigs) { + obj.bigs = message.bigs.map(e => (e || BigInt(0)).toString()); + } else { + obj.bigs = []; + } + if (message.oBigs) { + obj.oBigs = message.oBigs.map(e => (e || BigInt(0)).toString()); + } else { + obj.oBigs = []; + } + if (message.salts) { + obj.salts = message.salts.map(e => base64FromBytes(e !== undefined ? e : new Uint8Array())); + } else { + obj.salts = []; + } + if (message.oSalts) { + obj.oSalts = message.oSalts.map(e => base64FromBytes(e !== undefined ? e : new Uint8Array())); + } else { + obj.oSalts = []; + } + if (message.raws) { + obj.raws = message.raws.map(e => base64FromBytes(e !== undefined ? e : new Uint8Array())); + } else { + obj.raws = []; + } + if (message.oRaws) { + obj.oRaws = message.oRaws.map(e => base64FromBytes(e !== undefined ? e : new Uint8Array())); + } else { + obj.oRaws = []; + } + if (message.wasms) { + obj.wasms = message.wasms.map(e => base64FromBytes(e !== undefined ? e : new Uint8Array())); + } else { + obj.wasms = []; + } + if (message.oWasms) { + obj.oWasms = message.oWasms.map(e => base64FromBytes(e !== undefined ? e : new Uint8Array())); + } else { + obj.oWasms = []; + } + if (message.opts) { + obj.opts = message.opts.map(e => voteOptionToJSON(e)); + } else { + obj.opts = []; + } + if (message.oOpts) { + obj.oOpts = message.oOpts.map(e => voteOptionToJSON(e)); + } else { + obj.oOpts = []; + } + if (message.periods) { + obj.periods = message.periods.map(e => e ? Duration.toJSON(e) : undefined); + } else { + obj.periods = []; + } + if (message.oPeriods) { + obj.oPeriods = message.oPeriods.map(e => e ? Duration.toJSON(e) : undefined); + } else { + obj.oPeriods = []; + } + if (message.protos) { + obj.protos = message.protos.map(e => e ? AccessConfig.toJSON(e) : undefined); + } else { + obj.protos = []; + } + if (message.oProtos) { + obj.oProtos = message.oProtos.map(e => e ? AccessConfig.toJSON(e) : undefined); + } else { + obj.oProtos = []; + } + if (message.auths) { + obj.auths = message.auths.map(e => e ? Any.toJSON(e) : undefined); + } else { + obj.auths = []; + } + if (message.oAuths) { + obj.oAuths = message.oAuths.map(e => e ? Any.toJSON(e) : undefined); + } else { + obj.oAuths = []; + } + message.dec !== undefined && (obj.dec = message.dec); + message.oDec !== undefined && (obj.oDec = message.oDec); + if (message.decs) { + obj.decs = message.decs.map(e => e); + } else { + obj.decs = []; + } + if (message.oDecs) { + obj.oDecs = message.oDecs.map(e => e); + } else { + obj.oDecs = []; + } + return obj; + }, + fromPartial(object: DeepPartial): EncodingTestForOmit { + const message = createBaseEncodingTestForOmit(); + message.str = object.str ?? ""; + message.oStr = object.oStr ?? ""; + message.b = object.b ?? false; + message.oB = object.oB ?? false; + message.num = object.num ?? 0; + message.oNum = object.oNum ?? 0; + if (object.big !== undefined && object.big !== null) { + message.big = BigInt(object.big.toString()); + } + if (object.oBig !== undefined && object.oBig !== null) { + message.oBig = BigInt(object.oBig.toString()); + } + if (object.proto !== undefined && object.proto !== null) { + message.proto = AccessConfig.fromPartial(object.proto); + } + if (object.oProto !== undefined && object.oProto !== null) { + message.oProto = AccessConfig.fromPartial(object.oProto); + } + if (object.auth !== undefined && object.auth !== null) { + message.auth = Any.fromPartial(object.auth); + } + if (object.oAuth !== undefined && object.oAuth !== null) { + message.oAuth = Any.fromPartial(object.oAuth); + } + message.salt = object.salt ?? new Uint8Array(); + message.oSalt = object.oSalt ?? new Uint8Array(); + message.raw = object.raw ?? new Uint8Array(); + message.oRaw = object.oRaw ?? new Uint8Array(); + message.wasm = object.wasm ?? new Uint8Array(); + message.oWasm = object.oWasm ?? new Uint8Array(); + message.opt = object.opt ?? 0; + message.oOpt = object.oOpt ?? 0; + if (object.period !== undefined && object.period !== null) { + message.period = Duration.fromPartial(object.period); + } + if (object.oPeriod !== undefined && object.oPeriod !== null) { + message.oPeriod = Duration.fromPartial(object.oPeriod); + } + message.date = object.date ?? undefined; + message.oDate = object.oDate ?? undefined; + if (object.pubkey !== undefined && object.pubkey !== null) { + message.pubkey = Any.fromPartial(object.pubkey); + } + if (object.oPubkey !== undefined && object.oPubkey !== null) { + message.oPubkey = Any.fromPartial(object.oPubkey); + } + message.nums = object.nums?.map(e => e) || []; + message.oNums = object.oNums?.map(e => e) || []; + message.bigs = object.bigs?.map(e => BigInt(e.toString())) || []; + message.oBigs = object.oBigs?.map(e => BigInt(e.toString())) || []; + message.salts = object.salts?.map(e => e) || []; + message.oSalts = object.oSalts?.map(e => e) || []; + message.raws = object.raws?.map(e => e) || []; + message.oRaws = object.oRaws?.map(e => e) || []; + message.wasms = object.wasms?.map(e => e) || []; + message.oWasms = object.oWasms?.map(e => e) || []; + message.opts = object.opts?.map(e => e) || []; + message.oOpts = object.oOpts?.map(e => e) || []; + message.periods = object.periods?.map(e => Duration.fromPartial(e)) || []; + message.oPeriods = object.oPeriods?.map(e => Duration.fromPartial(e)) || []; + message.protos = object.protos?.map(e => AccessConfig.fromPartial(e)) || []; + message.oProtos = object.oProtos?.map(e => AccessConfig.fromPartial(e)) || []; + message.auths = object.auths?.map(e => Any.fromPartial(e)) || []; + message.oAuths = object.oAuths?.map(e => Any.fromPartial(e)) || []; + message.dec = object.dec ?? ""; + message.oDec = object.oDec ?? ""; + message.decs = object.decs?.map(e => e) || []; + message.oDecs = object.oDecs?.map(e => e) || []; + return message; + }, + fromSDK(object: EncodingTestForOmitSDKType): EncodingTestForOmit { + return { + str: object?.str, + oStr: object?.o_str, + b: object?.b, + oB: object?.o_b, + num: object?.num, + oNum: object?.o_num, + big: object?.big, + oBig: object?.o_big, + proto: object.proto ? AccessConfig.fromSDK(object.proto) : undefined, + oProto: object.o_proto ? AccessConfig.fromSDK(object.o_proto) : undefined, + auth: object.auth ? Any.fromSDK(object.auth) : undefined, + oAuth: object.o_auth ? Any.fromSDK(object.o_auth) : undefined, + salt: object?.salt, + oSalt: object?.o_salt, + raw: object?.raw, + oRaw: object?.o_raw, + wasm: object?.wasm, + oWasm: object?.o_wasm, + opt: isSet(object.opt) ? voteOptionFromJSON(object.opt) : -1, + oOpt: isSet(object.o_opt) ? voteOptionFromJSON(object.o_opt) : -1, + period: object.period ? Duration.fromSDK(object.period) : undefined, + oPeriod: object.o_period ? Duration.fromSDK(object.o_period) : undefined, + date: object.date ?? undefined, + oDate: object.o_date ?? undefined, + pubkey: object.pubkey ? Any.fromSDK(object.pubkey) : undefined, + oPubkey: object.o_pubkey ? Any.fromSDK(object.o_pubkey) : undefined, + nums: Array.isArray(object?.nums) ? object.nums.map((e: any) => e) : [], + oNums: Array.isArray(object?.o_nums) ? object.o_nums.map((e: any) => e) : [], + bigs: Array.isArray(object?.bigs) ? object.bigs.map((e: any) => e) : [], + oBigs: Array.isArray(object?.o_bigs) ? object.o_bigs.map((e: any) => e) : [], + salts: Array.isArray(object?.salts) ? object.salts.map((e: any) => e) : [], + oSalts: Array.isArray(object?.o_salts) ? object.o_salts.map((e: any) => e) : [], + raws: Array.isArray(object?.raws) ? object.raws.map((e: any) => e) : [], + oRaws: Array.isArray(object?.o_raws) ? object.o_raws.map((e: any) => e) : [], + wasms: Array.isArray(object?.wasms) ? object.wasms.map((e: any) => e) : [], + oWasms: Array.isArray(object?.o_wasms) ? object.o_wasms.map((e: any) => e) : [], + opts: Array.isArray(object?.opts) ? object.opts.map((e: any) => voteOptionFromJSON(e)) : [], + oOpts: Array.isArray(object?.o_opts) ? object.o_opts.map((e: any) => voteOptionFromJSON(e)) : [], + periods: Array.isArray(object?.periods) ? object.periods.map((e: any) => Duration.fromSDK(e)) : [], + oPeriods: Array.isArray(object?.o_periods) ? object.o_periods.map((e: any) => Duration.fromSDK(e)) : [], + protos: Array.isArray(object?.protos) ? object.protos.map((e: any) => AccessConfig.fromSDK(e)) : [], + oProtos: Array.isArray(object?.o_protos) ? object.o_protos.map((e: any) => AccessConfig.fromSDK(e)) : [], + auths: Array.isArray(object?.auths) ? object.auths.map((e: any) => Any.fromSDK(e)) : [], + oAuths: Array.isArray(object?.o_auths) ? object.o_auths.map((e: any) => Any.fromSDK(e)) : [], + dec: object?.dec, + oDec: object?.o_dec, + decs: Array.isArray(object?.decs) ? object.decs.map((e: any) => e) : [], + oDecs: Array.isArray(object?.o_decs) ? object.o_decs.map((e: any) => e) : [] + }; + }, + fromSDKJSON(object: any): EncodingTestForOmitSDKType { + return { + str: isSet(object.str) ? String(object.str) : "", + o_str: isSet(object.o_str) ? String(object.o_str) : "", + b: isSet(object.b) ? Boolean(object.b) : false, + o_b: isSet(object.o_b) ? Boolean(object.o_b) : false, + num: isSet(object.num) ? Number(object.num) : 0, + o_num: isSet(object.o_num) ? Number(object.o_num) : 0, + big: isSet(object.big) ? BigInt(object.big.toString()) : BigInt(0), + o_big: isSet(object.o_big) ? BigInt(object.o_big.toString()) : BigInt(0), + proto: isSet(object.proto) ? AccessConfig.fromSDKJSON(object.proto) : undefined, + o_proto: isSet(object.o_proto) ? AccessConfig.fromSDKJSON(object.o_proto) : undefined, + auth: isSet(object.auth) ? Any.fromSDKJSON(object.auth) : undefined, + o_auth: isSet(object.o_auth) ? Any.fromSDKJSON(object.o_auth) : undefined, + salt: isSet(object.salt) ? bytesFromBase64(object.salt) : new Uint8Array(), + o_salt: isSet(object.o_salt) ? bytesFromBase64(object.o_salt) : new Uint8Array(), + raw: isSet(object.raw) ? bytesFromBase64(object.raw) : new Uint8Array(), + o_raw: isSet(object.o_raw) ? bytesFromBase64(object.o_raw) : new Uint8Array(), + wasm: isSet(object.wasm) ? bytesFromBase64(object.wasm) : new Uint8Array(), + o_wasm: isSet(object.o_wasm) ? bytesFromBase64(object.o_wasm) : new Uint8Array(), + opt: isSet(object.opt) ? voteOptionFromJSON(object.opt) : -1, + o_opt: isSet(object.o_opt) ? voteOptionFromJSON(object.o_opt) : -1, + period: isSet(object.period) ? Duration.fromSDKJSON(object.period) : undefined, + o_period: isSet(object.o_period) ? Duration.fromSDKJSON(object.o_period) : undefined, + date: isSet(object.date) ? new Date(object.date) : undefined, + o_date: isSet(object.o_date) ? new Date(object.o_date) : undefined, + pubkey: isSet(object.pubkey) ? Any.fromSDKJSON(object.pubkey) : undefined, + o_pubkey: isSet(object.o_pubkey) ? Any.fromSDKJSON(object.o_pubkey) : undefined, + nums: Array.isArray(object?.nums) ? object.nums.map((e: any) => Number(e)) : [], + o_nums: Array.isArray(object?.o_nums) ? object.o_nums.map((e: any) => Number(e)) : [], + bigs: Array.isArray(object?.bigs) ? object.bigs.map((e: any) => BigInt(e.toString())) : [], + o_bigs: Array.isArray(object?.o_bigs) ? object.o_bigs.map((e: any) => BigInt(e.toString())) : [], + salts: Array.isArray(object?.salts) ? object.salts.map((e: any) => bytesFromBase64(e)) : [], + o_salts: Array.isArray(object?.o_salts) ? object.o_salts.map((e: any) => bytesFromBase64(e)) : [], + raws: Array.isArray(object?.raws) ? object.raws.map((e: any) => bytesFromBase64(e)) : [], + o_raws: Array.isArray(object?.o_raws) ? object.o_raws.map((e: any) => bytesFromBase64(e)) : [], + wasms: Array.isArray(object?.wasms) ? object.wasms.map((e: any) => bytesFromBase64(e)) : [], + o_wasms: Array.isArray(object?.o_wasms) ? object.o_wasms.map((e: any) => bytesFromBase64(e)) : [], + opts: Array.isArray(object?.opts) ? object.opts.map((e: any) => voteOptionFromJSON(e)) : [], + o_opts: Array.isArray(object?.o_opts) ? object.o_opts.map((e: any) => voteOptionFromJSON(e)) : [], + periods: Array.isArray(object?.periods) ? object.periods.map((e: any) => Duration.fromSDKJSON(e)) : [], + o_periods: Array.isArray(object?.o_periods) ? object.o_periods.map((e: any) => Duration.fromSDKJSON(e)) : [], + protos: Array.isArray(object?.protos) ? object.protos.map((e: any) => AccessConfig.fromSDKJSON(e)) : [], + o_protos: Array.isArray(object?.o_protos) ? object.o_protos.map((e: any) => AccessConfig.fromSDKJSON(e)) : [], + auths: Array.isArray(object?.auths) ? object.auths.map((e: any) => Any.fromSDKJSON(e)) : [], + o_auths: Array.isArray(object?.o_auths) ? object.o_auths.map((e: any) => Any.fromSDKJSON(e)) : [], + dec: isSet(object.dec) ? String(object.dec) : "", + o_dec: isSet(object.o_dec) ? String(object.o_dec) : "", + decs: Array.isArray(object?.decs) ? object.decs.map((e: any) => String(e)) : [], + o_decs: Array.isArray(object?.o_decs) ? object.o_decs.map((e: any) => String(e)) : [] + }; + }, + toSDK(message: EncodingTestForOmit): EncodingTestForOmitSDKType { + const obj: any = {}; + obj.str = message.str; + obj.o_str = message.oStr; + obj.b = message.b; + obj.o_b = message.oB; + obj.num = message.num; + obj.o_num = message.oNum; + obj.big = message.big; + obj.o_big = message.oBig; + message.proto !== undefined && (obj.proto = message.proto ? AccessConfig.toSDK(message.proto) : undefined); + message.oProto !== undefined && (obj.o_proto = message.oProto ? AccessConfig.toSDK(message.oProto) : undefined); + message.auth !== undefined && (obj.auth = message.auth ? Any.toSDK(message.auth) : undefined); + message.oAuth !== undefined && (obj.o_auth = message.oAuth ? Any.toSDK(message.oAuth) : undefined); + obj.salt = message.salt; + obj.o_salt = message.oSalt; + obj.raw = message.raw; + obj.o_raw = message.oRaw; + obj.wasm = message.wasm; + obj.o_wasm = message.oWasm; + message.opt !== undefined && (obj.opt = voteOptionToJSON(message.opt)); + message.oOpt !== undefined && (obj.o_opt = voteOptionToJSON(message.oOpt)); + message.period !== undefined && (obj.period = message.period ? Duration.toSDK(message.period) : undefined); + message.oPeriod !== undefined && (obj.o_period = message.oPeriod ? Duration.toSDK(message.oPeriod) : undefined); + message.date !== undefined && (obj.date = message.date ?? undefined); + message.oDate !== undefined && (obj.o_date = message.oDate ?? undefined); + message.pubkey !== undefined && (obj.pubkey = message.pubkey ? Any.toSDK(message.pubkey) : undefined); + message.oPubkey !== undefined && (obj.o_pubkey = message.oPubkey ? Any.toSDK(message.oPubkey) : undefined); + if (message.nums) { + obj.nums = message.nums.map(e => e); + } else { + obj.nums = []; + } + if (message.oNums) { + obj.o_nums = message.oNums.map(e => e); + } else { + obj.o_nums = []; + } + if (message.bigs) { + obj.bigs = message.bigs.map(e => e); + } else { + obj.bigs = []; + } + if (message.oBigs) { + obj.o_bigs = message.oBigs.map(e => e); + } else { + obj.o_bigs = []; + } + if (message.salts) { + obj.salts = message.salts.map(e => e); + } else { + obj.salts = []; + } + if (message.oSalts) { + obj.o_salts = message.oSalts.map(e => e); + } else { + obj.o_salts = []; + } + if (message.raws) { + obj.raws = message.raws.map(e => e); + } else { + obj.raws = []; + } + if (message.oRaws) { + obj.o_raws = message.oRaws.map(e => e); + } else { + obj.o_raws = []; + } + if (message.wasms) { + obj.wasms = message.wasms.map(e => e); + } else { + obj.wasms = []; + } + if (message.oWasms) { + obj.o_wasms = message.oWasms.map(e => e); + } else { + obj.o_wasms = []; + } + if (message.opts) { + obj.opts = message.opts.map(e => voteOptionToJSON(e)); + } else { + obj.opts = []; + } + if (message.oOpts) { + obj.o_opts = message.oOpts.map(e => voteOptionToJSON(e)); + } else { + obj.o_opts = []; + } + if (message.periods) { + obj.periods = message.periods.map(e => e ? Duration.toSDK(e) : undefined); + } else { + obj.periods = []; + } + if (message.oPeriods) { + obj.o_periods = message.oPeriods.map(e => e ? Duration.toSDK(e) : undefined); + } else { + obj.o_periods = []; + } + if (message.protos) { + obj.protos = message.protos.map(e => e ? AccessConfig.toSDK(e) : undefined); + } else { + obj.protos = []; + } + if (message.oProtos) { + obj.o_protos = message.oProtos.map(e => e ? AccessConfig.toSDK(e) : undefined); + } else { + obj.o_protos = []; + } + if (message.auths) { + obj.auths = message.auths.map(e => e ? Any.toSDK(e) : undefined); + } else { + obj.auths = []; + } + if (message.oAuths) { + obj.o_auths = message.oAuths.map(e => e ? Any.toSDK(e) : undefined); + } else { + obj.o_auths = []; + } + obj.dec = message.dec; + obj.o_dec = message.oDec; + if (message.decs) { + obj.decs = message.decs.map(e => e); + } else { + obj.decs = []; + } + if (message.oDecs) { + obj.o_decs = message.oDecs.map(e => e); + } else { + obj.o_decs = []; + } + return obj; + }, + fromAmino(object: EncodingTestForOmitAmino): EncodingTestForOmit { + const message = createBaseEncodingTestForOmit(); + if (object.str !== undefined && object.str !== null) { + message.str = object.str; + } + if (object.o_str !== undefined && object.o_str !== null) { + message.oStr = object.o_str; + } + if (object.b !== undefined && object.b !== null) { + message.b = object.b; + } + if (object.o_b !== undefined && object.o_b !== null) { + message.oB = object.o_b; + } + if (object.num !== undefined && object.num !== null) { + message.num = object.num; + } + if (object.o_num !== undefined && object.o_num !== null) { + message.oNum = object.o_num; + } + if (object.big !== undefined && object.big !== null) { + message.big = BigInt(object.big); + } + if (object.o_big !== undefined && object.o_big !== null) { + message.oBig = BigInt(object.o_big); + } + if (object.proto !== undefined && object.proto !== null) { + message.proto = AccessConfig.fromAmino(object.proto); + } + if (object.o_proto !== undefined && object.o_proto !== null) { + message.oProto = AccessConfig.fromAmino(object.o_proto); + } + if (object.auth !== undefined && object.auth !== null) { + message.auth = Any.fromAmino(object.auth); + } + if (object.o_auth !== undefined && object.o_auth !== null) { + message.oAuth = Any.fromAmino(object.o_auth); + } + if (object.salt !== undefined && object.salt !== null) { + message.salt = bytesFromBase64(object.salt); + } + if (object.o_salt !== undefined && object.o_salt !== null) { + message.oSalt = bytesFromBase64(object.o_salt); + } + if (object.raw !== undefined && object.raw !== null) { + message.raw = toUtf8(JSON.stringify(object.raw)); + } + if (object.o_raw !== undefined && object.o_raw !== null) { + message.oRaw = toUtf8(JSON.stringify(object.o_raw)); + } + if (object.wasm !== undefined && object.wasm !== null) { + message.wasm = fromBase64(object.wasm); + } + if (object.o_wasm !== undefined && object.o_wasm !== null) { + message.oWasm = fromBase64(object.o_wasm); + } + if (object.opt !== undefined && object.opt !== null) { + message.opt = object.opt; + } + if (object.o_opt !== undefined && object.o_opt !== null) { + message.oOpt = object.o_opt; + } + if (object.period !== undefined && object.period !== null) { + message.period = Duration.fromAmino(object.period); + } + if (object.o_period !== undefined && object.o_period !== null) { + message.oPeriod = Duration.fromAmino(object.o_period); + } + if (object.date !== undefined && object.date !== null) { + message.date = fromTimestamp(Timestamp.fromAmino(object.date)); + } + if (object.o_date !== undefined && object.o_date !== null) { + message.oDate = fromTimestamp(Timestamp.fromAmino(object.o_date)); + } + if (object.pubkey !== undefined && object.pubkey !== null) { + message.pubkey = encodePubkey(object.pubkey); + } + if (object.o_pubkey !== undefined && object.o_pubkey !== null) { + message.oPubkey = encodePubkey(object.o_pubkey); + } + message.nums = object.nums?.map(e => e) || []; + message.oNums = object.o_nums?.map(e => e) || []; + message.bigs = object.bigs?.map(e => BigInt(e)) || []; + message.oBigs = object.o_bigs?.map(e => BigInt(e)) || []; + message.salts = object.salts?.map(e => bytesFromBase64(e)) || []; + message.oSalts = object.o_salts?.map(e => bytesFromBase64(e)) || []; + message.raws = object.raws?.map(e => toUtf8(JSON.stringify(e))) || []; + message.oRaws = object.o_raws?.map(e => toUtf8(JSON.stringify(e))) || []; + message.wasms = object.wasms?.map(e => fromBase64(e)) || []; + message.oWasms = object.o_wasms?.map(e => fromBase64(e)) || []; + message.opts = object.opts?.map(e => e) || []; + message.oOpts = object.o_opts?.map(e => e) || []; + message.periods = object.periods?.map(e => Duration.fromAmino(e)) || []; + message.oPeriods = object.o_periods?.map(e => Duration.fromAmino(e)) || []; + message.protos = object.protos?.map(e => AccessConfig.fromAmino(e)) || []; + message.oProtos = object.o_protos?.map(e => AccessConfig.fromAmino(e)) || []; + message.auths = object.auths?.map(e => Any.fromAmino(e)) || []; + message.oAuths = object.o_auths?.map(e => Any.fromAmino(e)) || []; + if (object.dec !== undefined && object.dec !== null) { + message.dec = object.dec; + } + if (object.o_dec !== undefined && object.o_dec !== null) { + message.oDec = object.o_dec; + } + message.decs = object.decs?.map(e => e) || []; + message.oDecs = object.o_decs?.map(e => e) || []; + return message; + }, + toAmino(message: EncodingTestForOmit): EncodingTestForOmitAmino { + const obj: any = {}; + obj.str = message.str ?? ""; + obj.o_str = message.oStr === "" ? undefined : message.oStr; + obj.b = message.b ?? false; + obj.o_b = message.oB === false ? undefined : message.oB; + obj.num = message.num ?? 0; + obj.o_num = message.oNum === 0 ? undefined : message.oNum; + obj.big = message.big ? (message.big?.toString)() : "0"; + obj.o_big = message.oBig !== BigInt(0) ? (message.oBig?.toString)() : undefined; + obj.proto = message.proto ? AccessConfig.toAmino(message.proto) : AccessConfig.toAmino(AccessConfig.fromPartial({})); + obj.o_proto = message.oProto ? AccessConfig.toAmino(message.oProto) : undefined; + obj.auth = message.auth ? Any.toAmino(message.auth) : Any.toAmino(Any.fromPartial({})); + obj.o_auth = message.oAuth ? Any.toAmino(message.oAuth) : undefined; + obj.salt = message.salt ? base64FromBytes(message.salt) : ""; + obj.o_salt = message.oSalt ? base64FromBytes(message.oSalt) : undefined; + obj.raw = message.raw ? JSON.parse(fromUtf8(message.raw)) : {}; + obj.o_raw = message.oRaw ? JSON.parse(fromUtf8(message.oRaw)) : undefined; + obj.wasm = message.wasm ? toBase64(message.wasm) : ""; + obj.o_wasm = message.oWasm ? toBase64(message.oWasm) : undefined; + obj.opt = message.opt ?? 0; + obj.o_opt = message.oOpt === 0 ? undefined : message.oOpt; + obj.period = message.period ? Duration.toAmino(message.period) : Duration.toAmino(Duration.fromPartial({})); + obj.o_period = message.oPeriod ? Duration.toAmino(message.oPeriod) : undefined; + obj.date = message.date ? Timestamp.toAmino(toTimestamp(message.date)) : null; + obj.o_date = message.oDate ? Timestamp.toAmino(toTimestamp(message.oDate)) : undefined; + obj.pubkey = message.pubkey ? decodePubkey(message.pubkey) : null; + obj.o_pubkey = message.oPubkey ? decodePubkey(message.oPubkey) : undefined; + if (message.nums) { + obj.nums = message.nums.map(e => e); + } else { + obj.nums = message.nums; + } + if (message.oNums) { + obj.o_nums = message.oNums.map(e => e); + } else { + obj.o_nums = message.oNums; + } + if (message.bigs) { + obj.bigs = message.bigs.map(e => e.toString()); + } else { + obj.bigs = message.bigs; + } + if (message.oBigs) { + obj.o_bigs = message.oBigs.map(e => e.toString()); + } else { + obj.o_bigs = message.oBigs; + } + if (message.salts) { + obj.salts = message.salts.map(e => base64FromBytes(e)); + } else { + obj.salts = message.salts; + } + if (message.oSalts) { + obj.o_salts = message.oSalts.map(e => base64FromBytes(e)); + } else { + obj.o_salts = message.oSalts; + } + if (message.raws) { + obj.raws = message.raws.map(e => JSON.parse(fromUtf8(e))); + } else { + obj.raws = message.raws; + } + if (message.oRaws) { + obj.o_raws = message.oRaws.map(e => JSON.parse(fromUtf8(e))); + } else { + obj.o_raws = message.oRaws; + } + if (message.wasms) { + obj.wasms = message.wasms.map(e => toBase64(e)); + } else { + obj.wasms = message.wasms; + } + if (message.oWasms) { + obj.o_wasms = message.oWasms.map(e => toBase64(e)); + } else { + obj.o_wasms = message.oWasms; + } + if (message.opts) { + obj.opts = message.opts.map(e => e); + } else { + obj.opts = message.opts; + } + if (message.oOpts) { + obj.o_opts = message.oOpts.map(e => e); + } else { + obj.o_opts = message.oOpts; + } + if (message.periods) { + obj.periods = message.periods.map(e => e ? Duration.toAmino(e) : undefined); + } else { + obj.periods = message.periods; + } + if (message.oPeriods) { + obj.o_periods = message.oPeriods.map(e => e ? Duration.toAmino(e) : undefined); + } else { + obj.o_periods = message.oPeriods; + } + if (message.protos) { + obj.protos = message.protos.map(e => e ? AccessConfig.toAmino(e) : undefined); + } else { + obj.protos = message.protos; + } + if (message.oProtos) { + obj.o_protos = message.oProtos.map(e => e ? AccessConfig.toAmino(e) : undefined); + } else { + obj.o_protos = message.oProtos; + } + if (message.auths) { + obj.auths = message.auths.map(e => e ? Any.toAmino(e) : undefined); + } else { + obj.auths = message.auths; + } + if (message.oAuths) { + obj.o_auths = message.oAuths.map(e => e ? Any.toAmino(e) : undefined); + } else { + obj.o_auths = message.oAuths; + } + obj.dec = message.dec ?? ""; + obj.o_dec = message.oDec === "" ? undefined : message.oDec; + if (message.decs) { + obj.decs = message.decs.map(e => e); + } else { + obj.decs = message.decs; + } + if (message.oDecs) { + obj.o_decs = message.oDecs.map(e => e); + } else { + obj.o_decs = message.oDecs; + } + return obj; + }, + fromAminoMsg(object: EncodingTestForOmitAminoMsg): EncodingTestForOmit { + return EncodingTestForOmit.fromAmino(object.value); + }, + fromProtoMsg(message: EncodingTestForOmitProtoMsg): EncodingTestForOmit { + return EncodingTestForOmit.decode(message.value); + }, + toProto(message: EncodingTestForOmit): Uint8Array { + return EncodingTestForOmit.encode(message).finish(); + }, + toProtoMsg(message: EncodingTestForOmit): EncodingTestForOmitProtoMsg { + return { + typeUrl: "/misc.EncodingTestForOmit", + value: EncodingTestForOmit.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/misc/output-base64/misc/bundle.ts b/__fixtures__/misc/output-base64/misc/bundle.ts new file mode 100644 index 0000000000..b01459ff18 --- /dev/null +++ b/__fixtures__/misc/output-base64/misc/bundle.ts @@ -0,0 +1,20 @@ +import * as _190 from "./all_fields"; +import * as _191 from "./eval_request"; +import * as _192 from "./nest"; +import * as _193 from "./tx"; +import * as _194 from "./tx.amino"; +import * as _195 from "./tx.registry"; +import * as _196 from "./tx.rpc.msg"; +import * as _197 from "./rpc.tx"; +export const misc = { + ..._190, + ..._191, + ..._192, + ..._193, + ..._194, + ..._195, + ..._196, + ClientFactory: { + ..._197 + } +}; \ No newline at end of file diff --git a/__fixtures__/misc/output-base64/misc/client.ts b/__fixtures__/misc/output-base64/misc/client.ts new file mode 100644 index 0000000000..ee9a8bda9d --- /dev/null +++ b/__fixtures__/misc/output-base64/misc/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 miscTxRegistry from "./tx.registry"; +import * as miscTxAmino from "./tx.amino"; +export const miscAminoConverters = { + ...miscTxAmino.AminoConverter +}; +export const miscProtoRegistry: ReadonlyArray<[string, GeneratedType]> = [...miscTxRegistry.registry]; +export const getSigningMiscClientOptions = ({ + defaultTypes = defaultRegistryTypes +}: { + defaultTypes?: ReadonlyArray<[string, GeneratedType]>; +} = {}): { + registry: Registry; + aminoTypes: AminoTypes; +} => { + const registry = new Registry([...defaultTypes, ...miscProtoRegistry]); + const aminoTypes = new AminoTypes({ + ...miscAminoConverters + }); + return { + registry, + aminoTypes + }; +}; +export const getSigningMiscClient = async ({ + rpcEndpoint, + signer, + defaultTypes = defaultRegistryTypes +}: { + rpcEndpoint: string | HttpEndpoint; + signer: OfflineSigner; + defaultTypes?: ReadonlyArray<[string, GeneratedType]>; +}) => { + const { + registry, + aminoTypes + } = getSigningMiscClientOptions({ + 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__/misc/output-base64/misc/eval_request.ts b/__fixtures__/misc/output-base64/misc/eval_request.ts new file mode 100644 index 0000000000..d439afc11d --- /dev/null +++ b/__fixtures__/misc/output-base64/misc/eval_request.ts @@ -0,0 +1,952 @@ +import { ExprValue, ExprValueAmino, ExprValueSDKType, IdRef, IdRefAmino, IdRefSDKType } from "../google/api/expr/v1alpha1/eval"; +import { FeatureSet_Utf8Validation, FeatureSet_Utf8ValidationSDKType, featureSet_Utf8ValidationFromJSON, featureSet_Utf8ValidationToJSON } from "../google/protobuf/descriptor"; +import { TestNest_Graph, TestNest_GraphAmino, TestNest_GraphSDKType } from "./nest"; +import { BinaryReader, BinaryWriter } from "../binary"; +import { isSet, DeepPartial, isObject } from "../helpers"; +import { JsonSafe } from "../json-safe"; +export const protobufPackage = "misc"; +/** 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 const VoteOptionAmino = 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"; + } +} +export interface EvalRequest_BindingsEntry { + key: string; + value?: ExprValue; +} +export interface EvalRequest_BindingsEntryProtoMsg { + typeUrl: string; + value: Uint8Array; +} +export interface EvalRequest_BindingsEntryAmino { + key?: string; + value?: ExprValueAmino; +} +export interface EvalRequest_BindingsEntryAminoMsg { + type: string; + value: EvalRequest_BindingsEntryAmino; +} +export interface EvalRequest_BindingsEntrySDKType { + key: string; + value?: ExprValueSDKType; +} +export interface EvalRequest_RefsEntry { + key: string; + value?: IdRef; +} +export interface EvalRequest_RefsEntryProtoMsg { + typeUrl: string; + value: Uint8Array; +} +export interface EvalRequest_RefsEntryAmino { + key?: string; + value?: IdRefAmino; +} +export interface EvalRequest_RefsEntryAminoMsg { + type: string; + value: EvalRequest_RefsEntryAmino; +} +export interface EvalRequest_RefsEntrySDKType { + key: string; + value?: IdRefSDKType; +} +export interface EvalRequest { + /** + * 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; + }; + refs: { + [key: string]: IdRef; + }; + testNum: number; + testString: string; + testBool: boolean; + instantiatePermission?: AccessConfig; + /** [(gogoproto.nullable) = false] wouldn't work in this case */ + id?: string; + name?: string; + testArray: string[]; + opt: FeatureSet_Utf8Validation; + graph?: TestNest_Graph; +} +export interface EvalRequestProtoMsg { + typeUrl: "/misc.EvalRequest"; + value: Uint8Array; +} +export interface EvalRequestAmino { + /** + * 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]: ExprValueAmino; + }; + refs?: { + [key: string]: IdRefAmino; + }; + test_num?: number; + test_string?: string; + test_bool?: boolean; + instantiate_permission?: AccessConfigAmino; + /** [(gogoproto.nullable) = false] wouldn't work in this case */ + id?: string; + name?: string; + test_array?: string[]; + opt: FeatureSet_Utf8Validation; + graph?: TestNest_GraphAmino; +} +export interface EvalRequestAminoMsg { + type: "/misc.EvalRequest"; + value: EvalRequestAmino; +} +export interface EvalRequestSDKType { + bindings: { + [key: string]: ExprValueSDKType; + }; + refs: { + [key: string]: IdRefSDKType; + }; + test_num: number; + test_string: string; + test_bool: boolean; + instantiate_permission?: AccessConfigSDKType; + id?: string; + name?: string; + test_array: string[]; + opt: FeatureSet_Utf8Validation; + graph?: TestNest_GraphSDKType; +} +export interface AccessConfig { + sender: string; +} +export interface AccessConfigProtoMsg { + typeUrl: "/misc.AccessConfig"; + value: Uint8Array; +} +export interface AccessConfigAmino { + sender?: string; +} +export interface AccessConfigAminoMsg { + type: "/misc.AccessConfig"; + value: AccessConfigAmino; +} +export interface AccessConfigSDKType { + sender: string; +} +export interface GenericAuthorization { + /** Msg, identified by it's type URL, to grant unrestricted permissions to execute */ + msg: string; +} +export interface GenericAuthorizationProtoMsg { + typeUrl: "/misc.GenericAuthorization"; + value: Uint8Array; +} +export interface GenericAuthorizationAmino { + /** Msg, identified by it's type URL, to grant unrestricted permissions to execute */ + msg?: string; +} +export interface GenericAuthorizationAminoMsg { + type: "/misc.GenericAuthorization"; + value: GenericAuthorizationAmino; +} +export interface GenericAuthorizationSDKType { + msg: string; +} +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 !== "") { + 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_RefsEntry(): EvalRequest_RefsEntry { + return { + key: "", + value: undefined + }; +} +export const EvalRequest_RefsEntry = { + encode(message: EvalRequest_RefsEntry, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.key !== "") { + writer.uint32(10).string(message.key); + } + if (message.value !== undefined) { + IdRef.encode(message.value, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): EvalRequest_RefsEntry { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseEvalRequest_RefsEntry(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.string(); + break; + case 2: + message.value = IdRef.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): EvalRequest_RefsEntry { + const obj = createBaseEvalRequest_RefsEntry(); + if (isSet(object.key)) obj.key = String(object.key); + if (isSet(object.value)) obj.value = IdRef.fromJSON(object.value); + return obj; + }, + toJSON(message: EvalRequest_RefsEntry): JsonSafe { + const obj: any = {}; + message.key !== undefined && (obj.key = message.key); + message.value !== undefined && (obj.value = message.value ? IdRef.toJSON(message.value) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): EvalRequest_RefsEntry { + const message = createBaseEvalRequest_RefsEntry(); + message.key = object.key ?? ""; + if (object.value !== undefined && object.value !== null) { + message.value = IdRef.fromPartial(object.value); + } + return message; + }, + fromSDK(object: EvalRequest_RefsEntrySDKType): EvalRequest_RefsEntry { + return { + key: object?.key, + value: object.value ? IdRef.fromSDK(object.value) : undefined + }; + }, + fromSDKJSON(object: any): EvalRequest_RefsEntrySDKType { + return { + key: isSet(object.key) ? String(object.key) : "", + value: isSet(object.value) ? IdRef.fromSDKJSON(object.value) : undefined + }; + }, + toSDK(message: EvalRequest_RefsEntry): EvalRequest_RefsEntrySDKType { + const obj: any = {}; + obj.key = message.key; + message.value !== undefined && (obj.value = message.value ? IdRef.toSDK(message.value) : undefined); + return obj; + }, + fromAmino(object: EvalRequest_RefsEntryAmino): EvalRequest_RefsEntry { + const message = createBaseEvalRequest_RefsEntry(); + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } + if (object.value !== undefined && object.value !== null) { + message.value = IdRef.fromAmino(object.value); + } + return message; + }, + toAmino(message: EvalRequest_RefsEntry): EvalRequest_RefsEntryAmino { + const obj: any = {}; + obj.key = message.key === "" ? undefined : message.key; + obj.value = message.value ? IdRef.toAmino(message.value) : undefined; + return obj; + }, + fromAminoMsg(object: EvalRequest_RefsEntryAminoMsg): EvalRequest_RefsEntry { + return EvalRequest_RefsEntry.fromAmino(object.value); + }, + fromProtoMsg(message: EvalRequest_RefsEntryProtoMsg): EvalRequest_RefsEntry { + return EvalRequest_RefsEntry.decode(message.value); + }, + toProto(message: EvalRequest_RefsEntry): Uint8Array { + return EvalRequest_RefsEntry.encode(message).finish(); + } +}; +function createBaseEvalRequest(): EvalRequest { + return { + bindings: {}, + refs: {}, + testNum: 0, + testString: "", + testBool: false, + instantiatePermission: undefined, + id: undefined, + name: undefined, + testArray: [], + opt: 0, + graph: undefined + }; +} +export const EvalRequest = { + typeUrl: "/misc.EvalRequest", + encode(message: EvalRequest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + Object.entries(message.bindings).forEach(([key, value]) => { + EvalRequest_BindingsEntry.encode({ + key: (key as any), + value + }, writer.uint32(10).fork()).ldelim(); + }); + Object.entries(message.refs).forEach(([key, value]) => { + EvalRequest_RefsEntry.encode({ + key: (key as any), + value + }, writer.uint32(18).fork()).ldelim(); + }); + if (message.testNum !== 0) { + writer.uint32(24).uint32(message.testNum); + } + if (message.testString !== "") { + writer.uint32(34).string(message.testString); + } + if (message.testBool === true) { + writer.uint32(40).bool(message.testBool); + } + if (message.instantiatePermission !== undefined) { + AccessConfig.encode(message.instantiatePermission, writer.uint32(66).fork()).ldelim(); + } + if (message.id !== undefined) { + writer.uint32(98).string(message.id); + } + if (message.name !== undefined) { + writer.uint32(106).string(message.name); + } + for (const v of message.testArray) { + writer.uint32(114).string(v!); + } + if (message.opt !== 0) { + writer.uint32(120).int32(message.opt); + } + if (message.graph !== undefined) { + TestNest_Graph.encode(message.graph, writer.uint32(130).fork()).ldelim(); + } + 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: + const entry1 = EvalRequest_BindingsEntry.decode(reader, reader.uint32()); + if (entry1.value !== undefined) { + message.bindings[entry1.key] = entry1.value; + } + break; + case 2: + const entry2 = EvalRequest_RefsEntry.decode(reader, reader.uint32()); + if (entry2.value !== undefined) { + message.refs[entry2.key] = entry2.value; + } + break; + case 3: + message.testNum = reader.uint32(); + break; + case 4: + message.testString = reader.string(); + break; + case 5: + message.testBool = reader.bool(); + break; + case 8: + message.instantiatePermission = AccessConfig.decode(reader, reader.uint32()); + break; + case 12: + message.id = reader.string(); + break; + case 13: + message.name = reader.string(); + break; + case 14: + message.testArray.push(reader.string()); + break; + case 15: + message.opt = (reader.int32() as any); + break; + case 16: + message.graph = TestNest_Graph.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): EvalRequest { + const obj = createBaseEvalRequest(); + 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 (isObject(object.refs)) obj.refs = Object.entries(object.refs).reduce<{ + [key: string]: IdRef; + }>((acc, [key, value]) => { + acc[key] = IdRef.fromJSON(value); + return acc; + }, {}); + if (isSet(object.testNum)) obj.testNum = Number(object.testNum); + if (isSet(object.testString)) obj.testString = String(object.testString); + if (isSet(object.testBool)) obj.testBool = Boolean(object.testBool); + if (isSet(object.instantiatePermission)) obj.instantiatePermission = AccessConfig.fromJSON(object.instantiatePermission); + if (isSet(object.id)) obj.id = String(object.id); + if (isSet(object.name)) obj.name = String(object.name); + if (Array.isArray(object?.testArray)) obj.testArray = object.testArray.map((e: any) => String(e)); + if (isSet(object.opt)) obj.opt = featureSet_Utf8ValidationFromJSON(object.opt); + if (isSet(object.graph)) obj.graph = TestNest_Graph.fromJSON(object.graph); + return obj; + }, + toJSON(message: EvalRequest): JsonSafe { + const obj: any = {}; + obj.bindings = {}; + if (message.bindings) { + Object.entries(message.bindings).forEach(([k, v]) => { + obj.bindings[k] = ExprValue.toJSON(v); + }); + } + obj.refs = {}; + if (message.refs) { + Object.entries(message.refs).forEach(([k, v]) => { + obj.refs[k] = IdRef.toJSON(v); + }); + } + message.testNum !== undefined && (obj.testNum = Math.round(message.testNum)); + message.testString !== undefined && (obj.testString = message.testString); + message.testBool !== undefined && (obj.testBool = message.testBool); + message.instantiatePermission !== undefined && (obj.instantiatePermission = message.instantiatePermission ? AccessConfig.toJSON(message.instantiatePermission) : undefined); + message.id !== undefined && (obj.id = message.id); + message.name !== undefined && (obj.name = message.name); + if (message.testArray) { + obj.testArray = message.testArray.map(e => e); + } else { + obj.testArray = []; + } + message.opt !== undefined && (obj.opt = featureSet_Utf8ValidationToJSON(message.opt)); + message.graph !== undefined && (obj.graph = message.graph ? TestNest_Graph.toJSON(message.graph) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): EvalRequest { + const message = createBaseEvalRequest(); + message.bindings = Object.entries(object.bindings ?? {}).reduce<{ + [key: string]: ExprValue; + }>((acc, [key, value]) => { + if (value !== undefined) { + acc[key] = ExprValue.fromPartial(value); + } + return acc; + }, {}); + message.refs = Object.entries(object.refs ?? {}).reduce<{ + [key: string]: IdRef; + }>((acc, [key, value]) => { + if (value !== undefined) { + acc[key] = IdRef.fromPartial(value); + } + return acc; + }, {}); + message.testNum = object.testNum ?? 0; + message.testString = object.testString ?? ""; + message.testBool = object.testBool ?? false; + if (object.instantiatePermission !== undefined && object.instantiatePermission !== null) { + message.instantiatePermission = AccessConfig.fromPartial(object.instantiatePermission); + } + message.id = object.id ?? undefined; + message.name = object.name ?? undefined; + message.testArray = object.testArray?.map(e => e) || []; + message.opt = object.opt ?? 0; + if (object.graph !== undefined && object.graph !== null) { + message.graph = TestNest_Graph.fromPartial(object.graph); + } + return message; + }, + fromSDK(object: EvalRequestSDKType): EvalRequest { + return { + bindings: isObject(object.bindings) ? Object.entries(object.bindings).reduce<{ + [key: string]: ExprValue; + }>((acc, [key, value]) => { + acc[key] = ExprValue.fromSDK(value); + return acc; + }, {}) : {}, + refs: isObject(object.refs) ? Object.entries(object.refs).reduce<{ + [key: string]: IdRef; + }>((acc, [key, value]) => { + acc[key] = IdRef.fromSDK(value); + return acc; + }, {}) : {}, + testNum: object?.test_num, + testString: object?.test_string, + testBool: object?.test_bool, + instantiatePermission: object.instantiate_permission ? AccessConfig.fromSDK(object.instantiate_permission) : undefined, + id: object?.id, + name: object?.name, + testArray: Array.isArray(object?.test_array) ? object.test_array.map((e: any) => e) : [], + opt: isSet(object.opt) ? featureSet_Utf8ValidationFromJSON(object.opt) : -1, + graph: object.graph ? TestNest_Graph.fromSDK(object.graph) : undefined + }; + }, + fromSDKJSON(object: any): EvalRequestSDKType { + return { + bindings: isObject(object.bindings) ? Object.entries(object.bindings).reduce<{ + [key: string]: ExprValue; + }>((acc, [key, value]) => { + acc[key] = ExprValue.fromSDKJSON(value); + return acc; + }, {}) : {}, + refs: isObject(object.refs) ? Object.entries(object.refs).reduce<{ + [key: string]: IdRef; + }>((acc, [key, value]) => { + acc[key] = IdRef.fromSDKJSON(value); + return acc; + }, {}) : {}, + test_num: isSet(object.test_num) ? Number(object.test_num) : 0, + test_string: isSet(object.test_string) ? String(object.test_string) : "", + test_bool: isSet(object.test_bool) ? Boolean(object.test_bool) : false, + instantiate_permission: isSet(object.instantiate_permission) ? AccessConfig.fromSDKJSON(object.instantiate_permission) : undefined, + id: isSet(object.id) ? String(object.id) : undefined, + name: isSet(object.name) ? String(object.name) : undefined, + test_array: Array.isArray(object?.test_array) ? object.test_array.map((e: any) => String(e)) : [], + opt: isSet(object.opt) ? featureSet_Utf8ValidationFromJSON(object.opt) : -1, + graph: isSet(object.graph) ? TestNest_Graph.fromSDKJSON(object.graph) : undefined + }; + }, + toSDK(message: EvalRequest): EvalRequestSDKType { + const obj: any = {}; + obj.bindings = {}; + if (message.bindings) { + Object.entries(message.bindings).forEach(([k, v]) => { + obj.bindings[k] = ExprValue.toSDK(v); + }); + } + obj.refs = {}; + if (message.refs) { + Object.entries(message.refs).forEach(([k, v]) => { + obj.refs[k] = IdRef.toSDK(v); + }); + } + obj.test_num = message.testNum; + obj.test_string = message.testString; + obj.test_bool = message.testBool; + message.instantiatePermission !== undefined && (obj.instantiate_permission = message.instantiatePermission ? AccessConfig.toSDK(message.instantiatePermission) : undefined); + obj.id = message.id; + obj.name = message.name; + if (message.testArray) { + obj.test_array = message.testArray.map(e => e); + } else { + obj.test_array = []; + } + message.opt !== undefined && (obj.opt = featureSet_Utf8ValidationToJSON(message.opt)); + message.graph !== undefined && (obj.graph = message.graph ? TestNest_Graph.toSDK(message.graph) : undefined); + return obj; + }, + fromAmino(object: EvalRequestAmino): EvalRequest { + const message = createBaseEvalRequest(); + message.bindings = Object.entries(object.bindings ?? {}).reduce<{ + [key: string]: ExprValue; + }>((acc, [key, value]) => { + if (value !== undefined) { + acc[key] = ExprValue.fromAmino(value); + } + return acc; + }, {}); + message.refs = Object.entries(object.refs ?? {}).reduce<{ + [key: string]: IdRef; + }>((acc, [key, value]) => { + if (value !== undefined) { + acc[key] = IdRef.fromAmino(value); + } + return acc; + }, {}); + if (object.test_num !== undefined && object.test_num !== null) { + message.testNum = object.test_num; + } + if (object.test_string !== undefined && object.test_string !== null) { + message.testString = object.test_string; + } + if (object.test_bool !== undefined && object.test_bool !== null) { + message.testBool = object.test_bool; + } + if (object.instantiate_permission !== undefined && object.instantiate_permission !== null) { + message.instantiatePermission = AccessConfig.fromAmino(object.instantiate_permission); + } + if (object.id !== undefined && object.id !== null) { + message.id = object.id; + } + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + message.testArray = object.test_array?.map(e => e) || []; + if (object.opt !== undefined && object.opt !== null) { + message.opt = object.opt; + } + if (object.graph !== undefined && object.graph !== null) { + message.graph = TestNest_Graph.fromAmino(object.graph); + } + return message; + }, + toAmino(message: EvalRequest): EvalRequestAmino { + const obj: any = {}; + obj.bindings = {}; + if (message.bindings) { + Object.entries(message.bindings).forEach(([k, v]) => { + obj.bindings[k] = ExprValue.toAmino(v); + }); + } + obj.refs = {}; + if (message.refs) { + Object.entries(message.refs).forEach(([k, v]) => { + obj.refs[k] = IdRef.toAmino(v); + }); + } + obj.test_num = message.testNum === 0 ? undefined : message.testNum; + obj.test_string = message.testString === "" ? undefined : message.testString; + obj.test_bool = message.testBool === false ? undefined : message.testBool; + obj.instantiate_permission = message.instantiatePermission ? AccessConfig.toAmino(message.instantiatePermission) : undefined; + obj.id = message.id === null ? undefined : message.id; + obj.name = message.name === null ? undefined : message.name; + if (message.testArray) { + obj.test_array = message.testArray.map(e => e); + } else { + obj.test_array = message.testArray; + } + obj.opt = message.opt ?? 0; + obj.graph = message.graph ? TestNest_Graph.toAmino(message.graph) : undefined; + 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: "/misc.EvalRequest", + value: EvalRequest.encode(message).finish() + }; + } +}; +function createBaseAccessConfig(): AccessConfig { + return { + sender: "" + }; +} +export const AccessConfig = { + typeUrl: "/misc.AccessConfig", + encode(message: AccessConfig, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.sender !== "") { + writer.uint32(10).string(message.sender); + } + 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.sender = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): AccessConfig { + const obj = createBaseAccessConfig(); + if (isSet(object.sender)) obj.sender = String(object.sender); + return obj; + }, + toJSON(message: AccessConfig): JsonSafe { + const obj: any = {}; + message.sender !== undefined && (obj.sender = message.sender); + return obj; + }, + fromPartial(object: DeepPartial): AccessConfig { + const message = createBaseAccessConfig(); + message.sender = object.sender ?? ""; + return message; + }, + fromSDK(object: AccessConfigSDKType): AccessConfig { + return { + sender: object?.sender + }; + }, + fromSDKJSON(object: any): AccessConfigSDKType { + return { + sender: isSet(object.sender) ? String(object.sender) : "" + }; + }, + toSDK(message: AccessConfig): AccessConfigSDKType { + const obj: any = {}; + obj.sender = message.sender; + return obj; + }, + fromAmino(object: AccessConfigAmino): AccessConfig { + const message = createBaseAccessConfig(); + if (object.sender !== undefined && object.sender !== null) { + message.sender = object.sender; + } + return message; + }, + toAmino(message: AccessConfig): AccessConfigAmino { + const obj: any = {}; + obj.sender = message.sender === "" ? undefined : message.sender; + return obj; + }, + fromAminoMsg(object: AccessConfigAminoMsg): AccessConfig { + return AccessConfig.fromAmino(object.value); + }, + fromProtoMsg(message: AccessConfigProtoMsg): AccessConfig { + return AccessConfig.decode(message.value); + }, + toProto(message: AccessConfig): Uint8Array { + return AccessConfig.encode(message).finish(); + }, + toProtoMsg(message: AccessConfig): AccessConfigProtoMsg { + return { + typeUrl: "/misc.AccessConfig", + value: AccessConfig.encode(message).finish() + }; + } +}; +function createBaseGenericAuthorization(): GenericAuthorization { + return { + msg: "" + }; +} +export const GenericAuthorization = { + typeUrl: "/misc.GenericAuthorization", + encode(message: GenericAuthorization, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.msg !== "") { + 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); + }, + fromProtoMsg(message: GenericAuthorizationProtoMsg): GenericAuthorization { + return GenericAuthorization.decode(message.value); + }, + toProto(message: GenericAuthorization): Uint8Array { + return GenericAuthorization.encode(message).finish(); + }, + toProtoMsg(message: GenericAuthorization): GenericAuthorizationProtoMsg { + return { + typeUrl: "/misc.GenericAuthorization", + value: GenericAuthorization.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/misc/output-base64/misc/nest.ts b/__fixtures__/misc/output-base64/misc/nest.ts new file mode 100644 index 0000000000..92749260cb --- /dev/null +++ b/__fixtures__/misc/output-base64/misc/nest.ts @@ -0,0 +1,214 @@ +import { BinaryReader, BinaryWriter } from "../binary"; +import { isSet, DeepPartial } from "../helpers"; +import { JsonSafe } from "../json-safe"; +export const protobufPackage = "misc"; +export interface TestNest { + test: string; +} +export interface TestNestProtoMsg { + typeUrl: "/misc.TestNest"; + value: Uint8Array; +} +export interface TestNestAmino { + test?: string; +} +export interface TestNestAminoMsg { + type: "/misc.TestNest"; + value: TestNestAmino; +} +export interface TestNestSDKType { + test: string; +} +export interface TestNest_Graph { + name: string; +} +export interface TestNest_GraphProtoMsg { + typeUrl: "/misc.Graph"; + value: Uint8Array; +} +export interface TestNest_GraphAmino { + name?: string; +} +export interface TestNest_GraphAminoMsg { + type: "/misc.Graph"; + value: TestNest_GraphAmino; +} +export interface TestNest_GraphSDKType { + name: string; +} +function createBaseTestNest(): TestNest { + return { + test: "" + }; +} +export const TestNest = { + typeUrl: "/misc.TestNest", + encode(message: TestNest, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.test !== "") { + writer.uint32(10).string(message.test); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): TestNest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseTestNest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.test = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): TestNest { + const obj = createBaseTestNest(); + if (isSet(object.test)) obj.test = String(object.test); + return obj; + }, + toJSON(message: TestNest): JsonSafe { + const obj: any = {}; + message.test !== undefined && (obj.test = message.test); + return obj; + }, + fromPartial(object: DeepPartial): TestNest { + const message = createBaseTestNest(); + message.test = object.test ?? ""; + return message; + }, + fromSDK(object: TestNestSDKType): TestNest { + return { + test: object?.test + }; + }, + fromSDKJSON(object: any): TestNestSDKType { + return { + test: isSet(object.test) ? String(object.test) : "" + }; + }, + toSDK(message: TestNest): TestNestSDKType { + const obj: any = {}; + obj.test = message.test; + return obj; + }, + fromAmino(object: TestNestAmino): TestNest { + const message = createBaseTestNest(); + if (object.test !== undefined && object.test !== null) { + message.test = object.test; + } + return message; + }, + toAmino(message: TestNest): TestNestAmino { + const obj: any = {}; + obj.test = message.test === "" ? undefined : message.test; + return obj; + }, + fromAminoMsg(object: TestNestAminoMsg): TestNest { + return TestNest.fromAmino(object.value); + }, + fromProtoMsg(message: TestNestProtoMsg): TestNest { + return TestNest.decode(message.value); + }, + toProto(message: TestNest): Uint8Array { + return TestNest.encode(message).finish(); + }, + toProtoMsg(message: TestNest): TestNestProtoMsg { + return { + typeUrl: "/misc.TestNest", + value: TestNest.encode(message).finish() + }; + } +}; +function createBaseTestNest_Graph(): TestNest_Graph { + return { + name: "" + }; +} +export const TestNest_Graph = { + typeUrl: "/misc.Graph", + encode(message: TestNest_Graph, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): TestNest_Graph { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseTestNest_Graph(); + 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): TestNest_Graph { + const obj = createBaseTestNest_Graph(); + if (isSet(object.name)) obj.name = String(object.name); + return obj; + }, + toJSON(message: TestNest_Graph): JsonSafe { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + return obj; + }, + fromPartial(object: DeepPartial): TestNest_Graph { + const message = createBaseTestNest_Graph(); + message.name = object.name ?? ""; + return message; + }, + fromSDK(object: TestNest_GraphSDKType): TestNest_Graph { + return { + name: object?.name + }; + }, + fromSDKJSON(object: any): TestNest_GraphSDKType { + return { + name: isSet(object.name) ? String(object.name) : "" + }; + }, + toSDK(message: TestNest_Graph): TestNest_GraphSDKType { + const obj: any = {}; + obj.name = message.name; + return obj; + }, + fromAmino(object: TestNest_GraphAmino): TestNest_Graph { + const message = createBaseTestNest_Graph(); + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } + return message; + }, + toAmino(message: TestNest_Graph): TestNest_GraphAmino { + const obj: any = {}; + obj.name = message.name === "" ? undefined : message.name; + return obj; + }, + fromAminoMsg(object: TestNest_GraphAminoMsg): TestNest_Graph { + return TestNest_Graph.fromAmino(object.value); + }, + fromProtoMsg(message: TestNest_GraphProtoMsg): TestNest_Graph { + return TestNest_Graph.decode(message.value); + }, + toProto(message: TestNest_Graph): Uint8Array { + return TestNest_Graph.encode(message).finish(); + }, + toProtoMsg(message: TestNest_Graph): TestNest_GraphProtoMsg { + return { + typeUrl: "/misc.Graph", + value: TestNest_Graph.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/misc/output-base64/misc/rpc.tx.ts b/__fixtures__/misc/output-base64/misc/rpc.tx.ts new file mode 100644 index 0000000000..95f48c2dfe --- /dev/null +++ b/__fixtures__/misc/output-base64/misc/rpc.tx.ts @@ -0,0 +1,8 @@ +import { Rpc } from "../helpers"; +export const createRPCMsgClient = async ({ + rpc +}: { + rpc: Rpc; +}) => ({ + misc: new (await import("./tx.rpc.msg")).MsgClientImpl(rpc) +}); \ No newline at end of file diff --git a/__fixtures__/misc/output-base64/misc/tx.amino.ts b/__fixtures__/misc/output-base64/misc/tx.amino.ts new file mode 100644 index 0000000000..caa000ad3d --- /dev/null +++ b/__fixtures__/misc/output-base64/misc/tx.amino.ts @@ -0,0 +1,9 @@ +import { EncodingTestForDontOmit, EncodingTestForDontOmitSDKType, EncodingTestForOmit, EncodingTestForOmitSDKType } from "./all_fields"; +import { InputMsg, InputMsgSDKType } from "./tx"; +export const AminoConverter = { + "/misc.InputMsg": { + aminoType: "/misc.InputMsg", + toAmino: InputMsg.toAmino, + fromAmino: InputMsg.fromAmino + } +}; \ No newline at end of file diff --git a/__fixtures__/misc/output-base64/misc/tx.registry.ts b/__fixtures__/misc/output-base64/misc/tx.registry.ts new file mode 100644 index 0000000000..1d15c5745c --- /dev/null +++ b/__fixtures__/misc/output-base64/misc/tx.registry.ts @@ -0,0 +1,51 @@ +import { EncodingTestForDontOmit, EncodingTestForDontOmitSDKType, EncodingTestForOmit, EncodingTestForOmitSDKType } from "./all_fields"; +import { GeneratedType, Registry } from "@cosmjs/proto-signing"; +import { InputMsg, InputMsgSDKType } from "./tx"; +export const registry: ReadonlyArray<[string, GeneratedType]> = [["/misc.InputMsg", InputMsg]]; +export const load = (protoRegistry: Registry) => { + registry.forEach(([typeUrl, mod]) => { + protoRegistry.register(typeUrl, mod); + }); +}; +export const MessageComposer = { + encoded: { + sendMsg(value: InputMsg) { + return { + typeUrl: "/misc.InputMsg", + value: InputMsg.encode(value).finish() + }; + } + }, + withTypeUrl: { + sendMsg(value: InputMsg) { + return { + typeUrl: "/misc.InputMsg", + value + }; + } + }, + toJSON: { + sendMsg(value: InputMsg) { + return { + typeUrl: "/misc.InputMsg", + value: InputMsg.toJSON(value) + }; + } + }, + fromJSON: { + sendMsg(value: any) { + return { + typeUrl: "/misc.InputMsg", + value: InputMsg.fromJSON(value) + }; + } + }, + fromPartial: { + sendMsg(value: InputMsg) { + return { + typeUrl: "/misc.InputMsg", + value: InputMsg.fromPartial(value) + }; + } + } +}; \ No newline at end of file diff --git a/__fixtures__/misc/output-base64/misc/tx.rpc.msg.ts b/__fixtures__/misc/output-base64/misc/tx.rpc.msg.ts new file mode 100644 index 0000000000..6d03a2bcb5 --- /dev/null +++ b/__fixtures__/misc/output-base64/misc/tx.rpc.msg.ts @@ -0,0 +1,23 @@ +import { EncodingTestForDontOmit, EncodingTestForDontOmitSDKType, EncodingTestForOmit, EncodingTestForOmitSDKType } from "./all_fields"; +import { Rpc } from "../helpers"; +import { BinaryReader } from "../binary"; +import { InputMsg, InputMsgSDKType, MsgResponse, MsgResponseSDKType } from "./tx"; +export interface Msg { + /** test tx */ + sendMsg(request: InputMsg): Promise; +} +export class MsgClientImpl implements Msg { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + this.sendMsg = this.sendMsg.bind(this); + } + sendMsg(request: InputMsg): Promise { + const data = InputMsg.encode(request).finish(); + const promise = this.rpc.request("misc.Msg", "SendMsg", data); + return promise.then(data => MsgResponse.decode(new BinaryReader(data))); + } +} +export const createClientImpl = (rpc: Rpc) => { + return new MsgClientImpl(rpc); +}; \ No newline at end of file diff --git a/__fixtures__/misc/output-base64/misc/tx.ts b/__fixtures__/misc/output-base64/misc/tx.ts new file mode 100644 index 0000000000..5febb5a6f1 --- /dev/null +++ b/__fixtures__/misc/output-base64/misc/tx.ts @@ -0,0 +1,228 @@ +import { EncodingTestForDontOmit, EncodingTestForDontOmitAmino, EncodingTestForDontOmitSDKType, EncodingTestForOmit, EncodingTestForOmitAmino, EncodingTestForOmitSDKType } from "./all_fields"; +import { BinaryReader, BinaryWriter } from "../binary"; +import { isSet, DeepPartial } from "../helpers"; +import { JsonSafe } from "../json-safe"; +export const protobufPackage = "misc"; +/** + * 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 InputMsg { + dOTests: EncodingTestForDontOmit; + oTests: EncodingTestForOmit; +} +export interface InputMsgProtoMsg { + typeUrl: "/misc.InputMsg"; + 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 InputMsgAmino { + d_o_tests?: EncodingTestForDontOmitAmino; + o_tests?: EncodingTestForOmitAmino; +} +export interface InputMsgAminoMsg { + type: "/misc.InputMsg"; + value: InputMsgAmino; +} +/** + * 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 InputMsgSDKType { + d_o_tests: EncodingTestForDontOmitSDKType; + o_tests: EncodingTestForOmitSDKType; +} +/** MsgGrantResponse defines the Msg/MsgGrant response type. */ +export interface MsgResponse {} +export interface MsgResponseProtoMsg { + typeUrl: "/misc.MsgResponse"; + value: Uint8Array; +} +/** MsgGrantResponse defines the Msg/MsgGrant response type. */ +export interface MsgResponseAmino {} +export interface MsgResponseAminoMsg { + type: "/misc.MsgResponse"; + value: MsgResponseAmino; +} +/** MsgGrantResponse defines the Msg/MsgGrant response type. */ +export interface MsgResponseSDKType {} +function createBaseInputMsg(): InputMsg { + return { + dOTests: EncodingTestForDontOmit.fromPartial({}), + oTests: EncodingTestForOmit.fromPartial({}) + }; +} +export const InputMsg = { + typeUrl: "/misc.InputMsg", + encode(message: InputMsg, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + if (message.dOTests !== undefined) { + EncodingTestForDontOmit.encode(message.dOTests, writer.uint32(10).fork()).ldelim(); + } + if (message.oTests !== undefined) { + EncodingTestForOmit.encode(message.oTests, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): InputMsg { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseInputMsg(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.dOTests = EncodingTestForDontOmit.decode(reader, reader.uint32()); + break; + case 2: + message.oTests = EncodingTestForOmit.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(object: any): InputMsg { + const obj = createBaseInputMsg(); + if (isSet(object.dOTests)) obj.dOTests = EncodingTestForDontOmit.fromJSON(object.dOTests); + if (isSet(object.oTests)) obj.oTests = EncodingTestForOmit.fromJSON(object.oTests); + return obj; + }, + toJSON(message: InputMsg): JsonSafe { + const obj: any = {}; + message.dOTests !== undefined && (obj.dOTests = message.dOTests ? EncodingTestForDontOmit.toJSON(message.dOTests) : undefined); + message.oTests !== undefined && (obj.oTests = message.oTests ? EncodingTestForOmit.toJSON(message.oTests) : undefined); + return obj; + }, + fromPartial(object: DeepPartial): InputMsg { + const message = createBaseInputMsg(); + if (object.dOTests !== undefined && object.dOTests !== null) { + message.dOTests = EncodingTestForDontOmit.fromPartial(object.dOTests); + } + if (object.oTests !== undefined && object.oTests !== null) { + message.oTests = EncodingTestForOmit.fromPartial(object.oTests); + } + return message; + }, + fromSDK(object: InputMsgSDKType): InputMsg { + return { + dOTests: object.d_o_tests ? EncodingTestForDontOmit.fromSDK(object.d_o_tests) : undefined, + oTests: object.o_tests ? EncodingTestForOmit.fromSDK(object.o_tests) : undefined + }; + }, + fromSDKJSON(object: any): InputMsgSDKType { + return { + d_o_tests: isSet(object.d_o_tests) ? EncodingTestForDontOmit.fromSDKJSON(object.d_o_tests) : undefined, + o_tests: isSet(object.o_tests) ? EncodingTestForOmit.fromSDKJSON(object.o_tests) : undefined + }; + }, + toSDK(message: InputMsg): InputMsgSDKType { + const obj: any = {}; + message.dOTests !== undefined && (obj.d_o_tests = message.dOTests ? EncodingTestForDontOmit.toSDK(message.dOTests) : undefined); + message.oTests !== undefined && (obj.o_tests = message.oTests ? EncodingTestForOmit.toSDK(message.oTests) : undefined); + return obj; + }, + fromAmino(object: InputMsgAmino): InputMsg { + const message = createBaseInputMsg(); + if (object.d_o_tests !== undefined && object.d_o_tests !== null) { + message.dOTests = EncodingTestForDontOmit.fromAmino(object.d_o_tests); + } + if (object.o_tests !== undefined && object.o_tests !== null) { + message.oTests = EncodingTestForOmit.fromAmino(object.o_tests); + } + return message; + }, + toAmino(message: InputMsg): InputMsgAmino { + const obj: any = {}; + obj.d_o_tests = message.dOTests ? EncodingTestForDontOmit.toAmino(message.dOTests) : undefined; + obj.o_tests = message.oTests ? EncodingTestForOmit.toAmino(message.oTests) : undefined; + return obj; + }, + fromAminoMsg(object: InputMsgAminoMsg): InputMsg { + return InputMsg.fromAmino(object.value); + }, + fromProtoMsg(message: InputMsgProtoMsg): InputMsg { + return InputMsg.decode(message.value); + }, + toProto(message: InputMsg): Uint8Array { + return InputMsg.encode(message).finish(); + }, + toProtoMsg(message: InputMsg): InputMsgProtoMsg { + return { + typeUrl: "/misc.InputMsg", + value: InputMsg.encode(message).finish() + }; + } +}; +function createBaseMsgResponse(): MsgResponse { + return {}; +} +export const MsgResponse = { + typeUrl: "/misc.MsgResponse", + encode(_: MsgResponse, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { + return writer; + }, + decode(input: BinaryReader | Uint8Array, length?: number): MsgResponse { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + fromJSON(_: any): MsgResponse { + const obj = createBaseMsgResponse(); + return obj; + }, + toJSON(_: MsgResponse): JsonSafe { + const obj: any = {}; + return obj; + }, + fromPartial(_: DeepPartial): MsgResponse { + const message = createBaseMsgResponse(); + return message; + }, + fromSDK(_: MsgResponseSDKType): MsgResponse { + return {}; + }, + fromSDKJSON(_: any): MsgResponseSDKType { + return {}; + }, + toSDK(_: MsgResponse): MsgResponseSDKType { + const obj: any = {}; + return obj; + }, + fromAmino(_: MsgResponseAmino): MsgResponse { + const message = createBaseMsgResponse(); + return message; + }, + toAmino(_: MsgResponse): MsgResponseAmino { + const obj: any = {}; + return obj; + }, + fromAminoMsg(object: MsgResponseAminoMsg): MsgResponse { + return MsgResponse.fromAmino(object.value); + }, + fromProtoMsg(message: MsgResponseProtoMsg): MsgResponse { + return MsgResponse.decode(message.value); + }, + toProto(message: MsgResponse): Uint8Array { + return MsgResponse.encode(message).finish(); + }, + toProtoMsg(message: MsgResponse): MsgResponseProtoMsg { + return { + typeUrl: "/misc.MsgResponse", + value: MsgResponse.encode(message).finish() + }; + } +}; \ No newline at end of file diff --git a/__fixtures__/misc/output-base64/mobx.ts b/__fixtures__/misc/output-base64/mobx.ts new file mode 100644 index 0000000000..e9d995fe00 --- /dev/null +++ b/__fixtures__/misc/output-base64/mobx.ts @@ -0,0 +1,82 @@ +/** +* 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 { + makeAutoObservable, + runInAction +} from 'mobx'; + +import { QueryStatus } from '@tanstack/react-query'; + +export interface MobxResponse { + data: T | undefined; + isSuccess: boolean; + isLoading: boolean; + refetch: () => Promise; +} + +export class QueryStore { + state?: QueryStatus; + request?: Request; + response?: Response; + fetchFunc?: (request: Request) => Promise; + + constructor(fetchFunc?: (request: Request) => Promise) { + this.fetchFunc = fetchFunc; + makeAutoObservable(this) + } + + get isLoading() { + return this.state === 'loading'; + } + + get isSuccess() { + return this.state === 'success'; + } + + refetch = async (): Promise => { + runInAction(() => { + this.response = void 0; + this.state = 'loading'; + }); + try { + if (!this.fetchFunc) + throw new Error( + 'Query Service not initialized or request function not implemented' + ); + if (!this.request) throw new Error('Request not provided'); + const response = await this.fetchFunc(this.request); + runInAction(() => { + this.response = response; + this.state = 'success'; + }); + console.log( + '%cquery.rpc.Query.ts line:572 this.state', + 'color: #007acc;', + this.state, + this.response + ); + } catch (e) { + console.error(e); + runInAction(() => { + this.state = 'error'; + }); + } + } + + getData(request?: Request): MobxResponse { + runInAction(() => { + this.request = request; + }); + return { + data: this.response, + isSuccess: this.isSuccess, + isLoading: this.isLoading, + refetch: this.refetch, + }; + } +} diff --git a/__fixtures__/misc/output-base64/pinia-endpoint.ts b/__fixtures__/misc/output-base64/pinia-endpoint.ts new file mode 100644 index 0000000000..354d471be7 --- /dev/null +++ b/__fixtures__/misc/output-base64/pinia-endpoint.ts @@ -0,0 +1,22 @@ +/** +* 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 { defineStore } from "pinia"; +import type { LCDClient } from '@cosmology/lcd'; + +export const useEndpoint = defineStore('pinia.endpoint', { + state: () => { + return { + restClient: {} as LCDClient, + } + }, + actions: { + setRestClient(client: LCDClient) { + this.restClient = client + } + } +}) diff --git a/__fixtures__/misc/output-base64/react-query.ts b/__fixtures__/misc/output-base64/react-query.ts new file mode 100644 index 0000000000..58e216f472 --- /dev/null +++ b/__fixtures__/misc/output-base64/react-query.ts @@ -0,0 +1,71 @@ +/** +* 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 { getRpcClient } from './extern' +import { + useQuery, + UseQueryOptions, +} from '@tanstack/react-query'; + +import { HttpEndpoint, ProtobufRpcClient } from '@cosmjs/stargate'; +import { Tendermint34Client } from '@cosmjs/tendermint-rpc'; + +export interface ReactQueryParams { + options?: UseQueryOptions; +} + +export interface UseRpcClientQuery extends ReactQueryParams { + rpcEndpoint: string | HttpEndpoint; +} + +export interface UseRpcEndpointQuery extends ReactQueryParams { + getter: () => Promise; + extraKey?: string +} + +export const useRpcEndpoint = ({ + getter, + options, + extraKey +}: UseRpcEndpointQuery) => { + return useQuery(['rpcEndpoint', extraKey], async () => { + return await getter(); + }, options); +}; + +export const useRpcClient = ({ + rpcEndpoint, + options, +}: UseRpcClientQuery) => { + return useQuery(['rpcClient', rpcEndpoint], async () => { + return await getRpcClient(rpcEndpoint); + }, options); +}; + +interface UseTendermintClient extends ReactQueryParams { + rpcEndpoint: string | HttpEndpoint; +} + +/** + * Hook that uses react-query to cache a connected tendermint client. + */ +export const useTendermintClient = ({ + rpcEndpoint, + options, +}: UseTendermintClient) => { + const { data: client } = useQuery( + ['client', 'tendermint', rpcEndpoint], + () => Tendermint34Client.connect(rpcEndpoint), + { + // allow overriding + onError: (e) => { + throw new Error(`Failed to connect to ${rpcEndpoint}` + '\n' + e) + }, + ...options, + } + ) + return { client } +}; diff --git a/__fixtures__/misc/output-base64/utf8.ts b/__fixtures__/misc/output-base64/utf8.ts new file mode 100644 index 0000000000..7747be1bd4 --- /dev/null +++ b/__fixtures__/misc/output-base64/utf8.ts @@ -0,0 +1,148 @@ +/** +* 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. + +"use strict"; + +/** + * Calculates the UTF8 byte length of a string. + * @param {string} string String + * @returns {number} Byte length + */ +export function utf8Length(str: string) { + let len = 0, + c = 0; + for (let i = 0; i < str.length; ++i) { + c = str.charCodeAt(i); + if (c < 128) len += 1; + else if (c < 2048) len += 2; + else if ( + (c & 0xfc00) === 0xd800 && + (str.charCodeAt(i + 1) & 0xfc00) === 0xdc00 + ) { + ++i; + len += 4; + } else len += 3; + } + return len; +} + +/** + * Reads UTF8 bytes as a string. + * @param {Uint8Array} buffer Source buffer + * @param {number} start Source start + * @param {number} end Source end + * @returns {string} String read + */ +export function utf8Read( + buffer: ArrayLike, + start: number, + end: number +) { + const len = end - start; + if (len < 1) return ""; + const chunk = []; + let parts: string[] = [], + i = 0, // char offset + t; // temporary + while (start < end) { + t = buffer[start++]; + if (t < 128) chunk[i++] = t; + else if (t > 191 && t < 224) + chunk[i++] = ((t & 31) << 6) | (buffer[start++] & 63); + else if (t > 239 && t < 365) { + t = + (((t & 7) << 18) | + ((buffer[start++] & 63) << 12) | + ((buffer[start++] & 63) << 6) | + (buffer[start++] & 63)) - + 0x10000; + chunk[i++] = 0xd800 + (t >> 10); + chunk[i++] = 0xdc00 + (t & 1023); + } else + chunk[i++] = + ((t & 15) << 12) | + ((buffer[start++] & 63) << 6) | + (buffer[start++] & 63); + if (i > 8191) { + (parts || (parts = [])).push(String.fromCharCode(...chunk)); + i = 0; + } + } + if (parts) { + if (i) parts.push(String.fromCharCode(...chunk.slice(0, i))); + return parts.join(""); + } + return String.fromCharCode(...chunk.slice(0, i)); +} + +/** + * Writes a string as UTF8 bytes. + * @param {string} string Source string + * @param {Uint8Array} buffer Destination buffer + * @param {number} offset Destination offset + * @returns {number} Bytes written + */ +export function utf8Write( + str: string, + buffer: Uint8Array | Array, + offset: number +) { + const start = offset; + let c1, // character 1 + c2; // character 2 + for (let i = 0; i < str.length; ++i) { + c1 = str.charCodeAt(i); + if (c1 < 128) { + buffer[offset++] = c1; + } else if (c1 < 2048) { + buffer[offset++] = (c1 >> 6) | 192; + buffer[offset++] = (c1 & 63) | 128; + } else if ( + (c1 & 0xfc00) === 0xd800 && + ((c2 = str.charCodeAt(i + 1)) & 0xfc00) === 0xdc00 + ) { + c1 = 0x10000 + ((c1 & 0x03ff) << 10) + (c2 & 0x03ff); + ++i; + buffer[offset++] = (c1 >> 18) | 240; + buffer[offset++] = ((c1 >> 12) & 63) | 128; + buffer[offset++] = ((c1 >> 6) & 63) | 128; + buffer[offset++] = (c1 & 63) | 128; + } else { + buffer[offset++] = (c1 >> 12) | 224; + buffer[offset++] = ((c1 >> 6) & 63) | 128; + buffer[offset++] = (c1 & 63) | 128; + } + } + return offset - start; +} diff --git a/__fixtures__/misc/output-base64/varint.ts b/__fixtures__/misc/output-base64/varint.ts new file mode 100644 index 0000000000..6c2e8062a8 --- /dev/null +++ b/__fixtures__/misc/output-base64/varint.ts @@ -0,0 +1,488 @@ +/** +* 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 2008 Google Inc. 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 Google Inc. 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 Protocol Buffer compiler 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. + +/* eslint-disable prefer-const,@typescript-eslint/restrict-plus-operands */ + +/** + * Read a 64 bit varint as two JS numbers. + * + * Returns tuple: + * [0]: low bits + * [1]: high bits + * + * Copyright 2008 Google Inc. All rights reserved. + * + * See https://github.com/protocolbuffers/protobuf/blob/8a71927d74a4ce34efe2d8769fda198f52d20d12/js/experimental/runtime/kernel/buffer_decoder.js#L175 + */ +export function varint64read(this: ReaderLike): [number, number] { + let lowBits = 0; + let highBits = 0; + + for (let shift = 0; shift < 28; shift += 7) { + let b = this.buf[this.pos++]; + lowBits |= (b & 0x7f) << shift; + if ((b & 0x80) == 0) { + this.assertBounds(); + return [lowBits, highBits]; + } + } + + let middleByte = this.buf[this.pos++]; + + // last four bits of the first 32 bit number + lowBits |= (middleByte & 0x0f) << 28; + + // 3 upper bits are part of the next 32 bit number + highBits = (middleByte & 0x70) >> 4; + + if ((middleByte & 0x80) == 0) { + this.assertBounds(); + return [lowBits, highBits]; + } + + for (let shift = 3; shift <= 31; shift += 7) { + let b = this.buf[this.pos++]; + highBits |= (b & 0x7f) << shift; + if ((b & 0x80) == 0) { + this.assertBounds(); + return [lowBits, highBits]; + } + } + + throw new Error("invalid varint"); +} + +/** + * Write a 64 bit varint, given as two JS numbers, to the given bytes array. + * + * Copyright 2008 Google Inc. All rights reserved. + * + * See https://github.com/protocolbuffers/protobuf/blob/8a71927d74a4ce34efe2d8769fda198f52d20d12/js/experimental/runtime/kernel/writer.js#L344 + */ +export function varint64write(lo: number, hi: number, bytes: number[]): void { + for (let i = 0; i < 28; i = i + 7) { + const shift = lo >>> i; + const hasNext = !(shift >>> 7 == 0 && hi == 0); + const byte = (hasNext ? shift | 0x80 : shift) & 0xff; + bytes.push(byte); + if (!hasNext) { + return; + } + } + + const splitBits = ((lo >>> 28) & 0x0f) | ((hi & 0x07) << 4); + const hasMoreBits = !(hi >> 3 == 0); + bytes.push((hasMoreBits ? splitBits | 0x80 : splitBits) & 0xff); + + if (!hasMoreBits) { + return; + } + + for (let i = 3; i < 31; i = i + 7) { + const shift = hi >>> i; + const hasNext = !(shift >>> 7 == 0); + const byte = (hasNext ? shift | 0x80 : shift) & 0xff; + bytes.push(byte); + if (!hasNext) { + return; + } + } + + bytes.push((hi >>> 31) & 0x01); +} + +// constants for binary math +const TWO_PWR_32_DBL = 0x100000000; + +/** + * Parse decimal string of 64 bit integer value as two JS numbers. + * + * Copyright 2008 Google Inc. All rights reserved. + * + * See https://github.com/protocolbuffers/protobuf-javascript/blob/a428c58273abad07c66071d9753bc4d1289de426/experimental/runtime/int64.js#L10 + */ +export function int64FromString(dec: string): { lo: number; hi: number } { + // Check for minus sign. + const minus = dec[0] === "-"; + if (minus) { + dec = dec.slice(1); + } + + // Work 6 decimal digits at a time, acting like we're converting base 1e6 + // digits to binary. This is safe to do with floating point math because + // Number.isSafeInteger(ALL_32_BITS * 1e6) == true. + const base = 1e6; + let lowBits = 0; + let highBits = 0; + + function add1e6digit(begin: number, end?: number) { + // Note: Number('') is 0. + const digit1e6 = Number(dec.slice(begin, end)); + highBits *= base; + lowBits = lowBits * base + digit1e6; + // Carry bits from lowBits to + if (lowBits >= TWO_PWR_32_DBL) { + highBits = highBits + ((lowBits / TWO_PWR_32_DBL) | 0); + lowBits = lowBits % TWO_PWR_32_DBL; + } + } + + add1e6digit(-24, -18); + add1e6digit(-18, -12); + add1e6digit(-12, -6); + add1e6digit(-6); + return minus ? negate(lowBits, highBits) : newBits(lowBits, highBits); +} + +/** + * Losslessly converts a 64-bit signed integer in 32:32 split representation + * into a decimal string. + * + * Copyright 2008 Google Inc. All rights reserved. + * + * See https://github.com/protocolbuffers/protobuf-javascript/blob/a428c58273abad07c66071d9753bc4d1289de426/experimental/runtime/int64.js#L10 + */ +export function int64ToString(lo: number, hi: number): string { + let bits = newBits(lo, hi); + // If we're treating the input as a signed value and the high bit is set, do + // a manual two's complement conversion before the decimal conversion. + const negative = bits.hi & 0x80000000; + if (negative) { + bits = negate(bits.lo, bits.hi); + } + const result = uInt64ToString(bits.lo, bits.hi); + return negative ? "-" + result : result; +} + +/** + * Losslessly converts a 64-bit unsigned integer in 32:32 split representation + * into a decimal string. + * + * Copyright 2008 Google Inc. All rights reserved. + * + * See https://github.com/protocolbuffers/protobuf-javascript/blob/a428c58273abad07c66071d9753bc4d1289de426/experimental/runtime/int64.js#L10 + */ +export function uInt64ToString(lo: number, hi: number): string { + ({ lo, hi } = toUnsigned(lo, hi)); + // Skip the expensive conversion if the number is small enough to use the + // built-in conversions. + // Number.MAX_SAFE_INTEGER = 0x001FFFFF FFFFFFFF, thus any number with + // highBits <= 0x1FFFFF can be safely expressed with a double and retain + // integer precision. + // Proven by: Number.isSafeInteger(0x1FFFFF * 2**32 + 0xFFFFFFFF) == true. + if (hi <= 0x1fffff) { + return String(TWO_PWR_32_DBL * hi + lo); + } + + // What this code is doing is essentially converting the input number from + // base-2 to base-1e7, which allows us to represent the 64-bit range with + // only 3 (very large) digits. Those digits are then trivial to convert to + // a base-10 string. + + // The magic numbers used here are - + // 2^24 = 16777216 = (1,6777216) in base-1e7. + // 2^48 = 281474976710656 = (2,8147497,6710656) in base-1e7. + + // Split 32:32 representation into 16:24:24 representation so our + // intermediate digits don't overflow. + const low = lo & 0xffffff; + const mid = ((lo >>> 24) | (hi << 8)) & 0xffffff; + const high = (hi >> 16) & 0xffff; + + // Assemble our three base-1e7 digits, ignoring carries. The maximum + // value in a digit at this step is representable as a 48-bit integer, which + // can be stored in a 64-bit floating point number. + let digitA = low + mid * 6777216 + high * 6710656; + let digitB = mid + high * 8147497; + let digitC = high * 2; + + // Apply carries from A to B and from B to C. + const base = 10000000; + if (digitA >= base) { + digitB += Math.floor(digitA / base); + digitA %= base; + } + + if (digitB >= base) { + digitC += Math.floor(digitB / base); + digitB %= base; + } + + // If digitC is 0, then we should have returned in the trivial code path + // at the top for non-safe integers. Given this, we can assume both digitB + // and digitA need leading zeros. + return ( + digitC.toString() + + decimalFrom1e7WithLeadingZeros(digitB) + + decimalFrom1e7WithLeadingZeros(digitA) + ); +} + +function toUnsigned(lo: number, hi: number): { lo: number; hi: number } { + return { lo: lo >>> 0, hi: hi >>> 0 }; +} + +function newBits(lo: number, hi: number): { lo: number; hi: number } { + return { lo: lo | 0, hi: hi | 0 }; +} + +/** + * Returns two's compliment negation of input. + * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators#Signed_32-bit_integers + */ +function negate(lowBits: number, highBits: number) { + highBits = ~highBits; + if (lowBits) { + lowBits = ~lowBits + 1; + } else { + // If lowBits is 0, then bitwise-not is 0xFFFFFFFF, + // adding 1 to that, results in 0x100000000, which leaves + // the low bits 0x0 and simply adds one to the high bits. + highBits += 1; + } + return newBits(lowBits, highBits); +} + +/** + * Returns decimal representation of digit1e7 with leading zeros. + */ +const decimalFrom1e7WithLeadingZeros = (digit1e7: number) => { + const partial = String(digit1e7); + return "0000000".slice(partial.length) + partial; +}; + +/** + * Write a 32 bit varint, signed or unsigned. Same as `varint64write(0, value, bytes)` + * + * Copyright 2008 Google Inc. All rights reserved. + * + * See https://github.com/protocolbuffers/protobuf/blob/1b18833f4f2a2f681f4e4a25cdf3b0a43115ec26/js/binary/encoder.js#L144 + */ +export function varint32write(value: number, bytes: number[]): void { + if (value >= 0) { + // write value as varint 32 + while (value > 0x7f) { + bytes.push((value & 0x7f) | 0x80); + value = value >>> 7; + } + bytes.push(value); + } else { + for (let i = 0; i < 9; i++) { + bytes.push((value & 127) | 128); + value = value >> 7; + } + bytes.push(1); + } +} + +/** + * Read an unsigned 32 bit varint. + * + * See https://github.com/protocolbuffers/protobuf/blob/8a71927d74a4ce34efe2d8769fda198f52d20d12/js/experimental/runtime/kernel/buffer_decoder.js#L220 + */ +export function varint32read(this: ReaderLike): number { + let b = this.buf[this.pos++]; + let result = b & 0x7f; + if ((b & 0x80) == 0) { + this.assertBounds(); + return result; + } + + b = this.buf[this.pos++]; + result |= (b & 0x7f) << 7; + if ((b & 0x80) == 0) { + this.assertBounds(); + return result; + } + + b = this.buf[this.pos++]; + result |= (b & 0x7f) << 14; + if ((b & 0x80) == 0) { + this.assertBounds(); + return result; + } + + b = this.buf[this.pos++]; + result |= (b & 0x7f) << 21; + if ((b & 0x80) == 0) { + this.assertBounds(); + return result; + } + + // Extract only last 4 bits + b = this.buf[this.pos++]; + result |= (b & 0x0f) << 28; + + for (let readBytes = 5; (b & 0x80) !== 0 && readBytes < 10; readBytes++) + b = this.buf[this.pos++]; + + if ((b & 0x80) != 0) throw new Error("invalid varint"); + + this.assertBounds(); + + // Result can have 32 bits, convert it to unsigned + return result >>> 0; +} + +type ReaderLike = { + buf: Uint8Array; + pos: number; + len: number; + assertBounds(): void; +}; + +/** + * encode zig zag + */ +export function zzEncode(lo: number, hi: number) { + let mask = hi >> 31; + hi = (((hi << 1) | (lo >>> 31)) ^ mask) >>> 0; + lo = ((lo << 1) ^ mask) >>> 0; + return [lo, hi]; +} + +/** + * decode zig zag + */ +export function zzDecode(lo: number, hi: number) { + let mask = -(lo & 1); + lo = (((lo >>> 1) | (hi << 31)) ^ mask) >>> 0; + hi = ((hi >>> 1) ^ mask) >>> 0; + return [lo, hi]; +} + +/** + * unsigned int32 without moving pos. + */ +export function readUInt32(buf: Uint8Array, pos: number) { + return ( + (buf[pos] | (buf[pos + 1] << 8) | (buf[pos + 2] << 16)) + + buf[pos + 3] * 0x1000000 + ); +} + +/** + * signed int32 without moving pos. + */ +export function readInt32(buf: Uint8Array, pos: number) { + return ( + (buf[pos] | (buf[pos + 1] << 8) | (buf[pos + 2] << 16)) + + (buf[pos + 3] << 24) + ); +} + +/** + * writing varint32 to pos + */ +export function writeVarint32( + val: number, + buf: Uint8Array | number[], + pos: number +) { + while (val > 127) { + buf[pos++] = (val & 127) | 128; + val >>>= 7; + } + buf[pos] = val; +} + +/** + * writing varint64 to pos + */ +export function writeVarint64( + val: { lo: number; hi: number }, + buf: Uint8Array | number[], + pos: number +) { + while (val.hi) { + buf[pos++] = (val.lo & 127) | 128; + val.lo = ((val.lo >>> 7) | (val.hi << 25)) >>> 0; + val.hi >>>= 7; + } + while (val.lo > 127) { + buf[pos++] = (val.lo & 127) | 128; + val.lo = val.lo >>> 7; + } + buf[pos++] = val.lo; +} + +export function int64Length(lo: number, hi: number) { + let part0 = lo, + part1 = ((lo >>> 28) | (hi << 4)) >>> 0, + part2 = hi >>> 24; + return part2 === 0 + ? part1 === 0 + ? part0 < 16384 + ? part0 < 128 + ? 1 + : 2 + : part0 < 2097152 + ? 3 + : 4 + : part1 < 16384 + ? part1 < 128 + ? 5 + : 6 + : part1 < 2097152 + ? 7 + : 8 + : part2 < 128 + ? 9 + : 10; +} + +export function writeFixed32( + val: number, + buf: Uint8Array | number[], + pos: number +) { + buf[pos] = val & 255; + buf[pos + 1] = (val >>> 8) & 255; + buf[pos + 2] = (val >>> 16) & 255; + buf[pos + 3] = val >>> 24; +} + +export function writeByte( + val: number, + buf: Uint8Array | number[], + pos: number +) { + buf[pos] = val & 255; +}