/* eslint-disable */
import Long from "long";
import _m0 from "protobufjs/minimal";
export const protobufPackage = "gossip.v1";
const baseGossipMessage = {};
export const GossipMessage = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.signedObservation !== undefined) {
            SignedObservation.encode(message.signedObservation, writer.uint32(18).fork()).ldelim();
        }
        if (message.signedHeartbeat !== undefined) {
            SignedHeartbeat.encode(message.signedHeartbeat, writer.uint32(26).fork()).ldelim();
        }
        if (message.signedVaaWithQuorum !== undefined) {
            SignedVAAWithQuorum.encode(message.signedVaaWithQuorum, writer.uint32(34).fork()).ldelim();
        }
        if (message.signedObservationRequest !== undefined) {
            SignedObservationRequest.encode(message.signedObservationRequest, writer.uint32(42).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseGossipMessage);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 2:
                    message.signedObservation = SignedObservation.decode(reader, reader.uint32());
                    break;
                case 3:
                    message.signedHeartbeat = SignedHeartbeat.decode(reader, reader.uint32());
                    break;
                case 4:
                    message.signedVaaWithQuorum = SignedVAAWithQuorum.decode(reader, reader.uint32());
                    break;
                case 5:
                    message.signedObservationRequest = SignedObservationRequest.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseGossipMessage);
        if (object.signedObservation !== undefined &&
            object.signedObservation !== null) {
            message.signedObservation = SignedObservation.fromJSON(object.signedObservation);
        }
        else {
            message.signedObservation = undefined;
        }
        if (object.signedHeartbeat !== undefined &&
            object.signedHeartbeat !== null) {
            message.signedHeartbeat = SignedHeartbeat.fromJSON(object.signedHeartbeat);
        }
        else {
            message.signedHeartbeat = undefined;
        }
        if (object.signedVaaWithQuorum !== undefined &&
            object.signedVaaWithQuorum !== null) {
            message.signedVaaWithQuorum = SignedVAAWithQuorum.fromJSON(object.signedVaaWithQuorum);
        }
        else {
            message.signedVaaWithQuorum = undefined;
        }
        if (object.signedObservationRequest !== undefined &&
            object.signedObservationRequest !== null) {
            message.signedObservationRequest = SignedObservationRequest.fromJSON(object.signedObservationRequest);
        }
        else {
            message.signedObservationRequest = undefined;
        }
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.signedObservation !== undefined &&
            (obj.signedObservation = message.signedObservation
                ? SignedObservation.toJSON(message.signedObservation)
                : undefined);
        message.signedHeartbeat !== undefined &&
            (obj.signedHeartbeat = message.signedHeartbeat
                ? SignedHeartbeat.toJSON(message.signedHeartbeat)
                : undefined);
        message.signedVaaWithQuorum !== undefined &&
            (obj.signedVaaWithQuorum = message.signedVaaWithQuorum
                ? SignedVAAWithQuorum.toJSON(message.signedVaaWithQuorum)
                : undefined);
        message.signedObservationRequest !== undefined &&
            (obj.signedObservationRequest = message.signedObservationRequest
                ? SignedObservationRequest.toJSON(message.signedObservationRequest)
                : undefined);
        return obj;
    },
    fromPartial(object) {
        const message = Object.assign({}, baseGossipMessage);
        if (object.signedObservation !== undefined &&
            object.signedObservation !== null) {
            message.signedObservation = SignedObservation.fromPartial(object.signedObservation);
        }
        else {
            message.signedObservation = undefined;
        }
        if (object.signedHeartbeat !== undefined &&
            object.signedHeartbeat !== null) {
            message.signedHeartbeat = SignedHeartbeat.fromPartial(object.signedHeartbeat);
        }
        else {
            message.signedHeartbeat = undefined;
        }
        if (object.signedVaaWithQuorum !== undefined &&
            object.signedVaaWithQuorum !== null) {
            message.signedVaaWithQuorum = SignedVAAWithQuorum.fromPartial(object.signedVaaWithQuorum);
        }
        else {
            message.signedVaaWithQuorum = undefined;
        }
        if (object.signedObservationRequest !== undefined &&
            object.signedObservationRequest !== null) {
            message.signedObservationRequest = SignedObservationRequest.fromPartial(object.signedObservationRequest);
        }
        else {
            message.signedObservationRequest = undefined;
        }
        return message;
    },
};
const baseSignedHeartbeat = {};
export const SignedHeartbeat = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.heartbeat.length !== 0) {
            writer.uint32(10).bytes(message.heartbeat);
        }
        if (message.signature.length !== 0) {
            writer.uint32(18).bytes(message.signature);
        }
        if (message.guardianAddr.length !== 0) {
            writer.uint32(26).bytes(message.guardianAddr);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseSignedHeartbeat);
        message.heartbeat = new Uint8Array();
        message.signature = new Uint8Array();
        message.guardianAddr = new Uint8Array();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.heartbeat = reader.bytes();
                    break;
                case 2:
                    message.signature = reader.bytes();
                    break;
                case 3:
                    message.guardianAddr = reader.bytes();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseSignedHeartbeat);
        message.heartbeat = new Uint8Array();
        message.signature = new Uint8Array();
        message.guardianAddr = new Uint8Array();
        if (object.heartbeat !== undefined && object.heartbeat !== null) {
            message.heartbeat = bytesFromBase64(object.heartbeat);
        }
        if (object.signature !== undefined && object.signature !== null) {
            message.signature = bytesFromBase64(object.signature);
        }
        if (object.guardianAddr !== undefined && object.guardianAddr !== null) {
            message.guardianAddr = bytesFromBase64(object.guardianAddr);
        }
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.heartbeat !== undefined &&
            (obj.heartbeat = base64FromBytes(message.heartbeat !== undefined ? message.heartbeat : new Uint8Array()));
        message.signature !== undefined &&
            (obj.signature = base64FromBytes(message.signature !== undefined ? message.signature : new Uint8Array()));
        message.guardianAddr !== undefined &&
            (obj.guardianAddr = base64FromBytes(message.guardianAddr !== undefined
                ? message.guardianAddr
                : new Uint8Array()));
        return obj;
    },
    fromPartial(object) {
        const message = Object.assign({}, baseSignedHeartbeat);
        if (object.heartbeat !== undefined && object.heartbeat !== null) {
            message.heartbeat = object.heartbeat;
        }
        else {
            message.heartbeat = new Uint8Array();
        }
        if (object.signature !== undefined && object.signature !== null) {
            message.signature = object.signature;
        }
        else {
            message.signature = new Uint8Array();
        }
        if (object.guardianAddr !== undefined && object.guardianAddr !== null) {
            message.guardianAddr = object.guardianAddr;
        }
        else {
            message.guardianAddr = new Uint8Array();
        }
        return message;
    },
};
const baseHeartbeat = {
    nodeName: "",
    counter: "0",
    timestamp: "0",
    version: "",
    guardianAddr: "",
    bootTimestamp: "0",
};
export const Heartbeat = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.nodeName !== "") {
            writer.uint32(10).string(message.nodeName);
        }
        if (message.counter !== "0") {
            writer.uint32(16).int64(message.counter);
        }
        if (message.timestamp !== "0") {
            writer.uint32(24).int64(message.timestamp);
        }
        for (const v of message.networks) {
            Heartbeat_Network.encode(v, writer.uint32(34).fork()).ldelim();
        }
        if (message.version !== "") {
            writer.uint32(42).string(message.version);
        }
        if (message.guardianAddr !== "") {
            writer.uint32(50).string(message.guardianAddr);
        }
        if (message.bootTimestamp !== "0") {
            writer.uint32(56).int64(message.bootTimestamp);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseHeartbeat);
        message.networks = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.nodeName = reader.string();
                    break;
                case 2:
                    message.counter = longToString(reader.int64());
                    break;
                case 3:
                    message.timestamp = longToString(reader.int64());
                    break;
                case 4:
                    message.networks.push(Heartbeat_Network.decode(reader, reader.uint32()));
                    break;
                case 5:
                    message.version = reader.string();
                    break;
                case 6:
                    message.guardianAddr = reader.string();
                    break;
                case 7:
                    message.bootTimestamp = longToString(reader.int64());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseHeartbeat);
        message.networks = [];
        if (object.nodeName !== undefined && object.nodeName !== null) {
            message.nodeName = String(object.nodeName);
        }
        else {
            message.nodeName = "";
        }
        if (object.counter !== undefined && object.counter !== null) {
            message.counter = String(object.counter);
        }
        else {
            message.counter = "0";
        }
        if (object.timestamp !== undefined && object.timestamp !== null) {
            message.timestamp = String(object.timestamp);
        }
        else {
            message.timestamp = "0";
        }
        if (object.networks !== undefined && object.networks !== null) {
            for (const e of object.networks) {
                message.networks.push(Heartbeat_Network.fromJSON(e));
            }
        }
        if (object.version !== undefined && object.version !== null) {
            message.version = String(object.version);
        }
        else {
            message.version = "";
        }
        if (object.guardianAddr !== undefined && object.guardianAddr !== null) {
            message.guardianAddr = String(object.guardianAddr);
        }
        else {
            message.guardianAddr = "";
        }
        if (object.bootTimestamp !== undefined && object.bootTimestamp !== null) {
            message.bootTimestamp = String(object.bootTimestamp);
        }
        else {
            message.bootTimestamp = "0";
        }
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.nodeName !== undefined && (obj.nodeName = message.nodeName);
        message.counter !== undefined && (obj.counter = message.counter);
        message.timestamp !== undefined && (obj.timestamp = message.timestamp);
        if (message.networks) {
            obj.networks = message.networks.map((e) => e ? Heartbeat_Network.toJSON(e) : undefined);
        }
        else {
            obj.networks = [];
        }
        message.version !== undefined && (obj.version = message.version);
        message.guardianAddr !== undefined &&
            (obj.guardianAddr = message.guardianAddr);
        message.bootTimestamp !== undefined &&
            (obj.bootTimestamp = message.bootTimestamp);
        return obj;
    },
    fromPartial(object) {
        const message = Object.assign({}, baseHeartbeat);
        message.networks = [];
        if (object.nodeName !== undefined && object.nodeName !== null) {
            message.nodeName = object.nodeName;
        }
        else {
            message.nodeName = "";
        }
        if (object.counter !== undefined && object.counter !== null) {
            message.counter = object.counter;
        }
        else {
            message.counter = "0";
        }
        if (object.timestamp !== undefined && object.timestamp !== null) {
            message.timestamp = object.timestamp;
        }
        else {
            message.timestamp = "0";
        }
        if (object.networks !== undefined && object.networks !== null) {
            for (const e of object.networks) {
                message.networks.push(Heartbeat_Network.fromPartial(e));
            }
        }
        if (object.version !== undefined && object.version !== null) {
            message.version = object.version;
        }
        else {
            message.version = "";
        }
        if (object.guardianAddr !== undefined && object.guardianAddr !== null) {
            message.guardianAddr = object.guardianAddr;
        }
        else {
            message.guardianAddr = "";
        }
        if (object.bootTimestamp !== undefined && object.bootTimestamp !== null) {
            message.bootTimestamp = object.bootTimestamp;
        }
        else {
            message.bootTimestamp = "0";
        }
        return message;
    },
};
const baseHeartbeat_Network = {
    id: 0,
    height: "0",
    contractAddress: "",
    errorCount: "0",
};
export const Heartbeat_Network = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.id !== 0) {
            writer.uint32(8).uint32(message.id);
        }
        if (message.height !== "0") {
            writer.uint32(16).int64(message.height);
        }
        if (message.contractAddress !== "") {
            writer.uint32(26).string(message.contractAddress);
        }
        if (message.errorCount !== "0") {
            writer.uint32(32).uint64(message.errorCount);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseHeartbeat_Network);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.id = reader.uint32();
                    break;
                case 2:
                    message.height = longToString(reader.int64());
                    break;
                case 3:
                    message.contractAddress = reader.string();
                    break;
                case 4:
                    message.errorCount = longToString(reader.uint64());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseHeartbeat_Network);
        if (object.id !== undefined && object.id !== null) {
            message.id = Number(object.id);
        }
        else {
            message.id = 0;
        }
        if (object.height !== undefined && object.height !== null) {
            message.height = String(object.height);
        }
        else {
            message.height = "0";
        }
        if (object.contractAddress !== undefined &&
            object.contractAddress !== null) {
            message.contractAddress = String(object.contractAddress);
        }
        else {
            message.contractAddress = "";
        }
        if (object.errorCount !== undefined && object.errorCount !== null) {
            message.errorCount = String(object.errorCount);
        }
        else {
            message.errorCount = "0";
        }
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.id !== undefined && (obj.id = message.id);
        message.height !== undefined && (obj.height = message.height);
        message.contractAddress !== undefined &&
            (obj.contractAddress = message.contractAddress);
        message.errorCount !== undefined && (obj.errorCount = message.errorCount);
        return obj;
    },
    fromPartial(object) {
        const message = Object.assign({}, baseHeartbeat_Network);
        if (object.id !== undefined && object.id !== null) {
            message.id = object.id;
        }
        else {
            message.id = 0;
        }
        if (object.height !== undefined && object.height !== null) {
            message.height = object.height;
        }
        else {
            message.height = "0";
        }
        if (object.contractAddress !== undefined &&
            object.contractAddress !== null) {
            message.contractAddress = object.contractAddress;
        }
        else {
            message.contractAddress = "";
        }
        if (object.errorCount !== undefined && object.errorCount !== null) {
            message.errorCount = object.errorCount;
        }
        else {
            message.errorCount = "0";
        }
        return message;
    },
};
const baseSignedObservation = { messageId: "" };
export const SignedObservation = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.addr.length !== 0) {
            writer.uint32(10).bytes(message.addr);
        }
        if (message.hash.length !== 0) {
            writer.uint32(18).bytes(message.hash);
        }
        if (message.signature.length !== 0) {
            writer.uint32(26).bytes(message.signature);
        }
        if (message.txHash.length !== 0) {
            writer.uint32(34).bytes(message.txHash);
        }
        if (message.messageId !== "") {
            writer.uint32(42).string(message.messageId);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseSignedObservation);
        message.addr = new Uint8Array();
        message.hash = new Uint8Array();
        message.signature = new Uint8Array();
        message.txHash = new Uint8Array();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.addr = reader.bytes();
                    break;
                case 2:
                    message.hash = reader.bytes();
                    break;
                case 3:
                    message.signature = reader.bytes();
                    break;
                case 4:
                    message.txHash = reader.bytes();
                    break;
                case 5:
                    message.messageId = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseSignedObservation);
        message.addr = new Uint8Array();
        message.hash = new Uint8Array();
        message.signature = new Uint8Array();
        message.txHash = new Uint8Array();
        if (object.addr !== undefined && object.addr !== null) {
            message.addr = bytesFromBase64(object.addr);
        }
        if (object.hash !== undefined && object.hash !== null) {
            message.hash = bytesFromBase64(object.hash);
        }
        if (object.signature !== undefined && object.signature !== null) {
            message.signature = bytesFromBase64(object.signature);
        }
        if (object.txHash !== undefined && object.txHash !== null) {
            message.txHash = bytesFromBase64(object.txHash);
        }
        if (object.messageId !== undefined && object.messageId !== null) {
            message.messageId = String(object.messageId);
        }
        else {
            message.messageId = "";
        }
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.addr !== undefined &&
            (obj.addr = base64FromBytes(message.addr !== undefined ? message.addr : new Uint8Array()));
        message.hash !== undefined &&
            (obj.hash = base64FromBytes(message.hash !== undefined ? message.hash : new Uint8Array()));
        message.signature !== undefined &&
            (obj.signature = base64FromBytes(message.signature !== undefined ? message.signature : new Uint8Array()));
        message.txHash !== undefined &&
            (obj.txHash = base64FromBytes(message.txHash !== undefined ? message.txHash : new Uint8Array()));
        message.messageId !== undefined && (obj.messageId = message.messageId);
        return obj;
    },
    fromPartial(object) {
        const message = Object.assign({}, baseSignedObservation);
        if (object.addr !== undefined && object.addr !== null) {
            message.addr = object.addr;
        }
        else {
            message.addr = new Uint8Array();
        }
        if (object.hash !== undefined && object.hash !== null) {
            message.hash = object.hash;
        }
        else {
            message.hash = new Uint8Array();
        }
        if (object.signature !== undefined && object.signature !== null) {
            message.signature = object.signature;
        }
        else {
            message.signature = new Uint8Array();
        }
        if (object.txHash !== undefined && object.txHash !== null) {
            message.txHash = object.txHash;
        }
        else {
            message.txHash = new Uint8Array();
        }
        if (object.messageId !== undefined && object.messageId !== null) {
            message.messageId = object.messageId;
        }
        else {
            message.messageId = "";
        }
        return message;
    },
};
const baseSignedVAAWithQuorum = {};
export const SignedVAAWithQuorum = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.vaa.length !== 0) {
            writer.uint32(10).bytes(message.vaa);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseSignedVAAWithQuorum);
        message.vaa = new Uint8Array();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.vaa = reader.bytes();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseSignedVAAWithQuorum);
        message.vaa = new Uint8Array();
        if (object.vaa !== undefined && object.vaa !== null) {
            message.vaa = bytesFromBase64(object.vaa);
        }
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.vaa !== undefined &&
            (obj.vaa = base64FromBytes(message.vaa !== undefined ? message.vaa : new Uint8Array()));
        return obj;
    },
    fromPartial(object) {
        const message = Object.assign({}, baseSignedVAAWithQuorum);
        if (object.vaa !== undefined && object.vaa !== null) {
            message.vaa = object.vaa;
        }
        else {
            message.vaa = new Uint8Array();
        }
        return message;
    },
};
const baseSignedObservationRequest = {};
export const SignedObservationRequest = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.observationRequest.length !== 0) {
            writer.uint32(10).bytes(message.observationRequest);
        }
        if (message.signature.length !== 0) {
            writer.uint32(18).bytes(message.signature);
        }
        if (message.guardianAddr.length !== 0) {
            writer.uint32(26).bytes(message.guardianAddr);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseSignedObservationRequest);
        message.observationRequest = new Uint8Array();
        message.signature = new Uint8Array();
        message.guardianAddr = new Uint8Array();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.observationRequest = reader.bytes();
                    break;
                case 2:
                    message.signature = reader.bytes();
                    break;
                case 3:
                    message.guardianAddr = reader.bytes();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseSignedObservationRequest);
        message.observationRequest = new Uint8Array();
        message.signature = new Uint8Array();
        message.guardianAddr = new Uint8Array();
        if (object.observationRequest !== undefined &&
            object.observationRequest !== null) {
            message.observationRequest = bytesFromBase64(object.observationRequest);
        }
        if (object.signature !== undefined && object.signature !== null) {
            message.signature = bytesFromBase64(object.signature);
        }
        if (object.guardianAddr !== undefined && object.guardianAddr !== null) {
            message.guardianAddr = bytesFromBase64(object.guardianAddr);
        }
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.observationRequest !== undefined &&
            (obj.observationRequest = base64FromBytes(message.observationRequest !== undefined
                ? message.observationRequest
                : new Uint8Array()));
        message.signature !== undefined &&
            (obj.signature = base64FromBytes(message.signature !== undefined ? message.signature : new Uint8Array()));
        message.guardianAddr !== undefined &&
            (obj.guardianAddr = base64FromBytes(message.guardianAddr !== undefined
                ? message.guardianAddr
                : new Uint8Array()));
        return obj;
    },
    fromPartial(object) {
        const message = Object.assign({}, baseSignedObservationRequest);
        if (object.observationRequest !== undefined &&
            object.observationRequest !== null) {
            message.observationRequest = object.observationRequest;
        }
        else {
            message.observationRequest = new Uint8Array();
        }
        if (object.signature !== undefined && object.signature !== null) {
            message.signature = object.signature;
        }
        else {
            message.signature = new Uint8Array();
        }
        if (object.guardianAddr !== undefined && object.guardianAddr !== null) {
            message.guardianAddr = object.guardianAddr;
        }
        else {
            message.guardianAddr = new Uint8Array();
        }
        return message;
    },
};
const baseObservationRequest = { chainId: 0 };
export const ObservationRequest = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.chainId !== 0) {
            writer.uint32(8).uint32(message.chainId);
        }
        if (message.txHash.length !== 0) {
            writer.uint32(18).bytes(message.txHash);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseObservationRequest);
        message.txHash = new Uint8Array();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.chainId = reader.uint32();
                    break;
                case 2:
                    message.txHash = reader.bytes();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseObservationRequest);
        message.txHash = new Uint8Array();
        if (object.chainId !== undefined && object.chainId !== null) {
            message.chainId = Number(object.chainId);
        }
        else {
            message.chainId = 0;
        }
        if (object.txHash !== undefined && object.txHash !== null) {
            message.txHash = bytesFromBase64(object.txHash);
        }
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.chainId !== undefined && (obj.chainId = message.chainId);
        message.txHash !== undefined &&
            (obj.txHash = base64FromBytes(message.txHash !== undefined ? message.txHash : new Uint8Array()));
        return obj;
    },
    fromPartial(object) {
        const message = Object.assign({}, baseObservationRequest);
        if (object.chainId !== undefined && object.chainId !== null) {
            message.chainId = object.chainId;
        }
        else {
            message.chainId = 0;
        }
        if (object.txHash !== undefined && object.txHash !== null) {
            message.txHash = object.txHash;
        }
        else {
            message.txHash = new Uint8Array();
        }
        return message;
    },
};
var globalThis = (() => {
    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 = globalThis.atob ||
    ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary"));
function bytesFromBase64(b64) {
    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 = globalThis.btoa ||
    ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64"));
function base64FromBytes(arr) {
    const bin = [];
    for (const byte of arr) {
        bin.push(String.fromCharCode(byte));
    }
    return btoa(bin.join(""));
}
function longToString(long) {
    return long.toString();
}
if (_m0.util.Long !== Long) {
    _m0.util.Long = Long;
    _m0.configure();
}
