/* eslint-disable */ import { Writer, Reader } from 'protobufjs/minimal'; /** * Pairs defines a repeated slice of Pair objects. */ export interface Pairs { pairs: Pair[]; } /** * Pair defines a key/value bytes tuple. */ export interface Pair { key: Uint8Array; value: Uint8Array; } const basePairs: object = { }; const basePair: object = { }; export const protobufPackage = 'cosmos.base.kv.v1beta1' export const Pairs = { encode(message: Pairs, writer: Writer = Writer.create()): Writer { for (const v of message.pairs) { Pair.encode(v!, writer.uint32(10).fork()).ldelim(); } return writer; }, decode(input: Uint8Array | Reader, length?: number): Pairs { const reader = input instanceof Uint8Array ? new Reader(input) : input; let end = length === undefined ? reader.len : reader.pos + length; const message = { ...basePairs } as Pairs; message.pairs = []; while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: message.pairs.push(Pair.decode(reader, reader.uint32())); break; default: reader.skipType(tag & 7); break; } } return message; }, fromJSON(object: any): Pairs { const message = { ...basePairs } as Pairs; message.pairs = []; if (object.pairs !== undefined && object.pairs !== null) { for (const e of object.pairs) { message.pairs.push(Pair.fromJSON(e)); } } return message; }, fromPartial(object: DeepPartial): Pairs { const message = { ...basePairs } as Pairs; message.pairs = []; if (object.pairs !== undefined && object.pairs !== null) { for (const e of object.pairs) { message.pairs.push(Pair.fromPartial(e)); } } return message; }, toJSON(message: Pairs): unknown { const obj: any = {}; if (message.pairs) { obj.pairs = message.pairs.map(e => e ? Pair.toJSON(e) : undefined); } else { obj.pairs = []; } return obj; }, }; export const Pair = { encode(message: Pair, writer: Writer = Writer.create()): Writer { writer.uint32(10).bytes(message.key); writer.uint32(18).bytes(message.value); return writer; }, decode(input: Uint8Array | Reader, length?: number): Pair { const reader = input instanceof Uint8Array ? new Reader(input) : input; let end = length === undefined ? reader.len : reader.pos + length; const message = { ...basePair } as Pair; while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: message.key = reader.bytes(); break; case 2: message.value = reader.bytes(); break; default: reader.skipType(tag & 7); break; } } return message; }, fromJSON(object: any): Pair { const message = { ...basePair } as Pair; if (object.key !== undefined && object.key !== null) { message.key = bytesFromBase64(object.key); } if (object.value !== undefined && object.value !== null) { message.value = bytesFromBase64(object.value); } return message; }, fromPartial(object: DeepPartial): Pair { const message = { ...basePair } as Pair; if (object.key !== undefined && object.key !== null) { message.key = object.key; } else { message.key = new Uint8Array(); } if (object.value !== undefined && object.value !== null) { message.value = object.value; } else { message.value = new Uint8Array(); } return message; }, toJSON(message: Pair): unknown { const obj: any = {}; message.key !== undefined && (obj.key = base64FromBytes(message.key !== undefined ? message.key : new Uint8Array())); message.value !== undefined && (obj.value = base64FromBytes(message.value !== undefined ? message.value : new Uint8Array())); return obj; }, }; interface WindowBase64 { atob(b64: string): string; btoa(bin: string): string; } const windowBase64 = (globalThis as unknown as WindowBase64); const atob = windowBase64.atob || ((b64: string) => Buffer.from(b64, 'base64').toString('binary')); const btoa = windowBase64.btoa || ((bin: string) => Buffer.from(bin, 'binary').toString('base64')); 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; } function base64FromBytes(arr: Uint8Array): string { const bin: string[] = []; for (let i = 0; i < arr.byteLength; ++i) { bin.push(String.fromCharCode(arr[i])); } return btoa(bin.join('')); } type Builtin = Date | Function | Uint8Array | string | number | undefined; export type DeepPartial = T extends Builtin ? T : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial;