//@ts-nocheck
import { Any } from '../../../../google/protobuf/any.js';
import { BinaryReader, BinaryWriter } from '../../../../binary.js';
import { isSet } from '../../../../helpers.js';
import {} from '../../../../json-safe.js';
import { decodeBase64 as bytesFromBase64 } from '@endo/base64';
import { encodeBase64 as base64FromBytes } from '@endo/base64';
function createBaseClientState() {
    return {
        sequence: BigInt(0),
        isFrozen: false,
        consensusState: undefined,
    };
}
export const ClientState = {
    typeUrl: '/ibc.lightclients.solomachine.v3.ClientState',
    encode(message, writer = BinaryWriter.create()) {
        if (message.sequence !== BigInt(0)) {
            writer.uint32(8).uint64(message.sequence);
        }
        if (message.isFrozen === true) {
            writer.uint32(16).bool(message.isFrozen);
        }
        if (message.consensusState !== undefined) {
            ConsensusState.encode(message.consensusState, writer.uint32(26).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseClientState();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.sequence = reader.uint64();
                    break;
                case 2:
                    message.isFrozen = reader.bool();
                    break;
                case 3:
                    message.consensusState = ConsensusState.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        return {
            sequence: isSet(object.sequence)
                ? BigInt(object.sequence.toString())
                : BigInt(0),
            isFrozen: isSet(object.isFrozen) ? Boolean(object.isFrozen) : false,
            consensusState: isSet(object.consensusState)
                ? ConsensusState.fromJSON(object.consensusState)
                : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        message.sequence !== undefined &&
            (obj.sequence = (message.sequence || BigInt(0)).toString());
        message.isFrozen !== undefined && (obj.isFrozen = message.isFrozen);
        message.consensusState !== undefined &&
            (obj.consensusState = message.consensusState
                ? ConsensusState.toJSON(message.consensusState)
                : undefined);
        return obj;
    },
    fromPartial(object) {
        const message = createBaseClientState();
        message.sequence =
            object.sequence !== undefined && object.sequence !== null
                ? BigInt(object.sequence.toString())
                : BigInt(0);
        message.isFrozen = object.isFrozen ?? false;
        message.consensusState =
            object.consensusState !== undefined && object.consensusState !== null
                ? ConsensusState.fromPartial(object.consensusState)
                : undefined;
        return message;
    },
    fromProtoMsg(message) {
        return ClientState.decode(message.value);
    },
    toProto(message) {
        return ClientState.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: '/ibc.lightclients.solomachine.v3.ClientState',
            value: ClientState.encode(message).finish(),
        };
    },
};
function createBaseConsensusState() {
    return {
        publicKey: undefined,
        diversifier: '',
        timestamp: BigInt(0),
    };
}
export const ConsensusState = {
    typeUrl: '/ibc.lightclients.solomachine.v3.ConsensusState',
    encode(message, writer = BinaryWriter.create()) {
        if (message.publicKey !== undefined) {
            Any.encode(message.publicKey, writer.uint32(10).fork()).ldelim();
        }
        if (message.diversifier !== '') {
            writer.uint32(18).string(message.diversifier);
        }
        if (message.timestamp !== BigInt(0)) {
            writer.uint32(24).uint64(message.timestamp);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseConsensusState();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.publicKey = Any.decode(reader, reader.uint32());
                    break;
                case 2:
                    message.diversifier = reader.string();
                    break;
                case 3:
                    message.timestamp = reader.uint64();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        return {
            publicKey: isSet(object.publicKey)
                ? Any.fromJSON(object.publicKey)
                : undefined,
            diversifier: isSet(object.diversifier) ? String(object.diversifier) : '',
            timestamp: isSet(object.timestamp)
                ? BigInt(object.timestamp.toString())
                : BigInt(0),
        };
    },
    toJSON(message) {
        const obj = {};
        message.publicKey !== undefined &&
            (obj.publicKey = message.publicKey
                ? Any.toJSON(message.publicKey)
                : undefined);
        message.diversifier !== undefined &&
            (obj.diversifier = message.diversifier);
        message.timestamp !== undefined &&
            (obj.timestamp = (message.timestamp || BigInt(0)).toString());
        return obj;
    },
    fromPartial(object) {
        const message = createBaseConsensusState();
        message.publicKey =
            object.publicKey !== undefined && object.publicKey !== null
                ? Any.fromPartial(object.publicKey)
                : undefined;
        message.diversifier = object.diversifier ?? '';
        message.timestamp =
            object.timestamp !== undefined && object.timestamp !== null
                ? BigInt(object.timestamp.toString())
                : BigInt(0);
        return message;
    },
    fromProtoMsg(message) {
        return ConsensusState.decode(message.value);
    },
    toProto(message) {
        return ConsensusState.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: '/ibc.lightclients.solomachine.v3.ConsensusState',
            value: ConsensusState.encode(message).finish(),
        };
    },
};
function createBaseHeader() {
    return {
        timestamp: BigInt(0),
        signature: new Uint8Array(),
        newPublicKey: undefined,
        newDiversifier: '',
    };
}
export const Header = {
    typeUrl: '/ibc.lightclients.solomachine.v3.Header',
    encode(message, writer = BinaryWriter.create()) {
        if (message.timestamp !== BigInt(0)) {
            writer.uint32(8).uint64(message.timestamp);
        }
        if (message.signature.length !== 0) {
            writer.uint32(18).bytes(message.signature);
        }
        if (message.newPublicKey !== undefined) {
            Any.encode(message.newPublicKey, writer.uint32(26).fork()).ldelim();
        }
        if (message.newDiversifier !== '') {
            writer.uint32(34).string(message.newDiversifier);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseHeader();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.timestamp = reader.uint64();
                    break;
                case 2:
                    message.signature = reader.bytes();
                    break;
                case 3:
                    message.newPublicKey = Any.decode(reader, reader.uint32());
                    break;
                case 4:
                    message.newDiversifier = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        return {
            timestamp: isSet(object.timestamp)
                ? BigInt(object.timestamp.toString())
                : BigInt(0),
            signature: isSet(object.signature)
                ? bytesFromBase64(object.signature)
                : new Uint8Array(),
            newPublicKey: isSet(object.newPublicKey)
                ? Any.fromJSON(object.newPublicKey)
                : undefined,
            newDiversifier: isSet(object.newDiversifier)
                ? String(object.newDiversifier)
                : '',
        };
    },
    toJSON(message) {
        const obj = {};
        message.timestamp !== undefined &&
            (obj.timestamp = (message.timestamp || BigInt(0)).toString());
        message.signature !== undefined &&
            (obj.signature = base64FromBytes(message.signature !== undefined ? message.signature : new Uint8Array()));
        message.newPublicKey !== undefined &&
            (obj.newPublicKey = message.newPublicKey
                ? Any.toJSON(message.newPublicKey)
                : undefined);
        message.newDiversifier !== undefined &&
            (obj.newDiversifier = message.newDiversifier);
        return obj;
    },
    fromPartial(object) {
        const message = createBaseHeader();
        message.timestamp =
            object.timestamp !== undefined && object.timestamp !== null
                ? BigInt(object.timestamp.toString())
                : BigInt(0);
        message.signature = object.signature ?? new Uint8Array();
        message.newPublicKey =
            object.newPublicKey !== undefined && object.newPublicKey !== null
                ? Any.fromPartial(object.newPublicKey)
                : undefined;
        message.newDiversifier = object.newDiversifier ?? '';
        return message;
    },
    fromProtoMsg(message) {
        return Header.decode(message.value);
    },
    toProto(message) {
        return Header.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: '/ibc.lightclients.solomachine.v3.Header',
            value: Header.encode(message).finish(),
        };
    },
};
function createBaseMisbehaviour() {
    return {
        sequence: BigInt(0),
        signatureOne: undefined,
        signatureTwo: undefined,
    };
}
export const Misbehaviour = {
    typeUrl: '/ibc.lightclients.solomachine.v3.Misbehaviour',
    encode(message, writer = BinaryWriter.create()) {
        if (message.sequence !== BigInt(0)) {
            writer.uint32(8).uint64(message.sequence);
        }
        if (message.signatureOne !== undefined) {
            SignatureAndData.encode(message.signatureOne, writer.uint32(18).fork()).ldelim();
        }
        if (message.signatureTwo !== undefined) {
            SignatureAndData.encode(message.signatureTwo, writer.uint32(26).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseMisbehaviour();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.sequence = reader.uint64();
                    break;
                case 2:
                    message.signatureOne = SignatureAndData.decode(reader, reader.uint32());
                    break;
                case 3:
                    message.signatureTwo = SignatureAndData.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        return {
            sequence: isSet(object.sequence)
                ? BigInt(object.sequence.toString())
                : BigInt(0),
            signatureOne: isSet(object.signatureOne)
                ? SignatureAndData.fromJSON(object.signatureOne)
                : undefined,
            signatureTwo: isSet(object.signatureTwo)
                ? SignatureAndData.fromJSON(object.signatureTwo)
                : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        message.sequence !== undefined &&
            (obj.sequence = (message.sequence || BigInt(0)).toString());
        message.signatureOne !== undefined &&
            (obj.signatureOne = message.signatureOne
                ? SignatureAndData.toJSON(message.signatureOne)
                : undefined);
        message.signatureTwo !== undefined &&
            (obj.signatureTwo = message.signatureTwo
                ? SignatureAndData.toJSON(message.signatureTwo)
                : undefined);
        return obj;
    },
    fromPartial(object) {
        const message = createBaseMisbehaviour();
        message.sequence =
            object.sequence !== undefined && object.sequence !== null
                ? BigInt(object.sequence.toString())
                : BigInt(0);
        message.signatureOne =
            object.signatureOne !== undefined && object.signatureOne !== null
                ? SignatureAndData.fromPartial(object.signatureOne)
                : undefined;
        message.signatureTwo =
            object.signatureTwo !== undefined && object.signatureTwo !== null
                ? SignatureAndData.fromPartial(object.signatureTwo)
                : undefined;
        return message;
    },
    fromProtoMsg(message) {
        return Misbehaviour.decode(message.value);
    },
    toProto(message) {
        return Misbehaviour.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: '/ibc.lightclients.solomachine.v3.Misbehaviour',
            value: Misbehaviour.encode(message).finish(),
        };
    },
};
function createBaseSignatureAndData() {
    return {
        signature: new Uint8Array(),
        path: new Uint8Array(),
        data: new Uint8Array(),
        timestamp: BigInt(0),
    };
}
export const SignatureAndData = {
    typeUrl: '/ibc.lightclients.solomachine.v3.SignatureAndData',
    encode(message, writer = BinaryWriter.create()) {
        if (message.signature.length !== 0) {
            writer.uint32(10).bytes(message.signature);
        }
        if (message.path.length !== 0) {
            writer.uint32(18).bytes(message.path);
        }
        if (message.data.length !== 0) {
            writer.uint32(26).bytes(message.data);
        }
        if (message.timestamp !== BigInt(0)) {
            writer.uint32(32).uint64(message.timestamp);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseSignatureAndData();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.signature = reader.bytes();
                    break;
                case 2:
                    message.path = reader.bytes();
                    break;
                case 3:
                    message.data = reader.bytes();
                    break;
                case 4:
                    message.timestamp = reader.uint64();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        return {
            signature: isSet(object.signature)
                ? bytesFromBase64(object.signature)
                : new Uint8Array(),
            path: isSet(object.path)
                ? bytesFromBase64(object.path)
                : new Uint8Array(),
            data: isSet(object.data)
                ? bytesFromBase64(object.data)
                : new Uint8Array(),
            timestamp: isSet(object.timestamp)
                ? BigInt(object.timestamp.toString())
                : BigInt(0),
        };
    },
    toJSON(message) {
        const obj = {};
        message.signature !== undefined &&
            (obj.signature = base64FromBytes(message.signature !== undefined ? message.signature : new Uint8Array()));
        message.path !== undefined &&
            (obj.path = base64FromBytes(message.path !== undefined ? message.path : new Uint8Array()));
        message.data !== undefined &&
            (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array()));
        message.timestamp !== undefined &&
            (obj.timestamp = (message.timestamp || BigInt(0)).toString());
        return obj;
    },
    fromPartial(object) {
        const message = createBaseSignatureAndData();
        message.signature = object.signature ?? new Uint8Array();
        message.path = object.path ?? new Uint8Array();
        message.data = object.data ?? new Uint8Array();
        message.timestamp =
            object.timestamp !== undefined && object.timestamp !== null
                ? BigInt(object.timestamp.toString())
                : BigInt(0);
        return message;
    },
    fromProtoMsg(message) {
        return SignatureAndData.decode(message.value);
    },
    toProto(message) {
        return SignatureAndData.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: '/ibc.lightclients.solomachine.v3.SignatureAndData',
            value: SignatureAndData.encode(message).finish(),
        };
    },
};
function createBaseTimestampedSignatureData() {
    return {
        signatureData: new Uint8Array(),
        timestamp: BigInt(0),
    };
}
export const TimestampedSignatureData = {
    typeUrl: '/ibc.lightclients.solomachine.v3.TimestampedSignatureData',
    encode(message, writer = BinaryWriter.create()) {
        if (message.signatureData.length !== 0) {
            writer.uint32(10).bytes(message.signatureData);
        }
        if (message.timestamp !== BigInt(0)) {
            writer.uint32(16).uint64(message.timestamp);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseTimestampedSignatureData();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.signatureData = reader.bytes();
                    break;
                case 2:
                    message.timestamp = reader.uint64();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        return {
            signatureData: isSet(object.signatureData)
                ? bytesFromBase64(object.signatureData)
                : new Uint8Array(),
            timestamp: isSet(object.timestamp)
                ? BigInt(object.timestamp.toString())
                : BigInt(0),
        };
    },
    toJSON(message) {
        const obj = {};
        message.signatureData !== undefined &&
            (obj.signatureData = base64FromBytes(message.signatureData !== undefined
                ? message.signatureData
                : new Uint8Array()));
        message.timestamp !== undefined &&
            (obj.timestamp = (message.timestamp || BigInt(0)).toString());
        return obj;
    },
    fromPartial(object) {
        const message = createBaseTimestampedSignatureData();
        message.signatureData = object.signatureData ?? new Uint8Array();
        message.timestamp =
            object.timestamp !== undefined && object.timestamp !== null
                ? BigInt(object.timestamp.toString())
                : BigInt(0);
        return message;
    },
    fromProtoMsg(message) {
        return TimestampedSignatureData.decode(message.value);
    },
    toProto(message) {
        return TimestampedSignatureData.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: '/ibc.lightclients.solomachine.v3.TimestampedSignatureData',
            value: TimestampedSignatureData.encode(message).finish(),
        };
    },
};
function createBaseSignBytes() {
    return {
        sequence: BigInt(0),
        timestamp: BigInt(0),
        diversifier: '',
        path: new Uint8Array(),
        data: new Uint8Array(),
    };
}
export const SignBytes = {
    typeUrl: '/ibc.lightclients.solomachine.v3.SignBytes',
    encode(message, writer = BinaryWriter.create()) {
        if (message.sequence !== BigInt(0)) {
            writer.uint32(8).uint64(message.sequence);
        }
        if (message.timestamp !== BigInt(0)) {
            writer.uint32(16).uint64(message.timestamp);
        }
        if (message.diversifier !== '') {
            writer.uint32(26).string(message.diversifier);
        }
        if (message.path.length !== 0) {
            writer.uint32(34).bytes(message.path);
        }
        if (message.data.length !== 0) {
            writer.uint32(42).bytes(message.data);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseSignBytes();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.sequence = reader.uint64();
                    break;
                case 2:
                    message.timestamp = reader.uint64();
                    break;
                case 3:
                    message.diversifier = reader.string();
                    break;
                case 4:
                    message.path = reader.bytes();
                    break;
                case 5:
                    message.data = reader.bytes();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        return {
            sequence: isSet(object.sequence)
                ? BigInt(object.sequence.toString())
                : BigInt(0),
            timestamp: isSet(object.timestamp)
                ? BigInt(object.timestamp.toString())
                : BigInt(0),
            diversifier: isSet(object.diversifier) ? String(object.diversifier) : '',
            path: isSet(object.path)
                ? bytesFromBase64(object.path)
                : new Uint8Array(),
            data: isSet(object.data)
                ? bytesFromBase64(object.data)
                : new Uint8Array(),
        };
    },
    toJSON(message) {
        const obj = {};
        message.sequence !== undefined &&
            (obj.sequence = (message.sequence || BigInt(0)).toString());
        message.timestamp !== undefined &&
            (obj.timestamp = (message.timestamp || BigInt(0)).toString());
        message.diversifier !== undefined &&
            (obj.diversifier = message.diversifier);
        message.path !== undefined &&
            (obj.path = base64FromBytes(message.path !== undefined ? message.path : new Uint8Array()));
        message.data !== undefined &&
            (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array()));
        return obj;
    },
    fromPartial(object) {
        const message = createBaseSignBytes();
        message.sequence =
            object.sequence !== undefined && object.sequence !== null
                ? BigInt(object.sequence.toString())
                : BigInt(0);
        message.timestamp =
            object.timestamp !== undefined && object.timestamp !== null
                ? BigInt(object.timestamp.toString())
                : BigInt(0);
        message.diversifier = object.diversifier ?? '';
        message.path = object.path ?? new Uint8Array();
        message.data = object.data ?? new Uint8Array();
        return message;
    },
    fromProtoMsg(message) {
        return SignBytes.decode(message.value);
    },
    toProto(message) {
        return SignBytes.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: '/ibc.lightclients.solomachine.v3.SignBytes',
            value: SignBytes.encode(message).finish(),
        };
    },
};
function createBaseHeaderData() {
    return {
        newPubKey: undefined,
        newDiversifier: '',
    };
}
export const HeaderData = {
    typeUrl: '/ibc.lightclients.solomachine.v3.HeaderData',
    encode(message, writer = BinaryWriter.create()) {
        if (message.newPubKey !== undefined) {
            Any.encode(message.newPubKey, writer.uint32(10).fork()).ldelim();
        }
        if (message.newDiversifier !== '') {
            writer.uint32(18).string(message.newDiversifier);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseHeaderData();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.newPubKey = Any.decode(reader, reader.uint32());
                    break;
                case 2:
                    message.newDiversifier = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        return {
            newPubKey: isSet(object.newPubKey)
                ? Any.fromJSON(object.newPubKey)
                : undefined,
            newDiversifier: isSet(object.newDiversifier)
                ? String(object.newDiversifier)
                : '',
        };
    },
    toJSON(message) {
        const obj = {};
        message.newPubKey !== undefined &&
            (obj.newPubKey = message.newPubKey
                ? Any.toJSON(message.newPubKey)
                : undefined);
        message.newDiversifier !== undefined &&
            (obj.newDiversifier = message.newDiversifier);
        return obj;
    },
    fromPartial(object) {
        const message = createBaseHeaderData();
        message.newPubKey =
            object.newPubKey !== undefined && object.newPubKey !== null
                ? Any.fromPartial(object.newPubKey)
                : undefined;
        message.newDiversifier = object.newDiversifier ?? '';
        return message;
    },
    fromProtoMsg(message) {
        return HeaderData.decode(message.value);
    },
    toProto(message) {
        return HeaderData.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: '/ibc.lightclients.solomachine.v3.HeaderData',
            value: HeaderData.encode(message).finish(),
        };
    },
};
//# sourceMappingURL=solomachine.js.map