import { GenesisState as GenesisState1 } from "../../client/v1/genesis";
import { GenesisState as GenesisState2 } from "../../connection/v1/genesis";
import { GenesisState as GenesisState3 } from "../../channel/v1/genesis";
import { GenesisState as GenesisState4 } from "../../client/v2/genesis";
import { GenesisState as GenesisState5 } from "../../channel/v2/genesis";
import { BinaryReader, BinaryWriter } from "../../../../binary";
import { GlobalDecoderRegistry } from "../../../../registry";
function createBaseGenesisState() {
    return {
        clientGenesis: GenesisState1.fromPartial({}),
        connectionGenesis: GenesisState2.fromPartial({}),
        channelGenesis: GenesisState3.fromPartial({}),
        clientV2Genesis: GenesisState4.fromPartial({}),
        channelV2Genesis: GenesisState5.fromPartial({})
    };
}
/**
 * GenesisState defines the ibc module's genesis state.
 * @name GenesisState
 * @package ibc.core.types.v1
 * @see proto type: ibc.core.types.v1.GenesisState
 */
export const GenesisState = {
    typeUrl: "/ibc.core.types.v1.GenesisState",
    aminoType: "cosmos-sdk/GenesisState",
    is(o) {
        return o && (o.$typeUrl === GenesisState.typeUrl || GenesisState1.is(o.clientGenesis) && GenesisState2.is(o.connectionGenesis) && GenesisState3.is(o.channelGenesis) && GenesisState4.is(o.clientV2Genesis) && GenesisState5.is(o.channelV2Genesis));
    },
    isAmino(o) {
        return o && (o.$typeUrl === GenesisState.typeUrl || GenesisState1.isAmino(o.client_genesis) && GenesisState2.isAmino(o.connection_genesis) && GenesisState3.isAmino(o.channel_genesis) && GenesisState4.isAmino(o.client_v2_genesis) && GenesisState5.isAmino(o.channel_v2_genesis));
    },
    encode(message, writer = BinaryWriter.create()) {
        if (message.clientGenesis !== undefined) {
            GenesisState1.encode(message.clientGenesis, writer.uint32(10).fork()).ldelim();
        }
        if (message.connectionGenesis !== undefined) {
            GenesisState2.encode(message.connectionGenesis, writer.uint32(18).fork()).ldelim();
        }
        if (message.channelGenesis !== undefined) {
            GenesisState3.encode(message.channelGenesis, writer.uint32(26).fork()).ldelim();
        }
        if (message.clientV2Genesis !== undefined) {
            GenesisState4.encode(message.clientV2Genesis, writer.uint32(34).fork()).ldelim();
        }
        if (message.channelV2Genesis !== undefined) {
            GenesisState5.encode(message.channelV2Genesis, writer.uint32(42).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 = createBaseGenesisState();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.clientGenesis = GenesisState1.decode(reader, reader.uint32());
                    break;
                case 2:
                    message.connectionGenesis = GenesisState2.decode(reader, reader.uint32());
                    break;
                case 3:
                    message.channelGenesis = GenesisState3.decode(reader, reader.uint32());
                    break;
                case 4:
                    message.clientV2Genesis = GenesisState4.decode(reader, reader.uint32());
                    break;
                case 5:
                    message.channelV2Genesis = GenesisState5.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 ? GenesisState1.fromPartial(object.clientGenesis) : undefined;
        message.connectionGenesis = object.connectionGenesis !== undefined && object.connectionGenesis !== null ? GenesisState2.fromPartial(object.connectionGenesis) : undefined;
        message.channelGenesis = object.channelGenesis !== undefined && object.channelGenesis !== null ? GenesisState3.fromPartial(object.channelGenesis) : undefined;
        message.clientV2Genesis = object.clientV2Genesis !== undefined && object.clientV2Genesis !== null ? GenesisState4.fromPartial(object.clientV2Genesis) : undefined;
        message.channelV2Genesis = object.channelV2Genesis !== undefined && object.channelV2Genesis !== null ? GenesisState5.fromPartial(object.channelV2Genesis) : undefined;
        return message;
    },
    fromAmino(object) {
        const message = createBaseGenesisState();
        if (object.client_genesis !== undefined && object.client_genesis !== null) {
            message.clientGenesis = GenesisState1.fromAmino(object.client_genesis);
        }
        if (object.connection_genesis !== undefined && object.connection_genesis !== null) {
            message.connectionGenesis = GenesisState2.fromAmino(object.connection_genesis);
        }
        if (object.channel_genesis !== undefined && object.channel_genesis !== null) {
            message.channelGenesis = GenesisState3.fromAmino(object.channel_genesis);
        }
        if (object.client_v2_genesis !== undefined && object.client_v2_genesis !== null) {
            message.clientV2Genesis = GenesisState4.fromAmino(object.client_v2_genesis);
        }
        if (object.channel_v2_genesis !== undefined && object.channel_v2_genesis !== null) {
            message.channelV2Genesis = GenesisState5.fromAmino(object.channel_v2_genesis);
        }
        return message;
    },
    toAmino(message) {
        const obj = {};
        obj.client_genesis = message.clientGenesis ? GenesisState1.toAmino(message.clientGenesis) : undefined;
        obj.connection_genesis = message.connectionGenesis ? GenesisState2.toAmino(message.connectionGenesis) : undefined;
        obj.channel_genesis = message.channelGenesis ? GenesisState3.toAmino(message.channelGenesis) : undefined;
        obj.client_v2_genesis = message.clientV2Genesis ? GenesisState4.toAmino(message.clientV2Genesis) : undefined;
        obj.channel_v2_genesis = message.channelV2Genesis ? GenesisState5.toAmino(message.channelV2Genesis) : undefined;
        return obj;
    },
    fromAminoMsg(object) {
        return GenesisState.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "cosmos-sdk/GenesisState",
            value: GenesisState.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return GenesisState.decode(message.value);
    },
    toProto(message) {
        return GenesisState.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/ibc.core.types.v1.GenesisState",
            value: GenesisState.encode(message).finish()
        };
    },
    registerTypeUrl() {
        if (!GlobalDecoderRegistry.registerExistingTypeUrl(GenesisState.typeUrl)) {
            return;
        }
        GenesisState1.registerTypeUrl();
        GenesisState2.registerTypeUrl();
        GenesisState3.registerTypeUrl();
        GenesisState4.registerTypeUrl();
        GenesisState5.registerTypeUrl();
    }
};
