"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.GenesisState = void 0;
const genesis_1 = require("../../client/v1/genesis");
const genesis_2 = require("../../connection/v1/genesis");
const genesis_3 = require("../../channel/v1/genesis");
const genesis_4 = require("../../client/v2/genesis");
const genesis_5 = require("../../channel/v2/genesis");
const binary_1 = require("../../../../binary");
const registry_1 = require("../../../../registry");
function createBaseGenesisState() {
    return {
        clientGenesis: genesis_1.GenesisState.fromPartial({}),
        connectionGenesis: genesis_2.GenesisState.fromPartial({}),
        channelGenesis: genesis_3.GenesisState.fromPartial({}),
        clientV2Genesis: genesis_4.GenesisState.fromPartial({}),
        channelV2Genesis: genesis_5.GenesisState.fromPartial({})
    };
}
/**
 * GenesisState defines the ibc module's genesis state.
 * @name GenesisState
 * @package ibc.core.types.v1
 * @see proto type: ibc.core.types.v1.GenesisState
 */
exports.GenesisState = {
    typeUrl: "/ibc.core.types.v1.GenesisState",
    aminoType: "cosmos-sdk/GenesisState",
    is(o) {
        return o && (o.$typeUrl === exports.GenesisState.typeUrl || genesis_1.GenesisState.is(o.clientGenesis) && genesis_2.GenesisState.is(o.connectionGenesis) && genesis_3.GenesisState.is(o.channelGenesis) && genesis_4.GenesisState.is(o.clientV2Genesis) && genesis_5.GenesisState.is(o.channelV2Genesis));
    },
    isAmino(o) {
        return o && (o.$typeUrl === exports.GenesisState.typeUrl || genesis_1.GenesisState.isAmino(o.client_genesis) && genesis_2.GenesisState.isAmino(o.connection_genesis) && genesis_3.GenesisState.isAmino(o.channel_genesis) && genesis_4.GenesisState.isAmino(o.client_v2_genesis) && genesis_5.GenesisState.isAmino(o.channel_v2_genesis));
    },
    encode(message, writer = binary_1.BinaryWriter.create()) {
        if (message.clientGenesis !== undefined) {
            genesis_1.GenesisState.encode(message.clientGenesis, writer.uint32(10).fork()).ldelim();
        }
        if (message.connectionGenesis !== undefined) {
            genesis_2.GenesisState.encode(message.connectionGenesis, writer.uint32(18).fork()).ldelim();
        }
        if (message.channelGenesis !== undefined) {
            genesis_3.GenesisState.encode(message.channelGenesis, writer.uint32(26).fork()).ldelim();
        }
        if (message.clientV2Genesis !== undefined) {
            genesis_4.GenesisState.encode(message.clientV2Genesis, writer.uint32(34).fork()).ldelim();
        }
        if (message.channelV2Genesis !== undefined) {
            genesis_5.GenesisState.encode(message.channelV2Genesis, writer.uint32(42).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof binary_1.BinaryReader ? input : new binary_1.BinaryReader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseGenesisState();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.clientGenesis = genesis_1.GenesisState.decode(reader, reader.uint32());
                    break;
                case 2:
                    message.connectionGenesis = genesis_2.GenesisState.decode(reader, reader.uint32());
                    break;
                case 3:
                    message.channelGenesis = genesis_3.GenesisState.decode(reader, reader.uint32());
                    break;
                case 4:
                    message.clientV2Genesis = genesis_4.GenesisState.decode(reader, reader.uint32());
                    break;
                case 5:
                    message.channelV2Genesis = genesis_5.GenesisState.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(object) {
        const message = createBaseGenesisState();
        message.clientGenesis = object.clientGenesis !== undefined && object.clientGenesis !== null ? genesis_1.GenesisState.fromPartial(object.clientGenesis) : undefined;
        message.connectionGenesis = object.connectionGenesis !== undefined && object.connectionGenesis !== null ? genesis_2.GenesisState.fromPartial(object.connectionGenesis) : undefined;
        message.channelGenesis = object.channelGenesis !== undefined && object.channelGenesis !== null ? genesis_3.GenesisState.fromPartial(object.channelGenesis) : undefined;
        message.clientV2Genesis = object.clientV2Genesis !== undefined && object.clientV2Genesis !== null ? genesis_4.GenesisState.fromPartial(object.clientV2Genesis) : undefined;
        message.channelV2Genesis = object.channelV2Genesis !== undefined && object.channelV2Genesis !== null ? genesis_5.GenesisState.fromPartial(object.channelV2Genesis) : undefined;
        return message;
    },
    fromAmino(object) {
        const message = createBaseGenesisState();
        if (object.client_genesis !== undefined && object.client_genesis !== null) {
            message.clientGenesis = genesis_1.GenesisState.fromAmino(object.client_genesis);
        }
        if (object.connection_genesis !== undefined && object.connection_genesis !== null) {
            message.connectionGenesis = genesis_2.GenesisState.fromAmino(object.connection_genesis);
        }
        if (object.channel_genesis !== undefined && object.channel_genesis !== null) {
            message.channelGenesis = genesis_3.GenesisState.fromAmino(object.channel_genesis);
        }
        if (object.client_v2_genesis !== undefined && object.client_v2_genesis !== null) {
            message.clientV2Genesis = genesis_4.GenesisState.fromAmino(object.client_v2_genesis);
        }
        if (object.channel_v2_genesis !== undefined && object.channel_v2_genesis !== null) {
            message.channelV2Genesis = genesis_5.GenesisState.fromAmino(object.channel_v2_genesis);
        }
        return message;
    },
    toAmino(message) {
        const obj = {};
        obj.client_genesis = message.clientGenesis ? genesis_1.GenesisState.toAmino(message.clientGenesis) : undefined;
        obj.connection_genesis = message.connectionGenesis ? genesis_2.GenesisState.toAmino(message.connectionGenesis) : undefined;
        obj.channel_genesis = message.channelGenesis ? genesis_3.GenesisState.toAmino(message.channelGenesis) : undefined;
        obj.client_v2_genesis = message.clientV2Genesis ? genesis_4.GenesisState.toAmino(message.clientV2Genesis) : undefined;
        obj.channel_v2_genesis = message.channelV2Genesis ? genesis_5.GenesisState.toAmino(message.channelV2Genesis) : undefined;
        return obj;
    },
    fromAminoMsg(object) {
        return exports.GenesisState.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "cosmos-sdk/GenesisState",
            value: exports.GenesisState.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return exports.GenesisState.decode(message.value);
    },
    toProto(message) {
        return exports.GenesisState.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/ibc.core.types.v1.GenesisState",
            value: exports.GenesisState.encode(message).finish()
        };
    },
    registerTypeUrl() {
        if (!registry_1.GlobalDecoderRegistry.registerExistingTypeUrl(exports.GenesisState.typeUrl)) {
            return;
        }
        genesis_1.GenesisState.registerTypeUrl();
        genesis_2.GenesisState.registerTypeUrl();
        genesis_3.GenesisState.registerTypeUrl();
        genesis_4.GenesisState.registerTypeUrl();
        genesis_5.GenesisState.registerTypeUrl();
    }
};
